mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-23 16:19:44 +00:00
Parse PARAM.SFO to get the disc ID, show in title bar on Windows
This commit is contained in:
parent
6102e0f143
commit
a5e35ad6d9
@ -588,6 +588,8 @@ add_library(${CoreLibName} ${CoreLinkType}
|
||||
Core/ELF/ElfTypes.h
|
||||
Core/ELF/PrxDecrypter.cpp
|
||||
Core/ELF/PrxDecrypter.h
|
||||
Core/ELF/ParamSFO.cpp
|
||||
Core/ELF/ParamSFO.h
|
||||
Core/FileSystems/BlockDevices.cpp
|
||||
Core/FileSystems/BlockDevices.h
|
||||
Core/FileSystems/DirectoryFileSystem.cpp
|
||||
|
@ -13,6 +13,7 @@ set(SRCS
|
||||
MIPS/MIPSVFPUUtils.cpp
|
||||
MIPS/JitCommon/JitCommon.cpp
|
||||
ELF/ElfReader.cpp
|
||||
ELF/ParamSFO.cpp
|
||||
ELF/PrxDecrypter.cpp
|
||||
HLE/HLE.cpp
|
||||
HLE/HLETables.cpp
|
||||
|
@ -120,6 +120,7 @@
|
||||
<ClCompile Include="Debugger\Breakpoints.cpp" />
|
||||
<ClCompile Include="Debugger\SymbolMap.cpp" />
|
||||
<ClCompile Include="ELF\ElfReader.cpp" />
|
||||
<ClCompile Include="ELF\ParamSFO.cpp" />
|
||||
<ClCompile Include="ELF\PrxDecrypter.cpp" />
|
||||
<ClCompile Include="FileSystems\BlockDevices.cpp" />
|
||||
<ClCompile Include="FileSystems\DirectoryFileSystem.cpp" />
|
||||
@ -251,6 +252,7 @@
|
||||
<ClInclude Include="Debugger\SymbolMap.h" />
|
||||
<ClInclude Include="ELF\ElfReader.h" />
|
||||
<ClInclude Include="ELF\ElfTypes.h" />
|
||||
<ClInclude Include="ELF\ParamSFO.h" />
|
||||
<ClInclude Include="ELF\PrxDecrypter.h" />
|
||||
<ClInclude Include="FileSystems\BlockDevices.h" />
|
||||
<ClInclude Include="FileSystems\DirectoryFileSystem.h" />
|
||||
|
@ -300,6 +300,9 @@
|
||||
<ClCompile Include="HLE\sceFont.cpp">
|
||||
<Filter>HLE\Libraries</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ELF\ParamSFO.cpp">
|
||||
<Filter>ELF</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
@ -548,6 +551,9 @@
|
||||
<ClInclude Include="HLE\sceFont.h">
|
||||
<Filter>HLE\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ELF\ParamSFO.h">
|
||||
<Filter>ELF</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
93
Core/ELF/ParamSFO.cpp
Normal file
93
Core/ELF/ParamSFO.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "../Globals.h"
|
||||
#include "ParamSFO.h"
|
||||
|
||||
struct Header
|
||||
{
|
||||
u32 magic; /* Always PSF */
|
||||
u32 version; /* Usually 1.1 */
|
||||
u32 key_table_start; /* Start position of key_table */
|
||||
u32 data_table_start; /* Start position of data_table */
|
||||
u32 index_table_entries; /* Number of entries in index_table*/
|
||||
};
|
||||
|
||||
struct IndexTable
|
||||
{
|
||||
u16 key_table_offset; /* Offset of the param_key from start of key_table */
|
||||
u16 param_fmt; /* Type of data of param_data in the data_table */
|
||||
u32 param_len; /* Used Bytes by param_data in the data_table */
|
||||
u32 param_max_len; /* Total bytes reserved for param_data in the data_table */
|
||||
u32 data_table_offset; /* Offset of the param_data from start of data_table */
|
||||
};
|
||||
|
||||
void ParseDataString(const char *key, const char *utfdata, ParamSFOData *sfodata)
|
||||
{
|
||||
if (!strcmp(key, "DISC_ID"))
|
||||
{
|
||||
sfodata->discID = utfdata;
|
||||
}
|
||||
}
|
||||
|
||||
// I'm so sorry Ced but this is highly endian unsafe :(
|
||||
bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data)
|
||||
{
|
||||
const Header *header = (const Header *)paramsfo;
|
||||
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++)
|
||||
{
|
||||
const char *key = (const char *)(key_start + indexTables[i].key_table_offset);
|
||||
|
||||
switch (indexTables[i].param_fmt) {
|
||||
case 0x0404:
|
||||
{
|
||||
// Unsigned int
|
||||
const u32 *data = (const u32 *)(data_start + indexTables[i].data_table_offset);
|
||||
DEBUG_LOG(LOADER, "%s %08x", key, *data);
|
||||
}
|
||||
break;
|
||||
case 0x0004:
|
||||
// Special format UTF-8
|
||||
{
|
||||
const char *utfdata = (const char *)(data_start + indexTables[i].data_table_offset);
|
||||
DEBUG_LOG(LOADER, "%s %s", key, utfdata);
|
||||
ParseDataString(key, utfdata, data);
|
||||
}
|
||||
break;
|
||||
case 0x0204:
|
||||
// Regular UTF-8
|
||||
{
|
||||
const char *utfdata = (const char *)(data_start + indexTables[i].data_table_offset);
|
||||
DEBUG_LOG(LOADER, "%s %s", key, utfdata);
|
||||
ParseDataString(key, utfdata, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
27
Core/ELF/ParamSFO.h
Normal file
27
Core/ELF/ParamSFO.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
struct ParamSFOData
|
||||
{
|
||||
std::string discID;
|
||||
};
|
||||
|
||||
bool ParseParamSFO(const u8 *paramsfo, size_t size, ParamSFOData *data);
|
@ -58,6 +58,7 @@ public:
|
||||
|
||||
virtual bool IsDebuggingEnabled() {return true;}
|
||||
virtual bool AttemptLoadSymbolMap() {return false;}
|
||||
virtual void SetWindowTitle(const char *message) {}
|
||||
};
|
||||
|
||||
extern Host *host;
|
||||
|
@ -950,7 +950,7 @@ int MIPSInterpret_RunUntil(u64 globalTicks)
|
||||
// int cycles = 0;
|
||||
{
|
||||
again:
|
||||
u32 op = Memory::ReadUnchecked_U32(curMips->pc);
|
||||
u32 op = Memory::Read_U32(curMips->pc);
|
||||
//u32 op = Memory::Read_Opcode_JIT(mipsr4k.pc);
|
||||
/*
|
||||
// Choke on VFPU
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "HLE/sceKernelThread.h"
|
||||
#include "HLE/sceKernelModule.h"
|
||||
#include "HLE/sceKernelMemory.h"
|
||||
|
||||
#include "ELF/ParamSFO.h"
|
||||
|
||||
BlockDevice *constructBlockDevice(const char *filename)
|
||||
{
|
||||
@ -52,10 +52,13 @@ BlockDevice *constructBlockDevice(const char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Load_PSP_ISO(const char *filename, std::string *error_string)
|
||||
{
|
||||
ISOFileSystem *umd2 = new ISOFileSystem(&pspFileSystem, constructBlockDevice(filename));
|
||||
|
||||
// Parse PARAM.SFO
|
||||
|
||||
//pspFileSystem.Mount("host0:",umd2);
|
||||
pspFileSystem.Mount("umd0:", umd2);
|
||||
pspFileSystem.Mount("umd1:", umd2);
|
||||
@ -66,6 +69,24 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string)
|
||||
pspFileSystem.Mount("DISC0:", umd2);
|
||||
pspFileSystem.Mount("UMD:", umd2);
|
||||
|
||||
std::string sfoPath("disc0:/PSP_GAME/PARAM.SFO");
|
||||
PSPFileInfo fileInfo = pspFileSystem.GetFileInfo(sfoPath.c_str());
|
||||
if (fileInfo.exists)
|
||||
{
|
||||
u8 *paramsfo = new u8[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))
|
||||
{
|
||||
INFO_LOG(LOADER, "Disc ID: %s", data.discID.c_str());
|
||||
host->SetWindowTitle(data.discID.c_str());
|
||||
}
|
||||
delete [] paramsfo;
|
||||
}
|
||||
|
||||
|
||||
std::string bootpath("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN");
|
||||
// bypass patchers
|
||||
if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.OLD").exists) {
|
||||
@ -80,6 +101,7 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string)
|
||||
if (memcmp(head, "~PSP", 4) == 0 || memcmp(head, "\x7F""ELF", 4) == 0) {
|
||||
hasEncrypted = true;
|
||||
}
|
||||
pspFileSystem.CloseFile(fd);
|
||||
}
|
||||
if (!hasEncrypted)
|
||||
{
|
||||
|
@ -35,6 +35,13 @@ void WindowsHost::ShutdownGL()
|
||||
GL_Shutdown();
|
||||
}
|
||||
|
||||
void WindowsHost::SetWindowTitle(const char *message)
|
||||
{
|
||||
// Really need a better way to deal with versions.
|
||||
std::string title = "PPSSPP v0.31 - ";
|
||||
title += message;
|
||||
SetWindowText(mainWindow_, title.c_str());
|
||||
}
|
||||
|
||||
void WindowsHost::InitSound(PMixer *mixer)
|
||||
{
|
||||
|
@ -6,9 +6,10 @@
|
||||
class WindowsHost : public Host
|
||||
{
|
||||
public:
|
||||
WindowsHost(HWND _displayWindow)
|
||||
WindowsHost(HWND mainWindow, HWND displayWindow)
|
||||
{
|
||||
displayWindow = _displayWindow;
|
||||
mainWindow_ = mainWindow;
|
||||
displayWindow_ = displayWindow;
|
||||
input = getInputDevices();
|
||||
}
|
||||
void UpdateMemView();
|
||||
@ -31,8 +32,10 @@ public:
|
||||
void BootDone();
|
||||
void PrepareShutdown();
|
||||
bool AttemptLoadSymbolMap();
|
||||
void SetWindowTitle(const char *message);
|
||||
|
||||
private:
|
||||
HWND displayWindow;
|
||||
HWND displayWindow_;
|
||||
HWND mainWindow_;
|
||||
std::list<std::shared_ptr<InputDevice>> input;
|
||||
};
|
@ -75,12 +75,12 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
|
||||
InitCommonControlsEx(&comm);
|
||||
|
||||
MainWindow::Init(_hInstance);
|
||||
host = new WindowsHost(MainWindow::GetDisplayHWND());
|
||||
|
||||
HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS);
|
||||
g_hPopupMenus = LoadMenu(_hInstance, (LPCSTR)IDR_POPUPMENUS);
|
||||
|
||||
MainWindow::Show(_hInstance, iCmdShow);
|
||||
host = new WindowsHost(MainWindow::GetHWND(), MainWindow::GetDisplayHWND());
|
||||
|
||||
HWND hwndMain = MainWindow::GetHWND();
|
||||
HMENU menu = GetMenu(hwndMain);
|
||||
|
@ -80,6 +80,7 @@ LOCAL_SRC_FILES := \
|
||||
$(SRC)/GPU/Null/NullGpu.cpp \
|
||||
$(SRC)/Core/ELF/ElfReader.cpp \
|
||||
$(SRC)/Core/ELF/PrxDecrypter.cpp \
|
||||
$(SRC)/Core/ELF/ParamSFO.cpp \
|
||||
$(SRC)/Core/HW/MemoryStick.cpp \
|
||||
$(SRC)/Core/Core.cpp \
|
||||
$(SRC)/Core/Config.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user