Prev: E39A Up: Map Next: E436
E3B8: Print Cards
Used by the routine at CheckCardType.
PrintAceCard E3B8 SUB $03 A-=03.
E3BA DEC B Decrease B by three.
E3BB DEC B
E3BC DEC B
This entry point is used by the routine at CheckCardType.
PrintNumberCard E3BD LD C,B Copy the original card value into C as we need B for the loop below.
E3BE LD B,A Set a counter in B of the card number (this is the lower four bits).
E3BF INC B Increment B by one, due to the way the loop below works.
E3C0 LD DE,$001E The card UDG data blocks are 001E in length, so store this in DE for the calculation.
E3C3 LD HL,$E436 The card data begins from E436 so store this in HL.
E3C6 XOR A Reset the flags.
E3C7 SBC HL,DE Subtract DE from HL as the loop will add it back and then it will be pointing to the beginning again.
FindCardUDGData_Loop E3C9 ADD HL,DE Add 001E to HL to move to the next block of card UDG data.
E3CA DJNZ FindCardUDGData_Loop Decrease the card value counter by one and loop back to FindCardUDGData_Loop until the appropriate card UDG data block is found.
E3CC LD ($E563),HL Write the card UDG data block pointer to *PointerCardUDGData.
Work out the suit.
E3CF LD B,$04 Using the original card value, shift the upper four bits to be the lower four bits.
SuitShift_Loop E3D1 SRL C
E3D3 DJNZ SuitShift_Loop
E3D5 LD A,C Write the calculated suit to *CurrentCardSuit.
E3D6 LD ($E562),A
Now calculate the suit UDG data address.
E3D9 LD B,C Set a counter in B of the calculated suit (this is the upper four bits).
E3DA INC B Increment B by one, due to the way the loop below works.
E3DB LD DE,$0058 The suit UDG data blocks are 0058 in length, so store this in DE for the calculation.
E3DE LD HL,$E6BF The suit UDG data begins from E6BF so store this in HL.
E3E1 XOR A Reset the flags.
E3E2 SBC HL,DE Subtract DE from HL as the loop will add it back and then it will be pointing to the beginning again.
FindSuitUDGData_Loop E3E4 ADD HL,DE Add 0058 to HL to move to the next block of suit UDG data.
E3E5 DJNZ FindSuitUDGData_Loop Decrease the suit counter by one and loop back to FindSuitUDGData_Loop until the appropriate suit UDG data block is found.
E3E7 PUSH DE Set a counter in BC to the length of the suit UDG data block: 0058.
E3E8 POP BC
E3E9 LD DE,$E667 Set the target in DE to Buffer_CardData.
E3EC LDIR Copy the suit UDG data block to the card data buffer.
Set the card character-set to be the in-use font.
E3EE LD HL,$E35F Write E35F to *CHARS.
E3F1 LD ($5C36),HL
Handle setting the colour of the card.
E3F4 LD A,$13 BRIGHT: ON.
E3F6 RST $10
E3F7 LD A,$01
E3F9 RST $10
E3FA LD A,$10 Set INK: BLACK.
E3FC RST $10
E3FD LD A,$00
E3FF RST $10
E400 LD A,($E562) Jump to PrintCard if *CurrentCardSuit is 02 or higher (so Spades or Clubs).
E403 CP $02
E405 JR NC,PrintCard
Else this card is a Diamonds or Hearts so set the INK appropriately.
E407 LD A,$10 Set INK: RED.
E409 RST $10
E40A LD A,$02
E40C RST $10
This entry point is used by the routine at CheckCardType.
PrintCard E40D LD A,($E81F) Fetch the current *CardPosition and store this in A.
E410 LD C,$06 Each card is 06 character blocks in width, store this count in C.
E412 LD B,A Set a counter in B of the card position we're processing.
Subtract 06 from 26 the number of times for the current card position. For example; position 01 is: 26 - (01 * 06) = 20.
E413 LD A,$26 A=26.
FindCardPosition_Loop E415 SUB C A-=C.
E416 DJNZ FindCardPosition_Loop Decrease card position counter by one and loop back to FindCardPosition_Loop until the counter is zero.
E418 LD C,A Store the result in C, this is the column position.
E419 LD B,$0C Set B to 0C this is the row position.
E41B LD DE,($E563) Retrieve *PointerCardUDGData for the current card.
PrintCard_Loop E41F PUSH DE Stash the UDG data pointer on the stack.
E420 LD A,B Jump to PrintCard_Finish when the current print line is equal to 07.
E421 CP $07
E423 JR Z,PrintCard_Finish
E425 CALL $0DE2 Call 0DE2 (CL_SET) to change the co-ordinates in BC to a screen buffer address.
E428 POP DE Restore the UDG data pointer from the stack.
E429 PUSH BC Stash BC on the stack.
E42A LD BC,$0006 Set the number of characters to print in BC (0006).
E42D CALL $203C Call PR_STRING to print to the screen.
E430 POP BC Restore BC from the stack.
E431 DEC B Decrease B by one.
E432 JR PrintCard_Loop Jump to PrintCard_Loop.
Housekeeping and return.
PrintCard_Finish E434 POP DE Restore DE from the stack.
E435 RET Return.
Prev: E39A Up: Map Next: E436