Factor common code to change AppMode.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
5230a6a558
commit
32c200d65c
3 changed files with 27 additions and 18 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "Common.h"
|
||||
#include "frontends/common2/commonframe.h"
|
||||
#include "frontends/common2/speed.h"
|
||||
#include <SDL.h>
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue