Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RachelBryk committed Jan 19, 2013
1 parent 905d388 commit ed1a948
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
8 changes: 7 additions & 1 deletion Source/Core/Core/Src/HW/EXI.cpp
Expand Up @@ -25,6 +25,7 @@

#include "EXI.h"
#include "Sram.h"
#include "../Movie.h"
SRAM g_SRAM;

namespace ExpansionInterface
Expand All @@ -44,7 +45,12 @@ void Init()
for (u32 i = 0; i < NUM_CHANNELS; i++)
g_Channels[i] = new CEXIChannel(i);

g_Channels[0]->AddDevice(SConfig::GetInstance().m_EXIDevice[0], 0); // SlotA
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
g_Channels[1]->AddDevice(SConfig::GetInstance().m_EXIDevice[1], 0); // SlotB
Expand Down
52 changes: 25 additions & 27 deletions Source/Core/Core/Src/Movie.cpp
Expand Up @@ -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;
Expand All @@ -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:
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit ed1a948

Please sign in to comment.