some movie playback fixes
This commit is contained in:
parent
1ad05f7440
commit
d2f61fa155
|
@ -638,10 +638,9 @@ void Wiimote::Update()
|
|||
Movie::SetPolledDevice();
|
||||
|
||||
const ReportFeatures& rptf = reporting_mode_features[m_reporting_mode - WM_REPORT_CORE];
|
||||
if (!Movie::IsPlayingInput() || !Movie::PlayWiimote(m_index, data, rptf_size, rptf.core?(data+rptf.core):NULL, rptf.accel?(data+rptf.accel):NULL, rptf.ir?(data+rptf.ir):NULL))
|
||||
rptf_size = rptf.size;
|
||||
if (!Movie::IsPlayingInput() || !Movie::PlayWiimote(m_index, data, rptf, m_reg_ir.mode))
|
||||
{
|
||||
rptf_size = rptf.size;
|
||||
|
||||
data[0] = 0xA1;
|
||||
data[1] = m_reporting_mode;
|
||||
|
||||
|
@ -661,8 +660,8 @@ void Wiimote::Update()
|
|||
if (rptf.ext)
|
||||
GetExtData(data + rptf.ext);
|
||||
|
||||
// hybrid wiimote stuff
|
||||
if (WIIMOTE_SRC_HYBRID == g_wiimote_sources[m_index])
|
||||
// hybrid wiimote stuff (for now, it's not supported while recording)
|
||||
if (WIIMOTE_SRC_HYBRID == g_wiimote_sources[m_index] && !Movie::IsRecordingInput())
|
||||
{
|
||||
using namespace WiimoteReal;
|
||||
|
||||
|
@ -744,7 +743,7 @@ void Wiimote::Update()
|
|||
}
|
||||
if (Movie::IsRecordingInput())
|
||||
{
|
||||
Movie::RecordWiimote(m_index, data, rptf_size, rptf.core?(data+rptf.core):NULL, rptf.accel?(data+rptf.accel):NULL, rptf.ir?(data+rptf.ir):NULL);
|
||||
Movie::RecordWiimote(m_index, data, rptf, m_reg_ir.mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -457,7 +457,8 @@ void RecordInput(SPADStatus *PadStatus, int controllerID)
|
|||
|
||||
g_padState.CStickX = PadStatus->substickX;
|
||||
g_padState.CStickY = PadStatus->substickY;
|
||||
|
||||
|
||||
|
||||
memcpy(&(tmpInput[g_currentByte]), &g_padState, 8);
|
||||
g_currentByte += 8;
|
||||
g_totalBytes = g_currentByte;
|
||||
|
@ -465,12 +466,18 @@ void RecordInput(SPADStatus *PadStatus, int controllerID)
|
|||
SetInputDisplayString(g_padState, controllerID);
|
||||
}
|
||||
|
||||
void RecordWiimote(int wiimote, u8 *data, s8 size, u8* const coreData, u8* const accelData, u8* const irData)
|
||||
void RecordWiimote(int wiimote, u8 *data, const WiimoteEmu::ReportFeatures& rptf, int irMode)
|
||||
{
|
||||
if(!IsRecordingInput() || !IsUsingWiimote(wiimote))
|
||||
return;
|
||||
|
||||
u8* const coreData = rptf.core?(data+rptf.core):NULL;
|
||||
u8* const accelData = rptf.accel?(data+rptf.accel):NULL;
|
||||
u8* const irData = rptf.ir?(data+rptf.ir):NULL;
|
||||
u8 size = rptf.size;
|
||||
|
||||
InputUpdate();
|
||||
tmpInput[g_currentByte++] = (u8) size;
|
||||
tmpInput[g_currentByte++] = size;
|
||||
memcpy(&(tmpInput[g_currentByte]), data, size);
|
||||
g_currentByte += size;
|
||||
g_totalBytes = g_currentByte;
|
||||
|
@ -526,6 +533,10 @@ bool PlayInput(const char *filename)
|
|||
g_totalLagCount = tmpHeader.lagCount;
|
||||
g_totalInputCount = tmpHeader.inputCount;
|
||||
|
||||
g_currentFrame = 0;
|
||||
g_currentLagCount = 0;
|
||||
g_currentInputCount = 0;
|
||||
|
||||
g_playMode = MODE_PLAYING;
|
||||
|
||||
g_totalBytes = g_recordfd.GetSize() - 256;
|
||||
|
@ -687,7 +698,8 @@ void PlayController(SPADStatus *PadStatus, int controllerID)
|
|||
signed char e = PadStatus->err;
|
||||
memset(PadStatus, 0, sizeof(SPADStatus));
|
||||
PadStatus->err = e;
|
||||
|
||||
|
||||
|
||||
memcpy(&g_padState, &(tmpInput[g_currentByte]), 8);
|
||||
g_currentByte += 8;
|
||||
|
||||
|
@ -740,32 +752,43 @@ void PlayController(SPADStatus *PadStatus, int controllerID)
|
|||
CheckInputEnd();
|
||||
}
|
||||
|
||||
bool PlayWiimote(int wiimote, u8 *data, s8 &size, u8* const coreData, u8* const accelData, u8* const irData)
|
||||
bool PlayWiimote(int wiimote, u8 *data, const WiimoteEmu::ReportFeatures& rptf, int irMode)
|
||||
{
|
||||
s8 count = 0;
|
||||
|
||||
if(!IsPlayingInput() || !IsUsingWiimote(wiimote) || tmpInput == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
if (g_currentByte > g_totalBytes)
|
||||
{
|
||||
PanicAlertT("Premature movie end in PlayWiimote. %u > %u", (u32)g_currentByte, (u32)g_totalBytes);
|
||||
EndPlayInput(!g_bReadOnly);
|
||||
return false;
|
||||
}
|
||||
|
||||
count = (s8) (tmpInput[g_currentByte++]);
|
||||
|
||||
if (g_currentByte + count > g_totalBytes)
|
||||
u8* const coreData = rptf.core?(data+rptf.core):NULL;
|
||||
u8* const accelData = rptf.accel?(data+rptf.accel):NULL;
|
||||
u8* const irData = rptf.ir?(data+rptf.ir):NULL;
|
||||
u8 size = rptf.size;
|
||||
|
||||
u8 sizeInMovie = tmpInput[g_currentByte];
|
||||
|
||||
if (size != sizeInMovie)
|
||||
{
|
||||
PanicAlertT("Premature movie end in PlayWiimote. %u + %d > %u", (u32)g_currentByte, count, (u32)g_totalBytes);
|
||||
PanicAlertT("Error in PlayWiimote. %u != %u, byte %d.\nSorry, Wii recording is temporarily broken.", sizeInMovie, size, g_currentByte);
|
||||
EndPlayInput(!g_bReadOnly);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_currentByte++;
|
||||
|
||||
if (g_currentByte + size > g_totalBytes)
|
||||
{
|
||||
PanicAlertT("Premature movie end in PlayWiimote. %u + %d > %u", (u32)g_currentByte, size, (u32)g_totalBytes);
|
||||
EndPlayInput(!g_bReadOnly);
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(data, &(tmpInput[g_currentByte]), count);
|
||||
g_currentByte += count;
|
||||
size = (count > size) ? size : count;
|
||||
memcpy(data, &(tmpInput[g_currentByte]), size);
|
||||
g_currentByte += size;
|
||||
|
||||
SetWiiInputDisplayString(wiimote, coreData, accelData, irData);
|
||||
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
|
||||
#include "ChunkFile.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
struct ReportFeatures;
|
||||
}
|
||||
|
||||
// Per-(video )Movie actions
|
||||
|
||||
namespace Movie {
|
||||
|
@ -127,12 +132,12 @@ void FrameSkipping();
|
|||
|
||||
bool BeginRecordingInput(int controllers);
|
||||
void RecordInput(SPADStatus *PadStatus, int controllerID);
|
||||
void RecordWiimote(int wiimote, u8* data, s8 size, u8* const coreData, u8* const accelData, u8* const irData);
|
||||
void RecordWiimote(int wiimote, u8* data, const struct WiimoteEmu::ReportFeatures& rptf, int irMode);
|
||||
|
||||
bool PlayInput(const char *filename);
|
||||
void LoadInput(const char *filename);
|
||||
void PlayController(SPADStatus *PadStatus, int controllerID);
|
||||
bool PlayWiimote(int wiimote, u8* data, s8 &size, u8* const coreData, u8* const accelData, u8* const irData);
|
||||
bool PlayWiimote(int wiimote, u8* data, const struct WiimoteEmu::ReportFeatures& rptf, int irMode);
|
||||
void EndPlayInput(bool cont);
|
||||
void SaveRecording(const char *filename);
|
||||
void DoState(PointerWrap &p, bool doNot=false);
|
||||
|
|
Loading…
Reference in New Issue