Prev: 9516 Up: Map Next: 9540
9518: Count Duplicates
Used by the routine at PlayGame.
Input
IX Pointer to either the player or girls hand
First, clear down any old values and evaluate fresh.
CountDuplicates 9518 LD HL,$9540 HL=Table_CardDuplicates.
951B LD B,$0D Set a counter in B of the number of possible values of cards there are in one suit.
ClearDuplicatesTable_Loop 951D LD (HL),$00 Write 00 to *HL.
951F INC HL Increment HL by one.
9520 DJNZ ClearDuplicatesTable_Loop Decrease counter by one and loop back to ClearDuplicatesTable_Loop until counter is zero.
9522 PUSH IX Stash the hand pointer on the stack.
9524 PUSH IX Copy the hand pointer into HL from IX (using the stack).
9526 POP HL
Using the duplicates table, count how many cards of each value are present in the given hand.
9527 LD B,$05 Set a counter in B of the number of cards in a hand.
CountDuplicates_Loop 9529 LD IX,$9540 IX=Table_CardDuplicates.
952D LD A,(HL) Fetch the current card from the hand.
952E AND %00001111 Convert it into a suit-less value (by keeping only bits 0-3).
9530 LD E,A Create an offset using DE, this will help us to point to the relevant card value in the duplicates table.
9531 LD D,$00
9533 ADD IX,DE Add the card offset in DE to IX.
9535 INC (IX+$00) Increment the card duplicate count in the duplicates table by one.
9538 INC HL Move onto the next card in the hand.
9539 DJNZ CountDuplicates_Loop Decrease the card counter by one and loop back to CountDuplicates_Loop until all the cards in the hand have been evaluated.
953B POP IX Restore the hand pointer from the stack.
953D JP CountSuits Jump to CountSuits.
Prev: 9516 Up: Map Next: 9540