From 2fc29f20a343504780125aa2bed048cece79a37b Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 4 May 2023 12:44:03 +0100 Subject: Update the full fb once to sync with RAM This is after loading the programm. --- tr8vm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tr8vm.c b/tr8vm.c index 941e207..d4adb67 100644 --- a/tr8vm.c +++ b/tr8vm.c @@ -94,6 +94,12 @@ static uint32_t palette[] = uint8_t ram[UINT16_MAX + 1] = { 0 }; uint32_t *fb_data = NULL; +static void update_fb() +{ + for (uint16_t addr = 0; addr < 16384; addr++) + fb_data[addr] = palette[ram[VIDEO_RAM + addr] & 15]; +} + void write_m(uint16_t addr, uint8_t b) { if (addr >= VIDEO_RAM && addr < (VIDEO_RAM + 16384)) @@ -186,6 +192,13 @@ int main(int argc, char *argv[]) int pitch = 0; uint8_t rc; + /* update full fb once to sync with RAM */ + pitch = 0; + fb_data = NULL; + SDL_LockTexture(fb, NULL, (void **)&fb_data, &pitch); + update_fb(); + SDL_UnlockTexture(fb); + SDL_Event ev; while (1) { -- cgit v1.2.3