diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2021-05-29 20:57:36 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2021-05-29 20:57:36 -0400 |
commit | af472505c60f7a0463e8195e9039af4806b9d42b (patch) | |
tree | 9dd5ab3396a9fd834b796a5fa8ad360321e952ec | |
parent | fea86c63479708926cce890f65cf7c9217f6fc4c (diff) |
Document game_init.c
51 files changed, 258 insertions, 229 deletions
diff --git a/arm9/asm/unk_0200BB14.s b/arm9/asm/unk_0200BB14.s index b8a6eab5..840d91d1 100644 --- a/arm9/asm/unk_0200BB14.s +++ b/arm9/asm/unk_0200BB14.s @@ -342,7 +342,7 @@ _0200BD68: str r0, [sp, #0x18] ldr r0, [r5, #0x0] ldr r1, [r6, #0x0] - bl FUN_020161A4 + bl AllocAndReadFile ldr r1, [sp, #0x18] ldr r2, [r5, #0x0] str r0, [sp, #0x1c] @@ -408,7 +408,7 @@ _0200BDF6: ldr r1, [sp, #0x10] ldr r0, [r5, #0x0] ldr r1, [r1, #0x18] - bl FUN_020161A4 + bl AllocAndReadFile ldr r1, [r4, #0x14] add r6, r0, #0x0 str r1, [sp, #0x0] diff --git a/arm9/asm/unk_0201B1A8.s b/arm9/asm/unk_0201B1A8.s index 359f9bfe..115edca0 100644 --- a/arm9/asm/unk_0201B1A8.s +++ b/arm9/asm/unk_0201B1A8.s @@ -21,7 +21,7 @@ FUN_0201B1A8: ; 0x0201B1A8 push {r3-r5, lr} add r5, r3, #0x0 add r4, r2, #0x0 - bl FUN_020161A4 + bl AllocAndReadFile str r0, [r5, #0x0] bl NNS_G3dGetTex cmp r0, #0x0 diff --git a/arm9/asm/unk_0201F06C.s b/arm9/asm/unk_0201F06C.s index 03e1404e..d33edce3 100644 --- a/arm9/asm/unk_0201F06C.s +++ b/arm9/asm/unk_0201F06C.s @@ -1821,7 +1821,7 @@ _0201FD0C: str r0, [r4, r1] ldr r0, [r5, #0x8] ldr r1, _0201FD54 ; =UNK_02105BBC - bl FUN_020161A4 + bl AllocAndReadFile mov r1, #0x46 lsl r1, r1, #0x2 str r0, [r4, r1] diff --git a/arm9/asm/unk_02020C44.s b/arm9/asm/unk_02020C44.s index 235543ee..4550b5cb 100644 --- a/arm9/asm/unk_02020C44.s +++ b/arm9/asm/unk_02020C44.s @@ -146,7 +146,7 @@ _02020D38: _02020D48: ldr r0, [sp, #0x0] add r1, r6, #0x0 - bl FUN_020161A4 + bl AllocAndReadFile str r0, [r4, #0x4] cmp r0, #0x0 bne _02020D5A diff --git a/arm9/asm/unk_02033B68.s b/arm9/asm/unk_02033B68.s index 9e204377..57ae58f9 100644 --- a/arm9/asm/unk_02033B68.s +++ b/arm9/asm/unk_02033B68.s @@ -326,7 +326,7 @@ FUN_02033D3C: ; 0x02033D3C beq _02033D92 ldr r0, _02033D98 ; =UNK_02105D88 add r1, sp, #0x4 - bl FUN_020161F8 + bl OpenAndReadWholeFile mov r1, #0x96 ldr r0, [sp, #0x4] lsl r1, r1, #0x2 @@ -374,11 +374,11 @@ FUN_02033D9C: ; 0x02033D9C add r1, sp, #0x4 beq _02033DC2 ldr r0, _02033E5C ; =UNK_02105D98 - bl FUN_020161F8 + bl OpenAndReadWholeFile b _02033DC8 _02033DC2: ldr r0, _02033E60 ; =UNK_02105DA8 - bl FUN_020161F8 + bl OpenAndReadWholeFile _02033DC8: mov r1, #0x96 ldr r0, [sp, #0x4] diff --git a/arm9/asm/unk_02033F50.s b/arm9/asm/unk_02033F50.s index ed33e084..eb65ebfd 100644 --- a/arm9/asm/unk_02033F50.s +++ b/arm9/asm/unk_02033F50.s @@ -110,7 +110,7 @@ _02033FA4: str r0, [r2, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers ldr r0, _02034160 ; =gMain + 0x60 mov r1, #0x0 strb r1, [r0, #0x5] diff --git a/arm9/asm/unk_02034188.s b/arm9/asm/unk_02034188.s index 08265835..a91f1c2c 100644 --- a/arm9/asm/unk_02034188.s +++ b/arm9/asm/unk_02034188.s @@ -58,7 +58,7 @@ FUN_02034188: ; 0x02034188 str r0, [r2, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers ldr r0, _02034370 ; =gMain + 0x60 mov r1, #0x0 strb r1, [r0, #0x5] diff --git a/arm9/asm/unk_02053750.s b/arm9/asm/unk_02053750.s index 38f594ef..cf28dafb 100644 --- a/arm9/asm/unk_02053750.s +++ b/arm9/asm/unk_02053750.s @@ -974,7 +974,7 @@ _02053E24: bl FUN_02009DAC ldr r1, _02053E88 ; =UNK_02105F80 mov r0, #0x4 - bl FUN_020161A4 + bl AllocAndReadFile ldr r1, [r5, #0x10] add r4, r0, #0x0 str r1, [sp, #0x0] @@ -1012,7 +1012,7 @@ FUN_02053E8C: ; 0x02053E8C add r4, r0, #0x0 mov r0, #0x4 add r1, r6, #0x0 - bl FUN_020161A4 + bl AllocAndReadFile add r6, r0, #0x0 add r1, r4, #0x0 mov r2, #0x4 diff --git a/arm9/asm/unk_0206F3FC.s b/arm9/asm/unk_0206F3FC.s index 17adb2d2..53557016 100644 --- a/arm9/asm/unk_0206F3FC.s +++ b/arm9/asm/unk_0206F3FC.s @@ -143,7 +143,7 @@ FUN_0206F3FC: ; 0x0206F3FC strh r1, [r3, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r2, #0x2 mov r0, #0x3 mov r1, #0xc diff --git a/arm9/asm/unk_020772F0.s b/arm9/asm/unk_020772F0.s index 87e9cab0..5a4129b1 100644 --- a/arm9/asm/unk_020772F0.s +++ b/arm9/asm/unk_020772F0.s @@ -777,7 +777,7 @@ _020772FE: str r0, [r4, r1] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers bl FUN_02077B24 mov r0, #0x16 lsl r0, r0, #0x4 diff --git a/arm9/asm/unk_02079C70.s b/arm9/asm/unk_02079C70.s index 3134a96c..87da24ba 100644 --- a/arm9/asm/unk_02079C70.s +++ b/arm9/asm/unk_02079C70.s @@ -87,7 +87,7 @@ FUN_02079C7C: ; 0x02079C7C strh r2, [r0, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r2, #0x1 mov r0, #0x3 mov r1, #0x13 diff --git a/arm9/asm/unk_02089498.s b/arm9/asm/unk_02089498.s index 3facd182..8e706149 100644 --- a/arm9/asm/unk_02089498.s +++ b/arm9/asm/unk_02089498.s @@ -119,7 +119,7 @@ _020894FC: str r0, [r2, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r4, #0x0 bl FUN_0208961C add r0, r4, #0x0 diff --git a/arm9/asm/unk_02089960.s b/arm9/asm/unk_02089960.s index 9c06a4ab..bd234548 100644 --- a/arm9/asm/unk_02089960.s +++ b/arm9/asm/unk_02089960.s @@ -101,7 +101,7 @@ _020899B8: str r0, [r2, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r6, #0x0 bl FUN_02089A6C add r0, r6, #0x0 diff --git a/arm9/asm/unk_02089D90.s b/arm9/asm/unk_02089D90.s index e7b88272..1fd86f68 100644 --- a/arm9/asm/unk_02089D90.s +++ b/arm9/asm/unk_02089D90.s @@ -57,7 +57,7 @@ FUN_02089D90: ; 0x02089D90 str r0, [r2, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers ldr r0, _02089EFC ; =gMain + 0x60 mov r1, #0x0 strb r1, [r0, #0x5] diff --git a/arm9/asm/unk_02089F24.s b/arm9/asm/unk_02089F24.s index b5c93a8a..14ed66e2 100644 --- a/arm9/asm/unk_02089F24.s +++ b/arm9/asm/unk_02089F24.s @@ -61,7 +61,7 @@ FUN_02089F24: ; 0x02089F24 str r0, [r2, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers ldr r0, _0208A090 ; =gMain + 0x60 mov r1, #0x0 strb r1, [r0, #0x5] @@ -230,7 +230,7 @@ _0208A0C8: str r0, [r2, #0x0] mov r0, #0x4 mov r1, #0x8 - bl FUN_0201669C + bl SetKeyRepeatTimers ldr r0, _0208A230 ; =gMain + 0x60 mov r1, #0x0 strb r1, [r0, #0x5] diff --git a/arm9/global.inc b/arm9/global.inc index 19284cbe..288dcf4e 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -1010,18 +1010,18 @@ .extern Main_SetVBlankIntrCB .extern FUN_02015F1C .extern FUN_02015F34 -.extern FUN_020161A4 -.extern FUN_020161F8 -.extern FUN_020162FC -.extern FUN_02016324 -.extern FUN_020163BC +.extern AllocAndReadFile +.extern OpenAndReadWholeFile +.extern ClearFileCache +.extern OpenFileCached +.extern InitKeypadAndTouchpad .extern FUN_02016438 .extern FUN_02016444 .extern FUN_02016454 -.extern FUN_02016464 -.extern FUN_0201669C -.extern FUN_020166A8 -.extern FUN_020166B8 +.extern ReadKeypadAndTocuhpad +.extern SetKeyRepeatTimers +.extern SetSoftResetDisableMask +.extern ClearSoftResetDisableMask .extern FUN_020166C8 .extern FUN_0201681C .extern FUN_02016828 diff --git a/arm9/lib/include/tp.h b/arm9/lib/include/tp.h index d2687545..dc762f10 100644 --- a/arm9/lib/include/tp.h +++ b/arm9/lib/include/tp.h @@ -1,6 +1,14 @@ #ifndef NITRO_TP_H_ #define NITRO_TP_H_ +#define TP_TOUCH_OFF 0 // Not being touched +#define TP_TOUCH_ON 1 // Being touched + +#define TP_VALIDITY_VALID 0 // Valid +#define TP_VALIDITY_INVALID_X 1 // Data with invalid X coordinate +#define TP_VALIDITY_INVALID_Y 2 // Data with invalid Y coordinate +#define TP_VALIDITY_INVALID_XY (TP_VALIDITY_INVALID_X | TP_VALIDITY_INVALID_Y) // Data with invalid X and Y coordinates + // Touch panel input structure typedef struct { diff --git a/arm9/modules/05/asm/mod05_021D9320.s b/arm9/modules/05/asm/mod05_021D9320.s index ec304548..419b92fd 100644 --- a/arm9/modules/05/asm/mod05_021D9320.s +++ b/arm9/modules/05/asm/mod05_021D9320.s @@ -53,7 +53,7 @@ _021D9374: str r0, [sp, #0x20] ldr r1, [r6] add r0, r4, #0 - bl FUN_020161A4 + bl AllocAndReadFile ldr r1, [sp, #0x20] str r0, [sp, #0x24] add r2, r4, #0 @@ -161,7 +161,7 @@ _021D944A: ldr r1, [sp, #0x10] add r0, r4, #0 ldr r1, [r1, #0x18] - bl FUN_020161A4 + bl AllocAndReadFile mov r3, #0x4e lsl r3, r3, #2 ldr r1, [r5, r3] diff --git a/arm9/modules/05/asm/mod05_021DB44C.s b/arm9/modules/05/asm/mod05_021DB44C.s index eaee32f8..bba92897 100644 --- a/arm9/modules/05/asm/mod05_021DB44C.s +++ b/arm9/modules/05/asm/mod05_021DB44C.s @@ -255,7 +255,7 @@ MOD05_021DB61C: ; 0x021DB61C str r1, [sp] mov r0, #4 add r1, r2, #0 - bl FUN_020161A4 + bl AllocAndReadFile mov r1, #0 str r0, [sp, #0x14] str r1, [sp, #8] diff --git a/arm9/modules/05/asm/mod05_021DBEF4.s b/arm9/modules/05/asm/mod05_021DBEF4.s index f65de9d8..ae93e2a3 100644 --- a/arm9/modules/05/asm/mod05_021DBEF4.s +++ b/arm9/modules/05/asm/mod05_021DBEF4.s @@ -120,7 +120,7 @@ _021DBFA8: add r7, #0x10 mov r0, #4 add r1, sp, #0xc - bl FUN_020161A4 + bl AllocAndReadFile str r0, [r7, r5] add r0, r6, #0 str r0, [sp, #8] @@ -128,7 +128,7 @@ _021DBFA8: str r0, [sp, #8] ldr r0, [r7, r5] mov r1, #4 - bl FUN_02016324 + bl OpenFileCached ldr r1, [sp, #8] str r0, [r1, r5] add r0, r1, #0 diff --git a/arm9/modules/05/asm/module_05.s b/arm9/modules/05/asm/module_05.s index 006e8bb1..913e5b00 100644 --- a/arm9/modules/05/asm/module_05.s +++ b/arm9/modules/05/asm/module_05.s @@ -13882,7 +13882,7 @@ MOD05_021EF4F8: ; 0x021EF4F8 MOD05_021EF514: ; 0x021EF514 push {r3, r4, r5, r6, r7, lr} add r5, r0, #0 - bl FUN_020162FC + bl ClearFileCache bl NNS_GfdResetLnkTexVramState bl NNS_GfdResetLnkPlttVramState mov r4, #0 diff --git a/arm9/modules/12/asm/module_12.s b/arm9/modules/12/asm/module_12.s index effb333a..fcb737d8 100644 --- a/arm9/modules/12/asm/module_12.s +++ b/arm9/modules/12/asm/module_12.s @@ -102,7 +102,7 @@ MOD12_0222D5C0: ; 0x0222D5C0 bl FUN_0201C24C mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r2, #0x23 add r1, r4, #0 lsl r2, r2, #4 @@ -3237,7 +3237,7 @@ MOD12_0222EF04: ; 0x0222EF04 bl FUN_0201C24C mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers ldr r0, [r5, #0x30] bl MOD12_0222F548 bl FUN_0201CC08 @@ -5099,7 +5099,7 @@ MOD12_0222FE4C: ; 0x0222FE4C bl FUN_0201C24C mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r1, r5, #0 ldr r0, [r5] add r1, #0x14 @@ -41182,7 +41182,7 @@ MOD12_02241210: ; 0x02241210 bl FUN_0201C24C mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers ldr r0, [r5, #0x30] bl MOD12_02241864 bl FUN_0201CC08 diff --git a/arm9/modules/18/asm/module_18.s b/arm9/modules/18/asm/module_18.s index 9b2fdf67..e84656ac 100644 --- a/arm9/modules/18/asm/module_18.s +++ b/arm9/modules/18/asm/module_18.s @@ -43226,7 +43226,7 @@ _0224E848: ; jump table _0224E858: mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers bl MOD18_0224E01C ldr r3, _0224E940 ; =0x00000504 add r1, r6, #0 diff --git a/arm9/modules/53/asm/module_53.s b/arm9/modules/53/asm/module_53.s index d070f979..3c747f56 100644 --- a/arm9/modules/53/asm/module_53.s +++ b/arm9/modules/53/asm/module_53.s @@ -60,7 +60,7 @@ _021D74F6: str r0, [r4, #0x10] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers bl MOD53_021D78D0 ldr r0, [r4] bl MOD53_021D78F0 diff --git a/arm9/modules/54/asm/module_54.s b/arm9/modules/54/asm/module_54.s index b11b96cf..04f3927a 100644 --- a/arm9/modules/54/asm/module_54.s +++ b/arm9/modules/54/asm/module_54.s @@ -67,7 +67,7 @@ _021D74F6: str r0, [r4, #0x28] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers bl MOD54_021D7874 ldr r0, [r4] bl MOD54_021D7894 diff --git a/arm9/modules/55/asm/module_55.s b/arm9/modules/55/asm/module_55.s index b9f3c277..f90f346e 100644 --- a/arm9/modules/55/asm/module_55.s +++ b/arm9/modules/55/asm/module_55.s @@ -43,7 +43,7 @@ MOD55_021D7504: ; 0x021D7504 str r0, [r2] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r0, #0x34 bl FUN_02016B94 str r0, [r4, #4] diff --git a/arm9/modules/56/asm/module_56.s b/arm9/modules/56/asm/module_56.s index 531194c6..2f71e04c 100644 --- a/arm9/modules/56/asm/module_56.s +++ b/arm9/modules/56/asm/module_56.s @@ -267,7 +267,7 @@ MOD56_02211FD4: ; 0x02211FD4 str r0, [r2] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r0, #0x36 bl FUN_02016B94 add r1, r4, #0 diff --git a/arm9/modules/57/asm/module_57.s b/arm9/modules/57/asm/module_57.s index 481488f8..624f332c 100644 --- a/arm9/modules/57/asm/module_57.s +++ b/arm9/modules/57/asm/module_57.s @@ -28,7 +28,7 @@ MOD57_021D74E0: ; 0x021D74E0 str r0, [r2] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r2, #0xa mov r0, #3 mov r1, #0x19 diff --git a/arm9/modules/58/asm/module_58.s b/arm9/modules/58/asm/module_58.s index eb13ddb7..c3ac0512 100644 --- a/arm9/modules/58/asm/module_58.s +++ b/arm9/modules/58/asm/module_58.s @@ -66,7 +66,7 @@ _021D9A36: str r0, [r4, #0x14] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers bl MOD58_021D9CDC ldr r0, [r4] bl MOD58_021D9CFC diff --git a/arm9/modules/59/asm/mod59_021D74E0_asm.s b/arm9/modules/59/asm/mod59_021D74E0_asm.s index 5604bf3c..c47887c1 100644 --- a/arm9/modules/59/asm/mod59_021D74E0_asm.s +++ b/arm9/modules/59/asm/mod59_021D74E0_asm.s @@ -56,7 +56,7 @@ _021D7592: str r0, [r2] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r4, #0 bl MOD59_021D778C add r0, r4, #0 diff --git a/arm9/modules/59/asm/mod59_021D9868.s b/arm9/modules/59/asm/mod59_021D9868.s index 2925c404..78e2c5b2 100644 --- a/arm9/modules/59/asm/mod59_021D9868.s +++ b/arm9/modules/59/asm/mod59_021D9868.s @@ -81,7 +81,7 @@ _021D98C6: str r0, [r2] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r4, #0 bl MOD59_021D9A20 add r0, r4, #0 diff --git a/arm9/modules/63/asm/mod63_021D74E0.s b/arm9/modules/63/asm/mod63_021D74E0.s index ea96bf3b..d309fdee 100644 --- a/arm9/modules/63/asm/mod63_021D74E0.s +++ b/arm9/modules/63/asm/mod63_021D74E0.s @@ -37,7 +37,7 @@ MOD63_021D74E0: ; 0x021D74E0 str r0, [r2] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r2, #1 mov r0, #3 mov r1, #0x1e diff --git a/arm9/modules/63/asm/mod63_021D8890.s b/arm9/modules/63/asm/mod63_021D8890.s index 6f6f8f75..42cbfcd7 100644 --- a/arm9/modules/63/asm/mod63_021D8890.s +++ b/arm9/modules/63/asm/mod63_021D8890.s @@ -582,7 +582,7 @@ MOD63_021D8D10: ; 0x021D8D10 bl GX_DisableEngineBLayers mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r0, #3 mov r1, #0x4c lsl r2, r0, #0x11 diff --git a/arm9/modules/67/asm/module_67.s b/arm9/modules/67/asm/module_67.s index 60bd02b5..cc5e6e22 100644 --- a/arm9/modules/67/asm/module_67.s +++ b/arm9/modules/67/asm/module_67.s @@ -30,7 +30,7 @@ MOD67_021D74E0: ; 0x021D74E0 strh r1, [r3] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers mov r2, #2 mov r0, #3 mov r1, #0x2a diff --git a/arm9/modules/68/asm/module_68.s b/arm9/modules/68/asm/module_68.s index b2170444..3d73e7bd 100644 --- a/arm9/modules/68/asm/module_68.s +++ b/arm9/modules/68/asm/module_68.s @@ -73,7 +73,7 @@ MOD68_021D74E0: ; 0x021D74E0 bl MOD68_021D7870 mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers bl FUN_0201CC08 mov r0, #4 bl FUN_0201CC24 diff --git a/arm9/modules/71/asm/module_71.s b/arm9/modules/71/asm/module_71.s index 303bee40..613e6aa0 100644 --- a/arm9/modules/71/asm/module_71.s +++ b/arm9/modules/71/asm/module_71.s @@ -74,7 +74,7 @@ MOD71_0222D5C0: ; 0x0222D5C0 bl MOD71_0222E76C mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers bl MOD71_0222E558 mov r0, #0x5d lsl r0, r0, #2 @@ -932,7 +932,7 @@ _0222DDA6: mov r0, #0x50 bl FUN_02031588 mov r0, #2 - bl FUN_020166A8 + bl SetSoftResetDisableMask add r0, r4, #0 bl MOD71_02230B88 ldr r0, [r4, #0x4c] @@ -1317,7 +1317,7 @@ _0222E094: mov r2, #1 bl MOD71_02230F40 mov r0, #2 - bl FUN_020166B8 + bl ClearSoftResetDisableMask add sp, #0x10 mov r0, #1 pop {r3, r4, r5, r6, r7, pc} diff --git a/arm9/modules/75/asm/module_75.s b/arm9/modules/75/asm/module_75.s index 3500c458..fc726042 100644 --- a/arm9/modules/75/asm/module_75.s +++ b/arm9/modules/75/asm/module_75.s @@ -68,7 +68,7 @@ MOD75_021E6BA0: ; 0x021E6BA0 bl FUN_0200E1D0 mov r0, #3 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r4, #0 bl MOD75_021E7470 add r0, r4, #0 diff --git a/arm9/modules/77/asm/module_77.s b/arm9/modules/77/asm/module_77.s index 6affcb88..1f240502 100644 --- a/arm9/modules/77/asm/module_77.s +++ b/arm9/modules/77/asm/module_77.s @@ -100,7 +100,7 @@ _021D7540: bl GX_SwapDisplay mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r5, #0 bl MOD77_021D7C64 mov r0, #1 diff --git a/arm9/modules/80/asm/module_80.s b/arm9/modules/80/asm/module_80.s index 83e02d71..56c92006 100644 --- a/arm9/modules/80/asm/module_80.s +++ b/arm9/modules/80/asm/module_80.s @@ -1453,7 +1453,7 @@ _0222DFE4: str r0, [r4, r1] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r4, #0 add r1, r6, #0 bl MOD80_0222E338 diff --git a/arm9/modules/82/asm/module_82.s b/arm9/modules/82/asm/module_82.s index f1a3e494..b897380f 100644 --- a/arm9/modules/82/asm/module_82.s +++ b/arm9/modules/82/asm/module_82.s @@ -695,7 +695,7 @@ _0222DA48: str r0, [r4, r1] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r4, #0 add r1, r6, #0 bl MOD82_0222DD04 diff --git a/arm9/modules/83/asm/module_83.s b/arm9/modules/83/asm/module_83.s index 09c161b4..354932d5 100644 --- a/arm9/modules/83/asm/module_83.s +++ b/arm9/modules/83/asm/module_83.s @@ -15353,11 +15353,11 @@ MOD83_02234E40: ; 0x02234E40 add r0, r4, #0 bl FUN_0202BF90 mov r0, #4 - bl FUN_020166A8 + bl SetSoftResetDisableMask ldr r0, [r5, #0x10] bl FUN_02022720 mov r0, #4 - bl FUN_020166B8 + bl ClearSoftResetDisableMask pop {r3, r4, r5, pc} thumb_func_end MOD83_02234E40 @@ -19168,7 +19168,7 @@ _02236CAE: mov r0, #0x15 str r0, [r5] mov r0, #4 - bl FUN_020166A8 + bl SetSoftResetDisableMask b _02236D90 _02236CF0: ldr r0, _02236DB0 ; =0x0000E88C @@ -19219,7 +19219,7 @@ _02236D36: mov r0, #0x16 str r0, [r5] mov r0, #4 - bl FUN_020166B8 + bl ClearSoftResetDisableMask b _02236D90 _02236D54: ldr r0, _02236DC8 ; =gMain + 0x40 @@ -24577,7 +24577,7 @@ _022394E4: ; jump table .short _02239538 - _022394E4 - 2 ; case 4 _022394EE: mov r0, #4 - bl FUN_020166A8 + bl SetSoftResetDisableMask ldr r0, [r4, #0x14] mov r1, #2 bl FUN_02022840 @@ -24610,7 +24610,7 @@ _02239528: cmp r0, #1 bhi _02239534 mov r0, #4 - bl FUN_020166B8 + bl ClearSoftResetDisableMask _02239534: add r0, r5, #0 pop {r3, r4, r5, pc} @@ -24645,7 +24645,7 @@ MOD83_0223955C: ; 0x0223955C ldr r0, [r0, #0x14] bl FUN_0202287C mov r0, #4 - bl FUN_020166B8 + bl ClearSoftResetDisableMask pop {r3, pc} nop _02239570: .word MOD83_0223BC30 diff --git a/arm9/modules/86/asm/module_86.s b/arm9/modules/86/asm/module_86.s index 2bd7d12a..82dca844 100644 --- a/arm9/modules/86/asm/module_86.s +++ b/arm9/modules/86/asm/module_86.s @@ -57,7 +57,7 @@ MOD86_021D74E0: ; 0x021D74E0 str r0, [r2] mov r0, #4 mov r1, #8 - bl FUN_0201669C + bl SetKeyRepeatTimers add r0, r4, #0 bl MOD86_021D76EC add r0, r4, #0 diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c index 28627d6b..9996cbb1 100644 --- a/arm9/src/error_message_reset.c +++ b/arm9/src/error_message_reset.c @@ -61,7 +61,7 @@ THUMB_FUNC void PrintErrorMessageAndReset() reg_GX_DISPCNT &= 0xFFFFE0FF; reg_GXS_DB_DISPCNT &= 0xFFFFE0FF; - FUN_0201669C(4, 8); + SetKeyRepeatTimers(4, 8); gMain.unk65 = 0; GX_SwapDisplay(); diff --git a/arm9/src/game_init.c b/arm9/src/game_init.c index 64ea7a54..2b8f8c8f 100644 --- a/arm9/src/game_init.c +++ b/arm9/src/game_init.c @@ -30,7 +30,7 @@ OS_DTCM; static struct { void * contents; u32 name_hash; -} UNK_021C4928[128]; +} sFileCache[128]; struct Main gMain; @@ -136,7 +136,7 @@ void FUN_02015FC8(void) { csum += digest[i]; } - csum = (csum << 24) >> 24; + csum %= 256; while (csum & 3) { csum++; @@ -189,7 +189,7 @@ void InitGraphicMemory(void) MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE); } -void * FUN_020161A4(u32 heap_id, const char * path) +void * AllocAndReadFile(u32 heap_id, const char * path) { void * ret; @@ -214,7 +214,7 @@ void * FUN_020161A4(u32 heap_id, const char * path) return ret; } -void FUN_020161F8(const char * path, void ** ptr) +void OpenAndReadWholeFile(const char * path, void ** ptr) { FSFile file; FS_InitFile(&file); @@ -227,94 +227,94 @@ void FUN_020161F8(const char * path, void ** ptr) } } -u32 FUN_02016230(const s8 * str) +u32 GetFilenameHash(const s8 * str) { u16 len = (u16)strlen(str); - u16 sp4; + u16 numWords; if ((len % 4) != 0) - sp4 = (u16)((len / 4) + 1); + numWords = (u16)((len / 4) + 1); else - sp4 = (u16)(len / 4); - u32 r7 = 0; + numWords = (u16)(len / 4); + u32 hash = 0; s32 i, j; - for (i = 0; i < sp4; i++) + for (i = 0; i < numWords; i++) { - u32 r1 = 0; + u32 curWord = 0; for (j = 0; j < 4; j++) { - int r5 = str[4 * i + j]; - if (r5 == 0) + int curChar = str[4 * i + j]; + if (curChar == 0) break; - r1 |= r5 << (8 * j); + curWord |= curChar << (8 * j); } - r7 ^= r1; + hash ^= curWord; } - return r7; + return hash; } -int FUN_020162A0(u32 a0) +int GetFileCacheId(u32 hash) { for (int i = 0; i < 128; i++) { - if (UNK_021C4928[i].name_hash == a0 && UNK_021C4928[i].contents != NULL) + if (sFileCache[i].name_hash == hash && sFileCache[i].contents != NULL) return i; } return -1; } -int FUN_020162C8(void * a0, u32 a1) +int AddFileToCache(void * contents, u32 hash) { for (int i = 0; i < 128; i++) { - if (UNK_021C4928[i].contents == NULL) + if (sFileCache[i].contents == NULL) { - UNK_021C4928[i].contents = a0; - UNK_021C4928[i].name_hash = a1; + sFileCache[i].contents = contents; + sFileCache[i].name_hash = hash; return i; } } return -1; } -void FUN_020162FC(void) +void ClearFileCache(void) { for (int i = 127; i > -1; i--) { - if (UNK_021C4928[i].contents != NULL) + if (sFileCache[i].contents != NULL) { - FreeToHeap(UNK_021C4928[i].contents); - UNK_021C4928[i].contents = NULL; - UNK_021C4928[i].name_hash = 0; + FreeToHeap(sFileCache[i].contents); + sFileCache[i].contents = NULL; + sFileCache[i].name_hash = 0; } } } -void * FUN_02016324(const s8 * str, u32 heap_id) +void * OpenFileCached(const s8 * str, u32 heap_id) { - s8 sp0[32]; + s8 filenameBuf[32]; FSFile file; void * ret; - int r5 = 0; + int skipCache = 0; if (str[0] == '!') { - strcpy(sp0, str + 1); - r5 = 1; + strcpy(filenameBuf, str + 1); + skipCache = 1; } else { - strcpy(sp0, str); + strcpy(filenameBuf, str); } - u32 r7 = FUN_02016230(sp0); - s32 r0 = FUN_020162A0(r7); - if (r0 >= 0 && r5 == 0) + u32 hash = GetFilenameHash(filenameBuf); + s32 cacheId = GetFileCacheId(hash); + if (cacheId >= 0 && skipCache == 0) { - ret = UNK_021C4928[r0].contents; + ret = sFileCache[cacheId].contents; } else { FS_InitFile(&file); - if (FS_OpenFile(&file, (const char *)sp0)) + if (FS_OpenFile(&file, (const char *)filenameBuf)) { u32 size = file.prop.file.bottom - file.prop.file.top; ret = AllocFromHeap(heap_id, size); @@ -327,8 +327,8 @@ void * FUN_02016324(const s8 * str, u32 heap_id) } } FS_CloseFile(&file); - if (r5 == 0) - FUN_020162C8(ret, r7); + if (skipCache == 0) + AddFileToCache(ret, hash); } else ret = NULL; @@ -336,24 +336,24 @@ void * FUN_02016324(const s8 * str, u32 heap_id) return ret; } -void FUN_020163BC(void) +void InitKeypadAndTouchpad(void) { TPCalibrateParam tp; - gMain.unk34 = 0; - gMain.unk38 = 0; - gMain.unk3C = 0; - gMain.unk40 = 0; - gMain.unk44 = 0; + gMain.buttonMode = 0; + gMain.heldKeysRaw = 0; + gMain.newKeysRaw = 0; + gMain.newAndRepeatedKeysRaw = 0; + gMain.heldKeys = 0; gMain.newKeys = 0; gMain.newAndRepeatedKeys = 0; - gMain.unk50 = 0; - gMain.unk54 = 8; - gMain.unk58 = 15; - gMain.unk5C = 0; - gMain.unk5E = 0; - gMain.unk60 = 0; - gMain.unk62 = 0; - gMain.unk64 = 0; + gMain.keyRepeatCounter = 0; + gMain.keyRepeatContinueDelay = 8; + gMain.keyRepeatStartDelay = 15; + gMain.touchX = 0; + gMain.touchY = 0; + gMain.touchNew = 0; + gMain.touchHeld = 0; + gMain.touchpadReadAuto = 0; TP_Init(); if (TP_GetUserInfo(&tp) == TRUE) TP_SetCalibrateParam(&tp); @@ -382,38 +382,53 @@ void FUN_02016454(u8 a0) gMain.unk67 &= ~a0; } -void FUN_02016464(void) +void ReadKeypadAndTocuhpad(void) { TPData raw, calib; if (PAD_DetectFold()) { + // Can't press any buttons while the lid is closed. gMain.newKeys = 0; - gMain.unk44 = 0; + gMain.heldKeys = 0; gMain.newAndRepeatedKeys = 0; - gMain.unk60 = 0; - gMain.unk62 = 0; + gMain.touchNew = 0; + gMain.touchHeld = 0; return; } - u32 r0 = PAD_Read(); - gMain.unk40 = gMain.unk3C = (r0 ^ gMain.unk38) & r0; - if (r0 != 0 && gMain.unk38 == r0) + + u32 padRead = PAD_Read(); + + // newKeys is all keys that were pressed on this frame but + // not the last frame. + gMain.newAndRepeatedKeysRaw = gMain.newKeysRaw = (padRead ^ gMain.heldKeysRaw) & padRead; + + // If you are holding down buttons, indicate them "repeated" every few frames + // as defined by .keyRepeatStartDelay and .keyRepeatContinueDelay. + // Same logic as gen3, but fixes the bug where the + // remapped keys are incorrectly used here. + // See also: pokeemerald/src/main.c:ReadKeys + if (padRead != 0 && gMain.heldKeysRaw == padRead) { - if (--gMain.unk50 == 0) + if (--gMain.keyRepeatCounter == 0) { - gMain.unk40 = r0; - gMain.unk50 = gMain.unk54; + gMain.newAndRepeatedKeysRaw = padRead; + gMain.keyRepeatCounter = gMain.keyRepeatContinueDelay; } } else { - gMain.unk50 = gMain.unk58; + gMain.keyRepeatCounter = gMain.keyRepeatStartDelay; } - gMain.unk38 = r0; - gMain.newKeys = gMain.unk3C; - gMain.unk44 = r0; - gMain.newAndRepeatedKeys = gMain.unk40; - FUN_02016568(); - if (gMain.unk64 == 0) + gMain.heldKeysRaw = padRead; + + // Apply the button mode option to the read key input + gMain.newKeys = gMain.newKeysRaw; + gMain.heldKeys = padRead; + gMain.newAndRepeatedKeys = gMain.newAndRepeatedKeysRaw; + ApplyButtonModeToInput(); + + // Read the touchpad. New to gen 4. + if (gMain.touchpadReadAuto == 0) { while (TP_RequestRawSampling(&raw)) ; @@ -421,111 +436,117 @@ void FUN_02016464(void) else TP_GetLatestRawPointInAuto(&raw); TP_GetCalibratedPoint(&calib, &raw); - if (calib.validity == 0) + + // If the touchpad is valid, we gucci. + if (calib.validity == TP_VALIDITY_VALID) { - gMain.unk5C = calib.x; - gMain.unk5E = calib.y; + gMain.touchX = calib.x; + gMain.touchY = calib.y; } - else if (gMain.unk62) + + // If the touchpad was used last frame, salvage what we can. + else if (gMain.touchHeld) { switch (calib.validity) { - case 1: - gMain.unk5E = calib.y; + case TP_VALIDITY_INVALID_X: + gMain.touchY = calib.y; break; - case 2: - gMain.unk5C = calib.x; + case TP_VALIDITY_INVALID_Y: + gMain.touchX = calib.x; break; - case 3: + case TP_VALIDITY_INVALID_XY: break; } } + // What was read from the touchpad was not salvageable. + // Ignore touch input. else calib.touch = 0; - gMain.unk60 = (u16)((gMain.unk62 ^ calib.touch) & calib.touch); - gMain.unk62 = calib.touch; + gMain.touchNew = (u16)((gMain.touchHeld ^ calib.touch) & calib.touch); + gMain.touchHeld = calib.touch; } -void FUN_02016568(void) +void ApplyButtonModeToInput(void) { - switch (gMain.unk34) + switch (gMain.buttonMode) { case 0: // Normal break; case 1: // Start = X if (gMain.newKeys & PAD_BUTTON_START) gMain.newKeys |= PAD_BUTTON_X; - if (gMain.unk44 & PAD_BUTTON_START) - gMain.unk44 |= PAD_BUTTON_X; + if (gMain.heldKeys & PAD_BUTTON_START) + gMain.heldKeys |= PAD_BUTTON_X; if (gMain.newAndRepeatedKeys & PAD_BUTTON_START) gMain.newAndRepeatedKeys |= PAD_BUTTON_X; break; case 2: // Swap X and Y; unused in the retail game { - u32 r1 = 0; + u32 swapMask = 0; if (gMain.newKeys & PAD_BUTTON_X) { - r1 |= PAD_BUTTON_Y; + swapMask |= PAD_BUTTON_Y; } if (gMain.newKeys & PAD_BUTTON_Y) { - r1 |= PAD_BUTTON_X; + swapMask |= PAD_BUTTON_X; } - gMain.newKeys &= 0xF3FF; - gMain.newKeys |= r1; + gMain.newKeys &= ((PAD_BUTTON_X | PAD_BUTTON_Y) ^ 0xFFFF);; + gMain.newKeys |= swapMask; } { - u32 r1 = 0; - if (gMain.unk44 & PAD_BUTTON_X) + u32 swapMask = 0; + if (gMain.heldKeys & PAD_BUTTON_X) { - r1 |= PAD_BUTTON_Y; + swapMask |= PAD_BUTTON_Y; } - if (gMain.unk44 & PAD_BUTTON_Y) + if (gMain.heldKeys & PAD_BUTTON_Y) { - r1 |= PAD_BUTTON_X; + swapMask |= PAD_BUTTON_X; } - gMain.unk44 &= 0xF3FF; - gMain.unk44 |= r1; + gMain.heldKeys &= ((PAD_BUTTON_X | PAD_BUTTON_Y) ^ 0xFFFF); + gMain.heldKeys |= swapMask; } { - u32 r1 = 0; + u32 swapMask = 0; if (gMain.newAndRepeatedKeys & PAD_BUTTON_X) { - r1 |= PAD_BUTTON_Y; + swapMask |= PAD_BUTTON_Y; } if (gMain.newAndRepeatedKeys & PAD_BUTTON_Y) { - r1 |= PAD_BUTTON_X; + swapMask |= PAD_BUTTON_X; } - gMain.newAndRepeatedKeys &= 0xF3FF; - gMain.newAndRepeatedKeys |= r1; + gMain.newAndRepeatedKeys &= ((PAD_BUTTON_X | PAD_BUTTON_Y) ^ 0xFFFF); + gMain.newAndRepeatedKeys |= swapMask; } break; case 3: // L = A if (gMain.newKeys & PAD_BUTTON_L) gMain.newKeys |= PAD_BUTTON_A; - if (gMain.unk44 & PAD_BUTTON_L) - gMain.unk44 |= PAD_BUTTON_A; + if (gMain.heldKeys & PAD_BUTTON_L) + gMain.heldKeys |= PAD_BUTTON_A; if (gMain.newAndRepeatedKeys & PAD_BUTTON_L) gMain.newAndRepeatedKeys |= PAD_BUTTON_A; - gMain.newKeys &= 0xFCFF; - gMain.unk44 &= 0xFCFF; - gMain.newAndRepeatedKeys &= 0xFCFF; + gMain.newKeys &= ((PAD_BUTTON_L | PAD_BUTTON_R) ^ 0xFFFF); + gMain.heldKeys &= ((PAD_BUTTON_L | PAD_BUTTON_R) ^ 0xFFFF); + gMain.newAndRepeatedKeys &= ((PAD_BUTTON_L | PAD_BUTTON_R) ^ 0xFFFF); } } -void FUN_0201669C(int x, int y) +void SetKeyRepeatTimers(int x, int y) { - gMain.unk54 = x; - gMain.unk58 = y; + gMain.keyRepeatContinueDelay = x; + gMain.keyRepeatStartDelay = y; } -void FUN_020166A8(u8 a0) +void SetSoftResetDisableMask(u8 a0) { - gMain.unk68 |= a0; + gMain.softResetDisabled |= a0; } -void FUN_020166B8(u8 a0) +void ClearSoftResetDisableMask(u8 a0) { - gMain.unk68 &= ~a0; + gMain.softResetDisabled &= ~a0; } diff --git a/arm9/src/main.c b/arm9/src/main.c index 7a8a14d8..1421ac48 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -54,10 +54,10 @@ THUMB_FUNC void NitroMain(void) { InitSystemForTheGame(); InitGraphicMemory(); - FUN_020163BC(); + InitKeypadAndTouchpad(); FUN_02016438(0); - PM_GetBackLight((PMBackLightSwitch *)SDK_STATIC_BSS_START, NULL); + PM_GetBackLight(&gBacklightTop, NULL); FUN_02022294(); GF_InitRTCWork(); @@ -105,8 +105,8 @@ THUMB_FUNC void NitroMain(void) { FUN_02000EE8(); HandleDSLidAction(); - FUN_02016464(); - if ((gMain.unk38 & SOFT_RESET_KEY) == SOFT_RESET_KEY && !gMain.unk68) // soft reset? + ReadKeypadAndTocuhpad(); + if ((gMain.heldKeysRaw & SOFT_RESET_KEY) == SOFT_RESET_KEY && !gMain.softResetDisabled) // soft reset? { DoSoftReset(0); // soft reset? } @@ -249,7 +249,7 @@ THUMB_FUNC void FUN_02000F4C(u32 arg0, u32 arg1) while (1) { HandleDSLidAction(); - FUN_02016464(); + ReadKeypadAndTocuhpad(); if (gMain.newKeys & 1) break; FUN_02000E9C(); diff --git a/arm9/src/options.c b/arm9/src/options.c index 296b398a..03b63864 100644 --- a/arm9/src/options.c +++ b/arm9/src/options.c @@ -35,14 +35,14 @@ void Options_SetButtonModeOnMain(struct SaveBlock2 * sav2, u32 buttonMode) { switch (buttonMode) { case 1: - gMain.unk34 = 1; + gMain.buttonMode = 1; break; case 2: - gMain.unk34 = 3; + gMain.buttonMode = 3; break; case 0: default: - gMain.unk34 = 0; + gMain.buttonMode = 0; break; } } diff --git a/arm9/src/unk_02016B94.c b/arm9/src/unk_02016B94.c index 6a9dd194..19ec831d 100644 --- a/arm9/src/unk_02016B94.c +++ b/arm9/src/unk_02016B94.c @@ -7745,7 +7745,7 @@ THUMB_FUNC void FUN_0201AB24(struct Window *window, u8 param1) THUMB_FUNC u32 FUN_0201AB28(struct Window *window, u32 heap_id, const char *path) { - void *ptr = FUN_020161A4(heap_id, path); + void *ptr = AllocAndReadFile(heap_id, path); window->unk00 = ptr; u32 st0; NNS_G2dGetUnpackedBGCharacterData(ptr, &st0); @@ -7755,7 +7755,7 @@ THUMB_FUNC u32 FUN_0201AB28(struct Window *window, u32 heap_id, const char *path THUMB_FUNC u32 FUN_0201AB44(struct Window *window, u32 heap_id, const char *path) { - void *ptr = FUN_020161A4(heap_id, path); + void *ptr = AllocAndReadFile(heap_id, path); window->unk00 = ptr; u32 st0; NNS_G2dGetUnpackedPaletteData(ptr, &st0); diff --git a/arm9/src/unk_0202F150.c b/arm9/src/unk_0202F150.c index 09b5b56f..ef9a6193 100644 --- a/arm9/src/unk_0202F150.c +++ b/arm9/src/unk_0202F150.c @@ -535,7 +535,7 @@ THUMB_FUNC BOOL FUN_0202FB80() { UNK_021C59F4.unk00 = 0; FUN_0202F984(); - UNK_021C59F4.unk04->unk628 |= gMain.unk44 & 0x7FFF; + UNK_021C59F4.unk04->unk628 |= gMain.heldKeys & 0x7FFF; FUN_02030674(); FUN_0202FCCC(); diff --git a/arm9/src/unk_02031734.c b/arm9/src/unk_02031734.c index 57764b82..49283907 100644 --- a/arm9/src/unk_02031734.c +++ b/arm9/src/unk_02031734.c @@ -1807,7 +1807,7 @@ THUMB_FUNC void FUN_020331C4() { if (UNK_021C5A00 != NULL) { - FUN_020166B8(1); + ClearSoftResetDisableMask(1); FUN_02031D20(FUN_02032440, 5); } } @@ -1875,7 +1875,7 @@ THUMB_FUNC void FUN_02033288(struct SaveBlock2 *sav2) UNK_021C5A00->unk46 = 1; UNK_021C5A00->unk28 = sav2; FUN_020334E8(0, 1); - FUN_020166A8(1); + SetSoftResetDisableMask(1); } } @@ -1883,7 +1883,7 @@ THUMB_FUNC void FUN_020332DC() { if (UNK_021C5A00 != 0) { - FUN_020166B8(1); + ClearSoftResetDisableMask(1); FUN_020334E8(0, 0); FreeToHeap(UNK_021C5A00); UNK_021C5A00 = NULL; @@ -1903,7 +1903,7 @@ THUMB_FUNC void FUN_02033310(struct SaveBlock2 *sav2) UNK_021C5A00->unk46 = 1; UNK_021C5A00->unk28 = sav2; FUN_020334E8(0, 1); - FUN_020166A8(1); + SetSoftResetDisableMask(1); } } @@ -1911,7 +1911,7 @@ THUMB_FUNC void FUN_02033364() { if (UNK_021C5A00 != 0) { - FUN_020166B8(1); + ClearSoftResetDisableMask(1); FUN_020334E8(0, 0); FreeToHeap(UNK_021C5A00); UNK_021C5A00 = NULL; @@ -1985,7 +1985,7 @@ THUMB_FUNC void *FUN_0203346C(struct SaveBlock2 *sav2, u32 param1) return 0; } - FUN_020166A8(1); + SetSoftResetDisableMask(1); FUN_02016828(3, 0xf, 0x7080); FUN_02031734(sav2, 0x17); UNK_021C5A00->unk00 = AllocFromHeap(0xf, param1); @@ -2127,7 +2127,7 @@ THUMB_FUNC void FUN_020335F4() FUN_0200541C(); FUN_0202287C(UNK_021C5A00->unk28); - gMain.unk64 = 1; + gMain.touchpadReadAuto = 1; if (UNK_021C5A00->unk4E == 3) { FUN_020335A4(3); diff --git a/include/game_init.h b/include/game_init.h index 7a6e34fb..6aaeb6b4 100644 --- a/include/game_init.h +++ b/include/game_init.h @@ -14,21 +14,21 @@ void Main_HBlankIntr(BOOL a0); void FUN_02015FC8(void); void InitSystemForTheGame(void); void InitGraphicMemory(void); -void * FUN_020161A4(u32 heap_id, const char * path); -void FUN_020161F8(const char * path, void ** ptr); -u32 FUN_02016230(const s8 * str); -int FUN_020162A0(u32 a0); -int FUN_020162C8(void * a0, u32 a1); -void FUN_020162FC(void); -void * FUN_02016324(const s8 * str, u32 heap_id); -void FUN_020163BC(void); +void * AllocAndReadFile(u32 heap_id, const char * path); +void OpenAndReadWholeFile(const char * path, void ** ptr); +u32 GetFilenameHash(const s8 * str); +int GetFileCacheId(u32 hash); +int AddFileToCache(void * contents, u32 hash); +void ClearFileCache(void); +void * OpenFileCached(const s8 * str, u32 heap_id); +void InitKeypadAndTouchpad(void); void FUN_02016438(u8 a0); void FUN_02016444(u8 a0); void FUN_02016454(u8 a0); -void FUN_02016464(void); -void FUN_02016568(void); -void FUN_0201669C(int x, int y); -void FUN_020166A8(u8 a0); -void FUN_020166B8(u8 a0); +void ReadKeypadAndTocuhpad(void); +void ApplyButtonModeToInput(void); +void SetKeyRepeatTimers(int x, int y); +void SetSoftResetDisableMask(u8 a0); +void ClearSoftResetDisableMask(u8 a0); #endif //POKEDIAMOND_GAME_INIT_H diff --git a/include/main.h b/include/main.h index 9227d9a8..ba4d7bc2 100644 --- a/include/main.h +++ b/include/main.h @@ -79,26 +79,26 @@ struct Main s32 unk28; u32 unk2C; s32 unk30; - u32 unk34; - u32 unk38; - u32 unk3C; - u32 unk40; - u32 unk44; + u32 buttonMode; + u32 heldKeysRaw; + u32 newKeysRaw; + u32 newAndRepeatedKeysRaw; + u32 heldKeys; u32 newKeys; u32 newAndRepeatedKeys; - s32 unk50; - s32 unk54; - s32 unk58; - u16 unk5C; - u16 unk5E; - u16 unk60; - u16 unk62; - u8 unk64; + s32 keyRepeatCounter; + s32 keyRepeatContinueDelay; + s32 keyRepeatStartDelay; + u16 touchX; + u16 touchY; + u16 touchNew; + u16 touchHeld; + u8 touchpadReadAuto; u8 unk65; u8 unk66; u8 unk67; - u8 unk68; - u8 padding_69[3]; + u8 softResetDisabled; + u8 padding_69[3]; // nice s32 unk6C; }; |