Skip to content

Commit 670529b

Browse files
authoredJun 30, 2022
Merge pull request #6 from Klairm/chip8_ps4_dev
fix[draw function]: renderer not being correctly updated
2 parents 2414ac8 + 783c46c commit 670529b

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed
 

‎chip8/chip8.cpp

+11-20
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ int main(int argc, char **argv)
4242
setvbuf(stdout, NULL, _IONBF, 0);
4343

4444
scene = new Scene2D(FRAME_WIDTH, FRAME_HEIGHT, FRAME_DEPTH);
45-
auto controller = new Controller();
46-
auto sceKeyboard = new Keyboard();
4745
if (!scene->Init(0xC000000, 2))
4846
{
4947
DEBUGLOG << "[ERROR] Can't init scene2D!!";
5048
}
51-
49+
auto sceKeyboard = new Keyboard();
5250
if (!sceKeyboard->Init(-1))
5351
{
52+
5453
DEBUGLOG << "[ERROR] Can't init SceKeyboard!!";
5554
}
5655

56+
auto controller = new Controller();
5757
if (!controller->Init(-1))
5858
{
5959
DEBUGLOG << "[ERROR] Can't init the controller!!";
@@ -114,7 +114,7 @@ int main(int argc, char **argv)
114114

115115
sceVideoOutClose(scene->videoID());
116116
free(scene);
117-
117+
free(controller);
118118
quitMain = 1;
119119
}
120120
listFiles();
@@ -130,10 +130,10 @@ int main(int argc, char **argv)
130130
notifi(NULL, "%s", SDL_GetError());
131131
return 1;
132132
}
133-
int32_t speed = 7;
134133

135134
uint8_t keys[32];
136135
memset(keys, 0, 32);
136+
137137
while (!quit)
138138
{
139139

@@ -223,16 +223,7 @@ int main(int argc, char **argv)
223223
case 'V':
224224
press ? keyboard[0xF] = 1 : keyboard[0xF] = 0;
225225
break;
226-
case 'M':
227-
case 'm':
228-
speed--;
229-
notifi(NULL, "Speed: %d", speed);
230-
break;
231-
case 'L':
232-
case 'l':
233-
speed++;
234-
notifi(NULL, "Speed: %d", speed);
235-
break;
226+
236227
case 'K':
237228
case 'k':
238229
initChip8();
@@ -241,6 +232,8 @@ int main(int argc, char **argv)
241232
CleanUp_SDL();
242233
return 0;
243234
}
235+
break;
236+
244237
default:
245238
break;
246239
}
@@ -253,7 +246,6 @@ int main(int argc, char **argv)
253246
{
254247
--delay_timer;
255248
}
256-
257249
execute();
258250
draw();
259251
}
@@ -407,8 +399,7 @@ uint32_t loadRom(char *file)
407399
// Draw function
408400
void draw()
409401
{
410-
void *pixels;
411-
int pitch;
402+
412403
SDL_Rect r;
413404
int x, y;
414405
r.x = 0;
@@ -432,10 +423,10 @@ void draw()
432423
SDL_RenderFillRect(renderer, &r);
433424
}
434425
}
435-
SDL_RenderPresent(renderer);
436426
}
437-
drawflag = false;
427+
SDL_RenderPresent(renderer);
438428
}
429+
drawflag = false;
439430
}
440431

441432
// Emulate cycle

0 commit comments

Comments
 (0)