Without any ado, here's the Retrochallenge 2014 SC craps program that I wrote for the Epson PX-8 in BASIC.
First, a video demonstration:
Now, the source code:
1000 REM Remove menu bar and set text screen mode
1010 SCREEN 0,0,0
1020 CLS
1030 PRINT "Welcome to RC-CRAPS! What is your name: ";
1040 LINE INPUT N$
1050 REM Get random seed from 614.4 KHz clock at Z80 I/O reg 0 and 1
1060 R=INP(1)*256+INP(0)
1070 R=R-32768!
1080 RANDOMIZE R
1090 PRINT "Hello ";N$;"! Would you like instructions? (Y/N): ";
1100 YN$=INPUT$(1)
1110 IF YN$="y" OR YN$="Y" THEN GOSUB 1630
1120 BR%=1000
1130 CLS
1140 PRINT "You have ";
1150 PRINT USING "$#####";BR%;
1160 PRINT " in the bank."
1170 PRINT "Your bet? (1-50 dollars, or Q to quit: ";
1180 LINE INPUT BT$
1190 IF LEFT$(BT$,1) = "q" OR LEFT$(BT$,1) = "Q" THEN 1870
1200 BT% = VAL(BT$)
1210 IF BT%<1 OR BT%>50 THEN 1170
1220 PRINT "(P)ASS/win or (D)ON'T PASS/lose?: ";
1230 PD$=INPUT$(1)
1240 PRINT
1250 IF INSTR("PpDd",PD$)=0 THEN 1220
1260 PRINT
1270 GOSUB 1800
1280 IF (P%=7) OR (P%=11) THEN 1320
1290 IF (P%=2) OR (P%=3) THEN 1370
1300 IF (P%=12) THEN 1420
1310 GOTO 1450
1320 REM win
1330 PRINT "You win!"
1340 IF PD$="p" OR PD$="P" THEN PRINT "You bet you would win. Good job!":BR%=BR%+BT%
1350 IF PD$="d" OR PD$="D" THEN PRINT "You bet against yourself. OOPS!":BR%=BR%-BT%
1360 GOTO 1140
1370 REM lose
1380 PRINT "You lose!"
1390 IF PD$="p" OR PD$="P" THEN PRINT "You bet you would win. OOPS!":BR%=BR%-BT%
1400 IF PD$="d" OR PD$="D" THEN PRINT "You bet against yourself. Good job!":BR%=BR%+BT%
1410 GOTO 1140
1420 REM push
1430 PRINT "You rolled boxcars (12). No win or loss."
1440 GOTO 1140
1450 REM continue point roll
1460 PT%=P%
1470 PRINT "Your point is";PT%
1480 GOSUB 1800
1490 IF P% = 7 THEN 1530
1500 IF PT% = P% THEN 1570
1510 PRINT "Keep playing!"
1520 GOTO 1470
1530 PRINT "You lose"
1540 IF PD$="p" OR PD$="P" THEN PRINT "You bet you would win. OOPS!":BR%=BR%-BT%
1550 IF PD$="d" OR PD$="D" THEN PRINT "You bet against yourself. Good job!":BR%=BR%+BT%
1560 GOTO 1140
1570 PRINT "You win"
1580 IF PD$="p" OR PD$="P" THEN PRINT "You bet you would win. Good job!":BR%=BR%+BT%
1590 IF PD$="d" OR PD$="D" THEN PRINT "You bet against yourself. OOPS!":BR%=BR%-BT%
1600 GOTO 1140
1610 GOTO 1140
1620 END
1630 CLS
1640 PRINT "RC-CRAPS rules:"
1650 PRINT "1. The bank gives you an initial bankroll. Use it wisely!"
1660 PRINT "2. Make a bet on PASS (win) or DON'T PASS (loss). Max bet is $50."
1670 PRINT "3. Make an initial roll of the dice:"
1680 PRINT " 7 or 11 wins. 2 or 3 loses. 12 is a 'do over' (no win or loss)"
1690 PRINT
1700 PRINT "Press any key for next page...";
1710 NT$=INPUT$(1)
1720 CLS
1730 PRINT "4. Any other roll sets your 'point'. Rolling this again is your goal."
1740 PRINT "5. Roll again until you roll your point for a win, or 7 for a loss."
1750 PRINT "6. Good luck! Remember, what happens in RC-CRAPS, stays in RC-CRAPS!"
1760 PRINT
1770 PRINT "Press any key to continue...";
1780 NT$=INPUT$(1)
1790 RETURN
1800 REM Two dice at random
1810 PRINT "Press any key to roll the dice!"
1820 NT$=INPUT$(1):PRINT
1830 D1%=INT(RND(1)*6)+1:D2%=INT(RND(1)*6)+1
1840 P%=D1%+D2%
1850 PRINT "You rolled a";D1%;"and a";D2%;"for a";P%;"!"
1860 RETURN
1870 CLS
1880 PRINT "Thanks for playing RC-CRAPS!"
1890 PRINT "You left with $";BR%;"in the bank!"
1900 END
No comments:
Post a Comment