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