Prev: 62665 Up: Map Next: 63537
63434: 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 63434 LD HL,63538 Write BufferSmallFont to *UDG.
63437 LD (23675),HL
Print40ColumnText_Loop 63440 LD A,B Jump to Process40ColumnText if BC is not zero.
63441 OR C
63442 JR NZ,Process40ColumnText
63444 LD HL,63537 HL=FlagShiftLetter.
63447 BIT 0,(HL) Return if bit 0 of *HL is not set.
63449 RET Z
63450 LD A,144 Print the UDG buffer to the screen.
63452 RST 16
63453 RES 0,(HL) Reset bit 0 of *HL.
63455 RET Return.
Process the current letter.
Process40ColumnText 63456 LD A,(DE) Fetch the current letter from the pointer in *DE, and store it in A.
63457 SUB 32 Subtract 32 from A to "normalise" it. ASCII characters start from 32 ("SPACE") so this makes them 0-based.
63459 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).
63461 ADD A,32 Add 32 to the character to restore the "proper" ASCII value.
63463 PUSH DE Stash the string pointer on the stack.
63464 RST 16 Action the current ASCII character.
63465 POP DE Restore the string pointer from the stack.
63466 INC DE Move onto the next letter in the string.
63467 DEC BC Decrease the string length counter by one.
63468 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 63470 INC A Increment A by one.
63471 PUSH DE Stash the string pointer and string length on the stack.
63472 PUSH BC
Locate the UDG character for the current letter.
63473 LD HL,63538 HL=BufferSmallFont.
63476 LD DE,8 HL+=0008.
LocateSmallCharacter_Loop 63479 ADD HL,DE
63480 DEC A Decrease A by one.
63481 JR NZ,LocateSmallCharacter_Loop Jump to LocateSmallCharacter_Loop until A is zero.
63483 LD DE,63538 DE=BufferSmallFont.
The UDGs are still 8 bytes each, just for each only the first 4 bits are used of the 8 total bits.
63486 LD B,8 Set a UDG counter of 8.
SmallCharacterCopy_Loop 63488 LD A,(63537) Test bit 0 of *FlagShiftLetter...
63491 BIT 0,A
63493 LD A,(HL) Fetch the UDG letter byte and store it in A.
63494 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.
63496 LD C,4 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 63498 SRL A
63500 DEC C
63501 JR NZ,ShiftToRightHandSide_Loop
63503 LD C,A Merge the current byte in BufferSmallFont together with the shifted letter in C. The result is stored in A.
63504 LD A,(DE)
63505 OR C
WriteSmallCharacterToBuffer 63506 LD (DE),A Write A to the buffer.
63507 INC HL Move onto the next byte of the UDG letter.
63508 INC DE Move onto the next byte in the buffer.
63509 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.
63511 LD A,(63537) Flip bit 0 of *FlagShiftLetter.
63514 XOR %00000001
63516 LD (63537),A
63519 POP BC Restore the string length and string pointer from the stack.
63520 POP DE
63521 INC DE Move onto the next letter in the string.
63522 DEC BC Decrease the string length counter by one.
63523 LD A,(63537) Jump to Print40ColumnText_Loop if bit 0 of *FlagShiftLetter is set.
63526 BIT 0,A
63528 JR NZ,Print40ColumnText_Loop
Else, we can now print the UDG buffer at BufferSmallFont to the screen.
63530 PUSH DE Stash the string pointer on the stack.
63531 LD A,144 Print the UDG buffer to the screen.
63533 RST 16
63534 POP DE Restore the string pointer from the stack.
63535 JR Print40ColumnText_Loop Jump to Print40ColumnText_Loop.
Prev: 62665 Up: Map Next: 63537