Short Term Memory

Developer(s): Hal Renko, Sam Edwards
Date: 1983
Type: Program
Platform(s): TS 2068
Tags: Game

Short Term Memory is a sequence-recall game that challenges players to memorize progressively longer strings of letters, digits, or binary characters. The menu allows selection among three symbol sets, implemented by setting the base ASCII value and range in variables before a shared display-and-input routine. A user-defined function at line 320 reads the three-byte system clock counter at memory addresses 23672–23674, converting it to seconds elapsed, so the game can report how long the player took to complete their run. Sequences are built character by character using RND, displayed one at a time, then erased before the player must type the full string from memory.


Program Structure

The program is organized into a title/introduction block, a menu, a mode-selection dispatcher, and a shared game loop. Control flow uses computed GO TO to jump to one of three mode-initialization blocks.

LinesPurpose
1–6Title screen with FLASH, colors, and introductory text
9–70Menu display and input validation
100, 200, 300Mode initialization (letters, digits, binary)
320DEF FN for elapsed-time calculation
330–395Main game loop: sequence build, display, input, scoring
400Exit/goodbye screen
9999SAVE with auto-run

Mode Dispatcher

At line 70, LET x= VAL a$ converts the menu key character to an integer 1–4, then GO TO 100*x jumps to line 100, 200, 300, or 400. Choosing option 4 jumps directly to the goodbye routine at line 400, cleanly doubling as a “stop” option.

Each mode sets two variables before falling through to the shared game logic:

  • a — the size of the symbol pool (26 letters, 10 digits, or 2 binary characters)
  • b — the ASCII base offset (97 for lowercase ‘a’, 48 for ‘0’)

The binary mode (line 300) uses a=2 and b=48, so CHR$ INT (48+ RND*2) produces either ‘0’ or ‘1’. The letter mode uses base 97 (lowercase ASCII), so sequences will be lowercase letters ‘a’–’z’.

Elapsed-Time Function

Line 320 defines a function that reads the Spectrum’s three-byte frame counter from addresses 23672–23674:

DEF FN t()= INT ((65536* PEEK 23674+256* PEEK 23673+ PEEK 23672)/60)

This reconstructs a 24-bit tick count (60 ticks per second) and divides by 60 to yield elapsed seconds since power-on. The game captures t1 at the start of each run and t2 at the end to report a session time to the player.

Game Loop Logic

The main loop (lines 330–395) increments the sequence length c on each correct answer. The inner FOR loop at line 340 appends one random character per iteration to both the display and the string a$. After the loop, line 350 erases the trailing space marker. The player then types their recalled sequence; a correct answer increments c and checks whether 40 or more seconds have elapsed (line 390), ending the game as a time-based cap.

Key BASIC Idioms

  • Spin-wait input: Line 60 uses LET a$= INKEY$: IF a$<"1" OR a$>"4" THEN GO TO 60 to poll for a valid single keypress without INPUT.
  • Computed GO TO: GO TO 100*x is a compact dispatch table technique.
  • PAUSE 0 / INKEY$ pattern: Line 6 uses PAUSE 0 to halt until any key is pressed before continuing.
  • String accumulation: LET a$=a$+b$ inside the FOR loop builds the target answer string incrementally.

Notable Anomalies

  • Line 300 includes a spurious PAUSE 1 that the other mode-initialization lines (100, 200) do not have; it has no functional effect but is inconsistent.
  • The replay prompt at line 380 only restarts for lowercase "y"; uppercase "Y" falls through to GO TO 400, which may surprise players.
  • The 40-second time cap at line 390 applies globally regardless of how many characters the player has already recalled correctly, meaning a slow but accurate player is penalized the same as an inaccurate one.
  • Line 3 references a copyright symbol using © (the RESET token escape), which in string context here renders as the © glyph rather than executing any command.

Content

Appears On

Related Products

Related Articles

Related Content

Image Gallery

Source Code

    1 PAPER 0:BORDER 0
    2 CLS :BORDER 0:PAPER 0:INK 7:PRINT AT 5,10;"Welcome to:":FLASH 1:INK 4:PRINT AT 8,12;"S.T.M.":FLASH 0:INK 7:PRINT AT 10,6;"(Short Term Memory)"
    3 PRINT AT 15,0;"from the book:",,"TANTALIZING GAMES FOR THE T/S   2000 SERIES",,"by H. Renko/ S. Edwards","©1983 Addison-Wesley Pub. Ltd."
    4 PAUSE 900:CLS 
    5 PRINT "This game tests your short term  memory.",,"Play it with your friends and   family and see who can remember the most."
    6 PRINT AT 8,0;"Press any key for menu.":PRINT :PRINT "Game will be in play as soon as number is selected from menu.","Good Luck.":PAUSE 0
    9 PAPER 1
   10 CLS :PRINT "Do you want to play with:"
   20 PRINT " 1. LETTERS?"
   30 PRINT " 2. NUMBERS?"
   40 PRINT " 3. 0 AND 1?"
   50 PRINT " 4.  OR STOP?"
   55 PRINT :PRINT 
   60 LET a$= INKEY$:IF a$<"1" OR a$>"4" THEN GO TO 60
   70 PAUSE 50:LET x= VAL a$:GO TO 100*x
  100 LET a=26:LET b=97:GO TO 320
  200 LET a=10:LET b=48:GO TO 320
  300 LET a=2:LET b=48:PAUSE 1
  320 DEF FN t()= INT ((65536* PEEK 23674+256* PEEK 23673+ PEEK 23672)/60):REM seconds since start
  330 LET c=1:LET t1= FN t()
  340 PAUSE 10:LET a$="":FOR i=1 TO c:LET b$= CHR$ INT (b+ RND*a):PRINT AT 10,i;" "+b$;:LET a$=a$+b$
  350 PAUSE 15:NEXT i:PRINT AT 10,i;" "
  360 INPUT "ANSWER: ";b$:IF b$=a$ THEN GO TO 390
  370 PRINT :PRINT "WRONG, YOUR SCORE IS: ";c-1:PRINT "IT WAS ";a$;" , NOT ";b$
  380 LET t2= FN t():PRINT "TIME: "; INT (t2-t1);" SECONDS":INPUT "Play again (Y/N)?";a$:IF a$="y" THEN GO TO 10
  385 GO TO 400
  390 LET c=c+1:LET t2= FN t():IF t2-t1 >=40 THEN PRINT :PRINT "Your score is: ";c-1:GO TO 380
  395 GO TO 340
  400 PAPER 7:INK 2:PRINT :PRINT "Thankyou for playing.":PRINT "Good Bye...":PAPER 0:INK 7:STOP 
 9999 SAVE "stm" LINE 1

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top