Movies: Fixed regressions (due to refactoring) - PollCounter + bk2/fm2 playback
This commit is contained in:
parent
2504fe0b71
commit
97270f2b2e
7 changed files with 35 additions and 15 deletions
|
@ -5,7 +5,8 @@
|
||||||
#include "VsSystemActionManager.h"
|
#include "VsSystemActionManager.h"
|
||||||
#include "BizhawkMovie.h"
|
#include "BizhawkMovie.h"
|
||||||
#include "VsControlManager.h"
|
#include "VsControlManager.h"
|
||||||
#include "FDS.h"
|
#include "Console.h"
|
||||||
|
#include "NotificationManager.h"
|
||||||
|
|
||||||
BizhawkMovie::BizhawkMovie(shared_ptr<Console> console)
|
BizhawkMovie::BizhawkMovie(shared_ptr<Console> console)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +98,7 @@ bool BizhawkMovie::InitializeGameData(ZipReader &reader)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_console->GetControlManager()->ResetPollCounter();
|
_console->GetControlManager()->SetPollCounter(0);
|
||||||
|
|
||||||
while(!fileData.eof()) {
|
while(!fileData.eof()) {
|
||||||
string line;
|
string line;
|
||||||
|
@ -187,13 +188,12 @@ bool BizhawkMovie::Play(VirtualFile &file)
|
||||||
file.ReadFile(ss);
|
file.ReadFile(ss);
|
||||||
|
|
||||||
reader.LoadArchive(ss);
|
reader.LoadArchive(ss);
|
||||||
_console->GetControlManager()->RegisterInputProvider(this);
|
|
||||||
|
_console->GetNotificationManager()->RegisterNotificationListener(shared_from_this());
|
||||||
|
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllOnes);
|
||||||
if(InitializeInputData(reader) && InitializeGameData(reader)) {
|
if(InitializeInputData(reader) && InitializeGameData(reader)) {
|
||||||
//NesHawk initializes memory to 1s
|
//NesHawk initializes memory to 1s
|
||||||
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllOnes);
|
|
||||||
_isPlaying = true;
|
_isPlaying = true;
|
||||||
} else {
|
|
||||||
_console->GetControlManager()->UnregisterInputProvider(this);
|
|
||||||
}
|
}
|
||||||
_console->Resume();
|
_console->Resume();
|
||||||
return _isPlaying;
|
return _isPlaying;
|
||||||
|
@ -203,3 +203,10 @@ bool BizhawkMovie::IsPlaying()
|
||||||
{
|
{
|
||||||
return _isPlaying;
|
return _isPlaying;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BizhawkMovie::ProcessNotification(ConsoleNotificationType type, void* parameter)
|
||||||
|
{
|
||||||
|
if(type == ConsoleNotificationType::GameLoaded) {
|
||||||
|
_console->GetControlManager()->RegisterInputProvider(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "MovieManager.h"
|
#include "MovieManager.h"
|
||||||
#include "../Utilities/ZipReader.h"
|
#include "../Utilities/ZipReader.h"
|
||||||
|
#include "INotificationListener.h"
|
||||||
|
|
||||||
class VirtualFile;
|
class VirtualFile;
|
||||||
class Console;
|
class Console;
|
||||||
|
|
||||||
class BizhawkMovie : public IMovie
|
class BizhawkMovie : public IMovie, public INotificationListener, public std::enable_shared_from_this<BizhawkMovie>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool InitializeGameData(ZipReader &reader);
|
bool InitializeGameData(ZipReader &reader);
|
||||||
|
@ -28,4 +29,7 @@ public:
|
||||||
bool SetInput(BaseControlDevice *device) override;
|
bool SetInput(BaseControlDevice *device) override;
|
||||||
bool Play(VirtualFile &file) override;
|
bool Play(VirtualFile &file) override;
|
||||||
bool IsPlaying() override;
|
bool IsPlaying() override;
|
||||||
|
|
||||||
|
// Inherited via INotificationListener
|
||||||
|
virtual void ProcessNotification(ConsoleNotificationType type, void * parameter) override;
|
||||||
};
|
};
|
|
@ -279,12 +279,20 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
|
||||||
|
|
||||||
//Temporarely disable battery saves to prevent battery files from being created for the wrong game (for Battle Box & Turbo File)
|
//Temporarely disable battery saves to prevent battery files from being created for the wrong game (for Battle Box & Turbo File)
|
||||||
BatteryManager::SetSaveEnabled(false);
|
BatteryManager::SetSaveEnabled(false);
|
||||||
|
|
||||||
|
uint32_t pollCounter = 0;
|
||||||
|
if(_controlManager && !isDifferentGame) {
|
||||||
|
//When power cycling, poll counter must be preserved to allow movies to playback properly
|
||||||
|
pollCounter = _controlManager->GetPollCounter();
|
||||||
|
}
|
||||||
if(system == GameSystem::VsUniSystem) {
|
if(system == GameSystem::VsUniSystem) {
|
||||||
_controlManager.reset(new VsControlManager(shared_from_this(), _systemActionManager, _mapper->GetMapperControlDevice()));
|
_controlManager.reset(new VsControlManager(shared_from_this(), _systemActionManager, _mapper->GetMapperControlDevice()));
|
||||||
} else {
|
} else {
|
||||||
_controlManager.reset(new ControlManager(shared_from_this(), _systemActionManager, _mapper->GetMapperControlDevice()));
|
_controlManager.reset(new ControlManager(shared_from_this(), _systemActionManager, _mapper->GetMapperControlDevice()));
|
||||||
}
|
}
|
||||||
|
_controlManager->SetPollCounter(pollCounter);
|
||||||
_controlManager->UpdateControlDevices();
|
_controlManager->UpdateControlDevices();
|
||||||
|
|
||||||
//Re-enable battery saves
|
//Re-enable battery saves
|
||||||
BatteryManager::SetSaveEnabled(true);
|
BatteryManager::SetSaveEnabled(true);
|
||||||
|
|
||||||
|
|
|
@ -305,9 +305,9 @@ uint32_t ControlManager::GetPollCounter()
|
||||||
return ControlManager::_pollCounter;
|
return ControlManager::_pollCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlManager::ResetPollCounter()
|
void ControlManager::SetPollCounter(uint32_t value)
|
||||||
{
|
{
|
||||||
_pollCounter = 0;
|
_pollCounter = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ControlManager::ReadRAM(uint16_t addr)
|
uint8_t ControlManager::ReadRAM(uint16_t addr)
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
void ResetLagCounter();
|
void ResetLagCounter();
|
||||||
|
|
||||||
uint32_t GetPollCounter();
|
uint32_t GetPollCounter();
|
||||||
void ResetPollCounter();
|
void SetPollCounter(uint32_t value);
|
||||||
|
|
||||||
virtual void Reset(bool softReset);
|
virtual void Reset(bool softReset);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "ControlManager.h"
|
#include "ControlManager.h"
|
||||||
#include "FceuxMovie.h"
|
#include "FceuxMovie.h"
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
|
#include "NotificationManager.h"
|
||||||
|
|
||||||
bool FceuxMovie::InitializeData(stringstream &filestream)
|
bool FceuxMovie::InitializeData(stringstream &filestream)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +17,7 @@ bool FceuxMovie::InitializeData(stringstream &filestream)
|
||||||
_dataByFrame[2].push_back("");
|
_dataByFrame[2].push_back("");
|
||||||
_dataByFrame[3].push_back("");
|
_dataByFrame[3].push_back("");
|
||||||
|
|
||||||
_console->GetControlManager()->ResetPollCounter();
|
_console->GetControlManager()->SetPollCounter(0);
|
||||||
|
|
||||||
while(!filestream.eof()) {
|
while(!filestream.eof()) {
|
||||||
string line;
|
string line;
|
||||||
|
@ -25,6 +26,7 @@ bool FceuxMovie::InitializeData(stringstream &filestream)
|
||||||
vector<uint8_t> md5array = Base64::Decode(line.substr(19, line.size() - 20));
|
vector<uint8_t> md5array = Base64::Decode(line.substr(19, line.size() - 20));
|
||||||
HashInfo hashInfo;
|
HashInfo hashInfo;
|
||||||
hashInfo.PrgChrMd5Hash = HexUtilities::ToHex(md5array);
|
hashInfo.PrgChrMd5Hash = HexUtilities::ToHex(md5array);
|
||||||
|
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllZeros);
|
||||||
if(_console->LoadMatchingRom("", hashInfo)) {
|
if(_console->LoadMatchingRom("", hashInfo)) {
|
||||||
result = true;
|
result = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,9 +67,8 @@ bool FceuxMovie::Play(VirtualFile &file)
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
file.ReadFile(ss);
|
file.ReadFile(ss);
|
||||||
|
_console->GetNotificationManager()->RegisterNotificationListener(shared_from_this());
|
||||||
if(InitializeData(ss)) {
|
if(InitializeData(ss)) {
|
||||||
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllZeros);
|
|
||||||
_console->GetControlManager()->RegisterInputProvider(this);
|
|
||||||
_console->Reset(false);
|
_console->Reset(false);
|
||||||
_isPlaying = true;
|
_isPlaying = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ bool MesenMovie::Play(VirtualFile &file)
|
||||||
//Disable auto-configure input option (otherwise the movie file's input types are ignored)
|
//Disable auto-configure input option (otherwise the movie file's input types are ignored)
|
||||||
bool autoConfigureInput = EmulationSettings::CheckFlag(EmulationFlags::AutoConfigureInput);
|
bool autoConfigureInput = EmulationSettings::CheckFlag(EmulationFlags::AutoConfigureInput);
|
||||||
EmulationSettings::ClearFlags(EmulationFlags::AutoConfigureInput);
|
EmulationSettings::ClearFlags(EmulationFlags::AutoConfigureInput);
|
||||||
_console->GetControlManager()->ResetPollCounter();
|
_console->GetControlManager()->SetPollCounter(0);
|
||||||
bool gameLoaded = LoadGame();
|
bool gameLoaded = LoadGame();
|
||||||
EmulationSettings::SetFlagState(EmulationFlags::AutoConfigureInput, autoConfigureInput);
|
EmulationSettings::SetFlagState(EmulationFlags::AutoConfigureInput, autoConfigureInput);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ bool MesenMovie::Play(VirtualFile &file)
|
||||||
_console->Resume();
|
_console->Resume();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
_console->GetControlManager()->ResetPollCounter();
|
_console->GetControlManager()->SetPollCounter(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue