From e2244831a77723a1a565b8df24dda3ade00f584f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 1 Dec 2017 21:51:06 -0500 Subject: [PATCH] through sub_800DB18 --- asm/link_rfu.s | 160 --------------------------------------------- include/link_rfu.h | 10 ++- src/link_rfu.c | 69 +++++++++++++++++++ 3 files changed, 78 insertions(+), 161 deletions(-) diff --git a/asm/link_rfu.s b/asm/link_rfu.s index f8d6eddcd8..3667d39bc3 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -7,166 +7,6 @@ @ file boundary? - thumb_func_start sub_800DA68 -sub_800DA68: @ 800DA68 - push {r4,lr} - adds r2, r0, 0 - adds r4, r1, 0 - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _0800DA7E - adds r0, r2, 0 - movs r1, 0 - bl sub_800DAC8 - b _0800DAC0 -_0800DA7E: - movs r3, 0 -_0800DA80: - ldrb r1, [r2, 0x1C] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 1 - adds r0, r3, r0 - adds r0, r2, r0 - adds r1, r4, r3 - ldrb r1, [r1] - strb r1, [r0] - adds r3, 0x1 - cmp r3, 0xD - ble _0800DA80 - ldrb r0, [r2, 0x1C] - adds r0, 0x1 - ldrb r1, [r2, 0x1C] - strb r0, [r2, 0x1C] - ldrb r1, [r2, 0x1C] - movs r0, 0x1 - ands r0, r1 - ldrb r1, [r2, 0x1C] - strb r0, [r2, 0x1C] - ldrb r0, [r2, 0x1E] - cmp r0, 0x1 - bhi _0800DABA - ldrb r0, [r2, 0x1E] - adds r0, 0x1 - ldrb r1, [r2, 0x1E] - strb r0, [r2, 0x1E] - b _0800DAC0 -_0800DABA: - ldrb r0, [r2, 0x1C] - ldrb r1, [r2, 0x1D] - strb r0, [r2, 0x1D] -_0800DAC0: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_800DA68 - - thumb_func_start sub_800DAC8 -sub_800DAC8: @ 800DAC8 - push {r4,r5,lr} - adds r3, r0, 0 - adds r5, r1, 0 - ldrb r0, [r3, 0x1E] - cmp r0, 0 - bne _0800DAD8 - movs r0, 0 - b _0800DB12 -_0800DAD8: - cmp r5, 0 - beq _0800DAF6 - movs r4, 0 -_0800DADE: - adds r2, r5, r4 - ldrb r1, [r3, 0x1D] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 1 - adds r0, r4, r0 - adds r0, r3, r0 - ldrb r0, [r0] - strb r0, [r2] - adds r4, 0x1 - cmp r4, 0xD - ble _0800DADE -_0800DAF6: - ldrb r0, [r3, 0x1D] - adds r0, 0x1 - ldrb r1, [r3, 0x1D] - strb r0, [r3, 0x1D] - ldrb r1, [r3, 0x1D] - movs r0, 0x1 - ands r0, r1 - ldrb r1, [r3, 0x1D] - strb r0, [r3, 0x1D] - ldrb r0, [r3, 0x1E] - subs r0, 0x1 - ldrb r1, [r3, 0x1E] - strb r0, [r3, 0x1E] - movs r0, 0x1 -_0800DB12: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_800DAC8 - - thumb_func_start sub_800DB18 -sub_800DB18: @ 800DB18 - push {r4,r5,lr} - adds r3, r0, 0 - adds r5, r1, 0 - ldr r1, =0x00000202 - adds r0, r3, r1 - ldrb r0, [r0] - cmp r0, 0x1 - bhi _0800DB70 - movs r2, 0 - movs r0, 0x80 - lsls r0, 2 - adds r4, r3, r0 -_0800DB30: - ldrb r0, [r4] - lsls r0, 8 - adds r0, r2, r0 - adds r0, r3, r0 - adds r1, r5, r2 - ldrb r1, [r1] - strb r1, [r0] - adds r2, 0x1 - cmp r2, 0xFF - ble _0800DB30 - movs r0, 0x80 - lsls r0, 2 - adds r1, r3, r0 - ldrb r0, [r1] - adds r0, 0x1 - ldrb r2, [r1] - strb r0, [r1] - ldrb r2, [r1] - movs r0, 0x1 - ands r0, r2 - ldrb r2, [r1] - strb r0, [r1] - ldr r0, =0x00000202 - adds r1, r3, r0 - ldrb r0, [r1] - adds r0, 0x1 - ldrb r2, [r1] - strb r0, [r1] - b _0800DB7A - .pool -_0800DB70: - ldr r1, =0x00000203 - adds r0, r3, r1 - ldrb r1, [r0] - movs r1, 0x1 - strb r1, [r0] -_0800DB7A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800DB18 - thumb_func_start sub_800DB84 sub_800DB84: @ 800DB84 push {r4,r5,lr} diff --git a/include/link_rfu.h b/include/link_rfu.h index ad313d5dad..28e244503d 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -94,6 +94,13 @@ struct UnkRfuStruct_2_Sub_9e8 { /* 0x233 */ vu8 unk_233; }; +struct UnkRfuStruct_2_Sub_c1c { + /* 0x00 */ u8 unk_00[2][14]; + /* 0x1c */ vu8 unk_1c; + /* 0x1d */ vu8 unk_1d; + /* 0x1e */ vu8 unk_1e; +}; + struct UnkRfuStruct_Sub_Unused { /* 0x000 */ u8 unk_00[2][256]; /* 0x200 */ vu8 unk_200; @@ -109,7 +116,8 @@ struct UnkRfuStruct_2 { /* 0x06c */ u8 filler_6c[0xb8]; /* 0x124 */ struct UnkRfuStruct_2_Sub_124 unk_124; /* 0x9e8 */ struct UnkRfuStruct_2_Sub_9e8 unk_9e8; - /* 0xc1c */ u8 filler_c1c[0x23]; + /* 0xc1c */ struct UnkRfuStruct_2_Sub_c1c unk_c1c; + /* 0xc3c */ u8 filler_c3c[3]; /* 0xc3f */ u8 filler_c3f[0xb9]; }; // size = 0xcf8 diff --git a/src/link_rfu.c b/src/link_rfu.c index e3ed186042..63776a298b 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -38,6 +38,7 @@ static void sub_800D358(u8 a0); 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); // .rodata @@ -1596,3 +1597,71 @@ bool8 sub_800D9DC(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2) REG_IME = imeBak; return TRUE; } + +void sub_800DA68(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2) +{ + int i; + + if (q2[1] == 0) + { + sub_800DAC8(q1, NULL); + } + else + { + for (i = 0; i < 14; i++) + { + q1->unk_00[q1->unk_1c][i] = q2[i]; + } + q1->unk_1c++; + q1->unk_1c %= 2; + if (q1->unk_1e < 2) + { + q1->unk_1e++; + } + else + { + q1->unk_1d = q1->unk_1c; + } + } +} + +bool8 sub_800DAC8(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2) +{ + int i; + + if (q1->unk_1e == 0) + { + return FALSE; + } + if (q2 != NULL) + { + for (i = 0; i < 14; i++) + { + q2[i] = q1->unk_00[q1->unk_1d][i]; + } + } + q1->unk_1d++; + q1->unk_1d %= 2; + q1->unk_1e--; + return TRUE; +} + +void sub_800DB18(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2) +{ + int i; + + if (q1->unk_202 < 2) + { + for (i = 0; i < 256; i++) + { + q1->unk_00[q1->unk_200][i] = q2[i]; + } + q1->unk_200++; + q1->unk_200 %= 2; + q1->unk_202++; + } + else + { + q1->unk_203 = 1; + } +}