1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#include "../desktop-ui.hpp"
#include "platform.cpp"
#include "load.cpp"
#include "states.cpp"
#include "rewind.cpp"
#include "status.cpp"
#include "utility.cpp"
#include "drivers.cpp"
Program program;
auto Program::create() -> void {
ares::platform = this;
videoDriverUpdate();
audioDriverUpdate();
inputDriverUpdate();
driverSettings.videoRefresh();
driverSettings.audioRefresh();
driverSettings.inputRefresh();
if(startGameLoad) {
if(auto emulator = identify(startGameLoad)) {
if(load(emulator, startGameLoad)) {
if(startFullScreen) videoFullScreenToggle();
}
}
}
}
auto Program::main() -> void {
if(Application::modal()) {
ruby::audio.clear();
return;
}
updateMessage();
inputManager.poll();
inputManager.pollHotkeys();
bool defocused = driverSettings.inputDefocusPause.checked() && !ruby::video.fullScreen() && !presentation.focused();
if(emulator && defocused) message.text = "Paused";
if(!emulator || paused || defocused) {
ruby::audio.clear();
usleep(20 * 1000);
return;
}
rewindRun();
if(!runAhead || fastForwarding || rewinding) {
emulator->root->run();
} else {
ares::setRunAhead(true);
emulator->root->run();
auto state = emulator->root->serialize(false);
ares::setRunAhead(false);
emulator->root->run();
state.setReading();
emulator->root->unserialize(state);
}
if(settings.general.autoSaveMemory) {
static u64 previousTime = chrono::timestamp();
u64 currentTime = chrono::timestamp();
if(currentTime - previousTime >= 30) {
previousTime = currentTime;
emulator->save();
}
}
//if Platform::video() changed the screen resolution, resize the presentation window here.
//window operations must be performed from the main thread.
if(emulator->latch.changed) {
emulator->latch.changed = false;
if(settings.video.adaptiveSizing) presentation.resizeWindow();
}
memoryEditor.liveRefresh();
graphicsViewer.liveRefresh();
propertiesViewer.liveRefresh();
}
auto Program::quit() -> void {
unload();
presentation.setVisible(false); //makes quitting the emulator feel more responsive
Application::processEvents();
Application::quit();
ruby::video.reset();
ruby::audio.reset();
ruby::input.reset();
}
|