fix conflicts

This commit is contained in:
DizzyEggg 2018-03-09 22:54:57 +01:00
commit 711a345fd4
49 changed files with 2719 additions and 3928 deletions

View File

@ -4894,7 +4894,7 @@ sub_813A46C: @ 813A46C
lsrs r0, 24
mov r1, sp
movs r2, 0
bl sub_81AE860
bl ListMenuGetScrollAndRow
ldr r1, =gUnknown_0203AB68
mov r0, sp
ldrh r0, [r0]
@ -4903,7 +4903,7 @@ sub_813A46C: @ 813A46C
lsls r0, 24
lsrs r0, 24
mov r1, sp
bl sub_81AE838
bl ListMenuGetCurrentItemArrayId
ldrh r0, [r4, 0x1E]
ldr r5, =gUnknown_0203AB6A
ldrh r1, [r5]
@ -5007,7 +5007,7 @@ sub_813A570: @ 813A570
lsls r0, 24
lsrs r0, 24
mov r1, sp
bl sub_81AE838
bl ListMenuGetCurrentItemArrayId
ldrh r0, [r4, 0x1E]
mov r1, sp
ldrh r1, [r1]
@ -5019,7 +5019,7 @@ sub_813A570: @ 813A570
lsrs r0, 24
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldr r0, =gUnknown_0203AB64
ldr r0, [r0]
bl Free
@ -6012,7 +6012,7 @@ sub_813ADD4: @ 813ADD4
adds r4, 0x16
add r1, sp, 0x14
adds r2, r4, 0
bl sub_81AE860
bl ListMenuGetScrollAndRow
ldrh r0, [r6, 0x22]
lsls r0, 24
lsrs r0, 24
@ -6173,7 +6173,7 @@ sub_813AF48: @ 813AF48
lsrs r0, 24
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldr r0, =gUnknown_0203AB64
ldr r0, [r0]
bl Free

View File

@ -903,7 +903,7 @@ sub_8160EA0: @ 8160EA0
ldrb r0, [r0]
ldr r1, =gUnknown_0203BC38
adds r2, r1, 0x2
bl sub_81AE6C8
bl DestroyListMenuTask
bl FreeAllWindowBuffers
ldr r0, [r4]
bl Free
@ -988,7 +988,7 @@ sub_8160F50: @ 8160F50
ldr r4, =gUnknown_0203BC38
adds r2, r4, 0x2
adds r1, r4, 0
bl sub_81AE860
bl ListMenuGetScrollAndRow
movs r0, 0x2
negs r0, r0
cmp r5, r0

File diff suppressed because it is too large Load Diff

View File

@ -1021,7 +1021,7 @@ sub_816B674: @ 816B674
mov r8, r1
adds r1, r7, 0
mov r2, r8
bl sub_81AE860
bl ListMenuGetScrollAndRow
movs r0, 0x2
negs r0, r0
cmp r6, r0
@ -1050,7 +1050,7 @@ _0816B6EA:
ldrb r0, [r4, 0xA]
adds r1, r7, 0
mov r2, r8
bl sub_81AE6C8
bl DestroyListMenuTask
movs r0, 0
bl schedule_bg_copy_tilemap_to_vram
mov r1, r8
@ -1129,7 +1129,7 @@ sub_816B798: @ 816B798
ldrb r0, [r4, 0xA]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
movs r0, 0
bl schedule_bg_copy_tilemap_to_vram
bl sub_81D1EC0
@ -2476,7 +2476,7 @@ sub_816C30C: @ 816C30C
ldr r1, =gUnknown_0203BCBA
subs r4, r1, 0x2
adds r2, r4, 0
bl sub_81AE860
bl ListMenuGetScrollAndRow
ldrh r1, [r4, 0x2]
ldrh r0, [r4]
adds r1, r0
@ -2497,7 +2497,7 @@ _0816C35C:
ldrb r0, [r4, 0xA]
ldr r1, =gUnknown_0203BCBA
subs r2, r1, 0x2
bl sub_81AE860
bl ListMenuGetScrollAndRow
movs r0, 0x2
negs r0, r0
cmp r6, r0
@ -2584,7 +2584,7 @@ sub_816C400: @ 816C400
ldrb r0, [r5, 0xA]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldr r0, =gUnknown_0203BCC4
ldr r0, [r0]
movs r1, 0xCD
@ -2691,7 +2691,7 @@ sub_816C4FC: @ 816C4FC
ldrb r0, [r4, 0xA]
ldr r1, =gUnknown_0203BCBA
subs r2, r1, 0x2
bl sub_81AE860
bl ListMenuGetScrollAndRow
b _0816C57E
.pool
_0816C530:
@ -2702,7 +2702,7 @@ _0816C530:
ldr r1, =gUnknown_0203BCBA
subs r4, r1, 0x2
adds r2, r4, 0
bl sub_81AE860
bl ListMenuGetScrollAndRow
ldr r0, =gUnknown_0203BCC4
ldr r0, [r0]
movs r1, 0xCD
@ -2776,7 +2776,7 @@ sub_816C5A0: @ 816C5A0
ldrb r0, [r2, 0xA]
adds r1, r4, 0x2
adds r2, r4, 0
bl sub_81AE6C8
bl DestroyListMenuTask
cmp r5, 0
bne _0816C60A
ldr r1, =gUnknown_0203BCC4
@ -3359,7 +3359,7 @@ sub_816CB04: @ 816CB04
ldrb r0, [r5, 0xA]
adds r1, r4, 0x2
adds r2, r4, 0
bl sub_81AE6C8
bl DestroyListMenuTask
bl sub_816C110
bl sub_816C140
bl sub_816BD04

View File

@ -3469,7 +3469,7 @@ sub_81C5B4C: @ 81C5B4C
ldr r4, =gUnknown_0203CF38
subs r2, r4, 0x2
adds r1, r4, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldr r0, =gUnknown_0203CF2C
ldr r0, [r0]
ldr r0, [r0]
@ -3545,7 +3545,7 @@ _081C5C12:
adds r1, r4, 0
adds r1, 0x8
adds r2, r4, 0x6
bl sub_81AE860
bl ListMenuGetScrollAndRow
ldrh r1, [r4, 0x8]
ldrh r0, [r4, 0x6]
adds r1, r0
@ -3572,7 +3572,7 @@ _081C5C5C:
mov r8, r1
mov r2, r8
subs r2, 0x2
bl sub_81AE860
bl ListMenuGetScrollAndRow
movs r0, 0x2
negs r0, r0
cmp r6, r0
@ -4642,7 +4642,7 @@ sub_81C65CC: @ 81C65CC
ldrb r0, [r4]
adds r1, r6, 0
adds r2, r7, 0
bl sub_81AE6C8
bl DestroyListMenuTask
bl sub_81C5924
bl sub_81C59BC
bl sub_81C5314
@ -4953,7 +4953,7 @@ sub_81C68B0: @ 81C68B0
ldrb r0, [r4]
ldr r1, =gUnknown_0203CF38
subs r2, r1, 0x2
bl sub_81AE860
bl ListMenuGetScrollAndRow
b _081C6940
.pool
_081C68F8:
@ -4964,7 +4964,7 @@ _081C68F8:
ldr r4, =gUnknown_0203CF38
subs r2, r4, 0x2
adds r1, r4, 0
bl sub_81AE860
bl ListMenuGetScrollAndRow
movs r0, 0
bl sub_81C7028
subs r4, 0x8
@ -5054,7 +5054,7 @@ _081C69A8:
ldrb r0, [r5]
adds r1, r7, 0
mov r2, r8
bl sub_81AE6C8
bl DestroyListMenuTask
movs r3, 0x2
ldrsh r0, [r5, r3]
cmp r0, r4
@ -5109,7 +5109,7 @@ sub_81C6A14: @ 81C6A14
ldrb r0, [r4]
adds r1, r5, 0
adds r2, r7, 0
bl sub_81AE6C8
bl DestroyListMenuTask
movs r0, 0x2
ldrsh r2, [r4, r0]
ldrh r0, [r5]

View File

@ -1192,7 +1192,7 @@ sub_8012F64: @ 8012F64
ldrb r0, [r4, 0x12]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldrb r0, [r4, 0x10]
bl ClearWindowTilemap
ldrb r0, [r4, 0xF]
@ -2394,7 +2394,7 @@ _08013A8C:
ldrb r0, [r6, 0xE]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldrb r0, [r6, 0xC]
bl ClearWindowTilemap
ldrb r0, [r6, 0xB]
@ -4511,7 +4511,7 @@ _08014E16:
ldrb r0, [r5, 0x12]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
movs r0, 0
bl CopyBgTilemapBufferToVram
ldrb r0, [r5, 0xF]
@ -4567,7 +4567,7 @@ _08014EA8:
ldrb r0, [r5, 0x12]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
movs r0, 0
bl CopyBgTilemapBufferToVram
ldrb r0, [r5, 0xF]
@ -4923,7 +4923,7 @@ _08015204:
ldrb r0, [r7, 0xE]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
movs r0, 0
bl CopyBgTilemapBufferToVram
ldrb r0, [r7, 0xD]
@ -5292,7 +5292,7 @@ _08015564:
ldrb r0, [r5, 0xE]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
movs r0, 0
bl CopyBgTilemapBufferToVram
ldrb r0, [r5, 0xB]
@ -8545,7 +8545,7 @@ _08017228:
ldrb r0, [r4]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldrb r0, [r5]
movs r1, 0x1
bl sub_819746C
@ -8565,7 +8565,7 @@ _08017264:
ldrb r0, [r6]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldrb r0, [r5]
movs r1, 0x1
bl sub_819746C
@ -8669,7 +8669,7 @@ _0801733E:
ldrb r0, [r4]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldrb r0, [r6]
bl RemoveWindow
mov r7, r9
@ -8691,7 +8691,7 @@ _08017368:
ldrb r0, [r1]
movs r1, 0
movs r2, 0
bl sub_81AE6C8
bl DestroyListMenuTask
ldrb r0, [r6]
bl RemoveWindow
mov r3, r9

View File

@ -1985,7 +1985,7 @@ _080E0AEA:
adds r1, r2, r3
subs r3, 0x2
adds r2, r3
bl sub_81AE860
bl ListMenuGetScrollAndRow
movs r0, 0x2
negs r0, r0
cmp r5, r0

View File

@ -0,0 +1,2 @@
gUnknown_03006300
gMultiuseListMenuTemplate

View File

@ -563,6 +563,14 @@ struct BattleStruct
#define IS_MOVE_PHYSICAL(moveType)(moveType < TYPE_MYSTERY)
#define IS_MOVE_SPECIAL(moveType)(moveType > TYPE_MYSTERY)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0))
#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type))
#define SET_BATTLER_TYPE(battlerId, type) \
{ \
gBattleMons[battlerId].type1 = type; \
gBattleMons[battlerId].type2 = type; \
}
#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

View File

@ -229,13 +229,62 @@ extern const u8* const gPokeblockWasTooXStringTable[];
extern const u8* const gRefereeStringsTable[];
extern const u8* const gStatNamesTable2[];
extern const u8 gText_PkmnIsEvolving[];
extern const u8 gText_CongratsPkmnEvolved[];
extern const u8 gText_PkmnStoppedEvolving[];
extern const u8 gText_EllipsisQuestionMark[];
extern const u8 gText_WhatWillPkmnDo[];
extern const u8 gText_WhatWillPkmnDo2[];
extern const u8 gText_WhatWillWallyDo[];
extern const u8 gText_LinkStandby[];
extern const u8 gText_BattleMenu[];
extern const u8 gText_SafariZoneMenu[];
extern const u8 gText_MoveInterfacePP[];
extern const u8 gText_MoveInterfaceType[];
extern const u8 gText_MoveInterfacePpType[];
extern const u8 gText_MoveInterfaceDynamicColors[];
extern const u8 gText_WhichMoveToForget4[];
extern const u8 gText_BattleYesNoChoice[];
extern const u8 gText_BattleSwitchWhich[];
extern const u8 gText_BattleSwitchWhich2[];
extern const u8 gText_BattleSwitchWhich3[];
extern const u8 gText_BattleSwitchWhich4[];
extern const u8 gText_BattleSwitchWhich5[];
extern const u8 gText_SafariBalls[];
extern const u8 gText_SafariBallLeft[];
extern const u8 gText_SpaceAndSpace[];
extern const u8 gText_CommaSpace[];
extern const u8 gText_Space2[];
extern const u8 gText_ScrollTextUp[];
extern const u8 gText_NewLine[];
extern const u8 gText_Are[];
extern const u8 gText_Are2[];
extern const u8 gText_BadEgg[];
extern const u8 gText_BattleWallyName[];
extern const u8 gText_Win[];
extern const u8 gText_Loss[];
extern const u8 gText_Draw[];
extern const u8 gText_StatRose[];
extern const u8 gText_PkmnsStatChanged2[];
extern const u8 gText_PkmnGettingPumped[];
extern const u8 gText_PkmnShroudedInMist[];
extern const u8 gText_BattleWallyName[];
extern const u8 gText_PkmnsXPreventsSwitching[];
extern const u8 gText_TheGreatNewHope[];
extern const u8 gText_WillChampinshipDreamComeTrue[];
extern const u8 gText_AFormerChampion[];
extern const u8 gText_ThePreviousChampion[];
extern const u8 gText_TheUnbeatenChampion[];
extern const u8 gText_PlayerMon1Name[];
extern const u8 gText_Vs[];
extern const u8 gText_OpponentMon1Name[];
extern const u8 gText_Mind[];
extern const u8 gText_Skill[];
extern const u8 gText_Body[];
extern const u8 gText_Judgement[];
extern const u8 gText_EmptyString3[];
extern const u8 gText_RecordBattleToPass[];
extern const u8 gText_BattleRecordedOnPass[];
extern const u8 gText_BattleTourney[];
extern const u16 gMissStringIds[];
extern const u16 gTrappingMoves[];

View File

@ -49,36 +49,36 @@ void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move);
void PressurePPLoseOnUsingPerishSong(u8 bankAtk);
void PressurePPLoseOnUsingImprision(u8 bankAtk);
void MarkAllBattlersForControllerExec(void); // unused
void MarkBattlerForControllerExec(u8 bank);
void MarkBattlerForControllerExec(u8 battlerId);
void sub_803F850(u8 arg0);
void CancelMultiTurnMoves(u8 bank);
bool8 WasUnableToUseMove(u8 bank);
void PrepareStringBattle(u16 stringId, u8 bank);
void CancelMultiTurnMoves(u8 battlerId);
bool8 WasUnableToUseMove(u8 battlerId);
void PrepareStringBattle(u16 stringId, u8 battlerId);
void ResetSentPokesToOpponentValue(void);
void sub_803F9EC(u8 bank);
void sub_803FA70(u8 bank);
void sub_803F9EC(u8 battlerId);
void sub_803FA70(u8 battlerId);
void BattleScriptPush(const u8* bsPtr);
void BattleScriptPushCursor(void);
void BattleScriptPop(void);
u8 TrySetCantSelectMoveBattleScript(void);
u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check);
u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check);
bool8 AreAllMovesUnusable(void);
u8 GetImprisonedMovesCount(u8 bank, u16 move);
u8 GetImprisonedMovesCount(u8 battlerId, u16 move);
u8 UpdateTurnCounters(void);
u8 TurnBasedEffects(void);
bool8 HandleWishPerishSongOnTurnEnd(void);
bool8 HandleFaintedMonActions(void);
void TryClearRageStatuses(void);
u8 AtkCanceller_UnableToUseMove(void);
bool8 sub_80423F4(u8 bank, u8 r1, u8 r2);
u8 CastformDataTypeChange(u8 bank);
u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg);
bool8 sub_80423F4(u8 battlerId, u8 r1, u8 r2);
u8 CastformDataTypeChange(u8 battlerId);
u8 AbilityBattleEffects(u8 caseID, u8 battlerId, u8 ability, u8 special, u16 moveArg);
void BattleScriptExecute(const u8* BS_ptr);
void BattleScriptPushCursorAndCallback(const u8* BS_ptr);
u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u8 bank);
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u8 battlerId);
void HandleAction_RunBattleScript(void);
u8 GetMoveTarget(u16 move, u8 useMoveTarget);
u8 GetMoveTarget(u16 move, u8 setTarget);
u8 IsMonDisobedient(void);
#endif // GUARD_BATTLE_UTIL_H

View File

@ -4,9 +4,11 @@
#define LIST_NOTHING_CHOSEN -1
#define LIST_B_PRESSED -2
// Exported type declarations
#define LIST_NO_MULTIPLE_SCROLL 0
#define LIST_MULTIPLE_SCROLL_DPAD 1
#define LIST_MULTIPLE_SCROLL_L_R 2
// Exported RAM declarations
struct ListMenu;
struct ListMenuItem
{
@ -14,33 +16,31 @@ struct ListMenuItem
s32 id;
};
struct ListMenu;
struct ListMenuTemplate
{
const struct ListMenuItem *items;
void (* moveCursorFunc)(u32, bool8, struct ListMenu *);
void (* unk_08)(u8, s32, u8);
void (* moveCursorFunc)(s32, bool8, struct ListMenu *);
void (* unk_08)(u8 windowId, s32 itemId, u8 y);
u16 totalItems;
u16 maxShowed;
u8 unk_10;
u8 windowId;
u8 unk_11;
u8 unk_12;
u8 cursor_Y;
u32 upText_Y:4; // x1, x2, x4, x8 = xF
u32 cursorColor:4; // x10, x20, x40, x80 = xF0
u32 fillColor:4; // x100, x200, x400, x800 = xF00
u32 cursorShadowColor:4; // x1000, x2000, x4000, x8000 = xF000
u32 unk_16_0:1; // x10000
u32 spaceBetweenItems:6; // x20000, x40000, x80000, x100000, x200000, x400000 = x7E0000
u32 unk_16_7:1; // x800000
u32 unk_17_0:6; // x1000000, x2000000, x4000000, x8000000, x10000000, x20000000 = x3F000000
u32 cursorKind:2; // x40000000, x80000000
u8 cursor_X;
u8 upText_Y:4; // x1, x2, x4, x8 = xF
u8 cursorPal:4; // x10, x20, x40, x80 = xF0
u8 fillValue:4; // x1, x2, x4, x8 = xF
u8 cursorShadowPal:4; // x10, x20, x40, x80 = xF0
u8 lettersSpacing:3;
u8 unk_16_3:3;
u8 scrollMultiple:2; // x40, x80 = xC0
u8 fontId:6; // x1, x2, x4, x8, x10, x20 = x3F
u8 cursorKind:2; // x40, x80
};
struct ListMenu
{
struct ListMenuTemplate _template;
struct ListMenuTemplate template;
u16 scrollOffset;
u16 selectedRow;
u8 unk_1C;
@ -49,14 +49,30 @@ struct ListMenu
u8 unk_1F;
};
struct UnknownListMenuWindowStruct
{
u8 x;
u8 y;
u8 width;
u8 height;
u8 palNum;
};
extern struct ListMenuTemplate gMultiuseListMenuTemplate;
// Exported ROM declarations
u8 ListMenuInit(struct ListMenuTemplate *template, u16 cursorPage, u16 cursorPosition);
s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum);
u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow);
u8 ListMenuInitWithWindows(struct ListMenuTemplate *listMenuTemplate, struct UnknownListMenuWindowStruct *arg1, u16 scrollOffset, u16 selectedRow);
s32 ListMenuHandleInputGetItemId(u8 listTaskId);
void sub_81AE860(u8 listTaskId, u16 *a1, u16 *a2);
void sub_81AE6C8(u8 listTaskId, u16 *a1, u16 *a2);
u8 ListMenuGetYCoordForPrintingArrowCursor(u8);
void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow);
void sub_81AE70C(u8 listTaskId);
void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillValue, u8 cursorShadowPal);
void ChangeListMenuCoords(u8 listTaskId, u8 x, u8 y);
s32 ListMenuTestInput(struct ListMenuTemplate *template, u32 scrollOffset, u32 selectedRow, u16 keys, u16 *newScrollOffset, u16 *newSelectedRow);
void ListMenuGetCurrentItemArrayId(u8 listTaskId, u16 *arrayId);
void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow);
u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId);
void sub_81AF028(u8 cursorPal, u8 fillValue, u8 cursorShadowPal);
void sub_81AF078(s32 arg0, u8 arg1, struct ListMenu *list);
#endif //GUARD_LIST_MENU_H

