@@ -255,7 +255,7 @@ bool Console::Initialize(VirtualFile &romFile)
255255 return Initialize (romFile, patchFile);
256256}
257257
258- bool Console::Initialize (VirtualFile &romFile, VirtualFile &patchFile)
258+ bool Console::Initialize (VirtualFile &romFile, VirtualFile &patchFile, bool forPowerCycle )
259259{
260260 if (romFile.IsValid ()) {
261261 Pause ();
@@ -306,14 +306,17 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
306306 StopRecordingHdPack ();
307307 }
308308
309+ shared_ptr<BaseMapper> previousMapper = _mapper;
309310 _mapper = mapper;
310311 _memoryManager.reset (new MemoryManager (shared_from_this ()));
311312 _cpu.reset (new CPU (shared_from_this ()));
312313 _apu.reset (new APU (shared_from_this ()));
313314
314315 _mapper->SetConsole (shared_from_this ());
315316 _mapper->Initialize (romData);
316- GetNotificationManager ()->RegisterNotificationListener (_mapper);
317+ if (!isDifferentGame && forPowerCycle) {
318+ _mapper->CopyPrgChrRom (previousMapper);
319+ }
317320
318321 if (_slave) {
319322 _slave->Release (false );
@@ -400,8 +403,10 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
400403 ResetComponents (false );
401404
402405 // Reset components before creating rewindmanager, otherwise the first save state it takes will be invalid
403- _rewindManager.reset (new RewindManager (shared_from_this ()));
404- _notificationManager->RegisterNotificationListener (_rewindManager);
406+ if (!forPowerCycle) {
407+ _rewindManager.reset (new RewindManager (shared_from_this ()));
408+ _notificationManager->RegisterNotificationListener (_rewindManager);
409+ }
405410
406411 // Poll controller input after creating rewind manager, to make sure it catches the first frame's input
407412 _controlManager->UpdateInputState ();
@@ -418,9 +423,12 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
418423 FolderUtilities::AddKnownGameFolder (romFile.GetFolderPath ());
419424
420425 if (IsMaster ()) {
421- string modelName = _model == NesModel::PAL ? " PAL" : (_model == NesModel::Dendy ? " Dendy" : " NTSC" );
422- string messageTitle = MessageManager::Localize (" GameLoaded" ) + " (" + modelName + " )" ;
423- MessageManager::DisplayMessage (messageTitle, FolderUtilities::GetFilename (GetRomInfo ().RomName , false ));
426+ if (!forPowerCycle) {
427+ string modelName = _model == NesModel::PAL ? " PAL" : (_model == NesModel::Dendy ? " Dendy" : " NTSC" );
428+ string messageTitle = MessageManager::Localize (" GameLoaded" ) + " (" + modelName + " )" ;
429+ MessageManager::DisplayMessage (messageTitle, FolderUtilities::GetFilename (GetRomInfo ().RomName , false ));
430+ }
431+
424432 _settings->ClearFlags (EmulationFlags::ForceMaxSpeed);
425433
426434 if (_slave) {
@@ -565,11 +573,16 @@ shared_ptr<SystemActionManager> Console::GetSystemActionManager()
565573}
566574
567575void Console::PowerCycle ()
576+ {
577+ ReloadRom (true );
578+ }
579+
580+ void Console::ReloadRom (bool forPowerCycle)
568581{
569582 if (_initialized && !_romFilepath.empty ()) {
570583 VirtualFile romFile = _romFilepath;
571584 VirtualFile patchFile = _patchFilename;
572- Initialize (romFile, patchFile);
585+ Initialize (romFile, patchFile, forPowerCycle );
573586 }
574587}
575588
0 commit comments