| Routines

03082: THE 'MESSAGE PRINTING' SUBROUTINE

Used by the routines at SAVE_ETC, SA_CONTRL, PO_SCR, NEW and MAIN_EXEC. This subroutine is used to print messages and tokens.
Input
A | Message table entry number
DE | Message table address (CASSETTE, BLOCK_HDR-1, SCROLL, REPORTS, COMMA_SPC-1 or COPYRIGHT-1)
PO_MSG | 03082 | PUSH HL | The high byte of the last entry on the machine stack is made zero so as to suppress trailing spaces (see below).
| 03083 | LD H,0
| 03085 | EX (SP),HL
| 03086 | JR PO_TABLE | Jump forward.
This entry point is used by the routine at PO_ANY. Enter here when expanding token codes.
PO_TOKENS | 03088 | LD DE,149 | The base address of the token table.
| 03091 | PUSH AF | Save the code on the stack. (Range 0 to 90, RND to COPY).
The table is searched and the correct entry printed.
PO_TABLE | 03092 | CALL PO_SEARCH | Locate the required entry.
| 03095 | JR C,PO_EACH | Print the message/token.
| 03097 | LD A," " | A 'space' will be printed before the message/token if required (bit 0 of FLAGS reset).
| 03099 | BIT 0,(IY+1)
| 03103 | CALL Z,PO_SAVE
The characters of the message/token are printed in turn.
PO_EACH | 03106 | LD A,(DE) | Collect a code.
| 03107 | AND 127 | Cancel any 'inverted bit'.
| 03109 | CALL PO_SAVE | Print the character.
| 03112 | LD A,(DE) | Collect the code again.
| 03113 | INC DE | Advance the pointer.
| 03114 | ADD A,A | The 'inverted bit' goes to the carry flag and signals the end of the message/token; otherwise jump back.
| 03115 | JR NC,PO_EACH
Now consider whether a 'trailing space' is required.
| 03117 | POP DE | For messages, D holds 0; for tokens, D holds 0 to 90.
| 03118 | CP 72 | Jump forward if the last character was a '$'.
| 03120 | JR Z,PO_TR_SP
| 03122 | CP 130 | Return if the last character was any other before 'A'.
| 03124 | RET C
PO_TR_SP | 03125 | LD A,D | Examine the value in D and return if it indicates a message, RND, INKEY$ or PI.
| 03126 | CP 3
| 03128 | RET C
| 03129 | LD A," " | All other cases will require a 'trailing space'.
This routine continues into PO_SAVE.