From 1189da826ca8c4fc09e909f661de9069cd57c904 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 30 Nov 2012 22:32:15 +0100 Subject: [PATCH] Also get TITLE from PARAM.SFO --- Core/ELF/ParamSFO.cpp | 13 +++++++------ Core/ELF/ParamSFO.h | 1 + Core/PSPLoaders.cpp | 10 ++++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Core/ELF/ParamSFO.cpp b/Core/ELF/ParamSFO.cpp index 32395e6b74..9119f162a5 100644 --- a/Core/ELF/ParamSFO.cpp +++ b/Core/ELF/ParamSFO.cpp @@ -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 { diff --git a/Core/ELF/ParamSFO.h b/Core/ELF/ParamSFO.h index 7840513604..f92bef1a5a 100644 --- a/Core/ELF/ParamSFO.h +++ b/Core/ELF/ParamSFO.h @@ -22,6 +22,7 @@ struct ParamSFOData { std::string discID; + std::string title; // utf-8 }; bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data); \ No newline at end of file diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index 22b0aa5d15..ae628e760a 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -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; }