Compare commits

...

6 Commits

Author SHA1 Message Date
coah
829957aa71 feat: add eZiText zkokeyp source
Decompile the Korean keypad candidate functions. The unit stays
NonMatching: Zi8_81483118 matches exactly and the rest differ only by
register allocation or larger control-flow differences.

Salvaged from agent/hard0928/clibs.
2026-09-28 04:58:49 +00:00
coah
1cf4c5e6dc feat: complete RFL_NANDAccess data
Inline the NAND command block helpers so they no longer leave extab
entries, bringing extabindex to 100%.

Salvaged from agent/continue0924/rfl-nandaccess-data.
2026-09-28 04:57:23 +00:00
coah
35ce1b1700 feat: match iplGraphics unit
Compute the ortho projection bounds in the original order, size
Graphics::mArg without the trailing .bss padding, and link the unit.

Salvaged from agent/continue0923/src_utility_iplgraphics (without its
struct padding member).
2026-09-28 04:56:27 +00:00
coah
d4427b8a25 feat: match VF develop nand_drv unit
Make the NAND write/seek/create/delete wrappers inline so they fold into
_CreatePrfFile, test the override callbacks directly, fix the order of
the retry and sleep globals, size l_nandFunc without the trailing
padding, and link the unit. _MountPrfFile stays the existing asm.

Salvaged from agent/hard0928/clibs and
agent/continue0923/libs_revoex_src_vf_develop_nand_drv.
2026-09-28 04:55:56 +00:00
coah
5a2352a196 feat: match CDBSystem unit
Implement the database and record pool functions, give the CDB work
buffer pointer a real name (shared with CDBDatabase), size s_mutex as a
plain OSMutex, and link the unit.

Salvaged from agent/hard0928/clibs.
2026-09-28 04:53:58 +00:00
coah
6d8accf104 feat: match CDBAttr unit
Make CDBAttrGetDescOffset static and fold the IV generation into
CDBAttrInitIV with a function-local seed, then link the unit.

Salvaged from agent/hard0928/clibs.
2026-09-28 04:52:57 +00:00
9 changed files with 837 additions and 76 deletions

View File

@@ -7,7 +7,7 @@ mMac__Q33ipl6socket13SocketSetting = .bss:0x81089720; // type:object size:0x40
_database__7LibTVRC = .bss:0x81089760; // type:object size:0x20 data:4byte
_alarm__7LibTVRC = .bss:0x81089780; // type:object size:0x30
_tickWait__7LibTVRC = .bss:0x810897B0; // type:object size:0x10 data:4byte
mArg__Q33ipl7utility8Graphics = .bss:0x810897C0; // type:object size:0x88
mArg__Q33ipl7utility8Graphics = .bss:0x810897C0; // type:object size:0x84
unk__Q23ipl3snd = .bss:0x81089848; // type:object size:0xC
_seBlk__Q23ipl3snd = .bss:0x81089854; // type:object size:0xD8 data:4byte
sSystem__Q23ipl3snd = .bss:0x8108992C; // type:object size:0x63C data:4byte
@@ -123,7 +123,7 @@ CDB_SD_ROOT_PATH_LS = .bss:0x810C8A08; // type:object size:0x20
CDB_SD_VFF_FILE_NAME = .bss:0x810C8A28; // type:object size:0x48
lbl_810C8A80 = .bss:0x810C8A80; // type:object size:0x40 align:32
lbl_810C8AC0 = .bss:0x810C8AC0; // type:object size:0x40 align:32
s_mutex = .bss:0x810C8B00; // type:object size:0x20 scope:local
s_mutex = .bss:0x810C8B00; // type:object size:0x18 scope:local
s_cdbWiiId = .bss:0x810C8B20; // type:object size:0x40 scope:local
ncdMutex = .bss:0x810C8B60; // type:object size:0x20
ncdCommonResult = .bss:0x810C8B80; // type:object size:0x20 align:32 data:4byte
@@ -161,7 +161,7 @@ l_dev_init_info_table = .bss:0x810F55C0; // type:object size:0xD0 scope:local
l_tmpWName = .bss:0x810F5690; // type:object size:0x10 scope:local data:2byte
hashTable = .bss:0x810F56A0; // type:object size:0x22E scope:local data:byte
l_driveInfo = .bss:0x810F58D0; // type:object size:0x208 scope:local data:4byte
l_nandFunc = .bss:0x810F5AD8; // type:object size:0x1A8 scope:local
l_nandFunc = .bss:0x810F5AD8; // type:object size:0x1A0 scope:local
l_event = .bss:0x810F5C80; // type:object size:0x340 scope:local
l_sddrv_info = .bss:0x810F5FC0; // type:object size:0x80 scope:local
sZeroBuffer__Q44nw4r3snd6detail9AxManager = .bss:0x810F6040; // type:object size:0x100
@@ -23523,7 +23523,7 @@ s_fatalVFFlag = .sbss:0x81698D7C; // type:object size:0x4 scope:local data:4byte
CDBPrintDebugLevel = .sbss:0x81698D80; // type:object size:0x4 data:4byte
s_lastNANDError = .sbss:0x81698D84; // type:object size:0x4 scope:local data:4byte
s_lastVFError = .sbss:0x81698D88; // type:object size:0x4 scope:local data:4byte
lbl_81698D8C = .sbss:0x81698D8C; // type:object size:0x4 scope:local data:4byte
CDBDatabaseWorkBuf = .sbss:0x81698D8C; // type:object size:0x4 data:4byte
s_recordPool = .sbss:0x81698D90; // type:object size:0x4 scope:local data:4byte
s_databasePool = .sbss:0x81698D94; // type:object size:0x4 scope:local data:4byte
lbl_81698D98 = .sbss:0x81698D98; // type:object size:0x4 data:4byte

