A downloadable game

Jacks or Better VIDEO POKER

By D. Scott Williamson

For the EXTREME-256 category of the 2024 BASIC 10 Liner contest


Table of contents:

Included Files Description

Startup & Emulator Instructions

Description

Rules

How to Play

Cards

Gameplay Instructions

Strategy

Program features

Deck of cards

Ranking hands

Input method

Payout

Audio Visuals

Use of conditional expressions as integers (booleans)

Use of variables for constants

Modulus operator

Proof of 10 lines less than 256 columns

Program overview

Detailed program description


Included Files Description

README Jacks or Better VIDEO POKER.txt This file

Jacks or Better VIDEO POKER.atr Game disk file

Jacks or Better VIDEO POKER Line length.txt Line length <256 file (also below in this document)

Jacks or Better VIDEO POKER Line length.png Line length <256 image

Jacks or Better VIDEO POKER.gif Animated gif of listing and gameplay

Four of a Kind 1.png Screenshot

Four of a Kind 2.png Screenshot

Four of a Kind 3.png Screenshot

Four of a Kind 21.png Screenshot

Four of a kind 22.png Screenshot

Full House 1.png Screenshot

Full House 2.png Screenshot

Full House 3.png Screenshot

Jacks or Better 1.png Screenshot

Jacks or Better 2.png Screenshot

Jacks or Better 3.png Screenshot

Straight 1.png Screenshot

Straight 2.png Screenshot

Straight 21.png Screenshot

Straight 22.png Screenshot

Straight 31.png Screenshot

Straight 32.png Screenshot

Straight 33.png Screenshot

Three of a Kind 1.png Screenshot

Three of a Kind 2.png Screenshot

Three of a Kind 3.png Screenshot

Two Pair 1.png Screenshot

Two Pair 2.png Screenshot

Jacks or Better VIDEO POKER Title.png Video title screen (not a screenshot)


Description

Rules

Jacks or Better VIDEO POKER is a 5 card draw poker game.  The player places a bet, the deck is shuffled, and 5 cards are dealt.  The player then selects which cards to hold and which to discard.  Cards are discarded and replaced with new cards from the deck, the hand is evaluated, and if the player holds a winning hand they are rewarded with a payout based on the hand value and proportional to the initial bet.  This process is repeated so long as the player has enough money to cover a bet, the player may add money to the game between hands.

The ranking and description of winning hands from highest to lowest:

Royal Flush Ten, Jack, Queen, King, Ace in the same suit

Straight Flush Five cards of consecutive values in the same suit

Four of a Kind Four cards of the same value

Full House Three of a kind and Two of a kind

Flush Any five cards in the same suit

Straight Any five cards of consecutive value, Ace may be low (A2345) or high (TJQKA) but may not wrap (not QKA23)

Three of a Kind Three cards of the same value

Two Pair Two pairs of cards of the same value

Jacks or better Two cards of the same value ("a pair") that are Jack, Queen, King, or Ace

Cards do not need to be dealt in order in the hand (e.g. 7,8,4,6,5 is a straight equivalent to 4,5,6,7,8)


How to play

Cards are displayed as value and suit

Card values:

2-9 Number valued cards

T Ten

J Jack

Q Queen

K King

A Ace

Card Suits

Hearts

Clubs

Diamonds

Spades


Gameplay Instructions

Between hands

Pressing $ will add $25 to your Cash

Pressing + will increase your bet by $1 up to $5 maximum

Pressing - will decrease your bet by $1 down to $1 minimum

Pressing ENTER will place your bet and deal 5 cards if the player has enough cash to place the bet

During a hand

After the initial deal press 1, 2, 3, 4, or 5 as often as needed to toggle discarding ("D") or holding ("H") each of the 5 cards respectively

Press ENTER to discard and replace discarded cards with new cards from the deck.  

After cards are discarded and re-dealt, the hand is evaluated.  If the player holds a winning hand a payout is awarded.  

This process is repeated (and addictive).

See included gif or extended gameplay video: Jacks or Better VIDEO POKER in 10 lines of ATARI BASIC:

A Jacks or Better VIDEO POKER strategy to try:

1. If your hand includes four to a straight or a flush, hold all four.

2. If your hand includes three to a royal flush, hold.

3. If you receive a pair of any value, hold them and draw three new cards.

4. If you have three cards to a straight flush, hold.

5. If you don’t have any of the above, hold any jacks and any cards higher than a jack.


Program features

The deck of cards

The program manages a deck of 52 cards in a D$ where each card is represented by a value character (2-9,T,J,Q,K,A) and suit character (hearts, clubs, diamonds, spades).  Generating cards randomly risks dealing duplicate cards and checking for duplicates is more work than managing a deck.  The initial deck is read into D$ from data in line 2.  The deck is shuffled in a loop spanning lines 5 and 6 by swapping each card with a random one in the deck.  Initially, the program shuffled all 52 cards but since the deck is shuffled between each deal and each hand can only use a maximum of the first 10 cards (5 cards discarded and re-dealt) it is only necessary to shuffle the first 10 cards of the deck between hands reducing the delay considerably. 

Ranking hands

