Compare commits
1 Commits
bd63e3e9fa
...
16
| Author | SHA1 | Date | |
|---|---|---|---|
| 699ac9ab93 |
@@ -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. |
|
||||||
|
|||||||
@@ -685,9 +685,9 @@ seconds asks for fifty frames a second.
|
|||||||
### Why `GOTO` rather than `DO ... LOOP`
|
### Why `GOTO` rather than `DO ... LOOP`
|
||||||
|
|
||||||
A `DO ... LOOP` around the frame would read better, and it is not usable here: **a `GOTO`
|
A `DO ... LOOP` around the frame would read better, and it is not usable here: **a `GOTO`
|
||||||
that jumps out of a `FOR` or a `DO` does not release the loop's scope.** There are 12
|
that jumps out of a `FOR` or a `DO` does not release the loop's scope.** There are 32
|
||||||
scopes, so a game that leaves its main loop once per lost life stops on the
|
scopes, so a game that leaves its main loop once per lost life stops on the
|
||||||
twelfth one:
|
thirty-second one:
|
||||||
|
|
||||||
```basic
|
```basic
|
||||||
N# = 0
|
N# = 0
|
||||||
@@ -700,7 +700,7 @@ PRINT "SURVIVED " + N#
|
|||||||
```
|
```
|
||||||
|
|
||||||
```output
|
```output
|
||||||
? 3 : PARSE ERROR Environment pool exhausted at line 3 (12 in use)
|
? 3 : PARSE ERROR Environment pool exhausted at line 3 (32 in use)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1005,20 +1005,48 @@ 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
|
||||||
|
I# = 0
|
||||||
|
FOR I# = 1 TO 5
|
||||||
|
PRINT "ROLL " + (RND(6) + 1)
|
||||||
|
NEXT I#
|
||||||
|
END
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `RND` for the serve, too, so the ball does not always leave in the same direction:
|
||||||
|
|
||||||
|
```basic norun
|
||||||
|
LABEL SERVE
|
||||||
|
PX# = (SCW# - PW#) / 2
|
||||||
|
HELD# = 1
|
||||||
|
BX# = PX# + ((PW# / 2) - 4)
|
||||||
|
BY# = PY# - 10
|
||||||
|
BVX# = BSPD#
|
||||||
|
IF RND(2) = 0 THEN BVX# = 0 - BSPD#
|
||||||
|
BVY# = 0 - BSPD#
|
||||||
|
PDEC# = 0
|
||||||
|
GOSUB SHOWSPR
|
||||||
|
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
|
SEED# = 12345
|
||||||
RMAX# = 6
|
RMAX# = 6
|
||||||
RND# = 0
|
RND# = 0
|
||||||
@@ -1035,43 +1063,11 @@ RND# = MOD((SEED# / 65536), RMAX#)
|
|||||||
RETURN
|
RETURN
|
||||||
```
|
```
|
||||||
|
|
||||||
```output
|
The multiplication stays inside a 64-bit integer for any seed below 2147483648. The
|
||||||
ROLL 1
|
answer is taken from the middle bits because the low bits of a power-of-two modulus
|
||||||
ROLL 5
|
barely change from one call to the next. This used to be required; it is now built in.
|
||||||
ROLL 2
|
|
||||||
ROLL 1
|
|
||||||
ROLL 2
|
|
||||||
```
|
|
||||||
|
|
||||||
The multiplication stays inside a 64-bit integer for any seed below 2147483648, which is
|
</details>
|
||||||
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
|
|
||||||
LABEL SERVE
|
|
||||||
PX# = (SCW# - PW#) / 2
|
|
||||||
HELD# = 1
|
|
||||||
BX# = PX# + ((PW# / 2) - 4)
|
|
||||||
BY# = PY# - 10
|
|
||||||
RMAX# = 2
|
|
||||||
GOSUB RANDOM
|
|
||||||
BVX# = BSPD#
|
|
||||||
IF RND# = 0 THEN BVX# = 0 - BSPD#
|
|
||||||
BVY# = 0 - BSPD#
|
|
||||||
PDEC# = 0
|
|
||||||
GOSUB SHOWSPR
|
|
||||||
RETURN
|
|
||||||
```
|
|
||||||
|
|
||||||
`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,8 +1423,7 @@ IF STATE# = 2 THEN GOSUB UNSTICK
|
|||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
LABEL PRESSPAUSE
|
LABEL PRESSPAUSE
|
||||||
IF STATE# = 2 THEN STATE# = 6 : GMTYP# = 0 : BAN$ = "PAUSED"
|
IF STATE# = 2 THEN STATE# = 6 : GMTYP# = 0 : BAN$ = "PAUSED" : GOSUB SETBANNER : RETURN
|
||||||
IF STATE# = 6 THEN GOSUB SETBANNER : RETURN
|
|
||||||
IF STATE# = 6 THEN STATE# = 2 : BAN$ = "" : GOSUB SETBANNER
|
IF STATE# = 6 THEN STATE# = 2 : BAN$ = "" : GOSUB SETBANNER
|
||||||
RETURN
|
RETURN
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -56,10 +56,7 @@ 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. The strings come in
|
column once and looks random while carrying no state.
|
||||||
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`
|
||||||
@@ -85,10 +82,6 @@ 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
|
||||||
|
|||||||
@@ -461,78 +461,38 @@ 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$(56)
|
DIM IM$(16)
|
||||||
DIM VA#(6)
|
DIM VA#(6)
|
||||||
DIM VB#(6)
|
DIM VB#(6)
|
||||||
NS# = 32
|
NS# = 9
|
||||||
VA#(0) = 32
|
VA#(0) = 9
|
||||||
VB#(0) = 35
|
VB#(0) = 9
|
||||||
VA#(1) = 36
|
VA#(1) = 10
|
||||||
VB#(1) = 39
|
VB#(1) = 10
|
||||||
VA#(2) = 40
|
VA#(2) = 11
|
||||||
VB#(2) = 43
|
VB#(2) = 12
|
||||||
VA#(3) = 44
|
VA#(3) = 13
|
||||||
VB#(3) = 47
|
VB#(3) = 13
|
||||||
VA#(4) = 48
|
VA#(4) = 14
|
||||||
VB#(4) = 51
|
VB#(4) = 14
|
||||||
VA#(5) = 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9E9EPRCTA9A9A9A9APRCUE9E9E9E9EPRC3A9A9"
|
|
||||||
IM$(55) = "A9A9APRC5E9E9E9E9EPRDIA9A9A9A9AP"
|
|
||||||
REM ---- PICTURE-END
|
REM ---- PICTURE-END
|
||||||
SS# = 0
|
SS# = 0
|
||||||
SE# = NS# - 1
|
SE# = NS# - 1
|
||||||
@@ -1357,25 +1317,13 @@ 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"
|
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CO4AE O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A O1CO2CO3CO2CO3CEGO4CO1CO2CO3EGO4CEGO5C O1GO2GO3GO2GO3GBO4DGO1GO2GO3BO4DGBO5DO4B"
|
||||||
PLAY "V1T3U9S O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A"
|
|
||||||
PLAY "V1T3U9S O1CO2CO3CO2CO3CEGO4CO1CO2CO3EGO4CEGO5C"
|
|
||||||
PLAY "V1T3U9S O1GO2GO3GO2GO3GBO4DGO1GO2GO3BO4DGBO5DO4B"
|
|
||||||
MT# = TI# + 270
|
MT# = TI# + 270
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
LABEL TUNEB
|
LABEL TUNEB
|
||||||
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CEO4A"
|
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CEO4A O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A O1DO2DO3DO2DO3DFAO4DO1DO2DO3FAO4DFAO5D O1EO2EO3EO2EO3E#GBO4EO1EO2EO3#GBO4E#GBO5E"
|
||||||
PLAY "V1T3U9S O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A"
|
|
||||||
PLAY "V1T3U9S O1DO2DO3DO2DO3DFAO4DO1DO2DO3FAO4DFAO5D"
|
|
||||||
PLAY "V1T3U9S O1EO2EO3EO2EO3E#GBO4EO1EO2EO3#GBO4E#GBO5E"
|
|
||||||
MT# = TI# + 270
|
MT# = TI# + 270
|
||||||
RETURN
|
RETURN
|
||||||
|
|
||||||
|
|||||||
@@ -58,14 +58,7 @@ 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
|
||||||
@@ -213,32 +206,13 @@ def encode_delta(prev, cur):
|
|||||||
|
|
||||||
|
|
||||||
def chop(blob):
|
def chop(blob):
|
||||||
"""Split a stream into strings of at most PAYLOAD characters, cutting
|
return [blob[i:i + PAYLOAD] for i in range(0, len(blob), PAYLOAD)]
|
||||||
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, x=0, y=0):
|
def simulate(raster, blob):
|
||||||
"""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. The cursor comes in and
|
decoder does, skips-draw-nothing and all."""
|
||||||
goes back out because DRAWSTREAM carries it from one IM$ entry to
|
x = y = p = 0
|
||||||
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:
|
||||||
@@ -256,31 +230,20 @@ def simulate(raster, blob, x=0, y=0):
|
|||||||
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_lines, delta_line_groups):
|
def verify(frames, base_blob, delta_blobs):
|
||||||
"""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. This decodes the CHOPPED
|
any difference at all is an encoder bug."""
|
||||||
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_lines(raster, base_lines)
|
raster = simulate(raster, base_blob)
|
||||||
assert raster == frames[0], "base stream does not reproduce frame 0"
|
assert raster == frames[0], "base stream does not reproduce frame 0"
|
||||||
for i, lines in enumerate(delta_line_groups):
|
for i, blob in enumerate(delta_blobs):
|
||||||
want = frames[(i + 1) % PHASES]
|
want = frames[(i + 1) % PHASES]
|
||||||
raster = simulate_lines(raster, lines)
|
raster = simulate(raster, blob)
|
||||||
assert raster == want, "delta %d does not reproduce its frame" % i
|
assert raster == want, "delta %d does not reproduce its frame" % i
|
||||||
|
|
||||||
|
|
||||||
@@ -298,9 +261,6 @@ 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
|
||||||
|
|
||||||
|
|
||||||
@@ -343,15 +303,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_line_groups = []
|
delta_blobs = []
|
||||||
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_lines, delta_line_groups)
|
verify(frames, base_blob, delta_blobs)
|
||||||
dbytes = sum(len(l) for g in delta_line_groups for l in g)
|
dbytes = sum(len(b) for b in delta_blobs)
|
||||||
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,
|
||||||
|
|||||||
@@ -211,12 +211,8 @@ typedef struct akbasic_Runtime
|
|||||||
* not exist relative to the working directory, which is what makes a `.bas`
|
* not exist relative to the working directory, which is what makes a `.bas`
|
||||||
* beside its art work from anywhere. Group F's disk verbs will want the
|
* beside its art work from anywhere. Group F's disk verbs will want the
|
||||||
* same, which is why it is on the runtime rather than in the sprite state.
|
* same, which is why it is on the runtime rather than in the sprite state.
|
||||||
*
|
|
||||||
* Sized to AKBASIC_MAX_SOURCE_PATH_LENGTH, not AKBASIC_MAX_LINE_LENGTH: a
|
|
||||||
* directory is a filesystem path, not a line of BASIC, and the two do not
|
|
||||||
* belong to the same budget.
|
|
||||||
*/
|
*/
|
||||||
char sourcepath[AKBASIC_MAX_SOURCE_PATH_LENGTH];
|
char sourcepath[AKBASIC_MAX_LINE_LENGTH];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The armed interrupts, and the environment the one currently running was
|
* The armed interrupts, and the environment the one currently running was
|
||||||
@@ -252,6 +248,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.
|
||||||
@@ -369,7 +370,7 @@ akerr_ErrorContext AKERR_NOIGNORE *akbasic_runtime_set_ui(akbasic_Runtime *obj,
|
|||||||
* @param path Path to the program file, or NULL for none.
|
* @param path Path to the program file, or NULL for none.
|
||||||
* @return `NULL` on success, otherwise an error context owned by the caller.
|
* @return `NULL` on success, otherwise an error context owned by the caller.
|
||||||
* @throws AKERR_NULLPOINTER When `obj` is NULL.
|
* @throws AKERR_NULLPOINTER When `obj` is NULL.
|
||||||
* @throws AKBASIC_ERR_BOUNDS When the path is longer than AKBASIC_MAX_SOURCE_PATH_LENGTH.
|
* @throws AKBASIC_ERR_BOUNDS When the path is longer than AKBASIC_MAX_LINE_LENGTH.
|
||||||
*/
|
*/
|
||||||
akerr_ErrorContext AKERR_NOIGNORE *akbasic_runtime_set_source_path(akbasic_Runtime *obj, const char *path);
|
akerr_ErrorContext AKERR_NOIGNORE *akbasic_runtime_set_source_path(akbasic_Runtime *obj, const char *path);
|
||||||
|
|
||||||
|
|||||||
@@ -23,17 +23,9 @@
|
|||||||
* serves variables, functions and labels. Capacity is a member; the table is
|
* serves variables, functions and labels. Capacity is a member; the table is
|
||||||
* kept below a 75% load factor by construction because `capacity` counts slots
|
* kept below a 75% load factor by construction because `capacity` counts slots
|
||||||
* and the caller's logical maximum is smaller.
|
* and the caller's logical maximum is smaller.
|
||||||
*
|
|
||||||
* 172 rather than the old 256: no caller passes akbasic_symtab_init() anything
|
|
||||||
* larger than AKBASIC_MAX_VARIABLES (128), and 172 keeps that under the 75%
|
|
||||||
* load factor the comment above promises (128 / 0.75 = 170.7).
|
|
||||||
*
|
|
||||||
* AKBASIC_SYMTAB_MAX_KEY 24 rather than 64: the longest identifier across
|
|
||||||
* examples/breakout and examples/megademo -- variables, DIMmed arrays, labels
|
|
||||||
* and DEF FN names alike -- is 11 characters (TITLESCREEN, CLEARPOWERS).
|
|
||||||
*/
|
*/
|
||||||
#define AKBASIC_SYMTAB_MAX_SLOTS 172
|
#define AKBASIC_SYMTAB_MAX_SLOTS 256
|
||||||
#define AKBASIC_SYMTAB_MAX_KEY 24
|
#define AKBASIC_SYMTAB_MAX_KEY 64
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#ifndef _AKBASIC_TYPES_H_
|
#ifndef _AKBASIC_TYPES_H_
|
||||||
#define _AKBASIC_TYPES_H_
|
#define _AKBASIC_TYPES_H_
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -28,39 +27,15 @@
|
|||||||
#define AKBASIC_MAX_VALUES 64
|
#define AKBASIC_MAX_VALUES 64
|
||||||
#define AKBASIC_MAX_VARIABLES 128
|
#define AKBASIC_MAX_VARIABLES 128
|
||||||
|
|
||||||
/*
|
/* Whole-runtime pools */
|
||||||
* Whole-runtime pools.
|
#define AKBASIC_MAX_SOURCE_LINES 9999
|
||||||
*
|
#define AKBASIC_MAX_LINE_LENGTH 256
|
||||||
* AKBASIC_MAX_SOURCE_LINES, AKBASIC_MAX_LINE_LENGTH, AKBASIC_MAX_ARRAY_VALUES,
|
|
||||||
* AKBASIC_MAX_ENVIRONMENTS and AKBASIC_MAX_FUNCTIONS were cut from their
|
|
||||||
* original values against measurements taken off examples/breakout and
|
|
||||||
* examples/megademo, the two most demanding programs this interpreter runs --
|
|
||||||
* see the memory-footprint discussion this commit's PR body links. Each is
|
|
||||||
* sized at roughly 1.5-2x the peak the reference corpus actually reaches, not
|
|
||||||
* at the peak itself.
|
|
||||||
*
|
|
||||||
* AKBASIC_MAX_LINE_LENGTH in particular follows Commodore BASIC's own 80-column
|
|
||||||
* line limit rather than a measurement, which is why sink_stdio.c now refuses a
|
|
||||||
* line that fills the buffer with no terminator instead of silently truncating
|
|
||||||
* it: at 256 bytes that failure mode was theoretical, and at 80 it is not.
|
|
||||||
*
|
|
||||||
* AKBASIC_MAX_SOURCE_PATH_LENGTH is its own constant rather than a reuse of
|
|
||||||
* AKBASIC_MAX_LINE_LENGTH, which is where it used to come from. `sourcepath`
|
|
||||||
* (runtime.h) holds a directory, not a line of BASIC, and the two ideas do not
|
|
||||||
* scale together: shrinking the line limit to 80 broke every golden test in
|
|
||||||
* this checkout, because this repository's own working directory is deeper
|
|
||||||
* than that. PATH_MAX is the actual bound a filesystem path is subject to, so
|
|
||||||
* it is the one this borrows.
|
|
||||||
*/
|
|
||||||
#define AKBASIC_MAX_SOURCE_LINES 2048
|
|
||||||
#define AKBASIC_MAX_LINE_LENGTH 80 /* Commodore BASIC's own line limit */
|
|
||||||
#define AKBASIC_MAX_SOURCE_PATH_LENGTH PATH_MAX
|
|
||||||
#define AKBASIC_MAX_ARRAY_DEPTH 64 /* dimensions per array */
|
#define AKBASIC_MAX_ARRAY_DEPTH 64 /* dimensions per array */
|
||||||
#define AKBASIC_MAX_ARRAY_ELEMENTS 1024 /* elements in one array */
|
#define AKBASIC_MAX_ARRAY_ELEMENTS 1024 /* elements in one array */
|
||||||
#define AKBASIC_MAX_ARRAY_VALUES 2048 /* array elements across all variables */
|
#define AKBASIC_MAX_ARRAY_VALUES 4096 /* array elements across all variables */
|
||||||
#define AKBASIC_MAX_STRING_LENGTH 256 /* see TODO.md 1.2 */
|
#define AKBASIC_MAX_STRING_LENGTH 256 /* see TODO.md 1.2 */
|
||||||
#define AKBASIC_MAX_ENVIRONMENTS 12 /* new: Go allocated these unbounded */
|
#define AKBASIC_MAX_ENVIRONMENTS 32 /* new: Go allocated these unbounded */
|
||||||
#define AKBASIC_MAX_FUNCTIONS 8 /* new: Go used an unbounded map */
|
#define AKBASIC_MAX_FUNCTIONS 64 /* new: Go used an unbounded map */
|
||||||
#define AKBASIC_MAX_LABELS 64 /* new: Go used an unbounded map */
|
#define AKBASIC_MAX_LABELS 64 /* new: Go used an unbounded map */
|
||||||
/*
|
/*
|
||||||
* Leaves a DO/LOOP condition may use. Its own small pool rather than a second
|
* Leaves a DO/LOOP condition may use. Its own small pool rather than a second
|
||||||
|
|||||||
@@ -13,22 +13,12 @@
|
|||||||
|
|
||||||
#include <akerror.h>
|
#include <akerror.h>
|
||||||
|
|
||||||
#include <akbasic/symtab.h>
|
|
||||||
#include <akbasic/types.h>
|
#include <akbasic/types.h>
|
||||||
#include <akbasic/value.h>
|
#include <akbasic/value.h>
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/*
|
char name[AKBASIC_MAX_STRING_LENGTH];
|
||||||
* Sized to AKBASIC_SYMTAB_MAX_KEY, not AKBASIC_MAX_STRING_LENGTH: this name
|
|
||||||
* only ever gets here by surviving akbasic_symtab_set() first
|
|
||||||
* (akbasic_environment_create() calls it right after this field is
|
|
||||||
* populated), and that call refuses anything AKBASIC_SYMTAB_MAX_KEY
|
|
||||||
* characters or longer with AKBASIC_ERR_BOUNDS. A variable whose name did
|
|
||||||
* not fit could never exist, so the wider buffer was 232 bytes of headroom
|
|
||||||
* nothing could ever put a byte into.
|
|
||||||
*/
|
|
||||||
char name[AKBASIC_SYMTAB_MAX_KEY];
|
|
||||||
akbasic_Type valuetype;
|
akbasic_Type valuetype;
|
||||||
akbasic_Value *values; /** The pool, or `inlinevalue` for a scalar */
|
akbasic_Value *values; /** The pool, or `inlinevalue` for a scalar */
|
||||||
int valuecount;
|
int valuecount;
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ akerr_ErrorContext *akbasic_runtime_set_source_path(akbasic_Runtime *obj, const
|
|||||||
}
|
}
|
||||||
FAIL_ZERO_RETURN(errctx, (length < sizeof(obj->sourcepath)), AKBASIC_ERR_BOUNDS,
|
FAIL_ZERO_RETURN(errctx, (length < sizeof(obj->sourcepath)), AKBASIC_ERR_BOUNDS,
|
||||||
"Program path of %zu characters exceeds the %d character limit",
|
"Program path of %zu characters exceeds the %d character limit",
|
||||||
length, AKBASIC_MAX_SOURCE_PATH_LENGTH - 1);
|
length, AKBASIC_MAX_LINE_LENGTH - 1);
|
||||||
PASS(errctx, aksl_memcpy(obj->sourcepath, path, length));
|
PASS(errctx, aksl_memcpy(obj->sourcepath, path, length));
|
||||||
obj->sourcepath[length] = '\0';
|
obj->sourcepath[length] = '\0';
|
||||||
SUCCEED_RETURN(errctx);
|
SUCCEED_RETURN(errctx);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -74,19 +74,6 @@ static akerr_ErrorContext *stdio_readline(akbasic_TextSink *self, char *dest, si
|
|||||||
if ( *eof ) {
|
if ( *eof ) {
|
||||||
SUCCEED_RETURN(errctx);
|
SUCCEED_RETURN(errctx);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* aksl_fgets(3)'s own contract: a full buffer with no trailing newline is
|
|
||||||
* how a caller spots a line longer than the buffer, because the rest of it
|
|
||||||
* is still sitting unread in the stream. Refusing here is what makes that
|
|
||||||
* true -- without it, the unread remainder is picked up by the *next*
|
|
||||||
* readline() as if it were its own statement, which does not fail, it just
|
|
||||||
* runs the wrong program. AKBASIC_MAX_LINE_LENGTH is small enough now that
|
|
||||||
* this is not a hypothetical: examples/breakout's own longest line used to
|
|
||||||
* clear the old 256-byte ceiling by more than half.
|
|
||||||
*/
|
|
||||||
FAIL_NONZERO_RETURN(errctx, (used == len - 1 && dest[used - 1] != '\n' && dest[used - 1] != '\r'),
|
|
||||||
AKBASIC_ERR_BOUNDS,
|
|
||||||
"Source line exceeds the %zu character limit", len - 1);
|
|
||||||
/*
|
/*
|
||||||
* Strip the line terminator. The scanner treats \r and \n as end-of-line
|
* Strip the line terminator. The scanner treats \r and \n as end-of-line
|
||||||
* anyway, but leaving them on would make a stored source line differ from
|
* anyway, but leaving them on would make a stored source line differ from
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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; the arity counter walked
|
30 REM where an argument list chains its 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; akgl_audio_* synthesises and mixes but
|
10 REM FILTER has no device capability behind it -- akgl_audio_* synthesises and
|
||||||
20 REM has no filter stage, and SDL3 supplies no primitive to build one from.
|
20 REM mixes but has no filter stage, and SDL3 supplies no primitive to build one
|
||||||
30 REM It is refused rather than silently ignored, so a program that asked
|
30 REM from. It 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,
|
10 REM The standalone driver lends the script 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
|
||||||
|
|||||||
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 REM A DEF call takes one environment from the pool, exactly as
|
10 REM A DEF call takes its 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: calls in one expression shared a slot,
|
30 REM which cost two silent defects: two calls in one expression 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, so runaway recursion reports
|
180 REM Depth answers to the environment pool now, so runaway recursion reports
|
||||||
190 REM "Environment pool exhausted" rather than hanging. It is not exercised
|
190 REM "Environment pool exhausted" rather than hanging. It is not exercised here
|
||||||
200 REM here because the failed statement still prints junk afterwards;
|
200 REM because the statement containing a failed call still prints a junk value
|
||||||
210 REM this is a separate defect in TODO.md, and one this golden file
|
210 REM afterwards -- a separate, pre-existing defect recorded in TODO.md, and one
|
||||||
220 REM would pin if it went in. tests/user_functions.c asserts
|
220 REM this golden file would pin if it went in. tests/user_functions.c asserts
|
||||||
230 REM the message instead.
|
230 REM the message instead.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
10 REM A range check reported through the driver, end to end. The program
|
10 REM A range check reported through the driver, end to end. The program stops
|
||||||
20 REM at the first error, so this file covers one; the rest of the checks are
|
20 REM at the first error, so this file covers one; the rest of the checks are
|
||||||
30 REM asserted in tests/graphics_verbs.c against the recording backend.
|
30 REM asserted in tests/graphics_verbs.c against the recording backend.
|
||||||
40 PRINT "BEFORE"
|
40 PRINT "BEFORE"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
10 REM The standalone driver lends the script no graphics device.
|
10 REM The standalone driver lends the script no graphics device.
|
||||||
20 REM COLOR, LOCATE and SCALE touch interpreter state and must still work.
|
20 REM COLOR, LOCATE and SCALE only touch interpreter state and must still work.
|
||||||
30 COLOR 1, 3
|
30 COLOR 1, 3
|
||||||
40 LOCATE 40, 50
|
40 LOCATE 40, 50
|
||||||
50 SCALE 1, 640, 400
|
50 SCALE 1, 640, 400
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
10 REM Group B: housekeeping verbs. None is in the Go reference --
|
10 REM Group B: the housekeeping verbs. None of these is in the Go reference --
|
||||||
20 REM they are on its unimplemented list -- so each meaning here is
|
20 REM they are on its own unimplemented list -- so what each one means here is
|
||||||
30 REM a decision, recorded in src/runtime_housekeeping.c beside the verb.
|
30 REM a decision, recorded in src/runtime_housekeeping.c beside the verb.
|
||||||
40 A# = 1 : B# = 2
|
40 A# = 1 : B# = 2
|
||||||
50 PRINT A# : PRINT B#
|
50 PRINT A# : PRINT B#
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
110 P#(2) = 7 : Q#(2) = 9
|
110 P#(2) = 7 : Q#(2) = 9
|
||||||
120 SWAP P#, Q#
|
120 SWAP P#, Q#
|
||||||
130 PRINT P#(2) : PRINT Q#(2)
|
130 PRINT P#(2) : PRINT Q#(2)
|
||||||
140 REM TRON prints each line number inline, as a C128 does.
|
140 REM TRON prints each line number inline before the line runs, as a C128 does.
|
||||||
150 TRON
|
150 TRON
|
||||||
160 PRINT "TRACED"
|
160 PRINT "TRACED"
|
||||||
170 TROFF
|
170 TROFF
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
10 REM A leading zero is padding, not a radix. The reference selected base 8
|
10 REM A leading zero is padding, not a radix. The reference selects base 8 for
|
||||||
20 REM for lexemes starting with 0; 010 printed 8 and 08 was a parse error --
|
20 REM any lexeme starting with 0, so 010 printed 8 and 08 was a parse error --
|
||||||
30 REM TODO.md section 6 item 10 is fixed; Commodore BASIC has no octal.
|
30 REM TODO.md section 6 item 10, fixed. Commodore BASIC has no octal literals.
|
||||||
40 REM 0x is the one prefix that changes the base, and now reaches the scanner
|
40 REM 0x is the one prefix that changes the base, and it now reaches the scanner
|
||||||
50 REM whole: that was section 6 item 15.
|
50 REM whole: that was section 6 item 15.
|
||||||
60 PRINT 010
|
60 PRINT 010
|
||||||
70 PRINT 08
|
70 PRINT 08
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
10 REM A truth value carries its payload in boolvalue, not floatval. The three
|
10 REM A truth value carries its payload in boolvalue, not floatval. The three
|
||||||
20 REM numeric operators were `if ( INTEGER ) ... else <treat as float>`, and
|
20 REM numeric operators were `if ( INTEGER ) ... else <treat as float>`, and
|
||||||
30 REM that else was a catch-all, not a float branch -- so a truth value
|
30 REM that else was a catch-all rather than a float branch -- so a truth value
|
||||||
40 REM on the LEFT computed 0 - 1 into a field nothing reads, kept its BOOLEAN
|
40 REM on the LEFT computed 0 - 1 into a field nothing reads, kept its BOOLEAN
|
||||||
50 REM type, and printed `true` instead of -2. Silent, and wrong twice over.
|
50 REM type, and printed `true` instead of -2. Silent, and wrong twice over.
|
||||||
60 A# = 1
|
60 A# = 1
|
||||||
70 PRINT (A# == 1)
|
70 PRINT (A# == 1)
|
||||||
80 REM On the RIGHT it stays legal and stays -1, the same property that
|
80 REM On the RIGHT it stays legal and stays -1, which is the same property that
|
||||||
90 REM lets AND and OR act as logical operators. Refusing it would have
|
90 REM lets AND and OR double as logical operators. Refusing it here would have
|
||||||
100 REM broken every condition in the language.
|
100 REM broken every condition in the language.
|
||||||
110 PRINT 5 - (A# == 1)
|
110 PRINT 5 - (A# == 1)
|
||||||
120 PRINT 5 * (A# == 1)
|
120 PRINT 5 * (A# == 1)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
10 REM Statements separated by colons. The COLON token existed from the start;
|
10 REM Statements separated by colons. The COLON token existed from the start of
|
||||||
20 REM nothing consumed it, so a line could hold only one statement.
|
20 REM the port and nothing consumed it, so a line could hold only one statement.
|
||||||
30 PRINT "A" : PRINT "B"
|
30 PRINT "A" : PRINT "B"
|
||||||
40 A# = 1 : B# = 2 : PRINT A# + B#
|
40 A# = 1 : B# = 2 : PRINT A# + B#
|
||||||
50 REM Empty statements are valid: a trailing separator or runs of them.
|
50 REM An empty statement is not an error: a trailing separator, or a run of them.
|
||||||
60 PRINT "C" :
|
60 PRINT "C" :
|
||||||
70 PRINT "D" :: PRINT "E"
|
70 PRINT "D" :: PRINT "E"
|
||||||
80 REM Everything after THEN belongs to the condition, as in BASIC 7.0, and is
|
80 REM Everything after THEN belongs to the condition, which is BASIC 7.0 and is
|
||||||
90 REM not something the reference had an opinion about -- it never got here.
|
90 REM not something the reference had an opinion about -- it never got here.
|
||||||
100 IF 1 == 1 THEN PRINT "TRUE-1" : PRINT "TRUE-2"
|
100 IF 1 == 1 THEN PRINT "TRUE-1" : PRINT "TRUE-2"
|
||||||
110 IF 1 == 0 THEN PRINT "NEVER-1" : PRINT "NEVER-2"
|
110 IF 1 == 0 THEN PRINT "NEVER-1" : PRINT "NEVER-2"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
10 REM A field name is checked against the closed set the program declared;
|
10 REM A field name is checked against a closed set the program declared, which
|
||||||
20 REM this is the one thing whose valid spellings are written down.
|
20 REM is the one thing in this language whose valid spellings are written down.
|
||||||
30 REM A misspelled *variable* is still silent -- see the last two lines.
|
30 REM A misspelled *variable* is still silent -- see the last two lines.
|
||||||
40 TYPE RECT
|
40 TYPE RECT
|
||||||
50 W#
|
50 W#
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
170 RETURN B@.W#
|
170 RETURN B@.W#
|
||||||
180 PRINT WIDEN(A@)
|
180 PRINT WIDEN(A@)
|
||||||
190 PRINT A@.W#
|
190 PRINT A@.W#
|
||||||
200 REM To change one on purpose, pass a pointer. Assignment copies its
|
200 REM To change one on purpose, pass a pointer. Assignment copies a pointer's
|
||||||
210 REM reference, so the callee is looking at the caller's own record.
|
210 REM reference, so the callee is looking at the caller's own record.
|
||||||
220 DIM Q@ AS PTR TO CRATE
|
220 DIM Q@ AS PTR TO CRATE
|
||||||
230 POINT Q@ AT A@
|
230 POINT Q@ AT A@
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
370 N2@.COUNT# = 20
|
370 N2@.COUNT# = 20
|
||||||
380 POINT N1@.TAIL@ AT N2@
|
380 POINT N1@.TAIL@ AT N2@
|
||||||
390 DEF TOTAL(P@ AS PTR TO NODE)
|
390 DEF TOTAL(P@ AS PTR TO NODE)
|
||||||
395 REM A pointer is true when it points at something, so a walk knows
|
395 REM A pointer is true when it points at something, which is how a walk knows
|
||||||
396 REM where the list ends. NOT is the bitwise operator here, so the test is
|
396 REM where the list ends. NOT is the bitwise operator here, so the test is
|
||||||
397 REM written the positive way round.
|
397 REM written the positive way round.
|
||||||
400 IF P@->TAIL@ THEN RETURN P@->COUNT# + TOTAL(P@->TAIL@)
|
400 IF P@->TAIL@ THEN RETURN P@->COUNT# + TOTAL(P@->TAIL@)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
10 REM A TYPE declares its fields; each takes its type from its own suffix,
|
10 REM A TYPE declares its fields; each takes its own type from its own suffix,
|
||||||
20 REM which is the same rule every other name in this language follows.
|
20 REM which is the same rule every other name in this language follows.
|
||||||
30 TYPE COORD
|
30 TYPE COORD
|
||||||
40 X#
|
40 X#
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
10 REM A type name and a field name are bare words, and so is every verb, so
|
10 REM A type name and a field name are bare words, and so is every verb, so
|
||||||
20 REM they share a namespace whether we like it or not. Both are refused with
|
20 REM they share a namespace whether we like it or not. Both are refused with
|
||||||
30 REM the scanner applies the same rule to variable names -- and a type
|
30 REM the same rule the scanner already applies to variable names -- and a type
|
||||||
40 REM name is refused by the prescan, which can say so plainly rather than
|
40 REM name is refused by the prescan, which can say so plainly rather than
|
||||||
50 REM leaving the parser to report "Expected expression or literal".
|
50 REM leaving the parser to report "Expected expression or literal".
|
||||||
60 TYPE POINT
|
60 TYPE POINT
|
||||||
|
|||||||
@@ -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; neither loop should execute.
|
12 REM the outer loop should NOT execute. Therefore, 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"
|
||||||
|
|||||||
@@ -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; FLOATING POINT RESULTS ARE UNRELIABLE
|
40 REM MOD() ONLY WORKS WITH INTEGERS - RESULTS WITH FLOATING POINT 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.
|
||||||
|
|||||||
@@ -162,6 +162,26 @@ int main(void)
|
|||||||
expect_int("A# = INSTR(\"HELLO\", \"LL\")", 2);
|
expect_int("A# = INSTR(\"HELLO\", \"LL\")", 2);
|
||||||
expect_int("A# = INSTR(\"HELLO\", \"ZZ\")", -1);
|
expect_int("A# = INSTR(\"HELLO\", \"ZZ\")", -1);
|
||||||
|
|
||||||
|
/* RND auto-seeds from host time and follows the documented LCG. */
|
||||||
|
HARNESS_RUNTIME.rndseeded = false;
|
||||||
|
TEST_REQUIRE_OK(akbasic_runtime_settime(&HARNESS_RUNTIME, 12345));
|
||||||
|
expect_int("A# = RND(6)", 0);
|
||||||
|
expect_int("A# = RND(6)", 4);
|
||||||
|
expect_int("A# = RND(6)", 1);
|
||||||
|
expect_int("A# = RND(6)", 0);
|
||||||
|
expect_int("A# = RND(6)", 1);
|
||||||
|
expect_int("A# = RND(1)", 0);
|
||||||
|
TEST_REQUIRE_STATUS(eval_line("A# = RND(0)", &out), AKBASIC_ERR_VALUE);
|
||||||
|
TEST_REQUIRE_STATUS(eval_line("A# = RND(-1)", &out), AKBASIC_ERR_VALUE);
|
||||||
|
TEST_REQUIRE_STATUS(eval_line("A# = RND(\"x\")", &out), AKBASIC_ERR_TYPE);
|
||||||
|
|
||||||
|
/* ASC is the inverse of CHR for ASCII and non-ASCII code points. */
|
||||||
|
expect_int("A# = ASC(CHR(97))", 97);
|
||||||
|
expect_int("A# = ASC(\"A\")", 65);
|
||||||
|
expect_int("A# = ASC(CHR(8364))", 8364);
|
||||||
|
TEST_REQUIRE_STATUS(eval_line("A# = ASC(\"\")", &out), AKBASIC_ERR_BOUNDS);
|
||||||
|
TEST_REQUIRE_STATUS(eval_line("A# = ASC(65)", &out), AKBASIC_ERR_TYPE);
|
||||||
|
|
||||||
/* An unknown verb is diagnosed rather than silently ignored. */
|
/* An unknown verb is diagnosed rather than silently ignored. */
|
||||||
TEST_REQUIRE_OK(akbasic_environment_zero(HARNESS_RUNTIME.environment));
|
TEST_REQUIRE_OK(akbasic_environment_zero(HARNESS_RUNTIME.environment));
|
||||||
TEST_REQUIRE_STATUS(akbasic_runtime_evaluate(&HARNESS_RUNTIME, NULL, &out),
|
TEST_REQUIRE_STATUS(akbasic_runtime_evaluate(&HARNESS_RUNTIME, NULL, &out),
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ static void test_scoped_loop_counter_costs_nothing(void)
|
|||||||
/**
|
/**
|
||||||
* @brief The pool is genuinely untouched, not merely large enough.
|
* @brief The pool is genuinely untouched, not merely large enough.
|
||||||
*
|
*
|
||||||
* Two hundred scope entries and then the pool's *entire* width -- two arrays,
|
* Two hundred scope entries and then the pool's *entire* width -- four arrays,
|
||||||
* because AKBASIC_MAX_ARRAY_ELEMENTS caps any one of them at 1024 while the pool
|
* because AKBASIC_MAX_ARRAY_ELEMENTS caps any one of them at 1024 while the pool
|
||||||
* holds 2048. One leaked slot and the second `DIM` has nowhere to go, which
|
* holds 4096. One leaked slot and the fourth `DIM` has nowhere to go, which
|
||||||
* makes this the sharpest of the three and by far the cheapest: the two above
|
* makes this the sharpest of the three and by far the cheapest: the two above
|
||||||
* prove a program finishes, this proves nothing at all was spent. The long ones
|
* prove a program finishes, this proves nothing at all was spent. The long ones
|
||||||
* stay because they are the shape the defect was found in.
|
* stay because they are the shape the defect was found in.
|
||||||
@@ -111,8 +111,10 @@ static void test_pool_is_untouched_by_scopes(void)
|
|||||||
"30 NEXT T#\n"
|
"30 NEXT T#\n"
|
||||||
"40 DIM A#(1024)\n"
|
"40 DIM A#(1024)\n"
|
||||||
"50 DIM B#(1024)\n"
|
"50 DIM B#(1024)\n"
|
||||||
"70 B#(1023) = 7\n"
|
"60 DIM C#(1024)\n"
|
||||||
"90 PRINT B#(1023)\n"
|
"70 DIM D#(1024)\n"
|
||||||
|
"80 D#(1023) = 7\n"
|
||||||
|
"90 PRINT D#(1023)\n"
|
||||||
"100 END\n"
|
"100 END\n"
|
||||||
"110 LABEL SUBA\n"
|
"110 LABEL SUBA\n"
|
||||||
"120 LOC# = 1\n"
|
"120 LOC# = 1\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user