/*
 * 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 <stdio.h>

int getchar(void) __naked
{
    __asm
        push  ix
        ld    c, #0x30        ; ESTEX WAITKEY
        rst   #0x10
        pop   ix
        ld    d, #0
        ret
    __endasm;
}
