diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/battle.h | 7 | ||||
-rw-r--r-- | include/decompress.h | 29 | ||||
-rw-r--r-- | include/event_data.h | 52 | ||||
-rw-r--r-- | include/flags.h | 93 | ||||
-rw-r--r-- | include/game_stat.h | 59 | ||||
-rw-r--r-- | include/gba/m4a_internal.h | 5 | ||||
-rw-r--r-- | include/global.berry.h | 57 | ||||
-rw-r--r-- | include/global.fieldmap.h | 389 | ||||
-rw-r--r-- | include/global.h | 621 | ||||
-rw-r--r-- | include/item.h | 62 | ||||
-rw-r--r-- | include/malloc.h | 8 | ||||
-rw-r--r-- | include/new_game.h | 12 | ||||
-rw-r--r-- | include/play_time.h | 10 | ||||
-rw-r--r-- | include/pokemon.h | 7 | ||||
-rw-r--r-- | include/rtc.h | 2 | ||||
-rw-r--r-- | include/save.h | 92 | ||||
-rw-r--r-- | include/songs.h | 374 | ||||
-rw-r--r-- | include/sound.h | 48 | ||||
-rw-r--r-- | include/sprite.h | 305 | ||||
-rw-r--r-- | include/text_window.h | 22 | ||||
-rw-r--r-- | include/trig.h | 11 | ||||
-rw-r--r-- | include/vars.h | 53 | ||||
-rw-r--r-- | include/window.h | 40 |
23 files changed, 2355 insertions, 3 deletions
diff --git a/include/battle.h b/include/battle.h index 741e821e9..d5c5dd489 100644 --- a/include/battle.h +++ b/include/battle.h @@ -7,7 +7,7 @@ #define BATTLE_TYPE_TRAINER 0x0008 #define BATTLE_TYPE_FIRST_BATTLE 0x0010 #define BATTLE_TYPE_20 0x0020 -#define BATTLE_TYPE_40 0x0040 +#define BATTLE_TYPE_MULTI 0x0040 #define BATTLE_TYPE_SAFARI 0x0080 #define BATTLE_TYPE_BATTLE_TOWER 0x0100 #define BATTLE_TYPE_WALLY_TUTORIAL 0x0200 @@ -16,6 +16,11 @@ #define BATTLE_TYPE_KYOGRE_GROUDON 0x1000 #define BATTLE_TYPE_LEGENDARY 0x2000 #define BATTLE_TYPE_REGI 0x4000 +#define BATTLE_TYPE_TWO_VS_ONE 0x8000 +#define BATTLE_TYPE_RECORDED 0x1000000 +#define BATTLE_TYPE_GROUDON 0x10000000 +#define BATTLE_TYPE_KYORGE 0x20000000 +#define BATTLE_TYPE_RAYQUAZA 0x40000000 #define AI_ACTION_UNK1 0x0001 #define AI_ACTION_UNK2 0x0002 diff --git a/include/decompress.h b/include/decompress.h new file mode 100644 index 000000000..6c925f730 --- /dev/null +++ b/include/decompress.h @@ -0,0 +1,29 @@ +#ifndef GUARD_DECOMPRESS_H +#define GUARD_DECOMPRESS_H + +#include "sprite.h" + +void LZDecompressWram(const void *src, void *dest); +void LZDecompressVram(const void *src, void *dest); + +u16 LoadCompressedObjectPic(const struct CompressedSpriteSheet *src); +void LoadCompressedObjectPicOverrideBuffer(const struct CompressedSpriteSheet *src, void *buffer); +bool8 LoadCompressedObjectPicUsingHeap(struct CompressedSpriteSheet* src); + +void LoadCompressedObjectPalette(const struct CompressedSpritePalette *src); +void LoadCompressedObjectPaletteOverrideBuffer(const struct CompressedSpritePalette *a, void *buffer); +bool8 LoadCompressedObjectPaletteUsingHeap(const struct CompressedSpritePalette *src); + +void DecompressPicFromTable(const struct CompressedSpriteSheet *src, void* buffer, s32 species); +void DecompressPicFromTable_2(const struct CompressedSpriteSheet *src, void* buffer, s32 species); +void DecompressPicFromTable_DontHandleDeoxys(const struct CompressedSpriteSheet *src, void* buffer, s32 species); + +void HandleLoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality); +void HandleLoadSpecialPokePic_2(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality); +void HandleLoadSpecialPokePic_DontHandleDeoxys(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality); + +void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic); +void LoadSpecialPokePic_2(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic); +void LoadSpecialPokePic_DontHandleDeoxys(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic); + +#endif // GUARD_DECOMPRESS_H diff --git a/include/event_data.h b/include/event_data.h new file mode 100644 index 000000000..a2a501283 --- /dev/null +++ b/include/event_data.h @@ -0,0 +1,52 @@ +#ifndef GUARD_EVENT_DATA_H +#define GUARD_EVENT_DATA_H + +#include "flags.h" +#include "vars.h" + +void InitEventData(void); +void ClearTempFieldEventData(void); +void ClearUpperFlags(void); +void DisableNationalPokedex(void); +void EnableNationalPokedex(void); +bool32 IsNationalPokedexEnabled(void); +void DisableMysteryEvent(void); +void EnableMysteryEvent(void); +bool32 IsMysteryEventEnabled(void); +void DisableMysteryGift(void); +void EnableMysteryGift(void); +bool32 IsMysteryGiftEnabled(void); +void sub_809D4D8(void); +void sub_809D570(void); +void DisableResetRTC(void); +void EnableResetRTC(void); +bool32 CanResetRTC(void); +u16 *GetVarPointer(u16 id); +u16 VarGet(u16 id); +bool8 VarSet(u16 id, u16 value); +u8 VarGetFieldObjectGraphicsId(u8 id); +u8 *GetFlagPointer(u16 id); +u8 FlagSet(u16 id); +u8 FlagReset(u16 id); +bool8 FlagGet(u16 id); + +extern u16 gSpecialVar_0x8000; +extern u16 gSpecialVar_0x8001; +extern u16 gSpecialVar_0x8002; +extern u16 gSpecialVar_0x8003; +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; +extern u16 gSpecialVar_0x8007; +extern u16 gSpecialVar_0x8008; +extern u16 gSpecialVar_0x8009; +extern u16 gSpecialVar_0x800A; +extern u16 gSpecialVar_0x800B; +extern u16 gScriptResult; +extern u16 gScriptLastTalked; +extern u16 gScriptFacing; +extern u16 gSpecialVar_0x8012; +extern u16 gSpecialVar_0x8013; +extern u16 gSpecialVar_0x8014; + +#endif // GUARD_EVENT_DATA_H diff --git a/include/flags.h b/include/flags.h new file mode 100644 index 000000000..56e87b895 --- /dev/null +++ b/include/flags.h @@ -0,0 +1,93 @@ +#ifndef GUARD_FLAGS_H +#define GUARD_FLAGS_H + +#define TRAINER_FLAG_START 0x500 +#define TRAINERS_FLAG_NO 0x360 +#define CODE_FLAGS (TRAINER_FLAG_START + TRAINERS_FLAG_NO) + +// SYSTEM FLAGS + +#define SYS_POKEMON_GET CODE_FLAGS + 0 +#define SYS_POKEDEX_GET CODE_FLAGS + 1 +#define SYS_POKENAV_GET CODE_FLAGS + 2 +// third one appears unused +#define SYS_GAME_CLEAR CODE_FLAGS + 4 +#define SYS_CHAT_USED CODE_FLAGS + 5 +#define SYS_HIPSTER_MEET CODE_FLAGS + 6 + +// badges +#define BADGE01_GET CODE_FLAGS + 7 +#define BADGE02_GET CODE_FLAGS + 8 +#define BADGE03_GET CODE_FLAGS + 9 +#define BADGE04_GET CODE_FLAGS + 0xA +#define BADGE05_GET CODE_FLAGS + 0xB +#define BADGE06_GET CODE_FLAGS + 0xC +#define BADGE07_GET CODE_FLAGS + 0xD +#define BADGE08_GET CODE_FLAGS + 0xE + +// cities and towns +#define FLAG_VISITED_LITTLEROOT_TOWN CODE_FLAGS + 0xF +#define FLAG_VISITED_OLDALE_TOWN CODE_FLAGS + 0x10 +#define FLAG_VISITED_DEWFORD_TOWN CODE_FLAGS + 0x11 +#define FLAG_VISITED_LAVARIDGE_TOWN CODE_FLAGS + 0x12 +#define FLAG_VISITED_FALLARBOR_TOWN CODE_FLAGS + 0x13 +#define FLAG_VISITED_VERDANTURF_TOWN CODE_FLAGS + 0x14 +#define FLAG_VISITED_PACIFIDLOG_TOWN CODE_FLAGS + 0x15 +#define FLAG_VISITED_PETALBURG_CITY CODE_FLAGS + 0x16 +#define FLAG_VISITED_SLATEPORT_CITY CODE_FLAGS + 0x17 +#define FLAG_VISITED_MAUVILLE_CITY CODE_FLAGS + 0x18 +#define FLAG_VISITED_RUSTBORO_CITY CODE_FLAGS + 0x19 +#define FLAG_VISITED_FORTREE_CITY CODE_FLAGS + 0x1A +#define FLAG_VISITED_LILYCOVE_CITY CODE_FLAGS + 0x1B +#define FLAG_VISITED_MOSSDEEP_CITY CODE_FLAGS + 0x1C +#define FLAG_VISITED_SOOTOPOLIS_CITY CODE_FLAGS + 0x1D +#define FLAG_VISITED_EVER_GRANDE_CITY CODE_FLAGS + 0x1E + +#define SYS_UNKNOWN_880 CODE_FLAGS + 0x20 + +#define SYS_USE_FLASH CODE_FLAGS + 0x28 +#define SYS_USE_STRENGTH CODE_FLAGS + 0x29 +#define SYS_WEATHER_CTRL CODE_FLAGS + 0x2A +#define SYS_CYCLING_ROAD CODE_FLAGS + 0x2B +#define SYS_SAFARI_MODE CODE_FLAGS + 0x2C +#define SYS_CRUISE_MODE CODE_FLAGS + 0x2D + +#define SYS_TV_HOME CODE_FLAGS + 0x30 +#define SYS_TV_WATCH CODE_FLAGS + 0x31 +#define SYS_TV_START CODE_FLAGS + 0x32 +#define SYS_POPWORD_INPUT CODE_FLAGS + 0x33 +#define SYS_MIX_RECORD CODE_FLAGS + 0x34 +#define SYS_CLOCK_SET CODE_FLAGS + 0x35 +#define SYS_NATIONAL_DEX CODE_FLAGS + 0x36 +#define SYS_CAVE_SHIP CODE_FLAGS + 0x37 +#define SYS_CAVE_WONDER CODE_FLAGS + 0x38 +#define SYS_CAVE_BATTLE CODE_FLAGS + 0x39 +#define SYS_SHOAL_TIDE CODE_FLAGS + 0x3A +#define SYS_RIBBON_GET CODE_FLAGS + 0x3B + +#define SYS_PC_LANETTE CODE_FLAGS + 0x4B +#define SYS_MYSTERY_EVENT_ENABLE CODE_FLAGS + 0x4C +#define SYS_ENC_UP_ITEM CODE_FLAGS + 0x4D +#define SYS_ENC_DOWN_ITEM CODE_FLAGS + 0x4E +#define SYS_BRAILLE_DIG CODE_FLAGS + 0x4F +#define SYS_BRAILLE_STRENGTH CODE_FLAGS + 0x50 +#define SYS_BRAILLE_WAIT CODE_FLAGS + 0x51 +#define SYS_BRAILLE_FLY CODE_FLAGS + 0x52 +#define SYS_HAS_EON_TICKET CODE_FLAGS + 0x53 + +#define SYS_POKEMON_LEAGUE_FLY CODE_FLAGS + 0x54 + +#define SYS_TV_LATI CODE_FLAGS + 0x5D + +#define SYS_SHOAL_ITEM CODE_FLAGS + 0x5F +#define SYS_B_DASH CODE_FLAGS + 0x60 // got Running Shoes +#define SYS_CTRL_OBJ_DELETE CODE_FLAGS + 0x61 +#define SYS_RESET_RTC_ENABLE CODE_FLAGS + 0x62 + +#define SYS_MYSTERY_GIFT_ENABLE CODE_FLAGS + 0x7B + +// SPECIAL FLAGS (unknown purpose) + +#define SPECIAL_FLAG_1 0x4001 + +#endif // GUARD_FLAGS_H diff --git a/include/game_stat.h b/include/game_stat.h new file mode 100644 index 000000000..b8a5c3232 --- /dev/null +++ b/include/game_stat.h @@ -0,0 +1,59 @@ +#ifndef GUARD_GAME_STAT_H +#define GUARD_GAME_STAT_H + +#define GAME_STAT_SAVED_GAME 0 +#define GAME_STAT_FIRST_HOF_PLAY_TIME 1 +#define GAME_STAT_STARTED_TRENDS 2 +#define GAME_STAT_PLANTED_BERRIES 3 +#define GAME_STAT_TRADED_BIKES 4 +#define GAME_STAT_STEPS 5 +#define GAME_STAT_GOT_INTERVIEWED 6 +#define GAME_STAT_TOTAL_BATTLES 7 +#define GAME_STAT_WILD_BATTLES 8 +#define GAME_STAT_TRAINER_BATTLES 9 +#define GAME_STAT_ENTERED_HOF 10 +#define GAME_STAT_POKEMON_CAPTURES 11 +#define GAME_STAT_FISHING_CAPTURES 12 +#define GAME_STAT_HATCHED_EGGS 13 +#define GAME_STAT_EVOLVED_POKEMON 14 +#define GAME_STAT_USED_POKECENTER 15 +#define GAME_STAT_RESTED_AT_HOME 16 +#define GAME_STAT_ENTERED_SAFARI_ZONE 17 +#define GAME_STAT_USED_CUT 18 +#define GAME_STAT_USED_ROCK_SMASH 19 +#define GAME_STAT_MOVED_SECRET_BASE 20 +#define GAME_STAT_POKEMON_TRADES 21 +#define GAME_STAT_UNKNOWN_22 22 +#define GAME_STAT_LINK_BATTLE_WINS 23 +#define GAME_STAT_LINK_BATTLE_LOSSES 24 +#define GAME_STAT_LINK_BATTLE_DRAWS 25 +#define GAME_STAT_USED_SPLASH 26 +#define GAME_STAT_USED_STRUGGLE 27 +#define GAME_STAT_SLOT_JACKPOTS 28 +#define GAME_STAT_CONSECUTIVE_ROULETTE_WINS 29 +#define GAME_STAT_ENTERED_BATTLE_TOWER 30 +#define GAME_STAT_UNKNOWN_31 31 +#define GAME_STAT_BATTLE_TOWER_BEST_STREAK 32 +#define GAME_STAT_POKEBLOCKS 33 +#define GAME_STAT_POKEBLOCKS_WITH_FRIENDS 34 +#define GAME_STAT_WON_LINK_CONTEST 35 +#define GAME_STAT_ENTERED_CONTEST 36 +#define GAME_STAT_WON_CONTEST 37 +#define GAME_STAT_SHOPPED 38 +#define GAME_STAT_USED_ITEMFINDER 39 +#define GAME_STAT_GOT_RAINED_ON 40 +#define GAME_STAT_CHECKED_POKEDEX 41 +#define GAME_STAT_RECEIVED_RIBBONS 42 +#define GAME_STAT_JUMPED_DOWN_LEDGES 43 +#define GAME_STAT_WATCHED_TV 44 +#define GAME_STAT_CHECKED_CLOCK 45 +#define GAME_STAT_WON_POKEMON_LOTTERY 46 +#define GAME_STAT_USED_DAYCARE 47 +#define GAME_STAT_RODE_CABLE_CAR 48 +#define GAME_STAT_ENTERED_HOT_SPRINGS 49 + +/*TODO: add new stats added in Emerald*/ + +#define NUM_GAME_STATS 64 + +#endif // GUARD_GAME_STAT_H diff --git a/include/gba/m4a_internal.h b/include/gba/m4a_internal.h index f5d44de99..6cdfd13e1 100644 --- a/include/gba/m4a_internal.h +++ b/include/gba/m4a_internal.h @@ -1,3 +1,6 @@ +#ifndef GUARD_GBA_M4A_INTERNAL_H +#define GUARD_GBA_M4A_INTERNAL_H + #include "gba/gba.h" // ASCII encoding of 'Smsh' in reverse @@ -460,3 +463,5 @@ void ply_xleng(struct MusicPlayerInfo *, struct MusicPlayerTrack *); void ply_xswee(struct MusicPlayerInfo *, struct MusicPlayerTrack *); void ply_xcmd_0C(struct MusicPlayerInfo *, struct MusicPlayerTrack *); void ply_xcmd_0D(struct MusicPlayerInfo *, struct MusicPlayerTrack *); + +#endif // GUARD_GBA_M4A_INTERNAL_H diff --git a/include/global.berry.h b/include/global.berry.h new file mode 100644 index 000000000..6632e55e2 --- /dev/null +++ b/include/global.berry.h @@ -0,0 +1,57 @@ +#ifndef GUARD_GLOBAL_BERRY_H +#define GUARD_GLOBAL_BERRY_H + +struct Berry +{ + const u8 name[7]; + u8 firmness; + u16 size; + u8 maxYield; + u8 minYield; + const u8 *description1; + const u8 *description2; + u8 stageDuration; + u8 spicy; + u8 dry; + u8 sweet; + u8 bitter; + u8 sour; + u8 smoothness; +}; + +struct EnigmaBerry +{ + struct Berry berry; + u8 pic[(6 * 6) * TILE_SIZE_4BPP]; + u16 palette[16]; + u8 description1[45]; + u8 description2[45]; + u8 itemEffect[18]; + u8 holdEffect; + u8 holdEffectParam; + u32 checksum; +}; + +struct BattleEnigmaBerry +{ + /*0x00*/ u8 name[7]; + /*0x07*/ u8 holdEffect; + /*0x08*/ u8 itemEffect[18]; + /*0x1A*/ u8 holdEffectParam; +}; + +struct BerryTree +{ + u8 berry; + u8 stage:7; + u8 growthSparkle:1; + u16 minutesUntilNextStage; + u8 berryYield; + u8 regrowthCount:4; + u8 watered1:1; + u8 watered2:1; + u8 watered3:1; + u8 watered4:1; +}; + +#endif // GUARD_GLOBAL_BERRY_H diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h new file mode 100644 index 000000000..4029132e8 --- /dev/null +++ b/include/global.fieldmap.h @@ -0,0 +1,389 @@ +#ifndef GUARD_GLOBAL_FIELDMAP_H +#define GUARD_GLOBAL_FIELDMAP_H + +enum +{ + CONNECTION_SOUTH = 1, + CONNECTION_NORTH, + CONNECTION_WEST, + CONNECTION_EAST, + CONNECTION_DIVE, + CONNECTION_EMERGE +}; + +// map types +enum +{ + MAP_TYPE_0, + MAP_TYPE_TOWN, + MAP_TYPE_CITY, + MAP_TYPE_ROUTE, + MAP_TYPE_UNDERGROUND, + MAP_TYPE_UNDERWATER, + MAP_TYPE_6, + MAP_TYPE_7, + MAP_TYPE_INDOOR, + MAP_TYPE_SECRET_BASE +}; + +// map battle scenes +enum +{ + MAP_BATTLE_SCENE_NORMAL, // 0 + MAP_BATTLE_SCENE_GYM, // 1 + MAP_BATTLE_SCENE_MAGMA, // 2 + MAP_BATTLE_SCENE_AQUA, // 3 + MAP_BATTLE_SCENE_SIDNEY, // 4 + MAP_BATTLE_SCENE_PHOEBE, // 5 + MAP_BATTLE_SCENE_GLACIA, // 6 + MAP_BATTLE_SCENE_DRAKE, // 7 + MAP_BATTLE_SCENE_BATTLE_TOWER, // 8 +}; + +typedef void (*TilesetCB)(void); + +struct Tileset +{ + /*0x00*/ bool8 isCompressed; + /*0x01*/ bool8 isSecondary; + /*0x04*/ void *tiles; + /*0x08*/ void *palettes; + /*0x0c*/ void *metatiles; + /*0x10*/ void *metatileAttributes; + /*0x14*/ TilesetCB callback; +}; + +struct MapData +{ + /*0x00*/ s32 width; + /*0x04*/ s32 height; + /*0x08*/ u16 *border; + /*0x0c*/ u16 *map; + /*0x10*/ struct Tileset *primaryTileset; + /*0x14*/ struct Tileset *secondaryTileset; +}; + +struct BackupMapData +{ + s32 width; + s32 height; + u16 *map; +}; + +struct MapObjectTemplate +{ + /*0x00*/ u8 localId; + /*0x01*/ u8 graphicsId; + /*0x02*/ u8 unk2; + /*0x04*/ s16 x; + /*0x06*/ s16 y; + /*0x08*/ u8 elevation; + /*0x09*/ u8 movementType; + /*0x0A*/ u8 unkA_0:4; + u8 unkA_4:4; + ///*0x0B*/ u8 fillerB[1]; + /*0x0C*/ u16 unkC; + /*0x0E*/ u16 unkE; + /*0x10*/ u8 *script; + /*0x14*/ u16 flagId; + /*0x16*/ u8 filler_16[2]; +}; /*size = 0x18*/ + +struct WarpEvent +{ + s16 x, y; + s8 warpId; + u8 mapGroup; + u8 mapNum; + u8 unk7; +}; + +struct CoordEvent +{ + s16 x, y; + u8 unk4; + u8 filler_5; + u16 trigger; + u16 index; + u8 filler_A[0x2]; + u8 *script; +}; + +struct BgEvent +{ + u16 x, y; + u8 unk4; + u8 kind; + // 0x2 padding for the union beginning. + union { // carried over from diego's FR/LG work, seems to be the same struct + // in gen 3, "kind" (0x3 in BgEvent struct) determines the method to read the union. + u8 *script; + + // hidden item type probably + struct { + u8 filler6[0x2]; + u16 hiddenItemId; // flag offset to determine flag lookup + } hiddenItem; + + // secret base type + u32 secretBaseId; + + } bgUnion; +}; + +struct MapEvents +{ + u8 mapObjectCount; + u8 warpCount; + u8 coordEventCount; + u8 bgEventCount; + + struct MapObjectTemplate *mapObjects; + struct WarpEvent *warps; + struct CoordEvent *coordEvents; + struct BgEvent *bgEvents; +}; + +struct MapConnection +{ + /*0x00*/ u8 direction; + /*0x01*/ u32 offset; + /*0x05*/ u8 mapGroup; + /*0x06*/ u8 mapNum; +}; + +struct MapConnections +{ + s32 count; + struct MapConnection *connections; +}; + +struct MapHeader +{ + /* 0x00 */ struct MapData *mapData; + /* 0x04 */ struct MapEvents *events; + /* 0x08 */ u8 *mapScripts; + /* 0x0C */ struct MapConnections *connections; + /* 0x10 */ u16 music; + /* 0x12 */ u16 mapDataId; + /* 0x14 */ u8 regionMapSectionId; + /* 0x15 */ u8 cave; + /* 0x16 */ u8 weather; + /* 0x17 */ u8 mapType; + /* 0x18 */ u8 filler_18; + /* 0x19 */ u8 escapeRope; + /* 0x1A */ u8 flags; + /* 0x1B */ u8 battleType; +}; + +struct MapObject +{ + /*0x00*/ u32 active:1; + u32 mapobj_bit_1:1; + u32 mapobj_bit_2:1; + u32 mapobj_bit_3:1; + u32 mapobj_bit_4:1; + u32 mapobj_bit_5:1; + u32 mapobj_bit_6:1; + u32 mapobj_bit_7:1; + /*0x01*/ u32 mapobj_bit_8:1; + u32 mapobj_bit_9:1; + u32 mapobj_bit_10:1; + u32 mapobj_bit_11:1; + u32 mapobj_bit_12:1; + u32 mapobj_bit_13:1; + u32 mapobj_bit_14:1; + u32 mapobj_bit_15:1; + /*0x02*/ u32 mapobj_bit_16:1; + u32 mapobj_bit_17:1; + u32 mapobj_bit_18:1; + u32 mapobj_bit_19:1; + u32 mapobj_bit_20:1; + u32 mapobj_bit_21:1; + u32 mapobj_bit_22:1; + u32 mapobj_bit_23:1; + /*0x03*/ u32 mapobj_bit_24:1; + u32 mapobj_bit_25:1; + u32 mapobj_bit_26:1; + u32 mapobj_bit_27:1; + u32 mapobj_bit_28:1; + u32 mapobj_bit_29:1; + u32 mapobj_bit_30:1; + u32 mapobj_bit_31:1; + /*0x04*/ u8 spriteId; + /*0x05*/ u8 graphicsId; + /*0x06*/ u8 animPattern; + /*0x07*/ u8 trainerType; + /*0x08*/ u8 localId; + /*0x09*/ u8 mapNum; + /*0x0A*/ u8 mapGroup; + /*0x0B*/ u8 mapobj_unk_0B_0:4; + u8 elevation:4; + /*0x0C*/ struct Coords16 coords1; + /*0x10*/ struct Coords16 coords2; + /*0x14*/ struct Coords16 coords3; + /*0x18*/ u8 mapobj_unk_18:4; //current direction? + /*0x18*/ u8 placeholder18:4; + /*0x19*/ u8 mapobj_unk_19; + /*0x1A*/ u8 mapobj_unk_1A; + /*0x1B*/ u8 mapobj_unk_1B; + /*0x1C*/ u8 mapobj_unk_1C; + /*0x1D*/ u8 trainerRange_berryTreeId; + /*0x1E*/ u8 mapobj_unk_1E; + /*0x1F*/ u8 mapobj_unk_1F; + /*0x20*/ u8 mapobj_unk_20; + /*0x21*/ u8 mapobj_unk_21; + /*0x22*/ u8 animId; + /*size = 0x24*/ +}; + +// THIS IS NEEDED TO MAKE TRAINER_SEE.C MATCH, PLEASE DO NOT REMOVE UNLESS YOU FIX CHECKPATHBETWEENTRAINERANDPLAYER +struct MapObject2 +{ + /*0x00*/ u32 active:1; + u32 mapobj_bit_1:1; + u32 mapobj_bit_2:1; + u32 mapobj_bit_3:1; + u32 mapobj_bit_4:1; + u32 mapobj_bit_5:1; + u32 mapobj_bit_6:1; + u32 mapobj_bit_7:1; + /*0x01*/ u32 mapobj_bit_8:1; + u32 mapobj_bit_9:1; + u32 mapobj_bit_10:1; + u32 mapobj_bit_11:1; + u32 mapobj_bit_12:1; + u32 mapobj_bit_13:1; + u32 mapobj_bit_14:1; + u32 mapobj_bit_15:1; + /*0x02*/ u32 mapobj_bit_16:1; + u32 mapobj_bit_17:1; + u32 mapobj_bit_18:1; + u32 mapobj_bit_19:1; + u32 mapobj_bit_20:1; + u32 mapobj_bit_21:1; + u32 mapobj_bit_22:1; + u32 mapobj_bit_23:1; + /*0x03*/ u32 mapobj_bit_24:1; + u32 mapobj_bit_25:1; + u32 mapobj_bit_26:1; + u32 mapobj_bit_27:1; + u32 mapobj_bit_28:1; + u32 mapobj_bit_29:1; + u32 mapobj_bit_30:1; + u32 mapobj_bit_31:1; + /*0x04*/ u8 spriteId; + /*0x05*/ u8 graphicsId; + /*0x06*/ u8 animPattern; + /*0x07*/ u8 trainerType; + /*0x08*/ u8 localId; + /*0x09*/ u8 mapNum; + /*0x0A*/ u8 mapGroup; + /*0x0B*/ u8 mapobj_unk_0B_0:4; + u8 elevation:4; + /*0x0C*/ struct Coords16 coords1; + /*0x10*/ struct Coords16 coords2; + /*0x14*/ struct Coords16 coords3; + /*0x18*/ u8 mapobj_unk_18:4; + /*0x18*/ u8 placeholder18:4; + /*0x19*/ u8 mapobj_unk_19:4; + /*0x19*/ u8 mapobj_unk_19b:4; + /*0x1A*/ u8 mapobj_unk_1A; + /*0x1B*/ u8 mapobj_unk_1B; + /*0x1C*/ u8 mapobj_unk_1C; + /*0x1D*/ u8 trainerRange_berryTreeId; + /*0x1E*/ u8 mapobj_unk_1E; + /*0x1F*/ u8 mapobj_unk_1F; + /*0x20*/ u8 mapobj_unk_20; + /*0x21*/ u8 mapobj_unk_21; + /*size = 0x24*/ +}; + +struct MapObjectGraphicsInfo +{ + /*0x00*/ u16 tileTag; + /*0x02*/ u16 paletteTag1; + /*0x04*/ u16 paletteTag2; + /*0x06*/ u16 size; + /*0x08*/ s16 width; + /*0x0A*/ s16 height; + /*0x0C*/ u8 paletteSlot:4; + u8 shadowSize:2; + u8 inanimate:1; + u8 disableReflectionPaletteLoad:1; + /*0x0D*/ u8 tracks; + /*0x10*/ const struct OamData *oam; + /*0x14*/ const struct SubspriteTable *subspriteTables; + /*0x18*/ const union AnimCmd *const *anims; + /*0x1C*/ const struct SpriteFrameImage *images; + /*0x20*/ const union AffineAnimCmd *const *affineAnims; +}; + +#define PLAYER_AVATAR_FLAG_ON_FOOT (1 << 0) +#define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << 1) +#define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2) +#define PLAYER_AVATAR_FLAG_SURFING (1 << 3) +#define PLAYER_AVATAR_FLAG_4 (1 << 4) +#define PLAYER_AVATAR_FLAG_5 (1 << 5) +#define PLAYER_AVATAR_FLAG_6 (1 << 6) +#define PLAYER_AVATAR_FLAG_DASH (1 << 7) + +enum +{ + ACRO_BIKE_NORMAL, + ACRO_BIKE_TURNING, + ACRO_BIKE_WHEELIE_STANDING, + ACRO_BIKE_BUNNY_HOP, + ACRO_BIKE_WHEELIE_MOVING, + ACRO_BIKE_STATE5, + ACRO_BIKE_STATE6, +}; + +enum +{ + DIR_NONE, + DIR_SOUTH, + DIR_NORTH, + DIR_WEST, + DIR_EAST, +}; + +enum +{ + COLLISION_LEDGE_JUMP = 6 +}; + +struct PlayerAvatar /* 0x202E858 */ +{ + /*0x00*/ u8 flags; + /*0x01*/ u8 bike; + /*0x02*/ u8 running2; + /*0x03*/ u8 running1; + /*0x04*/ u8 spriteId; + /*0x05*/ u8 mapObjectId; + /*0x06*/ u8 unk6; + /*0x07*/ u8 gender; + u8 acroBikeState; + u8 unk9; + u8 bikeFrameCounter; + u8 unkB; + u32 unkC; + u32 unk10; + u8 unk14[8]; + u8 unk1C[8]; + // TODO: rest of struct +}; + +struct Camera +{ + bool8 field_0:1; + s32 x; + s32 y; +}; + +extern struct MapObject gMapObjects[]; +extern u8 gSelectedMapObject; +extern struct MapHeader gMapHeader; +extern struct PlayerAvatar gPlayerAvatar; + +#endif // GUARD_GLOBAL_FIELDMAP_H diff --git a/include/global.h b/include/global.h index 08ccc670b..c43b57e03 100644 --- a/include/global.h +++ b/include/global.h @@ -75,6 +75,65 @@ enum BAG_KEYITEMS }; +struct Coords16 +{ + s16 x; + s16 y; +}; + +struct UCoords16 +{ + u16 x; + u16 y; +}; + +struct Time +{ + /*0x00*/ s16 days; + /*0x02*/ s8 hours; + /*0x03*/ s8 minutes; + /*0x04*/ s8 seconds; +}; + +struct Pokedex +{ + /*0x00*/ u8 order; + /*0x01*/ u8 unknown1; + /*0x02*/ u8 nationalMagic; // must equal 0xDA in order to have National mode + /*0x03*/ u8 unknown2; + /*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]; +}; + +struct PokemonJumpResults // possibly used in the game itself? +{ + u16 jumpsInRow; + u16 field2; + u16 excellentsInRow; + u16 field6; + u16 field8; + u16 fieldA; + u32 bestJumpScore; +}; + +struct BerryPickingResults // possibly used in the game itself? Size may be wrong as well +{ + u32 bestScore; + u16 berriesPicked; + u16 berriesPickedInRow; + // unk size +}; + +struct PyramidBag +{ + u16 items_Lvl50[10]; + u16 items_OpenLvl[10]; + u8 quantity[10]; +}; + struct SaveBlock2 { /*0x00*/ u8 playerName[8]; @@ -92,10 +151,572 @@ struct SaveBlock2 u16 optionsBattleStyle:1; // OPTIONS_BATTLE_STYLE_[SHIFT/SET] u16 optionsBattleSceneOff:1; // whether battle animations are disabled u16 regionMapZoom:1; // whether the map is zoomed in + /*0x18*/ struct Pokedex pokedex; + /*0x90*/ u8 filler_90[0x8]; + /*0x98*/ struct Time localTimeOffset; + /*0xA0*/ struct Time lastBerryTreeUpdate; + /*0xA8*/ u8 filler_A8[0x4]; + /*0xAC*/ u32 encryptionKey; + + // TODO: fix and verify labels + /*0xB0*/ u8 field_B0[316]; + /*0x1EC*/ u16 berryCrushResults[4]; + /*0x1F4*/ u32 berryPowderAmount; + /*0x1F8*/ u32 field_1F8; + /*0x1FC*/ struct PokemonJumpResults pokeJumpResults; + /*0x20C*/ struct BerryPickingResults berryPickResults; + /*0x214*/ u8 field_214[1040]; + /*0x624*/ u16 contestLinkResults[20]; // 4 positions for 5 categories, possibly a struct or a 2d array + + // All below could be a one giant struct + + /*0x64C*/ u8 field_64C[1629]; + /*0xCA9*/ u8 frontierChosenLvl; + /*0xCAA*/ u8 field_CAA[368]; + /*0xE1A*/ u16 battlePyramidFloor; // possibly? + /*0xE1C*/ u8 field_E1C[16]; + /*0xE2C*/ struct PyramidBag pyramidBag; + /*0x???*/ u8 field_notSure[13]; + /*0xE6E*/ u16 battleTentWinStreak; + /*0xE70*/ u8 field_E70[72]; + /*0xEB8*/ u16 frontierBattlePoints; + /*0xEBA*/ u8 field_EBA[39]; + /*0xEE1*/ u8 field_EE1; + /*0xEE2*/ u8 field_EE2[7]; + /*0xEE9*/ u8 field_EE9; + /*0xEEA*/ u8 field_EEA[22]; }; extern struct SaveBlock2 *gSaveBlock2Ptr; +struct SecretBaseRecord +{ + /*ID?*/ /*0x1A08*/ u8 sbr_field_0; + /*0x1A09*/ u8 sbr_field_1_0:4; + /*0x1A09*/ u8 gender:1; + /*0x1A09*/ u8 sbr_field_1_5:1; + /*0x1A09*/ u8 sbr_field_1_6:2; + /*0x1A0A*/ u8 sbr_field_2[7]; // 0xFF bytes? + /*0x1A12*/ u8 trainerId[4]; // byte 0 is used for determining trainer class + /*0x1A16*/ u16 sbr_field_e; + /*0x1A18*/ u8 sbr_field_10; + /*0x1A19*/ u8 sbr_field_11; + /*0x1A1A*/ u8 decorations[16]; + /*0x1A2A*/ u8 decorationPos[16]; + /*0x1A3A*/ u32 partyPersonality[6]; + /*0x1A54*/ u16 partyMoves[6 * 4]; + /*0x1A84*/ u16 partySpecies[6]; + /*0x1A90*/ u16 partyHeldItems[6]; + /*0x1A9C*/ u8 partyLevels[6]; + /*0x1AA2*/ u8 partyEVs[6]; +}; + +#include "game_stat.h" +#include "global.fieldmap.h" +#include "global.berry.h" +#include "pokemon.h" + +struct WarpData +{ + s8 mapGroup; + s8 mapNum; + s8 warpId; + s16 x, y; +}; + +struct ItemSlot +{ + u16 itemId; + u16 quantity; +}; + +struct Pokeblock +{ + u8 color; + u8 spicy; + u8 dry; + u8 sweet; + u8 bitter; + u8 sour; + u8 feel; +}; + +struct Roamer +{ + /*0x00*/ u32 ivs; + /*0x04*/ u32 personality; + /*0x08*/ u16 species; + /*0x0A*/ u16 hp; + /*0x0C*/ u8 level; + /*0x0D*/ u8 status; + /*0x0E*/ u8 cool; + /*0x0F*/ u8 beauty; + /*0x10*/ u8 cute; + /*0x11*/ u8 smart; + /*0x12*/ u8 tough; + /*0x13*/ bool8 active; + /*0x14*/ u8 filler[0x8]; +}; + +struct RamScriptData +{ + u8 magic; + u8 mapGroup; + u8 mapNum; + u8 objectId; + u8 script[995]; +}; + +struct RamScript +{ + u32 checksum; + struct RamScriptData data; +}; + +struct EasyChatPair +{ + u16 unk0_0:7; + u16 unk0_7:7; + u16 unk1_6:1; + u16 unk2; + u16 words[2]; +}; /*size = 0x8*/ + +struct TVShowCommon +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 pad02[20]; + /*0x16*/ u16 var16[3]; + /*0x1C*/ u8 srcTrainerId3Lo; + /*0x1D*/ u8 srcTrainerId3Hi; + /*0x1E*/ u8 srcTrainerId2Lo; + /*0x1F*/ u8 srcTrainerId2Hi; + /*0x20*/ u8 srcTrainerIdLo; + /*0x21*/ u8 srcTrainerIdHi; + /*0x22*/ u8 trainerIdLo; + /*0x23*/ u8 trainerIdHi; +}; + +struct TVShowFanClubLetter +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u16 species; + /*0x04*/ u16 pad04[6]; + /*0x10*/ u8 playerName[8]; + /*0x18*/ u8 language; +}; + +struct TVShowRecentHappenings +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u16 var02; + /*0x04*/ u16 var04[6]; + /*0x10*/ u8 playerName[8]; + /*0x18*/ u8 language; + /*0x19*/ u8 pad19[10]; +}; + +struct TVShowFanclubOpinions +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u16 var02; + /*0x04*/ u8 var04A:4; + /*0x04*/ u8 var04B:4; + /*0x05*/ u8 playerName[8]; + /*0x0D*/ u8 language; + /*0x0E*/ u8 var0E; + /*0x0F*/ u8 var0F; + /*0x10*/ u8 var10[8]; + /*0x18*/ u16 var18[2]; + /*0x1C*/ u16 var1C[4]; +}; + +struct TVShowUnknownType04 +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 pad02[4]; + /*0x06*/ u16 var06; +}; + +struct TVShowNameRaterShow +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u16 species; + /*0x04*/ u8 pokemonName[11]; + /*0x0F*/ u8 trainerName[11]; + /*0x1A*/ u8 random; + /*0x1B*/ u8 random2; + /*0x1C*/ u16 var1C; + /*0x1E*/ u8 language; + /*0x1F*/ u8 pokemonNameLanguage; +}; + +struct TVShowBravoTrainerPokemonProfiles +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u16 species; + /*0x04*/ u16 var04[2]; + /*0x08*/ u8 pokemonNickname[11]; + /*0x13*/ u8 contestCategory:3; + /*0x13*/ u8 contestRank:2; + /*0x13*/ u8 contestResult:2; + /*0x13*/ u8 var13_7:1; + /*0x14*/ u16 var14; + /*0x16*/ u8 playerName[8]; + /*0x1E*/ u8 language; + /*0x1F*/ u8 var1f; +}; + +struct TVShowBravoTrainerBattleTowerSpotlight +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 trainerName[8]; + /*0x0A*/ u16 species; + /*0x0C*/ u8 pokemonName[8]; + /*0x14*/ u16 defeatedSpecies; + /*0x16*/ u16 var16; + /*0x18*/ u16 var18[1]; + /*0x1A*/ u8 btLevel; + /*0x1B*/ u8 var1b; + /*0x1C*/ u8 var1c; + /*0x1D*/ u8 language; +}; + +struct TVShowPokemonToday +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 language; + /*0x03*/ u8 language2; + /*0x04*/ u8 nickname[11]; + /*0x0F*/ u8 ball; + /*0x10*/ u16 species; + /*0x12*/ u8 var12; + /*0x13*/ u8 playerName[8]; +}; + +struct TVShowSmartShopper +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 priceReduced; + /*0x03*/ u8 language; + /*0x04*/ u8 pad04[2]; + /*0x06*/ u16 itemIds[3]; + /*0x0C*/ u16 itemAmounts[3]; + /*0x12*/ u8 shopLocation; + /*0x13*/ u8 playerName[8]; +}; + +struct TVShowPokemonTodayFailed +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 language; + /*0x03*/ u8 pad03[9]; + /*0x0c*/ u16 species; + /*0x0e*/ u16 species2; + /*0x10*/ u8 var10; + /*0x11*/ u8 var11; + /*0x12*/ u8 var12; + /*0x13*/ u8 playerName[8]; +}; + +struct TVShowPokemonAngler +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 var02; + /*0x03*/ u8 var03; + /*0x04*/ u16 var04; + /*0x06*/ u8 language; + u8 pad07[12]; + /*0x13*/ u8 playerName[8]; +}; + +struct TVShowWorldOfMasters +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u16 var02; + /*0x04*/ u16 var04; + /*0x06*/ u16 var06; + /*0x08*/ u16 var08; + /*0x0a*/ u8 var0a; + /*0x0b*/ u8 language; + u8 pad0c[7]; + /*0x13*/ u8 playerName[8]; +}; + +struct TVShowMassOutbreak +{ + /*0x00*/ u8 var00; + /*0x01*/ u8 var01; + /*0x02*/ u8 var02; + /*0x03*/ u8 var03; + /*0x04*/ u16 moves[4]; + /*0x0C*/ u16 species; + /*0x0E*/ u16 var0E; + /*0x10*/ u8 locationMapNum; + /*0x11*/ u8 locationMapGroup; + /*0x12*/ u8 var12; + /*0x13*/ u8 probability; + /*0x14*/ u8 level; + /*0x15*/ u8 var15; + /*0x16*/ u16 var16; + /*0x18*/ u8 language; + u8 pad19[11]; +}; + +typedef union TVShow +{ + struct TVShowCommon common; + struct TVShowFanClubLetter fanclubLetter; + struct TVShowRecentHappenings recentHappenings; + struct TVShowFanclubOpinions fanclubOpinions; + struct TVShowUnknownType04 unkShow04; + struct TVShowNameRaterShow nameRaterShow; + struct TVShowBravoTrainerPokemonProfiles bravoTrainer; + struct TVShowBravoTrainerBattleTowerSpotlight bravoTrainerTower; + struct TVShowPokemonToday pokemonToday; + struct TVShowSmartShopper smartshopperShow; + struct TVShowPokemonTodayFailed pokemonTodayFailed; + struct TVShowPokemonAngler pokemonAngler; + struct TVShowWorldOfMasters worldOfMasters; + struct TVShowMassOutbreak massOutbreak; +} TVShow; + +struct MailStruct +{ + /*0x00*/ u16 words[9]; + /*0x12*/ u8 playerName[8]; + /*0x1A*/ u8 trainerId[4]; + /*0x1E*/ u16 species; + /*0x20*/ u16 itemId; +}; + +struct UnkMauvilleOldManStruct +{ + u8 unk_2D94; + u8 unk_2D95; + /*0x2D96*/ u16 mauvilleOldMan_ecArray[6]; + /*0x2DA2*/ u16 mauvilleOldMan_ecArray2[6]; + /*0x2DAE*/ u8 playerName[8]; + /*0x2DB6*/ u8 filler_2DB6[0x3]; + /*0x2DB9*/ u8 playerTrainerId[4]; + u8 unk_2DBD; +}; /*size = 0x2C*/ + +struct UnkMauvilleOldManStruct2 +{ + u8 filler0; + u8 unk1; + u8 unk2; + u16 mauvilleOldMan_ecArray[10]; + u8 mauvilleOldMan_ecArray2[12]; + u8 fillerF[0x2]; +}; /*size = 0x2C*/ + +struct MauvilleOldManTrader +{ + u8 unk0; + u8 unk1[4]; + u8 unk5[4][11]; + u8 unk31; +}; + +typedef union OldMan +{ + struct UnkMauvilleOldManStruct oldMan1; + struct UnkMauvilleOldManStruct2 oldMan2; + struct MauvilleOldManTrader trader; + u8 filler[0x40]; +} OldMan; + +struct UnknownSaveStruct2ABC +{ + u8 val0; + u8 val1; + u16 val2; +}; + +struct GabbyAndTyData +{ + /*2b10*/ u16 mon1; + /*2b12*/ u16 mon2; + /*2b14*/ u16 lastMove; + /*2b16*/ u16 quote; + /*2b18*/ u8 mapnum; + /*2b19*/ u8 battleNum; + /*2b1a*/ u8 valA_0:1; + /*2b1a*/ u8 valA_1:1; + /*2b1a*/ u8 valA_2:1; + /*2b1a*/ u8 valA_3:1; + /*2b1a*/ u8 valA_4:1; + /*2b1a*/ u8 valA_5:3; + /*2b1b*/ u8 valB_0:1; + /*2b1b*/ u8 valB_1:1; + /*2b1b*/ u8 valB_2:1; + /*2b1b*/ u8 valB_3:1; + /*2b1b*/ u8 valB_4:1; + /*2b1b*/ u8 valB_5:3; +}; + +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 LinkBattleRecord +{ + u8 name[8]; + u16 trainerId; + u16 wins; + u16 losses; + u16 draws; +}; + +struct RecordMixingGiftData +{ + u8 unk0; + u8 quantity; + u16 itemId; + u8 filler4[8]; +}; + +struct RecordMixingGift +{ + int checksum; + struct RecordMixingGiftData data; +}; + +struct ContestWinner +{ + u32 personality; + u32 trainerId; + u16 species; + u8 contestCategory; + u8 monName[11]; + u8 trainerName[8]; + u8 contestRank; +}; + +#define FLAGS_NUMBER 300 +#define VARS_NUMBER 256 + +struct SaveBlock1 +{ + /*0x00*/ struct Coords16 pos; + /*0x04*/ struct WarpData location; + /*0x0C*/ struct WarpData warp1; + /*0x14*/ struct WarpData warp2; + /*0x1C*/ struct WarpData warp3; + /*0x24*/ struct WarpData warp4; + /*0x2C*/ u16 battleMusic; + /*0x2E*/ u8 weather; + /*0x2F*/ u8 filler_2F; + /*0x30*/ u8 flashUsed; + /*0x32*/ u16 mapDataId; + /*0x34*/ u16 mapView[0x100]; + /*0x234*/ u8 playerPartyCount; + /*0x238*/ struct Pokemon playerParty[6]; + /*0x490*/ u32 money; + /*0x494*/ u16 coins; + /*0x496*/ u16 registeredItem; // registered for use with SELECT button + /*0x498*/ struct ItemSlot pcItems[50]; + /*0x560*/ struct ItemSlot bagPocket_Items[30]; + /*0x5D8*/ struct ItemSlot bagPocket_KeyItems[30]; + /*0x650*/ struct ItemSlot bagPocket_PokeBalls[16]; + /*0x690*/ struct ItemSlot bagPocket_TMHM[64]; + /*0x790*/ struct ItemSlot bagPocket_Berries[46]; + /*0x848*/ struct Pokeblock pokeblocks[40]; + /*0x988*/ u8 seen1[52]; + /*0x9BC*/ u16 berryBlenderRecords[3]; + /*0x9C2*/ u8 field_9C2[6]; + /*0x9C8*/ u16 trainerRematchStepCounter; + /*0x9CA*/ u8 trainerRematches[100]; + /*0xA30*/ struct MapObject mapObjects[16]; + /*0xC70*/ struct MapObjectTemplate mapObjectTemplates[64]; + /*0x1270*/ u8 flags[FLAGS_NUMBER]; + /*0x139C*/ u16 vars[VARS_NUMBER]; + /*0x159C*/ u32 gameStats[NUM_GAME_STATS]; + /*0x169C*/ struct BerryTree berryTrees[128]; + /*0x1A9C*/ struct SecretBaseRecord secretBases[20]; + /*0x271C*/ u8 playerRoomDecor[12]; + /*0x2728*/ u8 playerRoomDecorPos[12]; + /*0x2734*/ u8 decorDesk[10]; + /*0x????*/ u8 decorChair[10]; + /*0x????*/ u8 decorPlant[10]; + /*0x????*/ u8 decorOrnament[30]; + /*0x????*/ u8 decorMat[30]; + /*0x????*/ u8 decorPoster[10]; + /*0x????*/ u8 decorDoll[40]; + /*0x????*/ u8 decorCushion[10]; + /*0x27CA*/ u8 padding_27CA[2]; + /*0x27CC*/ TVShow tvShows[25]; + /*0x2B50*/ struct UnknownSaveStruct2ABC pokeNews[16]; + /*0x2B90*/ u16 outbreakPokemonSpecies; + /*0x????*/ u8 outbreakLocationMapNum; + /*0x????*/ u8 outbreakLocationMapGroup; + /*0x????*/ u8 outbreakPokemonLevel; + /*0x????*/ u8 outbreakUnk1; + /*0x????*/ u16 outbreakUnk2; + /*0x????*/ u16 outbreakPokemonMoves[4]; + /*0x????*/ u8 outbreakUnk4; + /*0x????*/ u8 outbreakPokemonProbability; + /*0x????*/ u16 outbreakUnk5; + /*0x2BA4*/ struct GabbyAndTyData gabbyAndTyData; + /*0x????*/ u16 unk2B1C[6]; + /*0x????*/ u16 unk2B28[6]; + /*0x????*/ u16 unk2B34[6]; + /*0x????*/ u16 unk2B40[6]; + /*0x2BE0*/ struct MailStruct mail[16]; + /*0x2E20*/ u8 additionalPhrases; // bitfield for 33 additional phrases in easy chat system + /*0x2E25*/ u8 unk2E25[3]; // possibly padding? + /*0x2E28*/ OldMan oldMan; + /*0x2e64*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff + /*0x2e8c*/ u8 filler_2E8C[0x4]; + /*0x2e90*/ struct ContestWinner contestWinners[13]; // 0 - 5 used in contest hall, 6 - 7 unused?, 8 - 12 museum + + // TODO: fix + + /*0x????*/ struct BoxPokemon daycareData[2]; + /*0x????*/ struct RecordMixing_UnknownStruct filler_303C; + /*0x????*/ u8 filler_30B4[0x2]; + /*0x????*/ u8 filler_30B6; + /*0x????*/ u8 filler_30B7[1]; + /*0x????*/ struct LinkBattleRecord linkBattleRecords[5]; + /*0x????*/ u8 filler_3108[8]; + + /*0x31A8*/ u8 giftRibbons[52]; + /*0x31DC*/ struct Roamer roamer; + /*0x31F8*/ struct EnigmaBerry enigmaBerry; + + // TODO: fix + /*0x????*/ struct RamScript ramScript; + /*0x????*/ struct RecordMixingGift recordMixingGift; + /*0x????*/ u8 unk3A8C[52]; //pokedex related +}; + +extern struct SaveBlock1* gSaveBlock1Ptr; + struct Bitmap // TODO: Find a better spot for this { u8* pixels; diff --git a/include/item.h b/include/item.h new file mode 100644 index 000000000..eaefa0298 --- /dev/null +++ b/include/item.h @@ -0,0 +1,62 @@ +#ifndef ITEM_H +#define ITEM_H + +typedef void (*ItemUseFunc)(u8); + +struct Item +{ + u8 name[14]; + u16 itemId; + u16 price; + u8 holdEffect; + u8 holdEffectParam; + const u8 *description; + u8 importance; + u8 unk19; + u8 pocket; + u8 type; + ItemUseFunc fieldUseFunc; + u8 battleUsage; + ItemUseFunc battleUseFunc; + u8 secondaryId; +}; + +struct BagPocket +{ + struct ItemSlot *itemSlots; + u8 capacity; +}; + +extern struct BagPocket gBagPockets[]; + +void GetBerryCountString(u8* dst, const u8* berryName, u32 quantity); +void CopyItemName(u16 itemId, u8 *string); +bool8 IsBagPocketNonEmpty(u8 pocket); +bool8 CheckBagHasItem(u16 itemId, u16 count); +bool8 CheckBagHasSpace(u16 itemId, u16 count); +bool8 AddBagItem(u16 itemId, u16 count); +bool8 RemoveBagItem(u16 itemId, u16 count); +u8 GetPocketByItemId(u16 itemId); +void ClearItemSlots(struct ItemSlot *itemSlots, u8 b); +u8 CountUsedPCItemSlots(void); +bool8 CheckPCHasItem(u16 itemId, u16 count); +bool8 AddPCItem(u16 itemId, u16 count); +void RemovePCItem(u8 index, u16 count); +void SwapRegisteredBike(void); +const struct Item *ItemId_GetItem(u16 itemId); +u16 ItemId_GetId(u16 itemId); +u16 ItemId_GetPrice(u16 itemId); +u8 ItemId_GetHoldEffect(u16 itemId); +u8 ItemId_GetHoldEffectParam(u16 itemId); +const u8 *ItemId_GetDescription(u16 itemId); +bool32 ItemId_CopyDescription(u8 *a, u32 itemId, u32 c); +u8 ItemId_GetImportance(u16 itemId); +u8 ItemId_GetUnknownValue(u16 itemId); +u8 ItemId_GetPocket(u16 itemId); +u8 ItemId_GetType(u16 itemId); +ItemUseFunc ItemId_GetFieldFunc(u16 itemId); +u8 ItemId_GetBattleUsage(u16 itemId); +ItemUseFunc ItemId_GetBattleFunc(u16 itemId); +u8 ItemId_GetSecondaryId(u16 itemId); + +#endif // ITEM_H diff --git a/include/malloc.h b/include/malloc.h new file mode 100644 index 000000000..bd870ede3 --- /dev/null +++ b/include/malloc.h @@ -0,0 +1,8 @@ +#ifndef GUARD_MALLOC_H +#define GUARD_MALLOC_H + +void *Alloc(u32 size); +void *AllocZeroed(u32 size); +void Free(void *pointer); + +#endif // GUARD_MALLOC_H diff --git a/include/new_game.h b/include/new_game.h new file mode 100644 index 000000000..00ab55d70 --- /dev/null +++ b/include/new_game.h @@ -0,0 +1,12 @@ +#ifndef GUARD_NEW_GAME_H +#define GUARD_NEW_GAME_H + +void WriteUnalignedWord(u32 var, u8 *dataPtr); +void CopyUnalignedWord(u8 *copyTo, u8 *copyFrom); +void InitPlayerTrainerId(void); +void SetDefaultOptions(void); +void ClearPokedexFlags(void); +void WarpToTruck(void); +void NewGameInitData(void); + +#endif // GUARD_NEW_GAME_H diff --git a/include/play_time.h b/include/play_time.h new file mode 100644 index 000000000..49091f4b1 --- /dev/null +++ b/include/play_time.h @@ -0,0 +1,10 @@ +#ifndef GUARD_PLAY_TIME_H +#define GUARD_PLAY_TIME_H + +void PlayTimeCounter_Reset(void); +void PlayTimeCounter_Start(void); +void PlayTimeCounter_Stop(void); +void PlayTimeCounter_Update(void); +void PlayTimeCounter_SetToMax(void); + +#endif // GUARD_PLAY_TIME_H diff --git a/include/pokemon.h b/include/pokemon.h index b3381a4b0..299a25391 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -1,3 +1,6 @@ +#ifndef GUARD_POKEMON_H +#define GUARD_POKEMON_H + #define MON_DATA_PERSONALITY 0 #define MON_DATA_OT_ID 1 #define MON_DATA_NICKNAME 2 @@ -308,4 +311,6 @@ struct BattleMove // u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data); u32 GetMonData(); -u8 pokemon_species_get_gender_info(u16 species, u32 personality);
\ No newline at end of file +u8 pokemon_species_get_gender_info(u16 species, u32 personality); + +#endif // GUARD_POKEMON_H diff --git a/include/rtc.h b/include/rtc.h index fdc5ad709..5ee6a5316 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -22,7 +22,7 @@ extern struct Time gLocalTime; void RtcDisableInterrupts(void); void RtcRestoreInterrupts(void); u32 ConvertBcdToBinary(u8 bcd); -bool8 IsLeapYear(u8 year); +bool8 IsLeapYear(u32 year); u16 ConvertDateToDayCount(u8 year, u8 month, u8 day); u16 RtcGetDayCount(struct SiiRtcInfo *rtc); void RtcInit(void); diff --git a/include/save.h b/include/save.h new file mode 100644 index 000000000..1d7fdd6e3 --- /dev/null +++ b/include/save.h @@ -0,0 +1,92 @@ +#ifndef GUARD_SAVE_H +#define GUARD_SAVE_H + +struct SaveSectionLocation +{ + void *data; + u16 size; +}; + +struct SaveSection +{ + u8 data[0xFF4]; + u16 id; + u16 checksum; + u32 security; + u32 counter; +}; // size is 0x1000 + +// headless save section? +struct UnkSaveSection +{ + u8 data[0xFF4]; + u32 security; +}; // size is 0xFF8 + +struct SaveSectionOffsets +{ + u16 toAdd; + u16 size; +}; + +// Emerald changes this definition to be the sectors per slot. +#define NUM_SECTORS_PER_SLOT 16 // move to save.h + +#define UNKNOWN_CHECK_VALUE 0x8012025 + +// SetDamagedSectorBits states +enum +{ + ENABLE, + DISABLE, + CHECK // unused +}; + +// Do save types +enum +{ + NORMAL_SAVE, + LINK_SAVE, + //EREADER_SAVE, // depreciated in Emerald + LINK2_SAVE, // unknown 2nd link save + HOF_SAVE, + DIFFERENT_FILE_SAVE, + HOF_DELETE_SAVE // unused +}; + +void ClearSaveData(void); +void ResetSaveCounters(void); +//bool32 ManipulateSectorBits(u8 op, u8 bit); +//u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *a2); +u8 HandleWriteSector(u16, const struct SaveSectionLocation *); +//u8 HandleWriteSectorNBytes(u8 sector, u8 *data, u16 size); +u8 TryWriteSector(u8, u8 *); +//u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location); +//u32 RestoreSaveBackupVars(const struct SaveSectionLocation *location); +//u8 sub_812550C(u16 a1, const struct SaveSectionLocation *location); +u8 sub_8152A34(u16 a1, const struct SaveSectionLocation *location); +u8 ClearSaveData_2(u16, const struct SaveSectionLocation *location); +//u8 sub_8125758(u16 a1, const struct SaveSectionLocation *location); +//u8 sub_81257F0(u16 a1, const struct SaveSectionLocation *location); +//u8 sub_812587C(u16 a1, const struct SaveSectionLocation *location); +u8 sub_8152E10(u16, const struct SaveSectionLocation *location); +u8 GetSaveValidStatus(const struct SaveSectionLocation *location); +//u8 sub_8125B88(u8 a1, u8 *data, u16 size); +u8 DoReadFlashWholeSection(u8, struct SaveSection *); +u16 CalculateChecksum(void *, u16); +//u8 HandleSavingData(u8 saveType); +//u8 TrySavingData(u8 saveType); +//u8 sub_8125D80(void); +//bool8 sub_8125DA8(void); +//u8 sub_8125DDC(void); +//u8 sub_8125E04(void); +//u8 sub_8125E2C(void); +//bool8 sub_8125E6C(void); +//u8 sub_8125EC8(u8 a1); +//bool8 unref_sub_8125F4C(struct UnkSaveSection *a1); +//u8 unref_sub_8125FA0(void); +//u8 unref_sub_8125FF0(u8 *data, u16 size); +//u8 unref_sub_8126068(u8 sector, u8 *data, u32 size); +//u8 unref_sub_8126080(u8 sector, u8 *data); + +#endif // GUARD_SAVE_H diff --git a/include/songs.h b/include/songs.h new file mode 100644 index 000000000..afd26d683 --- /dev/null +++ b/include/songs.h @@ -0,0 +1,374 @@ +#ifndef GUARD_SONGS_H +#define GUARD_SONGS_H + +enum +{ + /*0x00*/ SE_STOP, + /*0x01*/ SE_KAIFUKU, + /*0x02*/ SE_PC_LOGON, + /*0x03*/ SE_PC_OFF, + /*0x04*/ SE_PC_ON, + /*0x05*/ SE_SELECT, + /*0x06*/ SE_WIN_OPEN, + /*0x07*/ SE_WALL_HIT, + /*0x08*/ SE_DOOR, + /*0x09*/ SE_KAIDAN, + /*0x0A*/ SE_DANSA, + /*0x0B*/ SE_JITENSYA, + /*0x0C*/ SE_KOUKA_L, + /*0x0D*/ SE_KOUKA_M, + /*0x0E*/ SE_KOUKA_H, + /*0x0F*/ SE_BOWA2, + /*0x10*/ SE_POKE_DEAD, + /*0x11*/ SE_NIGERU, + /*0x12*/ SE_JIDO_DOA, + /*0x13*/ SE_NAMINORI, + /*0x14*/ SE_BAN, + /*0x15*/ SE_PIN, + /*0x16*/ SE_BOO, + /*0x17*/ SE_BOWA, + /*0x18*/ SE_JYUNI, + /*0x19*/ SE_A, + /*0x1A*/ SE_I, + /*0x1B*/ SE_U, + /*0x1C*/ SE_E, + /*0x1D*/ SE_O, + /*0x1E*/ SE_N, + /*0x1F*/ SE_SEIKAI, + /*0x20*/ SE_HAZURE, + /*0x21*/ SE_EXP, + /*0x22*/ SE_JITE_PYOKO, + /*0x23*/ SE_MU_PACHI, + /*0x24*/ SE_TK_KASYA, + /*0x25*/ SE_FU_ZAKU, + /*0x26*/ SE_FU_ZAKU2, + /*0x27*/ SE_FU_ZUZUZU, + /*0x28*/ SE_RU_GASHIN, + /*0x29*/ SE_RU_GASYAN, + /*0x2A*/ SE_RU_BARI, + /*0x2B*/ SE_RU_HYUU, + /*0x2C*/ SE_KI_GASYAN, + /*0x2D*/ SE_TK_WARPIN, + /*0x2E*/ SE_TK_WARPOUT, + /*0x2F*/ SE_TU_SAA, + /*0x30*/ SE_HI_TURUN, + /*0x31*/ SE_TRACK_MOVE, + /*0x32*/ SE_TRACK_STOP, + /*0x33*/ SE_TRACK_HAIK, + /*0x34*/ SE_TRACK_DOOR, + /*0x35*/ SE_MOTER, + /*0x36*/ SE_CARD, + /*0x37*/ SE_SAVE, + /*0x38*/ SE_KON, + /*0x39*/ SE_KON2, + /*0x3A*/ SE_KON3, + /*0x3B*/ SE_KON4, + /*0x3C*/ SE_SUIKOMU, + /*0x3D*/ SE_NAGERU, + SE_TOY_C, + SE_TOY_D, + SE_TOY_E, + SE_TOY_F, + SE_TOY_G, + SE_TOY_A, + SE_TOY_B, + SE_TOY_C1, + SE_MIZU, + SE_HASHI, + SE_DAUGI, + SE_PINPON, + SE_FUUSEN1, + SE_FUUSEN2, + SE_FUUSEN3, + SE_TOY_KABE, + SE_TOY_DANGO, + SE_DOKU, + SE_ESUKA, + SE_T_AME, + SE_T_AME_E, + SE_T_OOAME, + SE_T_OOAME_E, + SE_T_KOAME, + SE_T_KOAME_E, + SE_T_KAMI, + SE_T_KAMI2, + SE_ELEBETA, + /*0x5A*/ SE_HINSI, + /*0x5B*/ SE_EXPMAX, + /*0x5C*/ SE_TAMAKORO, + /*0x5D*/ SE_TAMAKORO_E, + /*0x5E*/ SE_BASABASA, + /*0x5F*/ SE_REGI, + SE_C_GAJI, + SE_C_MAKU_U, + SE_C_MAKU_D, + SE_C_PASI, + SE_C_SYU, + SE_C_PIKON, + /*0x66*/ SE_REAPOKE, + /*0x67*/ SE_OP_BASYU, + /*0x68*/ SE_BT_START, + SE_DENDOU, + SE_JIHANKI, + SE_TAMA, + SE_Z_SCROLL, + /*0x6D*/ SE_Z_PAGE, + /*0x6E*/ SE_PN_ON, + /*0x6F*/ SE_PN_OFF, + /*0x70*/ SE_Z_SEARCH, + /*0x71*/ SE_TAMAGO, + /*0x72*/ SE_TB_START, + /*0x73*/ SE_TB_KON, + /*0x74*/ SE_TB_KARA, + /*0x75*/ SE_BIDORO, + /*0x76*/ SE_W085, + /*0x77*/ SE_W085B, + /*0x78*/ SE_W231, + /*0x79*/ SE_W171, + /*0x7A*/ SE_W233, + /*0x7B*/ SE_W233B, + /*0x7C*/ SE_W145, + /*0x7D*/ SE_W145B, + /*0x7E*/ SE_W145C, + /*0x7F*/ SE_W240, + /*0x80*/ SE_W015, + /*0x81*/ SE_W081, + /*0x82*/ SE_W081B, + /*0x83*/ SE_W088, + /*0x84*/ SE_W016, + /*0x85*/ SE_W016B, + /*0x86*/ SE_W003, + /*0x87*/ SE_W104, + /*0x88*/ SE_W013, + /*0x89*/ SE_W196, + /*0x8A*/ SE_W086, + /*0x8B*/ SE_W004, + /*0x8C*/ SE_W025, + /*0x8D*/ SE_W025B, + SE_W152, + SE_W026, + SE_W172, + SE_W172B, + SE_W053, + SE_W007, + SE_W092, + SE_W221, + SE_W221B, + SE_W052, + SE_W036, + SE_W059, + SE_W059B, + SE_W010, + SE_W011, + SE_W017, + SE_W019, + SE_W028, + SE_W013B, + SE_W044, + SE_W029, + SE_W057, + SE_W056, + SE_W250, + SE_W030, + SE_W039, + SE_W054, + SE_W077, + SE_W020, + SE_W082, + SE_W047, + SE_W195, + SE_W006, + SE_W091, + SE_W146, + SE_W120, + SE_W153, + SE_W071B, + SE_W071, + SE_W103, + /*0xB6*/ SE_W062, + /*0xB7*/ SE_W062B, + /*0xB8*/ SE_W048, + /*0xB9*/ SE_W187, + /*0xBA*/ SE_W118, + /*0xBB*/ SE_W155, + /*0xBC*/ SE_W122, + /*0xBD*/ SE_W060, + /*0xBE*/ SE_W185, + /*0xBF*/ SE_W014, + /*0xC0*/ SE_W043, + /*0xC1*/ SE_W207, + /*0xC2*/ SE_W207B, + /*0xC3*/ SE_W215, + /*0xC4*/ SE_W109, + /*0xC5*/ SE_W173, + /*0xC6*/ SE_W280, + /*0xC7*/ SE_W202, + /*0xC8*/ SE_W060B, + /*0xC9*/ SE_W076, + /*0xCA*/ SE_W080, + /*0xCB*/ SE_W100, + /*0xCC*/ SE_W107, + SE_W166, + SE_W129, + SE_W115, + SE_W112, + SE_W197, + SE_W199, + SE_W236, + SE_W204, + SE_W268, + SE_W070, + SE_W063, + SE_W127, + SE_W179, + SE_W151, + SE_W201, + SE_W161, + SE_W161B, + SE_W227, + SE_W227B, + SE_W226, + SE_W208, + SE_W213, + SE_W213B, + SE_W234, + SE_W260, + SE_W328, + SE_W320, + SE_W255, + SE_W291, + SE_W089, + SE_W239, + SE_W230, + SE_W281, + SE_W327, + SE_W287, + SE_W257, + SE_W253, + SE_W258, + SE_W322, + SE_W298, + SE_W287B, + SE_W114, + SE_W063B, + BGM_STOP = 349, + BGM_TETSUJI, + BGM_FIELD13, + BGM_KACHI22, + BGM_KACHI2, + BGM_KACHI3, + BGM_KACHI5, + BGM_PCC, + BGM_NIBI, + BGM_SUIKUN, + BGM_DOORO1, + BGM_DOORO_X1, + BGM_DOORO_X3, + BGM_MACHI_S2, + BGM_MACHI_S4, + BGM_GIM, + BGM_NAMINORI, + BGM_DAN01, + /*0x16F*/ BGM_FANFA1, + /*0x170*/ BGM_ME_ASA, + /*0x171*/ BGM_ME_BACHI, + /*0x172*/ BGM_FANFA4, + /*0x173*/ BGM_FANFA5, + /*0x174*/ BGM_ME_WAZA, + /*0x175*/ BGM_BIJYUTU, + /*0x176*/ BGM_DOORO_X4, + /*0x177*/ BGM_FUNE_KAN, + /*0x178*/ BGM_ME_SHINKA, + /*0x179*/ BGM_SHINKA, + /*0x17A*/ BGM_ME_WASURE, + /*0x17B*/ BGM_SYOUJOEYE, + /*0x17C*/ BGM_BOYEYE, + /*0x17D*/ BGM_DAN02, + /*0x17E*/ BGM_MACHI_S3, + /*0x17F*/ BGM_ODAMAKI, + /*0x180*/ BGM_B_TOWER, + /*0x181*/ BGM_SWIMEYE, + /*0x182*/ BGM_DAN03, + /*0x183*/ BGM_ME_KINOMI, + /*0x184*/ BGM_ME_TAMA, + /*0x185*/ BGM_ME_B_BIG, + /*0x186*/ BGM_ME_B_SMALL, + /*0x187*/ BGM_ME_ZANNEN, + /*0x188*/ BGM_BD_TIME, + /*0x189*/ BGM_TEST1, + /*0x18A*/ BGM_TEST2, + /*0x18B*/ BGM_TEST3, + /*0x18C*/ BGM_TEST4, + /*0x18D*/ BGM_TEST, + /*0x18E*/ BGM_GOMACHI0, + /*0x18F*/ BGM_GOTOWN, + /*0x190*/ BGM_POKECEN, + /*0x191*/ BGM_NEXTROAD, + /*0x192*/ BGM_GRANROAD, + /*0x193*/ BGM_CYCLING, + BGM_FRIENDLY, + BGM_MISHIRO, + BGM_TOZAN, + BGM_GIRLEYE, + BGM_MINAMO, + BGM_ASHROAD, + BGM_EVENT0, + BGM_DEEPDEEP, + BGM_KACHI1, + BGM_TITLE3, + BGM_DEMO1, + BGM_GIRL_SUP, + BGM_HAGESHII, + BGM_KAKKOII, + BGM_KAZANBAI, + BGM_AQA_0, + BGM_TSURETEK, + BGM_BOY_SUP, + BGM_RAINBOW, + BGM_AYASII, + BGM_KACHI4, + BGM_ROPEWAY, + BGM_CASINO, + BGM_HIGHTOWN, + BGM_SAFARI, + BGM_C_ROAD, + BGM_AJITO, + BGM_M_BOAT, + BGM_M_DUNGON, + BGM_FINECITY, + BGM_MACHUPI, + BGM_P_SCHOOL, + BGM_DENDOU, + BGM_TONEKUSA, + BGM_MABOROSI, + BGM_CON_FAN, + BGM_CONTEST0, + BGM_MGM0, + BGM_T_BATTLE, + BGM_OOAME, + BGM_HIDERI, + BGM_RUNECITY, + BGM_CON_K, + BGM_EIKOU_R, + BGM_KARAKURI, + BGM_HUTAGO, + BGM_SITENNOU, + BGM_YAMA_EYE, + BGM_CONLOBBY, + BGM_INTER_V, + BGM_DAIGO, + BGM_THANKFOR, + BGM_END, + BGM_BATTLE27, // wild + BGM_BATTLE31, // aqua/magma grunt + BGM_BATTLE20, // trainer + BGM_BATTLE32, // gym leader + BGM_BATTLE33, // champion + BGM_BATTLE36, // regi + BGM_BATTLE34, // weather trio + BGM_BATTLE35, // rival + BGM_BATTLE38, // elite four + BGM_BATTLE30, // aqua/magma leader +}; + +#endif // GUARD_SONGS_H diff --git a/include/sound.h b/include/sound.h new file mode 100644 index 000000000..7d47b7456 --- /dev/null +++ b/include/sound.h @@ -0,0 +1,48 @@ +#ifndef GUARD_SOUND_H +#define GUARD_SOUND_H + +void InitMapMusic(void); +void MapMusicMain(void); +void ResetMapMusic(void); +u16 GetCurrentMapMusic(void); +void PlayNewMapMusic(u16 songNum); +void StopMapMusic(void); +void FadeOutMapMusic(u8 speed); +void FadeOutAndPlayNewMapMusic(u16 songNum, u8 speed); +void FadeOutAndFadeInNewMapMusic(u16 songNum, u8 fadeOutSpeed, u8 fadeInSpeed); +void FadeInNewMapMusic(u16 songNum, u8 speed); +bool8 IsNotWaitingForBGMStop(void); +void PlayFanfareByFanfareNum(u8 fanfareNum); +bool8 WaitFanfare(bool8 stop); +void StopFanfareByFanfareNum(u8 fanfareNum); +void PlayFanfare(u16 songNum); +bool8 IsFanfareTaskInactive(void); +void FadeInNewBGM(u16 songNum, u8 speed); +void FadeOutBGMTemporarily(u8 speed); +bool8 IsBGMPausedOrStopped(void); +void FadeInBGM(u8 speed); +void FadeOutBGM(u8 speed); +bool8 IsBGMStopped(void); +void PlayCry1(u16 species, s8 pan); +void PlayCry2(u16 species, s8 pan, s8 volume, u8 priority); +void PlayCry3(u16 species, s8 pan, u8 mode); +void PlayCry4(u16 species, s8 pan, u8 mode); +void PlayCry5(u16 species, u8 mode); +void PlayCry6(u16 species, s8 pan, u8 mode); +void PlayCryInternal(u16 species, s8 pan, s8 volume, u8 priority, u8 mode); +bool8 IsCryFinished(void); +void StopCryAndClearCrySongs(void); +void StopCry(void); +bool8 IsCryPlayingOrClearCrySongs(void); +bool8 IsCryPlaying(void); +void PlayBGM(u16 songNum); +void PlaySE(u16 songNum); +void PlaySE12WithPanning(u16 songNum, s8 pan); +void PlaySE1WithPanning(u16 songNum, s8 pan); +void PlaySE2WithPanning(u16 songNum, s8 pan); +void SE12PanpotControl(s8 pan); +bool8 IsSEPlaying(void); +bool8 IsBGMPlaying(void); +bool8 IsSpecialSEPlaying(void); + +#endif // GUARD_SOUND_H diff --git a/include/sprite.h b/include/sprite.h new file mode 100644 index 000000000..68474b2ae --- /dev/null +++ b/include/sprite.h @@ -0,0 +1,305 @@ +#ifndef GUARD_SPRITE_H +#define GUARD_SPRITE_H + +#define MAX_SPRITES 64 + +struct SpriteSheet +{ + const u8 *data; // Raw uncompressed pixel data + u16 size; + u16 tag; +}; + +struct CompressedSpriteSheet +{ + const u8 *data; // LZ77 compressed pixel data + u16 size; // Uncompressed size of pixel data + u16 tag; +}; + +struct SpriteFrameImage +{ + const u8 *data; + u16 size; +}; + +#define obj_frame_tiles(ptr) {.data = (u8 *)ptr, .size = sizeof ptr} + +struct SpritePalette +{ + const u16 *data; // Raw uncompressed palette data + u16 tag; +}; + +struct CompressedSpritePalette +{ + const u8 *data; // LZ77 compressed palette data + u16 tag; +}; + +struct AnimFrameCmd +{ + // If the sprite has an array of images, this is the array index. + // If the sprite has a sheet, this is the tile offset. + u32 imageValue:16; + + u32 duration:6; + u32 hFlip:1; + u32 vFlip:1; +}; + +struct AnimLoopCmd +{ + u32 type:16; + u32 count:6; +}; + +struct AnimJumpCmd +{ + u32 type:16; + u32 target:6; +}; + +// The first halfword of this union specifies the type of command. +// If it -2, then it is a jump command. If it is -1, then it is the end of the script. +// Otherwise, it is the imageValue for a frame command. +union AnimCmd +{ + s16 type; + struct AnimFrameCmd frame; + struct AnimLoopCmd loop; + struct AnimJumpCmd jump; +}; + +#define ANIMCMD_FRAME(...) \ + {.frame = {__VA_ARGS__}} +#define ANIMCMD_LOOP(_count) \ + {.loop = {.type = -3, .count = _count}} +#define ANIMCMD_JUMP(_target) \ + {.jump = {.type = -2, .target = _target}} +#define ANIMCMD_END \ + {.type = -1} + +struct AffineAnimFrameCmd +{ + s16 xScale; + s16 yScale; + u8 rotation; + u8 duration; +}; + +struct AffineAnimLoopCmd +{ + s16 type; + s16 count; +}; + +struct AffineAnimJumpCmd +{ + s16 type; + u16 target; +}; + +union AffineAnimCmd +{ + s16 type; + struct AffineAnimFrameCmd frame; + struct AffineAnimLoopCmd loop; + struct AffineAnimJumpCmd jump; +}; + +#define AFFINEANIMCMDTYPE_LOOP 0x7FFD +#define AFFINEANIMCMDTYPE_JUMP 0x7FFE +#define AFFINEANIMCMDTYPE_END 0x7FFF + +#define AFFINEANIMCMD_FRAME(_xScale, _yScale, _rotation, _duration) \ + {.frame = {.xScale = _xScale, .yScale = _yScale, .rotation = _rotation, .duration = _duration}} +#define AFFINEANIMCMD_LOOP(_count) \ + {.loop = {.type = AFFINEANIMCMDTYPE_LOOP, .count = _count}} +#define AFFINEANIMCMD_JUMP(_target) \ + {.jump = {.type = AFFINEANIMCMDTYPE_JUMP, .target = _target}} +#define AFFINEANIMCMD_END \ + {.type = AFFINEANIMCMDTYPE_END} +#define AFFINEANIMCMD_LOOP(_count) \ + {.loop = {.type = AFFINEANIMCMDTYPE_LOOP, .count = _count}} +#define AFFINEANIMCMD_JUMP(_target) \ + {.jump = {.type = AFFINEANIMCMDTYPE_JUMP, .target = _target}} + +struct AffineAnimState +{ + u8 animNum; + u8 animCmdIndex; + u8 delayCounter; + u8 loopCounter; + s16 xScale; + s16 yScale; + u16 rotation; +}; + +enum +{ + SUBSPRITES_OFF, + SUBSPRITES_ON, + SUBSPRITES_IGNORE_PRIORITY, // on but priority is ignored +}; + +struct Subsprite +{ + s8 x; // was u16 in R/S + s8 y; // was u16 in R/S + u16 shape:2; + u16 size:2; + u16 tileOffset:10; + u16 priority:2; +}; + +struct SubspriteTable +{ + u8 subspriteCount; + const struct Subsprite *subsprites; +}; + +struct Sprite; + +struct SpriteTemplate +{ + u16 tileTag; + u16 paletteTag; + const struct OamData *oam; + const union AnimCmd *const *anims; + const struct SpriteFrameImage *images; + const union AffineAnimCmd *const *affineAnims; + void (*callback)(struct Sprite *); +}; + +struct Sprite +{ + /*0x00*/ struct OamData oam; + /*0x08*/ const union AnimCmd *const *anims; + /*0x0C*/ const struct SpriteFrameImage *images; + /*0x10*/ const union AffineAnimCmd *const *affineAnims; + /*0x14*/ const struct SpriteTemplate *template; + /*0x18*/ const struct SubspriteTable *subspriteTables; + /*0x1C*/ void (*callback)(struct Sprite *); + + /*0x20*/ struct Coords16 pos1; + /*0x24*/ struct Coords16 pos2; + /*0x28*/ s8 centerToCornerVecX; + /*0x29*/ s8 centerToCornerVecY; + + /*0x2A*/ u8 animNum; + /*0x2B*/ u8 animCmdIndex; + /*0x2C*/ u8 animDelayCounter:6; + u8 animPaused:1; + u8 affineAnimPaused:1; + /*0x2D*/ u8 animLoopCounter; + + // general purpose data fields + /*0x2E*/ s16 data0; + /*0x30*/ s16 data1; + /*0x32*/ s16 data2; + /*0x34*/ s16 data3; + /*0x36*/ s16 data4; + /*0x38*/ s16 data5; + /*0x3A*/ s16 data6; + /*0x3C*/ s16 data7; + + /*0x3E*/ u16 inUse:1; //1 + u16 coordOffsetEnabled:1; //2 + u16 invisible:1; //4 + u16 flags_3:1; //8 + u16 flags_4:1; //0x10 + u16 flags_5:1; //0x20 + u16 flags_6:1; //0x40 + u16 flags_7:1; //0x80 + /*0x3F*/ u16 hFlip:1; + u16 vFlip:1; + u16 animBeginning:1; + u16 affineAnimBeginning:1; + u16 animEnded:1; + u16 affineAnimEnded:1; + u16 usingSheet:1; + u16 flags_f:1; + + /*0x40*/ u16 sheetTileStart; + + /*0x42*/ u8 subspriteTableNum:6; + u8 subspriteMode:2; + + /*0x43*/ u8 subpriority; +}; + +struct OamMatrix +{ + s16 a; + s16 b; + s16 c; + s16 d; +}; + +extern struct Sprite gSprites[]; + +extern const struct OamData gDummyOamData; + +void ResetSpriteData(void); +void AnimateSprites(void); +void BuildOamBuffer(void); +u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); +u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); +u8 CreateInvisibleSprite(void (*callback)(struct Sprite *)); +u8 CreateSpriteAndAnimate(struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); +void DestroySprite(struct Sprite *sprite); +void ResetOamRange(u8 a, u8 b); +void LoadOam(void); +void SetOamMatrix(u8 matrixNum, u16 a, u16 b, u16 c, u16 d); +void CalcCenterToCornerVec(struct Sprite *sprite, u8 shape, u8 size, u8 affineMode); +void SpriteCallbackDummy(struct Sprite *sprite); +void ProcessSpriteCopyRequests(void); +void RequestSpriteCopy(const u8 *src, u8 *dest, u16 size); +void FreeSpriteTiles(struct Sprite *sprite); +void FreeSpritePalette(struct Sprite *sprite); +void FreeSpriteOamMatrix(struct Sprite *sprite); +void DestroySpriteAndFreeResources(struct Sprite *sprite); +void sub_800142C(u32 a1, u32 a2, u16 *a3, u16 a4, u32 a5); +void AnimateSprite(struct Sprite *sprite); +void StartSpriteAnim(struct Sprite *sprite, u8 animNum); +void StartSpriteAnimIfDifferent(struct Sprite *sprite, u8 animNum); +void SeekSpriteAnim(struct Sprite *sprite, u8 animCmdIndex); +void StartSpriteAffineAnim(struct Sprite *sprite, u8 animNum); +void StartSpriteAffineAnimIfDifferent(struct Sprite *sprite, u8 animNum); +void ChangeSpriteAffineAnim(struct Sprite *sprite, u8 animNum); +void ChangeSpriteAffineAnimIfDifferent(struct Sprite *sprite, u8 animNum); +void SetSpriteSheetFrameTileNum(struct Sprite *sprite); +u8 AllocOamMatrix(void); +void FreeOamMatrix(u8 matrixNum); +void InitSpriteAffineAnim(struct Sprite *sprite); +void SetOamMatrixRotationScaling(u8 matrixNum, s16 xScale, s16 yScale, u16 rotation); +u16 LoadSpriteSheet(const struct SpriteSheet *sheet); +void LoadSpriteSheets(const struct SpriteSheet *sheets); +u16 AllocTilesForSpriteSheet(struct SpriteSheet *sheet); +void AllocTilesForSpriteSheets(struct SpriteSheet *sheets); +void LoadTilesForSpriteSheet(const struct SpriteSheet *sheet); +void LoadTilesForSpriteSheets(struct SpriteSheet *sheets); +void FreeSpriteTilesByTag(u16 tag); +void FreeSpriteTileRanges(void); +u16 GetSpriteTileStartByTag(u16 tag); +u16 GetSpriteTileTagByTileStart(u16 start); +void RequestSpriteSheetCopy(const struct SpriteSheet *sheet); +u16 LoadSpriteSheetDeferred(const struct SpriteSheet *sheet); +void FreeAllSpritePalettes(void); +u8 LoadSpritePalette(const struct SpritePalette *palette); +void LoadSpritePalettes(const struct SpritePalette *palettes); +u8 AllocSpritePalette(u16 tag); +u8 IndexOfSpritePaletteTag(u16 tag); +u16 GetSpritePaletteTagByPaletteNum(u8 paletteNum); +void FreeSpritePaletteByTag(u16 tag); +void SetSubspriteTables(struct Sprite *sprite, const struct SubspriteTable *subspriteTables); +bool8 AddSpriteToOamBuffer(struct Sprite *object, u8 *oamIndex); +bool8 AddSubspritesToOamBuffer(struct Sprite *sprite, struct OamData *destOam, u8 *oamIndex); +void CopyToSprites(u8 *src); +void CopyFromSprites(u8 *dest); +u8 SpriteTileAllocBitmapOp(u16 bit, u8 op); +void ClearSpriteCopyRequests(void); +void ResetAffineAnimData(void); + +#endif //GUARD_SPRITE_H diff --git a/include/text_window.h b/include/text_window.h new file mode 100644 index 000000000..0cefeea8e --- /dev/null +++ b/include/text_window.h @@ -0,0 +1,22 @@ +#ifndef GUARD_TEXT_WINDOW_H +#define GUARD_TEXT_WINDOW_H + +struct TilesPal +{ + u32* tiles; + u16* pal; +}; + +const struct TilesPal* sub_8098758(u8 id); +void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset); +void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset); +void sub_80987D4(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset); +void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset); +void sub_8098858(u8 windowId, u16 tileNum, u8 palNum); +void sub_80989E0(u8 windowId, u16 tileNum, u8 palNum); +void rbox_fill_rectangle(u8 windowId); +const u16* stdpal_get(u8 id); +const u16* sub_8098C64(void); +void sub_8098C6C(u8 bg, u16 destOffset, u8 palOffset); + +#endif // GUARD_TEXT_WINDOW_H diff --git a/include/trig.h b/include/trig.h new file mode 100644 index 000000000..a2f98a3e6 --- /dev/null +++ b/include/trig.h @@ -0,0 +1,11 @@ +#ifndef GUARD_TRIG_H +#define GUARD_TRIG_H + +extern const s16 gSineTable[]; + +s16 Sin(s16 index, s16 amplitude); +s16 Cos(s16 index, s16 amplitude); +s16 Sin2(u16 angle); +s16 Cos2(u16 angle); + +#endif // GUARD_TRIG_H diff --git a/include/vars.h b/include/vars.h new file mode 100644 index 000000000..efbb462a4 --- /dev/null +++ b/include/vars.h @@ -0,0 +1,53 @@ +#ifndef GUARD_VARS_H +#define GUARD_VARS_H + +#define VAR_0x4000 0x4000 +#define VAR_0x4001 0x4001 +#define VAR_0x4002 0x4002 +#define VAR_0x4003 0x4003 +#define VAR_0x4004 0x4004 +#define VAR_0x4005 0x4005 +#define VAR_0x4006 0x4006 +#define VAR_0x4007 0x4007 +#define VAR_0x4008 0x4008 +#define VAR_0x4009 0x4009 +#define VAR_0x400A 0x400A +#define VAR_0x401F 0x401F +#define VAR_RECYCLE_GOODS 0x4020 +#define VAR_REPEL_STEP_COUNT 0x4021 +#define VAR_ICE_STEP_COUNT 0x4022 +#define VAR_FIRST_POKE 0x4023 +#define VAR_MIRAGE_RND_H 0x4024 +#define VAR_MIRAGE_RND_L 0x4025 +#define VAR_SECRET_BASE_MAP 0x4026 + +#define VAR_HAPPINESS_STEP_COUNTER 0x402A +#define VAR_POISON_STEP_COUNTER 0x402B +#define VAR_RESET_RTC_ENABLE 0x402C + +#define VAR_DAYS 0x4040 + +#define VAR_DEPT_STORE_FLOOR 0x4043 +#define VAR_POKELOT_PRIZE 0x4045 +#define VAR_NATIONAL_DEX 0x4046 +#define VAR_SHROOMISH_SIZE_RECORD 0x4047 +#define VAR_ASH_GATHER_COUNT 0x4048 +#define VAR_BIRCH_STATE 0x4049 +#define VAR_CRUISE_STEP_COUNT 0x404A +#define VAR_POKELOT_RND1 0x404B +#define VAR_POKELOT_RND2 0x404C + +#define VAR_BARBOACH_SIZE_RECORD 0x404F + +#define VAR_0x4054 0x4054 + +#define VAR_0x4089 0x4089 +#define VAR_0x4095 0x4095 +#define VAR_0x4097 0x4097 +#define VAR_0x409a 0x409a +#define VAR_PORTHOLE 0x40B4 + +#define VAR_0x40BC 0x40BC +#define VAR_0x40C2 0x40C2 + +#endif // GUARD_VARS_H diff --git a/include/window.h b/include/window.h index ca0520d41..6f5f55c11 100644 --- a/include/window.h +++ b/include/window.h @@ -1,6 +1,18 @@ #ifndef GUARD_WINDOW_H #define GUARD_WINDOW_H +enum +{ + WINDOW_PRIORITY, + WINDOW_TILEMAP_LEFT, + WINDOW_TILEMAP_TOP, + WINDOW_WIDTH, + WINDOW_HEIGHT, + WINDOW_PALETTE_NUM, + WINDOW_BASE_BLOCK, + WINDOW_TILE_DATA +}; + struct WindowTemplate { u8 priority; @@ -18,4 +30,32 @@ struct Window u8 *tileData; }; +bool16 InitWindows(struct WindowTemplate *templates); +u16 AddWindow(struct WindowTemplate *template); +int AddWindowWithoutTileMap(struct WindowTemplate *template); +void RemoveWindow(u8 windowId); +void FreeAllWindowBuffers(void); +void CopyWindowToVram(u8 windowId, u8 mode); +void CopyWindowRectToVram(u32 windowId, u32 mode, u32 x, u32 y, u32 w, u32 h); +void PutWindowTilemap(u8 windowId); +void PutWindowRectTilemapOverridePalette(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 palette); +void ClearWindowTilemap(u8 windowId); +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 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)); +bool8 SetWindowAttribute(u8 windowId, u8 attributeId, u32 value); +u32 GetWindowAttribute(u8 windowId, u8 attributeId); +u16 AddWindow8Bit(struct WindowTemplate *template); +u16 AddWindow8Bit(struct WindowTemplate *template); +void FillWindowPixelRect8Bit(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); +void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum); +void CopyWindowToVram8Bit(u8 windowId, u8 mode); + +extern struct Window gWindows[]; + #endif // GUARD_WINDOW_H |