diff --git a/ubb-vga/ubb-vga.c b/ubb-vga/ubb-vga.c index 882e5b8..e0f0483 100644 --- a/ubb-vga/ubb-vga.c +++ b/ubb-vga/ubb-vga.c @@ -244,11 +244,17 @@ static void cleanup(void) static void delay(uint16_t cycles) { static uint16_t next = 0; + uint16_t t; next += cycles; TDHR(TIMER) = next; TFCR = 1 << (TIMER+16); while (!(TFR & (1 << (TIMER+16)))); + t = next+24-TCNT(TIMER); + t >>= 1; + while (t--) + asm(""); + }