summaryrefslogtreecommitdiff
path: root/include/global.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/global.h')
-rw-r--r--include/global.h277
1 files changed, 241 insertions, 36 deletions
diff --git a/include/global.h b/include/global.h
index b05c87d88..c47bd2d15 100644
--- a/include/global.h
+++ b/include/global.h
@@ -3,6 +3,7 @@
#include "config.h"
#include "gba/gba.h"
+#include <string.h>
// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");
@@ -12,13 +13,23 @@
#define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided")
#if defined (__APPLE__) || defined (__CYGWIN__)
-void *memset(void *, int, size_t);
-void *memcpy(void *, const void *, size_t);
-int strcmp(const char *s1, const char *s2);
-char* strcpy(char *dst0, const char *src0);
+// Get the IDE to stfu
+
+// We define it this way to fool preproc.
+#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
+#define _(x) (x)
+#define __(x) (x)
#endif // __APPLE__
#define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0]))
+// GF's lingo
+#define NELEMS ARRAY_COUNT
// useful math macros
@@ -53,6 +64,15 @@ char* strcpy(char *dst0, const char *src0);
#define T2_READ_32(ptr) ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24))
#define T2_READ_PTR(ptr) (void*) T2_READ_32(ptr)
+// This macro is required to prevent the compiler from optimizing
+// a dpad up/down check in sub_812CAD8 (fame_checker.c).
+// We suspect it was used globally.
+// GameFreak never ceases to amaze.
+// TODO: Propagate use of this macro
+#define TEST_BUTTON(field, button) ({(field) & (button);})
+#define JOY_NEW(button) TEST_BUTTON(gMain.newKeys, button)
+#define JOY_HELD(button) TEST_BUTTON(gMain.heldKeys, button)
+
extern u8 gStringVar1[];
extern u8 gStringVar2[];
extern u8 gStringVar3[];
@@ -79,6 +99,7 @@ enum LanguageId {
#define GAME_LANGUAGE (LANGUAGE_ENGLISH)
+#define PC_ITEMS_COUNT 30
#define BAG_ITEMS_COUNT 42
#define BAG_KEYITEMS_COUNT 30
#define BAG_POKEBALLS_COUNT 13
@@ -146,6 +167,8 @@ struct Time
/*0x04*/ s8 seconds;
};
+#define DEX_FLAGS_NO ((POKEMON_SLOTS_NUMBER / 8) + ((POKEMON_SLOTS_NUMBER % 8) ? 1 : 0))
+
struct Pokedex
{
/*0x00*/ u8 order;
@@ -155,8 +178,8 @@ struct Pokedex
/*0x04*/ u32 unownPersonality; // set when you first see Unown
/*0x08*/ u32 spindaPersonality; // set when you first see Spinda
/*0x0C*/ u32 unknown3;
- /*0x10*/ u8 owned[52];
- /*0x44*/ u8 seen[52];
+ /*0x10*/ u8 owned[DEX_FLAGS_NO];
+ /*0x44*/ u8 seen[DEX_FLAGS_NO];
};
struct PokemonJumpResults // possibly used in the game itself?
@@ -201,6 +224,23 @@ struct BerryCrush
#define PLAYER_NAME_LENGTH 8
+#define LINK_B_RECORDS_COUNT 5
+
+struct LinkBattleRecord
+{
+ u8 name[PLAYER_NAME_LENGTH];
+ u16 trainerId;
+ u16 wins;
+ u16 losses;
+ u16 draws;
+};
+
+struct LinkBattleRecords
+{
+ struct LinkBattleRecord entries[LINK_B_RECORDS_COUNT];
+ u8 languages[LINK_B_RECORDS_COUNT];
+};
+
struct UnknownSaveBlock2Struct
{
u8 field_0;
@@ -221,6 +261,21 @@ struct UnknownSaveBlock2Struct
u8 field_EB;
}; // sizeof = 0xEC
+struct UnkSaveBlock2Substruct_55C
+{
+ /* 0x000:0x55C */ u8 unk_00_0:1;
+ u8 unk_00_1:1;
+ /* 0x001:0x55D */ u8 unk_01;
+ /* 0x002:0x55E */ u8 unk_02[2];
+ /* 0x004:0x560 */ u16 unk_04[2];
+ /* 0x008:0x564 */ u16 unk_08[2];
+ /* 0x00C:0x568 */ u16 unk_0C[2];
+ /* 0x010:0x56C */ u8 unk_10;
+ /* 0x011:0x56D */ u8 unk_11[3];
+ /* 0x014:0x570 */ u16 unk_14;
+ /* 0x016:0x572 */ u8 unk_16;
+}; // size: 0x018
+
struct SaveBlock2
{
/*0x000*/ u8 playerName[PLAYER_NAME_LENGTH];
@@ -243,7 +298,13 @@ struct SaveBlock2
/*0x098*/ struct Time localTimeOffset;
/*0x0A0*/ struct Time lastBerryTreeUpdate;
/*0x0A8*/ u32 field_A8;
- /*0x0AC*/ u8 filler_AC[0xE74];
+ /*0x0AC*/ u8 filler_AC[0x3F4];
+ /*0x4A0*/ u32 unk_4A0[0x2F];
+ /*0x55c*/ struct UnkSaveBlock2Substruct_55C unk_55C;
+ /*0x574*/ u8 filler_574[0x524];
+ /*0xA98*/ struct LinkBattleRecords linkBattleRecords;
+ /*0xAF0*/ struct BerryCrush berryCrush;
+ /*0xB00*/ u8 filler_B00[0x420];
/*0xF20*/ u32 encryptionKey;
};
@@ -411,15 +472,6 @@ struct RecordMixing_UnknownStruct
u16 unk74[0x2];
};
-struct LinkBattleRecord
-{
- u8 name[8];
- u16 trainerId;
- u16 wins;
- u16 losses;
- u16 draws;
-};
-
struct RecordMixingGiftData
{
u8 unk0;
@@ -466,8 +518,8 @@ struct DaycareMon
struct DayCare
{
struct DaycareMon mons[DAYCARE_MON_COUNT];
- u32 offspringPersonality;
- u8 stepCounter;
+ u16 unk_118;
+ u8 unk_11A;
};
struct DayCareMail
@@ -491,12 +543,145 @@ struct MysteryEventStruct
u8 unk_1;
};
+struct QuestLogNPCData
+{
+ u32 x:8;
+ u32 negx:1;
+ u32 y:8;
+ u32 negy:1;
+ u32 elevation:6;
+ u32 movementType:8;
+};
+
+struct UnkStruct_203B024
+{
+ u16 unk_00;
+ u16 unk_02;
+ u16 unk_04[14];
+};
+
+union QuestLogScene
+{
+ u8 allocation[32];
+ u16 ident;
+};
+
+typedef union QuestLogScene QuestLogScene;
+
+// This name is a complete guess and may change.
+
+// Declare here so that it can be recursively referenced.
+union QuestLogMovement;
+
+// Define here
+union QuestLogMovement
+{
+ u16 ident_raw;
+ struct {
+ u16 ident:12;
+ u16 flags:4;
+ } ident_struct;
+};
+
+struct QuestLog
+{
+ /*0x0000*/ u8 unk_000;
+ /*0x0001*/ s8 unk_001;
+ /*0x0002*/ s8 unk_002;
+ /*0x0003*/ s8 unk_003;
+ /*0x0004*/ s16 unk_004;
+ /*0x0006*/ s16 unk_006;
+ /*0x0008*/ u8 filler_008[0x140];
+
+ // These arrays hold the game state for
+ // playing back the quest log
+ /*0x0148*/ u8 flags[0x120];
+ /*0x02c8*/ u16 vars[0x100];
+ /*0x0468*/ struct QuestLogNPCData npcData[64];
+ /*0x0568*/ u16 unk_568[128];
+ /*0x0668*/ u16 end[0];
+};
+
+#include "fame_checker.h"
+
+struct FameCheckerSaveData
+{
+ /*3a54*/ u16 pickState:2;
+ u16 flavorTextFlags:12;
+ u16 unk_0_E:2;
+};
+
#define MAP_OBJECTS_COUNT 16
#define BERRY_TREES_COUNT 128
-#define FLAGS_COUNT 300
+#define FLAGS_COUNT 288 // 300
#define VARS_COUNT 256
#define MAIL_COUNT 16
+#define NUM_EASY_CHAT_EXTRA_PHRASES 33
+#define EASY_CHAT_EXTRA_PHRASES_SIZE ((NUM_EASY_CHAT_EXTRA_PHRASES >> 3) + (NUM_EASY_CHAT_EXTRA_PHRASES % 8 ? 1 : 0))
+
+struct MEventBuffer_3120_Sub
+{
+ u16 unk_00;
+ u8 unk_02;
+ u8 unk_03;
+ u8 unk_04[40];
+ u8 unk_2C[10][40];
+};
+
+struct MEventBuffer_3120
+{
+ u32 crc;
+ struct MEventBuffer_3120_Sub data;
+};
+
+struct MEventBuffer_32E0_Sub
+{
+ u16 unk_00;
+ u16 unk_02;
+ u32 unk_04;
+ u8 unk_08_0:2;
+ u8 unk_08_2:4;
+ u8 unk_08_6:2;
+ u8 unk_09;
+ u8 unk_0A[40];
+ u8 unk_32[40];
+ u8 unk_5A[4][40];
+ u8 unk_FA[40];
+ u8 unk_122[40];
+};
+
+struct MEventBuffer_32E0
+{
+ u32 crc;
+ struct MEventBuffer_32E0_Sub data;
+};
+
+struct MEventBuffer_3430_Sub
+{
+ u16 unk_00;
+ u16 unk_02;
+ u16 unk_04;
+ u16 unk_06;
+ u16 unk_08[2][7];
+};
+
+struct MEventBuffer_3430
+{
+ u32 crc;
+ struct MEventBuffer_3430_Sub data;
+};
+
+struct MEventBuffers
+{
+ /*0x000 0x3120*/ struct MEventBuffer_3120 buffer_000;
+ /*0x1c0 0x32e0*/ struct MEventBuffer_32E0 buffer_1c0;
+ /*0x310 0x3430*/ struct MEventBuffer_3430 buffer_310;
+ /*0x338 0x3458*/ u16 unk_338[4];
+ /*0x340 0x3460*/ struct MysteryEventStruct unk_340;
+ /*0x344 0x3464*/ u32 unk_344[2][5];
+}; // 0x36C 0x348C
+
struct SaveBlock1
{
/*0x0000*/ struct Coords16 pos;
@@ -505,34 +690,54 @@ struct SaveBlock1
/*0x0014*/ struct WarpData warp2;
/*0x001C*/ struct WarpData lastHealLocation;
/*0x0024*/ struct WarpData warp4;
- /*0x002C*/ u8 filler2C[0x8];
+ /*0x002C*/ u16 savedMusic;
+ /*0x002E*/ u8 weather;
+ /*0x002F*/ u8 filler_2F;
+ /*0x0030*/ u8 flashLevel;
+ /*0x0032*/ u16 mapDataId;
/*0x0034*/ u8 playerPartyCount;
/*0x0038*/ struct Pokemon playerParty[PARTY_SIZE];
/*0x0290*/ u32 money;
/*0x0294*/ u16 coins;
- /*0x0296*/ u8 filler296[0x7A];
+ /*0x0296*/ u16 registeredItem; // registered for use with SELECT button
+ /*0x0298*/ struct ItemSlot pcItems[PC_ITEMS_COUNT];
/*0x0310*/ struct ItemSlot bagPocket_Items[BAG_ITEMS_COUNT];
- struct ItemSlot bagPocket_KeyItems[BAG_KEYITEMS_COUNT];
- struct ItemSlot bagPocket_PokeBalls[BAG_POKEBALLS_COUNT];
- struct ItemSlot bagPocket_TMHM[BAG_TMHM_COUNT];
- struct ItemSlot bagPocket_Berries[BAG_BERRIES_COUNT];
- u8 filler5F8[0x40];
+ /*0x03b8*/ struct ItemSlot bagPocket_KeyItems[BAG_KEYITEMS_COUNT];
+ /*0x0430*/ struct ItemSlot bagPocket_PokeBalls[BAG_POKEBALLS_COUNT];
+ /*0x0464*/ struct ItemSlot bagPocket_TMHM[BAG_TMHM_COUNT];
+ /*0x054c*/ struct ItemSlot bagPocket_Berries[BAG_BERRIES_COUNT];
+ /*0x05F8*/ u8 seen1[DEX_FLAGS_NO];
+ /*0x062C*/ u16 berryBlenderRecords[3]; // unused
+ /*0x0632*/ u8 field_632[6]; // unused?
/*0x0638*/ u8 trainerRematchStepCounter;
- u8 filler_639;
- /*0x063a*/ u8 trainerRematches[100];
+ /*0x063A*/ u8 ALIGNED(2) trainerRematches[100];
/*0x06A0*/ struct MapObject mapObjects[MAP_OBJECTS_COUNT];
/*0x08E0*/ struct MapObjectTemplate mapObjectTemplates[64];
- /*0x0EE0*/ u8 fillerEE0[0x1DF0];
+ /*0x0EE0*/ u8 flags[FLAGS_COUNT];
+ /*0x1000*/ u16 vars[VARS_COUNT];
+ /*0x1200*/ u32 gameStats[NUM_GAME_STATS];
+ /*0x1300*/ struct QuestLog questLog[4];
+ /*0x2CA0*/ u16 unk2CA0[6];
+ /*0x2CAC*/ u16 unk2CAC[6];
+ /*0x2CB8*/ u16 unk2CB8[6];
+ /*0x2CC4*/ u16 unk2CC4[6];
/*0x2CD0*/ struct MailStruct mail[MAIL_COUNT];
- u8 filler2F10[0x1DA];
- /*0x30EA*/ struct EnigmaBerry enigmaBerry;
- /*0x3120*/ u8 filler3120[0x340];
- /*0x3460*/ struct MysteryEventStruct unk_3460;
- /*0x3464*/ u8 filler_3464[0x1b8];
+ /*0x2F10*/ u8 additionalPhrases[EASY_CHAT_EXTRA_PHRASES_SIZE];
+ /*0x2F18*/ OldMan oldMan; // unused
+ /*0x2F54*/ struct EasyChatPair easyChatPairs[5]; // unused
+ /*0x2F80*/ struct DayCare daycare;
+ /*0x309C*/ u8 giftRibbons[52];
+ /*0x30D0*/ struct Roamer roamer;
+ /*0x30EC*/ struct EnigmaBerry enigmaBerry;
+ /*0x3120*/ struct MEventBuffers unk_3120;
+ /*0x348C*/ u8 filler_348C[400];
/*0x361C*/ struct RamScript ramScript;
- /*0x3A08*/ u8 filler3A08[0x44];
+ /*0x3A08*/ u8 filler3A08[12];
+ /*0x3A14*/ u8 seen2[DEX_FLAGS_NO];
+ /*0x3A48*/ u8 filler_3a48[4];
/*0x3A4C*/ u8 rivalName[PLAYER_NAME_LENGTH];
- /*0x3A54*/ u8 filler3A54[0x2E4];
+ /*0x3A54*/ struct FameCheckerSaveData fameChecker[NUM_FAMECHECKER_PERSONS];
+ /*0x3A94*/ u8 filler3A94[0x2A4];
u32 unkArray[4][3];
};