From 22600e81cca075ecfa570365f14070d9318b33ce Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 19 Nov 2017 00:02:15 -0500 Subject: [PATCH] Start parsing out link_rfu common syms --- asm/link_rfu.s | 46 ++++++++++++------------ common_syms/link_rfu.txt | 2 ++ include/link_rfu.h | 76 ++++++++++++++++++++++------------------ src/link.c | 2 -- src/link_rfu.c | 10 +++--- sym_common.txt | 53 +--------------------------- 6 files changed, 74 insertions(+), 115 deletions(-) create mode 100644 common_syms/link_rfu.txt diff --git a/asm/link_rfu.s b/asm/link_rfu.s index 00eaf23de..0c84af711 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -4470,7 +4470,7 @@ _0800E64A: cmp r4, 0 bge _0800E64A movs r5, 0 - ldr r4, =gUnknown_0300506C + ldr r4, =gUnknown_03005000+0x6C adds r0, r4, 0 bl sub_800FCC4 adds r0, r4, 0 @@ -4530,7 +4530,7 @@ sub_800E6D0: @ 800E6D0 thumb_func_start sub_800E700 sub_800E700: @ 800E700 push {r4,lr} - ldr r0, =gUnknown_03004190 + ldr r0, =gUnknown_03004140+0x50 ldr r1, =0x00000e64 ldr r4, =gIntrTable + 0x4 adds r2, r4, 0 @@ -4692,7 +4692,7 @@ sub_800E88C: @ 800E88C bne _0800E8CC movs r3, 0 movs r5, 0x1 - ldr r1, =gUnknown_03005CDE + ldr r1, =gUnknown_03005000+0xCDE _0800E8A6: adds r0, r2, 0 ands r0, r5 @@ -4717,7 +4717,7 @@ _0800E8CC: mvns r0, r1 mov r12, r0 movs r7, 0x1 - ldr r4, =gUnknown_03005CDE + ldr r4, =gUnknown_03005000+0xCDE _0800E8D6: adds r2, r1, 0 ands r2, r7 @@ -4733,14 +4733,14 @@ _0800E8E2: cmp r3, 0x3 bls _0800E8D6 movs r4, 0x4 - ldr r0, =gUnknown_03005CDE + ldr r0, =gUnknown_03005000+0xCDE ldrb r7, [r0] _0800E8F4: movs r3, 0 subs r1, r4, 0x1 cmp r7, r4 beq _0800E910 - ldr r2, =gUnknown_03005CDE + ldr r2, =gUnknown_03005000+0xCDE _0800E8FE: adds r0, r3, 0x1 lsls r0, 24 @@ -4764,7 +4764,7 @@ _0800E916: ands r5, r0 movs r3, 0 movs r2, 0x1 - ldr r1, =gUnknown_03005CDE + ldr r1, =gUnknown_03005000+0xCDE _0800E928: adds r0, r5, 0 ands r0, r2 @@ -4949,7 +4949,7 @@ _0800EABC: lsls r2, r4, 3 subs r2, r4 lsls r2, 1 - ldr r0, =gUnknown_03005014 + ldr r0, =gUnknown_03005000+0x14 adds r2, r0 movs r0, 0x10 adds r1, r4, 0 @@ -4976,7 +4976,7 @@ sub_800EAFC: @ 800EAFC push {r4-r6,lr} ldr r0, =gUnknown_03004140 ldrb r5, [r0] - ldr r4, =gUnknown_03005C87 + ldr r4, =gUnknown_03005000+0xC87 adds r0, r5, 0 adds r1, r4, 0 movs r2, 0x46 @@ -5905,7 +5905,7 @@ _0800F2E0: movs r0, 0x1F ands r0, r1 strb r0, [r2] - ldr r2, =gUnknown_03005CDE + ldr r2, =gUnknown_03005000+0xCDE adds r0, r5, r2 ldrb r0, [r0] movs r6, 0 @@ -6138,7 +6138,7 @@ sub_800F4F0: @ 800F4F0 mov r7, r8 push {r7} sub sp, 0x58 - ldr r0, =gUnknown_03005124 + ldr r0, =gUnknown_03005000+0x124 mov r1, sp bl sub_800D934 movs r1, 0 @@ -6344,7 +6344,7 @@ _0800F6A0: adds r4, 0x1 cmp r4, 0x6 ble _0800F6A0 - ldr r0, =gUnknown_030059E8 + ldr r0, =gUnknown_03005000+0x9E8 mov r1, r12 bl sub_800D888 movs r1, 0x1 @@ -6356,7 +6356,7 @@ _0800F6A0: _0800F6C8: adds r1, r7, 0 adds r5, r6, 0 - ldr r3, =gUnknown_0300506E + ldr r3, =gUnknown_03005000+0x6E ldrh r3, [r3] cmp r5, r3 blt _0800F65A @@ -6687,7 +6687,7 @@ _0800F930: ldr r3, =gRecvCmds+0x4 adds r0, r5, r3 bl sub_800F74C - ldr r4, =gUnknown_03005CCE + ldr r4, =gUnknown_03005000+0xCCE strb r0, [r4] b _0800FC08 .pool @@ -6863,7 +6863,7 @@ _0800FAAC: b _0800FC04 .pool _0800FAD0: - ldr r1, =gUnknown_030050E4 + ldr r1, =gUnknown_03005000+0xE4 add r1, r8 movs r0, 0x1 strb r0, [r1] @@ -7266,7 +7266,7 @@ _0800FE14: .pool _0800FE20: movs r4, 0 - ldr r3, =gUnknown_030050F2 + ldr r3, =gUnknown_03005000+0xF2 _0800FE24: adds r2, r4, 0x1 lsls r1, r2, 1 @@ -7304,7 +7304,7 @@ sub_800FE50: @ 800FE50 bl sub_8011A80 cmp r0, 0 bne _0800FE76 - ldr r0, =gUnknown_030050F2 + ldr r0, =gUnknown_03005000+0xF2 adds r1, r4, 0 movs r2, 0xC bl memcpy @@ -8255,7 +8255,7 @@ sub_80105EC: @ 80105EC push {r4-r6,lr} movs r3, 0 movs r1, 0 - ldr r5, =gUnknown_03005CD5 + ldr r5, =gUnknown_03005000+0xCD5 movs r6, 0x1 movs r4, 0 _080105F8: @@ -8280,7 +8280,7 @@ _0801060C: bl rfu_waitREQComplete _08010620: movs r1, 0 - ldr r2, =gUnknown_03005CD5 + ldr r2, =gUnknown_03005000+0xCD5 _08010624: adds r0, r1, r2 ldrb r0, [r0] @@ -8756,7 +8756,7 @@ sub_80109E8: @ 80109E8 lsrs r2, r0, 16 movs r1, 0 movs r5, 0x1 - ldr r4, =gUnknown_03005CDE + ldr r4, =gUnknown_03005000+0xCDE movs r3, 0 _080109F6: adds r0, r2, 0 @@ -11163,7 +11163,7 @@ sub_8011DE0: @ 8011DE0 beq _08011E20 movs r3, 0 movs r2, 0 - ldr r5, =gUnknown_03005CDE + ldr r5, =gUnknown_03005000+0xCDE adds r6, r5, 0x4 _08011DF0: adds r0, r2, r5 @@ -11444,7 +11444,7 @@ _08012032: bne _0801202E cmp r5, 0x44 bne _08012092 - ldr r5, =gUnknown_0300510A + ldr r5, =gUnknown_03005000+0x10A ldrh r0, [r5, 0x8] ldr r3, =0x000003ff adds r2, r3, 0 @@ -11686,7 +11686,7 @@ sub_8012240: @ 8012240 movs r1, 0 ldr r0, =gUnknown_03004140 ldrb r2, [r0] - ldr r4, =gUnknown_03005CD1 + ldr r4, =gUnknown_03005000+0xCD1 movs r3, 0x1 _0801224C: adds r0, r2, 0 diff --git a/common_syms/link_rfu.txt b/common_syms/link_rfu.txt new file mode 100644 index 000000000..67dd00ca7 --- /dev/null +++ b/common_syms/link_rfu.txt @@ -0,0 +1,2 @@ +gUnknown_03004140 +gUnknown_03005000 diff --git a/include/link_rfu.h b/include/link_rfu.h index ce9953450..424a4767f 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -32,47 +32,55 @@ struct UnkLinkRfuStruct_02022B2C }; struct UnkRfuStruct_1 { - u8 unk_00; - u8 unk_01; - u8 unk_02; - vu8 unk_03; - u8 unk_04; - u8 unk_05; - u8 unk_06; - u8 unk_07; - u8 unk_08; - u8 unk_09; - u8 unk_0a; - u8 unk_0b; - u8 unk_0c; - u8 unk_0d; - u8 filler_0e[2]; - u8 unk_10; - u8 unk_11; - u8 unk_12; + /* 0x000 */ u8 unk_00; + /* 0x001 */ u8 unk_01; + /* 0x002 */ u8 unk_02; + /* 0x003 */ vu8 unk_03; + /* 0x004 */ u8 unk_04; + /* 0x005 */ u8 unk_05; + /* 0x006 */ u8 unk_06; + /* 0x007 */ u8 unk_07; + /* 0x008 */ u8 unk_08; + /* 0x009 */ u8 unk_09; + /* 0x00a */ u8 unk_0a; + /* 0x00b */ u8 unk_0b; + /* 0x00c */ u8 unk_0c; + /* 0x00d */ u8 unk_0d; + /* 0x00e */ u8 filler_0e[2]; + /* 0x010 */ u8 unk_10; + /* 0x011 */ u8 unk_11; + /* 0x012 */ u8 unk_12; // aligned - u16 unk_14; - u8 filler_16[2]; - u16 unk_18; - u16 unk_1a; - u8 filler_1c[2]; - u16 unk_1e; - u16 *unk_20; - u8 unk_24; - u16 unk_26; - u16 unk_28[4]; - u8 unk_30; + /* 0x014 */ u16 unk_14; + /* 0x016 */ u8 filler_16[2]; + /* 0x018 */ u16 unk_18; + /* 0x01a */ u16 unk_1a; + /* 0x01c */ u8 filler_1c[2]; + /* 0x01e */ u16 unk_1e; + /* 0x020 */ u16 *unk_20; + /* 0x024 */ u8 unk_24; + /* 0x026 */ u16 unk_26; + /* 0x028 */ u16 unk_28[4]; + /* 0x030 */ u8 unk_30; // aligned - u16 unk_32; - u16 unk_34[4]; - struct UnkLinkRfuStruct_02022B2C *unk_3c; - void (*unk_40)(u8); - void (*unk_44)(void); + /* 0x032 */ u16 unk_32; + /* 0x034 */ u16 unk_34[4]; + /* 0x03c */ struct UnkLinkRfuStruct_02022B2C *unk_3c; + /* 0x040 */ void (*unk_40)(u8); + /* 0x044 */ void (*unk_44)(void); + /* 0x048 */ u8 filler_48[0xe78]; +}; + +struct UnkRfuStruct_2 { + /* 0x000 */ u8 filler_00[13]; + /* 0x00d */ u8 playerCount; + /* 0x00e */ u8 filler_0e[0xcea]; }; // Exported RAM declarations extern struct UnkRfuStruct_1 gUnknown_03004140; +extern struct UnkRfuStruct_2 gUnknown_03005000; // Exported ROM declarations u32 sub_800BEC0(void); diff --git a/src/link.c b/src/link.c index 8c6dda32a..eebafef2c 100644 --- a/src/link.c +++ b/src/link.c @@ -2438,5 +2438,3 @@ void ResetRecvBuffer(void) } } } - -// rfu diff --git a/src/link_rfu.c b/src/link_rfu.c index 4f98d945f..9cc4b497a 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -7,9 +7,11 @@ // Static type declarations -struct UnkRfuStruct_1 gUnknown_03004140; - // Static RAM declarations + +struct UnkRfuStruct_1 gUnknown_03004140; +struct UnkRfuStruct_2 gUnknown_03005000; + IWRAM_DATA u8 gUnknown_03000D74; ALIGNED(4) IWRAM_DATA u8 gUnknown_03000D78[8]; IWRAM_DATA u8 gUnknown_03000D80[16]; @@ -80,7 +82,7 @@ int sub_800BF4C(void (*func1)(u8), void (*func2)(void)) { return 4; } - CpuFill16(0, &gUnknown_03004140, sizeof(gUnknown_03004140)); + CpuFill16(0, &gUnknown_03004140, offsetof(struct UnkRfuStruct_1, filler_48)); gUnknown_03004140.unk_06 = -1; gUnknown_03004140.unk_40 = func1; gUnknown_03004140.unk_44 = func2; @@ -91,7 +93,7 @@ int sub_800BF4C(void (*func1)(u8), void (*func2)(void)) void sub_800BFA0(void) { - CpuFill16(0, &gUnknown_03004140, sizeof(gUnknown_03004140) - 2 * sizeof(void *)); + CpuFill16(0, &gUnknown_03004140, offsetof(struct UnkRfuStruct_1, unk_40)); gUnknown_03004140.unk_06 = -1; } diff --git a/sym_common.txt b/sym_common.txt index 488ccd9a7..6a5b0fdc1 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -12,58 +12,7 @@ gUnknown_03002F70: @ 3002F70 .include "text.o" .include "sprite.o" .include "link.o" - -gUnknown_03004140: @ 3004140 - .space 0x48 - -gUnknown_03004188: @ 3004150 - .space 0x8 - -gUnknown_03004190: @ 3004190 - .space 0xE70 - -gUnknown_03005000: @ 3005000 - .space 0x14 - -gUnknown_03005014: @ 3005014 - .space 0x58 - -gUnknown_0300506C: @ 300506C - .space 0x2 - -gUnknown_0300506E: @ 300506E - .space 0x76 - -gUnknown_030050E4: @ 30050E4 - .space 0xE - -gUnknown_030050F2: @ 30050F2 - .space 0x18 - -gUnknown_0300510A: @ 300510A - .space 0x1A - -gUnknown_03005124: @ 3005124 - .space 0x8C4 - -gUnknown_030059E8: @ 30059E8 - .space 0x29F - -gUnknown_03005C87: @ 3005C87 - .space 0x47 - -gUnknown_03005CCE: @ 3005CCE - .space 0x3 - -gUnknown_03005CD1: @ 3005CD1 - .space 0x4 - -gUnknown_03005CD5: @ 3005CD5 - .space 0x9 - -gUnknown_03005CDE: @ 3005CDE - .space 0x1A - + .include "link_rfu.o" .include "rtc.o" gPreBattleCallback1: @ 3005D00