Power Cycle: Fixed a couple of bugs, moved logic to core

This commit is contained in:
Souryo 2017-05-02 23:31:06 -04:00
parent f5806ed5bb
commit c4ef93ccbb
5 changed files with 16 additions and 1 deletions

View file

@ -31,6 +31,7 @@ Console::Console()
{
_resetRequested = false;
_lagCounter = 0;
_archiveFileIndex = -1;
}
Console::~Console()
@ -63,6 +64,8 @@ bool Console::Initialize(string romFilename, stringstream *filestream, string pa
if(mapper) {
_romFilepath = romFilename;
_patchFilename = patchFilename;
_archiveFileIndex = archiveFileIndex;
_autoSaveManager.reset(new AutoSaveManager());
VideoDecoder::GetInstance()->StopThread();
@ -219,6 +222,13 @@ NesModel Console::GetModel()
return Instance->_model;
}
void Console::PowerCycle()
{
if(Instance->_initialized && !Instance->_romFilepath.empty()) {
LoadROM(Instance->_romFilepath, nullptr, Instance->_archiveFileIndex, Instance->_patchFilename);
}
}
void Console::Reset(bool softReset)
{
if(Instance->_initialized) {

View file

@ -39,6 +39,8 @@ class Console
NesModel _model;
string _romFilepath;
string _patchFilename;
int32_t _archiveFileIndex;
bool _stop = false;
@ -61,6 +63,7 @@ class Console
void Stop();
static void RequestReset();
static void Reset(bool softReset = true);
static void PowerCycle();
//Used to pause the emu loop to perform thread-safe operations
static void Pause();

View file

@ -917,7 +917,7 @@ namespace Mesen.GUI.Forms
private void mnuPowerCycle_Click(object sender, EventArgs e)
{
LoadROM(_currentRomPath, ConfigManager.Config.PreferenceInfo.AutoLoadIpsPatches, _currentRomArchiveIndex);
InteropEmu.PowerCycle();
}
private void mnuShowFPS_Click(object sender, EventArgs e)

View file

@ -62,6 +62,7 @@ namespace Mesen.GUI
[DllImport(DLLPath, EntryPoint = "GetRomInfo")] private static extern UInt32 GetRomInfoWrapper(ref InteropRomInfo romInfo, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename = "", Int32 archiveFileIndex = -1);
[DllImport(DLLPath)] public static extern void PowerCycle();
[DllImport(DLLPath)] public static extern void Reset();
[DllImport(DLLPath)] public static extern void ResetLagCounter();

View file

@ -204,6 +204,7 @@ namespace InteropEmu {
}
DllExport void __stdcall Reset() { Console::Reset(); }
DllExport void __stdcall PowerCycle() { Console::PowerCycle(); }
DllExport void __stdcall ResetLagCounter() { Console::ResetLagCounter(); }
DllExport void __stdcall StartServer(uint16_t port, char* hostPlayerName) { GameServer::StartServer(port, hostPlayerName); }