| Routines

0E9B: THE 'CL-ADDR' SUBROUTINE

Used by the routines at PO_SCR, CL_SET, CL_SC_ALL and CL_LINE. For a given line number, in the B register, the appropriate display file address is formed in the HL register pair.
Input
B | Line number
Output
HL | Display file address
CL_ADDR | 0E9B | LD A,$18 | The line number has to be reversed.
| 0E9D | SUB B
| 0E9E | LD D,A | The result is saved in D.
| 0E9F | RRCA | In effect '(A mod 8)*32'. In a 'third' of the display the low byte for the first line is +00, for the second line +20, etc.
| 0EA0 | RRCA
| 0EA1 | RRCA
| 0EA2 | AND $E0
| 0EA4 | LD L,A | The low byte goes into L.
| 0EA5 | LD A,D | The true line number is fetched.
| 0EA6 | AND $18 | In effect '64+8*INT (A/8)'. For the upper 'third' of the display the high byte is +40, for the middle 'third' +48, and for the lower 'third' +50.
| 0EA8 | OR $40
| 0EAA | LD H,A | The high byte goes to H.
| 0EAB | RET | Finished.