summaryrefslogtreecommitdiff
path: root/include/battle.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/battle.h')
-rw-r--r--include/battle.h123
1 files changed, 82 insertions, 41 deletions
diff --git a/include/battle.h b/include/battle.h
index 72211f50f..d576e92f4 100644
--- a/include/battle.h
+++ b/include/battle.h
@@ -19,6 +19,8 @@
#define BATTLE_TYPE_LEGENDARY 0x2000
#define BATTLE_TYPE_REGI 0x4000
+#define BATTLE_TYPE_LINK_DOUBLE (BATTLE_TYPE_MULTI | BATTLE_TYPE_TRAINER | BATTLE_TYPE_LINK | BATTLE_TYPE_DOUBLE)
+
#define BATTLE_WON 0x1
#define BATTLE_LOST 0x2
#define BATTLE_DREW 0x3
@@ -173,8 +175,19 @@
#define WEATHER_SUN_ANY ((WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT))
#define WEATHER_HAIL (1 << 7)
-// needed to match the hack that is get_item, thanks cam, someone else clean this up later.
-extern u8 unk_2000000[];
+enum
+{
+ BATTLE_TERRAIN_GRASS,
+ BATTLE_TERRAIN_LONG_GRASS,
+ BATTLE_TERRAIN_SAND,
+ BATTLE_TERRAIN_UNDERWATER,
+ BATTLE_TERRAIN_WATER,
+ BATTLE_TERRAIN_POND,
+ BATTLE_TERRAIN_MOUNTAIN,
+ BATTLE_TERRAIN_CAVE,
+ BATTLE_TERRAIN_BUILDING,
+ BATTLE_TERRAIN_PLAIN,
+};
struct Trainer
{
@@ -221,7 +234,11 @@ struct AI_ThinkingStruct /* 0x2016800 */
struct BattleStruct /* 0x2000000 */
{
- u8 filler0[0x15DDE];
+ /*0x00000*/ u8 unk0;
+ /*0x00001*/ bool8 unk1;
+ /*0x00002*/ u8 unk2;
+ /*0x00003*/ bool8 unk3;
+ u8 filler4[0x15DDA];
/*0x15DDE*/ u8 unk15DDE;
/*0x15DDF*/ u8 unk15DDF;
/*0x15DE0*/ u8 filler15DE0[0x220];
@@ -229,12 +246,11 @@ struct BattleStruct /* 0x2000000 */
/*0x16001*/ u8 turnEffectsBank;
/*0x16002*/ u8 animTurn;
/*0x16003*/ u8 scriptingActive;
- /*0x16004*/ u8 wrappedMove1[4];
- /*0x16008*/ u8 wrappedMove2[4];
+ /*0x16004*/ u8 wrappedMove[8];
/*0x1600C*/ u8 cmd49StateTracker;
/*0x1600D*/ u8 unk1600D;
/*0x1600E*/ u8 turncountersTracker;
- /*0x1600F*/ u8 cmd23StateTracker;
+ /*0x1600F*/ u8 atk23StateTracker;
/*0x16010*/ u8 moveTarget[4];
/*0x16014*/ u8 unk16014;
/*0x16015*/ u8 unk16015;
@@ -518,6 +534,21 @@ struct BattleResults
u8 unk36[10]; // usedBalls?
};
+struct Struct2017100
+{
+ u32 arr[4];
+};
+
+struct Struct2019348
+{
+ u16 unk0;
+ u16 unk2;
+ u8 unk4;
+ u32 unk8;
+ u32 unkC;
+ u32 unk10;
+};
+
struct Struct2017800
{
u8 invisible:1;
@@ -530,25 +561,25 @@ struct Struct2017800
struct Struct2017810
{
- u8 unk0_0:1;
- u8 unk0_1:1;
- u8 unk0_2:1;
- u8 unk0_3:1;
- u8 unk0_4:1;
- u8 unk0_5:1;
- u8 unk0_6:1;
- u8 unk0_7:1;
- u8 unk1_0:1;
- u8 unk1_1:5;
- u8 unk2;
- u8 unk3;
- u8 unk4;
- u8 unk5;
- u8 unk6;
- u8 unk7;
- u8 unk8;
- u8 unk9;
- u8 fillerA[2];
+ /*0x00*/ u8 unk0_0:1;
+ /*0x00*/ u8 unk0_1:1;
+ /*0x00*/ u8 unk0_2:1;
+ /*0x00*/ u8 unk0_3:1;
+ /*0x00*/ u8 unk0_4:1;
+ /*0x00*/ u8 unk0_5:1;
+ /*0x00*/ u8 unk0_6:1;
+ /*0x00*/ u8 unk0_7:1;
+ /*0x01*/ u8 unk1_0:1;
+ /*0x01*/ u8 unk1_1:5;
+ /*0x02*/ u8 unk2;
+ /*0x03*/ u8 unk3;
+ /*0x04*/ u8 unk4;
+ /*0x05*/ u8 unk5;
+ /*0x06*/ u8 unk6;
+ /*0x07*/ u8 unk7;
+ /*0x08*/ u8 unk8;
+ /*0x09*/ u8 unk9;
+ /*0x0A*/ u8 fillerA[2];
};
struct Struct2017840
@@ -656,20 +687,31 @@ extern struct WishFutureKnock gWishFutureKnock;
extern struct AI_ThinkingStruct gAIThinkingSpace;
extern struct Struct20238C8 gUnknown_020238C8;
-// TODO: move ewram to global.h
-extern u8 ewram[];
-
-#define BATTLE_STRUCT ((struct BattleStruct *) (ewram + 0x00000))
-#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(ewram + 0x16800))
-#define UNK_2016A00_STRUCT ((struct UnkBattleStruct1 *) (ewram + 0x16A00))
-#define AI_STACK ((struct AI_Stack *) (ewram + 0x16C00))
-#define AI_ARRAY_160CC ((struct SmallItemStruct *) (ewram + 0x160CC))
-#define B_BATTLESCRIPTS_STACK ((struct scriptsStack *) (ewram + 0x17110))
-#define B_FUNCTION_STACK ((struct funcStack *) (ewram + 0x17140))
-#define ewram17800 ((struct Struct2017800 *) (ewram + 0x17800))
-#define ewram17810 ((struct Struct2017810 *) (ewram + 0x17810))
-#define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840))
-#define ewram17000 ((u32 *) (ewram + 0x17100))
+// used in many battle files, it seems as though Hisashi Sogabe wrote
+// some sort of macro to replace the use of actually calling memset.
+// Perhaps it was thought calling memset was much slower?
+
+// The compiler wont allow us to locally declare ptr in this macro; some
+// functions that invoke this macro will not match without this egregeous
+// assumption about the variable names, so in order to avoid this assumption,
+// we opt to pass the variables themselves, even though it is likely that
+// Sogabe assumed the variables were named src and dest. Trust me: I tried to
+// avoid assuming variable names, but the ROM just will not match without the
+// assumptions. Therefore, these macros are bad practice, but I'm putting them
+// here anyway.
+#define MEMSET_ALT(data, c, size, var, dest) \
+{ \
+ dest = (u8 *)data; \
+ for(var = 0; var < (u32)size; var++) \
+ dest[var] = c; \
+} \
+
+#define MEMCPY_ALT(data, dest, size, var, src) \
+{ \
+ src = (u8 *)data; \
+ for(var = 0; var < (u32)size; var++) \
+ dest[var] = src[var]; \
+} \
typedef void (*BattleCmdFunc)(void);
@@ -710,7 +752,6 @@ void EmitEffectivenessSound(u8 a, u16 sound); //0x2B
void Emitcmd44(u8 a, u16 sound); //0x2C
void EmitFaintingCry(u8 a); //0x2D
void EmitIntroSlide(u8 a, u8 b); //0x2E
-void Emitcmd48(u8 a, u8 *b, u8 c); //0x30
void Emitcmd49(u8 a); //0x31
void EmitSpriteInvisibility(u8 a, u8 b); //0x33
void EmitBattleAnimation(u8 a, u8 b, u16 c); //0x34
@@ -782,7 +823,7 @@ void BattleTurnPassed(void);
// asm/battle_2.o
void sub_8012324(void);
void sub_8012FBC(u8, u8);
-u8 b_first_side(u8, u8, u8);
+u8 GetWhoStrikesFirst(u8, u8, u8);
void TurnValuesCleanUp(u8);
void SpecialStatusesClear(void);
void sub_80138F0(void);