From 74b81bf229ded3212ab77701aebd4e16799731ec Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 13 Oct 2018 00:48:26 +0200 Subject: start apprentice --- include/global.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 9ae892b5c..9b66f7da6 100644 --- a/include/global.h +++ b/include/global.h @@ -297,9 +297,16 @@ struct UnknownSaveBlock2Struct struct UnkRecordMixingStruct { - u8 field_0[0x34]; + u8 field_0_0:5; + u8 field_0_1:2; + u8 field_1; + u8 field_2; + u8 field_3[37]; + u16 unk28[6]; u8 playerId[4]; - u8 field_38[10]; + u8 playerName[PLAYER_NAME_LENGTH]; + u8 language; + u32 unk40; }; struct UnknownPokemonStruct @@ -492,10 +499,12 @@ struct SaveBlock2 // TODO: fix and verify labels /*0xB0*/ u8 field_B0; - /*0xB1*/ u8 field_B1; + /*0xB1*/ u8 field_B1_0:2; + /*0xB1*/ u8 field_B1_1:6; /*0xB2*/ u8 field_B2_0:3; /*0xB2*/ u8 field_B2_1:2; - /*0xB3*/ u8 field_B3[0x29]; + /*0xB3*/ u8 field_B3; + /*0xB4*/ u8 field_B4[0x28]; /*0xDC*/ struct UnkRecordMixingStruct field_DC[4]; /*0x1EC*/ struct BerryCrush berryCrush; /*0x1FC*/ struct PokemonJumpResults pokeJump; -- cgit v1.2.3 From a496a763ca54871e19e2482b550127e2aa709b05 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 13 Oct 2018 20:38:46 +0200 Subject: Merge record mixing, pokemon and global with apprentice --- include/apprentice.h | 17 +++++++++++++++++ include/global.h | 29 ++++++++++++++++++++++++----- include/pokemon.h | 28 +--------------------------- include/script_menu.h | 1 + 4 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 include/apprentice.h (limited to 'include') diff --git a/include/apprentice.h b/include/apprentice.h new file mode 100644 index 000000000..98185e3c2 --- /dev/null +++ b/include/apprentice.h @@ -0,0 +1,17 @@ +#ifndef GUARD_APPRENTICE_H +#define GUARD_APPRENTICE_H + +#define APPRENTICE_SPECIES_COUNT 10 + +struct ApprenticeTrainer +{ + u8 name[6][PLAYER_NAME_LENGTH + 1]; // For all six languages. + u16 otId; + u16 facilityClass; + u16 species[APPRENTICE_SPECIES_COUNT]; + u8 rest[14]; +}; + +extern const struct ApprenticeTrainer gApprentices[]; + +#endif // GUARD_APPRENTICE_H diff --git a/include/global.h b/include/global.h index 9b66f7da6..ec9fc99bf 100644 --- a/include/global.h +++ b/include/global.h @@ -295,13 +295,21 @@ struct UnknownSaveBlock2Struct u8 field_EB; }; // sizeof = 0xEC -struct UnkRecordMixingStruct +struct ApprenticeMon +{ + u16 species; + u16 moves[4]; + u16 item; +}; + +struct Apprentice { u8 field_0_0:5; u8 field_0_1:2; u8 field_1; u8 field_2; - u8 field_3[37]; + u8 field_3; + struct ApprenticeMon monData[3]; u16 unk28[6]; u8 playerId[4]; u8 playerName[PLAYER_NAME_LENGTH]; @@ -473,6 +481,15 @@ struct BattleFrontier /*0xEFC*/ struct FrontierMonData field_EFC[3]; }; +struct Sav2_B8 +{ + u8 unk0_0:2; + u8 unk0_1:2; + u8 unk0_2:2; + u8 unk0_3:2; + u16 unk2; +}; + struct SaveBlock2 { /*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; @@ -500,12 +517,14 @@ struct SaveBlock2 // TODO: fix and verify labels /*0xB0*/ u8 field_B0; /*0xB1*/ u8 field_B1_0:2; - /*0xB1*/ u8 field_B1_1:6; + /*0xB1*/ u8 field_B1_1:4; + /*0xB1*/ u8 field_B1_2:2; /*0xB2*/ u8 field_B2_0:3; /*0xB2*/ u8 field_B2_1:2; /*0xB3*/ u8 field_B3; - /*0xB4*/ u8 field_B4[0x28]; - /*0xDC*/ struct UnkRecordMixingStruct field_DC[4]; + /*0xB4*/ u8 field_B4[3]; + /*0xB8*/ struct Sav2_B8 field_B8[9]; + /*0xDC*/ struct Apprentice field_DC[4]; /*0x1EC*/ struct BerryCrush berryCrush; /*0x1FC*/ struct PokemonJumpResults pokeJump; /*0x20C*/ struct BerryPickingResults berryPick; diff --git a/include/pokemon.h b/include/pokemon.h index 9eddd8155..d261fba85 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -240,32 +240,6 @@ struct PokemonStorage /*0x83C2*/ u8 boxWallpapers[14]; }; -struct UnknownPokemonSubStruct2 -{ - u16 species; - u16 moves[4]; - u16 item; -}; - -struct UnknownPokemonStruct2 -{ - u8 field_0_0 : 5; - u8 field_0_1 : 2; - u8 field_1; - u8 field_2; - u8 field_3; - struct UnknownPokemonSubStruct2 mons[3]; - u8 field_28[23]; - u8 language; -}; - -struct UnknownPokemonStruct3 -{ - u8 field_0[48]; - u16 field_30; - u8 field_32[38]; -}; - struct Unknown_806F160_Struct { u8 field_0_0:4; @@ -472,7 +446,7 @@ void CreateMonWithIVsOTID(struct Pokemon *mon, u16 species, u8 level, u8 *ivs, u void CreateMonWithEVSpread(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 evSpread); void sub_806819C(struct Pokemon *mon, struct UnknownPokemonStruct *src); void sub_8068338(struct Pokemon *mon, struct UnknownPokemonStruct *src, bool8 lvl50); -void sub_8068528(struct Pokemon *mon, const struct UnknownPokemonStruct2 *src, u8 monId); +void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId); void CreateMonWithEVSpreadPersonalityOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId); void sub_80686FC(struct Pokemon *mon, struct UnknownPokemonStruct *dest); void CreateObedientMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); diff --git a/include/script_menu.h b/include/script_menu.h index c50bef00f..8870e80b9 100644 --- a/include/script_menu.h +++ b/include/script_menu.h @@ -13,5 +13,6 @@ s32 convert_pixel_width_to_tile_width(s32); u8 CreateWindowFromRect(u8, u8, u8, u8); void sub_80E2A78(u8); u32 display_text_and_get_width(const u8*, u32); +u8 sub_80E2D5C(u8 arg0, u8 tileWidth); #endif //GUARD_SCRIPT_MENU_H -- cgit v1.2.3 From 36b8a6a9a2ad5aca2e5d59a1293222819d987aa6 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 13 Oct 2018 23:23:33 +0200 Subject: More apprentice work --- include/global.h | 2 +- include/menu.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index ec9fc99bf..0100d04db 100644 --- a/include/global.h +++ b/include/global.h @@ -310,7 +310,7 @@ struct Apprentice u8 field_2; u8 field_3; struct ApprenticeMon monData[3]; - u16 unk28[6]; + u16 easyChatWords[6]; u8 playerId[4]; u8 playerName[PLAYER_NAME_LENGTH]; u8 language; diff --git a/include/menu.h b/include/menu.h index cddab0870..7815f71d8 100644 --- a/include/menu.h +++ b/include/menu.h @@ -50,7 +50,7 @@ void blit_move_info_icon(u8 winId, u8 a2, u16 x, u16 y); void reset_temp_tile_data_buffers(void); void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size, u16 offset, u8 mode); bool8 free_temp_tile_data_buffers_if_possible(void); -struct WindowTemplate CreateWindowTemplate(u8, u8, u8, u8, u8, u8, u16); +struct WindowTemplate CreateWindowTemplate(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock); void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos); void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, int size, u16 offset, u8 mode); s8 Menu_ProcessInputNoWrap_(void); -- cgit v1.2.3 From b4a42a6832e851f457636da61fceb530b77962f9 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 11:37:44 +0200 Subject: Decompile apprentice --- include/apprentice.h | 4 +++- include/constants/apprentice.h | 11 +++++++++++ include/item_menu.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 include/constants/apprentice.h (limited to 'include') diff --git a/include/apprentice.h b/include/apprentice.h index 98185e3c2..86c6250a0 100644 --- a/include/apprentice.h +++ b/include/apprentice.h @@ -7,11 +7,13 @@ struct ApprenticeTrainer { u8 name[6][PLAYER_NAME_LENGTH + 1]; // For all six languages. u16 otId; - u16 facilityClass; + u8 facilityClass; u16 species[APPRENTICE_SPECIES_COUNT]; u8 rest[14]; }; extern const struct ApprenticeTrainer gApprentices[]; +const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language); + #endif // GUARD_APPRENTICE_H diff --git a/include/constants/apprentice.h b/include/constants/apprentice.h new file mode 100644 index 000000000..7fa78bfbe --- /dev/null +++ b/include/constants/apprentice.h @@ -0,0 +1,11 @@ +#ifndef GUARD_CONSTANTS_APPRENTICE_H +#define GUARD_CONSTANTS_APPRENTICE_H + +#define APPRENTICE_ASK_WHICH_LEVEL 0 +#define APPRENTICE_ASK_3SPECIES 1 +#define APPRENTICE_ASK_2SPECIES 2 +#define APPRENTICE_ASK_MOVES 3 +#define APPRENTICE_ASK_GIVE 4 +#define APPRENTICE_ASK_YES_NO 6 + +#endif // GUARD_CONSTANTS_APPRENTICE_H diff --git a/include/item_menu.h b/include/item_menu.h index 8a474bc0f..59316e948 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -54,6 +54,7 @@ extern u16 gSpecialVar_ItemId; void sub_81AAC14(void); void sub_81AAC50(void); void sub_81AAC70(void); +void sub_81AAC28(void); void bag_menu_mail_related(void); void CB2_BagMenuFromStartMenu(void); u8 sub_81ABB2C(u8 pocketId); -- cgit v1.2.3 From 145df4906326488874b3f75ef96f99e85b18f2a0 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 14:35:51 +0200 Subject: Document more of apprentice --- include/apprentice.h | 1 + include/constants/apprentice.h | 11 +++++++++++ include/global.h | 11 +++++------ 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/apprentice.h b/include/apprentice.h index 86c6250a0..90383b737 100644 --- a/include/apprentice.h +++ b/include/apprentice.h @@ -14,6 +14,7 @@ struct ApprenticeTrainer extern const struct ApprenticeTrainer gApprentices[]; +void CopyFriendsApprenticeChallengeText(u8 saveblockApprenticeId); const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language); #endif // GUARD_APPRENTICE_H diff --git a/include/constants/apprentice.h b/include/constants/apprentice.h index 7fa78bfbe..9db58bb8e 100644 --- a/include/constants/apprentice.h +++ b/include/constants/apprentice.h @@ -8,4 +8,15 @@ #define APPRENTICE_ASK_GIVE 4 #define APPRENTICE_ASK_YES_NO 6 +#define APPRENTICE_BUFF_SPECIES1 0 +#define APPRENTICE_BUFF_SPECIES2 1 +#define APPRENTICE_BUFF_SPECIES3 2 +#define APPRENTICE_BUFF_MOVE1 3 +#define APPRENTICE_BUFF_MOVE2 4 +#define APPRENTICE_BUFF_ITEM 5 +#define APPRENTICE_BUFF_NAME 6 +#define APPRENTICE_BUFF_EASY_CHAT 7 +#define APPRENTICE_BUFF_LEVEL 8 +#define APPRENTICE_BUFF_SPECIES4 9 + #endif // GUARD_CONSTANTS_APPRENTICE_H diff --git a/include/global.h b/include/global.h index 0100d04db..43e829dcf 100644 --- a/include/global.h +++ b/include/global.h @@ -304,11 +304,10 @@ struct ApprenticeMon struct Apprentice { - u8 field_0_0:5; - u8 field_0_1:2; + u8 id:5; + u8 lvlMode:2; // + 1 u8 field_1; - u8 field_2; - u8 field_3; + u8 number; struct ApprenticeMon monData[3]; u16 easyChatWords[6]; u8 playerId[4]; @@ -514,7 +513,7 @@ struct SaveBlock2 /*0xA8*/ u32 field_A8; /*0xAC*/ u32 encryptionKey; - // TODO: fix and verify labels + // Possibly player's apprentice, will document once battle tower is decompiled. /*0xB0*/ u8 field_B0; /*0xB1*/ u8 field_B1_0:2; /*0xB1*/ u8 field_B1_1:4; @@ -524,7 +523,7 @@ struct SaveBlock2 /*0xB3*/ u8 field_B3; /*0xB4*/ u8 field_B4[3]; /*0xB8*/ struct Sav2_B8 field_B8[9]; - /*0xDC*/ struct Apprentice field_DC[4]; + /*0xDC*/ struct Apprentice apprentices[4]; /*0x1EC*/ struct BerryCrush berryCrush; /*0x1FC*/ struct PokemonJumpResults pokeJump; /*0x20C*/ struct BerryPickingResults berryPick; -- cgit v1.2.3 From 7952cfeba5c9eaed2cd58a7f49dea8d676a56840 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 16:27:48 +0200 Subject: document more of apprentice --- include/global.h | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 43e829dcf..2c5ce3777 100644 --- a/include/global.h +++ b/include/global.h @@ -178,12 +178,14 @@ enum OPTIONS_BATTLE_STYLE_SET }; -struct Coords8 { +struct Coords8 +{ s8 x; s8 y; }; -struct UCoords8 { +struct UCoords8 +{ u8 x; u8 y; }; @@ -489,6 +491,19 @@ struct Sav2_B8 u16 unk2; }; +struct PlayersApprentice +{ + /*0xB0*/ u8 id; + /*0xB1*/ u8 activeLvlMode:2; // +1, 0 means not active + /*0xB1*/ u8 field_B1_1:4; + /*0xB1*/ u8 field_B1_2:2; + /*0xB2*/ u8 field_B2_0:3; + /*0xB2*/ u8 field_B2_1:2; + /*0xB3*/ u8 field_B3; + /*0xB4*/ u8 monIds[3]; + /*0xB8*/ struct Sav2_B8 field_B8[9]; +}; + struct SaveBlock2 { /*0x00*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; @@ -512,17 +527,7 @@ struct SaveBlock2 /*0xA0*/ struct Time lastBerryTreeUpdate; /*0xA8*/ u32 field_A8; /*0xAC*/ u32 encryptionKey; - - // Possibly player's apprentice, will document once battle tower is decompiled. - /*0xB0*/ u8 field_B0; - /*0xB1*/ u8 field_B1_0:2; - /*0xB1*/ u8 field_B1_1:4; - /*0xB1*/ u8 field_B1_2:2; - /*0xB2*/ u8 field_B2_0:3; - /*0xB2*/ u8 field_B2_1:2; - /*0xB3*/ u8 field_B3; - /*0xB4*/ u8 field_B4[3]; - /*0xB8*/ struct Sav2_B8 field_B8[9]; + /*0xB0*/ struct PlayersApprentice playerApprentice; /*0xDC*/ struct Apprentice apprentices[4]; /*0x1EC*/ struct BerryCrush berryCrush; /*0x1FC*/ struct PokemonJumpResults pokeJump; -- cgit v1.2.3 From f47ed3268c76b43db4bce0a60f355b18d0edc875 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 17:00:41 +0200 Subject: Finish documenting apprentice for now --- include/apprentice.h | 4 ++++ include/battle_frontier_2.h | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/apprentice.h b/include/apprentice.h index 90383b737..ca0b04800 100644 --- a/include/apprentice.h +++ b/include/apprentice.h @@ -15,6 +15,10 @@ struct ApprenticeTrainer extern const struct ApprenticeTrainer gApprentices[]; void CopyFriendsApprenticeChallengeText(u8 saveblockApprenticeId); +void Apprentice_EnableBothScriptContexts(void); +void ResetApprenticeStruct(struct Apprentice *apprentice); +void ResetAllApprenticeData(void); +void CallApprenticeFunction(void); const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language); #endif // GUARD_APPRENTICE_H diff --git a/include/battle_frontier_2.h b/include/battle_frontier_2.h index d032f9f74..573053f10 100644 --- a/include/battle_frontier_2.h +++ b/include/battle_frontier_2.h @@ -11,7 +11,6 @@ void sub_81A895C(void); u16 sub_81A89A0(u8); void sub_81A8AF8(void); bool8 InBattlePike(void); -void sub_819FA50(void); void sub_81AA078(u16*, u8); void sub_81A4C30(void); bool8 sub_81A6BF4(void); -- cgit v1.2.3