CGBASupport: Add version differences for korean release

Former-commit-id: 87a74c0b48
This commit is contained in:
Phillip Stephens 2022-10-16 13:54:59 -07:00
parent 0fbdb1f381
commit dd5e5fb342
1 changed files with 42 additions and 5 deletions

View File

@ -8,13 +8,20 @@
#include "rstl/math.hpp"
void joyboot_callback(s32 chan, s32 ret) {}
#if VERSION < 2
const uint MAGIC = 0x414d5445;
#endif
static CGBASupport* g_GBA;
inline bool GetFontEncoding() { return OSGetFontEncode() == 1; }
CGBASupport::CGBASupport()
#if VERSION >= 2
: x0_file(GetFontEncoding() ? "client_jap.bin" : "client_pad.bin")
#else
: x0_file("client_pad.bin")
#endif
, x28_fileSize(OSRoundUp32B(x0_file.Length()))
, x2c_buffer((uchar*)CMemory::Alloc(x28_fileSize, IAllocator::kHI_RoundUpLen))
, x30_dvdReq(x0_file.SyncRead(x2c_buffer.get(), x28_fileSize))
@ -26,6 +33,9 @@ CGBASupport::CGBASupport()
, x45_fusionBeat(false) {
GBAInit();
g_GBA = this;
#if VERSION >= 2
OSGetFontEncode();
#endif
}
CGBASupport::~CGBASupport() { g_GBA = nullptr; }
@ -56,8 +66,18 @@ inline bool CGBASupport::CheckReadyStatus() {
buff[0xc9] = (tick >> 8);
buff[0xca] = (tick >> 16);
buff[0xcb] = (tick >> 24);
#if VERSION < 2
buff[0xaf] = 'E'; // set region to 'E' instead of 'J'
buff[0xbd] = 0xc9;
#else
if (GetFontEncoding()) {
buff[0xaf] = 'J'; // set region to 'E' instead of 'J'
buff[0xbd] = 0xc4;
} else {
buff[0xaf] = 'E'; // set region to 'E' instead of 'J'
buff[0xbd] = 0xc9;
}
#endif
return true;
}
return false;
@ -97,8 +117,8 @@ void CGBASupport::Update(float dt) {
case kP_StartJoyBusBoot:
x34_phase = kP_PollJoyBusBoot;
GBAJoyBootAsync(x40_siChan, x40_siChan << 1, 2, x2c_buffer.get(), x0_file.Length(),
&x3c_status, &joyboot_callback);
GBAJoyBootAsync(x40_siChan, x40_siChan << 1, 2, x2c_buffer.get(), x0_file.Length(), &x3c_status,
&joyboot_callback);
break;
case kP_PollJoyBusBoot:
@ -161,22 +181,39 @@ bool CGBASupport::PollResponse() {
if (gbaStatus != 0x28) {
return false;
}
#if VERSION >= 2
const uint targetMagic = GetFontEncoding() ? 0x414D544A : 0x414D5445;
#endif
uint magic;
if (GBARead(x40_siChan, reinterpret_cast<u8*>(&magic), &gbaStatus) == GBA_NOT_READY) {
if (GBARead(x40_siChan, (u8*)(&magic), &gbaStatus) == GBA_NOT_READY) {
return false;
}
#if VERSION < 2
if (magic != 0x414d5445) { // "AMTE"
return false;
}
#else
if (magic != targetMagic) { // "AMTE"
return false;
}
#endif
if (GBAGetStatus(x40_siChan, &gbaStatus) == GBA_NOT_READY) {
return false;
}
if (gbaStatus != 0x20) {
return false;
}
#if VERSION < 2
if (GBAWrite(x40_siChan, (u8*)(&MAGIC), &gbaStatus) == GBA_NOT_READY) {
return false;
}
#else
if (GBAWrite(x40_siChan, (u8*)(&targetMagic), &gbaStatus) == GBA_NOT_READY) {
return false;
}
#endif
if (GBAGetStatus(x40_siChan, &gbaStatus) == GBA_NOT_READY) {
return false;
}
@ -194,7 +231,7 @@ bool CGBASupport::PollResponse() {
uint read;
uchar fusionStatus[4];
if (GBARead(x40_siChan, reinterpret_cast<uchar*>(&read), &gbaStatus) != GBA_READY) {
if (GBARead(x40_siChan, reinterpret_cast< uchar* >(&read), &gbaStatus) != GBA_READY) {
return false;
}
fusionStatus[0] = read >> 24;