diff --git a/asm/link_rfu.s b/asm/link_rfu.s index 2f5ed4cec..7c5cd94e1 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -7,155 +7,6 @@ @ file boundary? - thumb_func_start sub_800DE7C -sub_800DE7C: @ 800DE7C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r7, r0, 0 - mov r8, r1 - lsls r2, 24 - lsrs r5, r2, 24 - ldr r0, =gUnknown_03004140 - ldrb r0, [r0, 0x6] - cmp r0, 0x1 - bne _0800DED8 - movs r0, 0x1 - mov r9, r0 - ldr r6, =gUnknown_03007890 - ldr r0, [r6] - lsls r4, r5, 5 - adds r0, r4 - ldrh r0, [r0, 0x18] - bl sub_8010454 - cmp r0, 0 - beq _0800DEB8 - ldr r1, [r6] - ldrb r0, [r1, 0x7] - asrs r0, r5 - mov r2, r9 - ands r0, r2 - cmp r0, 0 - bne _0800DEF0 -_0800DEB8: - adds r0, r7, 0 - movs r1, 0 - movs r2, 0xD - bl memset - mov r0, r8 - movs r1, 0 - movs r2, 0x8 - bl memset - b _0800DF24 - .pool -_0800DED8: - movs r0, 0 - mov r9, r0 - ldr r6, =gUnknown_03007890 - ldr r0, [r6] - lsls r4, r5, 5 - adds r0, r4 - ldrh r0, [r0, 0x18] - bl sub_8010454 - cmp r0, 0 - beq _0800DF10 - ldr r1, [r6] -_0800DEF0: - adds r1, r4, r1 - adds r1, 0x1A - adds r0, r7, 0 - movs r2, 0xD - bl memcpy - ldr r1, [r6] - adds r1, r4, r1 - adds r1, 0x29 - mov r0, r8 - movs r2, 0x8 - bl memcpy - b _0800DF24 - .pool -_0800DF10: - adds r0, r7, 0 - movs r1, 0 - movs r2, 0xD - bl memset - mov r0, r8 - movs r1, 0 - movs r2, 0x8 - bl memset -_0800DF24: - mov r0, r9 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_800DE7C - - thumb_func_start sub_800DF34 -sub_800DF34: @ 800DF34 - push {r4-r7,lr} - adds r3, r0, 0 - adds r5, r1, 0 - lsls r2, 24 - movs r7, 0 - ldr r6, =gUnknown_03007890 - ldr r0, [r6] - lsrs r4, r2, 19 - adds r2, r0, r4 - ldrh r1, [r2, 0x18] - ldr r0, =0x00007f7d - cmp r1, r0 - bne _0800DF74 - adds r1, r2, 0 - adds r1, 0x1A - adds r0, r3, 0 - movs r2, 0xD - bl memcpy - ldr r1, [r6] - adds r1, r4, r1 - adds r1, 0x29 - adds r0, r5, 0 - movs r2, 0x8 - bl memcpy - movs r7, 0x1 - b _0800DF88 - .pool -_0800DF74: - adds r0, r3, 0 - movs r1, 0 - movs r2, 0xD - bl memset - adds r0, r5, 0 - movs r1, 0 - movs r2, 0x8 - bl memset -_0800DF88: - adds r0, r7, 0 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_800DF34 - - thumb_func_start sub_800DF90 -sub_800DF90: @ 800DF90 - push {r4,lr} - adds r4, r1, 0 - ldr r1, =gUnknown_02022B14 - movs r2, 0xD - bl memcpy - ldr r1, =gUnknown_02022B14 + 0xE - adds r0, r4, 0 - movs r2, 0x8 - bl memcpy - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800DF90 - thumb_func_start sub_800DFB4 sub_800DFB4: @ 800DFB4 push {r4,r5,lr} diff --git a/include/librfu.h b/include/librfu.h index a012b64ec..1f22133b9 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -159,7 +159,8 @@ struct RfuUnk5 u16 unk_00; u8 unk_02; u16 unk_04; - u8 filler_06[26]; + u8 unk_06[15]; + u8 unk_15[11]; } unk_14[4]; }; diff --git a/include/link_rfu.h b/include/link_rfu.h index 9b7fa6e7e..1d430cb51 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -3,7 +3,7 @@ // Exported type declarations -struct UnkLinkRfuStruct_02022B14 +struct __attribute__((packed)) UnkLinkRfuStruct_02022B14 { u16 unk_00_0:4; u16 unk_00_4:1; @@ -23,8 +23,6 @@ struct UnkLinkRfuStruct_02022B14 u8 playerGender:1; u8 unk_0b_1:7; u8 unk_0c; - u8 unk_0d; - u8 filler_0e[8]; }; struct UnkLinkRfuStruct_02022B2C diff --git a/src/link_rfu.c b/src/link_rfu.c index bf7e92e69..c1a3b1d09 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -21,7 +21,8 @@ IWRAM_DATA u8 gUnknown_03000D80[16]; IWRAM_DATA u16 gUnknown_03000D90[8]; EWRAM_DATA u8 gUnknown_02022B10 = 0; -EWRAM_DATA struct UnkLinkRfuStruct_02022B14 gUnknown_02022B14 = {}; +EWRAM_DATA ALIGNED(4) struct UnkLinkRfuStruct_02022B14 gUnknown_02022B14 = {}; +EWRAM_DATA ALIGNED(2) u8 gUnknown_02022B22[8] = {}; EWRAM_DATA struct UnkLinkRfuStruct_02022B2C gUnknown_02022B2C = {}; // Static ROM declarations @@ -42,6 +43,7 @@ static void sub_800D434(void); static void sub_800D610(void); void sub_800D630(void); bool8 sub_800DAC8(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); +bool32 sub_8010454(u16 a0); // .rodata @@ -1953,3 +1955,61 @@ void sub_800DD94(struct UnkLinkRfuStruct_02022B14 *data, u8 r9, bool32 r2, int r data->unk_01_0 = IsNationalPokedexEnabled(); data->unk_01_1 = FlagGet(FLAG_SYS_GAME_CLEAR); } + +bool8 sub_800DE7C(void *buff1, void *buff2, u8 idx) +{ + bool8 retVal; + + if (gUnknown_03004140.unk_06 == 1) + { + retVal = TRUE; + if (sub_8010454(gUnknown_03007890->unk_14[idx].unk_04) && ((gUnknown_03007890->unk_07 >> idx) & 1)) + { + memcpy(buff1, gUnknown_03007890->unk_14[idx].unk_06, 13); + memcpy(buff2, gUnknown_03007890->unk_14[idx].unk_15, 8); + } + else + { + memset(buff1, 0, 13); + memset(buff2, 0, 8); + } + } + else + { + retVal = FALSE; + if (sub_8010454(gUnknown_03007890->unk_14[idx].unk_04)) + { + memcpy(buff1, gUnknown_03007890->unk_14[idx].unk_06, 13); + memcpy(buff2, gUnknown_03007890->unk_14[idx].unk_15, 8); + } + else + { + memset(buff1, 0, 13); + memset(buff2, 0, 8); + } + } + return retVal; +} + +bool8 sub_800DF34(void *buff1, void *buff2, u8 idx) +{ + bool8 retVal = FALSE; + if (gUnknown_03007890->unk_14[idx].unk_04 == 0x7F7D) + { + memcpy(buff1, gUnknown_03007890->unk_14[idx].unk_06, 13); + memcpy(buff2, gUnknown_03007890->unk_14[idx].unk_15, 8); + retVal = TRUE; + } + else + { + memset(buff1, 0, 13); + memset(buff2, 0, 8); + } + return retVal; +} + +void sub_800DF90(void *buff1, void *buff2) +{ + memcpy(buff1, &gUnknown_02022B14, 13); + memcpy(buff2, gUnknown_02022B22, 8); +}