View File

@ -7,16 +7,31 @@
// Exported ROM declarations
struct ArrowStruct {
struct ArrowStruct
{
u8 unk0[6];
u16 unk6[4];
u8 unkE;
};
struct CursorStruct
{
u8 unk0;
u8 unk1;
u16 unk2;
u16 unk4;
u16 unk6;
u16 unk8;
u8 unkA;
};
void Task_ScrollIndicatorArrowPairOnMainMenu(u8);
u8 AddScrollIndicatorArrowPairParametrized(u8, u8, u8, u8, s32, u16, u16, u16 *);
void RemoveScrollIndicatorArrowPair(u8);
u8 AddScrollIndicatorArrowPair(const struct ArrowStruct*, void*);
void sub_81AF15C(u8, u8, u8);
void ListMenuRemoveCursorObject(u8 taskId, u32 cursorKind);
void ListMenuUpdateCursorObject(u8 taskId, u16 x, u16 y, u32 cursorKind);
u8 ListMenuAddCursorObjectInternal(struct CursorStruct *cursor, u32 cursorKind);
#endif //GUARD_MENU_INDICATORS_H

View File

@ -112,9 +112,6 @@ extern const u8 gText_Cancel4[];
extern const u8 gText_IsThisTheCorrectTime[];
extern const u8 gText_PkmnFainted3[];
extern const u8 gText_Coins[];
extern const u8 gText_Draw[];
extern const u8 gText_Loss[];
extern const u8 gText_Win[];
extern const u8 gText_Var1AteTheVar2[];
extern const u8 gText_Var1HappilyAteVar2[];

View File

@ -247,7 +247,7 @@ SECTIONS {
src/menu.o(.text);
asm/battle_frontier_2.o(.text);
src/item_menu.o(.text);
asm/list_menu.o(.text);
src/list_menu.o(.text);
asm/menu_indicators.o(.text);
src/unk_text_util.o(.text);
src/save_location.o(.text);

View File

@ -12,10 +12,6 @@
#include "util.h"
#include "constants/battle_ai.h"
#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8)
#define AIScriptReadPtr(ptr) (const u8*) AIScriptRead32(ptr)
#define AI_ACTION_DONE 0x0001
#define AI_ACTION_FLEE 0x0002
#define AI_ACTION_WATCH 0x0004
@ -652,7 +648,7 @@ static void BattleAICmd_if_random_less_than(void)
u16 random = Random();
if (random % 256 < gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -662,7 +658,7 @@ static void BattleAICmd_if_random_greater_than(void)
u16 random = Random();
if (random % 256 > gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -672,7 +668,7 @@ static void BattleAICmd_if_random_equal(void)
u16 random = Random();
if (random % 256 == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -682,7 +678,7 @@ static void BattleAICmd_if_random_not_equal(void)
u16 random = Random();
if (random % 256 != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -707,7 +703,7 @@ static void BattleAICmd_if_hp_less_than(void)
battlerId = gBattlerTarget;
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) < gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
@ -722,7 +718,7 @@ static void BattleAICmd_if_hp_more_than(void)
battlerId = gBattlerTarget;
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) > gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
@ -737,7 +733,7 @@ static void BattleAICmd_if_hp_equal(void)
battlerId = gBattlerTarget;
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) == gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
@ -752,7 +748,7 @@ static void BattleAICmd_if_hp_not_equal(void)
battlerId = gBattlerTarget;
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) != gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
@ -767,10 +763,10 @@ static void BattleAICmd_if_status(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gBattleMons[battlerId].status1 & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -785,10 +781,10 @@ static void BattleAICmd_if_not_status(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gBattleMons[battlerId].status1 & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -803,10 +799,10 @@ static void BattleAICmd_if_status2(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gBattleMons[battlerId].status2 & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -821,10 +817,10 @@ static void BattleAICmd_if_not_status2(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gBattleMons[battlerId].status2 & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -839,10 +835,10 @@ static void BattleAICmd_if_status3(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gStatuses3[battlerId] & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -857,10 +853,10 @@ static void BattleAICmd_if_not_status3(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gStatuses3[battlerId] & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -876,10 +872,10 @@ static void BattleAICmd_if_side_affecting(void)
battlerId = gBattlerTarget;
side = GET_BATTLER_SIDE(battlerId);
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gSideStatuses[side] & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -895,10 +891,10 @@ static void BattleAICmd_if_not_side_affecting(void)
battlerId = gBattlerTarget;
side = GET_BATTLER_SIDE(battlerId);
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gSideStatuses[side] & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -906,7 +902,7 @@ static void BattleAICmd_if_not_side_affecting(void)
static void BattleAICmd_if_less_than(void)
{
if (AI_THINKING_STRUCT->funcResult < gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -914,7 +910,7 @@ static void BattleAICmd_if_less_than(void)
static void BattleAICmd_if_more_than(void)
{
if (AI_THINKING_STRUCT->funcResult > gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -922,7 +918,7 @@ static void BattleAICmd_if_more_than(void)
static void BattleAICmd_if_equal(void)
{
if (AI_THINKING_STRUCT->funcResult == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -930,80 +926,80 @@ static void BattleAICmd_if_equal(void)
static void BattleAICmd_if_not_equal(void)
{
if (AI_THINKING_STRUCT->funcResult != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
static void BattleAICmd_if_less_than_ptr(void)
{
const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *value = T1_READ_PTR(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->funcResult < *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
static void BattleAICmd_if_more_than_ptr(void)
{
const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *value = T1_READ_PTR(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->funcResult > *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
static void BattleAICmd_if_equal_ptr(void)
{
const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *value = T1_READ_PTR(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->funcResult == *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
static void BattleAICmd_if_not_equal_ptr(void)
{
const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *value = T1_READ_PTR(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->funcResult != *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
static void BattleAICmd_if_move(void)
{
u16 move = AIScriptRead16(gAIScriptPtr + 1);
u16 move = T1_READ_16(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->moveConsidered == move)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
static void BattleAICmd_if_not_move(void)
{
u16 move = AIScriptRead16(gAIScriptPtr + 1);
u16 move = T1_READ_16(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->moveConsidered != move)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
static void BattleAICmd_if_in_bytes(void)
{
const u8 *ptr = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFF)
{
if (AI_THINKING_STRUCT->funcResult == *ptr)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
return;
}
ptr++;
@ -1013,7 +1009,7 @@ static void BattleAICmd_if_in_bytes(void)
static void BattleAICmd_if_not_in_bytes(void)
{
const u8 *ptr = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFF)
{
@ -1024,18 +1020,18 @@ static void BattleAICmd_if_not_in_bytes(void)
}
ptr++;
}
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
}
static void BattleAICmd_if_in_hwords(void)
{
const u16 *ptr = (const u16 *)AIScriptReadPtr(gAIScriptPtr + 1);
const u16 *ptr = (const u16 *)T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFFFF)
{
if (AI_THINKING_STRUCT->funcResult == *ptr)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
return;
}
ptr++;
@ -1045,7 +1041,7 @@ static void BattleAICmd_if_in_hwords(void)
static void BattleAICmd_if_not_in_hwords(void)
{
const u16 *ptr = (u16 *)AIScriptReadPtr(gAIScriptPtr + 1);
const u16 *ptr = (u16 *)T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFFFF)
{
@ -1056,7 +1052,7 @@ static void BattleAICmd_if_not_in_hwords(void)
}
ptr++;
}
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
}
static void BattleAICmd_if_user_has_attacking_move(void)
@ -1072,7 +1068,7 @@ static void BattleAICmd_if_user_has_attacking_move(void)
if (i == 4)
gAIScriptPtr += 5;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
static void BattleAICmd_if_user_has_no_attacking_moves(void)
@ -1088,7 +1084,7 @@ static void BattleAICmd_if_user_has_no_attacking_moves(void)
if (i != 4)
gAIScriptPtr += 5;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
static void BattleAICmd_get_turn_count(void)
@ -1237,7 +1233,7 @@ static void BattleAICmd_get_last_used_bank_move(void)
static void BattleAICmd_if_equal_(void) // same as if_equal
{
if (gAIScriptPtr[1] == AI_THINKING_STRUCT->funcResult)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1245,7 +1241,7 @@ static void BattleAICmd_if_equal_(void) // same as if_equal
static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
{
if (gAIScriptPtr[1] != AI_THINKING_STRUCT->funcResult)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1253,7 +1249,7 @@ static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
static void BattleAICmd_if_user_goes(void)
{
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1261,7 +1257,7 @@ static void BattleAICmd_if_user_goes(void)
static void BattleAICmd_if_user_doesnt_go(void)
{
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1527,7 +1523,7 @@ static void BattleAICmd_if_type_effectiveness(void)
damageVar = gBattleMoveDamage;
if (damageVar == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1559,7 +1555,7 @@ static void BattleAICmd_if_status_in_party(void)
party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
statusToCompareTo = T1_READ_32(gAIScriptPtr + 2);
for (i = 0; i < PARTY_SIZE; i++)
{
@ -1569,7 +1565,7 @@ static void BattleAICmd_if_status_in_party(void)
if (species != SPECIES_NONE && species != SPECIES_EGG && hp != 0 && status == statusToCompareTo)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
return;
}
}
@ -1596,7 +1592,7 @@ static void BattleAICmd_if_status_not_in_party(void)
party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
statusToCompareTo = T1_READ_32(gAIScriptPtr + 2);
for (i = 0; i < PARTY_SIZE; i++)
{
@ -1610,7 +1606,7 @@ static void BattleAICmd_if_status_not_in_party(void)
}
}
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
}
static void BattleAICmd_get_weather(void)
@ -1630,7 +1626,7 @@ static void BattleAICmd_get_weather(void)
static void BattleAICmd_if_effect(void)
{
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1638,7 +1634,7 @@ static void BattleAICmd_if_effect(void)
static void BattleAICmd_if_not_effect(void)
{
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1653,7 +1649,7 @@ static void BattleAICmd_if_stat_level_less_than(void)
battlerId = gBattlerTarget;
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -1668,7 +1664,7 @@ static void BattleAICmd_if_stat_level_more_than(void)
battlerId = gBattlerTarget;
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -1683,7 +1679,7 @@ static void BattleAICmd_if_stat_level_equal(void)
battlerId = gBattlerTarget;
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -1698,7 +1694,7 @@ static void BattleAICmd_if_stat_level_not_equal(void)
battlerId = gBattlerTarget;
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -1727,7 +1723,7 @@ static void BattleAICmd_if_can_faint(void)
gBattleMoveDamage = 1;
if (gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -1754,7 +1750,7 @@ static void BattleAICmd_if_cant_faint(void)
// this macro is missing the damage 0 = 1 assumption.
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -1779,7 +1775,7 @@ static void BattleAICmd_if_has_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
case AI_USER_PARTNER:
@ -1803,7 +1799,7 @@ static void BattleAICmd_if_has_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
case AI_TARGET:
@ -1820,7 +1816,7 @@ static void BattleAICmd_if_has_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
}
@ -1847,7 +1843,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
case AI_TARGET:
@ -1864,7 +1860,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
}
@ -1886,7 +1882,7 @@ static void BattleAICmd_if_has_move_with_effect(void)
if (i == 4)
gAIScriptPtr += 7;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
break;
case AI_TARGET:
case AI_TARGET_PARTNER:
@ -1899,7 +1895,7 @@ static void BattleAICmd_if_has_move_with_effect(void)
if (i == 4)
gAIScriptPtr += 7;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
break;
}
}
@ -1920,7 +1916,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
if (i != 4)
gAIScriptPtr += 7;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
break;
case AI_TARGET:
case AI_TARGET_PARTNER:
@ -1932,7 +1928,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
if (i != 4)
gAIScriptPtr += 7;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
break;
}
}
@ -1953,7 +1949,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
gAIScriptPtr += 7;
return;
}
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
return;
}
else if (gAIScriptPtr[2] != 1) // ignore the macro if its not 0 or 1.
@ -1963,7 +1959,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
}
else if (gDisableStructs[battlerId].encoredMove != 0)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
return;
}
gAIScriptPtr += 7;
@ -1976,7 +1972,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void)
case 0:
if (gDisableStructs[gActiveBattler].disabledMove == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -1984,7 +1980,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void)
case 1:
if (gDisableStructs[gActiveBattler].encoredMove == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -2005,7 +2001,7 @@ static void BattleAICmd_if_random_safari_flee(void)
u8 safariFleeRate = gBattleStruct->field_7B * 5; // safari flee rate, from 0-20
if ((u8)(Random() % 100) < safariFleeRate)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -2048,7 +2044,7 @@ static void BattleAICmd_if_holds_item(void)
var1 = gAIScriptPtr[3];
if ((var1 | var2) == item)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -2183,12 +2179,12 @@ static void BattleAICmd_nullsub_57(void)
static void BattleAICmd_call(void)
{
AIStackPushVar(gAIScriptPtr + 5);
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
static void BattleAICmd_goto(void)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
static void BattleAICmd_end(void)
@ -2204,7 +2200,7 @@ static void BattleAICmd_if_level_cond(void)
case 0: // greater than
if (gBattleMons[sBattler_AI].level > gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -2212,7 +2208,7 @@ static void BattleAICmd_if_level_cond(void)
case 1: // less than
if (gBattleMons[sBattler_AI].level < gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -2220,7 +2216,7 @@ static void BattleAICmd_if_level_cond(void)
case 2: // equal
if (gBattleMons[sBattler_AI].level == gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -2231,7 +2227,7 @@ static void BattleAICmd_if_level_cond(void)
static void BattleAICmd_if_target_taunted(void)
{
if (gDisableStructs[gBattlerTarget].tauntTimer1 != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -2239,7 +2235,7 @@ static void BattleAICmd_if_target_taunted(void)
static void BattleAICmd_if_target_not_taunted(void)
{
if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -2247,7 +2243,7 @@ static void BattleAICmd_if_target_not_taunted(void)
static void BattleAICmd_if_target_is_ally(void)
{
if ((sBattler_AI & BIT_SIDE) == (gBattlerTarget & BIT_SIDE))
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -2257,7 +2253,7 @@ static void BattleAICmd_if_flash_fired(void)
u8 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
if (gBattleResources->flags->flags[battlerId] & UNKNOWN_FLAG_FLASH_FIRE)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}

View File

@ -9,8 +9,6 @@
#include "util.h"
#include "constants/items.h"
extern const u8 * const gItemEffectTable[]; // todo: fix once struct is declared
// this file's functions
static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng);
static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent);

View File

@ -19,10 +19,6 @@
// 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_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
extern u16 gBattle_WIN0H;
@ -352,7 +348,7 @@ static void ScriptCmd_loadspritegfx(void)
u16 index;
sBattleAnimScriptPtr++;
index = SCRIPT_READ_16(sBattleAnimScriptPtr);
index = T1_READ_16(sBattleAnimScriptPtr);
LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)]);
LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(index)]);
sBattleAnimScriptPtr += 2;
@ -366,7 +362,7 @@ static void ScriptCmd_unloadspritegfx(void)
u16 index;
sBattleAnimScriptPtr++;
index = SCRIPT_READ_16(sBattleAnimScriptPtr);
index = T1_READ_16(sBattleAnimScriptPtr);
FreeSpriteTilesByTag(gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)].tag);
FreeSpritePaletteByTag(gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)].tag);
sBattleAnimScriptPtr += 2;
@ -382,7 +378,7 @@ static void ScriptCmd_createsprite(void)
s16 subpriority;
sBattleAnimScriptPtr++;
template = (const struct SpriteTemplate *)(SCRIPT_READ_32(sBattleAnimScriptPtr));
template = (const struct SpriteTemplate *)(T2_READ_32(sBattleAnimScriptPtr));
sBattleAnimScriptPtr += 4;
argVar = sBattleAnimScriptPtr[0];
@ -392,7 +388,7 @@ static void ScriptCmd_createsprite(void)
sBattleAnimScriptPtr++;
for (i = 0; i < argsCount; i++)
{
gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr);
gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 2;
}
@ -433,7 +429,7 @@ static void ScriptCmd_createvisualtask(void)
sBattleAnimScriptPtr++;
taskFunc = (TaskFunc)SCRIPT_READ_32(sBattleAnimScriptPtr);
taskFunc = (TaskFunc)T2_READ_32(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 4;
taskPriority = sBattleAnimScriptPtr[0];
@ -444,7 +440,7 @@ static void ScriptCmd_createvisualtask(void)
for (i = 0; i < numArgs; i++)
{
gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr);
gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 2;
}
@ -542,26 +538,26 @@ static void ScriptCmd_end(void)
static void ScriptCmd_playse(void)
{
sBattleAnimScriptPtr++;
PlaySE(SCRIPT_READ_16(sBattleAnimScriptPtr));
PlaySE(T1_READ_16(sBattleAnimScriptPtr));
sBattleAnimScriptPtr += 2;
}
#define t1_MONBG_BANK 0
#define t1_MONBG_BATTLER 0
#define t1_MON_IN_BG2 1
#define t1_CREATE_ANOTHER_TASK 2
#define t1_IS_SECONDMON_BG 3
#define t2_BANK_SPRITE_ID 0
#define t2_BATTLER_SPRITE_ID 0
#define t2_MON_IN_BG2 5
#define t2_MONBG_BANK 6
#define t2_MONBG_BATTLER 6
static void sub_80A40F4(u8 taskId)
{
u8 newTaskId;
s16 *selfData = gTasks[taskId].data;
u8 bankSpriteId = gBattlerSpriteIds[selfData[t1_MONBG_BANK]];
gSprites[bankSpriteId].invisible = 1;
u8 battlerSpriteId = gBattlerSpriteIds[selfData[t1_MONBG_BATTLER]];
gSprites[battlerSpriteId].invisible = 1;
if (!selfData[t1_CREATE_ANOTHER_TASK])
{
@ -570,9 +566,9 @@ static void sub_80A40F4(u8 taskId)
}
newTaskId = CreateTask(task_pA_ma0A_obj_to_bg_pal, 10);
gTasks[newTaskId].data[t2_BANK_SPRITE_ID] = bankSpriteId;
gTasks[newTaskId].data[1] = gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x;
gTasks[newTaskId].data[2] = gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y;
gTasks[newTaskId].data[t2_BATTLER_SPRITE_ID] = battlerSpriteId;
gTasks[newTaskId].data[1] = gSprites[battlerSpriteId].pos1.x + gSprites[battlerSpriteId].pos2.x;
gTasks[newTaskId].data[2] = gSprites[battlerSpriteId].pos1.y + gSprites[battlerSpriteId].pos2.y;
if (!selfData[t1_MON_IN_BG2])
{
@ -586,7 +582,7 @@ static void sub_80A40F4(u8 taskId)
}
gTasks[newTaskId].data[t2_MON_IN_BG2] = selfData[t1_MON_IN_BG2];
gTasks[newTaskId].data[t2_MONBG_BANK] = selfData[t1_MONBG_BANK];
gTasks[newTaskId].data[t2_MONBG_BATTLER] = selfData[t1_MONBG_BATTLER];
sMonAnimTaskIdArray[selfData[t1_IS_SECONDMON_BG]] = newTaskId;
DestroyAnimVisualTask(taskId);
}
@ -595,48 +591,48 @@ static void ScriptCmd_monbg(void)
{
bool8 toBG_2;
u8 taskId;
u8 bank;
u8 battlerId;
u8 animBank;
sBattleAnimScriptPtr++;
animBank = sBattleAnimScriptPtr[0];
if (animBank & ANIM_TARGET)
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
else
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
if (IsBattlerSpriteVisible(bank))
if (IsBattlerSpriteVisible(battlerId))
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
sub_80A438C(battlerId, toBG_2, FALSE);
taskId = CreateTask(sub_80A40F4, 10);
gAnimVisualTaskCount++;
gTasks[taskId].data[t1_MONBG_BANK] = bank;
gTasks[taskId].data[t1_MONBG_BATTLER] = battlerId;
gTasks[taskId].data[t1_MON_IN_BG2] = toBG_2;
gTasks[taskId].data[t1_CREATE_ANOTHER_TASK] = TRUE;
gTasks[taskId].data[t1_IS_SECONDMON_BG] = 0;
}
bank ^= BIT_FLANK;
if (IsBattlerSpriteVisible(bank))
battlerId ^= BIT_FLANK;
if (IsBattlerSpriteVisible(battlerId))
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
sub_80A438C(battlerId, toBG_2, FALSE);
taskId = CreateTask(sub_80A40F4, 10);
gAnimVisualTaskCount++;
gTasks[taskId].data[0] = bank;
gTasks[taskId].data[0] = battlerId;
gTasks[taskId].data[1] = toBG_2;
gTasks[taskId].data[t1_CREATE_ANOTHER_TASK] = TRUE;
gTasks[taskId].data[t1_IS_SECONDMON_BG] = 1;
@ -647,33 +643,33 @@ static void ScriptCmd_monbg(void)
gAnimScriptCallback = WaitAnimFrameCount;
}
bool8 IsBattlerSpriteVisible(u8 bank)
bool8 IsBattlerSpriteVisible(u8 battlerId)
{
if (IsContest())
{
if (bank == gBattleAnimAttacker)
if (battlerId == gBattleAnimAttacker)
return TRUE;
else
return FALSE;
}
if (!IsBattlerSpritePresent(bank))
if (!IsBattlerSpritePresent(battlerId))
return FALSE;
if (IsContest())
return TRUE; // this line wont ever be reached.
if (!gBattleSpritesDataPtr->battlerData[bank].invisible || !gSprites[gBattlerSpriteIds[bank]].invisible)
if (!gBattleSpritesDataPtr->battlerData[battlerId].invisible || !gSprites[gBattlerSpriteIds[battlerId]].invisible)
return TRUE;
return FALSE;
}
void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
void sub_80A438C(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible)
{
struct UnknownAnimStruct2 unknownStruct;
u8 bankSpriteId;
u8 battlerSpriteId;
if (!toBG_2)
{
u8 bankIdentity;
u8 battlerPosition;
if (IsContest() == TRUE)
{
@ -694,28 +690,28 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 1);
SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 0);
bankSpriteId = gBattlerSpriteIds[bank];
battlerSpriteId = gBattlerSpriteIds[battlerId];
gBattle_BG1_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20;
gBattle_BG1_X = -(gSprites[battlerSpriteId].pos1.x + gSprites[battlerSpriteId].pos2.x) + 0x20;
if (IsContest() && IsSpeciesNotUnown(gContestResources->field_18->field_0))
gBattle_BG1_X--;
gBattle_BG1_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20;
gBattle_BG1_Y = -(gSprites[battlerSpriteId].pos1.y + gSprites[battlerSpriteId].pos2.y) + 0x20;
if (setSpriteInvisible)
gSprites[gBattlerSpriteIds[bank]].invisible = 1;
gSprites[gBattlerSpriteIds[battlerId]].invisible = 1;
SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X);
SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
LoadPalette(&gPlttBufferUnfaded[0x100 + bank * 16], unknownStruct.unk8 * 16, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + bank * 16], (void*)(BG_PLTT + unknownStruct.unk8 * 32), 0x20);
LoadPalette(&gPlttBufferUnfaded[0x100 + battlerId * 16], unknownStruct.unk8 * 16, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + battlerId * 16], (void*)(BG_PLTT + unknownStruct.unk8 * 32), 0x20);
if (IsContest())
bankIdentity = 0;
battlerPosition = 0;
else
bankIdentity = GetBattlerPosition(bank);
battlerPosition = GetBattlerPosition(battlerId);
sub_8118FBC(1, 0, 0, bankIdentity, unknownStruct.unk8, unknownStruct.unk0, unknownStruct.unk4, unknownStruct.unkA);
sub_8118FBC(1, 0, 0, battlerPosition, unknownStruct.unk8, unknownStruct.unk0, unknownStruct.unk4, unknownStruct.unkA);
if (IsContest())
sub_80A46A0();
@ -731,21 +727,21 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
SetAnimBgAttribute(2, BG_ANIM_SCREEN_SIZE, 1);
SetAnimBgAttribute(2, BG_ANIM_AREA_OVERFLOW_MODE, 0);
bankSpriteId = gBattlerSpriteIds[bank];
battlerSpriteId = gBattlerSpriteIds[battlerId];
gBattle_BG2_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20;
gBattle_BG2_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20;
gBattle_BG2_X = -(gSprites[battlerSpriteId].pos1.x + gSprites[battlerSpriteId].pos2.x) + 0x20;
gBattle_BG2_Y = -(gSprites[battlerSpriteId].pos1.y + gSprites[battlerSpriteId].pos2.y) + 0x20;
if (setSpriteInvisible)
gSprites[gBattlerSpriteIds[bank]].invisible = 1;
gSprites[gBattlerSpriteIds[battlerId]].invisible = 1;
SetGpuReg(REG_OFFSET_BG2HOFS, gBattle_BG2_X);
SetGpuReg(REG_OFFSET_BG2VOFS, gBattle_BG2_Y);
LoadPalette(&gPlttBufferUnfaded[0x100 + bank * 16], 0x90, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + bank * 16], (void*)(BG_PLTT + 0x120), 0x20);
LoadPalette(&gPlttBufferUnfaded[0x100 + battlerId * 16], 0x90, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + battlerId * 16], (void*)(BG_PLTT + 0x120), 0x20);
sub_8118FBC(2, 0, 0, GetBattlerPosition(bank), unknownStruct.unk8, unknownStruct.unk0 + 0x1000, unknownStruct.unk4 + 0x400, unknownStruct.unkA);
sub_8118FBC(2, 0, 0, GetBattlerPosition(battlerId), unknownStruct.unk8, unknownStruct.unk0 + 0x1000, unknownStruct.unk4 + 0x400, unknownStruct.unkA);
}
}
@ -852,7 +848,7 @@ static void task_pA_ma0A_obj_to_bg_pal(u8 taskId)
static void ScriptCmd_clearmonbg(void)
{
u8 animBankId;
u8 bank;
u8 battlerId;
u8 taskId;
sBattleAnimScriptPtr++;
@ -864,20 +860,20 @@ static void ScriptCmd_clearmonbg(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
else
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
if (sMonAnimTaskIdArray[0] != 0xFF)
gSprites[gBattlerSpriteIds[bank]].invisible = 0;
gSprites[gBattlerSpriteIds[battlerId]].invisible = 0;
if (animBankId > 1 && sMonAnimTaskIdArray[1] != 0xFF)
gSprites[gBattlerSpriteIds[bank ^ BIT_FLANK]].invisible = 0;
gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = 0;
else
animBankId = 0;
taskId = CreateTask(sub_80A4980, 5);
gTasks[taskId].data[0] = animBankId;
gTasks[taskId].data[2] = bank;
gTasks[taskId].data[2] = battlerId;
sBattleAnimScriptPtr++;
}
@ -913,7 +909,7 @@ static void sub_80A4980(u8 taskId)
static void ScriptCmd_monbg_22(void)
{
bool8 toBG_2;
u8 bank;
u8 battlerId;
u8 animBankId;
sBattleAnimScriptPtr++;
@ -926,31 +922,31 @@ static void ScriptCmd_monbg_22(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
else
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
if (IsBattlerSpriteVisible(bank))
if (IsBattlerSpriteVisible(battlerId))
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
sub_80A438C(battlerId, toBG_2, FALSE);
}
bank ^= BIT_FLANK;
if (animBankId > 1 && IsBattlerSpriteVisible(bank))
battlerId ^= BIT_FLANK;
if (animBankId > 1 && IsBattlerSpriteVisible(battlerId))
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
sub_80A438C(battlerId, toBG_2, FALSE);
}
sBattleAnimScriptPtr++;
@ -959,7 +955,7 @@ static void ScriptCmd_monbg_22(void)
static void ScriptCmd_clearmonbg_23(void)
{
u8 animBankId;
u8 bank;
u8 battlerId;
u8 taskId;
sBattleAnimScriptPtr++;
@ -971,20 +967,20 @@ static void ScriptCmd_clearmonbg_23(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
else
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
if (IsBattlerSpriteVisible(bank))
gSprites[gBattlerSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && IsBattlerSpriteVisible(bank ^ BIT_FLANK))
gSprites[gBattlerSpriteIds[bank ^ BIT_FLANK]].invisible = 0;
if (IsBattlerSpriteVisible(battlerId))
gSprites[gBattlerSpriteIds[battlerId]].invisible = 0;
if (animBankId > 1 && IsBattlerSpriteVisible(battlerId ^ BIT_FLANK))
gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = 0;
else
animBankId = 0;
taskId = CreateTask(sub_80A4BB0, 5);
gTasks[taskId].data[0] = animBankId;
gTasks[taskId].data[2] = bank;
gTasks[taskId].data[2] = battlerId;
sBattleAnimScriptPtr++;
}
@ -995,30 +991,30 @@ static void sub_80A4BB0(u8 taskId)
if (gTasks[taskId].data[1] != 1)
{
bool8 toBG_2;
u8 bank = gTasks[taskId].data[2];
u8 position = GetBattlerPosition(bank);
u8 battlerId = gTasks[taskId].data[2];
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
if (IsBattlerSpriteVisible(bank))
if (IsBattlerSpriteVisible(battlerId))
sub_80A477C(toBG_2);
if (gTasks[taskId].data[0] > 1 && IsBattlerSpriteVisible(bank ^ BIT_FLANK))
if (gTasks[taskId].data[0] > 1 && IsBattlerSpriteVisible(battlerId ^ BIT_FLANK))
sub_80A477C(toBG_2 ^ 1);
DestroyTask(taskId);
}
}
#undef t1_MONBG_BANK
#undef t1_MONBG_BATTLER
#undef t1_MON_IN_BG2
#undef t1_CREATE_ANOTHER_TASK
#undef t1_IS_SECONDMON_BG
#undef t2_BANK_SPRITE_ID
#undef t2_BATTLER_SPRITE_ID
#undef t2_MON_IN_BG2
#undef t2_MONBG_BANK
#undef t2_MONBG_BATTLER
static void ScriptCmd_setalpha(void)
{
@ -1052,7 +1048,7 @@ static void ScriptCmd_call(void)
{
sBattleAnimScriptPtr++;
sBattleAnimScriptRetAddr = sBattleAnimScriptPtr + 4;
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
}
static void ScriptCmd_return(void)
@ -1069,7 +1065,7 @@ static void ScriptCmd_setarg(void)
sBattleAnimScriptPtr++;
argId = sBattleAnimScriptPtr[0];
sBattleAnimScriptPtr++;
value = SCRIPT_READ_16(sBattleAnimScriptPtr);
value = T1_READ_16(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = addr + 4;
gBattleAnimArgs[argId] = value;
}
@ -1079,7 +1075,7 @@ static void ScriptCmd_choosetwoturnanim(void)
sBattleAnimScriptPtr++;
if (gAnimMoveTurn & 1)
sBattleAnimScriptPtr += 4;
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
}
static void ScriptCmd_jumpifmoveturn(void)
@ -1090,7 +1086,7 @@ static void ScriptCmd_jumpifmoveturn(void)
sBattleAnimScriptPtr++;
if (toCheck == gAnimMoveTurn)
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
else
sBattleAnimScriptPtr += 4;
}
@ -1098,7 +1094,7 @@ static void ScriptCmd_jumpifmoveturn(void)
static void ScriptCmd_goto(void)
{
sBattleAnimScriptPtr++;
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
}
// Uses of this function that rely on a TRUE return are expecting inBattle to not be ticked as defined in contest behavior. As a result, if misused, this function cannot reliably discern between field and contest status and could result in undefined behavior.
@ -1354,7 +1350,7 @@ static void ScriptCmd_playsewithpan(void)
s8 pan;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
pan = sBattleAnimScriptPtr[2];
PlaySE12WithPanning(songId, BattleAnimAdjustPanning(pan));
sBattleAnimScriptPtr += 3;
@ -1385,7 +1381,7 @@ static void ScriptCmd_panse_1B(void)
u8 taskId;
sBattleAnimScriptPtr++;
songNum = SCRIPT_READ_16(sBattleAnimScriptPtr);
songNum = T1_READ_16(sBattleAnimScriptPtr);
currentPanArg = sBattleAnimScriptPtr[2];
incrementPan = sBattleAnimScriptPtr[3];
incrementPanArg = sBattleAnimScriptPtr[4];
@ -1457,7 +1453,7 @@ static void ScriptCmd_panse_26(void)
u8 taskId;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
currentPan = sBattleAnimScriptPtr[2];
targetPan = sBattleAnimScriptPtr[3];
incrementPan = sBattleAnimScriptPtr[4];
@ -1484,7 +1480,7 @@ static void ScriptCmd_panse_27(void)
u8 taskId;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
currentPanArg = sBattleAnimScriptPtr[2];
targetPanArg = sBattleAnimScriptPtr[3];
incrementPanArg = sBattleAnimScriptPtr[4];
@ -1528,7 +1524,7 @@ static void ScriptCmd_loopsewithpan(void)
u8 taskId;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
panningArg = sBattleAnimScriptPtr[2];
framesToWait = sBattleAnimScriptPtr[3];
numberOfPlays = sBattleAnimScriptPtr[4];
@ -1585,7 +1581,7 @@ static void ScriptCmd_waitplaysewithpan(void)
u8 taskId;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
panningArg = sBattleAnimScriptPtr[2];
framesToWait = sBattleAnimScriptPtr[3];
panning = BattleAnimAdjustPanning(panningArg);
@ -1620,13 +1616,13 @@ static void ScriptCmd_createsoundtask(void)
s32 i;
sBattleAnimScriptPtr++;
func = (TaskFunc)SCRIPT_READ_32(sBattleAnimScriptPtr);
func = (TaskFunc)T2_READ_32(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 4;
numArgs = sBattleAnimScriptPtr[0];
sBattleAnimScriptPtr++;
for (i = 0; i < numArgs; i++)
{
gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr);
gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 2;
}
taskId = CreateTask(func, 1);
@ -1669,10 +1665,10 @@ static void ScriptCmd_jumpargeq(void)
sBattleAnimScriptPtr++;
argId = sBattleAnimScriptPtr[0];
valueToCheck = SCRIPT_READ_16(sBattleAnimScriptPtr + 1);
valueToCheck = T1_READ_16(sBattleAnimScriptPtr + 1);
if (valueToCheck == gBattleAnimArgs[argId])
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr + 3);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr + 3);
else
sBattleAnimScriptPtr += 7;
}
@ -1681,7 +1677,7 @@ static void ScriptCmd_jumpifcontest(void)
{
sBattleAnimScriptPtr++;
if (IsContest())
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
else
sBattleAnimScriptPtr += 4;
}
@ -1689,19 +1685,19 @@ static void ScriptCmd_jumpifcontest(void)
static void ScriptCmd_monbgprio_28(void)
{
u8 wantedBank;
u8 bank;
u8 bankIdentity;
u8 battlerId;
u8 battlerPosition;
wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2;
if (wantedBank != ANIM_ATTACKER)
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
else
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
bankIdentity = GetBattlerPosition(bank);
if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT))
battlerPosition = GetBattlerPosition(battlerId);
if (!IsContest() && (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_OPPONENT_RIGHT))
{
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1);
SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2);
@ -1721,20 +1717,20 @@ static void ScriptCmd_monbgprio_29(void)
static void ScriptCmd_monbgprio_2A(void)
{
u8 wantedBank;
u8 bankIdentity;
u8 bank;
u8 battlerPosition;
u8 battlerId;
wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2;
if (GetBattlerSide(gBattleAnimAttacker) != GetBattlerSide(gBattleAnimTarget))
{
if (wantedBank != ANIM_ATTACKER)
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
else
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
bankIdentity = GetBattlerPosition(bank);
if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT))
battlerPosition = GetBattlerPosition(battlerId);
if (!IsContest() && (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_OPPONENT_RIGHT))
{
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1);
SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2);

