@@ -74,6 +74,7 @@ Console::~Console()
7474void Console::Init ()
7575{
7676 _notificationManager.reset (new NotificationManager ());
77+ _batteryManager.reset (new BatteryManager ());
7778
7879 _videoRenderer.reset (new VideoRenderer (shared_from_this ()));
7980 _videoDecoder.reset (new VideoDecoder (shared_from_this ()));
@@ -135,6 +136,11 @@ void Console::Release(bool forShutdown)
135136 _controlManager.reset ();
136137}
137138
139+ shared_ptr<BatteryManager> Console::GetBatteryManager ()
140+ {
141+ return _batteryManager;
142+ }
143+
138144shared_ptr<SaveStateManager> Console::GetSaveStateManager ()
139145{
140146 return _saveStateManager;
@@ -264,7 +270,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
264270 vector<uint8_t > fileData;
265271 romFile.ReadFile (fileData);
266272
267- BatteryManager:: Initialize (FolderUtilities::GetFilename (romFile.GetFileName (), false ));
273+ _batteryManager-> Initialize (FolderUtilities::GetFilename (romFile.GetFileName (), false ));
268274 shared_ptr<BaseMapper> mapper = MapperFactory::InitializeFromFile (shared_from_this (), romFile.GetFileName (), fileData);
269275 if (mapper) {
270276 _soundMixer->StopAudio (true );
@@ -324,7 +330,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
324330 }
325331
326332 // Temporarely disable battery saves to prevent battery files from being created for the wrong game (for Battle Box & Turbo File)
327- BatteryManager:: SetSaveEnabled (false );
333+ _batteryManager-> SetSaveEnabled (false );
328334
329335 uint32_t pollCounter = 0 ;
330336 if (_controlManager && !isDifferentGame) {
@@ -341,7 +347,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
341347 _controlManager->UpdateControlDevices ();
342348
343349 // Re-enable battery saves
344- BatteryManager:: SetSaveEnabled (true );
350+ _batteryManager-> SetSaveEnabled (true );
345351
346352 if (_hdData && (!_hdData->Tiles .empty () || !_hdData->Backgrounds .empty ())) {
347353 _ppu.reset (new HdPpu (shared_from_this (), _hdData.get ()));
@@ -415,7 +421,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
415421 }
416422
417423 // Reset battery source to current game if new game failed to load
418- BatteryManager:: Initialize (FolderUtilities::GetFilename (GetRomInfo ().RomName , false ));
424+ _batteryManager-> Initialize (FolderUtilities::GetFilename (GetRomInfo ().RomName , false ));
419425 if (_mapper) {
420426 _videoDecoder->StartThread ();
421427 }
@@ -1275,6 +1281,8 @@ void Console::CopyRewindData(shared_ptr<Console> sourceConsole)
12751281 sourceConsole->Pause ();
12761282 Pause ();
12771283
1284+ // Disable battery saving for this instance
1285+ _batteryManager->SetSaveEnabled (false );
12781286 _historyViewer.reset (new HistoryViewer (shared_from_this ()));
12791287 sourceConsole->_rewindManager ->CopyHistory (_historyViewer);
12801288
0 commit comments