From aa7f69f067a83a651c84c1feb9a874858c3adf82 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 31 Mar 2019 12:59:01 +0200 Subject: [PATCH 1/2] Begin use pokeblock and menu specialised --- asm/menu_specialized.s | 846 --------------------------------- asm/pokenav.s | 28 +- data/menu_specialized.s | 76 --- include/graphics.h | 4 + include/menu_specialized.h | 20 +- include/pokenav.h | 2 - include/strings.h | 1 + src/menu_specialized.c | 376 +++++++++++++++ src/use_pokeblock.c | 928 +++++++++++-------------------------- 9 files changed, 693 insertions(+), 1588 deletions(-) diff --git a/asm/menu_specialized.s b/asm/menu_specialized.s index a08d72aa5..b09ab4c44 100644 --- a/asm/menu_specialized.s +++ b/asm/menu_specialized.s @@ -6,857 +6,11 @@ .text - thumb_func_start sub_81D2C68 -sub_81D2C68: @ 81D2C68 - push {lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 16 - lsrs r1, 16 - cmp r0, 0xE - bne _081D2CA8 - cmp r2, 0x2 - beq _081D2C7E - cmp r2, 0x7 - bne _081D2C94 -_081D2C7E: - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - adds r1, r2, 0 - adds r2, r3, 0 - bl GetMonData - b _081D2CCA - .pool -_081D2C94: - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - adds r1, r2, 0 - bl GetMonData - b _081D2CCA - .pool -_081D2CA8: - cmp r2, 0x2 - beq _081D2CB0 - cmp r2, 0x7 - bne _081D2CBE -_081D2CB0: - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - bl GetAndCopyBoxMonDataAt - b _081D2CCA -_081D2CBE: - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - bl GetBoxMonDataAt -_081D2CCA: - pop {r1} - bx r1 - thumb_func_end sub_81D2C68 - thumb_func_start sub_81D2CD0 -sub_81D2CD0: @ 81D2CD0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - lsls r1, 16 - lsrs r4, r1, 16 - lsls r2, 16 - lsrs r6, r2, 16 - movs r0, 0xFC - strb r0, [r5] - adds r5, 0x1 - movs r0, 0x4 - strb r0, [r5] - adds r5, 0x1 - movs r0, 0x8 - strb r0, [r5] - adds r5, 0x1 - movs r0, 0 - strb r0, [r5] - adds r5, 0x1 - movs r0, 0x9 - strb r0, [r5] - adds r5, 0x1 - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0x2D - movs r3, 0 - bl sub_81D2C68 - cmp r0, 0 - beq _081D2D20 - ldr r1, =gText_EggNickname - adds r0, r5, 0 - movs r2, 0 - movs r3, 0xC - bl StringCopyPadded - b _081D2E70 - .pool -_081D2D20: - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0x2 - adds r3, r5, 0 - bl sub_81D2C68 - adds r0, r5, 0 - bl StringGetEnd10 - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0xB - movs r3, 0 - bl sub_81D2C68 - lsls r0, 16 - lsrs r7, r0, 16 - cmp r4, 0xE - bne _081D2D70 - movs r0, 0x64 - adds r4, r6, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x38 - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - adds r0, r4, 0 - bl GetMonGender - lsls r0, 24 - lsrs r6, r0, 24 - b _081D2D92 - .pool -_081D2D70: - lsls r0, r4, 24 - lsrs r0, 24 - lsls r1, r6, 24 - lsrs r1, 24 - bl GetBoxedMonPtr - adds r4, r0, 0 - bl GetBoxMonGender - lsls r0, 24 - lsrs r6, r0, 24 - adds r0, r4, 0 - bl GetLevelFromBoxMonExp - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 -_081D2D92: - cmp r7, 0x1D - beq _081D2D9A - cmp r7, 0x20 - bne _081D2DB0 -_081D2D9A: - movs r0, 0xB - adds r1, r7, 0 - muls r1, r0 - ldr r0, =gSpeciesNames - adds r1, r0 - adds r0, r5, 0 - bl StringCompare - cmp r0, 0 - bne _081D2DB0 - movs r6, 0xFF -_081D2DB0: - adds r3, r5, 0 - b _081D2DBA - .pool -_081D2DB8: - adds r3, 0x1 -_081D2DBA: - ldrb r0, [r3] - cmp r0, 0xFF - bne _081D2DB8 - movs r1, 0xFC - strb r1, [r3] - adds r3, 0x1 - movs r0, 0x12 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0x3C - strb r0, [r3] - adds r3, 0x1 - cmp r6, 0 - beq _081D2DDE - cmp r6, 0xFE - beq _081D2E02 - movs r0, 0 - b _081D2E24 -_081D2DDE: - strb r1, [r3] - adds r3, 0x1 - movs r0, 0x1 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0x4 - strb r0, [r3] - adds r3, 0x1 - strb r1, [r3] - adds r3, 0x1 - movs r0, 0x3 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0x5 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0xB5 - b _081D2E24 -_081D2E02: - strb r1, [r3] - adds r3, 0x1 - movs r0, 0x1 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0x6 - strb r0, [r3] - adds r3, 0x1 - strb r1, [r3] - adds r3, 0x1 - movs r0, 0x3 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0x7 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0xB6 -_081D2E24: - strb r0, [r3] - adds r3, 0x1 - movs r0, 0xFC - strb r0, [r3] - adds r3, 0x1 - movs r0, 0x4 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0x8 - strb r0, [r3] - adds r3, 0x1 - movs r4, 0 - strb r4, [r3] - adds r3, 0x1 - movs r0, 0x9 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0xBA - strb r0, [r3] - adds r3, 0x1 - movs r0, 0xF9 - strb r0, [r3] - adds r3, 0x1 - movs r0, 0x5 - strb r0, [r3] - adds r3, 0x1 - adds r0, r3, 0 - mov r1, r8 - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - adds r3, r0, 0 - strb r4, [r3] - adds r3, 0x1 - movs r0, 0xFF - strb r0, [r3] - adds r0, r3, 0 -_081D2E70: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81D2CD0 - thumb_func_start sub_81D2E7C -sub_81D2E7C: @ 81D2E7C - push {r4,lr} - adds r4, r0, 0 - lsls r2, 16 - lsrs r2, 16 - b _081D2E94 -_081D2E86: - strb r3, [r4] - adds r1, 0x1 - adds r4, 0x1 - lsls r0, r2, 16 - ldr r2, =0xffff0000 - adds r0, r2 - lsrs r2, r0, 16 -_081D2E94: - ldrb r3, [r1] - adds r0, r3, 0 - cmp r0, 0xFF - bne _081D2E86 - adds r1, r2, 0 - lsls r0, r1, 16 - ldr r2, =0xffff0000 - adds r0, r2 - lsrs r2, r0, 16 - lsls r1, 16 - cmp r1, 0 - ble _081D2EC2 - movs r3, 0 -_081D2EAE: - strb r3, [r4] - adds r4, 0x1 - adds r1, r2, 0 - lsls r0, r1, 16 - ldr r2, =0xffff0000 - adds r0, r2 - lsrs r2, r0, 16 - lsls r1, 16 - cmp r1, 0 - bgt _081D2EAE -_081D2EC2: - movs r0, 0xFF - strb r0, [r4] - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D2E7C - thumb_func_start sub_81D2ED4 -sub_81D2ED4: @ 81D2ED4 - push {r4-r7,lr} - adds r5, r0, 0 - adds r6, r1, 0 - ldr r0, [sp, 0x14] - ldr r1, [sp, 0x18] - ldr r4, [sp, 0x1C] - lsls r2, 16 - lsrs r7, r2, 16 - lsls r3, 16 - lsrs r3, 16 - lsls r0, 16 - lsrs r2, r0, 16 - lsls r1, 16 - lsrs r0, r1, 16 - lsls r4, 24 - cmp r4, 0 - bne _081D2EFC - subs r0, 0x1 - lsls r0, 16 - lsrs r0, 16 -_081D2EFC: - cmp r2, r0 - beq _081D2F42 - adds r0, r6, 0 - adds r1, r7, 0 - adds r2, r3, 0 - bl sub_81D2CD0 - movs r0, 0xFC - strb r0, [r5] - movs r0, 0x4 - strb r0, [r5, 0x1] - movs r0, 0x8 - strb r0, [r5, 0x2] - movs r0, 0 - strb r0, [r5, 0x3] - movs r0, 0x9 - strb r0, [r5, 0x4] - cmp r7, 0xE - bne _081D2F2C - adds r0, r5, 0x5 - ldr r1, =gText_InParty - b _081D2F3A - .pool -_081D2F2C: - adds r4, r5, 0x5 - lsls r0, r7, 24 - lsrs r0, 24 - bl GetBoxNamePtr - adds r1, r0, 0 - adds r0, r4, 0 -_081D2F3A: - movs r2, 0x8 - bl sub_81D2E7C - b _081D2F72 -_081D2F42: - movs r1, 0 - movs r2, 0 -_081D2F46: - adds r0, r6, r1 - strb r2, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0xB - bls _081D2F46 - adds r1, r6, r1 - movs r0, 0xFF - strb r0, [r1] - movs r1, 0 - movs r2, 0 -_081D2F5E: - adds r0, r5, r1 - strb r2, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x7 - bls _081D2F5E - adds r1, r5, r1 - movs r0, 0xFF - strb r0, [r1] -_081D2F72: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D2ED4 - thumb_func_start sub_81D2F78 -sub_81D2F78: @ 81D2F78 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r8, r0 - mov r10, r1 - ldr r0, [sp, 0x20] - ldr r1, [sp, 0x24] - ldr r4, [sp, 0x28] - ldr r5, [sp, 0x2C] - lsls r2, 16 - lsrs r7, r2, 16 - lsls r3, 16 - lsrs r6, r3, 16 - lsls r0, 16 - lsrs r2, r0, 16 - lsls r1, 16 - lsrs r1, 16 - mov r9, r1 - lsls r4, 16 - lsrs r0, r4, 16 - lsls r5, 24 - cmp r5, 0 - bne _081D2FB0 - subs r0, 0x1 - lsls r0, 16 - lsrs r0, 16 -_081D2FB0: - cmp r2, r0 - beq _081D305C - adds r0, r7, 0 - adds r1, r6, 0 - movs r2, 0x16 - movs r3, 0 - bl sub_81D2C68 - mov r1, r9 - lsls r5, r1, 2 - adds r4, r5, r1 - mov r2, r8 - adds r1, r2, r4 - strb r0, [r1] - adds r0, r7, 0 - adds r1, r6, 0 - movs r2, 0x2F - movs r3, 0 - bl sub_81D2C68 - mov r1, r8 - adds r1, 0x1 - adds r1, r4 - strb r0, [r1] - adds r0, r7, 0 - adds r1, r6, 0 - movs r2, 0x21 - movs r3, 0 - bl sub_81D2C68 - mov r1, r8 - adds r1, 0x2 - adds r1, r4 - strb r0, [r1] - adds r0, r7, 0 - adds r1, r6, 0 - movs r2, 0x18 - movs r3, 0 - bl sub_81D2C68 - mov r1, r8 - adds r1, 0x3 - adds r1, r4 - strb r0, [r1] - adds r0, r7, 0 - adds r1, r6, 0 - movs r2, 0x17 - movs r3, 0 - bl sub_81D2C68 - mov r1, r8 - adds r1, 0x4 - adds r1, r4 - strb r0, [r1] - mov r4, r10 - add r4, r9 - adds r0, r7, 0 - adds r1, r6, 0 - movs r2, 0x30 - movs r3, 0 - bl sub_81D2C68 - cmp r0, 0xFF - beq _081D3044 - adds r0, r7, 0 - adds r1, r6, 0 - movs r2, 0x30 - movs r3, 0 - bl sub_81D2C68 - movs r1, 0x1D - bl __udivsi3 - b _081D3046 -_081D3044: - movs r0, 0x9 -_081D3046: - strb r0, [r4] - mov r0, r9 - adds r1, r5, r0 - mov r2, r8 - adds r0, r2, r1 - lsls r1, 2 - adds r1, 0x14 - add r1, r8 - bl sub_81D2754 - b _081D3086 -_081D305C: - movs r2, 0 - mov r0, r9 - lsls r5, r0, 2 - adds r1, r5, r0 - movs r6, 0 - lsls r3, r1, 2 - movs r5, 0x9B - movs r4, 0x5B -_081D306C: - adds r0, r2, r1 - add r0, r8 - strb r6, [r0] - lsls r0, r2, 2 - adds r0, r3 - add r0, r8 - strh r5, [r0, 0x14] - strh r4, [r0, 0x16] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0x4 - bls _081D306C -_081D3086: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D2F78 - thumb_func_start sub_81D3094 -sub_81D3094: @ 81D3094 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - mov r8, r0 - mov r9, r1 - ldr r0, [sp, 0x20] - ldr r1, [sp, 0x24] - ldr r4, [sp, 0x28] - lsls r2, 16 - lsrs r7, r2, 16 - lsls r3, 16 - lsrs r5, r3, 16 - lsls r0, 16 - lsrs r2, r0, 16 - lsls r1, 16 - lsrs r0, r1, 16 - lsls r4, 24 - cmp r4, 0 - bne _081D30C4 - subs r0, 0x1 - lsls r0, 16 - lsrs r0, 16 -_081D30C4: - cmp r2, r0 - beq _081D311A - adds r0, r7, 0 - adds r1, r5, 0 - movs r2, 0x41 - movs r3, 0 - bl sub_81D2C68 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r7, 0 - adds r1, r5, 0 - movs r2, 0x1 - movs r3, 0 - bl sub_81D2C68 - adds r6, r0, 0 - adds r0, r7, 0 - adds r1, r5, 0 - movs r2, 0 - movs r3, 0 - bl sub_81D2C68 - adds r5, r0, 0 - lsls r0, r4, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - movs r1, 0x1 - str r1, [sp] - mov r1, r8 - adds r2, r4, 0 - adds r3, r5, 0 - bl LoadSpecialPokePic - adds r0, r4, 0 - adds r1, r6, 0 - adds r2, r5, 0 - bl GetFrontSpritePalFromSpeciesAndPersonality - mov r1, r9 - bl LZ77UnCompWram -_081D311A: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D3094 - - thumb_func_start sub_81D312C -sub_81D312C: @ 81D312C - push {lr} - adds r1, r0, 0 - ldrh r0, [r1] - adds r0, 0x18 - strh r0, [r1] - lsls r0, 16 - cmp r0, 0 - ble _081D3140 - movs r0, 0 - strh r0, [r1] -_081D3140: - movs r0, 0 - ldrsh r1, [r1, r0] - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - pop {r1} - bx r1 - thumb_func_end sub_81D312C - - thumb_func_start sub_81D3150 -sub_81D3150: @ 81D3150 - push {lr} - adds r1, r0, 0 - ldrh r0, [r1] - subs r0, 0x18 - strh r0, [r1] - lsls r0, 16 - asrs r0, 16 - movs r2, 0x50 - negs r2, r2 - cmp r0, r2 - bge _081D3168 - strh r2, [r1] -_081D3168: - movs r0, 0 - ldrsh r1, [r1, r0] - eors r1, r2 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - pop {r1} - bx r1 - thumb_func_end sub_81D3150 - - thumb_func_start sub_81D3178 -sub_81D3178: @ 81D3178 - push {r4,r5,lr} - adds r5, r1, 0 - bl sub_81D2074 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r5, 0 - bl sub_81D312C - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - cmp r4, 0 - bne _081D319A - cmp r0, 0 - beq _081D319C -_081D319A: - movs r1, 0x1 -_081D319C: - adds r0, r1, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81D3178 - - thumb_func_start sub_81D31A4 -sub_81D31A4: @ 81D31A4 - push {r4,r5,lr} - adds r5, r1, 0 - bl sub_81D2074 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r5, 0 - bl sub_81D3150 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - cmp r4, 0 - bne _081D31C6 - cmp r0, 0 - beq _081D31C8 -_081D31C6: - movs r1, 0x1 -_081D31C8: - adds r0, r1, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81D31A4 - - thumb_func_start sub_81D31D0 -sub_81D31D0: @ 81D31D0 - push {r4-r7,lr} - sub sp, 0x20 - ldr r3, =gUnknown_08625A48 - ldr r4, [r3] - ldr r5, [r3, 0x4] - str r4, [sp, 0x18] - str r5, [sp, 0x1C] - mov r4, sp - ldr r3, =gUnknown_08625A50 - ldm r3!, {r5-r7} - stm r4!, {r5-r7} - ldm r3!, {r5-r7} - stm r4!, {r5-r7} - ldr r3, =gUnknown_08625A68 - ldr r4, [r3, 0x4] - ldr r3, [r3] - ldr r5, [sp, 0x18] - ldr r6, [sp, 0x1C] - str r5, [r0] - str r6, [r0, 0x4] - mov r0, sp - ldm r0!, {r5-r7} - stm r1!, {r5-r7} - ldm r0!, {r5-r7} - stm r1!, {r5-r7} - str r3, [r2] - str r4, [r2, 0x4] - add sp, 0x20 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D31D0 - - thumb_func_start sub_81D321C -sub_81D321C: @ 81D321C - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x50 - adds r5, r0, 0 - mov r12, r1 - mov r8, r2 - mov r1, sp - ldr r0, =gUnknown_08625A70 - ldm r0!, {r2-r4} - stm r1!, {r2-r4} - ldm r0!, {r2,r6,r7} - stm r1!, {r2,r6,r7} - ldm r0!, {r3,r4} - stm r1!, {r3,r4} - add r3, sp, 0x20 - adds r1, r3, 0 - ldr r0, =gUnknown_08625A90 - ldm r0!, {r2,r6,r7} - stm r1!, {r2,r6,r7} - ldm r0!, {r4,r6,r7} - stm r1!, {r4,r6,r7} - add r2, sp, 0x38 - adds r1, r2, 0 - ldr r0, =gUnknown_08625AA8 - ldm r0!, {r4,r6,r7} - stm r1!, {r4,r6,r7} - ldm r0!, {r4,r6,r7} - stm r1!, {r4,r6,r7} - movs r4, 0 -_081D3258: - lsls r0, r4, 3 - add r0, sp - ldr r1, [r0, 0x4] - ldr r0, [r0] - stm r5!, {r0,r1} - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _081D3258 - mov r1, r12 - adds r0, r2, 0 - ldm r0!, {r2,r4,r5} - stm r1!, {r2,r4,r5} - ldm r0!, {r2,r6,r7} - stm r1!, {r2,r6,r7} - movs r4, 0 -_081D327A: - lsls r0, r4, 3 - adds r0, r3, r0 - ldr r1, [r0, 0x4] - ldr r0, [r0] - mov r5, r8 - adds r5, 0x8 - mov r8, r5 - subs r5, 0x8 - stm r5!, {r0,r1} - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x2 - bls _081D327A - add sp, 0x50 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D321C - - thumb_func_start sub_81D32B0 -sub_81D32B0: @ 81D32B0 - push {r4,r5,lr} - ldr r2, =gUnknown_08625AC0 - ldr r4, [r2] - ldr r5, [r2, 0x4] - ldr r2, =gUnknown_08625AC8 - ldr r3, [r2, 0x4] - ldr r2, [r2] - str r4, [r0] - str r5, [r0, 0x4] - str r2, [r1] - str r3, [r1, 0x4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D32B0 thumb_func_start sub_81D32D4 sub_81D32D4: @ 81D32D4 diff --git a/asm/pokenav.s b/asm/pokenav.s index d568f4281..f575c9aa8 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -10839,7 +10839,7 @@ sub_81CD624: @ 81CD624 adds r1, r6, 0 movs r2, 0x2D movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData cmp r0, 0 beq _081CD690 ldr r1, =gText_EggNickname @@ -10854,14 +10854,14 @@ _081CD690: adds r1, r6, 0 movs r2, 0x2 adds r3, r5, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData adds r0, r5, 0 bl StringGetEnd10 adds r0, r4, 0 adds r1, r6, 0 movs r2, 0xB movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData lsls r0, 16 lsrs r7, r0, 16 cmp r4, 0xE @@ -11328,7 +11328,7 @@ _081CDA5A: adds r1, r7, 0 movs r2, 0x16 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData mov r1, r9 lsls r5, r1, 2 adds r4, r5, r1 @@ -11340,7 +11340,7 @@ _081CDA5A: adds r1, r7, 0 movs r2, 0x2F movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData ldr r1, =0x00006429 add r1, r8 adds r1, r4 @@ -11349,7 +11349,7 @@ _081CDA5A: adds r1, r7, 0 movs r2, 0x21 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData ldr r1, =0x0000642a add r1, r8 adds r1, r4 @@ -11358,7 +11358,7 @@ _081CDA5A: adds r1, r7, 0 movs r2, 0x18 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData ldr r1, =0x0000642b add r1, r8 adds r1, r4 @@ -11367,7 +11367,7 @@ _081CDA5A: adds r1, r7, 0 movs r2, 0x17 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData ldr r1, =0x0000642c add r1, r8 adds r1, r4 @@ -11381,14 +11381,14 @@ _081CDA5A: adds r1, r7, 0 movs r2, 0x30 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData cmp r0, 0xFF beq _081CDB10 adds r0, r6, 0 adds r1, r7, 0 movs r2, 0x30 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData movs r1, 0x1D bl __udivsi3 b _081CDB12 @@ -11401,7 +11401,7 @@ _081CDB12: adds r1, r7, 0 movs r2, 0x8 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData ldr r1, =0x00006783 add r1, r8 add r1, r9 @@ -11498,7 +11498,7 @@ _081CDBD0: adds r1, r6, 0 movs r2, 0x41 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData adds r4, r0, 0 lsls r4, 16 lsrs r4, 16 @@ -11506,13 +11506,13 @@ _081CDBD0: adds r1, r6, 0 movs r2, 0x1 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData mov r8, r0 adds r0, r5, 0 adds r1, r6, 0 movs r2, 0 movs r3, 0 - bl sub_81D2C68 + bl GetBoxOrPartyMonData adds r5, r0, 0 lsls r0, r4, 3 ldr r1, =gMonFrontPicTable diff --git a/data/menu_specialized.s b/data/menu_specialized.s index e88a68fcc..2005d5bf6 100644 --- a/data/menu_specialized.s +++ b/data/menu_specialized.s @@ -3,84 +3,8 @@ .section .rodata -gUnknown_08625560:: @ 8625560 - .incbin "graphics/pokenav/pokeball.4bpp" -gUnknown_08625660:: @ 8625660 - .incbin "graphics/pokenav/pokeball_placeholder.4bpp" - -gUnknown_08625680:: @ 8625680 - .incbin "graphics/pokenav/sparkle.gbapal" - -gUnknown_086256A0:: @ 86255A0 - .incbin "graphics/pokenav/sparkle.4bpp" - -gUnknown_08625A20:: @ 8625A20 - .2byte 0 - .2byte 0xC000 - .2byte 0x400 - .2byte 0 - -gUnknown_08625A28:: @ 8625A28 - .2byte 0 - .2byte 0x4000 - .2byte 0x800 - .2byte 0 - -gUnknown_08625A30:: @ 8625A30 - .2byte 0 - .2byte 5 - .2byte 0xFFFF - .2byte 0 - -gUnknown_08625A38:: @ 8625A38 - .2byte 4 - .2byte 5 - .2byte 0xFFFF - .2byte 0 - -gUnknown_08625A40:: @ 8625A40 - .4byte gUnknown_08625A30 - .4byte gUnknown_08625A38 -gUnknown_08625A48:: @ 8625A48 - .4byte NULL - .4byte 0x640800 - -gUnknown_08625A50:: @ 8625A50 - spr_template 0x64, 0x64, gUnknown_08625A20, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - -gUnknown_08625A68:: @ 8625A68 - .4byte NULL - .4byte 0x64 - -gUnknown_08625A70:: @ 8625A70 - .4byte gUnknown_08625560 - .byte 0, 1, 0x65, 0 - .4byte gUnknown_08625660 - .2byte 0x20, 0x67 - .4byte gPokenavConditionCancel_Gfx - .byte 0, 1, 0x66, 0 - .4byte NULL, NULL - -gUnknown_08625A90:: @ 8625A90 - .4byte gPokenavConditionCancel_Pal + 0x0 - .byte 0x65, 0, 0, 0 - .4byte gPokenavConditionCancel_Pal + 0x20 - .byte 0x66, 0, 0, 0 - .4byte NULL, NULL - -gUnknown_08625AA8:: @ 8625AA8 - spr_template 0x65, 0x65, gUnknown_08625A28, gUnknown_08625A40, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - -gUnknown_08625AC0:: @ 8625AC0 - .4byte gUnknown_086256A0 - .byte 0x80, 3, 0x68, 0 - -gUnknown_08625AC8:: @ 8625AC8 - .4byte gUnknown_08625680 - .byte 0x68, 0, 0, 0 - gUnknown_08625AD0:: @ 8625AD0 .2byte 0 .2byte 0x4000 diff --git a/include/graphics.h b/include/graphics.h index b49b2a661..7833d4f7d 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4917,4 +4917,8 @@ extern const u16 gLinkMiscMenu_Pal[]; extern const u32 gLinkMiscMenu_Gfx[]; extern const u32 gLinkMiscMenu_Tilemap[]; +// Pokeblock +extern const u8 gPokenavConditionCancel_Gfx[]; +extern const u16 gPokenavConditionCancel_Pal[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/menu_specialized.h b/include/menu_specialized.h index a629ab014..90623a888 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -26,6 +26,12 @@ struct UnknownStruct_81D1ED4 /*0x355*/ u8 unk355; }; +struct Unk81D2F78_Struct +{ + u8 contestStats[4][5]; + struct UnknownSubStruct_81D1ED4 field_20[4][5]; +}; + bool8 sub_81D1C44(u8 count); u8 sub_81D1C84(u8 a0); u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page); @@ -43,10 +49,7 @@ bool8 sub_81D20BC(struct UnknownStruct_81D1ED4 *arg0); void sub_81D354C(struct Sprite **); void sub_81D3464(struct Sprite **arg0); void sub_81D3480(struct Sprite **arg0, u8 arg1, u8 arg2); -u8 sub_81D3178(struct UnknownStruct_81D1ED4*, u16*); -u8 sub_81D31A4(struct UnknownStruct_81D1ED4*, u16*); bool32 sub_81D2074(struct UnknownStruct_81D1ED4 *a0); -u8 sub_81D3150(u16 *arg0); void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1); void sub_81D1F84(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2); void MoveRelearnerPrintText(u8 *str); @@ -55,5 +58,16 @@ void MoveRelearnerCreateYesNoMenu(void); u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices); void InitMoveRelearnerWindows(bool8 useContextWindow); void GetMonLevelUpWindowStats(struct Pokemon* mon, void* statStoreLocation); +s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst); +void sub_81D2ED4(u8 *dst, u8 *nameDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); +void sub_81D2F78(struct Unk81D2F78_Struct *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8); +void sub_81D3094(u8 *tilesDst, u8 *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); +bool8 sub_81D312C(s16 *var); +bool8 sub_81D3150(s16 *var); +bool8 sub_81D3178(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1); +bool8 sub_81D31A4(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1); +void sub_81D31D0(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal); +void sub_81D321C(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals); +void sub_81D32B0(struct SpriteSheet *sheet, struct SpritePalette *pal); #endif // GUARD_MENU_SPECIALIZED_H diff --git a/include/pokenav.h b/include/pokenav.h index 13cb0babf..4e1648c93 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -1,8 +1,6 @@ #ifndef GUARD_POKENAV_H #define GUARD_POKENAV_H -#include "list_menu.h" -bool8 sub_81D312C(void *arg0); void CB2_InitPokeNav(void); #endif //GUARD_POKENAV_H diff --git a/include/strings.h b/include/strings.h index 4a65e6875..c762ebd45 100644 --- a/include/strings.h +++ b/include/strings.h @@ -194,6 +194,7 @@ extern const u8 gText_SeeYaDescription[]; extern const u8 gText_EggNickname[]; extern const u8 gText_Pokemon[]; +extern const u8 gText_InParty[]; extern const u8 gText_InGameClockUsable[]; // reset rtc screen texts diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 3dadc7f80..ae150dcb4 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -2,7 +2,10 @@ #include "alloc.h" #include "battle_main.h" #include "contest_effect.h" +#include "data2.h" +#include "decompress.h" #include "gpu_regs.h" +#include "graphics.h" #include "menu.h" #include "international_string_util.h" #include "menu.h" @@ -11,16 +14,21 @@ #include "palette.h" #include "player_pc.h" #include "pokemon_summary_screen.h" +#include "pokemon_storage_system.h" #include "scanline_effect.h" #include "sound.h" #include "strings.h" #include "string_util.h" +#include "text.h" #include "text_window.h" #include "trig.h" #include "window.h" #include "constants/songs.h" +#include "constants/species.h" #include "gba/io_reg.h" +extern const struct CompressedSpriteSheet gMonFrontPicTable[]; + EWRAM_DATA static u8 sUnknown_0203CF48[3] = {0}; EWRAM_DATA static struct ListMenuItem *sUnknown_0203CF4C = NULL; @@ -1075,3 +1083,371 @@ void MoveRelearnerCreateYesNoMenu(void) { CreateYesNoMenu(&sMoveRelearnerYesNoMenuTemplate, 1, 0xE, 0); } + +s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst) +{ + s32 ret; + + if (boxId == TOTAL_BOXES_COUNT) // Party mon. + { + if (request == MON_DATA_NICKNAME || request == MON_DATA_OT_NAME) + ret = GetMonData(&gPlayerParty[monId], request, dst); + else + ret = GetMonData(&gPlayerParty[monId], request); + } + else + { + if (request == MON_DATA_NICKNAME || request == MON_DATA_OT_NAME) + ret = GetAndCopyBoxMonDataAt(boxId, monId, request, dst); + else + ret = GetBoxMonDataAt(boxId, monId, request); + } + + return ret; +} + +static u8 *sub_81D2CD0(u8 *dst, u16 boxId, u16 monId) +{ + u16 species, level, gender; + struct BoxPokemon *boxMon; + u8 *str; + + *(dst++) = EXT_CTRL_CODE_BEGIN; + *(dst++) = 4; + *(dst++) = 8; + *(dst++) = 0; + *(dst++) = 9; + if (GetBoxOrPartyMonData(boxId, monId, MON_DATA_IS_EGG, NULL)) + { + return StringCopyPadded(dst, gText_EggNickname, 0, 12); + } + else + { + GetBoxOrPartyMonData(boxId, monId, MON_DATA_NICKNAME, dst); + StringGetEnd10(dst); + species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES, NULL); + if (boxId == TOTAL_BOXES_COUNT) // Party mon. + { + level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); + gender = GetMonGender(&gPlayerParty[monId]); + } + else + { + // Needed to match, feel free to remove. + boxId++;boxId--; + monId++;monId--; + + boxMon = GetBoxedMonPtr(boxId, monId); + gender = GetBoxMonGender(boxMon); + level = GetLevelFromBoxMonExp(boxMon); + } + + if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(dst, gSpeciesNames[species])) + gender = MON_GENDERLESS; + + for (str = dst; *str != EOS; str++) + ; + + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = 0x12; + *(str++) = 0x3C; + + switch (gender) + { + default: + *(str++) = CHAR_SPACE; + break; + case MON_MALE: + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = EXT_CTRL_CODE_COLOR; + *(str++) = 4; + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = 3; + *(str++) = 5; + *(str++) = CHAR_MALE; + break; + case MON_FEMALE: + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = EXT_CTRL_CODE_COLOR; + *(str++) = 6; + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = 3; + *(str++) = 7; + *(str++) = CHAR_FEMALE; + break; + } + + *(str++) = EXT_CTRL_CODE_BEGIN; + *(str++) = 4; + *(str++) = 8; + *(str++) = 0; + *(str++) = 9; + *(str++) = CHAR_SLASH; + *(str++) = CHAR_SPECIAL_F9; + *(str++) = 5; + str = ConvertIntToDecimalStringN(str, level, STR_CONV_MODE_LEFT_ALIGN, 3); + *(str++) = CHAR_SPACE; + *str = EOS; + + return str; + } +} + +static u8 *sub_81D2E7C(u8 *dst, const u8 *src, s16 n) +{ + while (*src != EOS) + { + *(dst++) = *(src++); + n--; + } + while (n-- > 0) + *(dst++) = CHAR_SPACE; + + *dst = EOS; + return dst; +} + +void sub_81D2ED4(u8 *dst, u8 *nameDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7) +{ + u16 i; + + if (!arg7) + arg6--; + + if (arg5 != arg6) + { + sub_81D2CD0(nameDst, boxId, monId); + dst[0] = EXT_CTRL_CODE_BEGIN; + dst[1] = 4; + dst[2] = 8; + dst[3] = 0; + dst[4] = 9; + if (boxId == TOTAL_BOXES_COUNT) // Party mon. + { + sub_81D2E7C(dst + 5, gText_InParty, 8); + } + else + { + boxId++;boxId--; // Again...Someone fix this maybe? + sub_81D2E7C(dst + 5, GetBoxNamePtr(boxId), 8); + } + } + else + { + for (i = 0; i < 12; i++) + nameDst[i] = CHAR_SPACE; + nameDst[i] = EOS; + for (i = 0; i < 8; i++) + dst[i] = CHAR_SPACE; + dst[i] = EOS; + } +} + +void sub_81D2F78(struct Unk81D2F78_Struct *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8) +{ + u16 i; + + if (!arg8) + arg7--; + + if (arg5 != arg7) + { + arg0->contestStats[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + arg0->contestStats[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + arg0->contestStats[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + arg0->contestStats[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + arg0->contestStats[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + + sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF) + ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u + : 9; + + sub_81D2754(arg0->contestStats[id], arg0->field_20[id]); + } + else + { + for (i = 0; i < 5; i++) + { + arg0->contestStats[id][i] = 0; + arg0->field_20[id][i].unk0 = 155; + arg0->field_20[id][i].unk2 = 91; + } + } +} + +void sub_81D3094(u8 *tilesDst, u8 *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7) +{ + if (!arg7) + arg6--; + + if (arg5 != arg6) + { + u16 species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); + u32 trainerId = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); + u32 personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); + + LoadSpecialPokePic(&gMonFrontPicTable[species], tilesDst, species, personality, TRUE); + LZ77UnCompWram(GetFrontSpritePalFromSpeciesAndPersonality(species, trainerId, personality), palDst); + } +} + +bool8 sub_81D312C(s16 *var) +{ + *var += 24; + if (*var > 0) + *var = 0; + + return (*var != 0); +} + +bool8 sub_81D3150(s16 *var) +{ + *var -= 24; + if (*var < -80) + *var = -80; + + return (*var != -80); +} + +bool8 sub_81D3178(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1) +{ + bool8 var1 = sub_81D2074(arg0); + bool8 var2 = sub_81D312C(arg1); + + return ((var1 != 0) || (var2 != 0)); +} + +bool8 sub_81D31A4(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1) +{ + bool8 var1 = sub_81D2074(arg0); + bool8 var2 = sub_81D3150(arg1); + + return ((var1 != 0) || (var2 != 0)); +} + +const u32 gUnknown_08625560[] = INCBIN_U32("graphics/pokenav/pokeball.4bpp"); +const u32 gUnknown_08625660[] = INCBIN_U32("graphics/pokenav/pokeball_placeholder.4bpp"); +const u16 gUnknown_08625680[] = INCBIN_U16("graphics/pokenav/sparkle.gbapal"); +const u32 gUnknown_086256A0[] = INCBIN_U32("graphics/pokenav/sparkle.4bpp"); + +static const struct OamData sOamData_8625A20 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +const struct OamData sOamData_8625A28 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 2, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_8625A30[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_8625A38[] = +{ + ANIMCMD_FRAME(4, 5), + ANIMCMD_END +}; + +const union AnimCmd *const sSpriteAnimTable_8625A40[] = +{ + sSpriteAnim_8625A30, + sSpriteAnim_8625A38 +}; + +void sub_81D31D0(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal) +{ + struct SpriteSheet dataSheet = {NULL, 0x800, 100}; + + struct SpriteTemplate dataTemplate = + { + .tileTag = 100, + .paletteTag = 100, + .oam = &sOamData_8625A20, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }; + + struct SpritePalette dataPal = {NULL, 100}; + + *sheet = dataSheet; + *template = dataTemplate; + *pal = dataPal; +} + +void sub_81D321C(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals) +{ + u8 i; + + struct SpriteSheet dataSheets[] = + { + {gUnknown_08625560, 0x100, 101}, + {gUnknown_08625660, 0x20, 103}, + {gPokenavConditionCancel_Gfx, 0x100, 102}, + {}, + }; + + struct SpritePalette dataPals[] = + { + {gPokenavConditionCancel_Pal, 101}, + {gPokenavConditionCancel_Pal + 16, 102}, + {}, + }; + + struct SpriteTemplate dataTemplate = + { + .tileTag = 101, + .paletteTag = 101, + .oam = &sOamData_8625A28, + .anims = sSpriteAnimTable_8625A40, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }; + + for (i = 0; i < ARRAY_COUNT(dataSheets); i++) + *(sheets++) = dataSheets[i]; + + *template = dataTemplate; + + for (i = 0; i < ARRAY_COUNT(dataPals); i++) + *(pals++) = dataPals[i]; +} + +void sub_81D32B0(struct SpriteSheet *sheet, struct SpritePalette *pal) +{ + struct SpriteSheet dataSheet = {gUnknown_086256A0, 0x380, 104}; + struct SpritePalette dataPal = {gUnknown_08625680, 104}; + + *sheet = dataSheet; + *pal = dataPal; +} diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 9b02eeb72..d78132585 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -27,7 +27,7 @@ struct UsePokeblockSubStruct /*0x00*/ void (*field_0)(void); /*0x04*/ void (*callback)(void); /*0x08*/ struct Pokeblock *pokeblock; - /*0x0C*/ struct Pokemon *pokemon; + /*0x0C*/ struct Pokemon *mon; /*0x10*/ u8 stringBuffer[0x40]; /*0x50*/ u8 field_50; /*0x51*/ u8 field_51; @@ -57,11 +57,17 @@ struct Unk7FB8 struct UsePokeblockStruct { - /*0x0000*/ u8 field_0[0x7B06]; + /*0x0000*/ u8 field_0[4]; + /*0x0000*/ u16 field_4[3][0x40]; + /*0x0184*/ u8 field_184[0x304 - 0x184]; + /*0x0304*/ u8 field_304[3][0x2000]; + /*0x6304*/ u8 field_6304[0x7b06 - 0x6304]; /*0x7B06*/ u8 field_7B06[7]; - /*0x7B0E*/ u16 field_7B0E; + /*0x7B0E*/ s16 field_7B0E; /*0x7B10*/ u8 field_7B10; - /*0x7B11*/ u8 field_7B11[0xB]; + /*0x7B12*/ u16 field_7B12; + /*0x7B12*/ u16 field_7B14; + /*0x7B12*/ u8 *field_7B18; /*0x7B1C*/ struct Sprite *field_7B1C[10]; /*0x7B44*/ struct Sprite *field_7B44[2]; /*0x7B4C*/ u8 field_7B4C; @@ -80,6 +86,8 @@ struct UsePokeblockStruct extern u16 gKeyRepeatStartDelay; +extern void sub_81D21DC(u8); + // this file's functions void sub_816636C(void (*func)(void)); void sub_8166380(void); @@ -100,7 +108,7 @@ static void sub_8167CA0(bool8); void sub_8166BEC(void); void sub_8166D44(void); s8 sub_8166DE4(void); -bool8 sub_8167268(void); +bool8 IsSheenMaxed(void); void sub_8166F50(void); void sub_816681C(void); void sub_8166F94(void); @@ -114,22 +122,15 @@ bool8 sub_8166EDC(void); void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2); void Pokeblock_MenuWindowTextPrint(const u8 *message); void sub_8167184(struct Pokeblock *, struct Pokemon *); -extern u32 sub_81D2C68(s32, s32, s32, u8 *); void sub_81673DC(struct Sprite *sprite); void sub_81674BC(void); void sub_816753C(s16, u8); static u8 sub_8167EA4(void); static u8 sub_8167FA4(void); static u8 sub_8168048(void); -extern void sub_81D2ED4(u8, u8, u16, u8, u8, u8, u8); -extern void sub_81D2F78(u8, u8, s16, u16, u8, u8, u8, u8); -extern void sub_81D3094(u8, u8, s16, u16, u8, u8, u8); -extern void sub_81D31D0(struct SpritePalette *, struct SpritePalette *, struct SpritePalette *); -extern void sub_81D321C(struct SpriteSheet *, struct SpriteTemplate *, struct SpritePalette*); void sub_8168180(struct Sprite *sprite); void sub_81681B4(struct Sprite *sprite); -extern void sub_81D32B0(struct SpriteSheet *, struct SpritePalette*); -extern void sub_81D21DC(u8); +void sub_8168168(struct Sprite *sprite); extern const struct BgTemplate gUnknown_085DFCCC[4]; extern const struct WindowTemplate gUnknown_085DFCDC[]; @@ -160,9 +161,9 @@ EWRAM_DATA void (*gUnknown_0203BC94)(void) = NULL; EWRAM_DATA struct Pokeblock *gUnknown_0203BC98 = NULL; EWRAM_DATA u8 gPokeblockMonId = 0; EWRAM_DATA s16 gPokeblockGain = 0; -EWRAM_DATA void *gUnknown_0203BCA0 = NULL; -EWRAM_DATA void *gUnknown_0203BCA4 = NULL; -EWRAM_DATA void *gUnknown_0203BCA8 = NULL; +EWRAM_DATA u8 *gUnknown_0203BCA0 = NULL; +EWRAM_DATA u8 *gUnknown_0203BCA4 = NULL; +EWRAM_DATA u8 *gUnknown_0203BCA8 = NULL; EWRAM_DATA struct UsePokeblockStruct *gUnknown_0203BCAC = NULL; // const rom data @@ -349,8 +350,9 @@ void sub_8166564(void) } void sub_8166634(void) -{ +{ u8 var; + switch (gUnknown_0203BC90->field_50) { case 0: @@ -384,9 +386,9 @@ void sub_8166634(void) break; case 1: var = gUnknown_0203BCAC->info.unk74(); - if(!var) + if (!var) gUnknown_0203BC90->field_50 = var; - break; + break; case 2: break; case 3: @@ -406,7 +408,7 @@ void sub_8166634(void) gUnknown_0203BC90->field_50 = 0; break; case 0: - if (sub_8167268()) + if (IsSheenMaxed()) { sub_8166F50(); gUnknown_0203BC90->field_50 = 7; @@ -443,14 +445,10 @@ void sub_816681C(void) if (!gPaletteFade.active) { SetVBlankCallback(NULL); - Free(gUnknown_0203BCA0); - gUnknown_0203BCA0 = NULL; - Free(gUnknown_0203BCA4); - gUnknown_0203BCA4 = NULL; - Free(gUnknown_0203BCA8); - gUnknown_0203BCA8 = NULL; - Free(gUnknown_0203BCAC); - gUnknown_0203BCAC = NULL; + FREE_AND_SET_NULL(gUnknown_0203BCA0); + FREE_AND_SET_NULL(gUnknown_0203BCA4); + FREE_AND_SET_NULL(gUnknown_0203BCA8); + FREE_AND_SET_NULL(gUnknown_0203BCAC); FreeAllWindowBuffers(); gMain.savedCallback = CB2_ReturnAndChooseMonToGivePokeblock; CB2_PreparePokeblockFeedScene(); @@ -462,6 +460,7 @@ void sub_816681C(void) void sub_81668F8(void) { u16 var; + switch (gUnknown_0203BC90->field_50) { case 0: @@ -511,65 +510,65 @@ void sub_81668F8(void) void sub_8166A34(void) { + u8 var; + switch (gUnknown_0203BC90->field_50) { - u8 var; - case 0: - gUnknown_0203BC90->pokemon = gPlayerParty; - gUnknown_0203BC90->pokemon += gUnknown_0203BCAC->field_7FB8[gUnknown_0203BCAC->info.field_71].unk1; - sub_81D3520(gUnknown_0203BCAC->field_7B1C); + case 0: + gUnknown_0203BC90->mon = gPlayerParty; + gUnknown_0203BC90->mon += gUnknown_0203BCAC->field_7FB8[gUnknown_0203BCAC->info.field_71].unk1; + sub_81D3520(gUnknown_0203BCAC->field_7B1C); + gUnknown_0203BC90->field_50++; + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) gUnknown_0203BC90->field_50++; - break; - case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) - gUnknown_0203BC90->field_50++; - break; - case 2: - sub_8167104(); - sub_81D2754(gUnknown_0203BC90->field_5c, gUnknown_0203BCAC->field_7C58.unk14[3]); - sub_81D1F84(&gUnknown_0203BCAC->field_7C58, gUnknown_0203BCAC->field_7C58.unk14[gUnknown_0203BCAC->field_7FB3], gUnknown_0203BCAC->field_7C58.unk14[3]); - sub_8167338(); - gUnknown_0203BC90->field_50++; - break; - case 3: - var = sub_81D2074(&gUnknown_0203BCAC->field_7C58); - if(var) - return; - + break; + case 2: + sub_8167104(); + sub_81D2754(gUnknown_0203BC90->field_5c, gUnknown_0203BCAC->field_7C58.unk14[3]); + sub_81D1F84(&gUnknown_0203BCAC->field_7C58, gUnknown_0203BCAC->field_7C58.unk14[gUnknown_0203BCAC->field_7FB3], gUnknown_0203BCAC->field_7C58.unk14[3]); + sub_8167338(); + gUnknown_0203BC90->field_50++; + break; + case 3: + var = sub_81D2074(&gUnknown_0203BCAC->field_7C58); + if (!var) + { sub_81681F4(sub_81672A4(gUnknown_0203BCAC->info.field_71)); - if (gUnknown_0203BCAC->info.field_71 != gUnknown_0203BCAC->info.field_70 - 1) { u8 var0 = gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->field_7FB3]; sub_81D3480(gUnknown_0203BCAC->field_7B1C, gUnknown_0203BCAC->field_7B10, var0); } - + gUnknown_0203BC90->field_52 = 0; - gUnknown_0203BC90->field_50++; - break; - case 4: - if ((++gUnknown_0203BC90->field_52) > 16) - { - sub_8166E24(); - gUnknown_0203BC90->field_50++; - } - break; - case 5: - if (gMain.newKeys & (A_BUTTON | B_BUTTON) && !sub_8166EDC()) - { - TryClearPokeblock((u8)gSpecialVar_ItemId); - sub_816636C(sub_8166BEC); - } - break; + gUnknown_0203BC90->field_50++; + } + break; + case 4: + if (++gUnknown_0203BC90->field_52 > 16) + { + sub_8166E24(); + gUnknown_0203BC90->field_50++; + } + break; + case 5: + if (gMain.newKeys & (A_BUTTON | B_BUTTON) && !sub_8166EDC()) + { + TryClearPokeblock((u8)gSpecialVar_ItemId); + sub_816636C(sub_8166BEC); + } + break; } } void sub_8166BEC(void) { - u8 i; - u8 var; + u8 i, var; + switch (gUnknown_0203BC90->field_50) - { + { case 0: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gUnknown_0203BC90->field_50++; @@ -588,18 +587,18 @@ void sub_8166BEC(void) sub_81D354C(gUnknown_0203BCAC->field_7B1C); for (i = 0; i < 7; i++) DestroySprite(&gSprites[gUnknown_0203BCAC->field_7B06[i]]); - + FreeSpriteTilesByTag(0); FreeSpriteTilesByTag(1); FreeSpritePaletteByTag(0); FreeSpritePaletteByTag(1); - + for (i = 0; i < 2; i++) DestroySprite(gUnknown_0203BCAC->field_7B44[i]); - + if (gUnknown_0203BCAC->field_7B10 != 0xFF) DestroySprite(&gSprites[gUnknown_0203BCAC->field_7B10]); - + SetVBlankCallback(NULL); FREE_AND_SET_NULL(gUnknown_0203BCA0); FREE_AND_SET_NULL(gUnknown_0203BCA4); @@ -613,6 +612,7 @@ void sub_8166BEC(void) void sub_8166D44(void) { u8 stringBuffer[0x40]; + GetMonData(&gPlayerParty[sub_81672A4(gUnknown_0203BCAC->info.field_71)], MON_DATA_NICKNAME, stringBuffer); StringGetEnd10(stringBuffer); StringAppend(stringBuffer, gText_GetsAPokeBlockQuestion); @@ -627,19 +627,21 @@ void sub_8166D44(void) s8 sub_8166DE4(void) { - s8 retval = Menu_ProcessInputNoWrapClearOnChoose(); - switch(retval) + s8 menuItem = Menu_ProcessInputNoWrapClearOnChoose(); + + switch (menuItem) { case 0: break; - case -1: + case MENU_B_PRESSED: case 1: PlaySE(SE_SELECT); rbox_fill_rectangle(2); ClearWindowTilemap(2); break; } - return retval; + + return menuItem; } void sub_8166E24(void) @@ -647,13 +649,17 @@ void sub_8166E24(void) sub_8098858(2, 151, 14); FillWindowPixelBuffer(2, 17); - for (gUnknown_0203BC90->field_53 = 0; gUnknown_0203BC90->field_53 < 5 && gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53] == 0; gUnknown_0203BC90->field_53++); - + for (gUnknown_0203BC90->field_53 = 0; gUnknown_0203BC90->field_53 < 5; gUnknown_0203BC90->field_53++) + { + if (gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53] != 0) + break; + } + if (gUnknown_0203BC90->field_53 < 5) Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53]); else Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, 0); - + Pokeblock_MenuWindowTextPrint(gStringVar4); PutWindowTilemap(2); CopyWindowToVram(2, 3); @@ -662,7 +668,7 @@ void sub_8166E24(void) bool8 sub_8166EDC(void) { FillWindowPixelBuffer(2, 17); - + while (1) { gUnknown_0203BC90->field_53++; @@ -677,11 +683,11 @@ bool8 sub_8166EDC(void) return FALSE; } } - + Pokeblock_BufferEnhancedStatText(gStringVar4, gUnknown_0203BC90->field_53, gUnknown_0203BC90->field_61[gUnknown_0203BC90->field_53]); Pokeblock_MenuWindowTextPrint(gStringVar4); CopyWindowToVram(2, 2); - + return TRUE; } @@ -765,70 +771,67 @@ _08167018:\n\ } #endif -void Pokeblock_GetMonContestStats(struct Pokemon *pokemon, u8 *data) +void Pokeblock_GetMonContestStats(struct Pokemon *mon, u8 *data) { u16 i; for (i = 0; i < 5; i++) - data[i] = GetMonData(pokemon, gUnknown_085DFCB0[i]); + data[i] = GetMonData(mon, gUnknown_085DFCB0[i]); } -void sub_8167054(struct Pokeblock *pokeblock, struct Pokemon *pokemon) +void sub_8167054(struct Pokeblock *pokeblock, struct Pokemon *mon) { u16 i; s16 cstat; u8 data; - if (GetMonData(pokemon, MON_DATA_SHEEN) != 255) + + if (GetMonData(mon, MON_DATA_SHEEN) != 255) { - sub_8167184(pokeblock, pokemon); + sub_8167184(pokeblock, mon); for (i = 0; i < 5; i++) { - data = GetMonData(pokemon, gUnknown_085DFCB0[i]); + data = GetMonData(mon, gUnknown_085DFCB0[i]); cstat = data + gUnknown_0203BC90->field_66[i]; if (cstat < 0) cstat = 0; if (cstat > 255) cstat = 255; data = cstat; - SetMonData(pokemon, gUnknown_085DFCB0[i], &data); + SetMonData(mon, gUnknown_085DFCB0[i], &data); } - cstat = (u8)GetMonData(pokemon, MON_DATA_SHEEN); - cstat = cstat + pokeblock->feel; + cstat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel; if (cstat > 255) cstat = 255; data = cstat; - SetMonData(pokemon, MON_DATA_SHEEN, &data); + SetMonData(mon, MON_DATA_SHEEN, &data); } } void sub_8167104(void) { u16 i; - struct Pokemon *pokemon = gPlayerParty; - pokemon += gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->info.field_71 * 4 + 9]; - Pokeblock_GetMonContestStats(pokemon, gUnknown_0203BC90->field_57); - sub_8167054(gUnknown_0203BC90->pokeblock, pokemon); - Pokeblock_GetMonContestStats(pokemon, gUnknown_0203BC90->field_5c); - for (i=0; i<5; i++) - { + struct Pokemon *mon = gPlayerParty; + mon += gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->info.field_71 * 4 + 9]; + + Pokeblock_GetMonContestStats(mon, gUnknown_0203BC90->field_57); + sub_8167054(gUnknown_0203BC90->pokeblock, mon); + Pokeblock_GetMonContestStats(mon, gUnknown_0203BC90->field_5c); + for (i = 0; i < 5; i++) gUnknown_0203BC90->field_61[i] = gUnknown_0203BC90->field_5c[i] - gUnknown_0203BC90->field_57[i]; - } } -void sub_8167184(struct Pokeblock *pokeblock, struct Pokemon *pokemon) +void sub_8167184(struct Pokeblock *pokeblock, struct Pokemon *mon) { - s8 direction; - s8 i; - s16 amount; - s8 boost; - s8 taste; + s8 i, direction, taste; + gUnknown_0203BC90->field_66[0] = pokeblock->spicy; gUnknown_0203BC90->field_66[1] = pokeblock->sour; gUnknown_0203BC90->field_66[2] = pokeblock->bitter; gUnknown_0203BC90->field_66[3] = pokeblock->sweet; gUnknown_0203BC90->field_66[4] = pokeblock->dry; + if (gPokeblockGain > 0) direction = 1; else if (gPokeblockGain < 0) @@ -838,39 +841,43 @@ void sub_8167184(struct Pokeblock *pokeblock, struct Pokemon *pokemon) for (i = 0; i < 5; i++) { - amount = gUnknown_0203BC90->field_66[i]; - boost = amount / 10; + s16 amount = gUnknown_0203BC90->field_66[i]; + s8 boost = amount / 10; + if (amount % 10 >= 5) // round to the nearest boost++; - taste = GetMonFlavorRelation(pokemon, gUnknown_085DFCC4[i]); + taste = GetMonFlavorRelation(mon, gUnknown_085DFCC4[i]); if (taste == direction) gUnknown_0203BC90->field_66[i] += boost * taste; } } -bool8 sub_8167268(void) +bool8 IsSheenMaxed(void) { - u8 *mon; - mon = (u8 *) &gUnknown_0203BCAC->field_0[gUnknown_0203BCAC->info.field_71 * 4]; - if (sub_81D2C68(*(mon + 864 + 0x7C58), *(mon + 865 + 0x7C58), MON_DATA_SHEEN, 0) == 255) + if (GetBoxOrPartyMonData(gUnknown_0203BCAC->field_7FB8[gUnknown_0203BCAC->info.field_71].unk0, + gUnknown_0203BCAC->field_7FB8[gUnknown_0203BCAC->info.field_71].unk1, + MON_DATA_SHEEN, + NULL) == 255) return TRUE; - return FALSE; + else + return FALSE; } u8 sub_81672A4(u8 a0) { u8 i; + for (i = 0; i < PARTY_SIZE; i++) { if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) { if (a0 == 0) return i; - a0--; } } + return 0; } @@ -894,20 +901,21 @@ u8 sub_8167324(u8 a0) void sub_8167338(void) { - u16 flavor; - u8 spriteidx; + u16 i, spriteId; + LoadSpriteSheet(&gSpriteSheet_ConditionUpDown); LoadSpritePalette(&gSpritePalette_ConditionUpDown); gUnknown_0203BC90->field_54 = 0; - for (flavor = 0; flavor < 5; flavor++) + + for (i = 0; i < 5; i++) { - if (gUnknown_0203BC90->field_61[flavor] != 0) + if (gUnknown_0203BC90->field_61[i] != 0) { - spriteidx = CreateSprite(&gSpriteTemplate_085DFD5C, gUnknown_085DFD28[flavor][0], gUnknown_085DFD28[flavor][1], 0); - if (spriteidx != MAX_SPRITES) + spriteId = CreateSprite(&gSpriteTemplate_085DFD5C, gUnknown_085DFD28[i][0], gUnknown_085DFD28[i][1], 0); + if (spriteId != MAX_SPRITES) { - if (gUnknown_0203BC90->field_61[flavor] != 0) - gSprites[spriteidx].callback = sub_81673DC; + if (gUnknown_0203BC90->field_61[i] != 0) + gSprites[spriteId].callback = sub_81673DC; gUnknown_0203BC90->field_54++; } @@ -933,8 +941,8 @@ void sub_8167420(void) { u16 i; u16 numMons; - - for (i = 0, numMons = 0; i < CalculatePlayerPartyCount(); i++) + + for (i = 0, numMons = 0; i < CalculatePlayerPartyCount(); i++) { if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) { @@ -952,21 +960,21 @@ void sub_8167420(void) void sub_81674BC(void) { - s16 var; - s16 var2; - + s16 var, var2; + sub_816753C(gUnknown_0203BCAC->info.field_71, 0); gUnknown_0203BCAC->field_7FB3 = 0; gUnknown_0203BCAC->field_7FB4 = 1; gUnknown_0203BCAC->field_7FB5 = 2; + var = gUnknown_0203BCAC->info.field_71 + 1; if (var >= gUnknown_0203BCAC->info.field_70) var = 0; - + var2 = gUnknown_0203BCAC->info.field_71 - 1; if (var2 < 0) var2 = gUnknown_0203BCAC->info.field_70 - 1; - + sub_816753C(var, 1); sub_816753C(var2, 2); } @@ -977,11 +985,11 @@ void sub_816753C(s16 a1, u8 a2) u8 *v3; int v5; int v6; - + v3 = &gUnknown_0203BCAC->field_0[a1 << 16 >> 14]; v5 = *(0x7FB8 + v3); v6 = *(0x7FB9 + v3); - + sub_81D2ED4(gUnknown_0203BCAC->field_0[0x7B4D + 24 * a2], gUnknown_0203BCAC->field_0[0x7B95 + 64 * a2], v5, v6, a1, gUnknown_0203BCAC->info.field_70, 0); sub_81D2F78(gUnknown_0203BCAC->field_7C58[0], gUnknown_0203BCAC->field_0[0x7FB0], v5, v6, a1, a2, gUnknown_0203BCAC->info.field_70, 0); sub_81D3094(gUnknown_0203BCAC->field_0[(a2 << 13) + 0x304], gUnknown_0203BCAC->field_0[(a2 << 7) + 4], v5, v6, a1, gUnknown_0203BCAC->info.field_70, 0); @@ -1082,547 +1090,173 @@ void sub_816753C(s16 a1, u8 a2) } #endif -#ifdef NONMATCHING void sub_8167608(u8 arg0) { - u8 v4; - u8 *v5; - u8 *v6; - u32 v7; - struct SpritePalette array[5]; - if(gUnknown_0203BCAC->field_0[0x7B10] == 255) + u8 spriteId; + struct SpriteTemplate spriteTemplate; + struct SpriteSheet spriteSheet; + struct SpritePalette spritePal; + + if (gUnknown_0203BCAC->field_7B10 == 0xFF) { - sub_81D31D0(&array[3], &array[0], &array[4]); - array[1] = (struct SpritePallete *) ((u32) gUnknown_0203BCAC->field_0[(arg0 << 13) + 772]); - array[2] = (struct SpritePallete *) ((u32) gUnknown_0203BCAC->field_0[(arg0 << 7) + 4]); - gUnknown_0203BCAC->field_0[0x7B12] = LoadSpritePalette(&array[3]); - gUnknown_0203BCAC->field_0[0x7B14] = LoadSpritePalette(&array[4]); - v4 = CreateSprite(array[0], 38, 104, 0); - gUnknown_0203BCAC->field_0[0x7B10] = v4; - if(v4 == 64) + sub_81D31D0(&spriteSheet, &spriteTemplate, &spritePal); + spriteSheet.data = gUnknown_0203BCAC->field_304[arg0]; + spritePal.data = gUnknown_0203BCAC->field_4[arg0]; + gUnknown_0203BCAC->field_7B12 = LoadSpritePalette(&spritePal); + gUnknown_0203BCAC->field_7B14 = LoadSpriteSheet(&spriteSheet); + spriteId = CreateSprite(&spriteTemplate, 38, 104, 0); + gUnknown_0203BCAC->field_7B10 = spriteId; + if (spriteId == MAX_SPRITES) { FreeSpriteTilesByTag(100); FreeSpritePaletteByTag(100); - gUnknown_0203BCAC->field_0[0x7B10] = 255; + gUnknown_0203BCAC->field_7B10 = 0xFF; } else { - gUnknown_0203BCAC->field_0[0x7B10] = v4; - v5 = &gUnknown_0203BCAC->field_0[0]; - v6 = &gUnknown_0203BCAC->field_0[0x7B10]; - gSprites[v6].callback = sub_8168168; - gSprites[v6].pos2.y -= 32; - *(v5+0x7B18) = 32 * *(v5+0x7B14) + 0x06010000; - *(v5+0x7B12) = 16 * *(v5+0x7B12) + 0x100; + gUnknown_0203BCAC->field_7B10 = spriteId; + gSprites[gUnknown_0203BCAC->field_7B10].callback = sub_8168168; + gSprites[gUnknown_0203BCAC->field_7B10].pos2.y -= 34; + gUnknown_0203BCAC->field_7B18 = (void*)(OBJ_VRAM0 + (gUnknown_0203BCAC->field_7B14 * 32)); + gUnknown_0203BCAC->field_7B12 = (gUnknown_0203BCAC->field_7B12 * 16) + 0x100; } } else { - v7 = gUnknown_0203BCAC->field_0[0x7B18]; - REG_ADDR_DMA3SAD = gUnknown_0203BCAC->field_0[(arg0 << 13) + 772]; - REG_ADDR_DMA3DAD = v7; - REG_ADDR_DMA3CNT = 0x80000400; - LoadPalette(gUnknown_0203BCAC->field_0[arg0 << 7) + 4), gUnknown_0203BCAC->field_0[0x7B12], 32); + do {} while(0); // Surprised to see something like this? It's a very neat trick for generating the same assembly. It has no practical purpose, feel free to remove it. + DmaCopy16Defvars(3, gUnknown_0203BCAC->field_304[arg0], gUnknown_0203BCAC->field_7B18, 0x800); + LoadPalette(gUnknown_0203BCAC->field_4[arg0], gUnknown_0203BCAC->field_7B12, 32); } } -#else -NAKED -void sub_8167608(u8 arg0) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - sub sp, 0x28\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - ldr r1, =gUnknown_0203BCAC\n\ - ldr r3, [r1]\n\ - ldr r0, =0x00007b10\n\ - mov r8, r0\n\ - adds r0, r3, r0\n\ - ldrb r0, [r0]\n\ - adds r7, r1, 0\n\ - cmp r0, 0xFF\n\ - bne _08167714\n\ - add r5, sp, 0x18\n\ - add r4, sp, 0x20\n\ - adds r0, r5, 0\n\ - mov r1, sp\n\ - adds r2, r4, 0\n\ - bl sub_81D31D0\n\ - lsls r0, r6, 13\n\ - movs r1, 0xC1\n\ - lsls r1, 2\n\ - adds r0, r1\n\ - ldr r1, [r7]\n\ - adds r0, r1, r0\n\ - str r0, [sp, 0x18]\n\ - lsls r0, r6, 7\n\ - adds r0, 0x4\n\ - adds r1, r0\n\ - str r1, [sp, 0x20]\n\ - adds r0, r4, 0\n\ - bl LoadSpritePalette\n\ - ldr r1, [r7]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - ldr r2, =0x00007b12\n\ - adds r1, r2\n\ - strh r0, [r1]\n\ - adds r0, r5, 0\n\ - bl LoadSpriteSheet\n\ - ldr r1, [r7]\n\ - ldr r3, =0x00007b14\n\ - adds r1, r3\n\ - strh r0, [r1]\n\ - mov r0, sp\n\ - movs r1, 0x26\n\ - movs r2, 0x68\n\ - movs r3, 0\n\ - bl CreateSprite\n\ - lsls r0, 24\n\ - lsrs r1, r0, 24\n\ - ldr r0, [r7]\n\ - ldr r2, =0x00007b10\n\ - adds r0, r2\n\ - strb r1, [r0]\n\ - cmp r1, 0x40\n\ - bne _081676AC\n\ - movs r0, 0x64\n\ - bl FreeSpriteTilesByTag\n\ - movs r0, 0x64\n\ - bl FreeSpritePaletteByTag\n\ - ldr r0, [r7]\n\ - add r0, r8\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ - b _08167742\n\ - .pool\n\ -_081676AC:\n\ - ldr r0, [r7]\n\ - add r0, r8\n\ - strb r1, [r0]\n\ - ldr r4, =gSprites\n\ - ldr r2, [r7]\n\ - mov r0, r8\n\ - adds r3, r2, r0\n\ - ldrb r1, [r3]\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r1, r4, 0\n\ - adds r1, 0x1C\n\ - adds r0, r1\n\ - ldr r1, =sub_8168168\n\ - str r1, [r0]\n\ - ldrb r1, [r3]\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - adds r0, r4\n\ - ldrh r1, [r0, 0x26]\n\ - subs r1, 0x22\n\ - strh r1, [r0, 0x26]\n\ - ldr r3, =0x00007b18\n\ - adds r1, r2, r3\n\ - subs r3, 0x4\n\ - adds r0, r2, r3\n\ - ldrh r0, [r0]\n\ - lsls r0, 5\n\ - ldr r3, =0x06010000\n\ - adds r0, r3\n\ - str r0, [r1]\n\ - ldr r0, =0x00007b12\n\ - adds r2, r0\n\ - ldrh r0, [r2]\n\ - lsls r0, 4\n\ - movs r1, 0x80\n\ - lsls r1, 1\n\ - adds r0, r1\n\ - strh r0, [r2]\n\ - b _08167742\n\ - .pool\n\ -_08167714:\n\ - lsls r1, r6, 13\n\ - movs r0, 0xC1\n\ - lsls r0, 2\n\ - adds r1, r0\n\ - adds r1, r3, r1\n\ - ldr r2, =0x00007b18\n\ - adds r0, r3, r2\n\ - ldr r2, [r0]\n\ - ldr r0, =0x040000d4\n\ - str r1, [r0]\n\ - str r2, [r0, 0x4]\n\ - ldr r1, =0x80000400\n\ - str r1, [r0, 0x8]\n\ - ldr r0, [r0, 0x8]\n\ - lsls r0, r6, 7\n\ - adds r0, 0x4\n\ - adds r0, r3, r0\n\ - ldr r2, =0x00007b12\n\ - adds r1, r3, r2\n\ - ldrh r1, [r1]\n\ - movs r2, 0x20\n\ - bl LoadPalette\n\ -_08167742:\n\ - add sp, 0x28\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif -#ifdef NONMATCHING void sub_8167760(void) { - s32 i; - u8 v1; - u8 v2; - u8 v3; - u32 v4; - struct SpriteSheet *v6; - struct SpriteTemplate *v7; - void (*funcCB) (void); - struct SpritePalette *v9; - struct SpriteSheet *v10; - struct SpritePalette *v11; - - sub_81D321C(v6, v7, v9); - LoadSpriteSheets(v6); - LoadSpritePalettes(v9); - for(i = 0; i < gUnknown_0203BCAC->info.field_70 - 1; i++) + u16 i, spriteId; + struct SpriteSheet spriteSheets[4]; + struct SpriteTemplate spriteTemplate; + struct SpritePalette spritePals[3]; + struct SpriteSheet spriteSheet2; + struct SpritePalette spritePal2; + + sub_81D321C(spriteSheets, &spriteTemplate, spritePals); + LoadSpriteSheets(spriteSheets); + LoadSpritePalettes(spritePals); + + for (i = 0; i < gUnknown_0203BCAC->info.field_70 - 1; i++) { - v1 = CreateSprite(v7, 226, (0x140000 * i + 0x80000) >> 16, 0); - if(v1 == 64) + spriteId = CreateSprite(&spriteTemplate, 226, (i * 20) + 8, 0); + if (spriteId != MAX_SPRITES) { - gUnknown_0203BCAC->field_0[0x7B06 + i] = -1; + gUnknown_0203BCAC->field_7B06[i] = spriteId; + gSprites[spriteId].data[0] = i; + gSprites[spriteId].callback = sub_8168180; } else { - gUnknown_0203BCAC->field_0[0x7B06 + i] = v1; - gSprites[v1].data[0] = i; - gSprites[v1].callback = (SpriteCallback) sub_8168180; + gUnknown_0203BCAC->field_7B06[i] = -1; } } - for(v7->tileTag = 103; i <= 5; i++) + + spriteTemplate.tileTag = 103; + for (; i < 6; i++) { - v2 = CreateSprite(v7, 230, (0x140000 * i + 0x80000) >> 16, 0); - if(v2 == 64 ) + spriteId = CreateSprite(&spriteTemplate, 230, (i * 20) + 8, 0); + if (spriteId != MAX_SPRITES) { - gUnknown_0203BCAC->field_0[0x7B06 + i] = -1; + gUnknown_0203BCAC->field_7B06[i] = spriteId; + gSprites[spriteId].oam.size = 0; } else { - gUnknown_0203BCAC->field_0[0x7B06 + i] = v2; - gSprites[v2].oam.tileNum &= 0x3F; + gUnknown_0203BCAC->field_7B06[i] = -1; } } - v7->tileTag = 102; - funcCB = sub_81681B4; - v3 = CreateSprite(v7, 222, (0x140000 * i + 0x80000) >> 16, 0); - if(v3 == 64) + + spriteTemplate.tileTag = 102; + spriteTemplate.callback = sub_81681B4; + spriteId = CreateSprite(&spriteTemplate, 222, (i * 20) + 8, 0); + if (spriteId != MAX_SPRITES) { - gUnknown_0203BCAC->field_0[0x7B06 + i] = -1; - } - else - { - gUnknown_0203BCAC->field_0[0x7B06 + i] = v3; - v4 = 68 * v3 + 0x2020630; - (v4 + 1) = gSprites[v2].oam.affineMode & (0x3F | 0x40); - (v4 + 3) = (v4 + 3) & (0x3F | 0x80); + gUnknown_0203BCAC->field_7B06[i] = spriteId; + gSprites[spriteId].oam.shape = 1; + gSprites[spriteId].oam.size = 2; } - sub_81D32B0(v10, v11); - LoadSpriteSheet(v10); - LoadSpritePalette(v11); + else + { + gUnknown_0203BCAC->field_7B06[i] = -1; + } + + sub_81D32B0(&spriteSheet2, &spritePal2); + LoadSpriteSheet(&spriteSheet2); + LoadSpritePalette(&spritePal2); } -#else -NAKED -void sub_8167760(void) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x60\n\ - add r5, sp, 0x20\n\ - add r4, sp, 0x38\n\ - mov r0, sp\n\ - adds r1, r5, 0\n\ - adds r2, r4, 0\n\ - bl sub_81D321C\n\ - mov r0, sp\n\ - bl LoadSpriteSheets\n\ - adds r0, r4, 0\n\ - bl LoadSpritePalettes\n\ - movs r4, 0\n\ - ldr r1, =gUnknown_0203BCAC\n\ - ldr r0, [r1]\n\ - ldr r2, =0x00008040\n\ - adds r0, r2\n\ - ldrb r0, [r0]\n\ - subs r0, 0x1\n\ - adds r6, r5, 0\n\ - add r2, sp, 0x50\n\ - mov r9, r2\n\ - add r2, sp, 0x58\n\ - mov r10, r2\n\ - cmp r4, r0\n\ - bge _0816781C\n\ - adds r5, r1, 0\n\ - ldr r7, =gSprites\n\ - movs r0, 0x1C\n\ - adds r0, r7\n\ - mov r8, r0\n\ -_081677AC:\n\ - lsls r2, r4, 2\n\ - adds r2, r4\n\ - lsls r2, 18\n\ - movs r1, 0x80\n\ - lsls r1, 12\n\ - adds r2, r1\n\ - asrs r2, 16\n\ - adds r0, r6, 0\n\ - movs r1, 0xE2\n\ - movs r3, 0\n\ - bl CreateSprite\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - cmp r3, 0x40\n\ - beq _081677FC\n\ - ldr r0, [r5]\n\ - ldr r2, =0x00007b06\n\ - adds r0, r2\n\ - adds r0, r4\n\ - strb r3, [r0]\n\ - lsls r0, r3, 4\n\ - adds r0, r3\n\ - lsls r0, 2\n\ - adds r1, r0, r7\n\ - strh r4, [r1, 0x2E]\n\ - add r0, r8\n\ - ldr r1, =sub_8168180\n\ - str r1, [r0]\n\ - b _08167808\n\ - .pool\n\ -_081677FC:\n\ - ldr r0, [r5]\n\ - ldr r1, =0x00007b06\n\ - adds r0, r1\n\ - adds r0, r4\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ -_08167808:\n\ - adds r0, r4, 0x1\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - ldr r0, [r5]\n\ - ldr r2, =0x00008040\n\ - adds r0, r2\n\ - ldrb r0, [r0]\n\ - subs r0, 0x1\n\ - cmp r4, r0\n\ - blt _081677AC\n\ -_0816781C:\n\ - movs r0, 0x67\n\ - strh r0, [r6]\n\ - cmp r4, 0x5\n\ - bhi _0816788A\n\ - ldr r5, =gUnknown_0203BCAC\n\ - ldr r7, =gSprites\n\ -_08167828:\n\ - lsls r2, r4, 2\n\ - adds r2, r4\n\ - lsls r2, 18\n\ - movs r0, 0x80\n\ - lsls r0, 12\n\ - adds r2, r0\n\ - asrs r2, 16\n\ - adds r0, r6, 0\n\ - movs r1, 0xE6\n\ - movs r3, 0\n\ - bl CreateSprite\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - cmp r3, 0x40\n\ - beq _08167874\n\ - ldr r0, [r5]\n\ - ldr r1, =0x00007b06\n\ - adds r0, r1\n\ - adds r0, r4\n\ - strb r3, [r0]\n\ - lsls r1, r3, 4\n\ - adds r1, r3\n\ - lsls r1, 2\n\ - adds r1, r7\n\ - ldrb r2, [r1, 0x3]\n\ - movs r0, 0x3F\n\ - ands r0, r2\n\ - strb r0, [r1, 0x3]\n\ - b _08167880\n\ - .pool\n\ -_08167874:\n\ - ldr r0, [r5]\n\ - ldr r2, =0x00007b06\n\ - adds r0, r2\n\ - adds r0, r4\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ -_08167880:\n\ - adds r0, r4, 0x1\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - cmp r4, 0x5\n\ - bls _08167828\n\ -_0816788A:\n\ - movs r0, 0x66\n\ - strh r0, [r6]\n\ - ldr r0, =sub_81681B4\n\ - str r0, [r6, 0x14]\n\ - lsls r2, r4, 2\n\ - adds r2, r4\n\ - lsls r2, 18\n\ - movs r0, 0x80\n\ - lsls r0, 12\n\ - adds r2, r0\n\ - asrs r2, 16\n\ - adds r0, r6, 0\n\ - movs r1, 0xDE\n\ - movs r3, 0\n\ - bl CreateSprite\n\ - lsls r0, 24\n\ - lsrs r3, r0, 24\n\ - cmp r3, 0x40\n\ - beq _081678F4\n\ - ldr r0, =gUnknown_0203BCAC\n\ - ldr r0, [r0]\n\ - ldr r1, =0x00007b06\n\ - adds r0, r1\n\ - adds r0, r4\n\ - strb r3, [r0]\n\ - ldr r0, =gSprites\n\ - lsls r2, r3, 4\n\ - adds r2, r3\n\ - lsls r2, 2\n\ - adds r2, r0\n\ - ldrb r3, [r2, 0x1]\n\ - movs r1, 0x3F\n\ - adds r0, r1, 0\n\ - ands r0, r3\n\ - movs r3, 0x40\n\ - orrs r0, r3\n\ - strb r0, [r2, 0x1]\n\ - ldrb r0, [r2, 0x3]\n\ - ands r1, r0\n\ - movs r0, 0x80\n\ - orrs r1, r0\n\ - strb r1, [r2, 0x3]\n\ - b _08167902\n\ - .pool\n\ -_081678F4:\n\ - ldr r0, =gUnknown_0203BCAC\n\ - ldr r0, [r0]\n\ - ldr r2, =0x00007b06\n\ - adds r0, r2\n\ - adds r0, r4\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ -_08167902:\n\ - mov r0, r9\n\ - mov r1, r10\n\ - bl sub_81D32B0\n\ - mov r0, r9\n\ - bl LoadSpriteSheet\n\ - mov r0, r10\n\ - bl LoadSpritePalette\n\ - add sp, 0x60\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif bool8 sub_8167930(void) { - bool8 retvalue; - switch(gUnknown_0203BCAC->info.unk78) - { - case 0: - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 136 << 6, 0); - SetGpuReg(REG_OFFSET_DISPCNT, 28736); - SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2|BLDCNT_EFFECT_BLEND|BLDCNT_TGT2_BG1); - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); - break; - case 1: - (u32 *) gUnknown_0203BCA4 = Alloc(6656); - (u32 *) gUnknown_0203BCA0 = Alloc(1280); - (u32 *) gUnknown_0203BCA8 = Alloc(1280); - break; - case 2: - LZ77UnCompVram(gUnknown_085DFB60, gUnknown_0203BCA8); - break; - case 3: - LoadBgTiles(3, gUnknown_085DFA80, 224, 0); - break; - case 4: - LoadBgTilemap(3, gUnknown_0203BCA8, 1280, 0); - break; - case 5: - LoadPalette(gUnknown_085DFA60, 208, 32); - gUnknown_0203BCAC->field_7B0E = 0xFFB0; - break; - case 6: - LZ77UnCompVram(gUsePokeblockGraph_Gfx, gUnknown_0203BCA4); - break; - case 7: - LZ77UnCompVram(gUsePokeblockGraph_Tilemap, gUnknown_0203BCA0); - LoadPalette(gUsePokeblockGraph_Pal, 32, 32); - break; - case 8: - LoadBgTiles(1, gUnknown_0203BCA4, 6656, 160 << 2); - break; - case 9: - SetBgTilemapBuffer(1, gUnknown_0203BCA0); - CopyToBgTilemapBufferRect(1, gUsePokeblockNatureWin_Pal, 0, 13, 12, 4); - CopyBgTilemapBufferToVram(1); - break; - case 10: - LZ77UnCompVram(gUnknown_085DFC0C, &gUnknown_0203BCAC->field_0[0x7304]); - break; - case 11: - LoadBgTilemap(2, &gUnknown_0203BCAC->field_0[0x7304], 1280, 0); - LoadPalette(gUnknown_086231E8, 48, 32); - LoadPalette(gUnknown_08623208, 240, 32); - sub_81D21DC(2); - break; - default: - gUnknown_0203BCAC->info.unk78 = 0; - retvalue = 0; - return retvalue; - } - gUnknown_0203BCAC->info.unk78++; - retvalue = 1; - return retvalue; + switch (gUnknown_0203BCAC->info.unk78) + { + case 0: + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 136 << 6, 0); + SetGpuReg(REG_OFFSET_DISPCNT, 28736); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2|BLDCNT_EFFECT_BLEND|BLDCNT_TGT2_BG1); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); + break; + case 1: + gUnknown_0203BCA4 = Alloc(6656); + gUnknown_0203BCA0 = Alloc(1280); + gUnknown_0203BCA8 = Alloc(1280); + break; + case 2: + LZ77UnCompVram(gUnknown_085DFB60, gUnknown_0203BCA8); + break; + case 3: + LoadBgTiles(3, gUnknown_085DFA80, 224, 0); + break; + case 4: + LoadBgTilemap(3, gUnknown_0203BCA8, 1280, 0); + break; + case 5: + LoadPalette(gUnknown_085DFA60, 208, 32); + gUnknown_0203BCAC->field_7B0E = 0xFFB0; + break; + case 6: + LZ77UnCompVram(gUsePokeblockGraph_Gfx, gUnknown_0203BCA4); + break; + case 7: + LZ77UnCompVram(gUsePokeblockGraph_Tilemap, gUnknown_0203BCA0); + LoadPalette(gUsePokeblockGraph_Pal, 32, 32); + break; + case 8: + LoadBgTiles(1, gUnknown_0203BCA4, 6656, 160 << 2); + break; + case 9: + SetBgTilemapBuffer(1, gUnknown_0203BCA0); + CopyToBgTilemapBufferRect(1, gUsePokeblockNatureWin_Pal, 0, 13, 12, 4); + CopyBgTilemapBufferToVram(1); + break; + case 10: + LZ77UnCompVram(gUnknown_085DFC0C, &gUnknown_0203BCAC->field_0[0x7304]); + break; + case 11: + LoadBgTilemap(2, &gUnknown_0203BCAC->field_0[0x7304], 1280, 0); + LoadPalette(gUnknown_086231E8, 48, 32); + LoadPalette(gUnknown_08623208, 240, 32); + sub_81D21DC(2); + break; + default: + gUnknown_0203BCAC->info.unk78 = 0; + return FALSE; + } + + gUnknown_0203BCAC->info.unk78++; + return TRUE; } void sub_8167BA0(u16 arg0, u8 copyToVramMode) @@ -1658,9 +1292,7 @@ void sub_8167BA0(u16 arg0, u8 copyToVramMode) static void sub_8167CA0(bool8 arg0) { u16 var0; - int var1; - int r8; - int r4; + bool32 r8, r4; if (arg0) var0 = gUnknown_0203BCAC->field_7FB5; @@ -1680,11 +1312,11 @@ static void sub_8167CA0(bool8 arg0) gUnknown_0203BCAC->field_7FB3 = var0; gUnknown_0203BCAC->field_7FB6 = gUnknown_0203BCAC->field_7FB5; - gUnknown_0203BCAC->info.field_71 = gUnknown_0203BCAC->info.field_71 == 0 + gUnknown_0203BCAC->info.field_71 = (gUnknown_0203BCAC->info.field_71 == 0) ? gUnknown_0203BCAC->info.field_70 - 1 : gUnknown_0203BCAC->info.field_71 - 1; - gUnknown_0203BCAC->field_7B4C = gUnknown_0203BCAC->info.field_71 == 0 + gUnknown_0203BCAC->field_7B4C = (gUnknown_0203BCAC->info.field_71 == 0) ? gUnknown_0203BCAC->info.field_70 - 1 : gUnknown_0203BCAC->info.field_71 - 1; } @@ -1695,11 +1327,11 @@ static void sub_8167CA0(bool8 arg0) gUnknown_0203BCAC->field_7FB3 = var0; gUnknown_0203BCAC->field_7FB6 = gUnknown_0203BCAC->field_7FB4; - gUnknown_0203BCAC->info.field_71 = gUnknown_0203BCAC->info.field_71 < gUnknown_0203BCAC->info.field_70 - 1 + gUnknown_0203BCAC->info.field_71 = (gUnknown_0203BCAC->info.field_71 < gUnknown_0203BCAC->info.field_70 - 1) ? gUnknown_0203BCAC->info.field_71 + 1 : 0; - gUnknown_0203BCAC->field_7B4C = gUnknown_0203BCAC->info.field_71 < gUnknown_0203BCAC->info.field_70 - 1 + gUnknown_0203BCAC->field_7B4C = (gUnknown_0203BCAC->info.field_71 < gUnknown_0203BCAC->info.field_70 - 1) ? gUnknown_0203BCAC->info.field_71 + 1 : 0; } @@ -1835,7 +1467,8 @@ void sub_81681B4(struct Sprite *sprite) void sub_81681F4(u8 monIndex) { u8 sheen = GetMonData(&gPlayerParty[monIndex], MON_DATA_SHEEN); - gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->field_7FB3] = sheen != 255 + + gUnknown_0203BCAC->unk7FB0[gUnknown_0203BCAC->field_7FB3] = (sheen != 255) ? sheen / 29 : 9; } @@ -1868,7 +1501,7 @@ static void sub_8168294(void) if (spriteId != MAX_SPRITES) { gSprites[spriteId].data[0] = var; - gSprites[spriteId].data[1] = (i * xDiff) | 32; + gSprites[spriteId].data[1] = (i * xDiff) | 0x20; gSprites[spriteId].data[2] = i; StartSpriteAnim(&gSprites[spriteId], i); sprites[i] = &gSprites[spriteId]; @@ -1896,6 +1529,7 @@ static bool8 sub_8168328(void) void sub_8168374(struct Sprite *sprite) { s16 prevX = sprite->pos1.x; + sprite->pos1.x += sprite->data[0]; if ((prevX <= sprite->data[1] && sprite->pos1.x >= sprite->data[1]) || (prevX >= sprite->data[1] && sprite->pos1.x <= sprite->data[1])) From e3c07c83f2bb8ce91d96f4bb39110fae18eccdc1 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 31 Mar 2019 14:32:26 +0200 Subject: [PATCH 2/2] More work on use pokeblock --- asm/menu_specialized.s | 472 ------------------------------------- include/menu_specialized.h | 18 +- src/menu_specialized.c | 222 +++++++++++++++-- src/use_pokeblock.c | 142 ++--------- 4 files changed, 231 insertions(+), 623 deletions(-) diff --git a/asm/menu_specialized.s b/asm/menu_specialized.s index b09ab4c44..36db0f865 100644 --- a/asm/menu_specialized.s +++ b/asm/menu_specialized.s @@ -9,478 +9,6 @@ - - - - thumb_func_start sub_81D32D4 -sub_81D32D4: @ 81D32D4 - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0x30] - adds r0, 0x1 - strh r0, [r1, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3C - ble _081D32F0 - movs r0, 0 - strh r0, [r1, 0x30] - adds r0, r1, 0 - bl sub_81D3408 -_081D32F0: - pop {r0} - bx r0 - thumb_func_end sub_81D32D4 - - thumb_func_start sub_81D32F4 -sub_81D32F4: @ 81D32F4 - push {lr} - adds r2, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081D330C - movs r0, 0 - strh r0, [r2, 0x30] - ldr r0, =sub_81D32D4 - str r0, [r2, 0x1C] -_081D330C: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D32F4 - - thumb_func_start sub_81D3314 -sub_81D3314: @ 81D3314 - push {r4,r5,lr} - adds r4, r0, 0 - movs r1, 0x36 - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r3, r1, r0 - cmp r3, 0 - beq _081D3360 - ldrh r1, [r3, 0x24] - ldrh r2, [r3, 0x20] - adds r1, r2 - ldr r2, =gUnknown_08625B2C - movs r5, 0x2E - ldrsh r0, [r4, r5] - lsls r0, 2 - adds r0, r2 - ldrh r0, [r0] - adds r0, r1 - strh r0, [r4, 0x20] - ldrh r1, [r3, 0x26] - ldrh r3, [r3, 0x22] - adds r1, r3 - movs r3, 0x2E - ldrsh r0, [r4, r3] - lsls r0, 2 - adds r2, 0x2 - adds r0, r2 - ldrh r0, [r0] - adds r0, r1 - b _081D337E - .pool -_081D3360: - ldr r1, =gUnknown_08625B2C - movs r5, 0x2E - ldrsh r0, [r4, r5] - lsls r0, 2 - adds r0, r1 - ldrh r0, [r0] - adds r0, 0x28 - strh r0, [r4, 0x20] - movs r2, 0x2E - ldrsh r0, [r4, r2] - lsls r0, 2 - adds r1, 0x2 - adds r0, r1 - ldrh r0, [r0] - adds r0, 0x68 -_081D337E: - strh r0, [r4, 0x22] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D3314 - - thumb_func_start sub_81D338C -sub_81D338C: @ 81D338C - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r8, r2 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r7, r1, 24 - movs r5, 0 -_081D339E: - lsls r0, r5, 2 - mov r1, r8 - adds r4, r0, r1 - ldr r0, [r4] - cmp r0, 0 - beq _081D33F0 - strh r5, [r0, 0x2E] - ldr r1, [r4] - lsls r0, r5, 4 - adds r0, 0x1 - strh r0, [r1, 0x30] - ldr r0, [r4] - strh r6, [r0, 0x32] - ldr r0, [r4] - strh r5, [r0, 0x34] - cmp r7, 0 - beq _081D33C4 - cmp r6, 0x9 - beq _081D33D0 -_081D33C4: - ldr r1, [r4] - ldr r0, =sub_81D3564 - str r0, [r1, 0x1C] - b _081D33F0 - .pool -_081D33D0: - ldr r0, [r4] - bl sub_81D3314 - ldr r0, [r4] - bl sub_81D35E8 - ldr r2, [r4] - ldr r0, =sub_81D32F4 - str r0, [r2, 0x1C] - adds r2, 0x3E - ldrb r0, [r2] - movs r3, 0x5 - negs r3, r3 - adds r1, r3, 0 - ands r0, r1 - strb r0, [r2] -_081D33F0: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x9 - bls _081D339E - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D338C - - thumb_func_start sub_81D3408 -sub_81D3408: @ 81D3408 - push {r4-r7,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x38] - lsls r0, 24 - lsrs r2, r0, 24 - movs r3, 0 - movs r1, 0x32 - ldrsh r0, [r4, r1] - adds r0, 0x1 - cmp r3, r0 - bge _081D3454 - ldr r5, =gSprites - movs r7, 0x1C - adds r7, r5 - mov r12, r7 - ldr r6, =sub_81D3564 -_081D3428: - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r2, r1, r5 - movs r7, 0x2E - ldrsh r0, [r2, r7] - lsls r0, 4 - adds r0, 0x1 - strh r0, [r2, 0x30] - add r1, r12 - str r6, [r1] - ldrh r0, [r2, 0x38] - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - movs r1, 0x32 - ldrsh r0, [r4, r1] - adds r0, 0x1 - cmp r3, r0 - blt _081D3428 -_081D3454: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D3408 - - thumb_func_start sub_81D3464 -sub_81D3464: @ 81D3464 - push {lr} - adds r2, r0, 0 - movs r1, 0 - movs r3, 0 -_081D346C: - lsls r0, r1, 2 - adds r0, r2 - str r3, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - bls _081D346C - pop {r0} - bx r0 - thumb_func_end sub_81D3464 - - thumb_func_start sub_81D3480 -sub_81D3480: @ 81D3480 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r8, r0 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - lsls r2, 24 - movs r0, 0 - mov r9, r0 - lsrs r7, r2, 24 - movs r5, 0 - adds r0, r7, 0x1 - cmp r9, r0 - bge _081D34FE -_081D34A2: - ldr r0, =gUnknown_08625B14 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r3, r0, 24 - adds r6, r3, 0 - cmp r3, 0x40 - beq _081D34FE - lsls r0, r5, 2 - mov r1, r8 - adds r4, r0, r1 - lsls r0, r3, 4 - adds r0, r3 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - str r0, [r4] - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - ldr r0, [r4] - mov r1, r10 - strh r1, [r0, 0x36] - cmp r5, 0 - beq _081D34F0 - subs r0, r4, 0x4 - ldr r0, [r0] - strh r3, [r0, 0x38] - b _081D34F2 - .pool -_081D34F0: - mov r9, r6 -_081D34F2: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r7, 0x1 - cmp r5, r0 - blt _081D34A2 -_081D34FE: - lsls r0, r7, 2 - add r0, r8 - ldr r0, [r0] - mov r1, r9 - strh r1, [r0, 0x38] - adds r0, r7, 0 - movs r1, 0x1 - mov r2, r8 - bl sub_81D338C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81D3480 - - thumb_func_start sub_81D3520 -sub_81D3520: @ 81D3520 - push {r4-r6,lr} - adds r6, r0, 0 - movs r5, 0 -_081D3526: - cmp r5, 0x9 - bhi _081D3544 - lsls r0, r5, 2 - adds r4, r0, r6 - ldr r0, [r4] - cmp r0, 0 - beq _081D3544 - bl DestroySprite - movs r0, 0 - str r0, [r4] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - b _081D3526 -_081D3544: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81D3520 - - thumb_func_start sub_81D354C -sub_81D354C: @ 81D354C - push {lr} - bl sub_81D3520 - movs r0, 0x68 - bl FreeSpriteTilesByTag - movs r0, 0x68 - bl FreeSpritePaletteByTag - pop {r0} - bx r0 - thumb_func_end sub_81D354C - - thumb_func_start sub_81D3564 -sub_81D3564: @ 81D3564 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x30] - movs r2, 0x30 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _081D3592 - subs r0, r1, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - cmp r0, 0 - bne _081D35DC - adds r0, r4, 0 - movs r1, 0 - bl SeekSpriteAnim - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_081D3592: - adds r0, r4, 0 - bl sub_81D3314 - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081D35DC - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x34 - ldrsh r1, [r4, r0] - movs r2, 0x32 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _081D35D8 - cmp r1, 0x9 - bne _081D35D0 - adds r0, r4, 0 - bl sub_81D35E8 - ldr r0, =sub_81D32F4 - b _081D35DA - .pool -_081D35D0: - ldr r0, =sub_81D32D4 - b _081D35DA - .pool -_081D35D8: - ldr r0, =SpriteCallbackDummy -_081D35DA: - str r0, [r4, 0x1C] -_081D35DC: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D3564 - - thumb_func_start sub_81D35E8 -sub_81D35E8: @ 81D35E8 - push {r4-r7,lr} - adds r6, r0, 0 - ldrh r0, [r6, 0x38] - lsls r0, 24 - lsrs r1, r0, 24 - movs r5, 0 - movs r2, 0x32 - ldrsh r0, [r6, r2] - adds r0, 0x1 - cmp r5, r0 - bge _081D3636 - movs r0, 0x5 - negs r0, r0 - adds r7, r0, 0 -_081D3604: - lsls r4, r1, 4 - adds r4, r1 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - adds r0, r4, 0 - movs r1, 0 - bl SeekSpriteAnim - adds r1, r4, 0 - adds r1, 0x3E - ldrb r0, [r1] - ands r0, r7 - strb r0, [r1] - ldrh r0, [r4, 0x38] - lsls r0, 24 - lsrs r1, r0, 24 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - movs r2, 0x32 - ldrsh r0, [r6, r2] - adds r0, 0x1 - cmp r5, r0 - blt _081D3604 -_081D3636: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D35E8 - thumb_func_start DrawLevelUpWindowPg1 DrawLevelUpWindowPg1: @ 81D3640 push {r4-r7,lr} diff --git a/include/menu_specialized.h b/include/menu_specialized.h index 90623a888..d29ac5751 100644 --- a/include/menu_specialized.h +++ b/include/menu_specialized.h @@ -26,12 +26,6 @@ struct UnknownStruct_81D1ED4 /*0x355*/ u8 unk355; }; -struct Unk81D2F78_Struct -{ - u8 contestStats[4][5]; - struct UnknownSubStruct_81D1ED4 field_20[4][5]; -}; - bool8 sub_81D1C44(u8 count); u8 sub_81D1C84(u8 a0); u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page); @@ -44,11 +38,7 @@ void sub_81D1ED4(struct UnknownStruct_81D1ED4 *a0); void sub_81D2108(struct UnknownStruct_81D1ED4 *arg0); void sub_81D20AC(struct UnknownStruct_81D1ED4 *arg0); void sub_81D2230(struct UnknownStruct_81D1ED4 *arg0); -void sub_81D3520(struct Sprite **); bool8 sub_81D20BC(struct UnknownStruct_81D1ED4 *arg0); -void sub_81D354C(struct Sprite **); -void sub_81D3464(struct Sprite **arg0); -void sub_81D3480(struct Sprite **arg0, u8 arg1, u8 arg2); bool32 sub_81D2074(struct UnknownStruct_81D1ED4 *a0); void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1); void sub_81D1F84(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2); @@ -60,8 +50,8 @@ void InitMoveRelearnerWindows(bool8 useContextWindow); void GetMonLevelUpWindowStats(struct Pokemon* mon, void* statStoreLocation); s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst); void sub_81D2ED4(u8 *dst, u8 *nameDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); -void sub_81D2F78(struct Unk81D2F78_Struct *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8); -void sub_81D3094(u8 *tilesDst, u8 *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); +void sub_81D2F78(struct UnknownStruct_81D1ED4 *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8); +void sub_81D3094(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7); bool8 sub_81D312C(s16 *var); bool8 sub_81D3150(s16 *var); bool8 sub_81D3178(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1); @@ -69,5 +59,9 @@ bool8 sub_81D31A4(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1); void sub_81D31D0(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal); void sub_81D321C(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals); void sub_81D32B0(struct SpriteSheet *sheet, struct SpritePalette *pal); +void sub_81D3464(struct Sprite **sprites); +void sub_81D3480(struct Sprite **sprites, u8 arg1, u8 arg2); +void sub_81D3520(struct Sprite **sprites); +void sub_81D354C(struct Sprite **sprites); #endif // GUARD_MENU_SPECIALIZED_H diff --git a/src/menu_specialized.c b/src/menu_specialized.c index ae150dcb4..f21f4e51a 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -37,6 +37,9 @@ static void sub_81D24A4(struct UnknownStruct_81D1ED4 *a0); static void sub_81D2634(struct UnknownStruct_81D1ED4 *a0); static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list); static void nullsub_79(void); +static void sub_81D3408(struct Sprite *sprite); +/*static*/ void sub_81D3564(struct Sprite *sprite); +static void sub_81D35E8(struct Sprite *sprite); static const struct WindowTemplate sUnknown_086253E8[] = { @@ -1243,7 +1246,7 @@ void sub_81D2ED4(u8 *dst, u8 *nameDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, } } -void sub_81D2F78(struct Unk81D2F78_Struct *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8) +void sub_81D2F78(struct UnknownStruct_81D1ED4 *arg0, u8 *sheen, u16 boxId, u16 monId, u16 arg5, u16 id, u16 arg7, bool8 arg8) { u16 i; @@ -1252,30 +1255,30 @@ void sub_81D2F78(struct Unk81D2F78_Struct *arg0, u8 *sheen, u16 boxId, u16 monId if (arg5 != arg7) { - arg0->contestStats[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); - arg0->contestStats[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); - arg0->contestStats[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); - arg0->contestStats[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); - arg0->contestStats[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); + arg0->unk0[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); + arg0->unk0[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); + arg0->unk0[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); + arg0->unk0[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); + arg0->unk0[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF) ? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u : 9; - sub_81D2754(arg0->contestStats[id], arg0->field_20[id]); + sub_81D2754(arg0->unk0[id], arg0->unk14[id]); } else { for (i = 0; i < 5; i++) { - arg0->contestStats[id][i] = 0; - arg0->field_20[id][i].unk0 = 155; - arg0->field_20[id][i].unk2 = 91; + arg0->unk0[id][i] = 0; + arg0->unk14[id][i].unk0 = 155; + arg0->unk14[id][i].unk2 = 91; } } } -void sub_81D3094(u8 *tilesDst, u8 *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7) +void sub_81D3094(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 arg5, u16 arg6, bool8 arg7) { if (!arg7) arg6--; @@ -1325,10 +1328,10 @@ bool8 sub_81D31A4(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1) return ((var1 != 0) || (var2 != 0)); } -const u32 gUnknown_08625560[] = INCBIN_U32("graphics/pokenav/pokeball.4bpp"); -const u32 gUnknown_08625660[] = INCBIN_U32("graphics/pokenav/pokeball_placeholder.4bpp"); -const u16 gUnknown_08625680[] = INCBIN_U16("graphics/pokenav/sparkle.gbapal"); -const u32 gUnknown_086256A0[] = INCBIN_U32("graphics/pokenav/sparkle.4bpp"); +static const u32 gUnknown_08625560[] = INCBIN_U32("graphics/pokenav/pokeball.4bpp"); +static const u32 gUnknown_08625660[] = INCBIN_U32("graphics/pokenav/pokeball_placeholder.4bpp"); +static const u16 gUnknown_08625680[] = INCBIN_U16("graphics/pokenav/sparkle.gbapal"); +static const u32 gUnknown_086256A0[] = INCBIN_U32("graphics/pokenav/sparkle.4bpp"); static const struct OamData sOamData_8625A20 = { @@ -1347,7 +1350,7 @@ static const struct OamData sOamData_8625A20 = .affineParam = 0 }; -const struct OamData sOamData_8625A28 = +static const struct OamData sOamData_8625A28 = { .y = 0, .affineMode = 0, @@ -1376,7 +1379,7 @@ static const union AnimCmd sSpriteAnim_8625A38[] = ANIMCMD_END }; -const union AnimCmd *const sSpriteAnimTable_8625A40[] = +static const union AnimCmd *const sSpriteAnimTable_8625A40[] = { sSpriteAnim_8625A30, sSpriteAnim_8625A38 @@ -1451,3 +1454,188 @@ void sub_81D32B0(struct SpriteSheet *sheet, struct SpritePalette *pal) *sheet = dataSheet; *pal = dataPal; } + +static void sub_81D32D4(struct Sprite *sprite) +{ + if (++sprite->data[1] > 60) + { + sprite->data[1] = 0; + sub_81D3408(sprite); + } +} + +static void sub_81D32F4(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + sprite->data[1] = 0; + sprite->callback = sub_81D32D4; + } +} + +// Todo: Move these variables to C. +extern const s16 gUnknown_08625B2C[][2]; +extern const struct SpriteTemplate gUnknown_08625B14; + +void sub_81D3314(struct Sprite *sprite) +{ + struct Sprite *sprite2 = &gSprites[sprite->data[4]]; + + if (sprite2 != NULL) + { + sprite->pos1.x = sprite2->pos1.x + sprite2->pos2.x + gUnknown_08625B2C[sprite->data[0]][0]; + sprite->pos1.y = sprite2->pos1.y + sprite2->pos2.y + gUnknown_08625B2C[sprite->data[0]][1]; + } + else + { + sprite->pos1.x = gUnknown_08625B2C[sprite->data[0]][0] + 40; + sprite->pos1.y = gUnknown_08625B2C[sprite->data[0]][1] + 104; + } +} + +void sub_81D338C(u8 arg0, u8 arg1, struct Sprite **sprites) +{ + u16 i; + + for (i = 0; i < 10; i++) + { + if (sprites[i] != NULL) + { + sprites[i]->data[0] = i; + sprites[i]->data[1] = (i * 16) + 1; + sprites[i]->data[2] = arg0; + sprites[i]->data[3] = i; + if (arg1 == 0 || arg0 != 9) + { + sprites[i]->callback = sub_81D3564; + } + else + { + sub_81D3314(sprites[i]); + sub_81D35E8(sprites[i]); + sprites[i]->callback = sub_81D32F4; + sprites[i]->invisible = FALSE; + } + } + } +} + +static void sub_81D3408(struct Sprite *sprite) +{ + u16 i; + u8 id = sprite->data[5]; + + for (i = 0; i < sprite->data[2] + 1; i++) + { + gSprites[id].data[1] = (gSprites[id].data[0] * 16) + 1; + gSprites[id].callback = sub_81D3564; + id = gSprites[id].data[5]; + } +} + +void sub_81D3464(struct Sprite **sprites) +{ + u8 i; + + for (i = 0; i < 10; i++) + sprites[i] = NULL; +} + +void sub_81D3480(struct Sprite **sprites, u8 arg1, u8 arg2) +{ + u16 i, spriteId, firstSpriteId = 0; + u8 count = arg2; + + for (i = 0; i < count + 1; i++) + { + spriteId = CreateSprite(&gUnknown_08625B14, 0, 0, 0); + if (spriteId != MAX_SPRITES) + { + sprites[i] = &gSprites[spriteId]; + sprites[i]->invisible = TRUE; + sprites[i]->data[4] = arg1; + if (i != 0) + sprites[i - 1]->data[5] = spriteId; + else + firstSpriteId = spriteId; + } + else + { + break; + } + } + + sprites[count]->data[5] = firstSpriteId; + sub_81D338C(count, 1, sprites); +} + +void sub_81D3520(struct Sprite **sprites) +{ + u16 i; + + for (i = 0; i < 10; i++) + { + if (sprites[i] != NULL) + { + DestroySprite(sprites[i]); + sprites[i] = NULL; + } + else + { + break; + } + } +} + +void sub_81D354C(struct Sprite **sprites) +{ + sub_81D3520(sprites); + FreeSpriteTilesByTag(104); + FreeSpritePaletteByTag(104); +} + +/*static*/ void sub_81D3564(struct Sprite *sprite) +{ + if (sprite->data[1] != 0) + { + if (--sprite->data[1] != 0) + return; + + SeekSpriteAnim(sprite, 0); + sprite->invisible = FALSE; + } + + sub_81D3314(sprite); + if (sprite->animEnded) + { + sprite->invisible = TRUE; + if (sprite->data[3] == sprite->data[2]) + { + if (sprite->data[3] == 9) + { + sub_81D35E8(sprite); + sprite->callback = sub_81D32F4; + } + else + { + sprite->callback = sub_81D32D4; + } + } + else + { + sprite->callback = SpriteCallbackDummy; + } + } +} + +static void sub_81D35E8(struct Sprite *sprite) +{ + u8 i, id = sprite->data[5]; + + for (i = 0; i < sprite->data[2] + 1; i++) + { + SeekSpriteAnim(&gSprites[id], 0); + gSprites[id].invisible = FALSE; + id = gSprites[id].data[5]; + } +} diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index d78132585..6df826214 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -57,11 +57,11 @@ struct Unk7FB8 struct UsePokeblockStruct { - /*0x0000*/ u8 field_0[4]; - /*0x0000*/ u16 field_4[3][0x40]; - /*0x0184*/ u8 field_184[0x304 - 0x184]; + /*0x0000*/ u8 filler0[4]; + /*0x0000*/ u16 field_4[6][0x40]; /*0x0304*/ u8 field_304[3][0x2000]; - /*0x6304*/ u8 field_6304[0x7b06 - 0x6304]; + /*0x6304*/ u8 filler_6304[0x1000]; + /*0x7304*/ u8 tilemapBuffer[BG_SCREEN_SIZE + 2]; /*0x7B06*/ u8 field_7B06[7]; /*0x7B0E*/ s16 field_7B0E; /*0x7B10*/ u8 field_7B10; @@ -71,8 +71,7 @@ struct UsePokeblockStruct /*0x7B1C*/ struct Sprite *field_7B1C[10]; /*0x7B44*/ struct Sprite *field_7B44[2]; /*0x7B4C*/ u8 field_7B4C; - /*0x7B4D*/ u8 filler7B4D[0x47]; - /*0x7B94*/ u8 filler7B94; + /*0x7B4D*/ u8 field_7B4D[3][24]; /*0x7B95*/ u8 field_7B95[3][64]; /*0x7C58*/ struct UnknownStruct_81D1ED4 field_7C58; /*0x7FB0*/ u8 unk7FB0[3]; @@ -119,7 +118,7 @@ void sub_8167338(void); void sub_81681F4(u8); void sub_8166E24(void); bool8 sub_8166EDC(void); -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2); +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2); void Pokeblock_MenuWindowTextPrint(const u8 *message); void sub_8167184(struct Pokeblock *, struct Pokemon *); void sub_81673DC(struct Sprite *sprite); @@ -712,15 +711,13 @@ void Pokeblock_MenuWindowTextPrint(const u8 *message) AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL); } +// This function is a joke. #ifdef NONMATCHING -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) { if (a2 != 0) { - if (a2 > 0) - a2 = 0; - - StringCopy(dest, sContestStatNames[statID]); + StringCopy(dest, sContestStatNames[statId]); StringAppend(dest, gText_WasEnhanced); } else @@ -730,7 +727,7 @@ void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) } #else NAKED -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) { asm(".syntax unified\n\ push {r4,lr}\n\ @@ -979,116 +976,17 @@ void sub_81674BC(void) sub_816753C(var2, 2); } -#ifdef NONMATCHING -void sub_816753C(s16 a1, u8 a2) +void sub_816753C(s16 id1, u8 id2) { - u8 *v3; - int v5; - int v6; + u8 boxId = gUnknown_0203BCAC->field_7FB8[id1].unk0; + u8 monId = gUnknown_0203BCAC->field_7FB8[id1].unk1; + u8 r6 = gUnknown_0203BCAC->info.field_70; + bool8 r8 = FALSE; - v3 = &gUnknown_0203BCAC->field_0[a1 << 16 >> 14]; - v5 = *(0x7FB8 + v3); - v6 = *(0x7FB9 + v3); - - sub_81D2ED4(gUnknown_0203BCAC->field_0[0x7B4D + 24 * a2], gUnknown_0203BCAC->field_0[0x7B95 + 64 * a2], v5, v6, a1, gUnknown_0203BCAC->info.field_70, 0); - sub_81D2F78(gUnknown_0203BCAC->field_7C58[0], gUnknown_0203BCAC->field_0[0x7FB0], v5, v6, a1, a2, gUnknown_0203BCAC->info.field_70, 0); - sub_81D3094(gUnknown_0203BCAC->field_0[(a2 << 13) + 0x304], gUnknown_0203BCAC->field_0[(a2 << 7) + 4], v5, v6, a1, gUnknown_0203BCAC->info.field_70, 0); - //gUnknown_0203BCAC->field_0[0x7B4D + a1 * 40], gUnknown_0203BCAC->field_7FB8, gUnknown_0203BCAC->field_7FB9, gUnknown_203BCAC->field_0[0], gUnknown_203BCAC->info.field_70, 0) + sub_81D2ED4(gUnknown_0203BCAC->field_7B4D[id2], gUnknown_0203BCAC->field_7B95[id2], boxId, monId, id1, r6, r8); + sub_81D2F78(&gUnknown_0203BCAC->field_7C58, gUnknown_0203BCAC->unk7FB0, boxId, monId, id1, id2, r6, r8); + sub_81D3094(gUnknown_0203BCAC->field_304[id2], gUnknown_0203BCAC->field_4[id2], boxId, monId, id1, r6, r8); } -#else -NAKED -void sub_816753C(s16 a1, u8 a2) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x10\n\ - adds r5, r0, 0\n\ - adds r4, r1, 0\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - ldr r0, =gUnknown_0203BCAC\n\ - mov r9, r0\n\ - ldr r1, [r0]\n\ - lsls r5, 16\n\ - asrs r0, r5, 14\n\ - adds r0, r1, r0\n\ - ldr r3, =0x00007fb8\n\ - adds r2, r0, r3\n\ - ldrb r7, [r2]\n\ - ldr r2, =0x00007fb9\n\ - adds r0, r2\n\ - ldrb r0, [r0]\n\ - mov r10, r0\n\ - adds r3, 0x88\n\ - adds r0, r1, r3\n\ - ldrb r6, [r0]\n\ - movs r0, 0\n\ - mov r8, r0\n\ - lsls r0, r4, 1\n\ - adds r0, r4\n\ - lsls r0, 3\n\ - ldr r2, =0x00007b4d\n\ - adds r0, r2\n\ - adds r0, r1, r0\n\ - lsls r2, r4, 6\n\ - ldr r3, =0x00007b95\n\ - adds r2, r3\n\ - adds r1, r2\n\ - lsrs r5, 16\n\ - str r5, [sp]\n\ - str r6, [sp, 0x4]\n\ - mov r2, r8\n\ - str r2, [sp, 0x8]\n\ - adds r2, r7, 0\n\ - mov r3, r10\n\ - bl sub_81D2ED4\n\ - mov r3, r9\n\ - ldr r1, [r3]\n\ - ldr r2, =0x00007c58\n\ - adds r0, r1, r2\n\ - ldr r3, =0x00007fb0\n\ - adds r1, r3\n\ - str r5, [sp]\n\ - str r4, [sp, 0x4]\n\ - str r6, [sp, 0x8]\n\ - mov r2, r8\n\ - str r2, [sp, 0xC]\n\ - adds r2, r7, 0\n\ - mov r3, r10\n\ - bl sub_81D2F78\n\ - lsls r0, r4, 13\n\ - movs r1, 0xC1\n\ - lsls r1, 2\n\ - adds r0, r1\n\ - mov r3, r9\n\ - ldr r1, [r3]\n\ - adds r0, r1, r0\n\ - lsls r4, 7\n\ - adds r4, 0x4\n\ - adds r1, r4\n\ - str r5, [sp]\n\ - str r6, [sp, 0x4]\n\ - mov r2, r8\n\ - str r2, [sp, 0x8]\n\ - adds r2, r7, 0\n\ - mov r3, r10\n\ - bl sub_81D3094\n\ - add sp, 0x10\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void sub_8167608(u8 arg0) { @@ -1242,10 +1140,10 @@ bool8 sub_8167930(void) CopyBgTilemapBufferToVram(1); break; case 10: - LZ77UnCompVram(gUnknown_085DFC0C, &gUnknown_0203BCAC->field_0[0x7304]); + LZ77UnCompVram(gUnknown_085DFC0C, gUnknown_0203BCAC->tilemapBuffer); break; case 11: - LoadBgTilemap(2, &gUnknown_0203BCAC->field_0[0x7304], 1280, 0); + LoadBgTilemap(2, gUnknown_0203BCAC->tilemapBuffer, 1280, 0); LoadPalette(gUnknown_086231E8, 48, 32); LoadPalette(gUnknown_08623208, 240, 32); sub_81D21DC(2);