![]() |
Routines |
| Prev: A9B5 | Up: Map | Next: AA71 |
|
Used by the routines at PrintNewline, ProcessObject_Display, ProcessTextCommand, PrintCharacterAndReturnZero, PrintCharacterWithTimePeriod, PrintCharacterAndReturn, ExtractTokenFromText, PrintTextBasedOnFlag, ProcessLocationTokenDisplay, PrintFormattedObjectList, PrintObjectDescriptionText and E6BC.
|
||||||||
| Print_Character | A9B7 | PUSH AF | Stash the character code on the stack. | |||||
| A9B8 | LD A,($A027) | Jump to Print_Character_AlternateMode if *PrintModeFlag isn't set (not in direct print mode). | ||||||
| A9BB | AND A | |||||||
| A9BC | JR NZ,Print_Character_AlternateMode | |||||||
|
Handle direct print mode - write character to buffer.
|
||||||||
| A9BE | POP AF | Restore the character code from the stack. | ||||||
| A9BF | PUSH AF | Stash the character code and HL on the stack. | ||||||
| A9C0 | PUSH HL | |||||||
| A9C1 | LD HL,($A9B5) | HL=*BufferPointer (load the buffer pointer). | ||||||
| A9C4 | CP $20 | Jump to Print_Character_ScreenPrintMode if the character is a "SPACE" (ASCII 20). | ||||||
| A9C6 | JR Z,Print_Character_ScreenPrintMode | |||||||
| A9C8 | CP $0D | Jump to Print_Character_ScreenPrintMode if the character is an "ENTER" (ASCII 0D). | ||||||
| A9CA | JR Z,Print_Character_ScreenPrintMode | |||||||
| A9CC | CP $22 | Jump to Print_Character_ScreenPrintMode if the character is a quotation mark (ASCII 22). | ||||||
| A9CE | JR Z,Print_Character_ScreenPrintMode | |||||||
| A9D0 | CP $08 | Jump to Print_Character_WriteToBuffer if the character is not a backspace (ASCII 08). | ||||||
| A9D2 | JR NZ,Print_Character_WriteToBuffer | |||||||
|
The character IS a backspace, so handle this.
|
||||||||
| A9D4 | DEC HL | Decrease HL by one (move buffer pointer back for backspace). | ||||||
| A9D5 | JR Print_Character_UpdateBufferPointer | Jump to Print_Character_UpdateBufferPointer (skip writing the character). | ||||||
|
Write the character to the buffer.
|
||||||||
| Print_Character_WriteToBuffer | A9D7 | LD (HL),A | Write the character to the buffer. | |||||
| A9D8 | INC HL | Increment the buffer pointer by one. | ||||||
| Print_Character_UpdateBufferPointer | A9D9 | LD ($A9B5),HL | Write the buffer pointer back to *BufferPointer. | |||||
| A9DC | POP HL | Restore HL and the character code from the stack. | ||||||
| A9DD | POP AF | |||||||
| A9DE | RET | Return. | ||||||
|
Handle screen print mode - check if we need to scroll.
|
||||||||
| Print_Character_ScreenPrintMode | A9DF | PUSH DE | Stash DE on the stack. | |||||
| A9E0 | LD DE,$5C0B | Jump to Print_Character_ProcessChar if DEFADD is equal to HL. | ||||||
| A9E3 | AND A | |||||||
| A9E4 | SBC HL,DE | |||||||
| A9E6 | JR Z,Print_Character_ProcessChar | |||||||
|
Check if we need to scroll the screen.
|
||||||||
| A9E8 | LD A,($C1F5) | A=*ScreenWidth. | ||||||
| A9EB | CP L | Compare *ScreenWidth with L (the screen offset). | ||||||
| A9EC | PUSH AF | Stash the comparison result on the stack. | ||||||
| A9ED | 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). | ||||||
| A9EF | LD A,$0D | A=0D (load carriage return character). | ||||||
| A9F1 | CALL Print_Character_ProcessCharacter | Call Print_Character_ProcessCharacter to process the carriage return. | ||||||
|
Scroll the screen by clearing the first line.
|
||||||||
| Print_Character_ScrollScreen | A9F4 | PUSH BC | Stash BC on the stack. | |||||
| A9F5 | LD B,L | B=L (store the line width in B). | ||||||
| A9F6 | LD HL,$5C0B | HL=DEFADD (reset to the start of the screen buffer). | ||||||
| A9F9 | LD ($A9B5),HL | Write HL (the screen buffer pointer) to *BufferPointer. | ||||||
| Print_Character_ScrollLoop | A9FC | LD A,(HL) | Load a character from the screen buffer into A. | |||||
| A9FD | CALL Print_Character_ProcessCharacter | Call Print_Character_ProcessCharacter to process the character (shift it up). | ||||||
| AA00 | INC HL | Move to the next character. | ||||||
| AA01 | DJNZ Print_Character_ScrollLoop | Decrease counter by one and loop back to Print_Character_ScrollLoop until counter is zero. | ||||||
| AA03 | POP BC | Restore BC and AF from the stack. | ||||||
| AA04 | POP AF | |||||||
| AA05 | 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.
|
||||||||
| AA07 | XOR A | Reset *PrintPositionFlag. | ||||||
| AA08 | LD ($A025),A | |||||||
| Print_Character_ProcessChar | AA0B | POP DE | Restore DE, HL and the character code from the stack. | |||||
| AA0C | POP HL | |||||||
| AA0D | POP AF | |||||||
| AA0E | JR Print_Character_ProcessCharacter | Jump to Print_Character_ProcessCharacter to process the character. | ||||||
|
Use alternate print method (direct screen printing).
|
||||||||
| Print_Character_AlternateMode | AA10 | POP AF | Restore the character code from the stack. | |||||
| AA11 | JP CheckTVFlagAndProcess | Jump to CheckTVFlagAndProcess to print using alternate method. | ||||||
|
Convert uppercase letters to lowercase if needed.
|
||||||||
| Print_Character_ProcessCharacter | AA14 | CP $41 | Jump to Print_Character_CheckSpace if the character is not uppercase. | |||||
| AA16 | JR C,Print_Character_CheckSpace | |||||||
| AA18 | CP $5B | |||||||
| AA1A | JR NC,Print_Character_CheckSpace | |||||||
| AA1C | OR %00100000 | Set bit 5 (convert to lowercase). | ||||||
| Print_Character_CheckSpace | AA1E | PUSH AF | Stash the character code on the stack. | |||||
| AA1F | LD A,($A025) | 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). | ||||||
| AA22 | AND A | |||||||
| AA23 | JR NZ,Print_Character_MarkPrintStarted | |||||||
| AA25 | POP AF | Restore the character code from the stack. | ||||||
| AA26 | CP $20 | Return if the character is a "SPACE". | ||||||
| AA28 | RET Z | |||||||
| AA29 | PUSH AF | Stash the character code on the stack. | ||||||
|
Mark that we've started printing on this line.
|
||||||||
| Print_Character_MarkPrintStarted | AA2A | LD A,$01 | Set *PrintPositionFlag. | |||||
| AA2C | LD ($A025),A | |||||||
| AA2F | POP AF | Restore the character code from the stack. | ||||||
| AA30 | PUSH AF | Stash the character code on the stack. | ||||||
| AA31 | CP $0D | Jump to Print_Character_CheckQuote if the character is not a carriage return (compare with 0D jump if not equal). | ||||||
| AA33 | JR NZ,Print_Character_CheckQuote | |||||||
|
Reset the print position flag for a carriage return.
|
||||||||
| AA35 | XOR A | Clear *PrintPositionFlag. | ||||||
| AA36 | LD ($A025),A | |||||||
| AA39 | 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 | AA3B | CP $22 | Jump to Print_Character_CheckPeriod if the character is not a quote mark (compare with 22 jump if not equal). | |||||
| AA3D | JR NZ,Print_Character_CheckPeriod | |||||||
| AA3F | LD A,$20 | A=20 (replace quote with space). | ||||||
| AA41 | CALL CheckTVFlagAndProcess | Call CheckTVFlagAndProcess to print the space. | ||||||
| AA44 | 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 | AA46 | CP $2E | Jump to Print_Character_CheckLowercase if the character is not a period (compare with 2E jump if not equal). | |||||
| AA48 | JR NZ,Print_Character_CheckLowercase | |||||||
| Print_Character_SetTokenFormatFlag | AA4A | LD A,$01 | Set *TokenFormatFlag. | |||||
| AA4C | LD ($A026),A | |||||||
| AA4F | JR Print_Character_Print | Jump to Print_Character_Print (skip further processing). | ||||||
|
Handle lowercase letters (dictionary word characters).
|
||||||||
| Print_Character_CheckLowercase | AA51 | CP $61 | Jump to Print_Character_Print if the character is less than 61 (ASCII "a"). | |||||
| AA53 | JR C,Print_Character_Print | |||||||
| AA55 | CP $7B | Jump to Print_Character_Print if the character is greater than or equal to 7B (ASCII "z"+01). | ||||||
| AA57 | JR NC,Print_Character_Print | |||||||
| AA59 | LD A,($A851) | 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). | ||||||
| AA5C | AND A | |||||||
| AA5D | JR NZ,Print_Character_ResetTokenFormatFlag | |||||||
| AA5F | LD A,($A026) | Jump to Print_Character_Print if *TokenFormatFlag the token format flag is not set. | ||||||
| AA62 | AND A | |||||||
| AA63 | JR Z,Print_Character_Print | |||||||
|
Reset the token format flag before converting to uppercase.
|
||||||||
| Print_Character_ResetTokenFormatFlag | AA65 | XOR A | Reset *TokenFormatFlag. | |||||
| AA66 | LD ($A026),A | |||||||
| AA69 | POP AF | Restore the character code from the stack. | ||||||
|
Clear bit 5 from the character code (convert to uppercase).
|
||||||||
| AA6A | AND %01011111 | Keep only bits 0-4, 6 (clear bit 5 to convert lowercase to uppercase). | ||||||
| AA6C | PUSH AF | Stash the modified character code on the stack. | ||||||
| Print_Character_Print | AA6D | POP AF | Restore the character code from the stack. | |||||
| AA6E | JP CheckTVFlagAndProcess | Jump to CheckTVFlagAndProcess to print the character. | ||||||
| Prev: A9B5 | Up: Map | Next: AA71 |