![]() |
Routines |
| Prev: 43445 | Up: Map | Next: 43633 |
|
Used by the routines at PrintNewline, ProcessObject_Display, ProcessTextCommand, PrintCharacterAndReturnZero, PrintCharacterWithTimePeriod, PrintCharacterAndReturn, ExtractTokenFromText, PrintTextBasedOnFlag, ProcessLocationTokenDisplay, PrintFormattedObjectList, PrintObjectDescriptionText and 59068.
|
||||||||
| Print_Character | 43447 | PUSH AF | Stash the character code on the stack. | |||||
| 43448 | LD A,(40999) | Jump to Print_Character_AlternateMode if *PrintModeFlag isn't set (not in direct print mode). | ||||||
| 43451 | AND A | |||||||
| 43452 | JR NZ,Print_Character_AlternateMode | |||||||
|
Handle direct print mode - write character to buffer.
|
||||||||
| 43454 | POP AF | Restore the character code from the stack. | ||||||
| 43455 | PUSH AF | Stash the character code and HL on the stack. | ||||||
| 43456 | PUSH HL | |||||||
| 43457 | LD HL,(43445) | HL=*BufferPointer (load the buffer pointer). | ||||||
| 43460 | CP 32 | Jump to Print_Character_ScreenPrintMode if the character is a "SPACE" (ASCII 32). | ||||||
| 43462 | JR Z,Print_Character_ScreenPrintMode | |||||||
| 43464 | CP 13 | Jump to Print_Character_ScreenPrintMode if the character is an "ENTER" (ASCII 13). | ||||||
| 43466 | JR Z,Print_Character_ScreenPrintMode | |||||||
| 43468 | CP 34 | Jump to Print_Character_ScreenPrintMode if the character is a quotation mark (ASCII 34). | ||||||
| 43470 | JR Z,Print_Character_ScreenPrintMode | |||||||
| 43472 | CP 8 | Jump to Print_Character_WriteToBuffer if the character is not a backspace (ASCII 8). | ||||||
| 43474 | JR NZ,Print_Character_WriteToBuffer | |||||||
|
The character IS a backspace, so handle this.
|
||||||||
| 43476 | DEC HL | Decrease HL by one (move buffer pointer back for backspace). | ||||||
| 43477 | JR Print_Character_UpdateBufferPointer | Jump to Print_Character_UpdateBufferPointer (skip writing the character). | ||||||
|
Write the character to the buffer.
|
||||||||
| Print_Character_WriteToBuffer | 43479 | LD (HL),A | Write the character to the buffer. | |||||
| 43480 | INC HL | Increment the buffer pointer by one. | ||||||
| Print_Character_UpdateBufferPointer | 43481 | LD (43445),HL | Write the buffer pointer back to *BufferPointer. | |||||
| 43484 | POP HL | Restore HL and the character code from the stack. | ||||||
| 43485 | POP AF | |||||||
| 43486 | RET | Return. | ||||||
|
Handle screen print mode - check if we need to scroll.
|
||||||||
| Print_Character_ScreenPrintMode | 43487 | PUSH DE | Stash DE on the stack. | |||||
| 43488 | LD DE,23563 | Jump to Print_Character_ProcessChar if DEFADD is equal to HL. | ||||||
| 43491 | AND A | |||||||
| 43492 | SBC HL,DE | |||||||
| 43494 | JR Z,Print_Character_ProcessChar | |||||||
|
Check if we need to scroll the screen.
|
||||||||
| 43496 | LD A,(49653) | A=*ScreenWidth. | ||||||
| 43499 | CP L | Compare *ScreenWidth with L (the screen offset). | ||||||
| 43500 | PUSH AF | Stash the comparison result on the stack. | ||||||
| 43501 | JR NC,Print_Character_ScrollScreen | Jump to Print_Character_ScrollScreen if we don't need to scroll (A is greater than or equal to L). | ||||||
| 43503 | LD A,13 | A=13 (load carriage return character). | ||||||
| 43505 | CALL Print_Character_ProcessCharacter | Call Print_Character_ProcessCharacter to process the carriage return. | ||||||
|
Scroll the screen by clearing the first line.
|
||||||||
| Print_Character_ScrollScreen | 43508 | PUSH BC | Stash BC on the stack. | |||||
| 43509 | LD B,L | B=L (store the line width in B). | ||||||
| 43510 | LD HL,23563 | HL=DEFADD (reset to the start of the screen buffer). | ||||||
| 43513 | LD (43445),HL | Write HL (the screen buffer pointer) to *BufferPointer. | ||||||
| Print_Character_ScrollLoop | 43516 | LD A,(HL) | Load a character from the screen buffer into A. | |||||
| 43517 | CALL Print_Character_ProcessCharacter | Call Print_Character_ProcessCharacter to process the character (shift it up). | ||||||
| 43520 | INC HL | Move to the next character. | ||||||
| 43521 | DJNZ Print_Character_ScrollLoop | Decrease counter by one and loop back to Print_Character_ScrollLoop until counter is zero. | ||||||
| 43523 | POP BC | Restore BC and AF from the stack. | ||||||
| 43524 | POP AF | |||||||
| 43525 | JR NZ,Print_Character_ProcessChar | Jump to Print_Character_ProcessChar if we haven't finished scrolling (HL is not equal to L). | ||||||
|
Clear the print position flag after scrolling is complete.
|
||||||||
| 43527 | XOR A | Reset *PrintPositionFlag. | ||||||
| 43528 | LD (40997),A | |||||||
| Print_Character_ProcessChar | 43531 | POP DE | Restore DE, HL and the character code from the stack. | |||||
| 43532 | POP HL | |||||||
| 43533 | POP AF | |||||||
| 43534 | JR Print_Character_ProcessCharacter | Jump to Print_Character_ProcessCharacter to process the character. | ||||||
|
Use alternate print method (direct screen printing).
|
||||||||
| Print_Character_AlternateMode | 43536 | POP AF | Restore the character code from the stack. | |||||
| 43537 | JP CheckTVFlagAndProcess | Jump to CheckTVFlagAndProcess to print using alternate method. | ||||||
|
Convert uppercase letters to lowercase if needed.
|
||||||||
| Print_Character_ProcessCharacter | 43540 | CP 65 | Jump to Print_Character_CheckSpace if the character is not uppercase. | |||||
| 43542 | JR C,Print_Character_CheckSpace | |||||||
| 43544 | CP 91 | |||||||
| 43546 | JR NC,Print_Character_CheckSpace | |||||||
| 43548 | OR %00100000 | Set bit 5 (convert to lowercase). | ||||||
| Print_Character_CheckSpace | 43550 | PUSH AF | Stash the character code on the stack. | |||||
| 43551 | LD A,(40997) | Jump to Print_Character_MarkPrintStarted if we're not at the start of a line (load print position flag from *PrintPositionFlag, set flags, jump if not zero). | ||||||
| 43554 | AND A | |||||||
| 43555 | JR NZ,Print_Character_MarkPrintStarted | |||||||
| 43557 | POP AF | Restore the character code from the stack. | ||||||
| 43558 | CP 32 | Return if the character is a "SPACE". | ||||||
| 43560 | RET Z | |||||||
| 43561 | PUSH AF | Stash the character code on the stack. | ||||||
|
Mark that we've started printing on this line.
|
||||||||
| Print_Character_MarkPrintStarted | 43562 | LD A,1 | Set *PrintPositionFlag. | |||||
| 43564 | LD (40997),A | |||||||
| 43567 | POP AF | Restore the character code from the stack. | ||||||
| 43568 | PUSH AF | Stash the character code on the stack. | ||||||
| 43569 | CP 13 | Jump to Print_Character_CheckQuote if the character is not a carriage return (compare with 13 jump if not equal). | ||||||
| 43571 | JR NZ,Print_Character_CheckQuote | |||||||
|
Reset the print position flag for a carriage return.
|
||||||||
| 43573 | XOR A | Clear *PrintPositionFlag. | ||||||
| 43574 | LD (40997),A | |||||||
| 43577 | JR Print_Character_Print | Jump to Print_Character_Print (skip further processing). | ||||||
|
Check if the character is a quotation mark (needs special handling).
|
||||||||
| Print_Character_CheckQuote | 43579 | CP 34 | Jump to Print_Character_CheckPeriod if the character is not a quote mark (compare with 34 jump if not equal). | |||||
| 43581 | JR NZ,Print_Character_CheckPeriod | |||||||
| 43583 | LD A,32 | A=32 (replace quote with space). | ||||||
| 43585 | CALL CheckTVFlagAndProcess | Call CheckTVFlagAndProcess to print the space. | ||||||
| 43588 | JR Print_Character_SetTokenFormatFlag | Jump to Print_Character_SetTokenFormatFlag (continue processing). | ||||||
|
Check if the character is a period (sets token format flag if it is).
|
||||||||
| Print_Character_CheckPeriod | 43590 | CP 46 | Jump to Print_Character_CheckLowercase if the character is not a period (compare with 46 jump if not equal). | |||||
| 43592 | JR NZ,Print_Character_CheckLowercase | |||||||
| Print_Character_SetTokenFormatFlag | 43594 | LD A,1 | Set *TokenFormatFlag. | |||||
| 43596 | LD (40998),A | |||||||
| 43599 | JR Print_Character_Print | Jump to Print_Character_Print (skip further processing). | ||||||
|
Handle lowercase letters (dictionary word characters).
|
||||||||
| Print_Character_CheckLowercase | 43601 | CP 97 | Jump to Print_Character_Print if the character is less than 97 (ASCII "a"). | |||||
| 43603 | JR C,Print_Character_Print | |||||||
| 43605 | CP 123 | Jump to Print_Character_Print if the character is greater than or equal to 123 (ASCII "z"+1). | ||||||
| 43607 | JR NC,Print_Character_Print | |||||||
| 43609 | LD A,(43089) | Check the lowercase handling flag and jump to Print_Character_ResetTokenFormatFlag if it's not set (load flag from *LowercaseHandlingFlag, set flags, jump if not set). | ||||||
| 43612 | AND A | |||||||
| 43613 | JR NZ,Print_Character_ResetTokenFormatFlag | |||||||
| 43615 | LD A,(40998) | Jump to Print_Character_Print if *TokenFormatFlag the token format flag is not set. | ||||||
| 43618 | AND A | |||||||
| 43619 | JR Z,Print_Character_Print | |||||||
|
Reset the token format flag before converting to uppercase.
|
||||||||
| Print_Character_ResetTokenFormatFlag | 43621 | XOR A | Reset *TokenFormatFlag. | |||||
| 43622 | LD (40998),A | |||||||
| 43625 | POP AF | Restore the character code from the stack. | ||||||
|
Clear bit 5 from the character code (convert to uppercase).
|
||||||||
| 43626 | AND %01011111 | Keep only bits 0-4, 6 (clear bit 5 to convert lowercase to uppercase). | ||||||
| 43628 | PUSH AF | Stash the modified character code on the stack. | ||||||
| Print_Character_Print | 43629 | POP AF | Restore the character code from the stack. | |||||
| 43630 | JP CheckTVFlagAndProcess | Jump to CheckTVFlagAndProcess to print the character. | ||||||
| Prev: 43445 | Up: Map | Next: 43633 |