Prev: 9579 Up: Map Next: 95BB
959B: Reset Deck
Used by the routine at PlayGame.
This routine generates the following bytes in CardDeck:
Address Block Bytes
95BB 00 01 02 03 04 05 06 07 08 09 0A 0B 0C
95C8 10 11 12 13 14 15 16 17 18 19 1A 1B 1C
95D5 20 21 22 23 24 25 26 27 28 29 2A 2B 2C
95E2 30 31 32 33 34 35 36 37 38 39 3A 3B 3C
See cards for what these numbers represent.
ResetDeck 959B LD HL,$95BB HL=CardDeck.
959E LD C,$00 Initialise C to 00 this will hold the suit value.
ResetSuit_Loop 95A0 LD B,$00 Initialise B to 00 this will hold the card value.
The suit "value" is held as:
Byte Bits
00 00000000
10 00010000
20 00100000
30 00110000
The following loop utilises the "suit" counter in C which is 00-03 and shifts the bits into the correct position.
ResetCards_Loop 95A2 LD A,C Fetch the current "suit" value, and store it in A.
95A3 PUSH BC Temporarily stash BC on the stack.
95A4 LD B,$04 Shift A left four positions.
ResetSuitShift_Loop 95A6 SLA A
95A8 DJNZ ResetSuitShift_Loop
95AA POP BC Restore BC from the stack.
Process and write the current card value to the deck.
95AB OR B Merge the suit bits and the card value together.
95AC LD (HL),A Write the card value to the current position in the deck.
95AD INC HL Increment the current deck position by one.
95AE INC B Increment the card value by one.
There are 0D cards for each suit.
95AF LD A,B Keep jumping back to ResetCards_Loop until all card values have been written for this suit.
95B0 CP $0D
95B2 JR NZ,ResetCards_Loop
95B4 INC C Increment the suit value by one.
There are four suits, are we finished now?
95B5 LD A,C Keep jumping back to ResetSuit_Loop until all suits have been processed.
95B6 CP $04
95B8 JR NZ,ResetSuit_Loop
95BA RET Return.
Prev: 9579 Up: Map Next: 95BB