Prev: 36573 Up: Map Next: 36731
36602: Print word in temporary text buffer to screen, wrapping text if necessary, then process next word
This routine prints the string of characters stored in the temporary text buffer. If the string is longer than the available space to the right of the virtual text cursor, then the cursor is wrapped, moving down to the next character row and to the left edge of the current window.
Used by the routines at 34762 and 34861.
Input
A A word-ending character (e.g. a SPACE) from a character string
IX Points to current position in temporary text buffer at 24005
36602 LD (IX+0),A Store character in temporary text buffer
36605 PUSH HL Store HL (pointer to current position in text to print)
36606 LD HL,(54110) Load HL with address of bitmap virtual text cursor
36609 LD A,L Load x-coordinate of the cursor into B, decreasing by one...
36610 DEC A ...
36611 AND 31 ...
36613 LD B,A ...
36614 LD A,(23495) Load x-coordinate of right edge of current window into A
36617 SUB B Subtract B to get distance to right-edge of window in A
36618 PUSH AF Store AF (A = distance to right-edge of window)
36619 LD HL,24005 Point HL at start of temporary text buffer
36622 LD C,0 Set C to zero
36624 LD A,(HL) Load character from current position in temporary text buffer into A
36625 CP 32 If character is 32 (SPACE)...
36627 JR Z,36645 ...then skip ahead to 36645 as end of word reached
36629 CP 13 If character is 13 (carriage return / line feed to start of next character row down)...
36631 JR Z,36645 ...then skip ahead to 36645 as end of word reached
36633 CP 14 If character is 14 (carriage return / line feed to start of next character row down within window)...
36635 JR Z,36645 ...then skip ahead to 36645 as end of word reached
36637 CP 255 If character is 255 (end marker)...
36639 JR Z,36645 ...then skip ahead to 36645 as end of word reached
36641 INC C Increase C (number of characters to print)
36642 INC HL Advance to next character in temporary text buffer
36643 JR 36624 Loop back to 36624
36645 POP AF Restore AF (A = distance to right-edge of window)
36646 SUB C Subtract C (number of characters)
36647 CALL C,36731 If result is negative (i.e. more characters than space) then move virtual text cursors down to left edge of next row of window
36650 LD HL,24004 Point HL at byte before start of temporary text buffer
36653 INC HL Advance to next byte in temporary text buffer
36654 LD A,(HL) Load character from current position in temporary text buffer into A
36655 CP 255 If character is 255 (end marker)...
36657 JR Z,36723 ...then skip ahead to 36723 (reset temporary text buffer and load next word into it)
36659 CP 32 If character is 32 (SPACE)...
36661 JR Z,36704 ...then skip ahead to 36704
36663 CP 13 If character is 13 (carriage return / line feed to start of next character row down)...
36665 JP Z,36691 ...then skip ahead to 36691
36668 CP 14 If character is 14 (carriage return / line feed to start of next character row down within window)...
36670 JP Z,36699 ...then skip ahead to 36699
36673 CP 9 If character is 9 (move virtual text cursor right one character)...
36675 JP Z,36683 ...then skip ahead to 36683
36678 CALL 54097 Print the character
36681 JR 36653 Loop back to 36653
Move virtual text cursor right one character (9)
36683 PUSH HL Store HL (current position in temporary text buffer)
36684 CALL 54176 Advance bitmap virtual text cursor right by one character
36687 POP HL Restore HL (current position in temporary text buffer)
36688 JP 36653 Jump to 36653 for next character
Carriage return / line feed to start of next character row down (13)
36691 CALL 54192 Advance bitmap virtual text cursor to start of next character row
36694 CALL 54215 Update attribute virtual text cursor based upon current bitmap virtual text cursor
36697 JR 36723 Skip ahead to 36723 (reset temporary text buffer and load next word into it)
Carriage return / line feed to start of next character row down within window (14)
36699 CALL 36731 Move virtual text cursors (attribute and bitmap) down to left edge of next row of window
36702 JR 36723 Skip ahead to 36723 (reset temporary text buffer and load next word into it)
Print a SPACE (32)
36704 LD HL,(54110) Load HL with address of bitmap virtual text cursor
36707 LD A,L Strip out higher-order bits in L to leave only x-coordinate component...
36708 AND 31 ...
36710 LD L,A ...
36711 LD A,(23495) Load A with x-coordinate of right edge of current window plus one...
36714 INC A ...
36715 CP L If this is the same as the x-coordinate of the bitmap virtual text cursor...
36716 JR Z,36723 ...then skip ahead to 36723 (reset temporary text buffer and load next word into it, i.e. no need to print a SPACE)
36718 LD A,32 Print a SPACE character...
36720 CALL 54097 ...
End marker (255)
36723 POP HL Restore HL (pointer to current position in text to print)
36724 LD IX,24005 Point IX at start of temporary text buffer
36728 JP 34784 Jump back to 34784 to load next word into temporary text buffer
Prev: 36573 Up: Map Next: 36731