Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge movie-fixes.
  • Loading branch information
rog9 committed Nov 16, 2012
2 parents a024d04 + 101de62 commit 3a8e8af
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 81 deletions.
3 changes: 1 addition & 2 deletions Source/Core/Core/Src/BootManager.cpp
Expand Up @@ -118,13 +118,12 @@ bool BootCore(const std::string& _rFilename)

if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
{
Movie::Init();
StartUp.bCPUThread = Movie::IsDualCore();
StartUp.bSkipIdle = Movie::IsSkipIdle();
StartUp.bDSPHLE = Movie::IsDSPHLE();
StartUp.bProgressive = Movie::IsProgressive();
StartUp.bFastDiscSpeed = Movie::IsFastDiscSpeed();
if (Movie::IsUsingMemcard() && Movie::IsBlankMemcard())
if (Movie::IsUsingMemcard() && Movie::IsStartingFromClearSave() && !StartUp.bWii)
{
if (File::Exists("Movie.raw"))
File::Delete("Movie.raw");
Expand Down
10 changes: 10 additions & 0 deletions Source/Core/Core/Src/ConfigManager.cpp
Expand Up @@ -131,6 +131,7 @@ void SConfig::SaveSettings()

// General
ini.Set("General", "LastFilename", m_LastFilename);
ini.Set("General", "ShowLag", m_ShowLag);

// ISO folders
// clear removed folders
Expand Down Expand Up @@ -247,6 +248,10 @@ void SConfig::SaveSettings()
// GFX Backend
ini.Set("Core", "GFXBackend", m_LocalCoreStartupParameter.m_strVideoBackend);

// Movie
ini.Set("Movie", "PauseMovie", m_PauseMovie);
ini.Set("Movie", "Author", m_strMovieAuthor);

ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
m_SYSCONF->Save();
}
Expand All @@ -261,6 +266,7 @@ void SConfig::LoadSettings()
// General
{
ini.Get("General", "LastFilename", &m_LastFilename);
ini.Get("General", "ShowLag", &m_ShowLag, false);

m_ISOFolder.clear();
int numGCMPaths;
Expand Down Expand Up @@ -386,6 +392,10 @@ void SConfig::LoadSettings()

// GFX Backend
ini.Get("Core", "GFXBackend", &m_LocalCoreStartupParameter.m_strVideoBackend, "");

// Movie
ini.Get("General", "PauseMovie", &m_PauseMovie, false);
ini.Get("Movie", "Author", &m_strMovieAuthor, "");
}

m_SYSCONF = new SysConf();
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/Src/ConfigManager.h
Expand Up @@ -76,6 +76,9 @@ struct SConfig : NonCopyable
bool m_ListTaiwan;
bool m_ListUnknown;
std::string m_WirelessMac;
bool m_PauseMovie;
bool m_ShowLag;
std::string m_strMovieAuthor;

SysConf* m_SYSCONF;

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp
Expand Up @@ -52,7 +52,7 @@ CEXIMemoryCard::CEXIMemoryCard(const int index)
, m_bDirty(false)
{
m_strFilename = (card_index == 0) ? SConfig::GetInstance().m_strMemoryCardA : SConfig::GetInstance().m_strMemoryCardB;
if (Movie::IsUsingMemcard() && Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsBlankMemcard())
if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsUsingMemcard() && Movie::IsStartingFromClearSave())
m_strFilename = "Movie.raw";

// we're potentially leaking events here, since there's no UnregisterEvent until emu shutdown, but I guess it's inconsequential
Expand Down
50 changes: 50 additions & 0 deletions Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp
Expand Up @@ -57,7 +57,11 @@
#include "NandPaths.h"
#include "CommonPaths.h"
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "../Movie.h"

#ifdef _WIN32
#include <Windows.h>
#endif

std::string CWII_IPC_HLE_Device_es::m_ContentFile;

Expand Down Expand Up @@ -894,6 +898,52 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)

File::CreateFullPath(tmdPath);
File::CreateFullPath(Common::GetTitleDataPath(tmdTitleID));