View File

@@ -671,7 +671,7 @@ config.libs = [
Object(Matching, "utility/iplTVRCUtils.cpp"),
Object(Matching, "utility/iplTree.cpp"),
Object(Matching, "utility/iplFrameController.cpp"),
Object(Equivalent, "utility/iplGraphics.cpp"),
Object(Matching, "utility/iplGraphics.cpp"),
Object(Matching, "utility/iplCapture.cpp"),
Object(Matching, "utility/iplUtility.cpp"),
Object(Matching, "utility/iplThread.cpp"),
@@ -1025,8 +1025,8 @@ config.libs = [
Object(Matching, "cdb/CDBRecordFile.c"),
Object(Matching, "cdb/CDBRecordKey.c"),
Object(NonMatching, "cdb/CDBIntArray.c"),
Object(NonMatching, "cdb/CDBSystem.c"),
Object(Equivalent, "cdb/CDBAttr.c"),
Object(Matching, "cdb/CDBSystem.c"),
Object(Matching, "cdb/CDBAttr.c"),
Object(Matching, "cdb/CDBFBridge.c"),
Object(Matching, "cdb/CDBFBridgeVF.c"),
Object(Matching, "cdb/CDBFBridgeSD.c"),
@@ -1163,7 +1163,7 @@ config.libs = [
Object(Matching, "vf/develop/d_hash.c"),
Object(Matching, "vf/develop/d_time.c"),
Object(Matching, "vf/develop/d_common.c"),
Object(NonMatching, "vf/develop/nand_drv.c"),
Object(Matching, "vf/develop/nand_drv.c"),
Object(Matching, "vf/develop/sd_drv.c"),
]
),

View File

@@ -133,7 +133,7 @@ void RFLiEndWorking(RFLErrcode errcode) {
RFLiEndWorkingReason(errcode, 0);
}
NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
inline NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
NANDCommandBlock* block = &RFLiGetAccInfo(type)->commandBlock;
RFLiCallbackTag* store = &RFLiGetAccInfo(type)->callbackTag;
@@ -147,7 +147,7 @@ NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
return block;
}
RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
inline RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
RFLiCallbackTag* stored;
RFLi_ASSERTLINE_NULL(block, 312);
@@ -159,7 +159,7 @@ RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
return stored->tag;
}
RFLiFileType RFLiGetType(NANDCommandBlock* block) {
inline RFLiFileType RFLiGetType(NANDCommandBlock* block) {
RFLiCallbackTag* stored;
RFLi_ASSERTLINE_NULL(block, 335);
@@ -171,7 +171,7 @@ RFLiFileType RFLiGetType(NANDCommandBlock* block) {
return stored->type;
}
NANDFileInfo* RFLiGetWorkingFile(RFLiFileType type) {
inline NANDFileInfo* RFLiGetWorkingFile(RFLiFileType type) {
RFLi_ASSERTLINE_RANGE(type, RFLiFileType_Database, RFLiFileType_Max, 356);
if (!RFLAvailable()) {

View File

@@ -0,0 +1,534 @@
#include <zi8clib/zierror.h>
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
ziU32 value;
ziU16 count;
ziU32 i;
count = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
for (i = 0; (ziU16)i < count; i++) {
value = (ziU16)(((ziU16)table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 7] << 8) |
table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 8]);
if (key == value) {
Zi8LogError(0x64, ZI_WORK);
return i;
}
}
Zi8LogError(0x96A, ZI_WORK);
return 0xFFFF;
}
void Zi8_81483118(ziGetParam* param, ziU8* output) {
ziU8 i;
for (i = 0; i < 5; i++) {
output[i] = 0;
}
switch (param->elementCount) {
case 9:
output[4] |= (ziU8)((param->elements[8] & 0xF) << 4);
case 8:
output[3] = param->elements[7] & 0xF;
case 7:
output[3] |= (ziU8)((param->elements[6] & 0xF) << 4);
case 6:
output[2] = param->elements[5] & 0xF;
case 5:
output[2] |= (ziU8)((param->elements[4] & 0xF) << 4);
case 4:
output[1] = param->elements[3] & 0xF;
case 3:
output[1] |= (ziU8)((param->elements[2] & 0xF) << 4);
case 2:
output[0] = param->elements[1] & 0xF;
case 1:
output[0] |= (ziU8)((param->elements[0] & 0xF) << 4);
case 0:
break;
}
}
ziU32 Zi8_81483264(const ziGetParam* param ZI_NEED_WORK) {
ziU8 i;
if (param->scratch == ZI8_NULL) {
Zi8LogError(0x164, ZI_WORK);
return 1;
}
for (i = 0; i < param->maxCandidates; i++) {
((ziU16*)param->scratch)[i] = 0;
}
Zi8LogError(0x64, ZI_WORK);
return 0;
}
ziU32 Zi8_81483308(ziGetParam* param, ziU16 key, ziU8* count ZI_NEED_WORK) {
ziU8 i;
Zi8LogError(0x64, ZI_WORK);
if (param->scratch == ZI8_NULL) {
Zi8ReplaceLastError(0x164, ZI_WORK);
return 1;
}
for (i = 0; i < param->maxCandidates; i++) {
if (key == ((ziU16*)param->scratch)[i]) {
return 1;
}
}
((ziU16*)param->scratch)[*count] = key;
if (++*count >= param->maxCandidates) {
*count = 0;
}
return 0;
}
ziBool Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziU8 i;
Zi8LogError(0x64, ZI_WORK);
if (param->scratch == ZI8_NULL) {
Zi8ReplaceLastError(0x164, ZI_WORK);
return 0;
}
for (i = 0; i < param->maxCandidates; i++) {
if (key == ((ziU16*)param->scratch)[i]) {
return 1;
}
}
return 0;
}
ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
ziU8* inserted ZI_NEED_WORK) {
ziBool matches;
ziS32 entry;
ziS32 tableA;
ziS32 tableB;
ziU16 tableCount;
ziU8 matched;
ziU32 j;
ziS32 i;
ziU8 candidateIndex;
union {
ziU32 words[13];
ziU8 bytes[52];
} local;
matched = 0;
local.words[0] = 0;
local.bytes[4] = 0;
Zi8LogError(0x64, ZI_WORK);
if (param->elementCount == 0) {
if (*remaining >= *count) {
for (i = 0; i < *count; i++) {
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
*remaining = *remaining - *count;
*count = 0;
} else {
for (i = 0; i < *remaining; i++) {
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
for (i = 0; i < ((ziS32)*count - (ziS32)*remaining); i++) {
param->candidates[i] = param->candidates[(ziU32)*remaining + i];
}
*count = *count - (ziU8)*remaining;
*remaining = 0;
}
return 1;
} else if (param->elementCount <= 9) {
tableA = Zi8GetTableAddress(param->language, 9, ZI_WORK);
tableB = Zi8GetTableAddress(param->language, 10, ZI_WORK);
if (tableA == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
return 0;
} else if (tableB == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
} else {
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local.bytes);
i = 0;
while (i < tableCount && matched < *count) {
matches = ZI8_TRUE;
entry = (i << 3) + tableA + i;
j = 0;
if (param->elementCount > 1) {
for (j = 0; (j & 0xFF) < (ziU32)(param->elementCount >> 1); j++) {
if (local.bytes[j & 0xFF] != *((ziU8*)entry + (j & 0xFF))) {
matches = ZI8_FALSE;
break;
}
}
}
if (matches && (param->elementCount & 1) != 0 &&
((local.bytes[j & 0xFF] & 0xF0) != (*((ziU8*)entry + (j & 0xFF)) & 0xF0))) {
matches = ZI8_FALSE;
}
if (matches) {
for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) {
if (param->candidates[candidateIndex] ==
(ziU16)((*((ziU8*)entry + 7) << 8) | *((ziU8*)entry + 8))) {
matched++;
param->candidates[candidateIndex] =
param->candidates[candidateIndex] & 0x7FFF;
break;
}
}
}
i++;
}
if ((ziU16)matched >= *remaining) {
matched = *count;
*count = 0;
for (i = 0; i < matched; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
if (*remaining == 0) {
if (*count != i) {
param->candidates[*count] = param->candidates[i];
}
*count = *count + 1;
} else {
*remaining = *remaining - 1;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
}
}
*remaining = 0;
} else {
for (i = 0; i < *count; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
}
*remaining = *remaining - (ziU16)matched;
*count = 0;
}
}
} else {
*count = 0;
return 0;
}
return 0;
}
ziU32 Zi8GetKOcandidates(ziGetParam* param, ziU8* options ZI_NEED_WORK) {
ziBool bVar1;
ziU8 bVar2;
ziS32 iVar4;
ziU32 uVar6;
ziU8* pbVar7;
union {
ziU32 words[10];
ziU8 bytes[40];
} local_28;
ziU8 local_57;
ziU8 local_56;
ziU8 local_55;
ziU8 local_54;
ziU8 local_53;
ziS8 local_52;
ziU16 local_50;
ziU16 local_4E;
ziU16 local_4C;
ziU16 local_4A;
ziU16 local_48;
ziS32 local_44;
ziS32 local_2C;
ziS32 local_30;
ziU32 local_34;
ziU32 local_38;
ziU32 local_3C;
ziU32 local_40;
local_4E = 0xFFFF;
local_34 = 0;
local_28.words[0] = 0;
local_28.bytes[4] = 0;
local_52 = 0;
local_53 = 0;
local_54 = 0;
local_55 = 0;
local_50 = param->firstCandidate;
local_3C = 0;
local_40 = 0;
local_57 = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
iVar4 = Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
local_2C = Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (iVar4 == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
uVar6 = 0;
} else {
if (local_2C == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
uVar6 = 0;
goto LAB_000114C4;
}
if (*options == 0) {
param->letters = 0;
param->count = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount != 0) {
local_48 = Zi8_8148302C(param->currentWord[0], (ziU8*)iVar4, ZI_WORK);
if ((local_48 != 0xFFFF) &&
((((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 8) != 0)) {
local_38 = (ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 6] |
((ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 3) << 16 |
(ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 5] << 8;
local_52 = param->wordCharCount - 1;
local_53 = 1;
pbVar7 = (ziU8*)(local_2C + local_38);
LAB_00010D44:
if (local_52 != 0) {
local_48 = Zi8_8148302C(param->currentWord[local_53], (ziU8*)iVar4, ZI_WORK);
if (local_48 == (ziU16)((*pbVar7 & 0x1F) << 8 | pbVar7[1])) {
local_52 = local_52 - 1;
local_53 = local_53 + 1;
if ((*pbVar7 & 0x40) == 0) {
pbVar7 = pbVar7 + 2;
goto LAB_00010D44;
}
local_52 = param->wordCharCount - 1;
local_53 = 1;
} else {
local_53 = 1;
local_52 = param->wordCharCount - 1;
}
}
if (local_52 == 0) {
local_48 = (*pbVar7 & 0x1F) << 8 | pbVar7[1];
local_4C = (ziU16)(((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[7] << 8 |
((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[8]);
if (param->wordCharCount == 1) {
if (local_48 == local_4E) {
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
}
local_52 = param->wordCharCount;
goto LAB_00011114;
}
local_4E = local_48;
if (param->elementCount == 0) {
if (local_50 == 0) {
if (*options != 0) {
local_3C = local_3C + 1;
if ((ziS32)local_3C < *(ziS32*)(options + 0xC)) {
goto LAB_000110E8;
}
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_50 = local_50 + -1;
}
} else {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->letters = 0;
local_54 = 0;
}
}
}
} else {
for (local_40 = 0;
(local_40 < local_54 &&
(local_4C != param->candidates[local_40]));
local_40 = local_40 + 1) {
}
if ((local_40 == local_54) &&
(Zi8_814833F0(param, local_4C, ZI_WORK) == 0)) {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (bVar2 < param->maxCandidates) {
goto LAB_000110E8;
}
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->letters = 0;
local_54 = 0;
}
}
}
}
LAB_000110E8:
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
}
local_52 = param->wordCharCount;
LAB_00011114:
local_52 = local_52 + -1;
local_53 = 1;
pbVar7 = pbVar7 + 2;
if ((*pbVar7 & 0x80) != 0) {
goto LAB_00011124;
}
goto LAB_00010D44;
}
}
LAB_00011124:
local_34 = local_3C;
if (local_54 != 0) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
uVar6 = local_34;
if ((*options != 0) &&
(local_3C = local_3C + local_54, uVar6 = local_3C,
*(ziS32*)(options + 0xC) <= (ziS32)local_3C)) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
local_34 = uVar6;
param->count = local_54;
param->letters = local_54;
}
if (param->elementCount < 10) {
if ((param->elementCount == 0) || (*options != 0)) {
local_56 = 1;
} else {
local_56 = 0;
}
local_4A = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local_28.bytes);
do {
for (local_30 = 0; local_30 < (ziS32)(ziU32)local_4A; local_30 = local_30 + 1) {
bVar1 = ZI8_TRUE;
local_44 = iVar4 + local_30 * 9;
local_55 = 0;
if (1 < param->elementCount) {
for (local_55 = 0;
(ziU32)local_55 < (ziU32)((ziS32)(ziU32)param->elementCount >> 1);
local_55 = local_55 + 1) {
if (local_28.bytes[local_55] != *(ziU8*)(local_44 + local_55)) {
bVar1 = ZI8_FALSE;
break;
}
}
}
if ((bVar1 && ((param->elementCount & 1) != 0)) &&
((local_28.bytes[local_55] & 0xF0) !=
(*(ziU8*)(local_44 + local_55) & 0xF0))) {
bVar1 = ZI8_FALSE;
}
if (bVar1) {
bVar2 = local_56;
if ((param->elementCount & 1) == 0) {
if ((*(ziU8*)(local_44 + local_55) & 0xF0) == 0) {
if (local_56 == 0) {
goto LAB_000113B0;
}
bVar2 = *options;
}
if (bVar2 == 0) {
goto LAB_00011478;
}
} else {
if ((*(ziU8*)(local_44 + local_55) & 0xF) != 0) {
goto LAB_000113AC;
}
if (local_56 != 0) {
bVar2 = *options;
goto LAB_000113AC;
}
}
LAB_000113AC:
if (bVar2 == 0) {
goto LAB_00011478;
}
LAB_000113B0:
if (local_50 == 0) {
if (*options == 0) {
param->candidates[local_54] =
(ziU16)((*(ziU8*)(local_30 * 9 + iVar4 + 7) << 8) |
*(ziU8*)(local_30 * 9 + iVar4 + 8));
local_54 = local_54 + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_34 = local_34 + 1;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_34) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
}
} else {
local_50 = local_50 + -1;
}
}
LAB_00011478:
;
}
local_56 = local_56 + 1;
} while (local_56 < 2);
uVar6 = local_34;
if (*options == 0) {
uVar6 = param->letters;
}
} else {
param->letters = 0;
uVar6 = 0;
}
}
LAB_000114C4:
return uVar6;
}

