From 604a97bf50edce741c86f36db29f06c363cc43f0 Mon Sep 17 00:00:00 2001 From: kaienfr Date: Thu, 10 Apr 2014 05:19:03 +0200 Subject: [PATCH] Custom BGM is fixed Based on this commit https://github.com/hrydgard/ppsspp/pull/5828 on improvements to sceMp3 Custom BGM can be update now. Test on "Miku" is just all right :) --- Core/HLE/sceIo.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 2024a7a7f6..fdf7075460 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -1937,7 +1937,26 @@ u32 sceIoDread(int id, u32 dirent_addr) { strncpy(entry->d_name, info.name.c_str(), 256); entry->d_name[255] = '\0'; - entry->d_private = 0xC0DEBABE; + // write d_private for supporting Custom BGM + // ref JPCSP https://code.google.com/p/jpcsp/source/detail?r=3468 + if (Memory::IsValidAddress(entry->d_private)){ + if (sceKernelGetCompiledSdkVersion() <= 0x0307FFFF){ + // d_private is pointing to an area of unknown size + // - [0..12] "8.3" file name (null-terminated), could be empty. + // - [13..???] long file name (null-terminated) + strncpy((char*)Memory::GetPointer(entry->d_private + 13), (const char*)entry->d_name, ARRAY_SIZE(entry->d_name)); + } + else { + // d_private is pointing to an area of total size 1044 + // - [0..3] size of area + // - [4..19] "8.3" file name (null-terminated), could be empty. + // - [20..???] long file name (null-terminated) + auto size = Memory::Read_U32(entry->d_private); + if (size >= 1044) { + strncpy((char*)Memory::GetPointer(entry->d_private + 20), (const char*)entry->d_name, ARRAY_SIZE(entry->d_name)); + } + } + } DEBUG_LOG(SCEIO, "sceIoDread( %d %08x ) = %s", id, dirent_addr, entry->d_name); // TODO: Improve timing. Only happens on the *first* entry read, ms and umd.