From d51f87226f029143dfb027f5e7bc36c64c5959eb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 8 Nov 2017 20:11:29 -0500 Subject: [PATCH] sub_80099E0 --- asm/link.s | 71 ------------------------------------------------------ src/link.c | 46 ++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 72 deletions(-) diff --git a/asm/link.s b/asm/link.s index 345a68899..cedc3077f 100644 --- a/asm/link.s +++ b/asm/link.s @@ -5,77 +5,6 @@ .text - thumb_func_start c2_08009A8C -c2_08009A8C: @ 80099BC - push {lr} - bl sub_8009900 - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl sub_8009818 - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end c2_08009A8C - - thumb_func_start sub_80099E0 -sub_80099E0: @ 80099E0 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r0, =gUnknown_020229C4 - ldrb r0, [r0] - cmp r0, 0 - bne _080099F4 - movs r0, 0 - b _08009A3C - .pool -_080099F4: - movs r1, 0 - ldr r5, =gUnknown_03003084 - ldr r3, =gUnknown_03003110 - movs r2, 0 -_080099FC: - lsls r0, r1, 1 - adds r0, r3 - strh r2, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x7 - bls _080099FC - ldrh r0, [r4] - strh r0, [r5] - ldr r0, =gUnknown_030030E0 - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08009A38 - ldr r0, =0x04000128 - ldr r0, [r0] - lsls r0, 26 - lsrs r0, 30 - bl sub_8009AA0 - ldr r0, =gUnknown_03003140 - ldr r0, [r0] - cmp r0, 0 - beq _08009A34 - bl _call_via_r0 -_08009A34: - bl sub_800AEB4 -_08009A38: - ldr r0, =gUnknown_030030E0 - ldrh r0, [r0] -_08009A3C: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80099E0 - thumb_func_start sub_8009A58 sub_8009A58: @ 8009A58 push {r4-r6,lr} diff --git a/src/link.c b/src/link.c index 327a170d0..c07a6d701 100644 --- a/src/link.c +++ b/src/link.c @@ -31,6 +31,13 @@ struct LinkTestBGInfo u32 dummy_C; }; +struct SIOCnt { + u32 cnt0_0:4; + u32 cnt0_2:2; +}; + +#define REG_SIOCNT_STRUCT (*(volatile struct SIOCnt *)REG_ADDR_SIOCNT) + // Static RAM declarations IWRAM_DATA struct BlockTransfer gUnknown_03000D10; @@ -98,12 +105,14 @@ struct LinkPlayer gUnknown_020229CC = {}; void sub_8009638(void); void sub_80096BC(void); void c2_08009A8C(void); +void sub_8009AA0(u8 unused); void sub_800A2E0(void); void sub_800A2F4(void *heapptr, size_t src); void task00_link_test(u8 taskId); u16 sub_800A648(u16 *src, u16 size); void sub_800A6E8(u32 pos, u8 a0, u8 a1, u8 a2); void sub_800A824(void); +void sub_800AEB4(void); void sub_800B330(bool8 flag); void sub_800B4A4(void); void sub_800B53C(void); @@ -316,7 +325,7 @@ void sub_80097E8(void) sub_800B53C(); } -void sub_8009818(void) +static void sub_8009818(u8 nothing, u8 is, u8 used) { u8 i; u8 status; @@ -384,3 +393,38 @@ void sub_8009900(void) sub_800A994(gMain.vblankCounter2, gUnknown_03003140 ? gUnknown_03002748 : gUnknown_03002748 | 0x10); } } + +void c2_08009A8C(void) +{ + sub_8009900(); + sub_8009818(1, 1, 0); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +u16 sub_80099E0(const u16 *src) +{ + u8 i; + + if (!gUnknown_020229C4) + { + return 0; + } + for (i = 0; i < 8; i ++) + { + gUnknown_03003110[i] = 0; + } + gUnknown_03003084 = *src; + if (gUnknown_030030E0 & 0x40) + { + sub_8009AA0(REG_SIOCNT_STRUCT.cnt0_2); + if (gUnknown_03003140 != NULL) + { + gUnknown_03003140(); + } + sub_800AEB4(); + } + return gUnknown_030030E0; +}