This is the heart of this program, it accurately ranks a Jacks or Better Poker hand in about 1 line of code spanning 2 lines of this program.  The ranking system must accurately rank hands according to many rules and be compact enough to fit in the 10 line program.  IF ... THEN logic would quickly consume too many lines so I needed to devise a ranking system.  The hand ranks from highest to lowest are:

Royal Flush : Ten, Jack, Queen, King, Ace in the same suit

Straight Flush : Five cards in a row in the same suit

Four of a Kind : Four cards of the same value

Full House : Three of a kind and Two of a kind

Flush : Any five cards in the same suit

Straight : Any five cards in order, Ace may be low (A2345) or high (TJQKA) but may not wrap (not QKA23)

Three of a Kind : Three cards of the same value

Two Pair : Two pairs of any cards of the same value

Jacks or better : Two cards of the same value that are Jack, Queen, King, or Ace

Some combination of rules like a "Royal Straight" Ten, Jack, Queen, King, Ace are not legal Poker Hands and must not fall out of the hand ranking system.

To rank a hand several calculations are made and flags are set then combined to determine a numerical rank used to lookup hand values from a table.


Variables used in ranking

R Initial Rank

R1 Final Rank

S Straight detection (1 if there are 5 sequential card values in the hand in any order)

F Flush detection (1 if all 5 cards in the hand are the same suit)

