Skip to content

Read a new key on Jupiter Ace

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

Compile demo.fth in its listed order. Its final TURNS starts the caller. Press 1, let go, and press it again: the count reaches two.

Jupiter Ace native caller after accepted input.
Captured from the running caller in the configuration below.

Take the reader

Compile new-key.fth before a word that calls NEWKEY. It adds one character to the data stack. Compare or consume that result exactly once; the caller keeps its running total underneath. Compile click.fth before using CLICK. The complete file shows the definition order.

The reusable reader

new-key.fth
: NEWKEY
BEGIN INKEY 0= UNTIL
BEGIN INKEY ?DUP UNTIL ;

NEWKEY has stack effect ( – c ). It waits for INKEY to return zero, then waits for a nonzero character. A key held at entry must be released before it can become a new action. It preserves everything already below its result on the data stack.

NEWKEY blocks while it waits. It uses the ROM keyboard path and the ordinary data stack; it has no private variable or frame timer. It deliberately waits for release before another press.

Change it and recognise a mistake

Change the character comparison after NEWKEY. Keep release-then-press when an action must happen once per physical press; raw INKEY is useful for held-state controls instead.

The broken word fabricates its first key instead of waiting. The count changes before you press anything. Restore NEWKEY to keep the input decision with the player.

Deliberately broken input/update path

fabricated-key.fth
: CLICK 478 120 BEEP ;
: NEWKEY
BEGIN INKEY 0= UNTIL
BEGIN INKEY ?DUP UNTIL ;
: BOX CR ." XXX" CR ." X X" CR ." XXX" ;
: TURNS 0 BEGIN
CLS ." TURN " DUP U. BOX
DUP 0= IF 49 ELSE NEWKEY THEN 49 = IF 1+ CLICK THEN
0 UNTIL ;
TURNS
Jupiter Ace deliberately broken input caller.
Observed fault; use the working caller to repair it.

The complete caller

Working setup and integration

demo.fth
: CLICK 478 120 BEEP ;
: NEWKEY
BEGIN INKEY 0= UNTIL
BEGIN INKEY ?DUP UNTIL ;
: BOX CR ." XXX" CR ." X X" CR ." XXX" ;
: TURNS 0 BEGIN
CLS ." TURN " DUP U. BOX
NEWKEY 49 = IF 1+ CLICK THEN
0 UNTIL ;
TURNS

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

Verification and sources

Target: stock 3 KiB Ace, recorded FORTH ROM. 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.

Jupiter Cantab, Jupiter Ace User Manual: INKEY, ?DUP, conditional loops and BEEP; chapter on the loudspeaker and music.