View File

@ -14,7 +14,6 @@
#include "trig.h"
#include "sound.h"
#include "constants/songs.h"
#include "strings.h"
#include "window.h"
#include "text_window.h"
#include "menu.h"

View File

@ -33,7 +33,7 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern void sub_81851A8(u8 *);
extern u16 sub_8068B48(void);
@ -103,7 +103,7 @@ static void LinkOpponentBufferExecCompleted(void);
static void sub_8064DD0(void);
static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst);
static void SetLinkOpponentMonData(u8 monId);
static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit);
static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkOpponentDoMoveAnimation(void);
static void sub_8067618(u8 taskId);
@ -1159,36 +1159,36 @@ static void LinkOpponentHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_8064F40;
}
static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit)
static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
}
static void LinkOpponentHandleReturnMonToBall(void)
@ -1337,7 +1337,7 @@ static void LinkOpponentHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle bank function
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle battlerId function
LinkOpponentBufferExecCompleted();
}
@ -1548,11 +1548,11 @@ static void LinkOpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -32,7 +32,7 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern void sub_81851A8(u8 *);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -101,7 +101,7 @@ static void LinkPartnerBufferExecCompleted(void);
static void sub_814B554(void);
static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst);
static void SetLinkPartnerMonData(u8 monId);
static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit);
static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkPartnerDoMoveAnimation(void);
static void sub_814DCCC(u8 taskId);
@ -1045,35 +1045,35 @@ static void LinkPartnerHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_814B69C;
}
static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit)
static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void LinkPartnerHandleReturnMonToBall(void)
@ -1372,11 +1372,11 @@ static void LinkPartnerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -36,9 +36,9 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern void sub_81A57E4(u8 bank, u16 stringId);
extern void sub_81A57E4(u8 battlerId, u16 stringId);
extern u8 sub_81A4CB0(void);
extern u8 sub_81D5588(u16 trainerId);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -108,7 +108,7 @@ static void OpponentBufferExecCompleted(void);
static void sub_805FC80(void);
static u32 GetOpponentMonData(u8 monId, u8 *dst);
static void SetOpponentMonData(u8 monId);
static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit);
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void OpponentDoMoveAnimation(void);
static void sub_806280C(struct Sprite *sprite);
@ -1153,36 +1153,36 @@ static void OpponentHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_805FDF0;
}
static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit)
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
gBattlerSpriteIds[battlerId] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
}
static void OpponentHandleReturnMonToBall(void)
@ -1697,11 +1697,11 @@ static void OpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -43,19 +43,11 @@ extern struct SpriteTemplate gUnknown_0202499C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern const u8 gText_BattleSwitchWhich[];
extern const u8 gText_MoveInterfacePP[];
extern const u8 gText_MoveInterfaceType[];
extern const u8 gText_LinkStandby[];
extern const u8 gText_BattleMenu[];
extern const u8 gText_WhatWillPkmnDo[];
extern const u8 gText_BattleYesNoChoice[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_81B89AC(u8 arg0);
extern void sub_81AABB0(void);
extern void sub_806A068(u16, u8);
extern void sub_81A57E4(u8 bank, u16 stringId);
extern void sub_81A57E4(u8 battlerId, u16 stringId);
extern void sub_81851A8(u8 *);
// this file's functions
@ -138,7 +130,7 @@ static void sub_80595A4(u8 taskId);
static void PrintLinkStandbyMsg(void);
static u32 CopyPlayerMonData(u8 monId, u8 *dst);
static void SetPlayerMonData(u8 monId);
static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit);
static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void PlayerDoMoveAnimation(void);
static void task05_08033660(u8 taskId);
@ -1157,10 +1149,10 @@ static void CompleteOnInactiveTextPrinter(void)
static void Task_GiveExpToMon(u8 taskId)
{
u32 monId = (u8)(gTasks[taskId].tExpTask_monId);
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[bank]) // give exp without the expbar
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[battlerId]) // give exp without the expbar
{
struct Pokemon *mon = &gPlayerParty[monId];
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -1176,12 +1168,12 @@ static void Task_GiveExpToMon(u8 taskId)
CalculateMonStats(mon);
gainedExp -= nextLvlExp - currExp;
savedActiveBank = gActiveBattler;
gActiveBattler = bank;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank;
if (IsDoubleBattle() == TRUE
&& ((u16)(monId) == gBattlerPartyIndexes[bank] || (u16)(monId) == gBattlerPartyIndexes[bank ^ BIT_FLANK]))
&& ((u16)(monId) == gBattlerPartyIndexes[battlerId] || (u16)(monId) == gBattlerPartyIndexes[battlerId ^ BIT_FLANK]))
gTasks[taskId].func = sub_8059544;
else
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
@ -1190,7 +1182,7 @@ static void Task_GiveExpToMon(u8 taskId)
{
currExp += gainedExp;
SetMonData(mon, MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
}
@ -1204,7 +1196,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
s32 gainedExp = gTasks[taskId].tExpTask_gainedExp;
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
struct Pokemon *mon = &gPlayerParty[monIndex];
u8 level = GetMonData(mon, MON_DATA_LEVEL);
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -1214,7 +1206,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
exp -= currLvlExp;
expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(bank, gHealthboxSpriteIds[bank], expToNextLvl, exp, -gainedExp);
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
PlaySE(SE_EXP);
gTasks[taskId].func = sub_8059400;
}
@ -1229,11 +1221,11 @@ static void sub_8059400(u8 taskId)
{
u8 monId = gTasks[taskId].tExpTask_monId;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 r4;
r4 = sub_8074AA0(bank, gHealthboxSpriteIds[bank], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[bank]);
r4 = sub_8074AA0(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
if (r4 == -1)
{
u8 level;
@ -1255,7 +1247,7 @@ static void sub_8059400(u8 taskId)
CalculateMonStats(&gPlayerParty[monId]);
gainedExp -= expOnNextLvl - currExp;
savedActiveBank = gActiveBattler;
gActiveBattler = bank;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank;
gTasks[taskId].func = sub_8059544;
@ -1264,7 +1256,7 @@ static void sub_8059400(u8 taskId)
{
currExp += gainedExp;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
}
@ -1273,30 +1265,30 @@ static void sub_8059400(u8 taskId)
static void sub_8059544(u8 taskId)
{
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
u8 monIndex = gTasks[taskId].tExpTask_monId;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
bank ^= BIT_FLANK;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])
battlerId ^= BIT_FLANK;
InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP);
InitAndLaunchSpecialAnimation(battlerId, battlerId, battlerId, B_ANIM_LVL_UP);
gTasks[taskId].func = sub_80595A4;
}
static void sub_80595A4(u8 taskId)
{
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
if (!gBattleSpritesDataPtr->healthBoxesData[bank].specialAnimActive)
if (!gBattleSpritesDataPtr->healthBoxesData[battlerId].specialAnimActive)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
else
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[monIndex], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], &gPlayerParty[monIndex], HEALTHBOX_ALL);
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
}
@ -1305,12 +1297,12 @@ static void sub_80595A4(u8 taskId)
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
{
u8 monIndex;
u8 bank;
u8 battlerId;
monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
bank = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
battlerId = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
@ -2199,35 +2191,35 @@ static void PlayerHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_805902C;
}
static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit)
static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void PlayerHandleReturnMonToBall(void)
@ -2749,11 +2741,11 @@ static void PlayerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}
@ -2962,13 +2954,13 @@ static void PlayerHandleIntroTrainerBallThrow(void)
void sub_805CC00(struct Sprite *sprite)
{
u8 bank = sprite->data[5];
u8 battlerId = sprite->data[5];
FreeSpriteOamMatrix(sprite);
FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum));
DestroySprite(sprite);
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[bank]], bank);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], 0);
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
}
static void task05_08033660(u8 taskId)