Movie::g_titleID = tmdTitleID;
std::string savePath = Common::GetTitleDataPath(tmdTitleID);
if (Movie::IsRecordingInput())
{
// TODO: Check for the actual save data
if (File::Exists((savePath + "banner.bin").c_str()))
Movie::g_bClearSave = false;
else
Movie::g_bClearSave = true;
}

// TODO: Force the game to save to another location, instead of moving the user's save.
if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsStartingFromClearSave())
{
if (File::Exists((savePath + "banner.bin").c_str()))
{
if (File::Exists((savePath + "../backup/").c_str()))
{
// The last run of this game must have been to play back a movie, so their save is already backed up.
File::DeleteDirRecursively(savePath.c_str());
}
else
{
#ifdef _WIN32
MoveFile(savePath.c_str(), (savePath + "../backup/").c_str());
#else
File::CopyDir(savePath.c_str(),(savePath + "../backup/").c_str());
File::DeleteDirRecursively(savePath.c_str());
#endif
}
}
}
else if (File::Exists((savePath + "../backup/").c_str()))
{
// Delete the save made by a previous movie, and copy back the user's save.
if (File::Exists((savePath + "banner.bin").c_str()))
File::DeleteDirRecursively(savePath);
#ifdef _WIN32
MoveFile((savePath + "../backup/").c_str(), savePath.c_str());
#else
File::CopyDir((savePath + "../backup/").c_str(), savePath.c_str());
File::DeleteDirRecursively((savePath + "../backup/").c_str());
#endif
}

if(!File::Exists(tmdPath))
{
File::IOFile _pTMDFile(tmdPath, "wb");
Expand Down
122 changes: 54 additions & 68 deletions Source/Core/Core/Src/Movie.cpp
Expand Up @@ -35,6 +35,7 @@
#include "HW/EXI_Device.h"
#include "HW/EXI_Channel.h"
#include "HW/DVDInterface.h"
#include "../../Common/Src/NandPaths.h"

// large enough for just over 24 hours of single-player recording
#define MAX_DTM_LENGTH (40 * 1024 * 1024)
Expand All @@ -60,19 +61,14 @@ u64 g_currentFrame = 0, g_totalFrames = 0; // VI
u64 g_currentLagCount = 0, g_totalLagCount = 0; // just stats
u64 g_currentInputCount = 0, g_totalInputCount = 0; // just stats
u64 g_recordingStartTime; // seconds since 1970 that recording started
bool bSaveConfig = false;
bool bSkipIdle = false;
bool bDualCore = false;
bool bProgressive = false;
bool bDSPHLE = false;
bool bFastDiscSpeed = false;
bool bSaveConfig, bSkipIdle, bDualCore, bProgressive, bDSPHLE, bFastDiscSpeed = false;
bool bMemcard, g_bClearSave = false;
std::string videoBackend = "opengl";
int iCPUCore = 1;
bool bMemcard;
bool bBlankMC = false;
bool g_bDiscChange = false;
std::string g_discChange = "";
std::string author = "";
u64 g_titleID = 0;

bool g_bRecordingFromSaveState = false;
bool g_bPolled = false;
Expand All @@ -96,6 +92,10 @@ std::string GetInputDisplay()

void FrameUpdate()
{
if (IsPlayingInput() && g_currentInputCount == g_totalInputCount -1 && SConfig::GetInstance().m_PauseMovie)
{
Core::SetState(Core::CORE_PAUSE);
}
g_currentFrame++;
if(!g_bPolled)
g_currentLagCount++;
Expand All @@ -105,6 +105,10 @@ void FrameUpdate()
g_totalFrames = g_currentFrame;
g_totalLagCount = g_currentLagCount;
}
if (IsPlayingInput() && IsConfigSaved())
{
SetGraphicsConfig();
}

if (g_bFrameStep)
{
Expand Down Expand Up @@ -135,11 +139,21 @@ void Init()
if (IsPlayingInput())
{
ReadHeader();
if ((strncmp((char *)tmpHeader.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str(), 6)))
{
PanicAlert("The recorded game (%s) is not the same as the selected game (%s)", tmpHeader.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str());
EndPlayInput(false);
}
}
if (IsRecordingInput())
{
GetSettings();
}
g_frameSkipCounter = g_framesToSkip;
memset(&g_padState, 0, sizeof(g_padState));
if (!tmpHeader.bFromSaveState || !IsPlayingInput())
Core::SetStateFileName("");

for (int i = 0; i < 8; ++i)
g_InputDisplay[i].clear();

Expand Down Expand Up @@ -307,9 +321,9 @@ int GetCPUMode()
return iCPUCore;
}

bool IsBlankMemcard()
bool IsStartingFromClearSave()
{
return bBlankMC;
return g_bClearSave;
}

bool IsUsingMemcard()
Expand Down Expand Up @@ -376,19 +390,17 @@ bool BeginRecordingInput(int controllers)

State::SaveAs(tmpStateFilename.c_str());
g_bRecordingFromSaveState = true;

// This is only done here if starting from save state because otherwise we won't have the titleid. Otherwise it's set in WII_IPC_HLE_Device_es.cpp.
// TODO: find a way to GetTitleDataPath() from Movie::Init()
if (File::Exists((Common::GetTitleDataPath(g_titleID) + "banner.bin").c_str()))
Movie::g_bClearSave = false;
else
Movie::g_bClearSave = true;
}
g_playMode = MODE_RECORDING;