JB Jacks or Better detection (1 only if there is a single pair in the hand (rank 7) and the pair is Jack, Queen, King, or ACE (a 2 in the histogram for one of those values)

C(14) Counts (histogram) of cards A123456789TJQKA (includes A at both ends for straight detection)


Steps in the calculation

Count the number of cards of each value in the hand into array C to create the histogram (line 8-9).  A is counted twice, once at each end for straight calculation later.

The sum of the squares of the histogram values (line 9) for the first 13 histogram values (so A is not included twice) is accumulated in the initial rank R. At this point the rank values have the following meanings:

17  (4*4)+1 4 of a kind

13 (3*3)+(2*2) Full house

11 (3*3)+1+1 3 of a kind

9 (2*2)+(2*2)+1 two pair

7 (2*2)+1+1+1 pair

5 1+1+1+1+1 5 different value cards

Search for straights (line 9): Use a nested loop 0-10 then 0-4 to multiply consecutive card counts in the histogram  A straight will be 5 ones in a row so S can only be 1 if there are 5 cards in a row in any order in the hand.

Search for flush (line 9) by comparing the suit of the last 4 cards in the hand to the suit of the first and take the product of the comparisons.  It can only be 1 if all cards are the same suit.

Search for Jacks or Better JB (line 9) loop through counts of Jack, Queen, King, and Ace and add 1 to JB if the count is 2, then keep the result only if the initial rank is 7 (single pair).  JB is only a 1 if the hand contains a single pair of Jacks or better.

The final rank calculation (line 9) combines R with JB, S, F, and the count of Aces (C(13)) as follows R1=R+JB-S-F*2-(S*F*(C(N13))) resulting in the final hand ranking.  Values have the following meanings 

17  (4*4)+1 4 of a kind

13 (3*3)+(2*2) Full house

11 (3*3)+1+1 3 of a kind

9 (2*2)+(2*2)+1 two pair

8 7+JB jacks or better

7 (2*2)+1+1+1 pair (use jacks or better)

5 1+1+1+1+1 nothing

4 5-S straight

3 5-2*F flush

2 5-S-2*F straight flush

1 5-S-2*F-(S*F*(C(N13))) royal flush

The winning hand values are stored in the table with the payouts.  A loop scans all the potential winning hands to see if the rank matches one of the hands (line 10) and if so lookup the corresponding payout


Input method

There are too many options to use the joystick and it would have been unintuitive and using BASIC's INPUT requires pressing enter after every input and validating inputs so I decided to access the keyboard device to get blocking input on individual keypresses.  The keyboard device is opened for input in line 2 O.#N1,N4,N0,"K" (OPEN #1,4,0,"K") then keys are retrieved in input loops in line 4 and 7 GET#N1,K (GET #1,K).  The GET statement waits for a key and returns the ATASCII value in K which is used in conditionals in assignment and GOTO statements.  Examples include pressing $ to add money to the player account M=M+N25*(K=36) which adds 25 if K= 36 the ATASCII code for $ and 0 otherwise or G.N4+(K=NKE)*(M>=B) which loops at line 4 until ENTER (ATASCII 155 assigned to NKE for number keyboard enter) is pressed and the player has enough money to cover their bet. 

Payout 

If the player wins then the payout loop flashes the screen and rings the bell once for each dollar bet and adds the payout amount to the players total cash each time.

Audio Visuals

Just like in real gambling machines, wins are accompanied by ringing bells and flashing lights while losses pass silently leaving only reward and anticipation to drive continued play. 

Use of conditional expressions as integers (booleans)

The result of a comparison (=,<,<=,>,>=,<>) is 1 if true and 0 if false.  This can be used to create conditional calculations in without using IF ... THEN.  This technique is used extensively in this program to handle input, make conditional calculations in hand ranking, and in GOTO statements to vector to intended lines based on conditions.

Use of variables for constants

From the Atari BASIC Manual: "Each time a constant (4,5,16,3.14159, etc.) is used, it takes 7 bytes. Defining a new variable requires 8 bytes plus the length of the variable name (in characters). But each time it is used after being defined, it takes only I byte, regardless of its length."

Lines that contain too many constants overflow the internal tokenization buffer and cannot use the maximum 253 characters per line permitted by the input buffer length.  Using variables for constants is much more compact, furthermore deriving constants from other constants is even more compact during initialization.

Modulus operator

A modulus 2 calculation is used in line 5 to toggle holding cards  DC(I)=DC(I)-INT(DC(I)/N2)*N2

Atari BASIC does not have a modulus operator (modulus(a,b) returns the remainder of a/b).  Instead A-INT(A/B)*B is used, let's look at it in parts.

INT(A/B) is the integer portion of A/B, aka truncated value of A/B, aka ceil(A/B)

INT(A/B)*B is the integer portion of A larger than B

A-INT(A/B)*B Subtracting the integer portion of A larger than B from A leaves the remainder or modulus.


Proof of 10 lines less than 256 columns (also see included png)

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222
0000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999000000000011111111112222222222333333333344444444445555555
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
1 N0=0:N1=1:N2=N1+N1:N4=N2+2:N5=N4+N1:N9=N5+N4:N10=N5+N5:N13=N9+N4:N14=N13+N1:N15=N14+N1:N17=N15+N2:N19=N15+N4:N21=N19+N2:N25=N15+N10:N29=N25+N4:N119=119:N128=N119+N9:NKE=155:M=N25:B=N1:DIM D$(N119),HN$(165),H(N10+N10),H$(N10),T$(N128),C(N14),DC(N5)
2 N7=N5+N2:N8=N7+N1:N16=N15+N1:F.I=N0 TO N19:REA.T:H(I)=T:N.I:O.#N1,N4,N0,"K":POK.82,N0:GR.N0:POK.752,1:SE.N2,N7,N2:SE.N1,N0,15:REA.D$:REA.T$:HN$=T$(N2):REA.T$:HN$(61)=T$(N2):?:F.I=N1 TO N15:?"        ";:N.I:POS.9,2:?"Ö É Ä Å Ï    Ð Ï Ë Å Ò"
3 F.I=N9 TO N1 STEP -N1:T=N10-I:POS.N0,T+N4:?HN$(I*N15+N1,I*N15+N15):F.J=N1 TO N5:POS.N10+N1+N5*J,T+N4:?J*H(I+N10):N.J:N.I:?:?:?"Û±ÝÛ²ÝÛ³ÝÛ´Ý۵ݠ     Û­ÝÛ«Ý    Û¤Ý":POS.N0,N21:?,,,"  ÛÅÎÔÅÒÝ":?,,,"  Ä Å Á Ì";
4 POS.N29,N19:?"Cash:$";M;" ":POS.N21,N19:?"Bet:$";B:GET#N1,K:B=B+(N1*(K=43)*(B<N5))-((K=45)*(B>1)):M=M+N25*(K=36):POS.N0,20:G.N4+(K=NKE)*(M>=B):D. 0,8,9,11,4,3,13,17,2,1, 0,1,2,3,4,6,9,25,50,250
5 ?HN$(150,164):?HN$(150,164):?HN$(N1,N15);HN$(N1,N15):F.I=N1 TO20STEP N2:J=INT(RND(N0)*52)*N2+N1:T$=D$(I):D$(I,I+N1)=D$(J):D.²€³€´€µ€¶€·€¸€¹€Ô€Ê€Ñ€Ë€Á€²à³à´àµà¶à·à¸à¹àÔàÊàÑàËàÁಐ³´µ¶·¸¹ÔÊÑËÁ²û³û´ûµû¶û·û¸û¹ûÔûÊûÑûËûÁûÁ²³´µ¶·¸¹ÔÊÑËÁ
6 D$(J,J+N1)=T$:N.I:M=M-B:POS.N29,N19:?"Cash:$";M;" ":F.I=N1 TO N9 STEP N2:H$(I,I+N1)=D$(I):N.I: POS.N1,N19:F.I=N0 TO N5:DC(I)=N1:N.I:F.I=N1 TO N9 STEP N2: ?H$(I,I+N1);" ";:N.I:POS.N1,N17:D."               Jacks or BetterTwo Pair       Three of a Kind"
7 F.I=N0 TO N4: DC(I)=DC(I)+(K=(I+49)):DC(I)=DC(I)-INT(DC(I)/N2)*N2:?CHR$(72-DC(I)*N4);"  ";:N.I: GET#N1,K: POS.N1,N17:G. N9-N2+(K=NKE): D."Straight       Flush          Full House     Four of a Kind Straight Flush Royal Flush                  "
8 ?HN$(N1,N13):F.I=N0 TO N4: J=I*N2+N1: T=J+DC(I)*N10:H$(J)=D$(T,T+N1):N.I:POS.N1,N19:F.I=N1 TO N9 STEP N2: ?H$(I,I+N1);" ";:N.I:?:F.I=N1 TO N14:C(I)=N0:N.I:R=N0: F.I=N1 TO N14:F.J=N1 TO N9 STEP N2:T=104+I:C(I)=C(I)+H$(J,J)=D$(T,T):N.J
9 R=R+C(I)*C(I)*(I<N14): N.I:S=N0:F.I=N1 TO N10:T=N1:F.J=N0 TO N4:T=T*C(I+J):N.J:S=S+T:N.I:F=N1:F.I=N4 TO N10 STEP N2:F=F*H$(N2,N2)=H$(I,I):N.I:JB=N0:F.I=N10+N1 TO N14:JB=JB+(C(I)=N2):N.I:JB=JB*(R=N5+N2): R1=R+JB-S-F*2-(S*F*(C(N13))):HI=N0:W=N0:?:?
10 F. I=N1 TO N10:HI=HI+I*(H(I)=R1):N.I:?" ";HN$(HI*N15+N1,HI*N15+N15);:T=H(HI+N10):F.I=N1 TO B:W=W+T:M=M+T:POS.N21,22:?"WIN $";W:POS.N29,N19:?"Cash:$";M:F.J=(T>N0)*(N16)TO N0 STEP-N4:SO.N1,N29,N10,J:SE.N2,N15-(J=N0)*N8,J+N2:N.J:SE.N2,N7,N2:N.I:G.N4

Program Overview:

Line 1 Initialize constants, Dimension arrays

Line 2 Initialize constants, read hand ranks array from data, open keyboard device for key input, set left margin to 0, set graphics mode, hide the cursor, set colors, read deck of cards into D$ from data, read hand names from data into HN$, print white banner and VIDEO POKER title

Line 3 Display the winning hands and payout table, print legends for inputs

Line 4 Begin main game loop, pre-deal loop on line 4, print cash and bet, get input key in K, update bet B based on key if + or - pressed, update money ("Cash") if $ pressed, GOTO 5 if ENTER pressed, otherwise GOTO 4 to continue pre-deal input loop, DATA statement with hand ranks and payouts

Line 5  Initial print of card bodies, clear previous hand and winning hand string from screen, shuffle the (first 10 cards of) deck D$, data containing initial deck of cards and card values for histogram

Line 6 Shuffle continued, subtract bet from cash to begin hand, update cash display, deal 5 cards by copying first 5 cards from the deck D$ to the hand H$, set 5 discard flags DC to 1, print cards in hand, position cursor to print hold flags, DATA containing hand name strings

Line 7 Discard input loop, loop through 5 cards, if a corresponding number key K is pressed toggle hold/discard flag in DC(I), print H or D based on DC(I), get key frmo keyboard in K, GOTO 7 loop until enter is pressed, DATA holding hand names

Line 8 Clear hold/discard characters, replace discarded cards with those from the deck, print cards in players hand, clear histogram C(), reset rank, loop over card values to calculate value counts of cards in the players hand to build a histogram

Line 9 Continue building histogram, and accumulate histogram values squared into initial rank R, detect straight, detect flush, detect jacks or better, combine rank, straight, flush, and jacks or better flags into a final rank R1 calculation, initialize the hand index and win to 0 in case the hand is not a winning hand.

Line 10 Compare rank to winning hand ranks to get hand index HI, print hand name HN$(HI*15), lookup payout H(HI+10), payout loop once for each bet (1-5), award payout to win W and money M ("Cash"), print winnings and updated Cash balance, loop to cycle colors and ring bell, reset the screen color, GOTO 4 to return to the pre-deal state


Detailed program description:

1 N0=0        CONSTANT VARIABLE 0 

N1=1        CONSTANT VARIABLE 1

N2=N1+N1    CONSTANT VARIABLE 2 

N4=N2+2    CONSTANT VARIABLE 4 

N5=N4+N1    CONSTANT VARIABLE 5 

N9=N5+N4    CONSTANT VARIABLE 9 

N10=N5+N5  CONSTANT VARIABLE 10 

N13=N9+N4  CONSTANT VARIABLE 13 

N14=N13+N1 CONSTANT VARIABLE 14 

N15=N14+N1 CONSTANT VARIABLE 15 

N17=N15+N2 CONSTANT VARIABLE 17 

N19=N15+N4 CONSTANT VARIABLE 19 

N21=N19+N2 CONSTANT VARIABLE 21 

N25=N15+N10 CONSTANT VARIABLE 25 

N29=N25+N4 CONSTANT VARIABLE 29 

N119=119    CONSTANT VARIABLE 119 

N128=N119+N9 CONSTANT VARIABLE 128 

NKE=155      CONSTANT VARIABLE 155 (KEYCODE FOR ENTER)

M=N25        INITIALIZE MONEY TO 25 ($)

B=N1        INITIALIZE BET TO 1 ($)

DIM D$(N119),HN$(165),H(N10+N10),H$(N10),T$(N128),C(N14),DC(N5) DIMENSION VARIABLES

D$(1,52*2)  IS THE DECK OF CARDS, EACH CARD HAS A NUMBER AND A SUIT 

D$(105,119) ARE THE CARD NUMBERS FOR CALCULATING HISTOGRAMS A23456789TJKQA

HN$      IS THE HANDS NAME STRING, FOR DISPLAYING THE RATE TABLE AND HAND WHEN THE PLAYER WINS

H(20)    IS THE HAND VALUE TABLE, EACH OF THE 10 WINNING HANDS HAS A RANK AND A PAYOUT

H$(10)    IS THE PLAYERS 5 CARD HAND WHERE EVERY TWO CHARACTERS IS A CARD

T$(N128) IS A TEMPORARY STRING FOR READING STRINGS FROM DATA AND HOLDING STRINGS FOR CALCULATIONS

C(14)    HISTOGRAM OF CARD COUNTS IN PLAYERS HAND

DC(5)    DISCARD FLAG FOR DISCARDING OR HOLDING CARDS

 

2 N7=N5+N2    CONSTANT VARIABLE 7 

N8=N7+N1    CONSTANT VARIABLE 8 

N16=N15+N1  CONSTANT VARIABLE 16 

FOR I=N0 TO N19 LOOP TO READ HAND RANKS AND PAYOUTS FROM DATA INTO ARRAY H

READ T:?I,T     READ DATA INTO TEMPORARY VARIABLE

H(I)=T          COPY DATA INTO ARRAY (YOU CANNOT READ DATA DIRECTLY INTO AN ARRAY VARIABLE

NEXT I          LOOP

OPEN #N1,N4,N0,"K" OPEN THE KEYBOARD FOR INPUT SO KEYSTROKES CAN BE READ WITHOUT REQUIRING ENTER KEY

POKE 82,N0        SET LEFT MARGIN TO 0 FROM DEFAULT OF 2 TO USE ENTIRE SCREEN WIDTH

GRAPHICS N0       GRAPHICS 0, CLEAR SCREEN AND SET ATARI 40 COLUMN 24 ROW TEXT SCREEN MODE

POKE 752,1        HIDE CURSOR

SETCOLOR N2,N7,N2 SET THE BACKGROUND COLOR TO DARK BLUE

SETCOLOR N1,N0,15 SET THE TEXT COLOR TO BRIGHT WHITE

READ D$           READ THE DECK OF CARDS STRING FROM DATA

READ T$           READ PARTIAL HAND NAMES FROM DATA

HN$=T$(N2)        COPY THE HAND NAMES STRING SKIPPING THE INITIAL DOUBLE QUOTE CHARACTER IN T$

READ T$           READ MORE OF THE HAND NAMES FROM THE NEXT DATA STATEMENT

HN$(61)=T$(N2)    COPY THE HAND NAMES TO THE END OF HN$ SKIPPING THE INITIAL DOUBLE QUOTE CHARACTER IN T$

PRINT             PRINT A BLANK LINE 

FOR I=N1 TO N15   LOOP TO PRINT WHITE BANNER AT THE TOP OF THE SCREEN 

PRINT "        "; PRINT 8 INVERTED SPACES

NEXT I            LOOP

POSITION 9,2                  POSITION CURSOR IN MIDDLE OF THE BANNER

PRINT "Ö É Ä Å Ï    Ð Ï Ë Å Ò" PRINT INVERTED "V I D E O   P O K E R"


3 FOR I=N9 TO N1 STEP -N1       LOOP TO DISPLAY THE WINNING HANDS AND PAYOUTS FOR BETS

T=N10-I                       TEMPORARY VARIABLE T INDEXES THE ROW POSITION ON THE SCREEN IN DESCENDING ORDER

POSITION N0,T+N4              POSITION THE CURSOR TO PRINT THE NAME OF THE HAND

PRINT HN$(I*N15+N1,I*N15+N15) PRINT HAND NAME SUBSTRING OUT OF HN$ INDEXED BY I.  EACH NAME IS 15 CHARACTERS LONG

FOR J=N1 TO N5                LOOP OVER THE BET AMOUNTS FROM 1 TO 5

POSITION N10+N1+N5*J,T+N4     POSITION THE CURSOR IN THE RIGHT COLUMN AND ROW TO DISPLAY THE PAYOUT FOR HAND I AT BET LEVEL J

PRINT J*H(I+N10)              PRINT PAYOUT FOR HAND I AT BET LEVEL J

NEXT J                        LOOP OVER BET LEVELS

NEXT I                        LOOP OVER HANDS

PRINT                         PRINT A BLANK LINE

PRINT                         PRINT A BLANK LINE

PRINT "Û±ÝÛ²ÝÛ³ÝÛ´Ý۵ݠ     Û­ÝÛ«Ý    Û¤Ý" PRINT KEY LEGEND, INVERTED "[1][2][3][4][5]   [-][+]   [$]"

POSITION N0,N21               POSITION CURSOR TO PRINT DEAL KEY LEGEND

PRINT ,,,"  ÛÅÎÔÅÒÝ"          PRINT INVERTED "[ENTER]" TO THE RIGHT

PRINT ,,,"  Ä Å Á Ì";         PRINT INVERTED "D E A L" TO THE RIGHT, SEMICOLON PREVENTS NEWLINE FROM SCROLLING THE SCREEN

 

4 POSITION N29,N19              THIS IS THE BET AND CASH INPUT LOOP, POSITION THE CURSOR TO PRINT PLAYER CASH

PRINT "Cash:$";M;" "          PRINT THE AMOUNT OF MONEY THE PLAYER HAS, TRAILING SPACE NEEDED TO CLEAR DIGITS AS PLAYER CASH DECREASES

POSITION N21,N19              POSITION THE CURSOR TO PRINT THE PLAYER BET 

PRINT "Bet:$";B               PRINT THE PLAYER BET LEVEL

GET#N1,K                      READ A KEY FROM THE KEYBOARD INTO K

B=B+(N1*(K=43)*(B<N5))-((K=45)*(B>1)) UPDATE BET, ADD 1 ONLY IF K=43 ("+") AND THE BET IS LESS THAN 5, SUBTRACT 1 IF K=45 ("-") AND B>1

M=M+N25*(K=36)                UPDATE PLAYER MONEY, ADD 25 ONLY IF THE "$" KEY WAS PRESSED WHEN K=36

POSITION N0,20                POSITION CURSOR TO DISPLAY CARDS

GOTO N4+(K=NKE)*(M>=B)     GOTO IF ENTER PRESSED AND MONEY>=BET GOTO 5 (DEAL), OTHERWISE GOTO 4 (LOOP)

DATA 0,8,9,11,4,3,13,17,2,1, 0,1,2,3,4,6,9,25,50,250

REM DATA ON LINE 409 IS 10 HAND RANKS FOLLOWED BY 10 CORRESPONDING HAND VALUES

   

5 PRINT HN$(150,164)            PRINT FIVE PAIRS OF INVERTED SPACES TO LOOK LIKE CARDS FROM THE END OF THE HAND NAMES STRING

PRINT HN$(150,164)            PRINT FIVE PAIRS OF INVERTED SPACES TO LOOK LIKE CARDS FROM THE END OF THE HAND NAMES STRING

PRINT HN$(N1,N15);HN$(N1,N15) PRINT 15 BLANK SPACES TWICE TO CLEAR THE HAND AND "WIN$:X" STRINGS FROM THE SCREEN (THE FIRST HAND NAME IS BLANK, USED FOR ALL LOSING HANDS)

FOR I=N1 TO 20 STEP N2        SHUFFLE THE DECK, ONLY THE FIRST 10 CARDS AS THEY ARE THE ONLY ONES THAT MAY BE USED IN EACH HAND

J=INT(RND(N0)*52)*N2+N1       PICK ANOTHER RANDOM CARD IN THE DECK INDEXED BY J TO SWAP WITH CARD AT INDEX I

T$=D$(I)                      COPY THE DECK AT I TO T$

D$(I,I+N1)=D$(J)              COPY THE 2 CHARACTER CARD FROM LOCATION J IN THE DECK TO LOCATION I

DATA²€³€´€µ€¶€·€¸€¹€Ô€Ê€Ñ€Ë€Á€²à³à´àµà¶à·à¸à¹àÔàÊàÑàËàÁಐ³´µ¶·¸¹ÔÊÑËÁ²û³û´ûµû¶û·û¸û¹ûÔûÊûÑûËûÁûÁ²³´µ¶·¸¹ÔÊÑËÁ 

REM THE DATA IN LINE 507 IS THE INVERTED CHARACTERS OF THE DECK OF CARDS FOLLOWED BY VALUES OF CARDS (A123456789TJQKA) USED TO CALCULATE RANKING HISTOGRAM

    

6 D$(J,J+N1)=T$                 COPY THE TWO CHARACTER CARD FROM POSITION I SAVED IN T$ TO LOCATION J

NEXT I                        LOOP TO SHUFFLE NEXT CARD

M=M-B                         SUBTRACT BET FROM MONEY

POSITION N29,N19              POSITION CURSOR TO PRINT PLAYER CASH

PRINT "Cash:$";M;" "          PRINT PLAYER CASH

FOR I=N1 TO N9 STEP N2        LOOP TO DEAL 5 CARDS

H$(I,I+N1)=D$(I)              COPY THE FIRST 5 CARDS FROM THE DECK INTO THE PLAYERS HAND 2 CHARACTERS AT A TIME 

NEXT I                        LOOP DEAL

POSITION N1,N19               POSITION CURSOR TO PRINT CARDS

FOR I=N0 TO N5                LOOP TO SET ALL 5 DISCARD FLAGS TO 1

DC(I)=N1                      SET DISCARD FLAG I TO 1

NEXT I                        LOOP INITIALIZE DISCARD FLAGS

FOR I=N1 TO N9 STEP N2        LOOP TO PRINT CARDS

PRINT H$(I,I+N1);" ";         PRINT 2 CHARACTER CARD FROM THE HAND FOLLOWED BY A SPACE

NEXT I                        LOOP TO PRINT CARDS

POSITION N1,N17               POSITION CURSOR TO PRINT DISCARD/HOLD FLAGS

DATA"               Jacks or BetterTwo Pair       Three of a Kind" FIRST DATA FOR HN$

    

7 FOR I=N0 TO N4                DISCARD/HOLD INPUT LOOP, LOOP THROUGH 5 CARD DISCARD/HOLD VALUES

DC(I)=DC(I)+(K=(I+49))        INCREMENT D(I) DISCARD/HOLD IF K=49+I, KEYS 1-5 ARE KEY CODES 49-53

DC(I)=DC(I)-INT(DC(I)/N2)*N2  EFFECTIVELY MODULUS 2, LIMITS THE VALUES TO 1 OR 0

PRINT CHR$(72-DC(I)*N4);"  "; PRINT "D" IF DC(I) IS 1 OR "H" IF IT IS NOT FOLLOWED BY TWO SPACES

NEXT I                        LOOP THROUGH DISCARD ARRAY

GET #N1,K                     GET KEY FROM KEYBOARD

POSITION N1,N17               POSITION CURSOR TO PRINT DISCARD VALUES

GOTO N9-N2+(K=NKE)   IF ENTER PRESSED GOTO 8 OTHERWISE GOTO 7

DATA"Straight       Flush          Full House     Four of a Kind Straight Flush Royal Flush                  " SECOND DATA FOR HN$


8 PRINT HN$(N1,N13)             PRINT BLANK HAND NAME OVER DISCARD VALUES TO REMOVE THEM

FOR I=N0 TO N4                LOOP THROUGH 5 CARDS TO DEAL NEW CARDS FOR DISCARDS

J=I*N2+N1                     CALCULATE INDEX j OF CARD I IN THE HAND H$ (AND IN THE DECK D$ ON DEAL)

T=J+DC(I)*N10                 CALCULATE INDEX OF THE CARD IN THE DECK, IF DISCARD IS 1, SELECT CORRESPONDING CARD FROM NEXT 5 CARDS IN THE DECK

H$(J)=D$(T,T+N1)              COPY CARD FROM THE DECK TO THE HAND (EITHER HOLD OR DISCARD AND REDEAL CARD+5)

NEXT I                        LOOP DEAL DISCARDS

POSITION N1,N19               POSITION CURSOR TO PRINT CARDS

FOR I=N1 TO N9 STEP N2        LOOP OVER CARDS TO PRINT CARDS

PRINT H$(I,I+N1);" ";         PRINT 2 CHARACTER CARD FROM HAND AT INDEX I

NEXT I                        LOOP

PRINT                         PRINT BLANK LINE IN PREPARATION FOR PRINTING HAND DESCRIPTION AND WINNING

FOR I=N1 TO N14               LOOP OVER CARD VALUES TO CLEAR HISTOGRAM

C(I)=N0                       SET HISTOGRAM VALUE C(I) TO ZERO

NEXT I                        LOOP

R=N0                          SET RANK TO 0

FOR I=N1 TO N14               LOOP I OVER CARD VALUES TO CALCULATE HISTOGRAM IN C()

FOR J=N1 TO N9 STEP N2        LOOP J OVER CARD INDEXES IN HAND

T=104+I                       SET TEMPORARY VALUE TO 104+I,INDEX OF VALUE CHARACTER IN DECK STRING

C(I)=C(I)+H$(J,J)=D$(T,T)     ADD 1 TO C(I) IF THE VALUE CHARACTER IN THE HAND FOR CARD J MATCHES THE VALUE CHARACTER FROM THE DECK STRING

NEXT J                        LOOP NEXT CARD

    

9 R=R+C(I)*C(I)*(I<N14)         RANK IS THE SUM OF THE CARD COUNTS SQUARED ONLY INCLUDING THE ACE ONCE (IT'S INCLUDED TWICE TO DETECT STRAIGHTS)

NEXT I                        NEXT CARD VALUE, R CONTAINS RANK SUM OF SQUARES OF CARD COUNTS FOR THE HAND 

S=N0                          SET STRAIGHT FLAG S TO ZERO

FOR I=N1 TO N10               LOOP OVER LOWEST CARD FOR 10 POSSIBLE STRAIGHTS (A-5 THROUGH T-A)

T=N1                          SET TEMP TO 1

FOR J=N0 TO N4                LOOP THROUGH 5 CONSECUTIVE CARD COUNTS C(I+J) IN THE HISTOGRAM

T=T*C(I+J)                    MULTIPLY T BY THE HISTOGRAM VALUE AT I+J

NEXT J                        LOOP NEXT CARD

S=S+T                         ADD T TO S, T CAN ONLY BE 1 IF THE HAND CONTAINS 5 CONSECUTIVE CARDS

NEXT I                        LOOP NEXT POTENTIAL STRAIGHT

F=N1                          SET FLUSH DETECTION TO 1

FOR I=N4 TO N10 STEP N2       LOOP HAND INDEX I FROM THE SECOND CARD SUIT TO THE FIFTH CARD SUIT 

F=F*H$(N2,N2)=H$(I,I)         MULTIPLY THE FLUSH FLAG BY ONE ONLY IF THE SUIT CHARACTER OF THE FIRST CARD MATCHES THE SUIT OF THE INDEXED CARD

NEXT I                        NEXT CARD SUIT INDEX, WHEN DONE F WILL ONLY BE 1 IF ALL CARDS ARE THE SAME SUIT

JB=N0                         SET JACKS OR BETTER FLAG TO 0

FOR I=N10+N1 TO N14           LOOP INDEX I THROUGH THE CARD HISTOGRAMS FOR JACK (11) THROUGH HIGH ACE (14)

JB=JB+(C(I)=N2)               ADD 1 TO JB ONLY IF THE HISTOGRAM FOR VALUE I IS EQUAL TO 2

NEXT I                        LOOP THROUGH JACKS OR BETTER CARD COUNTS

JB=JB*(R=N5+N2)               JB IS MULTIPLIED BY 1 ONLY IF THE RANK IS 7, OTHERWISE 0.  RANK 7 IS A SINGLE PAIR (2^2+3*1^2)

R1=R+JB-S-F*2-(S*F*(C(N13)))  R1 IS THE FINAL COMPOSITE HAND RANK INCORPORATING FLUSH, STRAIGHT, JACKS OR BETTER FLAG, AND DETECTION OF ROYAL FLUSH (S*F*(C(N13)))

HI=N0                         SET THE HAND INDEX HI TO ZERO

W=N0                          WIN AMOUNT TO ZERO 

PRINT                         PRINT BLANK LINE IN PREPARATION FOR PRINTING HAND DESCRIPTION AND WINNING

PRINT                         PRINT BLANK LINE IN PREPARATION FOR PRINTING HAND DESCRIPTION AND WINNING

10 FOR I=N1 TO N10              LOOP THROUGH THE POTENTIAL WINNING HANDS (INDEX 1 - 10)

HI=HI+I*(H(I)=R1)            ADD WINNING HAND INDEX I TO HI ONLY IF THE HAND RANK EQUALS THE HAND RANK AT THE INDEX H(I)

NEXT I                       LOOP NEXT WINNING HAND, WHEN THIS IS DONE HI WILL CONTAIN AN INDEX INTO HAND NAMES AND PAYOUTS 

PRINT " ";HN$(HI*N15+N1,HI*N15+N15); PRINT HAND NAME, THE NAME AT INDEX ZERO IS BLANK FOR NON-WINNING HANDS

T=H(HI+N10)                  COPY THE WINNING BASE PAYOUT TO T

FOR I=N1 TO B                LOOP FROM 1 TO BET, HIGHER BETS, MORE WINNING PIZAZZ

W=W+T                        WITH EACH ITERATION OF THE LOOP THE WIN INDICATOR IS AWARDED THE BASE PAYOUT

M=M+T                        WITH EACH ITERATION OF THE LOOP THE PLAYERS MONEY IS INCREASED BY T

POSITION N21,22              POSITION CURSOR TO PRINT PLAYER WINNINGS

PRINT "WIN $";W              PRINT WINNINGS

POSITION N29,N19             POSITION CURSOR TO PRINT PLAYER MONEY

PRINT "Cash:$";M             PRINT PLAYER MONEY

FOR J=(T>N0)*(N16)TO N0 STEP-N4 IF THE WINNING BASE PAYOUT IS NOT ZERO, LOOP FROM 16 TO 0 

SOUND N1,N29,N10,J           MAKE WINNING SOUND

SETCOLOR N2,N15-(J=N0)*N8,J+N2 SET SCREEN TO EXCITING WINNING COLOR

NEXT J                       END OF MULTIMEDIA REWARD LOOP (END OF FLASH AND DING)

SETCOLOR N2,N7,N2            RESTORE SCREEN COLOR

NEXT I                       LOOP BET AMOUNT TIMES

GOTO N4      GO TO BET, MONEY, AND DEAL INPUT LOOP LINE

Download

Download
Jacks or Better VIDEO POKER.atr 90 kB
Download
Jacks or Better VIDEO POKER Line length.txt 3 kB
Download
README Jacks or Better VIDEO POKER.txt 31 kB

Install instructions

Startup & Emulator Instructions

1. Run Atari800Win PLus

2. Set Machine Type to XL/XE

3. Set Video System to NTSC (not strictly necessary)

4. Make sure BASIC is enabled ("Disable BASIC when booting" is disabled in settings

4. Alt-D or drag and drop to attach "Jacks or Better VIDEO POKER.atr" to the emulator

5. Shift-F5 to reset the emulator which will now be in BASIC at the READY prompt with the disk loaded in D1:

6. Type ENTER"D1:VIDPOKER.LST" and press enter to load the program (alternate LOAD"D1:VIDPOKER.BAS")

7. (optional) type "LIST" to see listing

8. type "RUN" to run the program

Comments

Log in with itch.io to leave a comment.

Greetings D. Scott Williamson,

we hope you doing great. I am Areeba Malik (aka Titania) from the BrewOtaku-Team, we are launching our first homebrew gaming magazine soon. We loved your work and we have mentioned your game "Jacks or Better VIDEO” in our very first issue.

Please share your contact details if you would like to have a digital copy of our magazine. As we intend to sell the magazine at a very affordable price, you would need to keep it confidential for you only, of course you would get a free copy.

We look forward to hearing from you soon.

Kind regards

Areeba Malik (Titania)

very good