From dd0f19476c3a15514e3d08855cee3266fdbdf2ed Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 15 Oct 2017 23:21:59 +0200 Subject: [PATCH] battle anim file is decompiled --- asm/battle_anim.s | 1065 --------------------------------- asm/battle_anim_80A9C70.s | 4 +- asm/battle_anim_80FE840.s | 38 +- asm/battle_anim_815A0D4.s | 10 +- asm/battle_anim_8170478.s | 10 +- asm/battle_anim_sound_tasks.s | 6 +- asm/intro.s | 4 +- asm/rom_80A5C6C.s | 8 +- data/battle_anims.s | 126 ---- data/rom_8525F58.s | 57 ++ include/battle_anim.h | 20 +- ld_script.txt | 3 +- src/battle_anim.c | 1018 ++++++++++++++++++++++++------- 13 files changed, 911 insertions(+), 1458 deletions(-) delete mode 100644 asm/battle_anim.s create mode 100644 data/rom_8525F58.s diff --git a/asm/battle_anim.s b/asm/battle_anim.s deleted file mode 100644 index a25ef98c6..000000000 --- a/asm/battle_anim.s +++ /dev/null @@ -1,1065 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - thumb_func_start ma1B_8073C2C -ma1B_8073C2C: @ 80A53B8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gBattleAnimScriptPtr - mov r10, r0 - ldr r0, [r0] - adds r1, r0, 0x1 - mov r2, r10 - str r1, [r2] - ldrb r0, [r0, 0x1] - mov r9, r0 - ldrb r0, [r1, 0x1] - lsls r0, 8 - mov r2, r9 - orrs r2, r0 - mov r9, r2 - ldrb r4, [r1, 0x3] - ldrb r6, [r1, 0x4] - ldrb r7, [r1, 0x5] - movs r0, 0x2 - ldrsb r0, [r1, r0] - bl BattleAnimAdjustPanning - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r4, 24 - asrs r4, 24 - adds r0, r4, 0 - bl BattleAnimAdjustPanning - mov r8, r0 - lsls r5, 24 - asrs r5, 24 - mov r0, r8 - lsls r0, 24 - asrs r0, 24 - mov r8, r0 - lsls r6, 24 - asrs r6, 24 - adds r0, r5, 0 - mov r1, r8 - adds r2, r6, 0 - bl sub_80A5314 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =c3_08073CEC - movs r1, 0x1 - 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 r5, [r1, 0x8] - mov r2, r8 - strh r2, [r1, 0xA] - lsls r4, 24 - asrs r4, 24 - strh r4, [r1, 0xC] - strh r7, [r1, 0xE] - strh r5, [r1, 0x10] - mov r0, r9 - adds r1, r5, 0 - bl PlaySE12WithPanning - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - mov r1, r10 - ldr r0, [r1] - adds r0, 0x6 - 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 ma1B_8073C2C - - thumb_func_start c3_08073CEC -c3_08073CEC: @ 80A5478 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r7, 0 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r2, r0, r1 - ldrh r0, [r2, 0x18] - adds r1, r0, 0x1 - strh r1, [r2, 0x18] - lsls r0, 16 - asrs r0, 16 - movs r3, 0xE - ldrsh r1, [r2, r3] - cmp r0, r1 - blt _080A54FC - strh r7, [r2, 0x18] - ldrh r6, [r2, 0x8] - ldrh r3, [r2, 0xA] - movs r4, 0x10 - ldrsh r0, [r2, r4] - movs r4, 0xC - ldrsh r1, [r2, r4] - adds r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - strh r4, [r2, 0x10] - cmp r1, 0 - bne _080A54C0 - lsls r2, r3, 16 - b _080A54E4 - .pool -_080A54C0: - lsls r1, r6, 16 - lsls r0, r3, 16 - asrs r3, r0, 16 - adds r2, r0, 0 - cmp r1, r2 - bge _080A54D6 - lsls r0, r4, 16 - asrs r0, 16 - cmp r0, r3 - blt _080A54E0 - b _080A54E4 -_080A54D6: - lsls r0, r4, 16 - asrs r0, 16 - cmp r0, r3 - bgt _080A54E0 - movs r7, 0x1 -_080A54E0: - cmp r7, 0 - beq _080A54F4 -_080A54E4: - lsrs r4, r2, 16 - adds r0, r5, 0 - bl DestroyTask - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] -_080A54F4: - lsls r0, r4, 24 - asrs r0, 24 - bl SE12PanpotControl -_080A54FC: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end c3_08073CEC - - thumb_func_start sub_80A5508 -sub_80A5508: @ 80A5508 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - ldr r0, =gBattleAnimScriptPtr - mov r9, r0 - ldr r0, [r0] - adds r1, r0, 0x1 - mov r2, r9 - str r1, [r2] - ldrb r0, [r0, 0x1] - mov r8, r0 - ldrb r0, [r1, 0x1] - lsls r0, 8 - mov r2, r8 - orrs r2, r0 - mov r8, r2 - ldrb r4, [r1, 0x2] - ldrb r5, [r1, 0x3] - ldrb r6, [r1, 0x4] - ldrb r1, [r1, 0x5] - mov r10, r1 - ldr r0, =c3_08073CEC - movs r1, 0x1 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - lsls r4, 24 - asrs r4, 24 - strh r4, [r1, 0x8] - lsls r5, 24 - asrs r5, 24 - strh r5, [r1, 0xA] - lsls r6, 24 - asrs r6, 24 - strh r6, [r1, 0xC] - mov r0, r10 - strh r0, [r1, 0xE] - strh r4, [r1, 0x10] - mov r0, r8 - adds r1, r4, 0 - bl PlaySE12WithPanning - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - mov r1, r9 - ldr r0, [r1] - adds r0, 0x6 - str r0, [r1] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A5508 - - thumb_func_start sub_80A559C -sub_80A559C: @ 80A559C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gBattleAnimScriptPtr - mov r10, r0 - ldr r0, [r0] - adds r1, r0, 0x1 - mov r2, r10 - str r1, [r2] - ldrb r0, [r0, 0x1] - mov r9, r0 - ldrb r0, [r1, 0x1] - lsls r0, 8 - mov r2, r9 - orrs r2, r0 - mov r9, r2 - ldrb r4, [r1, 0x3] - ldrb r0, [r1, 0x4] - mov r8, r0 - ldrb r7, [r1, 0x5] - movs r0, 0x2 - ldrsb r0, [r1, r0] - bl BattleAnimAdjustPanning2 - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r4, 24 - asrs r4, 24 - adds r0, r4, 0 - bl BattleAnimAdjustPanning2 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - mov r1, r8 - lsls r1, 24 - asrs r1, 24 - mov r8, r1 - mov r0, r8 - bl BattleAnimAdjustPanning2 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =c3_08073CEC - movs r1, 0x1 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - lsls r6, 24 - asrs r6, 24 - strh r6, [r1, 0x8] - lsls r5, 24 - asrs r5, 24 - strh r5, [r1, 0xA] - lsls r4, 24 - asrs r4, 24 - strh r4, [r1, 0xC] - strh r7, [r1, 0xE] - strh r6, [r1, 0x10] - mov r0, r9 - adds r1, r6, 0 - bl PlaySE12WithPanning - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - mov r2, r10 - ldr r0, [r2] - adds r0, 0x6 - str r0, [r2] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A559C - - thumb_func_start ma1C_8073ED0 -ma1C_8073ED0: @ 80A565C - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - ldr r6, =gBattleAnimScriptPtr - ldr r0, [r6] - adds r1, r0, 0x1 - str r1, [r6] - ldrb r5, [r0, 0x1] - ldrb r0, [r1, 0x1] - lsls r0, 8 - orrs r5, r0 - ldrb r0, [r1, 0x3] - mov r8, r0 - ldrb r2, [r1, 0x4] - mov r9, r2 - movs r0, 0x2 - ldrsb r0, [r1, r0] - bl BattleAnimAdjustPanning - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =sub_80A56E4 - movs r1, 0x1 - 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 r5, [r1, 0x8] - lsls r4, 24 - asrs r4, 24 - strh r4, [r1, 0xA] - mov r2, r8 - strh r2, [r1, 0xC] - mov r2, r9 - strh r2, [r1, 0xE] - mov r2, r8 - strh r2, [r1, 0x18] - ldr r1, [r1] - bl _call_via_r1 - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r0, [r6] - adds r0, 0x5 - str r0, [r6] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end ma1C_8073ED0 - - thumb_func_start sub_80A56E4 -sub_80A56E4: @ 80A56E4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r2, r0, r1 - ldrh r0, [r2, 0x18] - adds r1, r0, 0x1 - strh r1, [r2, 0x18] - lsls r0, 16 - asrs r0, 16 - movs r3, 0xC - ldrsh r1, [r2, r3] - cmp r0, r1 - blt _080A5732 - movs r0, 0 - strh r0, [r2, 0x18] - ldrh r0, [r2, 0x8] - ldrb r1, [r2, 0xA] - ldrh r4, [r2, 0xE] - subs r4, 0x1 - strh r4, [r2, 0xE] - lsls r4, 24 - lsrs r4, 24 - lsls r1, 24 - asrs r1, 24 - bl PlaySE12WithPanning - cmp r4, 0 - bne _080A5732 - adds r0, r5, 0 - bl DestroyTask - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] -_080A5732: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A56E4 - - thumb_func_start ma1D_08073FB4 -ma1D_08073FB4: @ 80A5740 - push {r4-r6,lr} - mov r6, r8 - push {r6} - ldr r6, =gBattleAnimScriptPtr - ldr r0, [r6] - adds r1, r0, 0x1 - str r1, [r6] - ldrb r5, [r0, 0x1] - ldrb r0, [r1, 0x1] - lsls r0, 8 - orrs r5, r0 - ldrb r0, [r1, 0x3] - mov r8, r0 - movs r0, 0x2 - ldrsb r0, [r1, r0] - bl BattleAnimAdjustPanning - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =sub_80A57B4 - movs r1, 0x1 - 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 r5, [r1, 0x8] - lsls r4, 24 - asrs r4, 24 - strh r4, [r1, 0xA] - mov r0, r8 - strh r0, [r1, 0xC] - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r0, [r6] - adds r0, 0x4 - str r0, [r6] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end ma1D_08073FB4 - - thumb_func_start sub_80A57B4 -sub_80A57B4: @ 80A57B4 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r2, r0, r1 - ldrh r0, [r2, 0xC] - subs r1, r0, 0x1 - strh r1, [r2, 0xC] - lsls r0, 16 - cmp r0, 0 - bgt _080A57E8 - ldrh r0, [r2, 0x8] - movs r1, 0xA - ldrsb r1, [r2, r1] - bl PlaySE12WithPanning - adds r0, r4, 0 - bl DestroyTask - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] -_080A57E8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A57B4 - - thumb_func_start sub_80A57F8 -sub_80A57F8: @ 80A57F8 - push {r4-r6,lr} - ldr r4, =gBattleAnimScriptPtr - ldr r1, [r4] - adds r3, r1, 0x1 - str r3, [r4] - ldrb r2, [r1, 0x1] - ldrb r0, [r3, 0x1] - lsls r0, 8 - adds r2, r0 - ldrb r0, [r3, 0x2] - lsls r0, 16 - adds r2, r0 - ldrb r0, [r3, 0x3] - lsls r0, 24 - adds r6, r2, r0 - adds r0, r1, 0x5 - str r0, [r4] - ldrb r0, [r1, 0x5] - adds r1, 0x6 - str r1, [r4] - cmp r0, 0 - beq _080A5842 - adds r5, r4, 0 - ldr r4, =gBattleAnimArgs - adds r3, r0, 0 -_080A582A: - ldr r2, [r5] - ldrb r1, [r2] - ldrb r0, [r2, 0x1] - lsls r0, 8 - orrs r1, r0 - strh r1, [r4] - adds r2, 0x2 - str r2, [r5] - adds r4, 0x2 - subs r3, 0x1 - cmp r3, 0 - bne _080A582A -_080A5842: - adds r0, r6, 0 - movs r1, 0x1 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - bl _call_via_r6 - ldr r1, =gAnimSoundTaskCount - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A57F8 - - thumb_func_start ma20_wait_for_something -ma20_wait_for_something: @ 80A586C - push {r4,r5,lr} - ldr r0, =gAnimSoundTaskCount - ldrb r5, [r0] - cmp r5, 0 - bne _080A58B4 - bl IsSEPlaying - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - beq _080A58CC - ldr r4, =gSoundAnimFramesToWait - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x5A - bls _080A58BA - ldr r0, =gMPlay_SE1 - bl m4aMPlayStop - ldr r0, =gMPlay_SE2 - bl m4aMPlayStop - strh r5, [r4] - b _080A58DE - .pool -_080A58B4: - ldr r1, =gSoundAnimFramesToWait - movs r0, 0 - strh r0, [r1] -_080A58BA: - ldr r1, =gAnimFramesToWait - movs r0, 0x1 - strb r0, [r1] - b _080A58DE - .pool -_080A58CC: - ldr r0, =gSoundAnimFramesToWait - movs r2, 0 - strh r1, [r0] - ldr r1, =gBattleAnimScriptPtr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - ldr r0, =gAnimFramesToWait - strb r2, [r0] -_080A58DE: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end ma20_wait_for_something - - thumb_func_start ma21_08074164 -ma21_08074164: @ 80A58F0 - push {r4-r6,lr} - ldr r5, =gBattleAnimScriptPtr - ldr r4, [r5] - adds r3, r4, 0x1 - str r3, [r5] - ldrb r2, [r4, 0x1] - ldrb r1, [r3, 0x1] - ldrb r0, [r3, 0x2] - lsls r0, 8 - orrs r1, r0 - ldr r0, =gBattleAnimArgs - lsls r2, 1 - adds r2, r0 - lsls r1, 16 - asrs r1, 16 - movs r6, 0 - ldrsh r0, [r2, r6] - cmp r1, r0 - bne _080A5938 - ldrb r1, [r3, 0x3] - ldrb r0, [r3, 0x4] - lsls r0, 8 - adds r1, r0 - ldrb r0, [r3, 0x5] - lsls r0, 16 - adds r1, r0 - ldrb r0, [r3, 0x6] - lsls r0, 24 - adds r1, r0 - str r1, [r5] - b _080A593E - .pool -_080A5938: - adds r0, r4, 0 - adds r0, 0x8 - str r0, [r5] -_080A593E: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end ma21_08074164 - - thumb_func_start sub_80A5944 -sub_80A5944: @ 80A5944 - push {r4,lr} - ldr r4, =gBattleAnimScriptPtr - ldr r0, [r4] - adds r0, 0x1 - str r0, [r4] - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _080A5978 - ldr r2, [r4] - ldrb r1, [r2] - ldrb r0, [r2, 0x1] - lsls r0, 8 - adds r1, r0 - ldrb r0, [r2, 0x2] - lsls r0, 16 - adds r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 24 - adds r1, r0 - str r1, [r4] - b _080A597E - .pool -_080A5978: - ldr r0, [r4] - adds r0, 0x4 - str r0, [r4] -_080A597E: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80A5944 - - thumb_func_start sub_80A5984 -sub_80A5984: @ 80A5984 - push {r4,lr} - ldr r0, =gBattleAnimScriptPtr - ldr r1, [r0] - ldrb r2, [r1, 0x1] - adds r1, 0x2 - str r1, [r0] - cmp r2, 0 - beq _080A59A0 - ldr r0, =gAnimBankTarget - b _080A59A2 - .pool -_080A59A0: - ldr r0, =gAnimBankAttacker -_080A59A2: - ldrb r0, [r0] - bl GetBankIdentity - lsls r0, 24 - lsrs r4, r0, 24 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _080A59D2 - cmp r4, 0 - beq _080A59BE - cmp r4, 0x3 - bne _080A59D2 -_080A59BE: - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0x1 - bl SetAnimBgAttribute - movs r0, 0x2 - movs r1, 0x4 - movs r2, 0x2 - bl SetAnimBgAttribute -_080A59D2: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A5984 - - thumb_func_start sub_80A59DC -sub_80A59DC: @ 80A59DC - push {lr} - ldr r0, =gBattleAnimScriptPtr - ldr r1, [r0] - adds r1, 0x1 - str r1, [r0] - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _080A5A04 - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0x1 - bl SetAnimBgAttribute - movs r0, 0x2 - movs r1, 0x4 - movs r2, 0x2 - bl SetAnimBgAttribute -_080A5A04: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A59DC - - thumb_func_start sub_80A5A0C -sub_80A5A0C: @ 80A5A0C - push {r4-r7,lr} - ldr r1, =gBattleAnimScriptPtr - ldr r0, [r1] - ldrb r6, [r0, 0x1] - adds r0, 0x2 - str r0, [r1] - ldr r7, =gAnimBankAttacker - ldrb r0, [r7] - bl GetBankSide - adds r4, r0, 0 - ldr r5, =gAnimBankTarget - ldrb r0, [r5] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _080A5A78 - cmp r6, 0 - beq _080A5A48 - ldrb r0, [r5] - b _080A5A4A - .pool -_080A5A48: - ldrb r0, [r7] -_080A5A4A: - bl GetBankIdentity - lsls r0, 24 - lsrs r4, r0, 24 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _080A5A78 - cmp r4, 0 - beq _080A5A64 - cmp r4, 0x3 - bne _080A5A78 -_080A5A64: - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0x1 - bl SetAnimBgAttribute - movs r0, 0x2 - movs r1, 0x4 - movs r2, 0x2 - bl SetAnimBgAttribute -_080A5A78: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80A5A0C - - thumb_func_start ma2B_make_side_invisible -ma2B_make_side_invisible: @ 80A5A80 - push {r4,lr} - ldr r4, =gBattleAnimScriptPtr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetAnimBankSpriteId - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _080A5AA8 - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_080A5AA8: - ldr r0, [r4] - adds r0, 0x2 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ma2B_make_side_invisible - - thumb_func_start ma2C_make_side_visible -ma2C_make_side_visible: @ 80A5ABC - push {r4,lr} - ldr r4, =gBattleAnimScriptPtr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetAnimBankSpriteId - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _080A5AE6 - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - adds r0, 0x3E - ldrb r2, [r0] - movs r1, 0x5 - negs r1, r1 - ands r1, r2 - strb r1, [r0] -_080A5AE6: - ldr r0, [r4] - adds r0, 0x2 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ma2C_make_side_visible - - thumb_func_start sub_80A5AFC -sub_80A5AFC: @ 80A5AFC - push {r4-r7,lr} - ldr r1, =gBattleAnimScriptPtr - ldr r0, [r1] - ldrb r7, [r0, 0x1] - adds r0, 0x2 - str r0, [r1] - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _080A5BA6 - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _080A5BA6 - ldr r6, =gAnimBankAttacker - ldrb r0, [r6] - bl GetBankSide - adds r4, r0, 0 - ldr r5, =gAnimBankTarget - ldrb r0, [r5] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _080A5BA6 - cmp r7, 0 - bne _080A5B54 - ldrb r0, [r6] - bl GetBankIdentity_permutated - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0 - b _080A5B60 - .pool -_080A5B54: - ldrb r0, [r5] - bl GetBankIdentity_permutated - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x1 -_080A5B60: - bl GetAnimBankSpriteId - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _080A5BA6 - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r2, r0, r1 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r3] - cmp r4, 0x2 - bne _080A5B90 - ldrb r0, [r2, 0x5] - movs r1, 0xC - orrs r0, r1 - strb r0, [r2, 0x5] -_080A5B90: - cmp r4, 0x1 - bne _080A5BA0 - movs r0, 0 - bl sub_80A477C - b _080A5BA6 - .pool -_080A5BA0: - movs r0, 0x1 - bl sub_80A477C -_080A5BA6: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80A5AFC - - thumb_func_start sub_80A5BAC -sub_80A5BAC: @ 80A5BAC - push {r4-r7,lr} - ldr r1, =gBattleAnimScriptPtr - ldr r0, [r1] - ldrb r7, [r0, 0x1] - adds r0, 0x2 - str r0, [r1] - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _080A5C38 - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _080A5C38 - ldr r6, =gAnimBankAttacker - ldrb r0, [r6] - bl GetBankSide - adds r4, r0, 0 - ldr r5, =gAnimBankTarget - ldrb r0, [r5] - bl GetBankSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _080A5C38 - cmp r7, 0 - bne _080A5C04 - ldrb r0, [r6] - bl GetBankIdentity_permutated - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0 - b _080A5C10 - .pool -_080A5C04: - ldrb r0, [r5] - bl GetBankIdentity_permutated - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x1 -_080A5C10: - bl GetAnimBankSpriteId - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _080A5C38 - cmp r4, 0x2 - bne _080A5C38 - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r2, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - movs r2, 0x8 - orrs r1, r2 - strb r1, [r0, 0x5] -_080A5C38: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80A5BAC - - thumb_func_start ma2F_stop_music -ma2F_stop_music: @ 80A5C44 - push {lr} - ldr r0, =gMPlay_SE1 - bl m4aMPlayStop - ldr r0, =gMPlay_SE2 - bl m4aMPlayStop - ldr r1, =gBattleAnimScriptPtr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end ma2F_stop_music - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/battle_anim_80A9C70.s b/asm/battle_anim_80A9C70.s index 0559ceab2..9b2939673 100644 --- a/asm/battle_anim_80A9C70.s +++ b/asm/battle_anim_80A9C70.s @@ -26,9 +26,9 @@ sub_80A9C70: @ 80A9C70 lsls r0, 24 lsrs r0, 24 mov r8, r0 - ldr r0, =gUnknown_08524F84 + ldr r0, =gBattleAnimPicTable + 0x440 bl LoadCompressedObjectPicUsingHeap - ldr r0, =gUnknown_0852588C + ldr r0, =gBattleAnimPaletteTable + 0x440 bl LoadCompressedObjectPaletteUsingHeap ldr r1, =gTasks mov r2, r8 diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index 1556523e2..9e6aae62f 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -732,7 +732,7 @@ _080FEE36: _080FEE3E: ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -8335,7 +8335,7 @@ _08102A9A: str r0, [r6] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -8376,7 +8376,7 @@ sub_8102AE0: @ 8102AE0 bne _08102B32 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -12777,7 +12777,7 @@ sub_8104E74: @ 8104E74 bl sub_80A861C strh r0, [r5, 0x26] ldrb r0, [r4] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -33069,7 +33069,7 @@ _0810F22E: lsrs r4, r0, 24 adds r7, r4, 0 adds r0, r4, 0 - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 @@ -33445,7 +33445,7 @@ sub_810F524: @ 810F524 lsls r0, 24 lsrs r0, 24 adds r4, r0, 0 - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 @@ -34592,7 +34592,7 @@ _0810FE86: _0810FE92: ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -38512,7 +38512,7 @@ sub_8111E78: @ 8111E78 adds r5, r0, r1 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r6, r0, 24 movs r1, 0x26 @@ -38866,7 +38866,7 @@ sub_8112170: @ 8112170 adds r4, r0, r1 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r6, r0, 24 movs r1, 0x26 @@ -41108,7 +41108,7 @@ sub_81133E8: @ 81133E8 adds r4, r1, r0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -41480,7 +41480,7 @@ sub_81136E8: @ 81136E8 movs r0, 0x52 bl SetGpuReg adds r0, r4, 0 - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -41663,7 +41663,7 @@ sub_8113888: @ 8113888 bl SetGpuReg ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -42098,7 +42098,7 @@ _08113C1E: strh r0, [r5, 0x18] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 strh r0, [r5, 0xE] @@ -42417,7 +42417,7 @@ _08113EBC: _08113EF8: ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 strh r0, [r5, 0xE] @@ -43016,7 +43016,7 @@ sub_81143C0: @ 81143C0 mov r10, r0 ldr r6, =gAnimBankAttacker ldrb r0, [r6] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 @@ -43093,7 +43093,7 @@ sub_8114470: @ 8114470 lsrs r6, r0, 24 ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 movs r1, 0x1 @@ -44098,7 +44098,7 @@ _08114D3C: strh r0, [r4, 0x1C] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 strh r0, [r4, 0x1E] @@ -44291,7 +44291,7 @@ sub_8114EB4: @ 8114EB4 strh r4, [r1, 0x26] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -44444,7 +44444,7 @@ _08115018: strh r0, [r4, 0x1C] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 strh r0, [r4, 0x1E] diff --git a/asm/battle_anim_815A0D4.s b/asm/battle_anim_815A0D4.s index 45f207eb9..69835bf4e 100755 --- a/asm/battle_anim_815A0D4.s +++ b/asm/battle_anim_815A0D4.s @@ -1629,7 +1629,7 @@ _0815ADDE: lsls r0, 24 lsrs r6, r0, 24 ldrb r0, [r4] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r7, r0, 24 adds r0, r6, 0 @@ -2935,7 +2935,7 @@ _0815B81C: bl SetGpuReg ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -3211,7 +3211,7 @@ _0815BA82: bl SetGpuReg ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -6123,7 +6123,7 @@ _0815D2B4: lsrs r0, 24 strh r0, [r4, 0x26] adds r0, r5, 0 - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -6218,7 +6218,7 @@ sub_815D398: @ 815D398 ldr r1, =gTasks adds r6, r0, r1 ldrb r0, [r6, 0x12] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 diff --git a/asm/battle_anim_8170478.s b/asm/battle_anim_8170478.s index 1e90e60c7..d2a7cbd63 100644 --- a/asm/battle_anim_8170478.s +++ b/asm/battle_anim_8170478.s @@ -4951,7 +4951,7 @@ _08172DC0: _08172DC6: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -5134,9 +5134,9 @@ _08172F4E: lsrs r0, 16 cmp r0, r7 bne _08172F6E - ldr r0, =gUnknown_0852528C + ldr r0, =gBattleAnimPicTable + 0x748 bl LoadCompressedObjectPicUsingHeap - ldr r0, =gUnknown_08525B94 + ldr r0, =gBattleAnimPaletteTable + 0x748 bl LoadCompressedObjectPaletteUsingHeap _08172F6E: ldr r5, =sub_8172FEC @@ -5533,9 +5533,9 @@ sub_81732B0: @ 81732B0 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - ldr r0, =gUnknown_085253AC + ldr r0, =gBattleAnimPicTable + 0x868 bl LoadCompressedObjectPicUsingHeap - ldr r0, =gUnknown_08525CB4 + ldr r0, =gBattleAnimPaletteTable + 0x868 bl LoadCompressedObjectPaletteUsingHeap ldr r0, =0x0000281d bl IndexOfSpritePaletteTag diff --git a/asm/battle_anim_sound_tasks.s b/asm/battle_anim_sound_tasks.s index 817e64b07..4bfd7ae68 100644 --- a/asm/battle_anim_sound_tasks.s +++ b/asm/battle_anim_sound_tasks.s @@ -36,7 +36,7 @@ sub_8158B30: @ 8158B30 adds r0, r4, 0 adds r1, r5, 0 movs r2, 0x2 - bl sub_80A5314 + bl CalculatePanIncrement strh r4, [r6, 0xC] strh r5, [r6, 0xE] lsls r0, 24 @@ -193,7 +193,7 @@ mas_80DCF38: @ 8158C58 adds r0, r4, 0 adds r1, r5, 0 adds r2, r6, 0 - bl sub_80A5314 + bl CalculatePanIncrement ldr r2, =gTasks mov r3, r8 lsls r1, r3, 2 @@ -924,7 +924,7 @@ sub_8159278: @ 8159278 adds r0, r4, 0 adds r1, r5, 0 adds r2, r6, 0 - bl sub_80A5314 + bl CalculatePanIncrement ldr r2, =gTasks mov r3, r8 lsls r1, r3, 2 diff --git a/asm/intro.s b/asm/intro.s index cd8f7c2d8..32b52ed06 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -1958,9 +1958,9 @@ task_intro_13: @ 816DD28 ldr r0, =gUnknown_08D8A818 ldr r1, =0x0600e000 bl LZDecompressVram - ldr r0, =gUnknown_08524D14 + ldr r0, =gBattleAnimPicTable + 0x1D0 bl LoadCompressedObjectPicUsingHeap - ldr r0, =gUnknown_0852561C + ldr r0, =gBattleAnimPaletteTable + 0x1D0 bl LoadCompressedObjectPaletteUsingHeap ldr r0, =gUnknown_08D85CD0 ldr r1, =gPlttBufferUnfaded diff --git a/asm/rom_80A5C6C.s b/asm/rom_80A5C6C.s index a4d786159..325c4a459 100644 --- a/asm/rom_80A5C6C.s +++ b/asm/rom_80A5C6C.s @@ -2063,7 +2063,7 @@ sub_80A6BFC: @ 80A6BFC _080A6C30: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankIdentity_permutated + bl sub_80A8364 lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0x1 @@ -5083,8 +5083,8 @@ _080A835C: bx r1 thumb_func_end sub_80A8328 - thumb_func_start GetBankIdentity_permutated -GetBankIdentity_permutated: @ 80A8364 + thumb_func_start sub_80A8364 +sub_80A8364: @ 80A8364 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 @@ -5109,7 +5109,7 @@ _080A838C: pop {r4} pop {r1} bx r1 - thumb_func_end GetBankIdentity_permutated + thumb_func_end sub_80A8364 thumb_func_start sub_80A8394 sub_80A8394: @ 80A8394 diff --git a/data/battle_anims.s b/data/battle_anims.s index 39d5df006..082a86fa1 100644 --- a/data/battle_anims.s +++ b/data/battle_anims.s @@ -353,9 +353,6 @@ gBattleAnimPicTable:: @ 8524B44 obj_tiles 0x08c0a8bc, 0x0200, 0x2747 obj_tiles 0x08c0a3ec, 0x1000, 0x2748 obj_tiles 0x08c0a980, 0x0180, 0x2749 - - .align 2 -gUnknown_08524D14:: @ 8524D14 obj_tiles 0x08c0aa2c, 0x0c00, 0x274a obj_tiles 0x08c0aebc, 0x0100, 0x274b obj_tiles 0x08c0af38, 0x0040, 0x274c @@ -434,9 +431,6 @@ gUnknown_08524D14:: @ 8524D14 obj_tiles 0x08c14b78, 0x0100, 0x2795 obj_tiles 0x08c14c1c, 0x0200, 0x2796 obj_tiles 0x08c1a3a0, 0x0200, 0x2797 - - .align 2 -gUnknown_08524F84:: @ 8524F84 obj_tiles 0x08c1a540, 0x0020, 0x2798 obj_tiles 0x08c1a58c, 0x0a00, 0x2799 obj_tiles 0x08c1ab40, 0x0800, 0x279a @@ -534,9 +528,6 @@ gUnknown_08524F84:: @ 8524F84 obj_tiles 0x08c258b8, 0x0800, 0x27f6 obj_tiles 0x08c28394, 0x0380, 0x27f7 obj_tiles 0x08c27e34, 0x0800, 0x27f8 - - .align 2 -gUnknown_0852528C:: @ 852528C obj_tiles 0x08c28564, 0x00c0, 0x27f9 obj_tiles 0x08c28610, 0x0800, 0x27fa obj_tiles 0x08c28880, 0x0060, 0x27fb @@ -573,9 +564,6 @@ gUnknown_0852528C:: @ 852528C obj_tiles 0x08d93b9c, 0x0080, 0x281a obj_tiles 0x08c2407c, 0x0800, 0x281b obj_tiles 0x08d8ea54, 0x0020, 0x281c - - .align 2 -gUnknown_085253AC:: @ 85253AC obj_tiles 0x08d8ef2c, 0x0080, 0x281d obj_tiles 0x08dba378, 0x0400, 0x281e obj_tiles 0x08dba4b8, 0x0080, 0x281f @@ -657,9 +645,6 @@ gBattleAnimPaletteTable:: @ 852544C obj_pal 0x08c09fd8, 0x2747 obj_pal 0x08c0a894, 0x2748 obj_pal 0x08c0aa08, 0x2749 - - .align 2 -gUnknown_0852561C:: @ 852561C obj_pal 0x08c0ae94, 0x274a obj_pal 0x08c0af1c, 0x274b obj_pal 0x08c0af60, 0x274c @@ -738,9 +723,6 @@ gUnknown_0852561C:: @ 852561C obj_pal 0x08c14bf4, 0x2795 obj_pal 0x08c14bf4, 0x2796 obj_pal 0x08c1a478, 0x2797 - - .align 2 -gUnknown_0852588C:: @ 852588C obj_pal 0x08c1a564, 0x2798 obj_pal 0x08c1a478, 0x2799 obj_pal 0x08c1a478, 0x279a @@ -838,9 +820,6 @@ gUnknown_0852588C:: @ 852588C obj_pal 0x08c25890, 0x27f6 obj_pal 0x08c2836c, 0x27f7 obj_pal 0x08c2836c, 0x27f8 - - .align 2 -gUnknown_08525B94:: @ 8525B94 obj_pal 0x08c285e8, 0x27f9 obj_pal 0x08c287d0, 0x27fa obj_pal 0x08c288d0, 0x27fb @@ -877,9 +856,6 @@ gUnknown_08525B94:: @ 8525B94 obj_pal 0x08d93bdc, 0x281a obj_pal 0x08d93bf4, 0x281b obj_pal 0x08d93c0c, 0x281c - - .align 2 -gUnknown_08525CB4:: @ 8525CB4 obj_pal 0x08d8ef80, 0x281d obj_pal 0x08dba35c, 0x281e obj_pal 0x08dba4a0, 0x281f @@ -930,105 +906,3 @@ gBattleAnimBackgroundTable:: @ 8525D54 .4byte 0x08c25bec, 0x08d91074, 0x08c26958 .4byte 0x08c25bec, 0x08d91074, 0x08c26e54 .4byte 0x08c25bec, 0x08d91074, 0x08c27324 - - .align 2 -sScriptCmdTable:: @ 8525E98 - .4byte ScriptCmd_loadspritegfx - .4byte ScriptCmd_unloadspritegfx - .4byte ScriptCmd_createsprite - .4byte ScriptCmd_createvisualtask - .4byte ScriptCmd_delay - .4byte ScriptCmd_waitforvisualfinish - .4byte ScriptCmd_hang1 - .4byte ScriptCmd_hang2 - .4byte ScriptCmd_end - .4byte ScriptCmd_playse - .4byte ScriptCmd_monbg - .4byte ScriptCmd_clearmonbg - .4byte ScriptCmd_setalpha - .4byte ScriptCmd_blendoff - .4byte ScriptCmd_call - .4byte ScriptCmd_return - .4byte ScriptCmd_setarg - .4byte ScriptCmd_choosetwoturnanim - .4byte ScriptCmd_jumpifmoveturn - .4byte ScriptCmd_jump - .4byte ScriptCmd_fadetobg - .4byte ScriptCmd_restorebg - .4byte ScriptCmd_waitbgfadeout - .4byte ScriptCmd_waitbgfadein - .4byte ScriptCmd_changebg - .4byte ScriptCmd_playsewithpan - .4byte ScriptCmd_setpan - .4byte ma1B_8073C2C - .4byte ma1C_8073ED0 - .4byte ma1D_08073FB4 - .4byte ScriptCmd_setbldcnt - .4byte sub_80A57F8 - .4byte ma20_wait_for_something - .4byte ma21_08074164 - .4byte ScriptCmd_monbg_22 - .4byte ScriptCmd_clearmonbg_23 - .4byte sub_80A5944 - .4byte ScriptCmd_fadetobgfromset - .4byte sub_80A5508 - .4byte sub_80A559C - .4byte sub_80A5984 - .4byte sub_80A59DC - .4byte sub_80A5A0C - .4byte ma2B_make_side_invisible - .4byte ma2C_make_side_visible - .4byte sub_80A5AFC - .4byte sub_80A5BAC - .4byte ma2F_stop_music - - .align 2 -gUnknown_08525F58:: @ 8525F58 - .byte 0x48, 0x50, 0x00, 0x00, 0xb0, 0x28, 0x00, 0x00 - .byte 0x30, 0x28, 0x00, 0x00, 0x70, 0x50, 0x00, 0x00 - .byte 0x20, 0x50, 0x00, 0x00, 0xc8, 0x28, 0x00, 0x00 - .byte 0x5a, 0x58, 0x00, 0x00, 0x98, 0x20, 0x00, 0x00 - - .align 2 -gCastformFrontSpriteCoords:: @ 8525F78 - .byte 0x44, 0x11, 0x00, 0x00, 0x66, 0x09, 0x00, 0x00 - .byte 0x46, 0x09, 0x00, 0x00, 0x86, 0x08, 0x00, 0x00 - - .align 2 -gUnknown_08525F88:: @ 8525F88 - .byte 0x0d, 0x0e, 0x0d, 0x0d - - .align 2 -gUnknown_08525F8C:: @ 8525F8C - .byte 0x00, 0x00, 0x00, 0x00 - - .align 2 -gUnknown_08525F90:: @ 8525F90 - spr_template 0xd755, 0xd755, gUnknown_0852497C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - spr_template 0xd756, 0xd756, gUnknown_0852497C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_08525FC0:: @ 8525FC0 - obj_tiles gMiscBlank_Gfx, 0x0800, 0xd755 - obj_tiles gMiscBlank_Gfx, 0x0800, 0xd756 - - .align 2 -@ the mother of all baserom includes - .incbin "baserom.gba", 0x525fd0, 0x18f60 - - .align 2 -gUnknown_0853EF30:: @ 853EF30 - .byte 0xf0, 0xf0, 0x0c, 0x80, 0xf0, 0x30, 0x0d, 0x84, 0x30, 0xf0, 0x0e, 0x86, 0x30, 0x30, 0x08, 0x88 - - .align 2 -gUnknown_0853EF40:: @ 853EF40 - .4byte 0x00000004, gUnknown_0853EF30 - - .align 2 -gUnknown_0853EF48:: @ 853EF48 - spr_template 0x271a, 0x271a, gUnknown_08524A3C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gUnknown_0853EF60:: @ 853EF60 - spr_template 0x2798, 0x2798, gUnknown_08524904, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80A9E44 - diff --git a/data/rom_8525F58.s b/data/rom_8525F58.s new file mode 100644 index 000000000..1cee7112a --- /dev/null +++ b/data/rom_8525F58.s @@ -0,0 +1,57 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + + .align 2 + + +gUnknown_08525F58:: @ 8525F58 + .byte 0x48, 0x50, 0x00, 0x00, 0xb0, 0x28, 0x00, 0x00 + .byte 0x30, 0x28, 0x00, 0x00, 0x70, 0x50, 0x00, 0x00 + .byte 0x20, 0x50, 0x00, 0x00, 0xc8, 0x28, 0x00, 0x00 + .byte 0x5a, 0x58, 0x00, 0x00, 0x98, 0x20, 0x00, 0x00 + + .align 2 +gCastformFrontSpriteCoords:: @ 8525F78 + .byte 0x44, 0x11, 0x00, 0x00, 0x66, 0x09, 0x00, 0x00 + .byte 0x46, 0x09, 0x00, 0x00, 0x86, 0x08, 0x00, 0x00 + + .align 2 +gUnknown_08525F88:: @ 8525F88 + .byte 0x0d, 0x0e, 0x0d, 0x0d + + .align 2 +gUnknown_08525F8C:: @ 8525F8C + .byte 0x00, 0x00, 0x00, 0x00 + + .align 2 +gUnknown_08525F90:: @ 8525F90 + spr_template 0xd755, 0xd755, gUnknown_0852497C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy + spr_template 0xd756, 0xd756, gUnknown_0852497C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy + + .align 2 +gUnknown_08525FC0:: @ 8525FC0 + obj_tiles gMiscBlank_Gfx, 0x0800, 0xd755 + obj_tiles gMiscBlank_Gfx, 0x0800, 0xd756 + + .align 2 +@ the mother of all baserom includes + .incbin "baserom.gba", 0x525fd0, 0x18f60 + + .align 2 +gUnknown_0853EF30:: @ 853EF30 + .byte 0xf0, 0xf0, 0x0c, 0x80, 0xf0, 0x30, 0x0d, 0x84, 0x30, 0xf0, 0x0e, 0x86, 0x30, 0x30, 0x08, 0x88 + + .align 2 +gUnknown_0853EF40:: @ 853EF40 + .4byte 0x00000004, gUnknown_0853EF30 + + .align 2 +gUnknown_0853EF48:: @ 853EF48 + spr_template 0x271a, 0x271a, gUnknown_08524A3C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy + + .align 2 +gUnknown_0853EF60:: @ 853EF60 + spr_template 0x2798, 0x2798, gUnknown_08524904, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80A9E44 + diff --git a/include/battle_anim.h b/include/battle_anim.h index 86eb20aec..3345d7de3 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -37,6 +37,24 @@ struct BattleAnimBackground void *tilemap; }; +#define ANIM_ARGS_COUNT 8 + +extern void (*gAnimScriptCallback)(void); +extern bool8 gAnimScriptActive; +extern u8 gAnimVisualTaskCount; +extern u8 gAnimSoundTaskCount; +extern struct DisableStruct *gAnimDisableStructPtr; +extern u32 gAnimMoveDmg; +extern u16 gAnimMovePower; +extern u8 gAnimFriendship; +extern u16 gWeatherMoveAnim; +extern s16 gBattleAnimArgs[ANIM_ARGS_COUNT]; +extern u8 gAnimMoveTurn; +extern u8 gAnimBankAttacker; +extern u8 gAnimBankTarget; +extern u16 gAnimSpeciesByBanks[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_02038440; + void ClearBattleAnimationVars(void); void DoMoveAnim(u16 move); void DoBattleAnim(const u8 *const animsTable[], u16 tableId, bool8 isMoveAnim); @@ -49,7 +67,7 @@ bool8 IsContest(void); s8 BattleAnimAdjustPanning(s8 pan); s8 BattleAnimAdjustPanning2(s8 pan); s16 sub_80A52EC(s16 a); -s16 sub_80A5314(s16 a, s16 b, s16 c); +s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); // battle_anim_80FE840.s void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value); diff --git a/ld_script.txt b/ld_script.txt index f56047947..a227d9510 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -114,7 +114,6 @@ SECTIONS { src/palette.o(.text); src/sound.o(.text); src/battle_anim.o(.text); - asm/battle_anim.o(.text); asm/rom_80A5C6C.o(.text); src/task.o(.text); src/reshow_battle_screen.o(.text); @@ -364,6 +363,8 @@ SECTIONS { src/palette.o(.rodata); data/fanfares.o(.rodata); data/battle_anims.o(.rodata); + src/battle_anim.o(.rodata); + data/rom_8525F58.o(.rodata); data/title_screen.o(.rodata); data/field_screen.o(.rodata); data/battle_setup.o(.rodata); diff --git a/src/battle_anim.c b/src/battle_anim.c index 7a2b7902c..13b74a84a 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -18,16 +18,11 @@ // sprites start at 10000 and thus must be subtracted of 10000 to account for the true index. #define GET_TRUE_SPRITE_INDEX(i) ((i - 10000)) -#define SCRIPT_READ_32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) #define SCRIPT_READ_16(ptr) ((ptr)[0] | ((ptr)[1] << 8)) +#define SCRIPT_READ_32(ptr) (((ptr)[0]) + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) #define SCRIPT_READ_PTR(ptr) ((const u8*)(SCRIPT_READ_32(ptr))) -#define SCRIPT_READ_16_(ptr) ((ptr)[0] + ((ptr)[1] << 8)) -#define SCRIPT_READ_32_(ptr) (((ptr)[0]) + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) -#define SCRIPT_READ_PTR_(ptr) ((const u8*)(SCRIPT_READ_32_(ptr))) - #define ANIM_SPRITE_INDEX_COUNT 8 -#define ANIM_ARGS_COUNT 8 extern u8 gBankAttacker; extern u8 gBankTarget; @@ -44,32 +39,8 @@ extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern struct MusicPlayerInfo gMPlay_BGM; extern struct MusicPlayerInfo gMPlay_SE1; extern struct MusicPlayerInfo gMPlay_SE2; +extern u8 gDecompressionBuffer[]; -EWRAM_DATA const u8 *gBattleAnimScriptPtr = NULL; -EWRAM_DATA const u8 *gBattleAnimScriptRetAddr = NULL; -EWRAM_DATA void (*gAnimScriptCallback)(void) = NULL; -EWRAM_DATA s8 gAnimFramesToWait = 0; -EWRAM_DATA bool8 gAnimScriptActive = FALSE; -EWRAM_DATA u8 gAnimVisualTaskCount = 0; -EWRAM_DATA u8 gAnimSoundTaskCount = 0; -EWRAM_DATA struct DisableStruct *gAnimDisableStructPtr = NULL; -EWRAM_DATA u32 gAnimMoveDmg = 0; -EWRAM_DATA u16 gAnimMovePower = 0; -EWRAM_DATA u16 gAnimSpriteIndexArray[ANIM_SPRITE_INDEX_COUNT] = {0}; -EWRAM_DATA u8 gAnimFriendship = 0; -EWRAM_DATA u16 gWeatherMoveAnim = 0; -EWRAM_DATA s16 gBattleAnimArgs[ANIM_ARGS_COUNT] = {0}; -EWRAM_DATA u16 gSoundAnimFramesToWait = 0; -EWRAM_DATA u8 gMonAnimTaskIdArray[2] = {0}; -EWRAM_DATA u8 gAnimMoveTurn = 0; -EWRAM_DATA u8 gUnknown_02038433 = 0; -EWRAM_DATA u16 gAnimMoveIndex = 0; // set but unused. -EWRAM_DATA u8 gAnimBankAttacker = 0; -EWRAM_DATA u8 gAnimBankTarget = 0; -EWRAM_DATA u16 gAnimSpeciesByBanks[BATTLE_BANKS_COUNT] = {0}; -EWRAM_DATA u8 gUnknown_02038440 = 0; - -extern void (* const sScriptCmdTable[])(void); extern const u16 gUnknown_082C8D64[]; extern const u8 * const gBattleAnims_Moves[]; extern const struct CompressedSpriteSheet gBattleAnimPicTable[]; @@ -83,17 +54,150 @@ extern u8 sub_80A82E4(u8 bank); // rom_80A5C6C.s extern u8 sub_80A5C6C(u8 bank, u8 attributeId); // rom_80A5C6C.s extern bool8 AnimBankSpriteExists(u8 bank); // rom_80A5C6C.s extern void sub_80A6C68(u8 arg0); // rom_80A5C6C.s +extern u8 GetAnimBankSpriteId(u8 wantedBank); // rom_80A5C6C.s extern u8 sub_80A6D94(void); +extern u8 sub_80A8364(u8); +extern bool8 IsDoubleBattle(void); // this file's functions -void RunAnimScriptCommand(void); -void task_pA_ma0A_obj_to_bg_pal(u8 taskId); -void sub_80A46A0(void); -void sub_80A4980(u8 taskId); -void sub_80A4BB0(u8 taskId); -void Task_FadeToBg(u8 taskId); -void LoadDefaultBg(void); -void LoadMoveBg(u16 bgId); +static void ScriptCmd_loadspritegfx(void); +static void ScriptCmd_unloadspritegfx(void); +static void ScriptCmd_createsprite(void); +static void ScriptCmd_createvisualtask(void); +static void ScriptCmd_delay(void); +static void ScriptCmd_waitforvisualfinish(void); +static void ScriptCmd_hang1(void); +static void ScriptCmd_hang2(void); +static void ScriptCmd_end(void); +static void ScriptCmd_playse(void); +static void ScriptCmd_monbg(void); +static void ScriptCmd_clearmonbg(void); +static void ScriptCmd_setalpha(void); +static void ScriptCmd_blendoff(void); +static void ScriptCmd_call(void); +static void ScriptCmd_return(void); +static void ScriptCmd_setarg(void); +static void ScriptCmd_choosetwoturnanim(void); +static void ScriptCmd_jumpifmoveturn(void); +static void ScriptCmd_jump(void); +static void ScriptCmd_fadetobg(void); +static void ScriptCmd_restorebg(void); +static void ScriptCmd_waitbgfadeout(void); +static void ScriptCmd_waitbgfadein(void); +static void ScriptCmd_changebg(void); +static void ScriptCmd_playsewithpan(void); +static void ScriptCmd_setpan(void); +static void ScriptCmd_panse_1B(void); +static void ScriptCmd_loopsewithpan(void); +static void ScriptCmd_waitplaysewithpan(void); +static void ScriptCmd_setbldcnt(void); +static void ScriptCmd_createsoundtask(void); +static void ScriptCmd_waitsound(void); +static void ScriptCmd_jumpargeq(void); +static void ScriptCmd_monbg_22(void); +static void ScriptCmd_clearmonbg_23(void); +static void ScriptCmd_jumpifcontest(void); +static void ScriptCmd_fadetobgfromset(void); +static void ScriptCmd_panse_26(void); +static void ScriptCmd_panse_27(void); +static void ScriptCmd_monbgprio_28(void); +static void ScriptCmd_monbgprio_29(void); +static void ScriptCmd_monbgprio_2A(void); +static void ScriptCmd_invisible(void); +static void ScriptCmd_visible(void); +static void ScriptCmd_doublebattle_2D(void); +static void ScriptCmd_doublebattle_2E(void); +static void ScriptCmd_stopsound(void); + +static void RunAnimScriptCommand(void); +static void task_pA_ma0A_obj_to_bg_pal(u8 taskId); +static void sub_80A46A0(void); +static void sub_80A4980(u8 taskId); +static void sub_80A4BB0(u8 taskId); +static void Task_FadeToBg(u8 taskId); +static void Task_PanFromInitialToTarget(u8 taskId); +static void Task_LoopAndPlaySE(u8 taskId); +static void Task_WaitAndPlaySE(u8 taskId); +static void LoadDefaultBg(void); +static void LoadMoveBg(u16 bgId); + +// ewram +EWRAM_DATA static const u8 *sBattleAnimScriptPtr = NULL; +EWRAM_DATA static const u8 *sBattleAnimScriptRetAddr = NULL; +EWRAM_DATA void (*gAnimScriptCallback)(void) = NULL; +EWRAM_DATA static s8 gAnimFramesToWait = 0; +EWRAM_DATA bool8 gAnimScriptActive = FALSE; +EWRAM_DATA u8 gAnimVisualTaskCount = 0; +EWRAM_DATA u8 gAnimSoundTaskCount = 0; +EWRAM_DATA struct DisableStruct *gAnimDisableStructPtr = NULL; +EWRAM_DATA u32 gAnimMoveDmg = 0; +EWRAM_DATA u16 gAnimMovePower = 0; +EWRAM_DATA static u16 sAnimSpriteIndexArray[ANIM_SPRITE_INDEX_COUNT] = {0}; +EWRAM_DATA u8 gAnimFriendship = 0; +EWRAM_DATA u16 gWeatherMoveAnim = 0; +EWRAM_DATA s16 gBattleAnimArgs[ANIM_ARGS_COUNT] = {0}; +EWRAM_DATA static u16 sSoundAnimFramesToWait = 0; +EWRAM_DATA static u8 sMonAnimTaskIdArray[2] = {0}; +EWRAM_DATA u8 gAnimMoveTurn = 0; +EWRAM_DATA static u8 sAnimBackgroundFadeState = 0; +EWRAM_DATA static u16 sAnimMoveIndex = 0; // set but unused. +EWRAM_DATA u8 gAnimBankAttacker = 0; +EWRAM_DATA u8 gAnimBankTarget = 0; +EWRAM_DATA u16 gAnimSpeciesByBanks[BATTLE_BANKS_COUNT] = {0}; +EWRAM_DATA u8 gUnknown_02038440 = 0; + +// const rom data +static void (* const sScriptCmdTable[])(void) = +{ + ScriptCmd_loadspritegfx, + ScriptCmd_unloadspritegfx, + ScriptCmd_createsprite, + ScriptCmd_createvisualtask, + ScriptCmd_delay, + ScriptCmd_waitforvisualfinish, + ScriptCmd_hang1, + ScriptCmd_hang2, + ScriptCmd_end, + ScriptCmd_playse, + ScriptCmd_monbg, + ScriptCmd_clearmonbg, + ScriptCmd_setalpha, + ScriptCmd_blendoff, + ScriptCmd_call, + ScriptCmd_return, + ScriptCmd_setarg, + ScriptCmd_choosetwoturnanim, + ScriptCmd_jumpifmoveturn, + ScriptCmd_jump, + ScriptCmd_fadetobg, + ScriptCmd_restorebg, + ScriptCmd_waitbgfadeout, + ScriptCmd_waitbgfadein, + ScriptCmd_changebg, + ScriptCmd_playsewithpan, + ScriptCmd_setpan, + ScriptCmd_panse_1B, + ScriptCmd_loopsewithpan, + ScriptCmd_waitplaysewithpan, + ScriptCmd_setbldcnt, + ScriptCmd_createsoundtask, + ScriptCmd_waitsound, + ScriptCmd_jumpargeq, + ScriptCmd_monbg_22, + ScriptCmd_clearmonbg_23, + ScriptCmd_jumpifcontest, + ScriptCmd_fadetobgfromset, + ScriptCmd_panse_26, + ScriptCmd_panse_27, + ScriptCmd_monbgprio_28, + ScriptCmd_monbgprio_29, + ScriptCmd_monbgprio_2A, + ScriptCmd_invisible, + ScriptCmd_visible, + ScriptCmd_doublebattle_2D, + ScriptCmd_doublebattle_2E, + ScriptCmd_stopsound +}; void ClearBattleAnimationVars(void) { @@ -110,17 +214,17 @@ void ClearBattleAnimationVars(void) // clear index array. for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) - gAnimSpriteIndexArray[i] |= 0xFFFF; + sAnimSpriteIndexArray[i] |= 0xFFFF; // clear anim args. for (i = 0; i < ANIM_ARGS_COUNT; i++) gBattleAnimArgs[i] = 0; - gMonAnimTaskIdArray[0] = 0xFF; - gMonAnimTaskIdArray[1] = 0xFF; + sMonAnimTaskIdArray[0] = 0xFF; + sMonAnimTaskIdArray[1] = 0xFF; gAnimMoveTurn = 0; - gUnknown_02038433 = 0; - gAnimMoveIndex = 0; + sAnimBackgroundFadeState = 0; + sAnimMoveIndex = 0; gAnimBankAttacker = 0; gAnimBankTarget = 0; gUnknown_02038440 = 0; @@ -156,22 +260,22 @@ void DoBattleAnim(const u8 *const animsTable[], u16 tableId, bool8 isMoveAnim) } if (!isMoveAnim) - gAnimMoveIndex = 0; + sAnimMoveIndex = 0; else - gAnimMoveIndex = tableId; + sAnimMoveIndex = tableId; for (i = 0; i < ANIM_ARGS_COUNT; i++) gBattleAnimArgs[i] = 0; - gMonAnimTaskIdArray[0] = 0xFF; - gMonAnimTaskIdArray[1] = 0xFF; - gBattleAnimScriptPtr = animsTable[tableId]; + sMonAnimTaskIdArray[0] = 0xFF; + sMonAnimTaskIdArray[1] = 0xFF; + sBattleAnimScriptPtr = animsTable[tableId]; gAnimScriptActive = TRUE; gAnimFramesToWait = 0; gAnimScriptCallback = RunAnimScriptCommand; for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) - gAnimSpriteIndexArray[i] |= 0xFFFF; + sAnimSpriteIndexArray[i] |= 0xFFFF; if (isMoveAnim) { @@ -210,35 +314,35 @@ void DestroyAnimSoundTask(u8 taskId) gAnimSoundTaskCount--; } -/*static*/ void AddSpriteIndex(u16 index) +static void AddSpriteIndex(u16 index) { s32 i; for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) { - if (gAnimSpriteIndexArray[i] == 0xFFFF) + if (sAnimSpriteIndexArray[i] == 0xFFFF) { - gAnimSpriteIndexArray[i] = index; + sAnimSpriteIndexArray[i] = index; return; } } } -/*static*/ void ClearSpriteIndex(u16 index) +static void ClearSpriteIndex(u16 index) { s32 i; for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) { - if (gAnimSpriteIndexArray[i] == index) + if (sAnimSpriteIndexArray[i] == index) { - gAnimSpriteIndexArray[i] |= 0xFFFF; + sAnimSpriteIndexArray[i] |= 0xFFFF; return; } } } -/*static*/ void WaitAnimFrameCount(void) +static void WaitAnimFrameCount(void) { if (gAnimFramesToWait <= 0) { @@ -251,41 +355,41 @@ void DestroyAnimSoundTask(u8 taskId) } } -/*static*/ void RunAnimScriptCommand(void) +static void RunAnimScriptCommand(void) { do { - sScriptCmdTable[gBattleAnimScriptPtr[0]](); + sScriptCmdTable[sBattleAnimScriptPtr[0]](); } while (gAnimFramesToWait == 0 && gAnimScriptActive); } -/*static*/ void ScriptCmd_loadspritegfx(void) +static void ScriptCmd_loadspritegfx(void) { u16 index; - gBattleAnimScriptPtr++; - index = SCRIPT_READ_16(gBattleAnimScriptPtr); + sBattleAnimScriptPtr++; + index = SCRIPT_READ_16(sBattleAnimScriptPtr); LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)]); LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(index)]); - gBattleAnimScriptPtr += 2; + sBattleAnimScriptPtr += 2; AddSpriteIndex(GET_TRUE_SPRITE_INDEX(index)); gAnimFramesToWait = 1; gAnimScriptCallback = WaitAnimFrameCount; } -/*static*/ void ScriptCmd_unloadspritegfx(void) +static void ScriptCmd_unloadspritegfx(void) { u16 index; - gBattleAnimScriptPtr++; - index = SCRIPT_READ_16(gBattleAnimScriptPtr); + sBattleAnimScriptPtr++; + index = SCRIPT_READ_16(sBattleAnimScriptPtr); FreeSpriteTilesByTag(gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)].tag); FreeSpritePaletteByTag(gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)].tag); - gBattleAnimScriptPtr += 2; + sBattleAnimScriptPtr += 2; ClearSpriteIndex(GET_TRUE_SPRITE_INDEX(index)); } -/*static*/ void ScriptCmd_createsprite(void) +static void ScriptCmd_createsprite(void) { s32 i; const struct SpriteTemplate *template; @@ -293,19 +397,19 @@ void DestroyAnimSoundTask(u8 taskId) u8 argsCount; s16 subpriority; - gBattleAnimScriptPtr++; - template = (const struct SpriteTemplate *)(SCRIPT_READ_32_(gBattleAnimScriptPtr)); - gBattleAnimScriptPtr += 4; + sBattleAnimScriptPtr++; + template = (const struct SpriteTemplate *)(SCRIPT_READ_32(sBattleAnimScriptPtr)); + sBattleAnimScriptPtr += 4; - argVar = gBattleAnimScriptPtr[0]; - gBattleAnimScriptPtr++; + argVar = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; - argsCount = gBattleAnimScriptPtr[0]; - gBattleAnimScriptPtr++; + argsCount = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; for (i = 0; i < argsCount; i++) { - gBattleAnimArgs[i] = SCRIPT_READ_16(gBattleAnimScriptPtr); - gBattleAnimScriptPtr += 2; + gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 2; } if (argVar & 0x80) @@ -335,7 +439,7 @@ void DestroyAnimSoundTask(u8 taskId) gAnimVisualTaskCount++; } -/*static*/ void ScriptCmd_createvisualtask(void) +static void ScriptCmd_createvisualtask(void) { TaskFunc taskFunc; u8 taskPriority; @@ -343,21 +447,21 @@ void DestroyAnimSoundTask(u8 taskId) u8 numArgs; s32 i; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; - taskFunc = (TaskFunc)SCRIPT_READ_32_(gBattleAnimScriptPtr); - gBattleAnimScriptPtr += 4; + taskFunc = (TaskFunc)SCRIPT_READ_32(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 4; - taskPriority = gBattleAnimScriptPtr[0]; - gBattleAnimScriptPtr++; + taskPriority = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; - numArgs = gBattleAnimScriptPtr[0]; - gBattleAnimScriptPtr++; + numArgs = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; for (i = 0; i < numArgs; i++) { - gBattleAnimArgs[i] = SCRIPT_READ_16(gBattleAnimScriptPtr); - gBattleAnimScriptPtr += 2; + gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 2; } taskId = CreateTask(taskFunc, taskPriority); @@ -365,22 +469,22 @@ void DestroyAnimSoundTask(u8 taskId) gAnimVisualTaskCount++; } -/*static*/ void ScriptCmd_delay(void) +static void ScriptCmd_delay(void) { - gBattleAnimScriptPtr++; - gAnimFramesToWait = gBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + gAnimFramesToWait = sBattleAnimScriptPtr[0]; if (gAnimFramesToWait == 0) gAnimFramesToWait = -1; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; gAnimScriptCallback = WaitAnimFrameCount; } // wait for visual tasks to finish. -/*static*/ void ScriptCmd_waitforvisualfinish(void) +static void ScriptCmd_waitforvisualfinish(void) { if (gAnimVisualTaskCount == 0) { - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; gAnimFramesToWait = 0; } else @@ -389,24 +493,24 @@ void DestroyAnimSoundTask(u8 taskId) } } -/*static*/ void ScriptCmd_hang1(void) +static void ScriptCmd_hang1(void) { } -/*static*/ void ScriptCmd_hang2(void) +static void ScriptCmd_hang2(void) { } -/*static*/ void ScriptCmd_end(void) +static void ScriptCmd_end(void) { s32 i; bool32 continuousAnim = FALSE; // keep waiting as long as there is animations to be done. if (gAnimVisualTaskCount != 0 || gAnimSoundTaskCount != 0 - || gMonAnimTaskIdArray[0] != 0xFF || gMonAnimTaskIdArray[1] != 0xFF) + || sMonAnimTaskIdArray[0] != 0xFF || sMonAnimTaskIdArray[1] != 0xFF) { - gSoundAnimFramesToWait = 0; + sSoundAnimFramesToWait = 0; gAnimFramesToWait = 1; return; } @@ -414,7 +518,7 @@ void DestroyAnimSoundTask(u8 taskId) // finish the sound effects. if (IsSEPlaying()) { - if (++gSoundAnimFramesToWait <= 90) // wait 90 frames, then halt the sound effect. + if (++sSoundAnimFramesToWait <= 90) // wait 90 frames, then halt the sound effect. { gAnimFramesToWait = 1; return; @@ -427,15 +531,15 @@ void DestroyAnimSoundTask(u8 taskId) } // the SE has halted, so set the SE Frame Counter to 0 and continue. - gSoundAnimFramesToWait = 0; + sSoundAnimFramesToWait = 0; for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) { - if (gAnimSpriteIndexArray[i] != 0xFFFF) + if (sAnimSpriteIndexArray[i] != 0xFFFF) { - FreeSpriteTilesByTag(gBattleAnimPicTable[gAnimSpriteIndexArray[i]].tag); - FreeSpritePaletteByTag(gBattleAnimPicTable[gAnimSpriteIndexArray[i]].tag); - gAnimSpriteIndexArray[i] |= 0xFFFF; // set terminator. + FreeSpriteTilesByTag(gBattleAnimPicTable[sAnimSpriteIndexArray[i]].tag); + FreeSpritePaletteByTag(gBattleAnimPicTable[sAnimSpriteIndexArray[i]].tag); + sAnimSpriteIndexArray[i] |= 0xFFFF; // set terminator. } } @@ -451,11 +555,11 @@ void DestroyAnimSoundTask(u8 taskId) } } -/*static*/ void ScriptCmd_playse(void) +static void ScriptCmd_playse(void) { - gBattleAnimScriptPtr++; - PlaySE(SCRIPT_READ_16(gBattleAnimScriptPtr)); - gBattleAnimScriptPtr += 2; + sBattleAnimScriptPtr++; + PlaySE(SCRIPT_READ_16(sBattleAnimScriptPtr)); + sBattleAnimScriptPtr += 2; } #define t1_MONBG_BANK 0 @@ -467,7 +571,7 @@ void DestroyAnimSoundTask(u8 taskId) #define t2_MON_IN_BG2 5 #define t2_MONBG_BANK 6 -/*static*/ void sub_80A40F4(u8 taskId) +static void sub_80A40F4(u8 taskId) { u8 newTaskId; @@ -499,20 +603,20 @@ void DestroyAnimSoundTask(u8 taskId) gTasks[newTaskId].data[t2_MON_IN_BG2] = selfData[t1_MON_IN_BG2]; gTasks[newTaskId].data[t2_MONBG_BANK] = selfData[t1_MONBG_BANK]; - gMonAnimTaskIdArray[selfData[t1_IS_SECONDMON_BG]] = newTaskId; + sMonAnimTaskIdArray[selfData[t1_IS_SECONDMON_BG]] = newTaskId; DestroyAnimVisualTask(taskId); } -/*static*/ void ScriptCmd_monbg(void) +static void ScriptCmd_monbg(void) { bool8 toBG_2; u8 taskId; u8 bank; u8 animBank; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; - animBank = gBattleAnimScriptPtr[0]; + animBank = sBattleAnimScriptPtr[0]; if (animBank & ANIM_BANK_TARGET) bank = gAnimBankTarget; else @@ -554,7 +658,7 @@ void DestroyAnimSoundTask(u8 taskId) gTasks[taskId].data[t1_IS_SECONDMON_BG] = 1; } - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; gAnimFramesToWait = 1; gAnimScriptCallback = WaitAnimFrameCount; } @@ -661,7 +765,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible) } } -/*static*/ void sub_80A46A0(void) +static void sub_80A46A0(void) { s32 i, j; struct UnknownAnimStruct2 unknownStruct; @@ -725,7 +829,7 @@ void sub_80A477C(bool8 to_BG2) } } -/*static*/ void task_pA_ma0A_obj_to_bg_pal(u8 taskId) +static void task_pA_ma0A_obj_to_bg_pal(u8 taskId) { u8 r4; u8 r6; @@ -763,14 +867,14 @@ void sub_80A477C(bool8 to_BG2) } } -/*static*/ void ScriptCmd_clearmonbg(void) +static void ScriptCmd_clearmonbg(void) { u8 animBankId; u8 bank; u8 taskId; - gBattleAnimScriptPtr++; - animBankId = gBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + animBankId = sBattleAnimScriptPtr[0]; if (animBankId == ANIM_BANK_ATTACKER) animBankId = ANIM_BANK_ATK_PARTNER; @@ -782,9 +886,9 @@ void sub_80A477C(bool8 to_BG2) else bank = gAnimBankTarget; - if (gMonAnimTaskIdArray[0] != 0xFF) + if (sMonAnimTaskIdArray[0] != 0xFF) gSprites[gBankSpriteIds[bank]].invisible = 0; - if (animBankId > 1 && gMonAnimTaskIdArray[1] != 0xFF) + if (animBankId > 1 && sMonAnimTaskIdArray[1] != 0xFF) gSprites[gBankSpriteIds[bank ^ BIT_MON]].invisible = 0; else animBankId = 0; @@ -793,10 +897,10 @@ void sub_80A477C(bool8 to_BG2) gTasks[taskId].data[0] = animBankId; gTasks[taskId].data[2] = bank; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; } -/*static*/ void sub_80A4980(u8 taskId) +static void sub_80A4980(u8 taskId) { gTasks[taskId].data[1]++; if (gTasks[taskId].data[1] != 1) @@ -808,31 +912,31 @@ void sub_80A477C(bool8 to_BG2) else to_BG2 = TRUE; - if (gMonAnimTaskIdArray[0] != 0xFF) + if (sMonAnimTaskIdArray[0] != 0xFF) { sub_80A477C(to_BG2); - DestroyTask(gMonAnimTaskIdArray[0]); - gMonAnimTaskIdArray[0] = 0xFF; + DestroyTask(sMonAnimTaskIdArray[0]); + sMonAnimTaskIdArray[0] = 0xFF; } if (gTasks[taskId].data[0] > 1) { sub_80A477C(to_BG2 ^ 1); - DestroyTask(gMonAnimTaskIdArray[1]); - gMonAnimTaskIdArray[1] = 0xFF; + DestroyTask(sMonAnimTaskIdArray[1]); + sMonAnimTaskIdArray[1] = 0xFF; } DestroyTask(taskId); } } -/*static*/ void ScriptCmd_monbg_22(void) +static void ScriptCmd_monbg_22(void) { bool8 toBG_2; u8 bank; u8 animBankId; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; - animBankId = gBattleAnimScriptPtr[0]; + animBankId = sBattleAnimScriptPtr[0]; if (animBankId == ANIM_BANK_ATTACKER) animBankId = ANIM_BANK_ATK_PARTNER; @@ -867,17 +971,17 @@ void sub_80A477C(bool8 to_BG2) sub_80A438C(bank, toBG_2, FALSE); } - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; } -/*static*/ void ScriptCmd_clearmonbg_23(void) +static void ScriptCmd_clearmonbg_23(void) { u8 animBankId; u8 bank; u8 taskId; - gBattleAnimScriptPtr++; - animBankId = gBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + animBankId = sBattleAnimScriptPtr[0]; if (animBankId == ANIM_BANK_ATTACKER) animBankId = ANIM_BANK_ATK_PARTNER; @@ -900,10 +1004,10 @@ void sub_80A477C(bool8 to_BG2) gTasks[taskId].data[0] = animBankId; gTasks[taskId].data[2] = bank; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; } -/*static*/ void sub_80A4BB0(u8 taskId) +static void sub_80A4BB0(u8 taskId) { gTasks[taskId].data[1]++; if (gTasks[taskId].data[1] != 1) @@ -934,85 +1038,85 @@ void sub_80A477C(bool8 to_BG2) #undef t2_MON_IN_BG2 #undef t2_MONBG_BANK -/*static*/ void ScriptCmd_setalpha(void) +static void ScriptCmd_setalpha(void) { u16 half1, half2; - gBattleAnimScriptPtr++; - half1 = *(gBattleAnimScriptPtr++); - half2 = *(gBattleAnimScriptPtr++) << 8; + sBattleAnimScriptPtr++; + half1 = *(sBattleAnimScriptPtr++); + half2 = *(sBattleAnimScriptPtr++) << 8; SetGpuReg(REG_OFFSET_BLDCNT, 0x3F40); SetGpuReg(REG_OFFSET_BLDALPHA, half1 | half2); } -/*static*/ void ScriptCmd_setbldcnt(void) +static void ScriptCmd_setbldcnt(void) { u16 half1, half2; - gBattleAnimScriptPtr++; - half1 = *(gBattleAnimScriptPtr++); - half2 = *(gBattleAnimScriptPtr++) << 8; + sBattleAnimScriptPtr++; + half1 = *(sBattleAnimScriptPtr++); + half2 = *(sBattleAnimScriptPtr++) << 8; SetGpuReg(REG_OFFSET_BLDCNT, half1 | half2); } -/*static*/ void ScriptCmd_blendoff(void) +static void ScriptCmd_blendoff(void) { - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); } -/*static*/ void ScriptCmd_call(void) +static void ScriptCmd_call(void) { - gBattleAnimScriptPtr++; - gBattleAnimScriptRetAddr = gBattleAnimScriptPtr + 4; - gBattleAnimScriptPtr = SCRIPT_READ_PTR_(gBattleAnimScriptPtr); + sBattleAnimScriptPtr++; + sBattleAnimScriptRetAddr = sBattleAnimScriptPtr + 4; + sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr); } -/*static*/ void ScriptCmd_return(void) +static void ScriptCmd_return(void) { - gBattleAnimScriptPtr = gBattleAnimScriptRetAddr; + sBattleAnimScriptPtr = sBattleAnimScriptRetAddr; } -/*static*/ void ScriptCmd_setarg(void) +static void ScriptCmd_setarg(void) { - const u8 *addr = gBattleAnimScriptPtr; + const u8 *addr = sBattleAnimScriptPtr; u16 value; u8 argId; - gBattleAnimScriptPtr++; - argId = gBattleAnimScriptPtr[0]; - gBattleAnimScriptPtr++; - value = SCRIPT_READ_16(gBattleAnimScriptPtr); - gBattleAnimScriptPtr = addr + 4; + sBattleAnimScriptPtr++; + argId = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + value = SCRIPT_READ_16(sBattleAnimScriptPtr); + sBattleAnimScriptPtr = addr + 4; gBattleAnimArgs[argId] = value; } -/*static*/ void ScriptCmd_choosetwoturnanim(void) +static void ScriptCmd_choosetwoturnanim(void) { - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; if (gAnimMoveTurn & 1) - gBattleAnimScriptPtr += 4; - gBattleAnimScriptPtr = SCRIPT_READ_PTR_(gBattleAnimScriptPtr); + sBattleAnimScriptPtr += 4; + sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr); } -/*static*/ void ScriptCmd_jumpifmoveturn(void) +static void ScriptCmd_jumpifmoveturn(void) { u8 toCheck; - gBattleAnimScriptPtr++; - toCheck = gBattleAnimScriptPtr[0]; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; + toCheck = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; if (toCheck == gAnimMoveTurn) - gBattleAnimScriptPtr = SCRIPT_READ_PTR_(gBattleAnimScriptPtr); + sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr); else - gBattleAnimScriptPtr += 4; + sBattleAnimScriptPtr += 4; } -/*static*/ void ScriptCmd_jump(void) +static void ScriptCmd_jump(void) { - gBattleAnimScriptPtr++; - gBattleAnimScriptPtr = SCRIPT_READ_PTR_(gBattleAnimScriptPtr); + sBattleAnimScriptPtr++; + sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr); } // Uses of this function that rely on a TRUE return are expecting inBattle to not be ticked as defined in contest behavior. As a result, if misused, this function cannot reliably discern between field and contest status and could result in undefined behavior. @@ -1027,29 +1131,29 @@ bool8 IsContest(void) #define tBackgroundId data[0] #define tState data[10] -/*static*/ void ScriptCmd_fadetobg(void) +static void ScriptCmd_fadetobg(void) { u8 backgroundId; u8 taskId; - gBattleAnimScriptPtr++; - backgroundId = gBattleAnimScriptPtr[0]; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; + backgroundId = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; taskId = CreateTask(Task_FadeToBg, 5); gTasks[taskId].tBackgroundId = backgroundId; - gUnknown_02038433 = 1; + sAnimBackgroundFadeState = 1; } -/*static*/ void ScriptCmd_fadetobgfromset(void) +static void ScriptCmd_fadetobgfromset(void) { u8 bg1, bg2, bg3; u8 taskId; - gBattleAnimScriptPtr++; - bg1 = gBattleAnimScriptPtr[0]; - bg2 = gBattleAnimScriptPtr[1]; - bg3 = gBattleAnimScriptPtr[2]; - gBattleAnimScriptPtr += 3; + sBattleAnimScriptPtr++; + bg1 = sBattleAnimScriptPtr[0]; + bg2 = sBattleAnimScriptPtr[1]; + bg3 = sBattleAnimScriptPtr[2]; + sBattleAnimScriptPtr += 3; taskId = CreateTask(Task_FadeToBg, 5); if (IsContest()) @@ -1059,10 +1163,10 @@ bool8 IsContest(void) else gTasks[taskId].tBackgroundId = bg1; - gUnknown_02038433 = 1; + sAnimBackgroundFadeState = 1; } -/*static*/ void Task_FadeToBg(u8 taskId) +static void Task_FadeToBg(u8 taskId) { if (gTasks[taskId].tState == 0) { @@ -1075,11 +1179,11 @@ bool8 IsContest(void) if (gTasks[taskId].tState == 1) { gTasks[taskId].tState++; - gUnknown_02038433 = 2; + sAnimBackgroundFadeState = 2; } else if (gTasks[taskId].tState == 2) { - s16 bgId = (u16)gTasks[taskId].tBackgroundId; + s16 bgId = gTasks[taskId].tBackgroundId; if (bgId == -1) LoadDefaultBg(); @@ -1095,17 +1199,15 @@ bool8 IsContest(void) if (gTasks[taskId].tState == 3) { DestroyTask(taskId); - gUnknown_02038433 = 0; + sAnimBackgroundFadeState = 0; } } -extern u8 gDecompressionBuffer[]; - -/*static*/ void LoadMoveBg(u16 bgId) +static void LoadMoveBg(u16 bgId) { if (IsContest()) { - void *tilemap = gBattleAnimBackgroundTable[bgId].tilemap; + const void *tilemap = gBattleAnimBackgroundTable[bgId].tilemap; void *dmaSrc; void *dmaDest; @@ -1125,7 +1227,7 @@ extern u8 gDecompressionBuffer[]; } } -/*static*/ void LoadDefaultBg(void) +static void LoadDefaultBg(void) { if (IsContest()) LoadContestBgAfterMoveAnim(); @@ -1133,21 +1235,24 @@ extern u8 gDecompressionBuffer[]; LoadFittingBackgroundForBattle(); } -/*static*/ void ScriptCmd_restorebg(void) +static void ScriptCmd_restorebg(void) { u8 taskId; - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; taskId = CreateTask(Task_FadeToBg, 5); - gTasks[taskId].data[0] = 0xFFFF; - gUnknown_02038433 = 1; + gTasks[taskId].tBackgroundId = -1; + sAnimBackgroundFadeState = 1; } -/*static*/ void ScriptCmd_waitbgfadeout(void) +#undef tBackgroundId +#undef tState + +static void ScriptCmd_waitbgfadeout(void) { - if (gUnknown_02038433 == 2) + if (sAnimBackgroundFadeState == 2) { - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; gAnimFramesToWait = 0; } else @@ -1156,11 +1261,11 @@ extern u8 gDecompressionBuffer[]; } } -/*static*/ void ScriptCmd_waitbgfadein(void) +static void ScriptCmd_waitbgfadein(void) { - if (gUnknown_02038433 == 0) + if (sAnimBackgroundFadeState == 0) { - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; gAnimFramesToWait = 0; } else @@ -1169,11 +1274,11 @@ extern u8 gDecompressionBuffer[]; } } -/*static*/ void ScriptCmd_changebg(void) +static void ScriptCmd_changebg(void) { - gBattleAnimScriptPtr++; - LoadMoveBg(gBattleAnimScriptPtr[0]); - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; + LoadMoveBg(sBattleAnimScriptPtr[0]); + sBattleAnimScriptPtr++; } s8 BattleAnimAdjustPanning(s8 pan) @@ -1247,38 +1352,501 @@ s16 sub_80A52EC(s16 a) return var; } -s16 sub_80A5314(s16 a, s16 b, s16 c) +s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan) { - u16 var; + s16 ret; - if (a < b) - var = ((c < 0) ? -c : c); - else if (a > b) - var = -((c < 0) ? -c : c); + if (sourcePan < targetPan) + ret = ((incrementPan < 0) ? -incrementPan : incrementPan); + else if (sourcePan > targetPan) + ret = -((incrementPan < 0) ? -incrementPan : incrementPan); else - var = 0; + ret = 0; - return var; + return ret; } -/*static*/ void ScriptCmd_playsewithpan(void) +static void ScriptCmd_playsewithpan(void) { u16 songId; s8 pan; - gBattleAnimScriptPtr++; - songId = SCRIPT_READ_16(gBattleAnimScriptPtr); - pan = gBattleAnimScriptPtr[2]; + sBattleAnimScriptPtr++; + songId = SCRIPT_READ_16(sBattleAnimScriptPtr); + pan = sBattleAnimScriptPtr[2]; PlaySE12WithPanning(songId, BattleAnimAdjustPanning(pan)); - gBattleAnimScriptPtr += 3; + sBattleAnimScriptPtr += 3; } -/*static*/ void ScriptCmd_setpan(void) +static void ScriptCmd_setpan(void) { s8 pan; - gBattleAnimScriptPtr++; - pan = gBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + pan = sBattleAnimScriptPtr[0]; SE12PanpotControl(BattleAnimAdjustPanning(pan)); - gBattleAnimScriptPtr++; + sBattleAnimScriptPtr++; +} + +#define tInitialPan data[0] +#define tTargetPan data[1] +#define tIncrementPan data[2] +#define tFramesToWait data[3] +#define tCurrentPan data[4] +#define tFrameCounter data[8] + +static void ScriptCmd_panse_1B(void) +{ + u16 songNum; + s8 currentPanArg, incrementPan, incrementPanArg, currentPan, targetPan; + u8 framesToWait; + u8 taskId; + + sBattleAnimScriptPtr++; + songNum = SCRIPT_READ_16(sBattleAnimScriptPtr); + currentPanArg = sBattleAnimScriptPtr[2]; + incrementPan = sBattleAnimScriptPtr[3]; + incrementPanArg = sBattleAnimScriptPtr[4]; + framesToWait = sBattleAnimScriptPtr[5]; + + currentPan = BattleAnimAdjustPanning(currentPanArg); + targetPan = BattleAnimAdjustPanning(incrementPan); + incrementPan = CalculatePanIncrement(currentPan, targetPan, incrementPanArg); + taskId = CreateTask(Task_PanFromInitialToTarget, 1); + gTasks[taskId].tInitialPan = currentPan; + gTasks[taskId].tTargetPan = targetPan; + gTasks[taskId].tIncrementPan = incrementPan; + gTasks[taskId].tFramesToWait = framesToWait; + gTasks[taskId].tCurrentPan = currentPan; + + PlaySE12WithPanning(songNum, currentPan); + + gAnimSoundTaskCount++; + sBattleAnimScriptPtr += 6; +} + +void Task_PanFromInitialToTarget(u8 taskId) +{ + bool32 destroyTask = FALSE; + if (gTasks[taskId].tFrameCounter++ >= gTasks[taskId].tFramesToWait) + { + s16 pan; + s16 initialPanning, targetPanning, currentPan, incrementPan; + + gTasks[taskId].tFrameCounter = 0; + initialPanning = gTasks[taskId].tInitialPan; + targetPanning = gTasks[taskId].tTargetPan; + currentPan = gTasks[taskId].tCurrentPan; + incrementPan = gTasks[taskId].tIncrementPan; + pan = currentPan + incrementPan; + gTasks[taskId].tCurrentPan = pan; + + if (incrementPan == 0) // If we're not incrementing, just cancel the task immediately + { + destroyTask = TRUE; + } + else if (initialPanning < targetPanning) // Panning increasing + { + if (pan >= targetPanning) // Target reached + destroyTask = TRUE; + } + else // Panning decreasing + { + if (pan <= targetPanning) // Target reached + destroyTask = TRUE; + } + + if (destroyTask) + { + pan = targetPanning; + DestroyTask(taskId); + gAnimSoundTaskCount--; + } + + SE12PanpotControl(pan); + } +} + +static void ScriptCmd_panse_26(void) +{ + u16 songId; + s8 currentPan, targetPan, incrementPan; + u8 framesToWait; + u8 taskId; + + sBattleAnimScriptPtr++; + songId = SCRIPT_READ_16(sBattleAnimScriptPtr); + currentPan = sBattleAnimScriptPtr[2]; + targetPan = sBattleAnimScriptPtr[3]; + incrementPan = sBattleAnimScriptPtr[4]; + framesToWait = sBattleAnimScriptPtr[5]; + + taskId = CreateTask(Task_PanFromInitialToTarget, 1); + gTasks[taskId].tInitialPan = currentPan; + gTasks[taskId].tTargetPan = targetPan; + gTasks[taskId].tIncrementPan = incrementPan; + gTasks[taskId].tFramesToWait = framesToWait; + gTasks[taskId].tCurrentPan = currentPan; + + PlaySE12WithPanning(songId, currentPan); + + gAnimSoundTaskCount++; + sBattleAnimScriptPtr += 6; +} + +static void ScriptCmd_panse_27(void) +{ + u16 songId; + s8 targetPanArg, incrementPanArg, currentPanArg, currentPan, targetPan, incrementPan; + u8 framesToWait; + u8 taskId; + + sBattleAnimScriptPtr++; + songId = SCRIPT_READ_16(sBattleAnimScriptPtr); + currentPanArg = sBattleAnimScriptPtr[2]; + targetPanArg = sBattleAnimScriptPtr[3]; + incrementPanArg = sBattleAnimScriptPtr[4]; + framesToWait = sBattleAnimScriptPtr[5]; + + currentPan = BattleAnimAdjustPanning2(currentPanArg); + targetPan = BattleAnimAdjustPanning2(targetPanArg); + incrementPan = BattleAnimAdjustPanning2(incrementPanArg); + + taskId = CreateTask(Task_PanFromInitialToTarget, 1); + gTasks[taskId].tInitialPan = currentPan; + gTasks[taskId].tTargetPan = targetPan; + gTasks[taskId].tIncrementPan = incrementPan; + gTasks[taskId].tFramesToWait = framesToWait; + gTasks[taskId].tCurrentPan = currentPan; + + PlaySE12WithPanning(songId, currentPan); + + gAnimSoundTaskCount++; + sBattleAnimScriptPtr += 6; +} + +#undef tInitialPan +#undef tTargetPan +#undef tIncrementPan +#undef tFramesToWait +#undef tCurrentPan +#undef tFrameCounter + +#define tSongId data[0] +#define tPanning data[1] +#define tFramesToWait data[2] +#define tNumberOfPlays data[3] +#define tFrameCounter data[8] + +static void ScriptCmd_loopsewithpan(void) +{ + u16 songId; + s8 panningArg, panning; + u8 framesToWait, numberOfPlays; + u8 taskId; + + sBattleAnimScriptPtr++; + songId = SCRIPT_READ_16(sBattleAnimScriptPtr); + panningArg = sBattleAnimScriptPtr[2]; + framesToWait = sBattleAnimScriptPtr[3]; + numberOfPlays = sBattleAnimScriptPtr[4]; + panning = BattleAnimAdjustPanning(panningArg); + + taskId = CreateTask(Task_LoopAndPlaySE, 1); + gTasks[taskId].tSongId = songId; + gTasks[taskId].tPanning = panning; + gTasks[taskId].tFramesToWait = framesToWait; + gTasks[taskId].tNumberOfPlays = numberOfPlays; + gTasks[taskId].tFrameCounter = framesToWait; + gTasks[taskId].func(taskId); + + gAnimSoundTaskCount++; + sBattleAnimScriptPtr += 5; +} + +static void Task_LoopAndPlaySE(u8 taskId) +{ + if (gTasks[taskId].tFrameCounter++ >= gTasks[taskId].tFramesToWait) + { + u16 songId; + s8 panning; + u8 numberOfPlays; + + gTasks[taskId].tFrameCounter = 0; + songId = gTasks[taskId].tSongId; + panning = gTasks[taskId].tPanning; + numberOfPlays = --gTasks[taskId].tNumberOfPlays; + PlaySE12WithPanning(songId, panning); + if (numberOfPlays == 0) + { + DestroyTask(taskId); + gAnimSoundTaskCount--; + } + } +} + +#undef tSongId +#undef tPanning +#undef tFramesToWait +#undef tNumberOfPlays +#undef tFrameCounter + +#define tSongId data[0] +#define tPanning data[1] +#define tFramesToWait data[2] + +static void ScriptCmd_waitplaysewithpan(void) +{ + u16 songId; + s8 panningArg, panning; + u8 framesToWait; + u8 taskId; + + sBattleAnimScriptPtr++; + songId = SCRIPT_READ_16(sBattleAnimScriptPtr); + panningArg = sBattleAnimScriptPtr[2]; + framesToWait = sBattleAnimScriptPtr[3]; + panning = BattleAnimAdjustPanning(panningArg); + + taskId = CreateTask(Task_WaitAndPlaySE, 1); + gTasks[taskId].tSongId = songId; + gTasks[taskId].tPanning = panning; + gTasks[taskId].tFramesToWait = framesToWait; + + gAnimSoundTaskCount++; + sBattleAnimScriptPtr += 4; +} + +static void Task_WaitAndPlaySE(u8 taskId) +{ + if (gTasks[taskId].tFramesToWait-- <= 0) + { + PlaySE12WithPanning(gTasks[taskId].tSongId, gTasks[taskId].tPanning); + DestroyTask(taskId); + gAnimSoundTaskCount--; + } +} + +#undef tSongId +#undef tPanning +#undef tFramesToWait + +static void ScriptCmd_createsoundtask(void) +{ + TaskFunc func; + u8 numArgs, taskId; + s32 i; + + sBattleAnimScriptPtr++; + func = (TaskFunc)SCRIPT_READ_32(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 4; + numArgs = sBattleAnimScriptPtr[0]; + sBattleAnimScriptPtr++; + for (i = 0; i < numArgs; i++) + { + gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr); + sBattleAnimScriptPtr += 2; + } + taskId = CreateTask(func, 1); + func(taskId); + gAnimSoundTaskCount++; +} + +static void ScriptCmd_waitsound(void) +{ + if (gAnimSoundTaskCount != 0) + { + sSoundAnimFramesToWait = 0; + gAnimFramesToWait = 1; + } + else if (IsSEPlaying()) + { + if (++sSoundAnimFramesToWait > 90) + { + m4aMPlayStop(&gMPlay_SE1); + m4aMPlayStop(&gMPlay_SE2); + sSoundAnimFramesToWait = 0; + } + else + { + gAnimFramesToWait = 1; + } + } + else + { + sSoundAnimFramesToWait = 0; + sBattleAnimScriptPtr++; + gAnimFramesToWait = 0; + } +} + +static void ScriptCmd_jumpargeq(void) +{ + u8 argId; + s16 valueToCheck; + + sBattleAnimScriptPtr++; + argId = sBattleAnimScriptPtr[0]; + valueToCheck = SCRIPT_READ_16(sBattleAnimScriptPtr + 1); + + if (valueToCheck == gBattleAnimArgs[argId]) + sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr + 3); + else + sBattleAnimScriptPtr += 7; +} + +static void ScriptCmd_jumpifcontest(void) +{ + sBattleAnimScriptPtr++; + if (IsContest()) + sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr); + else + sBattleAnimScriptPtr += 4; +} + +static void ScriptCmd_monbgprio_28(void) +{ + u8 wantedBank; + u8 bank; + u8 bankIdentity; + + wantedBank = sBattleAnimScriptPtr[1]; + sBattleAnimScriptPtr += 2; + + if (wantedBank != ANIM_BANK_ATTACKER) + bank = gAnimBankTarget; + else + bank = gAnimBankAttacker; + + bankIdentity = GetBankIdentity(bank); + if (!IsContest() && (bankIdentity == IDENTITY_PLAYER_MON1 || bankIdentity == IDENTITY_OPPONENT_MON2)) + { + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); + SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2); + } +} + +static void ScriptCmd_monbgprio_29(void) +{ + sBattleAnimScriptPtr++; + if (!IsContest()) + { + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); + SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2); + } +} + +static void ScriptCmd_monbgprio_2A(void) +{ + u8 wantedBank; + u8 bankIdentity; + u8 bank; + + wantedBank = sBattleAnimScriptPtr[1]; + sBattleAnimScriptPtr += 2; + if (GetBankSide(gAnimBankAttacker) != GetBankSide(gAnimBankTarget)) + { + if (wantedBank != ANIM_BANK_ATTACKER) + bank = gAnimBankTarget; + else + bank = gAnimBankAttacker; + + bankIdentity = GetBankIdentity(bank); + if (!IsContest() && (bankIdentity == IDENTITY_PLAYER_MON1 || bankIdentity == IDENTITY_OPPONENT_MON2)) + { + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); + SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2); + } + } +} + +static void ScriptCmd_invisible(void) +{ + u8 spriteId; + + spriteId = GetAnimBankSpriteId(sBattleAnimScriptPtr[1]); + if (spriteId != 0xFF) + gSprites[spriteId].invisible = 1; + + sBattleAnimScriptPtr += 2; +} + +static void ScriptCmd_visible(void) +{ + u8 spriteId; + + spriteId = GetAnimBankSpriteId(sBattleAnimScriptPtr[1]); + if (spriteId != 0xFF) + gSprites[spriteId].invisible = 0; + + sBattleAnimScriptPtr += 2; +} + +static void ScriptCmd_doublebattle_2D(void) +{ + u8 wantedBank; + u8 r4; + u8 spriteId; + + wantedBank = sBattleAnimScriptPtr[1]; + sBattleAnimScriptPtr += 2; + if (!IsContest() && IsDoubleBattle() + && GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget)) + { + if (wantedBank == ANIM_BANK_ATTACKER) + { + r4 = sub_80A8364(gAnimBankAttacker); + spriteId = GetAnimBankSpriteId(0); + } + else + { + r4 = sub_80A8364(gAnimBankTarget); + spriteId = GetAnimBankSpriteId(1); + } + if (spriteId != 0xFF) + { + gSprites[spriteId].invisible = FALSE; + if (r4 == 2) + gSprites[spriteId].oam.priority = 3; + + if (r4 == 1) + sub_80A477C(FALSE); + else + sub_80A477C(TRUE); + } + } +} + +static void ScriptCmd_doublebattle_2E(void) +{ + u8 wantedBank; + u8 r4; + u8 spriteId; + + wantedBank = sBattleAnimScriptPtr[1]; + sBattleAnimScriptPtr += 2; + if (!IsContest() && IsDoubleBattle() + && GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget)) + { + if (wantedBank == ANIM_BANK_ATTACKER) + { + r4 = sub_80A8364(gAnimBankAttacker); + spriteId = GetAnimBankSpriteId(0); + } + else + { + r4 = sub_80A8364(gAnimBankTarget); + spriteId = GetAnimBankSpriteId(1); + } + + if (spriteId != 0xFF && r4 == 2) + gSprites[spriteId].oam.priority = 2; + } +} + +static void ScriptCmd_stopsound(void) +{ + m4aMPlayStop(&gMPlay_SE1); + m4aMPlayStop(&gMPlay_SE2); + sBattleAnimScriptPtr++; }