diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/berry.h | 33 | ||||
-rw-r--r-- | include/constants/easy_chat.h | 1 | ||||
-rw-r--r-- | include/constants/global.h | 95 | ||||
-rw-r--r-- | include/global.fieldmap.h | 23 | ||||
-rw-r--r-- | include/global.h | 326 | ||||
-rw-r--r-- | include/mail.h | 2 | ||||
-rw-r--r-- | include/mail_data.h | 10 | ||||
-rw-r--r-- | include/mevent.h | 22 | ||||
-rw-r--r-- | include/mevent_server.h | 4 | ||||
-rw-r--r-- | include/mystery_event_script.h | 1 | ||||
-rw-r--r-- | include/pokemon.h | 2 | ||||
-rw-r--r-- | include/trade.h | 2 |
12 files changed, 228 insertions, 293 deletions
diff --git a/include/berry.h b/include/berry.h index d1efa0abf..359849101 100644 --- a/include/berry.h +++ b/include/berry.h @@ -25,45 +25,12 @@ enum #define NUM_BERRIES 44 -extern const u8 *const gBerryTreeObjectEventGraphicsIdTablePointers[NUM_BERRIES]; -extern const struct SpriteFrameImage *const gBerryTreePicTablePointers[NUM_BERRIES]; -extern const u8 *const gBerryTreePaletteSlotTablePointers[NUM_BERRIES]; - void ClearEnigmaBerries(void); void SetEnigmaBerry(u8 *src); -u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry); bool32 IsEnigmaBerryValid(void); const struct Berry *GetBerryInfo(u8 berry); -struct BerryTree *GetBerryTreeInfo(u8 id); -bool32 ObjectEventInteractionWaterBerryTree(void); -bool8 IsPlayerFacingPlantedBerryTree(void); -bool8 TryToWaterBerryTree(void); -void ClearBerryTrees(void); -bool32 BerryTreeGrow(struct BerryTree *tree); -void BerryTreeTimeUpdate(s32 minutes); -void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle); -void RemoveBerryTree(u8 id); -u8 GetBerryTypeByBerryTreeId(u8 id); -u8 GetStageByBerryTreeId(u8); u8 ItemIdToBerryType(u16 item); -u16 BerryTypeToItemId(u16 berry); void GetBerryNameByBerryType(u8 berry, u8 *string); -void ResetBerryTreeSparkleFlag(u8 id); -u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree); -u8 GetNumStagesWateredByBerryTreeId(u8 id); -u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water); -u8 CalcBerryYield(struct BerryTree *tree); -u8 GetBerryCountByBerryTreeId(u8 id); -u16 GetStageDurationByBerryType(u8); -void Bag_ChooseBerry(void); -void ObjectEventInteractionGetBerryTreeData(void); -void ObjectEventInteractionPlantBerryTree(void); -void ObjectEventInteractionPickBerryTree(void); -void ObjectEventInteractionRemoveBerryTree(void); -u8 PlayerHasBerries(void); -void ResetBerryTreeSparkleFlags(void); -void ClearEnigmaBerries(void); -const struct Berry * GetBerryInfo(u8 berryIdx); extern const struct Berry gBerries[]; diff --git a/include/constants/easy_chat.h b/include/constants/easy_chat.h index b43e93da2..982b79d2d 100644 --- a/include/constants/easy_chat.h +++ b/include/constants/easy_chat.h @@ -1077,6 +1077,7 @@ #define EC_WORD_OLD (EC_GROUP_TRENDY_SAYING << 9) | 0x1e #define EC_WORD_YOUNG (EC_GROUP_TRENDY_SAYING << 9) | 0x1f #define EC_WORD_UGLY (EC_GROUP_TRENDY_SAYING << 9) | 0x20 +#define NUM_ADDITIONAL_PHRASES 33 #define EC_POKEMON(mon) ((EC_GROUP_POKEMON << 9) | SPECIES_##mon) #define EC_POKEMON2(mon) ((EC_GROUP_POKEMON_2 << 9) | SPECIES_##mon) diff --git a/include/constants/global.h b/include/constants/global.h index 689848912..caee324aa 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -1,36 +1,77 @@ #ifndef GUARD_CONSTANTS_GLOBAL_H #define GUARD_CONSTANTS_GLOBAL_H - -#define ITEM_NAME_LENGTH 14 -#define POKEMON_NAME_LENGTH 10 -#define OT_NAME_LENGTH 7 -#define MOVE_NAME_LENGTH 12 - -#define VERSION_SAPPHIRE 1 -#define VERSION_RUBY 2 -#define VERSION_EMERALD 3 -#define VERSION_FIRE_RED 4 -#define VERSION_LEAF_GREEN 5 - -#define LANGUAGE_JAPANESE 1 -#define LANGUAGE_ENGLISH 2 -#define LANGUAGE_FRENCH 3 -#define LANGUAGE_ITALIAN 4 -#define LANGUAGE_GERMAN 5 - // 6 goes unused but the theory is it was meant to be Korean -#define LANGUAGE_SPANISH 7 +// Invalid Versions show as "----------" in Gen 4 and Gen 5's summary screen. +// In Gens 6 and 7, invalid versions instead show "a distant land" in the summary screen. +// In Gen 4 only, migrated Pokemon with Diamond, Pearl, or Platinum's ID show as "----------". +// Gen 5 and up read Diamond, Pearl, or Platinum's ID as "Sinnoh". +// In Gen 4 and up, migrated Pokemon with HeartGold or SoulSilver's ID show the otherwise unused "Johto" string. +#define VERSION_SAPPHIRE 1 +#define VERSION_RUBY 2 +#define VERSION_EMERALD 3 +#define VERSION_FIRE_RED 4 +#define VERSION_LEAF_GREEN 5 +#define VERSION_HEART_GOLD 7 +#define VERSION_SOUL_SILVER 8 +#define VERSION_DIAMOND 10 +#define VERSION_PEARL 11 +#define VERSION_PLATINUM 12 +#define VERSION_GAMECUBE 15 + +#define LANGUAGE_JAPANESE 1 +#define LANGUAGE_ENGLISH 2 +#define LANGUAGE_FRENCH 3 +#define LANGUAGE_ITALIAN 4 +#define LANGUAGE_GERMAN 5 +#define LANGUAGE_KOREAN 6 // 6 goes unused but the theory is it was meant to be Korean +#define LANGUAGE_SPANISH 7 +#define NUM_LANGUAGES 7 #ifdef ENGLISH #define GAME_LANGUAGE (LANGUAGE_ENGLISH) #endif +#define DAYCARE_MON_COUNT 2 #define PC_ITEMS_COUNT 30 #define BAG_ITEMS_COUNT 42 #define BAG_KEYITEMS_COUNT 30 #define BAG_POKEBALLS_COUNT 13 #define BAG_TMHM_COUNT 58 #define BAG_BERRIES_COUNT 43 +#define OBJECT_EVENTS_COUNT 16 #define OBJECT_EVENT_TEMPLATES_COUNT 64 +#define MAIL_COUNT (PARTY_SIZE + 10) +#define PC_MAIL_NUM(i) (PARTY_SIZE + (i)) +#define DECOR_MAX_SECRET_BASE 16 +#define MAX_REMATCH_ENTRIES 100 +#define UNION_ROOM_KB_ROW_COUNT 10 +#define GIFT_RIBBONS_COUNT 11 + +#define POCKET_ITEMS 1 +#define POCKET_KEY_ITEMS 2 +#define POCKET_POKE_BALLS 3 +#define POCKET_TM_CASE 4 +#define POCKET_BERRY_POUCH 5 +#define NUM_BAG_POCKETS 5 + +// string lengths +#define ITEM_NAME_LENGTH 14 +#define POKEMON_NAME_LENGTH 10 +#define PLAYER_NAME_LENGTH 7 +#define MAIL_WORDS_COUNT 9 +#define EASY_CHAT_BATTLE_WORDS_COUNT 6 +#define MOVE_NAME_LENGTH 12 +#define NUM_QUESTIONNAIRE_WORDS 4 +#define WONDER_CARD_TEXT_LENGTH 40 +#define WONDER_NEWS_TEXT_LENGTH 40 +#define WONDER_CARD_BODY_TEXT_LINES 4 +#define WONDER_NEWS_BODY_TEXT_LINES 10 + +#define MAX_STAMP_CARD_STAMPS 7 + +#define TRAINER_ID_LENGTH 4 +#define MAX_MON_MOVES 4 +#define PARTY_SIZE 6 +#define MULTI_PARTY_SIZE (PARTY_SIZE / 2) #define QUEST_LOG_SCENE_COUNT 4 @@ -43,6 +84,8 @@ #define BARD_SONG_LENGTH 6 #define NUM_STORYTELLER_TALES 4 #define NUM_TRADER_ITEMS 4 +#define GIDDY_MAX_TALES 10 +#define GIDDY_MAX_QUESTIONS 8 #define OPTIONS_BUTTON_MODE_HELP 0 #define OPTIONS_BUTTON_MODE_LR 1 @@ -58,20 +101,6 @@ #define OPTIONS_BATTLE_STYLE_SHIFT 0 #define OPTIONS_BATTLE_STYLE_SET 1 -#define POCKET_ITEMS 1 -#define POCKET_KEY_ITEMS 2 -#define POCKET_POKE_BALLS 3 -#define POCKET_TM_CASE 4 -#define POCKET_BERRY_POUCH 5 - -#define NUM_BAG_POCKETS 5 - -#define MAX_MON_MOVES 4 - -#define TRAINER_ID_LENGTH 4 -#define PARTY_SIZE 6 -#define MULTI_PARTY_SIZE (PARTY_SIZE / 2) - #define DIR_NONE 0 #define DIR_SOUTH 1 #define DIR_NORTH 2 diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index c57146445..1be9277f4 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -1,8 +1,6 @@ #ifndef GUARD_GLOBAL_FIELDMAP_H #define GUARD_GLOBAL_FIELDMAP_H -#define OBJECT_EVENTS_COUNT 16 - #define METATILE_BEHAVIOR_MASK 0x00FF #define METATILE_COLLISION_MASK 0x0C00 #define METATILE_ID_MASK 0x03FF @@ -63,7 +61,7 @@ struct Tileset /*0x08*/ void *palettes; /*0x0c*/ void *metatiles; /*0x10*/ TilesetCB callback; - /*0x14*/ void *metatileAttributes; + /*0x14*/ u32 *metatileAttributes; }; struct MapLayout @@ -134,7 +132,6 @@ struct BgEvent u32 isUnderfoot:1; } hiddenItemStr; u32 hiddenItem; - u32 secretBaseId; } bgUnion; }; @@ -144,7 +141,6 @@ struct MapEvents u8 warpCount; u8 coordEventCount; u8 bgEventCount; - struct ObjectEventTemplate *objectEvents; struct WarpEvent *warps; struct CoordEvent *coordEvents; @@ -177,20 +173,15 @@ struct MapHeader /* 0x15 */ u8 cave; /* 0x16 */ u8 weather; /* 0x17 */ u8 mapType; + // fields correspond to the arguments in the map_header_flags macro /* 0x18 */ bool8 bikingAllowed; - /* 0x19 */ u8 flags; + /* 0x19 */ bool8 allowEscaping:1; // Escape Rope and Dig + bool8 allowRunning:1; + bool8 showMapName:6; // the last 5 bits are unused /* 0x1A */ s8 floorNum; /* 0x1B */ u8 battleType; }; -// Flags for gMapHeader.flags, as defined in the map_header_flags macro -#define MAP_ALLOW_ESCAPE_ROPE (1 << 0) -#define MAP_ALLOW_RUN (1 << 1) -#define MAP_SHOW_MAP_NAME (1 << 2) -#define UNUSED_MAP_FLAGS (1 << 3 | 1 << 4 | 1 << 5 | 1 << 6 | 1 << 7) - -#define SHOW_MAP_NAME_ENABLED ((gMapHeader.flags & (MAP_SHOW_MAP_NAME | UNUSED_MAP_FLAGS)) == MAP_SHOW_MAP_NAME) - struct ObjectEvent { /*0x00*/ /* 0*/ u32 active:1; @@ -319,7 +310,7 @@ enum COLLISION_STOP_SURFING, COLLISION_LEDGE_JUMP, COLLISION_PUSHED_BOULDER, - COLLISION_UNKNOWN_WARP_6C_6D_6E_6F, + COLLISION_ROTATING_GATE, COLLISION_WHEELIE_HOP, COLLISION_ISOLATED_VERTICAL_RAIL, COLLISION_ISOLATED_HORIZONTAL_RAIL, @@ -344,7 +335,7 @@ enum T_TILE_CENTER, // player is on a frame in which they are centered on a tile during which the player either stops or keeps their momentum and keeps going, changing direction if necessary. }; -struct PlayerAvatar /* 0x202E858 */ +struct PlayerAvatar { /*0x00*/ u8 flags; /*0x01*/ u8 transitionFlags; // used to be bike, but it's not that in Emerald and probably isn't here either. maybe transition flags? diff --git a/include/global.h b/include/global.h index 597e7ce57..533b54a4d 100644 --- a/include/global.h +++ b/include/global.h @@ -8,6 +8,7 @@ #include "constants/flags.h" #include "constants/vars.h" #include "constants/species.h" +#include "constants/easy_chat.h" // Prevent cross-jump optimization. #define BLOCK_CROSS_JUMP asm(""); @@ -30,7 +31,10 @@ #define INCBIN_S32 INCBIN #endif // IDE support -#define NELEMS(array) (sizeof(array) / sizeof((array)[0])) +#define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0])) + +// Alias of ARRAY_COUNT using GameFreak's name from AgbAssert calls. +#define NELEMS(array) ARRAY_COUNT(array) #define SWAP(a, b, temp) \ { \ @@ -80,6 +84,12 @@ #define SAFE_DIV(a, b) ((a) / (b)) #endif +// Extracts the upper 16 bits of a 32-bit number +#define HIHALF(n) (((n) & 0xFFFF0000) >> 16) + +// Extracts the lower 16 bits of a 32-bit number +#define LOHALF(n) ((n) & 0xFFFF) + // There are many quirks in the source code which have overarching behavioral differences from // a number of other files. For example, diploma.c seems to declare rodata before each use while // other files declare out of order and must be at the beginning. There are also a number of @@ -100,23 +110,24 @@ // 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) -#define JOY_REPT(button) TEST_BUTTON(gMain.newAndRepeatedKeys, button) +#define JOY_NEW(button) TEST_BUTTON(gMain.newKeys, button) +#define JOY_HELD(button) TEST_BUTTON(gMain.heldKeys, button) +#define JOY_HELD_RAW(button) TEST_BUTTON(gMain.heldKeysRaw, button) +#define JOY_REPT(button) TEST_BUTTON(gMain.newAndRepeatedKeys, button) extern u8 gStringVar1[]; extern u8 gStringVar2[]; extern u8 gStringVar3[]; extern u8 gStringVar4[]; -#define ROUND_BITS_TO_BYTES(numBits)(((numBits) / 8) + (((numBits) % 8) ? 1 : 0)) +#define DIV_ROUND_UP(val, roundBy)(((val) / (roundBy)) + (((val) % (roundBy)) ? 1 : 0)) -#define DEX_FLAGS_NO (ROUND_BITS_TO_BYTES(NUM_SPECIES)) -#define NUM_FLAG_BYTES (ROUND_BITS_TO_BYTES(FLAGS_COUNT)) +#define ROUND_BITS_TO_BYTES(numBits) DIV_ROUND_UP(numBits, 8) + +#define DEX_FLAGS_NO ROUND_BITS_TO_BYTES(NUM_SPECIES) +#define NUM_FLAG_BYTES ROUND_BITS_TO_BYTES(FLAGS_COUNT) +#define NUM_ADDITIONAL_PHRASE_BYTES ROUND_BITS_TO_BYTES(NUM_ADDITIONAL_PHRASES) struct Coords8 { @@ -175,13 +186,13 @@ struct Pokedex /*0x44*/ u8 seen[DEX_FLAGS_NO]; }; -struct PokemonJumpResults // possibly used in the game itself? +struct PokemonJumpRecords { u16 jumpsInRow; - u16 field2; + u16 unused1; // Set to 0, never read u16 excellentsInRow; - u16 field6; - u32 field8; + u16 gamesWithMaxPlayers; + u32 unused2; // Set to 0, never read u32 bestJumpScore; }; @@ -202,13 +213,11 @@ struct BerryPickingResults // possibly used in the game itself? Size may be wron struct BerryCrush { - u16 berryCrushResults[4]; + u16 pressingSpeeds[4]; // For the record with each possible group size, 2-5 players u32 berryPowderAmount; u32 unk; }; -#define PLAYER_NAME_LENGTH 7 - #define LINK_B_RECORDS_COUNT 5 struct LinkBattleRecord @@ -226,6 +235,20 @@ struct LinkBattleRecords u8 languages[LINK_B_RECORDS_COUNT]; }; +struct RecordMixingGiftData +{ + u8 unk0; + u8 quantity; + u16 itemId; + u8 filler4[8]; +}; + +struct RecordMixingGift +{ + int checksum; + struct RecordMixingGiftData data; +}; + #include "constants/game_stat.h" #include "global.fieldmap.h" #include "global.berry.h" @@ -236,9 +259,9 @@ struct BattleTowerRecord // record mixing /*0x00*/ u8 battleTowerLevelType; // 0 = level 50, 1 = level 100 /*0x01*/ u8 trainerClass; /*0x02*/ u16 winStreak; - /*0x04*/ u8 name[8]; - /*0x0C*/ u8 trainerId[4]; - /*0x10*/ u16 greeting[6]; + /*0x04*/ u8 name[PLAYER_NAME_LENGTH + 1]; + /*0x0C*/ u8 trainerId[TRAINER_ID_LENGTH]; + /*0x10*/ u16 greeting[EASY_CHAT_BATTLE_WORDS_COUNT]; /*0x1C*/ struct BattleTowerPokemon party[3]; /*0xA0*/ u32 checksum; }; @@ -289,7 +312,7 @@ struct SaveBlock2 /*0x000*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x008*/ u8 playerGender; // MALE, FEMALE /*0x009*/ u8 specialSaveWarpFlags; - /*0x00A*/ u8 playerTrainerId[4]; + /*0x00A*/ u8 playerTrainerId[TRAINER_ID_LENGTH]; /*0x00E*/ u16 playTimeHours; /*0x010*/ u8 playTimeMinutes; /*0x011*/ u8 playTimeSeconds; @@ -306,13 +329,13 @@ struct SaveBlock2 /*0x098*/ struct Time localTimeOffset; /*0x0A0*/ struct Time lastBerryTreeUpdate; /*0x0A8*/ u32 gcnLinkFlags; // Read by Pokemon Colosseum/XD - /*0x0AC*/ u8 field_AC; - /*0x0AD*/ u8 field_AD; + /*0x0AC*/ bool8 unkFlag1; // Set TRUE, never read + /*0x0AD*/ bool8 unkFlag2; // Set FALSE, never read /*0x0B0*/ struct BattleTowerData battleTower; /*0x898*/ u16 mapView[0x100]; /*0xA98*/ struct LinkBattleRecords linkBattleRecords; /*0xAF0*/ struct BerryCrush berryCrush; - /*0xB00*/ struct PokemonJumpResults pokeJump; + /*0xB00*/ struct PokemonJumpRecords pokeJump; /*0xB10*/ struct BerryPickingResults berryPick; /*0xB20*/ u8 filler_B20[0x400]; /*0xF20*/ u32 encryptionKey; @@ -323,28 +346,29 @@ extern struct SaveBlock2 *gSaveBlock2Ptr; struct SecretBaseParty { u32 personality[PARTY_SIZE]; - u16 moves[PARTY_SIZE * 4]; + u16 moves[PARTY_SIZE * MAX_MON_MOVES]; u16 species[PARTY_SIZE]; u16 heldItems[PARTY_SIZE]; u8 levels[PARTY_SIZE]; u8 EVs[PARTY_SIZE]; }; +// Leftover from R/S, still referenced in the unused function CreateSecretBaseEnemyParty struct SecretBaseRecord { /*0x1A9C*/ u8 secretBaseId; - /*0x1A9D*/ u8 sbr_field_1_0:4; + /*0x1A9D*/ u8 toRegister:4; /*0x1A9D*/ u8 gender:1; - /*0x1A9D*/ u8 sbr_field_1_5:1; - /*0x1A9D*/ u8 sbr_field_1_6:2; + /*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 sbr_field_e; - /*0x1AAC*/ u8 sbr_field_10; - /*0x1AAD*/ u8 sbr_field_11; - /*0x1AAE*/ u8 decorations[16]; - /*0x1ABE*/ u8 decorationPos[16]; + /*0x1AAA*/ u16 numSecretBasesReceived; + /*0x1AAC*/ u8 numTimesEntered; + /*0x1AAD*/ u8 unused; + /*0x1AAE*/ u8 decorations[DECOR_MAX_SECRET_BASE]; + /*0x1ABE*/ u8 decorationPos[DECOR_MAX_SECRET_BASE]; /*0x1AD0*/ struct SecretBaseParty party; }; @@ -405,24 +429,16 @@ struct RamScript struct RamScriptData data; }; -struct EasyChatPair +// Leftover from R/S +struct DewfordTrend { - u16 unk0_0:7; - u16 unk0_7:7; - u16 unk1_6:1; - u16 unk2; + u16 trendiness:7; + u16 maxTrendiness:7; + u16 gainingTrendiness:1; + u16 rand; u16 words[2]; }; /*size = 0x8*/ -struct MailStruct -{ - /*0x00*/ u16 words[9]; - /*0x12*/ u8 playerName[8]; - /*0x1A*/ u8 trainerId[4]; - /*0x1E*/ u16 species; - /*0x20*/ u16 itemId; -}; - struct MauvilleManCommon { u8 id; @@ -456,8 +472,8 @@ struct MauvilleManGiddy /*0x00*/ u8 id; /*0x01*/ u8 taleCounter; /*0x02*/ u8 questionNum; - /*0x04*/ u16 randomWords[10]; - /*0x18*/ u8 questionList[8]; + /*0x04*/ u16 randomWords[GIDDY_MAX_TALES]; + /*0x18*/ u8 questionList[GIDDY_MAX_QUESTIONS]; /*0x20*/ u8 language; }; /*size = 0x2C*/ @@ -488,49 +504,19 @@ typedef union OldMan u8 filler[0x40]; } OldMan; -struct RecordMixing_UnknownStructSub -{ - u32 unk0; - u8 data[0x34]; - //u8 data[0x38]; -}; - -struct RecordMixing_UnknownStruct -{ - struct RecordMixing_UnknownStructSub data[2]; - u32 unk70; - u16 unk74[0x2]; -}; - -struct RecordMixingGiftData -{ - u8 unk0; - u8 quantity; - u16 itemId; - u8 filler4[8]; -}; - -struct RecordMixingGift -{ - int checksum; - struct RecordMixingGiftData data; -}; - -struct ContestWinner +struct Mail { - u32 personality; - u32 trainerId; - u16 species; - u8 contestCategory; - u8 monName[11]; - u8 trainerName[8]; - u8 contestRank; + /*0x00*/ u16 words[MAIL_WORDS_COUNT]; + /*0x12*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; + /*0x1A*/ u8 trainerId[TRAINER_ID_LENGTH]; + /*0x1E*/ u16 species; + /*0x20*/ u16 itemId; }; struct DayCareMail { - struct MailStruct message; - u8 OT_name[OT_NAME_LENGTH + 1]; + struct Mail message; + u8 OT_name[PLAYER_NAME_LENGTH + 1]; u8 monName[POKEMON_NAME_LENGTH + 1]; u8 gameLanguage:4; u8 monLanguage:4; @@ -543,8 +529,6 @@ struct DaycareMon u32 steps; }; -#define DAYCARE_MON_COUNT 2 - struct DayCare { struct DaycareMon mons[DAYCARE_MON_COUNT]; @@ -552,6 +536,7 @@ struct DayCare u8 stepCounter; }; +// Leftover from R/S, referenced in unused function InitDaycareMailRecordMixing struct RecordMixingDayCareMail { struct DayCareMail mail[DAYCARE_MON_COUNT]; @@ -559,14 +544,6 @@ struct RecordMixingDayCareMail bool16 holdsItem[DAYCARE_MON_COUNT]; }; -struct MENewsJisanStruct -{ - u8 unk_0_0:2; - u8 unk_0_2:3; - u8 unk_0_5:3; - u8 berry; -}; - struct QuestLogNPCData { u32 x:8; @@ -577,10 +554,6 @@ struct QuestLogNPCData u32 movementType:8; }; -#define BERRY_TREES_COUNT 128 -#define MAIL_COUNT (PARTY_SIZE + 10) -#define PC_MAIL_NUM(i) (PARTY_SIZE + (i)) - struct QuestLogObjectEvent { /*0x00*/ u8 active:1; @@ -646,70 +619,59 @@ struct FameCheckerSaveData u16 unk_0_E:2; }; -#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 MEWonderNewsData -{ - u16 newsId; - u8 shareState; - u8 unk_03; - u8 unk_04[40]; - u8 unk_2C[10][40]; -}; - -struct MEWonderNewsStruct +struct WonderNewsMetadata { - u32 crc; - struct MEWonderNewsData data; -}; - -struct MEWonderCardData -{ - u16 cardId; - u16 unk_02; - u32 unk_04; - u8 unk_08_0:2; - u8 unk_08_2:4; - u8 shareState:2; - u8 recvMonCapacity; - u8 unk_0A[40]; - u8 unk_32[40]; - u8 unk_5A[4][40]; - u8 unk_FA[40]; - u8 unk_122[40]; -}; - -struct MEWonderCardStruct -{ - u32 crc; - struct MEWonderCardData data; -}; - -struct MEventBuffer_3430_Sub -{ - u16 linkWins; - u16 linkLosses; - u16 linkTrades; - u16 unk_06; - u16 distributedMons[2][7]; // [0][x] = species - // [1][x] = ??? -}; - -struct MEventBuffer_3430 -{ - u32 crc; - struct MEventBuffer_3430_Sub data; + u8 unk_0_0:2; + u8 unk_0_2:3; + u8 unk_0_5:3; + u8 berry; }; -struct MEventBuffers +struct WonderNews { - /*0x000 0x3120*/ struct MEWonderNewsStruct menews; - /*0x1c0 0x32e0*/ struct MEWonderCardStruct mecard; - /*0x310 0x3430*/ struct MEventBuffer_3430 buffer_310; - /*0x338 0x3458*/ u16 ec_profile_maybe[4]; - /*0x340 0x3460*/ struct MENewsJisanStruct me_jisan; - /*0x344 0x3464*/ u32 unk_344[2][5]; + u16 newsId; + u8 sendType; // SEND_TYPE_* + u8 bgType; + u8 titleText[WONDER_NEWS_TEXT_LENGTH]; + u8 bodyText[WONDER_NEWS_BODY_TEXT_LINES][WONDER_NEWS_TEXT_LENGTH]; +}; + +struct WonderCard +{ + u16 flagId; // Event flag (sReceivedGiftFlags) + WONDER_CARD_FLAG_OFFSET + u16 iconSpecies; + u32 idNumber; + u8 type:2; // CARD_TYPE_* + u8 bgType:4; + u8 sendType:2; // SEND_TYPE_* + u8 maxStamps; + u8 titleText[WONDER_CARD_TEXT_LENGTH]; + u8 subtitleText[WONDER_CARD_TEXT_LENGTH]; + u8 bodyText[WONDER_CARD_BODY_TEXT_LINES][WONDER_CARD_TEXT_LENGTH]; + u8 footerLine1Text[WONDER_CARD_TEXT_LENGTH]; + u8 footerLine2Text[WONDER_CARD_TEXT_LENGTH]; +}; + +struct WonderCardMetadata +{ + u16 battlesWon; + u16 battlesLost; + u16 numTrades; + u16 iconSpecies; + u16 stampData[2][MAX_STAMP_CARD_STAMPS]; // First element is STAMP_SPECIES, second is STAMP_ID +}; + +struct MysteryGiftSave +{ + u32 newsCrc; + struct WonderNews news; + u32 cardCrc; + struct WonderCard card; + u32 cardMetadataCrc; + struct WonderCardMetadata cardMetadata; + u16 questionnaireWords[NUM_QUESTIONNAIRE_WORDS]; + struct WonderNewsMetadata newsMetadata; + u32 trainerIds[2][5]; // Saved ids for 10 trainers, 5 each for battles and trades }; // 0x36C 0x348C struct TrainerTower @@ -726,12 +688,6 @@ struct TrainerTower bool8 validated:1; }; -struct TrainerRematchState -{ - u16 stepCounter; - u8 rematches[100]; -}; - struct TrainerNameRecord { u32 trainerId; @@ -784,8 +740,6 @@ struct ExternalEventFlags } __attribute__((packed));/*size = 0x15*/ -#define UNION_ROOM_KB_ROW_COUNT 10 - struct SaveBlock1 { /*0x0000*/ struct Coords16 pos; @@ -812,41 +766,41 @@ struct SaveBlock1 /*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? + /*0x0632*/ u8 unused_632[6]; /*0x0638*/ u16 trainerRematchStepCounter; - /*0x063A*/ u8 ALIGNED(2) trainerRematches[100]; + /*0x063A*/ u8 ALIGNED(2) trainerRematches[MAX_REMATCH_ENTRIES]; /*0x06A0*/ struct ObjectEvent objectEvents[OBJECT_EVENTS_COUNT]; - /*0x08E0*/ struct ObjectEventTemplate objectEventTemplates[64]; + /*0x08E0*/ struct ObjectEventTemplate objectEventTemplates[OBJECT_EVENT_TEMPLATES_COUNT]; /*0x0EE0*/ u8 flags[NUM_FLAG_BYTES]; /*0x1000*/ u16 vars[VARS_COUNT]; /*0x1200*/ u32 gameStats[NUM_GAME_STATS]; /*0x1300*/ struct QuestLog questLog[QUEST_LOG_SCENE_COUNT]; - /*0x2CA0*/ u16 easyChatProfile[6]; - /*0x2CAC*/ u16 easyChatBattleStart[6]; - /*0x2CB8*/ u16 easyChatBattleWon[6]; - /*0x2CC4*/ u16 easyChatBattleLost[6]; - /*0x2CD0*/ struct MailStruct mail[MAIL_COUNT]; - /*0x2F10*/ u8 additionalPhrases[EASY_CHAT_EXTRA_PHRASES_SIZE]; + /*0x2CA0*/ u16 easyChatProfile[EASY_CHAT_BATTLE_WORDS_COUNT]; + /*0x2CAC*/ u16 easyChatBattleStart[EASY_CHAT_BATTLE_WORDS_COUNT]; + /*0x2CB8*/ u16 easyChatBattleWon[EASY_CHAT_BATTLE_WORDS_COUNT]; + /*0x2CC4*/ u16 easyChatBattleLost[EASY_CHAT_BATTLE_WORDS_COUNT]; + /*0x2CD0*/ struct Mail mail[MAIL_COUNT]; + /*0x2F10*/ u8 additionalPhrases[NUM_ADDITIONAL_PHRASE_BYTES]; /*0x2F18*/ OldMan oldMan; // unused - /*0x2F54*/ struct EasyChatPair easyChatPairs[5]; // unused + /*0x2F54*/ struct DewfordTrend dewfordTrends[5]; // unused /*0x2F80*/ struct DayCare daycare; - /*0x309C*/ u8 giftRibbons[11]; + /*0x309C*/ u8 giftRibbons[GIFT_RIBBONS_COUNT]; /*0x30A7*/ struct ExternalEventData externalEventData; /*0x30BB*/ struct ExternalEventFlags externalEventFlags; /*0x30D0*/ struct Roamer roamer; /*0x30EC*/ struct EnigmaBerry enigmaBerry; - /*0x3120*/ struct MEventBuffers mysteryEventBuffers; - /*0x348C*/ u8 filler_348C[400]; + /*0x3120*/ struct MysteryGiftSave mysteryGift; + /*0x348C*/ u8 unused_348C[400]; /*0x361C*/ struct RamScript ramScript; - /*0x3A08*/ u8 filler3A08[16]; + /*0x3A08*/ struct RecordMixingGift recordMixingGift; // unused /*0x3A18*/ u8 seen2[DEX_FLAGS_NO]; /*0x3A4C*/ u8 rivalName[PLAYER_NAME_LENGTH + 1]; /*0x3A54*/ struct FameCheckerSaveData fameChecker[NUM_FAMECHECKER_PERSONS]; - /*0x3A94*/ u8 filler3A94[0x40]; + /*0x3A94*/ u8 unused_3A94[64]; /*0x3AD4*/ u8 registeredTexts[UNION_ROOM_KB_ROW_COUNT][21]; /*0x3BA8*/ struct TrainerNameRecord trainerNameRecords[20]; /*0x3C98*/ struct DaycareMon route5DayCareMon; - /*0x3D24*/ u8 filler3D24[0x10]; + /*0x3D24*/ u8 unused_3D24[16]; /*0x3D34*/ u32 towerChallengeId; /*0x3D38*/ struct TrainerTower trainerTower[NUM_TOWER_CHALLENGE_TYPES]; }; // size: 0x3D68 diff --git a/include/mail.h b/include/mail.h index ca2fbfcc8..e2b6be8c8 100644 --- a/include/mail.h +++ b/include/mail.h @@ -22,6 +22,6 @@ #define ITEM_TO_MAIL(itemId) (itemId - FIRST_MAIL_IDX) -void ReadMail(struct MailStruct * mail, void (*savedCallback)(void), bool8 messageExists); +void ReadMail(struct Mail * mail, void (*savedCallback)(void), bool8 messageExists); #endif // GUARD_MAIL_H diff --git a/include/mail_data.h b/include/mail_data.h index a5795ed7e..79be06c33 100644 --- a/include/mail_data.h +++ b/include/mail_data.h @@ -3,19 +3,13 @@ #include "global.h" -// Exported type declarations - -// Exported RAM declarations - -// Exported ROM declarations - void ClearMailData(void); -void ClearMailStruct(struct MailStruct *mail); +void ClearMailStruct(struct Mail *mail); bool8 MonHasMail(struct Pokemon *mon); u8 GiveMailToMon(struct Pokemon *mon, u16 itemId); u16 SpeciesToMailSpecies(u16 species, u32 personality); u16 MailSpeciesToSpecies(u16 mailSpecies, u16 *buffer); -u8 GiveMailToMon2(struct Pokemon *mon, struct MailStruct *mail); +u8 GiveMailToMon2(struct Pokemon *mon, struct Mail *mail); void TakeMailFromMon(struct Pokemon *mon); void ClearMailItemId(u8 mailId); u8 TakeMailFromMon2(struct Pokemon *mon); diff --git a/include/mevent.h b/include/mevent.h index 4f3e365f7..28920b118 100644 --- a/include/mevent.h +++ b/include/mevent.h @@ -12,7 +12,7 @@ struct MEventClientHeaderStruct u32 unk_10; u16 id; u16 unk_16[4]; - struct MEventBuffer_3430_Sub unk_20; + struct WonderCardMetadata unk_20; u8 maxDistributionMons; u8 playerName[7]; u8 playerTrainerId[4]; @@ -50,16 +50,16 @@ extern const u16 gCard3Pal[]; extern const u16 gCard4Pal[]; extern const u16 gCard5Pal[]; -struct MEWonderNewsData * GetSavedWonderNews(void); -struct MEWonderCardData * GetSavedWonderCard(void); -struct MEventBuffer_3430_Sub * sav1_get_mevent_buffer_2(void); -struct MENewsJisanStruct * GetMENewsJisanStructPtr(void); -bool32 OverwriteSavedWonderNewsWithReceivedNews(const struct MEWonderNewsData * src); +struct WonderNews * GetSavedWonderNews(void); +struct WonderCard * GetSavedWonderCard(void); +struct WonderCardMetadata * sav1_get_mevent_buffer_2(void); +struct WonderNewsMetadata * GetMENewsJisanStructPtr(void); +bool32 OverwriteSavedWonderNewsWithReceivedNews(const struct WonderNews * src); bool32 ValidateReceivedWonderNews(void); bool32 ValidateReceivedWonderCard(void); bool32 MEvent_HaveAlreadyReceivedWonderNews(const u8 * src); -bool32 OverwriteSavedWonderCardWithReceivedCard(const struct MEWonderCardData * data); -void MEvent_WonderCardResetUnk08_6(struct MEWonderCardData * buffer); +bool32 OverwriteSavedWonderCardWithReceivedCard(const struct WonderCard * data); +void MEvent_WonderCardResetUnk08_6(struct WonderCard * buffer); bool32 MEvent_ReceiveDistributionMon(const u16 * data); void BuildMEventClientHeader(struct MEventClientHeaderStruct * data); bool32 ValidateMEventClientHeader(const struct MEventClientHeaderStruct * data); @@ -67,8 +67,8 @@ u32 sub_8144418(const u16 * a0, const struct MEventClientHeaderStruct * a1, void u32 MEvent_CanPlayerReceiveDistributionMon(const u16 * a0, const struct MEventClientHeaderStruct * a1, void * unused); bool32 sub_8144474(const struct MEventClientHeaderStruct * a0, const u16 * a1); u16 sub_81444B0(const struct MEventClientHeaderStruct * a0, u32 command); -bool32 InitWonderCardResources(struct MEWonderCardData * r5, struct MEventBuffer_3430_Sub * r6); -bool32 InitWonderNewsResources(const struct MEWonderNewsData * a0); +bool32 InitWonderCardResources(struct WonderCard * r5, struct WonderCardMetadata * r6); +bool32 InitWonderNewsResources(const struct WonderNews * a0); s32 FadeToWonderCardMenu(void); s32 FadeToWonderNewsMenu(void); void DestroyWonderCard(void); @@ -88,7 +88,7 @@ u16 MEvent_GetBattleCardCount(u32 command); void MEvent_RecordIdOfWonderCardSenderByEventType(u32 eventId, u32 trainerId); u16 *GetMEventProfileECWordsMaybe(void); void ResetReceivedWonderCardFlag(void); -bool32 MEventHandleReceivedWonderCard(u16 cardId); +bool32 MEventHandleReceivedWonderCard(u16 flagId); u16 GetWonderCardFlagId(void); #endif //GUARD_MEVENT_H diff --git a/include/mevent_server.h b/include/mevent_server.h index a7c7a3f23..17ece2f26 100644 --- a/include/mevent_server.h +++ b/include/mevent_server.h @@ -100,8 +100,8 @@ struct mevent_srv_common u32 cmdidx; const struct mevent_server_cmd * cmdBuffer; void * recvBuffer; - struct MEWonderCardData * card; - struct MEWonderNewsData * news; + struct WonderCard * card; + struct WonderNews * news; struct MEventClientHeaderStruct * mevent_unk1442cc; void * sendBuffer1; u32 sendBuffer1Size; diff --git a/include/mystery_event_script.h b/include/mystery_event_script.h index 8c59136c1..562df4a7b 100644 --- a/include/mystery_event_script.h +++ b/include/mystery_event_script.h @@ -5,7 +5,6 @@ u32 RunMysteryEventScript(u8 *); void SetMysteryEventScriptStatus(u32 val); -u16 GetRecordMixingGift(void); void MEventScript_InitContext(u8 *); bool32 MEventScript_Run(u32 *); diff --git a/include/pokemon.h b/include/pokemon.h index 8348b1178..6134064d0 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -96,7 +96,7 @@ struct BoxPokemon u8 hasSpecies:1; u8 isEgg:1; u8 unused:5; - u8 otName[OT_NAME_LENGTH]; + u8 otName[PLAYER_NAME_LENGTH]; u8 markings; u16 checksum; u16 unknown; diff --git a/include/trade.h b/include/trade.h index 04ea9406b..036c470a1 100644 --- a/include/trade.h +++ b/include/trade.h @@ -5,7 +5,7 @@ #include "link_rfu.h" #include "constants/trade.h" -extern struct MailStruct gLinkPartnerMail[6]; +extern struct Mail gLinkPartnerMail[6]; extern u8 gSelectedTradeMonPositions[2]; extern const u8 gText_MaleSymbol4[]; |