View File

@ -33,7 +33,7 @@ extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_81358F4(void);
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -107,7 +107,7 @@ static void sub_81BB688(u8 taskId);
static void sub_81BB9A0(void);
static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst);
static void SetPlayerPartnerMonData(u8 monId);
static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit);
static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void PlayerPartnerDoMoveAnimation(void);
static void sub_81BE2C8(u8 taskId);
@ -324,10 +324,10 @@ static void CompleteOnInactiveTextPrinter(void)
static void Task_GiveExpToMon(u8 taskId)
{
u32 monId = (u8)(gTasks[taskId].tExpTask_monId);
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[bank]) // give exp without the expbar
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[battlerId]) // give exp without the expbar
{
struct Pokemon *mon = &gPlayerParty[monId];
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -343,12 +343,12 @@ static void Task_GiveExpToMon(u8 taskId)
CalculateMonStats(mon);
gainedExp -= nextLvlExp - currExp;
savedActiveBank = gActiveBattler;
gActiveBattler = bank;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank;
if (IsDoubleBattle() == TRUE
&& ((u16)(monId) == gBattlerPartyIndexes[bank] || (u16)(monId) == gBattlerPartyIndexes[bank ^ BIT_FLANK]))
&& ((u16)(monId) == gBattlerPartyIndexes[battlerId] || (u16)(monId) == gBattlerPartyIndexes[battlerId ^ BIT_FLANK]))
gTasks[taskId].func = sub_81BB628;
else
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
@ -357,7 +357,7 @@ static void Task_GiveExpToMon(u8 taskId)
{
currExp += gainedExp;
SetMonData(mon, MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
}
@ -371,7 +371,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
s32 gainedExp = gTasks[taskId].tExpTask_gainedExp;
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
struct Pokemon *mon = &gPlayerParty[monIndex];
u8 level = GetMonData(mon, MON_DATA_LEVEL);
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -381,7 +381,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
exp -= currLvlExp;
expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(bank, gHealthboxSpriteIds[bank], expToNextLvl, exp, -gainedExp);
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
PlaySE(SE_EXP);
gTasks[taskId].func = sub_81BB4E4;
}
@ -396,11 +396,11 @@ static void sub_81BB4E4(u8 taskId)
{
u8 monId = gTasks[taskId].tExpTask_monId;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 r4;
r4 = sub_8074AA0(bank, gHealthboxSpriteIds[bank], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[bank]);
r4 = sub_8074AA0(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
if (r4 == -1)
{
u8 level;
@ -422,7 +422,7 @@ static void sub_81BB4E4(u8 taskId)
CalculateMonStats(&gPlayerParty[monId]);
gainedExp -= expOnNextLvl - currExp;
savedActiveBank = gActiveBattler;
gActiveBattler = bank;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank;
gTasks[taskId].func = sub_81BB628;
@ -431,7 +431,7 @@ static void sub_81BB4E4(u8 taskId)
{
currExp += gainedExp;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
}
@ -440,30 +440,30 @@ static void sub_81BB4E4(u8 taskId)
static void sub_81BB628(u8 taskId)
{
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
u8 monIndex = gTasks[taskId].tExpTask_monId;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
bank ^= BIT_FLANK;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])
battlerId ^= BIT_FLANK;
InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP);
InitAndLaunchSpecialAnimation(battlerId, battlerId, battlerId, B_ANIM_LVL_UP);
gTasks[taskId].func = sub_81BB688;
}
static void sub_81BB688(u8 taskId)
{
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
if (!gBattleSpritesDataPtr->healthBoxesData[bank].specialAnimActive)
if (!gBattleSpritesDataPtr->healthBoxesData[battlerId].specialAnimActive)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
else
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[monIndex], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], &gPlayerParty[monIndex], HEALTHBOX_ALL);
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
}
@ -472,12 +472,12 @@ static void sub_81BB688(u8 taskId)
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
{
u8 monIndex;
u8 bank;
u8 battlerId;
monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
bank = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
battlerId = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
@ -1232,35 +1232,35 @@ static void PlayerPartnerHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_81BBAE8;
}
static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit)
static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void PlayerPartnerHandleReturnMonToBall(void)
@ -1625,11 +1625,11 @@ static void PlayerPartnerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -35,7 +35,7 @@ extern u8 gUnknown_0203C7B4;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern u16 sub_8068B48(void);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -104,7 +104,7 @@ static void RecordedOpponentBufferExecCompleted(void);
static void sub_8186F14(void);
static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst);
static void SetRecordedOpponentMonData(u8 monId);
static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit);
static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void RecordedOpponentDoMoveAnimation(void);
static void sub_8189548(u8 taskId);
@ -1144,35 +1144,35 @@ static void RecordedOpponentHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_8187084;
}
static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit)
static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
gBattlerSpriteIds[battlerId] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
}
static void RecordedOpponentHandleReturnMonToBall(void)
@ -1490,11 +1490,11 @@ static void RecordedOpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -35,7 +35,7 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -103,7 +103,7 @@ static void RecordedPlayerBufferExecCompleted(void);
static void sub_818A328(void);
static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst);
static void SetRecordedPlayerMonData(u8 monId);
static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit);
static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void RecordedPlayerDoMoveAnimation(void);
static void sub_818CC24(u8 taskId);
@ -1129,35 +1129,35 @@ static void RecordedPlayerHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_818A470;
}
static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit)
static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void RecordedPlayerHandleReturnMonToBall(void)
@ -1512,11 +1512,11 @@ static void RecordedPlayerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -23,15 +23,11 @@
#include "pokeblock.h"
#include "item_use.h"
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern const u8 gText_SafariZoneMenu[];
extern const u8 gText_WhatWillPkmnDo2[];
extern void sub_81358F4(void);
// this file's functions

View File

@ -37,10 +37,7 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern const u8 gText_WhatWillWallyDo[];
extern const u8 gText_BattleMenu[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
// this file's functions
@ -1460,31 +1457,31 @@ static void WallyHandleIntroTrainerBallThrow(void)
gBattlerControllerFuncs[gActiveBattler] = nullsub_21;
}
static void sub_816AA80(u8 bank)
static void sub_816AA80(u8 battlerId)
{
u16 species;
gBattleSpritesDataPtr->battlerData[bank].transformSpecies = 0;
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = 0;
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void sub_816AC04(u8 taskId)

View File

@ -12,33 +12,14 @@
#include "constants/abilities.h"
#include "battle_message.h"
extern u32 gBattleExecBuffer;
extern void (*gBattleBankFunc[4])(void);
extern u8 gBanksByIdentity[4];
extern u8 gActionSelectionCursor[4];
extern u8 gMoveSelectionCursor[4];
extern u8 gNoOfAllBanks;
extern u8 gActiveBank;
extern u16 gBattlePartyID[4];
extern u8 gBattleBufferA[4][0x200];
extern u8 gBattleBufferB[4][0x200];
extern u8 gUnknown_02022D08;
extern u8 gUnknown_02022D09;
extern u8 gUnknown_02022D0A;
extern u8 gBankAttacker;
extern u8 gBankTarget;
extern u8 gAbsentBankFlags;
extern u8 gEffectBank;
extern struct BattlePokemon gBattleMons[4];
extern u16 gLastUsedMove;
extern u8 gStringBank;
extern u8 gBattleBuffersTransferData[0x100];
static EWRAM_DATA u8 sBattleBuffersTransferData[0x100] = {};
extern void task00_08081A90(u8 taskId); // cable_club
extern void sub_81B8D64(u8 bank, u8 arg1); // party_menu
extern void sub_81B8D64(u8 battlerId, u8 arg1); // party_menu
// this file's funcionts
static void CreateTasksForSendRecvLinkBuffers(void);
@ -885,7 +866,7 @@ void sub_8033648(void)
static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
{
u16 blockSize;
u8 bank;
u8 battlerId;
u8 var;
if (gTasks[taskId].data[15] != gTasks[taskId].data[14])
@ -896,17 +877,17 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
gTasks[taskId].data[12] = 0;
gTasks[taskId].data[15] = 0;
}
bank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ACTIVE_BANK];
battlerId = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ACTIVE_BANK];
blockSize = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8);
switch (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 0])
{
case 0:
if (gBattleControllerExecFlags & gBitTable[bank])
if (gBattleControllerExecFlags & gBitTable[battlerId])
return;
memcpy(gBattleBufferA[bank], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize);
sub_803F850(bank);
memcpy(gBattleBufferA[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize);
sub_803F850(battlerId);
if (!(gBattleTypeFlags & BATTLE_TYPE_WILD))
{
@ -917,11 +898,11 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
}
break;
case 1:
memcpy(gBattleBufferB[bank], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize);
memcpy(gBattleBufferB[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize);
break;
case 2:
var = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA];
gBattleControllerExecFlags &= ~(gBitTable[bank] << (var * 4));
gBattleControllerExecFlags &= ~(gBitTable[battlerId] << (var * 4));
break;
}

View File

@ -21,6 +21,7 @@
#include "safari_zone.h"
#include "battle_anim.h"
#include "constants/rgb.h"
#include "data2.h"
struct TestingBar
{
@ -154,7 +155,6 @@ enum
};
extern const u8 * const gNatureNamePointers[];
extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1];
// strings
extern const u8 gText_Slash[];
@ -162,8 +162,6 @@ extern const u8 gText_HighlightDarkGrey[];
extern const u8 gText_DynColor2[];
extern const u8 gText_DynColor2Male[];
extern const u8 gText_DynColor1Female[];
extern const u8 gText_SafariBalls[];
extern const u8 gText_SafariBallLeft[];
// graphics
extern const u8 gBattleInterface_BallStatusBarGfx[];
@ -198,10 +196,10 @@ static void SpriteCB_StatusSummaryBar(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBallsOnSwitchout(struct Sprite *sprite);
static u8 GetStatusIconForBankId(u8 statusElementId, u8 bank);
static u8 GetStatusIconForBankId(u8 statusElementId, u8 battlerId);
static s32 sub_8074DB8(s32 maxValue, s32 currValue, s32 receivedValue, s32 *arg3, u8 arg4, u16 arg5);
static u8 GetScaledExpFraction(s32 currValue, s32 receivedValue, s32 maxValue, u8 scale);
static void sub_8074B9C(u8 bank, u8 whichBar);
static void sub_8074B9C(u8 battlerId, u8 whichBar);
static u8 sub_8074E8C(s32 maxValue, s32 currValue, s32 receivedValue, s32 *arg3, u8 *arg4, u8 arg5);
static void sub_8074F88(struct TestingBar *barInfo, s32 *arg1, u16 *arg2);
@ -1034,13 +1032,13 @@ static void sub_8072924(struct Sprite *sprite)
sprite->pos2.y = gSprites[otherSpriteId].pos2.y;
}
void SetBattleBarStruct(u8 bank, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue)
void SetBattleBarStruct(u8 battlerId, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue)
{
gBattleSpritesDataPtr->battleBars[bank].healthboxSpriteId = healthboxSpriteId;
gBattleSpritesDataPtr->battleBars[bank].maxValue = maxVal;
gBattleSpritesDataPtr->battleBars[bank].currentValue = currVal;
gBattleSpritesDataPtr->battleBars[bank].receivedValue = receivedValue;
gBattleSpritesDataPtr->battleBars[bank].field_10 = -32768;
gBattleSpritesDataPtr->battleBars[battlerId].healthboxSpriteId = healthboxSpriteId;
gBattleSpritesDataPtr->battleBars[battlerId].maxValue = maxVal;
gBattleSpritesDataPtr->battleBars[battlerId].currentValue = currVal;
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue = receivedValue;
gBattleSpritesDataPtr->battleBars[battlerId].field_10 = -32768;
}
void SetHealthboxSpriteInvisible(u8 healthboxSpriteId)
@ -1281,12 +1279,12 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
}
else
{
u8 bank;
u8 battlerId;
memcpy(text, sUnknown_0832C3D8, sizeof(sUnknown_0832C3D8));
bank = gSprites[healthboxSpriteId].data[6];
battlerId = gSprites[healthboxSpriteId].data[6];
if (gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars) // don't print text if only bars are visible
if (gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars) // don't print text if only bars are visible
{
u8 var = 4;
u8 r7;
@ -1327,7 +1325,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
}
else
{
if (GetBattlerSide(bank) == B_SIDE_PLAYER) // impossible to reach part, because the bank is from the opponent's side
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) // impossible to reach part, because the battlerId is from the opponent's side
{
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_116),
(void*)(OBJ_VRAM0) + ((gSprites[healthboxSpriteId].oam.tileNum + 52) * 32),
@ -1469,7 +1467,7 @@ void SwapHpBarsWithHpText(void)
}
}
u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart)
u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart)
{
bool8 isOpponent;
s16 bar_X, bar_Y, bar_pos2_X, bar_data0;
@ -1478,9 +1476,9 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar
u8 ballIconSpritesIds[6];
u8 taskId;
if (!arg2 || GetBattlerPosition(bank) != B_POSITION_OPPONENT_RIGHT)
if (!arg2 || GetBattlerPosition(battlerId) != B_POSITION_OPPONENT_RIGHT)
{
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
{
isOpponent = FALSE;
bar_X = 136, bar_Y = 96;
@ -1559,7 +1557,7 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar
gSprites[ballIconSpritesIds[i]].data[2] = isOpponent;
}
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
@ -1658,7 +1656,7 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar
}
taskId = CreateTask(TaskDummy, 5);
gTasks[taskId].data[0] = bank;
gTasks[taskId].data[0] = battlerId;
gTasks[taskId].data[1] = barSpriteId;
for (i = 0; i < 6; i++)
@ -1680,12 +1678,12 @@ void sub_8073C30(u8 taskId)
u8 sp[6];
u8 r7;
u8 r10;
u8 bank;
u8 battlerId;
s32 i;
r7 = gTasks[taskId].data[10];
r10 = gTasks[taskId].data[1];
bank = gTasks[taskId].data[0];
battlerId = gTasks[taskId].data[0];
for (i = 0; i < 6; i++)
sp[i] = gTasks[taskId].data[3 + i];
@ -1704,7 +1702,7 @@ void sub_8073C30(u8 taskId)
{
for (i = 0; i < 6; i++)
{
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
{
gSprites[sp[5 - i]].data[1] = 7 * i;
gSprites[sp[5 - i]].data[3] = 0;
@ -1752,7 +1750,7 @@ static void sub_8073E64(u8 taskId)
u8 sp[6];
s32 i;
u8 bank = gTasks[taskId].data[0];
u8 battlerId = gTasks[taskId].data[0];
gTasks[taskId].data[15]--;
if (gTasks[taskId].data[15] == -1)
{
@ -1780,7 +1778,7 @@ static void sub_8073E64(u8 taskId)
}
else if (gTasks[taskId].data[15] == -3)
{
gBattleSpritesDataPtr->healthBoxesData[bank].flag_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].flag_x1 = 0;
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
DestroyTask(taskId);
@ -1792,7 +1790,7 @@ static void sub_8073F98(u8 taskId)
u8 sp[6];
s32 i;
u8 bank = gTasks[taskId].data[0];
u8 battlerId = gTasks[taskId].data[0];
gTasks[taskId].data[15]--;
if (gTasks[taskId].data[15] >= 0)
{
@ -1813,7 +1811,7 @@ static void sub_8073F98(u8 taskId)
}
else if (gTasks[taskId].data[15] == -3)
{
gBattleSpritesDataPtr->healthBoxesData[bank].flag_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].flag_x1 = 0;
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
DestroyTask(taskId);
@ -1976,17 +1974,17 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon)
static void TryAddPokeballIconToHealthbox(u8 healthboxSpriteId, bool8 noStatus)
{
u8 bank, healthboxSpriteId_2;
u8 battlerId, healthboxSpriteId_2;
if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
return;
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
return;
bank = gSprites[healthboxSpriteId].data[6];
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
battlerId = gSprites[healthboxSpriteId].data[6];
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
return;
if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT))
if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT))
return;
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5];
@ -2000,17 +1998,17 @@ static void TryAddPokeballIconToHealthbox(u8 healthboxSpriteId, bool8 noStatus)
static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
{
s32 i;
u8 bank, healthboxSpriteId_2;
u8 battlerId, healthboxSpriteId_2;
u32 status, pltAdder;
const u8 *statusGfxPtr;
s16 tileNumAdder;
u8 statusPalId;
bank = gSprites[healthboxSpriteId].data[6];
battlerId = gSprites[healthboxSpriteId].data[6];
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5];
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
{
status = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_STATUS);
status = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_STATUS);
if (!IsDoubleBattle())
tileNumAdder = 0x1A;
else
@ -2018,33 +2016,33 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
}
else
{
status = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_STATUS);
status = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_STATUS);
tileNumAdder = 0x11;
}
if (status & STATUS1_SLEEP)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_SLP_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_SLP_BANK0, battlerId));
statusPalId = PAL_STATUS_SLP;
}
else if (status & STATUS1_PSN_ANY)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PSN_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PSN_BANK0, battlerId));
statusPalId = PAL_STATUS_PSN;
}
else if (status & STATUS1_BURN)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_BRN_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_BRN_BANK0, battlerId));
statusPalId = PAL_STATUS_BRN;
}
else if (status & STATUS1_FREEZE)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_FRZ_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_FRZ_BANK0, battlerId));
statusPalId = PAL_STATUS_FRZ;
}
else if (status & STATUS1_PARALYSIS)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PRZ_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PRZ_BANK0, battlerId));
statusPalId = PAL_STATUS_PAR;
}
else
@ -2054,7 +2052,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
for (i = 0; i < 3; i++)
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder + i) * 32), 32);
if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)
if (!gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars)
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void *)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 64);
TryAddPokeballIconToHealthbox(healthboxSpriteId, TRUE);
@ -2062,14 +2060,14 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
}
pltAdder = gSprites[healthboxSpriteId].oam.paletteNum * 16;
pltAdder += bank + 12;
pltAdder += battlerId + 12;
FillPalette(sStatusIconColors[statusPalId], pltAdder + 0x100, 2);
CpuCopy16(gPlttBufferUnfaded + 0x100 + pltAdder, (void*)(OBJ_PLTT + pltAdder * 2), 2);
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96);
if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT)
if (IsDoubleBattle() == TRUE || GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
{
if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)
if (!gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars)
{
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_0), (void*)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 32);
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_65), (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId_2].oam.tileNum + 1) * 32), 32);
@ -2078,58 +2076,58 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
TryAddPokeballIconToHealthbox(healthboxSpriteId, FALSE);
}
static u8 GetStatusIconForBankId(u8 statusElementId, u8 bank)
static u8 GetStatusIconForBankId(u8 statusElementId, u8 battlerId)
{
u8 ret = statusElementId;
switch (statusElementId)
{
case HEALTHBOX_GFX_STATUS_PSN_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_PSN_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_PSN_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_PSN_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_PSN_BANK3;
break;
case HEALTHBOX_GFX_STATUS_PRZ_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_PRZ_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_PRZ_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_PRZ_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_PRZ_BANK3;
break;
case HEALTHBOX_GFX_STATUS_SLP_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_SLP_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_SLP_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_SLP_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_SLP_BANK3;
break;
case HEALTHBOX_GFX_STATUS_FRZ_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_FRZ_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_FRZ_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_FRZ_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_FRZ_BANK3;
break;
case HEALTHBOX_GFX_STATUS_BRN_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_BRN_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_BRN_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_BRN_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_BRN_BANK3;
@ -2170,10 +2168,10 @@ static void UpdateLeftNoOfBallsTextOnHealthbox(u8 healthboxSpriteId)
void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elementId)
{
s32 maxHp, currHp;
u8 bank = gSprites[healthboxSpriteId].data[6];
u8 battlerId = gSprites[healthboxSpriteId].data[6];
if (elementId == HEALTHBOX_ALL && !IsDoubleBattle())
GetBattlerSide(bank); // pointless function call
GetBattlerSide(battlerId); // pointless function call
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER)
{
@ -2190,8 +2188,8 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
LoadBattleBarGfx(0);
maxHp = GetMonData(mon, MON_DATA_MAX_HP);
currHp = GetMonData(mon, MON_DATA_HP);
SetBattleBarStruct(bank, healthboxSpriteId, maxHp, currHp, 0);
sub_8074AA0(bank, healthboxSpriteId, HEALTH_BAR, 0);
SetBattleBarStruct(battlerId, healthboxSpriteId, maxHp, currHp, 0);
sub_8074AA0(battlerId, healthboxSpriteId, HEALTH_BAR, 0);
}
isDoubles = IsDoubleBattle();
if (!isDoubles && (elementId == HEALTHBOX_EXP_BAR || elementId == HEALTHBOX_ALL))
@ -2208,8 +2206,8 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
currLevelExp = gExperienceTables[gBaseStats[species].growthRate][level];
currExpBarValue = exp - currLevelExp;
maxExpBarValue = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLevelExp;
SetBattleBarStruct(bank, healthboxSpriteId, maxExpBarValue, currExpBarValue, isDoubles);
sub_8074AA0(bank, healthboxSpriteId, EXP_BAR, 0);
SetBattleBarStruct(battlerId, healthboxSpriteId, maxExpBarValue, currExpBarValue, isDoubles);
sub_8074AA0(battlerId, healthboxSpriteId, EXP_BAR, 0);
}
if (elementId == HEALTHBOX_NICK || elementId == HEALTHBOX_ALL)
UpdateNickInHealthbox(healthboxSpriteId, mon);
@ -2229,8 +2227,8 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
LoadBattleBarGfx(0);
maxHp = GetMonData(mon, MON_DATA_MAX_HP);
currHp = GetMonData(mon, MON_DATA_HP);
SetBattleBarStruct(bank, healthboxSpriteId, maxHp, currHp, 0);
sub_8074AA0(bank, healthboxSpriteId, HEALTH_BAR, 0);
SetBattleBarStruct(battlerId, healthboxSpriteId, maxHp, currHp, 0);
sub_8074AA0(battlerId, healthboxSpriteId, HEALTH_BAR, 0);
}
if (elementId == HEALTHBOX_NICK || elementId == HEALTHBOX_ALL)
UpdateNickInHealthbox(healthboxSpriteId, mon);
@ -2239,44 +2237,44 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
}
}
s32 sub_8074AA0(u8 bank, u8 healthboxSpriteId, u8 whichBar, u8 arg3)
s32 sub_8074AA0(u8 battlerId, u8 healthboxSpriteId, u8 whichBar, u8 arg3)
{
s32 var;
if (whichBar == HEALTH_BAR) // health bar
{
var = sub_8074DB8(gBattleSpritesDataPtr->battleBars[bank].maxValue,
gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
var = sub_8074DB8(gBattleSpritesDataPtr->battleBars[battlerId].maxValue,
gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].field_10,
6, 1);
}
else // exp bar
{
u16 expFraction = GetScaledExpFraction(gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
gBattleSpritesDataPtr->battleBars[bank].maxValue, 8);
u16 expFraction = GetScaledExpFraction(gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
gBattleSpritesDataPtr->battleBars[battlerId].maxValue, 8);
if (expFraction == 0)
expFraction = 1;
expFraction = abs(gBattleSpritesDataPtr->battleBars[bank].receivedValue / expFraction);
expFraction = abs(gBattleSpritesDataPtr->battleBars[battlerId].receivedValue / expFraction);
var = sub_8074DB8(gBattleSpritesDataPtr->battleBars[bank].maxValue,
gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
var = sub_8074DB8(gBattleSpritesDataPtr->battleBars[battlerId].maxValue,
gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].field_10,
8, expFraction);
}
if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars))
sub_8074B9C(bank, whichBar);
if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars))
sub_8074B9C(battlerId, whichBar);
if (var == -1)
gBattleSpritesDataPtr->battleBars[bank].field_10 = 0;
gBattleSpritesDataPtr->battleBars[battlerId].field_10 = 0;
return var;
}
static void sub_8074B9C(u8 bank, u8 whichBar)
static void sub_8074B9C(u8 battlerId, u8 whichBar)
{
u8 array[8];
u8 subRet, level;
@ -2286,10 +2284,10 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
switch (whichBar)
{
case HEALTH_BAR:
subRet = sub_8074E8C(gBattleSpritesDataPtr->battleBars[bank].maxValue,
gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
subRet = sub_8074E8C(gBattleSpritesDataPtr->battleBars[battlerId].maxValue,
gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].field_10,
array, 6);
barElementId = 3;
if (subRet <= 0x18)
@ -2300,7 +2298,7 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
}
for (i = 0; i < 6; i++)
{
u8 healthboxSpriteId_2 = gSprites[gBattleSpritesDataPtr->battleBars[bank].healthboxSpriteId].data[5];
u8 healthboxSpriteId_2 = gSprites[gBattleSpritesDataPtr->battleBars[battlerId].healthboxSpriteId].data[5];
if (i < 2)
CpuCopy32(GetHealthboxElementGfxPtr(barElementId) + array[i] * 32,
(void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId_2].oam.tileNum + 2 + i) * 32), 32);
@ -2310,12 +2308,12 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
}
break;
case EXP_BAR:
sub_8074E8C(gBattleSpritesDataPtr->battleBars[bank].maxValue,
gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
sub_8074E8C(gBattleSpritesDataPtr->battleBars[battlerId].maxValue,
gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].field_10,
array, 8);
level = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_LEVEL);
level = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_LEVEL);
if (level == MAX_MON_LEVEL)
{
for (i = 0; i < 8; i++)
@ -2325,10 +2323,10 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
{
if (i < 4)
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_12) + array[i] * 32,
(void*)(OBJ_VRAM0 + (gSprites[gBattleSpritesDataPtr->battleBars[bank].healthboxSpriteId].oam.tileNum + 0x24 + i) * 32), 32);
(void*)(OBJ_VRAM0 + (gSprites[gBattleSpritesDataPtr->battleBars[battlerId].healthboxSpriteId].oam.tileNum + 0x24 + i) * 32), 32);
else
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_12) + array[i] * 32,
(void*)(OBJ_VRAM0 + 0xB80 + (i + gSprites[gBattleSpritesDataPtr->battleBars[bank].healthboxSpriteId].oam.tileNum) * 32), 32);
(void*)(OBJ_VRAM0 + 0xB80 + (i + gSprites[gBattleSpritesDataPtr->battleBars[battlerId].healthboxSpriteId].oam.tileNum) * 32), 32);
}
break;
}

