From a09d89ae908009fa3fc4673ef2f1890308d83e5b Mon Sep 17 00:00:00 2001 From: giomba Date: Mon, 16 Oct 2023 22:14:25 +0200 Subject: [PATCH] Update Makefile and main with new stuff. --- Makefile | 1 + src/main.c | 61 ++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index f8b9b3d..8efd8a0 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ SERIALPORT = /dev/ttyUSB0 SRC = \ src/ceda_print_a.asm \ src/ceda_print_c.c \ + src/crt.c \ src/cursor.c \ src/delay.asm \ src/main.c \ diff --git a/src/main.c b/src/main.c index b703a4e..b20f2b1 100644 --- a/src/main.c +++ b/src/main.c @@ -1,30 +1,69 @@ #include "ceda_print.h" +#include "crt.h" #include "cursor.h" #include "delay.h" #include "io.h" +static void wait(void) { + (void)io_in(0xA0); + + for (;;) { + const uint8_t port_c = io_in(0x82); + if (port_c & 0x2) + break; + } +} + int main(void) { ceda_print("Hello world!"); - // ceda_cls(); + ceda_cls(); +#if 0 + for (int i = 0; i < 80; ++i) { + cursor_setXY(i, 0); + + // TODO(giomba): add vsync? + delay_loop(US_TO_LOOPS(10000ULL)); + } +#endif + + int counter = 0; + __asm__("di"); + +#if 0 for (;;) { - for (int i = 0; i < 80; ++i) { - cursor_setXY(i, 0); + for (int i = 0; i < 50; ++i) + crt_waitNextFrame(); - // TODO(giomba): add vsync? - delay_loop(US_TO_LOOPS(200000ULL)); + // wait(); + counter++; + + int scratch = counter; + uint8_t digits[4]; + digits[3] = scratch % 10; + scratch /= 10; + digits[2] = scratch % 10; + scratch /= 10; + digits[1] = scratch % 10; + scratch /= 10; + digits[0] = scratch % 10; + + for (int i = 0; i < 4; ++i) { + digits[i] += '0'; + *((char *)(0xd000 + i)) = digits[i]; } } +#endif - cursor_setStartRaster(5); - cursor_setEndRaster(10); + cursor_setXY(39, 10); for (;;) { - for (int i = 0; i < (16 - 1); ++i) { - cursor_setStartRaster(i); - cursor_setEndRaster(i + 1); - delay_loop(US_TO_LOOPS(200000UL)); + for (int i = 0; i < 16; ++i) { + cursor_setStartRaster(0); + cursor_setEndRaster(i); + for (int j = 0; j < 8; ++j) + crt_waitNextFrame(); } }