Blackjack (Twist or Stick)

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Gambling

A simplified blackjack in which you draw cards and the computer simply announces its own total. You start with $50, and each deal costs $10. Press D to deal two cards, then T to twist (take another card) or S to stick; going over 21 is a bust. Cards are drawn on a green table with UDG corners and edges, a suit symbol in two corners and the value in the middle, and a face-down card stands at the top right above your cash. When you stick, the dealer’s total is shown and the winner announced; a win pays $50, and when the money runs out the game offers to start again.

No author is credited in the program or on the disk. This copy is B-Jack from a SNUG library disk; an identical copy is on a SINCUS library disk. The program uses the British card-game words twist and stick, and a dealer total of 21 is announced as “PONTOON!”.

Program Analysis

Structure

  • Line 20 calls line 9000, which POKEs 11 UDGs from the DATA in lines 9030–9130 into USR "A" to USR "K"+7.
  • Lines 30–40 set MONEY to 50 and call line 7000, which draws the table, the face-down card and the cash, takes $10 for the deal (line 7005) and waits for D.
  • Lines 50–220 deal and draw the first two cards. Lines 225–370 handle twisting, drawing each new card six columns to the right of the last.
  • Lines 1000–1070 settle the hand when you stick, and line 1070 plays a rising and falling run of beeps before the next deal. Line 2000 handles a bust, and lines 3000–3020 the end of your money, which restarts the program with RUN.

Cards and Scoring

Every card is INT (RND*10)+1, a value from 1 to 10 with each value equally likely, so there are no picture cards and an ace always counts 1. The suit is a random choice of UDGs a–d and does not affect play. The dealer is dealt no cards: its total is a single random number, INT (RND*13)+10, from 10 to 22. A dealer total of 22 is a bust and pays you, 21 is “PONTOON!” and beats you even if you also have 21, a higher total than yours wins for the dealer, and a tie goes to you.

Notable Techniques

  • (CHR$ 8 AND C1=10) prints a backspace before a 10, so the two-digit value takes the place of the space before it and the card’s right edge stays in line.
  • The suit is picked with CHR$ (144+INT (RND*4)), choosing one of the first four UDGs directly by character code.
  • UDG e is a checkered pattern (DATA 204,204,51,51…) that fills the face-down card.
  • The UDG loader reads its DATA into a variable named USER, and the next card for a twist is drawn in advance (lines 225 and 365).

Potential Issues

  • Lines 240 and 250 read INKEY$ separately. If S is released between the two tests, the program appears to take it as a twist.
  • On the fourth twist, line 275 clears the screen and starts again at the left. The earlier cards, the cash box and the T/S prompts are erased and not redrawn.
  • Because the dealer’s total is random and ignores your cards, the house wins only with 21 or a total higher than yours, and a win pays $50 against a $10 deal.
  • Line 990 and the RETURN in line 9140 are never reached.

This program came from an Oliger (JLO SAFE) disk. It contains no disk commands, so it needed no changes for tape, and like the disk copy it starts by itself. It was tested in ZEsarUX: a deal, a twist and a stick, with a winning hand taking the cash from 40 to 80 (the $50 win less the next $10 deal).

Appears On

Music with pictures, printer utilities, drawing tools, games and home programs: over fifty programs from the SINCUS library tape that followed tape 103, rescued from disk.

Image Gallery