View File

@ -94,12 +94,8 @@ extern const struct ScanlineEffectParams gUnknown_0831AC70;
// strings
extern const u8 gText_LinkStandby3[];
extern const u8 gText_RecordBattleToPass[];
extern const u8 gText_BattleYesNoChoice[];
extern const u8 gText_BattleRecordCouldntBeSaved[];
extern const u8 gText_BattleRecordedOnPass[];
extern const u8 gText_ShedinjaJapaneseName[];
extern const u8 gText_EmptyString3[];
extern const u8 gText_Poison[];
extern const u8 gText_Sleep[];
extern const u8 gText_Paralysis[];
@ -3594,7 +3590,6 @@ static void BattleIntroOpponent1SendsOutMonAnimation(void)
gBattleMainFunc = BattleIntroRecordMonsToDex;
}
#else
ASM_DIRECT
static void BattleIntroOpponent1SendsOutMonAnimation(void)
@ -3681,7 +3676,6 @@ _0803B2F2:\n\
.pool\n\
.syntax divided");
}
#endif // NONMATCHING
static void BattleIntroRecordMonsToDex(void)
@ -4042,8 +4036,7 @@ u8 IsRunningFromBattleImpossible(void)
}
if (side != GetBattlerSide(i)
&& gBattleMons[gActiveBattler].ability != ABILITY_LEVITATE
&& gBattleMons[gActiveBattler].type1 != TYPE_FLYING
&& gBattleMons[gActiveBattler].type2 != TYPE_FLYING
&& !IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_FLYING)
&& gBattleMons[i].ability == ABILITY_ARENA_TRAP)
{
gBattleScripting.battler = i;
@ -4053,7 +4046,7 @@ u8 IsRunningFromBattleImpossible(void)
}
}
i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0);
if (i != 0 && (gBattleMons[gActiveBattler].type1 == TYPE_STEEL || gBattleMons[gActiveBattler].type2 == TYPE_STEEL))
if (i != 0 && IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_STEEL))
{
gBattleScripting.battler = i - 1;
gLastUsedAbility = gBattleMons[i - 1].ability;
@ -4240,12 +4233,10 @@ static void HandleTurnActionSelectionState(void)
}
else if ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0))
|| ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0))
&& gBattleMons[gActiveBattler].type1 != TYPE_FLYING
&& gBattleMons[gActiveBattler].type2 != TYPE_FLYING
&& !IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_FLYING)
&& gBattleMons[gActiveBattler].ability != ABILITY_LEVITATE)
|| ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0))
&& (gBattleMons[gActiveBattler].type1 == TYPE_STEEL
|| gBattleMons[gActiveBattler].type2 == TYPE_STEEL)))
&& IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_STEEL)))
{
BtlController_EmitChoosePokemon(0, ((i - 1) << 4) | 4, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBattler]);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@
#include "overworld.h"
#include "field_weather.h"
#include "gym_leader_rematch.h"
#include "field_map_obj_helpers.h"
enum
{
@ -56,18 +57,12 @@ extern bool8 InBattlePyramid(void);
extern bool8 InBattlePike(void);
extern bool32 InTrainerHill(void);
extern bool32 FieldPoisonEffectIsRunning(void);
extern void overworld_free_bg_tilemaps(void);
extern void prev_quest_postbuffer_cursor_backup_reset(void);
extern void ResetPoisonStepCounter(void);
extern void sub_81BE72C(void);
extern void FreezeMapObjects(void);
extern void sub_808BCF4(void);
extern void sub_80EECC8(void);
extern void Overworld_ClearSavedMusic(void);
extern void CB2_WhiteOut(void);
extern void sub_80AF6F0(void);
extern void PlayBattleBGM(void);
extern u8 Overworld_GetFlashLevel(void);
extern u16 sub_81A9AA8(u8 localId);
extern u16 sub_81D6180(u8 localId);
extern bool8 GetBattlePyramidTrainerFlag(u8 mapObjId);

View File

@ -23,7 +23,6 @@
#include "link.h"
#include "berry.h"
extern u8 weather_get_current(void);
// rom const data
@ -1664,36 +1663,31 @@ u8 CastformDataTypeChange(u8 battler)
u8 formChange = 0;
if (gBattleMons[battler].species != SPECIES_CASTFORM || gBattleMons[battler].ability != ABILITY_FORECAST || gBattleMons[battler].hp == 0)
return CASTFORM_NO_CHANGE;
if (!WEATHER_HAS_EFFECT && gBattleMons[battler].type1 != TYPE_NORMAL && gBattleMons[battler].type2 != TYPE_NORMAL)
if (!WEATHER_HAS_EFFECT && !IS_BATTLER_OF_TYPE(battler, TYPE_NORMAL))
{
gBattleMons[battler].type1 = TYPE_NORMAL;
gBattleMons[battler].type2 = TYPE_NORMAL;
SET_BATTLER_TYPE(battler, TYPE_NORMAL);
return CASTFORM_TO_NORMAL;
}
if (!WEATHER_HAS_EFFECT)
return CASTFORM_NO_CHANGE;
if (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL)) && gBattleMons[battler].type1 != TYPE_NORMAL && gBattleMons[battler].type2 != TYPE_NORMAL)
if (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)) && !IS_BATTLER_OF_TYPE(battler, TYPE_NORMAL))
{
gBattleMons[battler].type1 = TYPE_NORMAL;
gBattleMons[battler].type2 = TYPE_NORMAL;
SET_BATTLER_TYPE(battler, TYPE_NORMAL);
formChange = CASTFORM_TO_NORMAL;
}
if (gBattleWeather & WEATHER_SUN_ANY && gBattleMons[battler].type1 != TYPE_FIRE && gBattleMons[battler].type2 != TYPE_FIRE)
if (gBattleWeather & WEATHER_SUN_ANY && !IS_BATTLER_OF_TYPE(battler, TYPE_FIRE))
{
gBattleMons[battler].type1 = TYPE_FIRE;
gBattleMons[battler].type2 = TYPE_FIRE;
SET_BATTLER_TYPE(battler, TYPE_FIRE);
formChange = CASTFORM_TO_FIRE;
}
if (gBattleWeather & WEATHER_RAIN_ANY && gBattleMons[battler].type1 != TYPE_WATER && gBattleMons[battler].type2 != TYPE_WATER)
if (gBattleWeather & WEATHER_RAIN_ANY && !IS_BATTLER_OF_TYPE(battler, TYPE_WATER))
{
gBattleMons[battler].type1 = TYPE_WATER;
gBattleMons[battler].type2 = TYPE_WATER;
SET_BATTLER_TYPE(battler, TYPE_WATER);
formChange = CASTFORM_TO_WATER;
}
if (gBattleWeather & WEATHER_HAIL && gBattleMons[battler].type1 != TYPE_ICE && gBattleMons[battler].type2 != TYPE_ICE)
if (gBattleWeather & WEATHER_HAIL_ANY && !IS_BATTLER_OF_TYPE(battler, TYPE_ICE))
{
gBattleMons[battler].type1 = TYPE_ICE;
gBattleMons[battler].type2 = TYPE_ICE;
SET_BATTLER_TYPE(battler, TYPE_ICE);
formChange = CASTFORM_TO_ICE;
}
return formChange;
@ -2023,14 +2017,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& move != MOVE_STRUGGLE
&& gBattleMoves[move].power != 0
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& gBattleMons[battler].type1 != moveType
&& gBattleMons[battler].type2 != moveType
&& TARGET_TURN_DAMAGED
&& !IS_BATTLER_OF_TYPE(battler, moveType)
&& gBattleMons[battler].hp != 0)
{
gBattleMons[battler].type1 = moveType;
gBattleMons[battler].type2 = moveType;
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType)
SET_BATTLER_TYPE(battler, moveType);
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ColorChangeActivates;
effect++;
@ -2040,7 +2032,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT))
{
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16;
@ -2055,7 +2047,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 10) == 0)
{
@ -2078,7 +2070,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 3) == 0)
{
@ -2093,7 +2085,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 3) == 0)
{
@ -2109,7 +2101,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (Random() % 3) == 0)
{
gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN;
@ -2124,7 +2116,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& gBattleMons[gBattlerTarget].hp != 0
&& (Random() % 3) == 0
&& gBattleMons[gBattlerAttacker].ability != ABILITY_OBLIVIOUS
@ -3134,7 +3126,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{
case HOLD_EFFECT_FLINCH:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (Random() % 100) < atkQuality
&& gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED
&& gBattleMons[gBattlerTarget].hp)
@ -3186,14 +3178,14 @@ void HandleAction_RunBattleScript(void) // identical to RunBattleScriptCommands
gBattleScriptingCommandsTable[*gBattlescriptCurrInstr]();
}
u8 GetMoveTarget(u16 move, u8 useMoveTarget)
u8 GetMoveTarget(u16 move, u8 setTarget)
{
u8 targetBank = 0;
u8 moveTarget;
u8 side;
if (useMoveTarget)
moveTarget = useMoveTarget - 1;
if (setTarget)
moveTarget = setTarget - 1;
else
moveTarget = gBattleMoves[move].target;

View File

@ -76,26 +76,26 @@ void FreeBattleResources(void)
void AdjustFriendshipOnBattleFaint(u8 battlerId)
{
u8 opposingBank;
u8 opposingBattlerId;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
u8 opposingBank2;
u8 opposingBattlerId2;
opposingBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposingBank2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
opposingBattlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposingBattlerId2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
if (gBattleMons[opposingBank2].level > gBattleMons[opposingBank].level)
opposingBank = opposingBank2;
if (gBattleMons[opposingBattlerId2].level > gBattleMons[opposingBattlerId].level)
opposingBattlerId = opposingBattlerId2;
}
else
{
opposingBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposingBattlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
}
if (gBattleMons[opposingBank].level > gBattleMons[battlerId].level)
if (gBattleMons[opposingBattlerId].level > gBattleMons[battlerId].level)
{
if (gBattleMons[opposingBank].level - gBattleMons[battlerId].level > 29)
if (gBattleMons[opposingBattlerId].level - gBattleMons[battlerId].level > 29)
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 8);
else
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 6);

