/* * getchar via ESTEX RST 10h. * * ESTEX 0x30 (WAITKEY): blocks until a key, returns * A = scan code, D = position code, E = ASCII, * C = mode flags, B = shift flags. * * IX is preserved (RST 10h clobbers it; callers rely on it as frame pointer). */ #include int getchar(void) __naked { __asm push ix ld c, #0x30 ; ESTEX WAITKEY rst #0x10 pop ix ld a, e ; E = ASCII (already the low byte of our return DE) or a, a jr Z, no_ascii ld d, #0 ret no_ascii: ld de, #-1 ret __endasm; }