From 0484a8cf434243c9c6a2852de2cd0e532970f678 Mon Sep 17 00:00:00 2001 From: Eggbertx Date: Tue, 8 Oct 2024 10:15:14 -0700 Subject: [PATCH] Fix persistent pixels in SDL build --- make.py | 2 +- src/io_sdl.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/make.py b/make.py index 4ff6956..c42ca06 100755 --- a/make.py +++ b/make.py @@ -297,7 +297,7 @@ def clean(): help="Generate listing file", default="", metavar="PATH") - parser.add_argument("--debug-symbols", + parser.add_argument("-g", "--debug-symbols", help="Build OmniChip-8 with debugging symbols", default=False, action="store_true") diff --git a/src/io_sdl.c b/src/io_sdl.c index 06183e9..2ec865b 100755 --- a/src/io_sdl.c +++ b/src/io_sdl.c @@ -35,6 +35,7 @@ void delay(ushort milliseconds) { uchar getEvent(void) { SDL_Event e; + uchar preResetStatus; SDL_PumpEvents(); SDL_PollEvent(&e); switch(e.type) { @@ -47,7 +48,7 @@ uchar getEvent(void) { togglePause(); } else if(e.key.keysym.sym == SDLK_F2) { printf("Resetting\n"); - uchar preResetStatus = chip8.status; + preResetStatus = chip8.status; initChip8(); initScreen(); chip8.status = preResetStatus; @@ -100,7 +101,6 @@ uchar getKey(void) { schar isPressed(uchar key) { const uchar* state = SDL_GetKeyboardState(NULL); - /* printf("Key : %d\n", key); */ switch(key) { case 0x1: return state[SDL_SCANCODE_1]; @@ -154,20 +154,23 @@ void playSound(void) { } void playAudio(void* data, void* stream, int length) { - + } void drawPixel(uchar x, uchar y) { - /* printf("Drawing pixel at %d,%d\n", x, y); */ SDL_RenderDrawPoint(renderer, x, y); } void flipScreen(void) { SDL_RenderPresent(renderer); + clearScreen(); } void clearScreen(void) { - SDL_FillRect(surface, NULL, 0x000000); + SDL_SetRenderDrawColor(renderer, 0,0,0,0); + SDL_RenderClear(renderer); + SDL_SetRenderDrawColor(renderer, 255,255,255,255); + /* SDL_FillRect(surface, NULL, 0x000000); */ } void cleanup(void) {