View File

@ -29,6 +29,7 @@
#include "pokeblock.h"
#include "trig.h"
#include "tv.h"
#include "item_menu.h"
#define BLENDER_SCORE_BEST 0
#define BLENDER_SCORE_GOOD 1
@ -128,7 +129,6 @@ struct BerryBlenderData
extern struct MusicPlayerInfo gMPlayInfo_SE2;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern u16 gSpecialVar_ItemId;
extern u8 gInGameOpponentsNo;
extern u8 gUnknown_020322D5;
extern u8 gResultsWindowId;
@ -155,13 +155,11 @@ extern void sub_81978B0(u16);
extern void sub_800A418(void);
extern u8 sub_800A9D8(void);
extern bool8 sub_800A4D8(u8);
extern void sub_8197DF8(u8 windowId, bool8 copyToVram);
extern void sub_809882C(u8, u16, u8);
extern void copy_textbox_border_tile_patterns_to_vram(u8, u16, u8);
extern void sub_81AABF0(void (*callback)(void));
extern void sub_800B4C0(void);
extern void ClearLinkCallback(void);
extern void CB2_ReturnToFieldContinueScript(void);
extern void sub_8153430(void);
extern bool8 sub_8153474(void);
extern void sub_80EECEC(void);

View File

@ -5,10 +5,6 @@
#include "constants/species.h"
#include "strings.h"
extern u16 gSpecialVar_0x8004;
extern u16 gSpecialVar_0x8005;
extern u16 gSpecialVar_0x8006;
bool16 ScriptGetPokedexInfo(void)
{
if (gSpecialVar_0x8004 == 0) // is national dex not present?

View File

@ -41,11 +41,10 @@ extern const u8 gDaycareText_PlayOther[];
extern u8 GetCursorSelectionMonId(void);
extern u16 ItemIdToBattleMoveId(u16);
extern s32 ListMenuHandleInputGetItemId(u8);
extern void sub_81AE6C8(u8, u16*, u16*);
extern void DestroyListMenuTask(u8, u16*, u16*);
extern void sub_819746C(u8, bool8);
extern void NewMenuHelpers_DrawStdWindowFrame(u8, bool8);
extern void sub_81B9328(void);
extern void sub_81AF078(u32, bool8, struct ListMenu *);
extern void CB2_ReturnToField(void);
// this file's functions
@ -79,18 +78,18 @@ static const struct ListMenuTemplate sDaycareListMenuLevelTemplate =
.unk_08 = DaycarePrintMonInfo,
.totalItems = 3,
.maxShowed = 3,
.unk_10 = 0,
.windowId = 0,
.unk_11 = 0,
.unk_12 = 8,
.cursor_Y = 0,
.cursor_X = 0,
.upText_Y = 1,
.cursorColor = 2,
.fillColor = 1,
.cursorShadowColor = 3,
.unk_16_0 = TRUE,
.spaceBetweenItems = 0,
.unk_16_7 = FALSE,
.unk_17_0 = 1,
.cursorPal = 2,
.fillValue = 1,
.cursorShadowPal = 3,
.lettersSpacing = 1,
.unk_16_3 = 0,
.scrollMultiple = LIST_NO_MULTIPLE_SCROLL,
.fontId = 1,
.cursorKind = 0
};
@ -1271,7 +1270,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
gSpecialVar_Result = 2;
break;
}
sub_81AE6C8(gTasks[taskId].tMenuListTaskId, NULL, NULL);
DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL);
sub_819746C(gTasks[taskId].tWindowId, TRUE);
RemoveWindow(gTasks[taskId].tWindowId);
DestroyTask(taskId);
@ -1280,7 +1279,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
else if (gMain.newKeys & B_BUTTON)
{
gSpecialVar_Result = 2;
sub_81AE6C8(gTasks[taskId].tMenuListTaskId, NULL, NULL);
DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL);
sub_819746C(gTasks[taskId].tWindowId, TRUE);
RemoveWindow(gTasks[taskId].tWindowId);
DestroyTask(taskId);
@ -1299,7 +1298,7 @@ void ShowDaycareLevelMenu(void)
NewMenuHelpers_DrawStdWindowFrame(windowId, FALSE);
menuTemplate = sDaycareListMenuLevelTemplate;
menuTemplate.unk_10 = windowId;
menuTemplate.windowId = windowId;
listMenuTaskId = ListMenuInit(&menuTemplate, 0, 0);
CopyWindowToVram(windowId, 3);

View File

@ -113,7 +113,7 @@ void sub_812719C(u8 taskId);
void sub_81271CC(u8 taskId);
void sub_8127268(u8 taskId);
void sub_8127454(u8 *dest, u16 decorId);
void sub_8127480(u32 a0, bool8 flag, struct ListMenu *menu);
void sub_8127480(s32 a0, bool8 flag, struct ListMenu *menu);
void sub_81274A0(u8 a0, s32 a1, u8 a2);
void sub_8127620(u8 taskId);
void sub_812764C(u8 taskId);
@ -801,7 +801,7 @@ void sub_8127330(u8 taskId)
sDecorPCBuffer->items[i].name = sDecorPCBuffer->names[i];
sDecorPCBuffer->items[i].id = -2;
gMultiuseListMenuTemplate = gUnknown_085A6BD0;
gMultiuseListMenuTemplate.unk_10 = sDecorMenuWindowIndices[1];
gMultiuseListMenuTemplate.windowId = sDecorMenuWindowIndices[1];
gMultiuseListMenuTemplate.totalItems = sDecorPCBuffer->unk_520;
gMultiuseListMenuTemplate.items = sDecorPCBuffer->items;
gMultiuseListMenuTemplate.maxShowed = sDecorPCBuffer->unk_521;
@ -813,7 +813,7 @@ void sub_8127454(u8 *dest, u16 decorId)
StringAppend(dest, gDecorations[decorId].name);
}
void sub_8127480(u32 a0, bool8 flag, struct ListMenu *menu)
void sub_8127480(s32 a0, bool8 flag, struct ListMenu *menu)
{
if (flag != TRUE)
{
@ -892,7 +892,7 @@ void sub_812764C(u8 taskId)
if (!gPaletteFade.active)
{
input = ListMenuHandleInputGetItemId(data[13]);
sub_81AE860(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo);
ListMenuGetScrollAndRow(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo);
switch (input)
{
case -1:
@ -905,7 +905,7 @@ void sub_812764C(u8 taskId)
PlaySE(SE_SELECT);
gCurDecorationIndex = input;
sub_8127554();
sub_81AE6C8(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo);
DestroyListMenuTask(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo);
sub_8126A58(1);
sub_81277A8();
free(sDecorPCBuffer);
@ -1074,7 +1074,7 @@ void sub_8127A8C(u8 taskId)
data = gTasks[taskId].data;
sub_8127554();
sub_81277A8();
sub_81AE6C8(data[13], NULL, NULL);
DestroyListMenuTask(data[13], NULL, NULL);
free(sDecorPCBuffer);
sub_8126E44(taskId);
}

View File

@ -49,7 +49,6 @@ extern u16 gBattle_BG2_Y;
extern u16 gBattle_BG3_X;
extern u16 gBattle_BG3_Y;
extern bool8 gAffineAnimsDisabled;
extern u16 gMoveToLearn;
extern const u8 gSpeciesNames[][11];
#define sEvoCursorPos gBattleCommunication[1] // when learning a new move
@ -59,11 +58,6 @@ extern const struct WindowTemplate gUnknown_0833900C;
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
// strings
extern const u8 gText_PkmnIsEvolving[];
extern const u8 gText_CongratsPkmnEvolved[];
extern const u8 gText_BattleYesNoChoice[];
extern const u8 gText_PkmnStoppedEvolving[];
extern const u8 gText_EllipsisQuestionMark[];
extern const u8 gText_CommunicationStandby5[];
extern void sub_80356D0(void);

View File

@ -124,7 +124,7 @@ void sub_81ABAC4(void);
void sub_81ABAE0(void);
u8 sub_81AB1F0(u8);
void sub_81AC23C(u8);
void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu*);
void bag_menu_change_item_callback(s32 a, bool8 b, struct ListMenu*);
void sub_81AB520(u8 rboxId, int item_index_in_pocket, u8 a);
void ItemMenu_UseOutOfBattle(u8 taskId);
void ItemMenu_Toss(u8 taskId);
@ -641,7 +641,7 @@ void get_name(s8 *dest, u16 itemId)
}
}
void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu *unused)
void bag_menu_change_item_callback(s32 a, bool8 b, struct ListMenu *unused)
{
if (b != 1)
{
@ -783,7 +783,7 @@ void task_close_bag_menu_2(u8 taskId)
s16* data = gTasks[taskId].data;
if (!gPaletteFade.active)
{
sub_81AE6C8(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
DestroyListMenuTask(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
if (gUnknown_0203CE54->unk0 != 0)
SetMainCallback2(gUnknown_0203CE54->unk0);
else
@ -868,7 +868,7 @@ void bag_menu_inits_lists_menu(u8 taskId)
u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket];
u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket];
bag_menu_RemoveBagItem_message_window(4);
sub_81AE6C8(data[0], scrollPos, cursorPos);
DestroyListMenuTask(data[0], scrollPos, cursorPos);
sub_81AB9A8(gUnknown_0203CE58.pocket);
sub_81ABA88(gUnknown_0203CE58.pocket);
load_bag_item_list_buffers(gUnknown_0203CE58.pocket);
@ -920,7 +920,7 @@ void Task_BagMenu(u8 taskId)
{
if (sub_81AC2C0() == 1)
{
sub_81AE860(data[0], scrollPos, cursorPos);
ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos);
if ((*scrollPos + *cursorPos) != gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - 1)
{
PlaySE(SE_SELECT);
@ -932,7 +932,7 @@ void Task_BagMenu(u8 taskId)
else
{
int r4 = ListMenuHandleInputGetItemId(data[0]);
sub_81AE860(data[0], scrollPos, cursorPos);
ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos);
switch (r4)
{
case -1:
@ -1013,7 +1013,7 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3)
{
ClearWindowTilemap(0);
ClearWindowTilemap(1);
sub_81AE6C8(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
DestroyListMenuTask(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
schedule_bg_copy_tilemap_to_vram(0);
gSprites[gUnknown_0203CE54->unk804[2 + (gUnknown_0203CE54->unk81B_1 ^ 1)]].invisible = 1;
sub_81AB824();
@ -1140,13 +1140,13 @@ void sub_81AC3C0(u8 taskId)
if (gMain.newKeys & SELECT_BUTTON)
{
PlaySE(SE_SELECT);
sub_81AE860(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
ListMenuGetScrollAndRow(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
sub_81AC498(taskId);
}
else
{
r7 = ListMenuHandleInputGetItemId(data[0]);
sub_81AE860(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
ListMenuGetScrollAndRow(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
sub_80D4FC8(0);
sub_80D4FEC(gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]);
switch (r7)
@ -1181,7 +1181,7 @@ void sub_81AC498(u8 taskId)
{
sub_80D702C(gBagPockets[gUnknown_0203CE58.pocket].itemSlots, data[1], realPos);
gUnknown_0203CE54->unk81A = -1;
sub_81AE6C8(data[0], scrollPos, cursorPos);
DestroyListMenuTask(data[0], scrollPos, cursorPos);
if (data[1] < realPos)
gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]--;
load_bag_item_list_buffers(gUnknown_0203CE58.pocket);
@ -1199,7 +1199,7 @@ void sub_81AC590(u8 taskId)
u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket];
gUnknown_0203CE54->unk81A = -1;
sub_81AE6C8(data[0], scrollPos, cursorPos);
DestroyListMenuTask(data[0], scrollPos, cursorPos);
if (data[1] < (*scrollPos + *cursorPos))
gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]--;
load_bag_item_list_buffers(gUnknown_0203CE58.pocket);
@ -1571,7 +1571,7 @@ void Task_ActuallyToss(u8 taskId)
{
PlaySE(SE_SELECT);
RemoveBagItem(gSpecialVar_ItemId, data[8]);
sub_81AE6C8(data[0], scrollPos, cursorPos);
DestroyListMenuTask(data[0], scrollPos, cursorPos);
sub_81AB9A8(gUnknown_0203CE58.pocket);
sub_81ABA88(gUnknown_0203CE58.pocket);
load_bag_item_list_buffers(gUnknown_0203CE58.pocket);
@ -1591,7 +1591,7 @@ void ItemMenu_Register(u8 taskId)
gSaveBlock1Ptr->registeredItem = 0;
else
gSaveBlock1Ptr->registeredItem = gSpecialVar_ItemId;
sub_81AE6C8(data[0], scrollPos, cursorPos);
DestroyListMenuTask(data[0], scrollPos, cursorPos);
load_bag_item_list_buffers(gUnknown_0203CE58.pocket);
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos);
schedule_bg_copy_tilemap_to_vram(0);
@ -1839,7 +1839,7 @@ void sub_81AD8C8(u8 taskId)
PlaySE(SE_REGI);
RemoveBagItem(gSpecialVar_ItemId, data[8]);
AddMoney(&gSaveBlock1Ptr->money, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]);
sub_81AE6C8(data[0], scrollPos, cursorPos);
DestroyListMenuTask(data[0], scrollPos, cursorPos);
sub_81AB9A8(gUnknown_0203CE58.pocket);
sub_81ABA88(gUnknown_0203CE58.pocket);
load_bag_item_list_buffers(gUnknown_0203CE58.pocket);
@ -2012,7 +2012,7 @@ void Task_WallyTutorialBagMenu(u8 taskId)
case 0x132:
PlaySE(SE_SELECT);
bag_menu_remove_some_window();
sub_81AE6C8(data[0], 0, 0);
DestroyListMenuTask(data[0], 0, 0);
RestoreBagAfterWallyTutorial();
unknown_ItemMenu_Confirm(taskId);
break;

633
src/list_menu.c Normal file
View File

@ -0,0 +1,633 @@
#include "global.h"
#include "menu.h"
#include "list_menu.h"
#include "window.h"
#include "text_window.h"
#include "main.h"
#include "task.h"
#include "menu_indicators.h"
#include "strings.h"
#include "sound.h"
#include "constants/songs.h"
struct UnknownMysteryGiftLinkMenuStruct
{
s32 field_0;
u8 field_4;
u8 field_5;
u8 field_6;
};
struct UnknownListMenuPals
{
u8 cursorPal:4;
u8 fillValue:4;
u8 cursorShadowPal:4;
u8 lettersSpacing:6;
u8 field_2_2:6; // unused
u8 fontId:7;
u8 field_3_7:1;
};
extern struct UnknownMysteryGiftLinkMenuStruct gUnknown_0203CE84;
// this file's functions
static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow);
static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown);
static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count);
static void ListMenuDrawCursor(struct ListMenu *list);
static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2);
static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind);
// IWRAM common
struct UnknownListMenuPals gUnknown_03006300;
struct ListMenuTemplate gMultiuseListMenuTemplate;
// code
static void ListMenuDummyTask(u8 taskId)
{
}
s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum)
{
switch (gUnknown_0203CE84.field_4)
{
case 0:
default:
gUnknown_0203CE84.field_5 = AddWindow(windowTemplate);
switch (arg2)
{
case 2:
sub_809882C(gUnknown_0203CE84.field_5, tileNum, palNum);
case 1:
sub_8098858(gUnknown_0203CE84.field_5, tileNum, palNum / 16);
break;
}
gMultiuseListMenuTemplate = *listMenuTemplate;
gMultiuseListMenuTemplate.windowId = gUnknown_0203CE84.field_5;
gUnknown_0203CE84.field_6 = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
CopyWindowToVram(gUnknown_0203CE84.field_5, 1);
gUnknown_0203CE84.field_4 = 1;
break;
case 1:
gUnknown_0203CE84.field_0 = ListMenuHandleInputGetItemId(gUnknown_0203CE84.field_6);
if (gMain.newKeys & A_BUTTON)
{
gUnknown_0203CE84.field_4 = 2;
}
if (gMain.newKeys & B_BUTTON)
{
gUnknown_0203CE84.field_0 = LIST_B_PRESSED;
gUnknown_0203CE84.field_4 = 2;
}
if (gUnknown_0203CE84.field_4 == 2)
{
if (arg2 == 0)
{
ClearWindowTilemap(gUnknown_0203CE84.field_5);
}
else
{
switch (arg2)
{
case 0: // can never be reached, because of the if statement above
sub_819746C(gUnknown_0203CE84.field_5, FALSE);
break;
case 2:
case 1:
sub_819746C(gUnknown_0203CE84.field_5, FALSE);
break;
}
}
CopyWindowToVram(gUnknown_0203CE84.field_5, 1);
}
break;
case 2:
DestroyListMenuTask(gUnknown_0203CE84.field_6, NULL, NULL);
RemoveWindow(gUnknown_0203CE84.field_5);
gUnknown_0203CE84.field_4 = 0;
return gUnknown_0203CE84.field_0;
}
return -1;
}
u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow)
{
u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow);
PutWindowTilemap(listMenuTemplate->windowId);
CopyWindowToVram(listMenuTemplate->windowId, 2);
return taskId;
}
// unused
u8 ListMenuInitWithWindows(struct ListMenuTemplate *listMenuTemplate, struct UnknownListMenuWindowStruct *arg1, u16 scrollOffset, u16 selectedRow)
{
s32 i;
u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow);
for (i = 0; arg1[i].palNum != 0xFF; i++)
{
PutWindowRectTilemapOverridePalette(listMenuTemplate->windowId,
arg1[i].x,
arg1[i].y,
arg1[i].width,
arg1[i].height,
arg1[i].palNum);
}
CopyWindowToVram(listMenuTemplate->windowId, 2);
return taskId;
}
s32 ListMenuHandleInputGetItemId(u8 listTaskId)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
if (gMain.newKeys & A_BUTTON)
{
return list->template.items[list->scrollOffset + list->selectedRow].id;
}
else if (gMain.newKeys & B_BUTTON)
{
return LIST_B_PRESSED;
}
else if (gMain.newAndRepeatedKeys & DPAD_UP)
{
ListMenuChangeSelection(list, TRUE, 1, FALSE);
return LIST_NOTHING_CHOSEN;
}
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{
ListMenuChangeSelection(list, TRUE, 1, TRUE);
return LIST_NOTHING_CHOSEN;
}
else // try to move by one window scroll
{
bool16 rightButton, leftButton;
switch (list->template.scrollMultiple)
{
case LIST_NO_MULTIPLE_SCROLL:
default:
leftButton = FALSE;
rightButton = FALSE;
break;
case LIST_MULTIPLE_SCROLL_DPAD:
leftButton = gMain.newAndRepeatedKeys & DPAD_LEFT;
rightButton = gMain.newAndRepeatedKeys & DPAD_RIGHT;
break;
case LIST_MULTIPLE_SCROLL_L_R:
leftButton = gMain.newAndRepeatedKeys & L_BUTTON;
rightButton = gMain.newAndRepeatedKeys & R_BUTTON;
break;
}
if (leftButton)
{
ListMenuChangeSelection(list, TRUE, list->template.maxShowed, FALSE);
return LIST_NOTHING_CHOSEN;
}
else if (rightButton)
{
ListMenuChangeSelection(list, TRUE, list->template.maxShowed, TRUE);
return LIST_NOTHING_CHOSEN;
}
else
{
return LIST_NOTHING_CHOSEN;
}
}
}
void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
if (scrollOffset != NULL)
*scrollOffset = list->scrollOffset;
if (selectedRow != NULL)
*selectedRow = list->selectedRow;
if (list->unk_1E != 0xFF)
ListMenuRemoveCursorObject(list->unk_1E, list->template.cursorKind - 2);
DestroyTask(listTaskId);
}
void sub_81AE70C(u8 listTaskId)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
ListMenuDrawCursor(list);
CopyWindowToVram(list->template.windowId, 2);
}
// unused
void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillValue, u8 cursorShadowPal)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
list->template.cursorPal = cursorPal;
list->template.fillValue = fillValue;
list->template.cursorShadowPal = cursorShadowPal;
}
// unused
void ChangeListMenuCoords(u8 listTaskId, u8 x, u8 y)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
SetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT, x);
SetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP, y);
}
// unused
s32 ListMenuTestInput(struct ListMenuTemplate *template, u32 scrollOffset, u32 selectedRow, u16 keys, u16 *newScrollOffset, u16 *newSelectedRow)
{
struct ListMenu list;
list.template = *template;
list.scrollOffset = scrollOffset;
list.selectedRow = selectedRow;
list.unk_1C = 0;
list.unk_1D = 0;
if (keys == DPAD_UP)
ListMenuChangeSelection(&list, FALSE, 1, FALSE);
if (keys == DPAD_DOWN)
ListMenuChangeSelection(&list, FALSE, 1, TRUE);
if (newScrollOffset != NULL)
*newScrollOffset = list.scrollOffset;
if (newSelectedRow != NULL)
*newSelectedRow = list.selectedRow;
return LIST_NOTHING_CHOSEN;
}
void ListMenuGetCurrentItemArrayId(u8 listTaskId, u16 *arrayId)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
if (arrayId != NULL)
*arrayId = list->scrollOffset + list->selectedRow;
}
void ListMenuGetScrollAndRow(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
if (scrollOffset != NULL)
*scrollOffset = list->scrollOffset;
if (selectedRow != NULL)
*selectedRow = list->selectedRow;
}
u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3;
return list->selectedRow * yMultiplier + list->template.upText_Y;
}
static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow)
{
u8 listTaskId = CreateTask(ListMenuDummyTask, 0);
struct ListMenu *list = (void*) gTasks[listTaskId].data;
list->template = *listMenuTemplate;
list->scrollOffset = scrollOffset;
list->selectedRow = selectedRow;
list->unk_1C = 0;
list->unk_1D = 0;
list->unk_1E = 0xFF;
list->unk_1F = 0;
gUnknown_03006300.cursorPal = list->template.cursorPal;
gUnknown_03006300.fillValue = list->template.fillValue;
gUnknown_03006300.cursorShadowPal = list->template.cursorShadowPal;
gUnknown_03006300.lettersSpacing = list->template.lettersSpacing;
gUnknown_03006300.fontId = list->template.fontId;
gUnknown_03006300.field_3_7 = 0;
if (list->template.totalItems < list->template.maxShowed)
list->template.maxShowed = list->template.totalItems;
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
ListMenuDrawCursor(list);
ListMenuCallSelectionChangedCallback(list, 1);
return listTaskId;
}
static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
{
u8 colors[3];
if (gUnknown_03006300.field_3_7)
{
colors[0] = gUnknown_03006300.fillValue;
colors[1] = gUnknown_03006300.cursorPal;
colors[2] = gUnknown_03006300.cursorShadowPal;
AddTextPrinterParameterized2(list->template.windowId,
gUnknown_03006300.fontId,
x, y,
gUnknown_03006300.lettersSpacing,
0, colors, TEXT_SPEED_FF, str);
gUnknown_03006300.field_3_7 = 0;
}
else
{
colors[0] = list->template.fillValue;
colors[1] = list->template.cursorPal;
colors[2] = list->template.cursorShadowPal;
AddTextPrinterParameterized2(list->template.windowId,
list->template.fontId,
x, y,
list->template.lettersSpacing,
0, colors, TEXT_SPEED_FF, str);
}
}
static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count)
{
s32 i;
u8 x, y;
u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3;
for (i = 0; i < count; i++)
{
if (list->template.items[startIndex].id != -3)
x = list->template.unk_12;
else
x = list->template.unk_11;
y = (yOffset + i) * yMultiplier + list->template.upText_Y;
if (list->template.unk_08 != NULL)
list->template.unk_08(list->template.windowId, list->template.items[startIndex].id, y);
ListMenuPrint(list, list->template.items[startIndex].name, x, y);
startIndex++;
}
}
static void ListMenuDrawCursor(struct ListMenu *list)
{
u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3;
u8 x = list->template.cursor_X;
u8 y = list->selectedRow * yMultiplier + list->template.upText_Y;
switch (list->template.cursorKind)
{
case 0:
ListMenuPrint(list, gText_SelectorArrow2, x, y);
break;
case 1:
break;
case 2:
if (list->unk_1E == 0xFF)
list->unk_1E = ListMenuAddCursorObject(list, 0);
ListMenuUpdateCursorObject(list->unk_1E,
GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT) * 8 - 1,
GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y - 1, 0);
break;
case 3:
if (list->unk_1E == 0xFF)
list->unk_1E = ListMenuAddCursorObject(list, 1);
ListMenuUpdateCursorObject(list->unk_1E,
GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_LEFT) * 8 + x,
GetWindowAttribute(list->template.windowId, WINDOW_TILEMAP_TOP) * 8 + y, 1);
break;
}
}
static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind)
{
struct CursorStruct cursor;
cursor.unk0 = 0;
cursor.unk1 = 0xA0;
cursor.unk2 = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8 + 2;
cursor.unk4 = GetFontAttribute(list->template.fontId, 1) + 2;
cursor.unk6 = 0x4000;
cursor.unk8 = 0xFFFF;
cursor.unkA = 0xF;
return ListMenuAddCursorObjectInternal(&cursor, cursorKind);
}
static void ListMenuErasePrintedCursor(struct ListMenu *list, u16 selectedRow)
{
u8 cursorKind = list->template.cursorKind;
if (cursorKind == 0)
{
u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3;
u8 width = GetMenuCursorDimensionByFont(list->template.fontId, 0);
u8 height = GetMenuCursorDimensionByFont(list->template.fontId, 1);
FillWindowPixelRect(list->template.windowId,
(list->template.fillValue << 4) | (list->template.fillValue),
list->template.cursor_X,
selectedRow * yMultiplier + list->template.upText_Y,
width,
height);
}
}
static u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(struct ListMenu *list, bool8 movingDown)
{
u16 selectedRow = list->selectedRow;
u16 scrollOffset = list->scrollOffset;
u16 newRow;
u32 newScroll;
if (!movingDown)
{
if (list->template.maxShowed == 1)
newRow = 0;
else
newRow = list->template.maxShowed - ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)) - 1;
if (scrollOffset == 0)
{
while (selectedRow != 0)
{
selectedRow--;
if (list->template.items[scrollOffset + selectedRow].id != -3)
{
list->selectedRow = selectedRow;
return 1;
}
}
return 0;
}
else
{
while (selectedRow > newRow)
{
selectedRow--;
if (list->template.items[scrollOffset + selectedRow].id != -3)
{
list->selectedRow = selectedRow;
return 1;
}
}
newScroll = scrollOffset - 1;
}
}
else
{
if (list->template.maxShowed == 1)
newRow = 0;
else
newRow = ((list->template.maxShowed / 2) + (list->template.maxShowed % 2));
if (scrollOffset == list->template.totalItems - list->template.maxShowed)
{
while (selectedRow < list->template.maxShowed - 1)
{
selectedRow++;
if (list->template.items[scrollOffset + selectedRow].id != -3)
{
list->selectedRow = selectedRow;
return 1;
}
}
return 0;
}
else
{
while (selectedRow < newRow)
{
selectedRow++;
if (list->template.items[scrollOffset + selectedRow].id != -3)
{
list->selectedRow = selectedRow;
return 1;
}
}
newScroll = scrollOffset + 1;
}
}
list->selectedRow = newRow;
list->scrollOffset = newScroll;
return 2;
}
static void ListMenuScroll(struct ListMenu *list, u8 count, bool8 movingDown)
{
if (count >= list->template.maxShowed)
{
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
}
else
{
u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3;
if (!movingDown)
{
u16 y, width, height;
ScrollWindow(list->template.windowId, 1, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, count);
y = (list->template.maxShowed * yMultiplier) + list->template.upText_Y;
width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8;
height = (GetWindowAttribute(list->template.windowId, WINDOW_HEIGHT) * 8) - y;
FillWindowPixelRect(list->template.windowId,
(list->template.fillValue << 4) | (list->template.fillValue),
0, y, width, height);
}
else
{
u16 width;
ScrollWindow(list->template.windowId, 0, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset + (list->template.maxShowed - count), list->template.maxShowed - count, count);
width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8;
FillWindowPixelRect(list->template.windowId,
(list->template.fillValue << 4) | (list->template.fillValue),
0, 0, width, list->template.upText_Y);
}
}
}
static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown)
{
u16 oldSelectedRow;
u8 selectionChange, i, cursorCount;
oldSelectedRow = list->selectedRow;
cursorCount = 0;
selectionChange = 0;
for (i = 0; i < count; i++)
{
do
{
u8 ret = ListMenuUpdateSelectedRowIndexAndScrollOffset(list, movingDown);
selectionChange |= ret;
if (ret != 2)
break;
cursorCount++;
} while (list->template.items[list->scrollOffset + list->selectedRow].id == -3);
}
if (updateCursorAndCallCallback)
{
switch (selectionChange)
{
case 0:
default:
return TRUE;
case 1:
ListMenuErasePrintedCursor(list, oldSelectedRow);
ListMenuDrawCursor(list);
ListMenuCallSelectionChangedCallback(list, 0);
CopyWindowToVram(list->template.windowId, 2);
break;
case 2:
case 3:
ListMenuErasePrintedCursor(list, oldSelectedRow);
ListMenuScroll(list, cursorCount, movingDown);
ListMenuDrawCursor(list);
ListMenuCallSelectionChangedCallback(list, 0);
CopyWindowToVram(list->template.windowId, 2);
break;
}
}
return FALSE;
}
static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2)
{
if (list->template.moveCursorFunc != NULL)
list->template.moveCursorFunc(list->template.items[list->scrollOffset + list->selectedRow].id, a2, list);
}
// unused
void sub_81AF028(u8 cursorPal, u8 fillValue, u8 cursorShadowPal)
{
gUnknown_03006300.cursorPal = cursorPal;
gUnknown_03006300.fillValue = fillValue;
gUnknown_03006300.cursorShadowPal = cursorShadowPal;
gUnknown_03006300.field_3_7 = 1;
}
void sub_81AF078(s32 arg0, u8 arg1, struct ListMenu *list)
{
if (!arg1)
PlaySE(SE_SELECT);
}

