mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Implement pause/resume
This commit is contained in:
parent
9ad34dd6c9
commit
1107dff9fa
2 changed files with 17 additions and 4 deletions
|
@ -59,7 +59,8 @@ class Emulator {
|
||||||
static constexpr u32 width = 400;
|
static constexpr u32 width = 400;
|
||||||
static constexpr u32 height = 240 * 2; // * 2 because 2 screens
|
static constexpr u32 height = 240 * 2; // * 2 because 2 screens
|
||||||
ROMType romType = ROMType::None;
|
ROMType romType = ROMType::None;
|
||||||
bool running = true;
|
bool running = false; // Is the emulator running a game?
|
||||||
|
bool programRunning = false; // Is the emulator program itself running?
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
||||||
HttpServer httpServer;
|
HttpServer httpServer;
|
||||||
|
@ -89,6 +90,9 @@ class Emulator {
|
||||||
void run();
|
void run();
|
||||||
void runFrame();
|
void runFrame();
|
||||||
|
|
||||||
|
void resume(); // Resume the emulator
|
||||||
|
void pause(); // Pause the emulator
|
||||||
|
|
||||||
bool loadROM(const std::filesystem::path& path);
|
bool loadROM(const std::filesystem::path& path);
|
||||||
bool loadNCSD(const std::filesystem::path& path, ROMType type);
|
bool loadNCSD(const std::filesystem::path& path, ROMType type);
|
||||||
bool loadELF(const std::filesystem::path& path);
|
bool loadELF(const std::filesystem::path& path);
|
||||||
|
|
|
@ -75,6 +75,8 @@ Emulator::Emulator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
running = false;
|
||||||
|
programRunning = false;
|
||||||
reset(ReloadOption::NoReload);
|
reset(ReloadOption::NoReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +116,9 @@ void Emulator::step() {}
|
||||||
void Emulator::render() {}
|
void Emulator::render() {}
|
||||||
|
|
||||||
void Emulator::run() {
|
void Emulator::run() {
|
||||||
while (running) {
|
programRunning = true;
|
||||||
|
|
||||||
|
while (programRunning) {
|
||||||
runFrame();
|
runFrame();
|
||||||
HIDService& hid = kernel.getServiceManager().getHID();
|
HIDService& hid = kernel.getServiceManager().getHID();
|
||||||
|
|
||||||
|
@ -125,7 +129,7 @@ void Emulator::run() {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
printf("Bye :(\n");
|
printf("Bye :(\n");
|
||||||
running = false;
|
programRunning = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
@ -344,8 +348,12 @@ void Emulator::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only resume if a ROM is properly loaded
|
||||||
|
void Emulator::resume() { running = (romType != ROMType::None); }
|
||||||
|
void Emulator::pause() { running = false; }
|
||||||
|
|
||||||
void Emulator::runFrame() {
|
void Emulator::runFrame() {
|
||||||
if (romType != ROMType::None) {
|
if (running) {
|
||||||
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
||||||
httpServer.processActions();
|
httpServer.processActions();
|
||||||
#endif
|
#endif
|
||||||
|
@ -408,6 +416,7 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
|
||||||
romType = ROMType::None;
|
romType = ROMType::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resume(); // Start the emulator
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue