safari controller is done

This commit is contained in:
DizzyEggg 2017-10-22 20:38:23 +02:00
parent f77dcef59d
commit 26c79313d8
7 changed files with 896 additions and 1652 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,168 @@
.section .rodata
.align 2
gUnknown_085CE004:: @ 85CE004
.2byte 0x0000, 0x0004, 0x0010, 0x0004
.2byte 0x0020, 0x0004, 0x0030, 0x0004
.2byte 0x0040, 0x0004, 0xffff, 0x0000
.align 2
gUnknown_085CE01C:: @ 85CE01C
.4byte gUnknown_085CE004
.align 2
gUnknown_085CE020:: @ 85CE020
spr_template 0x2799, 0x2799, gUnknown_08524A34, gUnknown_085CE01C, NULL, gDummySpriteAffineAnimTable, sub_80A77C8
.align 2
spr_template 0x2720, 0x2720, gUnknown_08524934, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815A0D4
.align 2
spr_template 0x2721, 0x2721, gUnknown_08524904, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80A78AC
.align 2
gUnknown_085CE068:: @ 85CE068
.2byte 0x0000, 0x0028, 0x0010, 0x0008
.2byte 0x0020, 0x0028, 0xffff, 0x0000
.align 2
gUnknown_085CE078:: @ 85CE078
.4byte gUnknown_085CE068
.align 2
gUnknown_085CE07C:: @ 85CE07C
spr_template 0x27ce, 0x27ce, gUnknown_08524914, gUnknown_085CE078, NULL, gDummySpriteAffineAnimTable, sub_80A77C8
.align 2
spr_template 0x27cf, 0x27cf, gUnknown_08524A3C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815A1B0
.align 2
spr_template 0x27cd, 0x27cd, gUnknown_08524974, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815A254
.align 2
gUnknown_085CE0C4:: @ 85CE0C4
.2byte 0x0180, 0x0180, 0x0000, 0x0000
.2byte 0xffe0, 0x0018, 0x0500, 0x0000
.2byte 0x0018, 0xffe0, 0x0500, 0x0000
.2byte 0x7ffe, 0x0001, 0x0000, 0x0000
.align 2
gUnknown_085CE0E4:: @ 85CE0E4
.2byte 0x0030, 0x0030, 0x0000, 0x0000
.2byte 0x0020, 0x0020, 0x0600, 0x0000
.2byte 0x7fff, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE0FC:: @ 85CE0FC
.4byte gUnknown_085CE0C4
.4byte gUnknown_085CE0E4
.align 2
gUnknown_085CE104:: @ 85CE104
spr_template 0x27cb, 0x27cb, gUnknown_08524AFC, gDummySpriteAnimTable, NULL, gUnknown_085CE0FC, sub_815A2F0
.align 2
spr_template 0x27a8, 0x27a8, gUnknown_0852490C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815A6C4
.align 2
gUnknown_085CE134:: @ 85CE134
.2byte 0x0000, 0x0003, 0x0010, 0x0003
.2byte 0x0020, 0x0003, 0x0030, 0x0003
.2byte 0x0040, 0x0003, 0xffff, 0x0000
.align 2
gUnknown_085CE14C:: @ 85CE14C
.4byte gUnknown_085CE134
.align 2
gUnknown_085CE150:: @ 85CE150
spr_template 0x272b, 0x272b, gUnknown_08524914, gUnknown_085CE14C, NULL, gDummySpriteAffineAnimTable, sub_815A7B0
.align 2
gUnknown_085CE168:: @ 85CE168
.2byte 0x0000, 0x0003, 0xffff, 0x0000
.align 2
gUnknown_085CE170:: @ 85CE170
.4byte gUnknown_085CE168
.align 2
gUnknown_085CE174:: @ 85CE174
.2byte 0xfff9, 0xfff9, 0x10fd, 0x0000
.2byte 0x0007, 0x0007, 0x1003, 0x0000
.2byte 0x7ffe, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE18C:: @ 85CE18C
.4byte gUnknown_085CE174
.align 2
gUnknown_085CE190:: @ 85CE190
spr_template 0x27f4, 0x27f4, gUnknown_08524974, gUnknown_085CE170, NULL, gUnknown_085CE18C, sub_815A7EC
.align 2
gUnknown_085CE1A8:: @ 85CE1A8
.2byte 0x0000, 0x0008, 0x0010, 0x0010, 0x0020, 0x0004, 0x0030, 0x0004, 0xffff, 0x0000
.align 2
gUnknown_085CE1BC:: @ 85CE1BC
.4byte gUnknown_085CE1A8
.align 2
gUnknown_085CE1C0:: @ 85CE1C0
.2byte 0x0200, 0x0200, 0x0000, 0x0000
.2byte 0xffe0, 0xffe0, 0x0800, 0x0000
.2byte 0x7fff, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE1D8:: @ 85CE1D8
.4byte gUnknown_085CE1C0
.align 2
gUnknown_085CE1DC:: @ 85CE1DC
spr_template 0x27d0, 0x27d0, gUnknown_085249D4, gUnknown_085CE1BC, NULL, gUnknown_085CE1D8, sub_815A8AC
.align 2
gUnknown_085CE1F4:: @ 85CE1F4
.2byte 0x0000, 0x0180, 0x0000, 0x0000
.2byte 0x0010, 0x0000, 0x1400, 0x0000
.2byte 0x7fff, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE20C:: @ 85CE20C
.2byte 0x0140, 0x0180, 0x0000, 0x0000
.2byte 0xfff0, 0x0000, 0x1300, 0x0000
.2byte 0x7fff, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE224:: @ 85CE224
.4byte gUnknown_085CE1F4
.4byte gUnknown_085CE20C
.align 2
gUnknown_085CE22C:: @ 85CE22C
spr_template 0x27f3, 0x27f3, gUnknown_085249DC, gDummySpriteAnimTable, NULL, gUnknown_085CE224, sub_815A934
.align 2
spr_template 0x2807, 0x2807, gUnknown_08524914, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815AAA4
.align 2
spr_template 0x2807, 0x2807, gUnknown_08524914, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815ABD0
.align 2
gUnknown_085CE274:: @ 85CE274
.2byte 0x0000, 0x0002, 0x0008, 0x0002
.2byte 0x0010, 0x0002, 0xfffe, 0x0000
.align 2
gUnknown_085CE284:: @ 85CE284
.4byte gUnknown_085CE274
.align 2
gUnknown_085CE288:: @ 85CE288
spr_template 0x27f5, 0x27f5, gUnknown_08524934, gUnknown_085CE284, NULL, gDummySpriteAffineAnimTable, sub_815ACD0
gUnknown_085CE2A0:: @ 85CE2A0
.incbin "baserom.gba", 0x5ce2a0, 0xb0

