From 051b9a46b870fbf8ba2c53bcc0bece34803919b3 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sun, 26 Feb 2023 11:07:29 -0800 Subject: [PATCH] We have a character on the screen! It looks like potato because no alpha blending yet, but it's certainly there! I don't like the spelling of the C code, but who cares? It works. --- implementations/uvm-ncc/xerblin.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/implementations/uvm-ncc/xerblin.c b/implementations/uvm-ncc/xerblin.c index afb42ce..89acf81 100644 --- a/implementations/uvm-ncc/xerblin.c +++ b/implementations/uvm-ncc/xerblin.c @@ -13,13 +13,15 @@ int wid; void -draw_char(u8 ch, u64 x, u64 y) +draw_char(u8 ch, u64 dest_x, u64 dest_y) { - u32* pix_ptr = frame_buffer + FRAME_WIDTH * y + x; + u32* dest = frame_buffer + FRAME_WIDTH * dest_y + dest_x; u32* character_data = font_data[ch]; for (size_t x = 0; x < font_width; ++x) { for (size_t y = 0; y < font_height; ++y) { - *pix_ptr = *character_data; + u32 pixel = character_data[x + font_width * y]; + u32* pix_ptr = dest + x + FRAME_WIDTH * y; + *pix_ptr = pixel; } } } @@ -68,6 +70,7 @@ main() wid = window_create(FRAME_WIDTH, FRAME_HEIGHT, "Bouncing Ball Example", 0); draw_background(); draw_char(0, 0, 0); + window_draw_frame(wid, frame_buffer); //window_on_keydown(wid, keydown); window_on_mousemove(wid, mousemove); enable_event_loop();