I'm currently programming a NES emulator using SDL 1.2 for video and keyboard I/O. I've looked online and attempted a solution to my problem, but my program just locks up no matter what I do. I'm trying to set my program up so that I can hit the p key and toggle stepping mode. While in stepping mode, my emulator will execute one CPU instruction and then print out debug information. It will then wait until I press the spacebar. Once spacebar has been hit, another instruction will execute and the new debug information will be printed.
I'm just trying to toggle a bool for the step mode and another bool for the spacebar. For some reason this code enters the loop without me ever hitting p, and then it just locks the program up. I have to kill -9 the process to end the process. What should I be doing differently?
Just in case you didn't know, SDL2 has hardware acceleration, SDL 1.2 doesn't.
Also, I'd use SDL_Event structure instead of keystates. You can see more SDL tutorials on lazyfoo's site(he uses SDL 1.2, but it's really similar with SDL 2.0).
I wanted to use SDL 2.0, but there was only 1.2 on the repo for Linux Mint 14, so I ended up using that. I'll look into using events instead of keystates. Thanks!