Skip to content

Read a command on Mattel Aquarius

Reuse the actual machine-specific reader, with its caller, state, ownership and a diagnosed input mistake.

Enter the complete demo.bas in Mattel Aquarius BASIC and RUN. Submit GO, then Return. One accepted command advances the displayed turn; another gives two.

Mattel Aquarius native caller after accepted input.
Captured from the running caller in the configuration below.

Take the reader

Copy read-command.bas into free line numbers, then call it with GOSUB 4000. It replaces A$; the caller checks that value before updating N. Keep N’s initialisation outside the repeated path. Renumber the GOSUB and routine together.

The reusable reader

read-command.bas
4000 INPUT A$
4010 RETURN

GOSUB 4000 replaces A$ with the submitted line. The caller recognises GO. The 4000 range deliberately leaves the existing 3000-range sound DATA intact.

BASIC owns the keyboard buffer, line editor, return stack and variable storage. The global variable and line-number names belong to your program: reserve or rename them consistently. INPUT waits; no animation or deadline code in your main path can run during that wait.

Fit it into a program

The complete numbered program is caller.bas, draw.bas, sound.bas and read-command.bas together. The reader does not accept a move on its own; the IF in the caller does that.

Initialise once, read, validate, then update

caller.bas
1 N=0:W=0:J=0:B=0:X=0:A$=""
2 DIM Z(16)
3 W=PEEK(14552)+256*PEEK(14553)+7
4 FOR J=0 TO 21:READ B:POKE W+J,B:NEXT J
5 POKE 14340,W AND 255:POKE 14341,INT(W/256)
10 N=0
20 PRINT "TURN";N
21 GOSUB 1000
30 GOSUB 4000
40 IF A$="GO" THEN N=N+1:GOSUB 2000
50 GOTO 20

Change it and recognise a mistake

Reserve the complete numbered ranges. Reusing line 3000 for INPUT replaces a sound DATA line; the native fault run fails before the game starts. The repaired program uses 4000/4010.

This deliberately broken caller reuses an accepted command instead of reading another one. The world advances without you. Restore the GOSUB before the validation/update path; the working caller waits at zero until input arrives.

Deliberately broken input/update path

stale-command.bas
1 N=0:W=0:J=0:B=0:X=0:A$=""
2 DIM Z(16)
3 W=PEEK(14552)+256*PEEK(14553)+7
4 FOR J=0 TO 21:READ B:POKE W+J,B:NEXT J
5 POKE 14340,W AND 255:POKE 14341,INT(W/256)
10 N=0
20 PRINT "TURN";N
21 GOSUB 1000
30 A$="GO"
40 IF A$="GO" THEN N=N+1:GOSUB 2000
50 GOTO 20
1000 PRINT "XXX"
1010 PRINT "X X"
1020 PRINT "XXX"
1030 RETURN
2000 X=USR(0)
2010 RETURN
3000 DATA 245,197,14,80,175,211,252,238
3008 DATA 1,6,100,16,254,13,32,245
3016 DATA 175,211,252,193,241,201
4000 INPUT A$
4010 RETURN
Mattel Aquarius deliberately broken input caller.
Observed fault; use the working caller to repair it.

The sound helper already uses DATA lines in the 3000 range. Defining INPUT at 3000 overwrote one of them and produced OD Error in 4 during READ. The repaired reader lives at 4000/4010. A new line number is an integration decision, not spare storage you can assume is free.

Aquarius shows OD Error in 4 after overlapping numbered lines.
The failed loader exposed the line-number collision before play began.

The complete caller

Working setup and integration

demo.bas
1 N=0:W=0:J=0:B=0:X=0:A$=""
2 DIM Z(16)
3 W=PEEK(14552)+256*PEEK(14553)+7
4 FOR J=0 TO 21:READ B:POKE W+J,B:NEXT J
5 POKE 14340,W AND 255:POKE 14341,INT(W/256)
10 N=0
20 PRINT "TURN";N
21 GOSUB 1000
30 GOSUB 4000
40 IF A$="GO" THEN N=N+1:GOSUB 2000
50 GOTO 20
1000 PRINT "XXX"
1010 PRINT "X X"
1020 PRINT "XXX"
1030 RETURN
2000 X=USR(0)
2010 RETURN
3000 DATA 245,197,14,80,175,211,252,238
3008 DATA 1,6,100,16,254,13,32,245
3016 DATA 175,211,252,193,241,201
4000 INPUT A$
4010 RETURN

For more responsive controls, compare polling, buffering and press edges in input choices.

Verification and sources

Target: stock Aquarius BASIC with an array-backed USR sound helper. These callers were executed with released Emu198x 0.44.1; assembly uses Asm198x 0.0.71. The sample folder contains reproduction instructions and retained observations. The independent checker binds source, native captures and actual output; its rejection tests exercise wrong state, missing files and false audio claims.

This qualifies the named emulator/firmware path. Pitch accuracy, original hardware and other peripherals require their own observations.

Mattel/Radofin, Aquarius BASIC documentation: INPUT, DATA/READ, DIM and USR; machine-code helper bytes and port behaviour are identified by this configuration’s executed source.