Slot

This file is part of Miscellaneous Programs, and SINCUS Exchange Tape 101 - Entertainment. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Game

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 rangePurpose
600Entry point — jumps to main program at 4000
1000–1030Flashing prompt + INKEY$ input subroutine
1100–1130Insert / eject money (update MO counter)
1200–1220Remove double-up state, redraw joker positions
1300–1310Clear status line 21
1400–1430Jackpot animation
1500–1580Flash possible hold positions and collect hold input
2000–2160Spin reels (animation + final reel-stop logic)
2300–2410Reset per-spin variables
2500–2560“Not enough money” handler
2600–2720Can-hold / cannot-hold prompt dispatchers
2800–2880Winnings prompt + generic “???” flash + delay loop
3100–3160Joker resolution (wild-card handling)
3200–3360Compute winnings into WI
3400–3500Gamble sub-game (spinning multiplier wheel)
4000–4600Main game loop
5600–5900End-of-game statistics display
6000–6500Initialisation, 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").

Content

Related Products

Related Articles

Related Content

Image Gallery

Slot

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 MO<N2 THEN LET HB=N1
 4310 GO SUB 2800: REM get instructions
 4320 LET CA=((I$="H" OR I$="h") AND NOT HB)+N2*(i$="G" OR I$="g")+N3*(i$="C" OR i$="c")
 4330 GO TO (4310 AND CA=N0)+(4600 AND CA=N1)+(4500 AND CA=N2)+(4400 AND CA=N3)
 4400 LET IN=WI: GO SUB 1100: GO TO 4020
 4500 LET HB=N1: GO SUB 3400: REM gamble
 4510 IF WI>N0 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<n0 THEN PRINT " LOST BY GAMBLING:";: LET X=-GW/4: GO SUB 5800
 5670 PRINT ''"NUMBER OF HOLDS:";: LET X=NH: GO SUB 5900
 5680 PRINT "NUMBER OF GAMBLES:";: LET X=NG: GO SUB 5900
 5700 STOP 
 5800 LET L=LEN STR$ X-LEN STR$ INT X
 5805 PRINT TAB 18;"$";
 5810 LET X$=STR$ X+("0" AND L=N2)+(".00" AND L=N0)
 5820 FOR I=LEN X$ TO 5: PRINT " ";: NEXT I: PRINT X$: RETURN 
 5900 PRINT TAB 19;: FOR I=LEN STR$ X TO N2: PRINT " ";: NEXT I: PRINT X: RETURN 
 6000 READ N0,N1,N2,N3,W$
 6100 DIM R(N3,13): DIM J(13): LET J(5)=N1: LET J(6)=N1: LET J(7)=N1
 6110 DATA 0,1,2,3,"AKQJ7*$0/=+#%"
 6120 FOR I=5 TO 12: READ R(N2,I),R(N3,I): NEXT I
 6130 DATA 8,40,8,40,7,30,5,25,N3,20,N3,20,N2,10,N2,10
 6140 DIM H(N3): DIM P(N3): DIM C(4): DIM D(4)
 6150 DIM K(N3): DIM V(4): DIM O(N3): DIM A(N3)
 6160 DIM F(N3): DIM G(4): DIM E(4,N2)
 6170 FOR I=N1 TO PI: READ P(I): LET V(I)=INT (RND*14): NEXT I
 6180 FOR i=N1 TO 4: READ d(i),e(i,N1),e(i,N2): NEXT i
 6190 DATA 12,14,16,12,N1,14,13,N2,20,15,N3,14,16,N2,9
 6200 LET b$="              "
 6209 READ NT,NJ,NI,WI,HB,DO,DC,JA,JC,MO,MM,R,GW,NH,NG
 6211 DATA -N1,4,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0,N0
 6245 FOR I=N0 TO 7: READ A
 6250 POKE USR "\a"+I,A: NEXT I
 6260 DATA 8,8,20,32,32,20,8,8
 6300 REM DRAW SCREEN$ 
 6310 CLS : PRINT AT 4,13;"25\a";TAB 11; PAPER N3;"       "
 6315 PRINT TAB 20; PAPER N2;" "
 6320 FOR I=N1 TO 4: PRINT TAB 10; PAPER N3;" "; PAPER N2;"       "; PAPER N3;" ";
 6325 PRINT TAB 20; PAPER N3;" ": NEXT I
 6330 PRINT AT 10,19; PAPER N3;" "
 6335 PRINT TAB 11; PAPER 5;"       "
 6340 FOR I=N0 TO N2: PRINT AT 9,12+N2*I; PAPER 6;" "
 6360 PRINT AT 11,12+N2*I; PAPER N2;" ": NEXT I
 6370 FOR I=N0 TO 4: PRINT TAB 12; PAPER 5;"     ": NEXT I
 6371 PRINT TAB 11; PAPER N1;"       ": PRINT TAB 10; PAPER N1;"         "
 6400 PRINT AT 8,N0;"--%- = 1";
 6410 FOR I=12 TO 5 STEP -N1
 6420 LET I$=W$(I)
 6430 PRINT AT 21-I,N0;"-";I$;I$;"- = ";R(N2,I);AT 21-I,22;I$;I$;I$;" =";R(N3,I);
 6440 IF J(I) THEN PRINT "+J"
 6450 NEXT I: RETURN 
 6500 SAVE "SLOT" LINE PI

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

People

No people associated with this content.

Scroll to Top