From 154a70e22829891ec56561e454a73a67e609679d Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 11 Sep 2017 11:35:41 +0200 Subject: start pokemon3 decomp --- include/battle.h | 15 +++- include/battle_message.h | 5 ++ include/global.berry.h | 8 +- include/link.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++ include/pokemon.h | 32 ++++++++ include/trainer_class.h | 53 +++++++++++++ 6 files changed, 300 insertions(+), 7 deletions(-) create mode 100644 include/link.h create mode 100644 include/trainer_class.h (limited to 'include') diff --git a/include/battle.h b/include/battle.h index 1db546de3..81d3e2c82 100644 --- a/include/battle.h +++ b/include/battle.h @@ -187,8 +187,7 @@ struct Trainer { /*0x00*/ u8 partyFlags; /*0x01*/ u8 trainerClass; - /*0x02*/ u8 encounterMusic:7; - /*0x02*/ u8 gender:1; + /*0x02*/ u8 encounterMusic_gender; // last bit is gender /*0x03*/ u8 trainerPic; /*0x04*/ u8 trainerName[12]; /*0x10*/ u16 items[4]; @@ -200,6 +199,8 @@ struct Trainer extern const struct Trainer gTrainers[]; +#define TRAINER_ENCOUNTER_MUSIC(trainer)((gTrainers[trainer].encounterMusic_gender & 0x7F)) + struct UnknownFlags { u32 flags[4]; @@ -412,4 +413,12 @@ struct BattleScripting extern struct BattleScripting gBattleScripting; -#endif +struct BattleDecompressedSprites +{ + void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon + void* sprites[4]; +}; + +extern struct BattleDecompressedSprites* gBattleDecompressedSprites; + +#endif // GUARD_BATTLE_H diff --git a/include/battle_message.h b/include/battle_message.h index 3e37a1ccd..ca310ae6f 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -20,4 +20,9 @@ void BufferStringBattle(u16 stringID); u32 StrCpyDecodeToDisplayedStringBattle(const u8* src); u32 StrCpyDecodeBattle(const u8* src, u8* dst); +extern u8 gBattleTextBuff1[]; +extern u8 gBattleTextBuff2[]; +extern u8 gBattleTextBuff3[]; +extern u8 gDisplayedStringBattle[]; + #endif // GUARD_BATTLE_MESSAGE_H diff --git a/include/global.berry.h b/include/global.berry.h index 6695a9f4b..4b9ca644c 100644 --- a/include/global.berry.h +++ b/include/global.berry.h @@ -42,14 +42,14 @@ struct Berry2 struct EnigmaBerry { struct Berry2 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; + u8 pic[(6 * 6) * TILE_SIZE_4BPP]; + u16 palette[16]; + u8 description1[45]; + u8 description2[45]; }; struct BattleEnigmaBerry diff --git a/include/link.h b/include/link.h new file mode 100644 index 000000000..5db3ff3d2 --- /dev/null +++ b/include/link.h @@ -0,0 +1,194 @@ +#ifndef GUARD_LINK_H +#define GUARD_LINK_H + +#define MAX_LINK_PLAYERS 4 +#define CMD_LENGTH 8 +#define QUEUE_CAPACITY 50 +#define BLOCK_BUFFER_SIZE 0x100 + +#define LINK_STAT_LOCAL_ID 0x00000003 +#define LINK_STAT_PLAYER_COUNT 0x0000001C +#define LINK_STAT_PLAYER_COUNT_SHIFT 2 +#define LINK_STAT_MASTER 0x00000020 +#define LINK_STAT_MASTER_SHIFT 5 +#define LINK_STAT_CONN_ESTABLISHED 0x00000040 +#define LINK_STAT_CONN_ESTABLISHED_SHIFT 6 +#define LINK_STAT_RECEIVED_NOTHING 0x00000100 +#define LINK_STAT_RECEIVED_NOTHING_SHIFT 8 +#define LINK_STAT_ERRORS 0x0007F000 + +#define EXTRACT_PLAYER_COUNT(status) \ +(((status) & LINK_STAT_PLAYER_COUNT) >> LINK_STAT_PLAYER_COUNT_SHIFT) +#define EXTRACT_MASTER(status) \ +(((status) >> LINK_STAT_MASTER_SHIFT) & 1) +#define EXTRACT_CONN_ESTABLISHED(status) \ +(((status) >> LINK_STAT_CONN_ESTABLISHED_SHIFT) & 1) +#define EXTRACT_RECEIVED_NOTHING(status) \ +(((status) >> LINK_STAT_RECEIVED_NOTHING_SHIFT) & 1) + +#define MASTER_HANDSHAKE 0x8FFF +#define SLAVE_HANDSHAKE 0xB9A0 + +enum +{ + LINK_STATE_START0, + LINK_STATE_START1, + LINK_STATE_HANDSHAKE, + LINK_STATE_INIT_TIMER, + LINK_STATE_CONN_ESTABLISHED, +}; + +enum +{ + EXCHANGE_NOT_STARTED, + EXCHANGE_COMPLETE, + EXCHANGE_TIMED_OUT, + EXCHANGE_IN_PROGRESS, +}; + +enum +{ + QUEUE_FULL_NONE, + QUEUE_FULL_SEND, + QUEUE_FULL_RECV, +}; + +enum +{ + LAG_NONE, + LAG_MASTER, + LAG_SLAVE, +}; + +struct LinkPlayer +{ + /* 0x00 */ u16 version; + /* 0x02 */ u16 lp_field_2; + /* 0x04 */ u32 trainerId; + /* 0x08 */ u8 name[11]; + /* 0x13 */ u8 gender; + /* 0x14 */ u32 linkType; + /* 0x18 */ u16 lp_field_18; + /* 0x1A */ u16 language; +}; + +struct LinkPlayerBlock +{ + u8 magic1[16]; + struct LinkPlayer linkPlayer; + u8 magic2[16]; +}; + +// circular queues + +struct SendQueue +{ + u16 data[CMD_LENGTH][QUEUE_CAPACITY]; + u8 pos; + u8 count; +}; + +struct RecvQueue +{ + u16 data[MAX_LINK_PLAYERS][CMD_LENGTH][QUEUE_CAPACITY]; + u8 pos; + u8 count; +}; + +struct Link +{ + u8 isMaster; // 0: slave, 8: master + u8 state; + u8 localId; // local multi-player ID + u8 playerCount; + u16 tempRecvBuffer[4]; + bool8 receivedNothing; + s8 serialIntrCounter; + bool8 handshakeAsMaster; + u8 link_field_F; + + // error conditions + bool8 hardwareError; // hardware reported an error + bool8 badChecksum; // checksum didn't match between devices + u8 queueFull; // send or recv queue out of space + u8 lag; // connection is lagging + + u16 checksum; + + u8 sendCmdIndex; + u8 recvCmdIndex; + + struct SendQueue sendQueue; + struct RecvQueue recvQueue; +}; + +struct BlockRequest +{ + void * address; + u32 size; +}; + +extern const struct BlockRequest sBlockRequestLookupTable[5]; + +extern struct Link gLink; +extern u16 gRecvCmds[CMD_LENGTH][MAX_LINK_PLAYERS]; +extern u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE]; +extern u16 gLinkType; +extern u32 gLinkStatus; +extern u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2]; +extern u16 gSendCmd[CMD_LENGTH]; +extern u8 gShouldAdvanceLinkState; +extern struct LinkPlayer gLinkPlayers[]; +extern u16 word_3002910[]; +extern bool8 gReceivedRemoteLinkPlayers; + +void Task_DestroySelf(u8); +void sub_8007270(u8); +void OpenLink(void); +void CloseLink(void); +u16 LinkMain2(u16 *); +void sub_8007B14(void); +bool32 sub_8007B24(void); +void ClearLinkCallback(void); +void ClearLinkCallback_2(void); +u8 GetLinkPlayerCount(void); +void OpenLinkTimed(void); +u8 GetLinkPlayerDataExchangeStatusTimed(void); +bool8 IsLinkPlayerDataExchangeComplete(void); +u32 GetLinkPlayerTrainerId(u8); +void ResetLinkPlayers(void); +void sub_8007E24(void); +void sub_8007E4C(void); +u8 GetMultiplayerId(void); +u8 bitmask_all_link_players_but_self(void); +bool8 SendBlock(u8, void *, u16); +bool8 sub_8007E9C(u8); +bool8 sub_8007ECC(void); +u8 GetBlockReceivedStatus(void); +void ResetBlockReceivedFlags(void); +void ResetBlockReceivedFlag(u8); +void sub_8007F4C(void); +void SetLinkDebugValues(u32, u32); +u8 sub_8008198(void); +void sub_80081C8(u8); +u8 sub_800820C(void); +u8 sub_8008218(void); +void sub_800826C(void); +void sub_80082EC(void); +u8 GetLinkPlayerCount_2(void); +bool8 IsLinkMaster(void); +void sub_800832C(void); +void sub_8008480(void); +void sub_80084A4(void); +void CB2_LinkError(void); +u8 GetSioMultiSI(void); +bool8 IsLinkConnectionEstablished(void); +void SetSuppressLinkErrorMessage(bool8); +bool8 HasLinkErrorOccurred(void); +void ResetSerial(void); +u32 LinkMain1(u8 *, u16 *, u16[CMD_LENGTH][MAX_LINK_PLAYERS]); +void LinkVSync(void); +void Timer3Intr(void); +void SerialCB(void); + +#endif // GUARD_LINK_H diff --git a/include/pokemon.h b/include/pokemon.h index a335e0154..cfee4261c 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -420,6 +420,12 @@ struct BattleMove u8 flags; }; +struct SpindaSpot +{ + u8 x, y; + u16 image[16]; +}; + struct __attribute__((packed)) LevelUpMove { u16 move:9; @@ -483,9 +489,11 @@ extern struct Pokemon gPlayerParty[PARTY_SIZE]; extern u8 gEnemyPartyCount; extern struct Pokemon gEnemyParty[PARTY_SIZE]; extern const struct BaseStats gBaseStats[]; +extern const u8 *const gItemEffectTable[]; extern const struct EvolutionData gEvolutionTable[]; extern struct PokemonStorage* gPokemonStoragePtr; extern const u32 gExperienceTables[][MAX_MON_LEVEL + 1]; +extern const u16 *const gLevelUpLearnsets[]; void ZeroBoxMonData(struct BoxPokemon *boxMon); void ZeroMonData(struct Pokemon *mon); @@ -551,4 +559,28 @@ void CopyPlayerPartyMonToBattleData(u8 battleIndex, u8 partyIndex); u8 GetNature(struct Pokemon *mon); u8 GetNatureFromPersonality(u32 personality); +u16 nature_stat_mod(u8 nature, u16 n, u8 statIndex); + +void MonRestorePP(struct Pokemon *); + +u16 NationalPokedexNumToSpecies(u16 nationalNum); +u16 NationalToHoennOrder(u16); +u16 SpeciesToNationalPokedexNum(u16); +u16 HoennToNationalOrder(u16); +u16 SpeciesToCryId(u16 species); +void DrawSpindaSpots(u16, u32, u8 *, u8); +void AdjustFriendship(struct Pokemon *, u8); +u8 CheckPartyHasHadPokerus(struct Pokemon *, u8); +void UpdatePartyPokerusTime(u16); +u32 CanMonLearnTMHM(struct Pokemon *, u8); +u32 CanSpeciesLearnTMHM(u16 species, u8 tm); +u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves); +void ClearBattleMonForms(void); +const u8 *pokemon_get_pal(struct Pokemon *mon); +const u8 *species_and_otid_get_pal(u16, u32, u32); +const struct CompressedSpritePalette *sub_80409C8(u16, u32, u32); +bool8 IsOtherTrainer(u32, u8 *); +void SetWildMonHeldItem(void); +u16 GetMonEVCount(struct Pokemon *); + #endif // GUARD_POKEMON_H diff --git a/include/trainer_class.h b/include/trainer_class.h new file mode 100644 index 000000000..14fc69a24 --- /dev/null +++ b/include/trainer_class.h @@ -0,0 +1,53 @@ +#ifndef GUARD_TRAINER_CLASS_H +#define GUARD_TRAINER_CLASS_H + +enum +{ + CLASS_PKMN_TRAINER0, //0 + CLASS_PKMN_TRAINER1, //1 + CLASS_HIKER, //2 + CLASS_TEAM_AQUA, //3 + CLASS_PKMN_BREEDER, //4 + CLASS_COOLTRAINER, //5 + CLASS_BIRDKEEPER, //6 + CLASS_COLLECTOR, //7 + CLASS_SWIMMER_MALE, //8 + CLASS_TEAM_MAGMA, //9 + CLASS_EXPERT, // 0xA + CLASS_AQUA_ADMIN, // 0xB + CLASS_BLACK_BELT, // 0xC + CLASS_AQUA_LEADER, // 0xD + CLASS_HEX_MANIAC, // 0xE + CLASS_AROMA_LADY, // 0xF + CLASS_RUIN_MANIAC, // 0x10 + CLASS_INTERVIEWER, // 0x11 + CLASS_TUBER_FEMALE, // 0x12 + CLASS_TUBER_MALE, // 0x13 + CLASS_LADY, // 0x14 + CLASS_BEAUTY, // 0x15 + CLASS_RICH_BOY, // 0x16 + CLASS_POKEMANIAC, // 0x17 + CLASS_GUITARIST, // 0x18 + CLASS_KINDLER, // 0x19 + CLASS_CAMPER, // 0x1A + CLASS_PICKNICKER, // 0x1B + CLASS_BUG_MANIAC, // 0x1C + CLASS_PSYCHIC, // 0x1D + CLASS_GENTLEMAN, // 0x1E + CLASS_ELITE_FOUR, // 0x1F + CLASS_LEADER, // 0x20 + CLASS_CHAMPION = 0x26, + CLASS_MAGMA_ADMIN = 0x31, + CLASS_PKMN_TRAINER_RIVAL = 0x32, + CLASS_MAGMA_LEADER = 0x35, + CLASS_SALON_MAIDEN = 0x3A, + CLASS_DOME_ACE, // 0x3B + CLASS_PALACE_MAVEN, // 0x3C + CLASS_ARENA_TYCOON, // 0x3D + CLASS_FACTORY_HEAD, // 0x3E + CLASS_PIKE_QUEEN, // 0x3F + CLASS_PYRAMID_KING, // 0x40 + CLASS_PKMN_TRAINER2, // 0x41 +}; + +#endif // GUARD_TRAINER_CLASS_H -- cgit v1.2.3 From 5394435520c4942ec9935454ff420acbab2ff4e4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 11 Sep 2017 14:42:13 +0200 Subject: more of pokemon3 decompiled --- include/battle.h | 102 +++++++++++++++++++++++++++++++++++++++++++++- include/m4a.h | 1 + include/pokemon.h | 8 ++++ include/trainer_class.h | 53 ------------------------ include/trainer_classes.h | 53 ++++++++++++++++++++++++ include/trainer_ids.h | 6 +++ 6 files changed, 169 insertions(+), 54 deletions(-) delete mode 100644 include/trainer_class.h create mode 100644 include/trainer_classes.h create mode 100644 include/trainer_ids.h (limited to 'include') diff --git a/include/battle.h b/include/battle.h index 81d3e2c82..61270bed0 100644 --- a/include/battle.h +++ b/include/battle.h @@ -32,6 +32,8 @@ #define BATTLE_TYPE_KYORGE 0x20000000 #define BATTLE_TYPE_RAYQUAZA 0x40000000 +#define STEVEN_PARTNER_ID 0xC03 + #define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) #define BATTLE_WON 0x1 @@ -337,7 +339,105 @@ struct BattleStruct u8 wildVictorySong; u8 dynamicMoveType; u8 wrappedBy[4]; - u8 field_18[0x63]; // TODO: expand + u8 field_18; + u8 field_19; + u8 field_1A; + u8 field_1B; + u8 field_1C; + u8 field_1D; + u8 field_1E; + u8 field_1F; + u8 field_20; + u8 field_21; + u8 field_22; + u8 field_23; + u8 field_24; + u8 field_25; + u8 field_26; + u8 field_27; + u8 field_28; + u8 field_29; + u8 field_2A; + u8 field_2B; + u8 field_2C; + u8 field_2D; + u8 field_2E; + u8 field_2F; + u8 field_30; + u8 field_31; + u8 field_32; + u8 field_33; + u8 field_34; + u8 field_35; + u8 field_36; + u8 field_37; + u8 field_38; + u8 field_39; + u8 field_3A; + u8 field_3B; + u8 field_3C; + u8 field_3D; + u8 field_3E; + u8 field_3F; + u8 field_40; + u8 field_41; + u8 field_42; + u8 field_43; + u8 field_44; + u8 field_45; + u8 field_46; + u8 field_47; + u8 field_48; + u8 field_49; + u8 field_4A; + u8 field_4B; + u8 field_4C; + u8 field_4D; + u8 field_4E; + u8 field_4F; + u8 field_50; + u8 field_51; + u8 field_52; + u8 field_53; + u8 field_54; + u8 field_55; + u8 field_56; + u8 field_57; + u8 field_58; + u8 field_59; + u8 field_5A; + u8 field_5B; + u8 field_5C; + u8 field_5D; + u8 field_5E; + u8 field_5F; + u8 field_60; + u8 field_61; + u8 field_62; + u8 field_63; + u8 field_64; + u8 field_65; + u8 field_66; + u8 field_67; + u8 field_68; + u8 field_69; + u8 field_6A; + u8 field_6B; + u8 field_6C; + u8 field_6D; + u8 field_6E; + u8 field_6F; + u8 field_70; + u8 field_71; + u8 field_72; + u8 field_73; + u8 field_74; + u8 field_75; + u8 field_76; + u8 field_77; + u8 field_78; + u8 field_79; + u8 field_7A; u8 field_7B; u8 field_7C; u8 field_7D; diff --git a/include/m4a.h b/include/m4a.h index 949403885..b6c8f9072 100644 --- a/include/m4a.h +++ b/include/m4a.h @@ -9,6 +9,7 @@ void m4aSoundInit(void); void m4aSoundMain(void); void m4aSongNumStart(u16); void m4aSongNumStop(u16 n); +void m4aMPlayAllStop(void); void m4aMPlayContinue(struct MusicPlayerInfo *mplayInfo); void m4aMPlayFadeOut(struct MusicPlayerInfo *mplayInfo, u16 speed); void m4aMPlayFadeOutTemporarily(struct MusicPlayerInfo *mplayInfo, u16 speed); diff --git a/include/pokemon.h b/include/pokemon.h index cfee4261c..12b58ba9f 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -562,6 +562,7 @@ u8 GetNatureFromPersonality(u32 personality); u16 nature_stat_mod(u8 nature, u16 n, u8 statIndex); void MonRestorePP(struct Pokemon *); +void BoxMonRestorePP(struct BoxPokemon *); u16 NationalPokedexNumToSpecies(u16 nationalNum); u16 NationalToHoennOrder(u16); @@ -583,4 +584,11 @@ bool8 IsOtherTrainer(u32, u8 *); void SetWildMonHeldItem(void); u16 GetMonEVCount(struct Pokemon *); +const struct CompressedSpritePalette *sub_806E794(struct Pokemon *mon); +const struct CompressedSpritePalette *sub_806E7CC(u16 species, u32 otId , u32 personality); +bool32 IsHMMove2(u16 move); +bool8 IsPokeSpriteNotFlipped(u16 species); +bool8 IsMonShiny(struct Pokemon *mon); +bool8 IsShinyOtIdPersonality(u32 otId, u32 personality); + #endif // GUARD_POKEMON_H diff --git a/include/trainer_class.h b/include/trainer_class.h deleted file mode 100644 index 14fc69a24..000000000 --- a/include/trainer_class.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GUARD_TRAINER_CLASS_H -#define GUARD_TRAINER_CLASS_H - -enum -{ - CLASS_PKMN_TRAINER0, //0 - CLASS_PKMN_TRAINER1, //1 - CLASS_HIKER, //2 - CLASS_TEAM_AQUA, //3 - CLASS_PKMN_BREEDER, //4 - CLASS_COOLTRAINER, //5 - CLASS_BIRDKEEPER, //6 - CLASS_COLLECTOR, //7 - CLASS_SWIMMER_MALE, //8 - CLASS_TEAM_MAGMA, //9 - CLASS_EXPERT, // 0xA - CLASS_AQUA_ADMIN, // 0xB - CLASS_BLACK_BELT, // 0xC - CLASS_AQUA_LEADER, // 0xD - CLASS_HEX_MANIAC, // 0xE - CLASS_AROMA_LADY, // 0xF - CLASS_RUIN_MANIAC, // 0x10 - CLASS_INTERVIEWER, // 0x11 - CLASS_TUBER_FEMALE, // 0x12 - CLASS_TUBER_MALE, // 0x13 - CLASS_LADY, // 0x14 - CLASS_BEAUTY, // 0x15 - CLASS_RICH_BOY, // 0x16 - CLASS_POKEMANIAC, // 0x17 - CLASS_GUITARIST, // 0x18 - CLASS_KINDLER, // 0x19 - CLASS_CAMPER, // 0x1A - CLASS_PICKNICKER, // 0x1B - CLASS_BUG_MANIAC, // 0x1C - CLASS_PSYCHIC, // 0x1D - CLASS_GENTLEMAN, // 0x1E - CLASS_ELITE_FOUR, // 0x1F - CLASS_LEADER, // 0x20 - CLASS_CHAMPION = 0x26, - CLASS_MAGMA_ADMIN = 0x31, - CLASS_PKMN_TRAINER_RIVAL = 0x32, - CLASS_MAGMA_LEADER = 0x35, - CLASS_SALON_MAIDEN = 0x3A, - CLASS_DOME_ACE, // 0x3B - CLASS_PALACE_MAVEN, // 0x3C - CLASS_ARENA_TYCOON, // 0x3D - CLASS_FACTORY_HEAD, // 0x3E - CLASS_PIKE_QUEEN, // 0x3F - CLASS_PYRAMID_KING, // 0x40 - CLASS_PKMN_TRAINER2, // 0x41 -}; - -#endif // GUARD_TRAINER_CLASS_H diff --git a/include/trainer_classes.h b/include/trainer_classes.h new file mode 100644 index 000000000..3f13dfc37 --- /dev/null +++ b/include/trainer_classes.h @@ -0,0 +1,53 @@ +#ifndef GUARD_TRAINER_CLASSES_H +#define GUARD_TRAINER_CLASSES_H + +enum +{ + CLASS_PKMN_TRAINER0, //0 + CLASS_PKMN_TRAINER1, //1 + CLASS_HIKER, //2 + CLASS_TEAM_AQUA, //3 + CLASS_PKMN_BREEDER, //4 + CLASS_COOLTRAINER, //5 + CLASS_BIRDKEEPER, //6 + CLASS_COLLECTOR, //7 + CLASS_SWIMMER_MALE, //8 + CLASS_TEAM_MAGMA, //9 + CLASS_EXPERT, // 0xA + CLASS_AQUA_ADMIN, // 0xB + CLASS_BLACK_BELT, // 0xC + CLASS_AQUA_LEADER, // 0xD + CLASS_HEX_MANIAC, // 0xE + CLASS_AROMA_LADY, // 0xF + CLASS_RUIN_MANIAC, // 0x10 + CLASS_INTERVIEWER, // 0x11 + CLASS_TUBER_FEMALE, // 0x12 + CLASS_TUBER_MALE, // 0x13 + CLASS_LADY, // 0x14 + CLASS_BEAUTY, // 0x15 + CLASS_RICH_BOY, // 0x16 + CLASS_POKEMANIAC, // 0x17 + CLASS_GUITARIST, // 0x18 + CLASS_KINDLER, // 0x19 + CLASS_CAMPER, // 0x1A + CLASS_PICKNICKER, // 0x1B + CLASS_BUG_MANIAC, // 0x1C + CLASS_PSYCHIC, // 0x1D + CLASS_GENTLEMAN, // 0x1E + CLASS_ELITE_FOUR, // 0x1F + CLASS_LEADER, // 0x20 + CLASS_CHAMPION = 0x26, + CLASS_MAGMA_ADMIN = 0x31, + CLASS_PKMN_TRAINER_RIVAL = 0x32, + CLASS_MAGMA_LEADER = 0x35, + CLASS_SALON_MAIDEN = 0x3A, + CLASS_DOME_ACE, // 0x3B + CLASS_PALACE_MAVEN, // 0x3C + CLASS_ARENA_TYCOON, // 0x3D + CLASS_FACTORY_HEAD, // 0x3E + CLASS_PIKE_QUEEN, // 0x3F + CLASS_PYRAMID_KING, // 0x40 + CLASS_PKMN_TRAINER2, // 0x41 +}; + +#endif // GUARD_TRAINER_CLASSES_H diff --git a/include/trainer_ids.h b/include/trainer_ids.h new file mode 100644 index 000000000..1dd3ba3ac --- /dev/null +++ b/include/trainer_ids.h @@ -0,0 +1,6 @@ +#ifndef GUARD_TRAINER_IDS_H +#define GUARD_TRAINER_IDS_H + +#define TRAINER_ID_STEVEN 804 + +#endif // GUARD_TRAINER_IDS_H -- cgit v1.2.3 From 8e88f2790af8e98d695c35088cf7b493356ae03c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 11 Sep 2017 18:27:54 +0200 Subject: pokemon2 get mon data troubles --- include/battle.h | 11 +++++++++-- include/pokemon.h | 8 ++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/battle.h b/include/battle.h index 61270bed0..01d89fc35 100644 --- a/include/battle.h +++ b/include/battle.h @@ -33,9 +33,13 @@ #define BATTLE_TYPE_RAYQUAZA 0x40000000 #define STEVEN_PARTNER_ID 0xC03 +#define SECRET_BASE_OPPONENT 0x400 #define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) +#define SIDE_PLAYER 0x0 +#define SIDE_OPPONENT 0x1 + #define BATTLE_WON 0x1 #define BATTLE_LOST 0x2 #define BATTLE_DREW 0x3 @@ -513,12 +517,15 @@ struct BattleScripting extern struct BattleScripting gBattleScripting; -struct BattleDecompressedSprites +#include "sprite.h" + +struct BattleSpritesGfx { void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon void* sprites[4]; + struct SpriteTemplate templates[4]; }; -extern struct BattleDecompressedSprites* gBattleDecompressedSprites; +extern struct BattleSpritesGfx* gBattleSpritesGfx; #endif // GUARD_BATTLE_H diff --git a/include/pokemon.h b/include/pokemon.h index 12b58ba9f..a7d89ea29 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -89,7 +89,7 @@ #define MON_DATA_DEF2 85 #define MON_DATA_SPD2 86 #define MON_DATA_SPATK2 87 -#define MON_DATA_SPDEF2 88 +#define MON_DATA_SPDEF2 88 #define OT_ID_RANDOM_NO_SHINY 2 #define OT_ID_PRESET 1 @@ -279,7 +279,7 @@ struct Pokemon struct BoxPokemon box; u32 status; u8 level; - u8 pokerus; + u8 mail; u16 hp; u16 maxHP; u16 attack; @@ -495,6 +495,10 @@ extern struct PokemonStorage* gPokemonStoragePtr; extern const u32 gExperienceTables[][MAX_MON_LEVEL + 1]; extern const u16 *const gLevelUpLearnsets[]; +#define BATTLE_ALIVE_EXCEPT_ACTIVE 0 +#define BATTLE_ALIVE_ATK_SIDE 1 +#define BATTLE_ALIVE_DEF_SIDE 2 + void ZeroBoxMonData(struct BoxPokemon *boxMon); void ZeroMonData(struct Pokemon *mon); void ZeroPlayerPartyMons(void); -- cgit v1.2.3 From e69606b5cb75ebb433f462ea7859ac9fbf025561 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 11 Sep 2017 19:42:37 +0200 Subject: praise cam the CHAMP man --- include/pokemon.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/pokemon.h b/include/pokemon.h index a7d89ea29..dc81b28e2 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -374,6 +374,16 @@ enum STAT_STAGE_EVASION, // 7 }; +enum +{ + STAT_HP, // 0 + STAT_ATK, // 1 + STAT_DEF, // 2 + STAT_SPD, // 3 + STAT_SPATK, // 4 + STAT_SPDEF, // 5 +}; + struct BaseStats { /* 0x00 */ u8 baseHP; -- cgit v1.2.3 From 738e77663092eaee6ebf3f243c4194e47694f2c5 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 11 Sep 2017 22:28:36 +0200 Subject: more pokemon2 decomp --- include/flags.h | 2 ++ include/pokemon.h | 19 ++++++++++++++----- include/text.h | 1 + include/vars.h | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/flags.h b/include/flags.h index 56e87b895..362e1be53 100644 --- a/include/flags.h +++ b/include/flags.h @@ -84,6 +84,8 @@ #define SYS_CTRL_OBJ_DELETE CODE_FLAGS + 0x61 #define SYS_RESET_RTC_ENABLE CODE_FLAGS + 0x62 +#define SYS_STORAGE_UNKNOWN_FLAG CODE_FLAGS + 0x77 + #define SYS_MYSTERY_GIFT_ENABLE CODE_FLAGS + 0x7B // SPECIAL FLAGS (unknown purpose) diff --git a/include/pokemon.h b/include/pokemon.h index dc81b28e2..dfb035133 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -81,10 +81,10 @@ #define MON_DATA_GIFT_RIBBON_6 77 #define MON_DATA_GIFT_RIBBON_7 78 #define MON_DATA_FATEFUL_ENCOUNTER 79 -#define MON_DATA_KNOWN_MOVES 80 -#define MON_DATA_RIBBON_COUNT 81 -#define MON_DATA_RIBBONS 82 -#define MON_DATA_83 83 +#define MON_DATA_OBEDIENCE 80 +#define MON_DATA_KNOWN_MOVES 81 +#define MON_DATA_RIBBON_COUNT 82 +#define MON_DATA_RIBBONS 83 #define MON_DATA_ATK2 84 #define MON_DATA_DEF2 85 #define MON_DATA_SPD2 86 @@ -95,6 +95,14 @@ #define OT_ID_PRESET 1 #define OT_ID_PLAYER_ID 0 +#define MON_GIVEN_TO_PARTY 0x0 +#define MON_GIVEN_TO_PC 0x1 +#define MON_CANT_GIVE 0x2 + +#define PLAYER_HAS_TWO_USABLE_MONS 0x0 +#define PLAYER_HAS_ONE_MON 0x1 +#define PLAYER_HAS_ONE_USABLE_MON 0x2 + #define MON_MALE 0x00 #define MON_FEMALE 0xFE #define MON_GENDERLESS 0xFF @@ -240,7 +248,8 @@ struct PokemonSubstruct3 /* 0x0B */ u32 giftRibbon5:1; /* 0x0B */ u32 giftRibbon6:1; /* 0x0B */ u32 giftRibbon7:1; - /* 0x0B */ u32 fatefulEncounter:5; // unused in Ruby/Sapphire, but the high bit must be set for Mew/Deoxys to obey in FR/LG/Emerald + /* 0x0B */ u32 fatefulEncounter:4; + /* 0x0B */ u32 obedient:1; }; union PokemonSubstruct diff --git a/include/text.h b/include/text.h index f52336d84..73e6e5437 100644 --- a/include/text.h +++ b/include/text.h @@ -74,6 +74,7 @@ #define EOS 0xFF // end of string #define EXT_CTRL_CODE_JPN 0x15 +#define EXT_CTRL_CODE_ENG 0x16 #define NUM_TEXT_PRINTERS 32 diff --git a/include/vars.h b/include/vars.h index 8a779dccf..5da960640 100644 --- a/include/vars.h +++ b/include/vars.h @@ -28,6 +28,7 @@ #define VAR_DAYS 0x4040 #define VAR_DEPT_STORE_FLOOR 0x4043 +#define VAR_STORAGE_UNKNOWN 0x4036 #define VAR_POKELOT_PRIZE 0x4045 #define VAR_NATIONAL_DEX 0x4046 #define VAR_SEEDOT_SIZE_RECORD 0x4047 -- cgit v1.2.3 From 4242ede44580122ee1b0e340737149e8311da8a5 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 12 Sep 2017 00:01:12 +0200 Subject: almost there, troubles --- include/battle.h | 2 +- include/pokemon.h | 4 ++-- include/species.h | 12 ++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/battle.h b/include/battle.h index 01d89fc35..51f9298cc 100644 --- a/include/battle.h +++ b/include/battle.h @@ -289,7 +289,7 @@ struct BattleScriptsStack struct BattleResources { - void* secretBaseOpponent; + struct SecretBaseRecord* secretBase; struct UnknownFlags *flags; struct BattleScriptsStack* battleScriptsStack; void* battleCallbackStack; diff --git a/include/pokemon.h b/include/pokemon.h index dfb035133..fefe2bd28 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -571,8 +571,8 @@ u8 GetMonAbility(struct Pokemon *mon); void CreateSecretBaseEnemyParty(struct SecretBaseRecord *secretBaseRecord); u8 GetSecretBaseTrainerPicIndex(void); u8 GetSecretBaseTrainerNameIndex(void); -u8 PlayerPartyAndPokemonStorageFull(void); -u8 PokemonStorageFull(void); +bool8 IsPlayerPartyAndPokemonStorageFull(void); +bool8 IsPokemonStorageFull(void); void GetSpeciesName(u8 *name, u16 species); u8 CalculatePPWithBonus(u16 move, u8 ppBonuses, u8 moveIndex); void RemoveMonPPBonus(struct Pokemon *mon, u8 moveIndex); diff --git a/include/species.h b/include/species.h index 5cce48ad6..9ab0565cb 100644 --- a/include/species.h +++ b/include/species.h @@ -1,4 +1,8 @@ -enum { +#ifndef GUARD_SPECIES_H +#define GUARD_SPECIES_H + +enum +{ SPECIES_NONE, // 0x000 SPECIES_BULBASAUR, // 0x001 SPECIES_IVYSAUR, // 0x002 @@ -442,4 +446,8 @@ enum { SPECIES_UNOWN_Z, SPECIES_UNOWN_EMARK, SPECIES_UNOWN_QMARK, -}; \ No newline at end of file +}; + +#define NUM_SPECIES SPECIES_EGG + +#endif // GUARD_SPECIES_H -- cgit v1.2.3 From 6539188fa65826e2c2b101d6502f3b7794dd5197 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 12 Sep 2017 13:05:54 +0200 Subject: label and decomp some pokemon animation stuff --- include/pokemon_animation.h | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 include/pokemon_animation.h (limited to 'include') diff --git a/include/pokemon_animation.h b/include/pokemon_animation.h new file mode 100644 index 000000000..42fc10809 --- /dev/null +++ b/include/pokemon_animation.h @@ -0,0 +1,7 @@ +#ifndef GUARD_POKEMON_ANIMATION_H +#define GUARD_POKEMON_ANIMATION_H + +void LaunchAnimationTaskForFrontSprite(struct Sprite* sprite, u8 frontAnimId); +void LaunchAnimationTaskForBackSprite(struct Sprite* sprite, u8 backAnimId); + +#endif // GUARD_POKEMON_ANIMATION_H -- cgit v1.2.3 From 0fe703023011421d9686ab0666904ae594906e7b Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 12 Sep 2017 15:05:40 +0200 Subject: pokemon 3 is almost decompiled --- include/flags.h | 4 ++-- include/pokedex.h | 20 ++++++++++++++++++++ include/trainer_ids.h | 3 ++- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 include/pokedex.h (limited to 'include') diff --git a/include/flags.h b/include/flags.h index 362e1be53..19ec01b56 100644 --- a/include/flags.h +++ b/include/flags.h @@ -2,8 +2,8 @@ #define GUARD_FLAGS_H #define TRAINER_FLAG_START 0x500 -#define TRAINERS_FLAG_NO 0x360 -#define CODE_FLAGS (TRAINER_FLAG_START + TRAINERS_FLAG_NO) +#define TRAINERS_FLAG_NO 0x356 +#define CODE_FLAGS (TRAINER_FLAG_START + TRAINERS_FLAG_NO + 0xA) // SYSTEM FLAGS diff --git a/include/pokedex.h b/include/pokedex.h new file mode 100644 index 000000000..15f819a2a --- /dev/null +++ b/include/pokedex.h @@ -0,0 +1,20 @@ +#ifndef GUARD_POKEDEX_H +#define GUARD_POKEDEX_H + +void ResetPokedex(void); +const u8 *GetPokemonCategory(u16); +u16 GetPokedexHeightWeight(u16 dexNum, u8 data); +u16 GetNationalPokedexCount(u8); +u16 GetHoennPokedexCount(u8); + +enum +{ + FLAG_GET_SEEN, + FLAG_GET_CAUGHT, + FLAG_SET_SEEN, + FLAG_SET_CAUGHT +}; + +u8 GetSetPokedexFlag(u16 nationalNum, u8 caseId); + +#endif // GUARD_POKEDEX_H diff --git a/include/trainer_ids.h b/include/trainer_ids.h index 1dd3ba3ac..65c80187f 100644 --- a/include/trainer_ids.h +++ b/include/trainer_ids.h @@ -1,6 +1,7 @@ #ifndef GUARD_TRAINER_IDS_H #define GUARD_TRAINER_IDS_H -#define TRAINER_ID_STEVEN 804 +#define NO_OF_TRAINERS 854 +#define TRAINER_ID_STEVEN 804 #endif // GUARD_TRAINER_IDS_H -- cgit v1.2.3 From 8731a8caa5602a516972329f7aa0624794b29ff2 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 12 Sep 2017 15:36:04 +0200 Subject: one more function in pokemon1 --- include/global.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 32c13d86c..2dfabeb6a 100644 --- a/include/global.h +++ b/include/global.h @@ -184,7 +184,8 @@ struct SaveBlock2 // All below could be a one giant struct /*0x64C*/ u8 field_64C[1629]; - /*0xCA9*/ u8 frontierChosenLvl; + /*0xCA9*/ u8 frontierChosenLvl : 2; + /*0xCA9*/ u8 field_CA9_a : 6; /*0xCAA*/ u8 field_CAA[368]; /*0xE1A*/ u16 battlePyramidFloor; // possibly? /*0xE1C*/ u8 field_E1C[16]; -- cgit v1.2.3 From 5f4c5e280cda788f2c575d860a6333fc6cbebebe Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 13 Sep 2017 11:16:26 +0200 Subject: berry.s decompiled --- include/berry.h | 4 +++- include/fieldmap.h | 6 ++++++ include/global.berry.h | 4 ---- include/global.h | 8 +++++--- 4 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 include/fieldmap.h (limited to 'include') diff --git a/include/berry.h b/include/berry.h index f0acbe0ad..7c2636411 100644 --- a/include/berry.h +++ b/include/berry.h @@ -37,12 +37,14 @@ 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 FieldObjectInteractionGetBerryTreeData(void); -void sub_80B4EE4(void); void FieldObjectInteractionPlantBerryTree(void); void FieldObjectInteractionPickBerryTree(void); void FieldObjectInteractionRemoveBerryTree(void); u8 PlayerHasBerries(void); void ResetBerryTreeSparkleFlags(void); +extern const struct Berry gBerries[]; + #endif // GUARD_BERRY_H diff --git a/include/fieldmap.h b/include/fieldmap.h new file mode 100644 index 000000000..f3b5a7668 --- /dev/null +++ b/include/fieldmap.h @@ -0,0 +1,6 @@ +#ifndef GUARD_FIELDMAP_H +#define GUARD_FIELDMAP_H + +void GetCameraCoords(u16*, u16*); + +#endif // GUARD_FIELDMAP_H diff --git a/include/global.berry.h b/include/global.berry.h index 6695a9f4b..a77da20ba 100644 --- a/include/global.berry.h +++ b/include/global.berry.h @@ -42,10 +42,6 @@ struct Berry2 struct EnigmaBerry { struct Berry2 berry; - u8 pic[(6 * 6) * TILE_SIZE_4BPP]; - u16 palette[16]; - u8 description1[45]; - u8 description2[45]; u8 itemEffect[18]; u8 holdEffect; u8 holdEffectParam; diff --git a/include/global.h b/include/global.h index 32c13d86c..5340a9790 100644 --- a/include/global.h +++ b/include/global.h @@ -649,8 +649,9 @@ struct DaycareData u8 stepCounter; }; -#define FLAGS_NUMBER 300 -#define VARS_NUMBER 256 +#define BERRY_TREES_NUMBER 128 +#define FLAGS_NUMBER 300 +#define VARS_NUMBER 256 struct SaveBlock1 { @@ -688,7 +689,7 @@ struct SaveBlock1 /*0x1270*/ u8 flags[FLAGS_NUMBER]; /*0x139C*/ u16 vars[VARS_NUMBER]; /*0x159C*/ u32 gameStats[NUM_GAME_STATS]; - /*0x169C*/ struct BerryTree berryTrees[128]; + /*0x169C*/ struct BerryTree berryTrees[BERRY_TREES_NUMBER]; /*0x1A9C*/ struct SecretBaseRecord secretBases[20]; /*0x271C*/ u8 playerRoomDecor[12]; /*0x2728*/ u8 playerRoomDecorPos[12]; @@ -731,6 +732,7 @@ struct SaveBlock1 /*0x31A8*/ u8 giftRibbons[52]; /*0x31DC*/ struct Roamer roamer; /*0x31F8*/ struct EnigmaBerry enigmaBerry; + /*0x322C*/ u8 field_322C[1276]; /*0x3728*/ struct RamScript ramScript; /*0x3B14*/ struct RecordMixingGift recordMixingGift; /*0x3B24*/ u8 seen2[52]; -- cgit v1.2.3 From a08cd8e5a718ad4383a5b66b48e44a50a99dc6bf Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 13 Sep 2017 12:17:48 +0200 Subject: define number of map objects --- include/global.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 5340a9790..c5fa7fef3 100644 --- a/include/global.h +++ b/include/global.h @@ -649,6 +649,7 @@ struct DaycareData u8 stepCounter; }; +#define MAP_OBJECTS_NUMBER 16 #define BERRY_TREES_NUMBER 128 #define FLAGS_NUMBER 300 #define VARS_NUMBER 256 @@ -684,7 +685,7 @@ struct SaveBlock1 /*0x9C2*/ u8 field_9C2[6]; /*0x9C8*/ u16 trainerRematchStepCounter; /*0x9CA*/ u8 trainerRematches[100]; - /*0xA30*/ struct MapObject mapObjects[16]; + /*0xA30*/ struct MapObject mapObjects[MAP_OBJECTS_NUMBER]; /*0xC70*/ struct MapObjectTemplate mapObjectTemplates[64]; /*0x1270*/ u8 flags[FLAGS_NUMBER]; /*0x139C*/ u16 vars[VARS_NUMBER]; -- cgit v1.2.3 From b1e90c1d5011ea19a50cacbb36bda39e436b1e56 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 13 Sep 2017 19:30:05 +0200 Subject: review berry cleanings --- include/global.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index c5fa7fef3..5b4bdc2a1 100644 --- a/include/global.h +++ b/include/global.h @@ -649,10 +649,10 @@ struct DaycareData u8 stepCounter; }; -#define MAP_OBJECTS_NUMBER 16 -#define BERRY_TREES_NUMBER 128 -#define FLAGS_NUMBER 300 -#define VARS_NUMBER 256 +#define MAP_OBJECTS_COUNT 16 +#define BERRY_TREES_COUNT 128 +#define FLAGS_COUNT 300 +#define VARS_COUNT 256 struct SaveBlock1 { @@ -685,12 +685,12 @@ struct SaveBlock1 /*0x9C2*/ u8 field_9C2[6]; /*0x9C8*/ u16 trainerRematchStepCounter; /*0x9CA*/ u8 trainerRematches[100]; - /*0xA30*/ struct MapObject mapObjects[MAP_OBJECTS_NUMBER]; + /*0xA30*/ struct MapObject mapObjects[MAP_OBJECTS_COUNT]; /*0xC70*/ struct MapObjectTemplate mapObjectTemplates[64]; - /*0x1270*/ u8 flags[FLAGS_NUMBER]; - /*0x139C*/ u16 vars[VARS_NUMBER]; + /*0x1270*/ u8 flags[FLAGS_COUNT]; + /*0x139C*/ u16 vars[VARS_COUNT]; /*0x159C*/ u32 gameStats[NUM_GAME_STATS]; - /*0x169C*/ struct BerryTree berryTrees[BERRY_TREES_NUMBER]; + /*0x169C*/ struct BerryTree berryTrees[BERRY_TREES_COUNT]; /*0x1A9C*/ struct SecretBaseRecord secretBases[20]; /*0x271C*/ u8 playerRoomDecor[12]; /*0x2728*/ u8 playerRoomDecorPos[12]; -- cgit v1.2.3