more of battle anim done

This commit is contained in:
DizzyEggg 2017-10-14 23:37:44 +02:00
parent 752ce9b90d
commit ebb2999c03
19 changed files with 736 additions and 1721 deletions

View File

@ -1424,8 +1424,8 @@ _0803575A:
.pool
thumb_func_end ApplyPlayerChosenFrameToBattleMenu
thumb_func_start load_battle_oval_graphics
load_battle_oval_graphics: @ 8035770
thumb_func_start LoadFittingBackgroundForBattle
LoadFittingBackgroundForBattle: @ 8035770
push {r4,r5,lr}
ldr r0, =gBattleTypeFlags
ldr r1, [r0]
@ -1665,7 +1665,7 @@ _08035A8A:
pop {r0}
bx r0
.pool
thumb_func_end load_battle_oval_graphics
thumb_func_end LoadFittingBackgroundForBattle
thumb_func_start LoadBattleTextboxAndBackground
LoadBattleTextboxAndBackground: @ 8035AA4
@ -1686,7 +1686,7 @@ LoadBattleTextboxAndBackground: @ 8035AA4
movs r2, 0x40
bl LoadCompressedPalette
bl ApplyPlayerChosenFrameToBattleMenu
bl load_battle_oval_graphics
bl LoadFittingBackgroundForBattle
pop {r0}
bx r0
.pool

File diff suppressed because it is too large Load Diff

View File

@ -2640,7 +2640,7 @@ _080FFD56:
cmp r0, 0
bne _080FFD8A
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -2658,7 +2658,7 @@ _080FFD8A:
str r0, [r4, 0x1C]
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -5778,7 +5778,7 @@ _08101604:
adds r0, r1
strh r0, [r5, 0x38]
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -5975,7 +5975,7 @@ _081017A4:
movs r2, 0x4
bl LoadPalette
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -7213,7 +7213,7 @@ sub_810217C: @ 810217C
strh r5, [r4, 0x34]
strh r5, [r4, 0x36]
subs r0, 0x42
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
lsls r0, 24
asrs r0, 24
strh r0, [r4, 0x38]
@ -10604,7 +10604,7 @@ _08103C90:
strh r0, [r4, 0xA]
movs r0, 0x3F
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -11235,7 +11235,7 @@ sub_810421C: @ 810421C
push {r4,lr}
adds r4, r0, 0
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -12986,7 +12986,7 @@ sub_810501C: @ 810501C
adds r0, 0x2
strh r0, [r4, 0x38]
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
lsls r0, 24
asrs r0, 24
strh r0, [r4, 0x3A]
@ -25228,12 +25228,12 @@ _0810B2DC:
movs r0, 0xC
strh r0, [r5, 0x1E]
subs r0, 0x4C
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
lsls r0, 24
asrs r0, 24
strh r0, [r5, 0x20]
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
lsls r0, 24
asrs r0, 24
strh r0, [r5, 0x22]
@ -29951,7 +29951,7 @@ sub_810D984: @ 810D984
strh r0, [r5, 0x34]
ldrh r0, [r1, 0x4]
strh r0, [r5, 0x36]
ldr r0, =gUnknown_02038432
ldr r0, =gAnimMoveTurn
ldrb r6, [r0]
ldrb r0, [r4]
bl GetBankSide
@ -35110,7 +35110,7 @@ _081102B8:
beq _08110360
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -36713,13 +36713,13 @@ _0811101E:
strh r4, [r6, 0x16]
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r4, r0, 0
lsls r4, 24
asrs r4, 8
lsrs r4, 16
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
lsls r0, 24
strh r4, [r6, 0x22]
asrs r0, 24
@ -43629,7 +43629,7 @@ sub_8114960: @ 8114960
push {lr}
lsls r0, 24
lsrs r3, r0, 24
ldr r2, =gUnknown_02038432
ldr r2, =gAnimMoveTurn
ldrb r0, [r2]
cmp r0, 0x1
bhi _08114974
@ -48614,7 +48614,7 @@ _08117280:
bne _081172CC
movs r0, 0x40
negs r0, r0
bl sub_80A5278
bl BattleAnimAdjustPanning2
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -48625,7 +48625,7 @@ _08117280:
_081172CC:
movs r0, 0x40
negs r0, r0
bl sub_80A5278
bl BattleAnimAdjustPanning2
adds r1, r0, 0
lsls r1, 24
asrs r1, 24

View File

