Prev: 46381 Up: Map Next: 46435
46397: Print Colour String
Used by the routines at Poem_Start, GameOver_1UP_Messaging and PrintBanner.
Prints a string at the position given, which has its attribute as the first byte. The last character of the string has bit 7 set. The attribute is written to each of the positions of the characters.
Before
colour-string-before
After PrintStringColour
colour-string-after
Input
HL Position of the text, with the Y position in H and the X position in L (both in pixels)
DE Pointer to string data
PrintStringColour 46397 PUSH HL Stash the position of the string on the stack.
46398 CALL ScreenAddress Convert the position into a screen address.
46401 LD A,(DE) Fetch the attribute of the string.
46402 EX AF,AF' Stash the attribute in the shadow AF register.
46403 INC DE Move onto the text of the string.
46404 EXX Switch to the shadow registers.
46405 POP HL Restore the position of the string from the stack.
46406 CALL AttributeAddress Convert the position into an attribute address.
This entry point is used by the routine at MenuWriteText.
PrintString_Loop 46409 EXX Switch back to the normal registers.
46410 LD A,(DE) Fetch the next character of the string.
46411 BIT 7,A Jump to PrintString_LastCharacter if this is the last character of the string (bit 7 is set).
46413 JR NZ,PrintString_LastCharacter
46415 CALL PrintScreen Print the character.
46418 INC DE Move onto the next character of the string.
46419 EXX Switch to the shadow registers.
46420 EX AF,AF' Fetch the attribute.
46421 LD (HL),A Set the attribute of the character on the screen.
46422 INC L Move onto the next column.
46423 EX AF,AF' Stash the attribute in the shadow AF register.
46424 JR PrintString_Loop Jump back to PrintString_Loop to print the next character.
Because the last character contains the terminator, it needs to be handled separately.
PrintString_LastCharacter 46426 AND %01111111 Keep only bits 0-6 (i.e. strip the bit 7 terminator).
46428 CALL PrintScreen Print the last character of the string.
46431 EXX Switch to the shadow registers.
46432 EX AF,AF' Fetch the attribute.
46433 LD (HL),A Set the attribute of the last character on the screen.
46434 RET Return.
Prev: 46381 Up: Map Next: 46435