From 788caa4fe2fcc7bd4673e947f8f30a0a0d3899ef Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 23 Feb 2019 13:34:01 +0100 Subject: [PATCH] pokenav --- asm/pokenav.s | 1204 +++++++++++--------------------------------- include/graphics.h | 1 + src/pokenav.c | 734 +++++++++++++++++---------- 3 files changed, 763 insertions(+), 1176 deletions(-) diff --git a/asm/pokenav.s b/asm/pokenav.s index 01ba420aa..d568f4281 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -5,645 +5,9 @@ .text - thumb_func_start sub_81C7CE4 -sub_81C7CE4: @ 81C7CE4 - push {r4,lr} - movs r0, 0 - bl sub_81C763C - ldr r2, [r0, 0x18] - movs r4, 0 - movs r1, 0xDC - strh r1, [r2, 0x20] - ldr r2, [r0, 0x18] - movs r1, 0xC - strh r1, [r2, 0x22] - ldr r2, [r0, 0x18] - ldr r1, =sub_81C7CB4 - str r1, [r2, 0x1C] - adds r2, 0x3E - ldrb r3, [r2] - movs r1, 0x5 - negs r1, r1 - ands r1, r3 - strb r1, [r2] - ldr r3, [r0, 0x18] - ldrb r2, [r3, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - strb r1, [r3, 0x5] - ldr r0, [r0, 0x18] - adds r0, 0x43 - strb r4, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C7CE4 - thumb_func_start sub_81C7D28 -sub_81C7D28: @ 81C7D28 - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r0, 0 - bl sub_81C763C - adds r6, r0, 0 - ldr r0, =gUnknown_0861FA64 - bl LoadCompressedSpriteSheet - movs r0, 0x1 - bl AllocSpritePalette - movs r0, 0x2 - bl AllocSpritePalette - movs r5, 0 - ldr r0, =gSprites - mov r8, r0 - movs r7, 0x4 -_081C7D50: - ldr r0, =gUnknown_0861FB2C - movs r1, 0 - movs r2, 0 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - lsls r4, r5, 2 - adds r2, r6, 0 - adds r2, 0x1C - adds r2, r4 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - str r0, [r2] - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r7 - strb r1, [r0] - ldr r1, [r2] - lsls r0, r5, 6 - strh r0, [r1, 0x24] - ldr r0, =gUnknown_0861FB44 - movs r1, 0 - movs r2, 0 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - adds r2, r6, 0 - adds r2, 0x24 - adds r2, r4 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - str r0, [r2] - adds r0, 0x3E - ldrb r1, [r0] - orrs r1, r7 - strb r1, [r0] - ldr r1, [r2] - lsls r0, r5, 5 - strh r0, [r1, 0x24] - ldr r1, [r2] - movs r0, 0x12 - strh r0, [r1, 0x26] - ldr r3, [r2] - ldrh r2, [r3, 0x4] - lsls r1, r2, 22 - lsrs r1, 22 - lsls r0, r5, 3 - adds r0, 0x40 - adds r1, r0 - ldr r4, =0x000003ff - adds r0, r4, 0 - ands r1, r0 - ldr r4, =0xfffffc00 - adds r0, r4, 0 - ands r2, r0 - orrs r2, r1 - strh r2, [r3, 0x4] - adds r5, 0x1 - cmp r5, 0x1 - ble _081C7D50 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C7D28 - thumb_func_start sub_81C7DFC -sub_81C7DFC: @ 81C7DFC - push {lr} - cmp r0, 0x5 - bhi _081C7E08 - bl sub_81C7E58 - b _081C7E0E -_081C7E08: - subs r0, 0x6 - bl sub_81C7F24 -_081C7E0E: - pop {r0} - bx r0 - thumb_func_end sub_81C7DFC - thumb_func_start sub_81C7E14 -sub_81C7E14: @ 81C7E14 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0 - bl sub_81C763C - adds r5, r0, 0 - cmp r4, 0x4 - bne _081C7E30 - movs r0, 0x2 - bl GetSpriteTileStartByTag - ldr r3, [r5, 0x20] - adds r0, 0x20 - b _081C7E3A -_081C7E30: - movs r0, 0x2 - bl GetSpriteTileStartByTag - ldr r3, [r5, 0x20] - adds r0, 0x40 -_081C7E3A: - ldr r2, =0x000003ff - adds r1, r2, 0 - ands r0, r1 - ldrh r2, [r3, 0x4] - ldr r1, =0xfffffc00 - ands r1, r2 - orrs r1, r0 - strh r1, [r3, 0x4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C7E14 - - thumb_func_start sub_81C7E58 -sub_81C7E58: @ 81C7E58 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - mov r9, r0 - cmp r0, 0x5 - bhi _081C7F16 - movs r0, 0 - bl sub_81C763C - adds r7, r0, 0 - ldr r0, =gUnknown_0861FA6C - mov r1, r9 - lsls r6, r1, 3 - adds r6, r0 - ldrh r4, [r6, 0x6] - ldr r2, [r6] - mov r8, r2 - mov r0, r8 - bl GetDecompressedDataSize - adds r5, r0, 0 - lsls r4, 5 - ldr r0, =gPokenavLeftHeader_Pal - adds r4, r0 - movs r0, 0x1 - bl IndexOfSpritePaletteTag - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 4 - movs r0, 0x80 - lsls r0, 17 - adds r1, r0 - lsrs r1, 16 - adds r0, r4, 0 - movs r2, 0x20 - bl LoadPalette - ldr r4, =gDecompressionBuffer - mov r0, r8 - adds r1, r4, 0 - bl LZ77UnCompWram - movs r0, 0x2 - bl GetSpriteTileStartByTag - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 11 - ldr r2, =0x06010000 - adds r1, r2 - lsls r5, 16 - lsrs r5, 16 - adds r0, r4, 0 - adds r2, r5, 0 - movs r3, 0x1 - bl RequestDma3Copy - movs r0, 0x2 - bl GetSpriteTileStartByTag - ldr r3, [r7, 0x20] - ldrh r1, [r6, 0x4] - adds r0, r1 - ldr r2, =0x000003ff - adds r1, r2, 0 - ands r0, r1 - ldrh r2, [r3, 0x4] - ldr r1, =0xfffffc00 - ands r1, r2 - orrs r1, r0 - strh r1, [r3, 0x4] - mov r0, r9 - subs r0, 0x4 - cmp r0, 0x1 - bhi _081C7F10 - ldr r1, [r7, 0x20] - movs r0, 0x38 - b _081C7F14 - .pool -_081C7F10: - ldr r1, [r7, 0x20] - movs r0, 0x40 -_081C7F14: - strh r0, [r1, 0x24] -_081C7F16: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C7E58 - - thumb_func_start sub_81C7F24 -sub_81C7F24: @ 81C7F24 - push {r4-r6,lr} - cmp r0, 0x6 - bhi _081C7F8A - ldr r2, =gUnknown_0861FA9C - lsls r1, r0, 3 - adds r0, r2, 0x4 - adds r0, r1, r0 - ldr r4, [r0] - adds r1, r2 - ldr r6, [r1] - adds r0, r6, 0 - bl GetDecompressedDataSize - adds r5, r0, 0 - lsls r4, 5 - ldr r0, =gPokenavLeftHeader_Pal - adds r4, r0 - movs r0, 0x2 - bl IndexOfSpritePaletteTag - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 4 - movs r0, 0x80 - lsls r0, 17 - adds r1, r0 - lsrs r1, 16 - adds r0, r4, 0 - movs r2, 0x20 - bl LoadPalette - ldr r4, =gDecompressionBuffer+0x1000 - adds r0, r6, 0 - adds r1, r4, 0 - bl LZ77UnCompWram - movs r0, 0x2 - bl GetSpriteTileStartByTag - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 11 - ldr r0, =0x06010800 - adds r1, r0 - lsls r5, 16 - lsrs r5, 16 - adds r0, r4, 0 - adds r2, r5, 0 - movs r3, 0x1 - bl RequestDma3Copy -_081C7F8A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C7F24 - - thumb_func_start sub_81C7FA0 -sub_81C7FA0: @ 81C7FA0 - push {lr} - adds r3, r0, 0 - movs r0, 0x10 - cmp r1, 0 - bne _081C7FAC - movs r0, 0x30 -_081C7FAC: - cmp r3, 0x5 - bhi _081C7FB8 - adds r1, r2, 0 - bl sub_81C803C - b _081C7FBE -_081C7FB8: - adds r1, r2, 0 - bl sub_81C8088 -_081C7FBE: - pop {r0} - bx r0 - thumb_func_end sub_81C7FA0 - - thumb_func_start sub_81C7FC4 -sub_81C7FC4: @ 81C7FC4 - push {lr} - cmp r0, 0x5 - bhi _081C7FD2 - adds r0, r1, 0 - bl sub_81C80D4 - b _081C7FD8 -_081C7FD2: - adds r0, r1, 0 - bl sub_81C8110 -_081C7FD8: - pop {r0} - bx r0 - thumb_func_end sub_81C7FC4 - - thumb_func_start sub_81C7FDC -sub_81C7FDC: @ 81C7FDC - push {r4,lr} - movs r0, 0 - bl sub_81C763C - movs r4, 0x4 - adds r2, r0, 0 - adds r2, 0x1C - movs r3, 0x1 -_081C7FEC: - ldr r1, [r2] - adds r1, 0x3E - ldrb r0, [r1] - orrs r0, r4 - strb r0, [r1] - ldr r1, [r2, 0x8] - adds r1, 0x3E - ldrb r0, [r1] - orrs r0, r4 - strb r0, [r1] - adds r2, 0x4 - subs r3, 0x1 - cmp r3, 0 - bge _081C7FEC - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81C7FDC - - thumb_func_start sub_81C8010 -sub_81C8010: @ 81C8010 - push {lr} - movs r0, 0 - bl sub_81C763C - adds r1, r0, 0 - ldr r0, [r1, 0x1C] - ldr r2, [r0, 0x1C] - ldr r0, =SpriteCallbackDummy - cmp r2, r0 - bne _081C8034 - ldr r0, [r1, 0x24] - ldr r0, [r0, 0x1C] - cmp r0, r2 - bne _081C8034 - movs r0, 0 - b _081C8036 - .pool -_081C8034: - movs r0, 0x1 -_081C8036: - pop {r1} - bx r1 - thumb_func_end sub_81C8010 - - thumb_func_start sub_81C803C -sub_81C803C: @ 81C803C - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r8, r0 - adds r4, r1, 0 - movs r0, 0 - bl sub_81C763C - cmp r4, 0 - bne _081C8058 - movs r7, 0x60 - negs r7, r7 - movs r6, 0x20 - b _081C805E -_081C8058: - movs r7, 0x80 - lsls r7, 1 - movs r6, 0xA0 -_081C805E: - adds r4, r0, 0 - adds r4, 0x1C - movs r5, 0x1 -_081C8064: - ldr r0, [r4] - mov r1, r8 - strh r1, [r0, 0x22] - ldm r4!, {r0} - adds r1, r7, 0 - adds r2, r6, 0 - movs r3, 0xC - bl sub_81C814C - subs r5, 0x1 - cmp r5, 0 - bge _081C8064 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C803C - - thumb_func_start sub_81C8088 -sub_81C8088: @ 81C8088 - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r8, r0 - adds r4, r1, 0 - movs r0, 0 - bl sub_81C763C - cmp r4, 0 - bne _081C80A4 - movs r7, 0x60 - negs r7, r7 - movs r6, 0x10 - b _081C80AA -_081C80A4: - movs r7, 0x80 - lsls r7, 1 - movs r6, 0xC0 -_081C80AA: - adds r4, r0, 0 - adds r4, 0x24 - movs r5, 0x1 -_081C80B0: - ldr r0, [r4] - mov r1, r8 - strh r1, [r0, 0x22] - ldm r4!, {r0} - adds r1, r7, 0 - adds r2, r6, 0 - movs r3, 0xC - bl sub_81C814C - subs r5, 0x1 - cmp r5, 0 - bge _081C80B0 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C8088 - - thumb_func_start sub_81C80D4 -sub_81C80D4: @ 81C80D4 - push {r4-r7,lr} - adds r4, r0, 0 - movs r0, 0 - bl sub_81C763C - cmp r4, 0 - bne _081C80EA - movs r6, 0x20 - movs r5, 0x60 - negs r5, r5 - b _081C80F0 -_081C80EA: - movs r6, 0xC0 - movs r5, 0x80 - lsls r5, 1 -_081C80F0: - adds r7, r0, 0 - adds r7, 0x1C - movs r4, 0x1 -_081C80F6: - ldm r7!, {r0} - adds r1, r6, 0 - adds r2, r5, 0 - movs r3, 0xC - bl sub_81C814C - subs r4, 0x1 - cmp r4, 0 - bge _081C80F6 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C80D4 - - thumb_func_start sub_81C8110 -sub_81C8110: @ 81C8110 - push {r4-r7,lr} - adds r4, r0, 0 - movs r0, 0 - bl sub_81C763C - cmp r4, 0 - bne _081C8126 - movs r6, 0x10 - movs r5, 0x60 - negs r5, r5 - b _081C812C -_081C8126: - movs r6, 0xC0 - movs r5, 0x80 - lsls r5, 1 -_081C812C: - adds r7, r0, 0 - adds r7, 0x24 - movs r4, 0x1 -_081C8132: - ldm r7!, {r0} - adds r1, r6, 0 - adds r2, r5, 0 - movs r3, 0xC - bl sub_81C814C - subs r4, 0x1 - cmp r4, 0 - bge _081C8132 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C8110 - - thumb_func_start sub_81C814C -sub_81C814C: @ 81C814C - push {r4-r6,lr} - adds r4, r0, 0 - adds r0, r1, 0 - adds r6, r2, 0 - adds r5, r3, 0 - strh r0, [r4, 0x20] - lsls r1, r0, 4 - strh r1, [r4, 0x2E] - subs r0, r6, r0 - lsls r0, 4 - adds r1, r5, 0 - bl __divsi3 - strh r0, [r4, 0x30] - strh r5, [r4, 0x32] - strh r6, [r4, 0x3C] - ldr r0, =sub_81C817C - str r0, [r4, 0x1C] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C814C - - thumb_func_start sub_81C817C -sub_81C817C: @ 81C817C - push {lr} - adds r2, r0, 0 - ldrh r1, [r2, 0x32] - movs r3, 0x32 - ldrsh r0, [r2, r3] - cmp r0, 0 - beq _081C81C4 - subs r0, r1, 0x1 - strh r0, [r2, 0x32] - ldrh r0, [r2, 0x30] - ldrh r1, [r2, 0x2E] - adds r0, r1 - strh r0, [r2, 0x2E] - lsls r0, 16 - asrs r0, 20 - strh r0, [r2, 0x20] - adds r0, 0x10 - lsls r0, 16 - movs r1, 0x88 - lsls r1, 17 - cmp r0, r1 - bls _081C81B6 - adds r0, r2, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - b _081C81CC -_081C81B6: - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - b _081C81CC -_081C81C4: - ldrh r0, [r2, 0x3C] - strh r0, [r2, 0x20] - ldr r0, =SpriteCallbackDummy - str r0, [r2, 0x1C] -_081C81CC: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C817C thumb_func_start sub_81C81D4 sub_81C81D4: @ 81C81D4 @@ -653,7 +17,7 @@ sub_81C81D4: @ 81C81D4 adds r7, r2, 0 ldr r1, =0x000008a4 movs r0, 0x11 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081C821C @@ -696,13 +60,13 @@ sub_81C8224: @ 81C8224 sub_81C8234: @ 81C8234 push {r4,lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81C8FE0 ldrb r0, [r4, 0x8] bl RemoveWindow movs r0, 0x11 - bl sub_81C7650 + bl FreeSubstruct pop {r4} pop {r0} bx r0 @@ -717,7 +81,7 @@ sub_81C8254: @ 81C8254 cmp r0, 0 bne _081C82C0 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r2, r0, 0 cmp r4, 0x4 bhi _081C82D6 @@ -921,7 +285,7 @@ sub_81C83F0: @ 81C83F0 sub sp, 0xC adds r6, r0, 0 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 cmp r6, 0 beq _081C8408 @@ -1014,7 +378,7 @@ _081C849C: sub_81C84A4: @ 81C84A4 push {lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00000888 adds r0, r1 ldrh r1, [r0] @@ -1030,7 +394,7 @@ sub_81C84A4: @ 81C84A4 sub_81C84C0: @ 81C84C0 push {lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00000888 adds r0, r1 movs r3, 0 @@ -1055,7 +419,7 @@ sub_81C84E8: @ 81C84E8 adds r6, r0, 0 adds r4, r1, 0 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r7, r0, 0 ldr r0, =0x00000888 adds r5, r7, r0 @@ -1149,7 +513,7 @@ sub_81C85A0: @ 81C85A0 push {r4-r6,lr} adds r5, r0, 0 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 cmp r5, 0 beq _081C85B8 @@ -1228,7 +592,7 @@ _081C862A: sub_81C8630: @ 81C8630 push {lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x28] bl sub_81C70D8 pop {r1} @@ -1239,7 +603,7 @@ sub_81C8630: @ 81C8630 sub_81C8644: @ 81C8644 push {lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00000888 adds r0, r1 pop {r1} @@ -1423,7 +787,7 @@ sub_81C8770: @ 81C8770 sub_81C877C: @ 81C877C push {r4,lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r0, =0x0000089c adds r1, r4, r0 @@ -1449,7 +813,7 @@ sub_81C87AC: @ 81C87AC lsls r4, 16 lsrs r4, 16 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, =0x00000888 adds r1, r5, r0 @@ -1477,7 +841,7 @@ sub_81C87AC: @ 81C87AC sub_81C87F0: @ 81C87F0 push {r4,lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r0, =0x0000089c adds r1, r4, r0 @@ -1500,7 +864,7 @@ sub_81C87F0: @ 81C87F0 sub_81C8820: @ 81C8820 push {lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr movs r1, 0x8A lsls r1, 4 adds r0, r1 @@ -1514,7 +878,7 @@ sub_81C8820: @ 81C8820 sub_81C8838: @ 81C8838 push {r4,lr} movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r0, =0x00000888 adds r2, r4, r0 @@ -1542,7 +906,7 @@ sub_81C8870: @ 81C8870 push {r4,r5,lr} adds r5, r0, 0 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 cmp r5, 0x4 bhi _081C894C @@ -1651,7 +1015,7 @@ sub_81C8958: @ 81C8958 push {r4,r5,lr} adds r5, r0, 0 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl IsDma3ManagerBusyWithBgCopy lsls r0, 24 @@ -1753,7 +1117,7 @@ sub_81C8A28: @ 81C8A28 cmp r0, 0 bne _081C8AA6 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r0, =0x00000888 adds r6, r4, r0 @@ -2525,7 +1889,7 @@ sub_81C9080: @ 81C9080 push {r4,lr} adds r4, r0, 0 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x0000088e adds r0, r1 ldrh r0, [r0] @@ -2637,7 +2001,7 @@ sub_81C9148: @ 81C9148 push {r4,lr} adds r4, r0, 0 movs r0, 0x11 - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0, 0x40] strh r4, [r1, 0x3C] ldr r0, [r0, 0x44] @@ -2812,7 +2176,7 @@ sub_81C9298: @ 81C9298 push {r4,lr} movs r0, 0x1 movs r1, 0x10 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081C92C4 @@ -2841,7 +2205,7 @@ sub_81C92CC: @ 81C92CC push {r4,lr} movs r0, 0x1 movs r1, 0x10 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081C92FA @@ -2871,7 +2235,7 @@ sub_81C9304: @ 81C9304 push {r4,lr} movs r0, 0x1 movs r1, 0x10 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081C932E @@ -2899,7 +2263,7 @@ sub_81C9338: @ 81C9338 push {lr} movs r0, 0x1 movs r1, 0x10 - bl sub_81C761C + bl AllocSubstruct adds r2, r0, 0 cmp r2, 0 beq _081C9360 @@ -2926,7 +2290,7 @@ sub_81C9368: @ 81C9368 push {r4,r5,lr} movs r0, 0x1 movs r1, 0x10 - bl sub_81C761C + bl AllocSubstruct adds r5, r0, 0 cmp r5, 0 beq _081C9394 @@ -2972,7 +2336,7 @@ _081C93B4: .4byte _081C93DC _081C93C8: movs r0, 0 - bl sub_81C7688 + bl SetPokenavMode _081C93CE: bl sub_81C93EC b _081C93DE @@ -2994,7 +2358,7 @@ _081C93E0: thumb_func_start sub_81C93EC sub_81C93EC: @ 81C93EC push {lr} - bl sub_81C767C + bl GetPokenavMode cmp r0, 0x1 beq _081C9408 cmp r0, 0x1 @@ -3021,7 +2385,7 @@ _081C9412: sub_81C941C: @ 81C941C push {lr} movs r0, 0x1 - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0, 0xC] bl _call_via_r1 pop {r1} @@ -3032,7 +2396,7 @@ sub_81C941C: @ 81C941C sub_81C9430: @ 81C9430 push {lr} movs r0, 0x1 - bl sub_81C7650 + bl FreeSubstruct pop {r0} bx r0 thumb_func_end sub_81C9430 @@ -3113,7 +2477,7 @@ _081C94D4: b _081C94EE .pool _081C94E0: - bl sub_81C76B8 + bl CanViewRibbonsMenu cmp r0, 0 beq _081C94FC movs r0, 0x9 @@ -3601,7 +2965,7 @@ _081C988E: sub_81C9894: @ 81C9894 push {lr} movs r0, 0x1 - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0] pop {r1} bx r1 @@ -3611,7 +2975,7 @@ sub_81C9894: @ 81C9894 sub_81C98A4: @ 81C98A4 push {lr} movs r0, 0x1 - bl sub_81C763C + bl GetSubstructPtr movs r1, 0x2 ldrsh r0, [r0, r1] pop {r1} @@ -3622,7 +2986,7 @@ sub_81C98A4: @ 81C98A4 sub_81C98B4: @ 81C98B4 push {lr} movs r0, 0x1 - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0, 0x4] pop {r1} bx r1 @@ -3632,7 +2996,7 @@ sub_81C98B4: @ 81C98B4 sub_81C98C4: @ 81C98C4 push {lr} movs r0, 0x1 - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0, 0x6] pop {r1} bx r1 @@ -3717,7 +3081,7 @@ sub_81C9958: @ 81C9958 push {r4,lr} ldr r1, =0x0000088c movs r0, 0x2 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081C997A @@ -3742,7 +3106,7 @@ sub_81C9990: @ 81C9990 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, =gUnknown_086201A0 lsls r4, 2 @@ -3763,7 +3127,7 @@ sub_81C9990: @ 81C9990 sub_81C99C0: @ 81C99C0 push {lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0] bl _call_via_r0 pop {r1} @@ -3774,7 +3138,7 @@ sub_81C99C0: @ 81C99C0 sub_81C99D4: @ 81C99D4 push {r4,lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81CA7F4 ldrb r0, [r4, 0x8] @@ -3782,7 +3146,7 @@ sub_81C99D4: @ 81C99D4 bl sub_81C9FEC bl sub_81CA994 movs r0, 0x2 - bl sub_81C7650 + bl FreeSubstruct pop {r4} pop {r0} bx r0 @@ -3792,7 +3156,7 @@ sub_81C99D4: @ 81C99D4 sub_81C99FC: @ 81C99FC push {lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x4] bl sub_81C70D8 pop {r1} @@ -3805,7 +3169,7 @@ sub_81C9A10: @ 81C9A10 sub sp, 0x4 adds r4, r0, 0 movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x9 bls _081C9A24 @@ -3832,7 +3196,7 @@ _081C9A34: _081C9A5C: ldr r0, =gUnknown_08620194 movs r1, 0x3 - bl sub_81C7B54 + bl InitBgTemplates ldr r1, =gPokenavMessageBox_Gfx movs r0, 0 str r0, [sp] @@ -4428,7 +3792,7 @@ _081C9F42: movs r0, 0 b _081C9FBE _081C9F52: - bl sub_81C7BE8 + bl IsDma3ManagerBusyWithBgCopy_ cmp r0, 0 bne _081C9FB8 bl sub_81C7880 @@ -4532,7 +3896,7 @@ sub_81CA02C: @ 81CA02C mov r7, r8 push {r7} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr movs r2, 0 adds r0, 0x2C mov r8, r0 @@ -4582,7 +3946,7 @@ _081CA054: sub_81CA094: @ 81CA094 push {r4-r7,lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr movs r1, 0 adds r7, r0, 0 adds r7, 0x2C @@ -4638,7 +4002,7 @@ sub_81CA0EC: @ 81CA0EC str r1, [sp, 0x14] str r2, [sp] movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr mov r10, r0 movs r0, 0x3 bl GetSpriteTileStartByTag @@ -4778,7 +4142,7 @@ sub_81CA20C: @ 81CA20C mov r7, r8 push {r7} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 bl sub_81C98A4 mov r8, r0 @@ -4833,7 +4197,7 @@ _081CA264: sub_81CA278: @ 81CA278 push {r4,r5,lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81C98A4 adds r3, r0, 0 @@ -4886,7 +4250,7 @@ _081CA2B2: sub_81CA2DC: @ 81CA2DC push {r4-r6,lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 movs r5, 0 adds r4, r6, 0 @@ -4926,7 +4290,7 @@ _081CA316: sub_81CA324: @ 81CA324 push {r4,lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r3, r0, 0 movs r2, 0 ldr r4, =SpriteCallbackDummy @@ -5008,7 +4372,7 @@ sub_81CA3B4: @ 81CA3B4 push {r7} adds r4, r0, 0 movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r7, r0, 0 movs r5, 0 mov r8, r5 @@ -5321,7 +4685,7 @@ _081CA5F6: cmp r0, 0xC bne _081CA638 movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr ldrb r1, [r0, 0xC] subs r1, 0x1 strb r1, [r0, 0xC] @@ -5345,7 +4709,7 @@ _081CA638: sub_81CA640: @ 81CA640 push {r4,lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r0, =gUnknown_0862036C movs r1, 0x10 @@ -5385,7 +4749,7 @@ _081CA690: sub_81CA698: @ 81CA698 push {lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x28] bl DestroySprite pop {r0} @@ -5426,7 +4790,7 @@ _081CA6DA: sub_81CA6E0: @ 81CA6E0 push {r4,lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r0, =gUnknown_086202CC bl AddWindow @@ -5451,7 +4815,7 @@ sub_81CA714: @ 81CA714 push {r4-r6,lr} sub sp, 0xC movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 bl sub_81C98B4 ldr r1, =gUnknown_086202D4 @@ -5493,7 +4857,7 @@ sub_81CA770: @ 81CA770 push {r4-r6,lr} sub sp, 0xC movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r6, =gText_NoRibbonWinners movs r2, 0x1 @@ -5540,7 +4904,7 @@ sub_81CA7C4: @ 81CA7C4 sub_81CA7D4: @ 81CA7D4 push {r4,lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r0, =sub_81CA808 movs r1, 0x2 @@ -5556,7 +4920,7 @@ sub_81CA7D4: @ 81CA7D4 sub_81CA7F4: @ 81CA7F4 push {lr} movs r0, 0x2 - bl sub_81C763C + bl GetSubstructPtr ldrb r0, [r0, 0xA] bl DestroyTask pop {r0} @@ -5738,7 +5102,7 @@ titlescreen_0: @ 81CA92C ldr r2, [r2, 0x8] bl ScanlineEffect_SetParams ldr r0, =sub_81CA914 - bl IndirectSetVBlankCallback + bl SetVBlankCallback_ ldr r0, =sub_81CA9EC movs r1, 0x3 bl CreateTask @@ -5763,7 +5127,7 @@ sub_81CA994: @ 81CA994 lsls r0, 24 lsrs r0, 24 bl DestroyTask - bl sub_81C760C + bl SetPokenavVBlankCallback pop {r0} bx r0 .pool @@ -5913,7 +5277,7 @@ sub_81CAAE8: @ 81CAAE8 movs r1, 0xD4 lsls r1, 1 movs r0, 0x5 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CAB1C @@ -5941,7 +5305,7 @@ _081CAB1E: sub_81CAB24: @ 81CAB24 push {lr} movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0, 0x18] bl _call_via_r1 pop {r1} @@ -5952,7 +5316,7 @@ sub_81CAB24: @ 81CAB24 sub_81CAB38: @ 81CAB38 push {lr} movs r0, 0x5 - bl sub_81C7650 + bl FreeSubstruct pop {r0} bx r0 thumb_func_end sub_81CAB38 @@ -6033,7 +5397,7 @@ _081CABD0: ands r0, r1 cmp r0, 0 beq _081CABF2 - bl sub_81C767C + bl GetPokenavMode cmp r0, 0x1 beq _081CABEC ldr r0, =sub_81CABFC @@ -6112,11 +5476,11 @@ _081CAC5E: bne _081CAC98 b _081CACA6 _081CAC64: - bl sub_81C767C + bl GetPokenavMode cmp r0, 0x1 bne _081CAC72 movs r0, 0x2 - bl sub_81C7688 + bl SetPokenavMode _081CAC72: ldr r0, =sub_81CACF8 str r0, [r4, 0x18] @@ -6220,7 +5584,7 @@ sub_81CAD20: @ 81CAD20 push {r4-r7,lr} adds r5, r0, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 cmp r5, 0x1 beq _081CAD4C @@ -6367,7 +5731,7 @@ _081CAE24: sub_81CAE28: @ 81CAE28 push {lr} movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x10] pop {r1} bx r1 @@ -6377,7 +5741,7 @@ sub_81CAE28: @ 81CAE28 sub_81CAE38: @ 81CAE38 push {lr} movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0, 0xA] pop {r1} bx r1 @@ -6387,7 +5751,7 @@ sub_81CAE38: @ 81CAE38 sub_81CAE48: @ 81CAE48 push {lr} movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0, 0xC] pop {r1} bx r1 @@ -6397,7 +5761,7 @@ sub_81CAE48: @ 81CAE48 sub_81CAE58: @ 81CAE58 push {lr} movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r1, r0, 0 ldrh r0, [r1, 0xA] ldrh r1, [r1, 0xC] @@ -6411,7 +5775,7 @@ sub_81CAE6C: @ 81CAE6C push {r4,lr} adds r4, r0, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r1, r0, 0 ldrh r0, [r1, 0xC] adds r4, r0 @@ -6434,7 +5798,7 @@ _081CAE8C: sub_81CAE94: @ 81CAE94 push {lr} movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r0, 0x1C pop {r1} bx r1 @@ -6445,7 +5809,7 @@ sub_81CAEA4: @ 81CAEA4 push {r4,lr} adds r4, r0, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr lsls r4, 2 adds r0, r4 ldrb r0, [r0, 0x1D] @@ -6459,7 +5823,7 @@ sub_81CAEBC: @ 81CAEBC push {r4,lr} adds r4, r0, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr lsls r1, r4, 2 adds r1, r0, r1 ldrb r0, [r1, 0x1C] @@ -6498,7 +5862,7 @@ sub_81CAF04: @ 81CAF04 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr lsls r1, r4, 2 adds r1, r0, r1 ldrb r0, [r1, 0x1C] @@ -6553,7 +5917,7 @@ sub_81CAF78: @ 81CAF78 adds r5, r0, 0 adds r6, r1, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 movs r0, 0 strb r0, [r6] @@ -6598,7 +5962,7 @@ sub_81CAFD8: @ 81CAFD8 adds r4, r0, 0 adds r5, r1, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr lsls r4, 2 adds r4, r0, r4 ldrb r0, [r4, 0x1C] @@ -6633,7 +5997,7 @@ _081CB012: sub_81CB01C: @ 81CB01C push {lr} movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0] pop {r1} bx r1 @@ -6644,7 +6008,7 @@ sub_81CB02C: @ 81CB02C push {r4,lr} adds r4, r0, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r1, r0, 0 ldrh r0, [r1, 0x2] cmp r0, r4 @@ -6742,7 +6106,7 @@ sub_81CB0E4: @ 81CB0E4 push {r4-r7,lr} adds r5, r0, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r7, r0, 0 movs r6, 0x1 adds r5, 0x1 @@ -6783,7 +6147,7 @@ sub_81CB128: @ 81CB128 push {r4-r6,lr} adds r5, r0, 0 movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r1, r0, 0 movs r6, 0x1 negs r6, r6 @@ -6874,7 +6238,7 @@ _081CB1C8: sub_81CB1D0: @ 81CB1D0 push {r4,lr} movs r0, 0x5 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81C875C adds r1, r0, 0 @@ -6940,7 +6304,7 @@ sub_81CB260: @ 81CB260 push {r4,lr} ldr r1, =0x00002048 movs r0, 0x6 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CB294 @@ -6968,7 +6332,7 @@ sub_81CB29C: @ 81CB29C push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, =gUnknown_08622798 lsls r4, 2 @@ -6989,7 +6353,7 @@ sub_81CB29C: @ 81CB29C sub_81CB2CC: @ 81CB2CC push {lr} movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0] bl _call_via_r0 pop {r1} @@ -7000,7 +6364,7 @@ sub_81CB2CC: @ 81CB2CC sub_81CB2E0: @ 81CB2E0 push {r4,lr} movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81CC2B4 bl sub_81CBC1C @@ -7011,7 +6375,7 @@ sub_81CB2E0: @ 81CB2E0 ldrb r0, [r4, 0x14] bl RemoveWindow movs r0, 0x6 - bl sub_81C7650 + bl FreeSubstruct pop {r4} pop {r0} bx r0 @@ -7021,7 +6385,7 @@ sub_81CB2E0: @ 81CB2E0 sub_81CB310: @ 81CB310 push {lr} movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x4] bl sub_81C70D8 pop {r1} @@ -7034,7 +6398,7 @@ sub_81CB324: @ 81CB324 sub sp, 0x8 adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x7 bls _081CB338 @@ -7059,7 +6423,7 @@ _081CB348: _081CB368: ldr r0, =gUnknown_0862278C movs r1, 0x3 - bl sub_81C7B54 + bl InitBgTemplates movs r0, 0x2 movs r1, 0 movs r2, 0 @@ -7234,7 +6598,7 @@ sub_81CB510: @ 81CB510 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CB55E @@ -7303,7 +6667,7 @@ sub_81CB588: @ 81CB588 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CB5D6 @@ -7372,7 +6736,7 @@ sub_81CB600: @ 81CB600 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CB64E @@ -7441,7 +6805,7 @@ sub_81CB678: @ 81CB678 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CB6C6 @@ -7510,7 +6874,7 @@ sub_81CB6F0: @ 81CB6F0 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0 beq _081CB706 @@ -7547,7 +6911,7 @@ sub_81CB734: @ 81CB734 movs r0, 0x5 bl PlaySE movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81CB01C adds r1, r0, 0 @@ -7566,7 +6930,7 @@ sub_81CB75C: @ 81CB75C push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0 beq _081CB772 @@ -7602,7 +6966,7 @@ sub_81CB7A0: @ 81CB7A0 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CB7D4 @@ -7668,7 +7032,7 @@ sub_81CB824: @ 81CB824 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CB85E @@ -7722,7 +7086,7 @@ sub_81CB888: @ 81CB888 push {r4-r6,lr} adds r5, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 movs r6, 0 cmp r5, 0x6 @@ -7780,7 +7144,7 @@ _081CB904: bl sub_81C7BA4 b _081CB934 _081CB90C: - bl sub_81C7BE8 + bl IsDma3ManagerBusyWithBgCopy_ cmp r0, 0 bne _081CB8EC ldrb r0, [r4, 0xF] @@ -7810,7 +7174,7 @@ sub_81CB93C: @ 81CB93C push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CB974 @@ -7860,7 +7224,7 @@ _081CB9A0: bl sub_81CC42C cmp r0, 0 bne _081CB9BA - bl sub_81C7BE8 + bl IsDma3ManagerBusyWithBgCopy_ cmp r0, 0 beq _081CB9BE _081CB9BA: @@ -7879,7 +7243,7 @@ sub_81CB9C8: @ 81CB9C8 push {r4,r5,lr} adds r5, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 cmp r5, 0x4 bhi _081CBA60 @@ -7955,7 +7319,7 @@ sub_81CBA68: @ 81CBA68 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CBA9C @@ -8011,7 +7375,7 @@ sub_81CBAD4: @ 81CBAD4 push {r4,r5,lr} adds r5, r0, 0 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 cmp r5, 0x4 bhi _081CBB6C @@ -8933,7 +8297,7 @@ sub_81CC214: @ 81CC214 push {r4-r6,lr} sub sp, 0x8 movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 movs r5, 0 ldr r4, =gUnknown_08622810 @@ -8998,7 +8362,7 @@ _081CC224: sub_81CC2B4: @ 81CC2B4 push {r4,lr} movs r0, 0x6 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r0, [r4, 0x1C] cmp r0, 0 @@ -9279,13 +8643,13 @@ sub_81CC4D4: @ 81CC4D4 push {r4,lr} movs r0, 0x3 movs r1, 0x14 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CC4F0 ldr r1, =0x00000884 movs r0, 0x10 - bl sub_81C761C + bl AllocSubstruct cmp r0, 0 bne _081CC4F8 _081CC4F0: @@ -9330,9 +8694,9 @@ sub_81CC524: @ 81CC524 orrs r0, r1 strb r0, [r3, 0x15] movs r0, 0x10 - bl sub_81C7650 + bl FreeSubstruct movs r0, 0x3 - bl sub_81C7650 + bl FreeSubstruct pop {r0} bx r0 .pool @@ -9342,7 +8706,7 @@ sub_81CC524: @ 81CC524 sub_81CC554: @ 81CC554 push {lr} movs r0, 0x3 - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0, 0x10] bl _call_via_r1 pop {r1} @@ -9428,7 +8792,7 @@ sub_81CC5DC: @ 81CC5DC sub_81CC5E4: @ 81CC5E4 push {lr} movs r0, 0x3 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0xC] pop {r1} bx r1 @@ -9439,7 +8803,7 @@ sub_81CC5F4: @ 81CC5F4 push {r4,lr} ldr r1, =0x00001948 movs r0, 0x4 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CC624 @@ -9465,7 +8829,7 @@ sub_81CC62C: @ 81CC62C push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, =gUnknown_086230E4 lsls r4, 2 @@ -9486,7 +8850,7 @@ sub_81CC62C: @ 81CC62C sub_81CC65C: @ 81CC65C push {lr} movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0] bl _call_via_r0 pop {r1} @@ -9497,17 +8861,17 @@ sub_81CC65C: @ 81CC65C sub_81CC670: @ 81CC670 push {r4,lr} movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl FreeRegionMapIconResources bl sub_81CC9EC ldrb r0, [r4, 0x8] bl RemoveWindow movs r0, 0x10 - bl sub_81C7650 + bl FreeSubstruct movs r0, 0x4 - bl sub_81C7650 - bl sub_81C760C + bl FreeSubstruct + bl SetPokenavVBlankCallback movs r0, 0 bl SetBgMode pop {r4} @@ -9530,7 +8894,7 @@ sub_81CC6A4: @ 81CC6A4 sub_81CC6BC: @ 81CC6BC push {lr} movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x4] bl sub_81C70D8 pop {r1} @@ -9563,7 +8927,7 @@ sub_81CC6F4: @ 81CC6F4 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x7 bls _081CC706 @@ -9587,7 +8951,7 @@ _081CC714: .4byte _081CC82A _081CC734: movs r0, 0 - bl IndirectSetVBlankCallback + bl SetVBlankCallback_ movs r0, 0x1 bl HideBg movs r0, 0x2 @@ -9599,9 +8963,9 @@ _081CC734: ldr r4, =gUnknown_086230D8 adds r0, r4, 0 movs r1, 0x2 - bl sub_81C7B54 + bl InitBgTemplates movs r0, 0x10 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 adds r4, 0x4 bl sub_81CC6D0 @@ -9667,7 +9031,7 @@ _081CC7E2: movs r0, 0x2 bl ShowBg ldr r0, =sub_81CC6A4 - bl IndirectSetVBlankCallback + bl SetVBlankCallback_ b _081CC77C .pool _081CC804: @@ -9710,7 +9074,7 @@ sub_81CC848: @ 81CC848 push {r4,lr} adds r4, r0, 0 movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr cmp r4, 0 beq _081CC85C cmp r4, 0x1 @@ -9769,7 +9133,7 @@ _081CC8A2: movs r0, 0 b _081CC8D2 _081CC8BE: - bl sub_81C7BE8 + bl IsDma3ManagerBusyWithBgCopy_ cmp r0, 0 beq _081CC8CA _081CC8C6: @@ -9790,7 +9154,7 @@ sub_81CC8D8: @ 81CC8D8 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CC90C @@ -9835,7 +9199,7 @@ _081CC924: movs r0, 0 b _081CC954 _081CC940: - bl sub_81C7BE8 + bl IsDma3ManagerBusyWithBgCopy_ cmp r0, 0 beq _081CC94C _081CC948: @@ -9929,7 +9293,7 @@ _081CC9C6: sub_81CC9EC: @ 81CC9EC push {r4,r5,lr} movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 movs r0, 0x6 bl FreeSpriteTilesByTag @@ -10055,7 +9419,7 @@ sub_81CCB0C: @ 81CCB0C sub sp, 0xC adds r4, r0, 0 movs r0, 0x10 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldrb r0, [r5, 0x2] cmp r0, 0x4 @@ -10318,7 +9682,7 @@ sub_81CCD34: @ 81CCD34 push {r4,lr} adds r4, r0, 0 movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr adds r2, r0, 0 cmp r4, 0x15 ble _081CCD48 @@ -10467,7 +9831,7 @@ sub_81CCE58: @ 81CCE58 mov r7, r8 push {r7} movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_8124658 lsls r0, 24 @@ -10612,7 +9976,7 @@ _081CCF70: sub_81CCF78: @ 81CCF78 push {r4,lr} movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 movs r0, 0x1 bl GetBgY @@ -10637,7 +10001,7 @@ sub_81CCFA4: @ 81CCFA4 push {r4-r6,lr} adds r4, r0, 0 movs r0, 0x4 - bl sub_81C763C + bl GetSubstructPtr movs r1, 0x1 ands r4, r1 lsls r5, r4, 2 @@ -10667,7 +10031,7 @@ sub_81CCFD8: @ 81CCFD8 push {r4,lr} ldr r1, =0x0000678c movs r0, 0xB - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CD01C @@ -10698,7 +10062,7 @@ sub_81CD024: @ 81CD024 push {r4,lr} ldr r1, =0x0000678c movs r0, 0xB - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CD068 @@ -10728,7 +10092,7 @@ _081CD06A: sub_81CD070: @ 81CD070 push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr ldr r2, =0x00006304 adds r1, r0, r2 ldr r1, [r1] @@ -10743,7 +10107,7 @@ sub_81CD08C: @ 81CD08C push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 adds r0, r4, 0 bl sub_81CD1E4 @@ -10818,7 +10182,7 @@ sub_81CD110: @ 81CD110 adds r1, r4, r1 strb r0, [r1] movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr ldrh r1, [r0, 0x2] lsls r1, 2 adds r0, r1 @@ -10886,7 +10250,7 @@ _081CD1B6: sub_81CD1C0: @ 81CD1C0 push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr movs r1, 0xC6 lsls r1, 7 adds r0, r1 @@ -10894,10 +10258,10 @@ sub_81CD1C0: @ 81CD1C0 cmp r0, 0 bne _081CD1DA movs r0, 0x12 - bl sub_81C7650 + bl FreeSubstruct _081CD1DA: movs r0, 0xB - bl sub_81C7650 + bl FreeSubstruct pop {r0} bx r0 thumb_func_end sub_81CD1C0 @@ -10907,7 +10271,7 @@ sub_81CD1E4: @ 81CD1E4 push {r4,lr} adds r4, r0, 0 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr adds r2, r0, 0 movs r3, 0 ldr r0, =gMain @@ -10971,10 +10335,10 @@ sub_81CD258: @ 81CD258 lsrs r0, 24 mov r8, r0 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 mov r0, r8 cmp r0, 0 @@ -11141,10 +10505,10 @@ _081CD3BA: sub_81CD3C4: @ 81CD3C4 push {r4,lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr adds r2, r0, 0 ldr r1, =0x0000678a adds r0, r4, r1 @@ -11329,7 +10693,7 @@ sub_81CD548: @ 81CD548 lsrs r4, r0, 24 adds r5, r4, 0 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr adds r1, r0, 0 cmp r4, 0x1 beq _081CD588 @@ -11449,7 +10813,7 @@ sub_81CD624: @ 81CD624 lsrs r2, 24 mov r10, r2 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr lsls r4, 2 adds r0, r4 ldrb r4, [r0, 0x4] @@ -11697,10 +11061,10 @@ sub_81CD824: @ 81CD824 lsls r1, 24 lsrs r6, r1, 24 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr adds r7, r0, 0 mov r1, r8 lsls r0, r1, 16 @@ -11841,11 +11205,11 @@ _081CD95C: sub_81CD970: @ 81CD970 push {r4-r7,lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr adds r7, r0, 0 ldr r1, =0x000006ac movs r0, 0x12 - bl sub_81C761C + bl AllocSubstruct adds r6, r0, 0 movs r0, 0xC6 lsls r0, 7 @@ -11908,7 +11272,7 @@ _081CD9C4: sub_81CD9F8: @ 81CD9F8 push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr movs r1, 0xC6 lsls r1, 7 adds r2, r0, r1 @@ -11935,10 +11299,10 @@ sub_81CDA1C: @ 81CDA1C lsrs r1, 24 mov r9, r1 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr mov r8, r0 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 lsls r0, r6, 16 asrs r5, r0, 16 @@ -12107,10 +11471,10 @@ sub_81CDB98: @ 81CDB98 lsrs r1, 24 mov r9, r1 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr adds r7, r0, 0 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 lsls r0, r6, 16 asrs r5, r0, 16 @@ -12187,7 +11551,7 @@ _081CDC3E: sub_81CDC50: @ 81CDC50 push {lr} movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0] pop {r1} bx r1 @@ -12197,7 +11561,7 @@ sub_81CDC50: @ 81CDC50 sub_81CDC60: @ 81CDC60 push {lr} movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0, 0x2] pop {r1} bx r1 @@ -12207,7 +11571,7 @@ sub_81CDC60: @ 81CDC60 sub_81CDC70: @ 81CDC70 push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00006428 adds r0, r1 pop {r1} @@ -12219,7 +11583,7 @@ sub_81CDC70: @ 81CDC70 sub_81CDC84: @ 81CDC84 push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00006786 adds r0, r1 ldrb r0, [r0] @@ -12232,7 +11596,7 @@ sub_81CDC84: @ 81CDC84 sub_81CDC9C: @ 81CDC9C push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00006302 adds r0, r1 ldrb r0, [r0] @@ -12248,7 +11612,7 @@ sub_81CDCB4: @ 81CDCB4 lsls r4, 24 lsrs r4, 24 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr lsls r4, 13 movs r1, 0xC0 lsls r1, 2 @@ -12266,7 +11630,7 @@ sub_81CDCD4: @ 81CDCD4 lsls r4, 24 lsrs r4, 24 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr lsls r4, 7 adds r0, r4 pop {r4} @@ -12278,7 +11642,7 @@ sub_81CDCD4: @ 81CDCD4 sub_81CDCEC: @ 81CDCEC push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00006789 adds r0, r1 ldrb r0, [r0] @@ -12294,7 +11658,7 @@ sub_81CDD04: @ 81CDD04 lsls r4, 24 lsrs r4, 24 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr lsls r4, 6 ldr r1, =0x00006368 adds r4, r1 @@ -12312,7 +11676,7 @@ sub_81CDD24: @ 81CDD24 lsls r4, 24 lsrs r4, 24 movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr lsls r1, r4, 1 adds r1, r4 lsls r1, 3 @@ -12329,7 +11693,7 @@ sub_81CDD24: @ 81CDD24 sub_81CDD48: @ 81CDD48 push {lr} movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr ldrh r1, [r0, 0x2] lsls r1, 2 adds r0, r1 @@ -12342,7 +11706,7 @@ sub_81CDD48: @ 81CDD48 sub_81CDD5C: @ 81CDD5C push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr movs r1, 0xC6 lsls r1, 7 adds r0, r1 @@ -12362,7 +11726,7 @@ _081CDD76: sub_81CDD7C: @ 81CDD7C push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr adds r2, r0, 0 movs r1, 0xC6 lsls r1, 7 @@ -12391,7 +11755,7 @@ _081CDDA6: sub_81CDDB0: @ 81CDDB0 push {lr} movs r0, 0xB - bl sub_81C763C + bl GetSubstructPtr ldr r2, =0x00006786 adds r1, r0, r2 ldrb r1, [r1] @@ -12411,7 +11775,7 @@ sub_81CDDD4: @ 81CDDD4 push {r4,lr} ldr r1, =0x000038ac movs r0, 0xC - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CDE24 @@ -12447,7 +11811,7 @@ sub_81CDE2C: @ 81CDE2C push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, =gUnknown_08623384 lsls r4, 2 @@ -12470,7 +11834,7 @@ sub_81CDE2C: @ 81CDE2C sub_81CDE64: @ 81CDE64 push {lr} movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00001810 adds r0, r1 ldr r0, [r0] @@ -12484,7 +11848,7 @@ sub_81CDE64: @ 81CDE64 sub_81CDE80: @ 81CDE80 push {lr} movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0] bl sub_81C70D8 pop {r1} @@ -12497,7 +11861,7 @@ sub_81CDE94: @ 81CDE94 sub sp, 0xC adds r4, r0, 0 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x14 bls _081CDEA8 @@ -12542,7 +11906,7 @@ _081CDF16: _081CDF18: ldr r0, =gUnknown_08623358 movs r1, 0x3 - bl sub_81C7B54 + bl InitBgTemplates movs r0, 0x1 movs r1, 0 movs r2, 0 @@ -12853,7 +12217,7 @@ _081CE218: bne _081CE2C0 _081CE230: ldr r0, =sub_81CEE44 - bl IndirectSetVBlankCallback + bl SetVBlankCallback_ b _081CDFB0 .pool _081CE23C: @@ -12924,7 +12288,7 @@ sub_81CE2D0: @ 81CE2D0 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CE308 @@ -13006,7 +12370,7 @@ sub_81CE37C: @ 81CE37C push {r4-r6,lr} adds r4, r0, 0 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 bl sub_81CDC70 adds r2, r0, 0 @@ -13160,7 +12524,7 @@ sub_81CE4D8: @ 81CE4D8 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x8 bhi _081CE5DC @@ -13282,7 +12646,7 @@ sub_81CE5E4: @ 81CE5E4 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x7 bhi _081CE6B2 @@ -13408,7 +12772,7 @@ _081CE6E6: bl sub_81C7BA4 b _081CE6E2 _081CE6EE: - bl sub_81C7BE8 + bl IsDma3ManagerBusyWithBgCopy_ cmp r0, 0x1 bne _081CE6E2 movs r0, 0x2 @@ -13444,7 +12808,7 @@ _081CE71E: bl sub_81C7BA4 b _081CE71A _081CE726: - bl sub_81C7BE8 + bl IsDma3ManagerBusyWithBgCopy_ cmp r0, 0x1 bne _081CE71A movs r0, 0x2 @@ -13486,7 +12850,7 @@ sub_81CE754: @ 81CE754 lsls r2, 24 lsrs r5, r2, 24 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 cmp r4, 0x1 beq _081CE7B8 @@ -13700,7 +13064,7 @@ _081CE926: sub_81CE934: @ 81CE934 push {r4,lr} movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldr r1, =0x00001822 adds r0, r4, r1 @@ -13798,7 +13162,7 @@ sub_81CE9E4: @ 81CE9E4 push {r5-r7} sub sp, 0x58 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 add r4, sp, 0x20 add r5, sp, 0x38 @@ -14101,7 +13465,7 @@ _081CEC8E: sub_81CECA0: @ 81CECA0 push {r4,lr} movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 movs r1, 0xC1 lsls r1, 5 @@ -14136,7 +13500,7 @@ _081CECF0: bl sub_81CEBF4 bl sub_81CEE68 movs r0, 0xC - bl sub_81C7650 + bl FreeSubstruct pop {r4} pop {r0} bx r0 @@ -14147,7 +13511,7 @@ sub_81CED10: @ 81CED10 push {r4,lr} adds r4, r0, 0 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr ldr r1, =0x00001814 adds r0, r1 ldrh r0, [r0] @@ -14168,7 +13532,7 @@ sub_81CED30: @ 81CED30 lsls r0, 24 lsrs r6, r0, 24 movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr mov r8, r0 ldr r7, =0x00001816 add r7, r8 @@ -14291,7 +13655,7 @@ sub_81CEE44: @ 81CEE44 thumb_func_start sub_81CEE68 sub_81CEE68: @ 81CEE68 push {lr} - bl sub_81C760C + bl SetPokenavVBlankCallback pop {r0} bx r0 thumb_func_end sub_81CEE68 @@ -14381,7 +13745,7 @@ _081CEF0C: sub_81CEF14: @ 81CEF14 push {r4,lr} movs r0, 0xC - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81CDD5C cmp r0, 0x1 @@ -14404,13 +13768,13 @@ sub_81CEF3C: @ 81CEF3C push {r4,lr} movs r0, 0x7 movs r1, 0x24 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CEF90 ldr r1, =0x000006ac movs r0, 0x12 - bl sub_81C761C + bl AllocSubstruct str r0, [r4, 0x20] cmp r0, 0 beq _081CEF90 @@ -14444,12 +13808,12 @@ sub_81CEF98: @ 81CEF98 push {r4,lr} movs r0, 0x7 movs r1, 0x24 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CEFD4 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr str r0, [r4, 0x20] ldr r0, =sub_81CF030 str r0, [r4] @@ -14476,7 +13840,7 @@ _081CEFD6: sub_81CEFDC: @ 81CEFDC push {lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0] bl _call_via_r1 pop {r1} @@ -14487,15 +13851,15 @@ sub_81CEFDC: @ 81CEFDC sub_81CEFF0: @ 81CEFF0 push {lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x1C] cmp r0, 0 bne _081CF004 movs r0, 0x12 - bl sub_81C7650 + bl FreeSubstruct _081CF004: movs r0, 0x7 - bl sub_81C7650 + bl FreeSubstruct pop {r0} bx r0 thumb_func_end sub_81CEFF0 @@ -14607,7 +13971,7 @@ sub_81CF0B8: @ 81CF0B8 sub_81CF0C0: @ 81CF0C0 push {lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x18] pop {r1} bx r1 @@ -14617,7 +13981,7 @@ sub_81CF0C0: @ 81CF0C0 sub_81CF0D0: @ 81CF0D0 push {lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x20] adds r0, 0x4 pop {r1} @@ -14628,7 +13992,7 @@ sub_81CF0D0: @ 81CF0D0 sub_81CF0E0: @ 81CF0E0 push {lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x20] ldrh r0, [r0] pop {r1} @@ -14639,7 +14003,7 @@ sub_81CF0E0: @ 81CF0E0 sub_81CF0F0: @ 81CF0F0 push {r4,lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81C875C ldr r1, [r4, 0x20] @@ -14655,7 +14019,7 @@ sub_81CF0F0: @ 81CF0F0 sub_81CF10C: @ 81CF10C push {lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x20] ldrh r0, [r0, 0x2] pop {r1} @@ -14680,7 +14044,7 @@ sub_81CF134: @ 81CF134 push {r4-r6,lr} sub sp, 0x4 movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 ldr r0, [r6, 0x20] movs r1, 0 @@ -14746,7 +14110,7 @@ _081CF1AA: sub_81CF1C4: @ 81CF1C4 push {lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr movs r1, 0 str r1, [r0, 0x10] str r1, [r0, 0xC] @@ -14762,7 +14126,7 @@ sub_81CF1D8: @ 81CF1D8 push {r7} sub sp, 0x4 movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 ldr r5, [r6, 0xC] ldr r4, [r6, 0x10] @@ -14839,7 +14203,7 @@ _081CF26A: sub_81CF278: @ 81CF278 push {r4-r6,lr} movs r0, 0x7 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, [r5, 0x20] ldrh r6, [r0] @@ -14950,7 +14314,7 @@ sub_81CF330: @ 81CF330 movs r1, 0x81 lsls r1, 4 movs r0, 0x8 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CF360 @@ -14979,7 +14343,7 @@ sub_81CF368: @ 81CF368 movs r1, 0x81 lsls r1, 4 movs r0, 0x8 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CF398 @@ -15006,7 +14370,7 @@ sub_81CF3A0: @ 81CF3A0 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, =gUnknown_08623598 lsls r4, 2 @@ -15027,7 +14391,7 @@ sub_81CF3A0: @ 81CF3A0 sub_81CF3D0: @ 81CF3D0 push {lr} movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0] bl _call_via_r0 pop {r1} @@ -15038,7 +14402,7 @@ sub_81CF3D0: @ 81CF3D0 sub_81CF3E4: @ 81CF3E4 push {lr} movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x4] bl sub_81C70D8 pop {r1} @@ -15049,13 +14413,13 @@ sub_81CF3E4: @ 81CF3E4 sub_81CF3F8: @ 81CF3F8 push {r4,lr} movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81C8234 ldrb r0, [r4, 0x8] bl RemoveWindow movs r0, 0x8 - bl sub_81C7650 + bl FreeSubstruct pop {r4} pop {r0} bx r0 @@ -15067,7 +14431,7 @@ sub_81CF418: @ 81CF418 sub sp, 0x4 adds r4, r0, 0 movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x5 bls _081CF42C @@ -15090,7 +14454,7 @@ _081CF43C: _081CF454: ldr r0, =gUnknown_08623590 movs r1, 0x2 - bl sub_81C7B54 + bl InitBgTemplates ldr r1, =gUnknown_086233E4 movs r0, 0 str r0, [sp] @@ -15214,7 +14578,7 @@ sub_81CF578: @ 81CF578 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CF5C6 @@ -15282,7 +14646,7 @@ sub_81CF5F0: @ 81CF5F0 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CF63E @@ -15350,7 +14714,7 @@ sub_81CF668: @ 81CF668 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CF6B6 @@ -15418,7 +14782,7 @@ sub_81CF6E0: @ 81CF6E0 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0x8 - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081CF72E @@ -15773,13 +15137,13 @@ sub_81CF9BC: @ 81CF9BC push {r4,lr} movs r0, 0x9 movs r1, 0x20 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CF9FC ldr r1, =0x000006ac movs r0, 0x12 - bl sub_81C761C + bl AllocSubstruct str r0, [r4, 0x1C] cmp r0, 0 beq _081CF9FC @@ -15807,12 +15171,12 @@ sub_81CFA04: @ 81CFA04 push {r4,lr} movs r0, 0x9 movs r1, 0x20 - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CFA2C movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr str r0, [r4, 0x1C] ldr r0, =sub_81CFA88 str r0, [r4] @@ -15832,7 +15196,7 @@ _081CFA2E: sub_81CFA34: @ 81CFA34 push {lr} movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0] bl _call_via_r1 pop {r1} @@ -15843,15 +15207,15 @@ sub_81CFA34: @ 81CFA34 sub_81CFA48: @ 81CFA48 push {lr} movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x18] cmp r0, 0 bne _081CFA5C movs r0, 0x12 - bl sub_81C7650 + bl FreeSubstruct _081CFA5C: movs r0, 0x9 - bl sub_81C7650 + bl FreeSubstruct pop {r0} bx r0 thumb_func_end sub_81CFA48 @@ -15963,7 +15327,7 @@ sub_81CFB10: @ 81CFB10 sub_81CFB18: @ 81CFB18 push {lr} movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x14] pop {r1} bx r1 @@ -15973,7 +15337,7 @@ sub_81CFB18: @ 81CFB18 sub_81CFB28: @ 81CFB28 push {lr} movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x1C] adds r0, 0x4 pop {r1} @@ -15984,7 +15348,7 @@ sub_81CFB28: @ 81CFB28 sub_81CFB38: @ 81CFB38 push {lr} movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x1C] ldrh r0, [r0] pop {r1} @@ -15995,7 +15359,7 @@ sub_81CFB38: @ 81CFB38 sub_81CFB48: @ 81CFB48 push {r4,lr} movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81C875C ldr r1, [r4, 0x1C] @@ -16011,7 +15375,7 @@ sub_81CFB48: @ 81CFB48 sub_81CFB64: @ 81CFB64 push {lr} movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x1C] ldrh r0, [r0, 0x2] pop {r1} @@ -16036,7 +15400,7 @@ sub_81CFB8C: @ 81CFB8C push {r4-r6,lr} sub sp, 0x4 movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr adds r6, r0, 0 ldr r0, [r6, 0x1C] movs r1, 0 @@ -16108,7 +15472,7 @@ _081CFC10: sub_81CFC2C: @ 81CFC2C push {lr} movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr movs r1, 0 str r1, [r0, 0x10] str r1, [r0, 0xC] @@ -16125,7 +15489,7 @@ sub_81CFC40: @ 81CFC40 push {r6,r7} sub sp, 0x4 movs r0, 0x9 - bl sub_81C763C + bl GetSubstructPtr mov r8, r0 ldr r7, [r0, 0xC] ldr r6, [r0, 0x10] @@ -16336,7 +15700,7 @@ sub_81CFDD0: @ 81CFDD0 movs r1, 0x81 lsls r1, 4 movs r0, 0xA - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CFE00 @@ -16365,7 +15729,7 @@ sub_81CFE08: @ 81CFE08 movs r1, 0x81 lsls r1, 4 movs r0, 0xA - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081CFE38 @@ -16392,7 +15756,7 @@ sub_81CFE40: @ 81CFE40 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, =gUnknown_086237B8 lsls r4, 2 @@ -16413,7 +15777,7 @@ sub_81CFE40: @ 81CFE40 sub_81CFE70: @ 81CFE70 push {lr} movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0] bl _call_via_r0 pop {r1} @@ -16424,7 +15788,7 @@ sub_81CFE70: @ 81CFE70 sub_81CFE84: @ 81CFE84 push {lr} movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x4] bl sub_81C70D8 pop {r1} @@ -16435,13 +15799,13 @@ sub_81CFE84: @ 81CFE84 sub_81CFE98: @ 81CFE98 push {r4,lr} movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 bl sub_81C8234 ldrb r0, [r4, 0x8] bl RemoveWindow movs r0, 0xA - bl sub_81C7650 + bl FreeSubstruct pop {r4} pop {r0} bx r0 @@ -16453,7 +15817,7 @@ sub_81CFEB8: @ 81CFEB8 sub sp, 0x4 adds r4, r0, 0 movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x5 bls _081CFECC @@ -16476,7 +15840,7 @@ _081CFEDC: _081CFEF4: ldr r0, =gUnknown_086237B0 movs r1, 0x2 - bl sub_81C7B54 + bl InitBgTemplates ldr r1, =gUnknown_08623604 movs r0, 0 str r0, [sp] @@ -16588,7 +15952,7 @@ sub_81CFFFC: @ 81CFFFC push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081D004A @@ -16656,7 +16020,7 @@ sub_81D0074: @ 81D0074 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081D00C2 @@ -16724,7 +16088,7 @@ sub_81D00EC: @ 81D00EC push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081D013A @@ -16792,7 +16156,7 @@ sub_81D0164: @ 81D0164 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xA - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081D01B2 @@ -17158,12 +16522,12 @@ sub_81D0450: @ 81D0450 push {r4,lr} movs r0, 0xD movs r1, 0x9C - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081D0498 movs r0, 0x12 - bl sub_81C763C + bl GetSubstructPtr str r0, [r4, 0x8] cmp r0, 0 beq _081D0498 @@ -17194,7 +16558,7 @@ _081D049A: sub_81D04A0: @ 81D04A0 push {lr} movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr adds r1, r0, 0 adds r1, 0x98 ldr r1, [r1] @@ -17207,7 +16571,7 @@ sub_81D04A0: @ 81D04A0 sub_81D04B8: @ 81D04B8 push {lr} movs r0, 0xD - bl sub_81C7650 + bl FreeSubstruct pop {r0} bx r0 thumb_func_end sub_81D04B8 @@ -17513,7 +16877,7 @@ _081D06BE: sub_81D06C4: @ 81D06C4 push {lr} movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x8] ldrh r0, [r0, 0x2] pop {r1} @@ -17524,7 +16888,7 @@ sub_81D06C4: @ 81D06C4 sub_81D06D4: @ 81D06D4 push {lr} movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x8] ldrh r0, [r0] pop {r1} @@ -17538,7 +16902,7 @@ sub_81D06E4: @ 81D06E4 adds r7, r1, 0 adds r6, r2, 0 movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0, 0x8] ldrh r0, [r1, 0x2] lsls r0, 2 @@ -17594,7 +16958,7 @@ sub_81D0760: @ 81D0760 adds r6, r1, 0 adds r7, r2, 0 movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0, 0x8] ldrh r0, [r1, 0x2] lsls r0, 2 @@ -17648,7 +17012,7 @@ _081D07D0: sub_81D07D8: @ 81D07D8 push {lr} movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr ldr r1, [r0, 0x8] ldrh r0, [r1, 0x2] lsls r0, 2 @@ -17815,7 +17179,7 @@ sub_81D0914: @ 81D0914 push {r4,lr} adds r4, r0, 0 movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr ldrh r1, [r0, 0x10] str r1, [r4] adds r0, 0x14 @@ -17829,7 +17193,7 @@ sub_81D092C: @ 81D092C push {r4,lr} adds r4, r0, 0 movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr ldrh r1, [r0, 0x12] str r1, [r4] adds r0, 0x78 @@ -17842,7 +17206,7 @@ sub_81D092C: @ 81D092C sub_81D0944: @ 81D0944 push {lr} movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr ldrh r0, [r0, 0xC] pop {r1} bx r1 @@ -17852,7 +17216,7 @@ sub_81D0944: @ 81D0944 sub_81D0954: @ 81D0954 push {lr} movs r0, 0xD - bl sub_81C763C + bl GetSubstructPtr adds r1, r0, 0 ldrh r0, [r1, 0xC] cmp r0, 0x18 @@ -17876,7 +17240,7 @@ sub_81D0978: @ 81D0978 push {r4,lr} ldr r1, =0x0000101c movs r0, 0xE - bl sub_81C761C + bl AllocSubstruct adds r4, r0, 0 cmp r4, 0 beq _081D09A8 @@ -17902,7 +17266,7 @@ sub_81D09B0: @ 81D09B0 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 ldr r0, =gUnknown_08624BA0 lsls r4, 2 @@ -17923,7 +17287,7 @@ sub_81D09B0: @ 81D09B0 sub_81D09E0: @ 81D09E0 push {lr} movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0] bl _call_via_r0 pop {r1} @@ -17934,7 +17298,7 @@ sub_81D09E0: @ 81D09E0 sub_81D09F4: @ 81D09F4 push {r4,lr} movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 ldrb r0, [r4, 0xA] bl RemoveWindow @@ -17963,7 +17327,7 @@ sub_81D09F4: @ 81D09F4 ldr r0, [r4, 0x14] bl DestroySprite movs r0, 0xE - bl sub_81C7650 + bl FreeSubstruct pop {r4} pop {r0} bx r0 @@ -17973,7 +17337,7 @@ sub_81D09F4: @ 81D09F4 sub_81D0A58: @ 81D0A58 push {lr} movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr ldr r0, [r0, 0x4] bl sub_81C70D8 pop {r1} @@ -17986,7 +17350,7 @@ sub_81D0A6C: @ 81D0A6C sub sp, 0x8 adds r4, r0, 0 movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x9 bls _081D0A80 @@ -18013,7 +17377,7 @@ _081D0A90: _081D0AB8: ldr r0, =gUnknown_08624B98 movs r1, 0x2 - bl sub_81C7B54 + bl InitBgTemplates ldr r1, =gUnknown_08DDE030 movs r0, 0 str r0, [sp] @@ -18215,7 +17579,7 @@ sub_81D0C84: @ 81D0C84 push {r4,r5,lr} adds r5, r0, 0 movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr adds r4, r0, 0 cmp r5, 0x6 bhi _081D0D24 @@ -18295,7 +17659,7 @@ sub_81D0D2C: @ 81D0D2C push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081D0D5C @@ -18347,7 +17711,7 @@ sub_81D0D8C: @ 81D0D8C push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081D0DC0 @@ -18408,7 +17772,7 @@ sub_81D0E00: @ 81D0E00 push {r4,r5,lr} adds r4, r0, 0 movs r0, 0xE - bl sub_81C763C + bl GetSubstructPtr adds r5, r0, 0 cmp r4, 0x1 beq _081D0E30 diff --git a/include/graphics.h b/include/graphics.h index 48c00943b..d4696bc8b 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4010,6 +4010,7 @@ extern const u32 gCreditsCopyrightEnd_Gfx[]; //pokenav extern const u8 gPokenavConditionMarker_Gfx[]; extern const u16 gPokenavConditionMarker_Pal[]; +extern const u16 gPokenavLeftHeader_Pal[]; extern const u16 gPokenavHeader_Pal[]; extern const u32 gPokenavHeader_Gfx[]; extern const u32 gPokenavHeader_Tilemap[]; diff --git a/src/pokenav.c b/src/pokenav.c index ff687e8dc..d09c3da94 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -13,26 +13,45 @@ #include "bg.h" #include "menu.h" #include "graphics.h" +#include "dma3.h" #include "gba/macro.h" #include "decompress.h" #include "strings.h" #include "constants/rgb.h" +enum +{ + MODE_NORMAL, // Chosen from Start menu. + MODE_FORCE_CALL_1, // Used for the script's special. Has to choose Match Call and make a call. + MODE_FORCE_CALL_2, // Set after making a call, has to exit Pokenav. +}; + #define UNKNOWN_OFFSET 100000 +struct UnknownSubStruct_0203CF40 +{ + void (*unk0)(u32); + u32 (*unk4)(void); + u32 unk8; + u32 unkC; + u32 unk10; + u32 unk14; + struct Sprite *unk18; + struct Sprite *unk1C[2]; + struct Sprite *unk24[2]; + u8 tilemapBuffer[0x1000]; +}; + +#define SUBSTRUCT_COUNT 19 + struct UnknownStruct_0203CF40 { u32 (*field0)(void); u32 field4; - u16 field8; + u16 mode; u16 fieldA; - u32 fieldC; - void *field10[19]; -}; - -struct UnknownStruct_sub_81C76C4 -{ - u32 data[523]; + bool32 hasAnyRibbons; + struct UnknownSubStruct_0203CF40 *field10[SUBSTRUCT_COUNT]; }; extern u32 sub_81C9430(void); @@ -101,34 +120,42 @@ extern u32 sub_81CFE08(void); u32 sub_81C791C(s32 a0); bool32 sub_81C756C(u32 a0); bool32 sub_81C76C4(void); -u32 AnyMonHasRibbon(void); +static bool32 AnyMonHasRibbon(void); u32 sub_81C75E0(void); u32 sub_81C75D4(void); u32 sub_81C76FC(void); u32 sub_81C786C(void); u32 sub_81C7764(s32 a0); -u32 atk47_cmd47(s32 a0); +u32 sub_81C78D4(s32 a0); bool32 sub_81C7738(void); void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 a1, u32 a2); -void sub_81C7834(u32 (*a0)(void), u32(*a1)(void)); -void sub_81C7360(struct UnknownStruct_0203CF40 *a0); -void sub_81C7650(u32 index); +void sub_81C7834(void *func1, void *func2); +static void InitMainStruct(struct UnknownStruct_0203CF40 *a0); +void FreeSubstruct(u32 index); void sub_81C7850(u32 a0); void sub_81C7BF8(u32 a0); void sub_81C71E4(u8 a0); -void sub_81C7170(u8 a0); +void sub_81C7170(u8 taskId); void sub_81C742C(u8 taskId); void sub_81C7710(void); -void sub_81C75F4(void); -void sub_81C7334(void); -void sub_81C7418(void); -void sub_81C7400(void); +static void InitKeys_(void); +static void FreeVars(void); +static void VblankCb_Pokenav(void); +static void Cb2_Pokenav(void); void sub_81C7C28(void); void sub_81C72BC(void); void sub_81C7B74(void); void sub_81C7C94(void); +void sub_81C7F24(u32 arg0); +void sub_81C7E58(u32 arg0); +void sub_81C8110(bool32 arg0); +void sub_81C80D4(bool32 arg0); +void sub_81C803C(u32 arg0, bool32 arg1); +void sub_81C8088(u32 arg0, bool32 arg1); +void sub_81C814C(struct Sprite *sprite, s32 arg1, s32 arg2, s32 arg3); +void sub_81C817C(struct Sprite *sprite); - +// Const rom data. u32 (*const gUnknown_0861F3EC[15][7])(void) = { { @@ -272,15 +299,17 @@ const u16 gUnknown_0861F590[] = INCBIN_U16("graphics/pokenav/icon2.gbapal"); const u32 gUnknown_0861F5B0[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz"); const u32 gUnknown_0861F994[] = INCBIN_U32("graphics/pokenav/icon2_unused.4bpp.lz"); -const struct BgTemplate gUnknown_0861FA04 = +const struct BgTemplate gUnknown_0861FA04[] = { - .bg = 0, - .charBaseIndex = 0, - .mapBaseIndex = 5, - .screenSize = 0, - .paletteMode = 0, - .priority = 0, - .baseTile = 0, + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 5, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0, + } }; const struct WindowTemplate gUnknown_0861FA08[2] = @@ -305,7 +334,7 @@ const struct WindowTemplate gUnknown_0861FA08[2] = }, }; -const u8 *const (MenuButtonReminders[12]) = +const u8 *const (sMenuButtonReminders[12]) = { gText_Navgear_ClearButtonList, gText_NavgearMap_ZoomedOutButtons, @@ -341,10 +370,6 @@ const struct SpritePalette gUnknown_0861FA54[2] = .data = gUnknown_0861F590, .tag = 0, }, - { - .data = NULL, - .tag = 0, - } }; const struct CompressedSpriteSheet gUnknown_0861FA64 = @@ -358,16 +383,17 @@ extern struct UnknownStruct_0203CF40 *gUnknown_0203CF40; extern u8 gUnknown_0203CF3C; extern const struct SpriteTemplate gUnknown_0861FB04; -u32 sub_81C7078(u32 (*a0)(s32), u32 a1) +// code +u32 sub_81C7078(u32 (*func)(s32), u32 priority) { u16 taskId; if (!is_c1_link_related_active()) - taskId = CreateTask(sub_81C7170, a1); + taskId = CreateTask(sub_81C7170, priority); else - taskId = CreateTask(sub_81C71E4, a1); + taskId = CreateTask(sub_81C71E4, priority); - SetWordTaskArg(taskId, 1, (u32)a0); + SetWordTaskArg(taskId, 1, (u32)func); gTasks[taskId].data[3] = gUnknown_0203CF3C; return ((gUnknown_0203CF3C++) << 16) | taskId; @@ -375,62 +401,52 @@ u32 sub_81C7078(u32 (*a0)(s32), u32 a1) bool32 sub_81C70D8(u32 a0) { - u32 v1 = a0 & 0xFFFF; + u32 taskId = a0 & 0xFFFF; u32 v2 = a0 >> 16; - if (gTasks[v1].isActive - && (gTasks[v1].func == sub_81C7170 || gTasks[v1].func == sub_81C71E4) - && gTasks[v1].data[3] == v2) - { - + + if (gTasks[taskId].isActive + && (gTasks[taskId].func == sub_81C7170 || gTasks[taskId].func == sub_81C71E4) + && gTasks[taskId].data[3] == v2) return TRUE; - } else - { return FALSE; - } } bool32 sub_81C7124(u32 a0) { s32 i; - for (i = 0; i < 16; i++) + for (i = 0; i < NUM_TASKS; i++) { if (gTasks[i].isActive - && (gTasks[i].func == sub_81C7170 || gTasks[i].func == sub_81C71E4)) - { - u32 arg = GetWordTaskArg((u8)i, 1); - if (arg == a0) - return TRUE; - } + && (gTasks[i].func == sub_81C7170 || gTasks[i].func == sub_81C71E4) + && GetWordTaskArg(i, 1) == a0) + return TRUE; } return FALSE; } void sub_81C7170(u8 taskId) { - s16 *dataPtr; - u32 (*func)(u32); - bool32 exitLoop; + u32 (*func)(s32) = (void *)GetWordTaskArg(taskId, 1); + s16 *data = gTasks[taskId].data; + bool32 exitLoop = FALSE; - func = (u32 (*)(u32))GetWordTaskArg(taskId, 1); - dataPtr = gTasks[taskId].data; - exitLoop = FALSE; while (!exitLoop) { - u32 v1 =((u32 (*)(u32))func)(dataPtr[0]); - switch (v1) + u32 var = func(data[0]); + switch (var) { case 1: - dataPtr[0] = dataPtr[0] + 1; + data[0] = data[0] + 1; break; case 0: - dataPtr[0]++; + data[0]++; return; case 4: DestroyTask(taskId); return; default: - dataPtr[0] = v1 - 5; + data[0] = var - 5; break; case 3: break; @@ -471,91 +487,81 @@ void sub_81C71E4(u8 taskId) void CB2_PokeNav(void) { - gUnknown_0203CF40 = Alloc(sizeof(struct UnknownStruct_0203CF40)); + gUnknown_0203CF40 = Alloc(sizeof(*gUnknown_0203CF40)); if (gUnknown_0203CF40 == NULL) { SetMainCallback2(CB2_ReturnToFieldWithOpenMenu); } else { - sub_81C7360(gUnknown_0203CF40); + InitMainStruct(gUnknown_0203CF40); ResetTasks(); SetVBlankCallback(NULL); CreateTask(sub_81C742C, 0); - SetMainCallback2(sub_81C7400); - SetVBlankCallback(sub_81C7418); + SetMainCallback2(Cb2_Pokenav); + SetVBlankCallback(VblankCb_Pokenav); } } -void sub_81C72A4() +void sub_81C72A4(void) { SetMainCallback2(sub_81C72BC); FadeScreen(1, 0); } -void sub_81C72BC() +void sub_81C72BC(void) { UpdatePaletteFade(); - if (!gPaletteFade.active) + if (gPaletteFade.active) + return; + + gUnknown_0203CF40 = Alloc(sizeof(*gUnknown_0203CF40)); + if (gUnknown_0203CF40 == NULL) { - gUnknown_0203CF40 = Alloc(sizeof(struct UnknownStruct_0203CF40)); - if (gUnknown_0203CF40 == NULL) - { - SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); - } - else - { - sub_81C7360(gUnknown_0203CF40); - gUnknown_0203CF40->field8 = 1; - ResetTasks(); - ResetSpriteData(); - FreeAllSpritePalettes(); - SetVBlankCallback(NULL); - CreateTask(sub_81C742C, 0); - SetMainCallback2(sub_81C7400); - SetVBlankCallback(sub_81C7418); - } + SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); + } + else + { + InitMainStruct(gUnknown_0203CF40); + gUnknown_0203CF40->mode = MODE_FORCE_CALL_1; + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); + SetVBlankCallback(NULL); + CreateTask(sub_81C742C, 0); + SetMainCallback2(Cb2_Pokenav); + SetVBlankCallback(VblankCb_Pokenav); } } -void sub_81C7334() +static void FreeVars(void) { s32 i; - for (i = 0; i < 19; i++) - { - sub_81C7650(i); - } - Free(gUnknown_0203CF40); - gUnknown_0203CF40 = NULL; + for (i = 0; i < SUBSTRUCT_COUNT; i++) + FreeSubstruct(i); + + FREE_AND_SET_NULL(gUnknown_0203CF40); InitKeys(); } // Clears UnknownStruct_0203CF40 -void sub_81C7360(struct UnknownStruct_0203CF40 *a0) +static void InitMainStruct(struct UnknownStruct_0203CF40 *a0) { s32 i; - void **arrayPtr; - void *fill; - fill = NULL; - i = 18; - arrayPtr = &(a0->field10[18]); - for (i; i >= 0; i--) - { - *arrayPtr = fill; - arrayPtr -= 1; - } - a0->field8 = 0; + for (i = 0; i < SUBSTRUCT_COUNT; i++) + a0->field10[i] = NULL; + + a0->mode = MODE_NORMAL; a0->field4 = 0; - a0->fieldC = AnyMonHasRibbon(); + a0->hasAnyRibbons = AnyMonHasRibbon(); a0->field0 = NULL; } -bool32 AnyMonHasRibbon() +static bool32 AnyMonHasRibbon(void) { - s32 i; - s32 j; + s32 i, j; for (i = 0; i < PARTY_SIZE; i++) { @@ -569,7 +575,7 @@ bool32 AnyMonHasRibbon() for (j = 0; j < TOTAL_BOXES_COUNT; j++) { - for (i = 0; i < IN_BOX_COUNT; i++) + for (i = 0; i < IN_BOX_COUNT; i++) { if (CheckBoxMonSanityAt(j, i) && GetBoxMonDataAt(j, i, MON_DATA_RIBBON_COUNT) != 0) @@ -582,7 +588,7 @@ bool32 AnyMonHasRibbon() return FALSE; } -void sub_81C7400() +static void Cb2_Pokenav(void) { RunTasks(); AnimateSprites(); @@ -590,7 +596,7 @@ void sub_81C7400() UpdatePaletteFade(); } -void sub_81C7418() +static void VblankCb_Pokenav(void) { TransferPlttBuffer(); LoadOam(); @@ -599,34 +605,31 @@ void sub_81C7418() void sub_81C742C(u8 taskId) { - s16 *dataPtr; u32 v1; - bool32 v2; + s16 *data = gTasks[taskId].data; - dataPtr = gTasks[taskId].data; - - switch (dataPtr[0]) + switch (data[0]) { case 0: sub_81C76C4(); - dataPtr[0] = 1; + data[0] = 1; break; case 1: if (sub_81C76FC()) break; sub_81C756C(UNKNOWN_OFFSET); - dataPtr[0] = 4; + data[0] = 4; break; case 2: if (sub_81C786C()) break; - dataPtr[0] = 3; + data[0] = 3; case 3: v1 = sub_81C75E0(); if (v1 == -1) { sub_81C7710(); - dataPtr[0] = 5; + data[0] = 5; } else if (v1 >= UNKNOWN_OFFSET) { @@ -634,32 +637,33 @@ void sub_81C742C(u8 taskId) gUnknown_0861F3EC[gUnknown_0203CF40->field4][5](); if (sub_81C756C(v1)) { - dataPtr[0] = 4; + data[0] = 4; } else { sub_81C7710(); - dataPtr[0] = 5; + data[0] = 5; } } else if (v1 != 0) { sub_81C7850(v1); if (sub_81C786C()) - dataPtr[0] = 2; + data[0] = 2; } break; case 4: if (!sub_81C75D4()) - dataPtr[0] = 3; + data[0] = 3; break; case 5: if (!sub_81C7738()) { - v2 = gUnknown_0203CF40->field8 != 0; + bool32 calledFromScript = (gUnknown_0203CF40->mode != MODE_NORMAL); + sub_81C9430(); - sub_81C7334(); - if (v2) + FreeVars(); + if (calledFromScript) SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); else SetMainCallback2(CB2_ReturnToFieldWithOpenMenu); @@ -670,14 +674,14 @@ void sub_81C742C(u8 taskId) bool32 sub_81C756C(u32 a0) { - u32 index; + u32 index = a0 - UNKNOWN_OFFSET; - index = a0 - UNKNOWN_OFFSET; - sub_81C75F4(); + InitKeys_(); if (!gUnknown_0861F3EC[index][0]()) return FALSE; if (!gUnknown_0861F3EC[index][2]()) return FALSE; + sub_81C7834(gUnknown_0861F3EC[index][3], gUnknown_0861F3EC[index][4]); gUnknown_0203CF40->field0 = gUnknown_0861F3EC[index][1]; gUnknown_0203CF40->field4 = index; @@ -694,52 +698,52 @@ u32 sub_81C75E0(void) return gUnknown_0203CF40->field0(); } -void sub_81C75F4(void) +static void InitKeys_(void) { InitKeys(); } -void IndirectSetVBlankCallback(IntrCallback callback) +void SetVBlankCallback_(IntrCallback callback) { SetVBlankCallback(callback); } -void sub_81C760C(void) +void SetPokenavVBlankCallback(void) { - SetVBlankCallback(sub_81C7418); + SetVBlankCallback(VblankCb_Pokenav); } -void *sub_81C761C(u32 index, u32 size) +void *AllocSubstruct(u32 index, u32 size) { - return gUnknown_0203CF40->field10[index] = (void*)Alloc(size); + return gUnknown_0203CF40->field10[index] = Alloc(size); } -void *sub_81C763C(u32 index) +struct UnknownSubStruct_0203CF40 *GetSubstructPtr(u32 index) { return gUnknown_0203CF40->field10[index]; } -void sub_81C7650(u32 index) +void FreeSubstruct(u32 index) { if (gUnknown_0203CF40->field10[index] != NULL) FREE_AND_SET_NULL(gUnknown_0203CF40->field10[index]); } -u16 sub_81C767C(void) +u16 GetPokenavMode(void) { - return gUnknown_0203CF40->field8; + return gUnknown_0203CF40->mode; } -void sub_81C7688(u16 a0) +void SetPokenavMode(u16 mode) { - gUnknown_0203CF40->field8 = a0; + gUnknown_0203CF40->mode = mode; } void sub_81C7694(u32 a0) { - u32 value; - value = a0; - if (a0 > 4) + u32 value = a0; + + if (value > 4) value = 0; gUnknown_0203CF40->fieldA = value; } @@ -749,34 +753,27 @@ u16 sub_81C76AC(void) return gUnknown_0203CF40->fieldA; } -u32 sub_81C76B8(void) +bool32 CanViewRibbonsMenu(void) { - return gUnknown_0203CF40->fieldC; + return gUnknown_0203CF40->hasAnyRibbons; } bool32 sub_81C76C4(void) { - struct UnknownStruct_sub_81C76C4 *v1; - - v1 = (struct UnknownStruct_sub_81C76C4*)sub_81C761C(0, sizeof(struct UnknownStruct_sub_81C76C4)); - if (v1 == NULL) - { + struct UnknownSubStruct_0203CF40 *structPtr = AllocSubstruct(0, 0x82C); + if (structPtr == NULL) return FALSE; - } - else - { - ResetSpriteData(); - FreeAllSpritePalettes(); - v1->data[3] = sub_81C7078(sub_81C7764, 1); - return TRUE; - } + + ResetSpriteData(); + FreeAllSpritePalettes(); + structPtr->unkC = sub_81C7078(sub_81C7764, 1); + return TRUE; } u32 sub_81C76FC(void) { - u32 *v1; - v1 = sub_81C763C(0); - return sub_81C70D8(v1[3]); + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + return sub_81C70D8(structPtr->unkC); } void sub_81C7710(void) @@ -794,15 +791,14 @@ bool32 sub_81C7738(void) sub_81C7C94(); FreeAllWindowBuffers(); return FALSE; - } else - { - return TRUE; } + + return TRUE; } u32 sub_81C7764(s32 a0) { - u32 *v1; + struct UnknownSubStruct_0203CF40 *structPtr; switch (a0) { @@ -810,14 +806,14 @@ u32 sub_81C7764(s32 a0) SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); FreeAllWindowBuffers(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, &gUnknown_0861FA04, 1); + InitBgsFromTemplates(0, gUnknown_0861FA04, ARRAY_COUNT(gUnknown_0861FA04)); sub_8199D98(); reset_temp_tile_data_buffers(); return 1; case 1: - v1 = sub_81C763C(0); + structPtr = GetSubstructPtr(0); decompress_and_copy_tile_data_to_vram(0, &gPokenavHeader_Gfx, 0, 0, 0); - SetBgTilemapBuffer(0, &v1[11]); + SetBgTilemapBuffer(0, structPtr->tilemapBuffer); CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0); CopyPaletteIntoBufferUnfaded(gPokenavHeader_Pal, 0, 0x20); CopyBgTilemapBufferToVram(0); @@ -825,7 +821,7 @@ u32 sub_81C7764(s32 a0) case 2: if (free_temp_tile_data_buffers_if_possible()) return 2; - + sub_81C7B74(); return 0; case 3: @@ -841,58 +837,46 @@ u32 sub_81C7764(s32 a0) } } -void sub_81C7834(u32 (*a0)(void), u32(*a1)(void)) +void sub_81C7834(void *func1, void *func2) // Fix types later. { - u32 (**v1)(void); - - v1 = sub_81C763C(0); - v1[0] = a0; - v1[1] = a1; - v1[2] = NULL; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + structPtr->unk0 = func1; + structPtr->unk4 = func2; + structPtr->unk8 = 0; } void sub_81C7850(u32 a0) { - void (**v1)(u32); - - v1 = sub_81C763C(0); - v1[2] = NULL; - v1[0](a0); + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + structPtr->unk8 = 0; + structPtr->unk0(a0); } u32 sub_81C786C(void) { - u32 (**v1)(void); - - v1 = sub_81C763C(0); - return v1[1](); + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + return structPtr->unk4(); } void sub_81C7880(void) { - u32 *v1; - - v1 = sub_81C763C(0); - v1[3] = sub_81C7078(atk47_cmd47, 4); + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + structPtr->unkC = sub_81C7078(sub_81C78D4, 4); } void sub_81C78A0(void) { - u32 *v1; - - v1 = sub_81C763C(0); - v1[3] = sub_81C7078(sub_81C791C, 4); + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + structPtr->unkC = sub_81C7078(sub_81C791C, 4); } bool32 sub_81C78C0(void) { - u32 *v1; - - v1 = sub_81C763C(0); - return sub_81C70D8(v1[3]); + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + return sub_81C70D8(structPtr->unkC); } -u32 atk47_cmd47(s32 a0) +u32 sub_81C78D4(s32 a0) { switch (a0) { @@ -903,12 +887,12 @@ u32 atk47_cmd47(s32 a0) case 0: return 0; case 2: - if ((u32)ChangeBgY(0, 384, 1) >= 0x2000) + if (ChangeBgY(0, 384, 1) >= 0x2000u) { ChangeBgY(0, 0x2000, 0); return 4; } - + return 2; } } @@ -923,7 +907,8 @@ u32 sub_81C791C(s32 a0) return 2; } -void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size) { +void CopyPaletteIntoBufferUnfaded(const u16 *palette, u32 bufferOffset, u32 size) +{ CpuCopy16(palette, gPlttBufferUnfaded + bufferOffset, size); } @@ -932,7 +917,7 @@ void sub_81C795C(const struct SpritePalette *palettes) const struct SpritePalette *current; u32 index; - for (current = palettes; current->data != NULL; current++) + for (current = palettes; current->data != NULL; current++) { index = AllocSpritePalette(current->tag); if (index == 0xFF) @@ -953,7 +938,7 @@ void sub_81C7990(u32 a0, u16 a1) } __attribute__((naked)) -void sub_81C79BC(u16 *a0, u16 *a1, u32 a2, u32 a3, u32 unused, u32 a5, u32 a6) +void sub_81C79BC(u16 *a0, u16 *a1, u32 a2, u32 a3, u32 a4, u32 a5) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -1090,15 +1075,15 @@ _081C7AAE:\n\ void sub_81C7AC0(s32 a0) { - u32 *v1; - v1 = sub_81C763C(0); + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + switch (a0) { case 0: - BeginNormalPaletteFade(v1[5], -2, 0, 16, RGB_BLACK); + BeginNormalPaletteFade(structPtr->unk14, -2, 0, 16, RGB_BLACK); break; case 1: - BeginNormalPaletteFade(v1[5], -2, 16, 0, RGB_BLACK); + BeginNormalPaletteFade(structPtr->unk14, -2, 16, 0, RGB_BLACK); break; case 2: BeginNormalPaletteFade(0xFFFFFFFF, -2, 0, 16, RGB_BLACK); @@ -1119,93 +1104,330 @@ void sub_81C7B40(void) BlendPalettes(0xFFFEFFFE, 16, RGB_BLACK); } -void sub_81C7B54(const struct BgTemplate *a0, s32 a1) +void InitBgTemplates(const struct BgTemplate *templates, s32 count) { s32 i; - if (a1 <= 0) - return; - for (i = a1; i != 0; i--) - { - InitBgFromTemplate(a0++); - } + + for (i = 0; i < count; i++) + InitBgFromTemplate(templates++); } void sub_81C7B74(void) { - u32 *v1; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); - v1 = sub_81C763C(0); InitWindows(&gUnknown_0861FA08[0]); - v1[4] = 0; - sub_81C7BF8(0); - PutWindowTilemap(v1[4]); - CopyWindowToVram(v1[4], 3); // TODO: Use a defined constant here. + structPtr->unk10 = 0; + sub_81C7BF8(structPtr->unk10); + PutWindowTilemap(structPtr->unk10); + CopyWindowToVram(structPtr->unk10, 3); // TODO: Use a defined constant here. } void sub_81C7BA4(u32 a0) { - u32 *v1; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); - v1 = sub_81C763C(0); - sub_81C7BF8(v1[4]); - AddTextPrinterParameterized3(v1[4], 1, 0, 1, gMenuButtonReminderColor, 0, MenuButtonReminders[a0]); + sub_81C7BF8(structPtr->unk10); + AddTextPrinterParameterized3(structPtr->unk10, 1, 0, 1, gMenuButtonReminderColor, 0, sMenuButtonReminders[a0]); } -bool8 sub_81C7BE8(void) +bool32 IsDma3ManagerBusyWithBgCopy_(void) { return IsDma3ManagerBusyWithBgCopy(); } -void sub_81C7BF8(u32 a0) +void sub_81C7BF8(u32 windowId) { - FillWindowPixelBuffer(a0, 0x44); - FillWindowPixelRect(a0, 0x55, 0, 0, 0x80, 1); + FillWindowPixelBuffer(windowId, 0x44); + FillWindowPixelRect(windowId, 0x55, 0, 0, 0x80, 1); } void sub_81C7C28(void) { - u32 *v1; - u32 i; - u8 v2; - u32 v3; - u32 v4; + s32 i; u8 spriteId; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); - v1 = sub_81C763C(0); for (i = 0; i < ARRAY_COUNT(gUnknown_0861FA4C); i++) - { LoadCompressedSpriteSheet(&gUnknown_0861FA4C[i]); - } sub_81C795C(gUnknown_0861FA54); - v2 = IndexOfSpritePaletteTag(0); - v1[5] = ~1 & ~(0x10000 << v2); + structPtr->unk14 = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0)); spriteId = CreateSprite(&gUnknown_0861FB04, 220, 12, 0); - v1[6] = (u32)(&gSprites[spriteId]); + structPtr->unk18 = &gSprites[spriteId]; } void sub_81C7C94(void) { - void **v1; - v1 = sub_81C763C(0); - DestroySprite(v1[6]); + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + DestroySprite(structPtr->unk18); FreeSpriteTilesByTag(0); FreeSpritePaletteByTag(0); } -void sub_81C7CB4(u16 *a0) +void sub_81C7CB4(struct Sprite *sprite) { - u32 v1; - v1 = GetBgY(0); - a0[19] = (v1 >> 8) * -1; + sprite->pos2.y = (GetBgY(0) / 256u) * -1; } struct Sprite *sub_81C7CCC(void) { - struct Sprite **v1; - struct Sprite *v2; - v1 = sub_81C763C(0); - v2 = v1[6]; - v2->callback = SpriteCallbackDummy; - return v2; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + structPtr->unk18->callback = SpriteCallbackDummy; + return structPtr->unk18; } + +void sub_81C7CE4(void) +{ + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + structPtr->unk18->pos1.x = 220; + structPtr->unk18->pos1.y = 12; + structPtr->unk18->callback = sub_81C7CB4; + structPtr->unk18->invisible = FALSE; + structPtr->unk18->oam.priority = 0; + structPtr->unk18->subpriority = 0; +} + +extern const struct SpriteTemplate gUnknown_0861FB2C; +extern const struct SpriteTemplate gUnknown_0861FB44; +extern const struct CompressedSpriteSheet gUnknown_0861FA6C[]; + +void sub_81C7D28(void) +{ + s32 i, spriteId; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + LoadCompressedSpriteSheet(&gUnknown_0861FA64); + AllocSpritePalette(1); + AllocSpritePalette(2); + for (i = 0; i < 2; i++) + { + spriteId = CreateSprite(&gUnknown_0861FB2C, 0, 0, 1); + structPtr->unk1C[i] = &gSprites[spriteId]; + structPtr->unk1C[i]->invisible = TRUE; + structPtr->unk1C[i]->pos2.x = i * 64; + + spriteId = CreateSprite(&gUnknown_0861FB44, 0, 0, 2); + structPtr->unk24[i] = &gSprites[spriteId]; + structPtr->unk24[i]->invisible = TRUE; + structPtr->unk24[i]->pos2.x = i * 32; + structPtr->unk24[i]->pos2.y = 18; + structPtr->unk24[i]->oam.tileNum += (i * 8) + 64; + } +} + +void sub_81C7DFC(u32 arg0) +{ + if (arg0 < 6) + sub_81C7E58(arg0); + else + sub_81C7F24(arg0 - 6); +} + +void sub_81C7E14(u32 arg0) +{ + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + if (arg0 == 4) + structPtr->unk1C[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32; + else + structPtr->unk1C[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64; +} + +void sub_81C7E58(u32 arg0) +{ + struct UnknownSubStruct_0203CF40 *structPtr; + u32 size, tag; + + if (arg0 >= 6) + return; + + structPtr = GetSubstructPtr(0); + tag = gUnknown_0861FA6C[arg0].tag; + size = GetDecompressedDataSize(gUnknown_0861FA6C[arg0].data); + LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20); + LZ77UnCompWram(gUnknown_0861FA6C[arg0].data, gDecompressionBuffer); + RequestDma3Copy(gDecompressionBuffer, (void *)VRAM + 0x10000 + (GetSpriteTileStartByTag(2) * 32), size, 1); + structPtr->unk1C[1]->oam.tileNum = GetSpriteTileStartByTag(2) + gUnknown_0861FA6C[arg0].size; + + if (arg0 == 4 || arg0 == 5) + structPtr->unk1C[1]->pos2.x = 56; + else + structPtr->unk1C[1]->pos2.x = 64; +} + +// Needed to match u32/u16 tag field difference. +struct CompressedSpritePalette_ +{ + const u32 *data; // LZ77 compressed palette data + u32 tag; +}; + +extern const struct CompressedSpritePalette_ gUnknown_0861FA9C[]; + +void sub_81C7F24(u32 arg0) +{ + u32 size, tag; + + if (arg0 >= 7) + return; + + tag = gUnknown_0861FA9C[arg0].tag; + size = GetDecompressedDataSize(gUnknown_0861FA9C[arg0].data); + LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(2) * 16) + 0x100, 0x20); + LZ77UnCompWram(gUnknown_0861FA9C[arg0].data, &gDecompressionBuffer[0x1000]); + RequestDma3Copy(&gDecompressionBuffer[0x1000], (void *)VRAM + 0x10800 + (GetSpriteTileStartByTag(2) * 32), size, 1); +} + +void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2) +{ + u32 var; + + if (!arg1) + var = 0x30; + else + var = 0x10; + + if (arg0 < 6) + sub_81C803C(var, arg2); + else + sub_81C8088(var, arg2); +} + +void sub_81C7FC4(u32 arg0, bool32 arg1) +{ + if (arg0 < 6) + sub_81C80D4(arg1); + else + sub_81C8110(arg1); +} + +void sub_81C7FDC(void) +{ + s32 i; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + for (i = 0; i < 2; i++) + { + structPtr->unk1C[i]->invisible = TRUE; + structPtr->unk24[i]->invisible = TRUE; + } +} + +bool32 sub_81C8010(void) +{ + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + if (structPtr->unk1C[0]->callback == SpriteCallbackDummy && structPtr->unk24[0]->callback == SpriteCallbackDummy) + return FALSE; + else + return TRUE; +} + +void sub_81C803C(u32 arg0, bool32 arg1) +{ + s32 var1, var2, i; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + if (!arg1) + var1 = -96, var2 = 32; + else + var1 = 256, var2 = 160; + + for (i = 0; i < 2; i++) + { + structPtr->unk1C[i]->pos1.y = arg0; + sub_81C814C(structPtr->unk1C[i], var1, var2, 12); + } +} + +void sub_81C8088(u32 arg0, bool32 arg1) +{ + s32 var1, var2, i; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + if (!arg1) + var1 = -96, var2 = 16; + else + var1 = 256, var2 = 192; + + for (i = 0; i < 2; i++) + { + structPtr->unk24[i]->pos1.y = arg0; + sub_81C814C(structPtr->unk24[i], var1, var2, 12); + } +} + +void sub_81C80D4(bool32 arg0) +{ + s32 var1, var2, i; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + if (!arg0) + var1 = 32, var2 = -96; + else + var1 = 192, var2 = 256; + + for (i = 0; i < 2; i++) + { + sub_81C814C(structPtr->unk1C[i], var1, var2, 12); + } +} + +void sub_81C8110(bool32 arg0) +{ + s32 var1, var2, i; + struct UnknownSubStruct_0203CF40 *structPtr = GetSubstructPtr(0); + + if (!arg0) + var1 = 16, var2 = -96; + else + var1 = 192, var2 = 256; + + for (i = 0; i < 2; i++) + { + sub_81C814C(structPtr->unk24[i], var1, var2, 12); + } +} + +void sub_81C814C(struct Sprite *sprite, s32 arg1, s32 arg2, s32 arg3) +{ + sprite->pos1.x = arg1; + sprite->data[0] = arg1 * 16; + sprite->data[1] = (arg2 - arg1) * 16 / arg3; + sprite->data[2] = arg3; + sprite->data[7] = arg2; + sprite->callback = sub_81C817C; +} + +void sub_81C817C(struct Sprite *sprite) +{ + if (sprite->data[2] != 0) + { + sprite->data[2]--; + sprite->data[0] += sprite->data[1]; + sprite->pos1.x = sprite->data[0] >> 4; + if (sprite->pos1.x < -16 || sprite->pos1.x > 256) + sprite->invisible = TRUE; + else + sprite->invisible = FALSE; + } + else + { + sprite->pos1.x = sprite->data[7]; + sprite->callback = SpriteCallbackDummy; + } +} + +/* +bool32 sub_81C81D4(const void *arg0, void *arg1, s32 arg3) +{ + struct UnknownSubStruct_0203CF40 *structPtr = AllocSubstruct(0x11, 0x8A4); + + if (structPtr == NULL) + return FALSE; +} +*/