From 5243285ab2cbf895f28e9866e3f5671326422348 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 2 Nov 2017 18:19:49 +0100 Subject: [PATCH 01/18] start working on battle 7 --- asm/battle_7.s | 827 ------------------------------- include/battle.h | 6 + include/battle_script_commands.h | 2 +- include/malloc.h | 6 + ld_script.txt | 1 + src/battle_7.c | 284 +++++++++++ 6 files changed, 298 insertions(+), 828 deletions(-) create mode 100644 src/battle_7.c diff --git a/asm/battle_7.s b/asm/battle_7.s index 94cc1ba8e..8d9321af0 100644 --- a/asm/battle_7.s +++ b/asm/battle_7.s @@ -5,834 +5,7 @@ .text - thumb_func_start AllocateBattleSpritesData -AllocateBattleSpritesData: @ 805D118 - push {r4,lr} - ldr r4, =gBattleSpritesDataPtr - movs r0, 0x10 - bl AllocZeroed - str r0, [r4] - movs r0, 0x10 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1] - movs r0, 0x30 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0x4] - movs r0, 0x10 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0x8] - movs r0, 0x50 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1, 0xC] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end AllocateBattleSpritesData - thumb_func_start FreeBattleSpritesData -FreeBattleSpritesData: @ 805D158 - push {r4,r5,lr} - ldr r5, =gBattleSpritesDataPtr - ldr r0, [r5] - cmp r0, 0 - beq _0805D192 - ldr r0, [r0, 0xC] - bl Free - ldr r0, [r5] - movs r4, 0 - str r4, [r0, 0xC] - ldr r0, [r0, 0x8] - bl Free - ldr r0, [r5] - str r4, [r0, 0x8] - ldr r0, [r0, 0x4] - bl Free - ldr r0, [r5] - str r4, [r0, 0x4] - ldr r0, [r0] - bl Free - ldr r0, [r5] - str r4, [r0] - bl Free - str r4, [r5] -_0805D192: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end FreeBattleSpritesData - - thumb_func_start ChooseMoveAndTargetInBattlePalace -ChooseMoveAndTargetInBattlePalace: @ 805D19C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r0, 0x1 - negs r0, r0 - mov r9, r0 - ldr r4, =gActiveBank - ldrb r0, [r4] - lsls r2, r0, 9 - ldr r1, =gBattleBufferA + 4 - adds r2, r1 - mov r10, r2 - movs r1, 0 - movs r2, 0xFF - bl CheckMoveLimitations - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r7, r0, 16 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x92 - ldrb r1, [r0] - ldr r2, =gBitTable - ldrb r0, [r4] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - negs r0, r1 - orrs r0, r1 - asrs r4, r0, 31 - movs r0, 0x2 - ands r4, r0 - adds r6, r4, 0 - adds r5, r4, 0x2 - b _0805D20E - .pool -_0805D20C: - adds r4, 0x1 -_0805D20E: - cmp r4, r5 - bge _0805D234 - ldr r0, =gActiveBank - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - ldr r1, =gBattleMons + 0x48 - adds r0, r1 - ldr r0, [r0] - bl GetNatureFromPersonality - lsls r0, 24 - lsrs r0, 22 - adds r0, r4, r0 - ldr r2, =gUnknown_0831C494 - adds r0, r2 - ldrb r0, [r0] - cmp r0, r7 - ble _0805D20C -_0805D234: - subs r7, r4, r6 - cmp r4, r5 - bne _0805D23C - movs r7, 0x2 -_0805D23C: - movs r6, 0 - movs r4, 0 - mov r1, r10 - ldrh r0, [r1] - cmp r0, 0 - beq _0805D27C - mov r5, r10 -_0805D24A: - ldrh r0, [r5] - bl sub_805D4A8 - lsls r0, 24 - lsrs r0, 24 - cmp r7, r0 - bne _0805D26E - mov r0, r10 - adds r0, 0x8 - adds r0, r4 - ldrb r0, [r0] - cmp r0, 0 - beq _0805D26E - ldr r0, =gBitTable - lsls r1, r4, 2 - adds r1, r0 - ldr r0, [r1] - orrs r6, r0 -_0805D26E: - adds r5, 0x2 - adds r4, 0x1 - cmp r4, 0x3 - bgt _0805D27C - ldrh r0, [r5] - cmp r0, 0 - bne _0805D24A -_0805D27C: - cmp r6, 0 - beq _0805D2AC - ldr r3, =gBattleStruct - ldr r1, [r3] - adds r1, 0x92 - ldrb r2, [r1] - movs r0, 0xF - ands r0, r2 - strb r0, [r1] - ldr r1, [r3] - adds r1, 0x92 - lsls r0, r6, 4 - ldrb r2, [r1] - orrs r0, r2 - strb r0, [r1] - lsls r0, r6, 24 - lsrs r0, 24 - bl BattleAI_SetupAIData - bl BattleAI_ChooseMoveOrAction - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0805D2AC: - movs r0, 0x1 - negs r0, r0 - cmp r9, r0 - beq _0805D2B6 - b _0805D40C -_0805D2B6: - mov r2, r8 - cmp r2, 0xF - bne _0805D2BE - b _0805D3EA -_0805D2BE: - movs r5, 0 - movs r6, 0 - ldr r7, =gBitTable - mov r4, r10 -_0805D2C6: - ldrh r0, [r4] - bl sub_805D4A8 - lsls r0, 24 - cmp r0, 0 - bne _0805D2DE - ldr r0, [r7] - mov r1, r8 - ands r0, r1 - cmp r0, 0 - bne _0805D2DE - adds r5, 0x1 -_0805D2DE: - ldrh r0, [r4] - bl sub_805D4A8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0805D2F8 - ldr r0, [r7] - mov r2, r8 - ands r0, r2 - cmp r0, 0 - bne _0805D2F8 - adds r5, 0x10 -_0805D2F8: - ldrh r0, [r4] - bl sub_805D4A8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0805D316 - ldr r0, [r7] - mov r1, r8 - ands r0, r1 - cmp r0, 0 - bne _0805D316 - movs r2, 0x80 - lsls r2, 1 - adds r5, r2 -_0805D316: - adds r7, 0x4 - adds r4, 0x2 - ldr r0, =gBitTable - adds r0, 0xC - cmp r7, r0 - ble _0805D2C6 - movs r1, 0xF - ands r1, r5 - cmp r1, 0x1 - ble _0805D32C - adds r6, 0x1 -_0805D32C: - movs r0, 0xF0 - ands r0, r5 - cmp r0, 0x1F - ble _0805D336 - adds r6, 0x1 -_0805D336: - ldr r2, =0x000001ff - cmp r0, r2 - ble _0805D33E - adds r6, 0x1 -_0805D33E: - cmp r6, 0x1 - bgt _0805D346 - cmp r6, 0 - bne _0805D388 -_0805D346: - ldr r5, =gBitTable -_0805D348: - bl Random - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - lsrs r4, r1, 16 - lsls r0, r4, 2 - adds r0, r5 - ldr r0, [r0] - mov r1, r8 - ands r0, r1 - cmp r0, 0 - bne _0805D366 - mov r9, r4 -_0805D366: - movs r0, 0x1 - negs r0, r0 - cmp r9, r0 - beq _0805D348 - b _0805D3D4 - .pool -_0805D388: - cmp r1, 0x1 - ble _0805D38E - movs r6, 0 -_0805D38E: - cmp r0, 0x1F - ble _0805D394 - movs r6, 0x1 -_0805D394: - cmp r0, r2 - ble _0805D39A - movs r6, 0x2 -_0805D39A: - bl Random - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - lsrs r4, r1, 16 - ldr r1, =gBitTable - lsls r0, r4, 2 - adds r0, r1 - ldr r0, [r0] - mov r2, r8 - ands r0, r2 - cmp r0, 0 - bne _0805D3CC - lsls r0, r4, 1 - add r0, r10 - ldrh r0, [r0] - bl sub_805D4A8 - lsls r0, 24 - lsrs r0, 24 - cmp r6, r0 - bne _0805D3CC - mov r9, r4 -_0805D3CC: - movs r0, 0x1 - negs r0, r0 - cmp r9, r0 - beq _0805D39A -_0805D3D4: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x31 - bls _0805D40C -_0805D3EA: - ldr r2, =gProtectStructs - ldr r0, =gActiveBank - ldrb r1, [r0] - lsls r1, 4 - adds r1, r2 - ldrb r0, [r1, 0x2] - movs r2, 0x10 - orrs r0, r2 - strb r0, [r1, 0x2] - movs r0, 0 - b _0805D496 - .pool -_0805D40C: - mov r1, r9 - lsls r0, r1, 1 - mov r2, r10 - adds r1, r2, r0 - ldrh r0, [r1] - cmp r0, 0xAE - bne _0805D434 - ldrb r0, [r2, 0x12] - movs r5, 0 - cmp r0, 0x7 - beq _0805D442 - ldrb r1, [r2, 0x13] - movs r0, 0x7 - eors r1, r0 - negs r0, r1 - orrs r0, r1 - asrs r5, r0, 31 - movs r0, 0x10 - ands r5, r0 - b _0805D442 -_0805D434: - ldr r2, =gBattleMoves - ldrh r1, [r1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r5, [r0, 0x6] -_0805D442: - movs r0, 0x10 - ands r0, r5 - cmp r0, 0 - beq _0805D45C - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r0, 8 - b _0805D48A - .pool -_0805D45C: - cmp r5, 0 - bne _0805D470 - bl sub_805D5F4 - lsls r0, 16 - lsrs r0, 16 - mov r2, r9 - orrs r2, r0 - mov r9, r2 - b _0805D490 -_0805D470: - ldr r0, =gActiveBank - ldrb r0, [r0] - bl GetBankIdentity - adds r1, r0, 0 - movs r2, 0x1 - movs r0, 0x1 - ands r0, r1 - eors r0, r2 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 16 -_0805D48A: - mov r1, r9 - orrs r1, r0 - mov r9, r1 -_0805D490: - mov r2, r9 - lsls r0, r2, 16 - lsrs r0, 16 -_0805D496: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end ChooseMoveAndTargetInBattlePalace - - thumb_func_start sub_805D4A8 -sub_805D4A8: @ 805D4A8 - push {lr} - lsls r0, 16 - lsrs r2, r0, 16 - ldr r1, =gBattleMoves - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0, 0x6] - adds r3, r1, 0 - cmp r0, 0x40 - bls _0805D4C2 - b _0805D5EE -_0805D4C2: - lsls r0, 2 - ldr r1, =_0805D4D4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0805D4D4: - .4byte _0805D5D8 - .4byte _0805D5E6 - .4byte _0805D5D8 - .4byte _0805D5EE - .4byte _0805D5D8 - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5D8 - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EA - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5D8 - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5EE - .4byte _0805D5E6 -_0805D5D8: - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0x1] - cmp r0, 0 - bne _0805D5EE -_0805D5E6: - movs r0, 0x2 - b _0805D5F0 -_0805D5EA: - movs r0, 0x1 - b _0805D5F0 -_0805D5EE: - movs r0, 0 -_0805D5F0: - pop {r1} - bx r1 - thumb_func_end sub_805D4A8 - - thumb_func_start sub_805D5F4 -sub_805D5F4: @ 805D5F4 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0805D6FA - ldr r0, =gActiveBank - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0805D630 - movs r0, 0x1 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r0, 0x3 - b _0805D63E - .pool -_0805D630: - movs r0, 0 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r0, 0x2 -_0805D63E: - bl GetBankByIdentity - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gBattleMons - movs r2, 0x58 - mov r0, r8 - muls r0, r2 - adds r5, r0, r1 - adds r0, r7, 0 - muls r0, r2 - adds r6, r0, r1 - ldrh r0, [r5, 0x28] - ldrh r3, [r6, 0x28] - cmp r0, r3 - bne _0805D680 - bl Random - adds r3, r0, 0 - ldr r0, =gActiveBank - ldrb r1, [r0] - movs r2, 0x1 - movs r0, 0x1 - ands r0, r1 - eors r0, r2 - movs r1, 0x2 - ands r1, r3 - adds r0, r1 - b _0805D702 - .pool -_0805D680: - ldr r4, =gUnknown_0831C604 - ldr r0, =gActiveBank - mov r9, r0 - ldrb r0, [r0] - muls r0, r2 - adds r1, 0x48 - adds r0, r1 - ldr r0, [r0] - bl GetNatureFromPersonality - lsls r0, 24 - lsrs r0, 24 - adds r0, r4 - ldrb r4, [r0] - cmp r4, 0x1 - beq _0805D6CC - cmp r4, 0x1 - bgt _0805D6B4 - cmp r4, 0 - beq _0805D6BA - b _0805D6FA - .pool -_0805D6B4: - cmp r4, 0x2 - beq _0805D6DE - b _0805D6FA -_0805D6BA: - ldrh r0, [r5, 0x28] - ldrh r6, [r6, 0x28] - cmp r0, r6 - bls _0805D6C8 - mov r1, r8 - lsls r0, r1, 8 - b _0805D704 -_0805D6C8: - lsls r0, r7, 8 - b _0805D704 -_0805D6CC: - ldrh r0, [r5, 0x28] - ldrh r6, [r6, 0x28] - cmp r0, r6 - bcs _0805D6DA - mov r3, r8 - lsls r0, r3, 8 - b _0805D704 -_0805D6DA: - lsls r0, r7, 8 - b _0805D704 -_0805D6DE: - bl Random - adds r3, r0, 0 - mov r0, r9 - ldrb r1, [r0] - movs r2, 0x1 - movs r0, 0x1 - ands r0, r1 - eors r0, r2 - ands r4, r3 - adds r0, r4 - lsls r0, 24 - lsrs r0, 16 - b _0805D704 -_0805D6FA: - ldr r0, =gActiveBank - ldrb r1, [r0] - movs r0, 0x1 - eors r0, r1 -_0805D702: - lsls r0, 8 -_0805D704: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_805D5F4 - - thumb_func_start sub_805D714 -sub_805D714: @ 805D714 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x30] - lsls r1, 24 - lsrs r1, 24 - ldr r2, =gSprites - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - adds r0, r1, 0 - adds r0, 0x3F - ldrb r3, [r0] - lsls r0, r3, 26 - cmp r0, 0 - bge _0805D766 - adds r0, r1, 0 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 29 - cmp r0, 0 - blt _0805D766 - adds r2, r1, 0 - adds r2, 0x2C - ldrb r1, [r2] - lsls r0, r1, 25 - cmp r0, 0 - bge _0805D75C - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - b _0805D766 - .pool -_0805D75C: - lsls r0, r3, 27 - cmp r0, 0 - bge _0805D766 - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_0805D766: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805D714 - - thumb_func_start sub_805D770 -sub_805D770: @ 805D770 - push {r4,lr} - adds r4, r0, 0 - lsls r1, 24 - adds r3, r4, 0 - adds r3, 0x2C - ldrb r0, [r3] - movs r2, 0x40 - orrs r0, r2 - strb r0, [r3] - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] - cmp r1, 0 - bne _0805D798 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - b _0805D7A0 - .pool -_0805D798: - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim -_0805D7A0: - adds r0, r4, 0 - bl AnimateSprite - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_805D770 - - thumb_func_start sub_805D7AC -sub_805D7AC: @ 805D7AC - push {lr} - adds r2, r0, 0 - ldr r0, =gUnknown_020243FC - ldrh r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0805D7E4 - ldrh r0, [r2, 0x2E] - ldrh r1, [r2, 0x24] - adds r0, r1 - strh r0, [r2, 0x24] - lsls r0, 16 - cmp r0, 0 - bne _0805D7E4 - movs r1, 0x26 - ldrsh r0, [r2, r1] - cmp r0, 0 - beq _0805D7E0 - ldr r0, =sub_805D7EC - b _0805D7E2 - .pool -_0805D7E0: - ldr r0, =SpriteCallbackDummy -_0805D7E2: - str r0, [r2, 0x1C] -_0805D7E4: - pop {r0} - bx r0 - .pool - thumb_func_end sub_805D7AC - - thumb_func_start sub_805D7EC -sub_805D7EC: @ 805D7EC - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0x26] - subs r0, 0x2 - strh r0, [r1, 0x26] - lsls r0, 16 - cmp r0, 0 - bne _0805D800 - ldr r0, =SpriteCallbackDummy - str r0, [r1, 0x1C] -_0805D800: - pop {r0} - bx r0 - .pool - thumb_func_end sub_805D7EC thumb_func_start DoStatusAnimation DoStatusAnimation: @ 805D808 diff --git a/include/battle.h b/include/battle.h index 1916f450a..d958294b1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -944,6 +944,12 @@ struct BattleAnimationInfo u8 field_9_x20 : 1; u8 field_9_x40 : 1; u8 field_9_x80 : 1; + u8 field_A; + u8 field_B; + u8 field_C; + u8 field_D; + u8 field_E; + u8 field_F; }; struct BattleHealthboxInfo diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index a466abc04..ebfeabccc 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -57,6 +57,6 @@ void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags); bool8 UproarWakeUpCheck(u8 bank); extern void (* const gBattleScriptingCommandsTable[])(void); -extern const u8 gUnknown_0831C494[]; +extern const u8 gUnknown_0831C494[][4]; #endif // GUARD_BATTLE_SCRIPT_COMMANDS_H diff --git a/include/malloc.h b/include/malloc.h index f3a731797..003ee1f03 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -5,6 +5,12 @@ #define calloc(ct, sz) AllocZeroed((ct) * (sz)) #define free Free +#define FREE_AND_SET_NULL(ptr) \ +{ \ + free(ptr); \ + ptr = NULL; \ +} + extern u8 gHeap[]; void *Alloc(u32 size); void *AllocZeroed(u32 size); diff --git a/ld_script.txt b/ld_script.txt index 6ea68b1c7..3cec6fd8f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -62,6 +62,7 @@ SECTIONS { src/battle_script_commands.o(.text); asm/battle_5.o(.text); src/battle_controller_player.o(.text); + src/battle_7.o(.text); asm/battle_7.o(.text); src/battle_controller_opponent.o(.text); src/battle_ai_switch_items.o(.text); diff --git a/src/battle_7.c b/src/battle_7.c new file mode 100644 index 000000000..8e21f9df5 --- /dev/null +++ b/src/battle_7.c @@ -0,0 +1,284 @@ +#include "global.h" +#include "battle.h" +#include "battle_controllers.h" +#include "battle_ai_script_commands.h" +#include "malloc.h" +#include "rng.h" +#include "util.h" +#include "pokemon.h" +#include "moves.h" + +extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; +extern u8 gActiveBank; +extern u16 gUnknown_020243FC; +extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; + +extern const struct BattleMove gBattleMoves[]; +extern const u8 gUnknown_0831C604[]; + +// this file's functions +u8 sub_805D4A8(u16 move); +u16 BattlePalaceGetTargetRetValue(void); +void sub_805D7EC(struct Sprite *sprite); + +void AllocateBattleSpritesData(void) +{ + gBattleSpritesDataPtr = AllocZeroed(sizeof(struct BattleSpriteData)); + gBattleSpritesDataPtr->bankData = AllocZeroed(sizeof(struct BattleSpriteInfo) * BATTLE_BANKS_COUNT); + gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * BATTLE_BANKS_COUNT); + gBattleSpritesDataPtr->animationData = AllocZeroed(sizeof(struct BattleAnimationInfo)); + gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * BATTLE_BANKS_COUNT); +} + +void FreeBattleSpritesData(void) +{ + if (gBattleSpritesDataPtr == NULL) + return; + + FREE_AND_SET_NULL(gBattleSpritesDataPtr->battleBars); + FREE_AND_SET_NULL(gBattleSpritesDataPtr->animationData); + FREE_AND_SET_NULL(gBattleSpritesDataPtr->healthBoxesData); + FREE_AND_SET_NULL(gBattleSpritesDataPtr->bankData); + FREE_AND_SET_NULL(gBattleSpritesDataPtr); +} + +u16 ChooseMoveAndTargetInBattlePalace(void) +{ + s32 i, var1, var2; + s32 chosenMoveId = -1; + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + u8 unusableMovesBits = CheckMoveLimitations(gActiveBank, 0, 0xFF); + s32 percent = Random() % 100; + + i = (gBattleStruct->field_92 & gBitTable[gActiveBank]) ? 2 : 0; + var2 = i; + var1 = i + 2; + + for (; i < var1; i++) + { + if (gUnknown_0831C494[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)][i] > percent) + break; + } + + percent = i - var2; + if (i == var1) + percent = 2; + + for (var2 = 0, i = 0; i < 4; i++) + { + if (moveInfo->moves[i] == MOVE_NONE) + break; + if (percent == sub_805D4A8(moveInfo->moves[i]) && moveInfo->currentPp[i] != 0) + var2 |= gBitTable[i]; + } + + if (var2 != 0) + { + gBattleStruct->field_92 &= 0xF; + gBattleStruct->field_92 |= (var2 << 4); + BattleAI_SetupAIData(var2); + chosenMoveId = BattleAI_ChooseMoveOrAction(); + } + + if (chosenMoveId == -1) + { + if (unusableMovesBits != 0xF) + { + var1 = 0, var2 = 0; + + for (i = 0; i < 4; i++) + { + if (sub_805D4A8(moveInfo->moves[i]) == 0 && !(gBitTable[i] & unusableMovesBits)) + var1 += 0x1; + if (sub_805D4A8(moveInfo->moves[i]) == 1 && !(gBitTable[i] & unusableMovesBits)) + var1 += 0x10; + if (sub_805D4A8(moveInfo->moves[i]) == 2 && !(gBitTable[i] & unusableMovesBits)) + var1 += 0x100; + } + + if ((var1 & 0xF) > 1) + var2++; + if ((var1 & 0xF0) > 0x1F) + var2++; + if ((var1 & 0xF0) > 0x1FF) + var2++; + + if (var2 > 1 || var2 == 0) + { + do + { + i = Random() % 4; + if (!(gBitTable[i] & unusableMovesBits)) + chosenMoveId = i; + } while (chosenMoveId == -1); + } + else + { + if ((var1 & 0xF) > 1) + var2 = 0; + if ((var1 & 0xF0) > 0x1F) + var2 = 1; + if ((var1 & 0xF0) > 0x1FF) + var2 = 2; + + do + { + i = Random() % 4; + if (!(gBitTable[i] & unusableMovesBits) && var2 == sub_805D4A8(moveInfo->moves[i])) + chosenMoveId = i; + } while (chosenMoveId == -1); + } + + if (Random() % 100 > 49) + { + gProtectStructs[gActiveBank].flag_x10 = 1; + return 0; + } + } + else + { + gProtectStructs[gActiveBank].flag_x10 = 1; + return 0; + } + } + + if (moveInfo->moves[chosenMoveId] == MOVE_CURSE) + { + if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST) + var1 = MOVE_TARGET_x10; + else + var1 = MOVE_TARGET_SELECTED; + } + else + { + var1 = gBattleMoves[moveInfo->moves[chosenMoveId]].target; + } + + if (var1 & MOVE_TARGET_x10) + chosenMoveId |= (gActiveBank << 8); + else if (var1 == MOVE_TARGET_SELECTED) + chosenMoveId |= (BattlePalaceGetTargetRetValue()); + else + chosenMoveId |= (GetBankByIdentity((GetBankIdentity(gActiveBank) & BIT_SIDE) ^ BIT_SIDE) << 8); + + return chosenMoveId; +} + +u8 sub_805D4A8(u16 move) +{ + switch (gBattleMoves[move].target) + { + case MOVE_TARGET_SELECTED: + case MOVE_TARGET_USER: + case MOVE_TARGET_RANDOM: + case MOVE_TARGET_BOTH: + case MOVE_TARGET_FOES_AND_ALLY: + if (gBattleMoves[move].power == 0) + return 2; + else + return 0; + break; + case MOVE_TARGET_DEPENDS: + case MOVE_TARGET_OPPONENTS_FIELD: + return 2; + case MOVE_TARGET_x10: + return 1; + default: + return 0; + } +} + +u16 BattlePalaceGetTargetRetValue(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + u8 opposing1, opposing2; + + if (GetBankSide(gActiveBank) == SIDE_PLAYER) + { + opposing1 = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + opposing2 = GetBankByIdentity(IDENTITY_OPPONENT_MON2); + } + else + { + opposing1 = GetBankByIdentity(IDENTITY_PLAYER_MON1); + opposing2 = GetBankByIdentity(IDENTITY_PLAYER_MON2); + } + + if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp) + return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; + + switch (gUnknown_0831C604[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)]) + { + case 0: + if (gBattleMons[opposing1].hp > gBattleMons[opposing2].hp) + return opposing1 << 8; + else + return opposing2 << 8; + case 1: + if (gBattleMons[opposing1].hp < gBattleMons[opposing2].hp) + return opposing1 << 8; + else + return opposing2 << 8; + case 2: + return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; + } + } + + return (gActiveBank ^ BIT_SIDE) << 8; +} + +void sub_805D714(struct Sprite *sprite) +{ + u8 spriteId = sprite->data1; + + if (!gSprites[spriteId].affineAnimEnded) + return; + if (gSprites[spriteId].invisible) + return; + + if (gSprites[spriteId].animPaused) + { + gSprites[spriteId].animPaused = 0; + } + else + { + if (gSprites[spriteId].animEnded) + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_805D770(struct Sprite *sprite, bool8 arg1) +{ + sprite->animPaused = 1; + sprite->callback = SpriteCallbackDummy; + + if (!arg1) + StartSpriteAffineAnim(sprite, 1); + else + StartSpriteAffineAnim(sprite, 1); + + AnimateSprite(sprite); +} + +void sub_805D7AC(struct Sprite *sprite) +{ + if (!(gUnknown_020243FC & 1)) + { + sprite->pos2.x += sprite->data0; + if (sprite->pos2.x == 0) + { + if (sprite->pos2.y != 0) + sprite->callback = sub_805D7EC; + else + sprite->callback = SpriteCallbackDummy; + } + } +} + +void sub_805D7EC(struct Sprite *sprite) +{ + sprite->pos2.y -= 2; + if (sprite->pos2.y == 0) + sprite->callback = SpriteCallbackDummy; +} From 6c8155074b67cce4dd5a6aa01d83bc6830b9d1c8 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 4 Nov 2017 16:11:13 +0100 Subject: [PATCH 02/18] battle 7 is decompiled --- asm/battle_7.s | 2988 --------------------- asm/battle_anim_80A5C6C.s | 16 +- asm/battle_anim_80A9C70.s | 6 +- asm/battle_anim_815A0D4.s | 6 +- asm/battle_anim_8170478.s | 4 +- asm/contest.s | 2 +- asm/contest_painting.s | 2 +- asm/link.s | 2 +- asm/pokeball.s | 6 +- asm/pokedex.s | 2 +- asm/pokemon_storage_system.s | 4 +- asm/pokemon_summary_screen.s | 2 +- asm/pokenav.s | 4 +- data/battle_7.s | 44 - data/graphics.s | 6 +- data/smokescreen.s | 6 +- include/battle.h | 65 +- include/battle_anim.h | 6 +- include/battle_gfx_sfx_util.h | 49 + include/battle_interface.h | 9 + include/contest.h | 6 + include/decompress.h | 2 + include/pokemon.h | 4 +- ld_script.txt | 5 +- src/battle_2.c | 4 +- src/battle_7.c | 284 -- src/battle_controller_link_opponent.c | 28 +- src/battle_controller_link_partner.c | 32 +- src/battle_controller_opponent.c | 28 +- src/battle_controller_player.c | 42 +- src/battle_controller_player_partner.c | 34 +- src/battle_controller_recorded_opponent.c | 28 +- src/battle_controller_recorded_player.c | 36 +- src/battle_controller_safari.c | 8 +- src/battle_controller_wally.c | 24 +- src/battle_dome_cards.c | 4 +- src/battle_gfx_sfx_util.c | 1299 +++++++++ src/battle_interface.c | 10 +- src/battle_script_commands.c | 45 +- src/pokemon_3.c | 6 +- src/reshow_battle_screen.c | 14 +- 41 files changed, 1607 insertions(+), 3565 deletions(-) delete mode 100644 asm/battle_7.s delete mode 100644 data/battle_7.s create mode 100644 include/battle_gfx_sfx_util.h delete mode 100644 src/battle_7.c create mode 100644 src/battle_gfx_sfx_util.c diff --git a/asm/battle_7.s b/asm/battle_7.s deleted file mode 100644 index 8d9321af0..000000000 --- a/asm/battle_7.s +++ /dev/null @@ -1,2988 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - thumb_func_start DoStatusAnimation -DoStatusAnimation: @ 805D808 - push {r4-r6,lr} - adds r4, r1, 0 - lsls r0, 24 - ldr r6, =gBattleSpritesDataPtr - ldr r1, [r6] - ldr r5, =gActiveBank - ldrb r2, [r5] - ldr r3, [r1, 0x4] - lsls r1, r2, 1 - adds r1, r2 - lsls r1, 2 - adds r1, r3 - ldrb r2, [r1] - movs r3, 0x10 - orrs r2, r3 - strb r2, [r1] - cmp r0, 0 - bne _0805D888 - cmp r4, 0x20 - bne _0805D844 - ldrb r0, [r5] - movs r1, 0x6 - bl move_anim_start_t2 - b _0805D902 - .pool -_0805D844: - cmp r4, 0x8 - beq _0805D850 - movs r0, 0x80 - ands r0, r4 - cmp r0, 0 - beq _0805D85A -_0805D850: - ldrb r0, [r5] - movs r1, 0 - bl move_anim_start_t2 - b _0805D902 -_0805D85A: - cmp r4, 0x10 - bne _0805D868 - ldrb r0, [r5] - movs r1, 0x2 - bl move_anim_start_t2 - b _0805D902 -_0805D868: - movs r0, 0x7 - ands r0, r4 - cmp r0, 0 - beq _0805D87A - ldrb r0, [r5] - movs r1, 0x4 - bl move_anim_start_t2 - b _0805D902 -_0805D87A: - cmp r4, 0x40 - bne _0805D8EA - ldrb r0, [r5] - movs r1, 0x5 - bl move_anim_start_t2 - b _0805D902 -_0805D888: - movs r0, 0xF0 - lsls r0, 12 - ands r0, r4 - cmp r0, 0 - beq _0805D89C - ldrb r0, [r5] - movs r1, 0x3 - bl move_anim_start_t2 - b _0805D902 -_0805D89C: - movs r0, 0x7 - ands r0, r4 - cmp r0, 0 - beq _0805D8AE - ldrb r0, [r5] - movs r1, 0x1 - bl move_anim_start_t2 - b _0805D902 -_0805D8AE: - movs r0, 0x80 - lsls r0, 21 - ands r0, r4 - cmp r0, 0 - beq _0805D8C2 - ldrb r0, [r5] - movs r1, 0x7 - bl move_anim_start_t2 - b _0805D902 -_0805D8C2: - movs r0, 0x80 - lsls r0, 20 - ands r0, r4 - cmp r0, 0 - beq _0805D8D6 - ldrb r0, [r5] - movs r1, 0x8 - bl move_anim_start_t2 - b _0805D902 -_0805D8D6: - movs r0, 0xE0 - lsls r0, 8 - ands r0, r4 - cmp r0, 0 - beq _0805D8EA - ldrb r0, [r5] - movs r1, 0x9 - bl move_anim_start_t2 - b _0805D902 -_0805D8EA: - ldr r0, [r6] - ldrb r2, [r5] - ldr r0, [r0, 0x4] - lsls r1, r2, 1 - adds r1, r2 - lsls r1, 2 - adds r1, r0 - ldrb r2, [r1] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - strb r0, [r1] -_0805D902: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end DoStatusAnimation - - thumb_func_start DoBattleAnimationFromTable -DoBattleAnimationFromTable: @ 805D908 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r4, [sp, 0x24] - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - lsls r2, 24 - lsrs r2, 24 - str r2, [sp] - lsls r3, 24 - lsrs r5, r3, 24 - lsls r4, 16 - lsrs r7, r4, 16 - cmp r5, 0 - bne _0805D950 - movs r0, 0x80 - ands r0, r7 - cmp r0, 0 - beq _0805D950 - ldr r0, =gBattleMonForms - adds r0, r6, r0 - movs r2, 0x7F - adds r1, r7, 0 - ands r1, r2 - strb r1, [r0] - movs r0, 0x1 - b _0805DA1E - .pool -_0805D950: - ldr r0, =gBattleSpritesDataPtr - mov r9, r0 - ldr r0, [r0] - ldr r0, [r0] - lsls r4, r6, 2 - adds r0, r4, r0 - ldrb r1, [r0] - movs r2, 0x4 - mov r8, r2 - mov r0, r8 - ands r0, r1 - cmp r0, 0 - beq _0805D9CC - adds r0, r5, 0 - bl sub_805DAA0 - lsls r0, 24 - cmp r0, 0 - bne _0805D980 - movs r0, 0x1 - b _0805DA1E - .pool -_0805D980: - mov r1, r9 - ldr r0, [r1] - ldr r0, [r0] - adds r0, r4, r0 - ldrb r1, [r0] - mov r0, r8 - ands r0, r1 - cmp r0, 0 - beq _0805D9CC - cmp r5, 0x2 - bne _0805D9CC - ldr r1, =gSprites - ldr r0, =gBankSpriteIds - adds r0, r6, r0 - ldrb r2, [r0] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 29 - cmp r0, 0 - bge _0805D9CC - adds r0, r6, 0 - movs r1, 0x1 - bl refresh_graphics_maybe - adds r0, r6, 0 - bl sub_805E974 - movs r0, 0x1 - b _0805DA1E - .pool -_0805D9CC: - ldr r0, =gAnimBankAttacker - mov r2, r10 - strb r2, [r0] - ldr r0, =gAnimBankTarget - mov r1, sp - ldrb r1, [r1] - strb r1, [r0] - ldr r4, =gBattleSpritesDataPtr - ldr r0, [r4] - ldr r0, [r0, 0x8] - strh r7, [r0] - ldr r0, =gUnknown_082C9320 - adds r1, r5, 0 - movs r2, 0 - bl LaunchBattleAnimation - ldr r0, =task0A_0803415C - movs r1, 0xA - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r6, [r1, 0x8] - ldr r0, [r4] - movs r2, 0x8 - ldrsh r1, [r1, r2] - ldr r2, [r0, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0] - movs r0, 0 -_0805DA1E: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end DoBattleAnimationFromTable - - thumb_func_start task0A_0803415C -task0A_0803415C: @ 805DA48 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gAnimScriptCallback - ldr r0, [r0] - bl _call_via_r0 - ldr r0, =gAnimScriptActive - ldrb r0, [r0] - cmp r0, 0 - bne _0805DA8A - ldr r0, =gBattleSpritesDataPtr - ldr r2, [r0] - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0x8 - ldrsh r0, [r0, r1] - ldr r2, [r2, 0x4] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r2, [r1] - movs r0, 0x21 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - adds r0, r4, 0 - bl DestroyTask -_0805DA8A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task0A_0803415C - - thumb_func_start sub_805DAA0 -sub_805DAA0: @ 805DAA0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xD - bgt _0805DAB4 - cmp r0, 0xA - bge _0805DAB8 - cmp r0, 0x2 - beq _0805DAB8 - b _0805DABC -_0805DAB4: - cmp r0, 0x11 - bne _0805DABC -_0805DAB8: - movs r0, 0x1 - b _0805DABE -_0805DABC: - movs r0, 0 -_0805DABE: - pop {r1} - bx r1 - thumb_func_end sub_805DAA0 - - thumb_func_start DoSpecialBattleAnimation -DoSpecialBattleAnimation: @ 805DAC4 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r3, 24 - lsrs r3, 24 - ldr r0, =gAnimBankAttacker - strb r1, [r0] - ldr r0, =gAnimBankTarget - strb r2, [r0] - ldr r0, =gUnknown_082C937C - adds r1, r3, 0 - movs r2, 0 - bl LaunchBattleAnimation - ldr r0, =task0A_08034248 - movs r1, 0xA - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r4, [r1, 0x8] - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - movs r2, 0x8 - ldrsh r1, [r1, r2] - ldr r2, [r0, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end DoSpecialBattleAnimation - - thumb_func_start task0A_08034248 -task0A_08034248: @ 805DB34 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gAnimScriptCallback - ldr r0, [r0] - bl _call_via_r0 - ldr r0, =gAnimScriptActive - ldrb r0, [r0] - cmp r0, 0 - bne _0805DB76 - ldr r0, =gBattleSpritesDataPtr - ldr r2, [r0] - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0x8 - ldrsh r0, [r0, r1] - ldr r2, [r2, 0x4] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r2, [r1] - movs r0, 0x41 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - adds r0, r4, 0 - bl DestroyTask -_0805DB76: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task0A_08034248 - - thumb_func_start IsMoveWithoutAnimation -IsMoveWithoutAnimation: @ 805DB8C - movs r0, 0 - bx lr - thumb_func_end IsMoveWithoutAnimation - - thumb_func_start mplay_80342A4 -mplay_80342A4: @ 805DB90 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - movs r5, 0 - bl IsSEPlaying - lsls r0, 24 - cmp r0, 0 - beq _0805DBD8 - ldr r2, =gBattleSpritesDataPtr - ldr r0, [r2] - ldr r1, [r0, 0x4] - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x8] - adds r1, 0x1 - strb r1, [r0, 0x8] - ldr r2, [r2] - ldr r0, =gActiveBank - ldrb r1, [r0] - ldr r2, [r2, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x8] - cmp r0, 0x1D - bls _0805DBDC - ldr r0, =gMPlay_SE1 - bl m4aMPlayStop - ldr r0, =gMPlay_SE2 - bl m4aMPlayStop -_0805DBD8: - cmp r5, 0 - beq _0805DBF0 -_0805DBDC: - movs r0, 0x1 - b _0805DC02 - .pool -_0805DBF0: - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r1, [r0, 0x4] - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r1 - strb r5, [r0, 0x8] - movs r0, 0 -_0805DC02: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end mplay_80342A4 - - thumb_func_start BattleLoadOpponentMonSpriteGfx -BattleLoadOpponentMonSpriteGfx: @ 805DC0C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - adds r4, r0, 0 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - movs r1, 0 - bl GetMonData - str r0, [sp] - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - mov r2, r8 - lsls r1, r2, 2 - adds r2, r1, r0 - ldrh r0, [r2, 0x2] - cmp r0, 0 - bne _0805DC50 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - ldr r6, [sp] - b _0805DC58 - .pool -_0805DC50: - ldrh r5, [r2, 0x2] - ldr r0, =gTransformedPersonalities - adds r0, r1, r0 - ldr r6, [r0] -_0805DC58: - adds r0, r4, 0 - movs r1, 0x1 - bl GetMonData - mov r10, r0 - mov r0, r8 - bl GetBankIdentity - lsls r0, 24 - lsls r2, r5, 3 - ldr r1, =gMonFrontPicTable - adds r2, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - lsrs r0, 22 - adds r1, 0x4 - adds r1, r0 - ldr r1, [r1] - adds r0, r2, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl HandleLoadSpecialPokePic_DontHandleDeoxys - mov r3, r8 - lsls r2, r3, 4 - movs r0, 0x80 - lsls r0, 1 - adds r7, r2, r0 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - lsls r1, r3, 2 - adds r0, r1, r0 - ldrh r0, [r0, 0x2] - str r1, [sp, 0x4] - mov r9, r2 - cmp r0, 0 - bne _0805DCBC - adds r0, r4, 0 - bl pokemon_get_pal - b _0805DCC6 - .pool -_0805DCBC: - adds r0, r5, 0 - mov r1, r10 - ldr r2, [sp] - bl species_and_otid_get_pal -_0805DCC6: - adds r6, r0, 0 - ldr r4, =0x0201c000 - adds r0, r6, 0 - adds r1, r4, 0 - bl LZDecompressWram - adds r0, r4, 0 - adds r1, r7, 0 - movs r2, 0x20 - bl LoadPalette - mov r1, r9 - adds r1, 0x80 - adds r0, r4, 0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =0x00000181 - cmp r5, r0 - bne _0805DD1A - movs r7, 0x80 - lsls r7, 1 - add r7, r9 - ldr r5, =gBattleStruct - ldr r1, [r5] - movs r4, 0x80 - lsls r4, 1 - adds r1, r4 - adds r0, r6, 0 - bl LZDecompressWram - ldr r0, =gBattleMonForms - add r0, r8 - ldrb r1, [r0] - lsls r1, 5 - adds r1, r4 - ldr r0, [r5] - adds r0, r1 - adds r1, r7, 0 - movs r2, 0x20 - bl LoadPalette -_0805DD1A: - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - ldr r1, [sp, 0x4] - adds r0, r1, r0 - ldrh r0, [r0, 0x2] - cmp r0, 0 - beq _0805DD46 - ldr r3, =0x00007fff - adds r0, r7, 0 - movs r1, 0x10 - movs r2, 0x6 - bl BlendPalette - lsls r1, r7, 1 - ldr r0, =gPlttBufferFaded - adds r0, r1, r0 - ldr r2, =gPlttBufferUnfaded - adds r1, r2 - ldr r2, =0x04000008 - bl CpuSet -_0805DD46: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end BattleLoadOpponentMonSpriteGfx - - thumb_func_start BattleLoadPlayerMonSpriteGfx -BattleLoadPlayerMonSpriteGfx: @ 805DD7C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - adds r6, r0, 0 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - movs r1, 0 - bl GetMonData - str r0, [sp] - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - mov r2, r8 - lsls r1, r2, 2 - adds r2, r1, r0 - ldrh r0, [r2, 0x2] - cmp r0, 0 - bne _0805DDC0 - adds r0, r6, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - ldr r4, [sp] - b _0805DDC8 - .pool -_0805DDC0: - ldrh r5, [r2, 0x2] - ldr r0, =gTransformedPersonalities - adds r0, r1, r0 - ldr r4, [r0] -_0805DDC8: - adds r0, r6, 0 - movs r1, 0x1 - bl GetMonData - str r0, [sp, 0x4] - mov r0, r8 - bl GetBankIdentity - lsls r0, 24 - lsrs r7, r0, 24 - movs r0, 0x1 - mov r1, r8 - bl sub_80688F8 - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - lsls r1, 2 - mov r10, r1 - cmp r0, 0x1 - beq _0805DE00 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - add r0, r10 - ldrh r0, [r0, 0x2] - cmp r0, 0 - beq _0805DE2C -_0805DE00: - lsls r0, r5, 3 - ldr r1, =gMonBackPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - lsls r2, r7, 2 - adds r1, 0x4 - adds r1, r2 - ldr r1, [r1] - adds r2, r5, 0 - adds r3, r4, 0 - bl HandleLoadSpecialPokePic_DontHandleDeoxys - b _0805DE46 - .pool -_0805DE2C: - lsls r0, r5, 3 - ldr r1, =gMonBackPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - lsls r2, r7, 2 - adds r1, 0x4 - adds r1, r2 - ldr r1, [r1] - adds r2, r5, 0 - adds r3, r4, 0 - bl HandleLoadSpecialPokePic -_0805DE46: - mov r2, r8 - lsls r1, r2, 4 - movs r0, 0x80 - lsls r0, 1 - adds r7, r1, r0 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - add r0, r10 - ldrh r0, [r0, 0x2] - mov r9, r1 - cmp r0, 0 - bne _0805DE74 - adds r0, r6, 0 - bl pokemon_get_pal - b _0805DE7E - .pool -_0805DE74: - adds r0, r5, 0 - ldr r1, [sp, 0x4] - ldr r2, [sp] - bl species_and_otid_get_pal -_0805DE7E: - adds r6, r0, 0 - ldr r4, =0x0201c000 - adds r0, r6, 0 - adds r1, r4, 0 - bl LZDecompressWram - adds r0, r4, 0 - adds r1, r7, 0 - movs r2, 0x20 - bl LoadPalette - mov r1, r9 - adds r1, 0x80 - adds r0, r4, 0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =0x00000181 - cmp r5, r0 - bne _0805DED2 - movs r7, 0x80 - lsls r7, 1 - add r7, r9 - ldr r5, =gBattleStruct - ldr r1, [r5] - movs r4, 0x80 - lsls r4, 1 - adds r1, r4 - adds r0, r6, 0 - bl LZDecompressWram - ldr r0, =gBattleMonForms - add r0, r8 - ldrb r1, [r0] - lsls r1, 5 - adds r1, r4 - ldr r0, [r5] - adds r0, r1 - adds r1, r7, 0 - movs r2, 0x20 - bl LoadPalette -_0805DED2: - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - add r0, r10 - ldrh r0, [r0, 0x2] - cmp r0, 0 - beq _0805DEFC - ldr r3, =0x00007fff - adds r0, r7, 0 - movs r1, 0x10 - movs r2, 0x6 - bl BlendPalette - lsls r1, r7, 1 - ldr r0, =gPlttBufferFaded - adds r0, r1, r0 - ldr r2, =gPlttBufferUnfaded - adds r1, r2 - ldr r2, =0x04000008 - bl CpuSet -_0805DEFC: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end BattleLoadPlayerMonSpriteGfx - - thumb_func_start nullsub_23 -nullsub_23: @ 805DF30 - bx lr - thumb_func_end nullsub_23 - - thumb_func_start nullsub_24 -nullsub_24: @ 805DF34 - bx lr - thumb_func_end nullsub_24 - - thumb_func_start DecompressTrainerFrontPic -DecompressTrainerFrontPic: @ 805DF38 - push {r4,lr} - adds r4, r0, 0 - adds r0, r1, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r0, 24 - lsrs r0, 24 - bl GetBankIdentity - lsls r0, 24 - lsls r4, 3 - ldr r2, =gTrainerFrontPicTable - adds r2, r4, r2 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - lsrs r0, 22 - adds r1, 0x4 - adds r1, r0 - ldr r1, [r1] - adds r0, r2, 0 - movs r2, 0 - bl DecompressPicFromTable_2 - ldr r0, =gTrainerFrontPicPaletteTable - adds r4, r0 - adds r0, r4, 0 - bl LoadCompressedObjectPalette - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end DecompressTrainerFrontPic - - thumb_func_start DecompressTrainerBackPic -DecompressTrainerBackPic: @ 805DF84 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - lsls r5, 16 - lsrs r5, 16 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl GetBankIdentity - lsls r0, 24 - lsls r5, 3 - ldr r2, =gTrainerBackPicTable - adds r2, r5, r2 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - lsrs r0, 22 - adds r1, 0x4 - adds r1, r0 - ldr r1, [r1] - adds r0, r2, 0 - movs r2, 0 - bl DecompressPicFromTable_2 - ldr r0, =gTrainerBackPicPaletteTable - adds r5, r0 - ldr r0, [r5] - lsls r4, 20 - movs r1, 0x80 - lsls r1, 17 - adds r4, r1 - lsrs r4, 16 - adds r1, r4, 0 - movs r2, 0x20 - bl LoadCompressedPalette - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end DecompressTrainerBackPic - - thumb_func_start nullsub_25 -nullsub_25: @ 805DFE0 - bx lr - thumb_func_end nullsub_25 - - thumb_func_start FreeTrainerFrontPicPalette -FreeTrainerFrontPicPalette: @ 805DFE4 - push {lr} - lsls r0, 16 - ldr r1, =gTrainerFrontPicPaletteTable - lsrs r0, 13 - adds r0, r1 - ldrh r0, [r0, 0x4] - bl FreeSpritePaletteByTag - pop {r0} - bx r0 - .pool - thumb_func_end FreeTrainerFrontPicPalette - - thumb_func_start sub_805DFFC -sub_805DFFC: @ 805DFFC - push {r4-r7,lr} - ldr r4, =gUnknown_0832C128 - adds r0, r4, 0 - bl LoadSpritePalette - adds r4, 0x8 - adds r0, r4, 0 - bl LoadSpritePalette - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - bne _0805E034 - ldr r0, =gUnknown_0832C0D0 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0832C0D8 - bl LoadCompressedObjectPic - movs r5, 0x2 - b _0805E056 - .pool -_0805E034: - ldr r4, =gUnknown_0832C0E0 - adds r0, r4, 0 - bl LoadCompressedObjectPic - adds r4, 0x8 - adds r0, r4, 0 - bl LoadCompressedObjectPic - ldr r4, =gUnknown_0832C0F0 - adds r0, r4, 0 - bl LoadCompressedObjectPic - adds r4, 0x8 - adds r0, r4, 0 - bl LoadCompressedObjectPic - movs r5, 0x4 -_0805E056: - movs r4, 0 - cmp r4, r5 - bcs _0805E076 - ldr r7, =gBanksByIdentity - ldr r6, =gUnknown_0832C108 -_0805E060: - adds r0, r4, r7 - ldrb r0, [r0] - lsls r0, 3 - adds r0, r6 - bl LoadCompressedObjectPic - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, r5 - bcc _0805E060 -_0805E076: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805DFFC - - thumb_func_start BattleLoadAllHealthBoxesGfx -BattleLoadAllHealthBoxesGfx: @ 805E08C - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - movs r6, 0 - cmp r4, 0 - bne _0805E09C - b _0805E1AE -_0805E09C: - cmp r4, 0x1 - bne _0805E0B8 - ldr r4, =gUnknown_0832C128 - adds r0, r4, 0 - bl LoadSpritePalette - adds r4, 0x8 - adds r0, r4, 0 - bl LoadSpritePalette - b _0805E1AE - .pool -_0805E0B8: - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - bne _0805E120 - cmp r4, 0x2 - bne _0805E0F0 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0805E0E4 - ldr r0, =gUnknown_0832C100 - bl LoadCompressedObjectPic - b _0805E1AE - .pool -_0805E0E4: - ldr r0, =gUnknown_0832C0D0 - bl LoadCompressedObjectPic - b _0805E1AE - .pool -_0805E0F0: - cmp r4, 0x3 - bne _0805E100 - ldr r0, =gUnknown_0832C0D8 - bl LoadCompressedObjectPic - b _0805E1AE - .pool -_0805E100: - cmp r4, 0x4 - bne _0805E110 - ldr r0, =gBanksByIdentity - ldrb r0, [r0] - b _0805E198 - .pool -_0805E110: - cmp r4, 0x5 - bne _0805E1AC - ldr r0, =gBanksByIdentity - ldrb r0, [r0, 0x1] - b _0805E198 - .pool -_0805E120: - cmp r4, 0x2 - bne _0805E130 - ldr r0, =gUnknown_0832C0E0 - bl LoadCompressedObjectPic - b _0805E1AE - .pool -_0805E130: - cmp r4, 0x3 - bne _0805E140 - ldr r0, =gUnknown_0832C0E8 - bl LoadCompressedObjectPic - b _0805E1AE - .pool -_0805E140: - cmp r4, 0x4 - bne _0805E150 - ldr r0, =gUnknown_0832C0F0 - bl LoadCompressedObjectPic - b _0805E1AE - .pool -_0805E150: - cmp r4, 0x5 - bne _0805E160 - ldr r0, =gUnknown_0832C0F8 - bl LoadCompressedObjectPic - b _0805E1AE - .pool -_0805E160: - cmp r4, 0x6 - bne _0805E170 - ldr r0, =gBanksByIdentity - ldrb r0, [r0] - b _0805E198 - .pool -_0805E170: - cmp r4, 0x7 - bne _0805E180 - ldr r0, =gBanksByIdentity - ldrb r0, [r0, 0x1] - b _0805E198 - .pool -_0805E180: - cmp r4, 0x8 - bne _0805E190 - ldr r0, =gBanksByIdentity - ldrb r0, [r0, 0x2] - b _0805E198 - .pool -_0805E190: - cmp r5, 0x9 - bne _0805E1AC - ldr r0, =gBanksByIdentity - ldrb r0, [r0, 0x3] -_0805E198: - lsls r0, 3 - ldr r1, =gUnknown_0832C108 - adds r0, r1 - bl LoadCompressedObjectPic - b _0805E1AE - .pool -_0805E1AC: - movs r6, 0x1 -_0805E1AE: - adds r0, r6, 0 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end BattleLoadAllHealthBoxesGfx - - thumb_func_start LoadBattleBarGfx -LoadBattleBarGfx: @ 805E1B8 - push {lr} - ldr r0, =gUnknown_08C093F0 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - movs r2, 0xBA - lsls r2, 1 - adds r1, r2 - ldr r1, [r1] - bl LZDecompressWram - pop {r0} - bx r0 - .pool - thumb_func_end LoadBattleBarGfx - - thumb_func_start BattleInitAllSprites -BattleInitAllSprites: @ 805E1D8 - push {r4-r6,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r6, 0 - ldrb r0, [r5] - cmp r0, 0x6 - bls _0805E1E8 - b _0805E346 -_0805E1E8: - lsls r0, 2 - ldr r1, =_0805E1F8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0805E1F8: - .4byte _0805E214 - .4byte _0805E21A - .4byte _0805E324 - .4byte _0805E230 - .4byte _0805E260 - .4byte _0805E29C - .4byte _0805E33C -_0805E214: - bl sub_805E378 - b _0805E324 -_0805E21A: - ldrb r0, [r4] - bl BattleLoadAllHealthBoxesGfx - lsls r0, 24 - cmp r0, 0 - beq _0805E228 - b _0805E320 -_0805E228: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - b _0805E346 -_0805E230: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0805E24C - ldrb r0, [r4] - cmp r0, 0 - bne _0805E24C - bl CreateSafariPlayerHealthboxSprites - b _0805E252 - .pool -_0805E24C: - ldrb r0, [r4] - bl CreateBankHealthboxSprites -_0805E252: - ldr r2, =gHealthBoxesIds - ldrb r1, [r4] - adds r1, r2 - strb r0, [r1] - b _0805E30E - .pool -_0805E260: - ldrb r0, [r4] - bl SetBankHealthboxSpritePos - ldr r0, =gBanksByIdentity - ldrb r1, [r4] - adds r0, r1, r0 - ldrb r0, [r0] - cmp r0, 0x1 - bhi _0805E288 - ldr r0, =gHealthBoxesIds - adds r0, r1, r0 - ldrb r0, [r0] - movs r1, 0 - bl DummyBattleInterfaceFunc - b _0805E30E - .pool -_0805E288: - ldr r0, =gHealthBoxesIds - adds r0, r1, r0 - ldrb r0, [r0] - movs r1, 0x1 - bl DummyBattleInterfaceFunc - b _0805E30E - .pool -_0805E29C: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0805E2E4 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0805E302 - ldr r0, =gHealthBoxesIds - ldrb r1, [r4] - adds r0, r1, r0 - ldrb r0, [r0] - ldr r2, =gBattlePartyID - lsls r1, 1 - adds r1, r2 - ldrh r2, [r1] - movs r1, 0x64 - muls r1, r2 - ldr r2, =gPlayerParty - adds r1, r2 - movs r2, 0 - bl UpdateHealthboxAttribute - b _0805E302 - .pool -_0805E2E4: - ldr r0, =gHealthBoxesIds - ldrb r1, [r4] - adds r0, r1, r0 - ldrb r0, [r0] - ldr r2, =gBattlePartyID - lsls r1, 1 - adds r1, r2 - ldrh r2, [r1] - movs r1, 0x64 - muls r1, r2 - ldr r2, =gEnemyParty - adds r1, r2 - movs r2, 0 - bl UpdateHealthboxAttribute -_0805E302: - ldr r1, =gHealthBoxesIds - ldrb r0, [r4] - adds r0, r1 - ldrb r0, [r0] - bl SetHealthboxSpriteInvisible -_0805E30E: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bne _0805E346 -_0805E320: - movs r0, 0 - strb r0, [r4] -_0805E324: - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - b _0805E346 - .pool -_0805E33C: - bl LoadAndCreateEnemyShadowSprites - bl sub_81B8C68 - movs r6, 0x1 -_0805E346: - adds r0, r6, 0 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end BattleInitAllSprites - - thumb_func_start sub_805E350 -sub_805E350: @ 805E350 - push {r4,lr} - ldr r4, =gBattleSpritesDataPtr - ldr r0, [r4] - ldr r0, [r0, 0x4] - movs r1, 0 - movs r2, 0x30 - bl memset - ldr r0, [r4] - ldr r0, [r0, 0x8] - movs r1, 0 - movs r2, 0x10 - bl memset - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805E350 - - thumb_func_start sub_805E378 -sub_805E378: @ 805E378 - push {lr} - bl sub_805E350 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - movs r1, 0 - movs r2, 0x10 - bl memset - pop {r0} - bx r0 - .pool - thumb_func_end sub_805E378 - - thumb_func_start sub_805E394 -sub_805E394: @ 805E394 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r4, 0 - ldr r5, =gNoOfAllBanks - ldrb r0, [r5] - cmp r4, r0 - bge _0805E3EA - ldr r0, =gSprites - mov r9, r0 - movs r0, 0x1 - mov r12, r0 - movs r0, 0x2 - negs r0, r0 - mov r8, r0 - ldr r7, =gBattleSpritesDataPtr - ldr r6, =gBankSpriteIds -_0805E3B8: - ldr r0, [r7] - ldr r0, [r0] - lsls r3, r4, 2 - adds r3, r0 - adds r0, r4, r6 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r9 - adds r0, 0x3E - ldrb r1, [r0] - lsls r1, 29 - lsrs r1, 31 - mov r0, r12 - ands r1, r0 - ldrb r2, [r3] - mov r0, r8 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - adds r4, 0x1 - ldrb r0, [r5] - cmp r4, r0 - blt _0805E3B8 -_0805E3EA: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805E394 - - thumb_func_start CopyBattleSpriteInvisibility -CopyBattleSpriteInvisibility: @ 805E408 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gBattleSpritesDataPtr - ldr r1, [r1] - ldr r1, [r1] - lsls r3, r0, 2 - adds r3, r1 - ldr r2, =gSprites - ldr r1, =gBankSpriteIds - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - adds r0, 0x3E - ldrb r1, [r0] - lsls r1, 29 - lsrs r1, 31 - ldrb r2, [r3] - movs r0, 0x2 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - bx lr - .pool - thumb_func_end CopyBattleSpriteInvisibility - - thumb_func_start sub_805E448 -sub_805E448: @ 805E448 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r7, r0, 24 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp] - lsls r2, 24 - cmp r2, 0 - beq _0805E51C - ldr r0, =gBankSpriteIds - adds r5, r7, r0 - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - mov r8, r1 - add r0, r8 - ldr r4, =gBattleSpritesDataPtr - ldr r1, [r4] - ldr r1, [r1, 0x8] - ldrb r1, [r1] - bl StartSpriteAnim - lsls r0, r7, 20 - movs r2, 0x80 - lsls r2, 17 - adds r0, r2 - lsrs r6, r0, 16 - ldr r2, =gBattleStruct - ldr r0, [r4] - ldr r0, [r0, 0x8] - ldrh r1, [r0] - lsls r1, 5 - movs r3, 0x80 - lsls r3, 1 - adds r1, r3 - ldr r0, [r2] - adds r0, r1 - adds r1, r6, 0 - movs r2, 0x20 - bl LoadPalette - ldr r1, =gBattleMonForms - adds r1, r7, r1 - ldr r0, [r4] - ldr r0, [r0, 0x8] - ldrh r0, [r0] - strb r0, [r1] - ldr r0, [r4] - ldr r1, [r0] - lsls r0, r7, 2 - adds r0, r1 - ldrh r0, [r0, 0x2] - cmp r0, 0 - beq _0805E4DE - ldr r3, =0x00007fff - adds r0, r6, 0 - movs r1, 0x10 - movs r2, 0x6 - bl BlendPalette - lsls r1, r6, 1 - ldr r0, =gPlttBufferFaded - adds r0, r1, r0 - ldr r2, =gPlttBufferUnfaded - adds r1, r2 - ldr r2, =0x04000008 - bl CpuSet -_0805E4DE: - adds r0, r7, 0 - bl sub_80A6138 - ldrb r2, [r5] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - add r1, r8 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r1, 0x22] - b _0805E77A - .pool -_0805E51C: - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0805E558 - movs r0, 0 - mov r10, r0 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r2, [r0, 0x18] - ldrh r1, [r2, 0x2] - mov r8, r1 - ldr r3, [r2, 0x8] - mov r9, r3 - ldr r4, [r2, 0xC] - lsls r0, r1, 3 - ldr r1, =gMonBackPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - ldr r1, [r1, 0x4] - ldr r3, [r2, 0x10] - b _0805E5FA - .pool -_0805E558: - adds r0, r7, 0 - bl GetBankIdentity - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r0, [sp] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0805E58C - ldr r1, =gBattlePartyID - ldr r2, [sp] - lsls r0, r2, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - b _0805E59C - .pool -_0805E58C: - ldr r1, =gBattlePartyID - ldr r3, [sp] - lsls r0, r3, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty -_0805E59C: - adds r0, r1 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - adds r0, r7, 0 - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0805E618 - ldr r0, =gBattlePartyID - lsls r4, r7, 1 - adds r4, r0 - ldrh r0, [r4] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gPlayerParty - adds r0, r5 - movs r1, 0 - bl GetMonData - mov r9, r0 - ldrh r0, [r4] - muls r0, r6 - adds r0, r5 - movs r1, 0x1 - bl GetMonData - adds r4, r0, 0 - mov r1, r8 - lsls r0, r1, 3 - ldr r1, =gMonBackPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - mov r3, r10 - lsls r2, r3, 2 - adds r1, 0x4 - adds r1, r2 - ldr r1, [r1] - ldr r3, =gTransformedPersonalities - lsls r2, r7, 2 - adds r2, r3 - ldr r3, [r2] -_0805E5FA: - mov r2, r8 - bl HandleLoadSpecialPokePic_DontHandleDeoxys - b _0805E662 - .pool -_0805E618: - ldr r0, =gBattlePartyID - lsls r4, r7, 1 - adds r4, r0 - ldrh r0, [r4] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gEnemyParty - adds r0, r5 - movs r1, 0 - bl GetMonData - mov r9, r0 - ldrh r0, [r4] - muls r0, r6 - adds r0, r5 - movs r1, 0x1 - bl GetMonData - adds r4, r0, 0 - mov r1, r8 - lsls r0, r1, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - mov r3, r10 - lsls r2, r3, 2 - adds r1, 0x4 - adds r1, r2 - ldr r1, [r1] - ldr r3, =gTransformedPersonalities - lsls r2, r7, 2 - adds r2, r3 - ldr r3, [r2] - mov r2, r8 - bl HandleLoadSpecialPokePic_DontHandleDeoxys -_0805E662: - ldr r0, =gMonSpritesGfxPtr - ldr r0, [r0] - mov r2, r10 - lsls r1, r2, 2 - adds r0, 0x4 - adds r0, r1 - ldr r2, [r0] - ldr r0, =gBankSpriteIds - adds r0, r7 - mov r10, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r3, =gSprites - adds r0, r3 - ldrh r0, [r0, 0x4] - lsls r0, 22 - lsrs r0, 17 - ldr r1, =0x06010000 - adds r0, r1 - ldr r1, =0x040000d4 - str r2, [r1] - str r0, [r1, 0x4] - ldr r0, =0x84000200 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - lsls r0, r7, 20 - movs r1, 0x80 - lsls r1, 17 - adds r0, r1 - lsrs r6, r0, 16 - mov r0, r8 - adds r1, r4, 0 - mov r2, r9 - bl species_and_otid_get_pal - mov r9, r0 - ldr r4, =0x0201c000 - adds r1, r4, 0 - bl LZDecompressWram - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0x20 - bl LoadPalette - ldr r0, =0x00000181 - cmp r8, r0 - bne _0805E70A - mov r2, r10 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r1, 0x8 - adds r0, r1 - ldr r1, =gMonAnimationsSpriteAnimsPtrTable - mov r3, r8 - lsls r2, r3, 2 - adds r1, r2 - ldr r1, [r1] - str r1, [r0] - ldr r5, =gBattleStruct - ldr r1, [r5] - movs r4, 0x80 - lsls r4, 1 - adds r1, r4 - mov r0, r9 - bl LZDecompressWram - ldr r0, =gBattleMonForms - ldr r1, [sp] - adds r0, r1, r0 - ldrb r1, [r0] - lsls r1, 5 - adds r1, r4 - ldr r0, [r5] - adds r0, r1 - adds r1, r6, 0 - movs r2, 0x20 - bl LoadPalette -_0805E70A: - ldr r3, =0x00007fff - adds r0, r6, 0 - movs r1, 0x10 - movs r2, 0x6 - bl BlendPalette - lsls r1, r6, 1 - ldr r0, =gPlttBufferFaded - adds r0, r1, r0 - ldr r2, =gPlttBufferUnfaded - adds r1, r2 - ldr r2, =0x04000008 - bl CpuSet - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0805E74A - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r1, [r0] - lsls r0, r7, 2 - adds r0, r1 - mov r2, r8 - strh r2, [r0, 0x2] - ldr r0, =gBattleMonForms - adds r1, r7, r0 - ldr r3, [sp] - adds r0, r3, r0 - ldrb r0, [r0] - strb r0, [r1] -_0805E74A: - adds r0, r7, 0 - bl sub_80A6138 - mov r1, r10 - ldrb r2, [r1] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - ldr r2, =gSprites - adds r1, r2 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r1, 0x22] - mov r3, r10 - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =gBattleMonForms - adds r1, r7, r1 - ldrb r1, [r1] - bl StartSpriteAnim -_0805E77A: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805E448 - - thumb_func_start BattleLoadSubstituteSpriteGfx -BattleLoadSubstituteSpriteGfx: @ 805E7DC - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - lsls r1, 24 - cmp r1, 0 - bne _0805E898 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0805E7F8 - movs r4, 0 - b _0805E802 -_0805E7F8: - adds r0, r4, 0 - bl GetBankIdentity - lsls r0, 24 - lsrs r4, r0, 24 -_0805E802: - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _0805E814 - ldr r0, =gUnknown_08C2D120 - b _0805E822 - .pool -_0805E814: - adds r0, r5, 0 - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - beq _0805E83C - ldr r0, =gUnknown_08C2CEE0 -_0805E822: - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - lsls r4, 2 - adds r1, 0x4 - adds r1, r4 - ldr r1, [r1] - bl LZDecompressVram - b _0805E84E - .pool -_0805E83C: - ldr r0, =gUnknown_08C2D120 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - lsls r4, 2 - adds r1, 0x4 - adds r1, r4 - ldr r1, [r1] - bl LZDecompressVram -_0805E84E: - movs r3, 0x1 - lsls r6, r5, 4 - ldr r7, =gUnknown_08C2CEBC - ldr r0, =gMonSpritesGfxPtr - ldr r0, [r0] - adds r0, 0x4 - adds r4, r0, r4 - ldr r2, =0x040000d4 - ldr r5, =0x84000200 -_0805E860: - ldr r0, [r4] - lsls r1, r3, 11 - adds r1, r0, r1 - str r0, [r2] - str r1, [r2, 0x4] - str r5, [r2, 0x8] - ldr r0, [r2, 0x8] - adds r3, 0x1 - cmp r3, 0x3 - ble _0805E860 - movs r0, 0x80 - lsls r0, 1 - adds r1, r6, r0 - adds r0, r7, 0 - movs r2, 0x20 - bl LoadCompressedPalette - b _0805E8E6 - .pool -_0805E898: - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _0805E8E6 - adds r0, r4, 0 - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - beq _0805E8D0 - ldr r1, =gBattlePartyID - lsls r0, r4, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - adds r0, r1 - adds r1, r4, 0 - bl BattleLoadOpponentMonSpriteGfx - b _0805E8E6 - .pool -_0805E8D0: - ldr r1, =gBattlePartyID - lsls r0, r5, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - adds r1, r5, 0 - bl BattleLoadPlayerMonSpriteGfx -_0805E8E6: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end BattleLoadSubstituteSpriteGfx - - thumb_func_start refresh_graphics_maybe -refresh_graphics_maybe: @ 805E8F4 - push {r4-r6,lr} - adds r5, r1, 0 - adds r4, r2, 0 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r4, 24 - lsrs r4, 24 - adds r0, r6, 0 - adds r1, r5, 0 - bl BattleLoadSubstituteSpriteGfx - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - ldr r0, =gBattleMonForms - adds r0, r6, r0 - ldrb r1, [r0] - adds r0, r4, 0 - bl StartSpriteAnim - cmp r5, 0 - bne _0805E938 - adds r0, r6, 0 - bl sub_80A614C - b _0805E93E - .pool -_0805E938: - adds r0, r6, 0 - bl sub_80A6138 -_0805E93E: - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x22] - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end refresh_graphics_maybe - - thumb_func_start TrySetBehindSubstituteSpriteBit -TrySetBehindSubstituteSpriteBit: @ 805E94C - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r1, 16 - lsrs r1, 16 - cmp r1, 0xA4 - bne _0805E96C - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0] - lsls r1, r2, 2 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] -_0805E96C: - pop {r0} - bx r0 - .pool - thumb_func_end TrySetBehindSubstituteSpriteBit - - thumb_func_start sub_805E974 -sub_805E974: @ 805E974 - lsls r0, 24 - ldr r1, =gBattleSpritesDataPtr - ldr r1, [r1] - ldr r1, [r1] - lsrs r0, 22 - adds r0, r1 - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - bx lr - .pool - thumb_func_end sub_805E974 - - thumb_func_start sub_805E990 -sub_805E990: @ 805E990 - push {r4-r7,lr} - adds r5, r0, 0 - lsls r1, 24 - lsrs r6, r1, 24 - adds r7, r6, 0 - movs r1, 0x39 - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r5, 0 - movs r1, 0x3A - bl GetMonData - adds r1, r0, 0 - lsls r4, 16 - asrs r4, 16 - lsls r1, 16 - asrs r1, 16 - adds r0, r4, 0 - bl GetHPBarLevel - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0805EA08 - ldr r7, =gBattleSpritesDataPtr - ldr r0, [r7] - ldr r2, [r0] - lsls r4, r6, 2 - adds r0, r4, r2 - ldrb r1, [r0] - movs r5, 0x2 - movs r3, 0x2 - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _0805EA5A - adds r0, r6, 0 - eors r0, r5 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _0805E9F6 - movs r0, 0x5A - bl PlaySE -_0805E9F6: - ldr r0, [r7] - ldr r1, [r0] - adds r1, r4, r1 - ldrb r0, [r1] - orrs r0, r5 - strb r0, [r1] - b _0805EA5A - .pool -_0805EA08: - ldr r4, =gBattleSpritesDataPtr - ldr r0, [r4] - ldr r0, [r0] - lsls r1, r6, 2 - adds r1, r0 - ldrb r2, [r1] - movs r0, 0x3 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - bne _0805EA34 - movs r0, 0x5A - bl m4aSongNumStop - b _0805EA5A - .pool -_0805EA34: - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _0805EA5A - ldr r1, [r4] - movs r0, 0x2 - eors r7, r0 - ldr r1, [r1] - lsls r0, r7, 2 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0805EA5A - movs r0, 0x5A - bl m4aSongNumStop -_0805EA5A: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_805E990 - - thumb_func_start BattleMusicStop -BattleMusicStop: @ 805EA60 - push {r4-r6,lr} - movs r0, 0 - bl GetBankByIdentity - lsls r0, 24 - lsrs r4, r0, 24 - ldr r5, =gBattleSpritesDataPtr - ldr r0, [r5] - ldr r0, [r0] - lsls r1, r4, 2 - adds r1, r0 - ldrb r2, [r1] - movs r6, 0x3 - negs r6, r6 - adds r0, r6, 0 - ands r0, r2 - strb r0, [r1] - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _0805EAA2 - ldr r2, [r5] - movs r0, 0x2 - adds r1, r4, 0 - eors r1, r0 - ldr r0, [r2] - lsls r1, 2 - adds r1, r0 - ldrb r2, [r1] - adds r0, r6, 0 - ands r0, r2 - strb r0, [r1] -_0805EAA2: - movs r0, 0x5A - bl m4aSongNumStop - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end BattleMusicStop - - thumb_func_start sub_805EAB4 -sub_805EAB4: @ 805EAB4 - push {r4,r5,lr} - adds r5, r0, 0 - movs r1, 0x39 - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r5, 0 - movs r1, 0x3A - bl GetMonData - adds r1, r0, 0 - lsls r4, 16 - asrs r4, 16 - lsls r1, 16 - asrs r1, 16 - adds r0, r4, 0 - bl GetHPBarLevel - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_805EAB4 - - thumb_func_start sub_805EAE8 -sub_805EAE8: @ 805EAE8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r0, =gMain - ldr r1, =0x00000439 - adds r0, r1 - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0805EB7E - movs r0, 0 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r0, 0x2 - bl GetBankByIdentity - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r5, =gBattlePartyID - mov r1, r8 - lsls r0, r1, 1 - adds r0, r5 - ldrb r0, [r0] - bl pokemon_order_func - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - mov r1, r9 - lsls r0, r1, 1 - adds r0, r5 - ldrb r0, [r0] - bl pokemon_order_func - lsls r0, 24 - lsrs r5, r0, 24 - movs r7, 0x64 - adds r0, r4, 0 - muls r0, r7 - ldr r6, =gPlayerParty - adds r4, r0, r6 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _0805EB5A - adds r0, r4, 0 - mov r1, r8 - bl sub_805E990 -_0805EB5A: - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _0805EB7E - adds r0, r5, 0 - muls r0, r7 - adds r4, r0, r6 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _0805EB7E - adds r0, r4, 0 - mov r1, r9 - bl sub_805E990 -_0805EB7E: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805EAE8 - - thumb_func_start sub_805EB9C -sub_805EB9C: @ 805EB9C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r5, 0 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - bge _0805EC6C - movs r0, 0x3 - mov r10, r8 - mov r1, r10 - ands r1, r0 - mov r10, r1 - movs r6, 0 - movs r2, 0x3F - negs r2, r2 - mov r9, r2 -_0805EBC8: - lsls r0, r5, 24 - lsrs r0, 24 - bl IsBankSpritePresent - lsls r0, 24 - cmp r0, 0 - beq _0805EC60 - ldr r4, =gSprites - ldr r0, =gBankSpriteIds - adds r3, r5, r0 - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0, 0x1] - movs r7, 0x4 - negs r7, r7 - adds r2, r7, 0 - ands r1, r2 - mov r2, r10 - orrs r1, r2 - strb r1, [r0, 0x1] - mov r7, r8 - cmp r7, 0 - bne _0805EC3C - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r2, [r0, 0x4] - adds r2, r6, r2 - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x3] - lsls r0, 26 - lsrs r0, 27 - strb r0, [r2, 0x6] - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0, 0x3] - mov r2, r9 - ands r1, r2 - strb r1, [r0, 0x3] - b _0805EC60 - .pool -_0805EC3C: - ldrb r0, [r3] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r4 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r0, [r0, 0x4] - adds r0, r6, r0 - ldrb r1, [r0, 0x6] - movs r0, 0x1F - ands r1, r0 - lsls r1, 1 - ldrb r0, [r2, 0x3] - mov r3, r9 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x3] -_0805EC60: - adds r6, 0xC - adds r5, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0805EBC8 -_0805EC6C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805EB9C - - thumb_func_start LoadAndCreateEnemyShadowSprites -LoadAndCreateEnemyShadowSprites: @ 805EC84 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gUnknown_0831C6A0 - bl LoadCompressedObjectPic - movs r0, 0x1 - bl GetBankByIdentity - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gUnknown_0831C6B0 - mov r8, r0 - adds r0, r5, 0 - movs r1, 0 - bl sub_80A5C6C - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80A5C6C - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 8 - movs r0, 0xE8 - lsls r0, 13 - adds r2, r0 - asrs r2, 16 - mov r0, r8 - adds r1, r4, 0 - movs r3, 0xC8 - bl CreateSprite - ldr r6, =gBattleSpritesDataPtr - ldr r1, [r6] - ldr r2, [r1, 0x4] - lsls r1, r5, 1 - adds r1, r5 - lsls r1, 2 - adds r2, r1, r2 - strb r0, [r2, 0x7] - ldr r7, =gSprites - ldr r0, [r6] - ldr r0, [r0, 0x4] - adds r1, r0 - ldrb r1, [r1, 0x7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r5, [r0, 0x2E] - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _0805ED56 - movs r0, 0x3 - bl GetBankByIdentity - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - adds r0, r5, 0 - movs r1, 0 - bl sub_80A5C6C - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r5, 0 - movs r1, 0x1 - bl sub_80A5C6C - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 8 - movs r0, 0xE8 - lsls r0, 13 - adds r2, r0 - asrs r2, 16 - mov r0, r8 - adds r1, r4, 0 - movs r3, 0xC8 - bl CreateSprite - ldr r1, [r6] - ldr r2, [r1, 0x4] - lsls r1, r5, 1 - adds r1, r5 - lsls r1, 2 - adds r2, r1, r2 - strb r0, [r2, 0x7] - ldr r0, [r6] - ldr r0, [r0, 0x4] - adds r1, r0 - ldrb r1, [r1, 0x7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - strh r5, [r0, 0x2E] -_0805ED56: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end LoadAndCreateEnemyShadowSprites - - thumb_func_start sub_805ED70 -@ int sub_805ED70(obj *a1) -sub_805ED70: @ 805ED70 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r0, 0 - movs r0, 0 - mov r8, r0 - ldrh r0, [r5, 0x2E] - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gBankSpriteIds - adds r0, r4, r0 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r7, r0, r1 - adds r6, r7, 0 - adds r6, 0x3E - ldrb r1, [r6] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0805EDAC - adds r0, r4, 0 - bl IsBankSpritePresent - lsls r0, 24 - cmp r0, 0 - bne _0805EDC0 -_0805EDAC: - ldr r0, =sub_805EE48 - str r0, [r5, 0x1C] - b _0805EE36 - .pool -_0805EDC0: - ldr r0, =gAnimScriptActive - ldrb r0, [r0] - cmp r0, 0 - bne _0805EDD2 - ldrb r1, [r6] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0805EDE4 -_0805EDD2: - movs r0, 0x1 - mov r8, r0 - ldr r2, =gBattleSpritesDataPtr - lsls r4, 2 - b _0805EE06 - .pool -_0805EDE4: - ldr r2, =gBattleSpritesDataPtr - ldr r0, [r2] - ldr r0, [r0] - lsls r1, r4, 2 - adds r3, r1, r0 - ldrh r0, [r3, 0x2] - adds r4, r1, 0 - cmp r0, 0 - beq _0805EE06 - ldr r0, =gEnemyMonElevation - ldrh r1, [r3, 0x2] - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0 - bne _0805EE06 - movs r0, 0x1 - mov r8, r0 -_0805EE06: - ldr r0, [r2] - ldr r0, [r0] - adds r0, r4, r0 - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0805EE1A - movs r0, 0x1 - mov r8, r0 -_0805EE1A: - ldrh r0, [r7, 0x20] - strh r0, [r5, 0x20] - ldrh r0, [r7, 0x24] - strh r0, [r5, 0x24] - adds r2, r5, 0 - adds r2, 0x3E - mov r0, r8 - lsls r3, r0, 2 - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - orrs r0, r3 - strb r0, [r2] -_0805EE36: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805ED70 - - thumb_func_start sub_805EE48 -sub_805EE48: @ 805EE48 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - bx lr - thumb_func_end sub_805EE48 - - thumb_func_start SetBankEnemyShadowSpriteCallback -SetBankEnemyShadowSpriteCallback: @ 805EE54 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - lsls r1, 16 - lsrs r5, r1, 16 - adds r0, r4, 0 - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - beq _0805EED0 - ldr r0, =gBattleSpritesDataPtr - ldr r3, [r0] - ldr r1, [r3] - lsls r0, r4, 2 - adds r1, r0, r1 - ldrh r0, [r1, 0x2] - cmp r0, 0 - beq _0805EE7E - adds r5, r0, 0 -_0805EE7E: - ldr r0, =gEnemyMonElevation - adds r0, r5, r0 - ldrb r0, [r0] - cmp r0, 0 - beq _0805EEB4 - ldr r2, =gSprites - ldr r1, [r3, 0x4] - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, 0x1C - adds r0, r2 - ldr r1, =sub_805ED70 - b _0805EECE - .pool -_0805EEB4: - ldr r2, =gSprites - ldr r1, [r3, 0x4] - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, 0x1C - adds r0, r2 - ldr r1, =sub_805EE48 -_0805EECE: - str r1, [r0] -_0805EED0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end SetBankEnemyShadowSpriteCallback - - thumb_func_start sub_805EEE0 -sub_805EEE0: @ 805EEE0 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSprites - ldr r1, =gBattleSpritesDataPtr - ldr r1, [r1] - ldr r3, [r1, 0x4] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r3 - ldrb r1, [r1, 0x7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r2, 0x1C - adds r0, r2 - ldr r1, =sub_805EE48 - str r1, [r0] - bx lr - .pool - thumb_func_end sub_805EEE0 - - thumb_func_start sub_805EF14 -sub_805EF14: @ 805EF14 - push {r4-r6,lr} - ldr r3, =0x06000240 - movs r0, 0 - movs r6, 0xF0 - lsls r6, 8 -_0805EF1E: - adds r5, r0, 0x1 - movs r4, 0xF -_0805EF22: - ldrh r1, [r3] - adds r0, r6, 0 - ands r0, r1 - cmp r0, 0 - bne _0805EF32 - adds r0, r6, 0 - orrs r0, r1 - strh r0, [r3] -_0805EF32: - ldrh r1, [r3] - movs r2, 0xF0 - lsls r2, 4 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _0805EF46 - adds r0, r2, 0 - orrs r0, r1 - strh r0, [r3] -_0805EF46: - ldrh r1, [r3] - movs r2, 0xF0 - movs r0, 0xF0 - ands r0, r1 - cmp r0, 0 - bne _0805EF58 - adds r0, r1, 0 - orrs r0, r2 - strh r0, [r3] -_0805EF58: - ldrh r1, [r3] - movs r2, 0xF - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - bne _0805EF6A - adds r0, r1, 0 - orrs r0, r2 - strh r0, [r3] -_0805EF6A: - adds r3, 0x2 - subs r4, 0x1 - cmp r4, 0 - bge _0805EF22 - adds r0, r5, 0 - cmp r0, 0x8 - ble _0805EF1E - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_805EF14 - - thumb_func_start ClearTemporarySpeciesSpriteData -ClearTemporarySpeciesSpriteData: @ 805EF84 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - ldr r0, =gBattleSpritesDataPtr - ldr r0, [r0] - ldr r2, [r0] - lsls r0, r4, 2 - adds r0, r2 - movs r3, 0 - movs r2, 0 - strh r2, [r0, 0x2] - ldr r0, =gBattleMonForms - adds r0, r4, r0 - strb r3, [r0] - cmp r1, 0 - bne _0805EFAC - adds r0, r4, 0 - bl sub_805E974 -_0805EFAC: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ClearTemporarySpeciesSpriteData - - thumb_func_start AllocateMonSpritesGfx -AllocateMonSpritesGfx: @ 805EFBC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r6, 0 - ldr r4, =gMonSpritesGfxPtr - str r6, [r4] - movs r0, 0xC0 - lsls r0, 1 - bl AllocZeroed - str r0, [r4] - movs r0, 0x80 - lsls r0, 8 - bl AllocZeroed - ldr r1, [r4] - str r0, [r1] -_0805EFE2: - ldr r0, =gMonSpritesGfxPtr - ldr r1, [r0] - lsls r4, r6, 2 - adds r2, r1, 0x4 - adds r2, r4 - lsls r3, r6, 13 - ldr r0, [r1] - adds r0, r3 - str r0, [r2] - lsls r3, r6, 1 - adds r0, r3, r6 - lsls r0, 3 - adds r1, r0, r1 - ldr r2, =gUnknown_08329D98 - adds r1, 0x14 - adds r0, r2 - ldm r0!, {r2,r5,r7} - stm r1!, {r2,r5,r7} - ldm r0!, {r2,r5,r7} - stm r1!, {r2,r5,r7} - movs r5, 0 - mov r9, r3 - lsls r0, r6, 5 - mov r8, r0 - adds r1, r6, 0x1 - mov r10, r1 - mov r12, r8 - adds r7, r4, 0 -_0805F01A: - ldr r2, =gMonSpritesGfxPtr - ldr r1, [r2] - lsls r4, r5, 3 - add r4, r12 - adds r3, r1, 0 - adds r3, 0x74 - adds r3, r4 - adds r0, r1, 0x4 - adds r0, r7 - lsls r2, r5, 11 - ldr r0, [r0] - adds r0, r2 - str r0, [r3] - adds r1, r4 - adds r1, 0x78 - movs r0, 0x80 - lsls r0, 4 - strh r0, [r1] - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _0805F01A - ldr r1, =gMonSpritesGfxPtr - ldr r2, [r1] - mov r5, r9 - adds r0, r5, r6 - lsls r0, 3 - adds r1, r2, 0 - adds r1, 0x20 - adds r1, r0 - mov r0, r8 - adds r0, 0x74 - adds r2, r0 - str r2, [r1] - mov r7, r10 - lsls r0, r7, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _0805EFE2 - movs r0, 0x80 - lsls r0, 5 - bl AllocZeroed - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - movs r2, 0xBA - lsls r2, 1 - adds r1, r2 - str r0, [r1] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end AllocateMonSpritesGfx - - thumb_func_start FreeMonSpritesGfx -FreeMonSpritesGfx: @ 805F094 - push {r4-r6,lr} - ldr r6, =gMonSpritesGfxPtr - ldr r0, [r6] - cmp r0, 0 - beq _0805F106 - movs r1, 0xBE - lsls r1, 1 - adds r0, r1 - ldr r0, [r0] - cmp r0, 0 - beq _0805F0BA - bl Free - ldr r0, [r6] - movs r1, 0xBE - lsls r1, 1 - adds r0, r1 - movs r1, 0 - str r1, [r0] -_0805F0BA: - ldr r0, [r6] - movs r1, 0xBC - lsls r1, 1 - adds r0, r1 - ldr r0, [r0] - cmp r0, 0 - beq _0805F0D8 - bl Free - ldr r0, [r6] - movs r1, 0xBC - lsls r1, 1 - adds r0, r1 - movs r1, 0 - str r1, [r0] -_0805F0D8: - ldr r0, [r6] - movs r5, 0xBA - lsls r5, 1 - adds r0, r5 - ldr r0, [r0] - bl Free - ldr r0, [r6] - adds r5, r0, r5 - movs r4, 0 - str r4, [r5] - ldr r0, [r0] - bl Free - ldr r0, [r6] - str r4, [r0] - str r4, [r0, 0x4] - str r4, [r0, 0x8] - str r4, [r0, 0xC] - str r4, [r0, 0x10] - bl Free - str r4, [r6] -_0805F106: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end FreeMonSpritesGfx - - thumb_func_start sub_805F110 -sub_805F110: @ 805F110 - push {r4,r5,lr} - adds r5, r0, 0 - movs r1, 0x37 - bl GetMonData - ldr r1, =0x00000fff - ands r1, r0 - cmp r1, 0 - bne _0805F158 - adds r0, r5, 0 - movs r1, 0x39 - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - adds r0, r5, 0 - movs r1, 0x3A - bl GetMonData - adds r1, r0, 0 - lsls r4, 16 - asrs r4, 16 - lsls r1, 16 - asrs r1, 16 - adds r0, r4, 0 - bl GetHPBarLevel - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - ble _0805F158 - movs r0, 0x1 - b _0805F15A - .pool -_0805F158: - movs r0, 0 -_0805F15A: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_805F110 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/battle_anim_80A5C6C.s b/asm/battle_anim_80A5C6C.s index 705146ce5..158da2a02 100644 --- a/asm/battle_anim_80A5C6C.s +++ b/asm/battle_anim_80A5C6C.s @@ -586,8 +586,8 @@ _080A612E: bx r1 thumb_func_end sub_80A60AC - thumb_func_start sub_80A6138 -sub_80A6138: @ 80A6138 + thumb_func_start GetBankSpriteDefault_Y +GetBankSpriteDefault_Y: @ 80A6138 push {lr} lsls r0, 24 lsrs r0, 24 @@ -597,10 +597,10 @@ sub_80A6138: @ 80A6138 lsrs r0, 24 pop {r1} bx r1 - thumb_func_end sub_80A6138 + thumb_func_end GetBankSpriteDefault_Y - thumb_func_start sub_80A614C -sub_80A614C: @ 80A614C + thumb_func_start GetSubstituteSpriteDefault_Y +GetSubstituteSpriteDefault_Y: @ 80A614C push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 @@ -633,7 +633,7 @@ _080A6180: pop {r4} pop {r1} bx r1 - thumb_func_end sub_80A614C + thumb_func_end GetSubstituteSpriteDefault_Y thumb_func_start sub_80A6190 sub_80A6190: @ 80A6190 @@ -5180,7 +5180,7 @@ _080A8412: adds r0, r6, 0 ldr r1, [sp, 0x3C] mov r2, r8 - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality lsls r1, r5, 20 movs r2, 0x80 lsls r2, 17 @@ -5243,7 +5243,7 @@ _080A84B0: adds r0, r6, 0 ldr r1, [sp, 0x3C] mov r2, r8 - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality lsls r1, r5, 20 movs r3, 0x80 lsls r3, 17 diff --git a/asm/battle_anim_80A9C70.s b/asm/battle_anim_80A9C70.s index 681802e12..d27852961 100644 --- a/asm/battle_anim_80A9C70.s +++ b/asm/battle_anim_80A9C70.s @@ -855,8 +855,8 @@ _080AA352: .pool thumb_func_end sub_80AA18C - thumb_func_start move_anim_start_t2 -move_anim_start_t2: @ 80AA364 + thumb_func_start LaunchStatusAnimation +LaunchStatusAnimation: @ 80AA364 push {r4,lr} adds r4, r0, 0 lsls r4, 24 @@ -885,7 +885,7 @@ move_anim_start_t2: @ 80AA364 pop {r0} bx r0 .pool - thumb_func_end move_anim_start_t2 + thumb_func_end LaunchStatusAnimation thumb_func_start task0A_80788BC task0A_80788BC: @ 80AA3B4 diff --git a/asm/battle_anim_815A0D4.s b/asm/battle_anim_815A0D4.s index 69835bf4e..d2a401f59 100755 --- a/asm/battle_anim_815A0D4.s +++ b/asm/battle_anim_815A0D4.s @@ -3006,7 +3006,7 @@ _0815B8A8: lsls r2, 3 adds r2, r3 ldrb r2, [r2, 0x1C] - bl sub_805E448 + bl HandleSpeciesGfxDataChange ldrb r1, [r5] mov r0, sp bl sub_80A6BFC @@ -3310,7 +3310,7 @@ sub_815BB58: @ 815BB58 ldr r1, =gAnimBankTarget ldrb r1, [r1] movs r2, 0x1 - bl sub_805E448 + bl HandleSpeciesGfxDataChange adds r0, r4, 0 bl DestroyAnimVisualTask pop {r4} @@ -10129,7 +10129,7 @@ _0815F2AC: ldr r4, =gAnimBankAttacker ldrb r0, [r4] movs r1, 0 - bl refresh_graphics_maybe + bl LoadBattleMonGfxAndAnimate bl IsContest lsls r0, 24 cmp r0, 0 diff --git a/asm/battle_anim_8170478.s b/asm/battle_anim_8170478.s index 8de82c629..a5e3b5f88 100644 --- a/asm/battle_anim_8170478.s +++ b/asm/battle_anim_8170478.s @@ -4825,7 +4825,7 @@ _08172CC8: ldrb r1, [r5, 0x1E] adds r0, r2, 0 adds r2, r6, 0 - bl refresh_graphics_maybe + bl LoadBattleMonGfxAndAnimate ldrh r0, [r5, 0x1C] adds r0, 0x1 strh r0, [r5, 0x1C] @@ -5030,7 +5030,7 @@ _08172E4E: movs r3, 0x1 bl RequestDma3Fill ldrb r0, [r4] - bl sub_805E974 + bl ClearBehindSubstituteBit adds r0, r5, 0 bl DestroyAnimVisualTask _08172E84: diff --git a/asm/contest.s b/asm/contest.s index 9c0684663..4852a548f 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -6763,7 +6763,7 @@ _080DB1CC: adds r0, r5, 0 adds r1, r7, 0 adds r2, r6, 0 - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality movs r1, 0x90 lsls r1, 1 movs r2, 0x20 diff --git a/asm/contest_painting.s b/asm/contest_painting.s index 2caf15194..98f001442 100644 --- a/asm/contest_painting.s +++ b/asm/contest_painting.s @@ -572,7 +572,7 @@ sub_81302E8: @ 81302E8 ldr r1, [r0, 0x4] ldr r2, [r0] adds r0, r5, 0 - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality ldr r7, =gUnknown_030061C4 ldr r1, [r7] bl LZDecompressVram diff --git a/asm/link.s b/asm/link.s index 291f71a57..524a1eeed 100644 --- a/asm/link.s +++ b/asm/link.s @@ -69004,7 +69004,7 @@ _0802CA32: ldrh r0, [r7] ldr r1, [r7, 0x4] ldr r2, [r7, 0x8] - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality str r0, [sp, 0x20] add r0, sp, 0x20 ldr r1, [r0, 0x4] diff --git a/asm/pokeball.s b/asm/pokeball.s index 0afd27932..b4fc36d97 100755 --- a/asm/pokeball.s +++ b/asm/pokeball.s @@ -936,7 +936,7 @@ _08075B9E: .pool _08075BB4: adds r0, r3, 0 - bl sub_805F110 + bl ShouldPlayNormalPokeCry cmp r0, 0x1 bne _08075BCC lsls r1, r5, 24 @@ -976,7 +976,7 @@ _08075BF8: cmp r0, 0 bne _08075CBA adds r0, r3, 0 - bl sub_805F110 + bl ShouldPlayNormalPokeCry cmp r0, 0x1 bne _08075C22 lsls r1, r5, 24 @@ -1066,7 +1066,7 @@ _08075CBA: b _08075D04 _08075CC0: adds r0, r3, 0 - bl sub_805F110 + bl ShouldPlayNormalPokeCry cmp r0, 0x1 bne _08075CD8 lsls r1, r5, 24 diff --git a/asm/pokedex.s b/asm/pokedex.s index 3d69281c2..e9506881e 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -8824,7 +8824,7 @@ _080C0168: adds r3, r5 ldrb r4, [r3, 0x5] lsrs r4, 4 - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality lsls r4, 4 movs r2, 0x80 lsls r2, 1 diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index d1f7bd161..a8365ba18 100755 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -14656,7 +14656,7 @@ _080CEC86: adds r1, r3 str r0, [r1] adds r0, r6, 0 - bl pokemon_get_pal + bl GetMonFrontSpritePal ldr r1, [r4] ldr r2, =0x00000cdc adds r1, r2 @@ -14759,7 +14759,7 @@ _080CED7E: adds r1, r4 ldrh r0, [r1] mov r1, r9 - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality ldr r1, [r5] ldr r3, =0x00000cdc adds r2, r1, r3 diff --git a/asm/pokemon_summary_screen.s b/asm/pokemon_summary_screen.s index a89c54304..db11f6865 100755 --- a/asm/pokemon_summary_screen.s +++ b/asm/pokemon_summary_screen.s @@ -1116,7 +1116,7 @@ sub_81C4778: @ 81C4778 bne _081C47AE adds r0, r1, 0 adds r0, 0xC - bl sub_805F110 + bl ShouldPlayNormalPokeCry cmp r0, 0x1 bne _081C47A4 ldrh r0, [r4, 0x2] diff --git a/asm/pokenav.s b/asm/pokenav.s index 0c7a80742..ba6d4fca0 100755 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -13532,7 +13532,7 @@ _081CDBD0: adds r0, r4, 0 mov r1, r8 adds r2, r5, 0 - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality mov r2, r9 lsls r1, r2, 7 adds r1, r7, r1 @@ -24408,7 +24408,7 @@ _081D30C4: adds r0, r4, 0 adds r1, r6, 0 adds r2, r5, 0 - bl species_and_otid_get_pal + bl GetFrontSpritePalFromSpeciesAndPersonality mov r1, r9 bl LZ77UnCompWram _081D311A: diff --git a/data/battle_7.s b/data/battle_7.s deleted file mode 100644 index ffd2e8daa..000000000 --- a/data/battle_7.s +++ /dev/null @@ -1,44 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_0832C0D0:: @ 832C0D0 - obj_tiles gUnknown_08C1F1C8, 0x1000, 0xd6ff - - .align 2 -gUnknown_0832C0D8:: @ 832C0D8 - obj_tiles gUnknown_08C1F46C, 0x1000, 0xd701 - - .align 2 -gUnknown_0832C0E0:: @ 832C0E0 - obj_tiles gUnknown_08C1F5E8, 0x0800, 0xd6ff - - .align 2 -gUnknown_0832C0E8:: @ 832C0E8 - obj_tiles gUnknown_08C1F5E8, 0x0800, 0xd700 - - .align 2 -gUnknown_0832C0F0:: @ 832C0F0 - obj_tiles gUnknown_08C1F76C, 0x0800, 0xd701 - - .align 2 -gUnknown_0832C0F8:: @ 832C0F8 - obj_tiles gUnknown_08C1F76C, 0x0800, 0xd702 - - .align 2 -gUnknown_0832C100:: @ 832C100 - obj_tiles gUnknown_08C1F8E8, 0x1000, 0xd70b - - .align 2 -gUnknown_0832C108:: @ 832C108 - obj_tiles gUnknown_08C0237C, 0x0100, 0xd704 - obj_tiles gUnknown_08C0237C, 0x0120, 0xd705 - obj_tiles gUnknown_08C0237C, 0x0100, 0xd706 - obj_tiles gUnknown_08C0237C, 0x0120, 0xd707 - - .align 2 -gUnknown_0832C128:: @ 832C128 - obj_pal gBattleInterface_BallStatusBarPal, 0xd6ff - obj_pal gBattleInterface_BallDisplayPal, 0xd704 diff --git a/data/graphics.s b/data/graphics.s index e89177a1d..594bba800 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -149,13 +149,13 @@ gUnknown_08C2A6D4:: @ 8C2A6D4 gUnknown_08C2A6EC:: @ 8C2A6EC .incbin "baserom.gba", 0xc2a6ec, 0x27d0 -gUnknown_08C2CEBC:: @ 8C2CEBC +gSubstituteDollPal:: @ 8C2CEBC .incbin "baserom.gba", 0xc2cebc, 0x24 -gUnknown_08C2CEE0:: @ 8C2CEE0 +gSubstituteDollGfx:: @ 8C2CEE0 .incbin "baserom.gba", 0xc2cee0, 0x240 -gUnknown_08C2D120:: @ 8C2D120 +gSubstituteDollTilemap:: @ 8C2D120 .incbin "baserom.gba", 0xc2d120, 0x600 gUnknown_08C2D720:: @ 8C2D720 diff --git a/data/smokescreen.s b/data/smokescreen.s index 6f2478842..d92c972df 100644 --- a/data/smokescreen.s +++ b/data/smokescreen.s @@ -52,7 +52,7 @@ gUnknown_0831C688:: @ 831C688 spr_template 0xd6eb, 0xd6eb, gUnknown_0831C630, gUnknown_0831C678, NULL, gDummySpriteAffineAnimTable, sub_80753B4 .align 2 -gUnknown_0831C6A0:: @ 831C6A0 +gSpriteSheet_EnemyShadow:: @ 831C6A0 obj_tiles gUnknown_08D8FBC0, 0x0080, 0xd759 .align 2 @@ -60,5 +60,5 @@ gUnknown_0831C6A8:: @ 831C6A8 .byte 0x00, 0x40, 0x00, 0x40, 0x00, 0x0c, 0x00, 0x00 .align 2 -gUnknown_0831C6B0:: @ 831C6B0 - spr_template 0xd759, 0xd6ff, gUnknown_0831C6A8, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_805EE48 +gSpriteTemplate_EnemyShadow:: @ 831C6B0 + spr_template 0xd759, 0xd6ff, gUnknown_0831C6A8, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCB_SetInvisible diff --git a/include/battle.h b/include/battle.h index d958294b1..794278ed1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -6,6 +6,7 @@ #include "battle_script_commands.h" #include "battle_2.h" #include "battle_ai_switch_items.h" +#include "battle_gfx_sfx_util.h" /* Banks are a name given to what could be called a 'battlerId' or 'monControllerId'. @@ -670,7 +671,7 @@ struct BattleStruct u8 fillerDC[0xDF-0xDC]; u8 field_DF; u8 mirrorMoveArrays[32]; - u16 castformPalette[4][16]; + u16 castformPalette[BATTLE_BANKS_COUNT][16]; u8 field_180; u8 field_181; u8 field_182; @@ -807,6 +808,18 @@ extern struct BattleStruct* gBattleStruct; #define B_ANIM_SUBSTITUTE_TO_MON 0x5 #define B_ANIM_MON_TO_SUBSTITUTE 0x6 +// status animation table +#define B_ANIM_STATUS_PSN 0x0 +#define B_ANIM_STATUS_CONFUSION 0x1 +#define B_ANIM_STATUS_BRN 0x2 +#define B_ANIM_STATUS_INFATUATION 0x3 +#define B_ANIM_STATUS_SLP 0x4 +#define B_ANIM_STATUS_PRZ 0x5 +#define B_ANIM_STATUS_FRZ 0x6 +#define B_ANIM_STATUS_CURSED 0x7 +#define B_ANIM_STATUS_NIGHTMARE 0x8 +#define B_ANIM_STATUS_WRAPPED 0x9 + #define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8 #define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40 #define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit @@ -864,43 +877,6 @@ void AdjustFriendshipOnBattleFaint(u8 bank); void sub_80571DC(u8 bank, u8 arg1); u32 sub_805725C(u8 bank); -// battle 7 -void AllocateBattleSpritesData(void); -void FreeBattleSpritesData(void); -void AllocateMonSpritesGfx(void); -void FreeMonSpritesGfx(void); -void BattleMusicStop(void); -void sub_805E990(struct Pokemon *mon, u8 bank); -void sub_805EF14(void); -bool8 BattleInitAllSprites(u8 *state1, u8 *state2); -void sub_805E350(void); -bool8 BattleLoadAllHealthBoxesGfx(u8 state); -void LoadAndCreateEnemyShadowSprites(void); -void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species); -void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank); -void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank); -void BattleLoadSubstituteSpriteGfx(u8 bank, bool8 arg1); -void nullsub_24(u16 arg0); -void nullsub_25(u8 arg0); -void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute); -void sub_805D714(struct Sprite *sprite); -void DecompressTrainerBackPic(u16 backPicId, u8 bank); -void DecompressTrainerFrontPic(u16 frontPicId, u8 bank); -void FreeTrainerFrontPicPalette(u16 frontPicId); -void sub_805D7AC(struct Sprite *sprite); -bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn); -void sub_805EB9C(u8 arg0); -void sub_805E394(void); -void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move); -void DoStatusAnimation(bool8 isStatus2, u32 status); -void DoSpecialBattleAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId); -bool8 DoBattleAnimationFromTable(u8 active, u8 atkBank, u8 defBank, u8 tableId, u16 argument); -void CopyBattleSpriteInvisibility(u8 bank); -u16 ChooseMoveAndTargetInBattlePalace(void); -void LoadBattleBarGfx(u8 arg0); -bool8 mplay_80342A4(u8 bank); -void sub_805EEE0(u8 bank); - enum { BACK_PIC_BRENDAN, @@ -921,7 +897,7 @@ u8 GetBankByIdentity(u8 bank); struct BattleSpriteInfo { u16 invisible : 1; // 0x1 - u16 flag_x2 : 1; // 0x2 + u16 lowHpSong : 1; // 0x2 u16 behindSubstitute : 1; // 0x4 u16 flag_x8 : 1; // 0x8 u16 hpNumbersNoBars : 1; // 0x10 @@ -930,7 +906,7 @@ struct BattleSpriteInfo struct BattleAnimationInfo { - u16 field; // to fill up later + u16 animArg; // to fill up later u8 field_2; u8 field_3; u8 field_4; @@ -972,7 +948,7 @@ struct BattleHealthboxInfo u8 animationState; u8 field_5; u8 field_6; - u8 field_7; + u8 shadowSpriteId; u8 field_8; u8 field_9; u8 field_A; @@ -1012,8 +988,11 @@ struct MonSpritesGfx void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon void* sprites[4]; struct SpriteTemplate templates[4]; - u8 field_74[0x100]; - u8 *fontPixels; + struct SpriteFrameImage field_74[4][4]; + u8 field_F4[0x80]; + u8 *barFontGfx; + void *field_178; + void *field_17C; }; extern struct BattleSpritesGfx* gMonSpritesGfx; diff --git a/include/battle_anim.h b/include/battle_anim.h index e912af6b1..c055e94fa 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -92,7 +92,11 @@ u8 sub_80A6D94(void); u8 sub_80A8364(u8); void StoreSpriteCallbackInData6(struct Sprite *sprite, void (*spriteCallback)(struct Sprite*)); void oamt_add_pos2_onto_pos1(struct Sprite *sprite); -u8 sub_80A6138(u8 bank); +u8 GetBankSpriteDefault_Y(u8 bank); u8 sub_80A82E4(u8 bank); +u8 GetSubstituteSpriteDefault_Y(u8 bank); + +// battle_anim_80A9C70.s +void LaunchStatusAnimation(u8 bank, u8 statusAnimId); #endif // GUARD_BATTLE_ANIM_H diff --git a/include/battle_gfx_sfx_util.h b/include/battle_gfx_sfx_util.h new file mode 100644 index 000000000..ac59361aa --- /dev/null +++ b/include/battle_gfx_sfx_util.h @@ -0,0 +1,49 @@ +#ifndef GUARD_BATTLE_GFX_SFX_UTIL +#define GUARD_BATTLE_GFX_SFX_UTIL + +void AllocateBattleSpritesData(void); +void FreeBattleSpritesData(void); +void sub_805D714(struct Sprite *sprite); +void sub_805D770(struct Sprite *sprite, bool8 arg1); +void sub_805D7AC(struct Sprite *sprite); +void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status); +bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId, u16 argument); +void InitAndLaunchSpecialAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId); +bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn); +bool8 mplay_80342A4(u8 bank); +void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank); +void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank); +void nullsub_23(void); +void nullsub_24(u16 species); +void DecompressTrainerFrontPic(u16 frontPicId, u8 bank); +void DecompressTrainerBackPic(u16 backPicId, u8 bank); +void nullsub_25(u8 arg0); +void FreeTrainerFrontPicPalette(u16 frontPicId); +void sub_805DFFC(void); +bool8 BattleLoadAllHealthBoxesGfx(u8 state); +void LoadBattleBarGfx(u8 arg0); +bool8 BattleInitAllSprites(u8 *state1, u8 *bank); +void ClearSpritesHealthboxAnimData(void); +void CopyAllBattleSpritesInvisibilities(void); +void CopyBattleSpriteInvisibility(u8 bank); +void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform); +void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite); +void LoadBattleMonGfxAndAnimate(u8 bank, bool8 loadMonSprite, u8 spriteId); +void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move); +void ClearBehindSubstituteBit(u8 bank); +void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank); +void BattleStopLowHpSound(void); +u8 GetMonHPBarLevel(struct Pokemon *mon); +void sub_805EAE8(void); +void sub_805EB9C(u8 affineMode); +void LoadAndCreateEnemyShadowSprites(void); +void SpriteCB_SetInvisible(struct Sprite *sprite); +void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species); +void EnemyShadowCallbackToSetInvisible(u8 bank); +void sub_805EF14(void); +void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute); +void AllocateMonSpritesGfx(void); +void FreeMonSpritesGfx(void); +bool32 ShouldPlayNormalPokeCry(struct Pokemon *mon); + +#endif // GUARD_BATTLE_GFX_SFX_UTIL diff --git a/include/battle_interface.h b/include/battle_interface.h index aad30f7b3..b2d3b1b97 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -15,6 +15,15 @@ enum EXP_BAR }; +enum +{ + HP_BAR_EMPTY, + HP_BAR_RED, + HP_BAR_YELLOW, + HP_BAR_GREEN, + HP_BAR_FULL, +}; + #define TAG_HEALTHBOX_PLAYER1_TILE 0xD6FF #define TAG_HEALTHBOX_PLAYER2_TILE 0xD700 #define TAG_HEALTHBOX_OPPONENT1_TILE 0xD701 diff --git a/include/contest.h b/include/contest.h index 7dcde7da2..76fbaad3e 100644 --- a/include/contest.h +++ b/include/contest.h @@ -20,6 +20,12 @@ struct ContestStruct_field_18 { // unknown size u16 field_0; + u16 field_2; + u16 field_4; + u16 field_6; + u32 field_8; + u32 field_C; + u32 field_10; }; struct ContestResources diff --git a/include/decompress.h b/include/decompress.h index c3a771893..36be803e0 100644 --- a/include/decompress.h +++ b/include/decompress.h @@ -3,6 +3,8 @@ #include "sprite.h" +extern u8 gDecompressionBuffer[0x4000]; + void LZDecompressWram(const void *src, void *dest); void LZDecompressVram(const void *src, void *dest); diff --git a/include/pokemon.h b/include/pokemon.h index 0c7d6ac40..69b9e71d5 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -612,8 +612,8 @@ u32 CanMonLearnTMHM(struct Pokemon *, u8); u32 CanSpeciesLearnTMHM(u16 species, u8 tm); u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves); void ClearBattleMonForms(void); -const u8 *pokemon_get_pal(struct Pokemon *mon); -const u8 *species_and_otid_get_pal(u16, u32, u32); +const u8 *GetMonFrontSpritePal(struct Pokemon *mon); +const u8 *GetFrontSpritePalFromSpeciesAndPersonality(u16, u32, u32); const struct CompressedSpritePalette *sub_80409C8(u16, u32, u32); bool8 IsOtherTrainer(u32, u8 *); void SetWildMonHeldItem(void); diff --git a/ld_script.txt b/ld_script.txt index 3cec6fd8f..aa88cf2e1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -62,8 +62,7 @@ SECTIONS { src/battle_script_commands.o(.text); asm/battle_5.o(.text); src/battle_controller_player.o(.text); - src/battle_7.o(.text); - asm/battle_7.o(.text); + src/battle_gfx_sfx_util.o(.text); src/battle_controller_opponent.o(.text); src/battle_ai_switch_items.o(.text); src/battle_controller_link_opponent.o(.text); @@ -345,7 +344,7 @@ SECTIONS { src/util.o(.rodata); data/daycare.o(.rodata); src/egg_hatch.o(.rodata); - data/battle_7.o(.rodata); + src/battle_gfx_sfx_util.o(.rodata); src/battle_interface.o(.rodata); data/pokeball.o(.rodata); data/trade.o(.rodata); diff --git a/src/battle_2.c b/src/battle_2.c index 24b43bdbd..e4ee624fb 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -4767,7 +4767,7 @@ static void HandleEndTurn_BattleWon(void) else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000 | BATTLE_TYPE_EREADER_TRAINER)) { - BattleMusicStop(); + BattleStopLowHpSound(); gBattlescriptCurrInstr = BattleScript_FrontierTrainerBattleWon; if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) @@ -4777,7 +4777,7 @@ static void HandleEndTurn_BattleWon(void) } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & BATTLE_TYPE_LINK)) { - BattleMusicStop(); + BattleStopLowHpSound(); gBattlescriptCurrInstr = BattleScript_LocalTrainerBattleWon; switch (gTrainers[gTrainerBattleOpponent_A].trainerClass) diff --git a/src/battle_7.c b/src/battle_7.c deleted file mode 100644 index 8e21f9df5..000000000 --- a/src/battle_7.c +++ /dev/null @@ -1,284 +0,0 @@ -#include "global.h" -#include "battle.h" -#include "battle_controllers.h" -#include "battle_ai_script_commands.h" -#include "malloc.h" -#include "rng.h" -#include "util.h" -#include "pokemon.h" -#include "moves.h" - -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gActiveBank; -extern u16 gUnknown_020243FC; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; - -extern const struct BattleMove gBattleMoves[]; -extern const u8 gUnknown_0831C604[]; - -// this file's functions -u8 sub_805D4A8(u16 move); -u16 BattlePalaceGetTargetRetValue(void); -void sub_805D7EC(struct Sprite *sprite); - -void AllocateBattleSpritesData(void) -{ - gBattleSpritesDataPtr = AllocZeroed(sizeof(struct BattleSpriteData)); - gBattleSpritesDataPtr->bankData = AllocZeroed(sizeof(struct BattleSpriteInfo) * BATTLE_BANKS_COUNT); - gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * BATTLE_BANKS_COUNT); - gBattleSpritesDataPtr->animationData = AllocZeroed(sizeof(struct BattleAnimationInfo)); - gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * BATTLE_BANKS_COUNT); -} - -void FreeBattleSpritesData(void) -{ - if (gBattleSpritesDataPtr == NULL) - return; - - FREE_AND_SET_NULL(gBattleSpritesDataPtr->battleBars); - FREE_AND_SET_NULL(gBattleSpritesDataPtr->animationData); - FREE_AND_SET_NULL(gBattleSpritesDataPtr->healthBoxesData); - FREE_AND_SET_NULL(gBattleSpritesDataPtr->bankData); - FREE_AND_SET_NULL(gBattleSpritesDataPtr); -} - -u16 ChooseMoveAndTargetInBattlePalace(void) -{ - s32 i, var1, var2; - s32 chosenMoveId = -1; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); - u8 unusableMovesBits = CheckMoveLimitations(gActiveBank, 0, 0xFF); - s32 percent = Random() % 100; - - i = (gBattleStruct->field_92 & gBitTable[gActiveBank]) ? 2 : 0; - var2 = i; - var1 = i + 2; - - for (; i < var1; i++) - { - if (gUnknown_0831C494[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)][i] > percent) - break; - } - - percent = i - var2; - if (i == var1) - percent = 2; - - for (var2 = 0, i = 0; i < 4; i++) - { - if (moveInfo->moves[i] == MOVE_NONE) - break; - if (percent == sub_805D4A8(moveInfo->moves[i]) && moveInfo->currentPp[i] != 0) - var2 |= gBitTable[i]; - } - - if (var2 != 0) - { - gBattleStruct->field_92 &= 0xF; - gBattleStruct->field_92 |= (var2 << 4); - BattleAI_SetupAIData(var2); - chosenMoveId = BattleAI_ChooseMoveOrAction(); - } - - if (chosenMoveId == -1) - { - if (unusableMovesBits != 0xF) - { - var1 = 0, var2 = 0; - - for (i = 0; i < 4; i++) - { - if (sub_805D4A8(moveInfo->moves[i]) == 0 && !(gBitTable[i] & unusableMovesBits)) - var1 += 0x1; - if (sub_805D4A8(moveInfo->moves[i]) == 1 && !(gBitTable[i] & unusableMovesBits)) - var1 += 0x10; - if (sub_805D4A8(moveInfo->moves[i]) == 2 && !(gBitTable[i] & unusableMovesBits)) - var1 += 0x100; - } - - if ((var1 & 0xF) > 1) - var2++; - if ((var1 & 0xF0) > 0x1F) - var2++; - if ((var1 & 0xF0) > 0x1FF) - var2++; - - if (var2 > 1 || var2 == 0) - { - do - { - i = Random() % 4; - if (!(gBitTable[i] & unusableMovesBits)) - chosenMoveId = i; - } while (chosenMoveId == -1); - } - else - { - if ((var1 & 0xF) > 1) - var2 = 0; - if ((var1 & 0xF0) > 0x1F) - var2 = 1; - if ((var1 & 0xF0) > 0x1FF) - var2 = 2; - - do - { - i = Random() % 4; - if (!(gBitTable[i] & unusableMovesBits) && var2 == sub_805D4A8(moveInfo->moves[i])) - chosenMoveId = i; - } while (chosenMoveId == -1); - } - - if (Random() % 100 > 49) - { - gProtectStructs[gActiveBank].flag_x10 = 1; - return 0; - } - } - else - { - gProtectStructs[gActiveBank].flag_x10 = 1; - return 0; - } - } - - if (moveInfo->moves[chosenMoveId] == MOVE_CURSE) - { - if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST) - var1 = MOVE_TARGET_x10; - else - var1 = MOVE_TARGET_SELECTED; - } - else - { - var1 = gBattleMoves[moveInfo->moves[chosenMoveId]].target; - } - - if (var1 & MOVE_TARGET_x10) - chosenMoveId |= (gActiveBank << 8); - else if (var1 == MOVE_TARGET_SELECTED) - chosenMoveId |= (BattlePalaceGetTargetRetValue()); - else - chosenMoveId |= (GetBankByIdentity((GetBankIdentity(gActiveBank) & BIT_SIDE) ^ BIT_SIDE) << 8); - - return chosenMoveId; -} - -u8 sub_805D4A8(u16 move) -{ - switch (gBattleMoves[move].target) - { - case MOVE_TARGET_SELECTED: - case MOVE_TARGET_USER: - case MOVE_TARGET_RANDOM: - case MOVE_TARGET_BOTH: - case MOVE_TARGET_FOES_AND_ALLY: - if (gBattleMoves[move].power == 0) - return 2; - else - return 0; - break; - case MOVE_TARGET_DEPENDS: - case MOVE_TARGET_OPPONENTS_FIELD: - return 2; - case MOVE_TARGET_x10: - return 1; - default: - return 0; - } -} - -u16 BattlePalaceGetTargetRetValue(void) -{ - if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - { - u8 opposing1, opposing2; - - if (GetBankSide(gActiveBank) == SIDE_PLAYER) - { - opposing1 = GetBankByIdentity(IDENTITY_OPPONENT_MON1); - opposing2 = GetBankByIdentity(IDENTITY_OPPONENT_MON2); - } - else - { - opposing1 = GetBankByIdentity(IDENTITY_PLAYER_MON1); - opposing2 = GetBankByIdentity(IDENTITY_PLAYER_MON2); - } - - if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp) - return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; - - switch (gUnknown_0831C604[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)]) - { - case 0: - if (gBattleMons[opposing1].hp > gBattleMons[opposing2].hp) - return opposing1 << 8; - else - return opposing2 << 8; - case 1: - if (gBattleMons[opposing1].hp < gBattleMons[opposing2].hp) - return opposing1 << 8; - else - return opposing2 << 8; - case 2: - return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; - } - } - - return (gActiveBank ^ BIT_SIDE) << 8; -} - -void sub_805D714(struct Sprite *sprite) -{ - u8 spriteId = sprite->data1; - - if (!gSprites[spriteId].affineAnimEnded) - return; - if (gSprites[spriteId].invisible) - return; - - if (gSprites[spriteId].animPaused) - { - gSprites[spriteId].animPaused = 0; - } - else - { - if (gSprites[spriteId].animEnded) - sprite->callback = SpriteCallbackDummy; - } -} - -void sub_805D770(struct Sprite *sprite, bool8 arg1) -{ - sprite->animPaused = 1; - sprite->callback = SpriteCallbackDummy; - - if (!arg1) - StartSpriteAffineAnim(sprite, 1); - else - StartSpriteAffineAnim(sprite, 1); - - AnimateSprite(sprite); -} - -void sub_805D7AC(struct Sprite *sprite) -{ - if (!(gUnknown_020243FC & 1)) - { - sprite->pos2.x += sprite->data0; - if (sprite->pos2.x == 0) - { - if (sprite->pos2.y != 0) - sprite->callback = sub_805D7EC; - else - sprite->callback = SpriteCallbackDummy; - } - } -} - -void sub_805D7EC(struct Sprite *sprite) -{ - sprite->pos2.y -= 2; - if (sprite->pos2.y == 0) - sprite->callback = SpriteCallbackDummy; -} diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 968f6d49f..cb2ca0a4c 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -449,7 +449,7 @@ static void sub_8064C58(void) { FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - sub_805EEE0(gActiveBank); + EnemyShadowCallbackToSetInvisible(gActiveBank); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); LinkOpponentBufferExecCompleted(); } @@ -485,7 +485,7 @@ static void sub_8064D60(void) if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleBankFunc[gActiveBank] = sub_8064DD0; } @@ -1164,7 +1164,7 @@ static void LinkOpponentHandleLoadMonSprite(void) gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(gActiveBank, 2), - sub_80A6138(gActiveBank), + GetBankSpriteDefault_Y(gActiveBank), sub_80A82E4(gActiveBank)); gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; @@ -1198,7 +1198,7 @@ static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit) gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, sub_80A5C6C(bank, 2), - sub_80A6138(bank), + GetBankSpriteDefault_Y(bank), sub_80A82E4(bank)); gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; @@ -1227,7 +1227,7 @@ static void LinkOpponentHandleReturnMonToBall(void) { FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - sub_805EEE0(gActiveBank); + EnemyShadowCallbackToSetInvisible(gActiveBank); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); LinkOpponentBufferExecCompleted(); } @@ -1239,7 +1239,7 @@ static void DoSwitchOutAnimation(void) { case 0: if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1247,7 +1247,7 @@ static void DoSwitchOutAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); gBattleBankFunc[gActiveBank] = sub_8064C58; } break; @@ -1382,7 +1382,7 @@ static void LinkOpponentHandleFaintAnimation(void) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; } else @@ -1455,7 +1455,7 @@ static void LinkOpponentDoMoveAnimation(void) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) { gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1474,7 +1474,7 @@ static void LinkOpponentDoMoveAnimation(void) sub_805EB9C(1); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; @@ -1483,7 +1483,7 @@ static void LinkOpponentDoMoveAnimation(void) case 3: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { - sub_805E394(); + CopyAllBattleSpritesInvisibilities(); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; LinkOpponentBufferExecCompleted(); @@ -1586,7 +1586,7 @@ static void LinkOpponentHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBank)) { - DoStatusAnimation(gBattleBufferA[gActiveBank][1], + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; } @@ -1698,7 +1698,7 @@ static void LinkOpponentHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -1850,7 +1850,7 @@ static void LinkOpponentHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) LinkOpponentBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 4a70a4dc1..79776c15d 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -312,7 +312,7 @@ static void CompleteOnHealthbarDone(void) } else { - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); LinkPartnerBufferExecCompleted(); } } @@ -373,7 +373,7 @@ static void sub_814B4E0(void) { CopyBattleSpriteInvisibility(gActiveBank); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleBankFunc[gActiveBank] = sub_814B554; } @@ -399,7 +399,7 @@ static void sub_814B5A8(void) FreeSpritePaletteByTag(0x27F9); CreateTask(c3_0802FDF4, 10); - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); sub_8076918(gActiveBank); @@ -1026,7 +1026,7 @@ static void SetLinkPartnerMonData(u8 monId) break; } - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); } static void LinkPartnerHandleSetRawMonData(void) @@ -1050,7 +1050,7 @@ static void LinkPartnerHandleLoadMonSprite(void) gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(gActiveBank, 2), - sub_80A6138(gActiveBank), + GetBankSpriteDefault_Y(gActiveBank), sub_80A82E4(gActiveBank)); gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank; @@ -1081,7 +1081,7 @@ static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit) gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, sub_80A5C6C(bank, 2), - sub_80A6138(bank), + GetBankSpriteDefault_Y(bank), sub_80A82E4(bank)); gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; @@ -1121,7 +1121,7 @@ static void DoSwitchOutAnimation(void) { case 0: if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1129,7 +1129,7 @@ static void DoSwitchOutAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); gBattleBankFunc[gActiveBank] = sub_814B3DC; } break; @@ -1201,7 +1201,7 @@ static void LinkPartnerHandleFaintAnimation(void) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; } else @@ -1209,7 +1209,7 @@ static void LinkPartnerHandleFaintAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; gSprites[gBankSpriteIds[gActiveBank]].data2 = 5; @@ -1277,7 +1277,7 @@ static void LinkPartnerDoMoveAnimation(void) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) { gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1296,7 +1296,7 @@ static void LinkPartnerDoMoveAnimation(void) sub_805EB9C(1); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; @@ -1305,7 +1305,7 @@ static void LinkPartnerDoMoveAnimation(void) case 3: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { - sub_805E394(); + CopyAllBattleSpritesInvisibilities(); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; LinkPartnerBufferExecCompleted(); @@ -1408,7 +1408,7 @@ static void LinkPartnerHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBank)) { - DoStatusAnimation(gBattleBufferA[gActiveBank][1], + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; } @@ -1520,7 +1520,7 @@ static void LinkPartnerHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -1683,7 +1683,7 @@ static void LinkPartnerHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) LinkPartnerBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 7ffd9d64b..831f434b0 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -437,7 +437,7 @@ static void sub_805FB08(void) { FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - sub_805EEE0(gActiveBank); + EnemyShadowCallbackToSetInvisible(gActiveBank); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); OpponentBufferExecCompleted(); } @@ -473,7 +473,7 @@ static void sub_805FC10(void) if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleBankFunc[gActiveBank] = sub_805FC80; } } @@ -1152,7 +1152,7 @@ static void OpponentHandleLoadMonSprite(void) gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(gActiveBank, 2), - sub_80A6138(gActiveBank), + GetBankSpriteDefault_Y(gActiveBank), sub_80A82E4(gActiveBank)); gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; @@ -1187,7 +1187,7 @@ static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit) gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(bank, 2), - sub_80A6138(bank), + GetBankSpriteDefault_Y(bank), sub_80A82E4(bank)); gSprites[gBankSpriteIds[bank]].data0 = bank; @@ -1217,7 +1217,7 @@ static void OpponentHandleReturnMonToBall(void) { FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - sub_805EEE0(gActiveBank); + EnemyShadowCallbackToSetInvisible(gActiveBank); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); OpponentBufferExecCompleted(); } @@ -1229,7 +1229,7 @@ static void DoSwitchOutAnimation(void) { case 0: if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1237,7 +1237,7 @@ static void DoSwitchOutAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); gBattleBankFunc[gActiveBank] = sub_805FB08; } break; @@ -1415,7 +1415,7 @@ static void OpponentHandleFaintAnimation(void) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; } else @@ -1487,7 +1487,7 @@ static void OpponentDoMoveAnimation(void) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) { gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1506,7 +1506,7 @@ static void OpponentDoMoveAnimation(void) sub_805EB9C(1); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; @@ -1515,7 +1515,7 @@ static void OpponentDoMoveAnimation(void) case 3: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { - sub_805E394(); + CopyAllBattleSpritesInvisibilities(); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; OpponentBufferExecCompleted(); @@ -1731,7 +1731,7 @@ static void OpponentHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBank)) { - DoStatusAnimation(gBattleBufferA[gActiveBank][1], + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; } @@ -1843,7 +1843,7 @@ static void OpponentHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -2000,7 +2000,7 @@ static void OpponentHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) OpponentBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 10d361cb9..91d3d55eb 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -1008,10 +1008,10 @@ static void sub_805896C(void) FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); if (IsDoubleBattle()) - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; gBattleBankFunc[gActiveBank] = sub_8058924; @@ -1107,7 +1107,7 @@ static void sub_8058EDC(void) FreeSpritePaletteByTag(0x27F9); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleBankFunc[gActiveBank] = sub_8058FC0; } @@ -1119,7 +1119,7 @@ static void sub_8058FC0(void) && !IsCryPlayingOrClearCrySongs()) { m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100); - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); PlayerBufferExecCompleted(); } } @@ -1164,7 +1164,7 @@ static void CompleteOnHealthbarDone(void) } else { - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); PlayerBufferExecCompleted(); } } @@ -1305,7 +1305,7 @@ static void sub_8059544(u8 taskId) if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON]) bank ^= BIT_MON; - DoSpecialBattleAnimation(bank, bank, bank, B_ANIM_LVL_UP); + InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP); gTasks[taskId].func = sub_80595A4; } @@ -2193,7 +2193,7 @@ static void SetPlayerMonData(u8 monId) break; } - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); } static void PlayerHandleSetRawMonData(void) @@ -2238,7 +2238,7 @@ static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit) gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, sub_80A5C6C(bank, 2), - sub_80A6138(bank), + GetBankSpriteDefault_Y(bank), sub_80A82E4(bank)); gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; @@ -2278,7 +2278,7 @@ static void DoSwitchOutAnimation(void) { case 0: if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -2286,7 +2286,7 @@ static void DoSwitchOutAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); gBattleBankFunc[gActiveBank] = sub_8059744; } break; @@ -2434,7 +2434,7 @@ static void PlayerHandleFaintAnimation(void) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; } else @@ -2442,7 +2442,7 @@ static void PlayerHandleFaintAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; gSprites[gBankSpriteIds[gActiveBank]].data2 = 5; @@ -2462,7 +2462,7 @@ static void PlayerHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; } @@ -2472,7 +2472,7 @@ static void PlayerHandleBallThrowAnim(void) gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; } @@ -2525,7 +2525,7 @@ static void PlayerDoMoveAnimation(void) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) { gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -2544,7 +2544,7 @@ static void PlayerDoMoveAnimation(void) sub_805EB9C(1); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; @@ -2553,7 +2553,7 @@ static void PlayerDoMoveAnimation(void) case 3: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { - sub_805E394(); + CopyAllBattleSpritesInvisibilities(); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; PlayerBufferExecCompleted(); @@ -2709,7 +2709,7 @@ static void PlayerHandleChoosePokemon(void) static void PlayerHandleCmd23(void) { - BattleMusicStop(); + BattleStopLowHpSound(); BeginNormalPaletteFade(-1, 2, 0, 16, 0); PlayerBufferExecCompleted(); } @@ -2788,7 +2788,7 @@ static void PlayerHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBank)) { - DoStatusAnimation(gBattleBufferA[gActiveBank][1], + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; } @@ -2930,7 +2930,7 @@ static void PlayerHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -3088,7 +3088,7 @@ static void PlayerHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) PlayerBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 34fd8a3eb..6ace9121c 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -327,7 +327,7 @@ static void CompleteOnHealthbarDone(void) } else { - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); PlayerPartnerBufferExecCompleted(); } } @@ -469,7 +469,7 @@ static void sub_81BB628(u8 taskId) if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON]) bank ^= BIT_MON; - DoSpecialBattleAnimation(bank, bank, bank, B_ANIM_LVL_UP); + InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP); gTasks[taskId].func = sub_81BB688; } @@ -560,7 +560,7 @@ static void sub_81BB92C(void) { CopyBattleSpriteInvisibility(gActiveBank); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleBankFunc[gActiveBank] = sub_81BB9A0; } @@ -586,7 +586,7 @@ static void sub_81BB9F4(void) FreeSpritePaletteByTag(0x27F9); CreateTask(c3_0802FDF4, 10); - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); sub_8076918(gActiveBank); @@ -1213,7 +1213,7 @@ static void SetPlayerPartnerMonData(u8 monId) break; } - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); } static void PlayerPartnerHandleSetRawMonData(void) @@ -1237,7 +1237,7 @@ static void PlayerPartnerHandleLoadMonSprite(void) gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(gActiveBank, 2), - sub_80A6138(gActiveBank), + GetBankSpriteDefault_Y(gActiveBank), sub_80A82E4(gActiveBank)); gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank; @@ -1268,7 +1268,7 @@ static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit) gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, sub_80A5C6C(bank, 2), - sub_80A6138(bank), + GetBankSpriteDefault_Y(bank), sub_80A82E4(bank)); gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; @@ -1308,7 +1308,7 @@ static void DoSwitchOutAnimation(void) { case 0: if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1316,7 +1316,7 @@ static void DoSwitchOutAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); gBattleBankFunc[gActiveBank] = sub_81BB828; } break; @@ -1395,7 +1395,7 @@ static void PlayerPartnerHandleFaintAnimation(void) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; } else @@ -1403,7 +1403,7 @@ static void PlayerPartnerHandleFaintAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; gSprites[gBankSpriteIds[gActiveBank]].data2 = 5; @@ -1470,7 +1470,7 @@ static void PlayerPartnerDoMoveAnimation(void) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) { gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1489,7 +1489,7 @@ static void PlayerPartnerDoMoveAnimation(void) sub_805EB9C(1); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; @@ -1498,7 +1498,7 @@ static void PlayerPartnerDoMoveAnimation(void) case 3: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { - sub_805E394(); + CopyAllBattleSpritesInvisibilities(); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; PlayerPartnerBufferExecCompleted(); @@ -1661,7 +1661,7 @@ static void PlayerPartnerHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBank)) { - DoStatusAnimation(gBattleBufferA[gActiveBank][1], + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; } @@ -1773,7 +1773,7 @@ static void PlayerPartnerHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -1929,7 +1929,7 @@ static void PlayerPartnerHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) PlayerPartnerBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 0dc7631ce..914ad9c43 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -433,7 +433,7 @@ static void sub_8186D9C(void) { FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - sub_805EEE0(gActiveBank); + EnemyShadowCallbackToSetInvisible(gActiveBank); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); RecordedOpponentBufferExecCompleted(); } @@ -469,7 +469,7 @@ static void sub_8186EA4(void) if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleBankFunc[gActiveBank] = sub_8186F14; } @@ -1149,7 +1149,7 @@ static void RecordedOpponentHandleLoadMonSprite(void) gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(gActiveBank, 2), - sub_80A6138(gActiveBank), + GetBankSpriteDefault_Y(gActiveBank), sub_80A82E4(gActiveBank)); @@ -1184,7 +1184,7 @@ static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit) gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(bank, 2), - sub_80A6138(bank), + GetBankSpriteDefault_Y(bank), sub_80A82E4(bank)); gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; @@ -1213,7 +1213,7 @@ static void RecordedOpponentHandleReturnMonToBall(void) { FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - sub_805EEE0(gActiveBank); + EnemyShadowCallbackToSetInvisible(gActiveBank); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); RecordedOpponentBufferExecCompleted(); } @@ -1225,7 +1225,7 @@ static void DoSwitchOutAnimation(void) { case 0: if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1233,7 +1233,7 @@ static void DoSwitchOutAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); gBattleBankFunc[gActiveBank] = sub_8186D9C; } break; @@ -1314,7 +1314,7 @@ static void RecordedOpponentHandleFaintAnimation(void) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; } else @@ -1386,7 +1386,7 @@ static void RecordedOpponentDoMoveAnimation(void) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) { gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1405,7 +1405,7 @@ static void RecordedOpponentDoMoveAnimation(void) sub_805EB9C(1); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; @@ -1414,7 +1414,7 @@ static void RecordedOpponentDoMoveAnimation(void) case 3: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { - sub_805E394(); + CopyAllBattleSpritesInvisibilities(); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; RecordedOpponentBufferExecCompleted(); @@ -1530,7 +1530,7 @@ static void RecordedOpponentHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBank)) { - DoStatusAnimation(gBattleBufferA[gActiveBank][1], + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; } @@ -1642,7 +1642,7 @@ static void RecordedOpponentHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -1794,7 +1794,7 @@ static void RecordedOpponentHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) RecordedOpponentBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index a3343a391..8db7b5626 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -272,9 +272,9 @@ static void sub_8189AA0(void) FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); if (IsDoubleBattle()) - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; gBattleBankFunc[gActiveBank] = sub_8189A58; @@ -397,7 +397,7 @@ static void CompleteOnHealthbarDone(void) } else { - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); RecordedPlayerBufferExecCompleted(); } } @@ -458,7 +458,7 @@ static void sub_818A2B4(void) { CopyBattleSpriteInvisibility(gActiveBank); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleBankFunc[gActiveBank] = sub_818A328; } @@ -484,7 +484,7 @@ static void sub_818A37C(void) FreeSpritePaletteByTag(0x27F9); CreateTask(c3_0802FDF4, 10); - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); sub_8076918(gActiveBank); @@ -1111,7 +1111,7 @@ static void SetRecordedPlayerMonData(u8 monId) break; } - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); } static void RecordedPlayerHandleSetRawMonData(void) @@ -1135,7 +1135,7 @@ static void RecordedPlayerHandleLoadMonSprite(void) gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(gActiveBank, 2), - sub_80A6138(gActiveBank), + GetBankSpriteDefault_Y(gActiveBank), sub_80A82E4(gActiveBank)); gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank; @@ -1166,7 +1166,7 @@ static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit) gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, sub_80A5C6C(bank, 2), - sub_80A6138(bank), + GetBankSpriteDefault_Y(bank), sub_80A82E4(bank)); gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; @@ -1206,7 +1206,7 @@ static void DoSwitchOutAnimation(void) { case 0: if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1214,7 +1214,7 @@ static void DoSwitchOutAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); gBattleBankFunc[gActiveBank] = sub_818A1B0; } break; @@ -1313,7 +1313,7 @@ static void RecordedPlayerHandleFaintAnimation(void) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; } else @@ -1321,7 +1321,7 @@ static void RecordedPlayerHandleFaintAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); PlaySE12WithPanning(SE_POKE_DEAD, -64); gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; gSprites[gBankSpriteIds[gActiveBank]].data2 = 5; @@ -1388,7 +1388,7 @@ static void RecordedPlayerDoMoveAnimation(void) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) { gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1407,7 +1407,7 @@ static void RecordedPlayerDoMoveAnimation(void) sub_805EB9C(1); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; @@ -1416,7 +1416,7 @@ static void RecordedPlayerDoMoveAnimation(void) case 3: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { - sub_805E394(); + CopyAllBattleSpritesInvisibilities(); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; RecordedPlayerBufferExecCompleted(); @@ -1549,7 +1549,7 @@ static void RecordedPlayerHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBank)) { - DoStatusAnimation(gBattleBufferA[gActiveBank][1], + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; } @@ -1661,7 +1661,7 @@ static void RecordedPlayerHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -1813,7 +1813,7 @@ static void RecordedPlayerHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) RecordedPlayerBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 0c5b698cf..468a92610 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -413,7 +413,7 @@ static void SafariHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; } @@ -423,7 +423,7 @@ static void SafariHandleBallThrowAnim(void) gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; } @@ -624,7 +624,7 @@ static void SafariHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -683,7 +683,7 @@ static void SafariHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) SafariBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index c2addd30c..ec052555a 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -369,7 +369,7 @@ static void sub_8168818(void) FreeSpritePaletteByTag(0x27F9); CreateTask(c3_0802FDF4, 10); - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); WallyBufferExecCompleted(); } @@ -387,7 +387,7 @@ static void CompleteOnHealthbarDone(void) } else { - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); WallyBufferExecCompleted(); } } @@ -1029,7 +1029,7 @@ static void SetWallyMonData(u8 monId) break; } - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); } static void WallyHandleSetRawMonData(void) @@ -1051,7 +1051,7 @@ static void WallyHandleReturnMonToBall(void) { if (gBattleBufferA[gActiveBank][1] == 0) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); gBattleBankFunc[gActiveBank] = sub_8168A20; } else @@ -1112,7 +1112,7 @@ static void WallyHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation; } @@ -1122,7 +1122,7 @@ static void WallyHandleBallThrowAnim(void) gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation; } @@ -1163,7 +1163,7 @@ static void WallyDoMoveAnimation(void) case 0: if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; break; @@ -1182,7 +1182,7 @@ static void WallyDoMoveAnimation(void) sub_805EB9C(1); if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) { - DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); } gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; } @@ -1190,7 +1190,7 @@ static void WallyDoMoveAnimation(void) case 3: if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { - sub_805E394(); + CopyAllBattleSpritesInvisibilities(); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; WallyBufferExecCompleted(); @@ -1429,7 +1429,7 @@ static void WallyHandlePlayFanfareOrBGM(void) { if (gBattleBufferA[gActiveBank][3]) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); } else @@ -1496,7 +1496,7 @@ static void sub_816AA80(u8 bank) sub_806A068(species, GetBankIdentity(bank)); gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, sub_80A5C6C(bank, 2), - sub_80A6138(bank), + GetBankSpriteDefault_Y(bank), sub_80A82E4(bank)); gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; @@ -1565,7 +1565,7 @@ static void WallyHandleBattleAnimation(void) u8 animationId = gBattleBufferA[gActiveBank][1]; u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); - if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) WallyBufferExecCompleted(); else gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; diff --git a/src/battle_dome_cards.c b/src/battle_dome_cards.c index e6c67b20e..9385417b4 100644 --- a/src/battle_dome_cards.c +++ b/src/battle_dome_cards.c @@ -119,7 +119,7 @@ static void sub_818D0C4(u16 species, u32 otId, u32 personality, u8 paletteSlot, if (paletteTag == 0xFFFF) { gUnknown_0203CCEC.paletteTag |= 0xFFFF; - LoadCompressedPalette(species_and_otid_get_pal(species, otId, personality), 0x100 + paletteSlot * 0x10, 0x20); + LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x100 + paletteSlot * 0x10, 0x20); } else { @@ -146,7 +146,7 @@ static void sub_818D180(u16 species, u32 otId, u32 personality, u8 paletteSlot, { if (!isTrainer) { - LoadCompressedPalette(species_and_otid_get_pal(species, otId, personality), paletteSlot * 0x10, 0x20); + LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), paletteSlot * 0x10, 0x20); } else { diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c new file mode 100644 index 000000000..99a82f3ca --- /dev/null +++ b/src/battle_gfx_sfx_util.c @@ -0,0 +1,1299 @@ +#include "global.h" +#include "battle.h" +#include "battle_controllers.h" +#include "battle_ai_script_commands.h" +#include "battle_anim.h" +#include "battle_interface.h" +#include "main.h" +#include "malloc.h" +#include "rng.h" +#include "util.h" +#include "pokemon.h" +#include "moves.h" +#include "task.h" +#include "sprite.h" +#include "sound.h" +#include "m4a.h" +#include "species.h" +#include "decompress.h" +#include "data2.h" +#include "palette.h" +#include "blend_palette.h" +#include "contest.h" +#include "songs.h" + +extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; +extern u8 gActiveBank; +extern u8 gNoOfAllBanks; +extern u16 gUnknown_020243FC; +extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; +extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u8 gBanksByIdentity[BATTLE_BANKS_COUNT]; +extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; +extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern struct MusicPlayerInfo gMPlay_SE1; +extern struct MusicPlayerInfo gMPlay_SE2; +extern struct MusicPlayerInfo gMPlay_BGM; + +extern const struct BattleMove gBattleMoves[]; +extern const u8 gUnknown_0831C604[]; +extern const u8 * const gUnknown_082C9320[]; +extern const u8 * const gUnknown_082C937C[]; +extern const struct CompressedSpriteSheet gMonFrontPicTable[]; +extern const struct CompressedSpriteSheet gMonBackPicTable[]; +extern const struct CompressedSpriteSheet gTrainerFrontPicTable[]; +extern const struct CompressedSpriteSheet gTrainerBackPicTable[]; +extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; +extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[]; +extern const union AnimCmd* const * const gMonAnimationsSpriteAnimsPtrTable[]; +extern const struct SpriteTemplate gUnknown_08329D98[4]; +extern const struct CompressedSpriteSheet gSpriteSheet_EnemyShadow; +extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow; +extern const u8 gEnemyMonElevation[]; + +// graphics +extern const u32 gUnknown_08C093F0[]; +extern const u32 gSubstituteDollTilemap[]; +extern const u32 gSubstituteDollGfx[]; +extern const u16 gSubstituteDollPal[]; +extern const u8 gUnknown_08C1F1C8[]; +extern const u8 gUnknown_08C1F46C[]; +extern const u8 gUnknown_08C1F5E8[]; +extern const u8 gUnknown_08C1F76C[]; +extern const u8 gUnknown_08C1F8E8[]; +extern const u8 gUnknown_08C0237C[]; +extern const u16 gBattleInterface_BallStatusBarPal[]; +extern const u16 gBattleInterface_BallDisplayPal[]; + +extern u8 sub_80688F8(u8, u8 bank); +extern u8 pokemon_order_func(u8); // party menu +extern void sub_81B8C68(void); + +// this file's functions +static u8 sub_805D4A8(u16 move); +static u16 BattlePalaceGetTargetRetValue(void); +static void sub_805D7EC(struct Sprite *sprite); +static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId); +static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId); +static void Task_ClearBitWhenSpecialAnimDone(u8 taskId); +static void ClearSpritesBankHealthboxAnimData(void); + +// const rom data +static const struct CompressedSpriteSheet gUnknown_0832C0D0 = +{ + gUnknown_08C1F1C8, 0x1000, TAG_HEALTHBOX_PLAYER1_TILE +}; + +static const struct CompressedSpriteSheet gUnknown_0832C0D8 = +{ + gUnknown_08C1F46C, 0x1000, TAG_HEALTHBOX_OPPONENT1_TILE +}; + +static const struct CompressedSpriteSheet gUnknown_0832C0E0[2] = +{ + {gUnknown_08C1F5E8, 0x800, TAG_HEALTHBOX_PLAYER1_TILE}, + {gUnknown_08C1F5E8, 0x800, TAG_HEALTHBOX_PLAYER2_TILE} +}; + +static const struct CompressedSpriteSheet gUnknown_0832C0F0[2] = +{ + {gUnknown_08C1F76C, 0x800, TAG_HEALTHBOX_OPPONENT1_TILE}, + {gUnknown_08C1F76C, 0x800, TAG_HEALTHBOX_OPPONENT2_TILE} +}; + +static const struct CompressedSpriteSheet gUnknown_0832C100 = +{ + gUnknown_08C1F8E8, 0x1000, TAG_HEALTHBOX_SAFARI_TILE +}; + +static const struct CompressedSpriteSheet gUnknown_0832C108[BATTLE_BANKS_COUNT] = +{ + {gUnknown_08C0237C, 0x0100, 0xd704}, + {gUnknown_08C0237C, 0x0120, 0xd705}, + {gUnknown_08C0237C, 0x0100, 0xd706}, + {gUnknown_08C0237C, 0x0120, 0xd707} +}; + +static const struct SpritePalette gUnknown_0832C128[2] = +{ + {gBattleInterface_BallStatusBarPal, TAG_HEALTHBOX_PAL}, + {gBattleInterface_BallDisplayPal, 0xd704} +}; + +// code +void AllocateBattleSpritesData(void) +{ + gBattleSpritesDataPtr = AllocZeroed(sizeof(struct BattleSpriteData)); + gBattleSpritesDataPtr->bankData = AllocZeroed(sizeof(struct BattleSpriteInfo) * BATTLE_BANKS_COUNT); + gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * BATTLE_BANKS_COUNT); + gBattleSpritesDataPtr->animationData = AllocZeroed(sizeof(struct BattleAnimationInfo)); + gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * BATTLE_BANKS_COUNT); +} + +void FreeBattleSpritesData(void) +{ + if (gBattleSpritesDataPtr == NULL) + return; + + FREE_AND_SET_NULL(gBattleSpritesDataPtr->battleBars); + FREE_AND_SET_NULL(gBattleSpritesDataPtr->animationData); + FREE_AND_SET_NULL(gBattleSpritesDataPtr->healthBoxesData); + FREE_AND_SET_NULL(gBattleSpritesDataPtr->bankData); + FREE_AND_SET_NULL(gBattleSpritesDataPtr); +} + +u16 ChooseMoveAndTargetInBattlePalace(void) +{ + s32 i, var1, var2; + s32 chosenMoveId = -1; + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + u8 unusableMovesBits = CheckMoveLimitations(gActiveBank, 0, 0xFF); + s32 percent = Random() % 100; + + i = (gBattleStruct->field_92 & gBitTable[gActiveBank]) ? 2 : 0; + var2 = i; + var1 = i + 2; + + for (; i < var1; i++) + { + if (gUnknown_0831C494[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)][i] > percent) + break; + } + + percent = i - var2; + if (i == var1) + percent = 2; + + for (var2 = 0, i = 0; i < 4; i++) + { + if (moveInfo->moves[i] == MOVE_NONE) + break; + if (percent == sub_805D4A8(moveInfo->moves[i]) && moveInfo->currentPp[i] != 0) + var2 |= gBitTable[i]; + } + + if (var2 != 0) + { + gBattleStruct->field_92 &= 0xF; + gBattleStruct->field_92 |= (var2 << 4); + BattleAI_SetupAIData(var2); + chosenMoveId = BattleAI_ChooseMoveOrAction(); + } + + if (chosenMoveId == -1) + { + if (unusableMovesBits != 0xF) + { + var1 = 0, var2 = 0; + + for (i = 0; i < 4; i++) + { + if (sub_805D4A8(moveInfo->moves[i]) == 0 && !(gBitTable[i] & unusableMovesBits)) + var1 += 0x1; + if (sub_805D4A8(moveInfo->moves[i]) == 1 && !(gBitTable[i] & unusableMovesBits)) + var1 += 0x10; + if (sub_805D4A8(moveInfo->moves[i]) == 2 && !(gBitTable[i] & unusableMovesBits)) + var1 += 0x100; + } + + if ((var1 & 0xF) > 1) + var2++; + if ((var1 & 0xF0) > 0x1F) + var2++; + if ((var1 & 0xF0) > 0x1FF) + var2++; + + if (var2 > 1 || var2 == 0) + { + do + { + i = Random() % 4; + if (!(gBitTable[i] & unusableMovesBits)) + chosenMoveId = i; + } while (chosenMoveId == -1); + } + else + { + if ((var1 & 0xF) > 1) + var2 = 0; + if ((var1 & 0xF0) > 0x1F) + var2 = 1; + if ((var1 & 0xF0) > 0x1FF) + var2 = 2; + + do + { + i = Random() % 4; + if (!(gBitTable[i] & unusableMovesBits) && var2 == sub_805D4A8(moveInfo->moves[i])) + chosenMoveId = i; + } while (chosenMoveId == -1); + } + + if (Random() % 100 > 49) + { + gProtectStructs[gActiveBank].flag_x10 = 1; + return 0; + } + } + else + { + gProtectStructs[gActiveBank].flag_x10 = 1; + return 0; + } + } + + if (moveInfo->moves[chosenMoveId] == MOVE_CURSE) + { + if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST) + var1 = MOVE_TARGET_x10; + else + var1 = MOVE_TARGET_SELECTED; + } + else + { + var1 = gBattleMoves[moveInfo->moves[chosenMoveId]].target; + } + + if (var1 & MOVE_TARGET_x10) + chosenMoveId |= (gActiveBank << 8); + else if (var1 == MOVE_TARGET_SELECTED) + chosenMoveId |= (BattlePalaceGetTargetRetValue()); + else + chosenMoveId |= (GetBankByIdentity((GetBankIdentity(gActiveBank) & BIT_SIDE) ^ BIT_SIDE) << 8); + + return chosenMoveId; +} + +static u8 sub_805D4A8(u16 move) +{ + switch (gBattleMoves[move].target) + { + case MOVE_TARGET_SELECTED: + case MOVE_TARGET_USER: + case MOVE_TARGET_RANDOM: + case MOVE_TARGET_BOTH: + case MOVE_TARGET_FOES_AND_ALLY: + if (gBattleMoves[move].power == 0) + return 2; + else + return 0; + break; + case MOVE_TARGET_DEPENDS: + case MOVE_TARGET_OPPONENTS_FIELD: + return 2; + case MOVE_TARGET_x10: + return 1; + default: + return 0; + } +} + +static u16 BattlePalaceGetTargetRetValue(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + u8 opposing1, opposing2; + + if (GetBankSide(gActiveBank) == SIDE_PLAYER) + { + opposing1 = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + opposing2 = GetBankByIdentity(IDENTITY_OPPONENT_MON2); + } + else + { + opposing1 = GetBankByIdentity(IDENTITY_PLAYER_MON1); + opposing2 = GetBankByIdentity(IDENTITY_PLAYER_MON2); + } + + if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp) + return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; + + switch (gUnknown_0831C604[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)]) + { + case 0: + if (gBattleMons[opposing1].hp > gBattleMons[opposing2].hp) + return opposing1 << 8; + else + return opposing2 << 8; + case 1: + if (gBattleMons[opposing1].hp < gBattleMons[opposing2].hp) + return opposing1 << 8; + else + return opposing2 << 8; + case 2: + return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; + } + } + + return (gActiveBank ^ BIT_SIDE) << 8; +} + +void sub_805D714(struct Sprite *sprite) +{ + u8 spriteId = sprite->data1; + + if (!gSprites[spriteId].affineAnimEnded) + return; + if (gSprites[spriteId].invisible) + return; + + if (gSprites[spriteId].animPaused) + { + gSprites[spriteId].animPaused = 0; + } + else + { + if (gSprites[spriteId].animEnded) + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_805D770(struct Sprite *sprite, bool8 arg1) +{ + sprite->animPaused = 1; + sprite->callback = SpriteCallbackDummy; + + if (!arg1) + StartSpriteAffineAnim(sprite, 1); + else + StartSpriteAffineAnim(sprite, 1); + + AnimateSprite(sprite); +} + +void sub_805D7AC(struct Sprite *sprite) +{ + if (!(gUnknown_020243FC & 1)) + { + sprite->pos2.x += sprite->data0; + if (sprite->pos2.x == 0) + { + if (sprite->pos2.y != 0) + sprite->callback = sub_805D7EC; + else + sprite->callback = SpriteCallbackDummy; + } + } +} + +static void sub_805D7EC(struct Sprite *sprite) +{ + sprite->pos2.y -= 2; + if (sprite->pos2.y == 0) + sprite->callback = SpriteCallbackDummy; +} + +void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status) +{ + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 1; + if (!isStatus2) + { + if (status == STATUS_FREEZE) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_FRZ); + else if (status == STATUS_POISON || status & STATUS_TOXIC_POISON) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_PSN); + else if (status == STATUS_BURN) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_BRN); + else if (status & STATUS_SLEEP) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_SLP); + else if (status == STATUS_PARALYSIS) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_PRZ); + else // no animation + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 0; + } + else + { + if (status & STATUS2_INFATUATION) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_INFATUATION); + else if (status & STATUS2_CONFUSION) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_CONFUSION); + else if (status & STATUS2_CURSED) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_CURSED); + else if (status & STATUS2_NIGHTMARE) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_NIGHTMARE); + else if (status & STATUS2_WRAPPED) + LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_WRAPPED); + else // no animation + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 0; + } +} + +#define tBank data[0] + +bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId, u16 argument) +{ + u8 taskId; + + if (tableId == B_ANIM_CASTFORM_CHANGE && (argument & 0x80)) + { + gBattleMonForms[activeBank] = (argument & ~(0x80)); + return TRUE; + } + if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute + && !ShouldAnimBeDoneRegardlessOfSubsitute(tableId)) + { + return TRUE; + } + if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute + && tableId == B_ANIM_SUBSTITUTE_FADE + && gSprites[gBankSpriteIds[activeBank]].invisible) + { + LoadBattleMonGfxAndAnimate(activeBank, TRUE, gBankSpriteIds[activeBank]); + ClearBehindSubstituteBit(activeBank); + return TRUE; + } + + gAnimBankAttacker = atkBank; + gAnimBankTarget = defBank; + gBattleSpritesDataPtr->animationData->animArg = argument; + LaunchBattleAnimation(gUnknown_082C9320, tableId, FALSE); + taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10); + gTasks[taskId].tBank = activeBank; + gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].animFromTableActive = 1; + + return FALSE; +} + +static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId) +{ + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].animFromTableActive = 0; + DestroyTask(taskId); + } +} + +#undef tBank + +static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId) +{ + switch (animId) + { + case B_ANIM_SUBSTITUTE_FADE: + case B_ANIM_RAIN_CONTINUES: + case B_ANIM_SUN_CONTINUES: + case B_ANIM_SANDSTORM_CONTINUES: + case B_ANIM_HAIL_CONTINUES: + case B_ANIM_SNATCH_MOVE: + return TRUE; + default: + return FALSE; + } +} + +#define tBank data[0] + +void InitAndLaunchSpecialAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId) +{ + u8 taskId; + + gAnimBankAttacker = atkBank; + gAnimBankTarget = defBank; + LaunchBattleAnimation(gUnknown_082C937C, tableId, FALSE); + taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10); + gTasks[taskId].tBank = activeBank; + gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].specialAnimActive = 1; +} + +static void Task_ClearBitWhenSpecialAnimDone(u8 taskId) +{ + gAnimScriptCallback(); + if (!gAnimScriptActive) + { + gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBank].specialAnimActive = 0; + DestroyTask(taskId); + } +} + +#undef tBank + +// great function to include newly added moves that don't have animation yet +bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn) +{ + return FALSE; +} + +bool8 mplay_80342A4(u8 bank) +{ + u8 zero = 0; + + if (IsSEPlaying()) + { + gBattleSpritesDataPtr->healthBoxesData[bank].field_8++; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_8 < 30) + return TRUE; + + m4aMPlayStop(&gMPlay_SE1); + m4aMPlayStop(&gMPlay_SE2); + } + if (zero == 0) + { + gBattleSpritesDataPtr->healthBoxesData[bank].field_8 = 0; + return FALSE; + } + + return TRUE; +} + +void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank) +{ + u32 monsPersonality, currentPersonality, otId; + u16 species; + u8 identity; + u16 paletteOffset; + const void *lzPaletteData; + + monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY); + + if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) + { + species = GetMonData(mon, MON_DATA_SPECIES); + currentPersonality = monsPersonality; + } + else + { + species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; + currentPersonality = gTransformedPersonalities[bank]; + } + + otId = GetMonData(mon, MON_DATA_OT_ID); + identity = GetBankIdentity(bank); + HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], + gMonSpritesGfxPtr->sprites[identity], + species, currentPersonality); + + paletteOffset = 0x100 + bank * 16; + + if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) + lzPaletteData = GetMonFrontSpritePal(mon); + else + lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality); + + LZDecompressWram(lzPaletteData, gDecompressionBuffer); + LoadPalette(gDecompressionBuffer, paletteOffset, 0x20); + LoadPalette(gDecompressionBuffer, 0x80 + bank * 16, 0x20); + + if (species == SPECIES_CASTFORM) + { + paletteOffset = 0x100 + bank * 16; + LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]); + LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[bank]], paletteOffset, 0x20); + } + + // transform's pink color + if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) + { + BlendPalette(paletteOffset, 16, 6, 0x7FFF); + CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); + } +} + +void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank) +{ + u32 monsPersonality, currentPersonality, otId; + u16 species; + u8 identity; + u16 paletteOffset; + const void *lzPaletteData; + + monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY); + + if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) + { + species = GetMonData(mon, MON_DATA_SPECIES); + currentPersonality = monsPersonality; + } + else + { + species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; + currentPersonality = gTransformedPersonalities[bank]; + } + + otId = GetMonData(mon, MON_DATA_OT_ID); + identity = GetBankIdentity(bank); + + if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) + { + HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species], + gMonSpritesGfxPtr->sprites[identity], + species, currentPersonality); + } + else + { + HandleLoadSpecialPokePic(&gMonBackPicTable[species], + gMonSpritesGfxPtr->sprites[identity], + species, currentPersonality); + } + + paletteOffset = 0x100 + bank * 16; + + if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) + lzPaletteData = GetMonFrontSpritePal(mon); + else + lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality); + + LZDecompressWram(lzPaletteData, gDecompressionBuffer); + LoadPalette(gDecompressionBuffer, paletteOffset, 0x20); + LoadPalette(gDecompressionBuffer, 0x80 + bank * 16, 0x20); + + if (species == SPECIES_CASTFORM) + { + paletteOffset = 0x100 + bank * 16; + LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]); + LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[bank]], paletteOffset, 0x20); + } + + // transform's pink color + if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) + { + BlendPalette(paletteOffset, 16, 6, 0x7FFF); + CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); + } +} + +void nullsub_23(void) +{ +} + +void nullsub_24(u16 species) +{ +} + +void DecompressTrainerFrontPic(u16 frontPicId, u8 bank) +{ + u8 identity = GetBankIdentity(bank); + DecompressPicFromTable_2(&gTrainerFrontPicTable[frontPicId], + gMonSpritesGfxPtr->sprites[identity], + SPECIES_NONE); + LoadCompressedObjectPalette(&gTrainerFrontPicPaletteTable[frontPicId]); +} + +void DecompressTrainerBackPic(u16 backPicId, u8 bank) +{ + u8 identity = GetBankIdentity(bank); + DecompressPicFromTable_2(&gTrainerBackPicTable[backPicId], + gMonSpritesGfxPtr->sprites[identity], + SPECIES_NONE); + LoadCompressedPalette(gTrainerBackPicPaletteTable[backPicId].data, + 0x100 + 16 * bank, 0x20); +} + +void nullsub_25(u8 arg0) +{ +} + +void FreeTrainerFrontPicPalette(u16 frontPicId) +{ + FreeSpritePaletteByTag(gTrainerFrontPicPaletteTable[frontPicId].tag); +} + +void sub_805DFFC(void) +{ + u8 numberOfBanks = 0; + u8 i; + + LoadSpritePalette(&gUnknown_0832C128[0]); + LoadSpritePalette(&gUnknown_0832C128[1]); + if (!IsDoubleBattle()) + { + LoadCompressedObjectPic(&gUnknown_0832C0D0); + LoadCompressedObjectPic(&gUnknown_0832C0D8); + numberOfBanks = 2; + } + else + { + LoadCompressedObjectPic(&gUnknown_0832C0E0[0]); + LoadCompressedObjectPic(&gUnknown_0832C0E0[1]); + LoadCompressedObjectPic(&gUnknown_0832C0F0[0]); + LoadCompressedObjectPic(&gUnknown_0832C0F0[1]); + numberOfBanks = 4; + } + for (i = 0; i < numberOfBanks; i++) + LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[i]]); +} + +bool8 BattleLoadAllHealthBoxesGfx(u8 state) +{ + bool8 retVal = FALSE; + + if (state != 0) + { + if (state == 1) + { + LoadSpritePalette(&gUnknown_0832C128[0]); + LoadSpritePalette(&gUnknown_0832C128[1]); + } + else if (!IsDoubleBattle()) + { + if (state == 2) + { + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + LoadCompressedObjectPic(&gUnknown_0832C100); + else + LoadCompressedObjectPic(&gUnknown_0832C0D0); + } + else if (state == 3) + LoadCompressedObjectPic(&gUnknown_0832C0D8); + else if (state == 4) + LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[0]]); + else if (state == 5) + LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[1]]); + else + retVal = TRUE; + } + else + { + if (state == 2) + LoadCompressedObjectPic(&gUnknown_0832C0E0[0]); + else if (state == 3) + LoadCompressedObjectPic(&gUnknown_0832C0E0[1]); + else if (state == 4) + LoadCompressedObjectPic(&gUnknown_0832C0F0[0]); + else if (state == 5) + LoadCompressedObjectPic(&gUnknown_0832C0F0[1]); + else if (state == 6) + LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[0]]); + else if (state == 7) + LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[1]]); + else if (state == 8) + LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[2]]); + else if (state == 9) + LoadCompressedObjectPic(&gUnknown_0832C108[gBanksByIdentity[3]]); + else + retVal = TRUE; + } + } + + return retVal; +} + +void LoadBattleBarGfx(u8 arg0) +{ + LZDecompressWram(gUnknown_08C093F0, gMonSpritesGfxPtr->barFontGfx); +} + +bool8 BattleInitAllSprites(u8 *state1, u8 *bank) +{ + bool8 retVal = FALSE; + + switch (*state1) + { + case 0: + ClearSpritesBankHealthboxAnimData(); + (*state1)++; + break; + case 1: + if (!BattleLoadAllHealthBoxesGfx(*bank)) + { + (*bank)++; + } + else + { + *bank = 0; + (*state1)++; + } + break; + case 2: + (*state1)++; + break; + case 3: + if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *bank == 0) + gHealthBoxesIds[*bank] = CreateSafariPlayerHealthboxSprites(); + else + gHealthBoxesIds[*bank] = CreateBankHealthboxSprites(*bank); + + (*bank)++; + if (*bank == gNoOfAllBanks) + { + *bank = 0; + (*state1)++; + } + break; + case 4: + SetBankHealthboxSpritePos(*bank); + if (gBanksByIdentity[*bank] <= 1) + DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], FALSE); + else + DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], TRUE); + + (*bank)++; + if (*bank == gNoOfAllBanks) + { + *bank = 0; + (*state1)++; + } + break; + case 5: + if (GetBankSide(*bank) == SIDE_PLAYER) + { + if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) + UpdateHealthboxAttribute(gHealthBoxesIds[*bank], &gPlayerParty[gBattlePartyID[*bank]], HEALTHBOX_ALL); + } + else + { + UpdateHealthboxAttribute(gHealthBoxesIds[*bank], &gEnemyParty[gBattlePartyID[*bank]], HEALTHBOX_ALL); + } + SetHealthboxSpriteInvisible(gHealthBoxesIds[*bank]); + (*bank)++; + if (*bank == gNoOfAllBanks) + { + *bank = 0; + (*state1)++; + } + break; + case 6: + LoadAndCreateEnemyShadowSprites(); + sub_81B8C68(); + retVal = TRUE; + break; + } + + return retVal; +} + +void ClearSpritesHealthboxAnimData(void) +{ + memset(gBattleSpritesDataPtr->healthBoxesData, 0, sizeof(struct BattleHealthboxInfo) * BATTLE_BANKS_COUNT); + memset(gBattleSpritesDataPtr->animationData, 0, sizeof(struct BattleAnimationInfo)); +} + +static void ClearSpritesBankHealthboxAnimData(void) +{ + ClearSpritesHealthboxAnimData(); + memset(gBattleSpritesDataPtr->bankData, 0, sizeof(struct BattleSpriteInfo) * BATTLE_BANKS_COUNT); +} + +void CopyAllBattleSpritesInvisibilities(void) +{ + s32 i; + + for (i = 0; i < gNoOfAllBanks; i++) + gBattleSpritesDataPtr->bankData[i].invisible = gSprites[gBankSpriteIds[i]].invisible; +} + +void CopyBattleSpriteInvisibility(u8 bank) +{ + gBattleSpritesDataPtr->bankData[bank].invisible = gSprites[gBankSpriteIds[bank]].invisible; +} + +void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform) +{ + u16 paletteOffset; + u32 personalityValue; + u32 otId; + u8 identity; + const u8 *lzPaletteData; + + if (notTransform) + { + StartSpriteAnim(&gSprites[gBankSpriteIds[bankAtk]], gBattleSpritesDataPtr->animationData->animArg); + paletteOffset = 0x100 + bankAtk * 16; + LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32); + gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg; + if (gBattleSpritesDataPtr->bankData[bankAtk].transformSpecies != SPECIES_NONE) + { + BlendPalette(paletteOffset, 16, 6, 0x7FFF); + CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); + } + gSprites[gBankSpriteIds[bankAtk]].pos1.y = GetBankSpriteDefault_Y(bankAtk); + } + else + { + const void *src; + void *dst; + u16 targetSpecies; + + if (IsContest()) + { + identity = 0; + targetSpecies = gContestResources->field_18->field_2; + personalityValue = gContestResources->field_18->field_8; + otId = gContestResources->field_18->field_C; + + HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies], + gMonSpritesGfxPtr->sprites[0], + targetSpecies, + gContestResources->field_18->field_10); + } + else + { + identity = GetBankIdentity(bankAtk); + + if (GetBankSide(bankDef) == SIDE_OPPONENT) + targetSpecies = GetMonData(&gEnemyParty[gBattlePartyID[bankDef]], MON_DATA_SPECIES); + else + targetSpecies = GetMonData(&gPlayerParty[gBattlePartyID[bankDef]], MON_DATA_SPECIES); + + if (GetBankSide(bankAtk) == SIDE_PLAYER) + { + personalityValue = GetMonData(&gPlayerParty[gBattlePartyID[bankAtk]], MON_DATA_PERSONALITY); + otId = GetMonData(&gPlayerParty[gBattlePartyID[bankAtk]], MON_DATA_OT_ID); + + HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies], + gMonSpritesGfxPtr->sprites[identity], + targetSpecies, + gTransformedPersonalities[bankAtk]); + } + else + { + personalityValue = GetMonData(&gEnemyParty[gBattlePartyID[bankAtk]], MON_DATA_PERSONALITY); + otId = GetMonData(&gEnemyParty[gBattlePartyID[bankAtk]], MON_DATA_OT_ID); + + HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[targetSpecies], + gMonSpritesGfxPtr->sprites[identity], + targetSpecies, + gTransformedPersonalities[bankAtk]); + } + } + + src = gMonSpritesGfxPtr->sprites[identity]; + dst = (void *)(VRAM + 0x10000 + gSprites[gBankSpriteIds[bankAtk]].oam.tileNum * 32); + DmaCopy32(3, src, dst, 0x800); + paletteOffset = 0x100 + bankAtk * 16; + lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue); + LZDecompressWram(lzPaletteData, gDecompressionBuffer); + LoadPalette(gDecompressionBuffer, paletteOffset, 32); + + if (targetSpecies == SPECIES_CASTFORM) + { + gSprites[gBankSpriteIds[bankAtk]].anims = gMonAnimationsSpriteAnimsPtrTable[targetSpecies]; + LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]); + LoadPalette(gBattleStruct->castformPalette[0] + gBattleMonForms[bankDef] * 16, paletteOffset, 32); + } + + BlendPalette(paletteOffset, 16, 6, 0x7FFF); + CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); + + if (!IsContest()) + { + gBattleSpritesDataPtr->bankData[bankAtk].transformSpecies = targetSpecies; + gBattleMonForms[bankAtk] = gBattleMonForms[bankDef]; + } + + gSprites[gBankSpriteIds[bankAtk]].pos1.y = GetBankSpriteDefault_Y(bankAtk); + StartSpriteAnim(&gSprites[gBankSpriteIds[bankAtk]], gBattleMonForms[bankAtk]); + } +} + +void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite) +{ + u8 identity; + s32 i; + u32 var; + const void *substitutePal; + + if (!loadMonSprite) + { + if (IsContest()) + identity = 0; + else + identity = GetBankIdentity(bank); + + if (IsContest()) + LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[identity]); + else if (GetBankSide(bank) != SIDE_PLAYER) + LZDecompressVram(gSubstituteDollGfx, gMonSpritesGfxPtr->sprites[identity]); + else + LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[identity]); + + i = 1; + var = bank * 16; + substitutePal = gSubstituteDollPal; + for (; i < 4; i++) + { + register void *dmaSrc asm("r0") = gMonSpritesGfxPtr->sprites[identity]; + void *dmaDst = (i * 0x800) + dmaSrc; + u32 dmaSize = 0x800; + DmaCopy32(3, dmaSrc, dmaDst, dmaSize); + i++;i--; + } + + LoadCompressedPalette(substitutePal, 0x100 + var, 32); + } + else + { + if (!IsContest()) + { + if (GetBankSide(bank) != SIDE_PLAYER) + BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); + else + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank); + } + } +} + +void LoadBattleMonGfxAndAnimate(u8 bank, bool8 loadMonSprite, u8 spriteId) +{ + BattleLoadSubstituteOrMonSpriteGfx(bank, loadMonSprite); + StartSpriteAnim(&gSprites[spriteId], gBattleMonForms[bank]); + + if (!loadMonSprite) + gSprites[spriteId].pos1.y = GetSubstituteSpriteDefault_Y(bank); + else + gSprites[spriteId].pos1.y = GetBankSpriteDefault_Y(bank); +} + +void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move) +{ + if (move == MOVE_SUBSTITUTE) + gBattleSpritesDataPtr->bankData[bank].behindSubstitute = 1; +} + +void ClearBehindSubstituteBit(u8 bank) +{ + gBattleSpritesDataPtr->bankData[bank].behindSubstitute = 0; +} + +void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank) +{ + u16 hp = GetMonData(mon, MON_DATA_HP); + u16 maxHP = GetMonData(mon, MON_DATA_MAX_HP); + + if (GetHPBarLevel(hp, maxHP) == HP_BAR_RED) + { + if (!gBattleSpritesDataPtr->bankData[bank].lowHpSong) + { + if (!gBattleSpritesDataPtr->bankData[bank ^ BIT_MON].lowHpSong) + PlaySE(SE_HINSI); + gBattleSpritesDataPtr->bankData[bank].lowHpSong = 1; + } + } + else + { + gBattleSpritesDataPtr->bankData[bank].lowHpSong = 0; + if (!IsDoubleBattle()) + { + m4aSongNumStop(SE_HINSI); + return; + } + if (IsDoubleBattle() && !gBattleSpritesDataPtr->bankData[bank ^ BIT_MON].lowHpSong) + { + m4aSongNumStop(SE_HINSI); + return; + } + } +} + +void BattleStopLowHpSound(void) +{ + u8 playerBank = GetBankByIdentity(IDENTITY_PLAYER_MON1); + + gBattleSpritesDataPtr->bankData[playerBank].lowHpSong = 0; + if (IsDoubleBattle()) + gBattleSpritesDataPtr->bankData[playerBank ^ BIT_MON].lowHpSong = 0; + + m4aSongNumStop(SE_HINSI); +} + +u8 GetMonHPBarLevel(struct Pokemon *mon) +{ + u16 hp = GetMonData(mon, MON_DATA_HP); + u16 maxHP = GetMonData(mon, MON_DATA_MAX_HP); + + return GetHPBarLevel(hp, maxHP); +} + +void sub_805EAE8(void) +{ + if (gMain.inBattle) + { + u8 playerBank1 = GetBankByIdentity(IDENTITY_PLAYER_MON1); + u8 playerBank2 = GetBankByIdentity(IDENTITY_PLAYER_MON2); + u8 bank1PartyId = pokemon_order_func(gBattlePartyID[playerBank1]); + u8 bank2PartyId = pokemon_order_func(gBattlePartyID[playerBank2]); + + if (GetMonData(&gPlayerParty[bank1PartyId], MON_DATA_HP) != 0) + HandleLowHpMusicChange(&gPlayerParty[bank1PartyId], playerBank1); + if (IsDoubleBattle() && GetMonData(&gPlayerParty[bank2PartyId], MON_DATA_HP) != 0) + HandleLowHpMusicChange(&gPlayerParty[bank2PartyId], playerBank2); + } +} + +void sub_805EB9C(u8 affineMode) +{ + s32 i; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (IsBankSpritePresent(i)) + { + gSprites[gBankSpriteIds[i]].oam.affineMode = affineMode; + if (affineMode == 0) + { + gBattleSpritesDataPtr->healthBoxesData[i].field_6 = gSprites[gBankSpriteIds[i]].oam.matrixNum; + gSprites[gBankSpriteIds[i]].oam.matrixNum = 0; + } + else + { + gSprites[gBankSpriteIds[i]].oam.matrixNum = gBattleSpritesDataPtr->healthBoxesData[i].field_6; + } + } + } +} + +#define tBank data0 + +void LoadAndCreateEnemyShadowSprites(void) +{ + u8 bank; + + LoadCompressedObjectPic(&gSpriteSheet_EnemyShadow); + + bank = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, sub_80A5C6C(bank, 0), sub_80A5C6C(bank, 1) + 29, 0xC8); + gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data0 = bank; + + if (IsDoubleBattle()) + { + bank = GetBankByIdentity(IDENTITY_OPPONENT_MON2); + gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, sub_80A5C6C(bank, 0), sub_80A5C6C(bank, 1) + 29, 0xC8); + gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data0 = bank; + } +} + +void SpriteCB_EnemyShadow(struct Sprite *shadowSprite) +{ + bool8 invisible = FALSE; + u8 bank = shadowSprite->tBank; + struct Sprite *bankSprite = &gSprites[gBankSpriteIds[bank]]; + + if (!bankSprite->inUse || !IsBankSpritePresent(bank)) + { + shadowSprite->callback = SpriteCB_SetInvisible; + return; + } + if (gAnimScriptActive || bankSprite->invisible) + invisible = TRUE; + else if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE + && gEnemyMonElevation[gBattleSpritesDataPtr->bankData[bank].transformSpecies] == 0) + invisible = TRUE; + + if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute) + invisible = TRUE; + + shadowSprite->pos1.x = bankSprite->pos1.x; + shadowSprite->pos2.x = bankSprite->pos2.x; + shadowSprite->invisible = invisible; +} + +#undef tBank + +void SpriteCB_SetInvisible(struct Sprite *sprite) +{ + sprite->invisible = 1; +} + +void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species) +{ + if (GetBankSide(bank) == SIDE_PLAYER) + return; + + if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) + species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; + + if (gEnemyMonElevation[species] != 0) + gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_EnemyShadow; + else + gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible; +} + +void EnemyShadowCallbackToSetInvisible(u8 bank) +{ + gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible; +} + +void sub_805EF14(void) +{ + u16 *vramPtr = (u16*)(VRAM + 0x240); + s32 i; + s32 j; + + for (i = 0; i < 9; i++) + { + for (j = 0; j < 16; j++) + { + if (!(*vramPtr & 0xF000)) + *vramPtr |= 0xF000; + if (!(*vramPtr & 0x0F00)) + *vramPtr |= 0x0F00; + if (!(*vramPtr & 0x00F0)) + *vramPtr |= 0x00F0; + if (!(*vramPtr & 0x000F)) + *vramPtr |= 0x000F; + vramPtr++; + } + } +} + +void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute) +{ + gBattleSpritesDataPtr->bankData[bank].transformSpecies = SPECIES_NONE; + gBattleMonForms[bank] = 0; + if (!dontClearSubstitute) + ClearBehindSubstituteBit(bank); +} + +void AllocateMonSpritesGfx(void) +{ + u8 i = 0, j; + + gMonSpritesGfxPtr = NULL; + gMonSpritesGfxPtr = AllocZeroed(sizeof(*gMonSpritesGfxPtr)); + gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x8000); + + for (i = 0; i < BATTLE_BANKS_COUNT; i++) + { + gMonSpritesGfxPtr->sprites[i] = gMonSpritesGfxPtr->firstDecompressed + (i * 0x2000); + *(gMonSpritesGfxPtr->templates + i) = gUnknown_08329D98[i]; + + for (j = 0; j < 4; j++) + { + gMonSpritesGfxPtr->field_74[i][j].data = gMonSpritesGfxPtr->sprites[i] + (j * 0x800); + gMonSpritesGfxPtr->field_74[i][j].size = 0x800; + } + + gMonSpritesGfxPtr->templates[i].images = gMonSpritesGfxPtr->field_74[i]; + } + + gMonSpritesGfxPtr->barFontGfx = AllocZeroed(0x1000); +} + +void FreeMonSpritesGfx(void) +{ + if (gMonSpritesGfxPtr == NULL) + return; + + if (gMonSpritesGfxPtr->field_17C != NULL) + FREE_AND_SET_NULL(gMonSpritesGfxPtr->field_17C); + if (gMonSpritesGfxPtr->field_178 != NULL) + FREE_AND_SET_NULL(gMonSpritesGfxPtr->field_178); + + FREE_AND_SET_NULL(gMonSpritesGfxPtr->barFontGfx); + FREE_AND_SET_NULL(gMonSpritesGfxPtr->firstDecompressed); + gMonSpritesGfxPtr->sprites[0] = NULL; + gMonSpritesGfxPtr->sprites[1] = NULL; + gMonSpritesGfxPtr->sprites[2] = NULL; + gMonSpritesGfxPtr->sprites[3] = NULL; + FREE_AND_SET_NULL(gMonSpritesGfxPtr); +} + +bool32 ShouldPlayNormalPokeCry(struct Pokemon *mon) +{ + s16 hp, maxHP; + s32 barLevel; + + if (GetMonData(mon, MON_DATA_STATUS) & (STATUS_ANY | STATUS_TOXIC_COUNTER)) + return FALSE; + + hp = GetMonData(mon, MON_DATA_HP); + maxHP = GetMonData(mon, MON_DATA_MAX_HP); + + barLevel = GetHPBarLevel(hp, maxHP); + if (barLevel <= HP_BAR_YELLOW) + return FALSE; + + return TRUE; +} diff --git a/src/battle_interface.c b/src/battle_interface.c index 5f582a366..811751ca3 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -2545,19 +2545,19 @@ u8 GetHPBarLevel(s16 hp, s16 maxhp) if (hp == maxhp) { - result = 4; + result = HP_BAR_FULL; } else { u8 fraction = GetScaledHPFraction(hp, maxhp, 48); if (fraction > 24) - result = 3; + result = HP_BAR_GREEN; else if (fraction > 9) - result = 2; + result = HP_BAR_YELLOW; else if (fraction > 0) - result = 1; + result = HP_BAR_RED; else - result = 0; + result = HP_BAR_EMPTY; } return result; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c6cec7f0d..91be4fd9d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1068,22 +1068,33 @@ static const u8 sBallCatchBonuses[] = 20, 15, 10, 15 // Ultra, Great, Poke, Safari }; -// could be a 2d array or a struct -const ALIGNED(4) u8 gUnknown_0831C494[] = +const ALIGNED(4) u8 gUnknown_0831C494[][4] = { - 0x3d, 0x44, 0x3d, 0x44, 0x14, 0x2d, 0x54, 0x5c, - 0x46, 0x55, 0x20, 0x5c, 0x26, 0x45, 0x46, 0x55, - 0x14, 0x5a, 0x46, 0x5c, 0x1e, 0x32, 0x20, 0x5a, - 0x38, 0x4e, 0x38, 0x4e, 0x19, 0x28, 0x4b, 0x5a, - 0x45, 0x4b, 0x1c, 0x53, 0x23, 0x2d, 0x1d, 0x23, - 0x3e, 0x48, 0x1e, 0x32, 0x3a, 0x5f, 0x58, 0x5e, - 0x22, 0x2d, 0x1d, 0x28, 0x23, 0x28, 0x23, 0x5f, - 0x38, 0x4e, 0x38, 0x4e, 0x23, 0x50, 0x22, 0x5e, - 0x2c, 0x5e, 0x22, 0x28, 0x38, 0x4e, 0x38, 0x4e, - 0x1e, 0x58, 0x1e, 0x58, 0x1e, 0x2b, 0x1b, 0x21, - 0x28, 0x5a, 0x19, 0x57, 0x12, 0x58, 0x5a, 0x5f, - 0x58, 0x5e, 0x16, 0x2a, 0x2a, 0x5c, 0x2a, 0x2f, - 0x38, 0x4e, 0x38, 0x4e + {0x3d, 0x44, 0x3d, 0x44}, + {0x14, 0x2d, 0x54, 0x5c}, + {0x46, 0x55, 0x20, 0x5c}, + {0x26, 0x45, 0x46, 0x55}, + {0x14, 0x5a, 0x46, 0x5c}, + {0x1e, 0x32, 0x20, 0x5a}, + {0x38, 0x4e, 0x38, 0x4e}, + {0x19, 0x28, 0x4b, 0x5a}, + {0x45, 0x4b, 0x1c, 0x53}, + {0x23, 0x2d, 0x1d, 0x23}, + {0x3e, 0x48, 0x1e, 0x32}, + {0x3a, 0x5f, 0x58, 0x5e}, + {0x22, 0x2d, 0x1d, 0x28}, + {0x23, 0x28, 0x23, 0x5f}, + {0x38, 0x4e, 0x38, 0x4e}, + {0x23, 0x50, 0x22, 0x5e}, + {0x2c, 0x5e, 0x22, 0x28}, + {0x38, 0x4e, 0x38, 0x4e}, + {0x1e, 0x58, 0x1e, 0x58}, + {0x1e, 0x2b, 0x1b, 0x21}, + {0x28, 0x5a, 0x19, 0x57}, + {0x12, 0x58, 0x5a, 0x5f}, + {0x58, 0x5e, 0x16, 0x2a}, + {0x2a, 0x5c, 0x2a, 0x2f}, + {0x38, 0x4e, 0x38, 0x4e} }; static const u8 sUnknown_0831C4F8[] = @@ -3533,7 +3544,7 @@ static void atk23_getexp(void) // music change in wild battle after fainting a poke if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) && gBattleMons[0].hp && !gBattleStruct->wildVictorySong) { - BattleMusicStop(); + BattleStopLowHpSound(); PlayBGM(0x161); gBattleStruct->wildVictorySong++; } @@ -3628,7 +3639,7 @@ static void atk23_getexp(void) if (gBattleBufferB[gActiveBank][0] == CONTROLLER_TWORETURNVALUES && gBattleBufferB[gActiveBank][1] == RET_VALUE_LEVELLED_UP) { if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId) - sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBank, gBattleStruct->expGetterId) diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 27da8b18e..01dfc954a 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1234,12 +1234,12 @@ static void sub_806E6CC(u8 taskId) DestroyTask(taskId); } -const u8 *pokemon_get_pal(struct Pokemon *mon) +const u8 *GetMonFrontSpritePal(struct Pokemon *mon) { u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); - return species_and_otid_get_pal(species, otId, personality); + return GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality); } // Extracts the upper 16 bits of a 32-bit number @@ -1248,7 +1248,7 @@ const u8 *pokemon_get_pal(struct Pokemon *mon) // Extracts the lower 16 bits of a 32-bit number #define LOHALF(n) ((n) & 0xFFFF) -const u8 *species_and_otid_get_pal(u16 species, u32 otId, u32 personality) +const u8 *GetFrontSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 personality) { u32 shinyValue; diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 002f4f069..3177a8946 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -37,8 +37,8 @@ extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[]; extern void dp12_8087EA4(void); extern void trs_config(void); extern bool8 IsDoubleBattle(void); -extern u8 sub_80A614C(u8 bank); -extern u8 sub_80A6138(u8 bank); +extern u8 GetSubstituteSpriteDefault_Y(u8 bank); +extern u8 GetBankSpriteDefault_Y(u8 bank); extern u8 sub_80A82E4(u8 bank); extern void sub_806A068(u16 species, u8 bankIdentity); extern void sub_806A12C(u16 backPicId, u8 bankIdentity); @@ -104,7 +104,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void) gReservedSpritePaletteCount = 4; break; case 5: - sub_805E350(); + ClearSpritesHealthboxAnimData(); break; case 6: if (BattleLoadAllHealthBoxesGfx(gBattleScripting.reshowHelperState)) @@ -217,7 +217,7 @@ static bool8 LoadBankSpriteGfx(u8 bank) if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); else - BattleLoadSubstituteSpriteGfx(bank, FALSE); + BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE); } else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, bank); @@ -226,7 +226,7 @@ static bool8 LoadBankSpriteGfx(u8 bank) else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank); else - BattleLoadSubstituteSpriteGfx(bank, FALSE); + BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE); gBattleScripting.reshowHelperState = 0; } @@ -250,9 +250,9 @@ static void CreateBankSprite(u8 bank) u8 posY; if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute) - posY = sub_80A614C(bank); + posY = GetSubstituteSpriteDefault_Y(bank); else - posY = sub_80A6138(bank); + posY = GetBankSpriteDefault_Y(bank); if (GetBankSide(bank) != SIDE_PLAYER) { From 32c7d4f252acf8cc9dc42d50da046c4b3f0beb16 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 4 Nov 2017 16:25:19 +0100 Subject: [PATCH 03/18] make it compile --- include/battle_gfx_sfx_util.h | 1 + src/battle_interface.c | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/battle_gfx_sfx_util.h b/include/battle_gfx_sfx_util.h index ac59361aa..313a29811 100644 --- a/include/battle_gfx_sfx_util.h +++ b/include/battle_gfx_sfx_util.h @@ -3,6 +3,7 @@ void AllocateBattleSpritesData(void); void FreeBattleSpritesData(void); +u16 ChooseMoveAndTargetInBattlePalace(void); void sub_805D714(struct Sprite *sprite); void sub_805D770(struct Sprite *sprite, bool8 arg1); void sub_805D7AC(struct Sprite *sprite); diff --git a/src/battle_interface.c b/src/battle_interface.c index 811751ca3..240c64862 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -1239,11 +1239,11 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) } ConvertIntToDecimalStringN(text + 6, value, STR_CONV_MODE_RIGHT_ALIGN, 3); - RenderTextFont9(gMonSpritesGfxPtr->fontPixels, 9, text); + RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text); for (i = 0; i < 3; i++) { - CpuCopy32(&gMonSpritesGfxPtr->fontPixels[i * 64 + 32], + CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[i * 64 + 32], (void*)((OBJ_VRAM0) + 32 * (gSprites[healthboxSpriteId].oam.tileNum + var + i)), 0x20); } @@ -1308,19 +1308,19 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 txtPtr = ConvertIntToDecimalStringN(text + 6, value, STR_CONV_MODE_RIGHT_ALIGN, 3); if (!maxOrCurrent) StringCopy(txtPtr, gText_Slash); - RenderTextFont9(gMonSpritesGfxPtr->fontPixels, 9, text); + RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text); for (i = var; i < var + 3; i++) { if (i < 3) { - CpuCopy32(&gMonSpritesGfxPtr->fontPixels[((i - var) * 64) + 32], + CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[((i - var) * 64) + 32], (void*)((OBJ_VRAM0) + 32 * (1 + gSprites[r7].oam.tileNum + i)), 0x20); } else { - CpuCopy32(&gMonSpritesGfxPtr->fontPixels[((i - var) * 64) + 32], + CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[((i - var) * 64) + 32], (void*)((OBJ_VRAM0 + 0x20) + 32 * (i + gSprites[r7].oam.tileNum)), 0x20); } @@ -1328,7 +1328,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 if (maxOrCurrent == HP_CURRENT) { - CpuCopy32(&gMonSpritesGfxPtr->fontPixels[224], + CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[224], (void*)((OBJ_VRAM0) + ((gSprites[r7].oam.tileNum + 4) * 32)), 0x20); CpuFill32(0, (void*)((OBJ_VRAM0) + (gSprites[r7].oam.tileNum * 32)), 0x20); @@ -1350,15 +1350,15 @@ static void sub_80730D4(u8 healthboxSpriteId, struct Pokemon *mon) { u8 text[20]; s32 j, var2; - u8 *fontPixels; + u8 *barFontGfx; u8 i, var, nature, healthboxSpriteId_2; memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4)); - fontPixels = &gMonSpritesGfxPtr->fontPixels[0x520 + (GetBankIdentity(gSprites[healthboxSpriteId].data6) * 384)]; + barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBankIdentity(gSprites[healthboxSpriteId].data6) * 384)]; var = 5; nature = GetNature(mon); StringCopy(text + 6, gNatureNamePointers[nature]); - RenderTextFont9(fontPixels, 9, text); + RenderTextFont9(barFontGfx, 9, text); for (j = 6, i = 0; i < var; i++, j++) { @@ -1371,18 +1371,18 @@ static void sub_80730D4(u8 healthboxSpriteId, struct Pokemon *mon) else elementId = 43; - CpuCopy32(GetHealthboxElementGfxPtr(elementId), fontPixels + (i * 64), 0x20); + CpuCopy32(GetHealthboxElementGfxPtr(elementId), barFontGfx + (i * 64), 0x20); } for (j = 1; j < var + 1; j++) { var2 = (gSprites[healthboxSpriteId].oam.tileNum + (j - (j / 8 * 8)) + (j / 8 * 64)) * 32; - CpuCopy32(fontPixels, (void*)(OBJ_VRAM0) + (var2), 0x20); - fontPixels += 0x20; + CpuCopy32(barFontGfx, (void*)(OBJ_VRAM0) + (var2), 0x20); + barFontGfx += 0x20; var2 = (8 + gSprites[healthboxSpriteId].oam.tileNum + (j - (j / 8 * 8)) + (j / 8 * 64)) * 32; - CpuCopy32(fontPixels, (void*)(OBJ_VRAM0) + (var2), 0x20); - fontPixels += 0x20; + CpuCopy32(barFontGfx, (void*)(OBJ_VRAM0) + (var2), 0x20); + barFontGfx += 0x20; } healthboxSpriteId_2 = gSprites[healthboxSpriteId].data5; @@ -1390,20 +1390,20 @@ static void sub_80730D4(u8 healthboxSpriteId, struct Pokemon *mon) ConvertIntToDecimalStringN(text + 9, gBattleStruct->field_7B, STR_CONV_MODE_RIGHT_ALIGN, 2); text[5] = CHAR_SPACE; text[8] = CHAR_SLASH; - RenderTextFont9(gMonSpritesGfxPtr->fontPixels, 9, text); + RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text); j = healthboxSpriteId_2; // needed to match for some reason for (j = 0; j < 5; j++) { if (j <= 1) { - CpuCopy32(&gMonSpritesGfxPtr->fontPixels[0x40 * j + 0x20], + CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[0x40 * j + 0x20], (void*)(OBJ_VRAM0) + (gSprites[healthboxSpriteId_2].oam.tileNum + 2 + j) * 32, 32); } else { - CpuCopy32(&gMonSpritesGfxPtr->fontPixels[0x40 * j + 0x20], + CpuCopy32(&gMonSpritesGfxPtr->barFontGfx[0x40 * j + 0x20], (void*)(OBJ_VRAM0 + 0xC0) + (j + gSprites[healthboxSpriteId_2].oam.tileNum) * 32, 32); } From 4d4d642285342bef6bafe4b932e3fd8eabeb7133 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 4 Nov 2017 22:40:36 +0100 Subject: [PATCH 04/18] dump berry blender and script menu --- asm/berry_blender.s | 88 +-- data/berry_blender.s | 167 ------ data/graphics.s | 38 +- data/script_menu.s | 220 +++---- data/strings.s | 100 ++-- graphics/berry_blender/arrow.pal | 19 + graphics/berry_blender/arrow.png | Bin 0 -> 682 bytes graphics/berry_blender/center.pal | 19 + graphics/berry_blender/center.png | Bin 0 -> 1374 bytes graphics/berry_blender/center_map.bin | Bin 0 -> 1024 bytes graphics/berry_blender/countdown_numbers.png | Bin 0 -> 457 bytes graphics/berry_blender/marubatsu.png | Bin 0 -> 293 bytes graphics/berry_blender/misc.pal | 19 + graphics/berry_blender/outer.pal | 19 + graphics/berry_blender/outer.png | Bin 0 -> 1880 bytes graphics/berry_blender/outer_map.bin | Bin 0 -> 2048 bytes graphics/berry_blender/particles.png | Bin 0 -> 217 bytes ld_script.txt | 3 +- src/berry_blender.c | 585 ++++++++++++++++++- 19 files changed, 869 insertions(+), 408 deletions(-) delete mode 100644 data/berry_blender.s create mode 100644 graphics/berry_blender/arrow.pal create mode 100644 graphics/berry_blender/arrow.png create mode 100644 graphics/berry_blender/center.pal create mode 100644 graphics/berry_blender/center.png create mode 100644 graphics/berry_blender/center_map.bin create mode 100644 graphics/berry_blender/countdown_numbers.png create mode 100644 graphics/berry_blender/marubatsu.png create mode 100644 graphics/berry_blender/misc.pal create mode 100644 graphics/berry_blender/outer.pal create mode 100644 graphics/berry_blender/outer.png create mode 100644 graphics/berry_blender/outer_map.bin create mode 100644 graphics/berry_blender/particles.png diff --git a/asm/berry_blender.s b/asm/berry_blender.s index 6d18ab7cb..1234dffeb 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -127,7 +127,7 @@ _0807F824: b _0807F966 .pool _0807F854: - ldr r1, =gUnknown_083390F4 + ldr r1, =sBlenderCenterMap movs r2, 0x80 lsls r2, 3 movs r0, 0x2 @@ -135,7 +135,7 @@ _0807F854: bl CopyToBgTilemapBuffer movs r0, 0x2 bl CopyBgTilemapBufferToVram - ldr r0, =gUnknown_083390D4 + ldr r0, =sBlenderCenterPal movs r2, 0x80 lsls r2, 1 movs r1, 0 @@ -216,14 +216,14 @@ _0807F910: b _0807F966 .pool _0807F940: - ldr r0, =gUnknown_083394F4 + ldr r0, =sBlenderOuterPal movs r1, 0x80 movs r2, 0x20 bl LoadPalette b _0807F962 .pool _0807F950: - ldr r0, =gUnknown_08339AC0 + ldr r0, =sSpriteSheet_BlenderArrow bl LoadSpriteSheet ldr r0, =gUnknown_08339BD8 bl LoadSpriteSheet @@ -243,9 +243,9 @@ _0807F980: bl LoadSpriteSheet ldr r0, =gUnknown_08339C58 bl LoadSpriteSheet - ldr r0, =gUnknown_08339AD0 + ldr r0, =sSpritePal_BlenderArrow bl LoadSpritePalette - ldr r0, =gUnknown_08339AC8 + ldr r0, =sSpritePal_BlenderMisc bl LoadSpritePalette ldr r4, =gUnknown_020322A4 ldr r0, [r4] @@ -482,12 +482,12 @@ _0807FBAC: b _0807FCE2 _0807FBB8: movs r4, 0 - ldr r5, =gUnknown_083399C8 + ldr r5, =sBlenderSyncArrowsPos ldr r6, =gUnknown_020322A4 _0807FBBE: ldrb r1, [r5] ldrb r2, [r5, 0x1] - ldr r0, =gUnknown_08339AD8 + ldr r0, =sBlenderSyncArrow_SpriteTemplate movs r3, 0x1 bl CreateSprite ldr r1, [r6] @@ -553,7 +553,7 @@ _0807FC64: ldr r4, [r6] ldr r0, =0x000011b8 adds r4, r0 - ldr r5, =gUnknown_0833973A + ldr r5, =gText_BerryBlenderStart bl sav2_get_text_speed adds r2, r0, 0 lsls r2, 24 @@ -833,7 +833,7 @@ _0807FE7C: bne _0807FEC8 adds r0, r4, 0 adds r0, 0x1C - ldr r1, =gUnknown_083397D0 + ldr r1, =sBlenderOpponentsNames ldr r1, [r1, 0xC] bl StringCopy b _0807FED4 @@ -841,7 +841,7 @@ _0807FE7C: _0807FEC8: adds r0, r4, 0 adds r0, 0x1C - ldr r1, =gUnknown_083397D0 + ldr r1, =sBlenderOpponentsNames ldr r1, [r1] bl StringCopy _0807FED4: @@ -866,7 +866,7 @@ _0807FEE8: bl StringCopy adds r0, r6, 0 adds r0, 0x1C - ldr r4, =gUnknown_083397D0 + ldr r4, =sBlenderOpponentsNames ldr r1, [r4, 0x10] bl StringCopy adds r0, r6, 0 @@ -896,7 +896,7 @@ _0807FF3C: bl StringCopy adds r0, r5, 0 adds r0, 0x1C - ldr r4, =gUnknown_083397D0 + ldr r4, =sBlenderOpponentsNames ldr r1, [r4, 0x14] bl StringCopy adds r0, r5, 0 @@ -1086,12 +1086,12 @@ _0808010C: .pool _08080120: movs r5, 0 - ldr r4, =gUnknown_083399C8 + ldr r4, =sBlenderSyncArrowsPos ldr r6, =gUnknown_020322A4 _08080126: ldrb r1, [r4] ldrb r2, [r4, 0x1] - ldr r0, =gUnknown_08339AD8 + ldr r0, =sBlenderSyncArrow_SpriteTemplate movs r3, 0x1 bl CreateSprite ldr r1, [r6] @@ -1160,7 +1160,7 @@ _080801C8: ldr r0, [r4] ldr r3, =0x000011b8 adds r0, r3 - ldr r1, =gUnknown_0833981A + ldr r1, =sText_CommunicationStandby movs r2, 0 bl sub_808417C ldr r1, [r4] @@ -2121,12 +2121,12 @@ _080809F0: .pool _08080A04: movs r4, 0 - ldr r5, =gUnknown_083399C8 + ldr r5, =sBlenderSyncArrowsPos ldr r6, =gUnknown_020322A4 _08080A0A: ldrb r1, [r5] ldrb r2, [r5, 0x1] - ldr r0, =gUnknown_08339AD8 + ldr r0, =sBlenderSyncArrow_SpriteTemplate movs r3, 0x1 bl CreateSprite ldr r1, [r6] @@ -3095,7 +3095,7 @@ sub_8081288: @ 8081288 mov r8, r7 lsls r1, 24 ldr r0, =gUnknown_08339B40 - ldr r4, =gUnknown_083399C8 + ldr r4, =sBlenderSyncArrowsPos lsrs r1, 23 adds r2, r1, r4 ldrb r6, [r2] @@ -5062,7 +5062,7 @@ _080822B0: ldr r4, [r6] ldr r5, =0x000011b8 adds r4, r5 - ldr r5, =gUnknown_08339831 + ldr r5, =sText_WouldLikeToBlendAnotherBerry bl sav2_get_text_speed adds r2, r0, 0 lsls r2, 24 @@ -5263,7 +5263,7 @@ _0808246C: ldr r4, [r6] ldr r0, =0x000011b8 adds r4, r0 - ldr r5, =gUnknown_0833981A + ldr r5, =sText_CommunicationStandby bl sav2_get_text_speed adds r2, r0, 0 lsls r2, 24 @@ -5555,7 +5555,7 @@ _080826EC: adds r1, r0 adds r0, r4, 0 bl StringCopy - ldr r1, =gUnknown_083398DD + ldr r1, =sText_someonesPokeblockCaseIsFull b _08082740 .pool _0808271C: @@ -5575,7 +5575,7 @@ _0808271C: adds r1, r0 adds r0, r4, 0 bl StringCopy - ldr r1, =gUnknown_083398B0 + ldr r1, =sText_hasNoBerriesToPut _08082740: adds r0, r4, 0 bl StringAppend @@ -5856,7 +5856,7 @@ _080829AA: adds r0, r1 strh r2, [r0] ldr r0, =gStringVar4 - ldr r1, =gUnknown_08339896 + ldr r1, =sText_YourPokeblockCaseIsFull bl StringCopy b _08082A92 .pool @@ -5872,7 +5872,7 @@ _080829D4: adds r0, r1 strh r2, [r0] ldr r0, =gStringVar4 - ldr r1, =gUnknown_08339858 + ldr r1, =sText_RunOutOfBerriesForBlending bl StringCopy b _08082A92 .pool @@ -7276,7 +7276,7 @@ _080834DE: b _08083854 .pool _08083518: - ldr r4, =gUnknown_083398F5 + ldr r4, =sText_BlendingResults movs r0, 0x1 adds r1, r4, 0 movs r2, 0xA8 @@ -7329,7 +7329,7 @@ _08083564: bl ConvertIntToDecimalStringN ldr r0, [r7] adds r0, 0x9F - ldr r1, =gUnknown_08339941 + ldr r1, =sText_Dot bl StringAppend ldr r0, [r7] adds r0, 0x9F @@ -7374,7 +7374,7 @@ _08083564: bl ConvertInternationalString ldr r0, [r7] adds r0, 0x9F - ldr r1, =gUnknown_08339914 + ldr r1, =sText_SpaceBerry bl StringAppend ldr r1, [r7] adds r1, 0x9F @@ -7397,7 +7397,7 @@ _08083564: cmp r6, r0 bcc _08083564 _0808361A: - ldr r1, =gUnknown_0833992E + ldr r1, =sText_MaximumSpeed movs r3, 0xFF mov r10, r3 str r3, [sp] @@ -7425,7 +7425,7 @@ _0808361A: bl ConvertIntToDecimalStringN ldr r0, [r6] adds r0, 0x9F - ldr r1, =gUnknown_08339941 + ldr r1, =sText_Dot bl StringAppend ldr r0, [r6] adds r0, 0x4E @@ -7445,7 +7445,7 @@ _0808361A: bl StringAppend ldr r0, [r6] adds r0, 0x9F - ldr r1, =gUnknown_0833993C + ldr r1, =sText_RPM bl StringAppend ldr r1, [r6] adds r1, 0x9F @@ -7463,7 +7463,7 @@ _0808361A: movs r0, 0x5 movs r3, 0x51 bl sub_80840D4 - ldr r1, =gUnknown_0833991B + ldr r1, =sText_Time mov r2, r10 str r2, [sp] mov r3, r9 @@ -7499,7 +7499,7 @@ _0808361A: bl ConvertIntToDecimalStringN ldr r0, [r6] adds r0, 0x9F - ldr r1, =gUnknown_08339921 + ldr r1, =sText_Min bl StringAppend adds r1, r4, 0 movs r2, 0x2 @@ -7507,7 +7507,7 @@ _0808361A: bl ConvertIntToDecimalStringN ldr r0, [r6] adds r0, 0x9F - ldr r1, =gUnknown_08339928 + ldr r1, =sText_Sec bl StringAppend ldr r1, [r6] adds r1, 0x9F @@ -7682,10 +7682,10 @@ sub_80838AC: @ 80838AC ldr r1, [r0] adds r0, r6, 0 bl StringCopy - ldr r1, =gUnknown_0833979D + ldr r1, =gText_wasMade adds r0, r6, 0 bl StringAppend - ldr r1, =gUnknown_08339943 + ldr r1, =sText_NewLine adds r0, r6, 0 bl StringAppend adds r0, r5, 0 @@ -7698,7 +7698,7 @@ sub_80838AC: @ 80838AC adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 - ldr r1, =gUnknown_0833994F + ldr r1, =sText_TheLevelIs adds r0, r6, 0 bl StringAppend mov r0, sp @@ -7709,7 +7709,7 @@ sub_80838AC: @ 80838AC adds r0, r6, 0 mov r1, sp bl StringAppend - ldr r1, =gUnknown_0833995D + ldr r1, =sText_TheFeelIs adds r0, r6, 0 bl StringAppend mov r0, sp @@ -7720,10 +7720,10 @@ sub_80838AC: @ 80838AC adds r0, r6, 0 mov r1, sp bl StringAppend - ldr r1, =gUnknown_08339970 + ldr r1, =sText_Dot2 adds r0, r6, 0 bl StringAppend - ldr r1, =gUnknown_0833979B + ldr r1, =gText_NewParagraph adds r0, r6, 0 bl StringAppend add sp, 0xC @@ -8041,7 +8041,7 @@ _08083B9A: movs r2, 0x1 movs r3, 0xD bl SetWindowBorderStyle - ldr r4, =gUnknown_08339947 + ldr r4, =sText_Ranking movs r0, 0x1 adds r1, r4, 0 movs r2, 0xA8 @@ -8161,7 +8161,7 @@ _08083C84: bl ConvertIntToDecimalStringN ldr r0, [r7] adds r0, 0x9F - ldr r1, =gUnknown_08339941 + ldr r1, =sText_Dot bl StringAppend ldr r0, [r7] adds r0, 0x9F @@ -8395,7 +8395,7 @@ _08083E8A: movs r3, 0x3 bl ConvertIntToDecimalStringN adds r5, r0, 0 - ldr r1, =gUnknown_08339941 + ldr r1, =sText_Dot bl StringAppend adds r5, r0, 0 adds r0, r4, 0 @@ -8407,7 +8407,7 @@ _08083E8A: movs r3, 0x2 bl ConvertIntToDecimalStringN adds r5, r0, 0 - ldr r1, =gUnknown_0833993C + ldr r1, =sText_RPM bl StringAppend movs r0, 0x1 add r1, sp, 0xC diff --git a/data/berry_blender.s b/data/berry_blender.s deleted file mode 100644 index d3360d4d8..000000000 --- a/data/berry_blender.s +++ /dev/null @@ -1,167 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2, 0 - -gUnknown_083390D4:: @ 83390D4 - .incbin "baserom.gba", 0x3390d4, 0x20 - -gUnknown_083390F4:: @ 83390F4 - .incbin "baserom.gba", 0x3390f4, 0x400 - -gUnknown_083394F4:: @ 83394F4 - .incbin "baserom.gba", 0x3394f4, 0x246 - -gUnknown_0833973A:: @ 833973A - .incbin "baserom.gba", 0x33973a, 0x61 - -gUnknown_0833979B:: @ 833979B - .incbin "baserom.gba", 0x33979b, 0x2 - -gUnknown_0833979D:: @ 833979D - .incbin "baserom.gba", 0x33979d, 0x33 - -gUnknown_083397D0:: @ 83397D0 - .incbin "baserom.gba", 0x3397d0, 0x4a - -gUnknown_0833981A:: @ 833981A - .incbin "baserom.gba", 0x33981a, 0x17 - -gUnknown_08339831:: @ 8339831 - .incbin "baserom.gba", 0x339831, 0x27 - -gUnknown_08339858:: @ 8339858 - .incbin "baserom.gba", 0x339858, 0x3e - -gUnknown_08339896:: @ 8339896 - .incbin "baserom.gba", 0x339896, 0x1a - -gUnknown_083398B0:: @ 83398B0 - .incbin "baserom.gba", 0x3398b0, 0x2d - -gUnknown_083398DD:: @ 83398DD - .incbin "baserom.gba", 0x3398dd, 0x18 - -gUnknown_083398F5:: @ 83398F5 - .incbin "baserom.gba", 0x3398f5, 0x1f - -gUnknown_08339914:: @ 8339914 - .incbin "baserom.gba", 0x339914, 0x7 - -gUnknown_0833991B:: @ 833991B - .incbin "baserom.gba", 0x33991b, 0x6 - -gUnknown_08339921:: @ 8339921 - .incbin "baserom.gba", 0x339921, 0x7 - -gUnknown_08339928:: @ 8339928 - .incbin "baserom.gba", 0x339928, 0x6 - -gUnknown_0833992E:: @ 833992E - .incbin "baserom.gba", 0x33992e, 0xe - -gUnknown_0833993C:: @ 833993C - .incbin "baserom.gba", 0x33993c, 0x5 - -gUnknown_08339941:: @ 8339941 - .incbin "baserom.gba", 0x339941, 0x2 - -gUnknown_08339943:: @ 8339943 - .incbin "baserom.gba", 0x339943, 0x4 - -gUnknown_08339947:: @ 8339947 - .incbin "baserom.gba", 0x339947, 0x8 - -gUnknown_0833994F:: @ 833994F - .incbin "baserom.gba", 0x33994f, 0xe - -gUnknown_0833995D:: @ 833995D - .incbin "baserom.gba", 0x33995d, 0x13 - -gUnknown_08339970:: @ 8339970 - .incbin "baserom.gba", 0x339970, 0x4 - -gUnknown_08339974:: @ 8339974 - .incbin "baserom.gba", 0x339974, 0xc - -gUnknown_08339980:: @ 8339980 - .incbin "baserom.gba", 0x339980, 0x38 - -gUnknown_083399B8:: @ 83399B8 - .incbin "baserom.gba", 0x3399b8, 0x8 - -gUnknown_083399C0:: @ 83399C0 - .incbin "baserom.gba", 0x3399c0, 0x8 - -gUnknown_083399C8:: @ 83399C8 - .incbin "baserom.gba", 0x3399c8, 0x8 - -gUnknown_083399D0:: @ 83399D0 - .incbin "baserom.gba", 0x3399d0, 0xc - -gUnknown_083399DC:: @ 83399DC - .incbin "baserom.gba", 0x3399dc, 0x8 - -gUnknown_083399E4:: @ 83399E4 - .incbin "baserom.gba", 0x3399e4, 0x3 - -gUnknown_083399E7:: @ 83399E7 - .incbin "baserom.gba", 0x3399e7, 0x5 - -gUnknown_083399EC:: @ 83399EC - .incbin "baserom.gba", 0x3399ec, 0xd4 - -gUnknown_08339AC0:: @ 8339AC0 - .incbin "baserom.gba", 0x339ac0, 0x8 - -gUnknown_08339AC8:: @ 8339AC8 - .incbin "baserom.gba", 0x339ac8, 0x8 - -gUnknown_08339AD0:: @ 8339AD0 - .incbin "baserom.gba", 0x339ad0, 0x8 - -gUnknown_08339AD8:: @ 8339AD8 - .incbin "baserom.gba", 0x339ad8, 0x60 - -gUnknown_08339B38:: @ 8339B38 - .incbin "baserom.gba", 0x339b38, 0x8 - -gUnknown_08339B40:: @ 8339B40 - .incbin "baserom.gba", 0x339b40, 0x98 - -gUnknown_08339BD8:: @ 8339BD8 - .incbin "baserom.gba", 0x339bd8, 0x8 - -gUnknown_08339BE0:: @ 8339BE0 - .incbin "baserom.gba", 0x339be0, 0x44 - -gUnknown_08339C24:: @ 8339C24 - .incbin "baserom.gba", 0x339c24, 0x8 - -gUnknown_08339C2C:: @ 8339C2C - .incbin "baserom.gba", 0x339c2c, 0x2c - -gUnknown_08339C58:: @ 8339C58 - .incbin "baserom.gba", 0x339c58, 0x8 - -gUnknown_08339C60:: @ 8339C60 - .incbin "baserom.gba", 0x339c60, 0x18 - -gUnknown_08339C78:: @ 8339C78 - .incbin "baserom.gba", 0x339c78, 0x28 - -gUnknown_08339CA0:: @ 8339CA0 - .incbin "baserom.gba", 0x339ca0, 0x1e - -gUnknown_08339CBE:: @ 8339CBE - .incbin "baserom.gba", 0x339cbe, 0x5 - -gUnknown_08339CC3:: @ 8339CC3 - .incbin "baserom.gba", 0x339cc3, 0x5 - -gUnknown_08339CC8:: @ 8339CC8 - .incbin "baserom.gba", 0x339cc8, 0x4c - -gUnknown_08339D14:: @ 8339D14 - .incbin "baserom.gba", 0x339d14, 0x8 diff --git a/data/graphics.s b/data/graphics.s index e89177a1d..3e4df7d9c 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -1197,8 +1197,44 @@ gUnknown_08DC9608:: @ 8DC9608 .incbin "baserom.gba", 0xdc9608, 0x20 gUnknown_08DC9628:: @ 8DC9628 - .incbin "baserom.gba", 0xdc9628, 0x2788 + .incbin "baserom.gba", 0xdc9628, 0x320 + +gBerryBlenderMiscPalette:: @ 8DCAB88 + .incbin "graphics/berry_blender/misc.gbapal" + +gBerryBlenderArrowPalette:: @ 8DC9948 + .incbin "graphics/berry_blender/arrow.gbapal" +gUnknown_8DC9988:: @ 8DC9988 + .incbin "baserom.gba", 0xdc9988, 0x200 + + .align 2 +gBerryBlenderMarubatsuTiles:: @ 8DC9B88 + .incbin "graphics/berry_blender/marubatsu.4bpp" + + .align 2 +gBerryBlenderParticlesTiles:: @ 8E90818 + .incbin "graphics/berry_blender/particles.4bpp" + + .space 0x120 + + .align 2 +gBerryBlenderCountdownNumbersTiles:: @ 8DC9F88 + .incbin "graphics/berry_blender/countdown_numbers.4bpp" + + .align 2 +gBerryBlenderStartTiles:: @ 8DCA588 + .incbin "baserom.gba" , 0xdca588, 1024 + + .space 512 + + .align 2 +gBerryBlenderArrowTiles:: @ 8DCAB88 + .incbin "graphics/berry_blender/arrow.4bpp" + +gUnknown_08DCB388:: @ 8DCB388 + .incbin "baserom.gba", 0xdcb388, 0xA28 + gUnknown_08DCBDB0:: @ 8DCBDB0 .incbin "baserom.gba", 0xdcbdb0, 0x20 diff --git a/data/script_menu.s b/data/script_menu.s index 8cf395c04..626f0a268 100644 --- a/data/script_menu.s +++ b/data/script_menu.s @@ -4,26 +4,22 @@ .section .rodata gUnknown_0858ABD8:: @ 858ABD8 -@ replacing .incbin "baserom.gba", 0x0058abd8, 0x18 .4byte gUnknown_085EAD37, 0 .4byte gUnknown_085EAD41, 0 .4byte gText_Exit, 0 gUnknown_0858ABF0:: @ 58ABF0 -@ replacing .incbin "baserom.gba", 0x0058abf0, 0x18 .4byte gUnknown_085EAD67, 0 .4byte gUnknown_085EAD6D, 0 .4byte gText_Exit, 0 gUnknown_0858AC08:: @ 58AC08 -@ replacing .incbin "baserom.gba", 0x0058ac08, 0x20 .4byte gUnknown_085EAD72, 0 .4byte gUnknown_085EAD84, 0 .4byte gUnknown_085EAD96, 0 .4byte gText_Cancel2, 0 gUnknown_0858AC28:: @ 58AC28 -@ replacing .incbin "baserom.gba", 0x0058ac28, 0x30 .4byte gUnknown_085EADA4, 0 .4byte gUnknown_085EADB5, 0 .4byte gUnknown_085EADC4, 0 @@ -32,32 +28,27 @@ gUnknown_0858AC28:: @ 58AC28 .4byte gText_Exit, 0 gUnknown_0858AC58:: @ 58AC58 -@ replacing .incbin "baserom.gba", 0x0058ac58, 0x20 .4byte gUnknown_085EADF9, 0 .4byte gUnknown_085EAE04, 0 .4byte gUnknown_085EAE12, 0 .4byte gText_Exit, 0 gUnknown_0858AC78:: @ 58AC78 -@ replacing .incbin "baserom.gba", 0x0058ac78, 0x18 .4byte gUnknown_085EADF9, 0 .4byte gUnknown_085EAE04, 0 .4byte gText_Exit, 0 gUnknown_0858AC90:: @ 58AC90 -@ replacing .incbin "baserom.gba", 0x0058ac90, 0x20 .4byte gUnknown_085E8CCB, 0 .4byte gUnknown_085EAE12, 0 .4byte gUnknown_085EAE1B, 0 .4byte gText_Cancel2, 0 gUnknown_0858ACB0:: @ 58ACB0 -@ replacing .incbin "baserom.gba", 0x0058acb0, 0x10 .4byte gUnknown_085EAE27, 0 .4byte gUnknown_085EAE2C, 0 gUnknown_0858ACC0:: @ 58ACC0 -@ replacing .incbin "baserom.gba", 0x0058acc0, 0x30 .4byte gUnknown_085EAE31, 0 .4byte gUnknown_085EAE35, 0 .4byte gUnknown_085EAE39, 0 @@ -66,157 +57,131 @@ gUnknown_0858ACC0:: @ 58ACC0 .4byte gText_Exit, 0 gUnknown_0858ACF0:: @ 58ACF0 -@ replacing .incbin "baserom.gba", 0x0058acf0, 0x10 .4byte gUnknown_085EAD5F, 0 .4byte gText_Exit, 0 gUnknown_0858AD00:: @ 58AD00 -@ replacing .incbin "baserom.gba", 0x0058ad00, 0x10 .4byte gUnknown_085EAE53, 0 .4byte gUnknown_085EAE5A, 0 gUnknown_0858AD10:: @ 58AD10 -@ replacing .incbin "baserom.gba", 0x0058ad10, 0x18 .4byte gText_Yes, 0 .4byte gText_No, 0 .4byte gUnknown_085EAD6D, 0 gUnknown_0858AD28:: @ 58AD28 -@ replacing .incbin "baserom.gba", 0x0058ad28, 0x18 .4byte gUnknown_085EAEA2, 0 .4byte gUnknown_085EAEAC, 0 .4byte gText_Exit, 0 gUnknown_0858AD40:: @ 58AD40 -@ replacing .incbin "baserom.gba", 0x0058ad40, 0x18 .4byte gText_Lv50, 0 .4byte gText_OpenLevel, 0 .4byte gText_Exit, 0 gUnknown_0858AD58:: @ 58AD58 -@ replacing .incbin "baserom.gba", 0x0058ad58, 0x18 .4byte gUnknown_0827ECBC, 0 .4byte gUnknown_0827ECC3, 0 .4byte gUnknown_0827ECCD, 0 gUnknown_0858AD70:: @ 58AD70 -@ replacing .incbin "baserom.gba", 0x0058ad70, 0x18 .4byte gUnknown_0827ECD5, 0 .4byte gUnknown_0827ECDD, 0 .4byte gUnknown_0827ECE3, 0 gUnknown_0858AD88:: @ 58AD88 -@ replacing .incbin "baserom.gba", 0x0058ad88, 0x18 .4byte gUnknown_0827ECEB, 0 .4byte gUnknown_0827ECF2, 0 .4byte gUnknown_0827ECF8, 0 gUnknown_0858ADA0:: @ 58ADA0 -@ replacing .incbin "baserom.gba", 0x0058ada0, 0x18 .4byte gUnknown_0827ED00, 0 .4byte gUnknown_0827ED06, 0 .4byte gUnknown_0827ED10, 0 gUnknown_0858ADB8:: @ 58ADB8 -@ replacing .incbin "baserom.gba", 0x0058adb8, 0x18 .4byte gUnknown_0827ED18, 0 .4byte gUnknown_0827ED22, 0 .4byte gUnknown_0827ED2C, 0 gUnknown_0858ADD0:: @ 58ADD0 -@ replacing .incbin "baserom.gba", 0x0058add0, 0x18 .4byte gUnknown_0827ED36, 0 .4byte gUnknown_0827ED40, 0 .4byte gUnknown_0827ED46, 0 gUnknown_0858ADE8:: @ 58ADE8 -@ replacing .incbin "baserom.gba", 0x0058ade8, 0x18 .4byte gUnknown_0827ED4F, 0 .4byte gUnknown_0827ED59, 0 .4byte gUnknown_0827ED65, 0 gUnknown_0858AE00:: @ 58AE00 -@ replacing .incbin "baserom.gba", 0x0058ae00, 0x18 .4byte gUnknown_0827ED70, 0 .4byte gUnknown_0827ED74, 0 .4byte gUnknown_0827ED78, 0 gUnknown_0858AE18:: @ 58AE18 -@ replacing .incbin "baserom.gba", 0x0058ae18, 0x18 .4byte gUnknown_0827ED80, 0 .4byte gUnknown_0827ED95, 0 .4byte gUnknown_0827EDAA, 0 gUnknown_0858AE30:: @ 58AE30 -@ replacing .incbin "baserom.gba", 0x0058ae30, 0x18 .4byte gUnknown_0827EDB5, 0 .4byte gUnknown_0827EDBA, 0 .4byte gUnknown_0827EDC1, 0 gUnknown_0858AE48:: @ 58AE48 -@ replacing .incbin "baserom.gba", 0x0058ae48, 0x18 .4byte gUnknown_0827EDC9, 0 .4byte gUnknown_0827EDD5, 0 .4byte gUnknown_0827EDE4, 0 gUnknown_0858AE60:: @ 58AE60 -@ replacing .incbin "baserom.gba", 0x0058ae60, 0x18 .4byte gUnknown_0827EDF0, 0 .4byte gUnknown_0827EDF5, 0 .4byte gUnknown_0827EDF7, 0 gUnknown_0858AE78:: @ 58AE78 -@ replacing .incbin "baserom.gba", 0x0058ae78, 0x18 .4byte gUnknown_0827EDF9, 0 .4byte gUnknown_0827EDFB, 0 .4byte gUnknown_0827EDFD, 0 gUnknown_0858AE90:: @ 58AE90 -@ replacing .incbin "baserom.gba", 0x0058ae90, 0x18 .4byte gUnknown_0827EDFF, 0 .4byte gUnknown_0827EE01, 0 .4byte gUnknown_0827EE03, 0 gUnknown_0858AEA8:: @ 58AEA8 -@ replacing .incbin "baserom.gba", 0x0058aea8, 0x18 .4byte gUnknown_0827EE05, 0 .4byte gUnknown_0827EE07, 0 .4byte gUnknown_0827EE09, 0 gUnknown_0858AEC0:: @ 58AEC0 -@ replacing .incbin "baserom.gba", 0x0058aec0, 0x20 .4byte gUnknown_085EAEC3, 0 .4byte gUnknown_085EAED6, 0 .4byte gUnknown_085EAEE6, 0 .4byte gText_Exit, 0 gUnknown_0858AEE0:: @ 58AEE0 -@ replacing .incbin "baserom.gba", 0x0058aee0, 0x20 .4byte gUnknown_085EAEF6, 0 .4byte gUnknown_085EAF02, 0 .4byte gUnknown_085EAF0E, 0 .4byte gText_Exit, 0 gUnknown_0858AF00:: @ 58AF00 -@ replacing .incbin "baserom.gba", 0x0058af00, 0x20 .4byte gUnknown_085EAF1B, 0 .4byte gUnknown_085EAF24, 0 .4byte gUnknown_085EAF2F, 0 .4byte gText_Exit, 0 gUnknown_0858AF20:: @ 58AF20 -@ replacing .incbin "baserom.gba", 0x0058af20, 0x10 .4byte gUnknown_085EAF34, 0 .4byte gUnknown_085EAF3E, 0 gUnknown_0858AF30:: @ 58AF30 -@ replacing .incbin "baserom.gba", 0x0058af30, 0x18 .4byte gUnknown_085EAF4B, 0 .4byte gUnknown_085EAF58, 0 .4byte gText_Exit, 0 gUnknown_0858AF48:: @ 58AF48 -@ replacing .incbin "baserom.gba", 0x0058af48, 0x40 .4byte gUnknown_085EAF65, 0 .4byte gUnknown_085EAF70, 0 .4byte gUnknown_085EAF7D, 0 @@ -227,14 +192,12 @@ gUnknown_0858AF48:: @ 58AF48 .4byte gText_Cancel2, 0 gUnknown_0858AF88:: @ 58AF88 -@ replacing .incbin "baserom.gba", 0x0058af88, 0x20 .4byte gUnknown_085EAFB6, 0 .4byte gUnknown_085EAFCF, 0 .4byte gUnknown_085EAFE8, 0 .4byte gText_Exit, 0 gUnknown_0858AFA8:: @ 58AFA8 -@ replacing .incbin "baserom.gba", 0x0058afa8, 0x30 .4byte gUnknown_085EB089, 0 .4byte gUnknown_085EB09C, 0 .4byte gUnknown_085EB0AF, 0 @@ -243,40 +206,33 @@ gUnknown_0858AFA8:: @ 58AFA8 .4byte gText_Exit, 0 gUnknown_0858AFD8:: @ 58AFD8 -@ replacing .incbin "baserom.gba", 0x0058afd8, 0x18 .4byte gUnknown_085EB002, 0 .4byte gUnknown_085EB017, 0 .4byte gText_Exit, 0 gUnknown_0858AFF0:: @ 58AFF0 -@ replacing .incbin "baserom.gba", 0x0058aff0, 0x10 .4byte gUnknown_085EB02A, 0 .4byte gUnknown_085EB034, 0 gUnknown_0858B000:: @ 58B000 -@ replacing .incbin "baserom.gba", 0x0058b000, 0x18 - .4byte gUnknown_085EB79B, 0 - .4byte gUnknown_085EB06E, 0 + .4byte gText_LilycoveCity, 0 + .4byte gText_BattleFrontier, 0 .4byte gText_Exit, 0 gUnknown_0858B018:: @ 58B018 -@ replacing .incbin "baserom.gba", 0x0058b018, 0x18 - .4byte gUnknown_085EB7A9, 0 - .4byte gUnknown_085EB79B, 0 + .4byte gText_SlateportCity, 0 + .4byte gText_LilycoveCity, 0 .4byte gText_Exit, 0 gUnknown_0858B030:: @ 58B030 -@ replacing .incbin "baserom.gba", 0x0058b030, 0x10 .4byte gUnknown_085EB07E, 0 .4byte gUnknown_085EB084, 0 gUnknown_0858B040:: @ 58B040 -@ replacing .incbin "baserom.gba", 0x0058b040, 0x10 - .4byte gUnknown_085EB79B, 0 + .4byte gText_LilycoveCity, 0 .4byte gText_Exit, 0 gUnknown_0858B050:: @ 58B050 -@ replacing .incbin "baserom.gba", 0x0058b050, 0x30 .4byte gUnknown_085EB676, 0 .4byte gUnknown_085EB673, 0 .4byte gUnknown_085EB670, 0 @@ -285,91 +241,76 @@ gUnknown_0858B050:: @ 58B050 .4byte gText_Exit, 0 gUnknown_0858B080:: @ 58B080 -@ replacing .incbin "baserom.gba", 0x0058b080, 0x10 .4byte gUnknown_085EB040, 0 .4byte gText_Exit, 0 gUnknown_0858B090:: @ 58B090 -@ replacing .incbin "baserom.gba", 0x0058b090, 0x10 .4byte gUnknown_085EB04A, 0 .4byte gText_Exit, 0 gUnknown_0858B0A0:: @ 58B0A0 -@ replacing .incbin "baserom.gba", 0x0058b0a0, 0x18 .4byte gUnknown_085EB040, 0 .4byte gUnknown_085EB04A, 0 .4byte gText_Exit, 0 gUnknown_0858B0B8:: @ 58B0B8 -@ replacing .incbin "baserom.gba", 0x0058b0b8, 0x10 .4byte gUnknown_085EB057, 0 .4byte gText_Exit, 0 gUnknown_0858B0C8:: @ 58B0C8 -@ replacing .incbin "baserom.gba", 0x0058b0c8, 0x18 .4byte gUnknown_085EB040, 0 .4byte gUnknown_085EB057, 0 .4byte gText_Exit, 0 gUnknown_0858B0E0:: @ 58B0E0 -@ replacing .incbin "baserom.gba", 0x0058b0e0, 0x18 .4byte gUnknown_085EB04A, 0 .4byte gUnknown_085EB057, 0 .4byte gText_Exit, 0 gUnknown_0858B0F8:: @ 58B0F8 -@ replacing .incbin "baserom.gba", 0x0058b0f8, 0x20 .4byte gUnknown_085EB040, 0 .4byte gUnknown_085EB04A, 0 .4byte gUnknown_085EB057, 0 .4byte gText_Exit, 0 gUnknown_0858B118:: @ 58B118 -@ replacing .incbin "baserom.gba", 0x0058b118, 0x10 .4byte gUnknown_085EB062, 0 .4byte gText_Exit, 0 gUnknown_0858B128:: @ 58B128 -@ replacing .incbin "baserom.gba", 0x0058b128, 0x18 .4byte gUnknown_085EB040, 0 .4byte gUnknown_085EB062, 0 .4byte gText_Exit, 0 gUnknown_0858B140:: @ 58B140 -@ replacing .incbin "baserom.gba", 0x0058b140, 0x18 .4byte gUnknown_085EB04A, 0 .4byte gUnknown_085EB062, 0 .4byte gText_Exit, 0 gUnknown_0858B158:: @ 58B158 -@ replacing .incbin "baserom.gba", 0x0058b158, 0x20 .4byte gUnknown_085EB040, 0 .4byte gUnknown_085EB04A, 0 .4byte gUnknown_085EB062, 0 .4byte gText_Exit, 0 gUnknown_0858B178:: @ 58B178 -@ replacing .incbin "baserom.gba", 0x0058b178, 0x18 .4byte gUnknown_085EB057, 0 .4byte gUnknown_085EB062, 0 .4byte gText_Exit, 0 gUnknown_0858B190:: @ 58B190 -@ replacing .incbin "baserom.gba", 0x0058b190, 0x20 .4byte gUnknown_085EB040, 0 .4byte gUnknown_085EB057, 0 .4byte gUnknown_085EB062, 0 .4byte gText_Exit, 0 gUnknown_0858B1B0:: @ 58B1B0 -@ replacing .incbin "baserom.gba", 0x0058b1b0, 0x20 .4byte gUnknown_085EB04A, 0 .4byte gUnknown_085EB057, 0 .4byte gUnknown_085EB062, 0 .4byte gText_Exit, 0 gUnknown_0858B1D0:: @ 58B1D0 -@ replacing .incbin "baserom.gba", 0x0058b1d0, 0x28 .4byte gUnknown_085EB040, 0 .4byte gUnknown_085EB04A, 0 .4byte gUnknown_085EB057, 0 @@ -377,42 +318,36 @@ gUnknown_0858B1D0:: @ 58B1D0 .4byte gText_Exit, 0 gUnknown_0858B1F8:: @ 58B1F8 -@ replacing .incbin "baserom.gba", 0x0058b1f8, 0x30 - .4byte gUnknown_085EB1A0, 0 - .4byte gUnknown_085EB1A9, 0 - .4byte gUnknown_085EB1B6, 0 + .4byte gText_Opponent, 0 + .4byte gText_Tourney_Tree, 0 + .4byte gText_ReadyToStart, 0 .4byte gUnknown_085EB5BC, 0 .4byte gUnknown_085EB5C3, 0 .4byte gUnknown_085EB5C8, 0 gUnknown_0858B228:: @ 58B228 -@ replacing .incbin "baserom.gba", 0x0058b228, 0x28 - .4byte gUnknown_085EB1A0, 0 - .4byte gUnknown_085EB1A9, 0 - .4byte gUnknown_085EB1B6, 0 + .4byte gText_Opponent, 0 + .4byte gText_Tourney_Tree, 0 + .4byte gText_ReadyToStart, 0 .4byte gUnknown_085EB5C3, 0 .4byte gUnknown_085EB5C8, 0 gUnknown_0858B250:: @ 58B250 -@ replacing .incbin "baserom.gba", 0x0058b250, 0x10 .4byte gUnknown_085EB29A, 0 .4byte gUnknown_085EB2A3, 0 gUnknown_0858B260:: @ 58B260 -@ replacing .incbin "baserom.gba", 0x0058b260, 0x20 .4byte gUnknown_085EB372, 0 .4byte gUnknown_085EB37F, 0 .4byte gUnknown_085EB389, 0 .4byte gText_Exit, 0 gUnknown_0858B280:: @ 58B280 -@ replacing .incbin "baserom.gba", 0x0058b280, 0x18 .4byte gText_Yes, 0 .4byte gText_No, 0 .4byte gUnknown_085EAD6D, 0 gUnknown_0858B298:: @ 58B298 -@ replacing .incbin "baserom.gba", 0x0058b298, 0x28 .4byte gUnknown_085EAE6E, 0 .4byte gUnknown_085EAE7C, 0 .4byte gUnknown_085EAE8A, 0 @@ -420,14 +355,12 @@ gUnknown_0858B298:: @ 58B298 .4byte gText_Exit, 0 gUnknown_0858B2C0:: @ 58B2C0 -@ replacing .incbin "baserom.gba", 0x0058b2c0, 0x20 .4byte gUnknown_085EB372, 0 .4byte gUnknown_085EB37F, 0 .4byte gUnknown_085EB397, 0 .4byte gText_Exit, 0 gUnknown_0858B2E0:: @ 58B2E0 -@ replacing .incbin "baserom.gba", 0x0058b2e0, 0x28 .4byte gUnknown_085EB372, 0 .4byte gUnknown_085EB37F, 0 .4byte gUnknown_085EB389, 0 @@ -435,52 +368,44 @@ gUnknown_0858B2E0:: @ 58B2E0 .4byte gText_Exit, 0 gUnknown_0858B308:: @ 58B308 -@ replacing .incbin "baserom.gba", 0x0058b308, 0x18 .4byte gUnknown_085EB372, 0 .4byte gUnknown_085EB37F, 0 .4byte gText_Exit, 0 gUnknown_0858B320:: @ 58B320 -@ replacing .incbin "baserom.gba", 0x0058b320, 0x18 .4byte gUnknown_085EB3A4, 0 .4byte gUnknown_085EB3B1, 0 .4byte gText_Exit, 0 gUnknown_0858B338:: @ 58B338 -@ replacing .incbin "baserom.gba", 0x0058b338, 0x18 .4byte gUnknown_085EB3D4, 0 .4byte gUnknown_085EB3C6, 0 .4byte gText_Exit, 0 gUnknown_0858B350:: @ 58B350 -@ replacing .incbin "baserom.gba", 0x0058b350, 0x28 - .4byte gUnknown_085EB1C5, 0 - .4byte gUnknown_085EB1D1, 0 - .4byte gUnknown_085EB1DC, 0 - .4byte gUnknown_085EB1E7, 0 + .4byte gText_NormalRank, 0 + .4byte gText_SuperRank, 0 + .4byte gText_HyperRank, 0 + .4byte gText_MasterRank, 0 .4byte gText_Exit, 0 gUnknown_0858B378:: @ 58B378 -@ replacing .incbin "baserom.gba", 0x0058b378, 0x18 - .4byte gUnknown_085EB212, 0 - .4byte gUnknown_085EB21D, 0 + .4byte gText_BattleBag, 0 + .4byte gText_HeldItem, 0 .4byte gText_Exit, 0 gUnknown_0858B390:: @ 58B390 -@ replacing .incbin "baserom.gba", 0x0058b390, 0x20 - .4byte gUnknown_085EB227, 0 - .4byte gUnknown_085EB234, 0 - .4byte gUnknown_085EB241, 0 + .4byte gText_LinkContest, 0 + .4byte gText_AboutE_Mode, 0 + .4byte gText_AboutG_Mode, 0 .4byte gText_Cancel2, 0 gUnknown_0858B3B0:: @ 58B3B0 -@ replacing .incbin "baserom.gba", 0x0058b3b0, 0x18 - .4byte gUnknown_085EB24E, 0 - .4byte gUnknown_085EB255, 0 + .4byte gText_E_Mode, 0 + .4byte gText_G_Mode, 0 .4byte gText_Exit, 0 gUnknown_0858B3C8:: @ 58B3C8 -@ replacing .incbin "baserom.gba", 0x0058b3c8, 0x40 .4byte gText_MenuOptionPokedex, 0 .4byte gText_MenuOptionPokemon, 0 .4byte gText_MenuOptionBag, 0 @@ -491,50 +416,42 @@ gUnknown_0858B3C8:: @ 58B3C8 .4byte gText_MenuOptionExit, 0 gUnknown_0858B408:: @ 58B408 -@ replacing .incbin "baserom.gba", 0x0058b408, 0x20 .4byte gUnknown_085EB28A, 0 .4byte gUnknown_085EB290, 0 .4byte gUnknown_085EB295, 0 .4byte gText_Exit, 0 gUnknown_0858B428:: @ 58B428 -@ replacing .incbin "baserom.gba", 0x0058b428, 0x18 - .4byte gUnknown_085EB2AD, 0 - .4byte gUnknown_085EB2BD, 0 + .4byte gText_SouthernIsland, 0 + .4byte gText_BirthIsland, 0 .4byte gText_Exit, 0 gUnknown_0858B440:: @ 58B440 -@ replacing .incbin "baserom.gba", 0x0058b440, 0x18 - .4byte gUnknown_085EB2AD, 0 - .4byte gUnknown_085EB2CA, 0 + .4byte gText_SouthernIsland, 0 + .4byte gText_FarawayIsland, 0 .4byte gText_Exit, 0 gUnknown_0858B458:: @ 58B458 -@ replacing .incbin "baserom.gba", 0x0058b458, 0x18 - .4byte gUnknown_085EB2BD, 0 - .4byte gUnknown_085EB2CA, 0 + .4byte gText_BirthIsland, 0 + .4byte gText_FarawayIsland, 0 .4byte gText_Exit, 0 gUnknown_0858B470:: @ 58B470 -@ replacing .incbin "baserom.gba", 0x0058b470, 0x20 - .4byte gUnknown_085EB2AD, 0 - .4byte gUnknown_085EB2BD, 0 - .4byte gUnknown_085EB2CA, 0 + .4byte gText_SouthernIsland, 0 + .4byte gText_BirthIsland, 0 + .4byte gText_FarawayIsland, 0 .4byte gText_Exit, 0 gUnknown_0858B490:: @ 58B490 -@ replacing .incbin "baserom.gba", 0x0058b490, 0x18 .4byte gUnknown_085EB2E4, 0 .4byte gUnknown_085EB2F0, 0 .4byte gText_Exit, 0 gUnknown_0858B4A8:: @ 58B4A8 -@ replacing .incbin "baserom.gba", 0x0058b4a8, 0x10 .4byte gText_Yes, 0 .4byte gUnknown_085EB2FC, 0 gUnknown_0858B4B8:: @ 58B4B8 -@ replacing .incbin "baserom.gba", 0x0058b4b8, 0x30 .4byte gUnknown_085EB3DF, 0 .4byte gUnknown_085EB3EA, 0 .4byte gUnknown_085EB3F1, 0 @@ -543,14 +460,12 @@ gUnknown_0858B4B8:: @ 58B4B8 .4byte gText_Exit, 0 gUnknown_0858B4E8:: @ 58B4E8 -@ replacing .incbin "baserom.gba", 0x0058b4e8, 0x20 .4byte gUnknown_085EB415, 0 .4byte gUnknown_085EB41D, 0 .4byte gUnknown_085EB424, 0 .4byte gText_Exit, 0 gUnknown_0858B508:: @ 58B508 -@ replacing .incbin "baserom.gba", 0x0058b508, 0x28 .4byte gUnknown_085EB45C, 0 .4byte gUnknown_085EB469, 0 .4byte gUnknown_085EB475, 0 @@ -558,7 +473,6 @@ gUnknown_0858B508:: @ 58B508 .4byte gText_Exit, 0 gUnknown_0858B530:: @ 58B530 -@ replacing .incbin "baserom.gba", 0x0058b530, 0x28 .4byte gUnknown_085EB42F, 0 .4byte gUnknown_085EB43A, 0 .4byte gUnknown_085EB444, 0 @@ -566,14 +480,12 @@ gUnknown_0858B530:: @ 58B530 .4byte gText_Exit, 0 gUnknown_0858B558:: @ 58B558 -@ replacing .incbin "baserom.gba", 0x0058b558, 0x20 .4byte gUnknown_085EB48E, 0 .4byte gUnknown_085EB496, 0 .4byte gUnknown_085EB4A3, 0 .4byte gText_Exit, 0 gUnknown_0858B578:: @ 58B578 -@ replacing .incbin "baserom.gba", 0x0058b578, 0x30 .4byte gUnknown_085EB4AD, 0 .4byte gUnknown_085EB4B9, 0 .4byte gUnknown_085EB4C7, 0 @@ -582,7 +494,6 @@ gUnknown_0858B578:: @ 58B578 .4byte gText_Exit, 0 gUnknown_0858B5A8:: @ 58B5A8 -@ replacing .incbin "baserom.gba", 0x0058b5a8, 0x30 .4byte gUnknown_085EB4EB, 0 .4byte gUnknown_085EB4F9, 0 .4byte gUnknown_085EB508, 0 @@ -591,7 +502,6 @@ gUnknown_0858B5A8:: @ 58B5A8 .4byte gText_Exit, 0 gUnknown_0858B5D8:: @ 58B5D8 -@ replacing .incbin "baserom.gba", 0x0058b5d8, 0x28 .4byte gUnknown_085EB532, 0 .4byte gUnknown_085EB543, 0 .4byte gUnknown_085EB555, 0 @@ -599,57 +509,48 @@ gUnknown_0858B5D8:: @ 58B5D8 .4byte gText_Exit, 0 gUnknown_0858B600:: @ 58B600 -@ replacing .incbin "baserom.gba", 0x0058b600, 0x20 .4byte gUnknown_085EB56E, 0 .4byte gUnknown_085EB57E, 0 .4byte gUnknown_085EB589, 0 .4byte gText_Exit, 0 gUnknown_0858B620:: @ 58B620 -@ replacing .incbin "baserom.gba", 0x0058b620, 0x20 .4byte gUnknown_085EB5B6, 0 .4byte gUnknown_085EB5BC, 0 .4byte gUnknown_085EB5C3, 0 .4byte gUnknown_085EB5C8, 0 gUnknown_0858B640:: @ 58B640 -@ replacing .incbin "baserom.gba", 0x0058b640, 0x18 .4byte gUnknown_085EB5B6, 0 .4byte gUnknown_085EB5C3, 0 .4byte gUnknown_085EB5C8, 0 gUnknown_0858B658:: @ 58B658 -@ replacing .incbin "baserom.gba", 0x0058b658, 0x18 .4byte gUnknown_085EB5B6, 0 .4byte gUnknown_085EB5BC, 0 .4byte gUnknown_085EB5C8, 0 gUnknown_0858B670:: @ 58B670 -@ replacing .incbin "baserom.gba", 0x0058b670, 0x10 .4byte gUnknown_085EB5B6, 0 .4byte gUnknown_085EB5C8, 0 gUnknown_0858B680:: @ 58B680 -@ replacing .incbin "baserom.gba", 0x0058b680, 0x10 .4byte gUnknown_085EE14B, 0 .4byte gUnknown_085EE14F, 0 gUnknown_0858B690:: @ 58B690 -@ replacing .incbin "baserom.gba", 0x0058b690, 0x20 .4byte gUnknown_085EB2FF, 0 .4byte gUnknown_085EB310, 0 .4byte gUnknown_085EB317, 0 .4byte gUnknown_085EB31F, 0 gUnknown_0858B6B0:: @ 58B6B0 -@ replacing .incbin "baserom.gba", 0x0058b6b0, 0x20 - .4byte gUnknown_085EB7B8, 0 - .4byte gUnknown_085EB7C7, 0 - .4byte gUnknown_085EB7D0, 0 - .4byte gUnknown_085EB7DB, 0 + .4byte gText_CaveOfOrigin, 0 + .4byte gText_MtPyre, 0 + .4byte gText_SkyPillar, 0 + .4byte gText_DontRemember, 0 gUnknown_0858B6D0:: @ 58B6D0 -@ replacing .incbin "baserom.gba", 0x0058b6d0, 0x30 .4byte gUnknown_085EB4AD, 0 .4byte gUnknown_085EB4B9, 0 .4byte gUnknown_085EB4C7, 0 @@ -658,7 +559,6 @@ gUnknown_0858B6D0:: @ 58B6D0 .4byte gText_Exit, 0 gUnknown_0858B700:: @ 58B700 -@ replacing .incbin "baserom.gba", 0x0058b700, 0x30 .4byte gUnknown_085EB5A6, 0 .4byte gUnknown_085EB45C, 0 .4byte gUnknown_085EB469, 0 @@ -667,7 +567,6 @@ gUnknown_0858B700:: @ 58B700 .4byte gText_Exit, 0 gUnknown_0858B730:: @ 58B730 -@ replacing .incbin "baserom.gba", 0x0058b730, 0x28 .4byte gUnknown_085EB32D, 0 .4byte gUnknown_085EB33E, 0 .4byte gUnknown_085EB350, 0 @@ -675,12 +574,10 @@ gUnknown_0858B730:: @ 58B730 .4byte gText_Exit, 0 gUnknown_0858B758:: @ 58B758 -@ replacing .incbin "baserom.gba", 0x0058b758, 0x8 .4byte gText_Exit, 0 gUnknown_0858B760:: @ 858B760 -@ replacing .incbin "baserom.gba", 0x0058b760, 0x390 .4byte 0x0858abd8, 3 .4byte gUnknown_0858B758, 1 .4byte gUnknown_0858ABF0, 3 @@ -797,16 +694,55 @@ gUnknown_0858B760:: @ 858B760 .4byte gUnknown_0858B730, 5 gUnknown_0858BAF0:: @ 858BAF0 - .incbin "baserom.gba", 0x58baf0, 0x78 + .4byte gText_Cool + .4byte gText_Beauty + .4byte gText_Cute + .4byte gText_Smart + .4byte gText_Tough + .4byte gText_Normal + .4byte gText_Super + .4byte gText_Hyper + .4byte gText_Master + .4byte gText_Cool2 + .4byte gText_Beauty2 + .4byte gText_Cute2 + .4byte gText_Smart2 + .4byte gText_Tough2 + .4byte gText_Items + .4byte gText_Key_Items + .4byte gText_Poke_Balls + .4byte gText_TMs_Hms + .4byte gText_Berries2 + .4byte gText_Single2 + .4byte gText_Double2 + .4byte gText_Multi + .4byte gText_MultiLink + .4byte gText_BattleTower2 + .4byte gText_BattleDome + .4byte gText_BattleFactory + .4byte gText_BattlePalace + .4byte gText_BattleArena + .4byte gText_BattlePike + .4byte gText_BattlePyramid gUnknown_0858BB68:: @ 858BB68 - .incbin "baserom.gba", 0x58bb68, 0x8 + .byte 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F +.align 2 gUnknown_0858BB70:: @ 858BB70 - .incbin "baserom.gba", 0x58bb70, 0x10 + .4byte gText_SomeonesPC + .4byte gText_LanettesPC + .4byte gText_PlayersPC + .4byte gText_LogOff gUnknown_0858BB80:: @ 858BB80 - .incbin "baserom.gba", 0x58bb80, 0x1c + .4byte gText_SlateportCity + .4byte gText_BattleFrontier + .4byte gText_SouthernIsland + .4byte gText_NavelRock + .4byte gText_BirthIsland + .4byte gText_FarawayIsland + .4byte gText_Exit gUnknown_0858BB9C:: @ 858BB9C .incbin "baserom.gba", 0x58bb9c, 0x10 diff --git a/data/strings.s b/data/strings.s index 2b88c6d03..fee4a0d66 100644 --- a/data/strings.s +++ b/data/strings.s @@ -1946,7 +1946,7 @@ gUnknown_085EB057:: @ 85EB057 gUnknown_085EB062:: @ 85EB062 .string "GREEN SHARD$" -gUnknown_085EB06E:: @ 85EB06E +gText_BattleFrontier:: @ 85EB06E .string "BATTLE FRONTIER$" gUnknown_085EB07E:: @ 85EB07E @@ -1985,46 +1985,46 @@ gText_Smart:: @ 85EB0F9 gText_Tough:: @ 85EB0FF .string "TOUGH$" -gUnknown_085EB105:: @ 85EB105 +gText_Normal:: @ 85EB105 .string "NORMAL$" -gUnknown_085EB10C:: @ 85EB10C +gText_Super:: @ 85EB10C .string "SUPER$" -gUnknown_085EB112:: @ 85EB112 +gText_Hyper:: @ 85EB112 .string "HYPER$" -gUnknown_085EB118:: @ 85EB118 +gText_Master:: @ 85EB118 .string "MASTER$" -gUnknown_085EB11F:: @ 85EB11F +gText_Cool2:: @ 85EB11F .string "COOL$" -gUnknown_085EB124:: @ 85EB124 +gText_Beauty2:: @ 85EB124 .string "BEAUTY$" -gUnknown_085EB12B:: @ 85EB12B +gText_Cute2:: @ 85EB12B .string "CUTE$" -gUnknown_085EB130:: @ 85EB130 +gText_Smart2:: @ 85EB130 .string "SMART$" -gUnknown_085EB136:: @ 85EB136 +gText_Tough2:: @ 85EB136 .string "TOUGH$" -gUnknown_085EB13C:: @ 85EB13C +gText_Items:: @ 85EB13C .string "ITEMS$" -gUnknown_085EB142:: @ 85EB142 +gText_Key_Items:: @ 85EB142 .string "KEY ITEMS$" -gUnknown_085EB14C:: @ 85EB14C +gText_Poke_Balls:: @ 85EB14C .string "POKé BALLS$" -gUnknown_085EB157:: @ 85EB157 +gText_TMs_Hms:: @ 85EB157 .string "TMs & HMs$" -gUnknown_085EB161:: @ 85EB161 +gText_Berries2:: @ 85EB161 .string "BERRIES$" gText_SomeonesPC:: @ 85EB169 @@ -2042,58 +2042,58 @@ gText_HallOfFame:: @ 85EB18B gText_LogOff:: @ 85EB198 .string "LOG OFF$" -gUnknown_085EB1A0:: @ 85EB1A0 +gText_Opponent:: @ 85EB1A0 .string "OPPONENT$" -gUnknown_085EB1A9:: @ 85EB1A9 +gText_Tourney_Tree:: @ 85EB1A9 .string "TOURNEY TREE$" -gUnknown_085EB1B6:: @ 85EB1B6 +gText_ReadyToStart:: @ 85EB1B6 .string "READY TO START$" -gUnknown_085EB1C5:: @ 85EB1C5 +gText_NormalRank:: @ 85EB1C5 .string "NORMAL RANK$" -gUnknown_085EB1D1:: @ 85EB1D1 +gText_SuperRank:: @ 85EB1D1 .string "SUPER RANK$" -gUnknown_085EB1DC:: @ 85EB1DC +gText_HyperRank:: @ 85EB1DC .string "HYPER RANK$" -gUnknown_085EB1E7:: @ 85EB1E7 +gText_MasterRank:: @ 85EB1E7 .string "MASTER RANK$" -gUnknown_085EB1F3:: @ 85EB1F3 +gText_Single2:: @ 85EB1F3 .string "SINGLE$" -gUnknown_085EB1FA:: @ 85EB1FA +gText_Double2:: @ 85EB1FA .string "DOUBLE$" -gUnknown_085EB201:: @ 85EB201 +gText_Multi:: @ 85EB201 .string "MULTI$" -gUnknown_085EB207:: @ 85EB207 +gText_MultiLink:: @ 85EB207 .string "MULTI-LINK$" -gUnknown_085EB212:: @ 85EB212 +gText_BattleBag:: @ 85EB212 .string "BATTLE BAG$" -gUnknown_085EB21D:: @ 85EB21D +gText_HeldItem:: @ 85EB21D .string "HELD ITEM$" -gUnknown_085EB227:: @ 85EB227 +gText_LinkContest:: @ 85EB227 .string "LINK CONTEST$" -gUnknown_085EB234:: @ 85EB234 +gText_AboutE_Mode:: @ 85EB234 .string "ABOUT E-MODE$" -gUnknown_085EB241:: @ 85EB241 +gText_AboutG_Mode:: @ 85EB241 .string "ABOUT G-MODE$" -gUnknown_085EB24E:: @ 85EB24E +gText_E_Mode:: @ 85EB24E .string "E-MODE$" -gUnknown_085EB255:: @ 85EB255 +gText_G_Mode:: @ 85EB255 .string "G-MODE$" gText_MenuOptionPokedex:: @ 85EB25C @@ -2138,16 +2138,16 @@ gUnknown_085EB29A:: @ 85EB29A gUnknown_085EB2A3:: @ 85EB2A3 .string "BLUE TENT$" -gUnknown_085EB2AD:: @ 85EB2AD +gText_SouthernIsland:: @ 85EB2AD .string "SOUTHERN ISLAND$" -gUnknown_085EB2BD:: @ 85EB2BD +gText_BirthIsland:: @ 85EB2BD .string "BIRTH ISLAND$" -gUnknown_085EB2CA:: @ 85EB2CA +gText_FarawayIsland:: @ 85EB2CA .string "FARAWAY ISLAND$" -gUnknown_085EB2D9:: @ 85EB2D9 +gText_NavelRock:: @ 85EB2D9 .string "NAVEL ROCK$" gUnknown_085EB2E4:: @ 85EB2E4 @@ -2477,22 +2477,22 @@ gUnknown_085EB77D:: @ 85EB77D gUnknown_085EB78A:: @ 85EB78A .string "EXCHANGE SERVICE$" -gUnknown_085EB79B:: @ 85EB79B +gText_LilycoveCity:: @ 85EB79B .string "LILYCOVE CITY$" -gUnknown_085EB7A9:: @ 85EB7A9 +gText_SlateportCity:: @ 85EB7A9 .string "SLATEPORT CITY$" -gUnknown_085EB7B8:: @ 85EB7B8 +gText_CaveOfOrigin:: @ 85EB7B8 .string "CAVE OF ORIGIN$" -gUnknown_085EB7C7:: @ 85EB7C7 +gText_MtPyre:: @ 85EB7C7 .string "MT. PYRE$" -gUnknown_085EB7D0:: @ 85EB7D0 +gText_SkyPillar:: @ 85EB7D0 .string "SKY PILLAR$" -gUnknown_085EB7DB:: @ 85EB7DB +gText_DontRemember:: @ 85EB7DB .string "Don’t remember$" gText_Exit:: @ 85EB7EA @@ -3563,25 +3563,25 @@ gText_BattleTower:: @ 85ED0D3 gText_WSlashStraightSlash:: @ 85ED0E0 .string "W/{COLOR RED}{SHADOW LIGHT_RED}{STR_VAR_1}{COLOR DARK_GREY}{SHADOW LIGHT_GREY} STRAIGHT/{COLOR RED}{SHADOW LIGHT_RED}{STR_VAR_2}$" -gUnknown_085ED104:: @ 85ED104 +gText_BattleTower2:: @ 85ED104 .string "BATTLE TOWER$" -gUnknown_085ED111:: @ 85ED111 +gText_BattleDome:: @ 85ED111 .string "BATTLE DOME$" -gUnknown_085ED11D:: @ 85ED11D +gText_BattlePalace:: @ 85ED11D .string "BATTLE PALACE$" -gUnknown_085ED12B:: @ 85ED12B +gText_BattleFactory:: @ 85ED12B .string "BATTLE FACTORY$" -gUnknown_085ED13A:: @ 85ED13A +gText_BattleArena:: @ 85ED13A .string "BATTLE ARENA$" -gUnknown_085ED147:: @ 85ED147 +gText_BattlePike:: @ 85ED147 .string "BATTLE PIKE$" -gUnknown_085ED153:: @ 85ED153 +gText_BattlePyramid:: @ 85ED153 .string "BATTLE PYRAMID$" .align 2 diff --git a/graphics/berry_blender/arrow.pal b/graphics/berry_blender/arrow.pal new file mode 100644 index 000000000..4c975292d --- /dev/null +++ b/graphics/berry_blender/arrow.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +0 0 0 +255 255 255 +213 222 238 +180 197 230 +148 172 222 +115 148 205 +82 123 197 +49 98 189 +255 180 205 +255 115 98 +255 49 0 +205 65 65 +189 24 24 +148 16 16 +74 57 139 +8 0 82 diff --git a/graphics/berry_blender/arrow.png b/graphics/berry_blender/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..a40948824e2b86c33c29344e72b86ced35840392 GIT binary patch literal 682 zcmV;b0#*HqP)wv2Noq42HeOi$>iOdq@Y5w4WgMk~L-ubSw~QKOpwIloUx>a!{ZsaKmZS z=bxl3eNA&*?Z*+^k0gX}0Bgi+RkJ$jBUm>A4JO z*L*G7buEAdKA)?CAO&xmf^^mpKHql`Dc_y#Lin+4uDwvu^(fzmLG^^+tsnUDKs!?W)Bf?4yHYXJrh45h74esc+K+nC-AbLCKPbkc>$oHpXIie%K_j;YA*eJ)iDCVfOfrrQ_wCF0B-nT{#$d|NOkAg(0GohYBI z0K7o-fPp?W$*TYWVGy`J7@dj+Uat&bCZeqmhtP*D8>j$gBH92>fJEv6%|s^f1_*+X z711hyeQ4^O>dz4tPEZfq=+|1Okq#58=A5Crx}601q<)31Uzt zg7XLIuk$=DKzd9BHK-Bbnf^QhzzDFCKJhUTR0ITY{dry7!q5An=OzIGLJz-W7QjGz zJ|MVmtg7E|{sRI_$V(jZ8Ni-}L)AZW00H+IAP4=!O~D#xB4_}#^TG9@0wxyr{fHHi87VYiKnQqD5PX}vKv-zU!Fp~| zYM5GKJ{Vmv$OGwVL_UyO03^sGagU($tOPIu9m=%BZi7J&@xj*_G$$JTD7j0-8np8c z4*{VAq#yGIehzTaWkD0CdU3*B4}pRbdkJsMz9YTct?=gY^CN&D%=9)uTA1qdj8wa= zCfFdDwQ`Y7FDQaaFcPq)mDb2seZzq!v;o;U%tE`&m#>wSfwJFJgrHtXRKm6^1OCW= z1tD2zFAnpP7#lztFaXH{0isw>h6aWf_~adJ19^zp7N~dvSq3($n_;0P60OX!H$Y9* zTVOAg*r&+5ycy6I(!y&dbw>E!0Jq>L@{EW%_qYMF;8A_&rFVj)E~xqh$XkY$nnC1L g`RiBz%YPgA2lUgB&OC%IZ2$lO07*qoM6N<$f-m%F(EtDd literal 0 HcmV?d00001 diff --git a/graphics/berry_blender/center_map.bin b/graphics/berry_blender/center_map.bin new file mode 100644 index 0000000000000000000000000000000000000000..ef28d5093b8e292f372e634bbc359cc35f817952 GIT binary patch literal 1024 zcmZQz7&L&9iJ66!jhzFBgE+akd3gEw1q6k#Dqs{A5fu}ckd%^^!D@o6oV*pU3 z7!({58WtXbO+GS8Dmo@ME1Q%>V%Z0094-oB#j-|Nj90|CGJGz5oCJMQ{d400040 zNklk3`M!Y$`VPD+l)j-GolDRMYvZas+=Xc!Ey%*`dNDhk8Ri`DB9oo z>5swRE{eknAxx&Os%kPdKslLu92JPQ0;v}8m1+gt_!hvrN98OC!2){p8ebNCqpSn9 z?|7pA70{nXz%kP-5pc{jErA?!>Y%#(0$@>@o3bYUEX!>7jmU3m>Zk}V6Q%BBh6f6~ zO#g_=^Us$A?%o=*Wdrzy0e1ikFuscgVP1hr1Ij8m)q^IR%V8K65VLZ1UAsICx|AXP z?8bm?i~;Kd1_?SD=x@9-#N~Q1M7hHNvb;>2ovTSK-8 zSSL?s4vWYTEam0{Gc|(820S zQpe};C*TbEO~)y-Mb2&ps$~t^MQv8OUAEE>;)a)5fQlO100000NkvXXu0mjfg2BfI literal 0 HcmV?d00001 diff --git a/graphics/berry_blender/marubatsu.png b/graphics/berry_blender/marubatsu.png new file mode 100644 index 0000000000000000000000000000000000000000..f927bbce94caeb4963cebdc65eec903094d80152 GIT binary patch literal 293 zcmeAS@N?(olHy`uVBq!ia0vp^0zmA*!VDxI2ESSgqznRlLR^6~1pL3s@INRh>HmL* zz5kQ`C!J+r_zy&L<^W}ZV*me7*}He||NsA83)nn>LK{3?978lF_6B%!xfpVMX1iCk ztynI6?}Q7hcSvc77;T-u=b>)fbEhN|HxWTrC$|h^?ao<@VQh&4jjb6c>$o$yryN=N zga4et(-@EL(^Jw7HcZ}^q*}Yz)h@Evqfobsu&=*SclFOMjbR{2Tr) zPBZ*}xxr}vMW^=(+ktw||2tg0tJ?R9><23j|DFA|rsCfw#9g(mlHI`^s?M>u`L5OB hDaDGqdY5aDi9cTVm0RJv(0Pz&Jzf1=);T3K0RTX%cl`hW literal 0 HcmV?d00001 diff --git a/graphics/berry_blender/misc.pal b/graphics/berry_blender/misc.pal new file mode 100644 index 000000000..9c1db8d12 --- /dev/null +++ b/graphics/berry_blender/misc.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +0 0 0 +0 0 0 +0 0 0 +255 213 0 +255 82 82 +98 255 255 +0 189 255 +98 255 98 +205 0 0 +255 0 0 +255 156 156 +0 0 0 +255 255 0 +255 255 148 +189 189 189 +255 255 255 diff --git a/graphics/berry_blender/outer.pal b/graphics/berry_blender/outer.pal new file mode 100644 index 000000000..c3b83cf16 --- /dev/null +++ b/graphics/berry_blender/outer.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +0 0 0 +255 255 255 +213 222 238 +180 197 230 +148 172 222 +115 148 205 +82 123 197 +49 98 189 +255 180 205 +255 115 98 +255 49 0 +205 65 65 +189 24 24 +148 123 197 +74 57 139 +8 0 82 diff --git a/graphics/berry_blender/outer.png b/graphics/berry_blender/outer.png new file mode 100644 index 0000000000000000000000000000000000000000..d8040b02205fe71a8e56137b79744d7399d3a6d6 GIT binary patch literal 1880 zcmV-e2dDUnP)aq{7S;G@NEEC?S0U_qK3 z8~|bZp#Xm``6`7Vc5T4NC4j##3Aqj!?xi3La=`#R+|2pymkRkv5lR5WF!%lO0Rqr9 z7i6&;eIf11JR#8#Ig?$F0DqDA3yeVr+|H%*BiYMIGAjf5Ljn9~%-EOXD&SLLKT4)* zq^%=@CsF~1(L9Jo6oU@9=JvWdM+kxj2xLYV}D z24H>=jZ^Gw9dOB}&aL8a=rBL50-SaBNCyC6FHOES0hoYWMNwq${2&f107!!YAVLLz z3D^ff@g62f5LW=s%mg68F#%HvC<-c-p$S;803eeS6F`aN0O3Ta1Dq-Ve3&!>xD!Fx z3IIY2fIHC+V1eV#Lbip|kWD$@H$^}v$OUiYimv2i1m2@D4nhKK!Zf@TW6%H;!UYL% zW-y?aAqNbjV4DMU2b}CL9q_&a5H1iPNRp@qu=ESVg+{<|H%Sh*32;Y?z*o20O^1enSl2d0J=Z`UfB<~0kHE}i@@>xCtZN-3f>3e_XMDfz+sUIpng;UiU9!= z{&o!jMg)xjDHOx*$i;E$z}ip)@NEDKpEm=Z8xd3i1p?wQ+}adEG5k4lu@CA2o(+I$ zxmnhRT7ZfG0Z%Ld)P|?h1B}4{gx8$_qc%_yMlOzm5}-u@Q#G;xW^I5NmZDpEFIWI0 z2{@Juqc$L5R|7oDRtIEP<-l_8Ju^}O0Ivq1hk!}AdR`jLY5-3v0JFdnK>6%lcLT(3 zm_$ykSz&~u0tH_}}|01V|(BE;d{&;d{cQ54l=vH*Ez0X*8i3kL|GO=k|s z@-_gvpd_>wmYKfY!IjAZcyS!90?<1_E?dChkl0?@s4jK^BqXj`8+!w^zW;v!+@8`5 z*vMd?a^bpJ2F>gO-_tcySJY;}1z4jUzPNDnMMgYQc*W0wdC?BQyIt|?F8wko0jb>w zKnC=S{0c_+Ib9)?PC)50+`Lf*z&CXOnoN{LJz>IaQt267o$6$g(|Lt%Yz9PX?7#+O zjaO0FNvMKKVipux(k#H5C<(9~7L_4TfSQ_U0V36`3~38M-5>x|1E2^6YumCtoM3GT zOF+ZA06hc%x({E2HPxQrE554*$fXSjV8nR+pKakrTD769kKn2Sw53fhuG|A&|L<`? z*~WF@o(WKkt6bhG2eSST27%tDbzv}Isu#88-91oCliX0^&5>%`0J*{F4PfDe+hqtf z09n*p09%8t@&Pn60oo3u836VJ4RAH807MMU0EYHV<#2U?8p<|6C7}r**IAW<6#@Em zt^w?nF*FS%M-z(Rt_9#O!0>&5Hn;guF58+tf8;R%;av?t&jkYxDBBgla>ug)6hp*& z3twS6m+eU<0t@i)TDSlOh5srqD55>o06c;_Er8mR)&*dXMGQ?vwGzQoRs}HOLQ`3< zI502(RVfjo1|Up7N9z>j1g`=A20%4nCBT#ecs&<2Km)9InDc`uxdzA@paEuG_H+~` z*8oid{+y6hcWbubVVqn8bO23d?J%xU@HkNGz7nv_*ib(XYzFi^kZb|;I}&XH^gEPo z1N1r;Zj_FL>1C~vE?68}j>fM#0bc9jeEzf(z~Yv_2l9B(4FJNmLU7^c%RJuf9?Ecg z-0&C463=n^09yZ~`HujS2I&om8>BY?=YE|w0+62e5a|j22-9J(c#S(<1DT6$PM+t# zv&Xr5;D9RpBc}N+=s7Ah&d*Wbf}W$k1wH?jS84{%03b~@z+OMVAq>;H5JGS72L!wU zJwt`Y*%|5^&@2{T>0YK~GVkae9jS8uS$PHR$QjX}pgBD+k5R z`~?CwK;29}>(WD_czDDo3D>iqTLioUJwk=X(Glt^&?D4Wphqw7?-#W> z*uVMaI|Q779-~6z_!#vB^ceL7^!TSw_HS^3V$}iV#q)kS7{?**cks_^1HinrUoWIM z5QYIA#+rcM-6+R_8Nw<9sVHvQIap;VBf!o9xZv~m=ffus)9qTY9Iy?3kbgp5+ocYc)d)07!yf~quQ zGRY+4QbP?Xozw{(*T48(#vkG;p^_@4GP&`zG0B+8kLjq6=&mz zqAF(ct?7CNLOQ4e+OK_j1~Zw(Z00bRdCbSB{3@V=DwOqed8=ghU+R0cN4vF4JM{t< zvWUejVJXX4j#IgmTX~e%5z7Dh+Uo;D!jmsgLXRTEM^C}m)(DE z{&Ih`S3KetmpJ7muXxQH-tvz3e87ndHy*tCSt*~toF9^)1jH{s`N%Mz_{8`guzId@j3_Jp#7U4OmG_%evueru4Z2>}>1t(UGrLOIf^oH4)v0>bkoBufm#xao PUsG!O!E^`yhYtJ$n8XS4 literal 0 HcmV?d00001 diff --git a/graphics/berry_blender/particles.png b/graphics/berry_blender/particles.png new file mode 100644 index 0000000000000000000000000000000000000000..d0086b0291cdf9eccb02aae5f787953319a8cfce GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^96)Tr!VDyhqL+vQDT4r?5LX}#0spTu{0|CB`v0F{ z@BgI#NoN@t{sYmRIY3#U*#G}i_U_&L|Nnp20yYnzP>QFEV~E7m!EyTL>C+QA+deUgG|gpnQ?L|BIq Date: Sun, 5 Nov 2017 00:16:09 +0100 Subject: [PATCH 05/18] dump some of the item menu --- asm/party_menu.s | 2 +- data/item_menu.s | 77 ++++++++++++++++++++++++++++++++++------------ data/script_menu.s | 2 +- data/strings.s | 22 ++++++------- 4 files changed, 71 insertions(+), 32 deletions(-) diff --git a/asm/party_menu.s b/asm/party_menu.s index 3d2af7e7d..280b658d4 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -4249,7 +4249,7 @@ _081B243E: adds r0, r4, 0 movs r1, 0 bl FillWindowPixelBuffer - ldr r5, =gText_Confirm + ldr r5, =gMenuText_Confirm movs r0, 0 adds r1, r5, 0 movs r2, 0x30 diff --git a/data/item_menu.s b/data/item_menu.s index 762f10ca4..c63b33396 100644 --- a/data/item_menu.s +++ b/data/item_menu.s @@ -4,61 +4,100 @@ .section .rodata gUnknown_08613F90:: @ 8613F90 - .incbin "baserom.gba", 0x613f90, 0xc + .4byte 0x11F0, 0x1E1, 0x21DE +@ possibly a struct gUnknown_08613F9C:: @ 8613F9C - .incbin "baserom.gba", 0x613f9c, 0x18 + .4byte 0 + .4byte bag_menu_change_item_callback + .4byte sub_81AB520 + .4byte 0 + .4byte 0x80000 + .4byte 0x7003011 gUnknown_08613FB4:: @ 8613FB4 - .incbin "baserom.gba", 0x613fb4, 0x78 + .4byte gMenuText_Use, ItemMenu_UseOutOfBattle + .4byte gMenuText_Toss, ItemMenu_Toss + .4byte gMenuText_Register, ItemMenu_Register + .4byte gMenuText_Give, ItemMenu_Give + .4byte gText_Cancel2, ItemMenu_Cancel + .4byte gMenuText_Use, ItemMenu_UseInBattle + .4byte gMenuText_Check, ItemMenu_UseOutOfBattle + .4byte gMenuText_Walk, ItemMenu_UseOutOfBattle + .4byte gMenuText_Deselect, ItemMenu_Register + .4byte gMenuText_CheckTag, ItemMenu_CheckTag + .4byte gMenuText_Confirm, unknown_ItemMenu_Confirm + .4byte gMenuText_Show, unknown_ItemMenu_Show + .4byte gMenuText_Give2, unknown_ItemMenu_Give2 + .4byte gMenuText_Confirm, unknown_ItemMenu_Confirm2 + .4byte gText_EmptyString2, 0 gUnknown_0861402C:: @ 861402C - .incbin "baserom.gba", 0x61402c, 0x4 + .byte 0, 3, 1, 4 gUnknown_08614030:: @ 8614030 - .incbin "baserom.gba", 0x614030, 0x4 + .byte 0, 2, 14, 4 gUnknown_08614034:: @ 8614034 - .incbin "baserom.gba", 0x614034, 0x4 + .byte 3, 14, 1, 4 gUnknown_08614038:: @ 8614038 - .incbin "baserom.gba", 0x614038, 0x4 + .byte 0, 3, 14, 4 gUnknown_0861403C:: @ 861403C - .incbin "baserom.gba", 0x61403c, 0x6 + .byte 9, 14, 0, 3, 1, 4 gUnknown_08614042:: @ 8614042 - .incbin "baserom.gba", 0x614042, 0x2 + .byte 5, 4 gUnknown_08614044:: @ 8614044 - .incbin "baserom.gba", 0x614044, 0x2 + .byte 3, 4 gUnknown_08614046:: @ 8614046 - .incbin "baserom.gba", 0x614046, 0x1 + .byte 4 gUnknown_08614047:: @ 8614047 - .incbin "baserom.gba", 0x614047, 0x4 + .byte 10, 9, 14, 4 gUnknown_0861404B:: @ 861404B - .incbin "baserom.gba", 0x61404b, 0x2 + .byte 11, 4 gUnknown_0861404D:: @ 861404D - .incbin "baserom.gba", 0x61404d, 0x2 + .byte 12, 4 gUnknown_0861404F:: @ 861404F - .incbin "baserom.gba", 0x61404f, 0x5 + .byte 13, 4 +.align 2 gUnknown_08614054:: @ 8614054 - .incbin "baserom.gba", 0x614054, 0x30 + .4byte unknown_item_menu_type + .4byte unknown_item_menu_type + .4byte item_menu_type_2 + .4byte display_sell_item_ask_str + .4byte unknown_ItemMenu_Confirm + .4byte unknown_item_menu_type + .4byte display_deposit_item_ask_str + .4byte unknown_item_menu_type + .4byte unknown_item_menu_type + .4byte unknown_item_menu_type + .4byte 0 + .4byte item_menu_type_b +.align 2 gUnknown_08614084:: @ 8614084 - .incbin "baserom.gba", 0x614084, 0x8 + .4byte BagMenuActuallyToss + .4byte BagMenuCancelToss gUnknown_0861408C:: @ 861408C - .incbin "baserom.gba", 0x61408c, 0x8 + .4byte sub_81AD84C + .4byte sub_81AD6FC +@probably a struct gUnknown_08614094:: @ 8614094 - .incbin "baserom.gba", 0x614094, 0x10 + .4byte 0x1101C00 + .4byte 0xFFFF1064 + .4byte 0x6FFFFF + .4byte 0x6F gUnknown_086140A4:: @ 86140A4 .incbin "baserom.gba", 0x6140a4, 0xc0 diff --git a/data/script_menu.s b/data/script_menu.s index 626f0a268..0afe3579a 100644 --- a/data/script_menu.s +++ b/data/script_menu.s @@ -39,7 +39,7 @@ gUnknown_0858AC78:: @ 58AC78 .4byte gText_Exit, 0 gUnknown_0858AC90:: @ 58AC90 - .4byte gUnknown_085E8CCB, 0 + .4byte gMenuText_Register, 0 .4byte gUnknown_085EAE12, 0 .4byte gUnknown_085EAE1B, 0 .4byte gText_Cancel2, 0 diff --git a/data/strings.s b/data/strings.s index fee4a0d66..42dcc2316 100644 --- a/data/strings.s +++ b/data/strings.s @@ -534,25 +534,25 @@ gUnknown_085E8CAC:: @ 85E8CAC gText_FlyToWhere:: @ 85E8CB4 .string "FLY to where?$" -gUnknown_085E8CC2:: @ 85E8CC2 +gMenuText_Use:: @ 85E8CC2 .string "USE$" -gUnknown_085E8CC6:: @ 85E8CC6 +gMenuText_Toss:: @ 85E8CC6 .string "TOSS$" -gUnknown_085E8CCB:: @ 85E8CCB +gMenuText_Register:: @ 85E8CCB .string "REGISTER$" -gUnknown_085E8CD4:: @ 85E8CD4 +gMenuText_Give:: @ 85E8CD4 .string "GIVE$" -gUnknown_085E8CD9:: @ 85E8CD9 +gMenuText_CheckTag:: @ 85E8CD9 .string "CHECK TAG$" -gText_Confirm:: @ 85E8CE3 +gMenuText_Confirm:: @ 85E8CE3 .string "CONFIRM$" -gUnknown_085E8CEB:: @ 85E8CEB +gMenuText_Walk:: @ 85E8CEB .string "WALK$" gText_Cancel:: @ 85E8CF0 @@ -561,7 +561,7 @@ gText_Cancel:: @ 85E8CF0 gText_Cancel2:: @ 85E8CF7 .string "CANCEL$" -gUnknown_085E8CFE:: @ 85E8CFE +gMenuText_Show:: @ 85E8CFE .string "SHOW$" gText_EmptyString2:: @ 85E8D03 @@ -582,13 +582,13 @@ gUnknown_085E8D15:: @ 85E8D15 gUnknown_085E8D1A:: @ 85E8D1A .string "STORE$" -gUnknown_085E8D20:: @ 85E8D20 +gMenuText_Check:: @ 85E8D20 .string "CHECK$" gText_None:: @ 85E8D26 .string "NONE$" -gUnknown_085E8D2B:: @ 85E8D2B +gMenuText_Deselect:: @ 85E8D2B .string "DESELECT$" gText_ThreeMarks:: @ 85E8D34 @@ -642,7 +642,7 @@ gText_GoBackPrevMenu:: @ 85E8D62 gText_WhatWouldYouLike:: @ 85E8D80 .string "What would you like to do?$" -gUnknown_085E8D9B:: @ 85E8D9B +gMenuText_Give2:: @ 85E8D9B .string "GIVE$" gText_xVar1:: @ 85E8DA0 From 99e697223f86356ef178e4af90f3a3b4b7132591 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 5 Nov 2017 00:25:09 +0100 Subject: [PATCH 06/18] get rid of two baseroms --- data/mauville_old_man.s | 4 ++-- data/save.s | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/data/mauville_old_man.s b/data/mauville_old_man.s index 539cace62..13e26f513 100644 --- a/data/mauville_old_man.s +++ b/data/mauville_old_man.s @@ -5,8 +5,8 @@ .align 2, 0 gUnknown_0859EFE4:: @ 859EFE4 - .incbin "baserom.gba", 0x59efe4, 0xc - + .2byte 0x2811, 0x1029, 0x1018, 0xE0D, 0x1A1A, 0x1A1D + gUnknown_0859EFF0:: @ 859EFF0 .incbin "baserom.gba", 0x59eff0, 0x20 diff --git a/data/save.s b/data/save.s index 29b750b3a..c0b0e007f 100644 --- a/data/save.s +++ b/data/save.s @@ -4,4 +4,18 @@ .section .rodata gSaveSectionOffsets:: @ 85CDC00 - .incbin "baserom.gba", 0x5cdc00, 0x38 + .2byte 0, 0xF2C + .2byte 0, 0xF80 + .2byte 0xF80, 0xF80 + .2byte 0x1F00, 0xF80 + .2byte 0x2E80, 0xF08 + .2byte 0, 0xF80 + .2byte 0xF80, 0xF80 + .2byte 0x1F00, 0xF80 + .2byte 0x2E80, 0xF80 + .2byte 0x3E00, 0xF80 + .2byte 0x4D80, 0xF80 + .2byte 0x5D00, 0xF80 + .2byte 0x6C80, 0xF80 + .2byte 0x7C00, 0x7D0 + \ No newline at end of file From bd56bb073f87eeca6e71b14ab1ec0a11ea1ee3a4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 5 Nov 2017 12:05:07 +0100 Subject: [PATCH 07/18] start working on hall of fame --- asm/credits.s | 2 +- asm/hall_of_fame.s | 764 +------------------------------------------ asm/link.s | 6 +- asm/rom6.s | 4 +- asm/start_menu.s | 2 +- asm/trade.s | 4 +- data/event_scripts.s | 2 +- data/hall_of_fame.s | 4 +- include/malloc.h | 6 + ld_script.txt | 1 + src/hall_of_fame.c | 319 ++++++++++++++++++ sym_ewram.txt | 4 +- 12 files changed, 354 insertions(+), 764 deletions(-) diff --git a/asm/credits.s b/asm/credits.s index 0b2da16b8..a5097f83c 100644 --- a/asm/credits.s +++ b/asm/credits.s @@ -26,7 +26,7 @@ sub_81754DC: @ 81754DC ands r0, r1 cmp r0, 0 beq _08175522 - ldr r0, =gUnknown_0203BCE4 + ldr r0, =HasHallOfFameRecords ldrb r0, [r0] cmp r0, 0 beq _08175522 diff --git a/asm/hall_of_fame.s b/asm/hall_of_fame.s index 9227c1795..0b1530b03 100644 --- a/asm/hall_of_fame.s +++ b/asm/hall_of_fame.s @@ -5,745 +5,9 @@ .text - thumb_func_start sub_817354C -sub_817354C: @ 817354C - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_817354C - thumb_func_start sub_8173560 -sub_8173560: @ 8173560 - push {lr} - bl RunTasks - bl RunTextPrinters - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_8173560 - - thumb_func_start sub_817357C -sub_817357C: @ 817357C - push {r4,lr} - sub sp, 0x4 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x4 - bls _08173590 - b _08173688 -_08173590: - lsls r0, 2 - ldr r1, =_081735A4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081735A4: - .4byte _081735B8 - .4byte _081735E8 - .4byte _081735EE - .4byte _08173620 - .4byte _0817365C -_081735B8: - movs r0, 0 - bl SetVBlankCallback - bl sub_8174EC4 - ldr r4, =gUnknown_0203BCDC - ldr r0, =0x00002014 - bl AllocZeroed - str r0, [r4] - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - b _08173688 - .pool -_081735E8: - bl sub_8174F70 - b _08173642 -_081735EE: - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0xE2 - lsls r1, 3 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - bl sub_8174FAC - ldr r0, =gUnknown_0203BCDC - ldr r1, [r0] - movs r0, 0 - strh r0, [r1] - b _08173642 - .pool -_08173620: - bl sub_8175024 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _08173688 - ldr r0, =sub_817354C - bl SetVBlankCallback - movs r0, 0x1 - negs r0, r0 - str r4, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade -_08173642: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08173688 - .pool -_0817365C: - bl UpdatePaletteFade - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08173688 - ldr r0, =sub_8173560 - bl SetMainCallback2 - movs r0, 0xDA - lsls r0, 1 - bl PlayBGM - movs r0, 0 - b _0817368A - .pool -_08173688: - movs r0, 0x1 -_0817368A: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_817357C - - thumb_func_start sub_8173694 -sub_8173694: @ 8173694 - push {r4,lr} - bl sub_817357C - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _081736C4 - ldr r0, =sub_817371C - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r4, [r1, 0x8] - ldr r4, =gUnknown_0203BCD8 - movs r0, 0x78 - bl AllocZeroed - str r0, [r4] -_081736C4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173694 - - thumb_func_start sub_81736D8 -sub_81736D8: @ 81736D8 - push {r4,lr} - bl sub_817357C - lsls r0, 24 - cmp r0, 0 - bne _08173708 - ldr r0, =sub_817371C - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r0, 0x1 - strh r0, [r1, 0x8] - ldr r4, =gUnknown_0203BCD8 - movs r0, 0x78 - bl AllocZeroed - str r0, [r4] -_08173708: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81736D8 - - thumb_func_start sub_817371C -sub_817371C: @ 817371C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r1, =gTasks - lsls r0, 2 - add r0, r8 - lsls r0, 3 - adds r0, r1 - movs r1, 0 - strh r1, [r0, 0xC] - movs r7, 0 - ldr r0, =gUnknown_0203BCD8 - mov r9, r0 -_08173740: - movs r0, 0x64 - adds r1, r7, 0 - muls r1, r0 - ldr r0, =gPlayerParty - adds r6, r1, r0 - adds r0, r6, 0 - movs r1, 0xB - bl GetMonData - adds r5, r0, 0 - cmp r5, 0 - beq _0817380C - adds r0, r6, 0 - movs r1, 0x41 - bl GetMonData - mov r1, r9 - ldr r3, [r1] - lsls r4, r7, 2 - adds r4, r7 - lsls r4, 2 - adds r3, r4 - ldr r2, =0x000001ff - adds r1, r2, 0 - ands r0, r1 - ldrh r1, [r3, 0x8] - ldr r5, =0xfffffe00 - adds r2, r5, 0 - ands r1, r2 - orrs r1, r0 - strh r1, [r3, 0x8] - adds r0, r6, 0 - movs r1, 0x1 - bl GetMonData - mov r2, r9 - ldr r1, [r2] - adds r1, r4 - str r0, [r1] - adds r0, r6, 0 - movs r1, 0 - bl GetMonData - mov r5, r9 - ldr r1, [r5] - adds r1, 0x4 - adds r1, r4 - str r0, [r1] - adds r0, r6, 0 - movs r1, 0x38 - bl GetMonData - ldr r2, [r5] - adds r2, r4 - lsls r0, 1 - ldrb r3, [r2, 0x9] - movs r1, 0x1 - ands r1, r3 - orrs r1, r0 - strb r1, [r2, 0x9] - adds r0, r6, 0 - movs r1, 0x2 - mov r2, sp - bl GetMonData - movs r2, 0 - mov r6, r8 - lsls r5, r6, 2 - ldr r3, =gUnknown_0203BCD8 -_081737CA: - ldr r0, [r3] - adds r1, r2, r4 - adds r0, 0xA - adds r0, r1 - mov r6, sp - adds r1, r6, r2 - ldrb r1, [r1] - strb r1, [r0] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, 0x9 - bls _081737CA - ldr r0, =gTasks - mov r2, r8 - adds r1, r5, r2 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0xC] - adds r0, 0x1 - strh r0, [r1, 0xC] - b _08173840 - .pool -_0817380C: - mov r6, r9 - ldr r3, [r6] - lsls r2, r7, 2 - adds r2, r7 - lsls r2, 2 - adds r4, r3, r2 - ldrh r0, [r4, 0x8] - ldr r6, =0xfffffe00 - adds r1, r6, 0 - ands r0, r1 - strh r0, [r4, 0x8] - str r5, [r4] - adds r3, 0x4 - adds r3, r2 - str r5, [r3] - ldrb r1, [r4, 0x9] - movs r0, 0x1 - ands r0, r1 - strb r0, [r4, 0x9] - mov r1, r9 - ldr r0, [r1] - adds r0, r2 - movs r1, 0xFF - strb r1, [r0, 0xA] - mov r2, r8 - lsls r5, r2, 2 -_08173840: - adds r0, r7, 0x1 - lsls r0, 16 - lsrs r7, r0, 16 - cmp r7, 0x5 - bhi _0817384C - b _08173740 -_0817384C: - ldr r0, =gUnknown_0203BCD4 - movs r3, 0 - str r3, [r0] - ldr r4, =gTasks - mov r6, r8 - adds r1, r5, r6 - lsls r1, 3 - adds r2, r1, r4 - strh r3, [r2, 0xA] - movs r0, 0xFF - strh r0, [r2, 0x10] - movs r7, 0 - adds r3, r4, 0 - adds r3, 0x8 - movs r2, 0xFF -_0817386A: - adds r0, r7, 0x5 - lsls r0, 1 - adds r0, r1 - adds r0, r3 - strh r2, [r0] - adds r0, r7, 0x1 - lsls r0, 16 - lsrs r7, r0, 16 - cmp r7, 0x5 - bls _0817386A - mov r1, r8 - adds r0, r5, r1 - lsls r0, 3 - adds r1, r0, r4 - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0 - beq _081738A4 - ldr r0, =sub_8173A8C - b _081738A6 - .pool -_081738A4: - ldr r0, =sub_81738BC -_081738A6: - str r0, [r1] - add sp, 0xC - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817371C - - thumb_func_start sub_81738BC -sub_81738BC: @ 81738BC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r7, =0x0201c000 - ldr r0, =gUnknown_0203BCE4 - ldrb r0, [r0] - cmp r0, 0 - bne _081738EC - movs r2, 0x80 - lsls r2, 6 - adds r0, r7, 0 - movs r1, 0 - bl memset - b _08173906 - .pool -_081738EC: - movs r0, 0x3 - bl sub_81534D0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08173906 - movs r2, 0x80 - lsls r2, 6 - adds r0, r7, 0 - movs r1, 0 - bl memset -_08173906: - movs r5, 0 - ldrh r1, [r7, 0x8] - ldr r2, =0x000001ff - adds r0, r2, 0 - ands r0, r1 - mov r1, r9 - lsls r1, 2 - mov r8, r1 - cmp r0, 0 - beq _08173930 -_0817391A: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r7, 0x78 - cmp r5, 0x31 - bhi _08173934 - ldrh r1, [r7, 0x8] - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _0817391A -_08173930: - cmp r5, 0x31 - bls _08173956 -_08173934: - ldr r4, =0x0201c000 - adds r6, r4, 0 - adds r4, 0x78 - movs r5, 0 - subs r7, 0x78 -_0817393E: - adds r0, r6, 0 - adds r1, r4, 0 - movs r2, 0x78 - bl memcpy - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r6, 0x78 - adds r4, 0x78 - cmp r5, 0x30 - bls _0817393E -_08173956: - ldr r0, =gUnknown_0203BCD8 - ldr r1, [r0] - adds r0, r7, 0 - movs r2, 0x78 - bl memcpy - movs r0, 0 - movs r1, 0 - bl sub_81973C4 - ldr r2, =gUnknown_082C8959 - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0x3 - str r0, [sp, 0xC] - movs r0, 0 - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParametrized - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - ldr r1, =gTasks - mov r0, r8 - add r0, r9 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81739C4 - str r1, [r0] - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81738BC - - thumb_func_start sub_81739C4 -sub_81739C4: @ 81739C4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gGameContinueCallback - ldr r0, =sub_81736D8 - str r0, [r1] - movs r0, 0x3 - bl TrySavingData - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - bne _08173A34 - ldr r0, =gDamagedSaveSectors - ldr r0, [r0] - cmp r0, 0 - beq _08173A34 - movs r0, 0x1 - bl UnsetBgTilemapBuffer - movs r0, 0x3 - bl UnsetBgTilemapBuffer - bl FreeAllWindowBuffers - ldr r5, =gUnknown_0203BCDC - ldr r0, [r5] - cmp r0, 0 - beq _08173A06 - bl Free - movs r0, 0 - str r0, [r5] -_08173A06: - ldr r5, =gUnknown_0203BCD8 - ldr r0, [r5] - cmp r0, 0 - beq _08173A16 - bl Free - movs r0, 0 - str r0, [r5] -_08173A16: - adds r0, r4, 0 - bl DestroyTask - b _08173A4C - .pool -_08173A34: - movs r0, 0x37 - bl PlaySE - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_8173A5C - str r1, [r0] - movs r1, 0x20 - strh r1, [r0, 0xE] -_08173A4C: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81739C4 - - thumb_func_start sub_8173A5C -sub_8173A5C: @ 8173A5C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrh r2, [r1, 0xE] - movs r3, 0xE - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _08173A80 - subs r0, r2, 0x1 - strh r0, [r1, 0xE] - b _08173A84 - .pool -_08173A80: - ldr r0, =sub_8173A8C - str r0, [r1] -_08173A84: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173A5C - - thumb_func_start sub_8173A8C -sub_8173A8C: @ 8173A8C - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r0, =sub_8173AA8 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_8173A8C - - thumb_func_start sub_8173AA8 -sub_8173AA8: @ 8173AA8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, =gTasks - mov r2, r8 - lsls r1, r2, 2 - add r1, r8 - lsls r1, 3 - adds r1, r0 - ldrh r6, [r1, 0xA] - ldr r2, =gUnknown_0203BCD8 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 2 - ldr r2, [r2] - adds r7, r2, r0 - movs r2, 0xC - ldrsh r0, [r1, r2] - cmp r0, 0x3 - ble _08173AEC - ldr r1, =gUnknown_085E53B4 - b _08173AEE - .pool -_08173AEC: - ldr r1, =gUnknown_085E53E4 -_08173AEE: - lsls r2, r6, 3 - adds r0, r2, r1 - ldrh r3, [r0] - adds r0, r1, 0x2 - adds r0, r2, r0 - ldrh r4, [r0] - adds r0, r1, 0x4 - adds r0, r2, r0 - ldrh r0, [r0] - mov r9, r0 - adds r1, 0x6 - adds r2, r1 - ldrh r5, [r2] - ldrh r2, [r7, 0x8] - ldr r0, =0x000001ff - ands r0, r2 - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - bne _08173B20 - lsls r0, r5, 16 - movs r1, 0xA0 - lsls r1, 12 - adds r0, r1 - lsrs r5, r0, 16 -_08173B20: - lsls r0, r2, 23 - lsrs r0, 23 - ldr r1, [r7] - ldr r2, [r7, 0x4] - lsls r3, 16 - asrs r3, 16 - str r3, [sp] - lsls r3, r4, 16 - asrs r3, 16 - str r3, [sp, 0x4] - lsls r3, r6, 24 - lsrs r3, 24 - str r3, [sp, 0x8] - ldr r3, =0x0000ffff - str r3, [sp, 0xC] - movs r3, 0x1 - bl sub_818D3E4 - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gSprites - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r3, r2, r4 - movs r1, 0 - mov r12, r1 - mov r1, r9 - strh r1, [r3, 0x30] - strh r5, [r3, 0x32] - mov r1, r12 - strh r1, [r3, 0x2E] - ldrh r1, [r7, 0x8] - lsls r1, 23 - lsrs r1, 23 - strh r1, [r3, 0x3C] - adds r4, 0x1C - adds r2, r4 - ldr r1, =sub_8175120 - str r1, [r2] - ldr r5, =gTasks - adds r1, r6, 0x5 - lsls r1, 1 - mov r2, r8 - lsls r4, r2, 2 - add r4, r8 - lsls r4, 3 - adds r1, r4 - adds r2, r5, 0 - adds r2, 0x8 - adds r1, r2 - strh r0, [r1] - movs r0, 0 - movs r1, 0x1 - bl sub_8197434 - adds r4, r5 - ldr r0, =sub_8173BC0 - str r0, [r4] - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173AA8 + + thumb_func_start sub_8173BC0 sub_8173BC0: @ 8173BC0 @@ -756,7 +20,7 @@ sub_8173BC0: @ 8173BC0 lsls r3, 3 adds r5, r3, r4 ldrh r0, [r5, 0xA] - ldr r2, =gUnknown_0203BCD8 + ldr r2, =gHofMonsPtr lsls r1, r0, 2 adds r1, r0 lsls r1, 2 @@ -813,7 +77,7 @@ sub_8173C34: @ 8173C34 lsls r6, r0, 3 adds r4, r6, r2 ldrh r3, [r4, 0xA] - ldr r1, =gUnknown_0203BCD8 + ldr r1, =gHofMonsPtr lsls r0, r3, 2 adds r0, r3 lsls r0, 2 @@ -1394,7 +658,7 @@ _081740FA: movs r0, 0 str r0, [r4] _08174150: - ldr r4, =gUnknown_0203BCD8 + ldr r4, =gHofMonsPtr ldr r0, [r4] cmp r0, 0 beq _08174160 @@ -1503,7 +767,7 @@ _08174240: movs r1, 0 movs r2, 0 bl sub_80F9BCC - ldr r0, =sub_817354C + ldr r0, =VBlankCB_HallOfFame bl SetVBlankCallback ldr r1, =gMain movs r4, 0x87 @@ -1563,12 +827,12 @@ _081742E2: lsrs r2, r0, 24 cmp r2, 0x5 bls _081742E2 - ldr r4, =gUnknown_0203BCD8 + ldr r4, =gHofMonsPtr movs r0, 0x80 lsls r0, 6 bl AllocZeroed str r0, [r4] - ldr r0, =sub_8173560 + ldr r0, =CB2_HallOfFame bl SetMainCallback2 _08174308: pop {r4} @@ -1606,7 +870,7 @@ sub_8174324: @ 8174324 .pool _08174364: ldr r0, =0x0201c000 - ldr r4, =gUnknown_0203BCD8 + ldr r4, =gHofMonsPtr ldr r1, [r4] movs r2, 0x80 lsls r2, 5 @@ -1678,7 +942,7 @@ sub_81743EC: @ 81743EC lsls r0, 24 lsrs r0, 24 mov r8, r0 - ldr r0, =gUnknown_0203BCD8 + ldr r0, =gHofMonsPtr ldr r3, [r0] movs r5, 0 ldr r1, =gTasks @@ -1756,7 +1020,7 @@ _08174478: cmp r0, 0x3 ble _081744B8 lsls r1, r5, 3 - ldr r0, =gUnknown_085E53B4 + ldr r0, =sHallOfFame_MonsFullTeamPositions adds r0, 0x4 adds r0, r1, r0 ldrh r3, [r0] @@ -1766,7 +1030,7 @@ _08174478: b _081744C8 .pool _081744B8: - ldr r0, =gUnknown_085E53E4 + ldr r0, =sHallOfFame_MonsHalfTeamPositions lsls r2, r5, 3 adds r1, r0, 0x4 adds r1, r2, r1 @@ -1910,7 +1174,7 @@ sub_81745FC: @ 81745FC push {r5-r7} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_0203BCD8 + ldr r0, =gHofMonsPtr ldr r5, [r0] movs r3, 0 ldr r1, =gTasks @@ -2296,7 +1560,7 @@ _08174928: movs r0, 0 str r0, [r4] _08174974: - ldr r4, =gUnknown_0203BCD8 + ldr r4, =gHofMonsPtr ldr r0, [r4] cmp r0, 0 beq _08174984 diff --git a/asm/link.s b/asm/link.s index 291f71a57..9b79ac96a 100644 --- a/asm/link.s +++ b/asm/link.s @@ -52022,7 +52022,7 @@ _080241A6: movs r0, 0 movs r1, 0 bl sub_81973C4 - ldr r2, =gUnknown_082C8959 + ldr r2, =gText_SavingDontTurnOffPower movs r0, 0 str r0, [sp] movs r0, 0x2 @@ -64112,7 +64112,7 @@ _0802A3AE: movs r0, 0 movs r1, 0 bl sub_81973C4 - ldr r2, =gUnknown_082C8959 + ldr r2, =gText_SavingDontTurnOffPower str r4, [sp] movs r0, 0x2 str r0, [sp, 0x4] @@ -70355,7 +70355,7 @@ _0802D516: strh r0, [r1, 0x12] lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_082C8959 + ldr r2, =gText_SavingDontTurnOffPower movs r1, 0x1 str r1, [sp] movs r1, 0xFF diff --git a/asm/rom6.s b/asm/rom6.s index 87b780ba5..746513de8 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -4043,12 +4043,12 @@ sub_8137734: @ 8137734 lsrs r1, r0, 24 cmp r1, 0x1 bne _08137760 - ldr r0, =gUnknown_0203BCE4 + ldr r0, =HasHallOfFameRecords strb r1, [r0] b _0813776C .pool _08137760: - ldr r1, =gUnknown_0203BCE4 + ldr r1, =HasHallOfFameRecords movs r0, 0 strb r0, [r1] adds r0, r4, 0 diff --git a/asm/start_menu.s b/asm/start_menu.s index 4f8544eea..e5e91bac8 100644 --- a/asm/start_menu.s +++ b/asm/start_menu.s @@ -1683,7 +1683,7 @@ _080A05AC: movs r0, 0 movs r1, 0x11 bl FillWindowPixelBuffer - ldr r2, =gUnknown_082C8959 + ldr r2, =gText_SavingDontTurnOffPower movs r4, 0 str r4, [sp] movs r0, 0x2 diff --git a/asm/trade.s b/asm/trade.s index ebb624d90..57253154e 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -13814,7 +13814,7 @@ _0807ED98: movs r0, 0x32 strb r0, [r1] ldr r4, =gStringVar4 - ldr r1, =gUnknown_082C8959 + ldr r1, =gText_SavingDontTurnOffPower _0807EDA6: adds r0, r4, 0 bl StringExpandPlaceholders @@ -14668,7 +14668,7 @@ _0807F50A: movs r1, 0x3 strb r1, [r0] ldr r4, =gStringVar4 - ldr r1, =gUnknown_082C8959 + ldr r1, =gText_SavingDontTurnOffPower adds r0, r4, 0 bl StringExpandPlaceholders movs r0, 0 diff --git a/data/event_scripts.s b/data/event_scripts.s index ad1216b91..bd6210c38 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1029,7 +1029,7 @@ gUnknown_082C8845:: @ 82C8845 gUnknown_082C892A:: @ 82C892A .incbin "baserom.gba", 0x2c892a, 0x2f -gUnknown_082C8959:: @ 82C8959 +gText_SavingDontTurnOffPower:: @ 82C8959 .incbin "baserom.gba", 0x2c8959, 0x22 gUnknown_082C897B:: @ 82C897B diff --git a/data/hall_of_fame.s b/data/hall_of_fame.s index 2678d96a6..f00fc6001 100644 --- a/data/hall_of_fame.s +++ b/data/hall_of_fame.s @@ -21,13 +21,13 @@ gUnknown_085E5394:: @ 85E5394 gUnknown_085E53A4:: @ 85E53A4 .incbin "baserom.gba", 0x5e53a4, 0x10 -gUnknown_085E53B4:: @ 85E53B4 +sHallOfFame_MonsFullTeamPositions:: @ 85E53B4 .incbin "baserom.gba", 0x5e53b4, 0x6 gUnknown_085E53BA:: @ 85E53BA .incbin "baserom.gba", 0x5e53ba, 0x2a -gUnknown_085E53E4:: @ 85E53E4 +sHallOfFame_MonsHalfTeamPositions:: @ 85E53E4 .incbin "baserom.gba", 0x5e53e4, 0x18 gUnknown_085E53FC:: @ 85E53FC diff --git a/include/malloc.h b/include/malloc.h index f3a731797..003ee1f03 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -5,6 +5,12 @@ #define calloc(ct, sz) AllocZeroed((ct) * (sz)) #define free Free +#define FREE_AND_SET_NULL(ptr) \ +{ \ + free(ptr); \ + ptr = NULL; \ +} + extern u8 gHeap[]; void *Alloc(u32 size); void *AllocZeroed(u32 size); diff --git a/ld_script.txt b/ld_script.txt index c8d31c846..16d7e10c9 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -214,6 +214,7 @@ SECTIONS { src/reset_save_heap.o(.text); asm/field_region_map.o(.text); asm/battle_anim_8170478.o(.text); + src/hall_of_fame.o(.text); asm/hall_of_fame.o(.text); asm/credits.o(.text); src/lottery_corner.o(.text); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index d9fd40b84..d63efe21e 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -1,4 +1,323 @@ #include "global.h" #include "hall_of_fame.h" +#include "task.h" +#include "palette.h" +#include "sprite.h" +#include "pokemon.h" +#include "text.h" +#include "malloc.h" +#include "gpu_regs.h" +#include "main.h" +#include "sound.h" +#include "songs.h" +#include "decompress.h" +#include "save.h" +#include "window.h" +#include "bg.h" +#include "species.h" +struct HallofFameMon +{ + u32 tid; + u32 personality; + u16 species : 9; + u16 lvl : 7; + u8 nick[10]; +}; +struct HallofFameMons +{ + struct HallofFameMon mons[6]; +}; + +extern struct HallofFameMons *gHofMonsPtr; + +struct HofGfx +{ + u16 field_0; + u8 field_2[0x2010]; +}; + +extern struct HofGfx *gUnknown_0203BCDC; + +extern u32 gUnknown_0203BCD4; +extern bool8 HasHallOfFameRecords; +extern u8 gDecompressionBuffer[]; + +#define HALL_OF_FAME_MAX_TEAMS 50 + +// strings +extern const u8 gText_SavingDontTurnOffPower[]; + +extern void sub_81973C4(u8, u8); +extern u16 AddTextPrinterParametrized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void ( *callback)(u16, struct TextPrinter *), u8 fgColor, u8 bgColor, u8 shadowColor); + +// this file's functions +void sub_8174EC4(void); +void sub_8174F70(void); +void sub_8174FAC(void); +bool8 sub_8175024(void); +void sub_817371C(u8 taskId); +void sub_81738BC(u8 taskId); +void sub_8173A8C(u8 taskId); +void sub_81739C4(u8 taskId); +void sub_8173A5C(u8 taskId); +void sub_8173AA8(u8 taskId); +void sub_8173BC0(u8 taskId); +void sub_8175120(struct Sprite *sprite); + +void VBlankCB_HallOfFame(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void CB2_HallOfFame(void) +{ + RunTasks(); + RunTextPrinters(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +bool8 sub_817357C(void) +{ + switch (gMain.state) + { + case 0: + SetVBlankCallback(NULL); + sub_8174EC4(); + gUnknown_0203BCDC = AllocZeroed(sizeof(*gUnknown_0203BCDC)); + gMain.state = 1; + break; + case 1: + sub_8174F70(); + gMain.state++; + break; + case 2: + SetGpuReg(REG_OFFSET_BLDCNT, 0x3F42); + SetGpuReg(REG_OFFSET_BLDALPHA, 0x710); + SetGpuReg(REG_OFFSET_BLDY, 0); + sub_8174FAC(); + gUnknown_0203BCDC->field_0 = 0; + gMain.state++; + break; + case 3: + if (!sub_8175024()) + { + SetVBlankCallback(VBlankCB_HallOfFame); + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gMain.state++; + } + break; + case 4: + UpdatePaletteFade(); + if (!gPaletteFade.active) + { + SetMainCallback2(CB2_HallOfFame); + PlayBGM(BGM_DENDOU); + return FALSE; + } + break; + } + return TRUE; +} + +#define tData0 data[0] +#define tDisplayedPoke data[1] +#define tPokesNumber data[2] +#define tFrameCount data[3] +#define tPlayerSpriteID data[4] +#define tMonSpriteID(i) data[i + 5] + +void sub_8173694(void) +{ + if (!sub_817357C()) + { + u8 taskId = CreateTask(sub_817371C, 0); + gTasks[taskId].tData0 = 0; + gHofMonsPtr = AllocZeroed(sizeof(*gHofMonsPtr)); + } +} + +void sub_81736D8(void) +{ + if (!sub_817357C()) + { + u8 taskId = CreateTask(sub_817371C, 0); + gTasks[taskId].tData0 = 1; + gHofMonsPtr = AllocZeroed(sizeof(*gHofMonsPtr)); + } +} + +void sub_817371C(u8 taskId) +{ + u16 i, j; + + gTasks[taskId].tPokesNumber = 0; // valid pokes + + for (i = 0; i < 6; i++) + { + u8 nick[POKEMON_NAME_LENGTH + 2]; + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES)) + { + gHofMonsPtr->mons[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + gHofMonsPtr->mons[i].tid = GetMonData(&gPlayerParty[i], MON_DATA_OT_ID); + gHofMonsPtr->mons[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); + gHofMonsPtr->mons[i].lvl = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); + GetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, nick); + for (j = 0; j < POKEMON_NAME_LENGTH; j++) + { + gHofMonsPtr->mons[i].nick[j] = nick[j]; + } + gTasks[taskId].tPokesNumber++; + } + else + { + gHofMonsPtr->mons[i].species = 0; + gHofMonsPtr->mons[i].tid = 0; + gHofMonsPtr->mons[i].personality = 0; + gHofMonsPtr->mons[i].lvl = 0; + gHofMonsPtr->mons[i].nick[0] = EOS; + } + } + + gUnknown_0203BCD4 = 0; + gTasks[taskId].tDisplayedPoke = 0; + gTasks[taskId].tPlayerSpriteID = 0xFF; + + for (i = 0; i < 6; i++) + { + gTasks[taskId].tMonSpriteID(i) = 0xFF; + } + + if (gTasks[taskId].tData0) + gTasks[taskId].func = sub_8173A8C; + else + gTasks[taskId].func = sub_81738BC; +} + +void sub_81738BC(u8 taskId) +{ + u16 i; + struct HallofFameMons* lastSavedTeam = (struct HallofFameMons*)(gDecompressionBuffer); + + if (!HasHallOfFameRecords) + { + memset(gDecompressionBuffer, 0, 0x2000); + } + else + { + if (sub_81534D0(3) != TRUE) + memset(gDecompressionBuffer, 0, 0x2000); + } + + for (i = 0; i < HALL_OF_FAME_MAX_TEAMS; i++, lastSavedTeam++) + { + if (lastSavedTeam->mons[0].species == 0) + break; + } + if (i >= HALL_OF_FAME_MAX_TEAMS) + { + struct HallofFameMons *afterTeam = (struct HallofFameMons*)(gDecompressionBuffer); + struct HallofFameMons *beforeTeam = (struct HallofFameMons*)(gDecompressionBuffer); + afterTeam++; + for (i = 0; i < HALL_OF_FAME_MAX_TEAMS - 1; i++, beforeTeam++, afterTeam++) + { + *beforeTeam = *afterTeam; + } + lastSavedTeam--; + } + *lastSavedTeam = *gHofMonsPtr; + + sub_81973C4(0, 0); + AddTextPrinterParametrized(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); + CopyWindowToVram(0, 3); + gTasks[taskId].func = sub_81739C4; +} + +extern u8 TrySavingData(u8); +extern MainCallback gGameContinueCallback; +extern u32 gDamagedSaveSectors; + +void sub_81739C4(u8 taskId) +{ + gGameContinueCallback = sub_81736D8; + if (TrySavingData(3) == 0xFF && gDamagedSaveSectors != 0) + { + UnsetBgTilemapBuffer(1); + UnsetBgTilemapBuffer(3); + FreeAllWindowBuffers(); + + if (gUnknown_0203BCDC != NULL) + FREE_AND_SET_NULL(gUnknown_0203BCDC); + if (gHofMonsPtr != NULL) + FREE_AND_SET_NULL(gHofMonsPtr); + + DestroyTask(taskId); + } + else + { + PlaySE(SE_SAVE); + gTasks[taskId].func = sub_8173A5C; + gTasks[taskId].tFrameCount = 32; + } +} + +void sub_8173A5C(u8 taskId) +{ + if (gTasks[taskId].tFrameCount) + gTasks[taskId].tFrameCount--; + else + gTasks[taskId].func = sub_8173A8C; +} + +void sub_8173A8C(u8 taskId) +{ + gTasks[taskId].func = sub_8173AA8; +} + +extern const s16 sHallOfFame_MonsFullTeamPositions[][4]; +extern const s16 sHallOfFame_MonsHalfTeamPositions[][4]; + +extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16); +extern void sub_8197434(u8, u8); + +void sub_8173AA8(u8 taskId) +{ + u8 spriteId; + s16 xPos, yPos, field4, field6; + + u16 currPokeID = gTasks[taskId].tDisplayedPoke; + struct HallofFameMon* currMon = &gHofMonsPtr->mons[currPokeID]; + + if (gTasks[taskId].tPokesNumber > 3) + { + xPos = sHallOfFame_MonsFullTeamPositions[currPokeID][0]; + yPos = sHallOfFame_MonsFullTeamPositions[currPokeID][1]; + field4 = sHallOfFame_MonsFullTeamPositions[currPokeID][2]; + field6 = sHallOfFame_MonsFullTeamPositions[currPokeID][3]; + } + else + { + xPos = sHallOfFame_MonsHalfTeamPositions[currPokeID][0]; + yPos = sHallOfFame_MonsHalfTeamPositions[currPokeID][1]; + field4 = sHallOfFame_MonsHalfTeamPositions[currPokeID][2]; + field6 = sHallOfFame_MonsHalfTeamPositions[currPokeID][3]; + } + + if (currMon->species == SPECIES_EGG) + field6 += 10; + + spriteId = sub_818D3E4(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currPokeID, 0xFFFF); + gSprites[spriteId].data1 = field4; + gSprites[spriteId].data2 = field6; + gSprites[spriteId].data0 = 0; + gSprites[spriteId].data7 = currMon->species; + gSprites[spriteId].callback = sub_8175120; + gTasks[taskId].tMonSpriteID(currPokeID) = spriteId; + sub_8197434(0, 1); + gTasks[taskId].func = sub_8173BC0; +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 52d24a9ab..ef5b714ce 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1404,7 +1404,7 @@ gUnknown_0203BCD0: @ 203BCD0 gUnknown_0203BCD4: @ 203BCD4 .space 0x4 -gUnknown_0203BCD8: @ 203BCD8 +gHofMonsPtr: @ 203BCD8 .space 0x4 gUnknown_0203BCDC: @ 203BCDC @@ -1416,7 +1416,7 @@ gUnknown_0203BCE0: @ 203BCE0 gUnknown_0203BCE2: @ 203BCE2 .space 0x2 -gUnknown_0203BCE4: @ 203BCE4 +HasHallOfFameRecords: @ 203BCE4 .space 0x1 gUnknown_0203BCE5: @ 203BCE5 From 0f723f7677d52075b4798d9ec6bb4b60d752906f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 5 Nov 2017 14:55:13 +0100 Subject: [PATCH 08/18] halfway through hall of fame --- asm/hall_of_fame.s | 1654 +------------------------------------------ asm/rom6.s | 4 +- data/hall_of_fame.s | 2 +- src/hall_of_fame.c | 668 +++++++++++++++-- 4 files changed, 627 insertions(+), 1701 deletions(-) diff --git a/asm/hall_of_fame.s b/asm/hall_of_fame.s index 0b1530b03..a16df82c5 100644 --- a/asm/hall_of_fame.s +++ b/asm/hall_of_fame.s @@ -6,1648 +6,12 @@ .text - - - thumb_func_start sub_8173BC0 -sub_8173BC0: @ 8173BC0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gTasks - lsls r3, r0, 2 - adds r3, r0 - lsls r3, 3 - adds r5, r3, r4 - ldrh r0, [r5, 0xA] - ldr r2, =gHofMonsPtr - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - ldr r2, [r2] - adds r2, r1 - adds r0, 0x5 - lsls r0, 1 - adds r0, r3 - adds r4, 0x8 - adds r0, r4 - movs r3, 0 - ldrsh r1, [r0, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r3, r0, r1 - ldr r1, [r3, 0x1C] - ldr r0, =SpriteCallbackDummy - cmp r1, r0 - bne _08173C1A - ldrb r1, [r3, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - strb r0, [r3, 0x1] - adds r0, r2, 0 - movs r1, 0 - movs r2, 0xE - bl sub_8174A88 - movs r0, 0x78 - strh r0, [r5, 0xE] - ldr r0, =sub_8173C34 - str r0, [r5] -_08173C1A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173BC0 - thumb_func_start sub_8173C34 -sub_8173C34: @ 8173C34 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r6, r0, 3 - adds r4, r6, r2 - ldrh r3, [r4, 0xA] - ldr r1, =gHofMonsPtr - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 2 - ldr r1, [r1] - adds r1, r0 - mov r9, r1 - ldrh r1, [r4, 0xE] - movs r7, 0xE - ldrsh r0, [r4, r7] - mov r12, r2 - cmp r0, 0 - beq _08173C78 - subs r0, r1, 0x1 - strh r0, [r4, 0xE] - b _08173D10 - .pool -_08173C78: - ldr r2, =gUnknown_0203BCD4 - ldr r0, =gSprites - mov r8, r0 - adds r0, r3, 0x5 - lsls r0, 1 - adds r0, r6 - mov r1, r12 - adds r1, 0x8 - adds r6, r0, r1 - movs r7, 0 - ldrsh r1, [r6, r7] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - ldrb r0, [r0, 0x5] - lsrs r0, 4 - movs r1, 0x80 - lsls r1, 9 - lsls r1, r0 - ldr r3, [r2] - orrs r3, r1 - str r3, [r2] - ldrh r2, [r4, 0xA] - movs r1, 0xA - ldrsh r0, [r4, r1] - cmp r0, 0x4 - bgt _08173D04 - mov r7, r9 - ldrh r1, [r7, 0x1C] - ldr r0, =0x000001ff - ands r0, r1 - cmp r0, 0 - beq _08173D04 - adds r0, r2, 0x1 - strh r0, [r4, 0xA] - ldr r0, =0x000063b0 - str r0, [sp] - adds r0, r3, 0 - movs r1, 0 - movs r2, 0xC - movs r3, 0xC - bl BeginNormalPaletteFade - movs r0, 0 - ldrsh r1, [r6, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - ldrb r2, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0, 0x5] - ldr r0, =sub_8173AA8 - str r0, [r4] - b _08173D10 - .pool -_08173D04: - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - add r0, r12 - ldr r1, =sub_8173D24 - str r1, [r0] -_08173D10: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173C34 - thumb_func_start sub_8173D24 -sub_8173D24: @ 8173D24 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =0xffff0000 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0 - bl BeginNormalPaletteFade - movs r3, 0 - lsls r1, r4, 2 - adds r0, r1, r4 - lsls r5, r0, 3 - ldr r0, =gTasks + 0x8 - mov r12, r0 - mov r8, r1 - ldr r6, =gSprites - movs r7, 0xD - negs r7, r7 -_08173D52: - adds r0, r3, 0x5 - lsls r0, 1 - adds r0, r5 - mov r2, r12 - adds r1, r0, r2 - movs r2, 0 - ldrsh r0, [r1, r2] - cmp r0, 0xFF - beq _08173D74 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - ldrb r2, [r1, 0x5] - adds r0, r7, 0 - ands r0, r2 - strb r0, [r1, 0x5] -_08173D74: - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x5 - bls _08173D52 - movs r0, 0 - movs r1, 0xF - bl sub_8174A38 - movs r0, 0x69 - bl PlaySE - ldr r1, =gTasks - mov r2, r8 - adds r0, r2, r4 - lsls r0, 3 - adds r0, r1 - movs r1, 0xC8 - lsls r1, 1 - strh r1, [r0, 0xE] - ldr r1, =sub_8173DC0 - str r1, [r0] - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173D24 - thumb_func_start sub_8173DC0 -sub_8173DC0: @ 8173DC0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r7, =gTasks - lsls r4, r6, 2 - adds r0, r4, r6 - lsls r5, r0, 3 - adds r1, r5, r7 - ldrh r2, [r1, 0xE] - movs r3, 0xE - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _08173E04 - subs r2, 0x1 - strh r2, [r1, 0xE] - movs r0, 0x3 - ands r0, r2 - cmp r0, 0 - bne _08173E7E - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, 0x6E - ble _08173E7E - bl sub_81751FC - b _08173E7E - .pool -_08173E04: - movs r3, 0 - mov r9, r4 - ldr r0, =gUnknown_0203BCD4 - mov r10, r0 - adds r4, r5, 0 - adds r7, 0x8 - mov r8, r7 - ldr r7, =gSprites - movs r1, 0xD - negs r1, r1 - mov r12, r1 - movs r5, 0x4 -_08173E1C: - adds r0, r3, 0x5 - lsls r0, 1 - adds r0, r4 - mov r2, r8 - adds r1, r0, r2 - movs r2, 0 - ldrsh r0, [r1, r2] - cmp r0, 0xFF - beq _08173E40 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0x5] - mov r0, r12 - ands r0, r2 - orrs r0, r5 - strb r0, [r1, 0x5] -_08173E40: - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x5 - bls _08173E1C - mov r3, r10 - ldr r0, [r3] - ldr r1, =0x000063b0 - str r1, [sp] - movs r1, 0 - movs r2, 0xC - movs r3, 0xC - bl BeginNormalPaletteFade - movs r0, 0 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - ldr r1, =gTasks - mov r2, r9 - adds r0, r2, r6 - lsls r0, 3 - adds r0, r1 - movs r1, 0x7 - strh r1, [r0, 0xE] - ldr r1, =sub_8173EA4 - str r1, [r0] -_08173E7E: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173DC0 - - thumb_func_start sub_8173EA4 -sub_8173EA4: @ 8173EA4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldrh r2, [r1, 0xE] - movs r3, 0xE - ldrsh r0, [r1, r3] - cmp r0, 0xF - ble _08173ECC - ldr r0, =sub_8173EE4 - str r0, [r1] - b _08173EDE - .pool -_08173ECC: - adds r0, r2, 0x1 - strh r0, [r1, 0xE] - movs r0, 0xE - ldrsh r1, [r1, r0] - lsls r1, 24 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg -_08173EDE: - pop {r0} - bx r0 - thumb_func_end sub_8173EA4 - - thumb_func_start sub_8173EE4 -sub_8173EE4: @ 8173EE4 - push {r4-r6,lr} - sub sp, 0x8 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x3 - bl ShowBg - ldr r6, =gSaveBlock2Ptr - ldr r0, [r6] - ldrb r0, [r0, 0x8] - movs r1, 0x1 - bl sub_818D97C - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x6 - str r1, [sp] - ldr r1, =0x0000ffff - str r1, [sp, 0x4] - movs r1, 0x1 - movs r2, 0x78 - movs r3, 0x48 - bl sub_818D8AC - ldr r1, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r1 - strh r0, [r4, 0x10] - ldr r0, =gUnknown_085E5380 - bl AddWindow - ldr r0, [r6] - ldrb r1, [r0, 0x14] - lsrs r1, 3 - ldr r2, =0x0000021d - movs r0, 0x1 - movs r3, 0xD0 - bl sub_80987D4 - movs r0, 0x1 - bl stdpal_get - movs r1, 0xE0 - movs r2, 0x20 - bl LoadPalette - movs r0, 0x78 - strh r0, [r4, 0xE] - ldr r0, =sub_8173F84 - str r0, [r4] - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173EE4 - - thumb_func_start sub_8173F84 -sub_8173F84: @ 8173F84 - push {r4,r5,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r4, r1, r2 - ldrh r0, [r4, 0xE] - movs r1, 0xE - ldrsh r5, [r4, r1] - cmp r5, 0 - beq _08173FAC - subs r0, 0x1 - strh r0, [r4, 0xE] - b _08174018 - .pool -_08173FAC: - ldr r2, =gSprites - movs r3, 0x10 - ldrsh r1, [r4, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - ldrh r2, [r1, 0x20] - movs r3, 0x20 - ldrsh r0, [r1, r3] - cmp r0, 0xC0 - beq _08173FD0 - adds r0, r2, 0x1 - strh r0, [r1, 0x20] - b _08174018 - .pool -_08173FD0: - movs r0, 0x20 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - movs r0, 0x1 - movs r1, 0x2 - bl sub_8174C98 - movs r0, 0 - movs r1, 0 - bl sub_81973C4 - ldr r2, =gText_LeagueChamp - str r5, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0x3 - str r0, [sp, 0xC] - movs r0, 0 - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParametrized - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - ldr r0, =sub_8174028 - str r0, [r4] -_08174018: - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8173F84 - - thumb_func_start sub_8174028 -sub_8174028: @ 8174028 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0817404E - movs r0, 0x4 - bl FadeOutBGM - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_8174060 - str r0, [r1] -_0817404E: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174028 - - thumb_func_start sub_8174060 -sub_8174060: @ 8174060 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gPlttBufferFaded - ldr r1, =gPlttBufferUnfaded - movs r2, 0x80 - lsls r2, 2 - bl CpuSet - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r1, 0x8 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81740B0 - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174060 - - thumb_func_start sub_81740B0 -sub_81740B0: @ 81740B0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08174164 - lsls r0, r7, 2 - mov r8, r0 - ldr r1, =gTasks - adds r0, r7 - lsls r0, 3 - adds r1, 0x12 - adds r5, r0, r1 - ldr r2, =gSprites - mov r9, r2 - movs r6, 0x5 -_081740DC: - ldrb r4, [r5] - cmp r4, 0xFF - beq _081740FA - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - add r0, r9 - ldrb r0, [r0, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - adds r0, r4, 0 - bl sub_818D820 -_081740FA: - adds r5, 0x2 - subs r6, 0x1 - cmp r6, 0 - bge _081740DC - ldr r0, =gTasks - mov r2, r8 - adds r1, r2, r7 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x10] - bl sub_818D8F0 - movs r0, 0 - bl HideBg - movs r0, 0x1 - bl HideBg - movs r0, 0x3 - bl HideBg - bl FreeAllWindowBuffers - movs r0, 0x1 - bl UnsetBgTilemapBuffer - movs r0, 0x3 - bl UnsetBgTilemapBuffer - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - adds r0, r7, 0 - bl DestroyTask - ldr r4, =gUnknown_0203BCDC - ldr r0, [r4] - cmp r0, 0 - beq _08174150 - bl Free - movs r0, 0 - str r0, [r4] -_08174150: - ldr r4, =gHofMonsPtr - ldr r0, [r4] - cmp r0, 0 - beq _08174160 - bl Free - movs r0, 0 - str r0, [r4] -_08174160: - bl sub_8174184 -_08174164: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81740B0 - - thumb_func_start sub_8174184 -sub_8174184: @ 8174184 - push {lr} - ldr r0, =sub_8175620 - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174184 - - thumb_func_start sub_8174194 -sub_8174194: @ 8174194 - push {r4,lr} - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x5 - bhi _081741D0 - lsls r0, 2 - ldr r1, =_081741B8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081741B8: - .4byte _081741D0 - .4byte _08174200 - .4byte _08174214 - .4byte _08174240 - .4byte _08174280 - .4byte _081742B0 -_081741D0: - movs r0, 0 - bl SetVBlankCallback - bl sub_8174EC4 - ldr r4, =gUnknown_0203BCDC - ldr r0, =0x00002014 - bl AllocZeroed - str r0, [r4] - ldr r0, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r2 - movs r1, 0x1 - strb r1, [r0] - b _08174308 - .pool -_08174200: - bl sub_8174F70 - ldr r1, =gMain - movs r3, 0x87 - lsls r3, 3 - adds r1, r3 - b _081742A2 - .pool -_08174214: - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - bl sub_8174FAC - ldr r1, =gMain - movs r4, 0x87 - lsls r4, 3 - adds r1, r4 - b _081742A2 - .pool -_08174240: - bl sub_8175024 - lsls r0, 24 - cmp r0, 0 - bne _08174308 - ldr r1, =0x0201c000 - ldr r0, =gUnknown_085E56D4 - ldm r0!, {r2-r4} - stm r1!, {r2-r4} - ldm r0!, {r2,r3} - stm r1!, {r2,r3} - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl sub_80F9BCC - ldr r0, =VBlankCB_HallOfFame - bl SetVBlankCallback - ldr r1, =gMain - movs r4, 0x87 - lsls r4, 3 - adds r1, r4 - b _081742A2 - .pool -_08174280: - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - bl sub_80F9C1C - lsls r0, 24 - cmp r0, 0 - bne _08174308 - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 -_081742A2: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08174308 - .pool -_081742B0: - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0xE2 - lsls r1, 3 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - ldr r0, =sub_8174324 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - movs r2, 0 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r4, =gTasks + 0x8 - movs r3, 0xFF -_081742E2: - adds r0, r2, 0x5 - lsls r0, 1 - adds r0, r1 - adds r0, r4 - strh r3, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x5 - bls _081742E2 - ldr r4, =gHofMonsPtr - movs r0, 0x80 - lsls r0, 6 - bl AllocZeroed - str r0, [r4] - ldr r0, =CB2_HallOfFame - bl SetMainCallback2 -_08174308: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174194 - - thumb_func_start sub_8174324 -sub_8174324: @ 8174324 - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =0x00000226 - str r0, [sp] - movs r0, 0 - movs r1, 0x1E - movs r2, 0 - movs r3, 0xC - bl sub_81980F0 - movs r0, 0x3 - bl sub_81534D0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08174364 - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_81749A0 - b _081743DA - .pool -_08174364: - ldr r0, =0x0201c000 - ldr r4, =gHofMonsPtr - ldr r1, [r4] - movs r2, 0x80 - lsls r2, 5 - bl CpuSet - ldr r4, [r4] - movs r2, 0 - ldrh r1, [r4, 0x8] - ldr r3, =0x000001ff - adds r0, r3, 0 - ands r0, r1 - lsls r5, r6, 2 - cmp r0, 0 - beq _0817439A -_08174384: - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - adds r4, 0x78 - cmp r2, 0x31 - bhi _081743BC - ldrh r1, [r4, 0x8] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - bne _08174384 -_0817439A: - cmp r2, 0x31 - bhi _081743BC - ldr r0, =gTasks - adds r1, r5, r6 - lsls r1, 3 - adds r1, r0 - subs r0, r2, 0x1 - b _081743C6 - .pool -_081743BC: - ldr r0, =gTasks - adds r1, r5, r6 - lsls r1, 3 - adds r1, r0 - movs r0, 0x31 -_081743C6: - strh r0, [r1, 0x8] - movs r0, 0xA - bl GetGameStat - ldr r2, =gTasks - adds r1, r5, r6 - lsls r1, 3 - adds r1, r2 - strh r0, [r1, 0xA] - ldr r0, =sub_81743EC -_081743DA: - str r0, [r1] - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174324 - - thumb_func_start sub_81743EC -sub_81743EC: @ 81743EC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, =gHofMonsPtr - ldr r3, [r0] - movs r5, 0 - ldr r1, =gTasks - mov r2, r8 - lsls r0, r2, 2 - add r0, r8 - lsls r0, 3 - adds r0, r1 - movs r4, 0x8 - ldrsh r0, [r0, r4] - adds r4, r1, 0 - ldr r2, =gUnknown_0203BCD4 - cmp r5, r0 - bge _0817442A - adds r1, r0, 0 -_0817441E: - adds r3, 0x78 - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, r1 - blt _0817441E -_0817442A: - adds r6, r3, 0 - movs r0, 0 - str r0, [r2] - mov r5, r8 - lsls r2, r5, 2 - adds r1, r2, r5 - lsls r1, 3 - adds r1, r4 - strh r0, [r1, 0xC] - strh r0, [r1, 0x10] - movs r5, 0 - str r2, [sp, 0x14] - ldr r4, =0x000001ff - adds r2, r1, 0 -_08174446: - ldrh r1, [r6, 0x8] - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _08174456 - ldrh r0, [r2, 0x10] - adds r0, 0x1 - strh r0, [r2, 0x10] -_08174456: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r6, 0x14 - cmp r5, 0x5 - bls _08174446 - adds r6, r3, 0 - movs r5, 0 - ldr r1, =gTasks - ldr r0, [sp, 0x14] - add r0, r8 - lsls r0, 3 - mov r9, r0 - adds r0, r1 - str r0, [sp, 0x10] - ldr r1, =0x000001ff - mov r10, r1 -_08174478: - ldrh r0, [r6, 0x8] - mov r1, r10 - ands r1, r0 - adds r7, r0, 0 - cmp r1, 0 - beq _08174540 - ldr r2, [sp, 0x10] - movs r4, 0x10 - ldrsh r0, [r2, r4] - cmp r0, 0x3 - ble _081744B8 - lsls r1, r5, 3 - ldr r0, =sHallOfFame_MonsFullTeamPositions - adds r0, 0x4 - adds r0, r1, r0 - ldrh r3, [r0] - ldr r0, =gUnknown_085E53BA - adds r1, r0 - ldrh r4, [r1] - b _081744C8 - .pool -_081744B8: - ldr r0, =sHallOfFame_MonsHalfTeamPositions - lsls r2, r5, 3 - adds r1, r0, 0x4 - adds r1, r2, r1 - ldrh r3, [r1] - adds r0, 0x6 - adds r2, r0 - ldrh r4, [r2] -_081744C8: - mov r1, r10 - ands r1, r7 - movs r0, 0xCE - lsls r0, 1 - cmp r1, r0 - bne _081744DE - lsls r0, r4, 16 - movs r1, 0xA0 - lsls r1, 12 - adds r0, r1 - lsrs r4, r0, 16 -_081744DE: - lsls r0, r7, 23 - lsrs r0, 23 - ldr r1, [r6] - ldr r2, [r6, 0x4] - lsls r3, 16 - asrs r3, 16 - str r3, [sp] - lsls r3, r4, 16 - asrs r3, 16 - str r3, [sp, 0x4] - lsls r3, r5, 24 - lsrs r3, 24 - str r3, [sp, 0x8] - ldr r3, =0x0000ffff - str r3, [sp, 0xC] - movs r3, 0x1 - bl sub_818D7D8 - lsls r0, 16 - lsrs r0, 16 - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r3, [r1, 0x5] - movs r4, 0xD - negs r4, r4 - adds r2, r4, 0 - ands r3, r2 - movs r2, 0x4 - orrs r3, r2 - strb r3, [r1, 0x5] - adds r1, r5, 0x5 - lsls r1, 1 - add r1, r9 - ldr r2, =gTasks + 0x8 - adds r1, r2 - strh r0, [r1] - b _0817454E - .pool -_08174540: - adds r0, r5, 0x5 - lsls r0, 1 - add r0, r9 - ldr r4, =gTasks + 0x8 - adds r0, r4 - movs r1, 0xFF - strh r1, [r0] -_0817454E: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r6, 0x14 - cmp r5, 0x5 - bls _08174478 - ldr r0, =0xffff0000 - ldr r2, =0x000063b0 - movs r1, 0xC - bl BlendPalettes - ldr r0, =gStringVar1 - ldr r1, =gTasks - ldr r4, [sp, 0x14] - add r4, r8 - lsls r4, 3 - adds r4, r1 - movs r5, 0xA - ldrsh r1, [r4, r5] - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r5, =gStringVar4 - ldr r1, =gText_HOFNumber - adds r0, r5, 0 - bl StringExpandPlaceholders - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - bgt _081745C0 - ldr r1, =gText_PickCancel - movs r0, 0x1 - str r0, [sp] - adds r0, r5, 0 - movs r2, 0 - movs r3, 0 - bl sub_8198204 - b _081745D0 - .pool -_081745C0: - ldr r1, =gText_PickNextCancel - movs r0, 0x1 - str r0, [sp] - adds r0, r5, 0 - movs r2, 0 - movs r3, 0 - bl sub_8198204 -_081745D0: - ldr r0, =gTasks - ldr r1, [sp, 0x14] - add r1, r8 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_81745FC - str r0, [r1] - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81743EC - - thumb_func_start sub_81745FC -sub_81745FC: @ 81745FC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gHofMonsPtr - ldr r5, [r0] - movs r3, 0 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r2, 0x8 - ldrsh r0, [r0, r2] - cmp r3, r0 - bge _08174630 - adds r1, r0, 0 -_08174624: - adds r5, 0x78 - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, r1 - blt _08174624 -_08174630: - movs r3, 0 - lsls r7, r4, 2 - adds r0, r7, r4 - lsls r6, r0, 3 - ldr r0, =gTasks + 0x8 - mov r10, r0 - ldr r1, =gSprites - mov r8, r1 - movs r2, 0xD - negs r2, r2 - mov r9, r2 - movs r0, 0x4 - mov r12, r0 -_0817464A: - adds r0, r3, 0x5 - lsls r0, 1 - adds r0, r6 - add r0, r10 - ldrh r1, [r0] - cmp r1, 0xFF - beq _0817466C - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - ldrb r2, [r0, 0x5] - mov r1, r9 - ands r1, r2 - mov r2, r12 - orrs r1, r2 - strb r1, [r0, 0x5] -_0817466C: - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x5 - bls _0817464A - adds r1, r7, r4 - lsls r1, 3 - ldr r0, =gTasks - adds r6, r1, r0 - movs r2, 0xC - ldrsh r0, [r6, r2] - adds r0, 0x5 - lsls r0, 1 - adds r0, r1 - ldr r1, =gTasks - adds r1, 0x8 - adds r0, r1 - ldrh r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - ldrb r2, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - strb r1, [r0, 0x5] - lsrs r1, 4 - movs r0, 0x80 - lsls r0, 9 - lsls r0, r1 - ldr r1, =0xffff0000 - eors r0, r1 - ldr r2, =gUnknown_0203BCD4 - str r0, [r2] - ldr r2, =0x000063b0 - movs r1, 0xC - bl BlendPalettesUnfaded - movs r0, 0xC - ldrsh r1, [r6, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r4, r5, r0 - ldrh r1, [r4, 0x8] - ldr r0, =0x000001ff - ands r0, r1 - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - beq _081746E6 - bl StopCryAndClearCrySongs - ldrh r0, [r4, 0x8] - lsls r0, 23 - lsrs r0, 23 - movs r1, 0 - bl PlayCry1 -_081746E6: - adds r0, r4, 0 - movs r1, 0 - movs r2, 0xE - bl sub_8174A88 - ldr r0, =sub_8174728 - str r0, [r6] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81745FC - - thumb_func_start sub_8174728 -sub_8174728: @ 8174728 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gMain - ldrh r2, [r1, 0x2E] - movs r0, 0x1 - ands r0, r2 - adds r3, r1, 0 - cmp r0, 0 - beq _081747E4 - ldr r0, =gTasks - mov r12, r0 - lsls r0, r6, 2 - adds r1, r0, r6 - lsls r3, r1, 3 - mov r1, r12 - adds r4, r3, r1 - ldrh r2, [r4, 0x8] - movs r5, 0x8 - ldrsh r1, [r4, r5] - mov r9, r0 - cmp r1, 0 - beq _081747B8 - subs r0, r2, 0x1 - strh r0, [r4, 0x8] - movs r5, 0 - adds r7, r3, 0 - movs r0, 0x8 - add r0, r12 - mov r8, r0 -_0817476A: - adds r0, r5, 0x5 - lsls r0, 1 - adds r0, r7 - mov r1, r8 - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0xFF - beq _08174782 - bl sub_818D820 - movs r0, 0xFF - strh r0, [r4] -_08174782: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x5 - bls _0817476A - ldr r0, =gTasks - mov r2, r9 - adds r1, r2, r6 - lsls r1, 3 - adds r1, r0 - ldrh r2, [r1, 0xA] - movs r3, 0xA - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _081747A4 - subs r0, r2, 0x1 - strh r0, [r1, 0xA] -_081747A4: - ldr r0, =sub_81743EC - str r0, [r1] - b _08174884 - .pool -_081747B8: - bl IsCryPlayingOrClearCrySongs - lsls r0, 24 - cmp r0, 0 - beq _081747D2 - bl StopCryAndClearCrySongs - ldr r0, =gMPlay_BGM - ldr r1, =0x0000ffff - movs r2, 0x80 - lsls r2, 1 - bl m4aMPlayVolumeControl -_081747D2: - ldr r0, =sub_8174898 - str r0, [r4] - b _08174884 - .pool -_081747E4: - movs r0, 0x2 - ands r0, r2 - cmp r0, 0 - beq _08174828 - bl IsCryPlayingOrClearCrySongs - lsls r0, 24 - cmp r0, 0 - beq _08174806 - bl StopCryAndClearCrySongs - ldr r0, =gMPlay_BGM - ldr r1, =0x0000ffff - movs r2, 0x80 - lsls r2, 1 - bl m4aMPlayVolumeControl -_08174806: - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_8174898 - str r0, [r1] - b _08174884 - .pool -_08174828: - movs r0, 0x40 - ands r0, r2 - cmp r0, 0 - beq _08174858 - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldrh r2, [r1, 0xC] - movs r4, 0xC - ldrsh r0, [r1, r4] - cmp r0, 0 - beq _08174858 - subs r0, r2, 0x1 - strh r0, [r1, 0xC] - ldr r0, =sub_81745FC - str r0, [r1] - b _08174884 - .pool -_08174858: - ldrh r1, [r3, 0x2E] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08174884 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r2, r0, r1 - movs r5, 0xC - ldrsh r1, [r2, r5] - movs r3, 0x10 - ldrsh r0, [r2, r3] - subs r0, 0x1 - cmp r1, r0 - bge _08174884 - ldrh r0, [r2, 0xC] - adds r0, 0x1 - strh r0, [r2, 0xC] - ldr r0, =sub_81745FC - str r0, [r2] -_08174884: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174728 - - thumb_func_start sub_8174898 -sub_8174898: @ 8174898 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gPlttBufferFaded - ldr r1, =gPlttBufferUnfaded - movs r2, 0x80 - lsls r2, 2 - bl CpuSet - ldr r1, =0x0201c000 - ldr r0, =gUnknown_085E56D4 - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3} - stm r1!, {r2,r3} - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl sub_80F9BF4 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81748F0 - str r1, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174898 - - thumb_func_start sub_81748F0 -sub_81748F0: @ 81748F0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r6, r0, 24 - bl sub_80F9C30 - lsls r0, 24 - cmp r0, 0 - bne _08174988 - movs r5, 0 - lsls r0, r6, 2 - adds r0, r6 - lsls r7, r0, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 -_08174910: - adds r0, r5, 0x5 - lsls r0, 1 - adds r0, r7 - mov r1, r8 - adds r4, r0, r1 - ldrh r0, [r4] - cmp r0, 0xFF - beq _08174928 - bl sub_818D820 - movs r0, 0xFF - strh r0, [r4] -_08174928: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x5 - bls _08174910 - movs r0, 0 - bl HideBg - movs r0, 0x1 - bl HideBg - movs r0, 0x3 - bl HideBg - bl sub_8198314 - bl FreeAllWindowBuffers - movs r0, 0x1 - bl UnsetBgTilemapBuffer - movs r0, 0x3 - bl UnsetBgTilemapBuffer - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - adds r0, r6, 0 - bl DestroyTask - ldr r4, =gUnknown_0203BCDC - ldr r0, [r4] - cmp r0, 0 - beq _08174974 - bl Free - movs r0, 0 - str r0, [r4] -_08174974: - ldr r4, =gHofMonsPtr - ldr r0, [r4] - cmp r0, 0 - beq _08174984 - bl Free - movs r0, 0 - str r0, [r4] -_08174984: - bl sub_8137C3C -_08174988: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81748F0 - - thumb_func_start sub_81749A0 -sub_81749A0: @ 81749A0 - push {r4,lr} - sub sp, 0x10 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gText_UnkCtrlF800Exit - movs r1, 0x8 - movs r2, 0x1 - bl sub_8198180 - movs r0, 0 - movs r1, 0 - bl sub_81973C4 - ldr r2, =gText_HOFCorrupted - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0x3 - str r0, [sp, 0xC] - movs r0, 0 - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParametrized - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_8174A08 - str r1, [r0] - add sp, 0x10 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81749A0 - - thumb_func_start sub_8174A08 -sub_8174A08: @ 8174A08 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08174A28 - ldr r0, =gTasks - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_8174898 - str r0, [r1] -_08174A28: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174A08 - - thumb_func_start sub_8174A38 -sub_8174A38: @ 8174A38 + thumb_func_start HallOfFame_PrintWelcomeText +HallOfFame_PrintWelcomeText: @ 8174A38 push {r4,lr} sub sp, 0xC movs r0, 0 @@ -1679,10 +43,10 @@ sub_8174A38: @ 8174A38 pop {r0} bx r0 .pool - thumb_func_end sub_8174A38 + thumb_func_end HallOfFame_PrintWelcomeText - thumb_func_start sub_8174A88 -sub_8174A88: @ 8174A88 + thumb_func_start HallOfFame_PrintMonInfo +HallOfFame_PrintMonInfo: @ 8174A88 push {r4-r7,lr} sub sp, 0x2C adds r7, r0, 0 @@ -1912,10 +276,10 @@ _08174C82: pop {r0} bx r0 .pool - thumb_func_end sub_8174A88 + thumb_func_end HallOfFame_PrintMonInfo - thumb_func_start sub_8174C98 -sub_8174C98: @ 8174C98 + thumb_func_start HallOfFame_PrintPlayerInfo +HallOfFame_PrintPlayerInfo: @ 8174C98 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -2151,7 +515,7 @@ _08174E30: pop {r0} bx r0 .pool - thumb_func_end sub_8174C98 + thumb_func_end HallOfFame_PrintPlayerInfo thumb_func_start sub_8174EC4 sub_8174EC4: @ 8174EC4 diff --git a/asm/rom6.s b/asm/rom6.s index 746513de8..e312b2330 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -4165,7 +4165,7 @@ _08137838: movs r1, 0x43 bl sub_80EE4DC _0813785A: - ldr r0, =sub_8173694 + ldr r0, =CB2_DoHallOfFameScreen bl SetMainCallback2 movs r0, 0 add sp, 0x1C @@ -4638,7 +4638,7 @@ sub_8137C10: @ 8137C10 thumb_func_start sub_8137C28 sub_8137C28: @ 8137C28 push {lr} - ldr r0, =sub_8174194 + ldr r0, =CB2_DoHallOfFamePC bl SetMainCallback2 bl ScriptContext2_Enable pop {r0} diff --git a/data/hall_of_fame.s b/data/hall_of_fame.s index f00fc6001..29e509a49 100644 --- a/data/hall_of_fame.s +++ b/data/hall_of_fame.s @@ -42,5 +42,5 @@ gUnknown_085E54E8:: @ 85E54E8 gUnknown_085E5508:: @ 85E5508 .incbin "baserom.gba", 0x5e5508, 0x1cc -gUnknown_085E56D4:: @ 85E56D4 +sDummyFameMon:: @ 85E56D4 .incbin "baserom.gba", 0x5e56d4, 0x1c diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index d63efe21e..35509b53a 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -15,6 +15,10 @@ #include "window.h" #include "bg.h" #include "species.h" +#include "game_stat.h" +#include "blend_palette.h" +#include "string_util.h" +#include "m4a.h" struct HallofFameMon { @@ -43,28 +47,79 @@ extern struct HofGfx *gUnknown_0203BCDC; extern u32 gUnknown_0203BCD4; extern bool8 HasHallOfFameRecords; extern u8 gDecompressionBuffer[]; +extern struct MusicPlayerInfo gMPlay_BGM; +extern MainCallback gGameContinueCallback; +extern u32 gDamagedSaveSectors; #define HALL_OF_FAME_MAX_TEAMS 50 // strings extern const u8 gText_SavingDontTurnOffPower[]; +extern const u8 gText_LeagueChamp[]; +extern const u8 gText_HOFNumber[]; +extern const u8 gText_PickNextCancel[]; +extern const u8 gText_PickCancel[]; +extern const u8 gText_UnkCtrlF800Exit[]; +extern const u8 gText_HOFCorrupted[]; extern void sub_81973C4(u8, u8); extern u16 AddTextPrinterParametrized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void ( *callback)(u16, struct TextPrinter *), u8 fgColor, u8 bgColor, u8 shadowColor); +extern void sub_8175620(void); +extern u8 TrySavingData(u8); +extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16); +extern void sub_8197434(u8, u8); +extern u16 sub_818D97C(u8 playerGender, u8); +extern u16 sub_818D8AC(u16, u8, s16, s16, u8, u16); +extern const void* stdpal_get(u8); +extern void sub_80987D4(u8, u8, u16, u8); +extern u16 sub_818D820(u16); +extern u16 sub_818D8F0(u16); +extern u16 sub_818D7D8(u16 species, u32 trainerId, u32 personality, u8 arg3, s16 sp0, s16 sp1, u8 sp2, u16 sp3); +extern void sub_8198204(u8 *dst, const u8 *src, u8, u8, u8); +extern bool8 sub_80F9C30(void); +extern void sub_8198314(void); +extern void sub_8137C3C(void); +extern void sub_8198180(const u8 *src, u8, u8); +extern void sub_80F9BF4(u16, u16, u8); +extern void sub_81980F0(u8, u8, u8, u8, u16); +extern void sub_80F9BCC(u16, u16, u8); +extern bool8 sub_80F9C1C(void); // this file's functions void sub_8174EC4(void); void sub_8174F70(void); void sub_8174FAC(void); +void sub_81751FC(void); +static void SetCallback2AfterHallOfFameDisplay(void); bool8 sub_8175024(void); -void sub_817371C(u8 taskId); -void sub_81738BC(u8 taskId); -void sub_8173A8C(u8 taskId); -void sub_81739C4(u8 taskId); -void sub_8173A5C(u8 taskId); -void sub_8173AA8(u8 taskId); -void sub_8173BC0(u8 taskId); +static void Task_Hof_InitMonData(u8 taskId); +static void Task_Hof_InitTeamSaveData(u8 taskId); +static void Task_Hof_SetMonDisplayTask(u8 taskId); +static void Task_Hof_TrySaveData(u8 taskId); +static void Task_Hof_WaitForFrames(u8 taskId); +static void Task_Hof_DisplayMon(u8 taskId); +static void Task_Hof_PrintMonInfoAfterAnimating(u8 taskId); +static void Task_Hof_TryDisplayAnotherMon(u8 taskId); +static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId); +static void sub_8173DC0(u8 taskId); +static void sub_8173EA4(u8 taskId); +static void sub_8173EE4(u8 taskId); +static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId); +static void Task_Hof_ExitOnKeyPressed(u8 taskId); +static void Task_Hof_HandlePaletteOnExit(u8 taskId); +static void Task_Hof_HandleExit(u8 taskId); +static void Task_HofPC_CopySaveData(u8 taskId); +static void Task_HofPC_PrintDataIsCorrupted(u8 taskId); +static void Task_HofPC_DrawSpritesPrintText(u8 taskId); +static void Task_HofPC_PrintMonInfo(u8 taskId); +static void Task_HofPC_HandleInput(u8 taskId); +static void Task_HofPC_HandlePaletteOnExit(u8 taskId); +static void Task_HofPC_HandleExit(u8 taskId); +static void Task_HofPC_ExitOnButtonPress(u8 taskId); void sub_8175120(struct Sprite *sprite); +void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2); +void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 arg1); +void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2); void VBlankCB_HallOfFame(void) { @@ -82,7 +137,7 @@ void CB2_HallOfFame(void) UpdatePaletteFade(); } -bool8 sub_817357C(void) +static bool8 InitHallOfFameScreen(void) { switch (gMain.state) { @@ -125,34 +180,34 @@ bool8 sub_817357C(void) return TRUE; } -#define tData0 data[0] -#define tDisplayedPoke data[1] +#define tDontSaveData data[0] +#define tDisplayedMonId data[1] #define tPokesNumber data[2] #define tFrameCount data[3] #define tPlayerSpriteID data[4] #define tMonSpriteID(i) data[i + 5] -void sub_8173694(void) +void CB2_DoHallOfFameScreen(void) { - if (!sub_817357C()) + if (!InitHallOfFameScreen()) { - u8 taskId = CreateTask(sub_817371C, 0); - gTasks[taskId].tData0 = 0; + u8 taskId = CreateTask(Task_Hof_InitMonData, 0); + gTasks[taskId].tDontSaveData = FALSE; gHofMonsPtr = AllocZeroed(sizeof(*gHofMonsPtr)); } } -void sub_81736D8(void) +void CB2_DoHallOfFameScreenDontSaveData(void) { - if (!sub_817357C()) + if (!InitHallOfFameScreen()) { - u8 taskId = CreateTask(sub_817371C, 0); - gTasks[taskId].tData0 = 1; + u8 taskId = CreateTask(Task_Hof_InitMonData, 0); + gTasks[taskId].tDontSaveData = TRUE; gHofMonsPtr = AllocZeroed(sizeof(*gHofMonsPtr)); } } -void sub_817371C(u8 taskId) +static void Task_Hof_InitMonData(u8 taskId) { u16 i, j; @@ -185,7 +240,7 @@ void sub_817371C(u8 taskId) } gUnknown_0203BCD4 = 0; - gTasks[taskId].tDisplayedPoke = 0; + gTasks[taskId].tDisplayedMonId = 0; gTasks[taskId].tPlayerSpriteID = 0xFF; for (i = 0; i < 6; i++) @@ -193,13 +248,13 @@ void sub_817371C(u8 taskId) gTasks[taskId].tMonSpriteID(i) = 0xFF; } - if (gTasks[taskId].tData0) - gTasks[taskId].func = sub_8173A8C; + if (gTasks[taskId].tDontSaveData) + gTasks[taskId].func = Task_Hof_SetMonDisplayTask; else - gTasks[taskId].func = sub_81738BC; + gTasks[taskId].func = Task_Hof_InitTeamSaveData; } -void sub_81738BC(u8 taskId) +static void Task_Hof_InitTeamSaveData(u8 taskId) { u16 i; struct HallofFameMons* lastSavedTeam = (struct HallofFameMons*)(gDecompressionBuffer); @@ -235,16 +290,12 @@ void sub_81738BC(u8 taskId) sub_81973C4(0, 0); AddTextPrinterParametrized(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); CopyWindowToVram(0, 3); - gTasks[taskId].func = sub_81739C4; + gTasks[taskId].func = Task_Hof_TrySaveData; } -extern u8 TrySavingData(u8); -extern MainCallback gGameContinueCallback; -extern u32 gDamagedSaveSectors; - -void sub_81739C4(u8 taskId) +static void Task_Hof_TrySaveData(u8 taskId) { - gGameContinueCallback = sub_81736D8; + gGameContinueCallback = CB2_DoHallOfFameScreenDontSaveData; if (TrySavingData(3) == 0xFF && gDamagedSaveSectors != 0) { UnsetBgTilemapBuffer(1); @@ -261,63 +312,574 @@ void sub_81739C4(u8 taskId) else { PlaySE(SE_SAVE); - gTasks[taskId].func = sub_8173A5C; + gTasks[taskId].func = Task_Hof_WaitForFrames; gTasks[taskId].tFrameCount = 32; } } -void sub_8173A5C(u8 taskId) +static void Task_Hof_WaitForFrames(u8 taskId) { if (gTasks[taskId].tFrameCount) gTasks[taskId].tFrameCount--; else - gTasks[taskId].func = sub_8173A8C; + gTasks[taskId].func = Task_Hof_SetMonDisplayTask; } -void sub_8173A8C(u8 taskId) +static void Task_Hof_SetMonDisplayTask(u8 taskId) { - gTasks[taskId].func = sub_8173AA8; + gTasks[taskId].func = Task_Hof_DisplayMon; } extern const s16 sHallOfFame_MonsFullTeamPositions[][4]; extern const s16 sHallOfFame_MonsHalfTeamPositions[][4]; -extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16); -extern void sub_8197434(u8, u8); - -void sub_8173AA8(u8 taskId) +static void Task_Hof_DisplayMon(u8 taskId) { u8 spriteId; s16 xPos, yPos, field4, field6; - u16 currPokeID = gTasks[taskId].tDisplayedPoke; - struct HallofFameMon* currMon = &gHofMonsPtr->mons[currPokeID]; + u16 currMonId = gTasks[taskId].tDisplayedMonId; + struct HallofFameMon* currMon = &gHofMonsPtr->mons[currMonId]; if (gTasks[taskId].tPokesNumber > 3) { - xPos = sHallOfFame_MonsFullTeamPositions[currPokeID][0]; - yPos = sHallOfFame_MonsFullTeamPositions[currPokeID][1]; - field4 = sHallOfFame_MonsFullTeamPositions[currPokeID][2]; - field6 = sHallOfFame_MonsFullTeamPositions[currPokeID][3]; + xPos = sHallOfFame_MonsFullTeamPositions[currMonId][0]; + yPos = sHallOfFame_MonsFullTeamPositions[currMonId][1]; + field4 = sHallOfFame_MonsFullTeamPositions[currMonId][2]; + field6 = sHallOfFame_MonsFullTeamPositions[currMonId][3]; } else { - xPos = sHallOfFame_MonsHalfTeamPositions[currPokeID][0]; - yPos = sHallOfFame_MonsHalfTeamPositions[currPokeID][1]; - field4 = sHallOfFame_MonsHalfTeamPositions[currPokeID][2]; - field6 = sHallOfFame_MonsHalfTeamPositions[currPokeID][3]; + xPos = sHallOfFame_MonsHalfTeamPositions[currMonId][0]; + yPos = sHallOfFame_MonsHalfTeamPositions[currMonId][1]; + field4 = sHallOfFame_MonsHalfTeamPositions[currMonId][2]; + field6 = sHallOfFame_MonsHalfTeamPositions[currMonId][3]; } if (currMon->species == SPECIES_EGG) field6 += 10; - spriteId = sub_818D3E4(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currPokeID, 0xFFFF); + spriteId = sub_818D3E4(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currMonId, 0xFFFF); gSprites[spriteId].data1 = field4; gSprites[spriteId].data2 = field6; gSprites[spriteId].data0 = 0; gSprites[spriteId].data7 = currMon->species; gSprites[spriteId].callback = sub_8175120; - gTasks[taskId].tMonSpriteID(currPokeID) = spriteId; + gTasks[taskId].tMonSpriteID(currMonId) = spriteId; sub_8197434(0, 1); - gTasks[taskId].func = sub_8173BC0; + gTasks[taskId].func = Task_Hof_PrintMonInfoAfterAnimating; } + +static void Task_Hof_PrintMonInfoAfterAnimating(u8 taskId) +{ + u16 currMonId = gTasks[taskId].tDisplayedMonId; + struct HallofFameMon* currMon = &gHofMonsPtr->mons[currMonId]; + struct Sprite *monSprite = &gSprites[gTasks[taskId].tMonSpriteID(currMonId)]; + + if (monSprite->callback == SpriteCallbackDummy) + { + monSprite->oam.affineMode = 0; + HallOfFame_PrintMonInfo(currMon, 0, 14); + gTasks[taskId].tFrameCount = 120; + gTasks[taskId].func = Task_Hof_TryDisplayAnotherMon; + } +} + +static void Task_Hof_TryDisplayAnotherMon(u8 taskId) +{ + u16 currPokeID = gTasks[taskId].tDisplayedMonId; + struct HallofFameMon* currMon = &gHofMonsPtr->mons[currPokeID]; + + if (gTasks[taskId].tFrameCount != 0) + { + gTasks[taskId].tFrameCount--; + } + else + { + gUnknown_0203BCD4 |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteID(currPokeID)].oam.paletteNum); + if (gTasks[taskId].tDisplayedMonId <= 4 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display + { + gTasks[taskId].tDisplayedMonId++; + BeginNormalPaletteFade(gUnknown_0203BCD4, 0, 12, 12, 0x63B0); + gSprites[gTasks[taskId].tMonSpriteID(currPokeID)].oam.priority = 1; + gTasks[taskId].func = Task_Hof_DisplayMon; + } + else + { + gTasks[taskId].func = Task_Hof_PaletteFadeAndPrintWelcomeText; + } + } +} + +static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskID) +{ + u16 i; + + BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, 0); + for (i = 0; i < 6; i++) + { + if (gTasks[taskID].tMonSpriteID(i) != 0xFF) + gSprites[gTasks[taskID].tMonSpriteID(i)].oam.priority = 0; + } + + HallOfFame_PrintWelcomeText(0, 15); + PlaySE(SE_DENDOU); + gTasks[taskID].tFrameCount = 400; + gTasks[taskID].func = sub_8173DC0; +} + +static void sub_8173DC0(u8 taskID) +{ + if (gTasks[taskID].tFrameCount != 0) + { + gTasks[taskID].tFrameCount--; + if ((gTasks[taskID].tFrameCount & 3) == 0 && gTasks[taskID].tFrameCount > 110) + sub_81751FC(); + } + else + { + u16 i; + for (i = 0; i < 6; i++) + { + if (gTasks[taskID].tMonSpriteID(i) != 0xFF) + gSprites[gTasks[taskID].tMonSpriteID(i)].oam.priority = 1; + } + BeginNormalPaletteFade(gUnknown_0203BCD4, 0, 12, 12, 0x63B0); + FillWindowPixelBuffer(0, 0); + CopyWindowToVram(0, 3); + gTasks[taskID].tFrameCount = 7; + gTasks[taskID].func = sub_8173EA4; + } +} + +static void sub_8173EA4(u8 taskID) +{ + if (gTasks[taskID].tFrameCount >= 16) + { + gTasks[taskID].func = sub_8173EE4; + } + else + { + gTasks[taskID].tFrameCount++; + SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskID].tFrameCount * 256); + } +} + +extern const struct WindowTemplate gUnknown_085E5380; + +static void sub_8173EE4(u8 taskID) +{ + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + ShowBg(0); + ShowBg(1); + ShowBg(3); + gTasks[taskID].tPlayerSpriteID = sub_818D8AC(sub_818D97C(gSaveBlock2Ptr->playerGender, 1), 1, 120, 72, 6, 0xFFFF); + AddWindow(&gUnknown_085E5380); + sub_80987D4(1, gSaveBlock2Ptr->optionsWindowFrameType, 0x21D, 0xD0); + LoadPalette(stdpal_get(1), 0xE0, 0x20); + gTasks[taskID].tFrameCount = 120; + gTasks[taskID].func = Task_Hof_WaitAndPrintPlayerInfo; +} + +static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskID) +{ + if (gTasks[taskID].tFrameCount != 0) + { + gTasks[taskID].tFrameCount--; + } + else if (gSprites[gTasks[taskID].tPlayerSpriteID].pos1.x != 192) + { + gSprites[gTasks[taskID].tPlayerSpriteID].pos1.x++; + } + else + { + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); + HallOfFame_PrintPlayerInfo(1, 2); + sub_81973C4(0, 0); + AddTextPrinterParametrized(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3); + CopyWindowToVram(0, 3); + gTasks[taskID].func = Task_Hof_ExitOnKeyPressed; + } +} + +static void Task_Hof_ExitOnKeyPressed(u8 taskID) +{ + if (gMain.newKeys & A_BUTTON) + { + FadeOutBGM(4); + gTasks[taskID].func = Task_Hof_HandlePaletteOnExit; + } +} + +static void Task_Hof_HandlePaletteOnExit(u8 taskID) +{ + CpuCopy16(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); + BeginNormalPaletteFade(-1, 8, 0, 0x10, 0); + gTasks[taskID].func = Task_Hof_HandleExit; +} + +static void Task_Hof_HandleExit(u8 taskID) +{ + if (!gPaletteFade.active) + { + s32 i; + + for (i = 0; i < 6; i++) + { + u8 spriteId = gTasks[taskID].tMonSpriteID(i); + if (spriteId != 0xFF) + { + FreeOamMatrix(gSprites[spriteId].oam.matrixNum); + sub_818D820(spriteId); + } + } + + sub_818D8F0(gTasks[taskID].tPlayerSpriteID); + HideBg(0); + HideBg(1); + HideBg(3); + FreeAllWindowBuffers(); + UnsetBgTilemapBuffer(1); + UnsetBgTilemapBuffer(3); + ResetBgsAndClearDma3BusyFlags(0); + DestroyTask(taskID); + + if (gUnknown_0203BCDC != NULL) + FREE_AND_SET_NULL(gUnknown_0203BCDC); + if (gHofMonsPtr != NULL) + FREE_AND_SET_NULL(gHofMonsPtr); + + SetCallback2AfterHallOfFameDisplay(); + } +} + +static void SetCallback2AfterHallOfFameDisplay(void) +{ + SetMainCallback2(sub_8175620); +} + +#undef tDontSaveData +#undef tDisplayedPoke +#undef tPokesNumber +#undef tFrameCount +#undef tPlayerSpriteID +#undef tMonSpriteID + +#define tCurrTeamNo data[0] +#define tCurrPageNo data[1] +#define tCurrPokeID data[2] +#define tPokesNo data[4] +#define tMonSpriteID(i) data[i + 5] + +extern const struct HallofFameMon sDummyFameMon; + +void CB2_DoHallOfFamePC(void) +{ + switch (gMain.state) + { + case 0: + default: + SetVBlankCallback(NULL); + sub_8174EC4(); + gUnknown_0203BCDC = AllocZeroed(sizeof(*gUnknown_0203BCDC)); + gMain.state = 1; + break; + case 1: + sub_8174F70(); + gMain.state++; + break; + case 2: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + sub_8174FAC(); + gMain.state++; + break; + case 3: + if (!sub_8175024()) + { + struct HallofFameMons *fameMons = (struct HallofFameMons*)(gDecompressionBuffer); + fameMons->mons[0] = sDummyFameMon; + sub_80F9BCC(0, 0, 0); + SetVBlankCallback(VBlankCB_HallOfFame); + gMain.state++; + } + break; + case 4: + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); + if (!sub_80F9C1C()) + gMain.state++; + break; + case 5: + { + u8 taskId, i; + + SetGpuReg(REG_OFFSET_BLDCNT, 0x3F42); + SetGpuReg(REG_OFFSET_BLDALPHA, 0x710); + SetGpuReg(REG_OFFSET_BLDY, 0); + taskId = CreateTask(Task_HofPC_CopySaveData, 0); + + for (i = 0; i < 6; i++) + { + gTasks[taskId].tMonSpriteID(i) = 0xFF; + } + + gHofMonsPtr = AllocZeroed(0x2000); + SetMainCallback2(CB2_HallOfFame); + } + break; + } +} + +static void Task_HofPC_CopySaveData(u8 taskID) +{ + sub_81980F0(0, 0x1E, 0, 0xC, 0x226); + if (sub_81534D0(3) != 1) + { + gTasks[taskID].func = Task_HofPC_PrintDataIsCorrupted; + } + else + { + u16 i; + struct HallofFameMons* savedTeams; + + CpuCopy16(gDecompressionBuffer, gHofMonsPtr, 0x2000); + savedTeams = gHofMonsPtr; + for (i = 0; i < HALL_OF_FAME_MAX_TEAMS; i++, savedTeams++) + { + if (savedTeams->mons[0].species == SPECIES_NONE) + break; + } + + if (i < HALL_OF_FAME_MAX_TEAMS) + gTasks[taskID].tCurrTeamNo = i - 1; + else + gTasks[taskID].tCurrTeamNo = HALL_OF_FAME_MAX_TEAMS - 1; + + gTasks[taskID].tCurrPageNo = GetGameStat(GAME_STAT_ENTERED_HOF); + + gTasks[taskID].func = Task_HofPC_DrawSpritesPrintText; + } +} + +static void Task_HofPC_DrawSpritesPrintText(u8 taskID) +{ + struct HallofFameMons* savedTeams = gHofMonsPtr; + struct HallofFameMon* currMon; + u16 i; + + for (i = 0; i < gTasks[taskID].tCurrTeamNo; i++) + savedTeams++; + + currMon = &savedTeams->mons[0]; + gUnknown_0203BCD4 = 0; + gTasks[taskID].tCurrPokeID = 0; + gTasks[taskID].tPokesNo = 0; + + for (i = 0; i < 6; i++, currMon++) + { + if (currMon->species != 0) + gTasks[taskID].tPokesNo++; + } + + currMon = &savedTeams->mons[0]; + + for (i = 0; i < 6; i++, currMon++) + { + if (currMon->species != 0) + { + u16 spriteID; + s16 posX, posY; + + if (gTasks[taskID].tPokesNo > 3) + { + posX = sHallOfFame_MonsFullTeamPositions[i][2]; + posY = sHallOfFame_MonsFullTeamPositions[i][3]; + } + else + { + posX = sHallOfFame_MonsHalfTeamPositions[i][2]; + posY = sHallOfFame_MonsHalfTeamPositions[i][3]; + } + + if (currMon->species == SPECIES_EGG) + posY += 10; + + spriteID = sub_818D7D8(currMon->species, currMon->tid, currMon->personality, 1, posX, posY, i, 0xFFFF); + gSprites[spriteID].oam.priority = 1; + gTasks[taskID].tMonSpriteID(i) = spriteID; + } + else + { + gTasks[taskID].tMonSpriteID(i) = 0xFF; + } + } + + BlendPalettes(0xFFFF0000, 0xC, 0x63B0); + + ConvertIntToDecimalStringN(gStringVar1, gTasks[taskID].tCurrPageNo, STR_CONV_MODE_RIGHT_ALIGN, 3); + StringExpandPlaceholders(gStringVar4, gText_HOFNumber); + + if (gTasks[taskID].tCurrTeamNo <= 0) + sub_8198204(gStringVar4, gText_PickCancel, 0, 0, 1); + else + sub_8198204(gStringVar4, gText_PickNextCancel, 0, 0, 1); + + gTasks[taskID].func = Task_HofPC_PrintMonInfo; +} + +static void Task_HofPC_PrintMonInfo(u8 taskID) +{ + struct HallofFameMons* savedTeams = gHofMonsPtr; + struct HallofFameMon* currMon; + u16 i; + u16 currMonID; + + for (i = 0; i < gTasks[taskID].tCurrTeamNo; i++) + savedTeams++; + + for (i = 0; i < 6; i++) + { + u16 spriteID = gTasks[taskID].tMonSpriteID(i); + if (spriteID != 0xFF) + gSprites[spriteID].oam.priority = 1; + } + + currMonID = gTasks[taskID].tMonSpriteID(gTasks[taskID].tCurrPokeID); + gSprites[currMonID].oam.priority = 0; + gUnknown_0203BCD4 = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000; + BlendPalettesUnfaded(gUnknown_0203BCD4, 0xC, 0x63B0); + + currMon = &savedTeams->mons[gTasks[taskID].tCurrPokeID]; + if (currMon->species != SPECIES_EGG) + { + StopCryAndClearCrySongs(); + PlayCry1(currMon->species, 0); + } + HallOfFame_PrintMonInfo(currMon, 0, 14); + + gTasks[taskID].func = Task_HofPC_HandleInput; +} + +static void Task_HofPC_HandleInput(u8 taskID) +{ + u16 i; + + if (gMain.newKeys & A_BUTTON) + { + if (gTasks[taskID].tCurrTeamNo != 0) // prepare another team to view + { + gTasks[taskID].tCurrTeamNo--; + for (i = 0; i < 6; i++) + { + u8 spriteID = gTasks[taskID].tMonSpriteID(i); + if (spriteID != 0xFF) + { + sub_818D820(spriteID); + gTasks[taskID].tMonSpriteID(i) = 0xFF; + } + } + if (gTasks[taskID].tCurrPageNo != 0) + gTasks[taskID].tCurrPageNo--; + gTasks[taskID].func = Task_HofPC_DrawSpritesPrintText; + } + else // no more teams to view, turn off hall of fame PC + { + if (IsCryPlayingOrClearCrySongs()) + { + StopCryAndClearCrySongs(); + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100); + } + gTasks[taskID].func = Task_HofPC_HandlePaletteOnExit; + } + } + else if (gMain.newKeys & B_BUTTON) // turn off hall of fame PC + { + if (IsCryPlayingOrClearCrySongs()) + { + StopCryAndClearCrySongs(); + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100); + } + gTasks[taskID].func = Task_HofPC_HandlePaletteOnExit; + } + else if (gMain.newKeys & DPAD_UP && gTasks[taskID].tCurrPokeID != 0) // change mon -1 + { + gTasks[taskID].tCurrPokeID--; + gTasks[taskID].func = Task_HofPC_PrintMonInfo; + } + else if (gMain.newKeys & DPAD_DOWN && gTasks[taskID].tCurrPokeID < gTasks[taskID].tPokesNo - 1) // change mon +1 + { + gTasks[taskID].tCurrPokeID++; + gTasks[taskID].func = Task_HofPC_PrintMonInfo; + } +} + +static void Task_HofPC_HandlePaletteOnExit(u8 taskID) +{ + struct HallofFameMons* fameMons; + + CpuCopy16(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); + fameMons = (struct HallofFameMons*)(gDecompressionBuffer); + fameMons->mons[0] = sDummyFameMon; + sub_80F9BF4(0, 0, 0); + gTasks[taskID].func = Task_HofPC_HandleExit; +} + +static void Task_HofPC_HandleExit(u8 taskID) +{ + if (!sub_80F9C30()) + { + u8 i; + + for (i = 0; i < 6; i++) + { + u16 spriteId = gTasks[taskID].tMonSpriteID(i); + if (spriteId != 0xFF) + { + sub_818D820(spriteId); + gTasks[taskID].tMonSpriteID(i) = 0xFF; + } + } + + HideBg(0); + HideBg(1); + HideBg(3); + sub_8198314(); + FreeAllWindowBuffers(); + UnsetBgTilemapBuffer(1); + UnsetBgTilemapBuffer(3); + ResetBgsAndClearDma3BusyFlags(0); + DestroyTask(taskID); + + if (gUnknown_0203BCDC != NULL) + FREE_AND_SET_NULL(gUnknown_0203BCDC); + if (gHofMonsPtr != NULL) + FREE_AND_SET_NULL(gHofMonsPtr); + + sub_8137C3C(); + } +} + +static void Task_HofPC_PrintDataIsCorrupted(u8 taskId) +{ + sub_8198180(gText_UnkCtrlF800Exit, 8, 1); + sub_81973C4(0, 0); + AddTextPrinterParametrized(0, 1, gText_HOFCorrupted, 0, NULL, 2, 1, 3); + CopyWindowToVram(0, 3); + gTasks[taskId].func = Task_HofPC_ExitOnButtonPress; +} + +static void Task_HofPC_ExitOnButtonPress(u8 taskID) +{ + if (gMain.newKeys & A_BUTTON) + gTasks[taskID].func = Task_HofPC_HandlePaletteOnExit; +} + +#undef tCurrTeamNo +#undef tCurrPageNo +#undef tCurrPokeID +#undef tPokesNo +#undef tMonSpriteID From a2263207bf64439c9ad35ad5b8f0d5c5ea289d30 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 6 Nov 2017 17:27:39 +0100 Subject: [PATCH 09/18] hall of fame is decompiled --- asm/hall_of_fame.s | 1220 ------------------------------------------- data/hall_of_fame.s | 6 +- src/hall_of_fame.c | 718 ++++++++++++++++++++----- 3 files changed, 600 insertions(+), 1344 deletions(-) diff --git a/asm/hall_of_fame.s b/asm/hall_of_fame.s index a16df82c5..13585c831 100644 --- a/asm/hall_of_fame.s +++ b/asm/hall_of_fame.s @@ -8,1224 +8,4 @@ - - - thumb_func_start HallOfFame_PrintWelcomeText -HallOfFame_PrintWelcomeText: @ 8174A38 - push {r4,lr} - sub sp, 0xC - movs r0, 0 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - bl PutWindowTilemap - ldr r4, =gText_WelcomeToHOF - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0xD0 - bl GetStringCenterAlignXOffset - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gUnknown_085E5388 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r4, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x1 - bl box_print - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end HallOfFame_PrintWelcomeText - - thumb_func_start HallOfFame_PrintMonInfo -HallOfFame_PrintMonInfo: @ 8174A88 - push {r4-r7,lr} - sub sp, 0x2C - adds r7, r0, 0 - movs r0, 0 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - bl PutWindowTilemap - ldrh r0, [r7, 0x8] - ldr r1, =0x000001ff - ands r1, r0 - movs r0, 0xCE - lsls r0, 1 - cmp r1, r0 - beq _08174B30 - ldr r1, =gText_Number - add r0, sp, 0xC - bl StringCopy - adds r6, r0, 0 - ldrh r0, [r7, 0x8] - lsls r0, 23 - lsrs r0, 23 - bl SpeciesToPokedexNum - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =0x0000ffff - cmp r4, r0 - beq _08174B04 - adds r0, r4, 0 - movs r1, 0x64 - bl __divsi3 - subs r0, 0x5F - strb r0, [r6] - adds r6, 0x1 - adds r0, r4, 0 - movs r1, 0x64 - bl __modsi3 - adds r4, r0, 0 - movs r1, 0xA - bl __divsi3 - subs r0, 0x5F - strb r0, [r6] - adds r6, 0x1 - adds r0, r4, 0 - movs r1, 0xA - bl __modsi3 - subs r0, 0x5F - b _08174B0E - .pool -_08174B04: - movs r0, 0xAC - strb r0, [r6] - adds r6, 0x1 - strb r0, [r6] - adds r6, 0x1 -_08174B0E: - strb r0, [r6] - adds r6, 0x1 - movs r0, 0xFF - strb r0, [r6] - ldr r0, =gUnknown_085E5388 - str r0, [sp] - movs r0, 0x1 - negs r0, r0 - str r0, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r2, 0x10 - movs r3, 0x1 - bl box_print -_08174B30: - adds r1, r7, 0 - adds r1, 0xA - add r0, sp, 0xC - movs r2, 0xA - bl memcpy - add r1, sp, 0xC - movs r0, 0xFF - strb r0, [r1, 0xA] - ldrh r1, [r7, 0x8] - ldr r4, =0x000001ff - adds r0, r4, 0 - ands r0, r1 - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - bne _08174B8C - movs r0, 0x1 - add r1, sp, 0xC - movs r2, 0xD0 - bl GetStringCenterAlignXOffset - lsls r2, r0, 24 - lsrs r2, 24 - ldr r0, =gUnknown_085E5388 - str r0, [sp] - movs r0, 0x1 - negs r0, r0 - str r0, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r3, 0x1 - bl box_print - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - b _08174C82 - .pool -_08174B8C: - movs r0, 0x1 - add r1, sp, 0xC - movs r2, 0x80 - bl GetStringRightAlignXOffset - lsls r2, r0, 24 - lsrs r2, 24 - ldr r0, =gUnknown_085E5388 - str r0, [sp] - movs r0, 0x1 - negs r0, r0 - str r0, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r3, 0x1 - bl box_print - add r1, sp, 0xC - movs r0, 0xBA - strb r0, [r1] - mov r0, sp - adds r0, 0xD - ldrh r1, [r7, 0x8] - lsls r1, 23 - lsrs r1, 23 - movs r2, 0xB - muls r1, r2 - ldr r2, =gSpeciesNames - adds r1, r2 - bl StringCopy - adds r6, r0, 0 - ldrh r1, [r7, 0x8] - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0x20 - beq _08174C0A - cmp r0, 0x1D - beq _08174C0A - lsls r0, r1, 23 - lsrs r0, 23 - ldr r1, [r7, 0x4] - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _08174C00 - cmp r0, 0xFE - beq _08174C04 - b _08174C0A - .pool -_08174C00: - movs r0, 0xB5 - b _08174C06 -_08174C04: - movs r0, 0xB6 -_08174C06: - strb r0, [r6] - adds r6, 0x1 -_08174C0A: - movs r0, 0xFF - strb r0, [r6] - ldr r5, =gUnknown_085E5388 - str r5, [sp] - movs r4, 0x1 - negs r4, r4 - str r4, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r2, 0x80 - movs r3, 0x1 - bl box_print - ldr r1, =gText_Level - add r0, sp, 0xC - bl StringCopy - adds r6, r0, 0 - ldrb r1, [r7, 0x9] - lsrs r1, 1 - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - str r5, [sp] - str r4, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r2, 0x24 - movs r3, 0x11 - bl box_print - ldr r1, =gText_IDNumber - add r0, sp, 0xC - bl StringCopy - adds r6, r0, 0 - ldrh r1, [r7] - movs r2, 0x2 - movs r3, 0x5 - bl ConvertIntToDecimalStringN - str r5, [sp] - str r4, [sp, 0x4] - add r0, sp, 0xC - str r0, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r2, 0x68 - movs r3, 0x11 - bl box_print - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram -_08174C82: - add sp, 0x2C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end HallOfFame_PrintMonInfo - - thumb_func_start HallOfFame_PrintPlayerInfo -HallOfFame_PrintPlayerInfo: @ 8174C98 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - movs r0, 0x1 - movs r1, 0x11 - bl FillWindowPixelBuffer - movs r0, 0x1 - bl PutWindowTilemap - ldr r2, =0x0000021d - movs r0, 0x1 - movs r1, 0 - movs r3, 0xD - bl SetWindowBorderStyle - ldr r0, =gUnknown_085E538C - mov r8, r0 - str r0, [sp] - movs r1, 0x1 - negs r1, r1 - mov r9, r1 - str r1, [sp, 0x4] - ldr r0, =gText_Name - str r0, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x1 - bl box_print - ldr r0, =gSaveBlock2Ptr - mov r10, r0 - ldr r1, [r0] - movs r0, 0x1 - movs r2, 0x70 - bl GetStringRightAlignXOffset - lsls r2, r0, 24 - lsrs r2, 24 - mov r1, r8 - str r1, [sp] - mov r0, r9 - str r0, [sp, 0x4] - mov r1, r10 - ldr r0, [r1] - str r0, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r3, 0x1 - bl box_print - mov r1, r10 - ldr r0, [r1] - ldrb r4, [r0, 0xA] - ldrb r0, [r0, 0xB] - lsls r0, 8 - orrs r4, r0 - mov r0, r8 - str r0, [sp] - movs r7, 0 - str r7, [sp, 0x4] - ldr r0, =gText_IDNumber - str r0, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x11 - bl box_print - add r6, sp, 0xC - ldr r1, =0x000186a0 - adds r0, r4, 0 - bl __modsi3 - ldr r5, =0x00002710 - adds r1, r5, 0 - bl __divsi3 - subs r0, 0x5F - strb r0, [r6] - add r6, sp, 0xC - adds r0, r4, 0 - adds r1, r5, 0 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - movs r5, 0xFA - lsls r5, 2 - adds r1, r5, 0 - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r6, 0x1] - add r6, sp, 0xC - adds r0, r4, 0 - adds r1, r5, 0 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r6, 0x2] - add r5, sp, 0xC - adds r0, r4, 0 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r5, 0x3] - add r5, sp, 0xC - adds r0, r4, 0 - movs r1, 0xA - bl __umodsi3 - adds r0, 0xA1 - strb r0, [r5, 0x4] - add r1, sp, 0xC - movs r0, 0xFF - strb r0, [r1, 0x5] - movs r0, 0x1 - movs r2, 0x70 - bl GetStringRightAlignXOffset - lsls r2, r0, 24 - lsrs r2, 24 - mov r1, r8 - str r1, [sp] - mov r0, r9 - str r0, [sp, 0x4] - add r1, sp, 0xC - str r1, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r3, 0x11 - bl box_print - mov r0, r8 - str r0, [sp] - mov r1, r9 - str r1, [sp, 0x4] - ldr r0, =gText_MainMenuTime - str r0, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - movs r3, 0x21 - bl box_print - add r5, sp, 0xC - mov r0, r10 - ldr r4, [r0] - ldrh r0, [r4, 0xE] - movs r1, 0x64 - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r5] - add r5, sp, 0xC - ldrh r0, [r4, 0xE] - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r5, 0x1] - add r5, sp, 0xC - ldrh r0, [r4, 0xE] - movs r1, 0xA - bl __umodsi3 - adds r0, 0xA1 - strb r0, [r5, 0x2] - add r0, sp, 0xC - ldrb r0, [r0] - cmp r0, 0xA1 - bne _08174E1E - add r0, sp, 0xC - strb r7, [r0] -_08174E1E: - add r0, sp, 0xC - ldrb r1, [r0] - cmp r1, 0 - bne _08174E30 - ldrb r0, [r0, 0x1] - cmp r0, 0xA1 - bne _08174E30 - add r0, sp, 0xC - strb r1, [r0, 0x8] -_08174E30: - add r1, sp, 0xC - movs r0, 0xF0 - strb r0, [r1, 0x3] - adds r4, r1, 0 - ldr r0, =gSaveBlock2Ptr - ldr r5, [r0] - ldrb r0, [r5, 0x10] - movs r1, 0x64 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0xA - bl __udivsi3 - adds r0, 0xA1 - strb r0, [r4, 0x4] - add r4, sp, 0xC - ldrb r0, [r5, 0x10] - movs r1, 0xA - bl __umodsi3 - adds r0, 0xA1 - strb r0, [r4, 0x5] - add r1, sp, 0xC - movs r0, 0xFF - strb r0, [r1, 0x6] - movs r0, 0x1 - movs r2, 0x70 - bl GetStringRightAlignXOffset - lsls r2, r0, 24 - lsrs r2, 24 - ldr r0, =gUnknown_085E538C - str r0, [sp] - movs r0, 0x1 - negs r0, r0 - str r0, [sp, 0x4] - add r1, sp, 0xC - str r1, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r3, 0x21 - bl box_print - movs r0, 0x1 - movs r1, 0x3 - bl CopyWindowToVram - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end HallOfFame_PrintPlayerInfo - - thumb_func_start sub_8174EC4 -sub_8174EC4: @ 8174EC4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - movs r3, 0xC0 - lsls r3, 19 - movs r4, 0xC0 - lsls r4, 9 - add r0, sp, 0x4 - mov r8, r0 - mov r2, sp - movs r6, 0 - ldr r1, =0x040000d4 - movs r5, 0x80 - lsls r5, 5 - ldr r7, =0x81000800 - movs r0, 0x81 - lsls r0, 24 - mov r12, r0 -_08174EEA: - strh r6, [r2] - mov r0, sp - str r0, [r1] - str r3, [r1, 0x4] - str r7, [r1, 0x8] - ldr r0, [r1, 0x8] - adds r3, r5 - subs r4, r5 - cmp r4, r5 - bhi _08174EEA - strh r6, [r2] - mov r2, sp - str r2, [r1] - str r3, [r1, 0x4] - lsrs r0, r4, 1 - mov r2, r12 - orrs r0, r2 - str r0, [r1, 0x8] - ldr r0, [r1, 0x8] - movs r0, 0xE0 - lsls r0, 19 - movs r3, 0x80 - lsls r3, 3 - movs r4, 0 - str r4, [sp, 0x4] - ldr r2, =0x040000d4 - mov r1, r8 - str r1, [r2] - str r0, [r2, 0x4] - lsrs r0, r3, 2 - movs r1, 0x85 - lsls r1, 24 - orrs r0, r1 - str r0, [r2, 0x8] - ldr r0, [r2, 0x8] - movs r1, 0xA0 - lsls r1, 19 - mov r0, sp - strh r4, [r0] - str r0, [r2] - str r1, [r2, 0x4] - lsrs r3, 1 - movs r0, 0x81 - lsls r0, 24 - orrs r3, r0 - str r3, [r2, 0x8] - ldr r0, [r2, 0x8] - bl ResetPaletteFade - ldr r0, =gUnknown_085E54E8 - movs r1, 0 - movs r2, 0x20 - bl LoadPalette - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174EC4 - - thumb_func_start sub_8174F70 -sub_8174F70: @ 8174F70 - push {lr} - bl remove_some_task - bl ResetTasks - bl ResetSpriteData - bl reset_temp_tile_data_buffers - bl dp13_810BB8C - bl FreeAllSpritePalettes - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x8 - strb r0, [r1] - ldr r0, =gUnknown_085E5394 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085E53A4 - bl LoadCompressedObjectPalette - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174F70 - - thumb_func_start sub_8174FAC -sub_8174FAC: @ 8174FAC - push {r4,lr} - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_085E5374 - movs r0, 0 - movs r2, 0x3 - bl InitBgsFromTemplates - ldr r4, =gUnknown_0203BCDC - ldr r1, [r4] - adds r1, 0x12 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, [r4] - ldr r0, =0x00001012 - adds r1, r0 - movs r0, 0x3 - bl SetBgTilemapBuffer - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x3 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8174FAC - - thumb_func_start sub_8175024 -sub_8175024: @ 8175024 - push {r4,lr} - sub sp, 0x8 - ldr r0, =gUnknown_0203BCDC - ldr r0, [r0] - ldrh r0, [r0] - cmp r0, 0x4 - bhi _08175108 - lsls r0, 2 - ldr r1, =_08175044 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08175044: - .4byte _08175058 - .4byte _08175070 - .4byte _0817507C - .4byte _081750D2 - .4byte _081750DC -_08175058: - ldr r1, =gUnknown_085E5508 - movs r0, 0 - str r0, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - b _08175108 - .pool -_08175070: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - beq _08175108 - b _08175112 -_0817507C: - movs r4, 0x20 - str r4, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - str r4, [sp] - movs r0, 0xB - str r0, [sp, 0x4] - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - movs r3, 0x3 - bl FillBgTilemapBufferRect_Palette0 - str r4, [sp] - movs r0, 0x6 - str r0, [sp, 0x4] - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - movs r3, 0xE - bl FillBgTilemapBufferRect_Palette0 - str r4, [sp] - str r4, [sp, 0x4] - movs r0, 0x3 - movs r1, 0x2 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - movs r0, 0x3 - bl CopyBgTilemapBufferToVram - b _08175108 -_081750D2: - bl sub_81971D0 - bl sub_8197200 - b _08175108 -_081750DC: - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x3 - bl ShowBg - ldr r0, =gUnknown_0203BCDC - ldr r1, [r0] - movs r0, 0 - strh r0, [r1] - b _08175114 - .pool -_08175108: - ldr r0, =gUnknown_0203BCDC - ldr r1, [r0] - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] -_08175112: - movs r0, 0x1 -_08175114: - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8175024 - - thumb_func_start sub_8175120 -sub_8175120: @ 8175120 - push {r4,lr} - adds r2, r0, 0 - ldr r1, [r2, 0x20] - ldr r0, [r2, 0x30] - cmp r1, r0 - beq _08175176 - ldrh r3, [r2, 0x20] - movs r1, 0x20 - ldrsh r0, [r2, r1] - movs r4, 0x30 - ldrsh r1, [r2, r4] - cmp r0, r1 - bge _08175140 - adds r0, r3, 0 - adds r0, 0xF - strh r0, [r2, 0x20] -_08175140: - ldrh r3, [r2, 0x20] - movs r4, 0x20 - ldrsh r0, [r2, r4] - cmp r0, r1 - ble _08175150 - adds r0, r3, 0 - subs r0, 0xF - strh r0, [r2, 0x20] -_08175150: - ldrh r3, [r2, 0x22] - movs r1, 0x22 - ldrsh r0, [r2, r1] - movs r4, 0x32 - ldrsh r1, [r2, r4] - cmp r0, r1 - bge _08175164 - adds r0, r3, 0 - adds r0, 0xA - strh r0, [r2, 0x22] -_08175164: - ldrh r3, [r2, 0x22] - movs r4, 0x22 - ldrsh r0, [r2, r4] - cmp r0, r1 - ble _0817519C - adds r0, r3, 0 - subs r0, 0xA - strh r0, [r2, 0x22] - b _0817519C -_08175176: - ldrh r0, [r2, 0x3C] - lsls r1, r0, 16 - movs r0, 0xCE - lsls r0, 17 - cmp r1, r0 - bne _08175190 - lsrs r1, 16 - adds r0, r2, 0 - movs r2, 0x1 - movs r3, 0x3 - bl DoMonFrontSpriteAnimation - b _0817519C -_08175190: - lsrs r1, 16 - adds r0, r2, 0 - movs r2, 0 - movs r3, 0x3 - bl DoMonFrontSpriteAnimation -_0817519C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8175120 - - thumb_func_start sub_81751A4 -sub_81751A4: @ 81751A4 - push {r4,r5,lr} - adds r5, r0, 0 - ldrh r1, [r5, 0x26] - movs r2, 0x26 - ldrsh r0, [r5, r2] - cmp r0, 0x78 - ble _081751BA - adds r0, r5, 0 - bl DestroySprite - b _081751F2 -_081751BA: - adds r0, r1, 0x1 - ldrh r1, [r5, 0x30] - adds r0, r1 - strh r0, [r5, 0x26] - ldrh r4, [r5, 0x2E] - lsls r4, 24 - lsrs r4, 24 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - ands r0, r1 - adds r0, 0x8 - ldr r1, =gSineTable - lsls r4, 1 - adds r4, r1 - movs r2, 0 - ldrsh r1, [r4, r2] - muls r0, r1 - cmp r0, 0 - bge _081751E8 - adds r0, 0xFF -_081751E8: - asrs r0, 8 - strh r0, [r5, 0x24] - ldrh r0, [r5, 0x2E] - adds r0, 0x4 - strh r0, [r5, 0x2E] -_081751F2: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81751A4 - - thumb_func_start sub_81751FC -sub_81751FC: @ 81751FC - push {r4,lr} - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xF0 - bl __umodsi3 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - bl Random - adds r2, r0, 0 - lsls r2, 16 - lsrs r2, 16 - movs r0, 0x7 - ands r2, r0 - negs r2, r2 - ldr r0, =gUnknown_085E54D0 - lsls r4, 16 - asrs r4, 16 - lsls r2, 16 - asrs r2, 16 - adds r1, r4, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r4, r1, r0 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x11 - bl __umodsi3 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim - bl Random - movs r1, 0x3 - ands r1, r0 - cmp r1, 0 - beq _08175274 - movs r0, 0 - b _08175276 - .pool -_08175274: - movs r0, 0x1 -_08175276: - strh r0, [r4, 0x30] - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81751FC - - thumb_func_start sub_8175280 -sub_8175280: @ 8175280 - push {r4,lr} - ldr r4, =gSpecialVar_0x8004 - movs r0, 0xB4 - strh r0, [r4] - ldr r0, =sub_8175364 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _081752AA - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r4] - strh r1, [r0, 0xA] - ldr r0, =gSpecialVar_0x8005 - strh r2, [r0] -_081752AA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8175280 - - thumb_func_start sub_81752C0 -sub_81752C0: @ 81752C0 - push {r4,lr} - ldr r0, =sub_8175364 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _081752D4 - bl DestroyTask -_081752D4: - bl sub_8152254 - ldr r4, =0x000003e9 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81752C0 - - thumb_func_start sub_81752F4 -sub_81752F4: @ 81752F4 - push {r4,r5,lr} - adds r5, r0, 0 - ldrh r1, [r5, 0xE] - movs r2, 0xE - ldrsh r0, [r5, r2] - cmp r0, 0x6E - ble _08175324 - ldr r2, =gTasks - movs r0, 0x28 - ldrsh r1, [r5, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrh r1, [r0, 0x26] - subs r1, 0x1 - strh r1, [r0, 0x26] - ldrb r0, [r5, 0x16] - bl sub_81525D0 - b _08175358 - .pool -_08175324: - adds r0, r1, 0x1 - ldrh r1, [r5, 0x1C] - adds r0, r1 - strh r0, [r5, 0xE] - ldrb r4, [r5, 0x1A] - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - ands r0, r1 - adds r0, 0x8 - ldr r1, =gSineTable - lsls r4, 1 - adds r4, r1 - movs r2, 0 - ldrsh r1, [r4, r2] - muls r0, r1 - cmp r0, 0 - bge _0817534E - adds r0, 0xFF -_0817534E: - asrs r0, 8 - strh r0, [r5, 0xC] - ldrh r0, [r5, 0x1A] - adds r0, 0x4 - strh r0, [r5, 0x1A] -_08175358: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81752F4 - - thumb_func_start sub_8175364 -sub_8175364: @ 8175364 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0xC - lsls r0, 24 - lsrs r4, r0, 24 - mov r8, r4 - movs r7, 0 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - ldrh r0, [r6] - cmp r0, 0x1 - beq _081753E0 - cmp r0, 0x1 - bgt _08175394 - cmp r0, 0 - beq _0817539C - b _081754B0 - .pool -_08175394: - cmp r0, 0xFF - bne _0817539A - b _081754A0 -_0817539A: - b _081754B0 -_0817539C: - movs r0, 0x40 - bl sub_81521C0 - cmp r0, 0 - bne _081753B8 - adds r0, r4, 0 - bl DestroyTask - ldr r0, =gSpecialVar_0x8004 - strh r7, [r0] - ldr r1, =gSpecialVar_0x8005 - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1] -_081753B8: - ldr r0, =gUnknown_085E5394 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_085E53A4 - bl LoadCompressedObjectPalette - ldrh r0, [r6] - adds r0, 0x1 - strh r0, [r6] - b _081754B0 - .pool -_081753E0: - ldrh r0, [r6, 0x2] - cmp r0, 0 - beq _08175478 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - bne _08175478 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xF0 - bl __umodsi3 - adds r5, r0, 0 - lsls r5, 16 - asrs r5, 16 - bl Random - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - movs r0, 0x7 - ands r4, r0 - negs r4, r4 - lsls r4, 16 - asrs r4, 16 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x11 - bl __umodsi3 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_085E53FC - ldr r2, =0x000003e9 - str r4, [sp] - str r0, [sp, 0x4] - str r7, [sp, 0x8] - adds r0, r1, 0 - adds r1, r2, 0 - adds r3, r5, 0 - bl sub_81524C4 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0xFF - beq _08175478 - adds r4, r7, 0 - ldr r1, =sub_81752F4 - adds r0, r4, 0 - bl sub_8152438 - bl Random - movs r1, 0x3 - ands r1, r0 - cmp r1, 0 - bne _08175468 - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0x1 - bl sub_8152474 -_08175468: - adds r0, r4, 0 - movs r1, 0x7 - mov r2, r8 - bl sub_8152474 - ldrh r0, [r6, 0x1E] - adds r0, 0x1 - strh r0, [r6, 0x1E] -_08175478: - bl sub_81522D4 - ldrh r0, [r6, 0x2] - cmp r0, 0 - beq _08175494 - subs r0, 0x1 - strh r0, [r6, 0x2] - b _081754B0 - .pool -_08175494: - ldrh r0, [r6, 0x1E] - cmp r0, 0 - bne _081754B0 - movs r0, 0xFF - strh r0, [r6] - b _081754B0 -_081754A0: - bl sub_81752C0 - ldr r0, =gSpecialVar_0x8004 - strh r7, [r0] - ldr r1, =gSpecialVar_0x8005 - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1] -_081754B0: - add sp, 0xC - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8175364 - .align 2, 0 @ Don't pad with nop. diff --git a/data/hall_of_fame.s b/data/hall_of_fame.s index 29e509a49..7771224e7 100644 --- a/data/hall_of_fame.s +++ b/data/hall_of_fame.s @@ -15,10 +15,10 @@ gUnknown_085E5388:: @ 85E5388 gUnknown_085E538C:: @ 85E538C .incbin "baserom.gba", 0x5e538c, 0x8 -gUnknown_085E5394:: @ 85E5394 +sHallOfFame_ConfettiSpriteSheet:: @ 85E5394 .incbin "baserom.gba", 0x5e5394, 0x10 -gUnknown_085E53A4:: @ 85E53A4 +sHallOfFame_ConfettiSpritePalette:: @ 85E53A4 .incbin "baserom.gba", 0x5e53a4, 0x10 sHallOfFame_MonsFullTeamPositions:: @ 85E53B4 @@ -36,7 +36,7 @@ gUnknown_085E53FC:: @ 85E53FC gUnknown_085E54D0:: @ 85E54D0 .incbin "baserom.gba", 0x5e54d0, 0x18 -gUnknown_085E54E8:: @ 85E54E8 +gHallOfFame_Pal:: @ 85E54E8 .incbin "baserom.gba", 0x5e54e8, 0x20 gUnknown_085E5508:: @ 85E5508 diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 35509b53a..6e9cac28b 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -19,6 +19,11 @@ #include "blend_palette.h" #include "string_util.h" #include "m4a.h" +#include "international_string_util.h" +#include "unknown_task.h" +#include "trig.h" +#include "rng.h" +#include "event_data.h" struct HallofFameMon { @@ -38,8 +43,25 @@ extern struct HallofFameMons *gHofMonsPtr; struct HofGfx { - u16 field_0; - u8 field_2[0x2010]; + u16 state; + u8 field_2; + u8 field_3; + u8 field_4; + u8 field_5; + u8 field_6; + u8 field_7; + u8 field_8; + u8 field_9; + u8 field_A; + u8 field_B; + u8 field_C; + u8 field_D; + u8 field_E; + u8 field_F; + u8 field_10; + u8 field_11; + u8 tilemap1[0x1000]; + u8 tilemap2[0x1000]; }; extern struct HofGfx *gUnknown_0203BCDC; @@ -50,9 +72,24 @@ extern u8 gDecompressionBuffer[]; extern struct MusicPlayerInfo gMPlay_BGM; extern MainCallback gGameContinueCallback; extern u32 gDamagedSaveSectors; +extern u8 gReservedSpritePaletteCount; #define HALL_OF_FAME_MAX_TEAMS 50 +extern const u8 gUnknown_085E53FC[]; +extern const struct SpriteTemplate gUnknown_085E54D0; +extern const struct BgTemplate gUnknown_085E5374[3]; +extern const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet; +extern const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette; +extern const u16 gHallOfFame_Pal[]; +extern const u8 gUnknown_085E5388[]; +extern const u8 gUnknown_085E538C[]; +extern const struct HallofFameMon sDummyFameMon; +extern const struct WindowTemplate gUnknown_085E5380; +extern const s16 sHallOfFame_MonsFullTeamPositions[][4]; +extern const s16 sHallOfFame_MonsHalfTeamPositions[][4]; +extern const u32 gUnknown_085E5508[]; + // strings extern const u8 gText_SavingDontTurnOffPower[]; extern const u8 gText_LeagueChamp[]; @@ -61,6 +98,12 @@ extern const u8 gText_PickNextCancel[]; extern const u8 gText_PickCancel[]; extern const u8 gText_UnkCtrlF800Exit[]; extern const u8 gText_HOFCorrupted[]; +extern const u8 gText_WelcomeToHOF[]; +extern const u8 gText_Number[]; +extern const u8 gText_Level[]; +extern const u8 gText_IDNumber[]; +extern const u8 gText_Name[]; +extern const u8 gText_MainMenuTime[]; extern void sub_81973C4(u8, u8); extern u16 AddTextPrinterParametrized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void ( *callback)(u16, struct TextPrinter *), u8 fgColor, u8 bgColor, u8 shadowColor); @@ -84,12 +127,23 @@ extern void sub_80F9BF4(u16, u16, u8); extern void sub_81980F0(u8, u8, u8, u8, u16); extern void sub_80F9BCC(u16, u16, u8); extern bool8 sub_80F9C1C(void); +extern u16 SpeciesToPokedexNum(u16 species); +extern void dp13_810BB8C(void); +extern void sub_81971D0(void); +extern void sub_8197200(void); +extern void sub_8152254(void); +extern void sub_81525D0(u8); +extern void sub_8152438(u8, void*); +extern void sub_8152474(u8, u8, u8); +extern void sub_81522D4(void); +extern bool32 sub_81521C0(u8); +extern u8 sub_81524C4(const void *arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, u8 arg5, s16 arg6); // this file's functions -void sub_8174EC4(void); +void ClearVramOamPltt_LoadHofPal(void); void sub_8174F70(void); void sub_8174FAC(void); -void sub_81751FC(void); +bool8 sub_81751FC(void); static void SetCallback2AfterHallOfFameDisplay(void); bool8 sub_8175024(void); static void Task_Hof_InitMonData(u8 taskId); @@ -116,10 +170,11 @@ static void Task_HofPC_HandleInput(u8 taskId); static void Task_HofPC_HandlePaletteOnExit(u8 taskId); static void Task_HofPC_HandleExit(u8 taskId); static void Task_HofPC_ExitOnButtonPress(u8 taskId); -void sub_8175120(struct Sprite *sprite); +void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite); void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2); -void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 arg1); +void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2); void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2); +void sub_8175364(u8 taskId); void VBlankCB_HallOfFame(void) { @@ -143,7 +198,7 @@ static bool8 InitHallOfFameScreen(void) { case 0: SetVBlankCallback(NULL); - sub_8174EC4(); + ClearVramOamPltt_LoadHofPal(); gUnknown_0203BCDC = AllocZeroed(sizeof(*gUnknown_0203BCDC)); gMain.state = 1; break; @@ -156,7 +211,7 @@ static bool8 InitHallOfFameScreen(void) SetGpuReg(REG_OFFSET_BLDALPHA, 0x710); SetGpuReg(REG_OFFSET_BLDY, 0); sub_8174FAC(); - gUnknown_0203BCDC->field_0 = 0; + gUnknown_0203BCDC->state = 0; gMain.state++; break; case 3: @@ -185,7 +240,7 @@ static bool8 InitHallOfFameScreen(void) #define tPokesNumber data[2] #define tFrameCount data[3] #define tPlayerSpriteID data[4] -#define tMonSpriteID(i) data[i + 5] +#define tMonSpriteId(i) data[i + 5] void CB2_DoHallOfFameScreen(void) { @@ -245,7 +300,7 @@ static void Task_Hof_InitMonData(u8 taskId) for (i = 0; i < 6; i++) { - gTasks[taskId].tMonSpriteID(i) = 0xFF; + gTasks[taskId].tMonSpriteId(i) = 0xFF; } if (gTasks[taskId].tDontSaveData) @@ -330,8 +385,9 @@ static void Task_Hof_SetMonDisplayTask(u8 taskId) gTasks[taskId].func = Task_Hof_DisplayMon; } -extern const s16 sHallOfFame_MonsFullTeamPositions[][4]; -extern const s16 sHallOfFame_MonsHalfTeamPositions[][4]; +#define tDestinationX data1 +#define tDestinationY data2 +#define tSpecies data7 static void Task_Hof_DisplayMon(u8 taskId) { @@ -360,12 +416,12 @@ static void Task_Hof_DisplayMon(u8 taskId) field6 += 10; spriteId = sub_818D3E4(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currMonId, 0xFFFF); - gSprites[spriteId].data1 = field4; - gSprites[spriteId].data2 = field6; + gSprites[spriteId].tDestinationX = field4; + gSprites[spriteId].tDestinationY = field6; gSprites[spriteId].data0 = 0; - gSprites[spriteId].data7 = currMon->species; - gSprites[spriteId].callback = sub_8175120; - gTasks[taskId].tMonSpriteID(currMonId) = spriteId; + gSprites[spriteId].tSpecies = currMon->species; + gSprites[spriteId].callback = SpriteCB_GetOnScreenAndAnimate; + gTasks[taskId].tMonSpriteId(currMonId) = spriteId; sub_8197434(0, 1); gTasks[taskId].func = Task_Hof_PrintMonInfoAfterAnimating; } @@ -374,7 +430,7 @@ static void Task_Hof_PrintMonInfoAfterAnimating(u8 taskId) { u16 currMonId = gTasks[taskId].tDisplayedMonId; struct HallofFameMon* currMon = &gHofMonsPtr->mons[currMonId]; - struct Sprite *monSprite = &gSprites[gTasks[taskId].tMonSpriteID(currMonId)]; + struct Sprite *monSprite = &gSprites[gTasks[taskId].tMonSpriteId(currMonId)]; if (monSprite->callback == SpriteCallbackDummy) { @@ -396,12 +452,12 @@ static void Task_Hof_TryDisplayAnotherMon(u8 taskId) } else { - gUnknown_0203BCD4 |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteID(currPokeID)].oam.paletteNum); + gUnknown_0203BCD4 |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.paletteNum); if (gTasks[taskId].tDisplayedMonId <= 4 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display { gTasks[taskId].tDisplayedMonId++; BeginNormalPaletteFade(gUnknown_0203BCD4, 0, 12, 12, 0x63B0); - gSprites[gTasks[taskId].tMonSpriteID(currPokeID)].oam.priority = 1; + gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.priority = 1; gTasks[taskId].func = Task_Hof_DisplayMon; } else @@ -411,29 +467,29 @@ static void Task_Hof_TryDisplayAnotherMon(u8 taskId) } } -static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskID) +static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId) { u16 i; BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, 0); for (i = 0; i < 6; i++) { - if (gTasks[taskID].tMonSpriteID(i) != 0xFF) - gSprites[gTasks[taskID].tMonSpriteID(i)].oam.priority = 0; + if (gTasks[taskId].tMonSpriteId(i) != 0xFF) + gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 0; } HallOfFame_PrintWelcomeText(0, 15); PlaySE(SE_DENDOU); - gTasks[taskID].tFrameCount = 400; - gTasks[taskID].func = sub_8173DC0; + gTasks[taskId].tFrameCount = 400; + gTasks[taskId].func = sub_8173DC0; } -static void sub_8173DC0(u8 taskID) +static void sub_8173DC0(u8 taskId) { - if (gTasks[taskID].tFrameCount != 0) + if (gTasks[taskId].tFrameCount != 0) { - gTasks[taskID].tFrameCount--; - if ((gTasks[taskID].tFrameCount & 3) == 0 && gTasks[taskID].tFrameCount > 110) + gTasks[taskId].tFrameCount--; + if ((gTasks[taskId].tFrameCount & 3) == 0 && gTasks[taskId].tFrameCount > 110) sub_81751FC(); } else @@ -441,55 +497,53 @@ static void sub_8173DC0(u8 taskID) u16 i; for (i = 0; i < 6; i++) { - if (gTasks[taskID].tMonSpriteID(i) != 0xFF) - gSprites[gTasks[taskID].tMonSpriteID(i)].oam.priority = 1; + if (gTasks[taskId].tMonSpriteId(i) != 0xFF) + gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1; } BeginNormalPaletteFade(gUnknown_0203BCD4, 0, 12, 12, 0x63B0); FillWindowPixelBuffer(0, 0); CopyWindowToVram(0, 3); - gTasks[taskID].tFrameCount = 7; - gTasks[taskID].func = sub_8173EA4; + gTasks[taskId].tFrameCount = 7; + gTasks[taskId].func = sub_8173EA4; } } -static void sub_8173EA4(u8 taskID) +static void sub_8173EA4(u8 taskId) { - if (gTasks[taskID].tFrameCount >= 16) + if (gTasks[taskId].tFrameCount >= 16) { - gTasks[taskID].func = sub_8173EE4; + gTasks[taskId].func = sub_8173EE4; } else { - gTasks[taskID].tFrameCount++; - SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskID].tFrameCount * 256); + gTasks[taskId].tFrameCount++; + SetGpuReg(REG_OFFSET_BLDALPHA, gTasks[taskId].tFrameCount * 256); } } -extern const struct WindowTemplate gUnknown_085E5380; - -static void sub_8173EE4(u8 taskID) +static void sub_8173EE4(u8 taskId) { SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); ShowBg(1); ShowBg(3); - gTasks[taskID].tPlayerSpriteID = sub_818D8AC(sub_818D97C(gSaveBlock2Ptr->playerGender, 1), 1, 120, 72, 6, 0xFFFF); + gTasks[taskId].tPlayerSpriteID = sub_818D8AC(sub_818D97C(gSaveBlock2Ptr->playerGender, 1), 1, 120, 72, 6, 0xFFFF); AddWindow(&gUnknown_085E5380); sub_80987D4(1, gSaveBlock2Ptr->optionsWindowFrameType, 0x21D, 0xD0); LoadPalette(stdpal_get(1), 0xE0, 0x20); - gTasks[taskID].tFrameCount = 120; - gTasks[taskID].func = Task_Hof_WaitAndPrintPlayerInfo; + gTasks[taskId].tFrameCount = 120; + gTasks[taskId].func = Task_Hof_WaitAndPrintPlayerInfo; } -static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskID) +static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId) { - if (gTasks[taskID].tFrameCount != 0) + if (gTasks[taskId].tFrameCount != 0) { - gTasks[taskID].tFrameCount--; + gTasks[taskId].tFrameCount--; } - else if (gSprites[gTasks[taskID].tPlayerSpriteID].pos1.x != 192) + else if (gSprites[gTasks[taskId].tPlayerSpriteID].pos1.x != 192) { - gSprites[gTasks[taskID].tPlayerSpriteID].pos1.x++; + gSprites[gTasks[taskId].tPlayerSpriteID].pos1.x++; } else { @@ -498,27 +552,27 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskID) sub_81973C4(0, 0); AddTextPrinterParametrized(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3); CopyWindowToVram(0, 3); - gTasks[taskID].func = Task_Hof_ExitOnKeyPressed; + gTasks[taskId].func = Task_Hof_ExitOnKeyPressed; } } -static void Task_Hof_ExitOnKeyPressed(u8 taskID) +static void Task_Hof_ExitOnKeyPressed(u8 taskId) { if (gMain.newKeys & A_BUTTON) { FadeOutBGM(4); - gTasks[taskID].func = Task_Hof_HandlePaletteOnExit; + gTasks[taskId].func = Task_Hof_HandlePaletteOnExit; } } -static void Task_Hof_HandlePaletteOnExit(u8 taskID) +static void Task_Hof_HandlePaletteOnExit(u8 taskId) { CpuCopy16(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); BeginNormalPaletteFade(-1, 8, 0, 0x10, 0); - gTasks[taskID].func = Task_Hof_HandleExit; + gTasks[taskId].func = Task_Hof_HandleExit; } -static void Task_Hof_HandleExit(u8 taskID) +static void Task_Hof_HandleExit(u8 taskId) { if (!gPaletteFade.active) { @@ -526,7 +580,7 @@ static void Task_Hof_HandleExit(u8 taskID) for (i = 0; i < 6; i++) { - u8 spriteId = gTasks[taskID].tMonSpriteID(i); + u8 spriteId = gTasks[taskId].tMonSpriteId(i); if (spriteId != 0xFF) { FreeOamMatrix(gSprites[spriteId].oam.matrixNum); @@ -534,7 +588,7 @@ static void Task_Hof_HandleExit(u8 taskID) } } - sub_818D8F0(gTasks[taskID].tPlayerSpriteID); + sub_818D8F0(gTasks[taskId].tPlayerSpriteID); HideBg(0); HideBg(1); HideBg(3); @@ -542,7 +596,7 @@ static void Task_Hof_HandleExit(u8 taskID) UnsetBgTilemapBuffer(1); UnsetBgTilemapBuffer(3); ResetBgsAndClearDma3BusyFlags(0); - DestroyTask(taskID); + DestroyTask(taskId); if (gUnknown_0203BCDC != NULL) FREE_AND_SET_NULL(gUnknown_0203BCDC); @@ -563,15 +617,13 @@ static void SetCallback2AfterHallOfFameDisplay(void) #undef tPokesNumber #undef tFrameCount #undef tPlayerSpriteID -#undef tMonSpriteID +#undef tMonSpriteId #define tCurrTeamNo data[0] #define tCurrPageNo data[1] -#define tCurrPokeID data[2] +#define tCurrPokeId data[2] #define tPokesNo data[4] -#define tMonSpriteID(i) data[i + 5] - -extern const struct HallofFameMon sDummyFameMon; +#define tMonSpriteId(i) data[i + 5] void CB2_DoHallOfFamePC(void) { @@ -580,7 +632,7 @@ void CB2_DoHallOfFamePC(void) case 0: default: SetVBlankCallback(NULL); - sub_8174EC4(); + ClearVramOamPltt_LoadHofPal(); gUnknown_0203BCDC = AllocZeroed(sizeof(*gUnknown_0203BCDC)); gMain.state = 1; break; @@ -624,7 +676,7 @@ void CB2_DoHallOfFamePC(void) for (i = 0; i < 6; i++) { - gTasks[taskId].tMonSpriteID(i) = 0xFF; + gTasks[taskId].tMonSpriteId(i) = 0xFF; } gHofMonsPtr = AllocZeroed(0x2000); @@ -634,12 +686,12 @@ void CB2_DoHallOfFamePC(void) } } -static void Task_HofPC_CopySaveData(u8 taskID) +static void Task_HofPC_CopySaveData(u8 taskId) { sub_81980F0(0, 0x1E, 0, 0xC, 0x226); if (sub_81534D0(3) != 1) { - gTasks[taskID].func = Task_HofPC_PrintDataIsCorrupted; + gTasks[taskId].func = Task_HofPC_PrintDataIsCorrupted; } else { @@ -655,34 +707,34 @@ static void Task_HofPC_CopySaveData(u8 taskID) } if (i < HALL_OF_FAME_MAX_TEAMS) - gTasks[taskID].tCurrTeamNo = i - 1; + gTasks[taskId].tCurrTeamNo = i - 1; else - gTasks[taskID].tCurrTeamNo = HALL_OF_FAME_MAX_TEAMS - 1; + gTasks[taskId].tCurrTeamNo = HALL_OF_FAME_MAX_TEAMS - 1; - gTasks[taskID].tCurrPageNo = GetGameStat(GAME_STAT_ENTERED_HOF); + gTasks[taskId].tCurrPageNo = GetGameStat(GAME_STAT_ENTERED_HOF); - gTasks[taskID].func = Task_HofPC_DrawSpritesPrintText; + gTasks[taskId].func = Task_HofPC_DrawSpritesPrintText; } } -static void Task_HofPC_DrawSpritesPrintText(u8 taskID) +static void Task_HofPC_DrawSpritesPrintText(u8 taskId) { struct HallofFameMons* savedTeams = gHofMonsPtr; struct HallofFameMon* currMon; u16 i; - for (i = 0; i < gTasks[taskID].tCurrTeamNo; i++) + for (i = 0; i < gTasks[taskId].tCurrTeamNo; i++) savedTeams++; currMon = &savedTeams->mons[0]; gUnknown_0203BCD4 = 0; - gTasks[taskID].tCurrPokeID = 0; - gTasks[taskID].tPokesNo = 0; + gTasks[taskId].tCurrPokeId = 0; + gTasks[taskId].tPokesNo = 0; for (i = 0; i < 6; i++, currMon++) { if (currMon->species != 0) - gTasks[taskID].tPokesNo++; + gTasks[taskId].tPokesNo++; } currMon = &savedTeams->mons[0]; @@ -691,10 +743,10 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskID) { if (currMon->species != 0) { - u16 spriteID; + u16 spriteId; s16 posX, posY; - if (gTasks[taskID].tPokesNo > 3) + if (gTasks[taskId].tPokesNo > 3) { posX = sHallOfFame_MonsFullTeamPositions[i][2]; posY = sHallOfFame_MonsFullTeamPositions[i][3]; @@ -708,52 +760,52 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskID) if (currMon->species == SPECIES_EGG) posY += 10; - spriteID = sub_818D7D8(currMon->species, currMon->tid, currMon->personality, 1, posX, posY, i, 0xFFFF); - gSprites[spriteID].oam.priority = 1; - gTasks[taskID].tMonSpriteID(i) = spriteID; + spriteId = sub_818D7D8(currMon->species, currMon->tid, currMon->personality, 1, posX, posY, i, 0xFFFF); + gSprites[spriteId].oam.priority = 1; + gTasks[taskId].tMonSpriteId(i) = spriteId; } else { - gTasks[taskID].tMonSpriteID(i) = 0xFF; + gTasks[taskId].tMonSpriteId(i) = 0xFF; } } BlendPalettes(0xFFFF0000, 0xC, 0x63B0); - ConvertIntToDecimalStringN(gStringVar1, gTasks[taskID].tCurrPageNo, STR_CONV_MODE_RIGHT_ALIGN, 3); + ConvertIntToDecimalStringN(gStringVar1, gTasks[taskId].tCurrPageNo, STR_CONV_MODE_RIGHT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_HOFNumber); - if (gTasks[taskID].tCurrTeamNo <= 0) + if (gTasks[taskId].tCurrTeamNo <= 0) sub_8198204(gStringVar4, gText_PickCancel, 0, 0, 1); else sub_8198204(gStringVar4, gText_PickNextCancel, 0, 0, 1); - gTasks[taskID].func = Task_HofPC_PrintMonInfo; + gTasks[taskId].func = Task_HofPC_PrintMonInfo; } -static void Task_HofPC_PrintMonInfo(u8 taskID) +static void Task_HofPC_PrintMonInfo(u8 taskId) { struct HallofFameMons* savedTeams = gHofMonsPtr; struct HallofFameMon* currMon; u16 i; u16 currMonID; - for (i = 0; i < gTasks[taskID].tCurrTeamNo; i++) + for (i = 0; i < gTasks[taskId].tCurrTeamNo; i++) savedTeams++; for (i = 0; i < 6; i++) { - u16 spriteID = gTasks[taskID].tMonSpriteID(i); - if (spriteID != 0xFF) - gSprites[spriteID].oam.priority = 1; + u16 spriteId = gTasks[taskId].tMonSpriteId(i); + if (spriteId != 0xFF) + gSprites[spriteId].oam.priority = 1; } - currMonID = gTasks[taskID].tMonSpriteID(gTasks[taskID].tCurrPokeID); + currMonID = gTasks[taskId].tMonSpriteId(gTasks[taskId].tCurrPokeId); gSprites[currMonID].oam.priority = 0; gUnknown_0203BCD4 = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000; BlendPalettesUnfaded(gUnknown_0203BCD4, 0xC, 0x63B0); - currMon = &savedTeams->mons[gTasks[taskID].tCurrPokeID]; + currMon = &savedTeams->mons[gTasks[taskId].tCurrPokeId]; if (currMon->species != SPECIES_EGG) { StopCryAndClearCrySongs(); @@ -761,30 +813,30 @@ static void Task_HofPC_PrintMonInfo(u8 taskID) } HallOfFame_PrintMonInfo(currMon, 0, 14); - gTasks[taskID].func = Task_HofPC_HandleInput; + gTasks[taskId].func = Task_HofPC_HandleInput; } -static void Task_HofPC_HandleInput(u8 taskID) +static void Task_HofPC_HandleInput(u8 taskId) { u16 i; if (gMain.newKeys & A_BUTTON) { - if (gTasks[taskID].tCurrTeamNo != 0) // prepare another team to view + if (gTasks[taskId].tCurrTeamNo != 0) // prepare another team to view { - gTasks[taskID].tCurrTeamNo--; + gTasks[taskId].tCurrTeamNo--; for (i = 0; i < 6; i++) { - u8 spriteID = gTasks[taskID].tMonSpriteID(i); - if (spriteID != 0xFF) + u8 spriteId = gTasks[taskId].tMonSpriteId(i); + if (spriteId != 0xFF) { - sub_818D820(spriteID); - gTasks[taskID].tMonSpriteID(i) = 0xFF; + sub_818D820(spriteId); + gTasks[taskId].tMonSpriteId(i) = 0xFF; } } - if (gTasks[taskID].tCurrPageNo != 0) - gTasks[taskID].tCurrPageNo--; - gTasks[taskID].func = Task_HofPC_DrawSpritesPrintText; + if (gTasks[taskId].tCurrPageNo != 0) + gTasks[taskId].tCurrPageNo--; + gTasks[taskId].func = Task_HofPC_DrawSpritesPrintText; } else // no more teams to view, turn off hall of fame PC { @@ -793,7 +845,7 @@ static void Task_HofPC_HandleInput(u8 taskID) StopCryAndClearCrySongs(); m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100); } - gTasks[taskID].func = Task_HofPC_HandlePaletteOnExit; + gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit; } } else if (gMain.newKeys & B_BUTTON) // turn off hall of fame PC @@ -803,21 +855,21 @@ static void Task_HofPC_HandleInput(u8 taskID) StopCryAndClearCrySongs(); m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100); } - gTasks[taskID].func = Task_HofPC_HandlePaletteOnExit; + gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit; } - else if (gMain.newKeys & DPAD_UP && gTasks[taskID].tCurrPokeID != 0) // change mon -1 + else if (gMain.newKeys & DPAD_UP && gTasks[taskId].tCurrPokeId != 0) // change mon -1 { - gTasks[taskID].tCurrPokeID--; - gTasks[taskID].func = Task_HofPC_PrintMonInfo; + gTasks[taskId].tCurrPokeId--; + gTasks[taskId].func = Task_HofPC_PrintMonInfo; } - else if (gMain.newKeys & DPAD_DOWN && gTasks[taskID].tCurrPokeID < gTasks[taskID].tPokesNo - 1) // change mon +1 + else if (gMain.newKeys & DPAD_DOWN && gTasks[taskId].tCurrPokeId < gTasks[taskId].tPokesNo - 1) // change mon +1 { - gTasks[taskID].tCurrPokeID++; - gTasks[taskID].func = Task_HofPC_PrintMonInfo; + gTasks[taskId].tCurrPokeId++; + gTasks[taskId].func = Task_HofPC_PrintMonInfo; } } -static void Task_HofPC_HandlePaletteOnExit(u8 taskID) +static void Task_HofPC_HandlePaletteOnExit(u8 taskId) { struct HallofFameMons* fameMons; @@ -825,10 +877,10 @@ static void Task_HofPC_HandlePaletteOnExit(u8 taskID) fameMons = (struct HallofFameMons*)(gDecompressionBuffer); fameMons->mons[0] = sDummyFameMon; sub_80F9BF4(0, 0, 0); - gTasks[taskID].func = Task_HofPC_HandleExit; + gTasks[taskId].func = Task_HofPC_HandleExit; } -static void Task_HofPC_HandleExit(u8 taskID) +static void Task_HofPC_HandleExit(u8 taskId) { if (!sub_80F9C30()) { @@ -836,11 +888,11 @@ static void Task_HofPC_HandleExit(u8 taskID) for (i = 0; i < 6; i++) { - u16 spriteId = gTasks[taskID].tMonSpriteID(i); + u16 spriteId = gTasks[taskId].tMonSpriteId(i); if (spriteId != 0xFF) { sub_818D820(spriteId); - gTasks[taskID].tMonSpriteID(i) = 0xFF; + gTasks[taskId].tMonSpriteId(i) = 0xFF; } } @@ -852,7 +904,7 @@ static void Task_HofPC_HandleExit(u8 taskID) UnsetBgTilemapBuffer(1); UnsetBgTilemapBuffer(3); ResetBgsAndClearDma3BusyFlags(0); - DestroyTask(taskID); + DestroyTask(taskId); if (gUnknown_0203BCDC != NULL) FREE_AND_SET_NULL(gUnknown_0203BCDC); @@ -872,14 +924,438 @@ static void Task_HofPC_PrintDataIsCorrupted(u8 taskId) gTasks[taskId].func = Task_HofPC_ExitOnButtonPress; } -static void Task_HofPC_ExitOnButtonPress(u8 taskID) +static void Task_HofPC_ExitOnButtonPress(u8 taskId) { if (gMain.newKeys & A_BUTTON) - gTasks[taskID].func = Task_HofPC_HandlePaletteOnExit; + gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit; } #undef tCurrTeamNo #undef tCurrPageNo -#undef tCurrPokeID +#undef tCurrPokeId #undef tPokesNo -#undef tMonSpriteID +#undef tMonSpriteId + +void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2) +{ + FillWindowPixelBuffer(0, 0); + PutWindowTilemap(0); + box_print(0, 1, GetStringCenterAlignXOffset(1, gText_WelcomeToHOF, 0xD0), 1, gUnknown_085E5388, 0, gText_WelcomeToHOF); + CopyWindowToVram(0, 3); +} + +void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2) +{ + u8 text[30]; + u8 *stringPtr; + s32 dexNumber; + s32 width; + + FillWindowPixelBuffer(0, 0); + PutWindowTilemap(0); + + // dex number + if (currMon->species != SPECIES_EGG) + { + stringPtr = StringCopy(text, gText_Number); + dexNumber = SpeciesToPokedexNum(currMon->species); + if (dexNumber != 0xFFFF) + { + stringPtr[0] = (dexNumber / 100) + CHAR_0; + stringPtr++; + dexNumber %= 100; + stringPtr[0] = (dexNumber / 10) + CHAR_0; + stringPtr++; + stringPtr[0] = (dexNumber % 10) + CHAR_0; + stringPtr++; + } + else + { + *(stringPtr)++ = CHAR_QUESTION_MARK; + *(stringPtr)++ = CHAR_QUESTION_MARK; + *(stringPtr)++ = CHAR_QUESTION_MARK; + } + stringPtr[0] = EOS; + box_print(0, 1, 0x10, 1, gUnknown_085E5388, -1, text); + } + + // nick, species names, gender and level + memcpy(text, currMon->nick, POKEMON_NAME_LENGTH); + text[POKEMON_NAME_LENGTH] = EOS; + if (currMon->species == SPECIES_EGG) + { + width = GetStringCenterAlignXOffset(1, text, 0xD0); + box_print(0, 1, width, 1, gUnknown_085E5388, -1, text); + CopyWindowToVram(0, 3); + } + else + { + width = GetStringRightAlignXOffset(1, text, 0x80); + box_print(0, 1, width, 1, gUnknown_085E5388, -1, text); + + text[0] = CHAR_SLASH; + stringPtr = StringCopy(text + 1, gSpeciesNames[currMon->species]); + + if (currMon->species != SPECIES_NIDORAN_M && currMon->species != SPECIES_NIDORAN_F) + { + switch (GetGenderFromSpeciesAndPersonality(currMon->species, currMon->personality)) + { + case MON_MALE: + stringPtr[0] = CHAR_MALE; + stringPtr++; + break; + case MON_FEMALE: + stringPtr[0] = CHAR_FEMALE; + stringPtr++; + break; + } + } + + stringPtr[0] = EOS; + box_print(0, 1, 0x80, 1, gUnknown_085E5388, -1, text); + + stringPtr = StringCopy(text, gText_Level); + ConvertIntToDecimalStringN(stringPtr, currMon->lvl, STR_CONV_MODE_LEFT_ALIGN, 3); + box_print(0, 1, 0x24, 0x11, gUnknown_085E5388, -1, text); + + stringPtr = StringCopy(text, gText_IDNumber); + ConvertIntToDecimalStringN(stringPtr, (u16)(currMon->tid), STR_CONV_MODE_LEADING_ZEROS, 5); + box_print(0, 1, 0x68, 0x11, gUnknown_085E5388, -1, text); + + CopyWindowToVram(0, 3); + } +} + +void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2) +{ + u8 text[20]; + u32 width; + u16 trainerId; + + FillWindowPixelBuffer(1, 0x11); + PutWindowTilemap(1); + SetWindowBorderStyle(1, FALSE, 0x21D, 0xD); + box_print(1, 1, 0, 1, gUnknown_085E538C, -1, gText_Name); + + width = GetStringRightAlignXOffset(1, gSaveBlock2Ptr->playerName, 0x70); + box_print(1, 1, width, 1, gUnknown_085E538C, -1, gSaveBlock2Ptr->playerName); + + trainerId = (gSaveBlock2Ptr->playerTrainerId[0]) | (gSaveBlock2Ptr->playerTrainerId[1] << 8); + box_print(1, 1, 0, 0x11, gUnknown_085E538C, 0, gText_IDNumber); + text[0] = (trainerId % 100000) / 10000 + CHAR_0; + text[1] = (trainerId % 10000) / 1000 + CHAR_0; + text[2] = (trainerId % 1000) / 100 + CHAR_0; + text[3] = (trainerId % 100) / 10 + CHAR_0; + text[4] = (trainerId % 10) / 1 + CHAR_0; + text[5] = EOS; + width = GetStringRightAlignXOffset(1, text, 0x70); + box_print(1, 1, width, 0x11, gUnknown_085E538C, -1, text); + + box_print(1, 1, 0, 0x21, gUnknown_085E538C, -1, gText_MainMenuTime); + text[0] = (gSaveBlock2Ptr->playTimeHours / 100) + CHAR_0; + text[1] = (gSaveBlock2Ptr->playTimeHours % 100) / 10 + CHAR_0; + text[2] = (gSaveBlock2Ptr->playTimeHours % 10) + CHAR_0; + + if (text[0] == CHAR_0) + text[0] = CHAR_SPACE; + if (text[0] == CHAR_SPACE && text[1] == CHAR_0) + text[8] = CHAR_SPACE; + + text[3] = CHAR_COLON; + text[4] = (gSaveBlock2Ptr->playTimeMinutes % 100) / 10 + CHAR_0; + text[5] = (gSaveBlock2Ptr->playTimeMinutes % 10) + CHAR_0; + text[6] = EOS; + + width = GetStringRightAlignXOffset(1, text, 0x70); + box_print(1, 1, width, 0x21, gUnknown_085E538C, -1, text); + + CopyWindowToVram(1, 3); +} + +void ClearVramOamPltt_LoadHofPal(void) +{ + u32 vramOffset, oamOffset, plttOffset; + u32 vramSize, oamSize, plttSize; + + vramOffset = (VRAM); + vramSize = VRAM_SIZE; + while (TRUE) + { + DmaFill16(3, 0, vramOffset, 0x1000); + vramOffset += 0x1000; + vramSize -= 0x1000; + if (vramSize <= 0x1000) + { + DmaFill16(3, 0, vramOffset, vramSize); + break; + } + } + + oamOffset = OAM; + oamSize = OAM_SIZE; + DmaFill32(3, 0, oamOffset, oamSize); + + plttOffset = PLTT; + plttSize = PLTT_SIZE; + DmaFill16(3, 0, plttOffset, plttSize); + + ResetPaletteFade(); + LoadPalette(gHallOfFame_Pal, 0, 0x20); +} + +void sub_8174F70(void) +{ + remove_some_task(); + ResetTasks(); + ResetSpriteData(); + reset_temp_tile_data_buffers(); + dp13_810BB8C(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + LoadCompressedObjectPic(&sHallOfFame_ConfettiSpriteSheet); + LoadCompressedObjectPalette(&sHallOfFame_ConfettiSpritePalette); +} + +void sub_8174FAC(void) +{ + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_085E5374, ARRAY_COUNT(gUnknown_085E5374)); + SetBgTilemapBuffer(1, gUnknown_0203BCDC->tilemap1); + SetBgTilemapBuffer(3, gUnknown_0203BCDC->tilemap2); + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); +} + +bool8 sub_8175024(void) +{ + switch (gUnknown_0203BCDC->state) + { + case 0: + decompress_and_copy_tile_data_to_vram(1, gUnknown_085E5508, 0, 0, 0); + break; + case 1: + if (free_temp_tile_data_buffers_if_possible()) + return TRUE; + break; + case 2: + FillBgTilemapBufferRect_Palette0(1, 1, 0, 0, 0x20, 2); + FillBgTilemapBufferRect_Palette0(1, 0, 0, 3, 0x20, 0xB); + FillBgTilemapBufferRect_Palette0(1, 1, 0, 0xE, 0x20, 6); + FillBgTilemapBufferRect_Palette0(3, 2, 0, 0, 0x20, 0x20); + + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(3); + break; + case 3: + sub_81971D0(); + sub_8197200(); + break; + case 4: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + ShowBg(0); + ShowBg(1); + ShowBg(3); + gUnknown_0203BCDC->state = 0; + return FALSE; + } + + gUnknown_0203BCDC->state++; + return TRUE; +} + +void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite) +{ + if (sprite->pos1.x != sprite->tDestinationX + || sprite->pos1.y != sprite->tDestinationY) + { + if (sprite->pos1.x < sprite->tDestinationX) + sprite->pos1.x += 15; + if (sprite->pos1.x > sprite->tDestinationX) + sprite->pos1.x -= 15; + + if (sprite->pos1.y < sprite->tDestinationY) + sprite->pos1.y += 10; + if (sprite->pos1.y > sprite->tDestinationY) + sprite->pos1.y -= 10; + } + else + { + s16 species = sprite->tSpecies; + + if (species == SPECIES_EGG) + DoMonFrontSpriteAnimation(sprite, species, TRUE, 3); + else + DoMonFrontSpriteAnimation(sprite, species, FALSE, 3); + } +} + +#undef tDestinationX +#undef tDestinationY +#undef tSpecies + +static void sub_81751A4(struct Sprite* sprite) +{ + if (sprite->pos2.y > 120) + { + DestroySprite(sprite); + } + else + { + u16 rand; + u8 tableID; + + sprite->pos2.y++; + sprite->pos2.y += sprite->data1; + + tableID = sprite->data0; + rand = (Random() % 4) + 8; + sprite->pos2.x = rand * gSineTable[tableID] / 256; + + sprite->data0 += 4; + } +} + +bool8 sub_81751FC(void) +{ + u8 spriteID; + struct Sprite* sprite; + + s16 posX = Random() % 240; + s16 posY = -(Random() % 8); + + spriteID = CreateSprite(&gUnknown_085E54D0, posX, posY, 0); + sprite = &gSprites[spriteID]; + + StartSpriteAnim(sprite, Random() % 17); + + if (Random() & 3) + sprite->data1 = 0; + else + sprite->data1 = 1; + + return FALSE; +} + +void sub_8175280(void) +{ + u8 taskId; + + gSpecialVar_0x8004 = 180; + taskId = CreateTask(sub_8175364, 0); + if (taskId != 0xFF) + { + gTasks[taskId].data[1] = gSpecialVar_0x8004; + gSpecialVar_0x8005 = taskId; + } +} + +void sub_81752C0(void) +{ + u8 taskId; + + if ((taskId = FindTaskIdByFunc(sub_8175364)) != 0xFF) + DestroyTask(taskId); + + sub_8152254(); + FreeSpriteTilesByTag(0x3E9); + FreeSpritePaletteByTag(0x3E9); +} + +struct UnknownStruct912B4 +{ + s16 field_0; + s16 field_2; + s16 field_4; + s16 field_6; + s16 field_8; + s16 field_A; + s16 field_C; + s16 field_E; + s16 field_10; + s16 field_12; + s16 field_14; + s16 field_16; + s16 field_18; + s16 field_1A; + s16 field_1C; + s16 field_1E; + s16 field_20; + s16 field_22; + s16 field_24; + s16 field_26; + s16 field_28; +}; + +void sub_81752F4(struct UnknownStruct912B4 *unkStruct) +{ + if (unkStruct->field_E > 110) + { + gTasks[unkStruct->field_28].data[15]--; + sub_81525D0(unkStruct->field_16); + } + else + { + u8 var; + s32 rand; + + unkStruct->field_E++; + unkStruct->field_E += unkStruct->field_1C; + + var = unkStruct->field_1A; + rand = Random(); + rand &= 3; + rand += 8; + unkStruct->field_C = (rand) * ((gSineTable[var])) / 256; + + unkStruct->field_1A += 4; + } +} + +void sub_8175364(u8 taskId) +{ + u32 var = 0; + u16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + if (!sub_81521C0(0x40)) + { + DestroyTask(taskId); + gSpecialVar_0x8004 = var; + gSpecialVar_0x8005 = 0xFFFF; + } + LoadCompressedObjectPic(&sHallOfFame_ConfettiSpriteSheet); + LoadCompressedObjectPalette(&sHallOfFame_ConfettiSpritePalette); + data[0]++; + break; + case 1: + if (data[1] != 0 && data[1] % 3 == 0) + { + var = sub_81524C4(gUnknown_085E53FC, 0x3E9, 0x3E9, Random() % 240, -(Random() % 8), Random() % 0x11, var); + if (var != 0xFF) + { + sub_8152438(var, sub_81752F4); + if ((Random() & 3) == 0) + sub_8152474(var, 1, 1); + sub_8152474(var, 7, taskId); + data[15]++; + } + } + sub_81522D4(); + if (data[1] != 0) + data[1]--; + else if (data[15] == 0) + data[0] = 0xFF; + break; + case 0xFF: + sub_81752C0(); + gSpecialVar_0x8004 = var; + gSpecialVar_0x8005 = 0xFFFF; + break; + } +} From a729e9838e88a982b590aafbd6330fc80c1f32e2 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 6 Nov 2017 18:41:32 +0100 Subject: [PATCH 10/18] move data to hall of fame c file --- asm/hall_of_fame.s | 11 -- data/graphics.s | 26 ++- data/hall_of_fame.s | 46 ----- include/hall_of_fame.h | 8 +- ld_script.txt | 3 +- src/hall_of_fame.c | 423 ++++++++++++++++++++++++++++++++++++----- 6 files changed, 408 insertions(+), 109 deletions(-) delete mode 100644 asm/hall_of_fame.s delete mode 100644 data/hall_of_fame.s diff --git a/asm/hall_of_fame.s b/asm/hall_of_fame.s deleted file mode 100644 index 13585c831..000000000 --- a/asm/hall_of_fame.s +++ /dev/null @@ -1,11 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - - .align 2, 0 @ Don't pad with nop. diff --git a/data/graphics.s b/data/graphics.s index e89177a1d..c3bbdd494 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -156,7 +156,31 @@ gUnknown_08C2CEE0:: @ 8C2CEE0 .incbin "baserom.gba", 0xc2cee0, 0x240 gUnknown_08C2D120:: @ 8C2D120 - .incbin "baserom.gba", 0xc2d120, 0x600 + .incbin "baserom.gba", 0xc2d120, 552 + +gUnknown_08C2D348:: @ 8C2D348 + .incbin "baserom.gba", 0xC2D348, 196 + +gUnknown_08C2D40C:: @ 8C2D40C + .incbin "baserom.gba", 0xC2D40C, 28 + +gContestConfetti_Gfx:: @ 8C2D428 + .incbin "baserom.gba", 0xC2D428, 288 + +gContestConfetti_Pal:: @ 8C2D548 + .incbin "baserom.gba", 0xC2D548, 40 + +gUnknown_08C2D570:: @ 8C2D570 + .incbin "baserom.gba", 0xC2D570, 316 + +gUnknown_08C2D6AC:: @ 8C2D6AC + .incbin "baserom.gba", 0xC2D6AC, 36 + +gUnknown_08C2D6D0:: @ 8C2D6D0 + .incbin "baserom.gba", 0xC2D6D0, 40 + +gUnknown_08C2D6F8:: @ 8C2D6F8 + .incbin "baserom.gba", 0xC2D6F8, 40 gUnknown_08C2D720:: @ 8C2D720 .incbin "baserom.gba", 0xc2d720, 0x210 diff --git a/data/hall_of_fame.s b/data/hall_of_fame.s deleted file mode 100644 index 7771224e7..000000000 --- a/data/hall_of_fame.s +++ /dev/null @@ -1,46 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -gUnknown_085E5374:: @ 85E5374 - .incbin "baserom.gba", 0x5e5374, 0xc - -gUnknown_085E5380:: @ 85E5380 - .incbin "baserom.gba", 0x5e5380, 0x8 - -gUnknown_085E5388:: @ 85E5388 - .incbin "baserom.gba", 0x5e5388, 0x4 - -gUnknown_085E538C:: @ 85E538C - .incbin "baserom.gba", 0x5e538c, 0x8 - -sHallOfFame_ConfettiSpriteSheet:: @ 85E5394 - .incbin "baserom.gba", 0x5e5394, 0x10 - -sHallOfFame_ConfettiSpritePalette:: @ 85E53A4 - .incbin "baserom.gba", 0x5e53a4, 0x10 - -sHallOfFame_MonsFullTeamPositions:: @ 85E53B4 - .incbin "baserom.gba", 0x5e53b4, 0x6 - -gUnknown_085E53BA:: @ 85E53BA - .incbin "baserom.gba", 0x5e53ba, 0x2a - -sHallOfFame_MonsHalfTeamPositions:: @ 85E53E4 - .incbin "baserom.gba", 0x5e53e4, 0x18 - -gUnknown_085E53FC:: @ 85E53FC - .incbin "baserom.gba", 0x5e53fc, 0xd4 - -gUnknown_085E54D0:: @ 85E54D0 - .incbin "baserom.gba", 0x5e54d0, 0x18 - -gHallOfFame_Pal:: @ 85E54E8 - .incbin "baserom.gba", 0x5e54e8, 0x20 - -gUnknown_085E5508:: @ 85E5508 - .incbin "baserom.gba", 0x5e5508, 0x1cc - -sDummyFameMon:: @ 85E56D4 - .incbin "baserom.gba", 0x5e56d4, 0x1c diff --git a/include/hall_of_fame.h b/include/hall_of_fame.h index 62e84c39e..d35ecf268 100644 --- a/include/hall_of_fame.h +++ b/include/hall_of_fame.h @@ -1,9 +1,9 @@ #ifndef GUARD_HALL_OF_FAME_H #define GUARD_HALL_OF_FAME_H -void sub_8141F90(void); -void sub_8143648(u16 paletteTag, u8 arg1); -void sub_81428CC(void); -void sub_8143680(int, u8); +void CB2_DoHallOfFameScreen(void); +void CB2_DoHallOfFameScreenDontSaveData(void); +void CB2_DoHallOfFamePC(void); +void sub_8175280(void); #endif // GUARD_HALL_OF_FAME_H diff --git a/ld_script.txt b/ld_script.txt index 16d7e10c9..32faa58ee 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -215,7 +215,6 @@ SECTIONS { asm/field_region_map.o(.text); asm/battle_anim_8170478.o(.text); src/hall_of_fame.o(.text); - asm/hall_of_fame.o(.text); asm/credits.o(.text); src/lottery_corner.o(.text); src/diploma.o(.text); @@ -436,7 +435,7 @@ SECTIONS { data/intro.o(.rodata); data/field_region_map.o(.rodata); data/battle_anim_8170478.o(.rodata); - data/hall_of_fame.o(.rodata); + src/hall_of_fame.o(.rodata); data/credits.o(.rodata); src/lottery_corner.o(.rodata); src/diploma.o(.rodata); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 6e9cac28b..50538dd49 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -76,20 +76,6 @@ extern u8 gReservedSpritePaletteCount; #define HALL_OF_FAME_MAX_TEAMS 50 -extern const u8 gUnknown_085E53FC[]; -extern const struct SpriteTemplate gUnknown_085E54D0; -extern const struct BgTemplate gUnknown_085E5374[3]; -extern const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet; -extern const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette; -extern const u16 gHallOfFame_Pal[]; -extern const u8 gUnknown_085E5388[]; -extern const u8 gUnknown_085E538C[]; -extern const struct HallofFameMon sDummyFameMon; -extern const struct WindowTemplate gUnknown_085E5380; -extern const s16 sHallOfFame_MonsFullTeamPositions[][4]; -extern const s16 sHallOfFame_MonsHalfTeamPositions[][4]; -extern const u32 gUnknown_085E5508[]; - // strings extern const u8 gText_SavingDontTurnOffPower[]; extern const u8 gText_LeagueChamp[]; @@ -105,6 +91,10 @@ extern const u8 gText_IDNumber[]; extern const u8 gText_Name[]; extern const u8 gText_MainMenuTime[]; +// graphics +extern const u8 gContestConfetti_Gfx[]; +extern const u8 gContestConfetti_Pal[]; + extern void sub_81973C4(u8, u8); extern u16 AddTextPrinterParametrized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void ( *callback)(u16, struct TextPrinter *), u8 fgColor, u8 bgColor, u8 shadowColor); extern void sub_8175620(void); @@ -137,15 +127,15 @@ extern void sub_8152438(u8, void*); extern void sub_8152474(u8, u8, u8); extern void sub_81522D4(void); extern bool32 sub_81521C0(u8); -extern u8 sub_81524C4(const void *arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, u8 arg5, s16 arg6); +extern u8 sub_81524C4(const struct OamData *arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, u8 arg5, s16 arg6); // this file's functions -void ClearVramOamPltt_LoadHofPal(void); -void sub_8174F70(void); -void sub_8174FAC(void); -bool8 sub_81751FC(void); +static void ClearVramOamPltt_LoadHofPal(void); +static void sub_8174F70(void); +static void sub_8174FAC(void); +static bool8 sub_81751FC(void); static void SetCallback2AfterHallOfFameDisplay(void); -bool8 sub_8175024(void); +static bool8 sub_8175024(void); static void Task_Hof_InitMonData(u8 taskId); static void Task_Hof_InitTeamSaveData(u8 taskId); static void Task_Hof_SetMonDisplayTask(u8 taskId); @@ -170,20 +160,363 @@ static void Task_HofPC_HandleInput(u8 taskId); static void Task_HofPC_HandlePaletteOnExit(u8 taskId); static void Task_HofPC_HandleExit(u8 taskId); static void Task_HofPC_ExitOnButtonPress(u8 taskId); -void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite); -void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2); -void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2); -void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2); -void sub_8175364(u8 taskId); +static void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite); +static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2); +static void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2); +static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2); +static void sub_8175364(u8 taskId); +static void sub_81751A4(struct Sprite* sprite); -void VBlankCB_HallOfFame(void) +// const rom data +static const struct BgTemplate sHof_BgTemplates[] = +{ + { + .bg = 0, + .charBaseIndex = 2, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 30, + .screenSize = 0, + .paletteMode = 0, + .priority = 1, + .baseTile = 0 + }, + { + .bg = 3, + .charBaseIndex = 0, + .mapBaseIndex = 29, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0 + }, +}; + +static const struct WindowTemplate sHof_WindowTemplate = {0, 2, 2, 0xE, 6, 0xE, 1}; + +static const u8 gUnknown_085E5388[] = {0, 1, 2, 0}; + +static const u8 gUnknown_085E538C[] = {0, 2, 3, 0, 4, 5, 0, 0}; + +static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet = +{ + gContestConfetti_Gfx, 0x220, 1001 +}; + +static const u8 sUnused0[8] = {}; + +static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette = +{ + gContestConfetti_Pal, 1001 +}; + +static const u8 sUnused1[8] = {}; + +static const s16 sHallOfFame_MonsFullTeamPositions[6][4] = +{ + {120, 210, 120, 40}, + {326, 220, 56, 40}, + {-86, 220, 184, 40}, + {120, -62, 120, 88}, + {-70, -92, 200, 88}, + {310, -92, 40, 88} +}; + +static const s16 sHallOfFame_MonsHalfTeamPositions[3][4] = +{ + {120, 234, 120, 64}, + {326, 244, 56, 64}, + {-86, 244, 184, 64} +}; + +static const struct OamData sOamData_85E53FC = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sSpriteAnim_85E5404[] = +{ + ANIMCMD_FRAME(0, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E540C[] = +{ + ANIMCMD_FRAME(1, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E5414[] = +{ + ANIMCMD_FRAME(2, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E541C[] = +{ + ANIMCMD_FRAME(3, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E5424[] = +{ + ANIMCMD_FRAME(4, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E542C[] = +{ + ANIMCMD_FRAME(5, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E5434[] = +{ + ANIMCMD_FRAME(6, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E543C[] = +{ + ANIMCMD_FRAME(7, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E5444[] = +{ + ANIMCMD_FRAME(8, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E544C[] = +{ + ANIMCMD_FRAME(9, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E5454[] = +{ + ANIMCMD_FRAME(10, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E545C[] = +{ + ANIMCMD_FRAME(11, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E5464[] = +{ + ANIMCMD_FRAME(12, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E546C[] = +{ + ANIMCMD_FRAME(13, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E5474[] = +{ + ANIMCMD_FRAME(14, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E547C[] = +{ + ANIMCMD_FRAME(15, 30), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_85E5484[] = +{ + ANIMCMD_FRAME(16, 30), + ANIMCMD_END +}; + +static const union AnimCmd * const sSpriteAnimTable_85E548C[] = +{ + sSpriteAnim_85E5404, sSpriteAnim_85E540C, sSpriteAnim_85E5414, sSpriteAnim_85E541C, + sSpriteAnim_85E5424, sSpriteAnim_85E542C, sSpriteAnim_85E5434, sSpriteAnim_85E543C, + sSpriteAnim_85E5444, sSpriteAnim_85E544C, sSpriteAnim_85E5454, sSpriteAnim_85E545C, + sSpriteAnim_85E5464, sSpriteAnim_85E546C, sSpriteAnim_85E5474, sSpriteAnim_85E547C, + sSpriteAnim_85E5484 +}; + +static const struct SpriteTemplate sSpriteTemplate_85E54D0 = +{ + .tileTag = 1001, + .paletteTag = 1001, + .oam = &sOamData_85E53FC, + .anims = sSpriteAnimTable_85E548C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_81751A4 +}; + +// todo: dump actual graphics +static const u32 sHallOfFame_Pal[] = +{ + 0, 0x109F63B0, 0x5B6E, 0, 0, 0, 0, 0x7FFF2108 +}; + +// todo: dump actual graphics +static const u32 sHallOfFame_Gfx[] = +{ + 0x3A010, + 0xF0000033, + 0x11019001, + 0x9001F011, + 0x22220001, + 0x44442222, + 0xF0E04444, + 0x70073007, + 0x11113329, + 0x13033331, + 0x33333311, + 0xF0030031, + 0x1108049, + 0x1111FFFF, + 0x4913EEEE, + 0xE10700F1, + 0x110B00EE, + 0x1D90EF, + 0x1EFFF11E, + 0x1EEEE11E, + 0x1500EF4A, + 0xB00EFEE, + 0xF11F90FF, + 0xFFF1FE01, + 0xEEE1EEE1, + 0xF1211200, + 0x1E0300EE, + 0x10E1EF11, + 0x3B40D029, + 0x1E7C00, + 0xF3331178, + 0x331100EF, + 0x3331FEEF, + 0x10E8F3EF, + 0x105F9003, + 0x7C003394, + 0x3AE1133E, + 0xC003EEE, + 0x1800310, + 0xEF8F10F1, + 0xFEA30081, + 0xE1FEEE1E, + 0x33A300EF, + 0x6800EEEF, + 0x1EFE0130, + 0x3009300, + 0xF11EFF0A, + 0xFFA1101E, + 0x17EF0300, + 0x80FEEEFE, + 0x11313F, + 0xD7006100, + 0xEF332F, + 0x8F00FF0A, + 0x7B209F60, + 0xEF440400, + 0x3EFE2201, + 0x33070013, + 0xC0FE50F1, + 0x110EF80, + 0xFEF1EEF1, + 0xF1EFFF00, + 0xF1FEEEFF, + 0x921EBF1, + 0x111120A0, + 0xF12601EE, + 0x1107D00, + 0x819100EB, + 0xFE2D005D, + 0x10FFB100, + 0xFE3910AB, + 0x9810B410, + 0x3108F11, + 0x89209F11, + 0xA0EFF6A0, + 0x1FE8D00, + 0xE111F153, + 0xF1AFE11E, + 0x641011B3, + 0x19110EF, + 0x406FA07C, + 0xA400CBB3, + 0xEEFF0300, + 0x611E2D01, + 0x6314612F, + 0x11470133, + 0xE3EE3387, + 0x23318810, + 0x210170F7, + 0x950087, + 0xA00FF03, + 0x1123FE0, + 0xCC00F141, + 0xFFFE1EEF, + 0x8F3402EE, + 0xF1EE1ED0, + 0x10B7201E, + 0x23CF0EE, + 0x8301EF17, + 0x1A011002, + 0x20CC0133, + 0x70A7017B, + 0xF35701, + 0x7C00EF80, + 0xF1BA22EE, + 0xDCED011D, + 0x1009621, + 0xE16000FE, + 0xF1F9001F, + 0xB42A5FE, + 0x113FF1EE, + 0xFEA702FF, + 0xE04101, + 0xD03F22BC, + 1 +}; + +static const struct HallofFameMon sDummyFameMon = +{ + 0x3EA03EA, 0, 0, 0, {0} +}; + +static const u8 sUnused2[6] = {2, 1, 3, 6, 4, 5}; + +// code +static void VBlankCB_HallOfFame(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -void CB2_HallOfFame(void) +static void CB2_HallOfFame(void) { RunTasks(); RunTextPrinters(); @@ -528,7 +861,7 @@ static void sub_8173EE4(u8 taskId) ShowBg(1); ShowBg(3); gTasks[taskId].tPlayerSpriteID = sub_818D8AC(sub_818D97C(gSaveBlock2Ptr->playerGender, 1), 1, 120, 72, 6, 0xFFFF); - AddWindow(&gUnknown_085E5380); + AddWindow(&sHof_WindowTemplate); sub_80987D4(1, gSaveBlock2Ptr->optionsWindowFrameType, 0x21D, 0xD0); LoadPalette(stdpal_get(1), 0xE0, 0x20); gTasks[taskId].tFrameCount = 120; @@ -936,7 +1269,7 @@ static void Task_HofPC_ExitOnButtonPress(u8 taskId) #undef tPokesNo #undef tMonSpriteId -void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2) +static void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2) { FillWindowPixelBuffer(0, 0); PutWindowTilemap(0); @@ -944,7 +1277,7 @@ void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2) CopyWindowToVram(0, 3); } -void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2) +static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2) { u8 text[30]; u8 *stringPtr; @@ -1026,7 +1359,7 @@ void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unuse } } -void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2) +static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2) { u8 text[20]; u32 width; @@ -1072,7 +1405,7 @@ void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2) CopyWindowToVram(1, 3); } -void ClearVramOamPltt_LoadHofPal(void) +static void ClearVramOamPltt_LoadHofPal(void) { u32 vramOffset, oamOffset, plttOffset; u32 vramSize, oamSize, plttSize; @@ -1100,10 +1433,10 @@ void ClearVramOamPltt_LoadHofPal(void) DmaFill16(3, 0, plttOffset, plttSize); ResetPaletteFade(); - LoadPalette(gHallOfFame_Pal, 0, 0x20); + LoadPalette(sHallOfFame_Pal, 0, 0x20); } -void sub_8174F70(void) +static void sub_8174F70(void) { remove_some_task(); ResetTasks(); @@ -1116,10 +1449,10 @@ void sub_8174F70(void) LoadCompressedObjectPalette(&sHallOfFame_ConfettiSpritePalette); } -void sub_8174FAC(void) +static void sub_8174FAC(void) { ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_085E5374, ARRAY_COUNT(gUnknown_085E5374)); + InitBgsFromTemplates(0, sHof_BgTemplates, ARRAY_COUNT(sHof_BgTemplates)); SetBgTilemapBuffer(1, gUnknown_0203BCDC->tilemap1); SetBgTilemapBuffer(3, gUnknown_0203BCDC->tilemap2); ChangeBgX(0, 0, 0); @@ -1130,12 +1463,12 @@ void sub_8174FAC(void) ChangeBgY(3, 0, 0); } -bool8 sub_8175024(void) +static bool8 sub_8175024(void) { switch (gUnknown_0203BCDC->state) { case 0: - decompress_and_copy_tile_data_to_vram(1, gUnknown_085E5508, 0, 0, 0); + decompress_and_copy_tile_data_to_vram(1, sHallOfFame_Gfx, 0, 0, 0); break; case 1: if (free_temp_tile_data_buffers_if_possible()) @@ -1167,7 +1500,7 @@ bool8 sub_8175024(void) return TRUE; } -void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite) +static void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite) { if (sprite->pos1.x != sprite->tDestinationX || sprite->pos1.y != sprite->tDestinationY) @@ -1219,7 +1552,7 @@ static void sub_81751A4(struct Sprite* sprite) } } -bool8 sub_81751FC(void) +static bool8 sub_81751FC(void) { u8 spriteID; struct Sprite* sprite; @@ -1227,7 +1560,7 @@ bool8 sub_81751FC(void) s16 posX = Random() % 240; s16 posY = -(Random() % 8); - spriteID = CreateSprite(&gUnknown_085E54D0, posX, posY, 0); + spriteID = CreateSprite(&sSpriteTemplate_85E54D0, posX, posY, 0); sprite = &gSprites[spriteID]; StartSpriteAnim(sprite, Random() % 17); @@ -1253,7 +1586,7 @@ void sub_8175280(void) } } -void sub_81752C0(void) +static void sub_81752C0(void) { u8 taskId; @@ -1290,7 +1623,7 @@ struct UnknownStruct912B4 s16 field_28; }; -void sub_81752F4(struct UnknownStruct912B4 *unkStruct) +static void sub_81752F4(struct UnknownStruct912B4 *unkStruct) { if (unkStruct->field_E > 110) { @@ -1315,7 +1648,7 @@ void sub_81752F4(struct UnknownStruct912B4 *unkStruct) } } -void sub_8175364(u8 taskId) +static void sub_8175364(u8 taskId) { u32 var = 0; u16 *data = gTasks[taskId].data; @@ -1336,7 +1669,7 @@ void sub_8175364(u8 taskId) case 1: if (data[1] != 0 && data[1] % 3 == 0) { - var = sub_81524C4(gUnknown_085E53FC, 0x3E9, 0x3E9, Random() % 240, -(Random() % 8), Random() % 0x11, var); + var = sub_81524C4(&sOamData_85E53FC, 0x3E9, 0x3E9, Random() % 240, -(Random() % 8), Random() % 0x11, var); if (var != 0xFF) { sub_8152438(var, sub_81752F4); From 19d9cff2ff582d68d5aa76fd9d2068a6407e1466 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 6 Nov 2017 18:57:22 +0100 Subject: [PATCH 11/18] static variables to hall of fame c --- asm/credits.s | 2 +- asm/rom6.s | 4 +- src/hall_of_fame.c | 108 +++++++++++++++++++-------------------------- sym_ewram.txt | 8 +--- 4 files changed, 51 insertions(+), 71 deletions(-) diff --git a/asm/credits.s b/asm/credits.s index a5097f83c..a9373c042 100644 --- a/asm/credits.s +++ b/asm/credits.s @@ -26,7 +26,7 @@ sub_81754DC: @ 81754DC ands r0, r1 cmp r0, 0 beq _08175522 - ldr r0, =HasHallOfFameRecords + ldr r0, =gHasHallOfFameRecords ldrb r0, [r0] cmp r0, 0 beq _08175522 diff --git a/asm/rom6.s b/asm/rom6.s index e312b2330..68719469f 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -4043,12 +4043,12 @@ sub_8137734: @ 8137734 lsrs r1, r0, 24 cmp r1, 0x1 bne _08137760 - ldr r0, =HasHallOfFameRecords + ldr r0, =gHasHallOfFameRecords strb r1, [r0] b _0813776C .pool _08137760: - ldr r1, =HasHallOfFameRecords + ldr r1, =gHasHallOfFameRecords movs r0, 0 strb r0, [r1] adds r0, r4, 0 diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 50538dd49..2148daddf 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -39,35 +39,19 @@ struct HallofFameMons struct HallofFameMon mons[6]; }; -extern struct HallofFameMons *gHofMonsPtr; - struct HofGfx { u16 state; - u8 field_2; - u8 field_3; - u8 field_4; - u8 field_5; - u8 field_6; - u8 field_7; - u8 field_8; - u8 field_9; - u8 field_A; - u8 field_B; - u8 field_C; - u8 field_D; - u8 field_E; - u8 field_F; - u8 field_10; - u8 field_11; + u8 field_2[16]; u8 tilemap1[0x1000]; u8 tilemap2[0x1000]; }; -extern struct HofGfx *gUnknown_0203BCDC; +static EWRAM_DATA struct HallofFameMons *sHofMonsPtr = NULL; +static EWRAM_DATA struct HofGfx *sHofGfxPtr = NULL; +extern bool8 gHasHallOfFameRecords; extern u32 gUnknown_0203BCD4; -extern bool8 HasHallOfFameRecords; extern u8 gDecompressionBuffer[]; extern struct MusicPlayerInfo gMPlay_BGM; extern MainCallback gGameContinueCallback; @@ -532,7 +516,7 @@ static bool8 InitHallOfFameScreen(void) case 0: SetVBlankCallback(NULL); ClearVramOamPltt_LoadHofPal(); - gUnknown_0203BCDC = AllocZeroed(sizeof(*gUnknown_0203BCDC)); + sHofGfxPtr = AllocZeroed(sizeof(*sHofGfxPtr)); gMain.state = 1; break; case 1: @@ -544,7 +528,7 @@ static bool8 InitHallOfFameScreen(void) SetGpuReg(REG_OFFSET_BLDALPHA, 0x710); SetGpuReg(REG_OFFSET_BLDY, 0); sub_8174FAC(); - gUnknown_0203BCDC->state = 0; + sHofGfxPtr->state = 0; gMain.state++; break; case 3: @@ -581,7 +565,7 @@ void CB2_DoHallOfFameScreen(void) { u8 taskId = CreateTask(Task_Hof_InitMonData, 0); gTasks[taskId].tDontSaveData = FALSE; - gHofMonsPtr = AllocZeroed(sizeof(*gHofMonsPtr)); + sHofMonsPtr = AllocZeroed(sizeof(*sHofMonsPtr)); } } @@ -591,7 +575,7 @@ void CB2_DoHallOfFameScreenDontSaveData(void) { u8 taskId = CreateTask(Task_Hof_InitMonData, 0); gTasks[taskId].tDontSaveData = TRUE; - gHofMonsPtr = AllocZeroed(sizeof(*gHofMonsPtr)); + sHofMonsPtr = AllocZeroed(sizeof(*sHofMonsPtr)); } } @@ -606,24 +590,24 @@ static void Task_Hof_InitMonData(u8 taskId) u8 nick[POKEMON_NAME_LENGTH + 2]; if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES)) { - gHofMonsPtr->mons[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); - gHofMonsPtr->mons[i].tid = GetMonData(&gPlayerParty[i], MON_DATA_OT_ID); - gHofMonsPtr->mons[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); - gHofMonsPtr->mons[i].lvl = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); + sHofMonsPtr->mons[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + sHofMonsPtr->mons[i].tid = GetMonData(&gPlayerParty[i], MON_DATA_OT_ID); + sHofMonsPtr->mons[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); + sHofMonsPtr->mons[i].lvl = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); GetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, nick); for (j = 0; j < POKEMON_NAME_LENGTH; j++) { - gHofMonsPtr->mons[i].nick[j] = nick[j]; + sHofMonsPtr->mons[i].nick[j] = nick[j]; } gTasks[taskId].tPokesNumber++; } else { - gHofMonsPtr->mons[i].species = 0; - gHofMonsPtr->mons[i].tid = 0; - gHofMonsPtr->mons[i].personality = 0; - gHofMonsPtr->mons[i].lvl = 0; - gHofMonsPtr->mons[i].nick[0] = EOS; + sHofMonsPtr->mons[i].species = 0; + sHofMonsPtr->mons[i].tid = 0; + sHofMonsPtr->mons[i].personality = 0; + sHofMonsPtr->mons[i].lvl = 0; + sHofMonsPtr->mons[i].nick[0] = EOS; } } @@ -647,7 +631,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId) u16 i; struct HallofFameMons* lastSavedTeam = (struct HallofFameMons*)(gDecompressionBuffer); - if (!HasHallOfFameRecords) + if (!gHasHallOfFameRecords) { memset(gDecompressionBuffer, 0, 0x2000); } @@ -673,7 +657,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId) } lastSavedTeam--; } - *lastSavedTeam = *gHofMonsPtr; + *lastSavedTeam = *sHofMonsPtr; sub_81973C4(0, 0); AddTextPrinterParametrized(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); @@ -690,10 +674,10 @@ static void Task_Hof_TrySaveData(u8 taskId) UnsetBgTilemapBuffer(3); FreeAllWindowBuffers(); - if (gUnknown_0203BCDC != NULL) - FREE_AND_SET_NULL(gUnknown_0203BCDC); - if (gHofMonsPtr != NULL) - FREE_AND_SET_NULL(gHofMonsPtr); + if (sHofGfxPtr != NULL) + FREE_AND_SET_NULL(sHofGfxPtr); + if (sHofMonsPtr != NULL) + FREE_AND_SET_NULL(sHofMonsPtr); DestroyTask(taskId); } @@ -728,7 +712,7 @@ static void Task_Hof_DisplayMon(u8 taskId) s16 xPos, yPos, field4, field6; u16 currMonId = gTasks[taskId].tDisplayedMonId; - struct HallofFameMon* currMon = &gHofMonsPtr->mons[currMonId]; + struct HallofFameMon* currMon = &sHofMonsPtr->mons[currMonId]; if (gTasks[taskId].tPokesNumber > 3) { @@ -762,7 +746,7 @@ static void Task_Hof_DisplayMon(u8 taskId) static void Task_Hof_PrintMonInfoAfterAnimating(u8 taskId) { u16 currMonId = gTasks[taskId].tDisplayedMonId; - struct HallofFameMon* currMon = &gHofMonsPtr->mons[currMonId]; + struct HallofFameMon* currMon = &sHofMonsPtr->mons[currMonId]; struct Sprite *monSprite = &gSprites[gTasks[taskId].tMonSpriteId(currMonId)]; if (monSprite->callback == SpriteCallbackDummy) @@ -777,7 +761,7 @@ static void Task_Hof_PrintMonInfoAfterAnimating(u8 taskId) static void Task_Hof_TryDisplayAnotherMon(u8 taskId) { u16 currPokeID = gTasks[taskId].tDisplayedMonId; - struct HallofFameMon* currMon = &gHofMonsPtr->mons[currPokeID]; + struct HallofFameMon* currMon = &sHofMonsPtr->mons[currPokeID]; if (gTasks[taskId].tFrameCount != 0) { @@ -931,10 +915,10 @@ static void Task_Hof_HandleExit(u8 taskId) ResetBgsAndClearDma3BusyFlags(0); DestroyTask(taskId); - if (gUnknown_0203BCDC != NULL) - FREE_AND_SET_NULL(gUnknown_0203BCDC); - if (gHofMonsPtr != NULL) - FREE_AND_SET_NULL(gHofMonsPtr); + if (sHofGfxPtr != NULL) + FREE_AND_SET_NULL(sHofGfxPtr); + if (sHofMonsPtr != NULL) + FREE_AND_SET_NULL(sHofMonsPtr); SetCallback2AfterHallOfFameDisplay(); } @@ -966,7 +950,7 @@ void CB2_DoHallOfFamePC(void) default: SetVBlankCallback(NULL); ClearVramOamPltt_LoadHofPal(); - gUnknown_0203BCDC = AllocZeroed(sizeof(*gUnknown_0203BCDC)); + sHofGfxPtr = AllocZeroed(sizeof(*sHofGfxPtr)); gMain.state = 1; break; case 1: @@ -1012,7 +996,7 @@ void CB2_DoHallOfFamePC(void) gTasks[taskId].tMonSpriteId(i) = 0xFF; } - gHofMonsPtr = AllocZeroed(0x2000); + sHofMonsPtr = AllocZeroed(0x2000); SetMainCallback2(CB2_HallOfFame); } break; @@ -1031,8 +1015,8 @@ static void Task_HofPC_CopySaveData(u8 taskId) u16 i; struct HallofFameMons* savedTeams; - CpuCopy16(gDecompressionBuffer, gHofMonsPtr, 0x2000); - savedTeams = gHofMonsPtr; + CpuCopy16(gDecompressionBuffer, sHofMonsPtr, 0x2000); + savedTeams = sHofMonsPtr; for (i = 0; i < HALL_OF_FAME_MAX_TEAMS; i++, savedTeams++) { if (savedTeams->mons[0].species == SPECIES_NONE) @@ -1052,7 +1036,7 @@ static void Task_HofPC_CopySaveData(u8 taskId) static void Task_HofPC_DrawSpritesPrintText(u8 taskId) { - struct HallofFameMons* savedTeams = gHofMonsPtr; + struct HallofFameMons* savedTeams = sHofMonsPtr; struct HallofFameMon* currMon; u16 i; @@ -1118,7 +1102,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId) static void Task_HofPC_PrintMonInfo(u8 taskId) { - struct HallofFameMons* savedTeams = gHofMonsPtr; + struct HallofFameMons* savedTeams = sHofMonsPtr; struct HallofFameMon* currMon; u16 i; u16 currMonID; @@ -1239,10 +1223,10 @@ static void Task_HofPC_HandleExit(u8 taskId) ResetBgsAndClearDma3BusyFlags(0); DestroyTask(taskId); - if (gUnknown_0203BCDC != NULL) - FREE_AND_SET_NULL(gUnknown_0203BCDC); - if (gHofMonsPtr != NULL) - FREE_AND_SET_NULL(gHofMonsPtr); + if (sHofGfxPtr != NULL) + FREE_AND_SET_NULL(sHofGfxPtr); + if (sHofMonsPtr != NULL) + FREE_AND_SET_NULL(sHofMonsPtr); sub_8137C3C(); } @@ -1453,8 +1437,8 @@ static void sub_8174FAC(void) { ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sHof_BgTemplates, ARRAY_COUNT(sHof_BgTemplates)); - SetBgTilemapBuffer(1, gUnknown_0203BCDC->tilemap1); - SetBgTilemapBuffer(3, gUnknown_0203BCDC->tilemap2); + SetBgTilemapBuffer(1, sHofGfxPtr->tilemap1); + SetBgTilemapBuffer(3, sHofGfxPtr->tilemap2); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); ChangeBgX(1, 0, 0); @@ -1465,7 +1449,7 @@ static void sub_8174FAC(void) static bool8 sub_8175024(void) { - switch (gUnknown_0203BCDC->state) + switch (sHofGfxPtr->state) { case 0: decompress_and_copy_tile_data_to_vram(1, sHallOfFame_Gfx, 0, 0, 0); @@ -1492,11 +1476,11 @@ static bool8 sub_8175024(void) ShowBg(0); ShowBg(1); ShowBg(3); - gUnknown_0203BCDC->state = 0; + sHofGfxPtr->state = 0; return FALSE; } - gUnknown_0203BCDC->state++; + sHofGfxPtr->state++; return TRUE; } diff --git a/sym_ewram.txt b/sym_ewram.txt index ef5b714ce..176620c2e 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1404,11 +1404,7 @@ gUnknown_0203BCD0: @ 203BCD0 gUnknown_0203BCD4: @ 203BCD4 .space 0x4 -gHofMonsPtr: @ 203BCD8 - .space 0x4 - -gUnknown_0203BCDC: @ 203BCDC - .space 0x4 + .include "src/hall_of_fame.o" gUnknown_0203BCE0: @ 203BCE0 .space 0x2 @@ -1416,7 +1412,7 @@ gUnknown_0203BCE0: @ 203BCE0 gUnknown_0203BCE2: @ 203BCE2 .space 0x2 -HasHallOfFameRecords: @ 203BCE4 +gHasHallOfFameRecords: @ 203BCE4 .space 0x1 gUnknown_0203BCE5: @ 203BCE5 From c967ba1d5f82c69e75f8a697fee60ceae6ef3218 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 12 Nov 2017 18:41:04 +0100 Subject: [PATCH 12/18] dump couple of baseroms review changes --- asm/berry_blender.s | 6 +++--- data/graphics.s | 2 +- data/item_menu.s | 38 +++++++++++++++++++------------------- data/mauville_old_man.s | 2 +- data/save.s | 1 - data/script_menu.s | 2 +- src/berry_blender.c | 8 ++++---- 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/asm/berry_blender.s b/asm/berry_blender.s index 1234dffeb..21da5e3da 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -5555,7 +5555,7 @@ _080826EC: adds r1, r0 adds r0, r4, 0 bl StringCopy - ldr r1, =sText_someonesPokeblockCaseIsFull + ldr r1, =ApostropheSPokeblockCaseIsFull b _08082740 .pool _0808271C: @@ -5575,7 +5575,7 @@ _0808271C: adds r1, r0 adds r0, r4, 0 bl StringCopy - ldr r1, =sText_hasNoBerriesToPut + ldr r1, =sText_HasNoBerriesToPut _08082740: adds r0, r4, 0 bl StringAppend @@ -7682,7 +7682,7 @@ sub_80838AC: @ 80838AC ldr r1, [r0] adds r0, r6, 0 bl StringCopy - ldr r1, =gText_wasMade + ldr r1, =gText_WasMade adds r0, r6, 0 bl StringAppend ldr r1, =sText_NewLine diff --git a/data/graphics.s b/data/graphics.s index 3e4df7d9c..26347ea7b 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -1226,7 +1226,7 @@ gBerryBlenderCountdownNumbersTiles:: @ 8DC9F88 gBerryBlenderStartTiles:: @ 8DCA588 .incbin "baserom.gba" , 0xdca588, 1024 - .space 512 + .space 0x200 .align 2 gBerryBlenderArrowTiles:: @ 8DCAB88 diff --git a/data/item_menu.s b/data/item_menu.s index c63b33396..b160200e8 100644 --- a/data/item_menu.s +++ b/data/item_menu.s @@ -16,21 +16,21 @@ gUnknown_08613F9C:: @ 8613F9C .4byte 0x7003011 gUnknown_08613FB4:: @ 8613FB4 - .4byte gMenuText_Use, ItemMenu_UseOutOfBattle - .4byte gMenuText_Toss, ItemMenu_Toss - .4byte gMenuText_Register, ItemMenu_Register - .4byte gMenuText_Give, ItemMenu_Give - .4byte gText_Cancel2, ItemMenu_Cancel - .4byte gMenuText_Use, ItemMenu_UseInBattle - .4byte gMenuText_Check, ItemMenu_UseOutOfBattle - .4byte gMenuText_Walk, ItemMenu_UseOutOfBattle - .4byte gMenuText_Deselect, ItemMenu_Register - .4byte gMenuText_CheckTag, ItemMenu_CheckTag - .4byte gMenuText_Confirm, unknown_ItemMenu_Confirm - .4byte gMenuText_Show, unknown_ItemMenu_Show - .4byte gMenuText_Give2, unknown_ItemMenu_Give2 - .4byte gMenuText_Confirm, unknown_ItemMenu_Confirm2 - .4byte gText_EmptyString2, 0 + .4byte gMenuText_Use, ItemMenu_UseOutOfBattle + .4byte gMenuText_Toss, ItemMenu_Toss + .4byte gMenuText_Register, ItemMenu_Register + .4byte gMenuText_Give, ItemMenu_Give + .4byte gText_Cancel2, ItemMenu_Cancel + .4byte gMenuText_Use, ItemMenu_UseInBattle + .4byte gMenuText_Check, ItemMenu_UseOutOfBattle + .4byte gMenuText_Walk, ItemMenu_UseOutOfBattle + .4byte gMenuText_Deselect, ItemMenu_Register + .4byte gMenuText_CheckTag, ItemMenu_CheckTag + .4byte gMenuText_Confirm, unknown_ItemMenu_Confirm + .4byte gMenuText_Show, unknown_ItemMenu_Show + .4byte gMenuText_Give2, unknown_ItemMenu_Give2 + .4byte gMenuText_Confirm, unknown_ItemMenu_Confirm2 + .4byte gText_EmptyString2, NULL gUnknown_0861402C:: @ 861402C .byte 0, 3, 1, 4 @@ -68,7 +68,7 @@ gUnknown_0861404D:: @ 861404D gUnknown_0861404F:: @ 861404F .byte 13, 4 -.align 2 + .align 2 gUnknown_08614054:: @ 8614054 .4byte unknown_item_menu_type .4byte unknown_item_menu_type @@ -80,10 +80,10 @@ gUnknown_08614054:: @ 8614054 .4byte unknown_item_menu_type .4byte unknown_item_menu_type .4byte unknown_item_menu_type - .4byte 0 + .4byte NULL .4byte item_menu_type_b -.align 2 + .align 2 gUnknown_08614084:: @ 8614084 .4byte BagMenuActuallyToss .4byte BagMenuCancelToss @@ -92,7 +92,7 @@ gUnknown_0861408C:: @ 861408C .4byte sub_81AD84C .4byte sub_81AD6FC -@probably a struct +@ probably a struct gUnknown_08614094:: @ 8614094 .4byte 0x1101C00 .4byte 0xFFFF1064 diff --git a/data/mauville_old_man.s b/data/mauville_old_man.s index 13e26f513..c9e096f19 100644 --- a/data/mauville_old_man.s +++ b/data/mauville_old_man.s @@ -6,7 +6,7 @@ gUnknown_0859EFE4:: @ 859EFE4 .2byte 0x2811, 0x1029, 0x1018, 0xE0D, 0x1A1A, 0x1A1D - + gUnknown_0859EFF0:: @ 859EFF0 .incbin "baserom.gba", 0x59eff0, 0x20 diff --git a/data/save.s b/data/save.s index c0b0e007f..15e201baa 100644 --- a/data/save.s +++ b/data/save.s @@ -18,4 +18,3 @@ gSaveSectionOffsets:: @ 85CDC00 .2byte 0x5D00, 0xF80 .2byte 0x6C80, 0xF80 .2byte 0x7C00, 0x7D0 - \ No newline at end of file diff --git a/data/script_menu.s b/data/script_menu.s index 0afe3579a..cf4a5df01 100644 --- a/data/script_menu.s +++ b/data/script_menu.s @@ -728,7 +728,7 @@ gUnknown_0858BAF0:: @ 858BAF0 gUnknown_0858BB68:: @ 858BB68 .byte 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F -.align 2 + .align 2 gUnknown_0858BB70:: @ 858BB70 .4byte gText_SomeonesPC .4byte gText_LanettesPC diff --git a/src/berry_blender.c b/src/berry_blender.c index 9d98f3fa7..0705812bf 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -49,7 +49,7 @@ static const u8 sUnusedText_LinkPartnerNotFound[] = _("Link partner(s) not found const u8 gText_BerryBlenderStart[] = _("Starting up the BERRY BLENDER.\pPlease select a BERRY from your BAG\nto put in the BERRY BLENDER.\p"); const u8 gText_NewParagraph[] = _("\p"); -const u8 gText_wasMade[] = _(" was made!"); +const u8 gText_WasMade[] = _(" was made!"); static const u8 sText_Mister[] = _("MISTER"); static const u8 sText_Laddie[] = _("LADDIE"); static const u8 sText_Lassie[] = _("LASSIE"); @@ -67,14 +67,14 @@ const u8* const sBlenderOpponentsNames[] = sText_Miss }; -static const u8 sText_PressA_ToStart[] = _("Press the A Button to start."); +static const u8 sText_PressAToStart[] = _("Press the A Button to start."); static const u8 sText_PleaseWaitAWhile[] = _("Please wait a while."); const u8 sText_CommunicationStandby[] = _("Communication standby…"); const u8 sText_WouldLikeToBlendAnotherBerry[] = _("Would you like to blend another BERRY?"); const u8 sText_RunOutOfBerriesForBlending[] = _("You’ve run out of BERRIES for\nblending in the BERRY BLENDER.\p"); const u8 sText_YourPokeblockCaseIsFull[] = _("Your {POKEBLOCK} CASE is full.\p"); -const u8 sText_hasNoBerriesToPut[] = _(" has no BERRIES to put in\nthe BERRY BLENDER."); -const u8 sText_someonesPokeblockCaseIsFull[] = _("’s {POKEBLOCK} CASE is full.\p"); +const u8 sText_HasNoBerriesToPut[] = _(" has no BERRIES to put in\nthe BERRY BLENDER."); +const u8 ApostropheSPokeblockCaseIsFull[] = _("’s {POKEBLOCK} CASE is full.\p"); const u8 sText_BlendingResults[] = _("RESULTS OF BLENDING"); static const u8 sText_BerryUsed[] = _("BERRY USED"); const u8 sText_SpaceBerry[] = _(" BERRY"); From ac681878951ff9f2708df8182e7c0cd20fc64f7b Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 13 Nov 2017 18:18:12 +0100 Subject: [PATCH 13/18] review changes adding a pal file --- graphics/unknown/unknown_339514.pal | 19 +++++++++++++++++++ src/berry_blender.c | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 graphics/unknown/unknown_339514.pal diff --git a/graphics/unknown/unknown_339514.pal b/graphics/unknown/unknown_339514.pal new file mode 100644 index 000000000..b87f25a6c --- /dev/null +++ b/graphics/unknown/unknown_339514.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +0 0 0 +255 255 255 +213 222 238 +180 197 230 +148 172 222 +115 148 205 +82 123 197 +49 98 189 +255 230 205 +255 164 98 +255 106 0 +222 65 8 +189 24 24 +106 106 0 +222 65 8 +189 24 24 diff --git a/src/berry_blender.c b/src/berry_blender.c index 0705812bf..cc56f15f7 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -37,7 +37,7 @@ const u8 sBlenderCenterMap[] = INCBIN_U8("graphics/berry_blender/center_map.bin" const u16 sBlenderOuterPal[] = INCBIN_U16("graphics/berry_blender/outer.gbapal"); // unreferenced pals? -static const u16 sUnknownPal_0[] = INCBIN_U16("graphics/unknown/8339514.gbapal"); +static const u16 sUnknownPal_0[] = INCBIN_U16("graphics/unknown/unknown_339514.gbapal"); static const u16 sUnknownArray_1[224] = {0}; // unused text? From 4d615350c87e65a68f095fcb4212926a6b31a85a Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 13 Nov 2017 19:36:23 +0100 Subject: [PATCH 14/18] added berry blender start gfx --- data/graphics.s | 2 +- graphics/berry_blender/start.png | Bin 0 -> 396 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 graphics/berry_blender/start.png diff --git a/data/graphics.s b/data/graphics.s index 26347ea7b..8b9f1041e 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -1224,7 +1224,7 @@ gBerryBlenderCountdownNumbersTiles:: @ 8DC9F88 .align 2 gBerryBlenderStartTiles:: @ 8DCA588 - .incbin "baserom.gba" , 0xdca588, 1024 + .incbin "graphics/berry_blender/start.4bpp" .space 0x200 diff --git a/graphics/berry_blender/start.png b/graphics/berry_blender/start.png new file mode 100644 index 0000000000000000000000000000000000000000..5c8d8d5d924d72c19e75b43db5a885f88806f3bc GIT binary patch literal 396 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!VDw>HYaZfQU(D&A+A6g0{&lR_#YIM^#4D@ z-v3Gelg=_Q{0E{rbAYlyvH$<4?A^Qf|NsB41#BJ+42^pIBBYxoq`laAitZxW%r5o6$g?;UJUj$CKs@%+5SI!f>mK-N=PWV9xI{_I85} zZ+5QMP-kJR*eLqYPG&)#ZuN89+D{ur9|@mW^Lu0J*UwMxeY%%7h0)8x^|^l{=MUYE zjfu85Cm#y;YRHSdxz0OFF2eO#u1w#K=_@;x_!6|1N{h~)yNCIz@PxU0+$y~;%VZvV n{HOb` Date: Mon, 13 Nov 2017 19:42:03 +0100 Subject: [PATCH 15/18] fix typo in a string --- asm/berry_blender.s | 2 +- src/berry_blender.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/asm/berry_blender.s b/asm/berry_blender.s index 21da5e3da..69c561beb 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -5555,7 +5555,7 @@ _080826EC: adds r1, r0 adds r0, r4, 0 bl StringCopy - ldr r1, =ApostropheSPokeblockCaseIsFull + ldr r1, =sText_ApostropheSPokeblockCaseIsFull b _08082740 .pool _0808271C: diff --git a/src/berry_blender.c b/src/berry_blender.c index cc56f15f7..8e5a51845 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -74,7 +74,7 @@ const u8 sText_WouldLikeToBlendAnotherBerry[] = _("Would you like to blend anoth const u8 sText_RunOutOfBerriesForBlending[] = _("You’ve run out of BERRIES for\nblending in the BERRY BLENDER.\p"); const u8 sText_YourPokeblockCaseIsFull[] = _("Your {POKEBLOCK} CASE is full.\p"); const u8 sText_HasNoBerriesToPut[] = _(" has no BERRIES to put in\nthe BERRY BLENDER."); -const u8 ApostropheSPokeblockCaseIsFull[] = _("’s {POKEBLOCK} CASE is full.\p"); +const u8 sText_ApostropheSPokeblockCaseIsFull[] = _("’s {POKEBLOCK} CASE is full.\p"); const u8 sText_BlendingResults[] = _("RESULTS OF BLENDING"); static const u8 sText_BerryUsed[] = _("BERRY USED"); const u8 sText_SpaceBerry[] = _(" BERRY"); From 5c44c640509f9a80d62ecb9cc5bccee20ca5b2b5 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 13 Nov 2017 21:55:38 +0100 Subject: [PATCH 16/18] add hof graphics --- graphics/misc/japanese_hof.pal | 19 +++++ graphics/misc/japanese_hof.png | Bin 0 -> 425 bytes graphics_file_rules.mk | 4 +- src/hall_of_fame.c | 126 +-------------------------------- 4 files changed, 23 insertions(+), 126 deletions(-) create mode 100644 graphics/misc/japanese_hof.pal create mode 100644 graphics/misc/japanese_hof.png diff --git a/graphics/misc/japanese_hof.pal b/graphics/misc/japanese_hof.pal new file mode 100644 index 000000000..f50aa5341 --- /dev/null +++ b/graphics/misc/japanese_hof.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +0 0 0 +0 0 0 +131 238 197 +255 32 32 +115 222 180 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +65 65 65 +255 255 255 diff --git a/graphics/misc/japanese_hof.png b/graphics/misc/japanese_hof.png new file mode 100644 index 0000000000000000000000000000000000000000..6d88a48b240fe04f426e15b537ab84af6f648856 GIT binary patch literal 425 zcmeAS@N?(olHy`uVBq!ia0vp^89*$-!VDyz2rLZ-QU(D&A+A6g2%6s={jZ=E@X3INYt;W>}9j( ziS7IHZ;8Oagew+WXTw^|Z5Mptt=-BZUdX#~UXIMvE$zmfFWQ@oCBAPx`a$C1t8>Rz ztA};-ED4{ieCOSjya_@JUA^wwEoDE?Ws=bRLc>5~hsVn6pX64&e7++r;2HCx;KeJS zPh&Q*4b`~I8G3fjCihj9%}o=QH+NjxY%n9IaMN+~bRoNTH z!$+HG9Lo;tyuPOKAkFDaiPzpA(ROBBt+{aw_5DxQYe^nHFzNc`2|EQUWS=kPXjSmO z*HE-gf{C9^Vh0;zopr02Yp_ A4*&oF literal 0 HcmV?d00001 diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index def35bc4e..6a2a46890 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -288,5 +288,5 @@ graphics/title_screen/pokemon_logo.gbapal: graphics/title_screen/pokemon_logo.pa $(INTROGFXDIR)/copyright.4bpp: $(INTROGFXDIR)/copyright.png $(GFX) $< $@ -num_tiles 39 -$(interfacedir)/pkmnjump_bg.4bpp: $(interfacedir)/pkmnjump_bg.png - $(GFX) $< $@ -num_tiles 63 +graphics/misc/japanese_hof.4bpp: graphics/misc/japanese_hof.png + $(GFX) $< $@ -num_tiles 29 diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index e3ad88cfe..bc7177bd7 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -359,131 +359,9 @@ static const struct SpriteTemplate sSpriteTemplate_85E54D0 = .callback = sub_81751A4 }; -// todo: dump actual graphics -static const u32 sHallOfFame_Pal[] = -{ - 0, 0x109F63B0, 0x5B6E, 0, 0, 0, 0, 0x7FFF2108 -}; +static const u16 sHallOfFame_Pal[] = INCBIN_U16("graphics/misc/japanese_hof.gbapal"); -// todo: dump actual graphics -static const u32 sHallOfFame_Gfx[] = -{ - 0x3A010, - 0xF0000033, - 0x11019001, - 0x9001F011, - 0x22220001, - 0x44442222, - 0xF0E04444, - 0x70073007, - 0x11113329, - 0x13033331, - 0x33333311, - 0xF0030031, - 0x1108049, - 0x1111FFFF, - 0x4913EEEE, - 0xE10700F1, - 0x110B00EE, - 0x1D90EF, - 0x1EFFF11E, - 0x1EEEE11E, - 0x1500EF4A, - 0xB00EFEE, - 0xF11F90FF, - 0xFFF1FE01, - 0xEEE1EEE1, - 0xF1211200, - 0x1E0300EE, - 0x10E1EF11, - 0x3B40D029, - 0x1E7C00, - 0xF3331178, - 0x331100EF, - 0x3331FEEF, - 0x10E8F3EF, - 0x105F9003, - 0x7C003394, - 0x3AE1133E, - 0xC003EEE, - 0x1800310, - 0xEF8F10F1, - 0xFEA30081, - 0xE1FEEE1E, - 0x33A300EF, - 0x6800EEEF, - 0x1EFE0130, - 0x3009300, - 0xF11EFF0A, - 0xFFA1101E, - 0x17EF0300, - 0x80FEEEFE, - 0x11313F, - 0xD7006100, - 0xEF332F, - 0x8F00FF0A, - 0x7B209F60, - 0xEF440400, - 0x3EFE2201, - 0x33070013, - 0xC0FE50F1, - 0x110EF80, - 0xFEF1EEF1, - 0xF1EFFF00, - 0xF1FEEEFF, - 0x921EBF1, - 0x111120A0, - 0xF12601EE, - 0x1107D00, - 0x819100EB, - 0xFE2D005D, - 0x10FFB100, - 0xFE3910AB, - 0x9810B410, - 0x3108F11, - 0x89209F11, - 0xA0EFF6A0, - 0x1FE8D00, - 0xE111F153, - 0xF1AFE11E, - 0x641011B3, - 0x19110EF, - 0x406FA07C, - 0xA400CBB3, - 0xEEFF0300, - 0x611E2D01, - 0x6314612F, - 0x11470133, - 0xE3EE3387, - 0x23318810, - 0x210170F7, - 0x950087, - 0xA00FF03, - 0x1123FE0, - 0xCC00F141, - 0xFFFE1EEF, - 0x8F3402EE, - 0xF1EE1ED0, - 0x10B7201E, - 0x23CF0EE, - 0x8301EF17, - 0x1A011002, - 0x20CC0133, - 0x70A7017B, - 0xF35701, - 0x7C00EF80, - 0xF1BA22EE, - 0xDCED011D, - 0x1009621, - 0xE16000FE, - 0xF1F9001F, - 0xB42A5FE, - 0x113FF1EE, - 0xFEA702FF, - 0xE04101, - 0xD03F22BC, - 1 -}; +static const u8 sHallOfFame_Gfx[] = INCBIN_U8("graphics/misc/japanese_hof.4bpp.lz"); static const struct HallofFameMon sDummyFameMon = { From 8a56532d358b03993a8c513d643a4591ffc5f97c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 13 Nov 2017 22:08:50 +0100 Subject: [PATCH 17/18] fix graphics rules file --- graphics_file_rules.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 6a2a46890..968ef85a4 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -287,6 +287,9 @@ graphics/title_screen/pokemon_logo.gbapal: graphics/title_screen/pokemon_logo.pa $(INTROGFXDIR)/copyright.4bpp: $(INTROGFXDIR)/copyright.png $(GFX) $< $@ -num_tiles 39 + +$(interfacedir)/pkmnjump_bg.4bpp: $(interfacedir)/pkmnjump_bg.png + $(GFX) $< $@ -num_tiles 63 graphics/misc/japanese_hof.4bpp: graphics/misc/japanese_hof.png $(GFX) $< $@ -num_tiles 29 From 048dc4aa28c3e8331e03031f6a1a3c17f482c858 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 13 Nov 2017 22:10:25 +0100 Subject: [PATCH 18/18] fix graphics rules file --- graphics_file_rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 968ef85a4..92c173933 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -289,7 +289,7 @@ $(INTROGFXDIR)/copyright.4bpp: $(INTROGFXDIR)/copyright.png $(GFX) $< $@ -num_tiles 39 $(interfacedir)/pkmnjump_bg.4bpp: $(interfacedir)/pkmnjump_bg.png - $(GFX) $< $@ -num_tiles 63 + $(GFX) $< $@ -num_tiles 63 graphics/misc/japanese_hof.4bpp: graphics/misc/japanese_hof.png $(GFX) $< $@ -num_tiles 29