Category : Miscellaneous Language Source Code
Archive   : SPL.ZIP
Filename : BLACKJAC.SP

 
Output of file : BLACKJAC.SP contained in archive : SPL.ZIP
BEGIN {Program written by Steve Helm.}
INTEGER ARRAY DECK(52,2);
INTEGER A,C,DECK_PNTR,P_COUNT,D_COUNT,CARD,MONEY,X,Y,T,BET,SUM_P,SUM_D,
SUM_X;
STRING WHO,S_OR_H,CARD_STR,ACE_P,ACE_D,ACE;

PROCEDURE INITIALIZE;
BEGIN
INTEGER SUIT,VALUE,CARD;
CARD := 1;
FOR SUIT:=1 STEP 1 UNTIL 4 DO
BEGIN
FOR VALUE:=1 STEP 1 UNTIL 13 DO
BEGIN
DECK(CARD,1) := VALUE;
DECK(CARD,2) := SUIT;
CARD := CARD + 1;
END
END
END



PROCEDURE SHUFFLE;
BEGIN
INTEGER TEMP_CARD,TEMP_SUIT;
INTEGER X,RANDOM;
FOR X:=52 STEP -1 UNTIL 1 DO
BEGIN
RANDOMIZE VAL(RIGHT$(TIME$,2));
TEMP_CARD := DECK(X,1);
TEMP_SUIT := DECK(X,2);
RANDOM := INT(RND*52)+1;
DECK(X,1) := DECK(RANDOM,1);
DECK(X,2) := DECK(RANDOM,2);
DECK(RANDOM,1):= TEMP_CARD;
DECK(RANDOM,2) := TEMP_SUIT;
DECK_PNTR := 1;
END
END


PROCEDURE PRINT_CARD;
BEGIN
LOCATE Y,X;OUTPUT(' _______');
LOCATE Y+1,X;OUTPUT('| |');
LOCATE Y+2,X;OUTPUT('| |');
LOCATE Y+3,X;OUTPUT('| |');
LOCATE Y+4,X;OUTPUT('| |');
LOCATE Y+5,X;OUTPUT('|_______|');
END