@ -1349,7 +1349,7 @@ sub_815AB5C: @ 815AB5C
bne _0815ABBA
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -2004,7 +2004,7 @@ _0815B0BC:
lsrs r4, r0, 24
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -3551,7 +3551,7 @@ _0815BD8E:
strh r0, [r1, 0x8]
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -10271,7 +10271,7 @@ _0815F3CE:
bne _0815F482
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -10341,7 +10341,7 @@ _0815F460:
bne _0815F482
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -10431,7 +10431,7 @@ _0815F520:
cmp r0, 0
blt _0815F61A
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -10460,7 +10460,7 @@ _0815F544:
cmp r1, 0x7F
ble _0815F61A
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -10502,7 +10502,7 @@ _0815F5B4:
cmp r0, 0x8
ble _0815F61A
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -11557,7 +11557,7 @@ _0815FE92:
cmp r1, r0
bne _0815FF2C
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24

View File

@ -22,12 +22,12 @@ sub_8158B30: @ 8158B30
strh r0, [r6, 0xA]
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r5, r0, 0
lsls r4, 24
asrs r4, 24
@ -128,7 +128,7 @@ sub_8158C04: @ 8158C04
movs r0, 0
strh r0, [r4, 0x1C]
movs r0, 0x3F
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
ldrh r0, [r4, 0xA]
lsls r1, 24
@ -175,14 +175,14 @@ mas_80DCF38: @ 8158C58
ldrb r0, [r0, 0x2]
lsls r0, 24
asrs r0, 24
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
lsls r5, 24
asrs r5, 24
adds r0, r5, 0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r5, r0, 0
lsls r4, 24
asrs r4, 24
@ -307,7 +307,7 @@ sub_8158D8C: @ 8158D8C
movs r4, 0
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
lsls r0, 24
lsrs r6, r0, 24
bl IsContest
@ -432,7 +432,7 @@ sub_8158E9C: @ 8158E9C
movs r4, 0
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
lsls r0, 24
lsrs r5, r0, 24
bl IsContest
@ -691,7 +691,7 @@ sub_81590B8: @ 81590B8
strh r1, [r0, 0x1C]
movs r0, 0x40
negs r0, r0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
lsls r0, 24
lsrs r5, r0, 24
bl IsContest
@ -849,7 +849,7 @@ sub_8159210: @ 8159210
ldrb r0, [r0, 0x2]
lsls r0, 24
asrs r0, 24
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -874,7 +874,7 @@ sub_8159244: @ 8159244
ldrb r0, [r0, 0x2]
lsls r0, 24
asrs r0, 24
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r1, r0, 0
lsls r1, 24
asrs r1, 24
@ -906,14 +906,14 @@ sub_8159278: @ 8159278
ldrb r0, [r0]
lsls r0, 24
asrs r0, 24
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
lsls r5, 24
asrs r5, 24
adds r0, r5, 0
bl BattleAnimGetPanControl
bl BattleAnimAdjustPanning
adds r5, r0, 0
lsls r4, 24
asrs r4, 24

View File

@ -4721,7 +4721,7 @@ _08066D32:
ldrb r0, [r0]
lsls r0, 8
orrs r6, r0
ldr r0, =gUnknown_02038432
ldr r0, =gAnimMoveTurn
mov r8, r0
mov r0, r12
adds r0, 0x3

View File

@ -4030,7 +4030,7 @@ _0814D2CE:
ldrb r0, [r0]
lsls r0, 8
orrs r6, r0
ldr r0, =gUnknown_02038432
ldr r0, =gAnimMoveTurn
mov r8, r0
mov r0, r12
adds r0, 0x3

View File

@ -4871,7 +4871,7 @@ _08061C8A:
ldrb r1, [r1]
lsls r1, 8
orrs r0, r1
ldr r5, =gUnknown_02038432
ldr r5, =gAnimMoveTurn
mov r1, r12
adds r1, 0x3
adds r2, r1

View File

@ -8134,7 +8134,7 @@ _0805BCBE:
ldrb r0, [r0]
lsls r0, 8
orrs r6, r0
ldr r0, =gUnknown_02038432
ldr r0, =gAnimMoveTurn
mov r8, r0
mov r0, r12
adds r0, 0x3

View File

@ -4652,7 +4652,7 @@ _081BD7A2:
ldrb r1, [r1]
lsls r1, 8
orrs r0, r1
ldr r5, =gUnknown_02038432
ldr r5, =gAnimMoveTurn
mov r1, r12
adds r1, 0x3
adds r2, r1

View File

@ -4408,7 +4408,7 @@ _08188BE6:
ldrb r1, [r1]
lsls r1, 8
orrs r0, r1
ldr r5, =gUnknown_02038432
ldr r5, =gAnimMoveTurn
mov r1, r12
adds r1, 0x3
adds r2, r1

View File

@ -4508,7 +4508,7 @@ _0818C192:
ldrb r1, [r1]
lsls r1, 8
orrs r0, r1
ldr r5, =gUnknown_02038432
ldr r5, =gAnimMoveTurn
mov r1, r12
adds r1, 0x3
adds r2, r1

