--- title: "Spell" id: 57270 type: "computer_media" slug: "spell" url: "http://localhost/computer_media/spell/" markdown_url: "http://localhost/computer_media/spell.md" published_at: "2024-10-04T07:53:15+00:00" modified_at: "2026-03-30T21:18:48+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/158_Spel.png" excerpt: "A memory-based spelling quiz that flashes each word on screen, clears it, then challenges you to type it correctly — with a flashy celebration for a perfect ten." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Education" slug: "education" taxonomy: "genre" url: "http://localhost/type/education/" media_contents: - id: 56734 title: "Timex Sinclair Public Domain Library Tape 1003" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1003/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/158_Spel.png" media_type_tags: "Education" --- This program is a ten-word spelling quiz that prompts the user to enter a list of words, then displays each word briefly before clearing the screen and asking the player to retype it from memory. Words are stored in a two-dimensional string array A$(10,10), with each word occupying up to ten characters, and the user’s answer is captured into a one-row array B$(1,10) for comparison. Incorrect answers loop back to redisplay the word until typed correctly, with the score penalised for each wrong attempt and rewarded for each correct one. A perfect score of 10 triggers a celebratory subroutine at line 400 that plots random pixels and flashes “RAH” in inverse video, using PLOT with RND-based coordinates to scatter 25 random dots across the screen. *** ## Program Analysis ### Program Structure The program is divided into four logical phases: 1. **Setup (lines 10–75):** Dimensions two string arrays and collects ten words from the user via `INPUT`. 2. **Quiz loop (lines 80–290):** Iterates over the ten stored words, briefly displays each, clears the screen, and accepts a typed answer. 3. **End-of-round handling (lines 300–360):** Checks for a perfect score, reports the result, and offers replay or a fresh set of words. 4. **Celebration subroutine (lines 400–470):** Plots random dots and flashes an inverse/normal “RAH” banner, then returns. ### Data Storage Words are held in a 2-D string array `A$(10,10)` — ten rows of ten characters — so each word can be up to ten characters long. The user’s answer is captured into `B$(1,1 TO 10)`, a one-row array of the same width. Slice notation (`A$(N,1 TO 10)` and `B$(1,1 TO 10)`) is used consistently for both input and comparison, which is idiomatic ZX81/TS1000 BASIC for fixed-width string handling. ### Quiz Logic and Scoring The scoring variable `S` starts at 0 each round. A correct answer on the first attempt adds 1 (`S=S+1` at line 260), while each wrong attempt subtracts 1 (`S=S-1` at line 210). Because wrong attempts loop back to line 160 for another try, a word that takes two attempts nets 0 points (−1 then +1), and one needing three attempts nets −1. A perfect score of exactly 10 triggers the celebration at line 330; any lower score is reported numerically at line 305. ### Key BASIC Idioms - **Busy-wait for keypress:** Lines 90–100 poll `INKEY$` in a tight loop, first waiting for any key, then filtering for “R” only — a common pattern when `PAUSE 0`/`INKEY$` is not used. - **PAUSE for timed display:**`PAUSE 100` (approximately 4 seconds at 25 fps) gives the player time to read a word or see feedback before the screen clears. - **Subroutine for celebration:** The fireworks/cheer effect is neatly isolated in a `GOSUB 400` subroutine, keeping the main flow readable. - **Replay option:** Line 306 uses a single `INKEY$` check without a wait loop; pressing “Y” repeats the quiz with the same words, while any other key resets `S` and restarts word entry from line 20. ### Celebration Subroutine (Lines 400–470) On a perfect score, 25 random pixels are plotted across the screen using `PLOT INT(RND*64), INT(RND*44)`. The column range of 64 and row range of 44 stay safely within the ZX81’s 64×44 pixel display. The “RAH” flash effect is achieved by printing the text first in inverse video (`%R%A%H`) and then immediately overwriting it in normal video (`RAH`) inside a 15-iteration loop, creating a crude flicker animation at line speed. ### Bugs and Anomalies - **Line 306 — missing keypress wait:** The “SAME WORDS? (Y/N)” prompt at line 305 is followed immediately by a single `INKEY$` test at line 306 with no loop. If the user has not pressed “Y” in that exact machine cycle, execution falls through to line 310 and restarts word entry regardless of intent. A `GOTO 306` or similar loop is needed here. - **Score can go negative:** Multiple wrong attempts per word can drive `S` below zero, making it impossible to reach the perfect-score branch (line 300) even if all words are eventually answered correctly. - **CLEAR at line 350:** Calling `CLEAR` before returning to line 20 erases all variables including `A$` and `B$`, which is intentional for a fresh round — but it also means the `DIM` statements at lines 20–30 must be re-executed, which they are since control passes back to line 20. ## Source Code ``` 10 REM %S%P%E%L%L 20 DIM A$(10,10) 30 DIM B$(1,10) 40 PRINT "LIST 10 WORDS" 50 FOR N=1 TO 10 60 INPUT A$(N,1 TO 10) 70 NEXT N 75 CLS 80 PRINT "PRESS ""R"" WHEN YOU ARE READY" 90 IF INKEY$="" THEN GOTO 90 100 IF INKEY$<>"R" THEN GOTO 90 140 LET S=0 150 FOR N=1 TO 10 155 CLS 160 PRINT A$(N,1 TO 10) 170 PAUSE 100 180 CLS 190 INPUT B$(1,1 TO 10) 200 IF B$(1,1 TO 10)=A$(N,1 TO 10) THEN GOTO 250 210 LET S=S-1 220 PRINT "WRONG" 230 PAUSE 100 235 CLS 240 GOTO 160 250 PRINT "CORRECT" 260 LET S=S+1 270 PAUSE 100 280 CLS 290 NEXT N 300 IF S=10 THEN GOTO 330 305 PRINT "SCORE= ";S,,"SAME WORDS? (Y/N)" 306 IF INKEY$="Y" THEN GOTO 150 310 LET S=0 320 GOTO 20 330 PRINT "ALL CORRECT" 335 GOSUB 400 340 PAUSE 200 350 CLEAR 355 CLS 360 GOTO 20 400 FOR U=1 TO 25 410 PLOT INT (RND*64),INT (RND*44) 420 NEXT U 430 FOR M=1 TO 15 440 PRINT AT 11,10;"%R%A%H"; 450 PRINT AT 11,10;"RAH" 460 NEXT M 470 RETURN 480 SAVE "1015%8" 490 RUN ```