Esempio n. 1
0
int sceCccSJIStoUTF16(u32 dstAddr, int dstSize, u32 srcAddr)
{
	PSPCharPointer src;
	PSPWCharPointer dst;
	dst = dstAddr;
	src = srcAddr;

	if (!dst.IsValid() || !src.IsValid())
	{
		ERROR_LOG(HLE, "sceCccSJIStoUTF16(%08x, %d, %08x): invalid pointers", dstAddr, dstSize, srcAddr);
		return 0;
	}
	if (!jis2ucsTable.IsValid())
	{
		ERROR_LOG(HLE, "sceCccSJIStoUTF16(%08x, %d, %08x): table not loaded", dstAddr, dstSize, srcAddr);
		return 0;
	}

	DEBUG_LOG(HLE, "sceCccSJIStoUTF16(%08x, %d, %08x)", dstAddr, dstSize, srcAddr);
	ShiftJIS sjis(src);
	int n = 0;
	while (u32 c = sjis.next())
	{
		dst += UTF16LE::encode(dst, __CccJIStoUCS(c, errorUTF16));
		n++;
	}
	return n;
}
Esempio n. 2
0
int sceCccSJIStoUTF16(u32 dstAddr, u32 dstSize, u32 srcAddr)
{
	const auto src = PSPConstCharPointer::Create(srcAddr);
	auto dst = PSPWCharPointer::Create(dstAddr);
	if (!dst.IsValid() || !src.IsValid())
	{
		ERROR_LOG(HLE, "sceCccSJIStoUTF16(%08x, %d, %08x): invalid pointers", dstAddr, dstSize, srcAddr);
		return 0;
	}
	if (!jis2ucsTable.IsValid())
	{
		ERROR_LOG(HLE, "sceCccSJIStoUTF16(%08x, %d, %08x): table not loaded", dstAddr, dstSize, srcAddr);
		return 0;
	}

	const auto dstEnd = PSPWCharPointer::Create(dstAddr + (dstSize & ~1));

	DEBUG_LOG(HLE, "sceCccSJIStoUTF16(%08x, %d, %08x)", dstAddr, dstSize, srcAddr);
	ShiftJIS sjis(src);
	int n = 0;
	while (u32 c = sjis.next())
	{
		if (dst + UTF16LE::encodeUnits(c) >= dstEnd)
			break;
		dst += UTF16LE::encode(dst, __CccJIStoUCS(c, errorUTF16));
		n++;
	}

	if (dst < dstEnd)
		*dst++ = 0;

	CBreakPoints::ExecMemCheck(srcAddr, false, sjis.byteIndex(), currentMIPS->pc);
	CBreakPoints::ExecMemCheck(dstAddr, true, dst.ptr - dstAddr, currentMIPS->pc);
	return n;
}
Esempio n. 3
0
u32 sceCccDecodeSJIS(u32 dstAddrAddr)
{
	auto dstp = PSPPointer<PSPCharPointer>::Create(dstAddrAddr);

	if (!dstp.IsValid() || !dstp->IsValid()) {
		ERROR_LOG(HLE, "sceCccDecodeSJIS(%08x): invalid pointer", dstAddrAddr);
		// Should crash?
		return 0;
	}

	DEBUG_LOG(HLE, "sceCccDecodeSJIS(%08x)", dstAddrAddr);
	ShiftJIS sjis(*dstp);
	u32 result = sjis.next();
	*dstp += sjis.byteIndex();

	if (result == ShiftJIS::INVALID)
		return errorSJIS;
	return result;
}