View File

@ -3316,7 +3316,7 @@ sub_816A144: @ 816A144
ldrb r1, [r1]
lsls r1, 8
orrs r0, r1
ldr r5, =gUnknown_02038432
ldr r5, =gAnimMoveTurn
mov r1, r12
adds r1, 0x3
adds r2, r1

View File

@ -76,8 +76,8 @@ sub_80D7678: @ 80D7678
.pool
thumb_func_end sub_80D7678
thumb_func_start sub_80D7724
sub_80D7724: @ 80D7724
thumb_func_start LoadContestBgAfterMoveAnim
LoadContestBgAfterMoveAnim: @ 80D7724
push {r4,r5,lr}
ldr r0, =gUnknown_08C17AB0
movs r1, 0xC0
@ -119,7 +119,7 @@ _080D775E:
pop {r0}
bx r0
.pool
thumb_func_end sub_80D7724
thumb_func_end LoadContestBgAfterMoveAnim
thumb_func_start sub_80D779C
sub_80D779C: @ 80D779C
@ -13662,7 +13662,7 @@ _080DE8FA:
cmp r0, 0x7
bne _080DE99C
_080DE910:
ldr r1, =gUnknown_02038432
ldr r1, =gAnimMoveTurn
movs r0, 0
b _080DE9A0
.pool
@ -13715,12 +13715,12 @@ _080DE978:
bne _080DE99C
movs r0, 0x2
strb r0, [r2]
ldr r0, =gUnknown_02038432
ldr r0, =gAnimMoveTurn
strb r1, [r0]
b _080DE9A2
.pool
_080DE99C:
ldr r1, =gUnknown_02038432
ldr r1, =gAnimMoveTurn
movs r0, 0x1
_080DE9A0:
strb r0, [r1]

View File

@ -902,7 +902,7 @@ gUnknown_08525CB4:: @ 8525CB4
obj_pal 0x08c1bf5c, 0x2830
.align 2
gUnknown_08525D54:: @ 8525D54
gBattleAnimBackgroundTable:: @ 8525D54
.4byte 0x08c1c844, 0x08c1ce3c, 0x08c1ce5c
.4byte 0x08c1c844, 0x08c1ce3c, 0x08c1ce5c
.4byte 0x08d90074, 0x08d90d3c, 0x08d90d58
@ -944,33 +944,33 @@ sScriptCmdTable:: @ 8525E98
.4byte ScriptCmd_end
.4byte ScriptCmd_playse
.4byte ScriptCmd_monbg
.4byte ma0B_0807324C
.4byte ma0C_set_BLDCNT_to_x3F40_and_BLDALPHA_to_argument
.4byte ma0D_reset_BLDCNT_and_BLDALPHA
.4byte ma0E_call
.4byte sub_80A4D00
.4byte ma10_080736AC
.4byte ma11_if_else
.4byte ma12_cond_if
.4byte ma13_goto
.4byte ma14_load_background
.4byte ma15_load_battle_screen_elements
.4byte ma16_wait_for_battle_screen_elements_s2
.4byte sub_80A5124
.4byte ma18_load_background_probably
.4byte ma19_08073BC8
.4byte ma1A_8073C00
.4byte ScriptCmd_clearmonbg
.4byte ScriptCmd_setalpha
.4byte ScriptCmd_blendoff
.4byte ScriptCmd_call
.4byte ScriptCmd_return
.4byte ScriptCmd_setarg
.4byte ScriptCmd_choosetwoturnanim
.4byte ScriptCmd_jumpifmoveturn
.4byte ScriptCmd_jump
.4byte ScriptCmd_fadetobg
.4byte ScriptCmd_restorebg
.4byte ScriptCmd_waitbgfadeout
.4byte ScriptCmd_waitbgfadein
.4byte ScriptCmd_changebg
.4byte ScriptCmd_playsewithpan
.4byte ScriptCmd_setpan
.4byte ma1B_8073C2C
.4byte ma1C_8073ED0
.4byte ma1D_08073FB4
.4byte ma1E_set_BLDCNT
.4byte ScriptCmd_setbldcnt
.4byte sub_80A57F8
.4byte ma20_wait_for_something
.4byte ma21_08074164
.4byte sub_80A4A18
.4byte ma23_8073484
.4byte ScriptCmd_monbg_22
.4byte ScriptCmd_clearmonbg_23
.4byte sub_80A5944
.4byte sub_80A4E5C
.4byte ScriptCmd_fadetobgfromset
.4byte sub_80A5508
.4byte sub_80A559C
.4byte sub_80A5984

View File

