battle 7 is decompiled

This commit is contained in:
DizzyEggg 2017-11-04 16:11:13 +01:00
parent 5243285ab2
commit 6c8155074b
41 changed files with 1607 additions and 3565 deletions

File diff suppressed because it is too large Load Diff

View File

@ -586,8 +586,8 @@ _080A612E:
bx r1 bx r1
thumb_func_end sub_80A60AC thumb_func_end sub_80A60AC
thumb_func_start sub_80A6138 thumb_func_start GetBankSpriteDefault_Y
sub_80A6138: @ 80A6138 GetBankSpriteDefault_Y: @ 80A6138
push {lr} push {lr}
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
@ -597,10 +597,10 @@ sub_80A6138: @ 80A6138
lsrs r0, 24 lsrs r0, 24
pop {r1} pop {r1}
bx r1 bx r1
thumb_func_end sub_80A6138 thumb_func_end GetBankSpriteDefault_Y
thumb_func_start sub_80A614C thumb_func_start GetSubstituteSpriteDefault_Y
sub_80A614C: @ 80A614C GetSubstituteSpriteDefault_Y: @ 80A614C
push {r4,lr} push {r4,lr}
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
@ -633,7 +633,7 @@ _080A6180:
pop {r4} pop {r4}
pop {r1} pop {r1}
bx r1 bx r1
thumb_func_end sub_80A614C thumb_func_end GetSubstituteSpriteDefault_Y
thumb_func_start sub_80A6190 thumb_func_start sub_80A6190
sub_80A6190: @ 80A6190 sub_80A6190: @ 80A6190
@ -5180,7 +5180,7 @@ _080A8412:
adds r0, r6, 0 adds r0, r6, 0
ldr r1, [sp, 0x3C] ldr r1, [sp, 0x3C]
mov r2, r8 mov r2, r8
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
lsls r1, r5, 20 lsls r1, r5, 20
movs r2, 0x80 movs r2, 0x80
lsls r2, 17 lsls r2, 17
@ -5243,7 +5243,7 @@ _080A84B0:
adds r0, r6, 0 adds r0, r6, 0
ldr r1, [sp, 0x3C] ldr r1, [sp, 0x3C]
mov r2, r8 mov r2, r8
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
lsls r1, r5, 20 lsls r1, r5, 20
movs r3, 0x80 movs r3, 0x80
lsls r3, 17 lsls r3, 17

View File

@ -855,8 +855,8 @@ _080AA352:
.pool .pool
thumb_func_end sub_80AA18C thumb_func_end sub_80AA18C
thumb_func_start move_anim_start_t2 thumb_func_start LaunchStatusAnimation
move_anim_start_t2: @ 80AA364 LaunchStatusAnimation: @ 80AA364
push {r4,lr} push {r4,lr}
adds r4, r0, 0 adds r4, r0, 0
lsls r4, 24 lsls r4, 24
@ -885,7 +885,7 @@ move_anim_start_t2: @ 80AA364
pop {r0} pop {r0}
bx r0 bx r0
.pool .pool
thumb_func_end move_anim_start_t2 thumb_func_end LaunchStatusAnimation
thumb_func_start task0A_80788BC thumb_func_start task0A_80788BC
task0A_80788BC: @ 80AA3B4 task0A_80788BC: @ 80AA3B4

View File

@ -3006,7 +3006,7 @@ _0815B8A8:
lsls r2, 3 lsls r2, 3
adds r2, r3 adds r2, r3
ldrb r2, [r2, 0x1C] ldrb r2, [r2, 0x1C]
bl sub_805E448 bl HandleSpeciesGfxDataChange
ldrb r1, [r5] ldrb r1, [r5]
mov r0, sp mov r0, sp
bl sub_80A6BFC bl sub_80A6BFC
@ -3310,7 +3310,7 @@ sub_815BB58: @ 815BB58
ldr r1, =gAnimBankTarget ldr r1, =gAnimBankTarget
ldrb r1, [r1] ldrb r1, [r1]
movs r2, 0x1 movs r2, 0x1
bl sub_805E448 bl HandleSpeciesGfxDataChange
adds r0, r4, 0 adds r0, r4, 0
bl DestroyAnimVisualTask bl DestroyAnimVisualTask
pop {r4} pop {r4}
@ -10129,7 +10129,7 @@ _0815F2AC:
ldr r4, =gAnimBankAttacker ldr r4, =gAnimBankAttacker
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0 movs r1, 0
bl refresh_graphics_maybe bl LoadBattleMonGfxAndAnimate
bl IsContest bl IsContest
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0

View File

@ -4825,7 +4825,7 @@ _08172CC8:
ldrb r1, [r5, 0x1E] ldrb r1, [r5, 0x1E]
adds r0, r2, 0 adds r0, r2, 0
adds r2, r6, 0 adds r2, r6, 0
bl refresh_graphics_maybe bl LoadBattleMonGfxAndAnimate
ldrh r0, [r5, 0x1C] ldrh r0, [r5, 0x1C]
adds r0, 0x1 adds r0, 0x1
strh r0, [r5, 0x1C] strh r0, [r5, 0x1C]
@ -5030,7 +5030,7 @@ _08172E4E:
movs r3, 0x1 movs r3, 0x1
bl RequestDma3Fill bl RequestDma3Fill
ldrb r0, [r4] ldrb r0, [r4]
bl sub_805E974 bl ClearBehindSubstituteBit
adds r0, r5, 0 adds r0, r5, 0
bl DestroyAnimVisualTask bl DestroyAnimVisualTask
_08172E84: _08172E84:

View File

@ -6763,7 +6763,7 @@ _080DB1CC:
adds r0, r5, 0 adds r0, r5, 0
adds r1, r7, 0 adds r1, r7, 0
adds r2, r6, 0 adds r2, r6, 0
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
movs r1, 0x90 movs r1, 0x90
lsls r1, 1 lsls r1, 1
movs r2, 0x20 movs r2, 0x20

View File

@ -572,7 +572,7 @@ sub_81302E8: @ 81302E8
ldr r1, [r0, 0x4] ldr r1, [r0, 0x4]
ldr r2, [r0] ldr r2, [r0]
adds r0, r5, 0 adds r0, r5, 0
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
ldr r7, =gUnknown_030061C4 ldr r7, =gUnknown_030061C4
ldr r1, [r7] ldr r1, [r7]
bl LZDecompressVram bl LZDecompressVram

View File

@ -69004,7 +69004,7 @@ _0802CA32:
ldrh r0, [r7] ldrh r0, [r7]
ldr r1, [r7, 0x4] ldr r1, [r7, 0x4]
ldr r2, [r7, 0x8] ldr r2, [r7, 0x8]
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
str r0, [sp, 0x20] str r0, [sp, 0x20]
add r0, sp, 0x20 add r0, sp, 0x20
ldr r1, [r0, 0x4] ldr r1, [r0, 0x4]

View File

@ -936,7 +936,7 @@ _08075B9E:
.pool .pool
_08075BB4: _08075BB4:
adds r0, r3, 0 adds r0, r3, 0
bl sub_805F110 bl ShouldPlayNormalPokeCry
cmp r0, 0x1 cmp r0, 0x1
bne _08075BCC bne _08075BCC
lsls r1, r5, 24 lsls r1, r5, 24
@ -976,7 +976,7 @@ _08075BF8:
cmp r0, 0 cmp r0, 0
bne _08075CBA bne _08075CBA
adds r0, r3, 0 adds r0, r3, 0
bl sub_805F110 bl ShouldPlayNormalPokeCry
cmp r0, 0x1 cmp r0, 0x1
bne _08075C22 bne _08075C22
lsls r1, r5, 24 lsls r1, r5, 24
@ -1066,7 +1066,7 @@ _08075CBA:
b _08075D04 b _08075D04
_08075CC0: _08075CC0:
adds r0, r3, 0 adds r0, r3, 0
bl sub_805F110 bl ShouldPlayNormalPokeCry
cmp r0, 0x1 cmp r0, 0x1
bne _08075CD8 bne _08075CD8
lsls r1, r5, 24 lsls r1, r5, 24

View File

@ -8824,7 +8824,7 @@ _080C0168:
adds r3, r5 adds r3, r5
ldrb r4, [r3, 0x5] ldrb r4, [r3, 0x5]
lsrs r4, 4 lsrs r4, 4
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
lsls r4, 4 lsls r4, 4
movs r2, 0x80 movs r2, 0x80
lsls r2, 1 lsls r2, 1

View File

@ -14656,7 +14656,7 @@ _080CEC86:
adds r1, r3 adds r1, r3
str r0, [r1] str r0, [r1]
adds r0, r6, 0 adds r0, r6, 0
bl pokemon_get_pal bl GetMonFrontSpritePal
ldr r1, [r4] ldr r1, [r4]
ldr r2, =0x00000cdc ldr r2, =0x00000cdc
adds r1, r2 adds r1, r2
@ -14759,7 +14759,7 @@ _080CED7E:
adds r1, r4 adds r1, r4
ldrh r0, [r1] ldrh r0, [r1]
mov r1, r9 mov r1, r9
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
ldr r1, [r5] ldr r1, [r5]
ldr r3, =0x00000cdc ldr r3, =0x00000cdc
adds r2, r1, r3 adds r2, r1, r3

View File

@ -1116,7 +1116,7 @@ sub_81C4778: @ 81C4778
bne _081C47AE bne _081C47AE
adds r0, r1, 0 adds r0, r1, 0
adds r0, 0xC adds r0, 0xC
bl sub_805F110 bl ShouldPlayNormalPokeCry
cmp r0, 0x1 cmp r0, 0x1
bne _081C47A4 bne _081C47A4
ldrh r0, [r4, 0x2] ldrh r0, [r4, 0x2]

View File

@ -13532,7 +13532,7 @@ _081CDBD0:
adds r0, r4, 0 adds r0, r4, 0
mov r1, r8 mov r1, r8
adds r2, r5, 0 adds r2, r5, 0
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
mov r2, r9 mov r2, r9
lsls r1, r2, 7 lsls r1, r2, 7
adds r1, r7, r1 adds r1, r7, r1
@ -24408,7 +24408,7 @@ _081D30C4:
adds r0, r4, 0 adds r0, r4, 0
adds r1, r6, 0 adds r1, r6, 0
adds r2, r5, 0 adds r2, r5, 0
bl species_and_otid_get_pal bl GetFrontSpritePalFromSpeciesAndPersonality
mov r1, r9 mov r1, r9
bl LZ77UnCompWram bl LZ77UnCompWram
_081D311A: _081D311A:

View File

@ -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

View File

@ -149,13 +149,13 @@ gUnknown_08C2A6D4:: @ 8C2A6D4
gUnknown_08C2A6EC:: @ 8C2A6EC gUnknown_08C2A6EC:: @ 8C2A6EC
.incbin "baserom.gba", 0xc2a6ec, 0x27d0 .incbin "baserom.gba", 0xc2a6ec, 0x27d0
gUnknown_08C2CEBC:: @ 8C2CEBC gSubstituteDollPal:: @ 8C2CEBC
.incbin "baserom.gba", 0xc2cebc, 0x24 .incbin "baserom.gba", 0xc2cebc, 0x24
gUnknown_08C2CEE0:: @ 8C2CEE0 gSubstituteDollGfx:: @ 8C2CEE0
.incbin "baserom.gba", 0xc2cee0, 0x240 .incbin "baserom.gba", 0xc2cee0, 0x240
gUnknown_08C2D120:: @ 8C2D120 gSubstituteDollTilemap:: @ 8C2D120
.incbin "baserom.gba", 0xc2d120, 0x600 .incbin "baserom.gba", 0xc2d120, 0x600
gUnknown_08C2D720:: @ 8C2D720 gUnknown_08C2D720:: @ 8C2D720