PROCEDURE HEAD;
BEGIN
LOCATE 2,1;
OUTPUT (' mmmmmmmm');
OUTPUT (' /~~~~~~~~~~~~\');
OUTPUT (' / \');
OUTPUT (' | |');
OUTPUT (' (| |');
OUTPUT (' | _\ |');
OUTPUT (' | |');
OUTPUT (' \ === /');
OUTPUT (' \_________/');
END

PROCEDURE EYES;
BEGIN
LOCATE 4,7;OUTPUT(' ');
LOCATE 5,7;OUTPUT(' ~o~ ~o~ ');
END


PROCEDURE TALK;
BEGIN
LOCATE 8,12;OUTPUT(' ___');
LOCATE 9,12;OUTPUT ('(___)');
FOR C:=1 STEP 1 UNTIL 50 DO BEGIN END
LOCATE 8,12;OUTPUT(' ');
LOCATE 9,12;OUTPUT(' === ');
FOR C:=1 STEP 1 UNTIL 50 DO BEGIN END
END


PROCEDURE MAD;
BEGIN
LOCATE 4,7;OUTPUT('~~~ \ / ~~~');
LOCATE 5,7;OUTPUT(' o o');
CALL TALK;
LOCATE 23,1;OUTPUT(' PLAYER');
CALL TALK;
LOCATE 23,10;OUTPUT('WINS ');
FOR A:=1 STEP 1 UNTIL 1000 DO BEGIN END
LOCATE 23,1;OUTPUT(' ');
CALL EYES;
END



PROCEDURE SMILE;
BEGIN
CALL TALK;
LOCATE 23,1;OUTPUT('DEALER');
CALL TALK;
LOCATE 23,8;OUTPUT('WINS');
LOCATE 9,12;OUTPUT('\___/');
FOR T:=1 STEP 1 UNTIL 1000 DO BEGIN END
LOCATE 9,12;OUTPUT(' === ');
LOCATE 23,1;OUTPUT(' ');
END


PROCEDURE SUM;
BEGIN
IF CARD > 1 THEN
BEGIN
IF CARD < 10 THEN
BEGIN
CARD_STR := CHR$(CARD+48);
END
IF CARD = 10 THEN
BEGIN
CARD_STR := '10';
END
IF CARD = 11 THEN
BEGIN
CARD_STR := 'J';CARD := 10;
END
IF CARD = 12 THEN
BEGIN
CARD_STR := 'Q';CARD := 10;
END
IF CARD = 13 THEN
BEGIN
CARD_STR := 'K';CARD := 10;
END
END
ELSE
BEGIN
CARD_STR := 'A';
IF SUM_X + 11 > 21 THEN
BEGIN
CARD := 1;
END
ELSE
BEGIN
CARD := 11;
ACE := 'Y';
END
END
SUM_X := SUM_X + CARD;
IF SUM_X > 21 THEN
BEGIN
IF ACE = 'Y' THEN
BEGIN
SUM_X := SUM_X - 10;
ACE := 'N';
END
END
END






PROCEDURE PRINT_PLAYER;
BEGIN
P_COUNT := P_COUNT+1;
Y := 14;
X := P_COUNT*13-3;
CALL PRINT_CARD;
LOCATE 17,P_COUNT*13;
OUTPUT (CARD_STR);
END


PROCEDURE PRINT_DEALER;
BEGIN
D_COUNT := D_COUNT+1;
Y := 5;
X := D_COUNT*13+8;
CALL PRINT_CARD;
LOCATE 8,D_COUNT*13+11;
OUTPUT (CARD_STR);
END

PROCEDURE DEAL;
BEGIN
CARD := DECK(DECK_PNTR,1);
IF WHO = 'D'
THEN
BEGIN
SUM_X := SUM_D ; ACE := ACE_D;
CALL SUM;
SUM_D := SUM_X ; ACE_D := ACE;
CALL PRINT_DEALER;
END
ELSE
BEGIN
SUM_X := SUM_P; ACE := ACE_P;
CALL SUM;
SUM_P := SUM_X; ACE_P := ACE;
CALL PRINT_PLAYER;
END
DECK_PNTR := DECK_PNTR+1;
IF DECK_PNTR > 52 THEN CALL SHUFFLE;
END


MONEY := 1000;
CALL INITIALIZE;CALL SHUFFLE;
WHILE MONEY > 0 DO
BEGIN
FOR A:=1 STEP 1 UNTIL 50 DO BEGIN OUTPUT(' ');END
CALL HEAD;CALL EYES;
LOCATE 2,50;OUTPUT(' CREDIT ......$ ');
LOCATE 2,66;OUTPUT(MONEY);
CALL TALK;LOCATE 23,1;OUTPUT('PLACE ');
CALL TALK;LOCATE 23,7;OUTPUT('YOUR ');
CALL TALK;LOCATE 23,12;OUTPUT('BET ');
LOCATE 23,17;INPUT(BET);
LOCATE 23,1;OUTPUT(' ');
P_COUNT := 0;D_COUNT := 0;SUM_P := 0;SUM_D := 0;
ACE_P := 'N'; ACE_D := 'N';
WHO := 'P';CALL DEAL;
WHO := 'D';CALL DEAL;
WHO := 'P';CALL DEAL;
WHO := 'D';CALL DEAL;
WHO := 'P';
CALL TALK;LOCATE 23,1;OUTPUT('STAY ');
CALL TALK;LOCATE 23,6;OUTPUT('OR ');
CALL TALK;LOCATE 23,9;OUTPUT('HIT ');
LOCATE 23,14;INPUT(S_OR_H);
LOCATE 23,1;OUTPUT(' ');
WHILE S_OR_H = 'H' DO
BEGIN
CALL DEAL;
IF SUM_P < 21 THEN
BEGIN
CALL TALK;LOCATE 23,1;OUTPUT('STAY ');
CALL TALK;LOCATE 23,6;OUTPUT('OR ');
CALL TALK;LOCATE 23,9;OUTPUT('HIT ');
LOCATE 23,14;INPUT(S_OR_H);
LOCATE 23,1;OUTPUT(' ');
END
ELSE S_OR_H := 'S';
END
WHO := 'D';
IF SUM_P < 22 THEN
BEGIN
WHILE SUM_D < 16 DO
BEGIN
CALL DEAL;
CALL SUM;
END
END
IF SUM_P > 21 THEN
BEGIN
CALL SMILE;
MONEY := MONEY - BET;
END
ELSE
BEGIN
IF SUM_D > 21 THEN
BEGIN
CALL MAD;
MONEY := MONEY + BET;
END
ELSE
BEGIN
IF SUM_P <= SUM_D THEN
BEGIN
CALL SMILE;
MONEY := MONEY - BET;
END
ELSE
BEGIN
CALL MAD;
MONEY := MONEY + BET;
END
END
END
END
END


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : SPL.ZIP
Filename : BLACKJAC.SP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/