Program listing on 48K Spectrum.
Key showing in-game features.
1 LET n=23620: POKE PEEK 23618*n,33: RANDOMIZE : BORDER 4: PAPER 4: LET m=3: DIM c(52): FOR c=1 TO 52: LET f=.5+RND*c: LET c(c)=c(f): LET c(f)=c-1: NEXT c: DIM s(6): CLS : PRINT "$";m: LET p=1: GO SUB 1: LET p=2: GO SUB 1: GO SUB 1: POKE (s(2)>20)*n,24+3*(q=6): INPUT c$: POKE (c$>"")*n,20: LET p=1: GO SUB 1: POKE (s(1)<s(2)*v)*n,25: LET w=SGN (s(2)*v-s(1)*(s(1)<22)): PRINT AT 0,3;"LDW"(w+2): BEEP .5,-w-w: BEEP 1,w+w: LET m=m+w: POKE n,8+29*(m<1 OR m>9): RESTORE : READ c,q,s(p+4),r,t,u,l,s(p+2),s(p),v: PRINT PAPER 7; INK 2*(c(c)<4*r-6);AT p*4-1,q;" 23456789TAJQK"(r);" ";AT p*4,q;" ": RETURN : DATA c-1,s(p+4)+3,q,INT (c(c)/4)+2,s(p)+r+(10-r)*(r>11),s(p+2)+(r=11),t>21 AND u,u-l,t-10*l,s(2)<22
Download the game
The variation of blackjack in this one-liner game first deals a single card to the dealer, and two cards to the player in each round. There is no hole-card, which makes this a European variation. The player then goes first, repeatedly deciding whether to "Hit" (Accept a further card), or "Stand" (Accept no more cards and finish their turn). After this, the dealer (CPU) takes its turn. To Hit, type any alphanumeric character into the INPUT prompt at the bottom of the screen, then press enter. To Stand, simply press enter at the INPUT prompt, entering an empty string.
The goal of each round, as in most blackjack variations is to reach a score as near as is possible to 21 points, without exceeding 21, in which case you would bust, losing the round. Numeric cards are worth their face value. In this game, the card "10" is represented by the character "T" to save space in the one-liner. Face Cards (Jack, Queen, King) are also worth 10. Aces are normally worth 11, except where that would cause the player to bust. In that case, one or more aces will be automatcally devalued during the round to 1 point such that the player does not bust. If the player immediatly starts the round with a blackjack (21 points in two cards), then the player automatically wins the round, without requiring any keyboard input. At the end of the round the player with the highest non-bust score wins the round. If the scores are equal then the round is a draw. The single letter indicator at the top of the screen indicates whether the human player won, lost or drew the round.
In this game, the player starts with a balance of $3 and $1 is automatically gambled on each round. The goal is for the player to win a total of $10. As the player balance is not updated on the screen at the moment the game ends, the game winning condition is indicated by "$9 W" appearing at the top of the screen, and the program stopping. The game is lost if the player's cash is reduced to zero (Likewise indicated by "$1 L" appearing at the top of the screen).
This program shows the use of GO SUB/RETURN in a one-liner program. This is achieved by taking advantage of the behaviour of the system variable NEWPPC. NEWPPC is normally set to zero when a program is initially RUN, but is automatically set to the current line number when certain statements are executed (in this case GO SUB). We take advantage of this fact to conditionally jump via NSPPC to a single subroutine in our one-liner program. The subroutine in this program is used to deal a single card.
The playing cards in this game do not show the suit in order to save space in the one-liner, but cards are still correctly shown as either red (hearts and diamonds), or black (clubs and spades).
Back to Sinclair stuff index