Unbreak the three example programs the RND merge left behind
All checks were successful
akbasic CI Build / cmake_build (push) Successful in 3m46s
akbasic CI Build / coverage (push) Successful in 4m16s
akbasic CI Build / sanitizers (push) Successful in 8m10s
akbasic CI Build / akgl_build (push) Successful in 8m10s
akbasic CI Build / mutation_test (push) Successful in 17m55s
All checks were successful
akbasic CI Build / cmake_build (push) Successful in 3m46s
akbasic CI Build / coverage (push) Successful in 4m16s
akbasic CI Build / sanitizers (push) Successful in 8m10s
akbasic CI Build / akgl_build (push) Successful in 8m10s
akbasic CI Build / mutation_test (push) Successful in 17m55s
Adding native RND and ASC (ae2c702) made RND a function name, and a suffixed
identifier that collides with one is refused -- "SYNTAX ERROR Reserved word in
variable name". Three example programs held their PRNG output in a variable
called RND#, or a host field called RND%, and none of them had run since:
- examples/galaga/ bound RND% as a host field on both ENEMY and GAME. The
BASIC-visible name is ROLL% now; the C member stays `rnd`. This one was
caught by example_galaga and example_galaga_interop, which have been
failing.
- examples/breakout/characters/breakout.bas and examples/megademo/
megademo.bas both use RND# for their LCG output, renamed to ROLL#. Neither
is in any test, so neither failure was visible.
examples/breakout/sprites/breakout.bas was broken a second way: seven REM lines
the reader refuses. Worth recording that the ceiling is not the one the message
names -- src/sink_stdio.c fails when the read filled the buffer without seeing
a terminator, so with AKBASIC_MAX_LINE_LENGTH at 80 the message says "79
character limit" and the real maximum is 78, because a 79-character line leaves
no room for the newline. The sweeps that fixed the corpus and the megademo for
this did not reach this file. The seven comments are reflowed.
The prose went stale with the code. Chapter 21 said "there is no RND verb in
this dialect; issue #16 tracks adding one", chapter 17's historical aside
offered an LCG that no longer parses, and four REM blocks across the two games
said the same thing. All of them now say RND exists, and say why these programs
keep their own generator anyway: the sequence has to be reproducible for a
headless run to be the same game on every machine, which is what lets
interop_test.c assert exact counts.
Chapter 21 also gains the rule that bit them, since a reader writing a host
type will hit it: a host field name is a bare word and shares a namespace with
every verb and function.
None of this came from the submodule bump -- all three were already broken on
main. It was found by running the tutorial games, which nothing else does;
that gap is akbasic issue #58.
Verified: all three run clean under the dummy drivers, and 114/114 default,
116/116 with akgl.
Co-Authored-By: Andrew Kesterson <andrew@aklabs.net>
Co-Authored-By: Claude Code (Claude Opus 5, claude-opus-5[1m]) <noreply@anthropic.com>
This commit is contained in:
@@ -241,7 +241,8 @@ SLX# = 0
|
||||
SLY# = 0
|
||||
SLI# = 0
|
||||
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.
|
||||
BL$ = ""
|
||||
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 written first. The tables are written first.
|
||||
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 verbs. Everything this game draws then simply stays there -- a drawing goes
|
||||
REM into a layer the frame composites, so nothing here is captured into a sprite
|
||||
REM verbs. Everything this game draws then simply stays there -- a drawing
|
||||
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.
|
||||
WINDOW 0, 35, 49, 36
|
||||
|
||||
@@ -293,7 +297,8 @@ ENVELOPE 0, 0, 6, 0, 4
|
||||
TEMPO 12
|
||||
|
||||
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 eight slots are spent here and never again.
|
||||
GOSUB DRAWPROTOS
|
||||
@@ -374,7 +379,8 @@ COLOR 1, 1
|
||||
FOR K# = 0 TO 15
|
||||
DRAW 1, 0, 130 + K# TO 67, 130 + 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 somewhere first.
|
||||
FOR K# = 0 TO 59
|
||||
@@ -393,7 +399,8 @@ DPLAY# = 1
|
||||
DHUD# = 1
|
||||
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 what lets the whole live-list machinery go.
|
||||
LABEL ERASEBRICK
|
||||
@@ -444,7 +451,8 @@ WIDTH 1
|
||||
COLOR 0, 1 : COLOR 1, 4 : COLOR 2, 8 : COLOR 3, 5
|
||||
COLOR 4, 11 : COLOR 5, 16 : COLOR 6, 6
|
||||
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.
|
||||
Z$ = HBL$
|
||||
GSHAPE Z$, 0, 0
|
||||
@@ -495,7 +503,10 @@ IF SNDON# = 0 THEN VOL 0
|
||||
RETURN
|
||||
|
||||
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
|
||||
RETURN
|
||||
|
||||
|
||||
Reference in New Issue
Block a user