View File

@ -1,228 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gSafariBufferCommands:: @ 85CDF20
.4byte sub_81597AC
.4byte sub_81597B8
.4byte sub_81597C4
.4byte sub_81597D0
.4byte sub_81597DC
.4byte sub_81597E8
.4byte sub_81597F4
.4byte sub_8159800
.4byte sub_81598E0
.4byte sub_81598EC
.4byte sub_81598F8
.4byte sub_8159904
.4byte sub_8159910
.4byte sub_8159964
.4byte sub_81599C4
.4byte sub_81599D0
.4byte dp01t_10_6_message
.4byte dp01t_11_6_message_for_player_only
.4byte sub_8159A94
.4byte sub_8159AFC
.4byte sub_8159B08
.4byte sub_8159B14
.4byte sub_8159B54
.4byte sub_8159B60
.4byte sub_8159B6C
.4byte sub_8159B78
.4byte sub_8159B84
.4byte sub_8159BC0
.4byte sub_8159BCC
.4byte sub_8159BD8
.4byte sub_8159BE4
.4byte sub_8159BF0
.4byte sub_8159BFC
.4byte sub_8159C08
.4byte sub_8159C14
.4byte sub_8159C20
.4byte sub_8159C2C
.4byte sub_8159C38
.4byte sub_8159C44
.4byte sub_8159C50
.4byte sub_8159C5C
.4byte sub_8159C68
.4byte sub_8159C74
.4byte sub_8159C80
.4byte dp01t_34_6_move_anim_start_t3
.4byte sub_8159D20
.4byte dp01t_2E_6_battle_intro
.4byte sub_8159D90
.4byte sub_8159DEC
.4byte sub_8159DF8
.4byte sub_8159E04
.4byte sub_8159E10
.4byte sub_8159E1C
.4byte sub_8159E78
.4byte sub_8159E84
.4byte sub_8159E90
.4byte nullsub_115
.align 2
gUnknown_085CE004:: @ 85CE004
.2byte 0x0000, 0x0004, 0x0010, 0x0004
.2byte 0x0020, 0x0004, 0x0030, 0x0004
.2byte 0x0040, 0x0004, 0xffff, 0x0000
.align 2
gUnknown_085CE01C:: @ 85CE01C
.4byte gUnknown_085CE004
.align 2
gUnknown_085CE020:: @ 85CE020
spr_template 0x2799, 0x2799, gUnknown_08524A34, gUnknown_085CE01C, NULL, gDummySpriteAffineAnimTable, sub_80A77C8
.align 2
spr_template 0x2720, 0x2720, gUnknown_08524934, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815A0D4
.align 2
spr_template 0x2721, 0x2721, gUnknown_08524904, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_80A78AC
.align 2
gUnknown_085CE068:: @ 85CE068
.2byte 0x0000, 0x0028, 0x0010, 0x0008
.2byte 0x0020, 0x0028, 0xffff, 0x0000
.align 2
gUnknown_085CE078:: @ 85CE078
.4byte gUnknown_085CE068
.align 2
gUnknown_085CE07C:: @ 85CE07C
spr_template 0x27ce, 0x27ce, gUnknown_08524914, gUnknown_085CE078, NULL, gDummySpriteAffineAnimTable, sub_80A77C8
.align 2
spr_template 0x27cf, 0x27cf, gUnknown_08524A3C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815A1B0
.align 2
spr_template 0x27cd, 0x27cd, gUnknown_08524974, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815A254
.align 2
gUnknown_085CE0C4:: @ 85CE0C4
.2byte 0x0180, 0x0180, 0x0000, 0x0000
.2byte 0xffe0, 0x0018, 0x0500, 0x0000
.2byte 0x0018, 0xffe0, 0x0500, 0x0000
.2byte 0x7ffe, 0x0001, 0x0000, 0x0000
.align 2
gUnknown_085CE0E4:: @ 85CE0E4
.2byte 0x0030, 0x0030, 0x0000, 0x0000
.2byte 0x0020, 0x0020, 0x0600, 0x0000
.2byte 0x7fff, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE0FC:: @ 85CE0FC
.4byte gUnknown_085CE0C4
.4byte gUnknown_085CE0E4
.align 2
gUnknown_085CE104:: @ 85CE104
spr_template 0x27cb, 0x27cb, gUnknown_08524AFC, gDummySpriteAnimTable, NULL, gUnknown_085CE0FC, sub_815A2F0
.align 2
spr_template 0x27a8, 0x27a8, gUnknown_0852490C, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815A6C4
.align 2
gUnknown_085CE134:: @ 85CE134
.2byte 0x0000, 0x0003, 0x0010, 0x0003
.2byte 0x0020, 0x0003, 0x0030, 0x0003
.2byte 0x0040, 0x0003, 0xffff, 0x0000
.align 2
gUnknown_085CE14C:: @ 85CE14C
.4byte gUnknown_085CE134
.align 2
gUnknown_085CE150:: @ 85CE150
spr_template 0x272b, 0x272b, gUnknown_08524914, gUnknown_085CE14C, NULL, gDummySpriteAffineAnimTable, sub_815A7B0
.align 2
gUnknown_085CE168:: @ 85CE168
.2byte 0x0000, 0x0003, 0xffff, 0x0000
.align 2
gUnknown_085CE170:: @ 85CE170
.4byte gUnknown_085CE168
.align 2
gUnknown_085CE174:: @ 85CE174
.2byte 0xfff9, 0xfff9, 0x10fd, 0x0000
.2byte 0x0007, 0x0007, 0x1003, 0x0000
.2byte 0x7ffe, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE18C:: @ 85CE18C
.4byte gUnknown_085CE174
.align 2
gUnknown_085CE190:: @ 85CE190
spr_template 0x27f4, 0x27f4, gUnknown_08524974, gUnknown_085CE170, NULL, gUnknown_085CE18C, sub_815A7EC
.align 2
gUnknown_085CE1A8:: @ 85CE1A8
.2byte 0x0000, 0x0008, 0x0010, 0x0010, 0x0020, 0x0004, 0x0030, 0x0004, 0xffff, 0x0000
.align 2
gUnknown_085CE1BC:: @ 85CE1BC
.4byte gUnknown_085CE1A8
.align 2
gUnknown_085CE1C0:: @ 85CE1C0
.2byte 0x0200, 0x0200, 0x0000, 0x0000
.2byte 0xffe0, 0xffe0, 0x0800, 0x0000
.2byte 0x7fff, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE1D8:: @ 85CE1D8
.4byte gUnknown_085CE1C0
.align 2
gUnknown_085CE1DC:: @ 85CE1DC
spr_template 0x27d0, 0x27d0, gUnknown_085249D4, gUnknown_085CE1BC, NULL, gUnknown_085CE1D8, sub_815A8AC
.align 2
gUnknown_085CE1F4:: @ 85CE1F4
.2byte 0x0000, 0x0180, 0x0000, 0x0000
.2byte 0x0010, 0x0000, 0x1400, 0x0000
.2byte 0x7fff, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE20C:: @ 85CE20C
.2byte 0x0140, 0x0180, 0x0000, 0x0000
.2byte 0xfff0, 0x0000, 0x1300, 0x0000
.2byte 0x7fff, 0x0000, 0x0000, 0x0000
.align 2
gUnknown_085CE224:: @ 85CE224
.4byte gUnknown_085CE1F4
.4byte gUnknown_085CE20C
.align 2
gUnknown_085CE22C:: @ 85CE22C
spr_template 0x27f3, 0x27f3, gUnknown_085249DC, gDummySpriteAnimTable, NULL, gUnknown_085CE224, sub_815A934
.align 2
spr_template 0x2807, 0x2807, gUnknown_08524914, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815AAA4
.align 2
spr_template 0x2807, 0x2807, gUnknown_08524914, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_815ABD0
.align 2
gUnknown_085CE274:: @ 85CE274
.2byte 0x0000, 0x0002, 0x0008, 0x0002
.2byte 0x0010, 0x0002, 0xfffe, 0x0000
.align 2
gUnknown_085CE284:: @ 85CE284
.4byte gUnknown_085CE274
.align 2
gUnknown_085CE288:: @ 85CE288
spr_template 0x27f5, 0x27f5, gUnknown_08524934, gUnknown_085CE284, NULL, gDummySpriteAffineAnimTable, sub_815ACD0