bSkipIdle = SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle;
bDualCore = SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread;
bProgressive = SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive;
bDSPHLE = SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE;
bFastDiscSpeed = SConfig::GetInstance().m_LocalCoreStartupParameter.bFastDiscSpeed;
videoBackend = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend;
iCPUCore = SConfig::GetInstance().m_LocalCoreStartupParameter.iCPUCore;
bBlankMC = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
bMemcard = SConfig::GetInstance().m_EXIDevice[0] == EXIDEVICE_MEMORYCARD;

GetSettings();
author = SConfig::GetInstance().m_strMovieAuthor;
delete [] tmpInput;
tmpInput = new u8[MAX_DTM_LENGTH];
g_currentByte = g_totalBytes = 0;
Expand Down Expand Up @@ -475,15 +487,6 @@ void SetInputDisplayString(ControllerState padState, int controllerID)
if(g_padState.DPadRight)
g_InputDisplay[controllerID].append(" RIGHT");

//if(g_padState.L)
//{
// g_InputDisplay[controllerID].append(" L");
//}
//if(g_padState.R)
//{
// g_InputDisplay[controllerID].append(" R");
//}

Analog1DToString(g_padState.TriggerL, " L", inp);
g_InputDisplay[controllerID].append(inp);

Expand Down Expand Up @@ -550,8 +553,6 @@ void SetWiiInputDisplayString(int remoteID, u8* const coreData, u8* const accelD
g_InputDisplay[controllerID].append("\n");
}



void RecordInput(SPADStatus *PadStatus, int controllerID)
{
if(!IsRecordingInput() || !IsUsingPad(controllerID))
Expand Down Expand Up @@ -628,24 +629,16 @@ void ReadHeader()
bDSPHLE = tmpHeader.bDSPHLE;
bFastDiscSpeed = tmpHeader.bFastDiscSpeed;
iCPUCore = tmpHeader.CPUCore;
bBlankMC = tmpHeader.bBlankMC;
g_bClearSave = tmpHeader.bClearSave;
bMemcard = tmpHeader.bMemcard;

}
else
{
GetSettings();
bSaveConfig = false;
bSkipIdle = SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle;
bDualCore = SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread;
bProgressive = SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive;
bDSPHLE = SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE;
bFastDiscSpeed = SConfig::GetInstance().m_LocalCoreStartupParameter.bFastDiscSpeed;
videoBackend = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend;
bBlankMC = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
bMemcard = SConfig::GetInstance().m_EXIDevice[0] == EXIDEVICE_MEMORYCARD;
}