View File

@ -43,7 +43,7 @@ static void sub_80768F0(struct Sprite *sprite);
static void sub_80769A8(struct Sprite *sprite);
static void sub_80769CC(struct Sprite *sprite);
static void SpriteCB_HitAnimHealthoxEffect(struct Sprite *sprite);
static u16 GetBankPokeballItemId(u8 bank);
static u16 GetBattlerPokeballItemId(u8 battlerId);
// rom const data
@ -317,11 +317,11 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
},
};
#define tFrames data[0]
#define tPan data[1]
#define tThrowId data[2]
#define tBank data[3]
#define tOpponentBank data[4]
#define tFrames data[0]
#define tPan data[1]
#define tThrowId data[2]
#define tBattler data[3]
#define tOpponentBattler data[4]
u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow)
{
@ -333,17 +333,17 @@ u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow)
taskId = CreateTask(Task_DoPokeballSendOutAnim, 5);
gTasks[taskId].tPan = pan;
gTasks[taskId].tThrowId = kindOfThrow;
gTasks[taskId].tBank = gActiveBattler;
gTasks[taskId].tBattler = gActiveBattler;
return 0;
}
#define sBank data[6]
#define sBattler data[6]
static void Task_DoPokeballSendOutAnim(u8 taskId)
{
u16 throwCaseId;
u8 bank;
u8 battlerId;
u16 itemId, ballId;
u8 ballSpriteId;
bool8 notSendOut = FALSE;
@ -355,12 +355,12 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
}
throwCaseId = gTasks[taskId].tThrowId;
bank = gTasks[taskId].tBank;
battlerId = gTasks[taskId].tBattler;
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
itemId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
itemId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_POKEBALL);
else
itemId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
itemId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_POKEBALL);
ballId = ItemIdToBallId(itemId);
LoadBallGfx(ballId);
@ -372,15 +372,15 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
switch (throwCaseId)
{
case POKEBALL_PLAYER_SENDOUT:
gBattlerTarget = bank;
gBattlerTarget = battlerId;
gSprites[ballSpriteId].pos1.x = 24;
gSprites[ballSpriteId].pos1.y = 68;
gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1;
break;
case POKEBALL_OPPONENT_SENDOUT:
gSprites[ballSpriteId].pos1.x = GetBattlerSpriteCoord(bank, BANK_X_POS);
gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(bank, BANK_Y_POS) + 24;
gBattlerTarget = bank;
gSprites[ballSpriteId].pos1.x = GetBattlerSpriteCoord(battlerId, BANK_X_POS);
gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(battlerId, BANK_Y_POS) + 24;
gBattlerTarget = battlerId;
gSprites[ballSpriteId].data[0] = 0;
gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut;
break;
@ -390,7 +390,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
break;
}
gSprites[ballSpriteId].sBank = gBattlerTarget;
gSprites[ballSpriteId].sBattler = gBattlerTarget;
if (!notSendOut)
{
DestroyTask(taskId);
@ -404,7 +404,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
gSprites[ballSpriteId].data[5] = -40;
sub_80A68D4(&gSprites[ballSpriteId]);
gSprites[ballSpriteId].oam.affineParam = taskId;
gTasks[taskId].tOpponentBank = gBattlerTarget;
gTasks[taskId].tOpponentBattler = gBattlerTarget;
gTasks[taskId].func = TaskDummy;
PlaySE(SE_NAGERU);
}
@ -415,7 +415,7 @@ static void SpriteCB_TestBallThrow(struct Sprite *sprite)
{
u16 ballId;
u8 taskId = sprite->oam.affineParam;
u8 opponentBank = gTasks[taskId].tOpponentBank;
u8 opponentBattler = gTasks[taskId].tOpponentBattler;
u8 noOfShakes = gTasks[taskId].tThrowId;
StartSpriteAnim(sprite, 1);
@ -425,10 +425,10 @@ static void SpriteCB_TestBallThrow(struct Sprite *sprite)
sprite->pos2.x = 0;
sprite->pos2.y = 0;
sprite->data[5] = 0;
ballId = ItemIdToBallId(GetBankPokeballItemId(opponentBank));
ballId = ItemIdToBallId(GetBattlerPokeballItemId(opponentBattler));
LaunchBallStarsTask(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, ballId);
sprite->data[0] = LaunchBallFadeMonTask(FALSE, opponentBank, 14, ballId);
sprite->sBank = opponentBank;
sprite->data[0] = LaunchBallFadeMonTask(FALSE, opponentBattler, 14, ballId);
sprite->sBattler = opponentBattler;
sprite->data[7] = noOfShakes;
DestroyTask(taskId);
sprite->callback = sub_80756D4;
@ -438,8 +438,8 @@ static void SpriteCB_TestBallThrow(struct Sprite *sprite)
#undef tFrames
#undef tPan
#undef tThrowId
#undef tBank
#undef tOpponentBank
#undef tBattler
#undef tOpponentBattler
static void sub_80756D4(struct Sprite *sprite)
{
@ -452,9 +452,9 @@ static void sub_80756E0(struct Sprite *sprite)
{
sprite->data[5] = 0;
sprite->callback = sub_807574C;
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBank]], 2);
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] = 0;
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBattler]], 2);
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]);
gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] = 0;
}
}
@ -463,17 +463,17 @@ static void sub_807574C(struct Sprite *sprite)
sprite->data[5]++;
if (sprite->data[5] == 11)
PlaySE(SE_SUIKOMU);
if (gSprites[gBattlerSpriteIds[sprite->sBank]].affineAnimEnded)
if (gSprites[gBattlerSpriteIds[sprite->sBattler]].affineAnimEnded)
{
StartSpriteAnim(sprite, 2);
gSprites[gBattlerSpriteIds[sprite->sBank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[sprite->sBattler]].invisible = TRUE;
sprite->data[5] = 0;
sprite->callback = sub_80757E4;
}
else
{
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] += 0x60;
gSprites[gBattlerSpriteIds[sprite->sBank]].pos2.y = -gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] >> 8;
gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] += 0x60;
gSprites[gBattlerSpriteIds[sprite->sBattler]].pos2.y = -gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] >> 8;
}
}
@ -641,7 +641,7 @@ static void sub_8075970(struct Sprite *sprite)
#define tCryTaskSpecies data[0]
#define tCryTaskPan data[1]
#define tCryTaskWantedCry data[2]
#define tCryTaskBank data[3]
#define tCryTaskBattler data[3]
#define tCryTaskMonSpriteId data[4]
#define tCryTaskMonPtr1 data[5]
#define tCryTaskMonPtr2 data[6]
@ -653,7 +653,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
u8 wantedCry = gTasks[taskId].tCryTaskWantedCry;
s8 pan = gTasks[taskId].tCryTaskPan;
u16 species = gTasks[taskId].tCryTaskSpecies;
u8 bank = gTasks[taskId].tCryTaskBank;
u8 battlerId = gTasks[taskId].tCryTaskBattler;
u8 monSpriteId = gTasks[taskId].tCryTaskMonSpriteId;
struct Pokemon *mon = (void*)(u32)((gTasks[taskId].tCryTaskMonPtr1 << 0x10) | (u16)(gTasks[taskId].tCryTaskMonPtr2));
@ -669,7 +669,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
PlayCry3(species, pan, 0);
else
PlayCry3(species, pan, 11);
gBattleSpritesDataPtr->healthBoxesData[bank].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
DestroyTask(taskId);
break;
case 2:
@ -685,7 +685,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
else
PlayCry4(species, pan, 12);
gBattleSpritesDataPtr->healthBoxesData[bank].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
DestroyTask(taskId);
}
else
@ -724,7 +724,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
else
PlayCry4(species, pan, 11);
gBattleSpritesDataPtr->healthBoxesData[bank].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
DestroyTask(taskId);
break;
}
@ -732,13 +732,13 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
{
u8 bank = sprite->sBank;
u8 battlerId = sprite->sBattler;
u32 ballId;
StartSpriteAnim(sprite, 1);
ballId = ItemIdToBallId(GetBankPokeballItemId(bank));
ballId = ItemIdToBallId(GetBattlerPokeballItemId(battlerId));
LaunchBallStarsTask(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, ballId);
sprite->data[0] = LaunchBallFadeMonTask(1, sprite->sBank, 14, ballId);
sprite->data[0] = LaunchBallFadeMonTask(1, sprite->sBattler, 14, ballId);
sprite->callback = HandleBallAnimEnd;
if (gMain.inBattle)
@ -749,19 +749,19 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
u16 wantedCryCase;
u8 taskId;
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
{
mon = &gEnemyParty[gBattlerPartyIndexes[bank]];
mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]];
pan = 25;
}
else
{
mon = &gPlayerParty[gBattlerPartyIndexes[bank]];
mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]];
pan = -25;
}
species = GetMonData(mon, MON_DATA_SPECIES);
if ((bank == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || bank == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
if ((battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
&& IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
@ -777,39 +777,39 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
if (!IsDoubleBattle() || !gBattleSpritesDataPtr->animationData->field_9_x1)
wantedCryCase = 0;
else if (bank == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || bank == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
else if (battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
wantedCryCase = 1;
else
wantedCryCase = 2;
gBattleSpritesDataPtr->healthBoxesData[bank].field_1_x40 = 1;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 1;
taskId = CreateTask(Task_PlayCryWhenReleasedFromBall, 3);
gTasks[taskId].tCryTaskSpecies = species;
gTasks[taskId].tCryTaskPan = pan;
gTasks[taskId].tCryTaskWantedCry = wantedCryCase;
gTasks[taskId].tCryTaskBank = bank;
gTasks[taskId].tCryTaskMonSpriteId = gBattlerSpriteIds[sprite->sBank];
gTasks[taskId].tCryTaskBattler = battlerId;
gTasks[taskId].tCryTaskMonSpriteId = gBattlerSpriteIds[sprite->sBattler];
gTasks[taskId].tCryTaskMonPtr1 = (u32)(mon) >> 0x10;
gTasks[taskId].tCryTaskMonPtr2 = (u32)(mon);
gTasks[taskId].tCryTaskState = 0;
}
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBank]], 1);
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBattler]], 1);
if (GetBattlerSide(sprite->sBank) == B_SIDE_OPPONENT)
gSprites[gBattlerSpriteIds[sprite->sBank]].callback = sub_8039B58;
if (GetBattlerSide(sprite->sBattler) == B_SIDE_OPPONENT)
gSprites[gBattlerSpriteIds[sprite->sBattler]].callback = sub_8039B58;
else
gSprites[gBattlerSpriteIds[sprite->sBank]].callback = sub_8039E44;
gSprites[gBattlerSpriteIds[sprite->sBattler]].callback = sub_8039E44;
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] = 0x1000;
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]);
gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] = 0x1000;
}
#undef tCryTaskSpecies
#undef tCryTaskPan
#undef tCryTaskWantedCry
#undef tCryTaskBank
#undef tCryTaskBattler
#undef tCryTaskMonSpriteId
#undef tCryTaskMonPtr1
#undef tCryTaskMonPtr2
@ -828,37 +828,37 @@ static void sub_8075FB4(struct Sprite *sprite)
static void HandleBallAnimEnd(struct Sprite *sprite)
{
bool8 affineAnimEnded = FALSE;
u8 bank = sprite->sBank;
u8 battlerId = sprite->sBattler;
gSprites[gBattlerSpriteIds[bank]].invisible = FALSE;
gSprites[gBattlerSpriteIds[battlerId]].invisible = FALSE;
if (sprite->animEnded)
sprite->invisible = TRUE;
if (gSprites[gBattlerSpriteIds[bank]].affineAnimEnded)
if (gSprites[gBattlerSpriteIds[battlerId]].affineAnimEnded)
{
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[bank]], 0);
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
affineAnimEnded = TRUE;
}
else
{
gSprites[gBattlerSpriteIds[bank]].data[1] -= 288;
gSprites[gBattlerSpriteIds[bank]].pos2.y = gSprites[gBattlerSpriteIds[bank]].data[1] >> 8;
gSprites[gBattlerSpriteIds[battlerId]].data[1] -= 288;
gSprites[gBattlerSpriteIds[battlerId]].pos2.y = gSprites[gBattlerSpriteIds[battlerId]].data[1] >> 8;
}
if (sprite->animEnded && affineAnimEnded)
{
s32 i, doneBanks;
s32 i, doneBattlers;
gSprites[gBattlerSpriteIds[bank]].pos2.y = 0;
gSprites[gBattlerSpriteIds[battlerId]].pos2.y = 0;
gDoingBattleAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].ballAnimActive = 0;
FreeSpriteOamMatrix(sprite);
DestroySprite(sprite);
for (doneBanks = 0, i = 0; i < MAX_BATTLERS_COUNT; i++)
for (doneBattlers = 0, i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (gBattleSpritesDataPtr->healthBoxesData[i].ballAnimActive == 0)
doneBanks++;
doneBattlers++;
}
if (doneBanks == MAX_BATTLERS_COUNT)
if (doneBattlers == MAX_BATTLERS_COUNT)
{
for (i = 0; i < POKEBALL_COUNT; i++)
FreeBallGfx(i);
@ -868,7 +868,7 @@ static void HandleBallAnimEnd(struct Sprite *sprite)
static void sub_80760F8(struct Sprite *sprite)
{
u8 bank = sprite->sBank;
u8 battlerId = sprite->sBattler;
sprite->data[4]++;
if (sprite->data[4] == 40)
@ -883,21 +883,21 @@ static void sub_80760F8(struct Sprite *sprite)
}
else if (sprite->data[4] == 315)
{
FreeOamMatrix(gSprites[gBattlerSpriteIds[sprite->sBank]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
FreeOamMatrix(gSprites[gBattlerSpriteIds[sprite->sBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]);
DestroySpriteAndFreeResources(sprite);
if (gMain.inBattle)
gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].ballAnimActive = 0;
}
}
static void SpriteCB_PlayerMonSendOut_1(struct Sprite *sprite)
{
sprite->data[0] = 25;
sprite->data[2] = GetBattlerSpriteCoord(sprite->sBank, 2);
sprite->data[4] = GetBattlerSpriteCoord(sprite->sBank, 3) + 24;
sprite->data[2] = GetBattlerSpriteCoord(sprite->sBattler, 2);
sprite->data[4] = GetBattlerSpriteCoord(sprite->sBattler, 3) + 24;
sprite->data[5] = -30;
sprite->oam.affineParam = sprite->sBank;
sprite->oam.affineParam = sprite->sBattler;
sub_80A68D4(sprite);
sprite->callback = SpriteCB_PlayerMonSendOut_2;
}
@ -923,7 +923,7 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite)
}
r4 = sprite->data[0];
sub_80A6F3C(sprite);
sprite->data[7] += sprite->sBank / 3;
sprite->data[7] += sprite->sBattler / 3;
sprite->pos2.y += Sin(HIBYTE(sprite->data[7]), sprite->data[5]);
sprite->oam.affineParam += 0x100;
if ((sprite->oam.affineParam >> 8) % 3 != 0)
@ -946,11 +946,11 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite)
sprite->pos1.y += sprite->pos2.y;
sprite->pos2.y = 0;
sprite->pos2.x = 0;
sprite->sBank = sprite->oam.affineParam & 0xFF;
sprite->sBattler = sprite->oam.affineParam & 0xFF;
sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1
&& sprite->sBank == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT))
&& sprite->sBattler == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall;
else
sprite->callback = SpriteCB_ReleaseMonFromBall;
@ -976,26 +976,26 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite)
{
sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1
&& sprite->sBank == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))
&& sprite->sBattler == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall;
else
sprite->callback = SpriteCB_ReleaseMonFromBall;
}
}
#undef sBank
#undef sBattler
static u8 LaunchBallStarsTaskForPokeball(u8 x, u8 y, u8 kindOfStars, u8 d)
{
return LaunchBallStarsTask(x, y, kindOfStars, d, BALL_POKE);
}
static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 bank, u32 arg2)
static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 battlerId, u32 arg2)
{
return LaunchBallFadeMonTask(unFadeLater, bank, arg2, BALL_POKE);
return LaunchBallFadeMonTask(unFadeLater, battlerId, arg2, BALL_POKE);
}
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 bank, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species)
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battlerId, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species)
{
u8 spriteId;
@ -1012,7 +1012,7 @@ void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 bank, u8 x, u8 y, u8 oa
gSprites[monSpriteId].data[7] = species;
gSprites[spriteId].data[1] = g;
gSprites[spriteId].data[2] = bank;
gSprites[spriteId].data[2] = battlerId;
gSprites[spriteId].data[3] = h;
gSprites[spriteId].data[4] = h >> 0x10;
gSprites[spriteId].oam.priority = oamPriority;
@ -1027,7 +1027,7 @@ static void sub_8076524(struct Sprite *sprite)
{
u8 r5;
u8 r7 = sprite->data[0];
u8 bank = sprite->data[2];
u8 battlerId = sprite->data[2];
u32 r4 = (u16)sprite->data[3] | ((u16)sprite->data[4] << 16);
if (sprite->subpriority != 0)
@ -1037,7 +1037,7 @@ static void sub_8076524(struct Sprite *sprite)
StartSpriteAnim(sprite, 1);
LaunchBallStarsTaskForPokeball(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r5);
sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, bank, r4);
sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, battlerId, r4);
sprite->callback = sub_80765E0;
gSprites[r7].invisible = FALSE;
StartSpriteAffineAnim(&gSprites[r7], 1);
@ -1175,16 +1175,16 @@ static void DestroySpriteAndFreeResources_(struct Sprite *sprite)
DestroySpriteAndFreeResources(sprite);
}
void sub_8076918(u8 bank)
void sub_8076918(u8 battlerId)
{
struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[bank]];
struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[battlerId]];
healthboxSprite->data[0] = 5;
healthboxSprite->data[1] = 0;
healthboxSprite->pos2.x = 0x73;
healthboxSprite->pos2.y = 0;
healthboxSprite->callback = sub_80769CC;
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
{
healthboxSprite->data[0] = -healthboxSprite->data[0];
healthboxSprite->data[1] = -healthboxSprite->data[1];
@ -1192,7 +1192,7 @@ void sub_8076918(u8 bank)
healthboxSprite->pos2.y = -healthboxSprite->pos2.y;
}
gSprites[healthboxSprite->data[5]].callback(&gSprites[healthboxSprite->data[5]]);
if (GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT)
if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT)
healthboxSprite->callback = sub_80769A8;
}
@ -1214,13 +1214,13 @@ static void sub_80769CC(struct Sprite *sprite)
sprite->callback = SpriteCallbackDummy;
}
void DoHitAnimHealthboxEffect(u8 bank)
void DoHitAnimHealthboxEffect(u8 battlerId)
{
u8 spriteId;
spriteId = CreateInvisibleSpriteWithCallback(SpriteCB_HitAnimHealthoxEffect);
gSprites[spriteId].data[0] = 1;
gSprites[spriteId].data[1] = gHealthboxSpriteIds[bank];
gSprites[spriteId].data[1] = gHealthboxSpriteIds[battlerId];
gSprites[spriteId].callback = SpriteCB_HitAnimHealthoxEffect;
}
@ -1267,10 +1267,10 @@ void FreeBallGfx(u8 ballId)
FreeSpritePaletteByTag(gBallSpritePalettes[ballId].tag);
}
static u16 GetBankPokeballItemId(u8 bank)
static u16 GetBattlerPokeballItemId(u8 battlerId)
{
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_POKEBALL);
else
return GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
return GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_POKEBALL);
}