@ -826,6 +826,7 @@ void LoadBattleTextboxAndBackground(void);
void LoadBattleEntryBackground(void);
void ApplyPlayerChosenFrameToBattleMenu(void);
bool8 LoadChosenBattleElement(u8 caseId);
void LoadFittingBackgroundForBattle(void);
void task00_0800F6FC(u8 taskId);
// battle_5
@ -890,6 +891,8 @@ struct BattleHealthboxInfo
u8 flag_x1 : 1;
u8 flag_x2 : 1;
u8 flag_x4 : 1;
u8 flag_x8 : 1;
u8 flag_x10 : 1;
u8 field_1;
u8 field_2;
u8 field_3;

View File

@ -30,6 +30,13 @@ struct UnknownAnimStruct2
u16 unkC;
};
struct BattleAnimBackground
{
void *image;
void *palette;
void *tilemap;
};
void ClearBattleAnimationVars(void);
void DoMoveAnim(u16 move);
void DoBattleAnim(const u8 *const animsTable[], u16 tableId, bool8 isMoveAnim);
@ -38,8 +45,11 @@ void DestroyAnimVisualTask(u8 taskId);
void DestroyAnimSoundTask(u8 taskId);
bool8 IsAnimBankSpriteVisible(u8 bank);
void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible);
bool8 IsContest(void);
s8 BattleAnimAdjustPanning(s8 pan);
s8 BattleAnimAdjustPanning2(s8 pan);
s16 sub_80A52EC(s16 a);
s16 sub_80A5314(s16 a, s16 b, s16 c);
// battle_anim_80FE840.s
void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value);

View File

@ -36,5 +36,6 @@ struct ContestResources
extern struct ContestResources *gContestResources;
bool8 IsSpeciesNotUnown(u16 species);
void LoadContestBgAfterMoveAnim(void);
#endif //GUARD_CONTEST_H

View File

