Compare commits
19 Commits
86e9b0802f
...
deps-updat
| Author | SHA1 | Date | |
|---|---|---|---|
|
13f1df03ef
|
|||
|
a15e172c2a
|
|||
|
ae2c702c2b
|
|||
|
5c58f4c16d
|
|||
|
ed6f463897
|
|||
|
d5647758d0
|
|||
|
1a7226eef1
|
|||
|
4bfcf72240
|
|||
|
6ba8a59c5e
|
|||
|
bb2d896e4b
|
|||
|
3183908012
|
|||
|
ed99d38534
|
|||
|
36fa1285b4
|
|||
|
8ef0b253b2
|
|||
|
61e08812e3
|
|||
|
a0ac978541
|
|||
|
f9742ed5a5
|
|||
|
350deb3a45
|
|||
|
8a02674af5
|
@@ -17,7 +17,7 @@ jobs:
|
|||||||
# Not recursive, deliberately. The top-level build needs
|
# Not recursive, deliberately. The top-level build needs
|
||||||
# deps/libakerror and deps/libakstdlib, via add_subdirectory, and
|
# deps/libakerror and deps/libakstdlib, via add_subdirectory, and
|
||||||
# nothing else: the golden corpus and the Commodore font now live in
|
# nothing else: the golden corpus and the Commodore font now live in
|
||||||
# this repository (tests/reference/ and assets/fonts/), so
|
# this repository (tests/language/ and assets/fonts/), so
|
||||||
# deps/basicinterpret is no longer a build dependency at all.
|
# deps/basicinterpret is no longer a build dependency at all.
|
||||||
# It does *not* need deps/libakgl, which is guarded behind
|
# It does *not* need deps/libakgl, which is guarded behind
|
||||||
# AKBASIC_WITH_AKGL and defaults OFF -- and recursing into it would
|
# AKBASIC_WITH_AKGL and defaults OFF -- and recursing into it would
|
||||||
@@ -62,11 +62,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cmake -S . -B build
|
cmake -S . -B build
|
||||||
cmake --build build --parallel 2
|
cmake --build build --parallel 2
|
||||||
# The suite is 78 cases: 41 golden files byte-compared against the Go
|
# The suite is 112 cases: 65 language files with sibling expectations,
|
||||||
# reference's own corpus (checked in at tests/reference/, see its README),
|
# 43 unit tests, 3 embedding examples, and docs_examples.
|
||||||
# 9 local golden cases for verbs the reference never implemented, 25 unit
|
# Some unit tests assert the *correct* contract for known defects (TODO.md
|
||||||
# tests, 2 embedding examples, and 1 known-failing test that asserts the
|
|
||||||
# *correct* contract for defects carried over from the reference (TODO.md
|
|
||||||
# section 6). A green run therefore does not mean defect-free -- see
|
# section 6). A green run therefore does not mean defect-free -- see
|
||||||
# AKBASIC_KNOWN_FAILING_TESTS.
|
# AKBASIC_KNOWN_FAILING_TESTS.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ repeating where you will see them:
|
|||||||
`include/akgl/SDL_GameControllerDB.h`. Change the template or the generator script.
|
`include/akgl/SDL_GameControllerDB.h`. Change the template or the generator script.
|
||||||
- **Do not reformat code you are not otherwise changing.** Several files mix tabs and spaces
|
- **Do not reformat code you are not otherwise changing.** Several files mix tabs and spaces
|
||||||
and there is no repo-wide formatter; style conversions get their own commit.
|
and there is no repo-wide formatter; style conversions get their own commit.
|
||||||
- **Do not edit `tests/reference/`.** Those expectations came from the Go implementation and
|
- **Keep `tests/language/` editable.** Its `.bas` programs and sibling `.txt` expectations
|
||||||
are never edited to suit this interpreter. A deliberate divergence goes in
|
are changed together when behavior changes. Record deliberate language decisions in
|
||||||
`tests/reference/README.md`'s divergence table and `docs/13-differences.md`.
|
`TODO.md` or `docs/13-differences.md`.
|
||||||
- **Open an issue for outstanding work; do not add it to `TODO.md`.**
|
- **Open an issue for outstanding work; do not add it to `TODO.md`.**
|
||||||
<https://source.starfort.tech/andrew/akbasic/issues>, or `tea issues create --repo
|
<https://source.starfort.tech/andrew/akbasic/issues>, or `tea issues create --repo
|
||||||
andrew/akbasic`. Name the file and line, the functional consequence, and what closing it would
|
andrew/akbasic`. Name the file and line, the functional consequence, and what closing it would
|
||||||
|
|||||||
@@ -51,12 +51,14 @@ option(AKBASIC_SANITIZE "Build with ASan + UBSan" OFF
|
|||||||
# through: the dependencies set target and directory properties that their own
|
# through: the dependencies set target and directory properties that their own
|
||||||
# builds depend on.
|
# builds depend on.
|
||||||
#
|
#
|
||||||
# libakerror additionally namespaces its `mutation` target when embedded but not
|
# All three dependencies now namespace both their `coverage` and their
|
||||||
# its `coverage` target (deps/libakerror/CMakeLists.txt:194 vs :172), so a
|
# `mutation` targets when embedded, so there is no custom-target collision left
|
||||||
# coverage build collides on the `coverage` target and fails to configure at all.
|
# to work around. libakerror was the last holdout -- it namespaced `mutation`
|
||||||
# Rename the dependency's on the way past. Remove this once libakerror applies
|
# but not `coverage`, and a coverage build collided on the bare name and failed
|
||||||
# the same CMAKE_SOURCE_DIR test to `coverage` that it already applies to
|
# to configure at all. 2.0.2 applies the same CMAKE_SOURCE_DIR test to both
|
||||||
# `mutation` -- filed as libakerror issue #15.
|
# (deps/libakerror/CMakeLists.txt:429-434), closing libakerror issue #15, and
|
||||||
|
# the add_custom_target() shadow that renamed it on the way past is gone with
|
||||||
|
# this comment.
|
||||||
#
|
#
|
||||||
# **Only one project in a tree may shadow add_test(), and this is that project.**
|
# **Only one project in a tree may shadow add_test(), and this is that project.**
|
||||||
# CMake exposes an overridden command as `_name` and chains exactly one level: a
|
# CMake exposes an overridden command as `_name` and chains exactly one level: a
|
||||||
@@ -86,14 +88,6 @@ function(set_property _scope)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(add_custom_target _name)
|
|
||||||
if(AKBASIC_SUPPRESS_ADD_TEST AND _name STREQUAL "coverage")
|
|
||||||
_add_custom_target(akerror_coverage ${ARGN})
|
|
||||||
else()
|
|
||||||
_add_custom_target(${ARGV})
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
add_subdirectory(deps/libakerror EXCLUDE_FROM_ALL)
|
add_subdirectory(deps/libakerror EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(deps/libakstdlib EXCLUDE_FROM_ALL)
|
add_subdirectory(deps/libakstdlib EXCLUDE_FROM_ALL)
|
||||||
if(AKBASIC_WITH_AKGL)
|
if(AKBASIC_WITH_AKGL)
|
||||||
@@ -511,7 +505,7 @@ if(AKBASIC_WITH_AKGL)
|
|||||||
# against.
|
# against.
|
||||||
#
|
#
|
||||||
# **A byte comparison of a rendered PNG is a deliberate bet**, the same bet
|
# **A byte comparison of a rendered PNG is a deliberate bet**, the same bet
|
||||||
# tests/reference/ already makes about golden output: that the dummy video
|
# the language corpus makes about golden output: that the dummy video
|
||||||
# driver and the software renderer are reproducible. They are, run to run and
|
# driver and the software renderer are reproducible. They are, run to run and
|
||||||
# build to build. What is untested is an SDL upgrade that shifts one pixel of
|
# build to build. What is untested is an SDL upgrade that shifts one pixel of
|
||||||
# a diagonal, and the answer to that is to regenerate the figures in the same
|
# a diagonal, and the answer to that is to regenerate the figures in the same
|
||||||
@@ -594,63 +588,20 @@ if(AKBASIC_WILL_FAIL_TESTS OR AKBASIC_KNOWN_FAILING_TESTS)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# The reference's own corpus, byte-compared against the sibling .txt. One CTest
|
# The editable language corpus. One CTest case per .bas so a failure names the
|
||||||
# case per .bas so a failure names the file.
|
# file. Each program is paired with a sibling .txt expectation; see
|
||||||
|
# tests/language/README.md for the editing rule.
|
||||||
#
|
#
|
||||||
# It used to be driven in place out of deps/basicinterpret, on the reasoning that
|
# The corpus includes programs carried over from the deprecated Go implementation
|
||||||
# copying a submodule's corpus guarantees drift. That reasoning was sound and it
|
# and cases written for this interpreter. Their provenance is useful when
|
||||||
# has been overruled deliberately: the Go dependency is being deprecated, and a
|
# investigating a regression, but it does not make any case immutable.
|
||||||
# build that cannot run its acceptance suite without cloning the implementation
|
|
||||||
# it replaced is not finished. The copy is byte-identical to
|
|
||||||
# basicinterpreter@d76162c and tests/reference/README.md records
|
|
||||||
# where it came from and what the drift now costs.
|
|
||||||
file(GLOB_RECURSE AKBASIC_GOLDEN_CASES
|
|
||||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/tests/reference"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/tests/reference/*.bas"
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach(_case IN LISTS AKBASIC_GOLDEN_CASES)
|
|
||||||
string(REGEX REPLACE "^tests/" "" _name "${_case}")
|
|
||||||
string(REGEX REPLACE "\\.bas$" "" _name "${_name}")
|
|
||||||
string(REPLACE "/" "_" _name "${_name}")
|
|
||||||
_add_test(
|
|
||||||
NAME golden_${_name}
|
|
||||||
COMMAND ${CMAKE_COMMAND}
|
|
||||||
-DBASIC=$<TARGET_FILE:basic>
|
|
||||||
-DCASE=${CMAKE_CURRENT_SOURCE_DIR}/tests/reference/${_case}
|
|
||||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/golden.cmake
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
if(AKBASIC_GOLDEN_CASES)
|
|
||||||
set(AKBASIC_GOLDEN_NAMES)
|
|
||||||
foreach(_case IN LISTS AKBASIC_GOLDEN_CASES)
|
|
||||||
string(REGEX REPLACE "^tests/" "" _name "${_case}")
|
|
||||||
string(REGEX REPLACE "\\.bas$" "" _name "${_name}")
|
|
||||||
string(REPLACE "/" "_" _name "${_name}")
|
|
||||||
list(APPEND AKBASIC_GOLDEN_NAMES golden_${_name})
|
|
||||||
endforeach()
|
|
||||||
_set_tests_properties(${AKBASIC_GOLDEN_NAMES} PROPERTIES TIMEOUT 30)
|
|
||||||
# An AKGL build of `basic` opens a window, and forty-one of them is not what
|
|
||||||
# anybody running the suite wanted. The dummy driver produces the same stdout,
|
|
||||||
# which is the only thing a golden case compares.
|
|
||||||
if(AKBASIC_WITH_AKGL)
|
|
||||||
_set_tests_properties(${AKBASIC_GOLDEN_NAMES} PROPERTIES
|
|
||||||
ENVIRONMENT "SDL_VIDEODRIVER=dummy;SDL_AUDIODRIVER=dummy;SDL_RENDER_DRIVER=software")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# The local golden corpus, for verbs the reference never implemented.
|
|
||||||
#
|
#
|
||||||
# Still separate now that the reference's corpus lives in this repository too,
|
# Programs carried over from the deprecated Go implementation and cases written
|
||||||
# and the reason changed rather than went away: tests/reference/ is a *record* of
|
# for this interpreter use the same editable `.bas`/`.txt` contract. Registered
|
||||||
# what the Go implementation did and nothing in it should ever be edited to suit
|
# under local_ so every failure identifies the program that produced it.
|
||||||
# this one, while tests/language/ is ours to change. Registered under local_ so a
|
|
||||||
# failure says at a glance which of the two it came from -- and so a diff that
|
|
||||||
# touches tests/reference/ stands out as the thing it is.
|
|
||||||
#
|
#
|
||||||
# Note what this can and cannot cover. The graphics and sound verbs draw and play
|
# Note what this can and cannot cover. The graphics and sound verbs draw and play
|
||||||
# rather than print, so what a golden file sees of them is their *refusals* and
|
# rather than print, so what a golden file sees of them is their refusals and
|
||||||
# whatever a program can PRINT about the state they changed. The behaviour that
|
# whatever a program can PRINT about the state they changed. The behaviour that
|
||||||
# reaches a device is asserted against tests/mockdevice.h instead.
|
# reaches a device is asserted against tests/mockdevice.h instead.
|
||||||
file(GLOB_RECURSE AKBASIC_LOCAL_CASES
|
file(GLOB_RECURSE AKBASIC_LOCAL_CASES
|
||||||
|
|||||||
132
MAINTENANCE.md
132
MAINTENANCE.md
@@ -68,12 +68,19 @@ the `akgl_*` or `aksl_*` entry point should look like, and what tests would cove
|
|||||||
decision, which is true of *changing* it and not of *reporting* it. Follow the prose-paragraph style of the entries already
|
decision, which is true of *changing* it and not of *reporting* it. Follow the prose-paragraph style of the entries already
|
||||||
there. Growing the dependency to serve the interpreter is a wanted outcome, not a detour.
|
there. Growing the dependency to serve the interpreter is a wanted outcome, not a detour.
|
||||||
|
|
||||||
It works. Four gaps were filed this way — text measurement, immediate-mode drawing, audio,
|
It works. **Five** gaps were filed this way and all five landed upstream: text measurement,
|
||||||
and a non-blocking keystroke read — and all four landed upstream as `akgl_text_measure`, the
|
immediate-mode drawing, audio and a non-blocking keystroke read became `akgl_text_measure`,
|
||||||
`akgl_draw_*` family, `akgl_audio_*` and `akgl_controller_poll_key`. `FILTER` is the one verb
|
the `akgl_draw_*` family, `akgl_audio_*` and `akgl_controller_poll_key`; and the
|
||||||
still blocked on a gap, and `DIRECTORY` is refused pending an `opendir`/`readdir` wrapper in
|
directory-reading wrapper `DIRECTORY` was waiting on became `aksl_opendir`, `aksl_readdir`,
|
||||||
`libakstdlib`. Both refuse at execution and say so, rather than being silently ignored: a
|
`aksl_closedir` and `aksl_rewinddir` — `libakstdlib` issue #10, in the revision this tree
|
||||||
program that asks for a low-pass filter and gets an unfiltered square wave has been lied to.
|
pins.
|
||||||
|
|
||||||
|
That leaves the two refusals in different positions, and the difference is worth keeping
|
||||||
|
straight. **`FILTER` is the one verb still blocked on a gap** — there is no filter stage in
|
||||||
|
`akgl_audio_*` to configure. **`DIRECTORY` is no longer blocked on anything**; it is simply
|
||||||
|
unwritten, and its refusal says so rather than naming a wrapper that now exists. Both refuse
|
||||||
|
at execution and say so, rather than being silently ignored: a program that asks for a
|
||||||
|
low-pass filter and gets an unfiltered square wave has been lied to.
|
||||||
|
|
||||||
### The Go reference
|
### The Go reference
|
||||||
|
|
||||||
@@ -88,7 +95,7 @@ source stays readable as documentation of what the original did. Neither is bind
|
|||||||
|
|
||||||
**It is not a build or test dependency.** Both configurations have been configured, built and
|
**It is not a build or test dependency.** Both configurations have been configured, built and
|
||||||
run from scratch with it moved out of the tree. Its acceptance corpus is checked in at
|
run from scratch with it moved out of the tree. Its acceptance corpus is checked in at
|
||||||
`tests/reference/` and its Commodore font at `assets/fonts/`.
|
`tests/language/` and its Commodore font at `assets/fonts/`.
|
||||||
|
|
||||||
```sh norun
|
```sh norun
|
||||||
cd deps/basicinterpret
|
cd deps/basicinterpret
|
||||||
@@ -156,10 +163,10 @@ guards every dependency with `if(NOT TARGET ...)`, so a top-level build must def
|
|||||||
`akerror::akerror` and `akstdlib::akstdlib` from `deps/libakerror` and `deps/libakstdlib`
|
`akerror::akerror` and `akstdlib::akstdlib` from `deps/libakerror` and `deps/libakstdlib`
|
||||||
**before** `add_subdirectory(deps/libakgl)`, or the targets are declared twice.
|
**before** `add_subdirectory(deps/libakgl)`, or the targets are declared twice.
|
||||||
|
|
||||||
That order is load-bearing for a second reason: `deps/libakerror` is at **2.0.1**, whose 2.0.0
|
That order is load-bearing for a second reason: `deps/libakerror` is at **2.0.2**, whose 2.0.0
|
||||||
was a source and ABI break carrying an soname (`libakerror.so.2`). `libakstdlib` and `libakgl`
|
was a source and ABI break carrying an soname (`libakerror.so.2`). `libakstdlib` and `libakgl`
|
||||||
must be compiled against that header, not a 1.x one, and an installed `libakerror.so.1` must
|
must be compiled against that header, not a 1.x one, and an installed `libakerror.so.1` must
|
||||||
not be picked up. The break is quiet if you get it wrong: `__akerr_last_ignored` became
|
not be picked up. The break is quiet if you get it wrong: the context behind `IGNORE` became
|
||||||
thread-local and `akerr_next_error()` now returns a context that already holds a reference, so
|
thread-local and `akerr_next_error()` now returns a context that already holds a reference, so
|
||||||
a mixed build leaks pool slots or frees one twice rather than failing to link.
|
a mixed build leaks pool slots or frees one twice rather than failing to link.
|
||||||
|
|
||||||
@@ -167,10 +174,47 @@ a mixed build leaks pool slots or frees one twice rather than failing to link.
|
|||||||
|
|
||||||
| Submodule | Version | soname | ABI rule | Version API |
|
| Submodule | Version | soname | ABI rule | Version API |
|
||||||
|---|---|---|---|---|
|
|---|---|---|---|---|
|
||||||
| `deps/libakerror` | 2.0.1 | `libakerror.so.2` | major only | **none** — no version macro; `include/akbasic/error.h` feature-tests `AKERR_THREAD_SAFE` and `AKERR_EXIT_STATUS_UNREPRESENTABLE` instead |
|
| `deps/libakerror` | 2.0.2 | `libakerror.so.2` | major only | **none** — no version macro; `include/akbasic/error.h` feature-tests `AKERR_THREAD_SAFE` and `AKERR_EXIT_STATUS_UNREPRESENTABLE` instead |
|
||||||
| `deps/libakstdlib` | 0.2.0 | `libakstdlib.so.0.2` | **`MAJOR.MINOR` while major is 0** | `AKSL_VERSION_*`, `aksl_version()`, `AKSL_VERSION_CHECK()` |
|
| `deps/libakstdlib` | 0.2.0 | `libakstdlib.so.0.2` | **`MAJOR.MINOR` while major is 0** | `AKSL_VERSION_*`, `aksl_version()`, `AKSL_VERSION_CHECK()` |
|
||||||
| `deps/libakgl` | 0.9.0 | `libakgl.so.0.9` | **`MAJOR.MINOR` while major is 0** | `AKGL_VERSION*`, `akgl_version()`, `AKGL_VERSION_AT_LEAST()` |
|
| `deps/libakgl` | 0.9.0 | `libakgl.so.0.9` | **`MAJOR.MINOR` while major is 0** | `AKGL_VERSION*`, `akgl_version()`, `AKGL_VERSION_AT_LEAST()` |
|
||||||
|
|
||||||
|
**The `libakerror` row is what `project(akerror VERSION ...)` declares, and it disagrees with
|
||||||
|
that library's own release notes**, which carry a "Release 2.0.3" section describing CI-only
|
||||||
|
changes. The version the build stamps into the soname and into
|
||||||
|
`akerrorConfigVersion.cmake` is 2.0.2; nothing consumers can observe says 2.0.3. Read the
|
||||||
|
table as the ABI and the notes as the changelog, and do not "correct" this row to 2.0.3
|
||||||
|
without the upstream `project()` bump to go with it. Reported as `libakerror` issue #38.
|
||||||
|
|
||||||
|
#### What 2.0.2's `IGNORE` change costs, measured
|
||||||
|
|
||||||
|
`IGNORE` now takes a *copy* of the context so the pool slot can be released, which fixes a
|
||||||
|
real leak. The copy lives in the public header as a file-scope `static`:
|
||||||
|
|
||||||
|
```c norun
|
||||||
|
static AKERR_THREAD_LOCAL akerr_ErrorContext akerr_last_ignored;
|
||||||
|
```
|
||||||
|
|
||||||
|
`static` means one per translation unit, and `AKERR_THREAD_LOCAL` means each one is
|
||||||
|
thread-local. `sizeof(akerr_ErrorContext)` is **37,296 bytes**, so:
|
||||||
|
|
||||||
|
| Build | TLS segment of `build/basic` |
|
||||||
|
|---|---|
|
||||||
|
| libakerror 2.0.1 | none at all |
|
||||||
|
| libakerror 2.0.2 | 1,417,248 bytes — **1.35 MiB**, per thread |
|
||||||
|
|
||||||
|
38 copies × 37,296 accounts for the segment exactly; `readelf -sW build/basic` shows all 38.
|
||||||
|
It scales with translation-unit count, not with anything about the program, and every thread
|
||||||
|
a host game spawns pays it again — which is worth knowing in a tree that spent a release
|
||||||
|
taking `akbasic_Runtime` from 10.75 MiB to 2.40 MiB.
|
||||||
|
|
||||||
|
It also emits **84 `-Wunused-variable` warnings**, one per TU that includes `akerror.h`
|
||||||
|
without using `IGNORE`. Nothing here builds with `-Werror`, so it is noise rather than a
|
||||||
|
failure — but a consumer that does cannot include the header.
|
||||||
|
|
||||||
|
**Both are `libakerror` issue #37 and neither is worked around here**, per the rule above: a
|
||||||
|
one-line `extern` in the header and a definition in `src/error.c` fixes it upstream, and
|
||||||
|
patching our copy would fork the submodule. Delete this subsection when it lands.
|
||||||
|
|
||||||
For both 0.x libraries the soname carries `MAJOR.MINOR` deliberately: 0.1 and 0.2 are
|
For both 0.x libraries the soname carries `MAJOR.MINOR` deliberately: 0.1 and 0.2 are
|
||||||
*different* ABIs, and both become major-only at 1.0. Do not read `0.1 → 0.2` as a compatible
|
*different* ABIs, and both become major-only at 1.0. Do not read `0.1 → 0.2` as a compatible
|
||||||
bump — both libraries have actually made that jump, so anything built against the 0.1 headers
|
bump — both libraries have actually made that jump, so anything built against the 0.1 headers
|
||||||
@@ -196,16 +240,32 @@ precedes the build tree on the include path and a stray copy there would shadow
|
|||||||
one and pin every consumer. It publishes `AKGL_VERSION_AT_LEAST(major, minor, patch)` — the
|
one and pin every consumer. It publishes `AKGL_VERSION_AT_LEAST(major, minor, patch)` — the
|
||||||
compile-time test `libakstdlib` could not write against `libakerror` — and `akgl_version()`.
|
compile-time test `libakstdlib` could not write against `libakerror` — and `akgl_version()`.
|
||||||
|
|
||||||
**Version-pinning in `find_package` is asymmetric, and that is deliberate.**
|
**Version-pinning in `find_package` used to be asymmetric. It no longer is.**
|
||||||
`find_package(akstdlib 0.1)` and `find_package(akgl 0.1)` both work; each ships a
|
`find_package(akstdlib 0.1)` and `find_package(akgl 0.1)` both work; each ships a
|
||||||
`ConfigVersion.cmake` at `SameMinorVersion`, mirroring its soname. `find_package(akerror 1.0)`
|
`ConfigVersion.cmake` at `SameMinorVersion`, mirroring its soname. `libakerror` shipped
|
||||||
**fails against a correct install**, because `libakerror` ships `akerrorConfig.cmake` and
|
`akerrorConfig.cmake` and `akerrorTargets.cmake` but no `akerrorConfigVersion.cmake`, so any
|
||||||
`akerrorTargets.cmake` but no `akerrorConfigVersion.cmake`. Ask for `akerror` unversioned. Its
|
versioned request failed against a correct install and the advice here was to ask for
|
||||||
floor is enforced instead by an `#error` feature-testing `AKERR_FIRST_CONSUMER_STATUS`, which
|
`akerror` unversioned. That was `libakerror` issue #16 — closed — and `libakstdlib` issue #5,
|
||||||
`akstdlib.h`, `akgl/error.h` and our own `include/akbasic/error.h` all carry — include any of
|
which tracks the same fix from the other side and is still open only because nobody has shut
|
||||||
them and you inherit the guard. The missing version file is filed in
|
it. It has landed: `libakerror` now writes `akerrorConfigVersion.cmake` at
|
||||||
`libakstdlib` issue #5 and `libakerror` issue #16; when it lands, add the `1.0` floor to the `find_dependency`
|
**`SameMajorVersion`**, matching the soname's major-only rule, rather than the
|
||||||
calls.
|
`SameMinorVersion` the other two use to match theirs.
|
||||||
|
|
||||||
|
Two things follow, and the second is the one that bites:
|
||||||
|
|
||||||
|
- **A versioned request now works** — but the floor to ask for is **`2.0`**, not the `1.0`
|
||||||
|
this file used to say. `find_package(akerror 1.0)` fails *harder* than before: it is a
|
||||||
|
request for major 1 against a major-2 install, which `SameMajorVersion` correctly rejects.
|
||||||
|
- **There is nothing in this repository to change.** `akbasic` reaches all three dependencies
|
||||||
|
by `add_subdirectory`, not `find_package`, and ships no CMake package config of its own —
|
||||||
|
so it has no `find_dependency` calls to add a floor to. The instruction that used to live
|
||||||
|
here was written for a consumer this project never became. It matters to anyone *installing*
|
||||||
|
these libraries and linking `akbasic` against the installed copies, which is why it is
|
||||||
|
recorded rather than deleted.
|
||||||
|
|
||||||
|
The compile-time floor is unchanged and still the real guard: an `#error` feature-testing
|
||||||
|
`AKERR_FIRST_CONSUMER_STATUS`, which `akstdlib.h`, `akgl/error.h` and our own
|
||||||
|
`include/akbasic/error.h` all carry — include any of them and you inherit it.
|
||||||
|
|
||||||
### Embedding all three dependencies collides four ways
|
### Embedding all three dependencies collides four ways
|
||||||
|
|
||||||
@@ -250,14 +310,19 @@ CTest names. `libakstdlib` still uses bare `test_<name>` targets. **Name every t
|
|||||||
this repo `akbasic_test_<name>`** — it costs nothing and it is the collision that actually
|
this repo `akbasic_test_<name>`** — it costs nothing and it is the collision that actually
|
||||||
stopped a build.
|
stopped a build.
|
||||||
|
|
||||||
**3. Duplicate custom targets.** `libakerror` namespaces its `mutation` target when embedded
|
**3. Duplicate custom targets — fixed upstream, and the workaround is gone.** `libakerror`
|
||||||
but **not** its `coverage` target, so any coverage-enabled top-level build fails with *"another
|
used to namespace its `mutation` target when embedded but **not** its `coverage` target, so
|
||||||
target with the same name already exists"*. We shadow `add_custom_target` and rename that one
|
any coverage-enabled top-level build failed with *"another target with the same name already
|
||||||
to `akerror_coverage` on the way past. `libakstdlib` (both targets) and `libakgl` (its
|
exists"*. This project shadowed `add_custom_target` and renamed that one to
|
||||||
`mutation` target) namespace themselves correctly. **The real fix is upstream in
|
`akerror_coverage` on the way past, and recorded the real fix as `libakerror` issue #15: the
|
||||||
`libakerror`** — the same `CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR` test it already
|
same `CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR` test it already applied to
|
||||||
applies to `mutation` — and it is filed as `libakerror` issue #15. Delete the
|
`mutation`.
|
||||||
workaround when it lands.
|
|
||||||
|
That landed in 2.0.2. `libakerror` now picks `akerror_coverage` itself when embedded, so the
|
||||||
|
shadow was dead code that could only ever fire on a name the dependency had stopped using —
|
||||||
|
and it is deleted. All three dependencies namespace both targets correctly now, so **there is
|
||||||
|
no custom-target collision left**; only collisions 1, 2 and 4 below are live. The heading says
|
||||||
|
four because four is what a reader coming from the issue tracker will be looking for.
|
||||||
|
|
||||||
**4. Stale build trees poison the coverage report.** See below; it is the reason for
|
**4. Stale build trees poison the coverage report.** See below; it is the reason for
|
||||||
`cmake -S . -B build`.
|
`cmake -S . -B build`.
|
||||||
@@ -351,15 +416,10 @@ name. That is not cosmetic: `add_executable` creates a dependency's targets even
|
|||||||
|
|
||||||
### The golden corpora
|
### The golden corpora
|
||||||
|
|
||||||
`tests/reference/` is the Go implementation's own acceptance suite, byte-compared.
|
`tests/language/` is the editable language corpus. It includes cases carried over from the
|
||||||
**Nothing in it is ever edited to suit this interpreter.** If a case fails, either this
|
deprecated Go implementation as well as cases written for this interpreter. Every `.bas` file
|
||||||
interpreter is wrong or the divergence is deliberate — and a deliberate one goes in
|
has a sibling `.txt` expectation, and a new language feature needs that pair as well as unit
|
||||||
`tests/reference/README.md`'s divergence table and `docs/13-differences.md`, not into the
|
tests. Change both deliberately in the same commit; provenance does not make a case immutable.
|
||||||
expectation file. `tests/reference/README.md`
|
|
||||||
says the same thing at more length.
|
|
||||||
|
|
||||||
`tests/language/` is ours and may be changed freely. A new language feature needs a
|
|
||||||
`.bas`/`.txt` pair there as well as unit tests.
|
|
||||||
|
|
||||||
### Mutation-check a fix before you believe it
|
### Mutation-check a fix before you believe it
|
||||||
|
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -10,7 +10,7 @@ implementation that started from the Java Lox instructions in
|
|||||||
[craftinginterpreters.com](https://craftinginterpreters.com) and then struck off on its own. That
|
[craftinginterpreters.com](https://craftinginterpreters.com) and then struck off on its own. That
|
||||||
project is deprecated. It is vendored here as the behavioural spec to read when a question about
|
project is deprecated. It is vendored here as the behavioural spec to read when a question about
|
||||||
semantics comes up, and its acceptance corpus is checked in at
|
semantics comes up, and its acceptance corpus is checked in at
|
||||||
[`tests/reference/`](tests/reference/README.md) and runs on every build — so nothing about
|
[`tests/language/`](tests/language/README.md) and runs on every build — so nothing about
|
||||||
building or testing this project needs it.
|
building or testing this project needs it.
|
||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
@@ -24,7 +24,7 @@ ctest --test-dir build --output-on-failure
|
|||||||
|
|
||||||
```sh norun
|
```sh norun
|
||||||
./build/basic # the REPL
|
./build/basic # the REPL
|
||||||
./build/basic tests/reference/language/functions.bas # run a program
|
./build/basic tests/language/functions.bas # run a program
|
||||||
```
|
```
|
||||||
|
|
||||||
```basic
|
```basic
|
||||||
@@ -129,7 +129,7 @@ version are catalogued in [`TODO.md`](TODO.md) and summarised for a BASIC progra
|
|||||||
| [`docs/`](docs/README.md) | The guide: twenty-one chapters, the language then each hardware area then a reference section for every verb and function, [Chapter 14](docs/14-architecture.md) on the interpreter's own architecture, [Chapter 15](docs/15-error-codes.md) listing every error code, [Chapters 17](docs/17-tutorial-breakout.md) and [18](docs/18-tutorial-breakout-artwork.md) building a whole game twice, and [Chapters 20](docs/20-tutorial-galaga.md) and [21](docs/21-tutorial-galaga-enemies.md) building a C game that embeds the interpreter |
|
| [`docs/`](docs/README.md) | The guide: twenty-one chapters, the language then each hardware area then a reference section for every verb and function, [Chapter 14](docs/14-architecture.md) on the interpreter's own architecture, [Chapter 15](docs/15-error-codes.md) listing every error code, [Chapters 17](docs/17-tutorial-breakout.md) and [18](docs/18-tutorial-breakout-artwork.md) building a whole game twice, and [Chapters 20](docs/20-tutorial-galaga.md) and [21](docs/21-tutorial-galaga-enemies.md) building a C game that embeds the interpreter |
|
||||||
| [`MAINTENANCE.md`](MAINTENANCE.md) | For contributors and maintainers: the documentation-example harness, the three test lists, mutation testing, error-code allocation, style |
|
| [`MAINTENANCE.md`](MAINTENANCE.md) | For contributors and maintainers: the documentation-example harness, the three test lists, mutation testing, error-code allocation, style |
|
||||||
| [`TODO.md`](TODO.md) | Outstanding defects, with file, line and consequence |
|
| [`TODO.md`](TODO.md) | Outstanding defects, with file, line and consequence |
|
||||||
| [`tests/reference/README.md`](tests/reference/README.md) | Where the golden corpus came from, and the rule for changing it |
|
| [`tests/language/README.md`](tests/language/README.md) | The editable language corpus and the rule for changing it |
|
||||||
|
|
||||||
API documentation builds with `doxygen Doxyfile`, into `build/docs/html`.
|
API documentation builds with `doxygen Doxyfile`, into `build/docs/html`.
|
||||||
|
|
||||||
@@ -138,12 +138,13 @@ API documentation builds with `doxygen Doxyfile`, into `build/docs/html`.
|
|||||||
Everything is a submodule; `git submodule update --init --recursive` gets all of it. There is
|
Everything is a submodule; `git submodule update --init --recursive` gets all of it. There is
|
||||||
nothing to install first.
|
nothing to install first.
|
||||||
|
|
||||||
* [libakerror](https://source.starfort.tech/andrew/libakerror) 2.0.1 — TRY/CATCH-style error
|
* [libakerror](https://source.starfort.tech/andrew/libakerror) 2.0.2 — TRY/CATCH-style error
|
||||||
contexts. Every function that can fail returns one. 2.0.0 made it thread safe and broke the
|
contexts. Every function that can fail returns one. 2.0.0 made it thread safe and broke the
|
||||||
ABI; anything built against a 1.x header must be rebuilt rather than relinked.
|
ABI; anything built against a 1.x header must be rebuilt rather than relinked.
|
||||||
* [libakstdlib](https://source.starfort.tech/andrew/libakstdlib) 0.2.0 — libc wrappers that
|
* [libakstdlib](https://source.starfort.tech/andrew/libakstdlib) 0.2.0 — libc wrappers that
|
||||||
report through `libakerror`. String-to-number conversion goes straight to it, which is why
|
report through `libakerror`. String-to-number conversion goes straight to it, which is why
|
||||||
`VAL("garbage")` is an error rather than a silent `0`.
|
`VAL("garbage")` is an error rather than a silent `0`. Its public header now also pulls in
|
||||||
|
`<dirent.h>` and `<sys/stat.h>` for the directory and file-metadata wrappers.
|
||||||
* [libakgl](https://source.starfort.tech/andrew/libakgl) 0.9.0 — **optional**, only for
|
* [libakgl](https://source.starfort.tech/andrew/libakgl) 0.9.0 — **optional**, only for
|
||||||
`-DAKBASIC_WITH_AKGL=ON`. Pulls in SDL3. Its soname carries `MAJOR.MINOR` while the major is 0,
|
`-DAKBASIC_WITH_AKGL=ON`. Pulls in SDL3. Its soname carries `MAJOR.MINOR` while the major is 0,
|
||||||
so rebuild rather than relink.
|
so rebuild rather than relink.
|
||||||
|
|||||||
43
TODO.md
43
TODO.md
@@ -38,7 +38,7 @@ What it changes:
|
|||||||
- **§1.8's message-text contract is now a convention.** Improving a message is allowed; it costs
|
- **§1.8's message-text contract is now a convention.** Improving a message is allowed; it costs
|
||||||
a golden file, which is a cost rather than a veto.
|
a golden file, which is a cost rather than a veto.
|
||||||
- **§5's bar drops** from "defensible against the golden suite" to defensible on its own merits.
|
- **§5's bar drops** from "defensible against the golden suite" to defensible on its own merits.
|
||||||
- **`tests/reference/` becomes a regression suite rather than a specification.** Diverging from
|
- **`tests/language/` is the editable language corpus rather than a protected specification.** Diverging from
|
||||||
it is allowed and must be deliberate and recorded — see its README.
|
it is allowed and must be deliberate and recorded — see its README.
|
||||||
|
|
||||||
What it does **not** change:
|
What it does **not** change:
|
||||||
@@ -306,13 +306,13 @@ to `Println`, which adds another.
|
|||||||
**This used to be a hard contract and is now a default.** The Go implementation is deprecated
|
**This used to be a hard contract and is now a default.** The Go implementation is deprecated
|
||||||
and will not be updated, so the two projects are no longer required to match — see §0.1. What
|
and will not be updated, so the two projects are no longer required to match — see §0.1. What
|
||||||
survives is the practical half: these strings and this newline behaviour are what every
|
survives is the practical half: these strings and this newline behaviour are what every
|
||||||
expectation in `tests/reference/` was written against, so changing one means changing golden
|
expectation in `tests/language/` was written against, so changing one means changing the paired
|
||||||
files, and that is worth doing on purpose rather than by accident. A message that reads
|
files, and that is worth doing on purpose rather than by accident. A message that reads
|
||||||
awkwardly *may* now be improved; do it deliberately, move the expectations in the same commit,
|
awkwardly *may* now be improved; do it deliberately, move the expectations in the same commit,
|
||||||
and add a line to §5.
|
and add a line to §5.
|
||||||
|
|
||||||
Numeric formatting still matches the reference: integers via `%" PRId64 "`, floats via `%f`
|
Numeric formatting still matches the reference: integers via `%" PRId64 "`, floats via `%f`
|
||||||
(Go's `%f` and C's `%f` both give six decimals — `tests/reference/language/arithmetic/float.txt`
|
(Go's `%f` and C's `%f` both give six decimals — `tests/language/arithmetic/float.txt`
|
||||||
confirms). No reason to change it, which is different from not being allowed to.
|
confirms). No reason to change it, which is different from not being allowed to.
|
||||||
|
|
||||||
### 1.9 Which `libakstdlib` calls are cleared for use — **the bans are lifted**
|
### 1.9 Which `libakstdlib` calls are cleared for use — **the bans are lifted**
|
||||||
@@ -375,7 +375,7 @@ Phases 0 through 6 of the original plan are done. The interpreter builds clean u
|
|||||||
|
|
||||||
It *did* reproduce the reference byte for byte, and that claim is retired rather than broken:
|
It *did* reproduce the reference byte for byte, and that claim is retired rather than broken:
|
||||||
§0.1 released it, and one case has since diverged deliberately (§6 item 16, listed in
|
§0.1 released it, and one case has since diverged deliberately (§6 item 16, listed in
|
||||||
`tests/reference/README.md`). Everything else still matches, which is worth knowing but is no
|
`tests/language/README.md`). Everything else still matches, which is worth knowing but is no
|
||||||
longer a gate.
|
longer a gate.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -408,17 +408,16 @@ and the only path that existed — `AKBASIC_MODE_RUNSTREAM` reading through the
|
|||||||
is the code the README quotes, built by every build and registered as a CTest case so a
|
is the code the README quotes, built by every build and registered as a CTest case so a
|
||||||
signature change breaks the build rather than rotting the document.
|
signature change breaks the build rather than rotting the document.
|
||||||
|
|
||||||
**The acceptance suite is the reference's own corpus, checked in at `tests/reference/`.** All
|
**The acceptance suite is the editable language corpus, checked in at `tests/language/`.** All
|
||||||
41 `.bas` files are registered as individual CTest cases and byte-compared against their `.txt`
|
65 `.bas` files are registered as individual CTest cases and compared against their `.txt`
|
||||||
— including the trailing double newline on an error line (§1.8).
|
— including the trailing double newline on an error line (§1.8).
|
||||||
|
|
||||||
It was driven *in place* out of `deps/basicinterpret` until 2026-07-31, on the reasoning that
|
It was driven *in place* out of `deps/basicinterpret` until 2026-07-31, on the reasoning that
|
||||||
copying a submodule's corpus guarantees drift. That reasoning was sound and was overruled
|
copying a submodule's corpus guarantees drift. That reasoning was sound and was overruled
|
||||||
deliberately: the Go dependency is being deprecated, and a build that cannot run its own
|
deliberately: the Go dependency is being deprecated, and a build that cannot run its own
|
||||||
acceptance suite without cloning the implementation it replaced is not finished. The copy is
|
acceptance suite without cloning the implementation it replaced is not finished. The copy is
|
||||||
byte-identical to `basicinterpreter@d76162c`, and `tests/reference/README.md` records the
|
originally byte-identical to `basicinterpreter@d76162c`, and `tests/language/README.md` records the
|
||||||
provenance, the cost of the drift nobody is watching for now, and the rule that those
|
provenance and the rule that programs and expectations are edited together deliberately.
|
||||||
expectations are never edited to suit this interpreter.
|
|
||||||
|
|
||||||
**Nothing in the build or the suite needs `deps/basicinterpret` any more**, and that is checked
|
**Nothing in the build or the suite needs `deps/basicinterpret` any more**, and that is checked
|
||||||
rather than assumed — both configurations were configured, built and run from scratch with the
|
rather than assumed — both configurations were configured, built and run from scratch with the
|
||||||
@@ -1026,7 +1025,7 @@ deviations from the reference's *program*: `main.go` and the SDL half of
|
|||||||
|
|
||||||
**What it costs a program:** a listing that used `INPUT$`, `LEN#` or `GOTO%` as a variable
|
**What it costs a program:** a listing that used `INPUT$`, `LEN#` or `GOTO%` as a variable
|
||||||
stops parsing, and the fix is to rename the variable. One case in the reference's own corpus
|
stops parsing, and the fix is to rename the variable. One case in the reference's own corpus
|
||||||
did exactly that; see `tests/reference/README.md`.
|
did exactly that; see `tests/language/examples/strreverse.bas`.
|
||||||
|
|
||||||
### Deviations in statement separation
|
### Deviations in statement separation
|
||||||
|
|
||||||
@@ -1391,10 +1390,10 @@ deviations from the reference's *program*: `main.go` and the SDL half of
|
|||||||
**This one moved a golden file.** A line with no number used to be filed under the loader's
|
**This one moved a golden file.** A line with no number used to be filed under the loader's
|
||||||
cursor unchanged — that is, on top of the line before it — so two unnumbered lines in a row
|
cursor unchanged — that is, on top of the line before it — so two unnumbered lines in a row
|
||||||
silently lost the first, and a *blank* line erased whatever preceded it. The reference does
|
silently lost the first, and a *blank* line erased whatever preceded it. The reference does
|
||||||
the same, and `tests/reference/language/arithmetic/integer.bas` is the proof: four `PRINT`
|
the same, and `tests/language/arithmetic/integer.bas` is the proof: four `PRINT`
|
||||||
statements, an expectation with three values, and a trailing blank line that erased
|
statements, an expectation with three values, and a trailing blank line that erased
|
||||||
`40 PRINT 4 - 2` before the program ran. The expectation is now `4 4 2 2` and
|
`40 PRINT 4 - 2` before the program ran. The expectation is now `4 4 2 2` and
|
||||||
`tests/reference/README.md` records it.
|
`tests/language/README.md` records it.
|
||||||
|
|
||||||
In its place: `akbasic_runtime_file_line()` (`src/runtime.c`) is the one implementation of
|
In its place: `akbasic_runtime_file_line()` (`src/runtime.c`) is the one implementation of
|
||||||
the rule, shared by `akbasic_runtime_load()`, RUNSTREAM and `DLOAD`. A numbered line is
|
the rule, shared by `akbasic_runtime_load()`, RUNSTREAM and `DLOAD`. A numbered line is
|
||||||
@@ -1586,9 +1585,9 @@ be reproduced before it can be fixed.
|
|||||||
|
|
||||||
**It cost one golden case, exactly as predicted, and the cost turned out to be nothing.**
|
**It cost one golden case, exactly as predicted, and the cost turned out to be nothing.**
|
||||||
The reference's `examples/strreverse.bas` names a variable `INPUT$`; the variable is renamed
|
The reference's `examples/strreverse.bas` names a variable `INPUT$`; the variable is renamed
|
||||||
to `SOURCE$` in `tests/reference/`, the expectation is byte-for-byte unchanged — the program
|
to `SOURCE$` in `tests/language/examples/strreverse.bas`, the expectation is byte-for-byte unchanged — the program
|
||||||
still prints `REVERSED: OLLEH` — and the case keeps every bit of its coverage. Recorded in
|
still prints `REVERSED: OLLEH` — and the case keeps every bit of its coverage. Recorded in
|
||||||
`tests/reference/README.md`'s divergence table, which this is the first entry in.
|
`tests/language/README.md` records the corpus editing rule.
|
||||||
|
|
||||||
This item sat parked because the corpus was the acceptance contract and lived in a submodule
|
This item sat parked because the corpus was the acceptance contract and lived in a submodule
|
||||||
this repository could not edit. Both premises are gone: the corpus is checked in, and
|
this repository could not edit. Both premises are gone: the corpus is checked in, and
|
||||||
@@ -2232,10 +2231,10 @@ update --init --recursive` gets them.
|
|||||||
|
|
||||||
## 8. Status
|
## 8. Status
|
||||||
|
|
||||||
**The port is done.** The C interpreter passes the Go reference's entire corpus and passes clean
|
**The port is done.** The C interpreter passes the language corpus and passes clean
|
||||||
under ASan and UBSan. It reproduced that corpus byte for byte until §0.1 retired the
|
under ASan and UBSan. It reproduced that corpus byte for byte until §0.1 retired the
|
||||||
requirement; two cases have diverged on purpose since, and
|
requirement; two cases have diverged on purpose since, and
|
||||||
`tests/reference/README.md` lists them.
|
`tests/language/README.md` lists them.
|
||||||
|
|
||||||
| Gate | Result |
|
| Gate | Result |
|
||||||
|---|---|
|
|---|---|
|
||||||
@@ -2243,7 +2242,7 @@ requirement; two cases have diverged on purpose since, and
|
|||||||
| `ctest` with `-DAKBASIC_WITH_AKGL=ON` | 112/112 headless, with `akgl_typing` skipping itself. The same set minus the four `no_device` cases the SDL driver contradicts, plus `akgl_backends`, `akgl_frontend`, `docs_screenshots` and `akgl_typing` — the last of which is the skip, and the `akgl_build` CI job is where it skips |
|
| `ctest` with `-DAKBASIC_WITH_AKGL=ON` | 112/112 headless, with `akgl_typing` skipping itself. The same set minus the four `no_device` cases the SDL driver contradicts, plus `akgl_backends`, `akgl_frontend`, `docs_screenshots` and `akgl_typing` — the last of which is the skip, and the `akgl_build` CI job is where it skips |
|
||||||
| `docs_examples` | Every fenced block in `README.md`, `MAINTENANCE.md` and `docs/` executed and byte-compared: 71 programs, 9 transcripts, 79 output comparisons, 4 C snippets, 2 excerpts, 2 shell blocks and 19 figures in the default build. The C-snippet count reads 0 when the harness is run by hand without `--cflags-file`; CTest passes it. `MAINTENANCE.md` documents the fence-tag convention |
|
| `docs_examples` | Every fenced block in `README.md`, `MAINTENANCE.md` and `docs/` executed and byte-compared: 71 programs, 9 transcripts, 79 output comparisons, 4 C snippets, 2 excerpts, 2 shell blocks and 19 figures in the default build. The C-snippet count reads 0 when the harness is run by hand without `--cflags-file`; CTest passes it. `MAINTENANCE.md` documents the fence-tag convention |
|
||||||
| `docs_screenshots` | 19/19 figures re-rendered and byte-identical to the checked-in PNGs. AKGL build only — rendering a picture needs the SDL half |
|
| `docs_screenshots` | 19/19 figures re-rendered and byte-identical to the checked-in PNGs. AKGL build only — rendering a picture needs the SDL half |
|
||||||
| Golden corpus | 41/41 byte-exact from `tests/reference/` — **and 41/41 again through the SDL binary**, which is most of what proves the frontend changes no output |
|
| Language corpus | 65/65 paired expectations — **and 65/65 again through the SDL binary**, which is most of what proves the frontend changes no output |
|
||||||
| ASan + UBSan | 112/112 |
|
| ASan + UBSan | 112/112 |
|
||||||
| Line coverage | 94.1% (7227/7681) — above the 90% gate |
|
| Line coverage | 94.1% (7227/7681) — above the 90% gate |
|
||||||
| Function coverage | 97.9% (474/484) |
|
| Function coverage | 97.9% (474/484) |
|
||||||
@@ -2340,9 +2339,9 @@ Dependency baseline:
|
|||||||
|
|
||||||
| Submodule | Version | Notes |
|
| Submodule | Version | Notes |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `deps/libakerror` | 2.0.1 | Private ownership-enforced status registry. akbasic reserves 512–767 in `akbasic_error_register()`. Does not namespace its `coverage` target when embedded — worked around in our `CMakeLists.txt`. **2.0.0 is thread safe and an ABI break** (`libakerror.so.2`): `__akerr_last_ignored` is thread-local and `akerr_next_error()` returns an owned reference, neither of which fails to link when mismatched. **2.0.1 fixes an exit status that mattered more to this band than to any other** — see below. |
|
| `deps/libakerror` | 2.0.2 | Private ownership-enforced status registry. akbasic reserves 512–767 in `akbasic_error_register()`. **2.0.0 is thread safe and an ABI break** (`libakerror.so.2`): the `IGNORE` context is thread-local and `akerr_next_error()` returns an owned reference, neither of which fails to link when mismatched. **2.0.1 fixes an exit status that mattered more to this band than to any other** — see below. **2.0.2** namespaces its embedded `coverage` target (issue #15 — our `add_custom_target` shadow is deleted), installs `akerrorConfigVersion.cmake` at `SameMajorVersion` (issue #16), fixes the `AKERR_USE_STDLIB=OFF` build, retires `PATH_MAX` for `AKERR_MAX_ERROR_FNAME_LENGTH`, and turns the `IGNORE` slot into a released copy — `__akerr_last_ignored` was an `extern` pointer and is now a per-TU `static akerr_last_ignored`. **That last one costs us 1.35 MiB of thread-local storage**: 38 translation units x 37,296 bytes, measured as the whole TLS segment of `build/basic`, where 2.0.1 produced no TLS segment at all. Filed upstream as libakerror issue #37, along with the 84 `-Wunused-variable` warnings it emits. Its `UPGRADING.md` describes a 2.0.3 that `project()` never stamped — libakerror issue #38, which is why the version above reads 2.0.2. |
|
||||||
| `deps/libakstdlib` | 0.2.0 | soname `libakstdlib.so.0.2`. `AKSL_VERSION_CHECK()` asserted in `tests/version_check.c`. This release fixed all six confirmed defects the port was working around — see §1.9, where the bans are now lifted. |
|
| `deps/libakstdlib` | 0.2.0 | soname `libakstdlib.so.0.2`. `AKSL_VERSION_CHECK()` asserted in `tests/version_check.c`. This release fixed all six confirmed defects the port was working around — see §1.9, where the bans are now lifted. Since then, and with no version bump: **directory wrappers landed** (`aksl_opendir`/`readdir`/`closedir`/`rewinddir`, issue #10) — the gap `DIRECTORY` was refused for, so that refusal now says only that the verb is unwritten; file-metadata wrappers landed; and `aksl_snprintf` keeps its `int *count` but now reports the *required* length on truncation rather than 0. Only read on success here, so nothing moved. |
|
||||||
| `deps/libakgl` | 0.7.0 | soname `libakgl.so.0.7`. Owns status codes 256–260. Linked and tested under `-DAKBASIC_WITH_AKGL=ON`, which still defaults OFF so the core library and its whole suite build on a machine with no SDL. **0.3.0 closed every API gap this port had filed** — see §7 — so the four workarounds §3 used to list are gone. 0.4.0 was a leak-and-overread release that changed no public struct. **0.5.0 is the first that broke our source as well as our ABI**: it namespaced every exported symbol, so `akgl_render_bind2d` is `akgl_render_2d_bind`, `akgl_sprite_sheet_coords_for_frame` is `akgl_spritesheet_coords_for_frame`, the `renderer`/`camera`/`window` globals carry the prefix, and `_akgl_renderer`/`_akgl_camera` are `akgl_default_renderer`/`akgl_default_camera`. `include/akbasic/akgl.h` asserts the floor. **0.6.0 and 0.7.0 broke nothing here** — 0.6.0 is three arcade-physics fixes and a `physics.max_timestep` property this port does not use, and 0.7.0 reports failures `libakstdlib`'s wrappers were already catching and takes `libakerror` 2.0.1. The floor moved anyway, because deciding for ourselves which of libakgl's minor releases were really compatible is the judgement the soname exists to take away. |
|
| `deps/libakgl` | 0.9.0 | soname `libakgl.so.0.9`. Owns status codes 256–262. Linked and tested under `-DAKBASIC_WITH_AKGL=ON`, which still defaults OFF so the core library and its whole suite build on a machine with no SDL. **0.3.0 closed every API gap this port had filed** — see §7 — so the four workarounds §3 used to list are gone. 0.4.0 was a leak-and-overread release that changed no public struct. **0.5.0 is the first that broke our source as well as our ABI**: it namespaced every exported symbol, so `akgl_render_bind2d` is `akgl_render_2d_bind`, `akgl_sprite_sheet_coords_for_frame` is `akgl_spritesheet_coords_for_frame`, the `renderer`/`camera`/`window` globals carry the prefix, and `_akgl_renderer`/`_akgl_camera` are `akgl_default_renderer`/`akgl_default_camera`. `include/akbasic/akgl.h` asserts the floor. **0.6.0 and 0.7.0 broke nothing here** — 0.6.0 is three arcade-physics fixes and a `physics.max_timestep` property this port does not use, and 0.7.0 reports failures `libakstdlib`'s wrappers were already catching and takes `libakerror` 2.0.1. **0.8.0 and 0.9.0 broke nothing here either** — 0.8.0 is the collision subsystem (`AKGL_ERR_COLLISION`, code 261, and the vendored `libccd` and `tg` submodules that come with it), and 0.9.0 is the `akgl_ui` subsystem (`AKGL_ERR_UI`, code 262, and vendored `clay`), which is what `src/ui_akgl.c` draws through. Both widen libakgl's reserved band from five codes to seven; the range map in `MAINTENANCE.md` carries it. The floor moved anyway, because deciding for ourselves which of libakgl's minor releases were really compatible is the judgement the soname exists to take away. **Note `deps/libakgl/deps/` pins its own `libakerror` and `libakstdlib` older than ours**; the top-level build declares both targets first and libakgl's `if(NOT TARGET ...)` guards mean its copies are never configured, so what libakgl actually compiles against is what this tree pins. |
|
||||||
|
|
||||||
**An unhandled error in this band used to exit zero, and 512 is the worst possible base for
|
**An unhandled error in this band used to exit zero, and 512 is the worst possible base for
|
||||||
that.** `libakerror`'s default unhandled-error handler ended in `exit(errctx->status)`, and a
|
that.** `libakerror`'s default unhandled-error handler ended in `exit(errctx->status)`, and a
|
||||||
@@ -2553,7 +2552,7 @@ What remains, in priority order:
|
|||||||
this whole arrangement exists against.
|
this whole arrangement exists against.
|
||||||
|
|
||||||
The byte comparison is a deliberate bet that the dummy driver and the software renderer
|
The byte comparison is a deliberate bet that the dummy driver and the software renderer
|
||||||
are reproducible, which is the same bet `tests/reference/` already makes about golden
|
are reproducible, which is the same bet `tests/language/` makes about golden
|
||||||
output. Verified run-to-run and build-to-build here; what is untested is an SDL upgrade
|
output. Verified run-to-run and build-to-build here; what is untested is an SDL upgrade
|
||||||
that moves one pixel of a diagonal. **If that happens, regenerate the figures in the same
|
that moves one pixel of a diagonal. **If that happens, regenerate the figures in the same
|
||||||
commit as the bump** — do not weaken the test to a size check, which would pass for every
|
commit as the bump** — do not weaken the test to a size check, which would pass for every
|
||||||
@@ -2636,7 +2635,7 @@ reduced against `build/basic`, the stdio build, unless it says otherwise.
|
|||||||
|
|
||||||
**It is narrower than it looks, and the golden corpus is why.** The first attempt
|
**It is narrower than it looks, and the golden corpus is why.** The first attempt
|
||||||
released the scope on *any* skip, which broke
|
released the scope on *any* skip, which broke
|
||||||
`tests/reference/language/flowcontrol/nestedforloopwaitingforcommand.bas`: a zero-
|
`tests/language/flowcontrol/nestedforloopwaitingforcommand.bas`: a zero-
|
||||||
iteration `FOR` skips its body by the same mechanism, and there the orphan is
|
iteration `FOR` skips its body by the same mechanism, and there the orphan is
|
||||||
load-bearing -- it is what absorbs the inner `NEXT` so the outer one still finds its
|
load-bearing -- it is what absorbs the inner `NEXT` so the outer one still finds its
|
||||||
`FOR`. Releasing it turns that case into "NEXT outside the context of FOR". So the
|
`FOR`. Releasing it turns that case into "NEXT outside the context of FOR". So the
|
||||||
|
|||||||
2
deps/libakerror
vendored
2
deps/libakerror
vendored
Submodule deps/libakerror updated: 5eaa956f50...ee38eed31c
2
deps/libakgl
vendored
2
deps/libakgl
vendored
Submodule deps/libakgl updated: bbb7b8f494...77091ed177
2
deps/libakstdlib
vendored
2
deps/libakstdlib
vendored
Submodule deps/libakstdlib updated: 2b79aca103...821200e618
@@ -126,7 +126,7 @@ exists, and reading into one you never sized writes over something else.
|
|||||||
| `COLLECT` | validates a disk's block allocation map. There is no map |
|
| `COLLECT` | validates a disk's block allocation map. There is no map |
|
||||||
| `BACKUP` | duplicates one disk onto another. There are no disks |
|
| `BACKUP` | duplicates one disk onto another. There are no disks |
|
||||||
| `BOOT` | loads and runs a boot sector. There is no boot sector |
|
| `BOOT` | loads and runs a boot sector. There is no boot sector |
|
||||||
| `DIRECTORY` / `CATALOG` | needs a directory-reading wrapper the standard library does not have yet. Filed upstream |
|
| `DIRECTORY` / `CATALOG` | not written yet. It was blocked on a directory-reading wrapper in the standard library; that landed, so only the verb is outstanding |
|
||||||
|
|
||||||
`DCLEAR` is the exception among the drive verbs: resetting a drive also closes its
|
`DCLEAR` is the exception among the drive verbs: resetting a drive also closes its
|
||||||
channels, and closing the channels is real, so that is what it does.
|
channels, and closing the channels is real, so that is what it does.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ for the reasoning in each case.
|
|||||||
| `DIALOG` | `DIALOG ["text"]` | Show a text panel across the bottom of the screen. No argument takes it down. See Chapter 19. |
|
| `DIALOG` | `DIALOG ["text"]` | Show a text panel across the bottom of the screen. No argument takes it down. See Chapter 19. |
|
||||||
| `DIM` | `DIM A#(n [,...])` | Make an array. Subscripts start at zero; `n` is the count. |
|
| `DIM` | `DIM A#(n [,...])` | Make an array. Subscripts start at zero; `n` is the count. |
|
||||||
| `DIM` … `AS` | `DIM S@ AS T`, `DIM P@ AS PTR TO T` | Make a structure, or a strict pointer to one. See Chapter 16. |
|
| `DIM` … `AS` | `DIM S@ AS T`, `DIM P@ AS PTR TO T` | Make a structure, or a strict pointer to one. See Chapter 16. |
|
||||||
| `DIRECTORY` | `DIRECTORY` | **Refused.** Needs a directory-reading wrapper that does not exist yet. |
|
| `DIRECTORY` | `DIRECTORY` | **Refused.** Not written yet; the standard-library wrapper it waited on has landed. |
|
||||||
| `DLOAD` | `DLOAD "name"` | Load a program from a file. |
|
| `DLOAD` | `DLOAD "name"` | Load a program from a file. |
|
||||||
| `DO` | `DO [WHILE c | UNTIL c]` | Start a loop. The condition may be here, on the `LOOP`, or neither. |
|
| `DO` | `DO [WHILE c | UNTIL c]` | Start a loop. The condition may be here, on the `LOOP`, or neither. |
|
||||||
| `DOPEN` | `DOPEN n, "name" [,W]` | Open a file on channel `n`. `W` opens it for writing. |
|
| `DOPEN` | `DOPEN n, "name" [,W]` | Open a file on channel `n`. `W` opens it for writing. |
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ so a call with the wrong number is a syntax error rather than a surprise.
|
|||||||
| Function | Args | Form | What it gives |
|
| Function | Args | Form | What it gives |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `ABS` | 1 | `ABS(n)` | The absolute value of an integer or float. |
|
| `ABS` | 1 | `ABS(n)` | The absolute value of an integer or float. |
|
||||||
|
| `ASC` | 1 | `ASC(A$)` | The Unicode code point of a string's first character. |
|
||||||
| `ATN` | 1 | `ATN(n)` | Arctangent, in radians. |
|
| `ATN` | 1 | `ATN(n)` | Arctangent, in radians. |
|
||||||
| `BUMP` | 1 | `BUMP(1)` | Which sprites have collided, as a bitmask. **Reading clears it.** |
|
| `BUMP` | 1 | `BUMP(1)` | Which sprites have collided, as a bitmask. **Reading clears it.** |
|
||||||
| `CHR` | 1 | `CHR(n)` | The character for a Unicode code point, as a string. |
|
| `CHR` | 1 | `CHR(n)` | The character for a Unicode code point, as a string. |
|
||||||
@@ -29,6 +30,7 @@ so a call with the wrong number is a syntax error rather than a surprise.
|
|||||||
| `RGR` | 1 | `RGR(f)` | The `GRAPHIC` mode (0), the drawing surface's width (1) or height (2) in pixels, or a character cell's width (3) or height (4). |
|
| `RGR` | 1 | `RGR(f)` | The `GRAPHIC` mode (0), the drawing surface's width (1) or height (2) in pixels, or a character cell's width (3) or height (4). |
|
||||||
| `RIGHT` | 2 | `RIGHT(A$, n)` | The rightmost `n` characters. Clamped. |
|
| `RIGHT` | 2 | `RIGHT(A$, n)` | The rightmost `n` characters. Clamped. |
|
||||||
| `RMENU` | 2 | `RMENU(n, f)` | A menu's state: field 0 the highlighted entry, field 1 whether it has been confirmed. **Reading field 1 clears it.** |
|
| `RMENU` | 2 | `RMENU(n, f)` | A menu's state: field 0 the highlighted entry, field 1 whether it has been confirmed. **Reading field 1 clears it.** |
|
||||||
|
| `RND` | 1 | `RND(n)` | A random integer from 0 up to but not including `n`. |
|
||||||
| `RWINDOW` | 1 | `RWINDOW(f)` | The current text window's rows (0) or columns (1). Field 2 is a C128 screen mode and is refused. |
|
| `RWINDOW` | 1 | `RWINDOW(f)` | The current text window's rows (0) or columns (1). Field 2 is a C128 screen mode and is refused. |
|
||||||
| `RSPCOLOR` | 1 | `RSPCOLOR(n)` | One of `SPRCOLOR`'s two shared registers, 1 or 2. |
|
| `RSPCOLOR` | 1 | `RSPCOLOR(n)` | One of `SPRCOLOR`'s two shared registers, 1 or 2. |
|
||||||
| `RSPHIT` | 2 | `RSPHIT(n, f)` | One of `SPRHIT`'s settings for sprite `n`, in `SPRHIT`'s own argument order: 0 the kind, 1 to 4 the two corners. |
|
| `RSPHIT` | 2 | `RSPHIT(n, f)` | One of `SPRHIT`'s settings for sprite `n`, in `SPRHIT`'s own argument order: 0 the kind, 1 to 4 the two corners. |
|
||||||
|
|||||||
@@ -199,7 +199,8 @@ interpreter's error code, which bears no relation to a Commodore error number. P
|
|||||||
- **`BLOAD` requires a length.**
|
- **`BLOAD` requires a length.**
|
||||||
- **`HEADER`, `COLLECT`, `BACKUP` and `BOOT` are refused.** They operate on a physical
|
- **`HEADER`, `COLLECT`, `BACKUP` and `BOOT` are refused.** They operate on a physical
|
||||||
disk.
|
disk.
|
||||||
- **`DIRECTORY` is refused** pending a wrapper in the standard library.
|
- **`DIRECTORY` is refused** because it is not written yet. The standard-library
|
||||||
|
wrapper it was waiting on has landed, so the remaining work is the verb.
|
||||||
|
|
||||||
## Machine
|
## Machine
|
||||||
|
|
||||||
|
|||||||
@@ -743,8 +743,8 @@ way to see that something pushed a scope and never popped it.
|
|||||||
|
|
||||||
```sh norun
|
```sh norun
|
||||||
ctest --test-dir build --output-on-failure -R for_next # one unit test
|
ctest --test-dir build --output-on-failure -R for_next # one unit test
|
||||||
ctest --test-dir build --output-on-failure -R golden_ # the reference corpus
|
ctest --test-dir build --output-on-failure -R local_ # the language corpus
|
||||||
./build/basic tests/reference/language/functions.bas | diff - tests/reference/language/functions.txt
|
./build/basic tests/language/functions.bas | diff - tests/language/functions.txt
|
||||||
./tests/docs_examples.sh --root . --basic ./build/basic \
|
./tests/docs_examples.sh --root . --basic ./build/basic \
|
||||||
--cflags-file build/docs_cflags.txt docs/14-architecture.md
|
--cflags-file build/docs_cflags.txt docs/14-architecture.md
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1005,57 +1005,26 @@ IF NUDGE# = 1 THEN GOSUB UNSTICK
|
|||||||
LABEL UNSTICK
|
LABEL UNSTICK
|
||||||
NUDGE# = 0
|
NUDGE# = 0
|
||||||
STALL# = 0
|
STALL# = 0
|
||||||
RMAX# = 4
|
BVX# = (RND(4) * 3) - 6
|
||||||
GOSUB RANDOM
|
|
||||||
BVX# = (RND# * 3) - 6
|
|
||||||
IF BVX# = 0 THEN BVX# = 3
|
IF BVX# = 0 THEN BVX# = 3
|
||||||
RETURN
|
RETURN
|
||||||
```
|
```
|
||||||
|
|
||||||
### You have to write your own random numbers
|
### Random numbers are built in
|
||||||
|
|
||||||
**There is no `RND` in this dialect**, and no `INT`, `SQR`, `ASC` or `TIMER` either. A
|
There is no `INT`, `SQR` or `TIMER` in this dialect, but
|
||||||
linear congruential generator is nine tokens and does the job. Put the number of possible
|
`RND(n)` returns an integer from zero through `n - 1`. It seeds itself
|
||||||
answers in `RMAX#` and read the result from `RND#`:
|
from the host clock the first time it is called, so a program only needs the bound:
|
||||||
|
|
||||||
```basic
|
```basic
|
||||||
SEED# = 12345
|
|
||||||
RMAX# = 6
|
|
||||||
RND# = 0
|
|
||||||
I# = 0
|
I# = 0
|
||||||
FOR I# = 1 TO 5
|
FOR I# = 1 TO 5
|
||||||
GOSUB RANDOM
|
PRINT "ROLL " + (RND(6) + 1)
|
||||||
PRINT "ROLL " + (RND# + 1)
|
|
||||||
NEXT I#
|
NEXT I#
|
||||||
END
|
END
|
||||||
|
|
||||||
LABEL RANDOM
|
|
||||||
SEED# = MOD(((SEED# * 1103515245) + 12345), 2147483648)
|
|
||||||
RND# = MOD((SEED# / 65536), RMAX#)
|
|
||||||
RETURN
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```output
|
Use `RND` for the serve, too, so the ball does not always leave in the same direction:
|
||||||
ROLL 1
|
|
||||||
ROLL 5
|
|
||||||
ROLL 2
|
|
||||||
ROLL 1
|
|
||||||
ROLL 2
|
|
||||||
```
|
|
||||||
|
|
||||||
The multiplication stays inside a 64-bit integer for any seed below 2147483648, which is
|
|
||||||
why the modulus is that number. The answer is taken from the middle bits — `SEED# / 65536`
|
|
||||||
— because the low bits of a power-of-two modulus barely change from one call to the next.
|
|
||||||
Integer division truncating for free is the `INT` you do not have.
|
|
||||||
|
|
||||||
Seed it from the clock at startup. `TI#` is the host's uptime in sixtieths of a second,
|
|
||||||
which is different every time the game is run:
|
|
||||||
|
|
||||||
```basic norun
|
|
||||||
SEED# = TI#
|
|
||||||
```
|
|
||||||
|
|
||||||
Use `RANDOM` for the serve, too, so the ball does not always leave in the same direction:
|
|
||||||
|
|
||||||
```basic norun
|
```basic norun
|
||||||
LABEL SERVE
|
LABEL SERVE
|
||||||
@@ -1063,16 +1032,43 @@ PX# = (SCW# - PW#) / 2
|
|||||||
HELD# = 1
|
HELD# = 1
|
||||||
BX# = PX# + ((PW# / 2) - 4)
|
BX# = PX# + ((PW# / 2) - 4)
|
||||||
BY# = PY# - 10
|
BY# = PY# - 10
|
||||||
RMAX# = 2
|
|
||||||
GOSUB RANDOM
|
|
||||||
BVX# = BSPD#
|
BVX# = BSPD#
|
||||||
IF RND# = 0 THEN BVX# = 0 - BSPD#
|
IF RND(2) = 0 THEN BVX# = 0 - BSPD#
|
||||||
BVY# = 0 - BSPD#
|
BVY# = 0 - BSPD#
|
||||||
PDEC# = 0
|
PDEC# = 0
|
||||||
GOSUB SHOWSPR
|
GOSUB SHOWSPR
|
||||||
RETURN
|
RETURN
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Historical aside: the LCG this chapter used to teach</summary>
|
||||||
|
|
||||||
|
Before `RND` existed, this nine-token linear congruential generator was copied into
|
||||||
|
every program. It remains a useful from-scratch PRNG example:
|
||||||
|
|
||||||
|
```basic norun
|
||||||
|
SEED# = 12345
|
||||||
|
RMAX# = 6
|
||||||
|
ROLL# = 0
|
||||||
|
I# = 0
|
||||||
|
FOR I# = 1 TO 5
|
||||||
|
GOSUB RANDOM
|
||||||
|
PRINT "ROLL " + (ROLL# + 1)
|
||||||
|
NEXT I#
|
||||||
|
END
|
||||||
|
|
||||||
|
LABEL RANDOM
|
||||||
|
SEED# = MOD(((SEED# * 1103515245) + 12345), 2147483648)
|
||||||
|
ROLL# = MOD((SEED# / 65536), RMAX#)
|
||||||
|
RETURN
|
||||||
|
```
|
||||||
|
|
||||||
|
The multiplication stays inside a 64-bit integer for any seed below 2147483648. The
|
||||||
|
answer is taken from the middle bits because the low bits of a power-of-two modulus
|
||||||
|
barely change from one call to the next. This used to be required; it is now built in.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
`HELD#` is the flag Step 6's loop tests: while it is 1 the ball sits on the paddle, and
|
`HELD#` is the flag Step 6's loop tests: while it is 1 the ball sits on the paddle, and
|
||||||
`HOLDBAL` keeps it there:
|
`HOLDBAL` keeps it there:
|
||||||
|
|
||||||
@@ -1422,9 +1418,7 @@ PX# = PX# + D#
|
|||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
LABEL DEMOAIM
|
LABEL DEMOAIM
|
||||||
RMAX# = 81
|
DOFF# = RND(81) - 40
|
||||||
GOSUB RANDOM
|
|
||||||
DOFF# = RND# - 40
|
|
||||||
RETURN
|
RETURN
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1501,7 +1495,7 @@ This is the shape of the whole file:
|
|||||||
LABEL SETUP the geometry from Step 2
|
LABEL SETUP the geometry from Step 2
|
||||||
the declaration block from Step 3
|
the declaration block from Step 3
|
||||||
the brick faces from Step 5
|
the brick faces from Step 5
|
||||||
SEED# = TI#
|
RND(n) seeds itself from the host clock
|
||||||
the ceiling from Step 9
|
the ceiling from Step 9
|
||||||
GOSUB MKSPR Step 4
|
GOSUB MKSPR Step 4
|
||||||
GOSUB SNDPROBE Step 14
|
GOSUB SNDPROBE Step 14
|
||||||
@@ -1576,10 +1570,7 @@ BB# = 0
|
|||||||
RX# = 0
|
RX# = 0
|
||||||
N# = 0
|
N# = 0
|
||||||
MROW# = 0
|
MROW# = 0
|
||||||
RMAX# = 2
|
|
||||||
RND# = 0
|
|
||||||
SND# = 0
|
SND# = 0
|
||||||
SEED# = 0
|
|
||||||
P$ = ""
|
P$ = ""
|
||||||
H$ = ""
|
H$ = ""
|
||||||
S$ = ""
|
S$ = ""
|
||||||
|
|||||||
@@ -1423,7 +1423,8 @@ IF STATE# = 2 THEN GOSUB UNSTICK
|
|||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
LABEL PRESSPAUSE
|
LABEL PRESSPAUSE
|
||||||
IF STATE# = 2 THEN STATE# = 6 : GMTYP# = 0 : BAN$ = "PAUSED" : GOSUB SETBANNER : RETURN
|
IF STATE# = 2 THEN STATE# = 6 : GMTYP# = 0 : BAN$ = "PAUSED"
|
||||||
|
IF STATE# = 2 THEN BAN$ = "PAUSED" : GOSUB SETBANNER : RETURN
|
||||||
IF STATE# = 6 THEN STATE# = 2 : BAN$ = "" : GOSUB SETBANNER
|
IF STATE# = 6 THEN STATE# = 2 : BAN$ = "" : GOSUB SETBANNER
|
||||||
RETURN
|
RETURN
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ whole development loop; the engine never rebuilds.
|
|||||||
- **[Step 2](#step-2-bind-the-engines-own-actor)** — bind the engine's own
|
- **[Step 2](#step-2-bind-the-engines-own-actor)** — bind the engine's own
|
||||||
actor as the second type, which is the point of the whole exercise
|
actor as the second type, which is the point of the whole exercise
|
||||||
- **[Step 3](#step-3-share-the-frame-and-the-dice)** — share the frame state,
|
- **[Step 3](#step-3-share-the-frame-and-the-dice)** — share the frame state,
|
||||||
and give the script randomness it cannot make itself
|
and hand the script dice the engine controls
|
||||||
- **[Step 4](#step-4-why-bindings-and-not-arguments)** — see why the structures
|
- **[Step 4](#step-4-why-bindings-and-not-arguments)** — see why the structures
|
||||||
are bindings rather than function arguments
|
are bindings rather than function arguments
|
||||||
- **[Step 5](#step-5-the-shape-of-the-script)** — learn the three language
|
- **[Step 5](#step-5-the-shape-of-the-script)** — learn the three language
|
||||||
@@ -75,7 +75,7 @@ typedef struct galaga_Enemy
|
|||||||
float t; /* parametric clock for the current maneuver */
|
float t; /* parametric clock for the current maneuver */
|
||||||
int32_t hp;
|
int32_t hp;
|
||||||
int32_t fire; /* outbox: script sets 1, engine consumes */
|
int32_t fire; /* outbox: script sets 1, engine consumes */
|
||||||
float rnd; /* inbox: engine writes fresh 0..1 each call */
|
float rnd; /* inbox: fresh 0..1 each call; ROLL% in BASIC */
|
||||||
} galaga_Enemy;
|
} galaga_Enemy;
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ static const akbasic_HostField ENEMY_FIELDS[] = {
|
|||||||
AKBASIC_HOST_FIELD( galaga_Enemy, t, "T%", AKBASIC_HOSTFIELD_FLOAT ),
|
AKBASIC_HOST_FIELD( galaga_Enemy, t, "T%", AKBASIC_HOSTFIELD_FLOAT ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Enemy, hp, "HP#", AKBASIC_HOSTFIELD_INT32 ),
|
AKBASIC_HOST_FIELD( galaga_Enemy, hp, "HP#", AKBASIC_HOSTFIELD_INT32 ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Enemy, fire, "FIRE#", AKBASIC_HOSTFIELD_INT32 ),
|
AKBASIC_HOST_FIELD( galaga_Enemy, fire, "FIRE#", AKBASIC_HOSTFIELD_INT32 ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Enemy, rnd, "RND%", AKBASIC_HOSTFIELD_FLOAT )
|
AKBASIC_HOST_FIELD( galaga_Enemy, rnd, "ROLL%", AKBASIC_HOSTFIELD_FLOAT )
|
||||||
};
|
};
|
||||||
static const akbasic_HostType ENEMY_TYPE = {
|
static const akbasic_HostType ENEMY_TYPE = {
|
||||||
"ENEMY", sizeof(galaga_Enemy), ENEMY_FIELDS, 8
|
"ENEMY", sizeof(galaga_Enemy), ENEMY_FIELDS, 8
|
||||||
@@ -194,7 +194,7 @@ typedef struct galaga_Shared
|
|||||||
float playerx; /* the player actor's position, this frame */
|
float playerx; /* the player actor's position, this frame */
|
||||||
float playery;
|
float playery;
|
||||||
int32_t wave;
|
int32_t wave;
|
||||||
float rnd; /* fresh 0..1 each frame; the issue #16 route */
|
float rnd; /* fresh 0..1 each frame; ROLL% to the script */
|
||||||
} galaga_Shared;
|
} galaga_Shared;
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -203,13 +203,24 @@ the engine refreshes it at the top of every frame. The boss reads
|
|||||||
`GAME@.PLAYERX%` to lead its dive; the fire decision reads it to know whether
|
`GAME@.PLAYERX%` to lead its dive; the fire decision reads it to know whether
|
||||||
anything is worth shooting at.
|
anything is worth shooting at.
|
||||||
|
|
||||||
The `rnd` fields — one here per frame, one on each enemy per call — exist
|
The `rnd` fields — one here per frame, one on each enemy per call — carry the
|
||||||
because the engine's PRNG is the script's **only** source of randomness: write
|
engine's PRNG into the script: write `SELF@.ROLL% < DT% * 1.5` and an enemy's
|
||||||
`SELF@.RND% < DT% * 1.5` and an enemy's trigger finger is a dice roll. There
|
trigger finger is a dice roll.
|
||||||
is no `RND` verb in this dialect; issue #16 tracks adding one, and Chapter
|
|
||||||
17's breakout hand-rolls a linear congruential generator in BASIC as the other
|
The dialect does now have a native `RND` function — issue #16 closed, and
|
||||||
route. Here the engine fills the field, which also keeps a headless run the
|
[Chapter 12](12-function-reference.md) documents it — so this is no longer the
|
||||||
same game on every machine — the PRNG is the example's own, not libc's.
|
*only* route; Chapter 17's breakout hand-rolls a linear congruential generator
|
||||||
|
in BASIC as a third. The engine keeps filling the field here on purpose,
|
||||||
|
because it buys something `RND` cannot: the numbers come from the example's own
|
||||||
|
PRNG rather than libc's, so a headless run is the same game on every machine,
|
||||||
|
which is what makes `example_galaga` a test and not just a demo.
|
||||||
|
|
||||||
|
**The BASIC name is `ROLL%`, not `RND%`.** A host field is a bare word and
|
||||||
|
shares a namespace with every verb and function, so once `RND` became a
|
||||||
|
function name a field could no longer be called that — the scanner refuses it
|
||||||
|
with *"Reserved word in variable name"*. The C member stays `rnd`; only the
|
||||||
|
name the script sees had to move. [Chapter 16](16-structures.md) has the same
|
||||||
|
rule for `TYPE` declarations.
|
||||||
|
|
||||||
## Step 4: Why bindings, and not arguments
|
## Step 4: Why bindings, and not arguments
|
||||||
|
|
||||||
@@ -351,7 +362,7 @@ DEF DECIDEFIRE(DT%)
|
|||||||
DX% = GAME@.PLAYERX% - ACTOR@.X%
|
DX% = GAME@.PLAYERX% - ACTOR@.X%
|
||||||
IF ABS(DX%) > 140 THEN RETURN 0
|
IF ABS(DX%) > 140 THEN RETURN 0
|
||||||
IF ACTOR@.Y% > GAME@.PLAYERY% THEN RETURN 0
|
IF ACTOR@.Y% > GAME@.PLAYERY% THEN RETURN 0
|
||||||
IF SELF@.RND% < DT% * 1.5 THEN SELF@.FIRE# = 1
|
IF SELF@.ROLL% < DT% * 1.5 THEN SELF@.FIRE# = 1
|
||||||
RETURN 0
|
RETURN 0
|
||||||
END
|
END
|
||||||
```
|
```
|
||||||
@@ -386,7 +397,7 @@ DEF UPDATEBEE(DT%)
|
|||||||
IF (S# AND 2) > 0 THEN BEGIN
|
IF (S# AND 2) > 0 THEN BEGIN
|
||||||
ACTOR@.X% = SELF@.HOMEX% + SIN(SELF@.T% * 1.7) * 16
|
ACTOR@.X% = SELF@.HOMEX% + SIN(SELF@.T% * 1.7) * 16
|
||||||
ACTOR@.Y% = SELF@.HOMEY%
|
ACTOR@.Y% = SELF@.HOMEY%
|
||||||
IF SELF@.RND% < DT% * 0.04 THEN SELF@.STATE# = 4 : SELF@.T% = 0
|
IF SELF@.ROLL% < DT% * 0.04 THEN SELF@.STATE# = 4 : SELF@.T% = 0
|
||||||
BEND
|
BEND
|
||||||
IF (S# AND 4) > 0 THEN BEGIN
|
IF (S# AND 4) > 0 THEN BEGIN
|
||||||
R# = DIVESTEP(DT%, 130, 0.2)
|
R# = DIVESTEP(DT%, 130, 0.2)
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ RX# = 0
|
|||||||
N# = 0
|
N# = 0
|
||||||
MROW# = 0
|
MROW# = 0
|
||||||
RMAX# = 2
|
RMAX# = 2
|
||||||
RND# = 0
|
ROLL# = 0
|
||||||
SND# = 0
|
SND# = 0
|
||||||
P$ = ""
|
P$ = ""
|
||||||
H$ = ""
|
H$ = ""
|
||||||
@@ -172,7 +172,8 @@ BSG$(4) = "[--]"
|
|||||||
BSG$(5) = "[--]"
|
BSG$(5) = "[--]"
|
||||||
|
|
||||||
REM --- the seed -------------------------------------------------------
|
REM --- the seed -------------------------------------------------------
|
||||||
REM There is no RND in this dialect. TI# is jiffies off the host's clock
|
REM RND exists now, but this program keeps its own LCG so a headless run
|
||||||
|
REM is the same game every time. TI# is jiffies off the host's clock
|
||||||
REM and is host uptime rather than zero-based, which makes it a fine seed.
|
REM and is host uptime rather than zero-based, which makes it a fine seed.
|
||||||
SEED# = TI#
|
SEED# = TI#
|
||||||
|
|
||||||
@@ -389,17 +390,18 @@ BY# = PY# - 10
|
|||||||
RMAX# = 2
|
RMAX# = 2
|
||||||
GOSUB RANDOM
|
GOSUB RANDOM
|
||||||
BVX# = BSPD#
|
BVX# = BSPD#
|
||||||
IF RND# = 0 THEN BVX# = 0 - BSPD#
|
IF ROLL# = 0 THEN BVX# = 0 - BSPD#
|
||||||
BVY# = 0 - BSPD#
|
BVY# = 0 - BSPD#
|
||||||
PDEC# = 0
|
PDEC# = 0
|
||||||
GOSUB SHOWSPR
|
GOSUB SHOWSPR
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
REM A linear congruential generator, because this dialect has no RND.
|
REM A linear congruential generator. RND(n) would do this in one token
|
||||||
|
REM now; the LCG stays because its sequence is reproducible.
|
||||||
REM The multiply stays inside int64 for any seed under 2^31.
|
REM The multiply stays inside int64 for any seed under 2^31.
|
||||||
LABEL RANDOM
|
LABEL RANDOM
|
||||||
SEED# = MOD(((SEED# * 1103515245) + 12345), 2147483648)
|
SEED# = MOD(((SEED# * 1103515245) + 12345), 2147483648)
|
||||||
RND# = MOD((SEED# / 65536), RMAX#)
|
ROLL# = MOD((SEED# / 65536), RMAX#)
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
REM ####################################################################
|
REM ####################################################################
|
||||||
@@ -632,7 +634,7 @@ NUDGE# = 0
|
|||||||
STALL# = 0
|
STALL# = 0
|
||||||
RMAX# = 4
|
RMAX# = 4
|
||||||
GOSUB RANDOM
|
GOSUB RANDOM
|
||||||
BVX# = (RND# * 3) - 6
|
BVX# = (ROLL# * 3) - 6
|
||||||
IF BVX# = 0 THEN BVX# = 3
|
IF BVX# = 0 THEN BVX# = 3
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
@@ -641,7 +643,7 @@ REM like something with a hand on the paddle rather than a mirror.
|
|||||||
LABEL DEMOAIM
|
LABEL DEMOAIM
|
||||||
RMAX# = 81
|
RMAX# = 81
|
||||||
GOSUB RANDOM
|
GOSUB RANDOM
|
||||||
DOFF# = RND# - 40
|
DOFF# = ROLL# - 40
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
REM ####################################################################
|
REM ####################################################################
|
||||||
|
|||||||
@@ -241,7 +241,8 @@ SLX# = 0
|
|||||||
SLY# = 0
|
SLY# = 0
|
||||||
SLI# = 0
|
SLI# = 0
|
||||||
REM The two eraser stamps. Declared here for exactly the same reason -- built
|
REM The two eraser stamps. Declared here for exactly the same reason -- built
|
||||||
REM inside DRAWPROTOS and left undeclared, they were SHAPE:6 and SHAPE:7 inside
|
REM inside DRAWPROTOS and left undeclared, they were SHAPE:6 and SHAPE:7
|
||||||
|
REM inside
|
||||||
REM it and empty everywhere else.
|
REM it and empty everywhere else.
|
||||||
BL$ = ""
|
BL$ = ""
|
||||||
HBL$ = ""
|
HBL$ = ""
|
||||||
@@ -254,10 +255,13 @@ REM cursor through every DATA item in the program in the order they appear
|
|||||||
REM in the file, so whichever loader runs first gets the DATA that is
|
REM in the file, so whichever loader runs first gets the DATA that is
|
||||||
REM written first. The tables are written first.
|
REM written first. The tables are written first.
|
||||||
REM The text layer repaints every row it owns, opaque, so it has to be moved
|
REM The text layer repaints every row it owns, opaque, so it has to be moved
|
||||||
REM out of the way before anything drawn can be seen. Two rows at the bottom is
|
REM out of the way before anything drawn can be seen. Two rows at the bottom
|
||||||
|
REM is
|
||||||
REM enough for the final score, and hands the other thirty-five to the drawing
|
REM enough for the final score, and hands the other thirty-five to the drawing
|
||||||
REM verbs. Everything this game draws then simply stays there -- a drawing goes
|
REM verbs. Everything this game draws then simply stays there -- a drawing
|
||||||
REM into a layer the frame composites, so nothing here is captured into a sprite
|
REM goes
|
||||||
|
REM into a layer the frame composites, so nothing here is captured into a
|
||||||
|
REM sprite
|
||||||
REM and nothing is redrawn every frame.
|
REM and nothing is redrawn every frame.
|
||||||
WINDOW 0, 35, 49, 36
|
WINDOW 0, 35, 49, 36
|
||||||
|
|
||||||
@@ -293,7 +297,8 @@ ENVELOPE 0, 0, 6, 0, 4
|
|||||||
TEMPO 12
|
TEMPO 12
|
||||||
|
|
||||||
COLLISION 2, BRICKHIT
|
COLLISION 2, BRICKHIT
|
||||||
REM The stamps, once. They used to be rebuilt whenever the SSHAPE pool ran dry,
|
REM The stamps, once. They used to be rebuilt whenever the SSHAPE pool ran
|
||||||
|
REM dry,
|
||||||
REM because every frame's capture spent another slot; nothing captures now, so
|
REM because every frame's capture spent another slot; nothing captures now, so
|
||||||
REM eight slots are spent here and never again.
|
REM eight slots are spent here and never again.
|
||||||
GOSUB DRAWPROTOS
|
GOSUB DRAWPROTOS
|
||||||
@@ -374,7 +379,8 @@ COLOR 1, 1
|
|||||||
FOR K# = 0 TO 15
|
FOR K# = 0 TO 15
|
||||||
DRAW 1, 0, 130 + K# TO 67, 130 + K#
|
DRAW 1, 0, 130 + K# TO 67, 130 + K#
|
||||||
NEXT K#
|
NEXT K#
|
||||||
REM And an eighth the width of the HUD strip, for the same reason: the strip is
|
REM And an eighth the width of the HUD strip, for the same reason: the strip
|
||||||
|
REM is
|
||||||
REM rewritten whenever a number in it changes, and the old digits have to go
|
REM rewritten whenever a number in it changes, and the old digits have to go
|
||||||
REM somewhere first.
|
REM somewhere first.
|
||||||
FOR K# = 0 TO 59
|
FOR K# = 0 TO 59
|
||||||
@@ -393,7 +399,8 @@ DPLAY# = 1
|
|||||||
DHUD# = 1
|
DHUD# = 1
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
REM Take one brick off the screen: stamp the blank over it. Called when a brick
|
REM Take one brick off the screen: stamp the blank over it. Called when a
|
||||||
|
REM brick
|
||||||
REM breaks, so the field is never redrawn as a whole during play -- which is
|
REM breaks, so the field is never redrawn as a whole during play -- which is
|
||||||
REM what lets the whole live-list machinery go.
|
REM what lets the whole live-list machinery go.
|
||||||
LABEL ERASEBRICK
|
LABEL ERASEBRICK
|
||||||
@@ -444,7 +451,8 @@ WIDTH 1
|
|||||||
COLOR 0, 1 : COLOR 1, 4 : COLOR 2, 8 : COLOR 3, 5
|
COLOR 0, 1 : COLOR 1, 4 : COLOR 2, 8 : COLOR 3, 5
|
||||||
COLOR 4, 11 : COLOR 5, 16 : COLOR 6, 6
|
COLOR 4, 11 : COLOR 5, 16 : COLOR 6, 6
|
||||||
REM The old strip goes first. Nothing here clears the screen -- a drawing
|
REM The old strip goes first. Nothing here clears the screen -- a drawing
|
||||||
REM stays, which is the whole point -- so the digits that were there have to be
|
REM stays, which is the whole point -- so the digits that were there have to
|
||||||
|
REM be
|
||||||
REM stamped over before the new ones are drawn.
|
REM stamped over before the new ones are drawn.
|
||||||
Z$ = HBL$
|
Z$ = HBL$
|
||||||
GSHAPE Z$, 0, 0
|
GSHAPE Z$, 0, 0
|
||||||
@@ -495,7 +503,10 @@ IF SNDON# = 0 THEN VOL 0
|
|||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
LABEL PRESSPAUSE
|
LABEL PRESSPAUSE
|
||||||
IF STATE# = 2 THEN STATE# = 6 : GMTYP# = 0 : BAN$ = "PAUSED" : GOSUB SETBANNER : RETURN
|
IF STATE# <> 2 THEN GOTO PRESSPAUSE2
|
||||||
|
STATE# = 6 : GMTYP# = 0 : BAN$ = "PAUSED" : GOSUB SETBANNER
|
||||||
|
RETURN
|
||||||
|
LABEL PRESSPAUSE2
|
||||||
IF STATE# = 6 THEN STATE# = 2 : BAN$ = "" : GOSUB SETBANNER
|
IF STATE# = 6 THEN STATE# = 2 : BAN$ = "" : GOSUB SETBANNER
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,15 @@ static char *ENEMY_CHARACTER[GALAGA_ENEMY_KINDS] = {
|
|||||||
/* --------------------------------------------------------------- random --- */
|
/* --------------------------------------------------------------- random --- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No RND verb exists (issue #16), so the engine is the script's only source
|
* The engine is this script's source of randomness: it refreshes GAME@.ROLL%
|
||||||
* of randomness: it refreshes GAME@.RND% each frame and SELF@.RND% each call
|
* each frame and SELF@.ROLL% each call from this PRNG. A hand-rolled LCG
|
||||||
* from this PRNG. A hand-rolled LCG rather than rand() so a headless run is
|
* rather than rand() so a headless run is the same game on every libc, which
|
||||||
* the same game on every libc.
|
* is what lets interop_test.c assert exact counts. The dialect gained a native
|
||||||
|
* RND (issue #16) after this example was written; the field stays because RND
|
||||||
|
* would reintroduce exactly the per-machine variation this avoids.
|
||||||
|
*
|
||||||
|
* The BASIC-visible name is ROLL%, not RND%: host field names share a
|
||||||
|
* namespace with verbs and functions, so RND stopped being available as one.
|
||||||
*/
|
*/
|
||||||
static uint32_t PRNG_STATE = 0x12345678u;
|
static uint32_t PRNG_STATE = 0x12345678u;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ DEF DECIDEFIRE(DT%)
|
|||||||
DX% = GAME@.PLAYERX% - ACTOR@.X%
|
DX% = GAME@.PLAYERX% - ACTOR@.X%
|
||||||
IF ABS(DX%) > 140 THEN RETURN 0
|
IF ABS(DX%) > 140 THEN RETURN 0
|
||||||
IF ACTOR@.Y% > GAME@.PLAYERY% THEN RETURN 0
|
IF ACTOR@.Y% > GAME@.PLAYERY% THEN RETURN 0
|
||||||
IF SELF@.RND% < DT% * 1.5 THEN SELF@.FIRE# = 1
|
IF SELF@.ROLL% < DT% * 1.5 THEN SELF@.FIRE# = 1
|
||||||
RETURN 0
|
RETURN 0
|
||||||
|
|
||||||
REM Bee: enter, breathe in formation, occasionally dive nearly straight.
|
REM Bee: enter, breathe in formation, occasionally dive nearly straight.
|
||||||
@@ -65,7 +65,7 @@ DEF UPDATEBEE(DT%)
|
|||||||
IF (S# AND 2) > 0 THEN BEGIN
|
IF (S# AND 2) > 0 THEN BEGIN
|
||||||
ACTOR@.X% = SELF@.HOMEX% + SIN(SELF@.T% * 1.7) * 16
|
ACTOR@.X% = SELF@.HOMEX% + SIN(SELF@.T% * 1.7) * 16
|
||||||
ACTOR@.Y% = SELF@.HOMEY%
|
ACTOR@.Y% = SELF@.HOMEY%
|
||||||
IF SELF@.RND% < DT% * 0.04 THEN SELF@.STATE# = 4 : SELF@.T% = 0
|
IF SELF@.ROLL% < DT% * 0.04 THEN SELF@.STATE# = 4 : SELF@.T% = 0
|
||||||
BEND
|
BEND
|
||||||
IF (S# AND 4) > 0 THEN BEGIN
|
IF (S# AND 4) > 0 THEN BEGIN
|
||||||
R# = DIVESTEP(DT%, 130, 0.2)
|
R# = DIVESTEP(DT%, 130, 0.2)
|
||||||
@@ -85,7 +85,7 @@ DEF UPDATEBFLY(DT%)
|
|||||||
IF (S# AND 2) > 0 THEN BEGIN
|
IF (S# AND 2) > 0 THEN BEGIN
|
||||||
ACTOR@.X% = SELF@.HOMEX% + SIN(SELF@.T% * 2.1) * 24
|
ACTOR@.X% = SELF@.HOMEX% + SIN(SELF@.T% * 2.1) * 24
|
||||||
ACTOR@.Y% = SELF@.HOMEY%
|
ACTOR@.Y% = SELF@.HOMEY%
|
||||||
IF SELF@.RND% < DT% * 0.05 THEN SELF@.STATE# = 4 : SELF@.T% = 0
|
IF SELF@.ROLL% < DT% * 0.05 THEN SELF@.STATE# = 4 : SELF@.T% = 0
|
||||||
BEND
|
BEND
|
||||||
IF (S# AND 4) > 0 THEN BEGIN
|
IF (S# AND 4) > 0 THEN BEGIN
|
||||||
R# = DIVESTEP(DT%, 260, 0.1)
|
R# = DIVESTEP(DT%, 260, 0.1)
|
||||||
@@ -108,7 +108,7 @@ DEF UPDATEBOSS(DT%)
|
|||||||
IF (S# AND 2) > 0 THEN BEGIN
|
IF (S# AND 2) > 0 THEN BEGIN
|
||||||
ACTOR@.X% = SELF@.HOMEX% + SIN(SELF@.T% * 1.1) * 10
|
ACTOR@.X% = SELF@.HOMEX% + SIN(SELF@.T% * 1.1) * 10
|
||||||
ACTOR@.Y% = SELF@.HOMEY%
|
ACTOR@.Y% = SELF@.HOMEY%
|
||||||
IF SELF@.RND% < DT% * 0.03 THEN SELF@.STATE# = 4 : SELF@.T% = 0
|
IF SELF@.ROLL% < DT% * 0.03 THEN SELF@.STATE# = 4 : SELF@.T% = 0
|
||||||
BEND
|
BEND
|
||||||
IF (S# AND 4) > 0 THEN BEGIN
|
IF (S# AND 4) > 0 THEN BEGIN
|
||||||
R# = DIVESTEP(DT%, 60, 0.9)
|
R# = DIVESTEP(DT%, 60, 0.9)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ typedef struct galaga_Enemy
|
|||||||
float t; /* parametric clock for the current maneuver */
|
float t; /* parametric clock for the current maneuver */
|
||||||
int32_t hp;
|
int32_t hp;
|
||||||
int32_t fire; /* outbox: script sets 1, engine consumes */
|
int32_t fire; /* outbox: script sets 1, engine consumes */
|
||||||
float rnd; /* inbox: engine writes fresh 0..1 each call */
|
float rnd; /* inbox: fresh 0..1 each call; ROLL% in BASIC */
|
||||||
} galaga_Enemy;
|
} galaga_Enemy;
|
||||||
|
|
||||||
/** @brief Frame state every enemy may read. Bound once as GAME@. */
|
/** @brief Frame state every enemy may read. Bound once as GAME@. */
|
||||||
@@ -86,7 +86,7 @@ typedef struct galaga_Shared
|
|||||||
float playerx; /* the player actor's position, this frame */
|
float playerx; /* the player actor's position, this frame */
|
||||||
float playery;
|
float playery;
|
||||||
int32_t wave;
|
int32_t wave;
|
||||||
float rnd; /* fresh 0..1 each frame; the issue #16 route */
|
float rnd; /* fresh 0..1 each frame; ROLL% to the script */
|
||||||
} galaga_Shared;
|
} galaga_Shared;
|
||||||
|
|
||||||
/* --------------------------------------------------------------- screens --- */
|
/* --------------------------------------------------------------- screens --- */
|
||||||
|
|||||||
@@ -491,7 +491,8 @@ static akerr_ErrorContext *frame(bool *running)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The shared frame state, refreshed before any enemy thinks. The engine
|
/* The shared frame state, refreshed before any enemy thinks. The engine
|
||||||
* filling GAME@.RND% is the issue #16 route: no RND verb exists. */
|
* fills GAME@.ROLL% from its own PRNG rather than letting the script call
|
||||||
|
* the native RND, so a headless run is the same game on every machine. */
|
||||||
galaga_shared.playerx = galaga_game.player->x + 50.0f;
|
galaga_shared.playerx = galaga_game.player->x + 50.0f;
|
||||||
galaga_shared.playery = galaga_game.player->y;
|
galaga_shared.playery = galaga_game.player->y;
|
||||||
galaga_shared.rnd = galaga_random();
|
galaga_shared.rnd = galaga_random();
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ static const akbasic_HostField ENEMY_FIELDS[] = {
|
|||||||
AKBASIC_HOST_FIELD( galaga_Enemy, t, "T%", AKBASIC_HOSTFIELD_FLOAT ),
|
AKBASIC_HOST_FIELD( galaga_Enemy, t, "T%", AKBASIC_HOSTFIELD_FLOAT ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Enemy, hp, "HP#", AKBASIC_HOSTFIELD_INT32 ),
|
AKBASIC_HOST_FIELD( galaga_Enemy, hp, "HP#", AKBASIC_HOSTFIELD_INT32 ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Enemy, fire, "FIRE#", AKBASIC_HOSTFIELD_INT32 ),
|
AKBASIC_HOST_FIELD( galaga_Enemy, fire, "FIRE#", AKBASIC_HOSTFIELD_INT32 ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Enemy, rnd, "RND%", AKBASIC_HOSTFIELD_FLOAT )
|
AKBASIC_HOST_FIELD( galaga_Enemy, rnd, "ROLL%", AKBASIC_HOSTFIELD_FLOAT )
|
||||||
};
|
};
|
||||||
static const akbasic_HostType ENEMY_TYPE = {
|
static const akbasic_HostType ENEMY_TYPE = {
|
||||||
"ENEMY", sizeof(galaga_Enemy), ENEMY_FIELDS, 8
|
"ENEMY", sizeof(galaga_Enemy), ENEMY_FIELDS, 8
|
||||||
@@ -87,7 +87,7 @@ static const akbasic_HostField GAME_FIELDS[] = {
|
|||||||
AKBASIC_HOST_FIELD( galaga_Shared, playerx, "PLAYERX%", AKBASIC_HOSTFIELD_FLOAT ),
|
AKBASIC_HOST_FIELD( galaga_Shared, playerx, "PLAYERX%", AKBASIC_HOSTFIELD_FLOAT ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Shared, playery, "PLAYERY%", AKBASIC_HOSTFIELD_FLOAT ),
|
AKBASIC_HOST_FIELD( galaga_Shared, playery, "PLAYERY%", AKBASIC_HOSTFIELD_FLOAT ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Shared, wave, "WAVE#", AKBASIC_HOSTFIELD_INT32 ),
|
AKBASIC_HOST_FIELD( galaga_Shared, wave, "WAVE#", AKBASIC_HOSTFIELD_INT32 ),
|
||||||
AKBASIC_HOST_FIELD( galaga_Shared, rnd, "RND%", AKBASIC_HOSTFIELD_FLOAT )
|
AKBASIC_HOST_FIELD( galaga_Shared, rnd, "ROLL%", AKBASIC_HOSTFIELD_FLOAT )
|
||||||
};
|
};
|
||||||
static const akbasic_HostType GAME_TYPE = {
|
static const akbasic_HostType GAME_TYPE = {
|
||||||
"GAME", sizeof(galaga_Shared), GAME_FIELDS, 4
|
"GAME", sizeof(galaga_Shared), GAME_FIELDS, 4
|
||||||
|
|||||||
@@ -56,7 +56,10 @@ This is a tour of the interpreter's edges, on purpose:
|
|||||||
counterpoint: a genuine 24x21 `SPRSAV` type-in sprite, 63 bytes, which is
|
counterpoint: a genuine 24x21 `SPRSAV` type-in sprite, 63 bytes, which is
|
||||||
everything `DATA` has room to say. The paint is the reveal, and the exit is a
|
everything `DATA` has room to say. The paint is the reveal, and the exit is a
|
||||||
stride-63 column dissolve — 63 is coprime to 160, so the walk hits every
|
stride-63 column dissolve — 63 is coprime to 160, so the walk hits every
|
||||||
column once and looks random while carrying no state.
|
column once and looks random while carrying no state. The strings come in
|
||||||
|
64-character chunks because a source line is 80 columns, like the machines
|
||||||
|
this pretends to be — the decoder carries its cursor from one `IM$` entry to
|
||||||
|
the next, and the generator refuses to cut inside a run.
|
||||||
- **And then the picture is video.** Six delta frames loop the floor grid toward
|
- **And then the picture is video.** Six delta frames loop the floor grid toward
|
||||||
you and crawl the sun's slice pattern — full motion video, 1.3 KB total, about
|
you and crawl the sun's slice pattern — full motion video, 1.3 KB total, about
|
||||||
220 bytes a frame. A delta re-encodes only the rows that changed: an `R`
|
220 bytes a frame. A delta re-encodes only the rows that changed: an `R`
|
||||||
@@ -82,6 +85,10 @@ This is a tour of the interpreter's edges, on purpose:
|
|||||||
batch a bar of noise drums. Noise is real: `ENVELOPE`'s sixth argument is a
|
batch a bar of noise drums. Noise is real: `ENVELOPE`'s sixth argument is a
|
||||||
waveform, 0 to 3, which Chapter 7 forgot to mention. Voice 1 carries the tune so
|
waveform, 0 to 3, which Chapter 7 forgot to mention. Voice 1 carries the tune so
|
||||||
the collision blips (voice 2) and scene sweeps (voice 3) never steal its channel.
|
the collision blips (voice 2) and scene sweeps (voice 3) never steal its channel.
|
||||||
|
A batch is four `PLAY` statements, one bar each — the 80-column line limit will
|
||||||
|
not hold four bars in one string, and it does not need to: the parser's voice,
|
||||||
|
envelope and duration state persists across statements and every `PLAY` appends
|
||||||
|
to the same queue, so four bars queue exactly as one line would.
|
||||||
|
|
||||||
It also probes for its hardware like a proper boot loader, with one `TRAP` per
|
It also probes for its hardware like a proper boot loader, with one `TRAP` per
|
||||||
device: no graphics refuses by name and exits, no audio mutes the soundtrack, no
|
device: no graphics refuses by name and exits, no audio mutes the soundtrack, no
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ REM A demoscene production for the akbasic interpreter, written as if
|
|||||||
REM it were 1985 and this dialect were the machine under the tree.
|
REM it were 1985 and this dialect were the machine under the tree.
|
||||||
REM It leans on every corner of the interpreter on purpose:
|
REM It leans on every corner of the interpreter on purpose:
|
||||||
REM
|
REM
|
||||||
REM - there is no RND, so it carries chapter 17's LCG and seeds it
|
REM - it carries chapter 17's LCG rather than the native RND, and seeds it
|
||||||
REM from the jiffy clock
|
REM from the jiffy clock
|
||||||
REM - the palette cannot be rewritten, so every "colour cycle" is an
|
REM - the palette cannot be rewritten, so every "colour cycle" is an
|
||||||
REM honest redraw of the same strokes in the next colour
|
REM honest redraw of the same strokes in the next colour
|
||||||
@@ -81,7 +81,7 @@ REM machine and a predeclared scratch variable occupies one forever,
|
|||||||
REM where a scoped one gives its slot back. The first cut of this
|
REM where a scoped one gives its slot back. The first cut of this
|
||||||
REM program predeclared everything and ran the pool dry.
|
REM program predeclared everything and ran the pool dry.
|
||||||
RMAX# = 0
|
RMAX# = 0
|
||||||
RND# = 0
|
ROLL# = 0
|
||||||
TX% = 0
|
TX% = 0
|
||||||
TB# = 0
|
TB# = 0
|
||||||
|
|
||||||
@@ -461,38 +461,78 @@ BS% = W# / 160
|
|||||||
IF BS% < 1 THEN BS% = 1
|
IF BS% < 1 THEN BS% = 1
|
||||||
REM ---- PICTURE-BEGIN (generated by vaporwave.py; do not
|
REM ---- PICTURE-BEGIN (generated by vaporwave.py; do not
|
||||||
REM ---- hand-edit -- rerun the script to change the picture)
|
REM ---- hand-edit -- rerun the script to change the picture)
|
||||||
DIM IM$(16)
|
DIM IM$(56)
|
||||||
DIM VA#(6)
|
DIM VA#(6)
|
||||||
DIM VB#(6)
|
DIM VB#(6)
|
||||||
NS# = 9
|
NS# = 32
|
||||||
VA#(0) = 9
|
VA#(0) = 32
|
||||||
VB#(0) = 9
|
VB#(0) = 35
|
||||||
VA#(1) = 10
|
VA#(1) = 36
|
||||||
VB#(1) = 10
|
VB#(1) = 39
|
||||||
VA#(2) = 11
|
VA#(2) = 40
|
||||||
VB#(2) = 12
|
VB#(2) = 43
|
||||||
VA#(3) = 13
|
VA#(3) = 44
|
||||||
VB#(3) = 13
|
VB#(3) = 47
|
||||||
VA#(4) = 14
|
VA#(4) = 48
|
||||||
VB#(4) = 14
|
VB#(4) = 51
|
||||||
VA#(5) = 15
|
VA#(5) = 52
|
||||||
VB#(5) = 15
|
VB#(5) = 55
|
||||||
IM$(0) = "G9G9G9G9GPGHEHG9GTEHG9GTEHGPGPEHG9GTEHG9GTEHGHGXEHGTBAG8EHG9GTEHG5EHGPEHG5EHGPEHG5EHGAPAG3EHGPEHG5EHGPEHGXGHEHG5EHGPEHG5EHGFBAGIEHGPGPEHGPEHGHEHGPEHGPEHGHEHGPEHGHEHGPEHGPEHGHEHGBPAGMEHGPEHGHEHGPEHGHEHGPEHGPEHGHEHGPEHGPEHGHEHGPEHGHEPGHEHGPEH"
|
IM$(0) = "G9G9G9G9GPGHEHG9GTEHG9GTEHGPGPEHG9GTEHG9GTEHGHGXEHGTBAG8EHG9GTEH"
|
||||||
IM$(1) = "GHEPGHEHGPEHGHEPGHEHGHEGBAEHGHEHGPEHGHEPGHEHGPEHGHEHGPEHGHEPGHEHGPEHGHEPGHEHGPECPAEDGHEPGHEHGHEPGHEPGHEHGHEPGHEPGHEHGHEPGHEHGHEPGHEPGHECBAEDGHEPGHEPGHEHGHEPGHEHGHEPGHEPGHEHGHEPGHEPEPGHEPGHE5GHEPGHE5GHEHEXGHEPGHEEPAEZGHEPGHE5GHE5GHEPGHE5GHEP"
|
IM$(1) = "G5EHGPEHG5EHGPEHG5EHGAPAG3EHGPEHG5EHGPEHGXGHEHG5EHGPEHG5EHGFBAGI"
|
||||||
IM$(2) = "GHE5GHE9ETGHE9ETGHEXEHGHE9ETGHHAE9ESGHEPEPGBBAGEE9EMHOE9ETGHEHE9E7HUE9E6E9E4H0E9E3E9E3H2E9EHBAETEHKHE9ELH6E9ECKHEPEPKHE9EBH9HAE9EIKHEHEXKHE2H9HCE9EPKHE5KHEPKDH9HEKCEPKHE5KHE5KHEKH9HGEBKHEPKHEXEHKHE5KHEBH9HIEIKHEPKHEPEPKHEPKHEHKAH9HKKHEHKHEP"
|
IM$(2) = "EHGPGPEHGPEHGHEHGPEHGPEHGHEHGPEHGHEHGPEHGPEHGHEHGBPAGMEHGPEHGHEH"
|
||||||
IM$(3) = "KHEHKHEPKHEPKHH9HMEGKHEHKHEPKHEHKHEPKHEPH9HMEOKHEHKHEPKHEHKPEHKHEGH9HOKFEPKHEHKPEHKHEHKPEHKGH9HOEFKHEPKHEHKHEPKHEHKPEFH9HQKEEHKHEPKHEHKHEPKHEHKMH9HSKLEHKHEPKHEHKPEHKHEHKEH9HSEDKPEHKPEHKHEHKPEHKHEEH9HSKDEHKPEHKPKPEHKPEHKDH9HUECKHEHKPEHKHKXEH"
|
IM$(3) = "GPEHGHEHGPEHGPEHGHEHGPEHGPEHGHEHGPEHGHEPGHEHGPEHGHEPGHEHGPEHGHEP"
|
||||||
IM$(4) = "KPEDH9HUKCEHK5EHK5EHKLH9HUKKEHK5EHK5EHKCH9HWEBKPEHKXKHEHK8I9IWKZEHKPKPEHK0I9IWK7EHKHKXEHKSI9IWK9KFEHK9KOI9IWK9KNK9KOI9IWK9KNK9KOI9IWK9KNKPIHKZI9IYK6IHKHKXIHKSI9IWK9KFIHK5IHKKI9IWK9KNIHK5IHKCI9IYKPIHKXKHIHK5IHKPIHK5IHKPIHKPKPIHK0I9IWKJIHKPIH"
|
IM$(4) = "GHEHGHEGBAEHGHEHGPEHGHEPGHEHGPEHGHEHGPEHGHEPGHEHGPEHGHEPGHEHGPEC"
|
||||||
IM$(5) = "KHIHKPIHKPI9IZKBIHKHIHKPIHKHIHKPIHKKI9IWKJIHKHIHKPIHKHIHKPIHKDI9IXKPIHKHIHKHKHIHKHIPKHI9IYKCIHKPIHKHIHKPIHKHIPKHIHKPIHKHIPKHIHKPIHKHIHKPIHKHI9I9IHKHIHKPIHKHIPKHIHKHIEC9CSKDIPKHIPKHIHKHIPKHIHKEC9CSIDKHIPKHIPIPKHIPKHIFC9CQKEIHKHIPKHIHIXKHIPKG"
|
IM$(5) = "PAEDGHEPGHEHGHEPGHEPGHEHGHEPGHEPGHEHGHEPGHEHGHEPGHEPGHECBAEDGHEP"
|
||||||
IM$(6) = "C9COIFKHI5KHI5KHIPKHI5KHIPKHI5KHI5KHIPKHI5KHIPKHIXIHKHI9IDC9CMI4KHIPIPKHI6C9CKI9IDKHIHIXKHIZC9CII9IMKHI9IWC9CGI9IVI9I9I9I9IPI9I9I9I9IPQ9Q9Q9Q9QPE9E9E9E9EPE9E9E9E9EPQ9Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9"
|
IM$(6) = "GHEPGHEHGHEPGHEHGHEPGHEPGHEHGHEPGHEPEPGHEPGHE5GHEPGHE5GHEHEXGHEP"
|
||||||
IM$(7) = "Q9QPE9E9E9E9EPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9"
|
IM$(7) = "GHEEPAEZGHEPGHE5GHE5GHEPGHE5GHEPGHE5GHE9ETGHE9ETGHEXEHGHE9ETGHHA"
|
||||||
IM$(8) = "Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QP"
|
IM$(8) = "E9ESGHEPEPGBBAGEE9EMHOE9ETGHEHE9E7HUE9E6E9E4H0E9E3E9E3H2E9EHBAET"
|
||||||
IM$(9) = "RBRQ9QOKMQHK5RBSQ9QTI9IRRBXQ9QTKPQHKHQPKERBYQ9QPI9IHRB3Q9QSKAI5KHIJRB5Q9QTC9CMRB9Q9QWI9IGRCBQ9QYC9CCRCIA9A9A9A9APRCJE9E9E9E9EPRCNA9A9A9A9APRCOE9E9E9E9EPRCUA9A9A9A9APRCVE9E9E9E9EPRC5A9A9A9A9APRC7E9E9E9E9EP"
|
IM$(9) = "EHKHE9ELH6E9ECKHEPEPKHE9EBH9HAE9EIKHEHEXKHE2H9HCE9EPKHE5KHEPKDH9"
|
||||||
IM$(10) = "RBQQ9QOK9KIQHKFRBRQ9QOI9IQRBWQ9QPKLQHKHQHKPRBXQ9QTI9QLIERB2Q9QRIBKHIPKHIPKCRB4Q9QSC9CORB8Q9QVI3KHIGRCAQ9QXC9CERCJA9A9A9A9APRCKE9E9E9E9EPRCOA9A9A9A9APRCPE9E9E9E9EPRCVA9A9A9A9APRCXE9E9E9E9EPRC7A9A9A9A9APRDAE9E9E9E9EP"
|
IM$(10) = "HEKCEPKHE5KHE5KHEKH9HGEBKHEPKHEXEHKHE5KHEBH9HIEIKHEPKHEPEPKHEPKH"
|
||||||
IM$(11) = "RBPQ9QOK9KAQHKNRBQQ9QOI9IWRBVQ9QOKEQHKHQHKPQHKFRBWQ9QPI9IPRB1Q9QQKCIPKHIPKHIDRB3Q9QSC9CORB7Q9QUIWKHIPRB9Q9QWC9CGRCEA9A9A9A9APRCFE9E9E9E9EPRCGA9A9A9A9APRCHE9E9E9E9EPRCPA9A9A9A9APRCQE9E9E9E9EPRCXA9A9A9A9APRCZE9E9E9E9EPRDAA9A9A9A9APRDCE9E9E9E9"
|
IM$(11) = "EHKAH9HKKHEHKHEPKHEHKHEPKHEPKHH9HMEGKHEHKHEPKHEHKHEPKHEPH9HMEOKH"
|
||||||
IM$(12) = "EP"
|
IM$(12) = "EHKHEPKHEHKPEHKHEGH9HOKFEPKHEHKPEHKHEHKPEHKGH9HOEFKHEPKHEHKHEPKH"
|
||||||
IM$(13) = "RBOQ9QNK3QHKWRBPQ9QOI9IWRBUQ9QTKHQHKPQHKNRBVQ9QOI9IWRB0Q9QQIKKHIPKHIHKDRB1Q9QQC9CSRB2Q9QRC9CQRB6Q9QTIPKHIYRB8Q9QVC9CIRCKA9A9A9A9APRCLE9E9E9E9EPRCQA9A9A9A9APRCRE9E9E9E9EPRCZA9A9A9A9APRC1E9E9E9E9EPRDCA9A9A9A9APRDFE9E9E9E9EP"
|
IM$(13) = "EHKPEFH9HQKEEHKHEPKHEHKHEPKHEHKMH9HSKLEHKHEPKHEHKPEHKHEHKEH9HSED"
|
||||||
IM$(14) = "RBOQ9QNI9IYRBTQ9QOKEQHKPQHKVRBUQ9QTI9IRRBZQ9QTKHQHKPQHKHRB0Q9QQC9CSRB5Q9QTIHKHI5KARB7Q9QUC9CKRCBQ9QYI9ICRCHA9A9A9A9APRCIE9E9E9E9EPRCLA9A9A9A9APRCME9E9E9E9EPRCRA9A9A9A9APRCTE9E9E9E9EPRC1A9A9A9A9APRC3E9E9E9E9EPRDFA9A9A9A9APRDIE9E9E9E9EP"
|
IM$(14) = "KPEHKPEHKHEHKPEHKHEEH9HSKDEHKPEHKPKPEHKPEHKDH9HUECKHEHKPEHKHKXEH"
|
||||||
IM$(15) = "RBSQ9QTKPQHK3RBTQ9QOI9IWRBYQ9QPKDQHKPQHKHRBZQ9QTI9ILRB4Q9QSIAKHI5KHIBRB6Q9QTC9CMRCAQ9QXI9IERCEE9E9E9E9EPRCFA9A9A9A9APRCGE9E9E9E9EPRCMA9A9A9A9APRCNE9E9E9E9EPRCTA9A9A9A9APRCUE9E9E9E9EPRC3A9A9A9A9APRC5E9E9E9E9EPRDIA9A9A9A9AP"
|
IM$(15) = "KPEDH9HUKCEHK5EHK5EHKLH9HUKKEHK5EHK5EHKCH9HWEBKPEHKXKHEHK8I9IWKZ"
|
||||||
|
IM$(16) = "EHKPKPEHK0I9IWK7EHKHKXEHKSI9IWK9KFEHK9KOI9IWK9KNK9KOI9IWK9KNK9KO"
|
||||||
|
IM$(17) = "I9IWK9KNKPIHKZI9IYK6IHKHKXIHKSI9IWK9KFIHK5IHKKI9IWK9KNIHK5IHKCI9"
|
||||||
|
IM$(18) = "IYKPIHKXKHIHK5IHKPIHK5IHKPIHKPKPIHK0I9IWKJIHKPIHKHIHKPIHKPI9IZKB"
|
||||||
|
IM$(19) = "IHKHIHKPIHKHIHKPIHKKI9IWKJIHKHIHKPIHKHIHKPIHKDI9IXKPIHKHIHKHKHIH"
|
||||||
|
IM$(20) = "KHIPKHI9IYKCIHKPIHKHIHKPIHKHIPKHIHKPIHKHIPKHIHKPIHKHIHKPIHKHI9I9"
|
||||||
|
IM$(21) = "IHKHIHKPIHKHIPKHIHKHIEC9CSKDIPKHIPKHIHKHIPKHIHKEC9CSIDKHIPKHIPIP"
|
||||||
|
IM$(22) = "KHIPKHIFC9CQKEIHKHIPKHIHIXKHIPKGC9COIFKHI5KHI5KHIPKHI5KHIPKHI5KH"
|
||||||
|
IM$(23) = "I5KHIPKHI5KHIPKHIXIHKHI9IDC9CMI4KHIPIPKHI6C9CKI9IDKHIHIXKHIZC9CI"
|
||||||
|
IM$(24) = "I9IMKHI9IWC9CGI9IVI9I9I9I9IPI9I9I9I9IPQ9Q9Q9Q9QPE9E9E9E9EPE9E9E9"
|
||||||
|
IM$(25) = "E9EPQ9Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPQ9Q9Q9Q9QP"
|
||||||
|
IM$(26) = "Q9Q9Q9Q9QPQ9Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9"
|
||||||
|
IM$(27) = "Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9"
|
||||||
|
IM$(28) = "QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9"
|
||||||
|
IM$(29) = "Q9Q9Q9QPE9E9E9E9EPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9"
|
||||||
|
IM$(30) = "Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QP"
|
||||||
|
IM$(31) = "Q9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QPQ9Q9Q9Q9QP"
|
||||||
|
IM$(32) = "RBRQ9QOKMQHK5RBSQ9QTI9IRRBXQ9QTKPQHKHQPKERBYQ9QPI9IHRB3Q9QSKAI5"
|
||||||
|
IM$(33) = "KHIJRB5Q9QTC9CMRB9Q9QWI9IGRCBQ9QYC9CCRCIA9A9A9A9APRCJE9E9E9E9EP"
|
||||||
|
IM$(34) = "RCNA9A9A9A9APRCOE9E9E9E9EPRCUA9A9A9A9APRCVE9E9E9E9EPRC5A9A9A9A9"
|
||||||
|
IM$(35) = "APRC7E9E9E9E9EP"
|
||||||
|
IM$(36) = "RBQQ9QOK9KIQHKFRBRQ9QOI9IQRBWQ9QPKLQHKHQHKPRBXQ9QTI9QLIERB2Q9QR"
|
||||||
|
IM$(37) = "IBKHIPKHIPKCRB4Q9QSC9CORB8Q9QVI3KHIGRCAQ9QXC9CERCJA9A9A9A9APRCK"
|
||||||
|
IM$(38) = "E9E9E9E9EPRCOA9A9A9A9APRCPE9E9E9E9EPRCVA9A9A9A9APRCXE9E9E9E9EP"
|
||||||
|
IM$(39) = "RC7A9A9A9A9APRDAE9E9E9E9EP"
|
||||||
|
IM$(40) = "RBPQ9QOK9KAQHKNRBQQ9QOI9IWRBVQ9QOKEQHKHQHKPQHKFRBWQ9QPI9IPRB1Q9"
|
||||||
|
IM$(41) = "QQKCIPKHIPKHIDRB3Q9QSC9CORB7Q9QUIWKHIPRB9Q9QWC9CGRCEA9A9A9A9AP"
|
||||||
|
IM$(42) = "RCFE9E9E9E9EPRCGA9A9A9A9APRCHE9E9E9E9EPRCPA9A9A9A9APRCQE9E9E9E9"
|
||||||
|
IM$(43) = "EPRCXA9A9A9A9APRCZE9E9E9E9EPRDAA9A9A9A9APRDCE9E9E9E9EP"
|
||||||
|
IM$(44) = "RBOQ9QNK3QHKWRBPQ9QOI9IWRBUQ9QTKHQHKPQHKNRBVQ9QOI9IWRB0Q9QQIKKH"
|
||||||
|
IM$(45) = "IPKHIHKDRB1Q9QQC9CSRB2Q9QRC9CQRB6Q9QTIPKHIYRB8Q9QVC9CIRCKA9A9A9"
|
||||||
|
IM$(46) = "A9APRCLE9E9E9E9EPRCQA9A9A9A9APRCRE9E9E9E9EPRCZA9A9A9A9APRC1E9E9"
|
||||||
|
IM$(47) = "E9E9EPRDCA9A9A9A9APRDFE9E9E9E9EP"
|
||||||
|
IM$(48) = "RBOQ9QNI9IYRBTQ9QOKEQHKPQHKVRBUQ9QTI9IRRBZQ9QTKHQHKPQHKHRB0Q9QQ"
|
||||||
|
IM$(49) = "C9CSRB5Q9QTIHKHI5KARB7Q9QUC9CKRCBQ9QYI9ICRCHA9A9A9A9APRCIE9E9E9"
|
||||||
|
IM$(50) = "E9EPRCLA9A9A9A9APRCME9E9E9E9EPRCRA9A9A9A9APRCTE9E9E9E9EPRC1A9A9"
|
||||||
|
IM$(51) = "A9A9APRC3E9E9E9E9EPRDFA9A9A9A9APRDIE9E9E9E9EP"
|
||||||
|
IM$(52) = "RBSQ9QTKPQHK3RBTQ9QOI9IWRBYQ9QPKDQHKPQHKHRBZQ9QTI9ILRB4Q9QSIAKH"
|
||||||
|
IM$(53) = "I5KHIBRB6Q9QTC9CMRCAQ9QXI9IERCEE9E9E9E9EPRCFA9A9A9A9APRCGE9E9E9"
|
||||||
|
IM$(54) = "E9EPRCMA9A9A9A9APRCNE9E9E9E9EPRCTA9A9A9A9APRCUE9E9E9E9EPRC3A9A9"
|
||||||
|
IM$(55) = "A9A9APRC5E9E9E9E9EPRDIA9A9A9A9AP"
|
||||||
REM ---- PICTURE-END
|
REM ---- PICTURE-END
|
||||||
SS# = 0
|
SS# = 0
|
||||||
SE# = NS# - 1
|
SE# = NS# - 1
|
||||||
@@ -776,11 +816,12 @@ REM =====================================================================
|
|||||||
REM Subroutines.
|
REM Subroutines.
|
||||||
REM =====================================================================
|
REM =====================================================================
|
||||||
|
|
||||||
REM Chapter 17's generator, verbatim: there is no RND in this dialect.
|
REM Chapter 17's historical generator, verbatim. RND(n) is built in now;
|
||||||
REM Answers 0 to RMAX#-1 in RND#, from the middle bits of the seed.
|
REM this stays so the demo runs identically on every machine.
|
||||||
|
REM Answers 0 to RMAX#-1 in ROLL#, from the middle bits of the seed.
|
||||||
LABEL RANDOM
|
LABEL RANDOM
|
||||||
SEED# = MOD(((SEED# * 1103515245) + 12345), 2147483648)
|
SEED# = MOD(((SEED# * 1103515245) + 12345), 2147483648)
|
||||||
RND# = MOD((SEED# / 65536), RMAX#)
|
ROLL# = MOD((SEED# / 65536), RMAX#)
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
REM NS# stars in four brightnesses. Two LCG pulls a star, and the
|
REM NS# stars in four brightnesses. Two LCG pulls a star, and the
|
||||||
@@ -790,10 +831,10 @@ SI# = 0
|
|||||||
DO WHILE SI# < NS#
|
DO WHILE SI# < NS#
|
||||||
RMAX# = W#
|
RMAX# = W#
|
||||||
GOSUB RANDOM
|
GOSUB RANDOM
|
||||||
X# = RND#
|
X# = ROLL#
|
||||||
RMAX# = H#
|
RMAX# = H#
|
||||||
GOSUB RANDOM
|
GOSUB RANDOM
|
||||||
Y# = RND#
|
Y# = ROLL#
|
||||||
B# = MOD(SEED#, 4)
|
B# = MOD(SEED#, 4)
|
||||||
COLOR 1, STC#(B#)
|
COLOR 1, STC#(B#)
|
||||||
DRAW 1, X#, Y#
|
DRAW 1, X#, Y#
|
||||||
@@ -1251,7 +1292,7 @@ LABEL REHOME
|
|||||||
MOVSPR L2#, 0.5 * W#, 0.5 * H#
|
MOVSPR L2#, 0.5 * W#, 0.5 * H#
|
||||||
RMAX# = 360
|
RMAX# = 360
|
||||||
GOSUB RANDOM
|
GOSUB RANDOM
|
||||||
SBG#(L2#) = RND#
|
SBG#(L2#) = ROLL#
|
||||||
MOVSPR L2#, SBG#(L2#) # 5
|
MOVSPR L2#, SBG#(L2#) # 5
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
@@ -1317,13 +1358,25 @@ TB# = TB# + 1
|
|||||||
IF TB# > 2 THEN TB# = 0
|
IF TB# > 2 THEN TB# = 0
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
|
REM A batch is four PLAY statements, one bar each: the parser's V, T,
|
||||||
|
REM U and duration state persists across statements and every PLAY
|
||||||
|
REM appends to the same queue, so four bars queue exactly as one long
|
||||||
|
REM string would -- which the 80-column line limit no longer allows.
|
||||||
|
REM Each bar restates the prefix anyway, so a bar dropped by QFULL
|
||||||
|
REM never leaves the next one playing with drum-kit state.
|
||||||
LABEL TUNEA
|
LABEL TUNEA
|
||||||
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CO4AE O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A O1CO2CO3CO2CO3CEGO4CO1CO2CO3EGO4CEGO5C O1GO2GO3GO2GO3GBO4DGO1GO2GO3BO4DGBO5DO4B"
|
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CO4AE"
|
||||||
|
PLAY "V1T3U9S O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A"
|
||||||
|
PLAY "V1T3U9S O1CO2CO3CO2CO3CEGO4CO1CO2CO3EGO4CEGO5C"
|
||||||
|
PLAY "V1T3U9S O1GO2GO3GO2GO3GBO4DGO1GO2GO3BO4DGBO5DO4B"
|
||||||
MT# = TI# + 270
|
MT# = TI# + 270
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
LABEL TUNEB
|
LABEL TUNEB
|
||||||
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CEO4A O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A O1DO2DO3DO2DO3DFAO4DO1DO2DO3FAO4DFAO5D O1EO2EO3EO2EO3E#GBO4EO1EO2EO3#GBO4E#GBO5E"
|
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CEO4A"
|
||||||
|
PLAY "V1T3U9S O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A"
|
||||||
|
PLAY "V1T3U9S O1DO2DO3DO2DO3DFAO4DO1DO2DO3FAO4DFAO5D"
|
||||||
|
PLAY "V1T3U9S O1EO2EO3EO2EO3E#GBO4EO1EO2EO3#GBO4E#GBO5E"
|
||||||
MT# = TI# + 270
|
MT# = TI# + 270
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,14 @@ SKIP = "Q"
|
|||||||
ROWREC = "R"
|
ROWREC = "R"
|
||||||
LENCH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
LENCH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
MAXRUN = len(LENCH)
|
MAXRUN = len(LENCH)
|
||||||
PAYLOAD = 240
|
|
||||||
|
# The interpreter reads source through an 80-byte line buffer and refuses
|
||||||
|
# any line that fills it (AKBASIC_MAX_LINE_LENGTH, sink_stdio.c), so a
|
||||||
|
# stored line is at most 78 characters plus its newline. 'IM$(NN) = "' and
|
||||||
|
# the closing quote spend 12 of those; 64 keeps the emitted lines under
|
||||||
|
# the ceiling with margin to spare while the index stays two digits.
|
||||||
|
PAYLOAD = 64
|
||||||
|
MAXLINE = 78
|
||||||
|
|
||||||
SUN_CX, SUN_CY, SUN_R = 80, 50, 30
|
SUN_CX, SUN_CY, SUN_R = 80, 50, 30
|
||||||
HORIZON = 74
|
HORIZON = 74
|
||||||
@@ -206,13 +213,32 @@ def encode_delta(prev, cur):
|
|||||||
|
|
||||||
|
|
||||||
def chop(blob):
|
def chop(blob):
|
||||||
return [blob[i:i + PAYLOAD] for i in range(0, len(blob), PAYLOAD)]
|
"""Split a stream into strings of at most PAYLOAD characters, cutting
|
||||||
|
only between records. The decoder reads a record's tail characters
|
||||||
|
with MID on the string it is walking, so a run (two characters) or a
|
||||||
|
row record (three) that straddled two IM$ entries would decode as
|
||||||
|
garbage; DRAWSTREAM only carries the cursor, never a partial record."""
|
||||||
|
out, cur = [], ""
|
||||||
|
p = 0
|
||||||
|
while p < len(blob):
|
||||||
|
n = 3 if blob[p] == ROWREC else 2
|
||||||
|
if len(cur) + n > PAYLOAD:
|
||||||
|
out.append(cur)
|
||||||
|
cur = ""
|
||||||
|
cur += blob[p:p + n]
|
||||||
|
p += n
|
||||||
|
if cur:
|
||||||
|
out.append(cur)
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
def simulate(raster, blob):
|
def simulate(raster, blob, x=0, y=0):
|
||||||
"""Apply one encoded stream to a raster exactly the way the BASIC
|
"""Apply one encoded stream to a raster exactly the way the BASIC
|
||||||
decoder does, skips-draw-nothing and all."""
|
decoder does, skips-draw-nothing and all. The cursor comes in and
|
||||||
x = y = p = 0
|
goes back out because DRAWSTREAM carries it from one IM$ entry to
|
||||||
|
the next -- decoding the chopped strings one at a time with the
|
||||||
|
cursor threaded through is exactly what the demo will execute."""
|
||||||
|
p = 0
|
||||||
while p < len(blob):
|
while p < len(blob):
|
||||||
c = blob[p]
|
c = blob[p]
|
||||||
if c == ROWREC:
|
if c == ROWREC:
|
||||||
@@ -230,20 +256,31 @@ def simulate(raster, blob):
|
|||||||
x = 0
|
x = 0
|
||||||
y += 1
|
y += 1
|
||||||
p += 2
|
p += 2
|
||||||
|
return raster, x, y
|
||||||
|
|
||||||
|
|
||||||
|
def simulate_lines(raster, lines):
|
||||||
|
"""One stream as its chopped strings, cursor carried across the
|
||||||
|
boundaries the way DRAWSTREAM carries X# and Y#."""
|
||||||
|
x = y = 0
|
||||||
|
for line in lines:
|
||||||
|
raster, x, y = simulate(raster, line, x, y)
|
||||||
return raster
|
return raster
|
||||||
|
|
||||||
|
|
||||||
def verify(frames, base_blob, delta_blobs):
|
def verify(frames, base_lines, delta_line_groups):
|
||||||
"""The base must reproduce frame 0 exactly, and each delta must
|
"""The base must reproduce frame 0 exactly, and each delta must
|
||||||
carry the raster exactly to the next frame. A skip leaves the cell
|
carry the raster exactly to the next frame. A skip leaves the cell
|
||||||
the encoder promised was already right, so equality is total and
|
the encoder promised was already right, so equality is total and
|
||||||
any difference at all is an encoder bug."""
|
any difference at all is an encoder bug. This decodes the CHOPPED
|
||||||
|
strings, not the blobs, so a chop that split a record would fail
|
||||||
|
here instead of corrupting the screen."""
|
||||||
raster = [[1] * W for _ in range(H)]
|
raster = [[1] * W for _ in range(H)]
|
||||||
raster = simulate(raster, base_blob)
|
raster = simulate_lines(raster, base_lines)
|
||||||
assert raster == frames[0], "base stream does not reproduce frame 0"
|
assert raster == frames[0], "base stream does not reproduce frame 0"
|
||||||
for i, blob in enumerate(delta_blobs):
|
for i, lines in enumerate(delta_line_groups):
|
||||||
want = frames[(i + 1) % PHASES]
|
want = frames[(i + 1) % PHASES]
|
||||||
raster = simulate(raster, blob)
|
raster = simulate_lines(raster, lines)
|
||||||
assert raster == want, "delta %d does not reproduce its frame" % i
|
assert raster == want, "delta %d does not reproduce its frame" % i
|
||||||
|
|
||||||
|
|
||||||
@@ -261,6 +298,9 @@ def emit_block(base_lines, delta_ranges, all_lines):
|
|||||||
for i, s in enumerate(all_lines):
|
for i, s in enumerate(all_lines):
|
||||||
out.append('IM$(%d) = "%s"' % (i, s))
|
out.append('IM$(%d) = "%s"' % (i, s))
|
||||||
out.append("REM ---- PICTURE-END")
|
out.append("REM ---- PICTURE-END")
|
||||||
|
for line in out:
|
||||||
|
assert len(line) <= MAXLINE, "emitted line over %d chars: %r" % (
|
||||||
|
MAXLINE, line)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
@@ -303,15 +343,15 @@ def main():
|
|||||||
base_lines = chop(base_blob)
|
base_lines = chop(base_blob)
|
||||||
all_lines = list(base_lines)
|
all_lines = list(base_lines)
|
||||||
delta_ranges = []
|
delta_ranges = []
|
||||||
delta_blobs = []
|
delta_line_groups = []
|
||||||
for i in range(PHASES):
|
for i in range(PHASES):
|
||||||
blob = encode_delta(frames[i], frames[(i + 1) % PHASES])
|
blob = encode_delta(frames[i], frames[(i + 1) % PHASES])
|
||||||
delta_blobs.append(blob)
|
|
||||||
lines = chop(blob)
|
lines = chop(blob)
|
||||||
|
delta_line_groups.append(lines)
|
||||||
delta_ranges.append((len(all_lines), len(all_lines) + len(lines) - 1))
|
delta_ranges.append((len(all_lines), len(all_lines) + len(lines) - 1))
|
||||||
all_lines.extend(lines)
|
all_lines.extend(lines)
|
||||||
verify(frames, base_blob, delta_blobs)
|
verify(frames, base_lines, delta_line_groups)
|
||||||
dbytes = sum(len(b) for b in delta_blobs)
|
dbytes = sum(len(l) for g in delta_line_groups for l in g)
|
||||||
print("base %d bytes in %d strings; video %d bytes in %d strings; "
|
print("base %d bytes in %d strings; video %d bytes in %d strings; "
|
||||||
"%d strings total" %
|
"%d strings total" %
|
||||||
(sum(len(s) for s in base_lines), len(base_lines), dbytes,
|
(sum(len(s) for s in base_lines), len(base_lines), dbytes,
|
||||||
|
|||||||
@@ -12,9 +12,12 @@
|
|||||||
* libakerror 2.0.0 is the floor, raised from 1.0.0 because 2.0.0 is an ABI break
|
* libakerror 2.0.0 is the floor, raised from 1.0.0 because 2.0.0 is an ABI break
|
||||||
* that a compile against the wrong header cannot survive quietly:
|
* that a compile against the wrong header cannot survive quietly:
|
||||||
*
|
*
|
||||||
* - `__akerr_last_ignored` became thread-local. `IGNORE` expands at *our* call
|
* - The context behind `IGNORE` became thread-local. `IGNORE` expands at *our*
|
||||||
* site, so our objects reference that symbol under whichever storage model
|
* call site, so our objects reference that storage under whichever model the
|
||||||
* the header on the include path declared.
|
* header on the include path declared. 2.0.2 went further and made it a
|
||||||
|
* per-translation-unit `static` snapshot named `akerr_last_ignored`, copied
|
||||||
|
* from the pool slot so the slot can be released; the old spelling
|
||||||
|
* `__akerr_last_ignored` was an `extern` pointer and no longer exists.
|
||||||
* - `akerr_next_error()` now returns a context that already holds a reference,
|
* - `akerr_next_error()` now returns a context that already holds a reference,
|
||||||
* and `ENSURE_ERROR_READY` no longer increments. Objects compiled against a
|
* and `ENSURE_ERROR_READY` no longer increments. Objects compiled against a
|
||||||
* 1.x header count every reference twice and never give a slot back.
|
* 1.x header count every reference twice and never give a slot back.
|
||||||
|
|||||||
@@ -252,6 +252,11 @@ typedef struct akbasic_Runtime
|
|||||||
*/
|
*/
|
||||||
int64_t timems;
|
int64_t timems;
|
||||||
|
|
||||||
|
/* RND's lazy seed state. The flag distinguishes an unseeded run from a
|
||||||
|
* legitimate LCG state of zero. */
|
||||||
|
int64_t rndseed;
|
||||||
|
bool rndseeded;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set by a branch that has decided the remaining statements on its line
|
* Set by a branch that has decided the remaining statements on its line
|
||||||
* belong to the arm it did not take, and cleared at the top of every line.
|
* belong to the arm it did not take, and cleared at the top of every line.
|
||||||
|
|||||||
@@ -282,9 +282,8 @@ def copy_tree(src, dst):
|
|||||||
# and a coverage tree drags along every .gcno/.gcda as well.
|
# and a coverage tree drags along every .gcno/.gcda as well.
|
||||||
#
|
#
|
||||||
# deps/ is copied wholesale and has to be: the build pulls libakerror and
|
# deps/ is copied wholesale and has to be: the build pulls libakerror and
|
||||||
# libakstdlib in with add_subdirectory. The golden corpus used to be the
|
# libakstdlib in with add_subdirectory. The language corpus is the other
|
||||||
# other reason -- it was driven in place out of deps/basicinterpret -- and
|
# reason it comes along with the rest of the tree.
|
||||||
# now lives in tests/reference/, which comes along with the rest of the tree.
|
|
||||||
# Only vendored Windows DLLs are dead weight, hence "*.dll".
|
# Only vendored Windows DLLs are dead weight, hence "*.dll".
|
||||||
#
|
#
|
||||||
# **PNGs are ours or theirs, and the difference matters.** This used to drop
|
# **PNGs are ours or theirs, and the difference matters.** This used to drop
|
||||||
|
|||||||
@@ -893,7 +893,7 @@ akerr_ErrorContext *akbasic_runtime_interpret(akbasic_Runtime *obj, akbasic_ASTL
|
|||||||
*
|
*
|
||||||
* **Only a block skip**, which is what the `BEND` test is for. A
|
* **Only a block skip**, which is what the `BEND` test is for. A
|
||||||
* zero-iteration `FOR` skips its body the same way, and there the
|
* zero-iteration `FOR` skips its body the same way, and there the
|
||||||
* orphan is load-bearing: `tests/reference/.../nestedforloopwaiting
|
* orphan is load-bearing: `tests/language/.../nestedforloopwaiting
|
||||||
* forcommand.bas` nests a loop inside one that runs zero times, and
|
* forcommand.bas` nests a loop inside one that runs zero times, and
|
||||||
* the inner scope is what absorbs the inner `NEXT` so the outer `NEXT`
|
* the inner scope is what absorbs the inner `NEXT` so the outer `NEXT`
|
||||||
* still finds its `FOR`. Popping it there turns that case into "NEXT
|
* still finds its `FOR`. Popping it there turns that case into "NEXT
|
||||||
@@ -1286,7 +1286,7 @@ akerr_ErrorContext *akbasic_runtime_process_line_runstream(akbasic_Runtime *obj)
|
|||||||
* This mode used to file it like any other, under the cursor -- which for a
|
* This mode used to file it like any other, under the cursor -- which for a
|
||||||
* blank line is the number of the line *before* it. A file ending in a blank
|
* blank line is the number of the line *before* it. A file ending in a blank
|
||||||
* line therefore had its last line erased before it ever ran, silently. The
|
* line therefore had its last line erased before it ever ran, silently. The
|
||||||
* reference did the same, and `tests/reference/language/arithmetic/integer.bas`
|
* reference did the same, and `tests/language/arithmetic/integer.bas`
|
||||||
* has an expectation with three values for four PRINT statements to prove it.
|
* has an expectation with three values for four PRINT statements to prove it.
|
||||||
*/
|
*/
|
||||||
if ( buffer[0] == '\0' ) {
|
if ( buffer[0] == '\0' ) {
|
||||||
|
|||||||
@@ -407,17 +407,22 @@ akerr_ErrorContext *akbasic_cmd_directory(akbasic_Runtime *obj, akbasic_ASTLeaf
|
|||||||
FAIL_ZERO_RETURN(errctx, (obj != NULL && dest != NULL), AKERR_NULLPOINTER,
|
FAIL_ZERO_RETURN(errctx, (obj != NULL && dest != NULL), AKERR_NULLPOINTER,
|
||||||
"NULL argument in DIRECTORY");
|
"NULL argument in DIRECTORY");
|
||||||
/*
|
/*
|
||||||
* Refused rather than half-built. Listing a directory needs opendir/readdir,
|
* Refused rather than half-built. This was blocked upstream: listing a
|
||||||
* which `libakstdlib` does not wrap -- and this project's rule is that a
|
* directory needs opendir/readdir, `libakstdlib` did not wrap them, and
|
||||||
* missing capability gets filed upstream rather than worked around here
|
* this project's rule is that a missing capability gets filed upstream
|
||||||
* (MAINTENANCE.md). Filed as libakstdlib issue #10.
|
* rather than worked around here (MAINTENANCE.md). That was libakstdlib
|
||||||
|
* issue #10, and it landed -- aksl_opendir, aksl_readdir, aksl_closedir
|
||||||
|
* and aksl_rewinddir all exist as of the revision this tree pins.
|
||||||
*
|
*
|
||||||
* The alternative was shelling out to `ls`, which a library has no business
|
* So the blocker is gone and only the work is left. Writing the verb needs
|
||||||
* doing, or calling readdir directly and stepping outside the error
|
* decisions this commit is not the place for: what a listing looks like on
|
||||||
* convention every other call in this file follows.
|
* a filesystem with no disk-image block counts, which of the Commodore
|
||||||
|
* wildcard forms to honour, and where the entries go. Tracked as akbasic
|
||||||
|
* issue #55; the refusal stays honest until then rather than growing a
|
||||||
|
* half-listing nobody specified.
|
||||||
*/
|
*/
|
||||||
FAIL_RETURN(errctx, AKBASIC_ERR_DEVICE,
|
FAIL_RETURN(errctx, AKBASIC_ERR_DEVICE,
|
||||||
"DIRECTORY is not implemented: libakstdlib has no directory-reading wrapper yet");
|
"DIRECTORY is not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ BSAVE/BLOAD -- */
|
/* ------------------------------------------------------------ BSAVE/BLOAD -- */
|
||||||
|
|||||||
@@ -183,6 +183,69 @@ akerr_ErrorContext *akbasic_fn_chr(akbasic_Runtime *obj, akbasic_ASTLeaf *expr,
|
|||||||
SUCCEED_RETURN(errctx);
|
SUCCEED_RETURN(errctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
akerr_ErrorContext *akbasic_fn_asc(akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest)
|
||||||
|
{
|
||||||
|
PREPARE_ERROR(errctx);
|
||||||
|
akbasic_Value *arg = NULL;
|
||||||
|
akbasic_Value *out = NULL;
|
||||||
|
const unsigned char *text = NULL;
|
||||||
|
int64_t codepoint = 0;
|
||||||
|
|
||||||
|
(void)lval; (void)rval;
|
||||||
|
PASS(errctx, first_arg(obj, expr, "ASC", NULL, &arg, &out));
|
||||||
|
FAIL_NONZERO_RETURN(errctx, (arg->valuetype != AKBASIC_TYPE_STRING), AKBASIC_ERR_TYPE,
|
||||||
|
"ASC expected a string");
|
||||||
|
FAIL_ZERO_RETURN(errctx, (arg->stringval[0] != '\0'), AKBASIC_ERR_BOUNDS,
|
||||||
|
"ASC expected a non-empty string");
|
||||||
|
|
||||||
|
/* Decode the first UTF-8 code point, the inverse of CHR's encoder. */
|
||||||
|
text = (const unsigned char *)arg->stringval;
|
||||||
|
if ( text[0] < 0x80 ) {
|
||||||
|
codepoint = text[0];
|
||||||
|
} else if ( (text[0] & 0xE0) == 0xC0 ) {
|
||||||
|
codepoint = ((int64_t)(text[0] & 0x1F) << 6) |
|
||||||
|
(text[1] & 0x3F);
|
||||||
|
} else if ( (text[0] & 0xF0) == 0xE0 ) {
|
||||||
|
codepoint = ((int64_t)(text[0] & 0x0F) << 12) |
|
||||||
|
((int64_t)(text[1] & 0x3F) << 6) |
|
||||||
|
(text[2] & 0x3F);
|
||||||
|
} else {
|
||||||
|
codepoint = ((int64_t)(text[0] & 0x07) << 18) |
|
||||||
|
((int64_t)(text[1] & 0x3F) << 12) |
|
||||||
|
((int64_t)(text[2] & 0x3F) << 6) |
|
||||||
|
(text[3] & 0x3F);
|
||||||
|
}
|
||||||
|
out->valuetype = AKBASIC_TYPE_INTEGER;
|
||||||
|
out->intval = codepoint;
|
||||||
|
*dest = out;
|
||||||
|
SUCCEED_RETURN(errctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
akerr_ErrorContext *akbasic_fn_rnd(akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest)
|
||||||
|
{
|
||||||
|
PREPARE_ERROR(errctx);
|
||||||
|
akbasic_Value *arg = NULL;
|
||||||
|
akbasic_Value *out = NULL;
|
||||||
|
const int64_t modulus = 2147483648;
|
||||||
|
|
||||||
|
(void)lval; (void)rval;
|
||||||
|
PASS(errctx, first_arg(obj, expr, "RND", NULL, &arg, &out));
|
||||||
|
FAIL_NONZERO_RETURN(errctx, (arg->valuetype != AKBASIC_TYPE_INTEGER), AKBASIC_ERR_TYPE,
|
||||||
|
"RND expected an integer");
|
||||||
|
FAIL_ZERO_RETURN(errctx, (arg->intval > 0), AKBASIC_ERR_VALUE,
|
||||||
|
"RND count %" PRId64 " must be positive", arg->intval);
|
||||||
|
|
||||||
|
if ( !obj->rndseeded ) {
|
||||||
|
obj->rndseed = obj->timems % modulus;
|
||||||
|
obj->rndseeded = true;
|
||||||
|
}
|
||||||
|
obj->rndseed = (obj->rndseed * 1103515245 + 12345) % modulus;
|
||||||
|
out->valuetype = AKBASIC_TYPE_INTEGER;
|
||||||
|
out->intval = (obj->rndseed / 65536) % arg->intval;
|
||||||
|
*dest = out;
|
||||||
|
SUCCEED_RETURN(errctx);
|
||||||
|
}
|
||||||
|
|
||||||
akerr_ErrorContext *akbasic_fn_hex(akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest)
|
akerr_ErrorContext *akbasic_fn_hex(akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest)
|
||||||
{
|
{
|
||||||
PREPARE_ERROR(errctx);
|
PREPARE_ERROR(errctx);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ static const akbasic_Verb VERBS[] = {
|
|||||||
{ "ABS", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_abs },
|
{ "ABS", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_abs },
|
||||||
{ "AND", AKBASIC_TOK_AND, -1, NULL, NULL },
|
{ "AND", AKBASIC_TOK_AND, -1, NULL, NULL },
|
||||||
{ "APPEND", AKBASIC_TOK_COMMAND, -1, akbasic_parse_arglist, akbasic_cmd_append },
|
{ "APPEND", AKBASIC_TOK_COMMAND, -1, akbasic_parse_arglist, akbasic_cmd_append },
|
||||||
|
{ "ASC", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_asc },
|
||||||
{ "ATN", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_atn },
|
{ "ATN", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_atn },
|
||||||
{ "AUTO", AKBASIC_TOK_COMMAND_IMMEDIATE, -1, NULL, akbasic_cmd_auto },
|
{ "AUTO", AKBASIC_TOK_COMMAND_IMMEDIATE, -1, NULL, akbasic_cmd_auto },
|
||||||
{ "BACKUP", AKBASIC_TOK_COMMAND, -1, akbasic_parse_optional_arglist, akbasic_cmd_backup },
|
{ "BACKUP", AKBASIC_TOK_COMMAND, -1, akbasic_parse_optional_arglist, akbasic_cmd_backup },
|
||||||
@@ -146,6 +147,7 @@ static const akbasic_Verb VERBS[] = {
|
|||||||
{ "RGR", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_rgr },
|
{ "RGR", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_rgr },
|
||||||
{ "RIGHT", AKBASIC_TOK_FUNCTION, 2, NULL, akbasic_fn_right },
|
{ "RIGHT", AKBASIC_TOK_FUNCTION, 2, NULL, akbasic_fn_right },
|
||||||
{ "RMENU", AKBASIC_TOK_FUNCTION, 2, NULL, akbasic_fn_rmenu },
|
{ "RMENU", AKBASIC_TOK_FUNCTION, 2, NULL, akbasic_fn_rmenu },
|
||||||
|
{ "RND", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_rnd },
|
||||||
{ "RSPCOLOR", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_rspcolor },
|
{ "RSPCOLOR", AKBASIC_TOK_FUNCTION, 1, NULL, akbasic_fn_rspcolor },
|
||||||
{ "RSPHIT", AKBASIC_TOK_FUNCTION, 2, NULL, akbasic_fn_rsphit },
|
{ "RSPHIT", AKBASIC_TOK_FUNCTION, 2, NULL, akbasic_fn_rsphit },
|
||||||
{ "RSPPOS", AKBASIC_TOK_FUNCTION, 2, NULL, akbasic_fn_rsppos },
|
{ "RSPPOS", AKBASIC_TOK_FUNCTION, 2, NULL, akbasic_fn_rsppos },
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ akerr_ErrorContext AKERR_NOIGNORE *akbasic_cmd_stop(struct akbasic_Runtime *obj,
|
|||||||
|
|
||||||
/* Function handlers -- src/runtime_functions.c */
|
/* Function handlers -- src/runtime_functions.c */
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_abs(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_abs(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_asc(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_atn(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_atn(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_chr(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_chr(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_cos(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_cos(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
@@ -154,6 +155,7 @@ akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_peek(struct akbasic_Runtime *obj,
|
|||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_pointer(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_pointer(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_pointervar(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_pointervar(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_rad(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_rad(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_rnd(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_right(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_right(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_sgn(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_sgn(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_shl(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_fn_shl(struct akbasic_Runtime *obj, akbasic_ASTLeaf *expr, akbasic_Value *lval, akbasic_Value *rval, akbasic_Value **dest);
|
||||||
|
|||||||
@@ -244,10 +244,16 @@ static void test_no_drive_verbs(void)
|
|||||||
harness_stop();
|
harness_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DIRECTORY is refused for a different reason, and says which. */
|
/*
|
||||||
|
* DIRECTORY is refused for a different reason than the five above: not for
|
||||||
|
* want of a drive, but because it is unwritten. It used to name the missing
|
||||||
|
* libakstdlib wrapper; that wrapper landed, so naming it would be a lie.
|
||||||
|
*/
|
||||||
TEST_REQUIRE_OK(run_program("10 DIRECTORY\n"));
|
TEST_REQUIRE_OK(run_program("10 DIRECTORY\n"));
|
||||||
TEST_REQUIRE(strstr(HARNESS_OUTPUT, "libakstdlib") != NULL,
|
TEST_REQUIRE(strstr(HARNESS_OUTPUT, "not implemented") != NULL,
|
||||||
"DIRECTORY should name the missing wrapper, got \"%s\"", HARNESS_OUTPUT);
|
"DIRECTORY should say it is unwritten, got \"%s\"", HARNESS_OUTPUT);
|
||||||
|
TEST_REQUIRE(strstr(HARNESS_OUTPUT, "libakstdlib") == NULL,
|
||||||
|
"DIRECTORY must not still blame libakstdlib, got \"%s\"", HARNESS_OUTPUT);
|
||||||
harness_stop();
|
harness_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ static void test_counter_survives_the_loop(void)
|
|||||||
* `FOR I = 1 TO 1` executes the body one time on every BASIC there has ever
|
* `FOR I = 1 TO 1` executes the body one time on every BASIC there has ever
|
||||||
* been. Here the entry test treats "the counter has reached the limit" as
|
* been. Here the entry test treats "the counter has reached the limit" as
|
||||||
* "do not enter", so the body is skipped entirely -- and
|
* "do not enter", so the body is skipped entirely -- and
|
||||||
* tests/reference/language/flowcontrol/forloopwaitingforcommand.bas pins that,
|
* tests/language/flowcontrol/forloopwaitingforcommand.bas pins that,
|
||||||
* which is why this cannot simply be corrected.
|
* which is why this cannot simply be corrected.
|
||||||
*/
|
*/
|
||||||
static void test_single_iteration_loop(void)
|
static void test_single_iteration_loop(void)
|
||||||
|
|||||||
16
tests/language/README.md
Normal file
16
tests/language/README.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# The language test corpus
|
||||||
|
|
||||||
|
The `.bas` files in this directory and their sibling `.txt` files are the editable language
|
||||||
|
corpus. CMake registers every program as an individual `local_*` CTest case and compares its
|
||||||
|
output with the sibling expectation.
|
||||||
|
|
||||||
|
The corpus includes cases carried over from the deprecated Go implementation as well as cases
|
||||||
|
written for this interpreter. Their provenance is useful when investigating a regression, but it
|
||||||
|
does not make any case immutable or turn the old implementation into a specification.
|
||||||
|
|
||||||
|
**Change a program and its expectation deliberately and in the same commit.** If the changed
|
||||||
|
output represents an intentional language decision, record the reason in `TODO.md` or the
|
||||||
|
relevant documentation. If it is an accidental change, fix the interpreter instead.
|
||||||
|
|
||||||
|
The `examples/` subdirectory contains complete BASIC programs used as worked examples. It is
|
||||||
|
part of the same corpus and follows the same `.bas`/`.txt` pairing rule.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
10 REM An array reference used as a function argument, and as one of several.
|
10 REM An array reference used as a function argument, and as one of several.
|
||||||
20 REM An identifier's subscript list used to hang off .right, which is also
|
20 REM An identifier's subscript list used to hang off .right, which is also
|
||||||
30 REM where an argument list chains its arguments -- so the arity counter walked
|
30 REM where arguments chain their arguments -- so the arity counter walked
|
||||||
40 REM straight into the subscripts and refused the call. TODO.md section 4.
|
40 REM straight into the subscripts and refused the call. TODO.md section 4.
|
||||||
50 DIM C#(4)
|
50 DIM C#(4)
|
||||||
60 C#(1) = -9
|
60 C#(1) = -9
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
10 REM FILTER has no device capability behind it -- akgl_audio_* synthesises and
|
10 REM FILTER has no device capability -- audio synthesises and mixes but
|
||||||
20 REM mixes but has no filter stage, and SDL3 supplies no primitive to build one
|
20 REM has no filter stage; SDL3 supplies no primitive to build one from. It
|
||||||
30 REM from. It is refused rather than silently ignored, so a program that asked
|
30 REM is refused rather than silently ignored, so a program that asked
|
||||||
40 REM for a low-pass finds out it did not get one.
|
40 REM for a low-pass finds out it did not get one.
|
||||||
50 PRINT "BEFORE"
|
50 PRINT "BEFORE"
|
||||||
60 FILTER 1000, 1, 0, 0, 5
|
60 FILTER 1000, 1, 0, 0, 5
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
10 REM The standalone driver lends the script no audio device. ENVELOPE, VOL and
|
10 REM The standalone driver has no audio device. ENVELOPE, VOL and
|
||||||
20 REM TEMPO only change interpreter state, so they work regardless; SOUND and
|
20 REM TEMPO only change interpreter state, so they work regardless; SOUND and
|
||||||
30 REM PLAY need the device and must name themselves when there is none.
|
30 REM PLAY need the device and must name themselves when there is none.
|
||||||
40 ENVELOPE 1, 5, 9, 12, 2
|
40 ENVELOPE 1, 5, 9, 12, 2
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
10 REM This shows the waitingForCommand utility in the BasicEnvironment
|
10 REM This shows the waitingForCommand utility in the BasicEnvironment
|
||||||
11 REM when we have a nested for loop. The inner loop SHOULD execute, but
|
11 REM when we have a nested for loop. The inner loop SHOULD execute, but
|
||||||
12 REM the outer loop should NOT execute. Therefore, neither loop should execute.
|
12 REM the outer loop should NOT execute. Neither loop should execute.
|
||||||
20 FOR I# = 1 TO 0
|
20 FOR I# = 1 TO 0
|
||||||
25 FOR J# = 2 TO 4
|
25 FOR J# = 2 TO 4
|
||||||
30 PRINT "waitingForCommand FAILS if this is seen"
|
30 PRINT "waitingForCommand FAILS if this is seen"
|
||||||
@@ -8,4 +8,4 @@
|
|||||||
35 NEXT J#
|
35 NEXT J#
|
||||||
40 NEXT I#
|
40 NEXT I#
|
||||||
50 PRINT "SUCCESS"
|
50 PRINT "SUCCESS"
|
||||||
80 QUIT
|
80 QUIT
|
||||||
3
tests/language/functions/asc.bas
Normal file
3
tests/language/functions/asc.bas
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
10 PRINT "97 : " + ASC("a")
|
||||||
|
20 PRINT "65 : " + ASC("A")
|
||||||
|
30 PRINT "64 : " + ASC("@")
|
||||||
3
tests/language/functions/asc.txt
Normal file
3
tests/language/functions/asc.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
97 : 97
|
||||||
|
65 : 65
|
||||||
|
64 : 64
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
10 PRINT MOD(10, 3)
|
10 PRINT MOD(10, 3)
|
||||||
20 PRINT MOD(12, 5)
|
20 PRINT MOD(12, 5)
|
||||||
30 PRINT MOD(4, 2)
|
30 PRINT MOD(4, 2)
|
||||||
40 REM MOD() ONLY WORKS WITH INTEGERS - RESULTS WITH FLOATING POINT ARE UNRELIABLE
|
40 REM MOD() ONLY WORKS WITH INTEGERS - FLOATING-POINT RESULTS ARE UNRELIABLE
|
||||||
50 REM PRINT MOD(1.2, 0.4)
|
50 REM PRINT MOD(1.2, 0.4)
|
||||||
60 REM THERE IS NO ERROR THROWN HERE. JUST DONT DO IT.
|
60 REM THERE IS NO ERROR THROWN HERE. JUST DONT DO IT.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
10 REM A DEF call takes its environment from the pool, one per call, exactly as
|
10 REM A DEF call takes an environment from the pool, one per call, exactly as
|
||||||
20 REM GOSUB does. It used to be owned by the funcdef and reset on every call,
|
20 REM GOSUB does. It used to be owned by the funcdef and reset on every call,
|
||||||
30 REM which cost two silent defects: two calls in one expression shared a slot,
|
30 REM which cost two silent defects: two calls shared a slot,
|
||||||
40 REM and recursion never came back at all.
|
40 REM and recursion never came back at all.
|
||||||
50 DEF FACT(N#)
|
50 DEF FACT(N#)
|
||||||
60 IF N# <= 1 THEN RETURN 1
|
60 IF N# <= 1 THEN RETURN 1
|
||||||
@@ -15,9 +15,9 @@
|
|||||||
150 DEF DBL(N#) = N# * 2
|
150 DEF DBL(N#) = N# * 2
|
||||||
160 PRINT DBL(10) + DBL(1)
|
160 PRINT DBL(10) + DBL(1)
|
||||||
170 PRINT DBL(1) + DBL(10) + DBL(100)
|
170 PRINT DBL(1) + DBL(10) + DBL(100)
|
||||||
180 REM Depth answers to the environment pool now, so runaway recursion reports
|
180 REM Depth answers to the pool, so runaway recursion reports
|
||||||
190 REM "Environment pool exhausted" rather than hanging. It is not exercised here
|
190 REM "Environment pool exhausted" rather than hanging. It is not exercised
|
||||||
200 REM because the statement containing a failed call still prints a junk value
|
200 REM here because a failed call's statement still prints a junk value
|
||||||
210 REM afterwards -- a separate, pre-existing defect recorded in TODO.md, and one
|
210 REM afterwards -- a TODO.md defect this file would pin
|
||||||
220 REM this golden file would pin if it went in. tests/user_functions.c asserts
|
220 REM if it went in. tests/user_functions.c asserts
|
||||||
230 REM the message instead.
|
230 REM the message instead.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user