View File

@ -52,7 +52,7 @@ gUnknown_0831C688:: @ 831C688
spr_template 0xd6eb, 0xd6eb, gUnknown_0831C630, gUnknown_0831C678, NULL, gDummySpriteAffineAnimTable, sub_80753B4 spr_template 0xd6eb, 0xd6eb, gUnknown_0831C630, gUnknown_0831C678, NULL, gDummySpriteAffineAnimTable, sub_80753B4
.align 2 .align 2
gUnknown_0831C6A0:: @ 831C6A0 gSpriteSheet_EnemyShadow:: @ 831C6A0
obj_tiles gUnknown_08D8FBC0, 0x0080, 0xd759 obj_tiles gUnknown_08D8FBC0, 0x0080, 0xd759
.align 2 .align 2
@ -60,5 +60,5 @@ gUnknown_0831C6A8:: @ 831C6A8
.byte 0x00, 0x40, 0x00, 0x40, 0x00, 0x0c, 0x00, 0x00 .byte 0x00, 0x40, 0x00, 0x40, 0x00, 0x0c, 0x00, 0x00
.align 2 .align 2
gUnknown_0831C6B0:: @ 831C6B0 gSpriteTemplate_EnemyShadow:: @ 831C6B0
spr_template 0xd759, 0xd6ff, gUnknown_0831C6A8, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_805EE48 spr_template 0xd759, 0xd6ff, gUnknown_0831C6A8, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCB_SetInvisible

View File

