diff options
Diffstat (limited to 'include/global.h')
-rw-r--r-- | include/global.h | 98 |
1 files changed, 51 insertions, 47 deletions
diff --git a/include/global.h b/include/global.h index 969680dd7..a82fe5861 100644 --- a/include/global.h +++ b/include/global.h @@ -2,6 +2,7 @@ #define GUARD_GLOBAL_H #include <string.h> +#include <limits.h> #include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines. #include "gba/gba.h" #include "constants/global.h" @@ -18,16 +19,23 @@ #if defined (__APPLE__) || defined (__CYGWIN__) || defined (_MSC_VER) #define _(x) x #define __(x) x -#define INCBIN_U8 {0} -#define INCBIN_U16 {0} -#define INCBIN_U32 {0} -#define INCBIN_S8 {0} -#define INCBIN_S16 {0} -#define INCBIN_S32 {0} + +// 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 #endif // IDE support #define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0])) +// GameFreak used a macro called "NELEMS", as evidenced by +// AgbAssert calls. +#define NELEMS(arr) (sizeof(arr)/sizeof(*(arr))) + #define SWAP(a, b, temp) \ { \ temp = a; \ @@ -62,6 +70,10 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) +#if MODERN +#define abs(x) (((x) < 0) ? -(x) : (x)) +#endif + // Extracts the upper 16 bits of a 32-bit number #define HIHALF(n) (((n) & 0xFFFF0000) >> 16) @@ -158,18 +170,17 @@ struct Pokedex /*0x44*/ u8 seen[DEX_FLAGS_NO]; }; -struct PokemonJumpResults // possibly used in the game itself? +struct PokemonJumpResults { u16 jumpsInRow; u16 field2; u16 excellentsInRow; u16 field6; - u16 field8; - u16 fieldA; + u32 field8; u32 bestJumpScore; }; -struct BerryPickingResults // possibly used in the game itself? Size may be wrong as well +struct BerryPickingResults { u32 bestScore; u16 berriesPicked; @@ -213,7 +224,7 @@ struct Apprentice u8 number; struct ApprenticeMon party[3]; u16 easyChatWords[6]; - u8 playerId[4]; + u8 playerId[TRAINER_ID_LENGTH]; u8 playerName[PLAYER_NAME_LENGTH]; u8 language; u32 checksum; @@ -252,7 +263,7 @@ struct EmeraldBattleTowerRecord /*0x01*/ u8 facilityClass; /*0x02*/ u16 winStreak; /*0x04*/ u8 name[PLAYER_NAME_LENGTH + 1]; - /*0x0C*/ u8 trainerId[4]; + /*0x0C*/ u8 trainerId[TRAINER_ID_LENGTH]; /*0x10*/ u16 greeting[6]; /*0x1C*/ u16 speechWon[6]; /*0x28*/ u16 speechLost[6]; @@ -267,7 +278,7 @@ struct BattleTowerEReaderTrainer /*0x01*/ u8 facilityClass; /*0x02*/ u16 winStreak; /*0x04*/ u8 name[PLAYER_NAME_LENGTH + 1]; - /*0x0C*/ u8 trainerId[4]; + /*0x0C*/ u8 trainerId[TRAINER_ID_LENGTH]; /*0x10*/ u16 greeting[6]; /*0x1C*/ u16 farewellPlayerLost[6]; /*0x28*/ u16 farewellPlayerWon[6]; @@ -414,7 +425,7 @@ struct PlayersApprentice struct RankingHall1P { - u8 id[4]; + u8 id[TRAINER_ID_LENGTH]; u16 winStreak; u8 name[PLAYER_NAME_LENGTH + 1]; u8 language; @@ -422,8 +433,8 @@ struct RankingHall1P struct RankingHall2P { - u8 id1[4]; - u8 id2[4]; + u8 id1[TRAINER_ID_LENGTH]; + u8 id2[TRAINER_ID_LENGTH]; u16 winStreak; u8 name1[PLAYER_NAME_LENGTH + 1]; u8 name2[PLAYER_NAME_LENGTH + 1]; @@ -435,7 +446,7 @@ struct SaveBlock2 /*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x08*/ u8 playerGender; // MALE, FEMALE /*0x09*/ u8 specialSaveWarpFlags; - /*0x0A*/ u8 playerTrainerId[4]; + /*0x0A*/ u8 playerTrainerId[TRAINER_ID_LENGTH]; /*0x0E*/ u16 playTimeHours; /*0x10*/ u8 playTimeMinutes; /*0x11*/ u8 playTimeSeconds; @@ -484,7 +495,7 @@ struct SecretBase /*0x1A9D*/ u8 battledOwnerToday:1; /*0x1A9D*/ u8 registryStatus:2; /*0x1A9E*/ u8 trainerName[PLAYER_NAME_LENGTH]; - /*0x1AA5*/ u8 trainerId[4]; // byte 0 is used for determining trainer class + /*0x1AA5*/ u8 trainerId[TRAINER_ID_LENGTH]; // byte 0 is used for determining trainer class /*0x1AA9*/ u8 language; /*0x1AAA*/ u16 numSecretBasesReceived; /*0x1AAC*/ u8 numTimesEntered; @@ -570,7 +581,7 @@ struct MailStruct { /*0x00*/ u16 words[MAIL_WORDS_COUNT]; /*0x12*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; - /*0x1A*/ u8 trainerId[4]; + /*0x1A*/ u8 trainerId[TRAINER_ID_LENGTH]; /*0x1E*/ u16 species; /*0x20*/ u16 itemId; }; @@ -587,7 +598,7 @@ struct MauvilleManBard /*0x0E*/ u16 temporaryLyrics[6]; /*0x1A*/ u8 playerName[8]; /*0x22*/ u8 filler_2DB6[0x3]; - /*0x25*/ u8 playerTrainerId[4]; + /*0x25*/ u8 playerTrainerId[TRAINER_ID_LENGTH]; /*0x29*/ bool8 hasChangedSong; /*0x2A*/ u8 language; }; /*size = 0x2C*/ @@ -726,50 +737,43 @@ struct RecordMixingDayCareMail bool16 holdsItem[DAYCARE_MON_COUNT]; }; -enum -{ - LILYCOVE_LADY_QUIZ, - LILYCOVE_LADY_FAVOUR, - LILYCOVE_LADY_CONTEST -}; - struct LilycoveLadyQuiz { /*0x000*/ u8 id; - /*0x001*/ u8 phase; - /*0x002*/ u16 unk_002[9]; - /*0x014*/ u16 unk_014; - /*0x016*/ u16 unk_016; + /*0x001*/ u8 state; + /*0x002*/ u16 question[9]; + /*0x014*/ u16 correctAnswer; + /*0x016*/ u16 playerAnswer; /*0x018*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; - /*0x020*/ u16 playerTrainerId[4]; - /*0x028*/ u16 itemId; - /*0x02a*/ u8 unk_02a; - /*0x02b*/ u8 unk_02b; - /*0x02c*/ u8 unk_02c; + /*0x020*/ u16 playerTrainerId[TRAINER_ID_LENGTH]; + /*0x028*/ u16 prize; + /*0x02a*/ bool8 waitingForChallenger; + /*0x02b*/ u8 questionId; + /*0x02c*/ u8 prevQuestionId; /*0x02d*/ u8 language; }; -struct LilycoveLadyFavour +struct LilycoveLadyFavor { /*0x000*/ u8 id; - /*0x001*/ u8 phase; - /*0x002*/ u8 unk_002; - /*0x003*/ u8 unk_003; + /*0x001*/ u8 state; + /*0x002*/ bool8 likedItem; + /*0x003*/ u8 numItemsGiven; /*0x004*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; - /*0x00c*/ u8 unk_00c; + /*0x00c*/ u8 favorId; /*0x00e*/ u16 itemId; - /*0x010*/ u16 unk_010; + /*0x010*/ u16 bestItem; /*0x012*/ u8 language; }; struct LilycoveLadyContest { /*0x000*/ u8 id; - /*0x001*/ u8 phase; - /*0x002*/ u8 fave_pkblk; - /*0x003*/ u8 other_pkblk; + /*0x001*/ bool8 givenPokeblock; + /*0x002*/ u8 numGoodPokeblocksGiven; + /*0x003*/ u8 numOtherPokeblocksGiven; /*0x004*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; - /*0x00c*/ u8 max_sheen; + /*0x00c*/ u8 maxSheen; /*0x00d*/ u8 category; /*0x00e*/ u8 language; }; @@ -777,7 +781,7 @@ struct LilycoveLadyContest typedef union // 3b58 { struct LilycoveLadyQuiz quiz; - struct LilycoveLadyFavour favour; + struct LilycoveLadyFavor favor; struct LilycoveLadyContest contest; u8 id; u8 pad[0x40]; |