Enter the complete demo.bas in Atari 800XL BASIC and RUN. Submit 1, then Return. One accepted command advances the displayed turn; another gives two.

Take the reader
Copy read-command.bas into free line numbers, then call it with GOSUB 3000. 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
3000 INPUT A
3010 RETURNINPUT A replaces one numeric variable; the caller accepts 1 and rejects 0. It does not poll a joystick or run while the player edits a line.
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
10 N=0
20 GRAPHICS 0:PRINT "TURN";N
21 GOSUB 1000
30 GOSUB 3000
40 IF A=1 THEN N=N+1:GOSUB 2000
50 GOTO 20Change it and recognise a mistake
Validate the submitted value before moving a piece or changing a room. Keep game state out of the reader.
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
10 N=0
20 GRAPHICS 0:PRINT "TURN";N
21 GOSUB 1000
30 A=1
40 IF A=1 THEN N=N+1:GOSUB 2000
50 GOTO 20
1000 PRINT "XXX"
1010 PRINT "X X"
1020 PRINT "XXX"
1030 RETURN
2000 SOUND 0,100,10,15
2010 FOR J=1 TO 200:NEXT J
2020 SOUND 0,0,0,0
2030 RETURN
3000 INPUT A
3010 RETURN
The complete caller
Working setup and integration
10 N=0
20 GRAPHICS 0:PRINT "TURN";N
21 GOSUB 1000
30 GOSUB 3000
40 IF A=1 THEN N=N+1:GOSUB 2000
50 GOTO 20
1000 PRINT "XXX"
1010 PRINT "X X"
1020 PRINT "XXX"
1030 RETURN
2000 SOUND 0,100,10,15
2010 FOR J=1 TO 200:NEXT J
2020 SOUND 0,0,0,0
2030 RETURN
3000 INPUT A
3010 RETURNFor more responsive controls, compare polling, buffering and press edges in input choices.
Verification and sources
Target: 800XL NTSC, Atari BASIC and GRAPHICS 0. 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.
Atari, Atari BASIC Reference Manual: INPUT, GOSUB/RETURN and SOUND; Atari Hardware Manual: POKEY audio channels.