Prev: F4C9 Up: Map Next: F831
F7CA: Print 40 Column Text
Used by the routine at Messaging_Girl.
Input
BC Length of string to print
DE Pointer to string to print
Print40ColumnText F7CA LD HL,$F832 Write BufferSmallFont to *UDG.
F7CD LD ($5C7B),HL
Print40ColumnText_Loop F7D0 LD A,B Jump to Process40ColumnText if BC is not zero.
F7D1 OR C
F7D2 JR NZ,Process40ColumnText
F7D4 LD HL,$F831 HL=FlagShiftLetter.
F7D7 BIT 0,(HL) Return if bit 0 of *HL is not set.
F7D9 RET Z
F7DA LD A,$90 Print the UDG buffer to the screen.
F7DC RST $10
F7DD RES 0,(HL) Reset bit 0 of *HL.
F7DF RET Return.
Process the current letter.
Process40ColumnText F7E0 LD A,(DE) Fetch the current letter from the pointer in *DE, and store it in A.
F7E1 SUB $20 Subtract 20 from A to "normalise" it. ASCII characters start from 20 ("SPACE") so this makes them 00-based.
F7E3 JR NC,Process40ColumnCharacter Jump to Process40ColumnCharacter if A is higher than zero.
Where A is less than zero, this means a control character needs to be actioned (e.g. setting INK/ PAPER/ PRINT AT/ etc).
F7E5 ADD A,$20 Add 20 to the character to restore the "proper" ASCII value.
F7E7 PUSH DE Stash the string pointer on the stack.
F7E8 RST $10 Action the current ASCII character.
F7E9 POP DE Restore the string pointer from the stack.
F7EA INC DE Move onto the next letter in the string.
F7EB DEC BC Decrease the string length counter by one.
F7EC JR Print40ColumnText_Loop Jump back to Print40ColumnText_Loop.
We have a character we want to process, the UDGs for the characters begin at SmallCustomFont.
Process40ColumnCharacter F7EE INC A Increment A by one.
F7EF PUSH DE Stash the string pointer and string length on the stack.
F7F0 PUSH BC
Locate the UDG character for the current letter.
F7F1 LD HL,$F832 HL=BufferSmallFont.
F7F4 LD DE,$0008 HL+=0008.
LocateSmallCharacter_Loop F7F7 ADD HL,DE
F7F8 DEC A Decrease A by one.
F7F9 JR NZ,LocateSmallCharacter_Loop Jump to LocateSmallCharacter_Loop until A is zero.
F7FB LD DE,$F832 DE=BufferSmallFont.
The UDGs are still 8 bytes each, just for each only the first 04 bits are used of the 08 total bits.
F7FE LD B,$08 Set a UDG counter of 08.
SmallCharacterCopy_Loop F800 LD A,($F831) Test bit 0 of *FlagShiftLetter...
F803 BIT 0,A
F805 LD A,(HL) Fetch the UDG letter byte and store it in A.
F806 JR Z,WriteSmallCharacterToBuffer Jump to WriteSmallCharacterToBuffer if bit 0 of *FlagShiftLetter was not set.
Shift the letter from the left-hand side of the UDG buffer over to the right-hand side.
F808 LD C,$04 Shift the bits of the current letter right four bits (move the letter from being on the left-hand side over to the right-hand side).
ShiftToRightHandSide_Loop F80A SRL A
F80C DEC C
F80D JR NZ,ShiftToRightHandSide_Loop
F80F LD C,A Merge the current byte in BufferSmallFont together with the shifted letter in C. The result is stored in A.
F810 LD A,(DE)
F811 OR C
WriteSmallCharacterToBuffer F812 LD (DE),A Write A to the buffer.
F813 INC HL Move onto the next byte of the UDG letter.
F814 INC DE Move onto the next byte in the buffer.
F815 DJNZ SmallCharacterCopy_Loop Decrease the UDG byte counter by one and loop back to SmallCharacterCopy_Loop until the counter is zero.
This toggle is the "magic" - it handles the left/ right flow of the code.
F817 LD A,($F831) Flip bit 0 of *FlagShiftLetter.
F81A XOR %00000001
F81C LD ($F831),A
F81F POP BC Restore the string length and string pointer from the stack.
F820 POP DE
F821 INC DE Move onto the next letter in the string.
F822 DEC BC Decrease the string length counter by one.
F823 LD A,($F831) Jump to Print40ColumnText_Loop if bit 0 of *FlagShiftLetter is set.
F826 BIT 0,A
F828 JR NZ,Print40ColumnText_Loop
Else, we can now print the UDG buffer at BufferSmallFont to the screen.
F82A PUSH DE Stash the string pointer on the stack.
F82B LD A,$90 Print the UDG buffer to the screen.
F82D RST $10
F82E POP DE Restore the string pointer from the stack.
F82F JR Print40ColumnText_Loop Jump to Print40ColumnText_Loop.
Prev: F4C9 Up: Map Next: F831