better debugging

This commit is contained in:
2024-04-15 04:25:40 -07:00
parent cfe7b1b82c
commit 317603709e

View File

@@ -54,6 +54,7 @@ void GameBoy::start(const std::string& bootrom, const std::string& game) {
bool quit = false; bool quit = false;
bool setIME = false; bool setIME = false;
bool debug = false; bool debug = false;
bool step = false;
while (!quit) { while (!quit) {
// Event loop // Event loop
@@ -89,7 +90,10 @@ void GameBoy::start(const std::string& bootrom, const std::string& game) {
joypadInput.START = true; joypadInput.START = true;
break; break;
case SDLK_h: case SDLK_h:
debug = true; debug = !debug;
break;
case SDLK_n:
step = true;
break; break;
default: default:
break; break;
@@ -121,9 +125,6 @@ void GameBoy::start(const std::string& bootrom, const std::string& game) {
case SDLK_p: case SDLK_p:
joypadInput.START = false; joypadInput.START = false;
break; break;
case SDLK_h:
debug = false;
break;
default: default:
break; break;
} }
@@ -134,6 +135,9 @@ void GameBoy::start(const std::string& bootrom, const std::string& game) {
} }
while (!rendered) { while (!rendered) {
if (debug == true && step == false)
break;
step = false;
joypadHandler(); joypadHandler();
if (PC > 0xFF && addressSpace.getBootromState()) { if (PC > 0xFF && addressSpace.getBootromState()) {
addressSpace.unmapBootrom(); addressSpace.unmapBootrom();