Change return value of initialize call.

Depending on version loaded by game.
This commit is contained in:
Jean-Philip Desjardins 2017-03-30 21:31:34 -04:00
parent e9cb5f0160
commit 6d9a9b469e
3 changed files with 44 additions and 1 deletions

View File

@ -287,6 +287,7 @@ void CIopBios::SaveState(Framework::CZipArchiveWriter& archive)
m_sifCmd->SaveState(archive);
m_cdvdman->SaveState(archive);
m_loadcore->SaveState(archive);
#ifdef _IOP_EMULATE_MODULES
m_fileIo->SaveState(archive);
#endif
@ -323,6 +324,7 @@ void CIopBios::LoadState(Framework::CZipArchiveReader& archive)
m_sifCmd->LoadState(archive);
m_cdvdman->LoadState(archive);
m_loadcore->LoadState(archive);
#ifdef _IOP_EMULATE_MODULES
m_fileIo->LoadState(archive);
#endif
@ -728,6 +730,7 @@ void CIopBios::ProcessModuleReset(const std::string& imagePath)
bool found = TryGetImageVersionFromPath(imagePath, &imageVersion);
if(!found) found = TryGetImageVersionFromContents(imagePath, &imageVersion);
assert(found);
m_loadcore->SetModuleVersion(imageVersion);
#ifdef _IOP_EMULATE_MODULES
m_fileIo->SetModuleVersion(imageVersion);
#endif

View File

@ -2,11 +2,15 @@
#include "Iop_Dynamic.h"
#include "IopBios.h"
#include "../Log.h"
#include "../RegisterStateFile.h"
using namespace Iop;
#define LOG_NAME "iop_loadcore"
#define STATE_VERSION_XML ("iop_loadcore/version.xml")
#define STATE_VERSION_MODULEVERSION ("moduleVersion")
#define FUNCTION_FLUSHDCACHE "FlushDcache"
#define FUNCTION_REGISTERLIBRARYENTRIES "RegisterLibraryEntries"
#define FUNCTION_QUERYBOOTMODE "QueryBootMode"
@ -22,6 +26,11 @@ CLoadcore::CLoadcore(CIopBios& bios, uint8* ram, CSifMan& sifMan)
sifMan.RegisterModule(MODULE_ID, this);
}
void CLoadcore::SetModuleVersion(unsigned int moduleVersion)
{
m_moduleVersion = moduleVersion;
}
std::string CLoadcore::GetId() const
{
return "loadcore";
@ -113,6 +122,19 @@ bool CLoadcore::Invoke(uint32 method, uint32* args, uint32 argsSize, uint32* ret
return true;
}
void CLoadcore::LoadState(Framework::CZipArchiveReader& archive)
{
auto registerFile = CRegisterStateFile(*archive.BeginReadFile(STATE_VERSION_XML));
m_moduleVersion = registerFile.GetRegister32(STATE_VERSION_MODULEVERSION);
}
void CLoadcore::SaveState(Framework::CZipArchiveWriter& archive)
{
auto registerFile = new CRegisterStateFile(STATE_VERSION_XML);
registerFile->SetRegister32(STATE_VERSION_MODULEVERSION, m_moduleVersion);
archive.InsertFile(registerFile);
}
void CLoadcore::SetLoadExecutableHandler(const LoadExecutableHandler& loadExecutableHandler)
{
m_loadExecutableHandler = loadExecutableHandler;
@ -276,5 +298,15 @@ void CLoadcore::Initialize(uint32* args, uint32 argsSize, uint32* ret, uint32 re
assert(argsSize == 0);
assert(retSize == 4);
ret[0] = 0x2E2E2E2E;
if(m_moduleVersion == 2020)
{
//Return '2020'
//This is needed by Super Bust-A-Move
ret[0] = 0x30323032;
}
else
{
//Return '....'
ret[0] = 0x2E2E2E2E;
}
}

View File

@ -2,6 +2,8 @@
#include "Iop_Module.h"
#include "Iop_SifMan.h"
#include "zip/ZipArchiveWriter.h"
#include "zip/ZipArchiveReader.h"
#include <functional>
class CIopBios;
@ -21,11 +23,16 @@ namespace Iop
CLoadcore(CIopBios&, uint8*, CSifMan&);
virtual ~CLoadcore() = default;
void SetModuleVersion(unsigned int);
std::string GetId() const override;
std::string GetFunctionName(unsigned int) const override;
void Invoke(CMIPS&, unsigned int) override;
bool Invoke(uint32, uint32*, uint32, uint32*, uint32, uint8*) override;
void LoadState(Framework::CZipArchiveReader&);
void SaveState(Framework::CZipArchiveWriter&);
void SetLoadExecutableHandler(const LoadExecutableHandler&);
private:
@ -43,6 +50,7 @@ namespace Iop
CIopBios& m_bios;
uint8* m_ram;
unsigned int m_moduleVersion = 1000;
LoadExecutableHandler m_loadExecutableHandler;
};