--- title: "Slot" id: 64738 type: "computer_media" slug: "slot" url: "http://localhost/computer_media/slot/" markdown_url: "http://localhost/computer_media/slot.md" published_at: "2026-03-07T14:33:58+00:00" modified_at: "2026-03-30T21:45:22+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/03/slot.png" excerpt: "A full-featured one-armed bandit with animated reels, jokers, holds, a gamble round, and a double-up bonus — all driven by computed GO TO dispatch." 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 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_contents: - id: 64715 title: "Miscellaneous Programs" type: "computer_media" url: "http://localhost/computer_media/miscellaneous-programs/" - id: 53877 title: "SINCUS Exchange Tape 101 – Entertainment" type: "computer_media" url: "http://localhost/computer_media/sincus-exchange-tape-101-entertainment/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2026/03/slot.png" media_type_tags: "Game" --- # Slot This program implements a fruit-machine (slot machine) simulation with three reels, joker symbols, a hold feature, a gamble sub-game, and a double-up bonus. Reel symbols are encoded as single characters in the string `W$="AKQJ7*$0/=+#%"`, with winning combinations and payouts stored in a two-dimensional array `R(3,13)`. The main loop uses computed `GO TO` expressions (e.g., `GO TO (4030 AND CA=0)+(4100 AND CA=1)+(4200 AND CA=2)+(4700 AND CA=3)`) as a dispatch mechanism, a common Sinclair BASIC technique for multi-way branching. Reel animation is produced by printing symbols column by column with a short delay subroutine at line 2880. A UDG character (`\a`) shaped like a diamond or star is defined via `POKE USR` with the data `8,8,20,32,32,20,8,8` and used in the screen layout. *** ## Program Structure The code is organised into functional blocks identified by REM labels, each occupying a distinct line-number range: | Line range | Purpose | | --- | --- | | 600 | Entry point — jumps to main program at 4000 | | 1000–1030 | Flashing prompt + `INKEY$` input subroutine | | 1100–1130 | Insert / eject money (update `MO` counter) | | 1200–1220 | Remove double-up state, redraw joker positions | | 1300–1310 | Clear status line 21 | | 1400–1430 | Jackpot animation | | 1500–1580 | Flash possible hold positions and collect hold input | | 2000–2160 | Spin reels (animation + final reel-stop logic) | | 2300–2410 | Reset per-spin variables | | 2500–2560 | “Not enough money” handler | | 2600–2720 | Can-hold / cannot-hold prompt dispatchers | | 2800–2880 | Winnings prompt + generic “???” flash + delay loop | | 3100–3160 | Joker resolution (wild-card handling) | | 3200–3360 | Compute winnings into `WI` | | 3400–3500 | Gamble sub-game (spinning multiplier wheel) | | 4000–4600 | Main game loop | | 5600–5900 | End-of-game statistics display | | 6000–6500 | Initialisation, data, screen draw, and SAVE | ## Initialisation and Data Line `6000` reads the four named constants `N0=0`, `N1=1`, `N2=2`, `N3=3` from `DATA` along with the symbol string `W$`. Using short numeric variables as aliases for small constants reduces token overhead throughout the listing. All major arrays (`R`, `H`, `P`, `C`, `D`, `K`, `V`, `O`, `F`, `G`, `E`) are dimensioned in the 6000-block, and their initial values are loaded from `DATA` statements nearby. The payout table is a `DIM R(3,13)` matrix; only rows 2 and 3 are populated (two-of-a-kind and three-of-a-kind payouts respectively for symbol indices 5–12). `DIM J(13)` flags which symbols award a jackpot on three-of-a-kind; indices 5, 6, and 7 are set to 1 (symbols `A`, `K`, `Q`). ## Computed GO TO Dispatch The program makes heavy use of the idiom: `GO TO (addr1 AND cond1)+(addr2 AND cond2)+...` Because exactly one condition is true and the others evaluate to 0, the sum equals the desired destination address. This replaces `IF…THEN GO TO` chains and is a classic Sinclair BASIC space-saving technique. Examples appear at lines `3210`, `4030`, `4050`, `4260`, and `4330`. ## Reel Simulation (lines 2000–2160) The spin animation runs in two phases: a downward scroll (lines `2050–2060`) followed by an upward scroll (`2070–2080`), each calling the short delay subroutine at `2880` (an empty `FOR/NEXT` loop to 15). The final symbol selection uses a probability-shaped mapping at line `2030`: `LET V(I)=5+(FI>7)+(FI>10)+(FI>13)+(FI>36)+(FI>49)+(FI>68)+(FI>87)` where `FI` is a random integer 1–100. Boolean expressions add 0 or 1 to build an index from 5 to 12, biasing higher-value symbols to appear less frequently. Values 1–4 are reserved for joker symbols (lines 3100–3150). The inner loop at `2100–2160` iterates `I` from 0 to 70, cycling each non-held reel’s display symbol (`O(J)`) and stopping it once `I > 10+13*J` and `O(J)=V(J)` — so reel 1 stops earliest and reel 3 last, with an audible beep per stop. ## Joker and Wild-Card Logic (lines 3100–3160) Symbols with `V(I) ≤ 4` are jokers. The subroutine counts the number of jokers (`JO`) and their position (`JW`). The winnings computation at `3210` then dispatches on `JO`: - `JO=0` or `JO=2`: use the face-value of the non-joker symbol (`FV`) - `JO=1`: the single joker takes the value of whichever neighbour gives the higher-paying combination - `JO=3`: branch to `3270` directly (all jokers — treated as the worst non-wild) When all four joker slots have been consumed (`NJ=0`), the “DOUBLE!” bonus activates with `DC=15` spins of doubling. ## Gamble Sub-Game (lines 3400–3500) The gamble routine cycles through four outcomes stored in `G(1..4)`: double, zero, 1.5×, and half. These are displayed in screen positions defined by array `E(4,2)`. The player presses S/s to stop; the program then continues to spin for a random additional count `DT = INT(1+RND*250)` before landing, preventing the player from timing the stop precisely. Net gambling profit/loss is accumulated in `GW`. ## Statistics Display (lines 5600–5900) On game end, the program prints money amounts formatted as dollars with two decimal places. The formatting subroutine at `5800` uses `LEN STR$ X - LEN STR$ INT X` to detect whether `X` already has a decimal part (`L=2` means one decimal digit present, `L=0` means integer). It appends `"0"` or `".00"` accordingly. The number-right-justification subroutine at `5900` pads with spaces based on digit count. ## UDG Definition A single UDG `\a` (character 144) is defined at lines `6245–6260` with data `8,8,20,32,32,20,8,8`, producing a diamond/arrow shape used in the score display at line `6310` (`"25\a"`). ## Source Code ``` 600 GO TO 4000 1000 REM FLASH AND INKEY$ 1010 PRINT AT R,C; OVER N1; FLASH N1;S$ 1020 LET I$=INKEY$: IF I$="" THEN GO TO 1020 1030 PRINT AT R,C; PAPER CL;T$: RETURN 1110 IF NOT IN THEN RETURN 1115 FOR I=SGN IN TO IN STEP SGN IN 1120 PRINT AT N0,7;MO+I;" ": BEEP .1,40: NEXT I 1130 LET MO=MO+IN: RETURN 1200 REM remove doubles 1210 LET DO=N0: PRINT AT 6,11; PAPER N2;" " 1220 DIM C(4): FOR I=N1 TO 4: PRINT AT 7,D(I);W$(I): NEXT I: RETURN 1300 REM CLEAR LINE 1310 PRINT AT 21,N0;TAB 31;: RETURN 1400 REM jackpot 1410 FOR T=N1 TO 4: FOR C=N1 TO JC: PRINT AT N0,11+C;" ": NEXT C 1420 FOR C=N1 TO JC: BEEP .1,10+N2*C: PRINT AT N0,11+C;"J": NEXT C 1430 NEXT T: RETURN 1500 REM FLASH POSS HOLDS AND GET INKEY$ 1510 FOR I=N1 TO PI: IF NOT H(I) THEN PRINT AT 11,P(I); FLASH N1; PAPER N2; INK 7; OVER N1;"H" 1520 NEXT I: LET HO=N0 1530 LET I$=INKEY$: IF I$="" THEN GO TO 1530 1540 IF I$<>"1" AND I$<>"2" AND I$<>"3" THEN GO TO 1570 1550 LET I=VAL I$: PRINT AT 11,P(I); PAPER N2; INK 7;"H" 1560 LET HO=N1: LET H(I)=N1: GO TO 1530 1570 FOR I=N1 TO PI: IF NOT H(I) THEN PRINT AT 11,P(I); PAPER N2;" " 1580 NEXT I: LET NH=NH+HO: RETURN 2000 REM play 2010 FOR I=N1 TO PI: IF H(I) THEN GO TO 2040 2020 LET O(I)=V(I): LET FI=INT (RND*100)+N1: LET V(I)=FI: IF FI<5 THEN GO TO 2040 2030 LET V(I)=5+(FI>7)+(FI>10)+(FI>13)+(FI>36)+(FI>49)+(FI>68)+(FI>87) 2040 NEXT I 2050 FOR C=6 TO 9: PRINT AT C,20;" ";AT C+N1,20; PAPER N2;" " 2060 GO SUB 2880: NEXT C 2070 FOR C=10 TO 7 STEP -N1: PRINT AT C,20; PAPER N3;" ";AT C-N1,20; PAPER N2;" " 2080 GO SUB 2880: NEXT C 2090 DIM F(N3) 2100 FOR I=N0 TO 70: FOR J=N1 TO PI 2110 IF H(J)=N1 THEN GO TO 2160 2120 IF F(J)=N1 THEN GO TO 2150 2130 LET O(J)=O(J)+N1: IF O(J)>13 THEN LET O(J)=N1 2140 IF I>10+13*J AND O(J)=V(J) THEN LET F(J)=N1: BEEP .02,8*J 2150 PRINT AT 9,P(J); PAPER 6;W$(O(J)) 2160 NEXT J: NEXT I: RETURN 2300 REM reset variables 2310 LET NT=NT+N1: IF WI>N0 THEN LET HB=N1: LET WI=N0 2320 DIM H(N3): FOR I=N1 TO PI: PRINT AT 11,P(I); PAPER N2;" ": NEXT I 2330 IF DO THEN GO TO 2380 2340 FOR I=N1 TO I: IF NOT C(I) THEN GO TO 2370 2350 LET C(I)=C(I)-N1: IF C(I)>N0 THEN GO TO 2370 2360 LET NJ=NJ+N1: PRINT AT 7,D(I);W$(I) 2370 NEXT I: GO TO 2390 2380 LET DC=DC-N1: IF NOT DC THEN GO SUB 1200 2390 IF JA THEN PRINT AT N0,11+JC;" ": LET JC=JC-N1: IF NOT JC THEN LET JA=N0 2400 IF MO>MM THEN LET MM=MO 2410 RETURN 2500 REM NOT enough $ 2510 LET HB=N1 : GO SUB 1200 2520 LET JA=N0: PRINT AT N0,10;TAB 31; 2530 GO SUB 1300: PRINT AT 21,8; PAPER 5;"INSERT OR END" 2540 LET S$="INSERT (I)": LET T$=B$: LET CL=7: LET R=N2: LET C=N0: GO SUB 1000 2550 IF I$="P" OR I$="p" THEN GO TO 2540 2560 RETURN 2600 REM can hold 2610 GO SUB 1300: PRINT AT 21,PI; PAPER 5;"INSERT, HOLD, PLAY OR END" 2620 GO SUB 1500: RETURN 2700 REM CANNOT HOLD 2710 GO SUB 1300: PRINT AT 21,5; PAPER 5;"INSERT, PLAY OR END" 2720 GO SUB 2870: RETURN 2800 REM handle winnings 2820 GO SUB 1300: IF NOT HB THEN PRINT AT 21,4; PAPER 5;"HOLD, " 2840 PRINT AT 21,7; PAPER 5;"GAMBLE OR COLLECT" 2850 GO SUB 2870: RETURN 2870 LET S$="???": LET T$=" ": LET CL=N1: LET R=18: LET C=13: GO SUB 1000: RETURN 2880 FOR I=N1 TO 15: NEXT I: RETURN 3100 REM handle jokers 3110 LET JO=N0: FOR I=N1 TO PI: LET V=V(I) 3120 IF V>4 THEN LET FV=V: GO TO 3150 3130 LET JW=I: LET JO=JO+N1: IF C(V)>N0 THEN GO TO 3150 3140 PRINT AT 7,D(V); PAPER N3;" ": LET C(V)=20: LET NJ=NJ-N1 3150 NEXT I: LET DO=(NJ=N0): IF DO THEN LET DC=15: PRINT AT 6,11;"DOUBLE!"; 3160 REM RETURN 3200 REM compute winnings 3210 LET HV=5: GO TO (3220 AND JO=N0)+(3250 AND JO=N1)+(3220 AND JO=N2)+(3270 AND JO=N3) 3220 LET HV=FV 3230 GO TO 3270 3250 LET V(4)=15: LET JR=JW+N1: LET JL=JW-N1: IF NOT JL THEN LET JL=4 3260 LET HV=V(JR): IF V(JR)>V(JL) THEN LET HV=V(JL) 3270 FOR I=N1 TO N3: LET K(I)=V(I): IF V(I)<5 THEN LET K(I)=HV 3280 NEXT I: IF K(N1)<>K(N2) OR K(N2)<>K(N3) THEN GO TO 3300 3290 IF J(K(N1)) THEN LET JA=N1: LET JC=15: GO SUB 1400 3300 LET W1=N0: LET W2=N0 3310 FOR I=N1 TO N3: IF K(I)=13 THEN LET W1=W1+N1 3320 NEXT I: LET NS=N1+(K(N1)=K(N2))+(K(N2)=K(N3)): LET W2=R(NS,K(N2)) 3330 LET W1=W2: IF W1>WI THEN LET WI=W1 3340 IF JA AND WI>N0 AND WI<10 THEN LET WI=10 3350 IF DO THEN LET WI=WI*N2 3360 RETURN 3400 REM bet here 3410 LET DT=N1: LET G(N1)=WI*N2: LET G(N2)=N0: LET G(N3)=INT (N3*WI/N2): LET G(4)=INT (WI/N2) 3420 LET NG=NG+N1: GO SUB 1300: PRINT AT 21,12; PAPER 5;"STOP" 3430 FOR I=N1 TO PI: PRINT AT I,8; PAPER 6;" ": NEXT I 3440 LET R=R+N1: IF R>4 THEN LET R=N1 3450 PRINT AT E(R,N1),E(R,N2); PAPER 6;G(R): BEEP .003,10+3*R 3460 IF I$<>"S" AND I$<>"s" THEN LET I$=INKEY$: GO TO 3480 3470 LET DT=(N1+RND*250) 3475 FOR I=N1 TO DT: NEXT I: IF DT>200 THEN GO TO 3490 3480 PRINT AT E(R,N1),E(R,N2); PAPER 6;" ": GO TO 3440 3490 FOR I=N1 TO PI: PRINT AT I,8;TAB 31;: NEXT I 3500 LET GW=GW+G(R)-WI: LET WI=G(R): RETURN 4000 REM MAIN PROGRAM 4010 GO SUB 6000: REM SET UP 4020 GO SUB 2300: REM ADAPT 4030 LET CA=N2*HB+(MO>N1)+N1: GO SUB (2500 AND CA=N1)+(2600 AND CA=N2)+(2500 AND CA=N3)+(2700 AND CA=4) 4040 PRINT AT PI,8;TAB 31;: LET CA=(I$="I" OR I$="i")+N2*(I$="P" OR I$="p")+N3*(I$="E" OR I$="e") 4050 GO TO (4030 AND CA=N0)+(4100 AND CA=N1)+(4200 AND CA=N2)+(4700 AND CA=N3) 4100 LET NI=NI+N1: LET IN=4: GO SUB 1100: IF MO>MM THEN LET MM=MO 4110 GO TO 4030 4200 LET IN=-N2: GO SUB 1100 4210 GO SUB 2000: REM play 4230 GO SUB 3100: REM joker 4240 REM GO SUB 3200: REM winnings 4250 IF H(N1)+H(N2)+H(N3)>N0 THEN GO TO 4270 4260 LET HB=N0: LET LW=WI: GO TO (4290 AND WI>N0)+(4020 AND WI<=N0) 4270 LET HB=N1: IF WI>LW THEN GO TO 4290 4275 IF NOT LW THEN GO TO 4020 4290 PRINT AT N3,10; PAPER 6;"YOU WON ";WI: FOR I=N1 TO WI: BEEP .1,20: NEXT I 4300 IF MON0 THEN GO TO 4290 4520 GO TO 4280 4600 LET WI=N0: GO TO 4020 5600 REM STOP GAME 5610 CLS : PRINT '"AMOUNT OF MONEY"'' 5620 PRINT " PUT IN :";: LET X=NI: GO SUB 5800 5630 PRINT " GOT BACK:";: LET X=MO/4: GO SUB 5800 5640 PRINT " MAX AT ONE TIME:";: LET X=MM/4: GO SUB 5800 5650 IF GW>=n0 THEN PRINT " WON BY GAMBLING:";: LET X=GW/4: GO SUB 5800 5660 IF GW