@ -13,13 +13,18 @@
#include "bg.h"
#include "gpu_regs.h"
#include "palette.h"
#include "main.h"
// sprites start at 10000 and thus must be subtracted of 10000 to account for the true index.
#define GET_TRUE_SPRITE_INDEX(i) ((i - 10000))
#define SCRIPT_READ_32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
#define SCRIPT_READ_32_(ptr) (((ptr)[0]) + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24))
#define SCRIPT_READ_16(ptr) ((ptr)[0] | ((ptr)[1] << 8))
#define SCRIPT_READ_PTR(ptr) ((const u8*)(SCRIPT_READ_32(ptr)))
#define SCRIPT_READ_16_(ptr) ((ptr)[0] + ((ptr)[1] << 8))
#define SCRIPT_READ_32_(ptr) (((ptr)[0]) + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24))
#define SCRIPT_READ_PTR_(ptr) ((const u8*)(SCRIPT_READ_32_(ptr)))
#define ANIM_SPRITE_INDEX_COUNT 8
#define ANIM_ARGS_COUNT 8
@ -56,7 +61,7 @@ EWRAM_DATA u16 gWeatherMoveAnim = 0;
EWRAM_DATA s16 gBattleAnimArgs[ANIM_ARGS_COUNT] = {0};
EWRAM_DATA u16 gSoundAnimFramesToWait = 0;
EWRAM_DATA u8 gMonAnimTaskIdArray[2] = {0};
EWRAM_DATA u8 gUnknown_02038432 = 0;
EWRAM_DATA u8 gAnimMoveTurn = 0;
EWRAM_DATA u8 gUnknown_02038433 = 0;
EWRAM_DATA u16 gAnimMoveIndex = 0; // set but unused.
EWRAM_DATA u8 gAnimBankAttacker = 0;
@ -69,6 +74,7 @@ extern const u16 gUnknown_082C8D64[];
extern const u8 * const gBattleAnims_Moves[];
extern const struct CompressedSpriteSheet gBattleAnimPicTable[];
extern const struct CompressedSpritePalette gBattleAnimPaletteTable[];
extern const struct BattleAnimBackground gBattleAnimBackgroundTable[];
extern void sub_80A8278(void); // rom_80A5C6C.s
extern void sub_80A6B30(struct UnknownAnimStruct2*); // rom_80A5C6C.s
@ -76,11 +82,18 @@ extern void sub_80A6B90(struct UnknownAnimStruct2*, u32 arg1); // rom_80A5C6C.s
extern u8 sub_80A82E4(u8 bank); // rom_80A5C6C.s
extern u8 sub_80A5C6C(u8 bank, u8 attributeId); // rom_80A5C6C.s
extern bool8 AnimBankSpriteExists(u8 bank); // rom_80A5C6C.s
extern void sub_80A6C68(u8 arg0); // rom_80A5C6C.s
extern u8 sub_80A6D94(void);
// this file's functions
void RunAnimScriptCommand(void);
void task_pA_ma0A_obj_to_bg_pal(u8 taskId);
void sub_80A46A0(void);
void sub_80A4980(u8 taskId);
void sub_80A4BB0(u8 taskId);
void Task_FadeToBg(u8 taskId);
void LoadDefaultBg(void);
void LoadMoveBg(u16 bgId);
void ClearBattleAnimationVars(void)
{
@ -105,7 +118,7 @@ void ClearBattleAnimationVars(void)
gMonAnimTaskIdArray[0] = 0xFF;
gMonAnimTaskIdArray[1] = 0xFF;
gUnknown_02038432 = 0;
gAnimMoveTurn = 0;
gUnknown_02038433 = 0;
gAnimMoveIndex = 0;
gAnimBankAttacker = 0;
@ -648,3 +661,624 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
}
}
/*static*/ void sub_80A46A0(void)
{
s32 i, j;
struct UnknownAnimStruct2 unknownStruct;
u16 *ptr;
if (IsSpeciesNotUnown(gContestResources->field_18->field_0))
{
sub_80A6B30(&unknownStruct);
ptr = unknownStruct.unk4;
for (i = 0; i < 8; i++)
{
for (j = 0; j < 4; j++)
{
u16 temp = ptr[j + i * 32];
ptr[j + i * 32] = ptr[7 - j + i * 32];
ptr[7 - j + i * 32] = temp;
}
}
for (i = 0; i < 8; i++)
{
for (j = 0; j < 8; j++)
ptr[j + i * 32] ^= 0x400;
}
}
}
void sub_80A4720(u16 a, u16 *b, u32 c, u8 d)
{
s32 i, j;
s32 var;
if (d == 0)
var = 32;
else
var = 64;
a <<= 12;
for (i = 0; i < var; i++)
{
for (j = 0; j < 32; j++)
b[j + i * 32] = ((b[j + i * 32] & 0xFFF) | a) + c;
}
}
void sub_80A477C(bool8 to_BG2)
{
struct UnknownAnimStruct2 unknownStruct;
sub_80A6B30(&unknownStruct);
if (!to_BG2 || IsContest())
{
sub_80A6C68(1);
gBattle_BG1_X = 0;
gBattle_BG1_Y = 0;
}
else
{
sub_80A6C68(2);
gBattle_BG2_X = 0;
gBattle_BG2_Y = 0;
}
}
/*static*/ void task_pA_ma0A_obj_to_bg_pal(u8 taskId)
{
u8 r4;
u8 r6;
s16 r3;
s16 r2;
struct UnknownAnimStruct2 unknownStruct;
r4 = gTasks[taskId].data[0];
r6 = gTasks[taskId].data[6];
sub_80A6B30(&unknownStruct);
r3 = gTasks[taskId].data[1] - (gSprites[r4].pos1.x + gSprites[r4].pos2.x);
r2 = gTasks[taskId].data[2] - (gSprites[r4].pos1.y + gSprites[r4].pos2.y);
if (gTasks[taskId].data[5] == 0)
{
u16 *src;
u16 *dst;
gBattle_BG1_X = r3 + gTasks[taskId].data[3];
gBattle_BG1_Y = r2 + gTasks[taskId].data[4];
src = gPlttBufferFaded + 0x100 + r6 * 16;
dst = gPlttBufferFaded + 0x100 + unknownStruct.unk8 * 16 - 256;
CpuCopy32(src, dst, 0x20);
}
else
{
u16 *src;
u16 *dst;
gBattle_BG2_X = r3 + gTasks[taskId].data[3];
gBattle_BG2_Y = r2 + gTasks[taskId].data[4];
src = gPlttBufferFaded + 0x100 + r6 * 16;
dst = gPlttBufferFaded + 0x100 - 112;
CpuCopy32(src, dst, 0x20);
}
}
/*static*/ void ScriptCmd_clearmonbg(void)
{
u8 animBankId;
u8 bank;
u8 taskId;
gBattleAnimScriptPtr++;
animBankId = gBattleAnimScriptPtr[0];
if (animBankId == ANIM_BANK_ATTACKER)
animBankId = ANIM_BANK_ATK_PARTNER;
else if (animBankId == ANIM_BANK_TARGET)
animBankId = ANIM_BANK_DEF_PARTNER;
if (animBankId == ANIM_BANK_ATTACKER || animBankId == ANIM_BANK_ATK_PARTNER)
bank = gAnimBankAttacker;
else
bank = gAnimBankTarget;
if (gMonAnimTaskIdArray[0] != 0xFF)
gSprites[gBankSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && gMonAnimTaskIdArray[1] != 0xFF)
gSprites[gBankSpriteIds[bank ^ BIT_MON]].invisible = 0;
else
animBankId = 0;
taskId = CreateTask(sub_80A4980, 5);
gTasks[taskId].data[0] = animBankId;
gTasks[taskId].data[2] = bank;
gBattleAnimScriptPtr++;
}
/*static*/ void sub_80A4980(u8 taskId)
{
gTasks[taskId].data[1]++;
if (gTasks[taskId].data[1] != 1)
{
u8 to_BG2;
u8 identity = GetBankIdentity(gTasks[taskId].data[2]);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
to_BG2 = FALSE;
else
to_BG2 = TRUE;
if (gMonAnimTaskIdArray[0] != 0xFF)
{
sub_80A477C(to_BG2);
DestroyTask(gMonAnimTaskIdArray[0]);
gMonAnimTaskIdArray[0] = 0xFF;
}
if (gTasks[taskId].data[0] > 1)
{
sub_80A477C(to_BG2 ^ 1);
DestroyTask(gMonAnimTaskIdArray[1]);
gMonAnimTaskIdArray[1] = 0xFF;
}
DestroyTask(taskId);
}
}
/*static*/ void ScriptCmd_monbg_22(void)
{
bool8 toBG_2;
u8 bank;
u8 animBankId;
gBattleAnimScriptPtr++;
animBankId = gBattleAnimScriptPtr[0];
if (animBankId == ANIM_BANK_ATTACKER)
animBankId = ANIM_BANK_ATK_PARTNER;
else if (animBankId == ANIM_BANK_TARGET)
animBankId = ANIM_BANK_DEF_PARTNER;
if (animBankId == ANIM_BANK_ATTACKER || animBankId == ANIM_BANK_ATK_PARTNER)
bank = gAnimBankAttacker;
else
bank = gAnimBankTarget;
if (IsAnimBankSpriteVisible(bank))
{
u8 identity = GetBankIdentity(bank);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
}
bank ^= BIT_MON;
if (animBankId > 1 && IsAnimBankSpriteVisible(bank))
{
u8 identity = GetBankIdentity(bank);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
}
gBattleAnimScriptPtr++;
}
/*static*/ void ScriptCmd_clearmonbg_23(void)
{
u8 animBankId;
u8 bank;
u8 taskId;
gBattleAnimScriptPtr++;
animBankId = gBattleAnimScriptPtr[0];
if (animBankId == ANIM_BANK_ATTACKER)
animBankId = ANIM_BANK_ATK_PARTNER;
else if (animBankId == ANIM_BANK_TARGET)
animBankId = ANIM_BANK_DEF_PARTNER;
if (animBankId == ANIM_BANK_ATTACKER || animBankId == ANIM_BANK_ATK_PARTNER)
bank = gAnimBankAttacker;
else
bank = gAnimBankTarget;
if (IsAnimBankSpriteVisible(bank))
gSprites[gBankSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && IsAnimBankSpriteVisible(bank ^ BIT_MON))
gSprites[gBankSpriteIds[bank ^ BIT_MON]].invisible = 0;
else
animBankId = 0;
taskId = CreateTask(sub_80A4BB0, 5);
gTasks[taskId].data[0] = animBankId;
gTasks[taskId].data[2] = bank;
gBattleAnimScriptPtr++;
}
/*static*/ void sub_80A4BB0(u8 taskId)
{
gTasks[taskId].data[1]++;
if (gTasks[taskId].data[1] != 1)
{
bool8 toBG_2;
u8 bank = gTasks[taskId].data[2];
u8 identity = GetBankIdentity(bank);
if (identity == IDENTITY_OPPONENT_MON1 || identity == IDENTITY_PLAYER_MON2 || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
if (IsAnimBankSpriteVisible(bank))
sub_80A477C(toBG_2);
if (gTasks[taskId].data[0] > 1 && IsAnimBankSpriteVisible(bank ^ BIT_MON))
sub_80A477C(toBG_2 ^ 1);
DestroyTask(taskId);
}
}
#undef t1_MONBG_BANK
#undef t1_MON_IN_BG2
#undef t1_CREATE_ANOTHER_TASK
#undef t1_IS_SECONDMON_BG
#undef t2_BANK_SPRITE_ID
#undef t2_MON_IN_BG2
#undef t2_MONBG_BANK
/*static*/ void ScriptCmd_setalpha(void)
{
u16 half1, half2;
gBattleAnimScriptPtr++;
half1 = *(gBattleAnimScriptPtr++);
half2 = *(gBattleAnimScriptPtr++) << 8;
SetGpuReg(REG_OFFSET_BLDCNT, 0x3F40);
SetGpuReg(REG_OFFSET_BLDALPHA, half1 | half2);
}
/*static*/ void ScriptCmd_setbldcnt(void)
{
u16 half1, half2;
gBattleAnimScriptPtr++;
half1 = *(gBattleAnimScriptPtr++);
half2 = *(gBattleAnimScriptPtr++) << 8;
SetGpuReg(REG_OFFSET_BLDCNT, half1 | half2);
}
/*static*/ void ScriptCmd_blendoff(void)
{
gBattleAnimScriptPtr++;
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
}
/*static*/ void ScriptCmd_call(void)
{
gBattleAnimScriptPtr++;
gBattleAnimScriptRetAddr = gBattleAnimScriptPtr + 4;
gBattleAnimScriptPtr = SCRIPT_READ_PTR_(gBattleAnimScriptPtr);
}
/*static*/ void ScriptCmd_return(void)
{
gBattleAnimScriptPtr = gBattleAnimScriptRetAddr;
}
/*static*/ void ScriptCmd_setarg(void)
{
const u8 *addr = gBattleAnimScriptPtr;
u16 value;
u8 argId;
gBattleAnimScriptPtr++;
argId = gBattleAnimScriptPtr[0];
gBattleAnimScriptPtr++;
value = SCRIPT_READ_16(gBattleAnimScriptPtr);
gBattleAnimScriptPtr = addr + 4;
gBattleAnimArgs[argId] = value;
}
/*static*/ void ScriptCmd_choosetwoturnanim(void)
{
gBattleAnimScriptPtr++;
if (gAnimMoveTurn & 1)
gBattleAnimScriptPtr += 4;
gBattleAnimScriptPtr = SCRIPT_READ_PTR_(gBattleAnimScriptPtr);
}
/*static*/ void ScriptCmd_jumpifmoveturn(void)
{
u8 toCheck;
gBattleAnimScriptPtr++;
toCheck = gBattleAnimScriptPtr[0];
gBattleAnimScriptPtr++;
if (toCheck == gAnimMoveTurn)
gBattleAnimScriptPtr = SCRIPT_READ_PTR_(gBattleAnimScriptPtr);
else
gBattleAnimScriptPtr += 4;
}
/*static*/ void ScriptCmd_jump(void)
{
gBattleAnimScriptPtr++;
gBattleAnimScriptPtr = SCRIPT_READ_PTR_(gBattleAnimScriptPtr);
}
// Uses of this function that rely on a TRUE return are expecting inBattle to not be ticked as defined in contest behavior. As a result, if misused, this function cannot reliably discern between field and contest status and could result in undefined behavior.
bool8 IsContest(void)
{
if (!gMain.inBattle)
return TRUE;
else
return FALSE;
}
#define tBackgroundId data[0]
#define tState data[10]
/*static*/ void ScriptCmd_fadetobg(void)
{
u8 backgroundId;
u8 taskId;
gBattleAnimScriptPtr++;
backgroundId = gBattleAnimScriptPtr[0];
gBattleAnimScriptPtr++;
taskId = CreateTask(Task_FadeToBg, 5);
gTasks[taskId].tBackgroundId = backgroundId;
gUnknown_02038433 = 1;
}
/*static*/ void ScriptCmd_fadetobgfromset(void)
{
u8 bg1, bg2, bg3;
u8 taskId;
gBattleAnimScriptPtr++;
bg1 = gBattleAnimScriptPtr[0];
bg2 = gBattleAnimScriptPtr[1];
bg3 = gBattleAnimScriptPtr[2];
gBattleAnimScriptPtr += 3;
taskId = CreateTask(Task_FadeToBg, 5);
if (IsContest())
gTasks[taskId].tBackgroundId = bg3;
else if (GetBankSide(gAnimBankTarget) == SIDE_PLAYER)
gTasks[taskId].tBackgroundId = bg2;
else
gTasks[taskId].tBackgroundId = bg1;
gUnknown_02038433 = 1;
}
/*static*/ void Task_FadeToBg(u8 taskId)
{
if (gTasks[taskId].tState == 0)
{
BeginHardwarePaletteFade(0xE8, 0, 0, 16, 0);
gTasks[taskId].tState++;
return;
}
if (gPaletteFade.active)
return;
if (gTasks[taskId].tState == 1)
{
gTasks[taskId].tState++;
gUnknown_02038433 = 2;
}
else if (gTasks[taskId].tState == 2)
{
s16 bgId = (u16)gTasks[taskId].tBackgroundId;
if (bgId == -1)
LoadDefaultBg();
else
LoadMoveBg(bgId);
BeginHardwarePaletteFade(0xE8, 0, 16, 0, 1);
gTasks[taskId].tState++;
return;
}
if (gPaletteFade.active)
return;
if (gTasks[taskId].tState == 3)
{
DestroyTask(taskId);
gUnknown_02038433 = 0;
}
}
extern u8 gDecompressionBuffer[];
/*static*/ void LoadMoveBg(u16 bgId)
{
if (IsContest())
{
void *tilemap = gBattleAnimBackgroundTable[bgId].tilemap;
void *dmaSrc;
void *dmaDest;
LZDecompressWram(tilemap, gDecompressionBuffer);
sub_80A4720(sub_80A6D94(), (void*)(gDecompressionBuffer), 0x100, 0);
dmaSrc = gDecompressionBuffer;
dmaDest = (void *)(VRAM + 0xD000);
DmaCopy32(3, dmaSrc, dmaDest, 0x800);
LZDecompressVram(gBattleAnimBackgroundTable[bgId].image, (void *)(VRAM + 0x2000));
LoadCompressedPalette(gBattleAnimBackgroundTable[bgId].palette, sub_80A6D94() * 16, 32);
}
else
{
LZDecompressVram(gBattleAnimBackgroundTable[bgId].tilemap, (void *)(VRAM + 0xD000));
LZDecompressVram(gBattleAnimBackgroundTable[bgId].image, (void *)(VRAM + 0x8000));
LoadCompressedPalette(gBattleAnimBackgroundTable[bgId].palette, 32, 32);
}
}
/*static*/ void LoadDefaultBg(void)
{
if (IsContest())
LoadContestBgAfterMoveAnim();
else
LoadFittingBackgroundForBattle();
}
/*static*/ void ScriptCmd_restorebg(void)
{
u8 taskId;
gBattleAnimScriptPtr++;
taskId = CreateTask(Task_FadeToBg, 5);
gTasks[taskId].data[0] = 0xFFFF;
gUnknown_02038433 = 1;
}
/*static*/ void ScriptCmd_waitbgfadeout(void)
{
if (gUnknown_02038433 == 2)
{
gBattleAnimScriptPtr++;
gAnimFramesToWait = 0;
}
else
{
gAnimFramesToWait = 1;
}
}
/*static*/ void ScriptCmd_waitbgfadein(void)
{
if (gUnknown_02038433 == 0)
{
gBattleAnimScriptPtr++;
gAnimFramesToWait = 0;
}
else
{
gAnimFramesToWait = 1;
}
}
/*static*/ void ScriptCmd_changebg(void)
{
gBattleAnimScriptPtr++;
LoadMoveBg(gBattleAnimScriptPtr[0]);
gBattleAnimScriptPtr++;
}
s8 BattleAnimAdjustPanning(s8 pan)
{
if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gAnimBankAttacker].flag_x10)
{
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER)
pan = 63;
else
pan = -64;
}
else if (IsContest())
{
if (gAnimBankAttacker != gAnimBankTarget || gAnimBankAttacker != 2 || pan != 63)
pan *= -1;
}
else if (GetBankSide(gAnimBankAttacker) == SIDE_PLAYER)
{
if (GetBankSide(gAnimBankTarget) == SIDE_PLAYER)
{
if (pan == 63)
pan = -64;
else if (pan != -64)
pan *= -1;
}
}
else if (GetBankSide(gAnimBankTarget) == SIDE_OPPONENT)
{
if (pan == -64)
pan = 63;
}
else
{
pan *= -1;
}
if (pan > 63)
pan = 63;
else if (pan < -64)
pan = -64;
return pan;
}
s8 BattleAnimAdjustPanning2(s8 pan)
{
if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gAnimBankAttacker].flag_x10)
{
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER)
pan = 63;
else
pan = -64;
}
else
{
if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER || IsContest())
pan = -pan;
}
return pan;
}
s16 sub_80A52EC(s16 a)
{
s16 var = a;
if (var > 63)
var = 63;
else if (var < -64)
var = -64;
return var;
}
s16 sub_80A5314(s16 a, s16 b, s16 c)
{
u16 var;
if (a < b)
var = ((c < 0) ? -c : c);
else if (a > b)
var = -((c < 0) ? -c : c);
else
var = 0;
return var;
}
/*static*/ void ScriptCmd_playsewithpan(void)
{
u16 songId;
s8 pan;
gBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(gBattleAnimScriptPtr);
pan = gBattleAnimScriptPtr[2];
PlaySE12WithPanning(songId, BattleAnimAdjustPanning(pan));
gBattleAnimScriptPtr += 3;
}
/*static*/ void ScriptCmd_setpan(void)
{
s8 pan;
gBattleAnimScriptPtr++;
pan = gBattleAnimScriptPtr[0];
SE12PanpotControl(BattleAnimAdjustPanning(pan));
gBattleAnimScriptPtr++;
}