![]() |
Routines |
| Prev: 25330 | Up: Map | Next: 25492 |
|
Used by the routine at FinishWord.
Adds the character to the current word. A space, ENTER or a terminator flushes the word, wrapping when it would pass column 43.
|
||||
| CollectWord | 25369 | PUSH AF | Stash the registers around the word buffer. | |
| 25370 | PUSH HL | |||
| 25371 | PUSH BC | |||
| 25372 | PUSH DE | |||
| 25373 | LD HL,(23449) | Store the character. | ||
| 25376 | LD (HL),A | |||
| 25377 | INC HL | Advance the word pointer. | ||
| 25378 | LD (23449),HL | |||
| 25381 | LD HL,23448 | Point HL at WordLength. | ||
| 25384 | INC (HL) | Count it. | ||
| 25385 | CP 32 | Jump to CollectWord_Flush if it is a space. | ||
| 25387 | JR Z,CollectWord_Flush | |||
| 25389 | CP 13 | Jump to CollectWord_Flush if it is ENTER. | ||
| 25391 | JR Z,CollectWord_Flush | |||
| 25393 | CP 94 | Jump to CollectWord_Flush if it is 94. | ||
| 25395 | JR Z,CollectWord_Flush | |||
| 25397 | CP 126 | Jump to CollectWord_Flush if it is 126. | ||
| 25399 | JR Z,CollectWord_Flush | |||
| 25401 | JP PrintCharacter_Done | Any other character returns. | ||
|
Flush the buffered word.
|
||||
| CollectWord_Flush | 25404 | LD HL,23448 | Point HL at WordLength. | |
| 25407 | CP 94 | Jump to CollectWord_Drop if it is 94. | ||
| 25409 | JR Z,CollectWord_Drop | |||
| 25411 | CP 126 | Jump to CollectWord_Drop if it is 126. | ||
| 25413 | JR Z,CollectWord_Drop | |||
| 25415 | CP 32 | A space is not part of the width either. | ||
| 25417 | JR NZ,CollectWord_Width | |||
|
Drop the terminator from the width.
|
||||
| CollectWord_Drop | 25419 | DEC (HL) | Drop that character from the count. | |
|
See whether the word fits.
|
||||
| CollectWord_Width | 25420 | PUSH AF | Remember the character being flushed. | |
| 25421 | LD A,(23434) | Call WrapLine when *PrintColumn plus the word would pass 42. | ||
| 25424 | ADD A,(HL) | |||
| 25425 | CP 43 | |||
| 25427 | CALL NC,WrapLine | |||
| 25430 | POP AF | Restore the character from the stack. | ||
| 25431 | LD HL,23392 | The buffered word starts at WordBuffer. | ||
|
Print the flushed characters.
|
||||
| CollectWord_Character | 25434 | LD A,(HL) | Jump to CollectWord_End if it is not 126. | |
| 25435 | CP 126 | |||
| 25437 | JR NZ,CollectWord_End | |||
| 25439 | LD A,32 | Print a space. | ||
| 25441 | CALL PrintCharacter | |||
| 25444 | JR CollectWord_Reset | Jump to CollectWord_Reset. | ||
|
Finish the message or keep printing.
|
||||
| CollectWord_End | 25446 | CP 94 | 94 finishes the message. | |
| 25448 | JR Z,CollectWord_Newline | |||
| 25450 | CP 32 | Jump to CollectWord_Break if it is a space. | ||
| 25452 | JR Z,CollectWord_Break | |||
| 25454 | CP 13 | Jump to CollectWord_Break if it is ENTER. | ||
| 25456 | JR Z,CollectWord_Break | |||
| 25458 | CALL PrintCharacter | Call PrintCharacter. | ||
| 25461 | INC HL | Advance to the next buffered character. | ||
| 25462 | JR CollectWord_Character | Jump to CollectWord_Character. | ||
|
The word does not fit on this row.
|
||||
| WrapLine | 25464 | LD A,13 | Start a new line. | |
| 25466 | CALL PrintCharacter | |||
| 25469 | RET | Return. | ||
|
Start a new line, then reset the word.
|
||||
| CollectWord_Newline | 25470 | PUSH AF | Stash the character on the stack. | |
| 25471 | CALL WrapLine | Call WrapLine. | ||
| 25474 | POP AF | Restore the character from the stack. | ||
| 25475 | JR CollectWord_Reset | Jump to CollectWord_Reset. | ||
|
A space or ENTER is printed before the reset.
|
||||
| CollectWord_Break | 25477 | CALL PrintCharacter | Call PrintCharacter. | |
|
Reset the word buffer.
|
||||
| CollectWord_Reset | 25480 | LD HL,23392 | Point the next word back at WordBuffer. | |
| 25483 | LD (23449),HL | |||
| 25486 | XOR A | Write 0 to WordLength. | ||
| 25487 | LD (23448),A | |||
| 25490 | JR PrintCharacter_Done | Jump to PrintCharacter_Done. | ||
| Prev: 25330 | Up: Map | Next: 25492 |