videoBackend.resize(ARRAYSIZE(tmpHeader.videoBackend));
for (int i = 0; i < ARRAYSIZE(tmpHeader.videoBackend);i++)
{
Expand Down Expand Up @@ -695,19 +688,6 @@ bool PlayInput(const char *filename)
Movie::LoadInput(filename);
}

/* TODO: Put this verification somewhere we have the gameID of the played game
// TODO: Replace with Unique ID
if(tmpHeader.uniqueID != 0) {
PanicAlert("Recording Unique ID Verification Failed");
goto cleanup;
}
if(strncmp((char *)tmpHeader.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str(), 6)) {
PanicAlert("The recorded game (%s) is not the same as the selected game (%s)", header.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str());
goto cleanup;
}
*/

ReadHeader();
g_totalFrames = tmpHeader.frameCount;
g_totalLagCount = tmpHeader.lagCount;
Expand Down Expand Up @@ -762,11 +742,8 @@ void LoadInput(const char *filename)
ReadHeader();
if (!g_bReadOnly)
{
if (g_rerecords > tmpHeader.numRerecords)
{
tmpHeader.numRerecords = g_rerecords;
}
tmpHeader.numRerecords++;
g_rerecords++;
tmpHeader.numRerecords = g_rerecords;
t_record.Seek(0, SEEK_SET);
t_record.WriteArray(&tmpHeader, 1);
}
Expand Down Expand Up @@ -892,10 +869,6 @@ void PlayController(SPADStatus *PadStatus, int controllerID)
if (!IsPlayingInput() || !IsUsingPad(controllerID) || tmpInput == NULL)
return;

if (IsConfigSaved())
{
SetGraphicsConfig();
}
if (g_currentFrame == 1)
{
if (tmpHeader.bMemcard)
Expand All @@ -915,8 +888,7 @@ void PlayController(SPADStatus *PadStatus, int controllerID)
return;
}

// dtm files don't save the mic button or error bit. not sure if they're actually
// used, but better safe than sorry
// dtm files don't save the mic button or error bit. not sure if they're actually used, but better safe than sorry
signed char e = PadStatus->err;
memset(PadStatus, 0, sizeof(SPADStatus));
PadStatus->err = e;
Expand Down Expand Up @@ -992,7 +964,6 @@ void PlayController(SPADStatus *PadStatus, int controllerID)
}
else
{
Core::SetState(Core::CORE_PAUSE);
PanicAlert("Change the disc to %s", g_discChange.c_str());
}
}
Expand Down Expand Up @@ -1104,7 +1075,7 @@ void SaveRecording(const char *filename)
header.bUseXFB = g_ActiveConfig.bUseXFB;
header.bUseRealXFB = g_ActiveConfig.bUseRealXFB;
header.bMemcard = bMemcard;
header.bBlankMC = bBlankMC;
header.bClearSave = g_bClearSave;
strncpy((char *)header.discChange, g_discChange.c_str(),ARRAYSIZE(header.discChange));
strncpy((char *)header.author, author.c_str(),ARRAYSIZE(header.author));

Expand Down Expand Up @@ -1150,4 +1121,19 @@ void SetGraphicsConfig()
g_Config.bUseXFB = tmpHeader.bUseXFB;
g_Config.bUseRealXFB = tmpHeader.bUseRealXFB;
}

void GetSettings()
{
bSaveConfig = true;
bSkipIdle = SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle;
bDualCore = SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread;
bProgressive = SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressive;
bDSPHLE = SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE;
bFastDiscSpeed = SConfig::GetInstance().m_LocalCoreStartupParameter.bFastDiscSpeed;
videoBackend = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend;
iCPUCore = SConfig::GetInstance().m_LocalCoreStartupParameter.iCPUCore;
if (!Core::g_CoreStartupParameter.bWii)
g_bClearSave = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
bMemcard = SConfig::GetInstance().m_EXIDevice[0] == EXIDEVICE_MEMORYCARD;
}
};

0 comments on commit 3a8e8af

Please sign in to comment.