View File

@ -91,7 +91,7 @@ static void sub_81362E0(void);
static void sub_8136344(void);
static void HandlePokeblockListMenuItems(void);
static void sub_81363BC(void);
static void MovePokeblockMenuCursor(u32 pkblId, bool8 arg1, struct ListMenu *arg2);
static void MovePokeblockMenuCursor(s32 pkblId, bool8 arg1, struct ListMenu *arg2);
static void PutPokeblockInfoText(void);
static void HandlePokeblockMenuCursor(u16 cursorPos, u16 arg1);
static void PutPokeblockListMenuString(u8 *dst, u16 pkblId);
@ -319,18 +319,18 @@ static const struct ListMenuTemplate sPokeblockListMenuTemplate =
.unk_08 = NULL,
.totalItems = 0,
.maxShowed = 0,
.unk_10 = 1,
.windowId = 1,
.unk_11 = 0,
.unk_12 = 1,
.cursor_Y = 0,
.cursor_X = 0,
.upText_Y = 1,
.cursorColor = 2,
.fillColor = 0,
.cursorShadowColor = 3,
.unk_16_0 = FALSE,
.spaceBetweenItems = 32,
.unk_16_7 = FALSE,
.unk_17_0 = 1,
.cursorPal = 2,
.fillValue = 0,
.cursorShadowPal = 3,
.lettersSpacing = 0,
.unk_16_3 = 0,
.scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD,
.fontId = 1,
.cursorKind = 1
};
@ -620,7 +620,7 @@ static void HandlePokeblockListMenuItems(void)
sPokeblockMenu->items[i].id = LIST_B_PRESSED;
gMultiuseListMenuTemplate = sPokeblockListMenuTemplate;
gMultiuseListMenuTemplate.unk_17_0 = 7;
gMultiuseListMenuTemplate.fontId = 7;
gMultiuseListMenuTemplate.totalItems = sPokeblockMenu->itemsNo;
gMultiuseListMenuTemplate.items = sPokeblockMenu->items;
gMultiuseListMenuTemplate.maxShowed = sPokeblockMenu->maxShowed;
@ -639,7 +639,7 @@ static void PutPokeblockListMenuString(u8 *dst, u16 pkblId)
StringExpandPlaceholders(txtPtr, gText_LvVar1);
}
static void MovePokeblockMenuCursor(u32 pkblId, bool8 arg1, struct ListMenu *arg2)
static void MovePokeblockMenuCursor(s32 pkblId, bool8 arg1, struct ListMenu *arg2)
{
if (arg1 != TRUE)
{
@ -869,7 +869,7 @@ static void Task_FreeDataAndExitPokeblockCase(u8 taskId)
if (sPokeblockMenu->caseId == PBLOCK_CASE_FEEDER || sPokeblockMenu->caseId == PBLOCK_CASE_GIVE)
gFieldCallback = sub_80AF168;
sub_81AE6C8(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
DestroyListMenuTask(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
sub_8136418();
ResetSpriteData();
FreeAllSpritePalettes();
@ -893,7 +893,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId)
{
if (gMain.newKeys & SELECT_BUTTON)
{
sub_81AE860(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
if (sSavedPokeblockData.lastItemPage + sSavedPokeblockData.lastItemPos != sPokeblockMenu->itemsNo - 1)
{
PlaySE(SE_SELECT);
@ -908,7 +908,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId)
u16 oldPosition = sSavedPokeblockData.lastItemPos;
s32 itemId = ListMenuHandleInputGetItemId(data[0]);
sub_81AE860(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
if (oldPosition != sSavedPokeblockData.lastItemPos)
{
HandlePokeblockMenuCursor(oldPosition, 5);
@ -945,7 +945,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId)
if (gMain.newKeys & SELECT_BUTTON)
{
PlaySE(SE_SELECT);
sub_81AE860(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
HandlePokeblocksSwap(taskId, FALSE);
}
else
@ -954,7 +954,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId)
u16 var = sSavedPokeblockData.lastItemPos;
s32 itemId = ListMenuHandleInputGetItemId(data[0]);
sub_81AE860(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
if (i != sSavedPokeblockData.lastItemPage || var != sSavedPokeblockData.lastItemPos)
{
for (i = 0; i < 9; i++)
@ -996,7 +996,7 @@ static void HandlePokeblocksSwap(u8 taskId, bool8 noSwap)
u16 swappedFromId = sSavedPokeblockData.lastItemPage + sSavedPokeblockData.lastItemPos;
sPokeblockMenu->isSwapping = FALSE;
sub_81AE6C8(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
DestroyListMenuTask(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
if (!noSwap && data[2] != swappedFromId && data[2] != swappedFromId - 1)
{
@ -1112,7 +1112,7 @@ static void HandleErasePokeblock(u8 taskId)
lastPos = &sSavedPokeblockData.lastItemPos;
data = gTasks[taskId].data;
sub_81AE6C8(data[0], lastPage, lastPos);
DestroyListMenuTask(data[0], lastPage, lastPos);
HandlePokeblockMenuCursor(*lastPos, 5);
SetMenuItemsCountAndMaxShowed();
sub_81362E0();

View File

@ -26,6 +26,7 @@
#include "international_string_util.h"
#include "scanline_effect.h"
#include "menu_helpers.h"
#include "daycare.h"
struct ContestMove
{
@ -3024,7 +3025,7 @@ void sub_81C31F0(u8 *a)
{
u8 level = gUnknown_0203CF1C->summary.metLevel;
if (level == 0)
level = 5;
level = EGG_HATCH_LEVEL;
ConvertIntToDecimalStringN(a, level, 0, 3);
UnkTextUtil_SetPtrI(3, a);
}

View File

@ -13,6 +13,7 @@
#include "constants/species.h"
#include "battle_interface.h"
#include "battle_anim.h"
#include "data2.h"
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
@ -25,14 +26,14 @@ extern u16 gBattle_BG3_Y;
extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];
extern void sub_806A068(u16 species, u8 bankIdentity);
extern void sub_806A12C(u16 backPicId, u8 bankIdentity);
extern void sub_806A068(u16 species, u8 battlerPosition);
extern void sub_806A12C(u16 backPicId, u8 battlerPosition);
// this file's functions
static void CB2_ReshowBattleScreenAfterMenu(void);
static bool8 LoadBattlerSpriteGfx(u8 bank);
static void CreateBattlerSprite(u8 bank);
static void CreateHealthboxSprite(u8 bank);
static bool8 LoadBattlerSpriteGfx(u8 battlerId);
static void CreateBattlerSprite(u8 battlerId);
static void CreateHealthboxSprite(u8 battlerId);
static void sub_80A95F4(void);
void nullsub_35(void)
@ -217,16 +218,6 @@ static bool8 LoadBattlerSpriteGfx(u8 battler)
return TRUE;
}
// 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 CreateBattlerSprite(u8 battler)
{
if (battler < gBattlersCount)

View File

@ -6,8 +6,8 @@
#include "main.h"
#include "task.h"
#include "palette.h"
#include "list_menu.h"
#include "window.h"
#include "list_menu.h"
#include "menu.h"
#include "menu_helpers.h"
#include "menu_indicators.h"
@ -66,7 +66,7 @@ EWRAM_DATA struct SecretBaseListMenuBuffer *gUnknown_0203A020 = NULL;
void sub_80E9C9C(u8 taskId);
void game_continue(u8 taskId);
void sub_80E9DEC(u32 a0, bool8 flag, struct ListMenu *menu);
void sub_80E9DEC(s32 a0, bool8 flag, struct ListMenu *menu);
void sub_80E9E00(u8 taskId);
void sub_80E9E44(u8 taskId);
void sub_80E9E90(u8 taskId);
@ -913,13 +913,13 @@ void game_continue(u8 taskId)
data[3] = 8;
}
gMultiuseListMenuTemplate = gUnknown_0858D07C;
gMultiuseListMenuTemplate.unk_10 = data[6];
gMultiuseListMenuTemplate.windowId = data[6];
gMultiuseListMenuTemplate.totalItems = data[0];
gMultiuseListMenuTemplate.items = gUnknown_0203A020->items;
gMultiuseListMenuTemplate.maxShowed = data[3];
}
void sub_80E9DEC(u32 a0, bool8 flag, struct ListMenu *menu)
void sub_80E9DEC(s32 a0, bool8 flag, struct ListMenu *menu)
{
if (flag != TRUE)
{
@ -953,14 +953,14 @@ void sub_80E9E90(u8 taskId)
data = gTasks[taskId].data;
input = ListMenuHandleInputGetItemId(data[5]);
sub_81AE860(data[5], &data[2], &data[1]);
ListMenuGetScrollAndRow(data[5], &data[2], &data[1]);
switch (input)
{
case -1:
break;
case -2:
PlaySE(SE_SELECT);
sub_81AE6C8(data[5], NULL, NULL);
DestroyListMenuTask(data[5], NULL, NULL);
RemoveScrollIndicatorArrowPair(data[8]);
sub_819746C(data[6], 0);
ClearWindowTilemap(data[6]);
@ -1042,7 +1042,7 @@ void sub_80EA08C(u8 taskId)
data = gTasks[taskId].data;
sub_8197434(0, 0);
sub_81AE6C8(data[5], &data[2], &data[1]);
DestroyListMenuTask(data[5], &data[2], &data[1]);
gSaveBlock1Ptr->secretBases[data[4]].sbr_field_1_6 = 0;
game_continue(taskId);
sub_812225C(&data[2], &data[1], data[3], data[0]);
@ -1061,7 +1061,7 @@ void sub_80EA13C(u8 taskId)
data = gTasks[taskId].data;
sub_8197434(0, 0);
sub_81AE6C8(data[5], &data[2], &data[1]);
DestroyListMenuTask(data[5], &data[2], &data[1]);
sub_80E9E00(taskId);
gTasks[taskId].func = sub_80E9E90;
}

View File

@ -178,11 +178,7 @@ gUnknown_030062F0: @ 30062F0
gUnknown_030062F4: @ 30062F4
.space 0xC
gUnknown_03006300: @ 3006300
.space 0x10
gMultiuseListMenuTemplate: @ 3006310
.space 0x18
.include "list_menu.o"
gUnknown_03006328: @ 3006328
.space 0x48