mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 09:48:37 +12:00
commit
b8486a489d
3 changed files with 57 additions and 30 deletions
|
@ -664,7 +664,7 @@ namespace loader
|
||||||
LOG_NOTICE(LOADER, "*** ppc seg: 0x%x", info.ppc_seg);
|
LOG_NOTICE(LOADER, "*** ppc seg: 0x%x", info.ppc_seg);
|
||||||
//LOG_NOTICE(LOADER, "*** crash dump param addr: 0x%x", info.crash_dump_param_addr);
|
//LOG_NOTICE(LOADER, "*** crash dump param addr: 0x%x", info.crash_dump_param_addr);
|
||||||
|
|
||||||
Emu.SetParams(info.sdk_version, info.malloc_pagesize, info.primary_stacksize, info.primary_prio);
|
Emu.SetParams(info.sdk_version, info.malloc_pagesize, std::max<u32>(info.primary_stacksize, 0x4000), info.primary_prio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -75,7 +75,7 @@ bool PSFLoader::Load(vfsStream& stream)
|
||||||
// load data
|
// load data
|
||||||
stream.Seek(header.off_data_table + indices[i].data_off);
|
stream.Seek(header.off_data_table + indices[i].data_off);
|
||||||
|
|
||||||
if (indices[i].param_fmt == PSF_PARAM_INT && indices[i].param_len == 4 && indices[i].param_max == 4)
|
if (indices[i].param_fmt == psf_entry_format::integer && indices[i].param_len == 4 && indices[i].param_max >= indices[i].param_len)
|
||||||
{
|
{
|
||||||
// load int data
|
// load int data
|
||||||
|
|
||||||
|
@ -84,7 +84,8 @@ bool PSFLoader::Load(vfsStream& stream)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (indices[i].param_fmt == PSF_PARAM_STR && indices[i].param_max >= indices[i].param_len)
|
else if ((indices[i].param_fmt == psf_entry_format::string || indices[i].param_fmt == psf_entry_format::string_not_null_term)
|
||||||
|
&& indices[i].param_max >= indices[i].param_len)
|
||||||
{
|
{
|
||||||
// load str data
|
// load str data
|
||||||
|
|
||||||
|
@ -143,12 +144,17 @@ bool PSFLoader::Save(vfsStream& stream) const
|
||||||
|
|
||||||
switch (m_entries[i].fmt) // calculate data size
|
switch (m_entries[i].fmt) // calculate data size
|
||||||
{
|
{
|
||||||
case PSF_PARAM_STR:
|
case psf_entry_format::string_not_null_term:
|
||||||
|
{
|
||||||
|
data_offset += (indices[i].param_len = indices[i].param_max = static_cast<u32>(m_entries[i].vstr.size()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case psf_entry_format::string:
|
||||||
{
|
{
|
||||||
data_offset += (indices[i].param_len = indices[i].param_max = static_cast<u32>(m_entries[i].vstr.size()) + 1);
|
data_offset += (indices[i].param_len = indices[i].param_max = static_cast<u32>(m_entries[i].vstr.size()) + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PSF_PARAM_INT:
|
case psf_entry_format::integer:
|
||||||
{
|
{
|
||||||
data_offset += (indices[i].param_len = indices[i].param_max = 4);
|
data_offset += (indices[i].param_len = indices[i].param_max = 4);
|
||||||
break;
|
break;
|
||||||
|
@ -190,7 +196,7 @@ bool PSFLoader::Save(vfsStream& stream) const
|
||||||
{
|
{
|
||||||
switch (entry.fmt)
|
switch (entry.fmt)
|
||||||
{
|
{
|
||||||
case PSF_PARAM_STR:
|
case psf_entry_format::string:
|
||||||
{
|
{
|
||||||
if (!stream.SWrite(entry.vstr[0], entry.vstr.size() + 1))
|
if (!stream.SWrite(entry.vstr[0], entry.vstr.size() + 1))
|
||||||
{
|
{
|
||||||
|
@ -198,7 +204,15 @@ bool PSFLoader::Save(vfsStream& stream) const
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PSF_PARAM_INT:
|
case psf_entry_format::string_not_null_term:
|
||||||
|
{
|
||||||
|
if (!stream.SWrite(entry.vstr[0], entry.vstr.size()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case psf_entry_format::integer:
|
||||||
{
|
{
|
||||||
if (!stream.SWrite(entry.vint))
|
if (!stream.SWrite(entry.vint))
|
||||||
{
|
{
|
||||||
|
@ -230,7 +244,7 @@ const PSFEntry* PSFLoader::SearchEntry(const std::string& key) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSFEntry& PSFLoader::AddEntry(const std::string& key, u16 fmt)
|
PSFEntry& PSFLoader::AddEntry(const std::string& key, psf_entry_format fmt)
|
||||||
{
|
{
|
||||||
for (auto& entry : m_entries)
|
for (auto& entry : m_entries)
|
||||||
{
|
{
|
||||||
|
@ -253,7 +267,7 @@ std::string PSFLoader::GetString(const std::string& key, std::string def) const
|
||||||
{
|
{
|
||||||
if (const auto entry = SearchEntry(key))
|
if (const auto entry = SearchEntry(key))
|
||||||
{
|
{
|
||||||
if (entry->fmt == PSF_PARAM_STR)
|
if (entry->fmt == psf_entry_format::string || entry->fmt == psf_entry_format::string_not_null_term)
|
||||||
{
|
{
|
||||||
return entry->vstr;
|
return entry->vstr;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +280,7 @@ s32 PSFLoader::GetInteger(const std::string& key, s32 def) const
|
||||||
{
|
{
|
||||||
if (const auto entry = SearchEntry(key))
|
if (const auto entry = SearchEntry(key))
|
||||||
{
|
{
|
||||||
if (entry->fmt == PSF_PARAM_INT)
|
if (entry->fmt == psf_entry_format::integer)
|
||||||
{
|
{
|
||||||
return entry->vint;
|
return entry->vint;
|
||||||
}
|
}
|
||||||
|
@ -277,10 +291,10 @@ s32 PSFLoader::GetInteger(const std::string& key, s32 def) const
|
||||||
|
|
||||||
void PSFLoader::SetString(const std::string& key, std::string value)
|
void PSFLoader::SetString(const std::string& key, std::string value)
|
||||||
{
|
{
|
||||||
AddEntry(key, PSF_PARAM_STR).vstr = value;
|
AddEntry(key, psf_entry_format::string).vstr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PSFLoader::SetInteger(const std::string& key, s32 value)
|
void PSFLoader::SetInteger(const std::string& key, s32 value)
|
||||||
{
|
{
|
||||||
AddEntry(key, PSF_PARAM_INT).vint = value;
|
AddEntry(key, psf_entry_format::integer).vint = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
|
|
||||||
struct vfsStream;
|
struct vfsStream;
|
||||||
|
|
||||||
|
enum class psf_entry_format : u16
|
||||||
|
{
|
||||||
|
string_not_null_term = 0x0004,
|
||||||
|
string = 0x0204,
|
||||||
|
integer = 0x0404,
|
||||||
|
};
|
||||||
|
|
||||||
struct PSFHeader
|
struct PSFHeader
|
||||||
{
|
{
|
||||||
u32 magic;
|
u32 magic;
|
||||||
|
@ -14,22 +21,15 @@ struct PSFHeader
|
||||||
struct PSFDefTable
|
struct PSFDefTable
|
||||||
{
|
{
|
||||||
u16 key_off;
|
u16 key_off;
|
||||||
u16 param_fmt;
|
psf_entry_format param_fmt;
|
||||||
u32 param_len;
|
u32 param_len;
|
||||||
u32 param_max;
|
u32 param_max;
|
||||||
u32 data_off;
|
u32 data_off;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum : u16
|
|
||||||
{
|
|
||||||
PSF_PARAM_UNK = 0x0004,
|
|
||||||
PSF_PARAM_STR = 0x0204,
|
|
||||||
PSF_PARAM_INT = 0x0404,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PSFEntry
|
struct PSFEntry
|
||||||
{
|
{
|
||||||
u16 fmt;
|
psf_entry_format fmt;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
s32 vint;
|
s32 vint;
|
||||||
|
@ -51,25 +51,38 @@ public:
|
||||||
virtual ~PSFLoader() = default;
|
virtual ~PSFLoader() = default;
|
||||||
|
|
||||||
bool Load(vfsStream& stream);
|
bool Load(vfsStream& stream);
|
||||||
|
|
||||||
bool Save(vfsStream& stream) const;
|
bool Save(vfsStream& stream) const;
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
operator bool() const
|
explicit operator bool() const
|
||||||
{
|
{
|
||||||
return !m_entries.empty();
|
return !m_entries.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
const PSFEntry* SearchEntry(const std::string& key) const;
|
const PSFEntry* SearchEntry(const std::string& key) const;
|
||||||
|
PSFEntry& AddEntry(const std::string& key, psf_entry_format format);
|
||||||
PSFEntry& AddEntry(const std::string& key, u16 type);
|
|
||||||
|
|
||||||
std::string GetString(const std::string& key, std::string def = "") const;
|
std::string GetString(const std::string& key, std::string def = "") const;
|
||||||
|
|
||||||
s32 GetInteger(const std::string& key, s32 def = 0) const;
|
s32 GetInteger(const std::string& key, s32 def = 0) const;
|
||||||
|
|
||||||
void SetString(const std::string& key, std::string value);
|
void SetString(const std::string& key, std::string value);
|
||||||
|
|
||||||
void SetInteger(const std::string& key, s32 value);
|
void SetInteger(const std::string& key, s32 value);
|
||||||
|
|
||||||
|
std::vector<PSFEntry>& entries()
|
||||||
|
{
|
||||||
|
return m_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<PSFEntry>& entries() const
|
||||||
|
{
|
||||||
|
return m_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<PSFEntry>::iterator begin()
|
||||||
|
{
|
||||||
|
return m_entries.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<PSFEntry>::iterator end()
|
||||||
|
{
|
||||||
|
return m_entries.end();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue