diff --git a/source/frontends/sdl/imgui/sdlsettings.cpp b/source/frontends/sdl/imgui/sdlsettings.cpp index 7aa17f69..610ca953 100644 --- a/source/frontends/sdl/imgui/sdlsettings.cpp +++ b/source/frontends/sdl/imgui/sdlsettings.cpp @@ -229,21 +229,21 @@ namespace sa2 if (ImGui::Button("Step")) { - g_nAppMode = MODE_STEPPING; + frame->ChangeMode(MODE_STEPPING); frame->Execute(myStepCycles); } ImGui::SameLine(); ImGui::PushItemWidth(150); - ImGui::DragInt("cycles", &myStepCycles, 0.2f, 0, 32, "%d"); + ImGui::DragInt("cycles", &myStepCycles, 0.2f, 0, 256, "%d"); ImGui::PopItemWidth(); if ((ImGui::SameLine(), ImGui::Button("Run"))) { - g_nAppMode = MODE_RUNNING; + frame->ChangeMode(MODE_RUNNING); } if ((ImGui::SameLine(), ImGui::Button("Pause"))) { - g_nAppMode = MODE_PAUSED; + frame->ChangeMode(MODE_PAUSED); } ImGui::SameLine(); ImGui::Text("%016llu - %04X", g_nCumulativeCycles, regs.pc); diff --git a/source/frontends/sdl/sdlframe.cpp b/source/frontends/sdl/sdlframe.cpp index 0bffcfee..7fd21c46 100644 --- a/source/frontends/sdl/sdlframe.cpp +++ b/source/frontends/sdl/sdlframe.cpp @@ -332,20 +332,8 @@ namespace sa2 } case SDLK_PAUSE: { - switch (g_nAppMode) - { - case MODE_RUNNING: - g_nAppMode = MODE_PAUSED; - SoundCore_SetFade(FADE_OUT); - break; - case MODE_PAUSED: - case MODE_DEBUG: - g_nAppMode = MODE_RUNNING; - SoundCore_SetFade(FADE_IN); - mySpeed.reset(); - break; - } - GetFrame().FrameRefreshStatus(DRAW_TITLE); + const AppMode_e newMode = (g_nAppMode == MODE_RUNNING) ? MODE_PAUSED : MODE_RUNNING; + ChangeMode(newMode); break; } case SDLK_CAPSLOCK: @@ -431,4 +419,23 @@ namespace sa2 // else do nothing, it is either paused, debugged or stepped } + void SDLFrame::ChangeMode(const AppMode_e mode) + { + if (mode != g_nAppMode) + { + g_nAppMode = mode; + switch (g_nAppMode) + { + case MODE_RUNNING: + SoundCore_SetFade(FADE_IN); + mySpeed.reset(); + break; + default: + SoundCore_SetFade(FADE_OUT); + break; + } + FrameRefreshStatus(DRAW_TITLE); + } + } + } diff --git a/source/frontends/sdl/sdlframe.h b/source/frontends/sdl/sdlframe.h index a455af5a..211c8a8a 100644 --- a/source/frontends/sdl/sdlframe.h +++ b/source/frontends/sdl/sdlframe.h @@ -1,5 +1,6 @@ #pragma once +#include "Common.h" #include "frontends/common2/commonframe.h" #include "frontends/common2/speed.h" #include @@ -26,6 +27,7 @@ namespace sa2 void Execute(const DWORD uCycles); void ExecuteOneFrame(const size_t msNextFrame); + void ChangeMode(const AppMode_e mode); virtual void UpdateTexture() = 0; virtual void RenderPresent() = 0;