Also get TITLE from PARAM.SFO

This commit is contained in:
Henrik Rydgard 2012-11-30 22:32:15 +01:00
parent e255550a8e
commit 1189da826c
3 changed files with 14 additions and 10 deletions

View File

@ -38,9 +38,10 @@ struct IndexTable
void ParseDataString(const char *key, const char *utfdata, ParamSFOData *sfodata)
{
if (!strcmp(key, "DISC_ID"))
{
if (!strcmp(key, "DISC_ID")) {
sfodata->discID = utfdata;
} else if (!strcmp(key, "TITLE")) {
sfodata->title = utfdata;
}
}
@ -48,17 +49,17 @@ void ParseDataString(const char *key, const char *utfdata, ParamSFOData *sfodata
bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data)
{
const Header *header = (const Header *)paramsfo;
if (header->magic != 0x46535000)
if (header->magic != 0x46535000)
return false;
if (header->version != 0x00000101)
WARN_LOG(LOADER, "Unexpected SFO header version: %08x", header->version);
const IndexTable *indexTables = (const IndexTable *)(paramsfo + sizeof(Header));
const u8 *key_start = paramsfo + header->key_table_start;
const u8 *data_start = paramsfo + header->data_table_start;
for (int i = 0; i < header->index_table_entries; i++)
for (int i = 0; i < header->index_table_entries; i++)
{
const char *key = (const char *)(key_start + indexTables[i].key_table_offset);
@ -69,7 +70,7 @@ bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data)
const u32 *data = (const u32 *)(data_start + indexTables[i].data_table_offset);
DEBUG_LOG(LOADER, "%s %08x", key, *data);
}
break;
break;
case 0x0004:
// Special format UTF-8
{

View File

@ -22,6 +22,7 @@
struct ParamSFOData
{
std::string discID;
std::string title; // utf-8
};
bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data);

View File

@ -73,15 +73,17 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string)
PSPFileInfo fileInfo = pspFileSystem.GetFileInfo(sfoPath.c_str());
if (fileInfo.exists)
{
u8 *paramsfo = new u8[fileInfo.size];
u8 *paramsfo = new u8[(size_t)fileInfo.size];
u32 fd = pspFileSystem.OpenFile(sfoPath, FILEACCESS_READ);
pspFileSystem.ReadFile(fd, paramsfo, fileInfo.size);
pspFileSystem.CloseFile(fd);
ParamSFOData data;
if (ParseParamSFO(paramsfo, fileInfo.size, &data))
if (ParseParamSFO(paramsfo, (size_t)fileInfo.size, &data))
{
INFO_LOG(LOADER, "Disc ID: %s", data.discID.c_str());
host->SetWindowTitle(data.discID.c_str());
char title[1024];
sprintf(title, "%s : %s", data.discID.c_str(), data.title.c_str());
INFO_LOG(LOADER, "%s", title);
host->SetWindowTitle(title);
}
delete [] paramsfo;
}