Source Code

   10 REM BLACKJACK
   20 GO SUB 9000
   30 LET MONEY=50
   40 GO SUB 7000
   50 LET C1=INT (RND*10)+1
   60 LET C2=INT (RND*10)+1
   70 PRINT AT 11,2;"fjjjg"
   80 LET B$=CHR$ (144+(INT (RND*4)))
   90 PRINT AT 12,2;"k";B$;"  k"
  100 PRINT AT 13,2;"k   k"
  110 PRINT AT 14,2;"k ";(CHR$ 8 AND C1=10);C1;" k"
  120 PRINT AT 15,2;"k   k"
  130 PRINT AT 16,2;"k  ";B$;"k"
  140 PRINT AT 17,2;"hjjji"
  150 LET B$=CHR$ (144+(INT (RND*4)))
  160 PRINT AT 11,8;"fjjjg"
  170 PRINT AT 12,8;"k";B$;"  k"
  180 PRINT AT 13,8;"k   k"
  190 PRINT AT 14,8;"k ";(CHR$ 8 AND C2=10);C2;" k"
  200 PRINT AT 15,8;"k   k"
  210 PRINT AT 16,8;"k  ";B$;"k"
  220 PRINT AT 17,8;"hjjji"
  225 LET TOT=C1+C2: LET C3=INT (RND*10)+1
  230 PRINT AT 5,5;"T-TWIST"
  235 PRINT AT 7,5;"S-STICK"
  240 IF INKEY$="T" OR INKEY$="t" OR INKEY$="S" OR INKEY$="s" THEN GO TO 250
  245 GO TO 240
  250 IF INKEY$="s" OR INKEY$="S" THEN GO TO 1000
  260 LET TOT=TOT+C3
  270 LET B$=CHR$ (144+(INT (RND*4)))
  275 IF P>26 THEN LET P=2: CLS 
  280 PRINT AT 11,P;"fjjjg"
  290 PRINT AT 12,P;"k";B$;"  k"
  300 PRINT AT 13,P;"k   k"
  310 PRINT AT 14,P;"k ";(CHR$ 8 AND C3=10);C3;" k"
  320 PRINT AT 15,P;"k   k"
  330 PRINT AT 16,P;"k  ";B$;"k"
  340 PRINT AT 17,P;"hjjji"
  350 IF TOT>21 THEN PRINT AT 1,1;"BUST": GO TO 2000
  360 LET P=P+6
  365 LET C3=INT (RND*10)+1
  370 GO TO 240
  990 STOP 
 1000 LET CS=INT (RND*13)+10
 1010 CLS 
 1020 PRINT '"I HAVE ";CS''"YOU HAVE ";TOT''
 1030 IF CS>21 THEN PRINT "I HAVE BUST,YOU WIN $50! ": LET MONEY=MONEY+50: GO TO 1070
 1040 IF CS=21 THEN PRINT "PONTOON! ": GO TO 1070
 1050 IF CS>TOT THEN PRINT "I WIN ": GO TO 1070
 1060 PRINT "YOU WIN $50!": LET MONEY=MONEY+50
 1070 FOR K=1 TO 40: BEEP .008,K: BEEP .008,-K: NEXT K: GO TO 40
 2000 PRINT "I WIN THAT GAME!"
 2010 GO TO 1070
 3000 CLS 
 3010 PRINT AT 10,7;"YOU'RE OUT OF MONEY"
 3020 INPUT "PRESS ENTER TO PLAY AGAIN "; LINE A$: RUN 
 7000 BORDER 0: PAPER 4: INK 9: CLS 
 7005 LET P=14: LET MONEY=MONEY-10: IF MONEY<0 THEN GO TO 3000
 7010 PRINT AT 1,24; INK 1;"fjjjg"
 7020 FOR A=1 TO 6
 7030 PRINT TAB 24; INK 1;"keeek"
 7040 NEXT A
 7050 PRINT TAB 24; INK 1;"hjjji";AT 9,23;"CASH ";MONEY
 7060 PRINT AT 3,5;"D-DEAL"
 7070 IF INKEY$<>"D" AND INKEY$<>"d" THEN GO TO 7070
 7990 RETURN 
 9000 FOR A=USR "A" TO USR "K"+7
 9010 READ USER: POKE A,USER
 9020 NEXT A: RETURN 
 9030 DATA 24,60,126,255,255,126,60,24
 9040 DATA 24,60,90,255,255,90,24,60
 9050 DATA 16,56,124,254,254,64,16,56
 9060 DATA 68,238,254,254,254,124,56,16
 9070 DATA 204,204,51,51,204,204,51,51
 9080 DATA 0,0,0,7,15,12,24,24
 9090 DATA 0,0,0,192,240,48,24,24
 9100 DATA 24,24,12,15,7,0,0,0
 9110 DATA 24,24,48,240,192,0,0,0
 9120 DATA 0,0,0,255,255,0,0,0
 9130 DATA 24,24,24,24,24,24,24,24
 9140 RETURN 
 9990 REM A B C D E F G H I J K
 9991 REM a b c d e f g h i j k

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