Fixed crash when loading VS-DualSystem games that are marked as having no work ram

This commit is contained in:
Sour 2020-04-27 20:47:28 -04:00
parent 55199beda7
commit 829c51957e
6 changed files with 22 additions and 5 deletions

View file

@ -438,7 +438,9 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile, bool forP
} }
//Used by netplay to take save state after UpdateInputState() is called above, to ensure client+server are in sync //Used by netplay to take save state after UpdateInputState() is called above, to ensure client+server are in sync
_notificationManager->SendNotification(ConsoleNotificationType::GameInitCompleted); if(!_master) {
_notificationManager->SendNotification(ConsoleNotificationType::GameInitCompleted);
}
Resume(); Resume();
return true; return true;
@ -627,7 +629,9 @@ void Console::ResetComponents(bool softReset)
_resetRunTimers = true; _resetRunTimers = true;
//This notification MUST be sent before the UpdateInputState() below to allow MovieRecorder to grab the first frame's worth of inputs //This notification MUST be sent before the UpdateInputState() below to allow MovieRecorder to grab the first frame's worth of inputs
_notificationManager->SendNotification(softReset ? ConsoleNotificationType::GameReset : ConsoleNotificationType::GameLoaded); if(!_master) {
_notificationManager->SendNotification(softReset ? ConsoleNotificationType::GameReset : ConsoleNotificationType::GameLoaded);
}
if(softReset) { if(softReset) {
shared_ptr<Debugger> debugger = _debugger; shared_ptr<Debugger> debugger = _debugger;

View file

@ -24,10 +24,16 @@ void VsControlManager::Reset(bool softReset)
_vsSystemType = _console->GetRomInfo().VsType; _vsSystemType = _console->GetRomInfo().VsType;
if(!softReset && !_console->IsMaster() && _console->GetDualConsole()) { if(!softReset && !_console->IsMaster() && _console->GetDualConsole()) {
UnregisterInputProvider(this);
RegisterInputProvider(this); RegisterInputProvider(this);
} }
} }
VsControlManager::~VsControlManager()
{
UnregisterInputProvider(this);
}
void VsControlManager::StreamState(bool saving) void VsControlManager::StreamState(bool saving)
{ {
ControlManager::StreamState(saving); ControlManager::StreamState(saving);

View file

@ -52,6 +52,7 @@ protected:
public: public:
using ControlManager::ControlManager; using ControlManager::ControlManager;
~VsControlManager();
void StreamState(bool saving) override; void StreamState(bool saving) override;
void Reset(bool softReset) override; void Reset(bool softReset) override;

View file

@ -99,9 +99,14 @@ public:
VsSystem* otherMapper = dynamic_cast<VsSystem*>(dualConsole->GetMapper()); VsSystem* otherMapper = dynamic_cast<VsSystem*>(dualConsole->GetMapper());
//Give memory access to master CPU or slave CPU, based on "slaveMasterBit" //Give memory access to master CPU or slave CPU, based on "slaveMasterBit"
if(_saveRamSize == 0 && _workRamSize == 0) {
RemoveCpuMemoryMapping(0x6000, 0x7FFF);
otherMapper->RemoveCpuMemoryMapping(0x6000, 0x7FFF);
}
for(int i = 0; i < 4; i++) { for(int i = 0; i < 4; i++) {
SetCpuMemoryMapping(0x6000 + i * 0x800, 0x67FF + i * 0x800, _workRam, slaveMasterBit ? MemoryAccessType::ReadWrite : MemoryAccessType::NoAccess); SetCpuMemoryMapping(0x6000 + i * 0x800, 0x67FF + i * 0x800, HasBattery() ? _saveRam : _workRam, slaveMasterBit ? MemoryAccessType::ReadWrite : MemoryAccessType::NoAccess);
otherMapper->SetCpuMemoryMapping(0x6000 + i * 0x800, 0x67FF + i * 0x800, _workRam, slaveMasterBit ? MemoryAccessType::NoAccess : MemoryAccessType::ReadWrite); otherMapper->SetCpuMemoryMapping(0x6000 + i * 0x800, 0x67FF + i * 0x800, HasBattery() ? _saveRam : _workRam, slaveMasterBit ? MemoryAccessType::NoAccess : MemoryAccessType::ReadWrite);
} }
} }
} }

View file

@ -669,7 +669,7 @@ namespace Mesen.GUI.Forms
private void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e) private void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e)
{ {
switch(e.NotificationType) { switch(e.NotificationType) {
case InteropEmu.ConsoleNotificationType.GameLoaded: case InteropEmu.ConsoleNotificationType.GameInitCompleted:
VideoInfo.ApplyOverscanConfig(); VideoInfo.ApplyOverscanConfig();
_currentGame = InteropEmu.GetRomInfo().GetRomName(); _currentGame = InteropEmu.GetRomInfo().GetRomName();
InteropEmu.SetNesModel(ConfigManager.Config.Region); InteropEmu.SetNesModel(ConfigManager.Config.Region);

View file

@ -951,6 +951,7 @@ namespace Mesen.GUI
BeforeEmulationStop = 19, BeforeEmulationStop = 19,
VsDualSystemStarted = 20, VsDualSystemStarted = 20,
VsDualSystemStopped = 21, VsDualSystemStopped = 21,
GameInitCompleted = 22
} }
public enum ControllerType public enum ControllerType