View File

@ -780,7 +780,7 @@ extern struct BattleStruct* gBattleStruct;
#define B_ANIM_SWITCH_OUT_MON 0x1
#define B_ANIM_SPECIAL_2 0x2
#define B_ANIM_BALL_THROW 0x3
#define B_ANIM_SPECIAL_4 0x4
#define B_ANIM_SAFARI_BALL_THROW 0x4
#define B_ANIM_SUBSTITUTE_TO_MON 0x5
#define B_ANIM_MON_TO_SUBSTITUTE 0x6

View File

@ -201,7 +201,7 @@ SECTIONS {
asm/field_effect_helpers.o(.text);
asm/contest_ai.o(.text);
asm/battle_anim_sound_tasks.o(.text);
asm/battle_controller_safari.o(.text);
src/battle_controller_safari.o(.text);
asm/fldeff_sweetscent.o(.text);
asm/battle_anim_815A0D4.o(.text);
asm/learn_move.o(.text);
@ -426,7 +426,7 @@ SECTIONS {
data/save.o(.rodata);
data/field_effect_helpers.o(.rodata);
data/contest_ai.o(.rodata);
data/battle_controller_safari.o(.rodata);
src/battle_controller_safari.o(.rodata);
data/battle_anim_815A0D4.o(.rodata);
data/learn_move.o(.rodata);
src/roamer.o(.rodata);

View File

@ -154,7 +154,7 @@ static void MoveSelectionDisplayMoveNames(void);
static void HandleMoveSwitchting(void);
static void sub_8058FC0(void);
static void sub_8059828(void);
static void sub_80598E0(void);
static void CompleteWhenChoseItem(void);
static void sub_8059544(u8 taskId);
static void Task_PrepareToGiveExpWithExpBar(u8 taskId);
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId);
@ -297,16 +297,16 @@ static void HandleInputChooseAction(void)
switch (gActionSelectionCursor[gActiveBank])
{
case ACTION_USE_MOVE:
case 0:
EmitTwoReturnValues(1, ACTION_USE_MOVE, 0);
break;
case ACTION_USE_ITEM:
case 1:
EmitTwoReturnValues(1, ACTION_USE_ITEM, 0);
break;
case ACTION_SWITCH:
case 2:
EmitTwoReturnValues(1, ACTION_SWITCH, 0);
break;
case ACTION_RUN:
case 3:
EmitTwoReturnValues(1, ACTION_RUN, 0);
break;
}
@ -1400,18 +1400,18 @@ static void sub_8059828(void)
}
}
static void sub_80598A4(void)
static void OpenBagAndChooseItem(void)
{
if (!gPaletteFade.active)
{
gBattleBankFunc[gActiveBank] = sub_80598E0;
gBattleBankFunc[gActiveBank] = CompleteWhenChoseItem;
nullsub_35();
FreeAllWindowBuffers();
sub_81AABB0();
}
}
static void sub_80598E0(void)
static void CompleteWhenChoseItem(void)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
@ -2685,7 +2685,7 @@ static void PlayerHandleChooseItem(void)
s32 i;
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gBattleBankFunc[gActiveBank] = sub_80598A4;
gBattleBankFunc[gActiveBank] = OpenBagAndChooseItem;
gBankInMenu = gActiveBank;
for (i = 0; i < 3; i++)

