Skip to content

Commit

Permalink
Fix persistent pixels in SDL build
Browse files Browse the repository at this point in the history
  • Loading branch information
Eggbertx committed Oct 8, 2024
1 parent 94d5ae5 commit 0484a8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion make.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 8 additions & 5 deletions src/io_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void delay(ushort milliseconds) {

uchar getEvent(void) {
SDL_Event e;
uchar preResetStatus;
SDL_PumpEvents();
SDL_PollEvent(&e);
switch(e.type) {
Expand All @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0484a8c

Please sign in to comment.