Merge pull request #2878 from unknownbrackets/ccc

Fix UTF-16 surrogate pairs and sceCccEncodeUTF16() return value
This commit is contained in:
Henrik Rydgård 2013-07-21 13:13:48 -07:00
commit 13b02739ae
5 changed files with 16 additions and 14 deletions

View File

@ -289,7 +289,7 @@ int sceCccStrlenSJIS(u32 strAddr)
return ShiftJIS(str).length();
}
int sceCccEncodeUTF8(u32 dstAddrAddr, u32 ucs)
u32 sceCccEncodeUTF8(u32 dstAddrAddr, u32 ucs)
{
PSPPointer<PSPCharPointer> dstp;
dstp = dstAddrAddr;
@ -304,7 +304,7 @@ int sceCccEncodeUTF8(u32 dstAddrAddr, u32 ucs)
return dstp->ptr;
}
int sceCccEncodeUTF16(u32 dstAddrAddr, u32 ucs)
void sceCccEncodeUTF16(u32 dstAddrAddr, u32 ucs)
{
PSPPointer<PSPWCharPointer> dstp;
dstp = dstAddrAddr;
@ -312,14 +312,16 @@ int sceCccEncodeUTF16(u32 dstAddrAddr, u32 ucs)
if (!dstp.IsValid() || !dstp->IsValid())
{
ERROR_LOG(HLE, "sceCccEncodeUTF16(%08x, U+%04x): invalid pointer", dstAddrAddr, ucs);
return 0;
return;
}
DEBUG_LOG(HLE, "sceCccEncodeUTF16(%08x, U+%04x)", dstAddrAddr, ucs);
// Anything above 0x10FFFF is unencodable, and 0xD800 - 0xDFFF are reserved for surrogate pairs.
if (ucs > 0x10FFFF || (ucs & 0xD800) == 0xD800)
ucs = errorUTF16;
*dstp += UTF16LE::encode(*dstp, ucs);
return dstp->ptr;
}
int sceCccEncodeSJIS(u32 dstAddrAddr, u32 jis)
u32 sceCccEncodeSJIS(u32 dstAddrAddr, u32 jis)
{
PSPPointer<PSPCharPointer> dstp;
dstp = dstAddrAddr;
@ -498,9 +500,9 @@ const HLEFunction sceCcc[] =
{0xb7d3c112, WrapI_U<sceCccStrlenUTF8>, "sceCccStrlenUTF8"},
{0x4BDEB2A8, WrapI_U<sceCccStrlenUTF16>, "sceCccStrlenUTF16"},
{0xd9392ccb, WrapI_U<sceCccStrlenSJIS>, "sceCccStrlenSJIS"},
{0x92C05851, WrapI_UU<sceCccEncodeUTF8>, "sceCccEncodeUTF8"},
{0x8406F469, WrapI_UU<sceCccEncodeUTF16>, "sceCccEncodeUTF16"},
{0x068c4320, WrapI_UU<sceCccEncodeSJIS>, "sceCccEncodeSJIS"},
{0x92C05851, WrapU_UU<sceCccEncodeUTF8>, "sceCccEncodeUTF8"},
{0x8406F469, WrapV_UU<sceCccEncodeUTF16>, "sceCccEncodeUTF16"},
{0x068c4320, WrapU_UU<sceCccEncodeSJIS>, "sceCccEncodeSJIS"},
{0xc6a8bee2, WrapI_U<sceCccDecodeUTF8>, "sceCccDecodeUTF8"},
{0xe0cf8091, WrapI_U<sceCccDecodeUTF16>, "sceCccDecodeUTF16"},
{0x953e6c10, WrapI_U<sceCccDecodeSJIS>, "sceCccDecodeSJIS"},

View File

@ -1184,9 +1184,9 @@ u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr,
case 2: // EMULATOR_DEVCTL__SEND_OUTPUT
{
std::string data(Memory::GetCharPointer(argAddr), argLen);
if (PSP_CoreParameter().printfEmuLog) {
host->SendDebugOutput(data.c_str());
} else {
if (PSP_CoreParameter().printfEmuLog) {
host->SendDebugOutput(data);
} else {
if (PSP_CoreParameter().collectEmuLog) {
*PSP_CoreParameter().collectEmuLog += data;
} else {

View File

@ -46,7 +46,7 @@ public:
virtual bool IsDebuggingEnabled() {return false;}
virtual bool AttemptLoadSymbolMap() {return false;}
virtual void SendDebugOutput(const std::string &output) { printf("%s", output.c_str()); }
virtual void SendDebugOutput(const std::string &output) { fwrite(output.data(), sizeof(char), output.length(), stdout); }
virtual void SetComparisonScreenshot(const std::string &filename) {}

View File

@ -88,7 +88,7 @@ void WindowsHeadlessHost::LoadNativeAssets()
void WindowsHeadlessHost::SendDebugOutput(const std::string &output)
{
fprintf_s(out, "%s", output.c_str());
fwrite(output.data(), sizeof(char), output.length(), out);
OutputDebugString(output.c_str());
}

2
native

@ -1 +1 @@
Subproject commit 7421e1de67fd97918c6f0da83fc84a9679ef3464
Subproject commit dd99cfbbe808a62528cfb2f51864ad596812c1f6