From 4f342198c2e4c579d0f3b42aa85eb6699145ad5f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 Dec 2017 23:55:40 -0500 Subject: [PATCH] sub_800E88C --- asm/link_rfu.s | 109 --------------------------------------------- include/link_rfu.h | 4 +- src/link_rfu.c | 44 ++++++++++++++++++ 3 files changed, 47 insertions(+), 110 deletions(-) diff --git a/asm/link_rfu.s b/asm/link_rfu.s index 94eb4a625..17bf9231c 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -5,115 +5,6 @@ .text - thumb_func_start sub_800E88C -sub_800E88C: @ 800E88C - push {r4-r7,lr} - adds r2, r0, 0 - adds r5, r1, 0 - movs r4, 0x1 - adds r1, r2, 0 - movs r6, 0 - movs r0, 0x1 - negs r0, r0 - cmp r5, r0 - bne _0800E8CC - movs r3, 0 - movs r5, 0x1 - ldr r1, =gUnknown_03005000+0xCDE -_0800E8A6: - adds r0, r2, 0 - ands r0, r5 - cmp r0, 0 - beq _0800E8B8 - adds r0, r3, r1 - strb r4, [r0] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_0800E8B8: - asrs r2, 1 - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3 - bls _0800E8A6 - b _0800E942 - .pool -_0800E8CC: - movs r3, 0 - mvns r0, r1 - mov r12, r0 - movs r7, 0x1 - ldr r4, =gUnknown_03005000+0xCDE -_0800E8D6: - adds r2, r1, 0 - ands r2, r7 - cmp r2, 0 - bne _0800E8E2 - adds r0, r3, r4 - strb r2, [r0] -_0800E8E2: - asrs r1, 1 - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3 - bls _0800E8D6 - movs r4, 0x4 - ldr r0, =gUnknown_03005000+0xCDE - ldrb r7, [r0] -_0800E8F4: - movs r3, 0 - subs r1, r4, 0x1 - cmp r7, r4 - beq _0800E910 - ldr r2, =gUnknown_03005000+0xCDE -_0800E8FE: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3 - bhi _0800E910 - adds r0, r3, r2 - ldrb r0, [r0] - cmp r0, r4 - bne _0800E8FE -_0800E910: - cmp r3, 0x4 - bne _0800E916 - adds r6, r4, 0 -_0800E916: - lsls r0, r1, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _0800E8F4 - mov r0, r12 - ands r5, r0 - movs r3, 0 - movs r2, 0x1 - ldr r1, =gUnknown_03005000+0xCDE -_0800E928: - adds r0, r5, 0 - ands r0, r2 - cmp r0, 0 - beq _0800E936 - adds r0, r3, r1 - strb r6, [r0] - adds r6, 0x1 -_0800E936: - asrs r5, 1 - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3 - bls _0800E928 -_0800E942: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800E88C - thumb_func_start sub_800E94C sub_800E94C: @ 800E94C push {r4-r7,lr} diff --git a/include/link_rfu.h b/include/link_rfu.h index f0b8ca84c..54d513b10 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -143,7 +143,9 @@ struct UnkRfuStruct_2 { /* 0xc3c */ u8 filler_c3c[3]; /* 0xc3f */ u8 filler_c3f[0x9c]; /* 0xcdb */ vu8 unk_cdb; - /* 0xcdc */ u8 filler_cdc[0x18]; + /* 0xcdc */ u8 filler_cdc[2]; + /* 0xcde */ u8 unk_cde[4]; + /* 0xce2 */ u8 filler_ce2[18]; }; // size = 0xcf4 // Exported RAM declarations diff --git a/src/link_rfu.c b/src/link_rfu.c index e21e79c41..46a765709 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -2523,3 +2523,47 @@ u8 sub_800E87C(u8 idx) { return gUnknown_082ED6A5[idx]; } + +void sub_800E88C(int r2, int r5) +{ + u8 i; + u8 r4 = 1; + int r1 = r2; + int r6 = 0; + if (r5 == -1) + { + for (i = 0; i < 4; r2 >>= 1, i++) + { + if (r2 & 1) + { + gUnknown_03005000.unk_cde[i] = r4; + r4++; + } + } + } + else + { + for (i = 0; i < 4; r1 >>= 1, i++) + { + if (!(r1 & 1)) + { + gUnknown_03005000.unk_cde[i] = 0; + } + } + for (r4 = 4; r4 != 0; r4--) + { + for (i = 0; i < 4 && gUnknown_03005000.unk_cde[i] != r4; i++); + if (i == 4) + { + r6 = r4; + } + } + for (r5 &= ~r2, i = 0; i < 4; r5 >>= 1, i++) + { + if (r5 & 1) + { + gUnknown_03005000.unk_cde[i] = r6++; + } + } + } +}