2017-04-24 22:28:50 +00:00
|
|
|
#include "stdafx.h"
|
2017-05-05 03:38:27 +00:00
|
|
|
#include <algorithm>
|
2017-11-20 04:08:23 +00:00
|
|
|
#include "../Utilities/StringUtilities.h"
|
2017-04-24 22:28:50 +00:00
|
|
|
#include "../Utilities/HexUtilities.h"
|
2017-11-25 02:38:12 +00:00
|
|
|
#include "../Utilities/Base64.h"
|
2017-11-20 04:08:23 +00:00
|
|
|
#include "ControlManager.h"
|
2017-04-24 22:28:50 +00:00
|
|
|
#include "FceuxMovie.h"
|
|
|
|
#include "Console.h"
|
|
|
|
|
|
|
|
bool FceuxMovie::InitializeData(stringstream &filestream)
|
|
|
|
{
|
|
|
|
bool result = false;
|
2017-11-20 04:08:23 +00:00
|
|
|
|
|
|
|
_dataByFrame[0].push_back("");
|
|
|
|
_dataByFrame[1].push_back("");
|
|
|
|
_dataByFrame[2].push_back("");
|
|
|
|
_dataByFrame[3].push_back("");
|
|
|
|
|
2017-12-23 17:32:44 +00:00
|
|
|
ControlManager::ResetPollCounter();
|
|
|
|
|
2017-04-24 22:28:50 +00:00
|
|
|
while(!filestream.eof()) {
|
|
|
|
string line;
|
|
|
|
std::getline(filestream, line);
|
|
|
|
if(line.compare(0, 19, "romChecksum base64:", 19) == 0) {
|
2017-11-25 02:38:12 +00:00
|
|
|
vector<uint8_t> md5array = Base64::Decode(line.substr(19, line.size() - 20));
|
2017-04-24 22:28:50 +00:00
|
|
|
HashInfo hashInfo;
|
|
|
|
hashInfo.PrgChrMd5Hash = HexUtilities::ToHex(md5array);
|
|
|
|
if(Console::LoadROM("", hashInfo)) {
|
|
|
|
result = true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if(line.size() > 0 && line[0] == '|') {
|
2017-11-20 04:08:23 +00:00
|
|
|
vector<string> lineData = StringUtilities::Split(line.substr(1), '|');
|
|
|
|
|
|
|
|
if(lineData.size() == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-04-24 22:28:50 +00:00
|
|
|
|
|
|
|
//Read power/reset/FDS/VS/etc. commands
|
2017-11-20 04:08:23 +00:00
|
|
|
uint32_t systemAction = 0;
|
|
|
|
try {
|
|
|
|
systemAction = (uint32_t)std::atol(lineData[0].c_str());
|
|
|
|
} catch(std::exception ex) {
|
2017-04-24 22:28:50 +00:00
|
|
|
}
|
2017-11-20 04:08:23 +00:00
|
|
|
_systemActionByFrame.push_back(systemAction);
|
2017-04-24 22:28:50 +00:00
|
|
|
|
|
|
|
//Only supports regular controllers (up to 4 of them)
|
2017-11-20 04:08:23 +00:00
|
|
|
for(size_t i = 1; i < lineData.size() && i < 5; i++) {
|
|
|
|
if(lineData[i].size() >= 8) {
|
|
|
|
string data = lineData[i].substr(3, 1) + lineData[i].substr(2, 1) + lineData[i].substr(1, 1) + lineData[i].substr(0, 1);
|
|
|
|
_dataByFrame[i - 1].push_back(data + lineData[i].substr(4, 4));
|
|
|
|
} else {
|
|
|
|
_dataByFrame[i - 1].push_back("");
|
2017-04-24 22:28:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-11-20 04:08:23 +00:00
|
|
|
bool FceuxMovie::Play(VirtualFile &file)
|
2017-04-24 22:28:50 +00:00
|
|
|
{
|
|
|
|
Console::Pause();
|
2017-11-20 04:08:23 +00:00
|
|
|
|
|
|
|
std::stringstream ss;
|
|
|
|
file.ReadFile(ss);
|
|
|
|
if(InitializeData(ss)) {
|
2017-04-24 22:28:50 +00:00
|
|
|
EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllZeros);
|
2017-11-20 04:08:23 +00:00
|
|
|
ControlManager::RegisterInputProvider(this);
|
2017-04-24 22:28:50 +00:00
|
|
|
Console::Reset(false);
|
|
|
|
_isPlaying = true;
|
|
|
|
}
|
2017-11-20 04:08:23 +00:00
|
|
|
|
2017-04-24 22:28:50 +00:00
|
|
|
Console::Resume();
|
|
|
|
return _isPlaying;
|
|
|
|
}
|