View File

@@ -11,9 +11,7 @@ static char CDB_ATTR_MAGIC[] = "CDBFILE";
static const u32 CDB_ATTR_VERSION = 0x02000000;
static const u32 CDB_ATTR_VERSION_PADDING = 0;
static u32 s_seed = 0;
u32 CDBAttrGetDescOffset(CDBAttr* attr) {
static u32 CDBAttrGetDescOffset(CDBAttr* attr) {
return attr->buf.version == 1 ? 0x0D : offsetof(CDBAttrBuf, descLength);
}
@@ -171,28 +169,18 @@ void CDBAttrGetKeyStr(CDBAttr* attr, char* keyString) {
memcpy(keyString, attr->buf.keyString, CDB_ATTR_BUF_KEY_STRING_LEN);
}
u32 CDBAttrSetIV(CDBAttr* attr, u32 seed);
void CDBAttrInitIV(CDBAttr* attr) {
int i, j;
u32 seed;
static u32 s_seed = 0;
int i;
if (s_seed == 0) {
s_seed = OSGetTick();
}
s_seed = CDBAttrSetIV(attr, s_seed);
}
u32 CDBAttrSetIV(CDBAttr* attr, u32 seed) {
int i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 8; j++) {
seed = 1566083941 * seed + 2531011;
attr->buf.iv[(i * 8) + j] = (s8)(seed >> 16);
}
for (i = 0; i < CDB_ATTR_BUF_KEY_IV_LEN; i++) {
s_seed = 1566083941 * s_seed + 2531011;
attr->buf.iv[i] = (s8)(s_seed >> 16);
}
return seed;
}
void CDBAttrGetIV(CDBAttr* attr, u8* iv) {

View File

@@ -62,7 +62,7 @@ extern void _restgpr_25();
extern void _restgpr_26();
extern int atoi();
#pragma section sdata_type ".sdata"
extern u32 lbl_81698D8C;
extern u32 CDBDatabaseWorkBuf;
extern char lbl_8166B528[];
extern char lbl_8166B550[];
extern char lbl_8166B57C[];
@@ -834,7 +834,7 @@ asm CDBErr CDBDatabaseSearchRecordLayer() {
stw r0, 0x124(r1)
addi r11, r1, 0x120
bl _savegpr_14
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
mr r20, r5
mr r22, r7
mr r24, r9
@@ -855,7 +855,7 @@ asm CDBErr CDBDatabaseSearchRecordLayer() {
bl CDBConvDirStrToCDBDate
lwz r0, 0x18(r19)
mr r31, r3
lwz r25, lbl_81698D8C(r0)
lwz r25, CDBDatabaseWorkBuf(r0)
addi r26, r3, 0x3b
cmpwi r0, 0x0
addi r0, r25, 0x994
@@ -1327,7 +1327,7 @@ asm CDBErr CDBDatabaseSearchMinuteLayer() {
stw r0, 0x174(r1)
addi r11, r1, 0x170
bl _savegpr_17
lwz r10, lbl_81698D8C(r0)
lwz r10, CDBDatabaseWorkBuf(r0)
mr r21, r5
mr r19, r3
mr r20, r4
@@ -1589,7 +1589,7 @@ asm CDBErr CDBDatabaseSearchHourLayer() {
stw r0, 0xb4(r1)
addi r11, r1, 0xb0
bl _savegpr_18
lwz r9, lbl_81698D8C(r0)
lwz r9, CDBDatabaseWorkBuf(r0)
mr r22, r5
mr r20, r3
mr r21, r4
@@ -1846,7 +1846,7 @@ asm CDBErr CDBDatabaseSearchDayLayer() {
stw r0, 0x104(r1)
addi r11, r1, 0x100
bl _savegpr_17
lwz r8, lbl_81698D8C(r0)
lwz r8, CDBDatabaseWorkBuf(r0)
mr r19, r5
mr r17, r3
mr r18, r4
@@ -2128,7 +2128,7 @@ asm CDBErr CDBDatabaseSearchMonthLayer() {
stw r0, 0xb4(r1)
addi r11, r1, 0xb0
bl _savegpr_19
lwz r7, lbl_81698D8C(r0)
lwz r7, CDBDatabaseWorkBuf(r0)
mr r23, r5
mr r21, r3
mr r22, r4
@@ -2398,7 +2398,7 @@ asm CDBErr CDBDatabaseSearchYearLayer() {
stw r0, 0x94(r1)
addi r11, r1, 0x90
bl _savegpr_22
lwz r6, lbl_81698D8C(r0)
lwz r6, CDBDatabaseWorkBuf(r0)
and. r0, r3, r4
mr r24, r3
mr r25, r4
@@ -2832,7 +2832,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesRecord() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_25
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
mr r25, r4
lwz r29, 0x138(r1)
mr r26, r5
@@ -2912,7 +2912,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesType() {
addi r11, r1, 0x140
bl _savegpr_22
li r0, 0x0
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
stw r0, 0x10(r1)
mr r22, r3
lwz r30, 0x148(r1)
@@ -3010,7 +3010,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesCode() {
stw r0, 0x144(r1)
addi r11, r1, 0x140
bl _savegpr_23
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r23, r3
mr r24, r4
@@ -3105,7 +3105,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesMinute() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_24
lwz r10, lbl_81698D8C(r0)
lwz r10, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r24, r3
mr r25, r4
@@ -3197,7 +3197,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesHour() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_25
lwz r9, lbl_81698D8C(r0)
lwz r9, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r25, r3
mr r26, r4
@@ -3286,7 +3286,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesDay() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_26
lwz r8, lbl_81698D8C(r0)
lwz r8, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r26, r3
mr r27, r4
@@ -3382,7 +3382,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesMonth() {
mr r28, r3
mr r4, r28
addi r3, r1, 0x10
lwz r7, lbl_81698D8C(r0)
lwz r7, CDBDatabaseWorkBuf(r0)
stw r0, 0x8(r1)
addi r31, r7, 0x3a78
bl CDBConvYearStrToFullPath
@@ -3460,7 +3460,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectories(CDBDatabase* database, CDBRecordLo
stw r30, 0x18(r1)
stw r29, 0x14(r1)
mr r29, r4
lwz r5, lbl_81698D8C(r0)
lwz r5, CDBDatabaseWorkBuf(r0)
addi r30, r5, 0x430c
bne L_8148A13C
li r3, 0x1

View File

@@ -9,19 +9,32 @@
#include <revolution/dvd.h>
#include <revolution/os.h>
typedef struct {
u32 used;
u8 padding[0xC00C];
u32 flags;
u32 unk;
} CDBDatabaseInstanceWork;
static OSMutex s_mutex;
static BOOL s_mutexInitialized = FALSE;
static BOOL s_fatalVFFlag = FALSE;
// This was likely a local originally, but oh well!
s32 CDBPrintDebugLevel = CDB_VERBOSE_LEVEL_NONE;
static u8 s_cdbWiiId[OSRoundUp32B(CDB_WIIID_DAT_SIZE)] ALIGN32;
static CDBDatabaseInstanceWork* s_databasePool;
static u8* s_recordPool;
u8* CDBDatabaseWorkBuf;
static VFErr s_lastVFError;
static s32 s_lastNANDError;
static u8 s_cdbWiiId[OSRoundUp32B(CDB_WIIID_DAT_SIZE)] ALIGN32;
static u8* s_recordPool;
extern void CDBDatabaseInstanceInit(void* instance, int flag, CDBDatabase* database);
extern BOOL CDBDatabaseInstanceIsUsed(void* instance);
extern void CDBRecordInstanceInit(void* instance, CDBRecord* record, int flag);
extern BOOL CDBRecordInstanceIsUsed(void* instance);
extern BOOL CDBRecordKeyCompare(CDBRecordKey* recordKey1, CDBRecordKey* recordKey2);
void MutexInitialized() {
s_mutexInitialized = TRUE;
@@ -35,6 +48,216 @@ void CDBUnlock() {
OSUnlockMutex(&s_mutex);
}
void CDBDatabaseInstancePoolInit(void* work) {
u32* workPointer = (u32*)work;
s_databasePool = (CDBDatabaseInstanceWork*)workPointer;
s_databasePool[0].used = 0;
s_databasePool[1].used = 0;
if (((u32)(workPointer + 0x7880) & 0x3f) != 0) {
CDBReportWarn("割り当てられた領域が64バイトアライメントされていません(%d)\n", (u64)((u32)(workPointer + 0x7880) & 0x3f));
}
CDBCryptBufSysInit((CDBCryptBuf*)(workPointer + 0x7880));
if (!s_mutexInitialized) {
OSInitMutex(&s_mutex);
}
CDBDatabaseWorkBuf = (u8*)workPointer + 0x19660;
}
void CDBRecordPoolInit(void* work) {
int i;
s_recordPool = (u8*)work + 0x18030;
for (i = 0; i < 5; i++) {
*(u32*)(s_recordPool + i * 0x470 + 0x18) = 0;
if (!s_mutexInitialized) {
OSInitMutex((OSMutex*)(s_recordPool + i * 0x470));
}
}
}
CDBErr CDBDatabaseAllocate(CDBDatabase* database, u32 flag) {
CDBDatabaseInstanceWork* databaseInstance;
CDBDatabaseInstanceWork* requestedInstance;
u32 writeFlag;
int i;
if (s_recordPool == NULL) {
OSPanic(__FILE__, 0x185, "(CDB) error : CDBInit() is not called\n");
}
OSLockMutex(&s_mutex);
requestedInstance = database->instance;
if (requestedInstance != NULL) {
for (i = 0, databaseInstance = s_databasePool; i < 2; i++, databaseInstance++) {
if (requestedInstance == databaseInstance) {
if (requestedInstance->flags == 0) {
CDBReportFatal("CDBDatabaseAllocate system error\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_FATAL_ERROR;
}
CDBReportError("database descripter has opened already\n");
OSUnlockMutex(&s_mutex);
return 0x1c;
}
}
CDBReportError("database descripter is not initialized\n");
OSUnlockMutex(&s_mutex);
return 0x18;
}
writeFlag = flag & CDB_RECORD_ALLOC_WRITE;
for (i = 0, databaseInstance = s_databasePool; i < 2; i++, databaseInstance++) {
if (databaseInstance->used != 0) {
if ((databaseInstance->flags & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the database as WRITE mode; another database discripter opened the database as WRITE mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
if (writeFlag != 0) {
CDBReportError("can't open the database as WRITE mode; other database discripter(s) opened the database as READ mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
}
}
for (i = 0; i < 2; i++) {
if (s_databasePool[i].used == 0) {
CDBDatabaseInstanceInit(s_databasePool + i, flag, database);
database->instance = s_databasePool + i;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
}
CDBReportError("can't open databases any more\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_CRYPT_ALLOC_FAIL;
}
CDBErr CDBDatabaseFree(CDBDatabase* database) {
int offset;
int i;
u32* databaseInstance = database->instance;
BOOL hasOpenRecord = FALSE;
if (databaseInstance == NULL) {
return 0x1b;
}
OSLockMutex(&s_mutex);
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset) &&
*(CDBDatabase**)(s_recordPool + offset + 0x468) == database) {
CDBReportError("can't close database; record %s is opened\n", s_recordPool + offset + 0x438);
hasOpenRecord = TRUE;
}
}
if (hasOpenRecord) {
OSUnlockMutex(&s_mutex);
return 0x21;
}
databaseInstance[0] = 0;
database->instance = NULL;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
CDBErr CDBDatabaseCheckOpenDatabase() {
int i;
BOOL hasOpenDatabase = FALSE;
OSLockMutex(&s_mutex);
for (i = 0; i < 2; i++) {
if (CDBDatabaseInstanceIsUsed(s_databasePool + i)) {
CDBReportError("database is opened\n");
hasOpenDatabase = TRUE;
}
}
OSUnlockMutex(&s_mutex);
if (hasOpenDatabase) {
return 0x22;
}
return CDB_ERROR_OK;
}
CDBErr CDBDatabaseCheckOpenRecord() {
int offset;
int i;
BOOL hasOpenRecord = FALSE;
OSLockMutex(&s_mutex);
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset)) {
CDBReportError("record %s is opened\n", s_recordPool + offset + 0x438);
hasOpenRecord = TRUE;
}
}
OSUnlockMutex(&s_mutex);
if (hasOpenRecord) {
return 0x21;
}
return CDB_ERROR_OK;
}
char s_recordOnSDMessage[] = "record %s on SD is opened\n";
CDBErr CDBRecordAllocate(CDBRecord* record, int flag) {
int writeFlag;
int offset;
int i;
CDBDatabaseInstanceWork* databaseInstance = ((CDBDatabase*)*(CDBDatabase**)record)->instance;
OSLockMutex(&s_mutex);
if (databaseInstance == NULL) {
CDBReportError("can't open the record; database is closed\n");
OSUnlockMutex(&s_mutex);
return 0x1b;
}
if ((databaseInstance->flags & CDB_RECORD_ALLOC_WRITE) == 0 && (flag & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the record as WRITE mode; database is readonly mode\n");
OSUnlockMutex(&s_mutex);
return 0x1a;
}
writeFlag = flag & CDB_RECORD_ALLOC_WRITE;
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset) &&
CDBRecordKeyCompare(&record->key, (CDBRecordKey*)(s_recordPool + offset + 0x438)) == FALSE &&
*(s32*)((u8*)record + 0x30) == *(s32*)(s_recordPool + offset + 0x460)) {
if ((*(u32*)(s_recordPool + offset + 0x1c) & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the record as WRITE mode; another record discripter opened the record as WRITE mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
if (writeFlag != 0) {
CDBReportError("can't open the record as WRITE mode; other record discripter(s) opened the record as READ mode \n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
}
}
for (i = 0; i < 5; i++) {
if (!CDBRecordInstanceIsUsed(s_recordPool + i * 0x470)) {
offset = i * 0x470;
CDBRecordInstanceInit(s_recordPool + offset, record, flag);
record->file = s_recordPool + offset;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
}
CDBReportError("can't open record any more\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_CRYPT_ALLOC_FAIL;
}
CDBErr CDBRecordFree(CDBRecord* record) {
CDBRecordFile* recordFile = record->file;
@@ -73,18 +296,6 @@ void CDBSetFatalVFErrorFlag() {
s_fatalVFFlag = TRUE;
}
void CDBRecordPoolInit(void* work) {
int i;
s_recordPool = (u8*)work + 0x18030;
for (i = 0; i < 5; i++) {
*(u32*)(s_recordPool + i * 0x470 + 0x18) = 0;
if (!s_mutexInitialized) {
OSInitMutex((OSMutex*)(s_recordPool + i * 0x470));
}
}
}
void CDBTryToCreate_wiiiddat(u8* data) {
NANDFileInfo fileInfo;
u32 nandCheck;
@@ -92,7 +303,7 @@ void CDBTryToCreate_wiiiddat(u8* data) {
// Requires 1 NAND block and 1 NAND node
s32 ret = NANDCheck(1, 1, &nandCheck);
if (ret != NAND_RESULT_OK) {
CDBReportError("failed NANDCheck\n");
CDBReportFatal("failed NANDCheck\n");
return;
}
@@ -327,6 +538,29 @@ void CDBCheckMakerCodeStr(char* makerCodeStr) {
}
}
BOOL CDBRecordBelongedDBOpenedAsRW(CDBRecord* record) {
int i;
CDBDatabaseInstanceWork* databaseInstance = NULL;
CDBDatabaseInstanceWork* databasePool;
if (record == NULL) {
return FALSE;
}
databasePool = s_databasePool;
for (i = 0; i < 2; i++) {
if (databasePool[i].used != 0 && (databasePool[i].flags & CDB_RECORD_ALLOC_WRITE) != 0) {
databaseInstance = databasePool + i;
break;
}
}
if (databaseInstance == NULL) {
return FALSE;
}
return TRUE;
}
static int s_vfSync = 1;
CDBErr CDBSetVFSyncMode(int sync) {

View File

@@ -53,8 +53,8 @@ static struct {
VFi_NANDDelete delete; // 0x0C
} l_nandFunc[PF_DRIVE_COUNT];
int VF_nand_retry_max;
int VF_nand_sleep_msec;
int VF_nand_retry_max;
#ifdef DEBUG
#define VFi_NANDPrint(...) printf(__VA_ARGS__)
@@ -130,7 +130,7 @@ s32 VFi_NandPrivateOpen(const char* path, NANDFileInfo* info, u8 accType) {
VFi_NANDFunction(NANDPrivateOpen(path, info, accType));
}
s32 VFi_NandWrite(NANDFileInfo* info, void* buf, u32 length) {
inline s32 VFi_NandWrite(NANDFileInfo* info, void* buf, u32 length) {
VFi_NANDFunction(NANDWrite(info, buf, length));
}
@@ -146,7 +146,7 @@ s32 VFi_NandPrivateCreateDir(const char* path, u8 perm, u8 attr) {
VFi_NANDFunction(NANDPrivateCreateDir(path, perm, attr));
}
s32 VFi_NandSeek(NANDFileInfo* info, s32 offset, s32 whence) {
inline s32 VFi_NandSeek(NANDFileInfo* info, s32 offset, s32 whence) {
VFi_NANDFunction(NANDSeek(info, offset, whence));
}
@@ -177,12 +177,12 @@ static u8 _MakePermitForRVL(u8 i_perm) {
return perm;
}
s32 VFi_NandCreateSp(const char* path, u8 i_perm, u8 attr, u32 i_handleIdx) {
inline s32 VFi_NandCreateSp(const char* path, u8 i_perm, u8 attr, u32 i_handleIdx) {
u8 perm = _MakePermitForRVL(i_perm);
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDCreate tmpCreate;
tmpCreate = l_nandFunc[i_handleIdx].create;
if (tmpCreate != NULL) {
if (tmpCreate) {
return tmpCreate(path, perm, attr);
}
return VFi_NandCreate(path, perm, attr);
@@ -197,7 +197,7 @@ s32 VFi_NandOpenSp(const char* path, void* info, u8 accType, u32 i_handleIdx) {
NANDFileInfo* info_p = info;
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDOpen tmpOpen = l_nandFunc[i_handleIdx].open;
if (tmpOpen != NULL) {
if (tmpOpen) {
return tmpOpen(path, info_p, accType);
}
return VFi_NandOpen(path, info_p, accType);
@@ -208,10 +208,10 @@ s32 VFi_NandOpenSp(const char* path, void* info, u8 accType, u32 i_handleIdx) {
return VFi_NandPrivateOpen(path, info_p, accType);
}
s32 VFi_NandDeleteSp(const char* path, u32 i_handleIdx) {
inline s32 VFi_NandDeleteSp(const char* path, u32 i_handleIdx) {
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDDelete tmpDelete = l_nandFunc[i_handleIdx].delete;
if (tmpDelete != NULL) {
if (tmpDelete) {
return tmpDelete(path);
}
return VFi_NandDelete(path);

View File

@@ -33,20 +33,25 @@ namespace ipl {
}
void Graphics::setOrthoProjection(const math::VEC3& translate, const math::VEC2& scale) {
nw4r::ut::Rect projRect(0, 0, 0, 0);
nw4r::ut::Rect projRect;
System::getProjectionRect(&projRect);
f32 temp_f9 = projRect.right / scale.x;
f32 temp_f7 = projRect.left / scale.x;
MTXOrtho(mArg.mProjMtx, translate.y - (projRect.top / scale.y), translate.y - (projRect.bottom / scale.y), translate.x + temp_f7,
translate.x + temp_f9, -100.0f, 100.0f);
f32 right = translate.x + projRect.right / scale.x;
f32 left = translate.x + projRect.left / scale.x;
f32 bottom = translate.y - (projRect.bottom / scale.y);
f32 top = translate.y - (projRect.top / scale.y);
MTXOrtho(mArg.mProjMtx, top, bottom, left, right, -100.0f, 100.0f);
GXSetProjection(mArg.mProjMtx, GX_ORTHOGRAPHIC);
}
void Graphics::setOrthoProjection(u32 id) {
GXRenderModeObj* rMode = System::getRenderModeObj();
MTXOrtho(mArg.mProjMtx, rMode->efbHeight / 2, -rMode->efbHeight / 2, -rMode->fbWidth / 2, rMode->fbWidth / 2, -100.0f, 100.0f);
f32 widthHalf = rMode->fbWidth / 2;
f32 negativeWidthHalf = -rMode->fbWidth / 2;
f32 negativeHeightHalf = -rMode->efbHeight / 2;
f32 heightHalf = rMode->efbHeight / 2;
MTXOrtho(mArg.mProjMtx, heightHalf, negativeHeightHalf, negativeWidthHalf, widthHalf, -100.0f, 100.0f);
GXSetProjection(mArg.mProjMtx, GX_ORTHOGRAPHIC);
calcOrthoCamera();