@ -6,6 +6,7 @@
#include "battle_script_commands.h" #include "battle_script_commands.h"
#include "battle_2.h" #include "battle_2.h"
#include "battle_ai_switch_items.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'. 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 fillerDC[0xDF-0xDC];
u8 field_DF; u8 field_DF;
u8 mirrorMoveArrays[32]; u8 mirrorMoveArrays[32];
u16 castformPalette[4][16]; u16 castformPalette[BATTLE_BANKS_COUNT][16];
u8 field_180; u8 field_180;
u8 field_181; u8 field_181;
u8 field_182; u8 field_182;
@ -807,6 +808,18 @@ extern struct BattleStruct* gBattleStruct;
#define B_ANIM_SUBSTITUTE_TO_MON 0x5 #define B_ANIM_SUBSTITUTE_TO_MON 0x5
#define B_ANIM_MON_TO_SUBSTITUTE 0x6 #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_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40 #define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit #define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
@ -864,43 +877,6 @@ void AdjustFriendshipOnBattleFaint(u8 bank);
void sub_80571DC(u8 bank, u8 arg1); void sub_80571DC(u8 bank, u8 arg1);
u32 sub_805725C(u8 bank); 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 enum
{ {
BACK_PIC_BRENDAN, BACK_PIC_BRENDAN,
@ -921,7 +897,7 @@ u8 GetBankByIdentity(u8 bank);
struct BattleSpriteInfo struct BattleSpriteInfo
{ {
u16 invisible : 1; // 0x1 u16 invisible : 1; // 0x1
u16 flag_x2 : 1; // 0x2 u16 lowHpSong : 1; // 0x2
u16 behindSubstitute : 1; // 0x4 u16 behindSubstitute : 1; // 0x4
u16 flag_x8 : 1; // 0x8 u16 flag_x8 : 1; // 0x8
u16 hpNumbersNoBars : 1; // 0x10 u16 hpNumbersNoBars : 1; // 0x10
@ -930,7 +906,7 @@ struct BattleSpriteInfo
struct BattleAnimationInfo struct BattleAnimationInfo
{ {
u16 field; // to fill up later u16 animArg; // to fill up later
u8 field_2; u8 field_2;
u8 field_3; u8 field_3;
u8 field_4; u8 field_4;
@ -972,7 +948,7 @@ struct BattleHealthboxInfo
u8 animationState; u8 animationState;
u8 field_5; u8 field_5;
u8 field_6; u8 field_6;
u8 field_7; u8 shadowSpriteId;
u8 field_8; u8 field_8;
u8 field_9; u8 field_9;
u8 field_A; u8 field_A;
@ -1012,8 +988,11 @@ struct MonSpritesGfx
void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon
void* sprites[4]; void* sprites[4];
struct SpriteTemplate templates[4]; struct SpriteTemplate templates[4];
u8 field_74[0x100]; struct SpriteFrameImage field_74[4][4];
u8 *fontPixels; u8 field_F4[0x80];
u8 *barFontGfx;
void *field_178;
void *field_17C;
}; };
extern struct BattleSpritesGfx* gMonSpritesGfx; extern struct BattleSpritesGfx* gMonSpritesGfx;

View File

@ -92,7 +92,11 @@ u8 sub_80A6D94(void);
u8 sub_80A8364(u8); u8 sub_80A8364(u8);
void StoreSpriteCallbackInData6(struct Sprite *sprite, void (*spriteCallback)(struct Sprite*)); void StoreSpriteCallbackInData6(struct Sprite *sprite, void (*spriteCallback)(struct Sprite*));
void oamt_add_pos2_onto_pos1(struct Sprite *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 sub_80A82E4(u8 bank);
u8 GetSubstituteSpriteDefault_Y(u8 bank);
// battle_anim_80A9C70.s
void LaunchStatusAnimation(u8 bank, u8 statusAnimId);
#endif // GUARD_BATTLE_ANIM_H #endif // GUARD_BATTLE_ANIM_H

View File

@ -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

View File

@ -15,6 +15,15 @@ enum
EXP_BAR 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_PLAYER1_TILE 0xD6FF
#define TAG_HEALTHBOX_PLAYER2_TILE 0xD700 #define TAG_HEALTHBOX_PLAYER2_TILE 0xD700
#define TAG_HEALTHBOX_OPPONENT1_TILE 0xD701 #define TAG_HEALTHBOX_OPPONENT1_TILE 0xD701

View File

@ -20,6 +20,12 @@ struct ContestStruct_field_18
{ {
// unknown size // unknown size
u16 field_0; u16 field_0;
u16 field_2;
u16 field_4;
u16 field_6;
u32 field_8;
u32 field_C;
u32 field_10;
}; };
struct ContestResources struct ContestResources

View File

@ -3,6 +3,8 @@
#include "sprite.h" #include "sprite.h"
extern u8 gDecompressionBuffer[0x4000];
void LZDecompressWram(const void *src, void *dest); void LZDecompressWram(const void *src, void *dest);
void LZDecompressVram(const void *src, void *dest); void LZDecompressVram(const void *src, void *dest);

View File

@ -612,8 +612,8 @@ u32 CanMonLearnTMHM(struct Pokemon *, u8);
u32 CanSpeciesLearnTMHM(u16 species, u8 tm); u32 CanSpeciesLearnTMHM(u16 species, u8 tm);
u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves); u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves);
void ClearBattleMonForms(void); void ClearBattleMonForms(void);
const u8 *pokemon_get_pal(struct Pokemon *mon); const u8 *GetMonFrontSpritePal(struct Pokemon *mon);
const u8 *species_and_otid_get_pal(u16, u32, u32); const u8 *GetFrontSpritePalFromSpeciesAndPersonality(u16, u32, u32);
const struct CompressedSpritePalette *sub_80409C8(u16, u32, u32); const struct CompressedSpritePalette *sub_80409C8(u16, u32, u32);
bool8 IsOtherTrainer(u32, u8 *); bool8 IsOtherTrainer(u32, u8 *);
void SetWildMonHeldItem(void); void SetWildMonHeldItem(void);

View File

@ -62,8 +62,7 @@ SECTIONS {
src/battle_script_commands.o(.text); src/battle_script_commands.o(.text);
asm/battle_5.o(.text); asm/battle_5.o(.text);
src/battle_controller_player.o(.text); src/battle_controller_player.o(.text);
src/battle_7.o(.text); src/battle_gfx_sfx_util.o(.text);
asm/battle_7.o(.text);
src/battle_controller_opponent.o(.text); src/battle_controller_opponent.o(.text);
src/battle_ai_switch_items.o(.text); src/battle_ai_switch_items.o(.text);
src/battle_controller_link_opponent.o(.text); src/battle_controller_link_opponent.o(.text);
@ -345,7 +344,7 @@ SECTIONS {
src/util.o(.rodata); src/util.o(.rodata);
data/daycare.o(.rodata); data/daycare.o(.rodata);
src/egg_hatch.o(.rodata); src/egg_hatch.o(.rodata);
data/battle_7.o(.rodata); src/battle_gfx_sfx_util.o(.rodata);
src/battle_interface.o(.rodata); src/battle_interface.o(.rodata);
data/pokeball.o(.rodata); data/pokeball.o(.rodata);
data/trade.o(.rodata); data/trade.o(.rodata);

View File

@ -4767,7 +4767,7 @@ static void HandleEndTurn_BattleWon(void)
else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER
&& gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000 | BATTLE_TYPE_EREADER_TRAINER)) && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000 | BATTLE_TYPE_EREADER_TRAINER))
{ {
BattleMusicStop(); BattleStopLowHpSound();
gBattlescriptCurrInstr = BattleScript_FrontierTrainerBattleWon; gBattlescriptCurrInstr = BattleScript_FrontierTrainerBattleWon;
if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_3FE) 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)) else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & BATTLE_TYPE_LINK))
{ {
BattleMusicStop(); BattleStopLowHpSound();
gBattlescriptCurrInstr = BattleScript_LocalTrainerBattleWon; gBattlescriptCurrInstr = BattleScript_LocalTrainerBattleWon;
switch (gTrainers[gTrainerBattleOpponent_A].trainerClass) switch (gTrainers[gTrainerBattleOpponent_A].trainerClass)

View File

@ -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;
}

View File

@ -449,7 +449,7 @@ static void sub_8064C58(void)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank); EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
@ -485,7 +485,7 @@ static void sub_8064D60(void)
if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleBankFunc[gActiveBank] = sub_8064DD0;
} }
@ -1164,7 +1164,7 @@ static void LinkOpponentHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2), sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank), GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank)); sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
@ -1198,7 +1198,7 @@ static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite( gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
sub_80A5C6C(bank, 2), sub_80A5C6C(bank, 2),
sub_80A6138(bank), GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@ -1227,7 +1227,7 @@ static void LinkOpponentHandleReturnMonToBall(void)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank); EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
@ -1239,7 +1239,7 @@ static void DoSwitchOutAnimation(void)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1247,7 +1247,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; 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; gBattleBankFunc[gActiveBank] = sub_8064C58;
} }
break; break;
@ -1382,7 +1382,7 @@ static void LinkOpponentHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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++; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
} }
else else
@ -1455,7 +1455,7 @@ static void LinkOpponentDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1474,7 +1474,7 @@ static void LinkOpponentDoMoveAnimation(void)
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) 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->bankData[gActiveBank].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@ -1483,7 +1483,7 @@ static void LinkOpponentDoMoveAnimation(void)
case 3: case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
sub_805E394(); CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
@ -1586,7 +1586,7 @@ static void LinkOpponentHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBank)) 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)); gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
} }
@ -1698,7 +1698,7 @@ static void LinkOpponentHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -1850,7 +1850,7 @@ static void LinkOpponentHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -312,7 +312,7 @@ static void CompleteOnHealthbarDone(void)
} }
else else
{ {
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
} }
@ -373,7 +373,7 @@ static void sub_814B4E0(void)
{ {
CopyBattleSpriteInvisibility(gActiveBank); CopyBattleSpriteInvisibility(gActiveBank);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleBankFunc[gActiveBank] = sub_814B554;
} }
@ -399,7 +399,7 @@ static void sub_814B5A8(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10); CreateTask(c3_0802FDF4, 10);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL);
sub_8076918(gActiveBank); sub_8076918(gActiveBank);
@ -1026,7 +1026,7 @@ static void SetLinkPartnerMonData(u8 monId)
break; break;
} }
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
} }
static void LinkPartnerHandleSetRawMonData(void) static void LinkPartnerHandleSetRawMonData(void)
@ -1050,7 +1050,7 @@ static void LinkPartnerHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2), sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank), GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank)); sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank; gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank;
@ -1081,7 +1081,7 @@ static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite( gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
sub_80A5C6C(bank, 2), sub_80A5C6C(bank, 2),
sub_80A6138(bank), GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@ -1121,7 +1121,7 @@ static void DoSwitchOutAnimation(void)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1129,7 +1129,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; 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; gBattleBankFunc[gActiveBank] = sub_814B3DC;
} }
break; break;
@ -1201,7 +1201,7 @@ static void LinkPartnerHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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++; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
} }
else else
@ -1209,7 +1209,7 @@ static void LinkPartnerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER);
gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; gSprites[gBankSpriteIds[gActiveBank]].data1 = 0;
gSprites[gBankSpriteIds[gActiveBank]].data2 = 5; gSprites[gBankSpriteIds[gActiveBank]].data2 = 5;
@ -1277,7 +1277,7 @@ static void LinkPartnerDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1296,7 +1296,7 @@ static void LinkPartnerDoMoveAnimation(void)
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) 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->bankData[gActiveBank].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@ -1305,7 +1305,7 @@ static void LinkPartnerDoMoveAnimation(void)
case 3: case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
sub_805E394(); CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
@ -1408,7 +1408,7 @@ static void LinkPartnerHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBank)) 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)); gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
} }
@ -1520,7 +1520,7 @@ static void LinkPartnerHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -1683,7 +1683,7 @@ static void LinkPartnerHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -437,7 +437,7 @@ static void sub_805FB08(void)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank); EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
@ -473,7 +473,7 @@ static void sub_805FC10(void)
if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleBankFunc[gActiveBank] = sub_805FC80;
} }
} }
@ -1152,7 +1152,7 @@ static void OpponentHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2), sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank), GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank)); sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
@ -1187,7 +1187,7 @@ static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(bank, 2), sub_80A5C6C(bank, 2),
sub_80A6138(bank), GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gBankSpriteIds[bank]].data0 = bank; gSprites[gBankSpriteIds[bank]].data0 = bank;
@ -1217,7 +1217,7 @@ static void OpponentHandleReturnMonToBall(void)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank); EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
@ -1229,7 +1229,7 @@ static void DoSwitchOutAnimation(void)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1237,7 +1237,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; 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; gBattleBankFunc[gActiveBank] = sub_805FB08;
} }
break; break;
@ -1415,7 +1415,7 @@ static void OpponentHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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++; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
} }
else else
@ -1487,7 +1487,7 @@ static void OpponentDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1506,7 +1506,7 @@ static void OpponentDoMoveAnimation(void)
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) 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->bankData[gActiveBank].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@ -1515,7 +1515,7 @@ static void OpponentDoMoveAnimation(void)
case 3: case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
sub_805E394(); CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
@ -1731,7 +1731,7 @@ static void OpponentHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBank)) 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)); gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
} }
@ -1843,7 +1843,7 @@ static void OpponentHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -2000,7 +2000,7 @@ static void OpponentHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -1008,10 +1008,10 @@ static void sub_805896C(void)
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
if (IsDoubleBattle()) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3;
gBattleBankFunc[gActiveBank] = sub_8058924; gBattleBankFunc[gActiveBank] = sub_8058924;
@ -1107,7 +1107,7 @@ static void sub_8058EDC(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleBankFunc[gActiveBank] = sub_8058FC0;
} }
@ -1119,7 +1119,7 @@ static void sub_8058FC0(void)
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
{ {
m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100); m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
} }
@ -1164,7 +1164,7 @@ static void CompleteOnHealthbarDone(void)
} }
else else
{ {
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
} }
@ -1305,7 +1305,7 @@ static void sub_8059544(u8 taskId)
if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON]) if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON])
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; gTasks[taskId].func = sub_80595A4;
} }
@ -2193,7 +2193,7 @@ static void SetPlayerMonData(u8 monId)
break; break;
} }
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
} }
static void PlayerHandleSetRawMonData(void) static void PlayerHandleSetRawMonData(void)
@ -2238,7 +2238,7 @@ static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite( gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
sub_80A5C6C(bank, 2), sub_80A5C6C(bank, 2),
sub_80A6138(bank), GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@ -2278,7 +2278,7 @@ static void DoSwitchOutAnimation(void)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -2286,7 +2286,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; 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; gBattleBankFunc[gActiveBank] = sub_8059744;
} }
break; break;
@ -2434,7 +2434,7 @@ static void PlayerHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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++; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
} }
else else
@ -2442,7 +2442,7 @@ static void PlayerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER);
gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; gSprites[gBankSpriteIds[gActiveBank]].data1 = 0;
gSprites[gBankSpriteIds[gActiveBank]].data2 = 5; gSprites[gBankSpriteIds[gActiveBank]].data2 = 5;
@ -2462,7 +2462,7 @@ static void PlayerHandleSuccessBallThrowAnim(void)
{ {
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE; 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; gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
} }
@ -2472,7 +2472,7 @@ static void PlayerHandleBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE; 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; gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
} }
@ -2525,7 +2525,7 @@ static void PlayerDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -2544,7 +2544,7 @@ static void PlayerDoMoveAnimation(void)
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) 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->bankData[gActiveBank].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@ -2553,7 +2553,7 @@ static void PlayerDoMoveAnimation(void)
case 3: case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
sub_805E394(); CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
@ -2709,7 +2709,7 @@ static void PlayerHandleChoosePokemon(void)
static void PlayerHandleCmd23(void) static void PlayerHandleCmd23(void)
{ {
BattleMusicStop(); BattleStopLowHpSound();
BeginNormalPaletteFade(-1, 2, 0, 16, 0); BeginNormalPaletteFade(-1, 2, 0, 16, 0);
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
@ -2788,7 +2788,7 @@ static void PlayerHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBank)) 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)); gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
} }
@ -2930,7 +2930,7 @@ static void PlayerHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -3088,7 +3088,7 @@ static void PlayerHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -327,7 +327,7 @@ static void CompleteOnHealthbarDone(void)
} }
else else
{ {
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
} }
@ -469,7 +469,7 @@ static void sub_81BB628(u8 taskId)
if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON]) if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON])
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; gTasks[taskId].func = sub_81BB688;
} }
@ -560,7 +560,7 @@ static void sub_81BB92C(void)
{ {
CopyBattleSpriteInvisibility(gActiveBank); CopyBattleSpriteInvisibility(gActiveBank);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleBankFunc[gActiveBank] = sub_81BB9A0;
} }
@ -586,7 +586,7 @@ static void sub_81BB9F4(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10); CreateTask(c3_0802FDF4, 10);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL);
sub_8076918(gActiveBank); sub_8076918(gActiveBank);
@ -1213,7 +1213,7 @@ static void SetPlayerPartnerMonData(u8 monId)
break; break;
} }
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
} }
static void PlayerPartnerHandleSetRawMonData(void) static void PlayerPartnerHandleSetRawMonData(void)
@ -1237,7 +1237,7 @@ static void PlayerPartnerHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2), sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank), GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank)); sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank; gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank;
@ -1268,7 +1268,7 @@ static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite( gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
sub_80A5C6C(bank, 2), sub_80A5C6C(bank, 2),
sub_80A6138(bank), GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@ -1308,7 +1308,7 @@ static void DoSwitchOutAnimation(void)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1316,7 +1316,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; 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; gBattleBankFunc[gActiveBank] = sub_81BB828;
} }
break; break;
@ -1395,7 +1395,7 @@ static void PlayerPartnerHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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++; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
} }
else else
@ -1403,7 +1403,7 @@ static void PlayerPartnerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER);
gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; gSprites[gBankSpriteIds[gActiveBank]].data1 = 0;
gSprites[gBankSpriteIds[gActiveBank]].data2 = 5; gSprites[gBankSpriteIds[gActiveBank]].data2 = 5;
@ -1470,7 +1470,7 @@ static void PlayerPartnerDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1489,7 +1489,7 @@ static void PlayerPartnerDoMoveAnimation(void)
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) 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->bankData[gActiveBank].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@ -1498,7 +1498,7 @@ static void PlayerPartnerDoMoveAnimation(void)
case 3: case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
sub_805E394(); CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
@ -1661,7 +1661,7 @@ static void PlayerPartnerHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBank)) 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)); gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
} }
@ -1773,7 +1773,7 @@ static void PlayerPartnerHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -1929,7 +1929,7 @@ static void PlayerPartnerHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -433,7 +433,7 @@ static void sub_8186D9C(void)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank); EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
@ -469,7 +469,7 @@ static void sub_8186EA4(void)
if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleBankFunc[gActiveBank] = sub_8186F14;
} }
@ -1149,7 +1149,7 @@ static void RecordedOpponentHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2), sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank), GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank)); sub_80A82E4(gActiveBank));
@ -1184,7 +1184,7 @@ static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(bank, 2), sub_80A5C6C(bank, 2),
sub_80A6138(bank), GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@ -1213,7 +1213,7 @@ static void RecordedOpponentHandleReturnMonToBall(void)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]);
sub_805EEE0(gActiveBank); EnemyShadowCallbackToSetInvisible(gActiveBank);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
@ -1225,7 +1225,7 @@ static void DoSwitchOutAnimation(void)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1233,7 +1233,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; 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; gBattleBankFunc[gActiveBank] = sub_8186D9C;
} }
break; break;
@ -1314,7 +1314,7 @@ static void RecordedOpponentHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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++; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
} }
else else
@ -1386,7 +1386,7 @@ static void RecordedOpponentDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1405,7 +1405,7 @@ static void RecordedOpponentDoMoveAnimation(void)
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) 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->bankData[gActiveBank].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@ -1414,7 +1414,7 @@ static void RecordedOpponentDoMoveAnimation(void)
case 3: case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
sub_805E394(); CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
@ -1530,7 +1530,7 @@ static void RecordedOpponentHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBank)) 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)); gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
} }
@ -1642,7 +1642,7 @@ static void RecordedOpponentHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -1794,7 +1794,7 @@ static void RecordedOpponentHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -272,9 +272,9 @@ static void sub_8189AA0(void)
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
if (IsDoubleBattle()) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3;
gBattleBankFunc[gActiveBank] = sub_8189A58; gBattleBankFunc[gActiveBank] = sub_8189A58;
@ -397,7 +397,7 @@ static void CompleteOnHealthbarDone(void)
} }
else else
{ {
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -458,7 +458,7 @@ static void sub_818A2B4(void)
{ {
CopyBattleSpriteInvisibility(gActiveBank); CopyBattleSpriteInvisibility(gActiveBank);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleBankFunc[gActiveBank] = sub_818A328;
} }
@ -484,7 +484,7 @@ static void sub_818A37C(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10); CreateTask(c3_0802FDF4, 10);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL);
sub_8076918(gActiveBank); sub_8076918(gActiveBank);
@ -1111,7 +1111,7 @@ static void SetRecordedPlayerMonData(u8 monId)
break; break;
} }
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
} }
static void RecordedPlayerHandleSetRawMonData(void) static void RecordedPlayerHandleSetRawMonData(void)
@ -1135,7 +1135,7 @@ static void RecordedPlayerHandleLoadMonSprite(void)
gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(gActiveBank, 2), sub_80A5C6C(gActiveBank, 2),
sub_80A6138(gActiveBank), GetBankSpriteDefault_Y(gActiveBank),
sub_80A82E4(gActiveBank)); sub_80A82E4(gActiveBank));
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank; gSprites[gBankSpriteIds[gActiveBank]].data0 = gActiveBank;
@ -1166,7 +1166,7 @@ static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit)
gBankSpriteIds[bank] = CreateSprite( gBankSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
sub_80A5C6C(bank, 2), sub_80A5C6C(bank, 2),
sub_80A6138(bank), GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@ -1206,7 +1206,7 @@ static void DoSwitchOutAnimation(void)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1214,7 +1214,7 @@ static void DoSwitchOutAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; 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; gBattleBankFunc[gActiveBank] = sub_818A1B0;
} }
break; break;
@ -1313,7 +1313,7 @@ static void RecordedPlayerHandleFaintAnimation(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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++; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++;
} }
else else
@ -1321,7 +1321,7 @@ static void RecordedPlayerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
PlaySE12WithPanning(SE_POKE_DEAD, -64); PlaySE12WithPanning(SE_POKE_DEAD, -64);
gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; gSprites[gBankSpriteIds[gActiveBank]].data1 = 0;
gSprites[gBankSpriteIds[gActiveBank]].data2 = 5; gSprites[gBankSpriteIds[gActiveBank]].data2 = 5;
@ -1388,7 +1388,7 @@ static void RecordedPlayerDoMoveAnimation(void)
&& !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1407,7 +1407,7 @@ static void RecordedPlayerDoMoveAnimation(void)
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) 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->bankData[gActiveBank].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
@ -1416,7 +1416,7 @@ static void RecordedPlayerDoMoveAnimation(void)
case 3: case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
sub_805E394(); CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
@ -1549,7 +1549,7 @@ static void RecordedPlayerHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBank)) 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)); gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24));
gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation;
} }
@ -1661,7 +1661,7 @@ static void RecordedPlayerHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -1813,7 +1813,7 @@ static void RecordedPlayerHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -413,7 +413,7 @@ static void SafariHandleSuccessBallThrowAnim(void)
{ {
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE; 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; gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
} }
@ -423,7 +423,7 @@ static void SafariHandleBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE; 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; gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
} }
@ -624,7 +624,7 @@ static void SafariHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -683,7 +683,7 @@ static void SafariHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
SafariBufferExecCompleted(); SafariBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -369,7 +369,7 @@ static void sub_8168818(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10); CreateTask(c3_0802FDF4, 10);
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
@ -387,7 +387,7 @@ static void CompleteOnHealthbarDone(void)
} }
else else
{ {
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
} }
@ -1029,7 +1029,7 @@ static void SetWallyMonData(u8 monId)
break; break;
} }
sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
} }
static void WallyHandleSetRawMonData(void) static void WallyHandleSetRawMonData(void)
@ -1051,7 +1051,7 @@ static void WallyHandleReturnMonToBall(void)
{ {
if (gBattleBufferA[gActiveBank][1] == 0) 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; gBattleBankFunc[gActiveBank] = sub_8168A20;
} }
else else
@ -1112,7 +1112,7 @@ static void WallyHandleSuccessBallThrowAnim(void)
{ {
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE; 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; gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation;
} }
@ -1122,7 +1122,7 @@ static void WallyHandleBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE; 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; gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation;
} }
@ -1163,7 +1163,7 @@ static void WallyDoMoveAnimation(void)
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1;
break; break;
@ -1182,7 +1182,7 @@ static void WallyDoMoveAnimation(void)
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) 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; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3;
} }
@ -1190,7 +1190,7 @@ static void WallyDoMoveAnimation(void)
case 3: case 3:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
{ {
sub_805E394(); CopyAllBattleSpritesInvisibilities();
TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0;
WallyBufferExecCompleted(); WallyBufferExecCompleted();
@ -1429,7 +1429,7 @@ static void WallyHandlePlayFanfareOrBGM(void)
{ {
if (gBattleBufferA[gActiveBank][3]) if (gBattleBufferA[gActiveBank][3])
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
} }
else else
@ -1496,7 +1496,7 @@ static void sub_816AA80(u8 bank)
sub_806A068(species, GetBankIdentity(bank)); sub_806A068(species, GetBankIdentity(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
sub_80A5C6C(bank, 2), sub_80A5C6C(bank, 2),
sub_80A6138(bank), GetBankSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data1 = gBankSpriteIds[bank];
@ -1565,7 +1565,7 @@ static void WallyHandleBattleAnimation(void)
u8 animationId = gBattleBufferA[gActiveBank][1]; u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
WallyBufferExecCompleted(); WallyBufferExecCompleted();
else else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;

View File

@ -119,7 +119,7 @@ static void sub_818D0C4(u16 species, u32 otId, u32 personality, u8 paletteSlot,
if (paletteTag == 0xFFFF) if (paletteTag == 0xFFFF)
{ {
gUnknown_0203CCEC.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 else
{ {
@ -146,7 +146,7 @@ static void sub_818D180(u16 species, u32 otId, u32 personality, u8 paletteSlot,
{ {
if (!isTrainer) if (!isTrainer)
{ {
LoadCompressedPalette(species_and_otid_get_pal(species, otId, personality), paletteSlot * 0x10, 0x20); LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), paletteSlot * 0x10, 0x20);
} }
else else
{ {

1299
src/battle_gfx_sfx_util.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2545,19 +2545,19 @@ u8 GetHPBarLevel(s16 hp, s16 maxhp)
if (hp == maxhp) if (hp == maxhp)
{ {
result = 4; result = HP_BAR_FULL;
} }
else else
{ {
u8 fraction = GetScaledHPFraction(hp, maxhp, 48); u8 fraction = GetScaledHPFraction(hp, maxhp, 48);
if (fraction > 24) if (fraction > 24)
result = 3; result = HP_BAR_GREEN;
else if (fraction > 9) else if (fraction > 9)
result = 2; result = HP_BAR_YELLOW;
else if (fraction > 0) else if (fraction > 0)
result = 1; result = HP_BAR_RED;
else else
result = 0; result = HP_BAR_EMPTY;
} }
return result; return result;

View File

@ -1068,22 +1068,33 @@ static const u8 sBallCatchBonuses[] =
20, 15, 10, 15 // Ultra, Great, Poke, Safari 20, 15, 10, 15 // Ultra, Great, Poke, Safari
}; };
// could be a 2d array or a struct const ALIGNED(4) u8 gUnknown_0831C494[][4] =
const ALIGNED(4) u8 gUnknown_0831C494[] =
{ {
0x3d, 0x44, 0x3d, 0x44, 0x14, 0x2d, 0x54, 0x5c, {0x3d, 0x44, 0x3d, 0x44},
0x46, 0x55, 0x20, 0x5c, 0x26, 0x45, 0x46, 0x55, {0x14, 0x2d, 0x54, 0x5c},
0x14, 0x5a, 0x46, 0x5c, 0x1e, 0x32, 0x20, 0x5a, {0x46, 0x55, 0x20, 0x5c},
0x38, 0x4e, 0x38, 0x4e, 0x19, 0x28, 0x4b, 0x5a, {0x26, 0x45, 0x46, 0x55},
0x45, 0x4b, 0x1c, 0x53, 0x23, 0x2d, 0x1d, 0x23, {0x14, 0x5a, 0x46, 0x5c},
0x3e, 0x48, 0x1e, 0x32, 0x3a, 0x5f, 0x58, 0x5e, {0x1e, 0x32, 0x20, 0x5a},
0x22, 0x2d, 0x1d, 0x28, 0x23, 0x28, 0x23, 0x5f, {0x38, 0x4e, 0x38, 0x4e},
0x38, 0x4e, 0x38, 0x4e, 0x23, 0x50, 0x22, 0x5e, {0x19, 0x28, 0x4b, 0x5a},
0x2c, 0x5e, 0x22, 0x28, 0x38, 0x4e, 0x38, 0x4e, {0x45, 0x4b, 0x1c, 0x53},
0x1e, 0x58, 0x1e, 0x58, 0x1e, 0x2b, 0x1b, 0x21, {0x23, 0x2d, 0x1d, 0x23},
0x28, 0x5a, 0x19, 0x57, 0x12, 0x58, 0x5a, 0x5f, {0x3e, 0x48, 0x1e, 0x32},
0x58, 0x5e, 0x16, 0x2a, 0x2a, 0x5c, 0x2a, 0x2f, {0x3a, 0x5f, 0x58, 0x5e},
0x38, 0x4e, 0x38, 0x4e {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[] = static const u8 sUnknown_0831C4F8[] =
@ -3533,7 +3544,7 @@ static void atk23_getexp(void)
// music change in wild battle after fainting a poke // music change in wild battle after fainting a poke
if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) && gBattleMons[0].hp && !gBattleStruct->wildVictorySong) if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) && gBattleMons[0].hp && !gBattleStruct->wildVictorySong)
{ {
BattleMusicStop(); BattleStopLowHpSound();
PlayBGM(0x161); PlayBGM(0x161);
gBattleStruct->wildVictorySong++; 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 (gBattleBufferB[gActiveBank][0] == CONTROLLER_TWORETURNVALUES && gBattleBufferB[gActiveBank][1] == RET_VALUE_LEVELLED_UP)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId) 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) PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBank, gBattleStruct->expGetterId)

View File

@ -1234,12 +1234,12 @@ static void sub_806E6CC(u8 taskId)
DestroyTask(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); u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0);
u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0);
u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 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 // 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 // Extracts the lower 16 bits of a 32-bit number
#define LOHALF(n) ((n) & 0xFFFF) #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; u32 shinyValue;

View File

@ -37,8 +37,8 @@ extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];
extern void dp12_8087EA4(void); extern void dp12_8087EA4(void);
extern void trs_config(void); extern void trs_config(void);
extern bool8 IsDoubleBattle(void); extern bool8 IsDoubleBattle(void);
extern u8 sub_80A614C(u8 bank); extern u8 GetSubstituteSpriteDefault_Y(u8 bank);
extern u8 sub_80A6138(u8 bank); extern u8 GetBankSpriteDefault_Y(u8 bank);
extern u8 sub_80A82E4(u8 bank); extern u8 sub_80A82E4(u8 bank);
extern void sub_806A068(u16 species, u8 bankIdentity); extern void sub_806A068(u16 species, u8 bankIdentity);
extern void sub_806A12C(u16 backPicId, u8 bankIdentity); extern void sub_806A12C(u16 backPicId, u8 bankIdentity);
@ -104,7 +104,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
gReservedSpritePaletteCount = 4; gReservedSpritePaletteCount = 4;
break; break;
case 5: case 5:
sub_805E350(); ClearSpritesHealthboxAnimData();
break; break;
case 6: case 6:
if (BattleLoadAllHealthBoxesGfx(gBattleScripting.reshowHelperState)) if (BattleLoadAllHealthBoxesGfx(gBattleScripting.reshowHelperState))
@ -217,7 +217,7 @@ static bool8 LoadBankSpriteGfx(u8 bank)
if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank);
else else
BattleLoadSubstituteSpriteGfx(bank, FALSE); BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE);
} }
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0)
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, bank); DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, bank);
@ -226,7 +226,7 @@ static bool8 LoadBankSpriteGfx(u8 bank)
else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank);
else else
BattleLoadSubstituteSpriteGfx(bank, FALSE); BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE);
gBattleScripting.reshowHelperState = 0; gBattleScripting.reshowHelperState = 0;
} }
@ -250,9 +250,9 @@ static void CreateBankSprite(u8 bank)
u8 posY; u8 posY;
if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute) if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
posY = sub_80A614C(bank); posY = GetSubstituteSpriteDefault_Y(bank);
else else
posY = sub_80A6138(bank); posY = GetBankSpriteDefault_Y(bank);
if (GetBankSide(bank) != SIDE_PLAYER) if (GetBankSide(bank) != SIDE_PLAYER)
{ {