summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDizzyEggg <jajkodizzy@wp.pl>2017-09-26 22:39:59 +0200
committerDizzyEggg <jajkodizzy@wp.pl>2017-09-26 22:39:59 +0200
commitd769ec137447c52062b48153851bd2824055b6df (patch)
treed4b067644c81b1f1bcfc70120b1b64ba1d214f28 /include
parent52a951276f8d4b79195a0d4889503e4a7f096024 (diff)
battle 4 up to a8
Diffstat (limited to 'include')
-rw-r--r--include/battle.h108
-rw-r--r--include/battle_controllers.h29
-rw-r--r--include/battle_message.h29
-rw-r--r--include/moves.h4
-rw-r--r--include/pokemon.h7
-rw-r--r--include/pokemon_icon.h7
-rw-r--r--include/pokemon_item_effects.h8
-rw-r--r--include/text.h38
-rw-r--r--include/window.h2
9 files changed, 173 insertions, 59 deletions
diff --git a/include/battle.h b/include/battle.h
index d45944274..f84a75cba 100644
--- a/include/battle.h
+++ b/include/battle.h
@@ -1,8 +1,28 @@
#ifndef GUARD_BATTLE_H
#define GUARD_BATTLE_H
+/*
+ Banks are a name given to what could be called a 'battlerId' or 'monControllerId'.
+ Each bank has a value consisting of two bits.
+ 0x1 bit is responsible for the side, 0 = player's side, 1 = opponent's side.
+ 0x2 bit is responsible for the id of sent out pokemon. 0 means it's the first sent out pokemon, 1 it's the second one. (Triple battle didn't exist at the time yet.)
+*/
+
#define BATTLE_BANKS_COUNT 4
+#define IDENTITY_PLAYER_MON1 0
+#define IDENTITY_OPPONENT_MON1 1
+#define IDENTITY_PLAYER_MON2 2
+#define IDENTITY_OPPONENT_MON2 3
+
+#define SIDE_PLAYER 0x0
+#define SIDE_OPPONENT 0x1
+
+#define BIT_SIDE 0x1
+#define BIT_MON 0x2
+
+#define GET_BANK_SIDE(bank)((GetBankIdentity(bank) & BIT_SIDE))
+
#define BATTLE_TYPE_DOUBLE 0x0001
#define BATTLE_TYPE_LINK 0x0002
#define BATTLE_TYPE_WILD 0x0004
@@ -40,9 +60,6 @@
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID)
-#define SIDE_PLAYER 0x0
-#define SIDE_OPPONENT 0x1
-
#define BATTLE_WON 0x1
#define BATTLE_LOST 0x2
#define BATTLE_DREW 0x3
@@ -66,11 +83,12 @@
#define STATUS2_CONFUSION 0x00000007
#define STATUS2_FLINCHED 0x00000008
#define STATUS2_UPROAR 0x00000070
-#define STATUS2_BIDE 0x00000300 //two bits 0x100 0x200
+#define STATUS2_BIDE 0x00000300 // two bits 0x100, 0x200
#define STATUS2_LOCK_CONFUSE 0x00000C00
#define STATUS2_MULTIPLETURNS 0x00001000
#define STATUS2_WRAPPED 0x0000E000
-#define STATUS2_INFATUATION 0x000F0000
+#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every bank
+#define STATUS2_INFATUATED_WITH(bank)((gBitTable[bank] << 16))
#define STATUS2_FOCUS_ENERGY 0x00100000
#define STATUS2_TRANSFORMED 0x00200000
#define STATUS2_RECHARGE 0x00400000
@@ -86,7 +104,7 @@
#define STATUS3_LEECHSEED_BANK 0x3
#define STATUS3_LEECHSEED 0x4
-#define STATUS3_ALWAYS_HITS 0x18 //two bits
+#define STATUS3_ALWAYS_HITS 0x18 // two bits
#define STATUS3_PERISH_SONG 0x20
#define STATUS3_ON_AIR 0x40
#define STATUS3_UNDERGROUND 0x80
@@ -188,17 +206,6 @@
#define WEATHER_HAIL (1 << 7)
#define WEATHER_HAIL_ANY ((WEATHER_HAIL))
-#define REQUEST_ALL_BATTLE 0x0
-#define REQUEST_SPECIES_BATTLE 0x1
-#define REQUEST_HELDITEM_BATTLE 0x2
-#define REQUEST_MOVES_PP_BATTLE 0x3
-#define REQUEST_PPMOVE1_BATTLE 0x9
-#define REQUEST_PPMOVE2_BATTLE 0xA
-#define REQUEST_PPMOVE3_BATTLE 0xB
-#define REQUEST_PPMOVE4_BATTLE 0xC
-#define REQUEST_STATUS_BATTLE 0x28
-#define REQUEST_HP_BATTLE 0x2A
-
// array entries for battle communication
#define CURSOR_POSITION 0x1
#define MOVE_EFFECT_BYTE 0x3
@@ -222,6 +229,7 @@
#define BS_GET_TARGET 0
#define BS_GET_ATTACKER 1
#define BS_GET_EFFECT_BANK 2
+#define BS_ATTACKER_WITH_PARTNER 4 // for atk98_status_icon_update
#define BS_GET_ATTACKER_SIDE 8 // for atk1E_jumpifability
#define BS_GET_NOT_ATTACKER_SIDE 9 // for atk1E_jumpifability
#define BS_GET_SCRIPTING_BANK 10
@@ -384,11 +392,11 @@ extern struct ProtectStruct gProtectStructs[BATTLE_BANKS_COUNT];
struct SpecialStatus
{
- u8 statLowered : 1;
- u8 lightningRodRedirected : 1;
- u8 restoredBankSprite: 1;
- u8 intimidatedPoke : 1;
- u8 traced : 1;
+ u8 statLowered : 1; // 0x1
+ u8 lightningRodRedirected : 1; // 0x2
+ u8 restoredBankSprite: 1; // 0x4
+ u8 intimidatedPoke : 1; // 0x8
+ u8 traced : 1; // 0x10
u8 flag20 : 1;
u8 flag40 : 1;
u8 focusBanded : 1;
@@ -690,6 +698,7 @@ struct BattleStruct
u8 field_298[8];
u8 field_2A0;
u8 field_2A1;
+ u8 field_2A2;
};
extern struct BattleStruct* gBattleStruct;
@@ -709,6 +718,13 @@ extern struct BattleStruct* gBattleStruct;
varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \
}
+#define GET_USED_ITEM_PTR_VIA_MEME_ACCESS(bank, varName) \
+{ \
+ void** memes1 = (void**)(&gBattleStruct); \
+ void* memes2 = (void*)((u32)(bank * 2 + offsetof(struct BattleStruct, usedHeldItems))); \
+ varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \
+}
+
#define GET_HP_SWITCHOUT_PTR_VIA_MEME_ACCESS(bank, varName) \
{ \
void** memes1 = (void**)(&gBattleStruct); \
@@ -724,8 +740,6 @@ extern struct BattleStruct* gBattleStruct;
typeArg = gBattleMoves[move].type; \
}
-#define GET_BANK_SIDE(bank)((GetBankIdentity(bank) & 1))
-
#define MOVE_EFFECT_SLEEP 0x1
#define MOVE_EFFECT_POISON 0x2
#define MOVE_EFFECT_BURN 0x3
@@ -832,26 +846,39 @@ extern struct BattleStruct* gBattleStruct;
#define ATK4F_DONT_CHECK_STATUSES 0x80
+#define VARIOUS_CANCEL_MULTI_TURN_MOVES 0
+#define VARIOUS_SET_MAGIC_COAT_TARGET 1
+#define VARIOUS_GET_MOVE_TARGET 3
+#define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5
+#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6
+#define VARIOUS_WAIT_CRY 18
+#define VARIOUS_RETURN_OPPONENT_MON1 19
+#define VARIOUS_RETURN_OPPONENT_MON2 20
+#define VARIOUS_SET_TELEPORT_OUTCOME 25
+#define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26
+
+#define ATK80_DMG_CHANGE_SIGN 0
+#define ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP 1
+#define ATK80_DMG_DOUBLED 2
+
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
-#define GET_STAT_BUFF_VALUE(n)((n & 0xF0) >> 4) // 0x10, 0x20, 0x40
+#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
+#define STAT_CHANGE_BS_PTR 0x1
+#define STAT_CHANGE_NOT_PROTECT_AFFECTED 0x20
+
+#define STAT_CHANGE_WORKED 0
+#define STAT_CHANGE_DIDNT_WORK 1
+
#define SET_STAT_BUFF_ID(n)((n & 0xF))
#define SET_STAT_BUFF_VALUE(n)(((s8)(((s8)(n) << 4)) & 0xF0))
struct BattleScripting
{
- u8 field_0;
- u8 field_1;
- u8 field_2;
- u8 field_3;
- u32 bideDmg;
- u8 field_8;
- u8 field_9;
- u8 field_A;
- u8 field_B;
- u8 field_C;
- u8 field_D;
+ s32 painSplitHp;
+ s32 bideDmg;
+ u8 multihitString[6];
u8 dmgMultiplier;
u8 field_F;
u8 animArg1;
@@ -868,7 +895,7 @@ struct BattleScripting
u8 field_1B;
u8 atk23_state;
u8 field_1D;
- u8 field_1E;
+ u8 atk6C_state;
u8 learnMoveState;
};
@@ -887,6 +914,9 @@ void SwitchInClearStructs(void);
void sub_803BDA0(u8 bank);
void sub_803FA70(u8 bank);
void BattleMainCB2(void);
+void ResetSentPokesToOpponentValue(void);
+bool8 CanRunFromBattle(u8 bank);
+bool8 IsRunningFromBattleImpossible(void);
// battle_3
void BattleScriptPush(const u8* bsPtr);
@@ -920,10 +950,12 @@ u8 AI_TypeCalc(u16 move, u16 species, u8 ability);
u8 BankGetTurnOrder(u8 bank);
void BattleDestroyCursorAt(u8 cursorPosition);
void BattleCreateCursorAt(u8 cursorPosition);
+void BufferMoveToLearnIntoBattleTextBuff2(void);
// battle_5
void AdjustFriendshipOnBattleFaint(u8 bank);
void sub_80571DC(u8 bank, u8 arg1);
+u32 sub_805725C(u8 bank);
// battle 7
void BattleMusicStop(void);
@@ -932,7 +964,7 @@ void sub_805E990(struct Pokemon* mon, u8 bank);
// rom_80A5C6C
u8 GetBankSide(u8 bank);
u8 GetBankIdentity(u8 bank);
-u8 GetBankByPlayerAI(u8 bank);
+u8 GetBankByIdentity(u8 bank);
// Move this somewhere else
diff --git a/include/battle_controllers.h b/include/battle_controllers.h
index b24aa9cc5..bb58cb699 100644
--- a/include/battle_controllers.h
+++ b/include/battle_controllers.h
@@ -7,8 +7,26 @@ struct HpAndStatus
u32 status;
};
+struct MovePpInfo
+{
+ u16 move[4];
+ u8 pp[4];
+ u8 ppBonuses;
+};
+
+#define REQUEST_ALL_BATTLE 0x0
+#define REQUEST_SPECIES_BATTLE 0x1
+#define REQUEST_HELDITEM_BATTLE 0x2
+#define REQUEST_MOVES_PP_BATTLE 0x3
+#define REQUEST_PPMOVE1_BATTLE 0x9
+#define REQUEST_PPMOVE2_BATTLE 0xA
+#define REQUEST_PPMOVE3_BATTLE 0xB
+#define REQUEST_PPMOVE4_BATTLE 0xC
+#define REQUEST_STATUS_BATTLE 0x28
+#define REQUEST_HP_BATTLE 0x2A
+
// rom3.s, emitters
-void EmitSetAttributes(u8 bufferId, u8 request, u8 c, u8 bytes, void *data);
+void EmitSetMonData(u8 bufferId, u8 request, u8 c, u8 bytes, void *data);
void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct* disableStructPtr, u8 multihit);
void EmitHealthBarUpdate(u8 bufferId, u16 hpValue);
void EmitEffectivenessSound(u8 bufferId, u16 songId);
@@ -20,7 +38,7 @@ void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints);
void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
void EmitReturnPokeToBall(u8 bufferId, u8 arg1);
-void EmitGetAttributes(u8 bufferId, u8 arg1, u8 arg2);
+void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2);
void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, const u8* arg4);
void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, u8 arg2);
@@ -31,6 +49,13 @@ void EmitHitAnimation(u8 bufferId);
void EmitCmd48(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2);
void EmitCmd49(u8 bufferId);
void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status);
+void EmitCmd13(u8 bufferId);
+void EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2);
+void EmitResetActionMoveSelection(u8 bufferId, u8 caseId);
+
+#define RESET_ACTION_MOVE_SELECTION 0
+#define RESET_ACTION_SELECTION 1
+#define RESET_MOVE_SELECTION 2
void MarkBufferBankForExecution(u8 bank);
diff --git a/include/battle_message.h b/include/battle_message.h
index ad1ce3455..3e28fa5e5 100644
--- a/include/battle_message.h
+++ b/include/battle_message.h
@@ -74,6 +74,22 @@
#define B_BUFF_PLACEHOLDER_BEGIN 0xFD
#define B_BUFF_EOS 0xFF
+#define PREPARE_STAT_BUFFER(textVar, statId) \
+{ \
+ textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \
+ textVar[1] = B_BUFF_STAT; \
+ textVar[2] = statId; \
+ textVar[3] = B_BUFF_EOS; \
+}
+
+#define PREPARE_TYPE_BUFFER(textVar, typeId) \
+{ \
+ textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \
+ textVar[1] = B_BUFF_TYPE; \
+ textVar[2] = typeId; \
+ textVar[3] = B_BUFF_EOS; \
+}
+
#define PREPARE_BYTE_NUMBER_BUFFER(textVar, maxDigits, number) \
{ \
textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \
@@ -84,6 +100,17 @@
textVar[5] = B_BUFF_EOS; \
}
+#define PREPARE_HWORD_NUMBER_BUFFER(textVar, maxDigits, number) \
+{ \
+ textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \
+ textVar[1] = B_BUFF_NUMBER; \
+ textVar[2] = 2; \
+ textVar[3] = maxDigits; \
+ textVar[4] = (number); \
+ textVar[5] = (number & 0x0000FF00) >> 8; \
+ textVar[6] = B_BUFF_EOS; \
+}
+
#define PREPARE_WORD_NUMBER_BUFFER(textVar, maxDigits, number) \
{ \
textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \
@@ -158,7 +185,7 @@ struct StringInfoBattle
};
void BufferStringBattle(u16 stringID);
-u32 StrCpyDecodeToDisplayedStringBattle(const u8* src);
+u32 BattleStringExpandPlaceholdersToDisplayedString(const u8* src);
u32 BattleStringExpandPlaceholders(const u8* src, u8* dst);
void sub_814F9EC(const u8* text, u8 arg1);
diff --git a/include/moves.h b/include/moves.h
index e3b6d3113..bc213cbc7 100644
--- a/include/moves.h
+++ b/include/moves.h
@@ -360,4 +360,6 @@ enum
MOVE_PSYCHO_BOOST,
};
-#endif // GUARD_MOVES_H \ No newline at end of file
+#define LAST_MOVE_INDEX MOVE_PSYCHO_BOOST
+
+#endif // GUARD_MOVES_H
diff --git a/include/pokemon.h b/include/pokemon.h
index 518d28e58..20e904f39 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -126,6 +126,8 @@
#define TYPE_DRAGON 0x10
#define TYPE_DARK 0x11
+#define NUMBER_OF_MON_TYPES 0x12
+
#define PARTY_SIZE 6
#define MAX_TOTAL_EVS 510
#define NUM_STATS 6
@@ -333,6 +335,8 @@ struct UnknownPokemonStruct
u8 friendship;
};
+#define BATTLE_STATS_NO 8
+
struct BattlePokemon
{
/*0x00*/ u16 species;
@@ -350,7 +354,7 @@ struct BattlePokemon
/*0x17*/ u32 spDefenseIV:5;
/*0x17*/ u32 isEgg:1;
/*0x17*/ u32 altAbility:1;
- /*0x18*/ s8 statStages[8];
+ /*0x18*/ s8 statStages[BATTLE_STATS_NO];
/*0x20*/ u8 ability;
/*0x21*/ u8 type1;
/*0x22*/ u8 type2;
@@ -521,6 +525,7 @@ extern struct PokemonStorage* gPokemonStoragePtr;
extern const u32 gExperienceTables[][MAX_MON_LEVEL + 1];
extern const u16 *const gLevelUpLearnsets[];
+u8 CountAliveMonsInBattle(u8 caseId);
#define BATTLE_ALIVE_EXCEPT_ACTIVE 0
#define BATTLE_ALIVE_ATK_SIDE 1
#define BATTLE_ALIVE_DEF_SIDE 2
diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h
new file mode 100644
index 000000000..b82334355
--- /dev/null
+++ b/include/pokemon_icon.h
@@ -0,0 +1,7 @@
+#ifndef GUARD_POKEMON_ICON_H
+#define GUARD_POKEMON_ICON_H
+
+const u8 *GetMonIconPtr(u16 speciesId, u32 personality, u32 frameNo);
+const u16 *GetValidMonIconPalettePtr(u16 speciesId);
+
+#endif // GUARD_POKEMON_ICON_H
diff --git a/include/pokemon_item_effects.h b/include/pokemon_item_effects.h
new file mode 100644
index 000000000..88f341317
--- /dev/null
+++ b/include/pokemon_item_effects.h
@@ -0,0 +1,8 @@
+#ifndef GUARD_POKEMON_ITEM_EFFECTS
+#define GUARD_POKEMON_ITEM_EFFECTS
+
+#include "pokemon.h"
+
+bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 itemId, u8 partyId, u8 monMoveIndex, u8 a5);
+
+#endif // GUARD_POKEMON_ITEM_EFFECTS
diff --git a/include/text.h b/include/text.h
index f0c85b978..88f2cc0e2 100644
--- a/include/text.h
+++ b/include/text.h
@@ -65,6 +65,7 @@
#define CHAR_x 0xEC
#define CHAR_y 0xED
#define CHAR_z 0xEE
+#define CHAR_SPECIAL_F9 0xF9
#define CHAR_COLON 0xF0
#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog
#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog
@@ -73,6 +74,10 @@
#define CHAR_NEWLINE 0xFE
#define EOS 0xFF // end of string
+#define TEXT_COLOR_TRANSPARENT 0x0
+#define TEXT_COLOR_WHITE 0x1
+#define TEXT_COLOR_DARK_GREY 0x2
+
// battle placeholders are located in battle_message.h
#define EXT_CTRL_CODE_JPN 0x15
@@ -80,23 +85,26 @@
#define NUM_TEXT_PRINTERS 32
+struct TextSubPrinter // TODO: Better name
+{
+ u8* current_text_offset;
+ u8 windowId;
+ u8 fontId;
+ u8 x;
+ u8 y;
+ u8 currentX; // 0x8
+ u8 currentY;
+ u8 letterSpacing;
+ u8 lineSpacing;
+ u8 fontColor_l:4; // 0xC
+ u8 fontColor_h:4;
+ u8 bgColor:4;
+ u8 shadowColor:4;
+};
+
struct TextPrinter
{
- struct TextSubPrinter { // TODO: Better name
- u8* current_text_offset;
- u8 windowId;
- u8 fontId;
- u8 x;
- u8 y;
- u8 currentX; // 0x8
- u8 currentY;
- u8 letterSpacing;
- u8 lineSpacing;
- u8 fontColor_l:4; // 0xC
- u8 fontColor_h:4;
- u8 bgColor:4;
- u8 shadowColor:4;
- } subPrinter;
+ struct TextSubPrinter subPrinter;
void (*callback)(struct TextSubPrinter *, u16); // 0x10
diff --git a/include/window.h b/include/window.h
index e8af82e81..4e814ebc6 100644
--- a/include/window.h
+++ b/include/window.h
@@ -55,7 +55,7 @@ void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height);
void BlitBitmapToWindow(u8 windowId, u8 *pixels, u16 x, u16 y, u16 width, u16 height);
void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight);
void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height);
-void CopyToWindowPixelBuffer(u8 windowId, u8 *src, u16 size, u16 tileOffset);
+void CopyToWindowPixelBuffer(u8 windowId, const u8 *src, u16 size, u16 tileOffset);
void FillWindowPixelBuffer(u8 windowId, u8 fillValue);
void ScrollWindow(u8 windowId, u8 direction, u8 distance, u8 fillValue);
void CallWindowFunction(u8 windowId, void ( *func)(u8, u8, u8, u8, u8, u8));