Prev: 38166 Up: Map Next: 38208
38168: 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 38168 LD HL,38208 HL=Table_CardDuplicates.
38171 LD B,13 Set a counter in B of the number of possible values of cards there are in one suit.
ClearDuplicatesTable_Loop 38173 LD (HL),0 Write 0 to *HL.
38175 INC HL Increment HL by one.
38176 DJNZ ClearDuplicatesTable_Loop Decrease counter by one and loop back to ClearDuplicatesTable_Loop until counter is zero.
38178 PUSH IX Stash the hand pointer on the stack.
38180 PUSH IX Copy the hand pointer into HL from IX (using the stack).
38182 POP HL
Using the duplicates table, count how many cards of each value are present in the given hand.
38183 LD B,5 Set a counter in B of the number of cards in a hand.
CountDuplicates_Loop 38185 LD IX,38208 IX=Table_CardDuplicates.
38189 LD A,(HL) Fetch the current card from the hand.
38190 AND %00001111 Convert it into a suit-less value (by keeping only bits 0-3).
38192 LD E,A Create an offset using DE, this will help us to point to the relevant card value in the duplicates table.
38193 LD D,0
38195 ADD IX,DE Add the card offset in DE to IX.
38197 INC (IX+0) Increment the card duplicate count in the duplicates table by one.
38200 INC HL Move onto the next card in the hand.
38201 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.
38203 POP IX Restore the hand pointer from the stack.
38205 JP CountSuits Jump to CountSuits.
Prev: 38166 Up: Map Next: 38208