Prev: 48360 Up: Map Next: 48518
48389: 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 46902 and 47023.
Input
A A word-ending character (e.g. a SPACE) from a character string
IX Points to current position in temporary text buffer at 25060
48389 LD (IX+0),A Store character in temporary text buffer
48392 PUSH HL Store HL (pointer to current position in text to print)
48393 LD HL,(63018) Load HL with address of bitmap virtual text cursor
48396 LD A,L Load x-coordinate of the cursor into B, decreasing by one...
48397 DEC A ...
48398 AND 31 ...
48400 LD B,A ...
48401 LD A,(23410) Load x-coordinate of right edge of current window into A
48404 SUB B Subtract B to get distance to right-edge of window in A
48405 PUSH AF Store AF (A = distance to right-edge of window)
48406 LD HL,25060 Point HL at start of temporary text buffer
48409 LD C,0 Set C to zero
48411 LD A,(HL) Load character from current position in temporary text buffer into A
48412 CP 32 If character is 32 (SPACE)...
48414 JR Z,48432 ...then skip ahead to 48432 as end of word reached
48416 CP 13 If character is 13 (carriage return / line feed to start of next character row down)...
48418 JR Z,48432 ...then skip ahead to 48432 as end of word reached
48420 CP 14 If character is 14 (carriage return / line feed to start of next character row down within window)...
48422 JR Z,48432 ...then skip ahead to 48432 as end of word reached
48424 CP 255 If character is 255 (end marker)...
48426 JR Z,48432 ...then skip ahead to 48432 as end of word reached
48428 INC C Increase C (number of characters to print)
48429 INC HL Advance to next character in temporary text buffer
48430 JR 48411 Loop back to 48411
48432 POP AF Restore AF (A = distance to right-edge of window)
48433 SUB C Subtract C (number of characters)
48434 CALL C,48518 If result is negative (i.e. more characters than space) then move virtual text cursors down to left edge of next row of window
48437 LD HL,25059 Point HL at byte before start of temporary text buffer
48440 INC HL Advance to next byte in temporary text buffer
48441 LD A,(HL) Load character from current position in temporary text buffer into A
48442 CP 255 If character is 255 (end marker)...
48444 JR Z,48510 ...then skip ahead to 48510 (reset temporary text buffer and load next word into it)
48446 CP 32 If character is 32 (SPACE)...
48448 JR Z,48491 ...then skip ahead to 48491
48450 CP 13 If character is 13 (carriage return / line feed to start of next character row down)...
48452 JP Z,48478 ...then skip ahead to 48478
48455 CP 14 If character is 14 (carriage return / line feed to start of next character row down within window)...
48457 JP Z,48486 ...then skip ahead to 48486
48460 CP 9 If character is 9 (move virtual text cursor right one character)...
48462 JP Z,48470 ...then skip ahead to 48470
48465 CALL 63005 Print the character
48468 JR 48440 Loop back to 48440
Move virtual text cursor right one character (9)
48470 PUSH HL Store HL (current position in temporary text buffer)
48471 CALL 63247 Advance bitmap virtual text cursor right by one character
48474 POP HL Restore HL (current position in temporary text buffer)
48475 JP 48440 Jump to 48440 for next character
Carriage return / line feed to start of next character row down (13)
48478 CALL 63263 Advance bitmap virtual text cursor to start of next character row
48481 CALL 63286 Update attribute virtual text cursor based upon current bitmap virtual text cursor
48484 JR 48510 Skip ahead to 48510 (reset temporary text buffer and load next word into it)
Carriage return / line feed to start of next character row down within window (14)
48486 CALL 48518 Move virtual text cursors (attribute and bitmap) down to left edge of next row of window
48489 JR 48510 Skip ahead to 48510 (reset temporary text buffer and load next word into it)
Print a SPACE (32)
48491 LD HL,(63018) Load HL with address of bitmap virtual text cursor
48494 LD A,L Strip out higher-order bits in L to leave only x-coordinate component...
48495 AND 31 ...
48497 LD L,A ...
48498 LD A,(23410) Load A with x-coordinate of right edge of current window plus one...
48501 INC A ...
48502 CP L If this is the same as the x-coordinate of the bitmap virtual text cursor...
48503 JR Z,48510 ...then skip ahead to 48510 (reset temporary text buffer and load next word into it, i.e. no need to print a SPACE)
48505 LD A,32 Print a SPACE character...
48507 CALL 63005 ...
End marker (255)
48510 POP HL Restore HL (pointer to current position in text to print)
48511 LD IX,25060 Point IX at start of temporary text buffer
48515 JP 46924 Jump back to 46924 to load next word into temporary text buffer
Prev: 48360 Up: Map Next: 48518