/* * sleep — block for N seconds using the 50 Hz frame interrupt. * * Sprinter ISR fires 50 times per second. `halt` parks the CPU until * the next IRQ, so 50 halts = ~1 second of wall clock. This is the * same trick solid-c uses in IO.ASM:285. * * Note: requires interrupts to be enabled (they are by default — ESTEX * sets up IM 1 with the frame ISR before our program runs). */ #include void sleep(unsigned int seconds) __naked { (void)seconds; __asm inter: ;; HL = seconds on entry (SDCC single int arg). ld a, h or a, l ret Z ; sleep(0) — return immediately ld b, #50 ; 50 halts per second (50 Hz interrupt) inner: halt djnz inner dec hl jr inter __endasm; }