So how does ap2000 process control characters like ESC?
I was watching the memory around $9800 and sending ESC M and ESC P would change the memory location $980a.
Typing trackmem enabled memory tracking and the relevant PC for $980a was $1510.
Setting a breakpoint on 1510 and then running history gave me enough info to figure out what was happening.
First it checks $C002. If the high bit is set, then there's data latched in $C003. So read that data and acknowledge by writing to $C004. You're looking at a history so it's in reverse chronological order (sequence goes from the bottom up).
Then we look at the byte, we check if it's less than 32 (nonprinting control characters) with LTI A,$20.
Eventually subtracting 7 and then shifting left (multiplying by 2), we get the offset into a jump table at $13DA.
SUINB A,$07 subract immediate value 7 and skip next if NB no borrow (result is greater than or equal to 0)
RET (skip this)
SLL A multiply by 2 with a shift left
LXI HL, $13DA put 13DA into HL
ADD L,A so now add A to L
ACI H,$00 add immediate with carry to H
LDEAX (HL) load EA indirect with the memory address pointed to by HL
JEA jump to value in EA
We have our table at 13DA:
and at address $1402 ($13DA + ($1b - 7) * 2) is the pointer to the routine for processing ESC, $13A3.
It's interesting to see in the table that with control characters that are ignored, like $1C, the jump address is $14b6 (shows up in the table as B6 14 because low byte is first) which points to just a single RET instruction.
No comments:
Post a Comment