save if a wii game's save data exists when starting recording. Probably not the best way to do this, and could result in a false negative if banner.bin exists, but the actual save file doesn't, but this should work well enough.

This commit is contained in:
rog 2012-10-25 02:44:30 -04:00
parent 8dfb12da3e
commit 0bc2021284
5 changed files with 35 additions and 18 deletions

View File

@ -123,7 +123,7 @@ bool BootCore(const std::string& _rFilename)
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");

View File

@ -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::IsUsingMemcard() && Movie::IsPlayingInput() && Movie::IsConfigSaved() && 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

View File

@ -57,6 +57,7 @@
#include "NandPaths.h"
#include "CommonPaths.h"
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "../Movie.h"
std::string CWII_IPC_HLE_Device_es::m_ContentFile;
@ -891,6 +892,16 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)
File::CreateFullPath(tmdPath);
File::CreateFullPath(Common::GetTitleDataPath(tmdTitleID));
Movie::g_titleID = tmdTitleID;
if (Movie::IsRecordingInput())
{
// TODO: Check for the actual save data
if (File::Exists((Common::GetTitleDataPath(tmdTitleID) + "banner.bin").c_str()))
Movie::g_bClearSave = false;
else
Movie::g_bClearSave = true;
}
if(!File::Exists(tmdPath))
{
File::IOFile _pTMDFile(tmdPath, "wb");

View File

@ -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)
@ -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;
@ -324,9 +320,9 @@ int GetCPUMode()
return iCPUCore;
}
bool IsBlankMemcard()
bool IsStartingFromClearSave()
{
return bBlankMC;
return g_bClearSave;
}
bool IsUsingMemcard()
@ -393,6 +389,14 @@ 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.
// If not starting from save state, it's set in WII_IPC_HLE_Device_es.cpp. There's probably a way to get this in Movie::Init, but i can't find one.
// 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;
GetSettings();
@ -626,7 +630,7 @@ void ReadHeader()
bDSPHLE = tmpHeader.bDSPHLE;
bFastDiscSpeed = tmpHeader.bFastDiscSpeed;
iCPUCore = tmpHeader.CPUCore;
bBlankMC = tmpHeader.bBlankMC;
g_bClearSave = tmpHeader.bClearSave;
bMemcard = tmpHeader.bMemcard;
}
@ -1078,7 +1082,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));
// TODO: prompt the user for author name. It's currently always blank, unless the user manually edits the .dtm file.
strncpy((char *)header.author, author.c_str(),ARRAYSIZE(header.author));
@ -1136,7 +1140,8 @@ void GetSettings()
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);
if (!Core::g_CoreStartupParameter.bWii)
g_bClearSave = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
bMemcard = SConfig::GetInstance().m_EXIDevice[0] == EXIDEVICE_MEMORYCARD;
}
};

View File

@ -61,8 +61,9 @@ static_assert(sizeof(ControllerState) == 8, "ControllerState should be 8 bytes")
#pragma pack(pop)
// Global declarations
extern bool g_bFrameStep, g_bPolled, g_bReadOnly, g_bDiscChange;
extern bool g_bFrameStep, g_bPolled, g_bReadOnly, g_bDiscChange, g_bClearSave;
extern PlayMode g_playMode;
extern u64 g_titleID;
extern u32 g_framesToSkip, g_frameSkipCounter;
@ -117,7 +118,7 @@ struct DTMHeader {
bool bUseXFB;
bool bUseRealXFB;
bool bMemcard;
bool bBlankMC; // Create a new memory card when playing back a movie if true
bool bClearSave; // Create a new memory card when playing back a movie if true
u8 reserved[16]; // Padding for any new config options
u8 discChange[40]; // Name of iso file to switch to, for two disc games.
u8 reserved2[47]; // Make heading 256 bytes, just because we can
@ -148,7 +149,7 @@ bool IsSkipIdle();
bool IsDSPHLE();
bool IsFastDiscSpeed();
int GetCPUMode();
bool IsBlankMemcard();
bool IsStartingFromClearSave();
bool IsUsingMemcard();
void SetGraphicsConfig();
void GetSettings();