Prev: 954D Up: Map Next: 9579
954E: Draw Cards
Used by the routine at PlayGame.
Input
IX Pointer to either the player or girls hand
If a card value in the players hand is FF this indicates that a card needs to be drawn.
If a card value in CardDeck is FF this indicates that the card has already been chosen.
DrawCards 954E PUSH IX Stash IX on the stack.
9550 PUSH IX DE=IX (using the stack).
9552 POP DE
9553 LD B,$05 A hand consists of 05 cards.
DrawCards_Loop 9555 PUSH BC Stash the card count on the stack.
DrawCards_RePick 9556 LD HL,$95BB HL=CardDeck.
Only draw a card if the current position in the hand is marked as needing to be picked.
9559 LD A,(DE) Jump to DrawCards_Next if the hand pointer is not equal to FF.
955A CP $FF
955C JR NZ,DrawCards_Next
955E PUSH DE Stash the hand and deck pointers on the stack temporarily.
955F PUSH HL
9560 CALL GetRandomNumber Call GetRandomNumber.
9563 POP HL Restore the deck and hand pointers from the stack.
9564 POP DE
9565 LD C,A Create an offset in BC.
9566 LD B,$00
9568 DEC BC Decrease the card count by one.
9569 ADD HL,BC HL+=BC.
956A LD A,(HL) Jump to DrawCards_RePick if this card has already been picked (if the chosen card "value" is equal to FF).
956B CP $FF
956D JR Z,DrawCards_RePick
The picked card is valid and able to be drawn into the hand.
956F LD (DE),A Write the drawn card to the current hand position.
9570 LD (HL),$FF Now mark the card in the deck as being unavailable so it can't be chosen again.
DrawCards_Next 9572 POP BC Restore the card count from the stack.
9573 INC DE Increment the hand pointer by one.
9574 DJNZ DrawCards_Loop Decrease the card count by one and loop back to DrawCards_Loop until the deck is filled.
9576 POP IX Restore IX from the stack.
9578 RET Return.
Prev: 954D Up: Map Next: 9579