diff --git a/src/main.c b/src/main.c index 046f0d2..8d69378 100644 --- a/src/main.c +++ b/src/main.c @@ -295,11 +295,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Error creating SDL texture: %s.\n", SDL_GetError()); exit(EXIT_FAILURE); } - SDL_Surface *screen = SDL_CreateRGBSurface(0, 720, 348, 32, - 0x00FF0000, - 0x0000FF00, - 0x000000FF, - 0); + SDL_Surface *screen = SDL_CreateRGBSurface(0, 720, 348, 32, 0, 0, 0, 0); if (!screen){ fprintf(stderr, "Error creating SDL surface: %s.\n", SDL_GetError()); exit(EXIT_FAILURE); @@ -442,8 +438,11 @@ int main(int argc, char *argv[]) } // Is it time to run the 60Hz periodic interrupt yet? if (clock_cycles > CLOCKS_PER_60HZ) { - // Refresh the screen - refreshScreen(screen, renderer, texture); + // Refresh the screen if VRAM has been changed + if (state.vram_updated){ + refreshScreen(screen, renderer, texture); + state.vram_updated = false; + } if (state.timer_enabled){ m68k_set_irq(6); state.timer_asserted = true; diff --git a/src/memory.c b/src/memory.c index 3e62dca..7700947 100644 --- a/src/memory.c +++ b/src/memory.c @@ -890,6 +890,7 @@ uint32_t m68k_read_memory_16(uint32_t address)/*{{{*/ case 0x020000: // Video RAM if (address > 0x427FFF) fprintf(stderr, "NOTE: RD16 from VideoRAM mirror, addr=0x%08X\n", address); data = RD16(state.vram, address, 0x7FFF); + state.vram_updated = true; break; default: data = IoRead(address, 16); diff --git a/src/state.h b/src/state.h index f5b195d..74eb75e 100644 --- a/src/state.h +++ b/src/state.h @@ -104,6 +104,9 @@ typedef struct { /// VIDPAL mod (allows user writing to VRAM) bool vidpal; + + /// Update screen only when VRAM has been changed + bool vram_updated; } S_state; // Global emulator state. Yes, I know global variables are evil, please don't