Prev: 38265 Up: Map Next: 38331
38299: Reset Deck
Used by the routine at PlayGame.
This routine generates the following bytes in CardDeck:
Address Block Bytes
38331 0 1 2 3 4 5 6 7 8 9 10 11 12
38344 16 17 18 19 20 21 22 23 24 25 26 27 28
38357 32 33 34 35 36 37 38 39 40 41 42 43 44
38370 48 49 50 51 52 53 54 55 56 57 58 59 60
See cards for what these numbers represent.
ResetDeck 38299 LD HL,38331 HL=CardDeck.
38302 LD C,0 Initialise C to 0 this will hold the suit value.
ResetSuit_Loop 38304 LD B,0 Initialise B to 0 this will hold the card value.
The suit "value" is held as:
Byte Bits
0 00000000
16 00010000
32 00100000
48 00110000
The following loop utilises the "suit" counter in C which is 0-3 and shifts the bits into the correct position.
ResetCards_Loop 38306 LD A,C Fetch the current "suit" value, and store it in A.
38307 PUSH BC Temporarily stash BC on the stack.
38308 LD B,4 Shift A left four positions.
ResetSuitShift_Loop 38310 SLA A
38312 DJNZ ResetSuitShift_Loop
38314 POP BC Restore BC from the stack.
Process and write the current card value to the deck.
38315 OR B Merge the suit bits and the card value together.
38316 LD (HL),A Write the card value to the current position in the deck.
38317 INC HL Increment the current deck position by one.
38318 INC B Increment the card value by one.
There are 13 cards for each suit.
38319 LD A,B Keep jumping back to ResetCards_Loop until all card values have been written for this suit.
38320 CP 13
38322 JR NZ,ResetCards_Loop
38324 INC C Increment the suit value by one.
There are four suits, are we finished now?
38325 LD A,C Keep jumping back to ResetSuit_Loop until all suits have been processed.
38326 CP 4
38328 JR NZ,ResetSuit_Loop
38330 RET Return.
Prev: 38265 Up: Map Next: 38331