This package contains two linked programs: a full backgammon game and a standalone animated dice roller. The backgammon program implements complete rules including doubling cube mechanics (with accept/reject prompts), gammon and backgammon scoring multipliers, bar handling, bearing off, and a computer opponent with four selectable skill levels controlled by the variable LMX. The computer AI uses machine code routines called via USR at addresses in the 16000s and 17000s, with Z80 opcodes embedded in a REM statement at line 1; these routines handle board evaluation, move generation, and dice animation using direct POKE/USR calls to display animated dice faces. The dice program similarly uses POKE 16514/16515 and USR 16530 to drive a hardware-level dice display animation loop with random spin counts. Both programs share the POKE/USR idiom for driving low-level display routines and include a self-referencing SAVE/RUN line for re-loading.
Program Analysis
Program Structure
The package consists of two independent BASIC programs. The first (lines 1–9993) is the backgammon game proper. The second (lines 1–9993 of the second listing) is a standalone animated dice demonstration. Each program stores its machine code payload in the bytes of a REM statement at line 1, accessed through USR calls at various addresses.
The backgammon program is organized into functional blocks:
- Lines 1–14: Machine code (REM) and array/variable dimensioning
- Lines 150–384: Title screen, skill level and speed selection
- Lines 400–800: Score display and game loop
- Lines 900–960: Generic keypress input subroutine
- Lines 1010–1570: Main game flow, win/loss detection, scoring
- Lines 2000–2800: Human player move input and validation
- Lines 3000–3990: Computer move selection (AI loop)
- Lines 4000–4900: Doubling cube logic
- Lines 5000–5990: Board evaluation scoring
- Lines 6000–6990: Move generation for computer
- Lines 7000–7690: Board display update routines
- Lines 8000–8990: Display helpers, dice rolling, board initialization
- Lines 9000–9390: Full board drawing (large PRINT block)
- Lines 9700–9790: Variable initialization
- Lines 9990–9993: SAVE and auto-run
Machine Code Usage
The REM statement at line 1 of the backgammon program holds a substantial Z80 machine code block. Multiple entry points are used, called via USR with specific addresses:
| Address | Purpose |
|---|---|
| 16523 / 16530 | Dice face display (POKE-driven, used in both programs) |
| 16639 | Board position penalty scoring (returns value subtracted from T) |
| 16642 | Apply/undo a trial move (toggled by BB) |
| 16645 | Find best source point for a move (returns point in Q) |
| 16648 | Board evaluation, populates T(1) and T(2) |
| 17348 | Format a move as a string into P$ |
| 17351 | Read player’s move input into N |
| 17354 | Display E$/F$ prompt strings on screen |
The dice animation in both programs is driven by POKE 16514 (die value) and POKE 16515 (screen column offset: 0 for left die, 27/144 for right), then calling USR to render a die face. This completely bypasses BASIC graphics for speed.
AI and Game Logic
The computer AI (lines 3000–3990) iterates up to LMX times (set at line 350 as 10*2^(SKL-1), giving 10/20/40/80 iterations for skill levels 1–4). Each iteration calls the move generator (line 6000) and the evaluator (line 5000). The best-scoring position is saved in arrays Q(I,1)/Q(I,2) via GOSUB 3900. In FAST mode (line 3190) the inner loop runs without screen updates for speed.
The evaluation function at line 5000 calls machine code at USR 16648 to populate T(1) (blot exposure) and T(2) (prime/blocking score). The BASIC then combines these with weighted terms: T = 9*T(2) + 36*HI + ZO, with an additional blot penalty term when BB=1. A penalty for weak positions is subtracted via USR 16639.
The doubling cube is fully implemented. DC tracks ownership (0 = centered, -1 = player holds, used to gate re-doubling). Lines 4100–4900 contain the computer’s decision to offer a double, using pip count comparisons and formulas like (3*P+100+100*DC)/40 to set thresholds. The player’s accept/reject uses INPUT R$ at line 4520.
Board Representation
The 24 points are stored in arrays Y(24) (player pieces) and Z(24) (computer pieces), numbered 1–24 from the player’s perspective. Bar pieces are tracked separately in YB and ZB. Pip counts YC and ZC are maintained incrementally throughout moves rather than recalculated, initialized to 167 each (the sum of all checker positions in the standard setup). Remaining piece counts YN and ZN start at 15 and decrement as pieces bear off.
Board Display
The initial board is drawn by a single large PRINT statement at line 9050 using inverse-video characters for the dark points (represented as %O etc.) and block graphics for borders. Updates are handled by subroutine 8500 (GOSUB 8500), which recalculates the screen column for a point using the formula 31-2*N-5*INT(N/7) for the upper half and 2*(N-12)+5*INT(N/19) for the lower half, accounting for the central bar gap. Bar piece display is handled by subroutine 7100 (line 7115), which prints a row of inverse O characters for computer pieces and normal O for player pieces.
Dice Animation
Subroutine 8800 (lines 8805–8890) animates dice by looping 7 times, each time generating random D(1) and D(2) values and calling the display machine code twice per die (once to erase with value 0, once to draw). The final values after the loop become the actual dice roll. Doubles set M=4 (four moves available); otherwise M=2.
The standalone dice program uses the same POKE/USR technique but with a simpler loop at line 2100, spinning INT(6+3*RND) times and waiting for a keypress at line 1110 to trigger the next roll.
Key BASIC Idioms
PAUSE 999at line 1482 for a timed display hold after win/loss announcement.VAL "number"is not used here; literal line numbers appear inGOTO/GOSUB.- The
GOSUB 900input routine uses thePAUSE 0/INKEY$pattern at line 920 to wait for a keypress efficiently. - String slicing (
F$(4*I-3 TO 4*I)at line 8039) is used to pack move notation into a fixed-width string. - The score display at line 422 uses
"\~~\~~\~~\~~\~~"— the~token represents theFREEkeyword, which here is inside a string literal and prints as the FREE character glyph rather than executing as a command.
Notable Anomalies
- Line 2550 is referenced by a
GOTOfrom line 2500 but the listing shows line 2555 as the first line in that block — line 2550 does not appear. This is a likely typo or missing line; execution would fall through or produce an error in the “bearing off with higher pieces still present” check. - Line 2240 is referenced (
GOTO 2240from line 2230) but does not appear in the listing; the move acceptance path appears to continue at line 2250, suggesting a missing or omitted line. - Variables
S$andP$are used (lines 1415, 8039) but not dimensioned in the initialization block at lines 9700–9790; they rely on implicit string sizing. - Line 8755 sets
E$=""after aUSR 17354call — the subroutine at 8710 is entered fromGOSUB 8700references throughout, but the listing shows 8710 as the entry point with 8755 as a fall-through clearing step, suggesting the subroutine label and display call are split across lines.
Content
Source Code
1 REM 6 023 343 1452224CDAD403A8340 E 4CB4728 2 E873A8240E6 7C847CB4720 13CCDBB40713D10F9C9 E 0 6 73E 03CCDBB407110F9C9F516 05F218340193A8340865F16 02A C40191153 219F1C9 B C D F F11 6 6 5 3 2 3 D 0 3 0 1 012 4 4 4 6 A 8 6 4 2 2 2 2 2 2 2 2 2 2 4 5 3 2 2 2C31D42C3D742C34E4321 0 022824022E4403E 132E04032E1403C32E24021 5 1CD5D41C52113 1CD5D41E1 97CB528 93E 13283403C32E14021 C 1CD5D4179328240CDA341ED4BE440 6 0212A 1CD8341C93DC811 5 0193D20FCC9E5ED4B1040 97EE67F47 E 02816237EF68057235E21 0 0CB23CB12CB15CB1410F6444DE1C9E5C578B128 D3E91CB21CB103D30F9CB38CB19ED5B1040197723702371C1E1C921 6 0CDCB4220143E 232E2402184 0CDCB4228163E 232E14018 F3AE1403D32E440 D20 83E 232E240C312423A8240B73E 228 B21E640ED5BE04016 0197E5F16 03AE2404721 0 01910FDE5211E 13AE140CD5341CD5D41E1 9444D211E 13AE140CD5341CD834121E2403421E040343E19BEC2A341C93E 132E14021 0 022E2402131 1CD5D417932E6402AE0406C22E04021 6 0CDCB42 D206A3E 032824032E4403A8340B728123AE140FE D30 B 1D3406F26 0 97E32824021E0403528253AE4403C32E440FE D301A2184 0CDCB4228E7 1D3403AE4406F26 0 97E218240867718D53A8240B728195F3AE140473E19904721 0 016 01910FDED5BE2401922E24021E140343AE6403CBEC23242ED4BE240C9E5218240CB4628 2ED44814FE1C93AE040CD5341CD5D4178B1C9212A 1CD5D41793282402138 1CD5D4179FE19201021FE 0CD5D413EFFCDBD42CD8341181132E04021 6 0CDCB423EFFCDBD42CD8341213F 1CD5D417932E040B020 F2146 1CD5D413E 1CDBD42CD8341C921 6 0CDCB423E 1CDBD42CD83412184 0CDCB42C82113 1CD5D413AE040CDBD42CD8341C9214D 1CD5D41ED43E040212A 1CD5D41ED43824021 6 0CDCB4228173A8240473AE040903822281C2184 0CDCE4279FE 238 A21E0403520DB 1 0 0C93AE0404F 6 0C93E 618 33AE040ED4BE040414FED43E04021E040347EFE1928 C21 6 0CDCB4228EF 1 0 0C93AE1404F 6 0212A 1C38341C35D44CD11442158 1117A 2CDD9432172 1119B 2ED4B1040 9EBED4B C40 9E5 61436 02310FBE1EBE5 114 0 9AF 52B 4B628FBE1EB78FE14D0CB3848 6 0 9ED44C6144F 6 0EBEDB0C92A1040 1A1 1 97ED626D83CFE1AD0FE1920 1AF 6 04F2187 1C5C5CD83412138 1C1CD8341218D 1CD5D41E1 9444D213F 1CD8341CD5D44ED4B10402172 1 9EB2198 1 9 1 3 0EDB0C91198 12A104019EB2138 1CD7344133E161213213F 1D5CD5D4179B728 9FE1938 3AF18 2C625D112C9 2 0EA
10 GOSUB 9700
12 DIM P(4,2)
13 DIM Q(4,2)
14 DIM D(2)
150 LET ZSC=0
155 LET YSC=0
200 CLS
220 PRINT AT 2,11;"BACKGAMMON"
230 PRINT AT 4,14;"FROM"
240 PRINT AT 6,8;"PSION COMPUTERS"
250 RAND
290 LET E$="ZX81 SKILL LEVEL?"
295 LET F$="PRESS 1,2,3 OR 4"
300 GOSUB 900
310 LET SKL=CODE R$-28
320 IF SKL<1 OR SKL>4 THEN GOTO 290
350 LET LMX=10*2**(SKL-1)
360 LET E$="FAST OR SLOW MODE?"
362 LET F$="PRESS F OR S"
370 GOSUB 900
382 LET FST=1
384 IF R$="S" THEN LET FST=0
410 CLS
420 PRINT AT 2,13;"SCORE"
422 PRINT AT 3,13;"~~~~~~~~~~"
430 PRINT AT 6,9;"YOU.......";YSC
440 PRINT AT 9,9;"ZX81......";ZSC
450 PRINT AT 14,0;"ZX81 SKILL LEVEL: ";SKL;TAB 27;
452 IF FST=0 THEN PRINT "SLOW"
454 IF FST=1 THEN PRINT " FAST"
460 LET E$="CHANGE SKILL LEVEL?"
462 LET F$="PRESS Y OR N"
470 GOSUB 900
480 IF R$="Y" THEN GOTO 200
500 GOSUB 1000
800 GOTO 400
900 LET T=USR 17354
920 IF INKEY$="" THEN GOTO 920
930 LET R$=INKEY$
940 IF R$=" " THEN GOTO 920
950 LET E$=""
952 LET F$=""
960 RETURN
1010 GOSUB 9000
1220 GOSUB 8800
1223 GOSUB 8900
1225 IF M=2 THEN GOTO 1300
1230 LET DD=2
1240 PRINT AT 8,15;"02"
1250 GOSUB 8800
1260 IF M=4 THEN GOTO 1250
1300 IF D(1)>D(2) THEN GOTO 1305
1301 GOSUB 2125
1302 GOTO 1340
1305 GOSUB 3030
1310 GOSUB 2000
1320 IF YN<1 THEN GOTO 1410
1340 GOSUB 3000
1350 IF ZN<1 THEN GOTO 1510
1400 GOTO 1310
1410 LET F$=""
1415 LET S$="YOU WIN"
1420 IF YN<0 OR ZN<15 THEN GOTO 1460
1425 LET F$="GAMMON"
1430 LET DD=2*DD
1435 IF ZB>0 THEN GOTO 1450
1440 FOR I=18 TO 24
1441 IF Z(I)>0 THEN GOTO 1447
1442 NEXT I
1445 GOTO 1460
1450 LET F$="BACKGAMMON"
1452 LET DD=1.5*DD
1460 LET YSC=YSC+DD
1470 LET S$=S$+" "+STR$ DD+" POINT"
1475 IF DD>1 THEN LET S$=S$+"S"
1476 LET E$=S$
1480 GOSUB 8700
1482 PAUSE 999
1490 RETURN
1510 LET F$=""
1515 LET S$="I WIN"
1520 IF ZN<0 OR YN<15 THEN GOTO 1560
1530 LET DD=2*DD
1532 LET F$="GAMMON"
1535 IF YB>0 THEN GOTO 1550
1540 FOR I=1 TO 6
1541 IF Y(I)>0 THEN GOTO 1550
1542 NEXT I
1545 GOTO 1560
1550 LET DD=1.5*DD
1552 LET F$="BACKGAMMON"
1560 LET ZSC=ZSC+DD
1570 GOTO 1470
2010 LET E$="PRESS A KEY"
2015 GOSUB 900
2017 LET U=USR 17354
2020 RAND
2025 IF R$<>"D" OR DC=1 THEN GOTO 2120
2030 LET E$="I WILL CONSIDER"
2032 LET F$="YOUR OFFER"
2035 GOSUB 8700
2050 GOSUB 4000
2060 IF YN<0 THEN RETURN
2065 LET E$="I ACCEPT"
2067 GOSUB 8700
2070 LET DC=1
2075 LET DD=2*DD
2080 GOSUB 8600
2090 PRINT AT 2,15;
2095 GOSUB 8300
2120 GOSUB 8800
2125 LET M1=M
2126 LET G=1
2127 LET R=1
2128 LET F=0
2129 GOSUB 8200
2130 GOSUB 2800
2132 IF J<0 THEN GOTO 2600
2145 LET P=D(R)
2147 LET E$="YOUR MOVE WITH THE "+STR$ P
2157 GOSUB 900
2160 LET N=-1
2161 LET U=USR 17351
2164 IF N<0 THEN GOTO 2190
2165 LET E$="PRESS NEW LINE"
2170 GOSUB 900
2171 IF CODE (R$)<>118 THEN GOTO 2160
2172 LET E$=""
2173 LET F$=P$
2174 GOSUB 8700
2175 IF N>0 THEN GOTO 2200
2178 IF YB=0 THEN GOTO 2212
2180 IF Z(P)>1 THEN GOTO 2232
2181 LET YC=YC-25
2182 LET YB=YB-1
2184 GOSUB 7100
2186 LET N=P
2188 GOTO 2260
2190 IF R$<>"Z" THEN GOTO 2147
2192 IF F=0 THEN LET R=3-R
2197 GOTO 2145
2200 IF YB=0 THEN GOTO 2210
2202 LET F$="YOU ARE ON THE BAR"
2203 GOSUB 8700
2204 GOTO 2145
2210 IF Y(N)>0 THEN GOTO 2220
2212 LET F$="NOTHING THERE"
2214 GOTO 2203
2220 IF N+P<25 THEN GOTO 2230
2221 IF LP>18 THEN GOTO 2500
2222 GOSUB 2740
2223 IF LP>18 THEN GOTO 2500
2224 LET F$="OFF THE BOARD"
2226 GOTO 2203
2230 IF Z(N+P)<2 THEN GOTO 2240
2232 LET F$="BLOCKED"
2234 GOTO 2203
2250 LET Y(N)=Y(N)-1
2251 LET YC=YC-25+N
2252 GOSUB 8500
2255 LET N=N+P
2257 LET FLG=0
2260 IF Z(N)<>1 THEN GOTO 2280
2264 LET Z(N)=0
2267 LET ZC=ZC+25-N
2268 LET ZB=ZB+1
2269 LET FLG=1
2280 LET Y(N)=Y(N)+1
2281 LET YC=YC+25-N
2282 GOSUB 8500
2283 IF FLG=1 THEN GOSUB 7100
2285 LET G=G+1
2290 LET R=3-R
2291 LET F=1
2292 IF YN=0 THEN RETURN
2293 IF G>M THEN RETURN
2294 IF G>M1 THEN GOTO 2600
2295 GOTO 2130
2500 IF N+P>25 THEN GOTO 2550
2510 LET YN=YN-1
2520 LET Y(N)=Y(N)-1
2530 LET YC=YC-25+N
2540 GOTO 2282
2555 FOR I=19 TO N-1
2560 IF Y(I)>0 THEN GOTO 2580
2569 NEXT I
2570 GOTO 2510
2580 LET F$="WHAT ABOUT "+CHR$ (I+37)
2590 GOTO 2203
2610 LET E$="YOU CAN NOT MOVE"
2620 GOTO 8700
2700 LET J=-2
2710 IF YB=0 THEN GOTO 2735
2715 IF Z(P)>1 THEN RETURN
2720 LET J=0
2725 RETURN
2735 IF LP>0 THEN GOTO 2747
2740 FOR I=1 TO 24
2742 IF Y(I)=0 THEN GOTO 2746
2744 LET LP=I
2745 GOTO 2747
2746 NEXT I
2747 IF LP<24-P THEN GOTO 2750
2748 LET J=LP
2749 RETURN
2750 FOR I=LP TO 24-P
2752 IF Y(I)=0 THEN GOTO 2759
2754 IF Z(I+P)>1 THEN GOTO 2759
2756 LET J=I
2758 RETURN
2759 NEXT I
2770 FOR I=LP TO 24-P
2772 IF Y(I)>0 THEN RETURN
2774 NEXT I
2780 LET J=25-P
2790 RETURN
2805 IF G=1 THEN LET LP=0
2810 IF M=2 THEN GOTO 2820
2811 LET P=D(1)
2815 GOTO 2700
2820 IF G=2 THEN RETURN
2825 FOR S=1 TO 2
2827 LET T(S)=0
2830 LET P=D(S)
2831 GOSUB 2700
2835 LET N=J
2836 LET Q=N+P
2838 IF N<0 THEN GOTO 2860
2840 LET T=1
2842 GOSUB 2950
2844 LET T(S)=1
2845 LET P=D(3-S)
2846 GOSUB 2700
2848 IF J<0 THEN GOTO 2855
2850 LET T(S)=2
2855 IF N<0 THEN GOTO 2860
2856 LET T=-1
2858 GOSUB 2950
2860 NEXT S
2862 IF T(1)=0 AND T(2)=0 THEN RETURN
2865 IF T(1)=2 AND T(2)=2 THEN RETURN
2867 LET F=1
2868 LET J=1
2870 IF T(1)=2 OR T(2)=2 THEN GOTO 2890
2871 LET M1=1
2872 IF T(1)=0 THEN LET R=2
2880 RETURN
2891 IF T(2)=2 THEN LET R=2
2895 RETURN
2955 IF N=0 THEN LET YB=YB-T
2960 IF N>0 THEN LET Y(N)=Y(N)-T
2965 IF Q<25 THEN LET Y(Q)=Y(Q)+T
2990 RETURN
3000 GOSUB 4100
3001 IF ZN<0 THEN RETURN
3005 LET E$="MY THROW"
3010 GOSUB 8700
3020 GOSUB 8800
3025 GOSUB 8200
3030 LET G=0
3031 LET M1=1
3032 LET F=-9999
3034 LET HI=0
3035 LET WB=0
3036 LET ZO=0
3040 FOR I=1 TO 4
3042 LET Q(I,1)=0
3044 LET Q(I,2)=0
3045 NEXT I
3055 LET WW=1
3057 LET LP=18
3060 LET XP=3
3062 LET WB=0
3065 LET SM=D(1)+D(2)
3070 IF D(1)=D(2) THEN LET SM=2*SM
3075 LET SM=SM+YC-ZC
3080 IF SM<(3*ZC+380)/40 THEN GOTO 3100
3085 LET WB=-999
3087 LET LP=15
3090 LET WW=0
3095 LET XP=9
3100 GOSUB 8750
3105 GOSUB 8700
3120 GOSUB 6000
3125 IF G=0 THEN GOTO 3300
3130 GOSUB 5000
3135 GOSUB 3900
3140 LET LM=2
3190 IF FST=1 THEN FAST
3200 GOSUB 6000
3210 IF G<M1 THEN GOTO 3300
3230 GOSUB 5000
3240 IF T>F OR G>M1 THEN GOSUB 3900
3280 LET LM=LM+1
3290 IF LM<=LMX THEN GOTO 3200
3300 SLOW
3310 GOSUB 8000
3330 GOSUB 7500
3350 RETURN
3910 LET F=T
3915 LET M1=G
3920 FOR I=1 TO M
3925 LET Q(I,1)=P(I,1)
3930 LET Q(I,2)=P(I,2)
3935 NEXT I
3990 RETURN
4010 GOSUB 5900
4020 IF P<55 THEN GOTO 4050
4030 IF ZC-YC>(3*P+220)/40 THEN LET YN=-1
4040 RETURN
4050 GOSUB 5500
4060 IF N-M>1+INT (M/6) THEN LET YN=-1
4090 RETURN
4140 IF DC=-1 THEN RETURN
4150 IF ZC>YC THEN RETURN
4160 GOSUB 5900
4165 IF P>110 THEN RETURN
4175 IF P<55 THEN GOTO 4250
4180 LET N=YC-ZC
4190 IF N<(3*P+100+100*DC)/40 THEN RETURN
4200 IF YN=15 AND N>35 THEN RETURN
4210 GOTO 4300
4250 GOSUB 5900
4260 LET N=M-N
4270 IF N<2 THEN RETURN
4280 IF YN=15 AND N>12 THEN RETURN
4310 FOR I=24 TO 18 STEP -1
4320 IF Z(I)>0 THEN GOTO 4350
4325 NEXT I
4330 GOTO 4500
4350 LET N=0
4360 FOR J=12 TO I
4365 IF Y(J)>1 THEN LET N=N+1
4370 NEXT J
4380 IF N>3 THEN RETURN
4510 LET E$="DOUBLE? ENTER A OR R"
4512 LET F$="TO ACCEPT OR REJECT"
4515 GOSUB 8700
4520 INPUT R$
4525 IF R$<>"R" THEN GOTO 4550
4530 LET ZN=-1
4540 RETURN
4550 LET DD=2*DD
4560 LET DC=-1
4570 GOSUB 8600
4574 PRINT AT 11,0
4580 GOSUB 8300
4900 RETURN
5015 LET BB=0
5025 LET T(1)=0
5030 LET T(2)=0
5100 LET U=USR 16648
5260 LET T=9*T(2)+36*HI+ZO
5270 IF BB=1 THEN LET T=T+XP*T(1)+WB
5290 IF T<=F THEN RETURN
5300 LET U=USR 16639
5310 LET T=T-U
5350 RETURN
5560 LET M=0
5570 LET N=0
5600 FOR I=1 TO 24
5605 LET J=INT ((I-1)/4+1)
5610 LET N=N+Z(I)*J
5620 LET M=M+Y(I)*J
5630 NEXT I
5650 LET N=N+ZB*7
5660 LET M=M+YB*7
5690 RETURN
5910 LET P=YC
5920 IF ZC>P THEN RETURN
5930 LET P=ZC
5940 RETURN
6010 IF G>0 THEN GOTO 6250
6015 LET R=1
6016 LET G=1
6020 LET Q=24
6030 LET JL=Q
6032 LET P=D(R)
6034 IF G<>1 THEN LET P=D(3-R)
6040 IF ZB=0 THEN GOTO 6050
6042 LET S=25-P
6043 IF Y(S)>1 THEN GOTO 6225
6044 LET P(G,1)=25
6045 LET P(G,2)=S
6049 GOTO 6200
6050 LET BB=P
6060 LET Q=USR 16645
6070 IF Q=0 THEN GOTO 6225
6080 LET S=Q-BB
6100 LET P(G,1)=Q
6112 LET P(G,2)=S
6210 GOSUB 6800
6215 IF G=M THEN RETURN
6220 LET G=G+1
6222 GOTO 6030
6225 IF G>M1 THEN GOTO 6380
6230 IF G=1 THEN GOTO 6350
6236 LET G=G-1
6250 GOSUB 6900
6251 IF P(G,1)=25 THEN GOTO 6350
6252 IF P(G,2)=0 THEN GOTO 6230
6255 LET JL=P(G,1)-1
6260 IF JL<1 THEN GOTO 6230
6270 LET P=D(R)
6275 IF G<>1 THEN LET P=D(3-R)
6290 GOTO 6050
6350 IF M=4 OR R=2 THEN GOTO 6365
6355 LET R=2
6360 IF G=1 THEN GOTO 6020
6362 GOSUB 6900
6363 LET G=G-1
6364 GOTO 6360
6370 IF G=1 THEN GOTO 6380
6371 GOSUB 6900
6372 LET G=G-1
6375 GOTO 6365
6380 FOR I=G TO M
6385 LET P(I,1)=0
6386 LET P(I,2)=0
6390 NEXT I
6393 LET G=G-1
6395 RETURN
6810 LET P1=P(G,1)
6811 LET P2=P(G,2)
6820 LET BB=0
6830 LET BB=USR 16642
6890 RETURN
6910 LET P1=P(G,1)
6911 LET P2=P(G,2)
6920 LET BB=1
6930 LET BB=USR 16642
6990 RETURN
7115 PRINT AT 8,1;"@@@@@@@@@@@@@@@@@@@@@@@@@@";TAB 18;"@@@@@@@@@@@@@@@@@@@@@@@@"
7120 IF ZB=0 THEN GOTO 7150
7125 PRINT AT 8,14-ZB;
7130 FOR I=1 TO ZB
7135 PRINT "%O";
7140 NEXT I
7150 IF YB=0 THEN RETURN
7155 PRINT AT 8,18;
7160 FOR I=1 TO YB
7165 PRINT "O";
7170 NEXT I
7190 RETURN
7520 IF G=0 THEN GOTO 7550
7525 GOSUB 6900
7530 LET G=G-1
7535 GOTO 7520
7550 FOR Q=1 TO M
7555 LET P1=Q(Q,1)
7560 LET P2=Q(Q,2)
7562 IF P1=P2 THEN GOTO 7655
7565 GOSUB 6820
7568 LET ZC=ZC+P2-P1
7570 LET N=P1
7575 IF N<25 THEN GOTO 7595
7580 GOSUB 7100
7590 GOTO 7600
7595 GOSUB 8500
7600 LET N=P2
7605 IF N>0 THEN GOTO 7610
7606 LET ZN=ZN-1
7607 GOTO 7650
7610 LET FLG=0
7615 IF Y(N)=0 THEN GOTO 7630
7620 LET Y(N)=0
7621 LET YC=YC+N
7623 LET YB=YB+1
7625 LET FLG=1
7630 GOSUB 8500
7635 IF FLG=1 THEN GOSUB 7100
7650 NEXT Q
7690 RETURN
8000 LET E$="MY MOVES ARE"
8010 LET F$=""
8025 IF Q(1,1)=Q(1,2) THEN LET F$="I CAN NOT MOVE"
8030 FOR I=1 TO M
8035 LET P1=Q(I,1)
8036 LET P2=Q(I,2)
8037 IF P1=P2 THEN RETURN
8038 LET U=USR 17348
8039 LET F$(4*I-3 TO 4*I)=P$
8040 NEXT I
8045 LET U=USR 17354
8090 RETURN
8210 IF D(1)>D(2) THEN RETURN
8220 LET BB=D(1)
8230 LET D(1)=D(2)
8240 LET D(2)=BB
8250 RETURN
8310 LET P$=STR$ (100+DD)
8330 PRINT TAB 15;"''''"
8332 PRINT TAB 15;P$(2 TO 3)
8334 PRINT TAB 15;"...."
8340 RETURN
8501 LET JL=Y(N)+Z(N)
8502 LET BB=JL
8503 IF JL>7 THEN LET JL=7
8507 LET R$="O"
8508 IF Z(N)>0 THEN LET R$="%O"
8510 IF N>12 THEN GOTO 8550
8511 LET X=31-2*N-5*INT (N/7)
8512 IF JL=0 THEN GOTO 8530
8515 FOR J=1 TO JL
8516 PRINT AT J,X;R$
8517 NEXT J
8520 IF JL=BB THEN GOTO 8530
8521 LET S=BB-JL
8522 LET R$=CHR$ (CODE R$-24)
8525 FOR J=1 TO S
8526 PRINT AT J,X;R$
8527 NEXT J
8529 RETURN
8530 LET S=JL+1
8531 IF S>7 THEN RETURN
8532 FOR J=S TO 7
8534 PRINT AT J,X;"@@"
8535 NEXT J
8545 RETURN
8550 LET X=2*(N-12)+5*INT (N/19)
8551 IF JL=0 THEN GOTO 8570
8555 FOR J=1 TO JL
8556 PRINT AT 16-J,X;R$
8557 NEXT J
8560 IF JL=BB THEN GOTO 8570
8561 LET S=BB-JL
8562 LET R$=CHR$ (CODE R$-24)
8565 FOR J=1 TO S
8566 PRINT AT 16-J,X;R$
8567 NEXT J
8569 RETURN
8570 LET S=JL+1
8572 IF S>7 THEN RETURN
8575 FOR J=S TO 7
8576 PRINT AT 16-J,X;"@@"
8577 NEXT J
8595 RETURN
8610 PRINT AT 0,0;
8620 FOR I=1 TO 15
8630 PRINT TAB 15;"% % "
8640 NEXT I
8650 RETURN
8710 LET U=USR 17354
8755 LET E$=""
8760 LET F$=""
8790 RETURN
8805 FOR I=1 TO 7
8810 LET D(1)=INT (RND*6+1)
8820 LET D(2)=INT (RND*6+1)
8825 FOR J=0 TO 1
8830 POKE 16514,J*D(1)
8832 POKE 16515,0
8834 LET P=USR 16523
8840 POKE 16514,J*D(2)
8842 POKE 16515,27
8844 LET P=USR 16523
8850 NEXT J
8870 NEXT I
8880 LET M=2
8882 IF D(1)=D(2) THEN LET M=4
8890 RETURN
8910 FOR I=1 TO 24
8920 LET Z(I)=0
8925 LET Y(I)=0
8930 NEXT I
8940 LET Y(1)=2
8942 LET Z(6)=5
8944 LET Z(8)=3
8946 LET Y(12)=5
8948 LET Z(13)=5
8950 LET Y(17)=3
8952 LET Y(19)=5
8954 LET Z(24)=2
8960 LET ZN=15
8962 LET YN=15
8963 LET ZC=167
8964 LET YC=167
8965 LET ZB=0
8966 LET YB=0
8967 LET DD=1
8968 LET DC=0
8990 RETURN
9000 CLS
9050 PRINT "% % %L% %K% %J% %I% %H% %G% % % % % % %F% %E% %D% %C% %B% %A% % % @@O@@@@@@@@@@@@@@%O@@@@@@% % % % @@%O@@@@@@@@@@@@@@@@@@O@@% % @@O@@@@@@@@@@@@@@%O@@@@@@% % % % @@%O@@@@@@@@@@@@@@@@@@O@@% % @@O@@@@@@@@@@@@@@%O@@@@@@% % % % @@%O@@@@@@@@@@@@@@@@@@@@@@% % @@O@@@@@@@@@@@@@@@@@@@@@@% % % % @@%O@@@@@@@@@@@@@@@@@@@@@@% % @@O@@@@@@@@@@@@@@@@@@@@@@% % % % @@%O@@@@@@@@@@@@@@@@@@@@@@% % @@@@@@@@@@@@@@@@@@@@@@@@@@% % % % @@@@@@@@@@@@@@@@@@@@@@@@@@% % @@@@@@@@@@@@@@@@@@@@@@@@@@% ''''% @@@@@@@@@@@@@@@@@@@@@@@@@@% % @@@@@@@@@@@@@@@@@@@@@@@@@@% 64% @@@@@@@@@@@@@@@@@@@@@@@@@@% % @@@@@@@@@@@@@@@@@@@@@@@@@@% ....% @@@@@@@@@@@@@@@@@@@@@@@@@@% % @@@@@@@@@@@@@@@@@@@@@@@@@@% % % % @@@@@@@@@@@@@@@@@@@@@@@@@@% % @@%O@@@@@@@@@@@@@@@@@@@@@@% % % % @@O@@@@@@@@@@@@@@@@@@@@@@% % @@%O@@@@@@@@@@@@@@@@@@@@@@% % % % @@O@@@@@@@@@@@@@@@@@@@@@@% % @@%O@@@@@@@@@@@@@@O@@@@@@% % % % @@O@@@@@@@@@@@@@@@@@@@@@@% % @@%O@@@@@@@@@@@@@@O@@@@@@% % % % @@O@@@@@@@@@@@@@@@@@@%O@@% % @@%O@@@@@@@@@@@@@@O@@@@@@% % % % @@O@@@@@@@@@@@@@@@@@@%O@@% % % %M% %N% %O% %P% %Q% %R% % % % % % %S% %T% %U% %V% %W% %X% % "
9075 PRINT "................................................................: % % % % %P%S%I%O%N% %B%A%C%K%G%A%M%M%O%N% % % % :: % % <- ZX81 YOU -> % % :: % % % % ::.......% % % % % % % % % % % % % % % % % % % % % % % % .......:"
9390 RETURN
9710 DIM Z(24)
9711 DIM Y(24)
9712 LET ZB=0
9713 LET YB=0
9714 LET WW=0
9715 LET HI=0
9716 DIM T(2)
9717 LET BB=0
9718 LET LP=0
9719 LET P1=0
9720 LET P2=0
9721 LET ZO=0
9722 LET JL=0
9723 DIM E$(20)
9724 DIM F$(20)
9725 LET N=0
9726 LET P=0
9727 DIM P$(3)
9728 DIM R$(1)
9790 RETURN
9990 SAVE "BACKGAMMO%N"
9993 IF USR (102+PEEK 16400+256*PEEK 16401)=0 THEN RUN
1 REM 69031 1B1 0B1 1A9 0B9 12D 135 1CDB040 E 0CDEA403A8240E6 7C847CB4720 13CCDC340CDDF403D10F7C9 E80CDEA40 6 73E 03CCDC340CDDF4010F7C916 05F21824019195E2356673A8340E67F6F7C26 019ED5B C4019C97123711120 019712371C93A8340E680A94FC927272727
50 CLS
60 FOR I=1 TO 22
62 PRINT "################################################################"
64 NEXT I
70 PRINT AT 3,0
80 FOR I=1 TO 12
82 PRINT "####% % % % % % % % % % % % ######## ####"
84 NEXT I
88 PRINT AT 1,10;"% %P%S%I%O%N% %D%I%C%E% "
90 PRINT AT 19,2;" PRESS ANY KEY EXCEPT BREAK "
1100 GOSUB 2000
1105 LET P=RND
1110 IF INKEY$="" THEN GOTO 1105
1120 GOTO 1100
2100 FOR I=1 TO 6+3*RND
2110 POKE 16515,0
2120 POKE 16514,0
2130 LET P=USR 16530
2140 POKE 16515,144
2160 LET P=USR 16530
2170 POKE 16515,0
2180 POKE 16514,INT (1+6*RND)
2190 LET P=USR 16530
2200 POKE 16515,144
2210 POKE 16514,INT (1+6*RND)
2220 LET P=USR 16530
2250 NEXT I
2290 RETURN
9000 STOP
9990 SAVE "DIC%E"
9993 IF USR (102+PEEK 16400+256*PEEK 16401)=0 THEN RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

