Skip to content

Commit

Permalink
refresh SDL only when VRAM has changed, use default RGB masks on surf…
Browse files Browse the repository at this point in the history
…ace creation
  • Loading branch information
agentbooth committed Oct 2, 2020
1 parent 93ecf0b commit 6b79a25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b79a25

Please sign in to comment.