Prev: 58131 Up: Map Next: 58266
58170: Check Card Type
Used by the routine at PrintHand.
Input
A Card value
CheckCardType 58170 LD B,A B=the original card value.
58171 AND %00001111 Convert the card value into a suit-less value (by keeping only bits 0-3).
58173 CP 9 Jump to PrintNumberCard if A is lower than 9.
58175 JR C,PrintNumberCard
58177 CP 12 Jump to PrintAceCard if A is equal to 12.
58179 JR Z,PrintAceCard
Anything else is a picture card, so work out what we're printing.
58181 LD HL,58904 HL=58904.
58184 LD DE,1080 DE=1080.
58187 SUB 8 A-=8.
58189 SBC HL,DE HL-=DE (with carry).
CheckCardType_0 58191 ADD HL,DE HL+=DE.
58192 DEC A Decrease A by one.
58193 JR NZ,CheckCardType_0 Jump to CheckCardType_0 until A is zero.
Work out the suit.
58195 LD A,4 A=4.
CardTypeSuitShift_Loop 58197 SRL B Shift B right.
58199 DEC A Decrease A by one.
58200 JR NZ,CardTypeSuitShift_Loop Jump back to CardTypeSuitShift_Loop until A is zero.
58202 LD DE,270 DE=0270.
58205 XOR A Reset flags.
58206 SBC HL,DE HL-=DE (with carry).
58208 INC B Increment B by one.
CheckCardType_1 58209 ADD HL,DE HL+=DE.
58210 DJNZ CheckCardType_1 Decrease counter by one and loop back to CheckCardType_1 until counter is zero.
58212 LD (23606),HL Write HL to *CHARS.
58215 LD DE,760 HL+=0760.
58218 ADD HL,DE
58219 PUSH HL Stash HL on the stack.
58220 LD HL,58266 Write Graphics_PictureCard to *PointerCardUDGData.
58223 LD (58723),HL
58226 CALL PrintCard Call PrintCard.
Calculate the attribute buffer position for the card position currently being printed.
58229 LD A,(59423) A=*CardPosition.
58232 LD HL,6 HL=0006.
58235 LD DE,22907 DE=22907 (attribute buffer location).
58238 EX DE,HL Exchange the DE and HL registers.
FindCardAttributePosition_Loop 58239 ADD HL,DE HL+=DE.
58240 DEC A Decrease A by one.
58241 JR NZ,FindCardAttributePosition_Loop Jump to FindCardAttributePosition_Loop until A is zero.
58243 EX DE,HL Exchange the DE and HL registers.
58244 POP HL Restore the attributes pointer from the stack.
58245 LD C,5 Set the card height (5) to C.
CopyCardAttributes_RowLoop 58247 LD B,6 Set the card width (6) to B.
CopyCardAttributes_Loop 58249 LD A,(HL) Copy an attribute byte from *HL to *DE.
58250 LD (DE),A
58251 INC HL Increment both HL and DE by one.
58252 INC DE
58253 DJNZ CopyCardAttributes_Loop Decrease the width counter by one and loop back to CopyCardAttributes_Loop until all the attributes in the row have been copied.
58255 PUSH HL Stash HL on the stack.
Move down one line, and to where the next row will start (6 less than one row ~ 32).
58256 LD HL,26 DE+=0026.
58259 ADD HL,DE
58260 EX DE,HL
58261 POP HL Restore HL from the stack.
58262 DEC C Decrease the height counter by one.
58263 JR NZ,CopyCardAttributes_RowLoop Jump to CopyCardAttributes_RowLoop until the entire card has been printed.
58265 RET Return.
Prev: 58131 Up: Map Next: 58266