Skip to content

Wait for a turn on Sinclair ZX80

Reuse an untimed command or press loop while retaining the machine’s actual display responsibilities.

Enter the complete demo.bas in Sinclair ZX80 BASIC and RUN. Submit 1, then Return. The number is added to the running total; entering 2 adds two.

Sinclair ZX80 native caller after accepted input.
Captured from the running caller in the configuration below.

Keep the world waiting

Initialise N once, show the state, read a submitted value, apply it, then return to the display/input path. Firmware activity does not mean the game world has taken a turn. No artificial frame timer is needed for this caller.

INPUT A is a blocking numeric reader. The nine-line caller adds the submitted A to N; it is a running total, not a validator restricted to 0 and 1. Entering 2 adds two.

The actual loop and its machine setup

demo.bas
10 LET N=0
20 CLS
30 PRINT N
31 PRINT "XXX"
32 PRINT "X X"
33 PRINT "XXX"
40 INPUT A
50 LET N=N+A
60 GOTO 20

Fit and adapt it

Copy the INPUT statement into a free numbered line in your own command flow. The complete caller shows where to initialise N and where to return after an update.

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.

Copy the INPUT statement into your own numbered flow. Preserve N between decisions. At 1 KiB, the program and its display compete for memory.

The broken update adds A twice. Submitting 1 reaches 2 immediately. INPUT read the right number; the update used it twice. Restore N=N+A. The caller also checks a nonzero start, so a lost initialiser cannot hide behind zero-filled state.

A repeated-path mistake to recognise

double-add.bas
10 LET N=0
20 CLS
30 PRINT N
31 PRINT "XXX"
32 PRINT "X X"
33 PRINT "XXX"
40 INPUT A
50 LET N=N+A+A
60 GOTO 20
Sinclair ZX80 faulty repeated path.
The fault fails the same rule-state guard as the working caller.

A timed turn is another policy: keep a deadline separately, decide how expiry competes with an arriving action, and service that clock while waiting. A blocking reader cannot provide that service from the same main path. A faster renderer or sound routine does not settle the rule.

See loop choices and the machine’s input entry for the reader’s complete contract.

Verification and sources

Target: stock 4 KiB ROM, 1 KiB RAM, keyword entry. 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.

Sinclair, ZX80 Operating Manual: INPUT, integer arithmetic, program/display memory and keyboard entry; stock ROM execution in the named 1 KiB configuration.