Misc movie fixes.

Fix setting memory cards on playback.

Fix saving revision to header.

Herpa derp lets open a file while it's still open in another function, and not even check if it fails to load.

Fix an assumption that wii games are using a wiimote.
This commit is contained in:
Rachel Bryk 2013-01-19 15:02:02 -05:00
parent 905d38827e
commit ed1a9480b0
2 changed files with 32 additions and 28 deletions

View File

@ -25,6 +25,7 @@
#include "EXI.h"
#include "Sram.h"
#include "../Movie.h"
SRAM g_SRAM;
namespace ExpansionInterface
@ -44,6 +45,11 @@ void Init()
for (u32 i = 0; i < NUM_CHANNELS; i++)
g_Channels[i] = new CEXIChannel(i);
if (Movie::IsPlayingInput() && Movie::IsUsingMemcard() && Movie::IsConfigSaved())
g_Channels[0]->AddDevice(EXIDEVICE_MEMORYCARD, 0); // SlotA
else if(Movie::IsPlayingInput() && !Movie::IsUsingMemcard() && Movie::IsConfigSaved())
g_Channels[0]->AddDevice(EXIDEVICE_NONE, 0); // SlotA
else
g_Channels[0]->AddDevice(SConfig::GetInstance().m_EXIDevice[0], 0); // SlotA
g_Channels[0]->AddDevice(EXIDEVICE_MASKROM, 1);
g_Channels[0]->AddDevice(SConfig::GetInstance().m_EXIDevice[2], 2); // Serial Port 1

View File

@ -736,16 +736,6 @@ bool PlayInput(const char *filename)
goto cleanup;
}
// Load savestate (and skip to frame data)
if(tmpHeader.bFromSaveState)
{
const std::string stateFilename = std::string(filename) + ".sav";
if(File::Exists(stateFilename))
Core::SetStateFileName(stateFilename);
g_bRecordingFromSaveState = true;
Movie::LoadInput(filename);
}
ReadHeader();
g_totalFrames = tmpHeader.frameCount;
g_totalLagCount = tmpHeader.lagCount;
@ -762,6 +752,16 @@ bool PlayInput(const char *filename)
g_currentByte = 0;
g_recordfd.Close();
// Load savestate (and skip to frame data)
if(tmpHeader.bFromSaveState)
{
const std::string stateFilename = std::string(filename) + ".sav";
if(File::Exists(stateFilename))
Core::SetStateFileName(stateFilename);
g_bRecordingFromSaveState = true;
Movie::LoadInput(filename);
}
return true;
cleanup:
@ -786,7 +786,13 @@ void DoState(PointerWrap &p)
void LoadInput(const char *filename)
{
File::IOFile t_record(filename, "r+b");
File::IOFile t_record;
if (!t_record.Open(filename, "r+b"))
{
PanicAlertT("Failed to read %s", filename);
EndPlayInput(false);
return;
}
t_record.ReadArray(&tmpHeader, 1);
@ -849,7 +855,7 @@ void LoadInput(const char *filename)
{
// this is a "you did something wrong" alert for the user's benefit.
// we'll try to say what's going on in excruciating detail, otherwise the user might not believe us.
if(Core::g_CoreStartupParameter.bWii)
if(IsUsingWiimote(1))
{
// TODO: more detail
PanicAlertT("Warning: You loaded a save whose movie mismatches on byte %d (0x%X). You should load another save before continuing, or load this state with read-only mode off. Otherwise you'll probably get a desync.", i+256, i+256);
@ -925,18 +931,6 @@ void PlayController(SPADStatus *PadStatus, int controllerID)
if (!IsPlayingInput() || !IsUsingPad(controllerID) || tmpInput == NULL)
return;
if (g_currentFrame == 1)
{
if (tmpHeader.bMemcard)
{
ExpansionInterface::ChangeDevice(0, EXIDEVICE_MEMORYCARD, 0);
}
else if (!tmpHeader.bMemcard)
{
ExpansionInterface::ChangeDevice(0, EXIDEVICE_NONE, 0);
}
}
if (g_currentByte + 8 > g_totalBytes)
{
PanicAlertT("Premature movie end in PlayController. %u + 8 > %u", (u32)g_currentByte, (u32)g_totalBytes);
@ -1194,9 +1188,13 @@ void GetSettings()
g_bClearSave = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
bMemcard = SConfig::GetInstance().m_EXIDevice[0] == EXIDEVICE_MEMORYCARD;
std::stringstream ss;
ss << std::hex << SCM_REV_STR;
ss >> revision;
int temp;
for(int i = 0; i < 4; ++i )
{
sscanf(SCM_REV_STR + 2 * i, "%2x", &temp );
revision[i] = temp;
}
}
void CheckMD5()