Merge pull request #58 from AlchemicRaker/feature/whilePaused-event-for-scripts

feature/whilePaused event for scripts
This commit is contained in:
NovaSquirrel 2021-11-09 20:31:28 -05:00 committed by GitHub
commit 6bf04088ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 0 deletions

View file

@ -1003,8 +1003,16 @@ bool Debugger::SleepUntilResume(BreakSource source, uint32_t breakpointId, Break
_executionStopped = true; _executionStopped = true;
_pausedForDebugHelper = breakRequested; _pausedForDebugHelper = breakRequested;
int whilePausedRunCounter = 0;
while((((stepCount == 0 || _breakRequested) && _suspendCount == 0) || _preventResume > 0) && !_stopFlag) { while((((stepCount == 0 || _breakRequested) && _suspendCount == 0) || _preventResume > 0) && !_stopFlag) {
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(10)); std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(10));
if (preventResume == 0) {
whilePausedRunCounter++;
if (whilePausedRunCounter > 10) {
ProcessEvent(EventType::WhilePaused);
whilePausedRunCounter = 0;
}
}
if(stepCount == 0) { if(stepCount == 0) {
_console->ResetRunTimers(); _console->ResetRunTimers();
} }

View file

@ -203,6 +203,7 @@ enum class EventType
SpriteZeroHit = 9, SpriteZeroHit = 9,
ScriptEnded = 10, ScriptEnded = 10,
BusConflict = 11, BusConflict = 11,
WhilePaused = 12,
EventTypeSize EventTypeSize
}; };

View file

@ -168,6 +168,7 @@ int LuaApi::GetLibrary(lua_State *lua)
lua_pushintvalue(stateSaved, EventType::StateSaved); lua_pushintvalue(stateSaved, EventType::StateSaved);
lua_pushintvalue(inputPolled, EventType::InputPolled); lua_pushintvalue(inputPolled, EventType::InputPolled);
lua_pushintvalue(scriptEnded, EventType::ScriptEnded); lua_pushintvalue(scriptEnded, EventType::ScriptEnded);
lua_pushintvalue(whilePaused, EventType::WhilePaused);
lua_settable(lua, -3); lua_settable(lua, -3);
lua_pushliteral(lua, "executeCountType"); lua_pushliteral(lua, "executeCountType");

View file

@ -578,6 +578,7 @@ namespace Mesen.GUI.Debugger
new List<string> {"enum","emu.eventType.inputPolled","Triggered when the emulation core polls the state of the input devices for the next frame","","",""}, new List<string> {"enum","emu.eventType.inputPolled","Triggered when the emulation core polls the state of the input devices for the next frame","","",""},
new List<string> {"enum","emu.eventType.spriteZeroHit","Triggered when the PPU sets the sprite zero hit flag","","",""}, new List<string> {"enum","emu.eventType.spriteZeroHit","Triggered when the PPU sets the sprite zero hit flag","","",""},
new List<string> {"enum","emu.eventType.scriptEnded","Triggered when the current Lua script ends (script window closed, execution stopped, etc.)","","",""}, new List<string> {"enum","emu.eventType.scriptEnded","Triggered when the current Lua script ends (script window closed, execution stopped, etc.)","","",""},
new List<string> {"enum","emu.eventType.whilePaused","Triggered repeatedly while execution is paused","","",""},
new List<string> {"enum","emu.executeCountType","emu.executeCountType.[value]","","","Values:\ncpuCycles = 0,\nppuCycles = 1,\ncpuInstructions = 2\n\nUsed by execute calls." }, new List<string> {"enum","emu.executeCountType","emu.executeCountType.[value]","","","Values:\ncpuCycles = 0,\nppuCycles = 1,\ncpuInstructions = 2\n\nUsed by execute calls." },
new List<string> {"enum","emu.executeCountType.cpuCycles","Count the number of CPU cycles","","",""}, new List<string> {"enum","emu.executeCountType.cpuCycles","Count the number of CPU cycles","","",""},
new List<string> {"enum","emu.executeCountType.ppuCycles","Count the number of PPU cycles","","",""}, new List<string> {"enum","emu.executeCountType.ppuCycles","Count the number of PPU cycles","","",""},