View File

@ -0,0 +1,723 @@
#include "global.h"
#include "battle.h"
#include "battle_controllers.h"
#include "battle_message.h"
#include "battle_interface.h"
#include "battle_anim.h"
#include "pokemon.h"
#include "link.h"
#include "util.h"
#include "main.h"
#include "songs.h"
#include "sound.h"
#include "window.h"
#include "m4a.h"
#include "palette.h"
#include "task.h"
#include "text.h"
#include "bg.h"
#include "reshow_battle_screen.h"
#include "pokeball.h"
extern u32 gBattleExecBuffer;
extern u8 gActiveBank;
extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT];
extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT];
extern u8 gNoOfAllBanks;
extern bool8 gDoingBattleAnim;
extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void);
extern void (*gPreBattleCallback1)(void);
extern u16 gBattlePartyID[BATTLE_BANKS_COUNT];
extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200];
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gScriptItemId;
extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT];
extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern u8 gBankInMenu;
extern u16 gUnknown_020243FC;
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern const u8 gText_SafariZoneMenu[];
extern const u8 gText_WhatWillPkmnDo2[];
extern void sub_81358F4(void);
// this file's functions
static void SafariHandleGetMonData(void);
static void SafariHandleGetRawMonData(void);
static void SafariHandleSetMonData(void);
static void SafariHandleSetRawMonData(void);
static void SafariHandleLoadMonSprite(void);
static void SafariHandleSwitchInAnim(void);
static void SafariHandleReturnMonToBall(void);
static void SafariHandleDrawTrainerPic(void);
static void SafariHandleTrainerSlide(void);
static void SafariHandleTrainerSlideBack(void);
static void SafariHandleFaintAnimation(void);
static void SafariHandlePaletteFade(void);
static void SafariHandleSuccessBallThrowAnim(void);
static void SafariHandleBallThrowAnim(void);
static void SafariHandlePause(void);
static void SafariHandleMoveAnimation(void);
static void SafariHandlePrintString(void);
static void SafariHandlePrintStringPlayerOnly(void);
static void SafariHandleChooseAction(void);
static void SafariHandleUnknownYesNoBox(void);
static void SafariHandleChooseMove(void);
static void SafariHandleChooseItem(void);
static void SafariHandleChoosePokemon(void);
static void SafariHandleCmd23(void);
static void SafariHandleHealthBarUpdate(void);
static void SafariHandleExpUpdate(void);
static void SafariHandleStatusIconUpdate(void);
static void SafariHandleStatusAnimation(void);
static void SafariHandleStatusXor(void);
static void SafariHandleDataTransfer(void);
static void SafariHandleDMA3Transfer(void);
static void SafariHandlePlayBGM(void);
static void SafariHandleCmd32(void);
static void SafariHandleTwoReturnValues(void);
static void SafariHandleChosenMonReturnValue(void);
static void SafariHandleOneReturnValue(void);
static void SafariHandleOneReturnValue_Duplicate(void);
static void SafariHandleCmd37(void);
static void SafariHandleCmd38(void);
static void SafariHandleCmd39(void);
static void SafariHandleCmd40(void);
static void SafariHandleHitAnimation(void);
static void SafariHandleCmd42(void);
static void SafariHandleEffectivenessSound(void);
static void SafariHandlePlayFanfareOrBGM(void);
static void SafariHandleFaintingCry(void);
static void SafariHandleIntroSlide(void);
static void SafariHandleIntroTrainerBallThrow(void);
static void SafariHandleDrawPartyStatusSummary(void);
static void SafariHandleCmd49(void);
static void SafariHandleCmd50(void);
static void SafariHandleSpriteInvisibility(void);
static void SafariHandleBattleAnimation(void);
static void SafariHandleLinkStandbyMsg(void);
static void SafariHandleResetActionMoveSelection(void);
static void SafariHandleCmd55(void);
static void nullsub_115(void);
static void SafariBufferRunCommand(void);
static void SafariBufferExecCompleted(void);
static void CompleteWhenChosePokeblock(void);
static void (*const gSafariBufferCommands[CONTOLLER_CMDS_COUNT])(void) =
{
SafariHandleGetMonData,
SafariHandleGetRawMonData,
SafariHandleSetMonData,
SafariHandleSetRawMonData,
SafariHandleLoadMonSprite,
SafariHandleSwitchInAnim,
SafariHandleReturnMonToBall,
SafariHandleDrawTrainerPic,
SafariHandleTrainerSlide,
SafariHandleTrainerSlideBack,
SafariHandleFaintAnimation,
SafariHandlePaletteFade,
SafariHandleSuccessBallThrowAnim,
SafariHandleBallThrowAnim,
SafariHandlePause,
SafariHandleMoveAnimation,
SafariHandlePrintString,
SafariHandlePrintStringPlayerOnly,
SafariHandleChooseAction,
SafariHandleUnknownYesNoBox,
SafariHandleChooseMove,
SafariHandleChooseItem,
SafariHandleChoosePokemon,
SafariHandleCmd23,
SafariHandleHealthBarUpdate,
SafariHandleExpUpdate,
SafariHandleStatusIconUpdate,
SafariHandleStatusAnimation,
SafariHandleStatusXor,
SafariHandleDataTransfer,
SafariHandleDMA3Transfer,
SafariHandlePlayBGM,
SafariHandleCmd32,
SafariHandleTwoReturnValues,
SafariHandleChosenMonReturnValue,
SafariHandleOneReturnValue,
SafariHandleOneReturnValue_Duplicate,
SafariHandleCmd37,
SafariHandleCmd38,
SafariHandleCmd39,
SafariHandleCmd40,
SafariHandleHitAnimation,
SafariHandleCmd42,
SafariHandleEffectivenessSound,
SafariHandlePlayFanfareOrBGM,
SafariHandleFaintingCry,
SafariHandleIntroSlide,
SafariHandleIntroTrainerBallThrow,
SafariHandleDrawPartyStatusSummary,
SafariHandleCmd49,
SafariHandleCmd50,
SafariHandleSpriteInvisibility,
SafariHandleBattleAnimation,
SafariHandleLinkStandbyMsg,
SafariHandleResetActionMoveSelection,
SafariHandleCmd55,
nullsub_115
};
static void nullsub_114(void)
{
}
void SetBankFuncToSafariBufferRunCommand(void)
{
gBattleBankFunc[gActiveBank] = SafariBufferRunCommand;
}
static void SafariBufferRunCommand(void)
{
if (gBattleExecBuffer & gBitTable[gActiveBank])
{
if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(gSafariBufferCommands))
gSafariBufferCommands[gBattleBufferA[gActiveBank][0]]();
else
SafariBufferExecCompleted();
}
}
static void HandleInputChooseAction(void)
{
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
switch (gActionSelectionCursor[gActiveBank])
{
case 0:
EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_BALL, 0);
break;
case 1:
EmitTwoReturnValues(1, ACTION_POKEBLOCK_CASE, 0);
break;
case 2:
EmitTwoReturnValues(1, ACTION_GO_NEAR, 0);
break;
case 3:
EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_RUN, 0);
break;
}
SafariBufferExecCompleted();
}
else if (gMain.newKeys & DPAD_LEFT)
{
if (gActionSelectionCursor[gActiveBank] & 1)
{
PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]);
gActionSelectionCursor[gActiveBank] ^= 1;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
}
}
else if (gMain.newKeys & DPAD_RIGHT)
{
if (!(gActionSelectionCursor[gActiveBank] & 1))
{
PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]);
gActionSelectionCursor[gActiveBank] ^= 1;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
}
}
else if (gMain.newKeys & DPAD_UP)
{
if (gActionSelectionCursor[gActiveBank] & 2)
{
PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]);
gActionSelectionCursor[gActiveBank] ^= 2;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
}
}
else if (gMain.newKeys & DPAD_DOWN)
{
if (!(gActionSelectionCursor[gActiveBank] & 2))
{
PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]);
gActionSelectionCursor[gActiveBank] ^= 2;
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
}
}
}
static void CompleteOnBankSpriteCallbackDummy(void)
{
if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy)
SafariBufferExecCompleted();
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(0))
SafariBufferExecCompleted();
}
static void CompleteOnHealthboxSpriteCallbackDummy(void)
{
if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy)
SafariBufferExecCompleted();
}
static void sub_81595E4(void)
{
if (!gPaletteFade.active)
{
gMain.inBattle = FALSE;
gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(gMain.savedCallback);
}
}
static void CompleteOnSpecialAnimDone(void)
{
if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive)
SafariBufferExecCompleted();
}
static void OpenPokeblockCase(void)
{
if (!gPaletteFade.active)
{
gBattleBankFunc[gActiveBank] = CompleteWhenChosePokeblock;
FreeAllWindowBuffers();
sub_81358F4();
}
}
static void CompleteWhenChosePokeblock(void)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
EmitOneReturnValue(1, gScriptItemId);
SafariBufferExecCompleted();
}
}
static void CompleteOnFinishedBattleAnimation(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive)
SafariBufferExecCompleted();
}
static void SafariBufferExecCompleted(void)
{
gBattleBankFunc[gActiveBank] = SafariBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
gBattleBufferA[gActiveBank][0] = CONTOLLER_CMDS_COUNT - 1;
}
else
{
gBattleExecBuffer &= ~gBitTable[gActiveBank];
}
}
static void CompleteOnFinishedStatusAnimation(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive)
SafariBufferExecCompleted();
}
static void SafariHandleGetMonData(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleGetRawMonData(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleSetMonData(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleSetRawMonData(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleLoadMonSprite(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleSwitchInAnim(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleReturnMonToBall(void)
{
SafariBufferExecCompleted();
}
// todo: get rid of it once the struct is declared in a header
struct MonCoords
{
// This would use a bitfield, but sub_8079F44
// uses it as a u8 and casting won't match.
u8 coords; // u8 x:4, y:4;
u8 y_offset;
};
extern const struct MonCoords gTrainerBackPicCoords[];
static void SafariHandleDrawTrainerPic(void)
{
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBank);
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBankIdentity(gActiveBank));
gBankSpriteIds[gActiveBank] = CreateSprite(
&gUnknown_0202499C,
80,
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80,
30);
gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank;
gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBank]].data0 = -2;
gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC;
gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy;
}
static void SafariHandleTrainerSlide(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleTrainerSlideBack(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleFaintAnimation(void)
{
SafariBufferExecCompleted();
}
static void SafariHandlePaletteFade(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleSuccessBallThrowAnim(void)
{
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
}
static void SafariHandleBallThrowAnim(void)
{
u8 ballThrowCaseId = gBattleBufferA[gActiveBank][1];
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE;
DoSpecialBattleAnimation(gActiveBank, gActiveBank, GetBankByIdentity(IDENTITY_OPPONENT_MON1), B_ANIM_SAFARI_BALL_THROW);
gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone;
}
static void SafariHandlePause(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleMoveAnimation(void)
{
SafariBufferExecCompleted();
}
static void SafariHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16*)(&gBattleBufferA[gActiveBank][2]);
BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter;
}
static void SafariHandlePrintStringPlayerOnly(void)
{
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
SafariHandlePrintString();
else
SafariBufferExecCompleted();
}
static void HandleChooseActionAfterDma3(void)
{
if (!IsDma3ManagerBusyWithBgCopy())
{
gBattle_BG0_X = 0;
gBattle_BG0_Y = 160;
gBattleBankFunc[gActiveBank] = HandleInputChooseAction;
}
}
static void SafariHandleChooseAction(void)
{
s32 i;
gBattleBankFunc[gActiveBank] = HandleChooseActionAfterDma3;
BattleHandleAddTextPrinter(gText_SafariZoneMenu, 2);
for (i = 0; i < 4; i++)
ActionSelectionDestroyCursorAt(i);
ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0);
BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo2);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 1);
}
static void SafariHandleUnknownYesNoBox(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleChooseMove(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleChooseItem(void)
{
s32 i;
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gBattleBankFunc[gActiveBank] = OpenPokeblockCase;
gBankInMenu = gActiveBank;
}
static void SafariHandleChoosePokemon(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd23(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleHealthBarUpdate(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleExpUpdate(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleStatusIconUpdate(void)
{
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_SAFARI_BALLS_TEXT);
SafariBufferExecCompleted();
}
static void SafariHandleStatusAnimation(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleStatusXor(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleDataTransfer(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleDMA3Transfer(void)
{
SafariBufferExecCompleted();
}
static void SafariHandlePlayBGM(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd32(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleTwoReturnValues(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleChosenMonReturnValue(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleOneReturnValue(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleOneReturnValue_Duplicate(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd37(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd38(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd39(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd40(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleHitAnimation(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd42(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleEffectivenessSound(void)
{
s8 pan;
if (GetBankSide(gActiveBank) == SIDE_PLAYER)
pan = PAN_SIDE_PLAYER;
else
pan = PAN_SIDE_OPPONENT;
PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan);
SafariBufferExecCompleted();
}
static void SafariHandlePlayFanfareOrBGM(void)
{
if (gBattleBufferA[gActiveBank][3])
{
BattleMusicStop();
PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
else
{
PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8));
}
SafariBufferExecCompleted();
}
static void SafariHandleFaintingCry(void)
{
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES);
PlayCry1(species, 25);
SafariBufferExecCompleted();
}
static void SafariHandleIntroSlide(void)
{
HandleIntroSlide(gBattleBufferA[gActiveBank][1]);
gUnknown_020243FC |= 1;
SafariBufferExecCompleted();
}
static void SafariHandleIntroTrainerBallThrow(void)
{
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_SAFARI_ALL_TEXT);
sub_8076918(gActiveBank);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]);
gBattleBankFunc[gActiveBank] = CompleteOnHealthboxSpriteCallbackDummy;
}
static void SafariHandleDrawPartyStatusSummary(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd49(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd50(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleSpriteInvisibility(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleBattleAnimation(void)
{
u8 animationId = gBattleBufferA[gActiveBank][1];
u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8);
if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument))
SafariBufferExecCompleted();
else
gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation;
}
static void SafariHandleLinkStandbyMsg(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleResetActionMoveSelection(void)
{
SafariBufferExecCompleted();
}
static void SafariHandleCmd55(void)
{
gBattleOutcome = gBattleBufferA[gActiveBank][1];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
SafariBufferExecCompleted();
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_WILD))
gBattleBankFunc[gActiveBank] = sub_81595E4;
}
static void nullsub_115(void)
{
}