Cleanup Movie.h/cpp.

This commit is contained in:
Rachel Bryk 2014-09-08 20:15:47 -04:00
parent 571727a5ad
commit 08db8c646b
2 changed files with 39 additions and 44 deletions

View File

@ -116,7 +116,7 @@ std::string GetInputDisplay()
if (!IsMovieActive()) if (!IsMovieActive())
{ {
s_numPads = 0; s_numPads = 0;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; ++i)
{ {
if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER || SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_TARUKONGA) if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER || SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_TARUKONGA)
s_numPads |= (1 << i); s_numPads |= (1 << i);
@ -175,9 +175,9 @@ void Init()
ReadHeader(); ReadHeader();
std::thread md5thread(CheckMD5); std::thread md5thread(CheckMD5);
md5thread.detach(); md5thread.detach();
if ((strncmp((char *)tmpHeader.gameID, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str(), 6))) if (strncmp((char *)tmpHeader.gameID, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str(), 6))
{ {
PanicAlert("The recorded game (%s) is not the same as the selected game (%s)", tmpHeader.gameID, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str()); PanicAlertT("The recorded game (%s) is not the same as the selected game (%s)", tmpHeader.gameID, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str());
EndPlayInput(false); EndPlayInput(false);
} }
} }
@ -219,7 +219,7 @@ void InputUpdate()
s_tickCountAtLastInput = CoreTiming::GetTicks(); s_tickCountAtLastInput = CoreTiming::GetTicks();
} }
if (IsPlayingInput() && g_currentInputCount == (g_totalInputCount -1) && SConfig::GetInstance().m_PauseMovie) if (IsPlayingInput() && g_currentInputCount == (g_totalInputCount - 1) && SConfig::GetInstance().m_PauseMovie)
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::CORE_PAUSE);
} }
@ -273,7 +273,7 @@ void SetReadOnly(bool bEnabled)
void FrameSkipping() void FrameSkipping()
{ {
// Frameskipping will desync movie playback // Frameskipping will desync movie playback
if (!IsMovieActive()) if (!IsMovieActive() || NetPlay::IsNetPlayRunning())
{ {
std::lock_guard<std::mutex> lk(cs_frameSkip); std::lock_guard<std::mutex> lk(cs_frameSkip);
@ -400,14 +400,14 @@ void ChangePads(bool instantly)
int controllers = 0; int controllers = 0;
for (int i = 0; i < MAX_SI_CHANNELS; i++) for (int i = 0; i < MAX_SI_CHANNELS; ++i)
if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER || SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_TARUKONGA) if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER || SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_TARUKONGA)
controllers |= (1 << i); controllers |= (1 << i);
if (instantly && (s_numPads & 0x0F) == controllers) if (instantly && (s_numPads & 0x0F) == controllers)
return; return;
for (int i = 0; i < MAX_SI_CHANNELS; i++) for (int i = 0; i < MAX_SI_CHANNELS; ++i)
if (instantly) // Changes from savestates need to be instantaneous if (instantly) // Changes from savestates need to be instantaneous
SerialInterface::AddDevice(IsUsingPad(i) ? (IsUsingBongo(i) ? SIDEVICE_GC_TARUKONGA : SIDEVICE_GC_CONTROLLER) : SIDEVICE_NONE, i); SerialInterface::AddDevice(IsUsingPad(i) ? (IsUsingBongo(i) ? SIDEVICE_GC_TARUKONGA : SIDEVICE_GC_CONTROLLER) : SIDEVICE_NONE, i);
else else
@ -418,7 +418,7 @@ void ChangeWiiPads(bool instantly)
{ {
int controllers = 0; int controllers = 0;
for (int i = 0; i < MAX_WIIMOTES; i++) for (int i = 0; i < MAX_WIIMOTES; ++i)
if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE) if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE)
controllers |= (1 << i); controllers |= (1 << i);
@ -426,7 +426,7 @@ void ChangeWiiPads(bool instantly)
if (instantly && (s_numPads >> 4) == controllers) if (instantly && (s_numPads >> 4) == controllers)
return; return;
for (int i = 0; i < MAX_WIIMOTES; i++) for (int i = 0; i < MAX_WIIMOTES; ++i)
{ {
g_wiimote_sources[i] = IsUsingWiimote(i) ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE; g_wiimote_sources[i] = IsUsingWiimote(i) ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE;
GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(IsUsingWiimote(i)); GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(IsUsingWiimote(i));
@ -673,9 +673,9 @@ void RecordInput(GCPadStatus* PadStatus, int controllerID)
void CheckWiimoteStatus(int wiimote, u8 *data, const WiimoteEmu::ReportFeatures& rptf) void CheckWiimoteStatus(int wiimote, u8 *data, const WiimoteEmu::ReportFeatures& rptf)
{ {
u8* const coreData = rptf.core?(data+rptf.core):nullptr; u8* const coreData = rptf.core ? (data + rptf.core) : nullptr;
u8* const accelData = rptf.accel?(data+rptf.accel):nullptr; u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr;
u8* const irData = rptf.ir?(data+rptf.ir):nullptr; u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr;
u8 size = rptf.size; u8 size = rptf.size;
SetWiiInputDisplayString(wiimote, coreData, accelData, irData); SetWiiInputDisplayString(wiimote, coreData, accelData, irData);
@ -750,7 +750,8 @@ bool PlayInput(const std::string& filename)
if (!IsMovieHeader(tmpHeader.filetype)) if (!IsMovieHeader(tmpHeader.filetype))
{ {
PanicAlertT("Invalid recording file"); PanicAlertT("Invalid recording file");
goto cleanup; g_recordfd.Close();
return false;
} }
ReadHeader(); ReadHeader();
@ -781,10 +782,6 @@ bool PlayInput(const std::string& filename)
} }
return true; return true;
cleanup:
g_recordfd.Close();
return false;
} }
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
@ -885,7 +882,7 @@ void LoadInput(const std::string& filename)
} }
else else
{ {
int frame = i/8; int frame = i / 8;
ControllerState curPadState; ControllerState curPadState;
memcpy(&curPadState, &(tmpInput[frame*8]), 8); memcpy(&curPadState, &(tmpInput[frame*8]), 8);
ControllerState movPadState; ControllerState movPadState;
@ -904,7 +901,6 @@ void LoadInput(const std::string& filename)
(int)frame, (int)frame,
(int)movPadState.Start, (int)movPadState.A, (int)movPadState.B, (int)movPadState.X, (int)movPadState.Y, (int)movPadState.Z, (int)movPadState.DPadUp, (int)movPadState.DPadDown, (int)movPadState.DPadLeft, (int)movPadState.DPadRight, (int)movPadState.L, (int)movPadState.R, (int)movPadState.TriggerL, (int)movPadState.TriggerR, (int)movPadState.AnalogStickX, (int)movPadState.AnalogStickY, (int)movPadState.CStickX, (int)movPadState.CStickY); (int)movPadState.Start, (int)movPadState.A, (int)movPadState.B, (int)movPadState.X, (int)movPadState.Y, (int)movPadState.Z, (int)movPadState.DPadUp, (int)movPadState.DPadDown, (int)movPadState.DPadLeft, (int)movPadState.DPadRight, (int)movPadState.L, (int)movPadState.R, (int)movPadState.TriggerL, (int)movPadState.TriggerR, (int)movPadState.AnalogStickX, (int)movPadState.AnalogStickY, (int)movPadState.CStickX, (int)movPadState.CStickY);
memcpy(tmpInput, movInput, s_currentByte);
} }
break; break;
} }
@ -1020,10 +1016,9 @@ void PlayController(GCPadStatus* PadStatus, int controllerID)
// This implementation assumes the disc change will only happen once. Trying to change more than that will cause // This implementation assumes the disc change will only happen once. Trying to change more than that will cause
// it to load the last disc every time. As far as i know though, there are no 3+ disc games, so this should be fine. // it to load the last disc every time. As far as i know though, there are no 3+ disc games, so this should be fine.
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::CORE_PAUSE);
int numPaths = (int)SConfig::GetInstance().m_ISOFolder.size();
bool found = false; bool found = false;
std::string path; std::string path;
for (int i = 0; i < numPaths; i++) for (int i = 0; i < SConfig::GetInstance().m_ISOFolder.size(); ++i)
{ {
path = SConfig::GetInstance().m_ISOFolder[i]; path = SConfig::GetInstance().m_ISOFolder[i];
if (File::Exists(path + '/' + g_discChange)) if (File::Exists(path + '/' + g_discChange))
@ -1039,7 +1034,7 @@ void PlayController(GCPadStatus* PadStatus, int controllerID)
} }
else else
{ {
PanicAlert("Change the disc to %s", g_discChange.c_str()); PanicAlertT("Change the disc to %s", g_discChange.c_str());
} }
} }
@ -1059,9 +1054,9 @@ bool PlayWiimote(int wiimote, u8 *data, const WiimoteEmu::ReportFeatures& rptf)
return false; return false;
} }
u8* const coreData = rptf.core?(data+rptf.core):nullptr; u8* const coreData = rptf.core ? (data + rptf.core) : nullptr;
u8* const accelData = rptf.accel?(data+rptf.accel):nullptr; u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr;
u8* const irData = rptf.ir?(data+rptf.ir):nullptr; u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr;
u8 size = rptf.size; u8 size = rptf.size;
u8 sizeInMovie = tmpInput[s_currentByte]; u8 sizeInMovie = tmpInput[s_currentByte];
@ -1240,7 +1235,7 @@ void GetSettings()
file_irom.ReadArray(irom.data(), DSP_IROM_SIZE); file_irom.ReadArray(irom.data(), DSP_IROM_SIZE);
file_irom.Close(); file_irom.Close();
for (int i = 0; i < DSP_IROM_SIZE; i++) for (int i = 0; i < DSP_IROM_SIZE; ++i)
irom[i] = Common::swap16(irom[i]); irom[i] = Common::swap16(irom[i]);
std::vector<u16> coef(DSP_COEF_SIZE); std::vector<u16> coef(DSP_COEF_SIZE);
@ -1248,7 +1243,7 @@ void GetSettings()
file_coef.ReadArray(coef.data(), DSP_COEF_SIZE); file_coef.ReadArray(coef.data(), DSP_COEF_SIZE);
file_coef.Close(); file_coef.Close();
for (int i = 0; i < DSP_COEF_SIZE; i++) for (int i = 0; i < DSP_COEF_SIZE; ++i)
coef[i] = Common::swap16(coef[i]); coef[i] = Common::swap16(coef[i]);
s_DSPiromHash = HashAdler32((u8*)irom.data(), DSP_IROM_BYTE_SIZE); s_DSPiromHash = HashAdler32((u8*)irom.data(), DSP_IROM_BYTE_SIZE);
s_DSPcoefHash = HashAdler32((u8*)coef.data(), DSP_COEF_BYTE_SIZE); s_DSPcoefHash = HashAdler32((u8*)coef.data(), DSP_COEF_BYTE_SIZE);

View File

@ -77,7 +77,7 @@ struct DTMHeader
u8 videoBackend[16]; // UTF-8 representation of the video backend u8 videoBackend[16]; // UTF-8 representation of the video backend
u8 audioEmulator[16]; // UTF-8 representation of the audio emulator u8 audioEmulator[16]; // UTF-8 representation of the audio emulator
unsigned char md5[16]; // MD5 of game iso u8 md5[16]; // MD5 of game iso
u64 recordingStartTime; // seconds since 1970 that recording started (used for RTC) u64 recordingStartTime; // seconds since 1970 that recording started (used for RTC)