diff options
Diffstat (limited to 'include')
28 files changed, 375 insertions, 252 deletions
diff --git a/include/battle.h b/include/battle.h index 14ecfbdd3..9434b9aa8 100644 --- a/include/battle.h +++ b/include/battle.h @@ -17,6 +17,11 @@ #define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE) #define GET_BATTLER_SIDE2(battler) (GET_BATTLER_POSITION(battler) & BIT_SIDE) +// Used to exclude moves learned temporarily by Transform or Mimic +#define MOVE_IS_PERMANENT(battler, moveSlot) \ + (!(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) \ + && !(gDisableStructs[battler].mimickedMoves & gBitTable[moveSlot])) + // Battle Actions // These determine what each battler will do in a turn #define B_ACTION_USE_MOVE 0 @@ -32,34 +37,21 @@ #define B_ACTION_EXEC_SCRIPT 10 #define B_ACTION_TRY_FINISH 11 #define B_ACTION_FINISHED 12 - #define B_ACTION_CANCEL_PARTNER 12 // when choosing an action #define B_ACTION_NOTHING_FAINTED 13 // when choosing an action #define B_ACTION_NONE 0xFF -#define MAX_TRAINER_ITEMS 4 - -// array entries for battle communication -#define MULTIUSE_STATE 0 -#define CURSOR_POSITION 1 -#define TASK_ID 1 // task Id and cursor position share the same field -#define SPRITES_INIT_STATE1 1 // shares the Id as well -#define SPRITES_INIT_STATE2 2 -#define MOVE_EFFECT_BYTE 3 -#define ACTIONS_CONFIRMED_COUNT 4 -#define MULTISTRING_CHOOSER 5 -#define MISS_TYPE 6 -#define MSG_DISPLAY 7 -#define BATTLE_COMMUNICATION_ENTRIES_COUNT 8 - -#define MOVE_TARGET_SELECTED 0x0 -#define MOVE_TARGET_DEPENDS 0x1 -#define MOVE_TARGET_USER_OR_SELECTED 0x2 -#define MOVE_TARGET_RANDOM 0x4 -#define MOVE_TARGET_BOTH 0x8 -#define MOVE_TARGET_USER 0x10 -#define MOVE_TARGET_FOES_AND_ALLY 0x20 -#define MOVE_TARGET_OPPONENTS_FIELD 0x40 +#define MOVE_TARGET_SELECTED 0 +#define MOVE_TARGET_DEPENDS (1 << 0) +#define MOVE_TARGET_USER_OR_SELECTED (1 << 1) +#define MOVE_TARGET_RANDOM (1 << 2) +#define MOVE_TARGET_BOTH (1 << 3) +#define MOVE_TARGET_USER (1 << 4) +#define MOVE_TARGET_FOES_AND_ALLY (1 << 5) +#define MOVE_TARGET_OPPONENTS_FIELD (1 << 6) + +// For the second argument of GetMoveTarget, when no target override is needed +#define NO_TARGET_OVERRIDE 0 #define BATTLE_BUFFER_LINK_SIZE 0x1000 @@ -117,7 +109,7 @@ struct ProtectStruct u32 confusionSelfDmg:1; u32 targetNotAffected:1; u32 chargingTurn:1; - u32 fleeFlag:2; // For RunAway and Smoke Ball. + u32 fleeType:2; // 0: Normal, 1: FLEE_ITEM, 2: FLEE_ABILITY u32 usedImprisonedMove:1; u32 loveImmobility:1; u32 usedDisabledMove:1; @@ -140,7 +132,7 @@ struct SpecialStatus u32 intimidatedMon:1; u32 traced:1; u32 ppNotAffectedByPressure:1; - u32 flag40:1; + u32 faintedHasReplacement:1; u32 focusBanded:1; s32 dmg; s32 physicalDmg; @@ -379,9 +371,9 @@ struct BattleStruct u8 field_52; u8 sentInPokes; bool8 selectionScriptFinished[MAX_BATTLERS_COUNT]; - u8 field_58[4]; + u8 battlerPartyIndexes[MAX_BATTLERS_COUNT]; u8 monToSwitchIntoId[MAX_BATTLERS_COUNT]; - u8 field_60[4][3]; + u8 battlerPartyOrders[MAX_BATTLERS_COUNT][PARTY_SIZE / 2]; u8 runTries; u8 caughtMonNick[POKEMON_NAME_LENGTH + 1]; u8 unused_2; @@ -400,7 +392,7 @@ struct BattleStruct u8 stringMoveType; u8 expGetterBattlerId; u8 unused_5; - u8 field_91; // related to gAbsentBattlerFlags, possibly absent flags turn ago? + u8 absentBattlerFlags; u8 palaceFlags; // First 4 bits are "is < 50% HP and not asleep" for each battler, last 4 bits are selected moves to pass to AI u8 field_93; // related to choosing pokemon? u8 wallyBattleState; @@ -428,7 +420,7 @@ struct BattleStruct u8 unused_6[3]; u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party. u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2]; // a 3-D array [target][attacker][byte] - u16 castformPalette[MAX_BATTLERS_COUNT][16]; + u16 castformPalette[NUM_CASTFORM_FORMS][16]; union { struct LinkBattlerHeader linkBattlerHeader; u32 battleVideo[2]; @@ -449,12 +441,16 @@ struct BattleStruct u8 alreadyStatusedMoveAttempt; // As bits for battlers; For example when using Thunder Wave on an already paralyzed pokemon. }; -#define GET_MOVE_TYPE(move, typeArg) \ -{ \ - if (gBattleStruct->dynamicMoveType) \ - typeArg = gBattleStruct->dynamicMoveType & 0x3F; \ - else \ - typeArg = gBattleMoves[move].type; \ +#define F_DYNAMIC_TYPE_1 (1 << 6) +#define F_DYNAMIC_TYPE_2 (1 << 7) +#define DYNAMIC_TYPE_MASK (F_DYNAMIC_TYPE_1 - 1) + +#define GET_MOVE_TYPE(move, typeArg) \ +{ \ + if (gBattleStruct->dynamicMoveType) \ + typeArg = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; \ + else \ + typeArg = gBattleMoves[move].type; \ } #define IS_TYPE_PHYSICAL(moveType)(moveType < TYPE_MYSTERY) @@ -478,6 +474,8 @@ struct BattleStruct #define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + (stage << 4) + (goesDown << 7)) +// NOTE: The members of this struct have hard-coded offsets +// in include/constants/battle_script_commands.h struct BattleScripting { s32 painSplitHp; @@ -500,18 +498,15 @@ struct BattleScripting u8 battleStyle; u8 drawlvlupboxState; u8 learnMoveState; - u8 field_20; + u8 pursuitDoublesAttacker; u8 reshowMainState; u8 reshowHelperState; u8 levelUpHP; - u8 windowsType; // 0 - normal, 1 - battle arena + u8 windowsType; // B_WIN_TYPE_* u8 multiplayerId; u8 specialTrainerBattleType; }; -// rom_80A5C6C - - struct BattleSpriteInfo { u16 invisible:1; // 0x1 @@ -594,16 +589,15 @@ struct BattleSpriteData struct MonSpritesGfx { void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon - union - { - void* ptr[4]; - u8* byte[4]; + union { + void* ptr[MAX_BATTLERS_COUNT]; + u8* byte[MAX_BATTLERS_COUNT]; } sprites; - struct SpriteTemplate templates[4]; - struct SpriteFrameImage field_74[4][4]; - u8 field_F4[0x80]; + struct SpriteTemplate templates[MAX_BATTLERS_COUNT]; + struct SpriteFrameImage frameImages[MAX_BATTLERS_COUNT][4]; + u8 unusedArr[0x80]; u8 *barFontGfx; - void *field_178; + void *unusedPtr; u16 *buffer; }; @@ -627,8 +621,8 @@ extern u8 gBattleTextBuff3[TEXT_BUFF_ARRAY_COUNT]; extern u32 gBattleTypeFlags; extern u8 gBattleTerrain; extern u32 gUnusedFirstBattleVar1; -extern u8 *gUnknown_0202305C; -extern u8 *gUnknown_02023060; +extern u8 *gBattleAnimBgTileBuffer; +extern u8 *gBattleAnimBgTilemapBuffer; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gActiveBattler; diff --git a/include/battle_anim.h b/include/battle_anim.h index ad160e74d..3f73f1daf 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -64,12 +64,12 @@ s8 BattleAnimAdjustPanning(s8 pan); s8 BattleAnimAdjustPanning2(s8 pan); s16 KeepPanInRange(s16 a, int oldPan); s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); -void sub_80A4720(u16 a, u16 *b, u32 c, u8 d); +void RelocateBattleBgPal(u16 paletteNum, u16 *dest, u32 offset, bool8 largeScreen); void ResetBattleAnimBg(bool8); // battle_intro.c void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value); -void sub_8118FBC(int bgId, u8 arg1, u8 arg2, u8 battlerPosition, u8 arg4, u8 *arg5, u16 *arg6, u16 arg7); +void DrawBattlerOnBg(int bgId, u8 x, u8 y, u8 battlerPosition, u8 paletteId, u8 *tiles, u16 *tilemap, u16 tilesOffset); void HandleIntroSlide(u8 terrainId); int GetAnimBgAttribute(u8 bgId, u8 attributeId); @@ -107,7 +107,7 @@ void AnimTranslateLinear_WaitEnd(struct Sprite *sprite); u8 GetBattlerSpriteBGPriority(u8 battlerId); void *LoadPointerFromVars(s16 bottom, s16 top); void StorePointerInVars(s16 *bottom, s16 *top, const void *ptr); -void sub_80A8278(void); +void InitPrioritiesForVisibleBattlers(void); void GetBattleAnimBg1Data(struct BattleAnimBgData*); void GetBattleAnimBgData(struct BattleAnimBgData*, u32 arg1); u8 GetBattlerSpriteSubpriority(u8 battlerId); @@ -125,7 +125,7 @@ u8 AnimDummyReturnArg(u8 battler); s16 CloneBattlerSpriteWithBlend(u8); void obj_delete_but_dont_free_vram(struct Sprite*); u8 CreateInvisibleSpriteCopy(int, u8, int); -void AnimLoadCompressedBgTilemapHandleContest(struct BattleAnimBgData*, const void*, u32); +void AnimLoadCompressedBgTilemapHandleContest(struct BattleAnimBgData*, const void*, bool32); void AnimLoadCompressedBgGfx(u32, const u32*, u32); void UpdateAnimBg3ScreenSize(bool8); void TranslateSpriteInGrowingCircleOverDuration(struct Sprite *); diff --git a/include/battle_arena.h b/include/battle_arena.h index b55fc39b0..c9a18ef61 100644 --- a/include/battle_arena.h +++ b/include/battle_arena.h @@ -7,7 +7,6 @@ void BattleArena_InitPoints(void); void BattleArena_AddMindPoints(u8 battler); void BattleArena_AddSkillPoints(u8 battler); void BattleArena_DeductMindPoints(u8 battler, u16 stringId); -void sub_81A586C(u8 battler); void DrawArenaRefereeTextBox(void); void EraseArenaRefereeTextBox(void); diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 34e916b0f..9d9fba1b4 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -1,8 +1,7 @@ #ifndef GUARD_BATTLE_CONTROLLERS_H #define GUARD_BATTLE_CONTROLLERS_H -enum -{ +enum { REQUEST_ALL_BATTLE, REQUEST_SPECIES_BATTLE, REQUEST_HELDITEM_BATTLE, @@ -67,19 +66,36 @@ enum // Special arguments for Battle Controller functions. -#define RESET_ACTION_MOVE_SELECTION 0 -#define RESET_ACTION_SELECTION 1 -#define RESET_MOVE_SELECTION 2 +enum { // Values given to the emit functions to choose gBattleBufferA or gBattleBufferB + BUFFER_A, + BUFFER_B +}; -#define BALL_NO_SHAKES 0 -#define BALL_1_SHAKE 1 -#define BALL_2_SHAKES 2 -#define BALL_3_SHAKES_FAIL 3 -#define BALL_3_SHAKES_SUCCESS 4 -#define BALL_TRAINER_BLOCK 5 +enum { + RESET_ACTION_MOVE_SELECTION, + RESET_ACTION_SELECTION, + RESET_MOVE_SELECTION, +}; + +enum { + BALL_NO_SHAKES, + BALL_1_SHAKE, + BALL_2_SHAKES, + BALL_3_SHAKES_FAIL, + BALL_3_SHAKES_SUCCESS, + BALL_TRAINER_BLOCK, +}; + +enum { + LINK_STANDBY_MSG_STOP_BOUNCE, + LINK_STANDBY_STOP_BOUNCE_ONLY, + LINK_STANDBY_MSG_ONLY, +}; #define INSTANT_HP_BAR_DROP 32767 +#define PARTY_SUMM_SKIP_DRAW_DELAY (1 << 7) + // Special return values in gBattleBufferB from Battle Controller functions. #define RET_VALUE_LEVELED_UP 11 @@ -191,7 +207,7 @@ void BtlController_EmitSetMonData(u8 bufferId, u8 requestId, u8 monToCheck, u8 b void BtlController_EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data); // unused void BtlController_EmitLoadMonSprite(u8 bufferId); void BtlController_EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); -void BtlController_EmitReturnMonToBall(u8 bufferId, u8 arg1); +void BtlController_EmitReturnMonToBall(u8 bufferId, bool8 skipAnim); void BtlController_EmitDrawTrainerPic(u8 bufferId); void BtlController_EmitTrainerSlide(u8 bufferId); void BtlController_EmitTrainerSlideBack(u8 bufferId); @@ -203,11 +219,11 @@ void BtlController_EmitPause(u8 bufferId, u8 toWait, void *data); // unused void BtlController_EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit); void BtlController_EmitPrintString(u8 bufferId, u16 stringId); void BtlController_EmitPrintSelectionString(u8 bufferId, u16 stringId); -void BtlController_EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2); +void BtlController_EmitChooseAction(u8 bufferId, u8 action, u16 itemId); void BtlController_EmitYesNoBox(u8 bufferId); void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData); void BtlController_EmitChooseItem(u8 bufferId, u8* arg1); -void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4); +void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 slotId, u8 abilityId, u8* data); void BtlController_EmitCmd23(u8 bufferId); // unused void BtlController_EmitHealthBarUpdate(u8 bufferId, u16 hpValue); void BtlController_EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints); @@ -216,7 +232,7 @@ void BtlController_EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status); void BtlController_EmitStatusXor(u8 bufferId, u8 b); // unused void BtlController_EmitDataTransfer(u8 bufferId, u16 size, void *data); void BtlController_EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data); // unused -void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbDataParameter); // unused +void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *data); // unused void BtlController_EmitCmd32(u8 bufferId, u16 size, void *c); // unused void BtlController_EmitTwoReturnValues(u8 bufferId, u8 arg1, u16 arg2); void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 b, u8 *c); @@ -233,7 +249,7 @@ void BtlController_EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM); void BtlController_EmitFaintingCry(u8 bufferId); void BtlController_EmitIntroSlide(u8 bufferId, u8 terrainId); void BtlController_EmitIntroTrainerBallThrow(u8 bufferId); -void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2); +void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 flags); void BtlController_EmitHidePartyStatusSummary(u8 bufferId); void BtlController_EmitEndBounceEffect(u8 bufferId); void BtlController_EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); diff --git a/include/battle_gfx_sfx_util.h b/include/battle_gfx_sfx_util.h index a367bc043..383facd69 100644 --- a/include/battle_gfx_sfx_util.h +++ b/include/battle_gfx_sfx_util.h @@ -18,7 +18,6 @@ void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId); void DecompressTrainerBackPic(u16 backPicId, u8 battlerId); void BattleGfxSfxDummy3(u8 gender); void FreeTrainerFrontPicPalette(u16 frontPicId); -void sub_805DFFC(void); bool8 BattleLoadAllHealthBoxesGfx(u8 state); void LoadBattleBarGfx(u8 arg0); bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId); diff --git a/include/battle_main.h b/include/battle_main.h index 78cf353df..f3e961b7b 100644 --- a/include/battle_main.h +++ b/include/battle_main.h @@ -7,7 +7,8 @@ struct TrainerMoney u8 value; }; -struct UnknownPokemonStruct4 +// For displaying a multi battle partner's Pokémon in the party menu +struct MultiPartnerMenuPokemon { /*0x00*/ u16 species; /*0x02*/ u16 heldItem; @@ -46,8 +47,6 @@ struct UnknownPokemonStruct4 void CB2_InitBattle(void); void BattleMainCB2(void); void CB2_QuitRecordedBattle(void); -void sub_8038528(struct Sprite* sprite); -void sub_8038A04(void); // unused void VBlankCB_Battle(void); void SpriteCB_VsLetterDummy(struct Sprite *sprite); void SpriteCB_VsLetterInit(struct Sprite *sprite); @@ -59,13 +58,12 @@ void SpriteCallbackDummy_2(struct Sprite *sprite); void SpriteCB_FaintOpponentMon(struct Sprite *sprite); void SpriteCb_ShowAsMoveTarget(struct Sprite *sprite); void SpriteCb_HideAsMoveTarget(struct Sprite *sprite); -void SpriteCb_OpponentMonFromBall(struct Sprite *sprite); +void SpriteCB_OpponentMonFromBall(struct Sprite *sprite); void SpriteCB_BattleSpriteStartSlideLeft(struct Sprite *sprite); void SpriteCB_FaintSlideAnim(struct Sprite *sprite); void DoBounceEffect(u8 battlerId, u8 b, s8 c, s8 d); void EndBounceEffect(u8 battlerId, bool8 b); -void SpriteCb_PlayerMonFromBall(struct Sprite *sprite); -void sub_8039E60(struct Sprite *sprite); +void SpriteCB_PlayerMonFromBall(struct Sprite *sprite); void SpriteCB_TrainerThrowObject(struct Sprite *sprite); void sub_8039E9C(struct Sprite *sprite); void BeginBattleIntroDummy(void); @@ -82,9 +80,9 @@ void RunBattleScriptCommands(void); bool8 TryRunFromBattle(u8 battlerId); void SpecialStatusesClear(void); -extern struct UnknownPokemonStruct4 gMultiPartnerParty[MULTI_PARTY_SIZE]; +extern struct MultiPartnerMenuPokemon gMultiPartnerParty[MULTI_PARTY_SIZE]; -extern const struct SpriteTemplate gUnknown_0831AC88; +extern const struct SpriteTemplate gUnusedBattleInitSprite; extern const struct OamData gOamData_BattleSpriteOpponentSide; extern const struct OamData gOamData_BattleSpritePlayerSide; extern const u8 gTypeEffectiveness[336]; diff --git a/include/battle_pyramid_bag.h b/include/battle_pyramid_bag.h index b8b3eb20f..258ca56b2 100644 --- a/include/battle_pyramid_bag.h +++ b/include/battle_pyramid_bag.h @@ -63,7 +63,6 @@ void CB2_PyramidBagMenuFromStartMenu(void); void CB2_ReturnToPyramidBagMenu(void); void UpdatePyramidBagList(void); void UpdatePyramidBagCursorPos(void); -void sub_81C4EFC(void); void GoToBattlePyramidBagMenu(u8 location, void (*exitCallback)(void)); void Task_CloseBattlePyramidBagMessage(u8 taskId); void TryStoreHeldItemsInPyramidBag(void); diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index ee3676463..cb81ad812 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -2,9 +2,11 @@ #define GUARD_BATTLE_SCRIPT_COMMANDS_H #include "constants/pokemon.h" +#include "constants/battle_script_commands.h" -#define WINDOW_CLEAR 0x1 -#define WINDOW_x80 0x80 +// Arguments for 'flags' in HandleBattleWindow +#define WINDOW_CLEAR (1 << 0) +#define WINDOW_BG1 (1 << 7) void AI_CalcDmg(u8 battlerIdAtk, u8 battlerIdDef); u8 TypeCalc(u16 move, u8 battlerIdAtk, u8 battlerIdDef); diff --git a/include/battle_transition.h b/include/battle_transition.h index a33032fb4..784c5f968 100644 --- a/include/battle_transition.h +++ b/include/battle_transition.h @@ -11,8 +11,7 @@ void GetBg0TilesDst(u16 **tilemap, u16 **tileset); extern const struct SpritePalette gSpritePalette_Pokeball; -enum // TRANSITION_MUGSHOT -{ +enum { MUGSHOT_SIDNEY, MUGSHOT_PHOEBE, MUGSHOT_GLACIA, @@ -21,52 +20,64 @@ enum // TRANSITION_MUGSHOT MUGSHOTS_COUNT }; -// credits for the names go to Dyskinesia, Tetrable and Farore -// names are naturally subject to change +enum { + B_TRANSITION_BLUR, + B_TRANSITION_SWIRL, + B_TRANSITION_SHUFFLE, + B_TRANSITION_BIG_POKEBALL, + B_TRANSITION_POKEBALLS_TRAIL, + B_TRANSITION_CLOCKWISE_BLACKFADE, + B_TRANSITION_RIPPLE, + B_TRANSITION_WAVE, + B_TRANSITION_SLICE, + B_TRANSITION_WHITEFADE, + B_TRANSITION_GRID_SQUARES, + B_TRANSITION_SHARDS, + B_TRANSITION_SIDNEY, + B_TRANSITION_PHOEBE, + B_TRANSITION_GLACIA, + B_TRANSITION_DRAKE, + B_TRANSITION_CHAMPION, + B_TRANSITION_AQUA, // Here below added in Emerald + B_TRANSITION_MAGMA, + B_TRANSITION_REGICE, + B_TRANSITION_REGISTEEL, + B_TRANSITION_REGIROCK, + B_TRANSITION_KYOGRE, + B_TRANSITION_GROUDON, + B_TRANSITION_RAYQUAZA, + B_TRANSITION_SHRED_SPLIT, + B_TRANSITION_BLACKHOLE1, + B_TRANSITION_BLACKHOLE2, + B_TRANSITION_RECTANGULAR_SPIRAL, + B_TRANSITION_FRONTIER_LOGO_WIGGLE, + B_TRANSITION_FRONTIER_LOGO_WAVE, + B_TRANSITION_FRONTIER_SQUARES, + B_TRANSITION_FRONTIER_SQUARES_SCROLL, + B_TRANSITION_FRONTIER_SQUARES_SPIRAL, + B_TRANSITION_FRONTIER_CIRCLES_MEET, + B_TRANSITION_FRONTIER_CIRCLES_CROSS, + B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL, + B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL, + B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ, + B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ, + B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ, + B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ, + B_TRANSITION_COUNT +}; -#define B_TRANSITION_BLUR 0 -#define B_TRANSITION_SWIRL 1 -#define B_TRANSITION_SHUFFLE 2 -#define B_TRANSITION_BIG_POKEBALL 3 -#define B_TRANSITION_POKEBALLS_TRAIL 4 -#define B_TRANSITION_CLOCKWISE_BLACKFADE 5 -#define B_TRANSITION_RIPPLE 6 -#define B_TRANSITION_WAVE 7 -#define B_TRANSITION_SLICE 8 -#define B_TRANSITION_WHITEFADE 9 -#define B_TRANSITION_GRID_SQUARES 10 -#define B_TRANSITION_SHARDS 11 -#define B_TRANSITION_SIDNEY 12 -#define B_TRANSITION_PHOEBE 13 -#define B_TRANSITION_GLACIA 14 -#define B_TRANSITION_DRAKE 15 -#define B_TRANSITION_CHAMPION 16 -// added in Emerald -#define B_TRANSITION_AQUA 17 -#define B_TRANSITION_MAGMA 18 -#define B_TRANSITION_REGICE 19 -#define B_TRANSITION_REGISTEEL 20 -#define B_TRANSITION_REGIROCK 21 -#define B_TRANSITION_KYOGRE 22 -#define B_TRANSITION_GROUDON 23 -#define B_TRANSITION_RAYQUAZA 24 -#define B_TRANSITION_SHRED_SPLIT 25 -#define B_TRANSITION_BLACKHOLE1 26 -#define B_TRANSITION_BLACKHOLE2 27 -#define B_TRANSITION_RECTANGULAR_SPIRAL 28 -#define B_TRANSITION_FRONTIER_LOGO_WIGGLE 29 -#define B_TRANSITION_FRONTIER_LOGO_WAVE 30 -#define B_TRANSITION_FRONTIER_SQUARES 31 -#define B_TRANSITION_FRONTIER_SQUARES_SCROLL 32 -#define B_TRANSITION_FRONTIER_SQUARES_SPIRAL 33 -#define B_TRANSITION_FRONTIER_CIRCLES_MEET 34 -#define B_TRANSITION_FRONTIER_CIRCLES_CROSS 35 -#define B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL 36 -#define B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL 37 -#define B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ 38 -#define B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ 39 -#define B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ 40 -#define B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ 41 -#define B_TRANSITION_COUNT 42 +// IDs for GetSpecialBattleTransition +enum { + B_TRANSITION_GROUP_B_TOWER, + B_TRANSITION_GROUP_B_DOME = 3, + B_TRANSITION_GROUP_B_PALACE, + B_TRANSITION_GROUP_B_ARENA, + B_TRANSITION_GROUP_B_FACTORY, + B_TRANSITION_GROUP_B_PIKE, + B_TRANSITION_GROUP_B_PYRAMID = 10, + B_TRANSITION_GROUP_TRAINER_HILL, + B_TRANSITION_GROUP_SECRET_BASE, + B_TRANSITION_GROUP_E_READER, +}; #endif // GUARD_BATTLE_TRANSITION_H diff --git a/include/battle_util.h b/include/battle_util.h index e4ef99e0b..914e44c04 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -6,37 +6,43 @@ #define MOVE_LIMITATION_DISABLED (1 << 2) #define MOVE_LIMITATION_TORMENTED (1 << 3) #define MOVE_LIMITATION_TAUNT (1 << 4) -#define MOVE_LIMITATION_IMPRISON (1 << 5) +#define MOVE_LIMITATION_IMPRISON (1 << 5) +#define MOVE_LIMITATIONS_ALL 0xFF -#define ABILITYEFFECT_ON_SWITCHIN 0x0 -#define ABILITYEFFECT_ENDTURN 0x1 -#define ABILITYEFFECT_MOVES_BLOCK 0x2 -#define ABILITYEFFECT_ABSORBING 0x3 -#define ABILITYEFFECT_ON_DAMAGE 0x4 -#define ABILITYEFFECT_IMMUNITY 0x5 -#define ABILITYEFFECT_FORECAST 0x6 -#define ABILITYEFFECT_SYNCHRONIZE 0x7 -#define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8 -#define ABILITYEFFECT_INTIMIDATE1 0x9 -#define ABILITYEFFECT_INTIMIDATE2 0xA -#define ABILITYEFFECT_TRACE 0xB -#define ABILITYEFFECT_CHECK_OTHER_SIDE 0xC -#define ABILITYEFFECT_CHECK_BATTLER_SIDE 0xD -#define ABILITYEFFECT_FIELD_SPORT 0xE -#define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BATTLER 0xF -#define ABILITYEFFECT_COUNT_OTHER_SIDE 0x10 -#define ABILITYEFFECT_COUNT_BATTLER_SIDE 0x11 -#define ABILITYEFFECT_COUNT_ON_FIELD 0x12 -#define ABILITYEFFECT_CHECK_ON_FIELD 0x13 -#define ABILITYEFFECT_SWITCH_IN_WEATHER 0xFF +#define ABILITYEFFECT_ON_SWITCHIN 0 +#define ABILITYEFFECT_ENDTURN 1 +#define ABILITYEFFECT_MOVES_BLOCK 2 +#define ABILITYEFFECT_ABSORBING 3 +#define ABILITYEFFECT_ON_DAMAGE 4 +#define ABILITYEFFECT_IMMUNITY 5 +#define ABILITYEFFECT_FORECAST 6 +#define ABILITYEFFECT_SYNCHRONIZE 7 +#define ABILITYEFFECT_ATK_SYNCHRONIZE 8 +#define ABILITYEFFECT_INTIMIDATE1 9 +#define ABILITYEFFECT_INTIMIDATE2 10 +#define ABILITYEFFECT_TRACE 11 +#define ABILITYEFFECT_CHECK_OTHER_SIDE 12 +#define ABILITYEFFECT_CHECK_BATTLER_SIDE 13 +#define ABILITYEFFECT_FIELD_SPORT 14 +#define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BATTLER 15 +#define ABILITYEFFECT_COUNT_OTHER_SIDE 16 +#define ABILITYEFFECT_COUNT_BATTLER_SIDE 17 +#define ABILITYEFFECT_COUNT_ON_FIELD 18 +#define ABILITYEFFECT_CHECK_ON_FIELD 19 +#define ABILITYEFFECT_MUD_SPORT 253 +#define ABILITYEFFECT_WATER_SPORT 254 +#define ABILITYEFFECT_SWITCH_IN_WEATHER 255 #define ABILITY_ON_OPPOSING_FIELD(battlerId, abilityId)(AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, battlerId, abilityId, 0, 0)) #define ABILITY_ON_FIELD(abilityId)(AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, abilityId, 0, 0)) #define ABILITY_ON_FIELD2(abilityId)(AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, abilityId, 0, 0)) -#define ITEMEFFECT_ON_SWITCH_IN 0x0 -#define ITEMEFFECT_MOVE_END 0x3 -#define ITEMEFFECT_KINGSROCK_SHELLBELL 0x4 +// For the first argument of ItemBattleEffects, to deteremine which block of item effects to try +#define ITEMEFFECT_ON_SWITCH_IN 0 +#define ITEMEFFECT_NORMAL 1 +#define ITEMEFFECT_DUMMY 2 // Unused, empty +#define ITEMEFFECT_MOVE_END 3 +#define ITEMEFFECT_KINGSROCK_SHELLBELL 4 #define WEATHER_HAS_EFFECT ((!ABILITY_ON_FIELD(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD(ABILITY_AIR_LOCK))) #define WEATHER_HAS_EFFECT2 ((!ABILITY_ON_FIELD2(ABILITY_CLOUD_NINE) && !ABILITY_ON_FIELD2(ABILITY_AIR_LOCK))) diff --git a/include/constants/battle.h b/include/constants/battle.h index f1ce757e7..2534ade4b 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -306,4 +306,56 @@ #define B_WAIT_TIME_MED 48 #define B_WAIT_TIME_SHORT 32 +#define CASTFORM_NORMAL 0 +#define CASTFORM_FIRE 1 +#define CASTFORM_WATER 2 +#define CASTFORM_ICE 3 +#define NUM_CASTFORM_FORMS 4 +#define CASTFORM_SUBSTITUTE (1 << 7) + +#define FLEE_ITEM 1 +#define FLEE_ABILITY 2 + +#define B_WIN_TYPE_NORMAL 0 +#define B_WIN_TYPE_ARENA 1 + +// Window Ids for gStandardBattleWindowTemplates / gBattleArenaWindowTemplates +#define B_WIN_MSG 0 +#define B_WIN_ACTION_PROMPT 1 // "What will {x} do?" +#define B_WIN_ACTION_MENU 2 // "Fight/Pokémon/Bag/Run" menu +#define B_WIN_MOVE_NAME_1 3 // Top left +#define B_WIN_MOVE_NAME_2 4 // Top right +#define B_WIN_MOVE_NAME_3 5 // Bottom left +#define B_WIN_MOVE_NAME_4 6 // Bottom right +#define B_WIN_PP 7 +#define B_WIN_DUMMY 8 +#define B_WIN_PP_REMAINING 9 +#define B_WIN_MOVE_TYPE 10 +#define B_WIN_SWITCH_PROMPT 11 // "Switch which?" +#define B_WIN_YESNO 12 +#define B_WIN_LEVEL_UP_BOX 13 +#define B_WIN_LEVEL_UP_BANNER 14 +#define B_WIN_VS_PLAYER 15 +#define B_WIN_VS_OPPONENT 16 +#define B_WIN_VS_MULTI_PLAYER_1 17 +#define B_WIN_VS_MULTI_PLAYER_2 18 +#define B_WIN_VS_MULTI_PLAYER_3 19 +#define B_WIN_VS_MULTI_PLAYER_4 20 +#define B_WIN_VS_OUTCOME_DRAW 21 +#define B_WIN_VS_OUTCOME_LEFT 22 +#define B_WIN_VS_OUTCOME_RIGHT 23 + +// The following are duplicate id values for windows that Battle Arena uses differently. +#define ARENA_WIN_PLAYER_NAME 15 +#define ARENA_WIN_VS 16 +#define ARENA_WIN_OPPONENT_NAME 17 +#define ARENA_WIN_MIND 18 +#define ARENA_WIN_SKILL 19 +#define ARENA_WIN_BODY 20 +#define ARENA_WIN_JUDGEMENT_TITLE 21 +#define ARENA_WIN_JUDGEMENT_TEXT 22 + +// Flag for BattlePutTextOnWindow. Never set +#define B_WIN_COPYTOVRAM (1 << 7) + #endif // GUARD_CONSTANTS_BATTLE_H diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index 4622876cc..48de594e2 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -318,7 +318,7 @@ #define SOUND_PAN_TARGET 63 // move background ids -#define BG_DARK_ 0 // the same as BG_DARK but is unused +#define BG_NONE 0 // the same as BG_DARK but is unused #define BG_DARK 1 #define BG_GHOST 2 #define BG_PSYCHIC 3 @@ -395,6 +395,9 @@ // Tasks with return values often assign them to gBattleAnimArgs[7]. #define ARG_RET_ID 7 +// For createsprite macro to use internally +#define ANIMSPRITE_IS_TARGET (1 << 7) + // Trapping Wrap-like moves end turn animation. #define TRAP_ANIM_BIND 0 #define TRAP_ANIM_WRAP 0 diff --git a/include/constants/battle_pyramid.h b/include/constants/battle_pyramid.h index 1be3c1115..ebb753882 100644 --- a/include/constants/battle_pyramid.h +++ b/include/constants/battle_pyramid.h @@ -4,9 +4,6 @@ #define TOTAL_ROUNDS 20 #define PICKUP_ITEMS_PER_ROUND 10 -#define FLOOR_WALKABLE_METATILE 0x28D -#define FLOOR_EXIT_METATILE 0x28E - #define HINT_EXIT_DIRECTION 0 #define HINT_REMAINING_ITEMS 1 #define HINT_REMAINING_TRAINERS 2 diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index d5e3eb7bb..83aacf316 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -1,38 +1,51 @@ #ifndef GUARD_CONSTANTS_BATTLE_SCRIPT_COMMANDS_H #define GUARD_CONSTANTS_BATTLE_SCRIPT_COMMANDS_H -// Battle Scripting and BattleCommunication addresses -#define sPAINSPLIT_HP gBattleScripting -#define sBIDE_DMG gBattleScripting + 4 -#define sMULTIHIT_STRING gBattleScripting + 8 -#define sDMG_MULTIPLIER gBattleScripting + 0xE -#define sTWOTURN_STRINGID gBattleScripting + 0xF -#define sB_ANIM_ARG1 gBattleScripting + 0x10 -#define sB_ANIM_ARG2 gBattleScripting + 0x11 -#define sTRIPLE_KICK_POWER gBattleScripting + 0x12 -#define sMOVEEND_STATE gBattleScripting + 0x14 -#define sBATTLER_WITH_ABILITY gBattleScripting + 0x15 -#define sMULTIHIT_EFFECT gBattleScripting + 0x16 -#define sBATTLER gBattleScripting + 0x17 -#define sB_ANIM_TURN gBattleScripting + 0x18 -#define sB_ANIM_TARGETS_HIT gBattleScripting + 0x19 -#define sSTATCHANGER gBattleScripting + 0x1A -#define sSTAT_ANIM_PLAYED gBattleScripting + 0x1B -#define sGIVEEXP_STATE gBattleScripting + 0x1C -#define sBATTLE_STYLE gBattleScripting + 0x1D -#define sLVLBOX_STATE gBattleScripting + 0x1E -#define sLEARNMOVE_STATE gBattleScripting + 0x1F -#define sFIELD_20 gBattleScripting + 0x20 -#define sRESHOW_MAIN_STATE gBattleScripting + 0x21 -#define sRESHOW_HELPER_STATE gBattleScripting + 0x22 -#define sFIELD_23 gBattleScripting + 0x23 -#define sWINDOWS_TYPE gBattleScripting + 0x24 -#define sMULTIPLAYER_ID gBattleScripting + 0x25 -#define sSPECIAL_TRAINER_BATTLE_TYPE gBattleScripting + 0x26 +// The following correspond to the struct members of BattleScripting by adding their offset +#define sPAINSPLIT_HP (gBattleScripting + 0x00) // painSplitHp +#define sBIDE_DMG (gBattleScripting + 0x04) // bideDmg +#define sMULTIHIT_STRING (gBattleScripting + 0x08) // multihitString +#define sDMG_MULTIPLIER (gBattleScripting + 0x0E) // dmgMultiplier +#define sTWOTURN_STRINGID (gBattleScripting + 0x0F) // twoTurnsMoveStringId +#define sB_ANIM_ARG1 (gBattleScripting + 0x10) // animArg1 +#define sB_ANIM_ARG2 (gBattleScripting + 0x11) // animArg2 +#define sTRIPLE_KICK_POWER (gBattleScripting + 0x12) // tripleKickPower +#define sMOVEEND_STATE (gBattleScripting + 0x14) // moveendState +#define sBATTLER_WITH_ABILITY (gBattleScripting + 0x15) // battlerWithAbility +#define sMULTIHIT_EFFECT (gBattleScripting + 0x16) // multihitMoveEffect +#define sBATTLER (gBattleScripting + 0x17) // battler +#define sB_ANIM_TURN (gBattleScripting + 0x18) // animTurn +#define sB_ANIM_TARGETS_HIT (gBattleScripting + 0x19) // animTargetsHit +#define sSTATCHANGER (gBattleScripting + 0x1A) // statChanger +#define sSTAT_ANIM_PLAYED (gBattleScripting + 0x1B) // statAnimPlayed +#define sGIVEEXP_STATE (gBattleScripting + 0x1C) // getexpState +#define sBATTLE_STYLE (gBattleScripting + 0x1D) // battleStyle +#define sLVLBOX_STATE (gBattleScripting + 0x1E) // drawlvlupboxState +#define sLEARNMOVE_STATE (gBattleScripting + 0x1F) // learnMoveState +#define sPURSUIT_DOUBLES_ATTACKER (gBattleScripting + 0x20) // pursuitDoublesAttacker +#define sRESHOW_MAIN_STATE (gBattleScripting + 0x21) // reshowMainState +#define sRESHOW_HELPER_STATE (gBattleScripting + 0x22) // reshowHelperState +#define sLVLUP_HP (gBattleScripting + 0x23) // levelUpHP +#define sWINDOWS_TYPE (gBattleScripting + 0x24) // windowsType +#define sMULTIPLAYER_ID (gBattleScripting + 0x25) // multiplayerId +#define sSPECIAL_TRAINER_BATTLE_TYPE (gBattleScripting + 0x26) // specialTrainerBattleType -#define cEFFECT_CHOOSER gBattleCommunication + 3 -#define cMULTISTRING_CHOOSER gBattleCommunication + 5 -#define cMISS_TYPE gBattleCommunication + 6 +// Array entries for battle communication +#define MULTIUSE_STATE 0 +#define CURSOR_POSITION 1 +#define TASK_ID 1 // task Id and cursor position share the same field +#define SPRITES_INIT_STATE1 1 // shares the Id as well +#define SPRITES_INIT_STATE2 2 +#define MOVE_EFFECT_BYTE 3 +#define ACTIONS_CONFIRMED_COUNT 4 +#define MULTISTRING_CHOOSER 5 +#define MISS_TYPE 6 +#define MSG_DISPLAY 7 +#define BATTLE_COMMUNICATION_ENTRIES_COUNT 8 + +#define cEFFECT_CHOOSER (gBattleCommunication + MOVE_EFFECT_BYTE) +#define cMULTISTRING_CHOOSER (gBattleCommunication + MULTISTRING_CHOOSER) +#define cMISS_TYPE (gBattleCommunication + MISS_TYPE) // Battle Script defines for getting the wanted battler #define BS_TARGET 0 @@ -40,8 +53,8 @@ #define BS_EFFECT_BATTLER 2 #define BS_FAINTED 3 #define BS_ATTACKER_WITH_PARTNER 4 // for Cmd_updatestatusicon -#define BS_UNK_5 5 -#define BS_UNK_6 6 +#define BS_FAINTED_LINK_MULTIPLE_1 5 +#define BS_FAINTED_LINK_MULTIPLE_2 6 #define BS_BATTLER_0 7 #define BS_ATTACKER_SIDE 8 // for Cmd_jumpifability #define BS_NOT_ATTACKER_SIDE 9 // for Cmd_jumpifability diff --git a/include/constants/map_scripts.h b/include/constants/map_scripts.h index 7a56cc908..c89df3948 100644 --- a/include/constants/map_scripts.h +++ b/include/constants/map_scripts.h @@ -13,14 +13,14 @@ Almost exclusively used to set metatiles on the map before it's first drawn 6. ON_FRAME_TABLE: Run every frame after the map has faded in, before player input is processed. - This is a table of scripts that each run if their condition is satisfied. + This is a table of scripts; only the first script whose condition is satisfied is run. Used to trigger an event, such as the player exiting the cable car or the SS Tidal sailor announcing progress 2. ON_TRANSITION: Run during the transition to the map Used to set map-specific flags/vars, update object positions/movement types, set weather, etc 5. ON_WARP_INTO_MAP_TABLE: Run after the map's objects are loaded. - This is a table of scripts that each run if their condition is satisfied. + This is a table of scripts; only the first script whose condition is satisfied is run. Used to add objects to the scene or update something about the player as they warp in (e.g. their facing dir or visibility) Note that ON_TRANSITION may also handle object visibility, but would do so by modifying a flag or var diff --git a/include/constants/metatile_labels.h b/include/constants/metatile_labels.h index 6159bf6cb..b4ee3eacf 100644 --- a/include/constants/metatile_labels.h +++ b/include/constants/metatile_labels.h @@ -788,4 +788,8 @@ #define METATILE_SecretBase_SpikesMat_BottomMid 0x32A #define METATILE_SecretBase_SpikesMat_BottomRight 0x32B +// gTileset_BattlePyramid +#define METATILE_BattlePyramid_Floor 0x28D +#define METATILE_BattlePyramid_Exit 0x28E + #endif // GUARD_METATILE_LABELS_H diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 9bafa0a0b..827725fc2 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -339,4 +339,10 @@ #define MON_PIC_SIZE (64 * 64 / 2) +#define BATTLE_ALIVE_EXCEPT_ACTIVE 0 +#define BATTLE_ALIVE_ATK_SIDE 1 +#define BATTLE_ALIVE_DEF_SIDE 2 + +#define SKIP_FRONT_ANIM (1 << 7) + #endif // GUARD_CONSTANTS_POKEMON_H diff --git a/include/constants/trainers.h b/include/constants/trainers.h index 3f22c7cef..31bad25df 100644 --- a/include/constants/trainers.h +++ b/include/constants/trainers.h @@ -110,6 +110,7 @@ #define TRAINER_PIC_RS_BRENDAN 91 #define TRAINER_PIC_RS_MAY 92 +// The player back pics are assumed to alternate according to the gender values (MALE/FEMALE) #define TRAINER_BACK_PIC_BRENDAN 0 #define TRAINER_BACK_PIC_MAY 1 #define TRAINER_BACK_PIC_RED 2 @@ -334,7 +335,7 @@ #define TRAINER_CLASS_SAILOR 0x2f #define TRAINER_CLASS_COOLTRAINER_2 0x30 // Used for only one trainer. #define TRAINER_CLASS_MAGMA_ADMIN 0x31 -#define TRAINER_CLASS_PKMN_TRAINER_3 0x32 +#define TRAINER_CLASS_RIVAL 0x32 #define TRAINER_CLASS_BUG_CATCHER 0x33 #define TRAINER_CLASS_PKMN_RANGER 0x34 #define TRAINER_CLASS_MAGMA_LEADER 0x35 diff --git a/include/contest.h b/include/contest.h index 9bac63eda..e7acb5a11 100644 --- a/include/contest.h +++ b/include/contest.h @@ -294,7 +294,7 @@ struct ContestResources u8 * contestBgTilemaps[CONTESTANT_COUNT]; void * boxBlinkTiles1; void * boxBlinkTiles2; - void * field_3c; + void * animBgTileBuffer; }; #define eContest (*gContestResources->contest) diff --git a/include/data.h b/include/data.h index f94f55a8f..374435cba 100644 --- a/include/data.h +++ b/include/data.h @@ -5,6 +5,8 @@ #define SPECIES_SHINY_TAG 500 +#define MAX_TRAINER_ITEMS 4 + enum { BATTLER_AFFINE_NORMAL, BATTLER_AFFINE_EMERGE, @@ -66,7 +68,7 @@ struct Trainer /*0x02*/ u8 encounterMusic_gender; // last bit is gender /*0x03*/ u8 trainerPic; /*0x04*/ u8 trainerName[12]; - /*0x10*/ u16 items[4]; + /*0x10*/ u16 items[MAX_TRAINER_ITEMS]; /*0x18*/ bool8 doubleBattle; /*0x1C*/ u32 aiFlags; /*0x20*/ u8 partySize; diff --git a/include/fieldmap.h b/include/fieldmap.h index 5bcbe20ea..28da8da2a 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -9,6 +9,14 @@ #define NUM_PALS_TOTAL 13 #define MAX_MAP_DATA_SIZE 0x2800 +// Map coordinates are offset by 7 when using the map +// buffer because it needs to load sufficient border +// metatiles to fill the player's view (the player has +// 7 metatiles of view horizontally in either direction). +#define MAP_OFFSET 7 +#define MAP_OFFSET_W (MAP_OFFSET * 2 + 1) +#define MAP_OFFSET_H (MAP_OFFSET * 2) + #include "main.h" extern struct BackupMapLayout gBackupMapLayout; diff --git a/include/gba/m4a_internal.h b/include/gba/m4a_internal.h index 2ccbb18f5..eeb79391b 100644 --- a/include/gba/m4a_internal.h +++ b/include/gba/m4a_internal.h @@ -313,6 +313,8 @@ struct MusicPlayerTrack #define MAX_MUSICPLAYER_TRACKS 16 +#define TRACKS_ALL 0xFFFF + #define TEMPORARY_FADE 0x0001 #define FADE_IN 0x0002 #define FADE_VOL_MAX 64 diff --git a/include/gba/types.h b/include/gba/types.h index 35d02e263..2e92bbe86 100644 --- a/include/gba/types.h +++ b/include/gba/types.h @@ -35,7 +35,7 @@ struct BgCnt { u16 priority:2; u16 charBaseBlock:2; - u16 dummy:2; + u16 dsCharBaseBlock:2; u16 mosaic:1; u16 palettes:1; u16 screenBaseBlock:5; diff --git a/include/global.h b/include/global.h index d82ea875e..7854eae96 100644 --- a/include/global.h +++ b/include/global.h @@ -19,19 +19,18 @@ #define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided") #define NAKED __attribute__((naked)) -// IDE support -#if defined (__APPLE__) || defined (__CYGWIN__) || defined (_MSC_VER) -#define _(x) x -#define __(x) x - -// Fool CLion IDE -#define INCBIN(x) {0} -#define INCBIN_U8 INCBIN -#define INCBIN_U16 INCBIN -#define INCBIN_U32 INCBIN -#define INCBIN_S8 INCBIN -#define INCBIN_S16 INCBIN -#define INCBIN_S32 INCBIN +/// IDE support +#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__INTELLISENSE__) +// We define these when using certain IDEs to fool preproc +#define _(x) (x) +#define __(x) (x) +#define INCBIN(...) {0} +#define INCBIN_U8 INCBIN +#define INCBIN_U16 INCBIN +#define INCBIN_U32 INCBIN +#define INCBIN_S8 INCBIN +#define INCBIN_S16 INCBIN +#define INCBIN_S32 INCBIN #endif // IDE support #define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0])) diff --git a/include/gym_leader_rematch.h b/include/gym_leader_rematch.h index dd9ead8b7..b31fb5e22 100644 --- a/include/gym_leader_rematch.h +++ b/include/gym_leader_rematch.h @@ -66,7 +66,7 @@ enum { REMATCH_TRENT, REMATCH_SAWYER, REMATCH_KIRA_AND_DAN, - REMATCH_WALLY_3, // Entries above WALLY are considered normal trainers, from Wally below are special trainers + REMATCH_WALLY_VR, // Entries above WALLY are considered normal trainers, from Wally below are special trainers REMATCH_ROXANNE, REMATCH_BRAWLY, REMATCH_WATTSON, @@ -75,7 +75,7 @@ enum { REMATCH_WINONA, REMATCH_TATE_AND_LIZA, REMATCH_JUAN, - REMATCH_SIDNEY, // Entries below SIDNEY are considered part of REMATCH_ELITE_FOUR_ENTRIES. + REMATCH_SIDNEY, // Entries from SIDNEY below are considered part of REMATCH_ELITE_FOUR_ENTRIES. REMATCH_PHOEBE, REMATCH_GLACIA, REMATCH_DRAKE, @@ -83,7 +83,7 @@ enum { REMATCH_TABLE_ENTRIES // The total number of rematch entries. Must be last in enum }; -#define REMATCH_SPECIAL_TRAINER_START REMATCH_WALLY_3 +#define REMATCH_SPECIAL_TRAINER_START REMATCH_WALLY_VR #define REMATCH_ELITE_FOUR_ENTRIES REMATCH_SIDNEY void UpdateGymLeaderRematch(void); diff --git a/include/pokemon.h b/include/pokemon.h index 3565bd966..315416c38 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -76,13 +76,22 @@ struct PokemonSubstruct3 /* 0x0B */ u32 eventLegal:1; // controls Mew & Deoxys obedience; if set, Pokémon is a fateful encounter in Gen 4+; set for in-game event island legendaries, some distributed events, and Pokémon from XD: Gale of Darkness. }; +// Number of bytes in the largest Pokémon substruct. +// They are assumed to be the same size, and will be padded to +// the largest size by the union. +// By default they are all 12 bytes. +#define NUM_SUBSTRUCT_BYTES (max(sizeof(struct PokemonSubstruct0), \ + max(sizeof(struct PokemonSubstruct1), \ + max(sizeof(struct PokemonSubstruct2), \ + sizeof(struct PokemonSubstruct3))))) + union PokemonSubstruct { struct PokemonSubstruct0 type0; struct PokemonSubstruct1 type1; struct PokemonSubstruct2 type2; struct PokemonSubstruct3 type3; - u16 raw[6]; + u16 raw[NUM_SUBSTRUCT_BYTES / 2]; // /2 because it's u16, not u8 }; struct BoxPokemon @@ -102,7 +111,7 @@ struct BoxPokemon union { - u32 raw[12]; + u32 raw[(NUM_SUBSTRUCT_BYTES * 4) / 4]; // *4 because there are 4 substructs, /4 because it's u32, not u8 union PokemonSubstruct substructs[4]; } secure; }; @@ -122,20 +131,32 @@ struct Pokemon u16 spDefense; }; -struct Unknown_806F160_Struct +struct MonSpritesGfxManager { - u32 field_0_0:4; - u32 field_0_1:4; - u32 field_1:8; - u16 magic:8; - u32 field_3_0:4; - u32 field_3_1:4; - void *bytes; - u8 **byteArrays; + u32 numSprites:4; + u32 numSprites2:4; // Never read + u32 numFrames:8; + u32 active:8; + u32 dataSize:4; + u32 mode:4; // MON_SPR_GFX_MODE_* + void *spriteBuffer; + u8 **spritePointers; struct SpriteTemplate *templates; struct SpriteFrameImage *frameImages; }; +enum { + MON_SPR_GFX_MODE_NORMAL, + MON_SPR_GFX_MODE_BATTLE, + MON_SPR_GFX_MODE_FULL_PARTY, +}; + +enum { + MON_SPR_GFX_MANAGER_A, + MON_SPR_GFX_MANAGER_B, // Nothing ever sets up this manager. + MON_SPR_GFX_MANAGERS_COUNT +}; + struct BattlePokemon { /*0x00*/ u16 species; @@ -247,6 +268,8 @@ struct Evolution | (((personality) & 0x00000003) >> 0) \ ) % NUM_UNOWN_FORMS) +#define GET_SHINY_VALUE(otId, personality)HIHALF(otId) ^ LOHALF(otId) ^ HIHALF(personality) ^ LOHALF(personality) + extern u8 gPlayerPartyCount; extern struct Pokemon gPlayerParty[PARTY_SIZE]; extern u8 gEnemyPartyCount; @@ -261,8 +284,8 @@ extern const u8 *const gItemEffectTable[]; extern const u32 gExperienceTables[][MAX_LEVEL + 1]; extern const u16 *const gLevelUpLearnsets[]; extern const u8 gPPUpGetMask[]; -extern const u8 gPPUpSetMask[]; -extern const u8 gPPUpAddMask[]; +extern const u8 gPPUpClearMask[]; +extern const u8 gPPUpAddValues[]; extern const u8 gStatStageRatios[MAX_STAT_STAGE + 1][2]; extern const u16 gLinkPlayerFacilityClasses[]; extern const struct SpriteTemplate gBattlerSpriteTemplates[]; @@ -281,7 +304,7 @@ void CreateMonWithIVsPersonality(struct Pokemon *mon, u16 species, u8 level, u32 void CreateMonWithIVsOTID(struct Pokemon *mon, u16 species, u8 level, u8 *ivs, u32 otId); void CreateMonWithEVSpread(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 evSpread); void CreateBattleTowerMon(struct Pokemon *mon, struct BattleTowerPokemon *src); -void CreateBattleTowerMon2(struct Pokemon *mon, struct BattleTowerPokemon *src, bool8 lvl50); +void CreateBattleTowerMon_HandleLevel(struct Pokemon *mon, struct BattleTowerPokemon *src, bool8 lvl50); void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId); void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId); void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest); @@ -305,12 +328,7 @@ u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove); void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move); void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 bankAtk, u8 bankDef); - u8 CountAliveMonsInBattle(u8 caseId); -#define BATTLE_ALIVE_EXCEPT_ACTIVE 0 -#define BATTLE_ALIVE_ATK_SIDE 1 -#define BATTLE_ALIVE_DEF_SIDE 2 - u8 GetDefaultMoveTarget(u8 battlerId); u8 GetMonGender(struct Pokemon *mon); u8 GetBoxMonGender(struct BoxPokemon *boxMon); @@ -330,7 +348,6 @@ void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg); void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg); void CopyMon(void *dest, void *src, size_t size); u8 GiveMonToPlayer(struct Pokemon *mon); -u8 SendMonToPC(struct Pokemon* mon); u8 CalculatePlayerPartyCount(void); u8 CalculateEnemyPartyCount(void); u8 GetMonsStateToDoubles(void); @@ -362,7 +379,6 @@ u16 SpeciesToNationalPokedexNum(u16 species); u16 SpeciesToHoennPokedexNum(u16 species); u16 HoennToNationalOrder(u16 hoennNum); u16 SpeciesToCryId(u16 species); -void sub_806D544(u16 species, u32 personality, u8 *dest); void DrawSpindaSpots(u16 species, u32 personality, u8 *dest, u8 a4); void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies); u8 GetPlayerFlankId(void); @@ -413,17 +429,15 @@ void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, void PokemonSummaryDoMonAnimation(struct Sprite* sprite, u16 species, bool8 oneFrame); void StopPokemonAnimationDelayTask(void); void BattleAnimateBackSprite(struct Sprite* sprite, u16 species); -u8 sub_806EF08(u8 arg0); -u8 sub_806EF84(u8 arg0, u8 arg1); -u16 sub_806EFF0(u16 arg0); +u8 GetOpposingLinkMultiBattlerId(bool8 rightSide, u8 multiplayerId); u16 FacilityClassToPicIndex(u16 facilityClass); u16 PlayerGenderToFrontTrainerPicId(u8 playerGender); void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality); const u8 *GetTrainerClassNameFromId(u16 trainerId); const u8 *GetTrainerNameFromId(u16 trainerId); bool8 HasTwoFramesAnimation(u16 species); -struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1); -void sub_806F47C(u8 id); -u8 *sub_806F4F8(u8 id, u8 arg1); +struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode); +void DestroyMonSpritesGfxManager(u8 managerId); +u8 *MonSpritesGfxManager_GetSpritePtr(u8 managerId, u8 spriteNum); #endif // GUARD_POKEMON_H diff --git a/include/recorded_battle.h b/include/recorded_battle.h index 5ae4ac12d..9b8939403 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -8,8 +8,8 @@ extern u8 gRecordedBattleMultiplayerId; #define B_RECORD_MODE_RECORDING 1 #define B_RECORD_MODE_PLAYBACK 2 -void RecordedBattle_Init(u8 arg0); -void sub_8184E58(void); +void RecordedBattle_Init(u8 mode); +void RecordedBattle_SetTrainerInfo(void); void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action); void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear); u8 RecordedBattle_GetBattlerAction(u8 battlerId); @@ -23,15 +23,15 @@ u8 GetRecordedBattleFronterBrainSymbol(void); void RecordedBattle_SaveParties(void); u8 GetActiveBattlerLinkPlayerGender(void); void RecordedBattle_ClearFrontierPassFlag(void); -void RecordedBattle_SetFrontierPassFlagFromHword(u16 arg0); +void RecordedBattle_SetFrontierPassFlagFromHword(u16 flags); u8 RecordedBattle_GetFrontierPassFlag(void); u8 GetBattleSceneInRecordedBattle(void); u8 GetTextSpeedInRecordedBattle(void); void RecordedBattle_CopyBattlerMoves(void); -void sub_818603C(u8 arg0); +void RecordedBattle_CheckMovesetChanges(u8 mode); u32 GetAiScriptsInRecordedBattle(void); -void sub_8186444(void); -bool8 sub_8186450(void); +void RecordedBattle_SetPlaybackFinished(void); +bool8 RecordedBattle_CanStopPlayback(void); void GetRecordedBattleRecordMixFriendName(u8 *dst); u8 GetRecordedBattleRecordMixFriendClass(void); u8 GetRecordedBattleApprenticeId(void); diff --git a/include/save.h b/include/save.h index 4eaa72458..406e2e492 100644 --- a/include/save.h +++ b/include/save.h @@ -34,8 +34,6 @@ struct SaveSectionOffsets #define SECTOR_FOOTER_SIZE 128 #define SECTOR_SIZE (SECTOR_DATA_SIZE + SECTOR_FOOTER_SIZE) -// Emerald changes this definition to be the sectors per slot. -#define NUM_SECTORS_PER_SLOT 16 #define NUM_SAVE_SLOTS 2 #define UNKNOWN_CHECK_VALUE 0x8012025 @@ -66,7 +64,7 @@ enum #define SECTOR_ID_SAVEBLOCK1_END 4 #define SECTOR_ID_PKMN_STORAGE_START 5 #define SECTOR_ID_PKMN_STORAGE_END 13 -#define SECTOR_SAVE_SLOT_LENGTH 14 +#define NUM_SECTORS_PER_SLOT 14 // Save Slot 1: 0-13; Save Slot 2: 14-27 #define SECTOR_ID_HOF_1 28 #define SECTOR_ID_HOF_2 29 |