![]() |
Routines |
| Prev: 36317 | Up: Map | Next: 36367 |
|
The default print handler for the state machine pointer at PrintState_Handler. Called on initialisation, and restored after each byte is consumed. Dispatches each byte of a messaging string to the appropriate action based on its value:
|
||||||||||||||||||||
| PrintHandler | 36323 | CP 128 | If the byte is less than 128 jump to PrintHandler_Dispatch. | |||||||||||||||||
| 36325 | JR C,PrintHandler_Dispatch | |||||||||||||||||||
| 36327 | LD A,33 | Otherwise replace the byte with 33 ("!"). | ||||||||||||||||||
| 36329 | JP PrintHandler_Render | Jump to PrintHandler_Render to render the character. | ||||||||||||||||||
|
Dispatch handler for printing.
|
||||||||||||||||||||
| PrintHandler_Dispatch | 36332 | CP 32 | If the byte is 32 or higher (printable ASCII), jump to PrintHandler_Render to render it. | |||||||||||||||||
| 36334 | JP NC,PrintHandler_Render | |||||||||||||||||||
| 36337 | CP 13 | If the byte is a carriage return (13), jump to PrintHandler_Newline. | ||||||||||||||||||
| 36339 | JR Z,PrintHandler_Newline | |||||||||||||||||||
| 36341 | CP 16 | If the byte is less than 16 jump to PrintHandler_Invalid (unsupported code). | ||||||||||||||||||
| 36343 | JR C,PrintHandler_Invalid | |||||||||||||||||||
| 36345 | CP 27 | If the byte is 27 or higher, jump to PrintHandler_Invalid (unsupported code). | ||||||||||||||||||
| 36347 | JR NC,PrintHandler_Invalid | |||||||||||||||||||
|
Look up the two-byte handler address from the control code dispatch table at ControlCode_DispatchTable. The code is zero-indexed from 16 and doubled since each table entry is two bytes wide.
|
||||||||||||||||||||
| 36349 | LD HL,36816 | HL=ControlCode_DispatchTable (base of the control code dispatch table). | ||||||||||||||||||
| 36352 | SUB 16 | Zero-index the control code from 16. | ||||||||||||||||||
| 36354 | LD D,0 | DE=zero-indexed control code. | ||||||||||||||||||
| 36356 | LD E,A | |||||||||||||||||||
| 36357 | ADD HL,DE | Double the index (two bytes per table entry). | ||||||||||||||||||
| 36358 | ADD HL,DE | |||||||||||||||||||
| 36359 | LD E,(HL) | Read the handler address from the dispatch table into DE. | ||||||||||||||||||
| 36360 | INC HL | |||||||||||||||||||
| 36361 | LD D,(HL) | |||||||||||||||||||
| 36362 | LD (32778),DE | Write the handler address to PrintState_Handler. | ||||||||||||||||||
| 36366 | RET | Return. | ||||||||||||||||||
| Prev: 36317 | Up: Map | Next: 36367 |