Routines |
Prev: 38003 | Up: Map | Next: 38043 |
|
||||||||||
CalculateSuit | 38011 | LD D,A | Copy the card value into D. | |||||||
38012 | LD E,0 | Initialise E to 0. | ||||||||
38014 | PUSH IX | Copy the hand pointer into HL from IX (using the stack). | ||||||||
38016 | POP HL | |||||||||
38017 | LD B,5 | Set a counter in B to check all 5 cards in this hand. | ||||||||
CalculateSuit_Loop | 38019 | LD A,(HL) | Fetch the card value and store it in A. | |||||||
38020 | AND %00001111 | Convert it into a suit-less value (by keeping only bits 0-3). | ||||||||
38022 | CP D | Jump to CalculateSuit_FoundMatch if A is equal to D. | ||||||||
38023 | JR Z,CalculateSuit_FoundMatch | |||||||||
CalculateSuit_Continue | 38025 | INC HL | Move the hand pointer to the next card. | |||||||
38026 | DJNZ CalculateSuit_Loop | Decrease the card counter by one and loop back to CalculateSuit_Loop until all cards in the hand have been evaluated. | ||||||||
38028 | LD A,E | A=E. | ||||||||
Work out the suit.
|
||||||||||
38029 | LD B,4 | Shift A right four positions. | ||||||||
CalculateSuitShift_Loop | 38031 | SRA A | ||||||||
38033 | DJNZ CalculateSuitShift_Loop | |||||||||
38035 | RET | Return. | ||||||||
CalculateSuit_FoundMatch | 38036 | LD A,(HL) | Jump to CalculateSuit_Continue if *HL is lower than E. | |||||||
38037 | CP E | |||||||||
38038 | JR C,CalculateSuit_Continue | |||||||||
38040 | LD E,A | E=A. | ||||||||
38041 | JR CalculateSuit_Continue | Jump to CalculateSuit_Continue. |
Prev: 38003 | Up: Map | Next: 38043 |