From 145df4906326488874b3f75ef96f99e85b18f2a0 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 14:35:51 +0200 Subject: [PATCH] Document more of apprentice --- asm/battle_frontier_2.s | 2 +- asm/battle_tower.s | 2 +- data/scripts/apprentice.inc | 211 +++++++++------------------------ include/apprentice.h | 1 + include/constants/apprentice.h | 11 ++ include/global.h | 11 +- src/apprentice.c | 110 +++++++++-------- src/pokemon.c | 10 +- src/record_mixing.c | 8 +- 9 files changed, 141 insertions(+), 225 deletions(-) diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index f8334b5a5..7f987ce4b 100644 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -3620,7 +3620,7 @@ _081A3758: adds r0, 0x70 lsls r0, 24 lsrs r0, 24 - bl sub_819F99C + bl CopyFriendsApprenticeChallengeText b _081A38F8 _081A3766: movs r0, 0xFA diff --git a/asm/battle_tower.s b/asm/battle_tower.s index aa6e3d779..0f319ab1e 100644 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -2831,7 +2831,7 @@ _0816399C: adds r0, 0x70 lsls r0, 24 lsrs r0, 24 - bl sub_819F99C + bl CopyFriendsApprenticeChallengeText _081639A8: pop {r0} bx r0 diff --git a/data/scripts/apprentice.inc b/data/scripts/apprentice.inc index 1021fb8b2..d157c0b45 100644 --- a/data/scripts/apprentice.inc +++ b/data/scripts/apprentice.inc @@ -1,5 +1,26 @@ #include "constants/apprentice.h" +.macro apprentice_msg waitbuttonpress which +setvar VAR_0x8004, 8 +setvar VAR_0x8005, \waitbuttonpress +setvar VAR_0x8006, \which +special sub_81A085C +.endm + +.macro apprentice_buff whichstringvar tobuff +setvar VAR_0x8004, 16 +setvar VAR_0x8005, \whichstringvar +setvar VAR_0x8006, \tobuff +special sub_81A085C +.endm + +.macro apprentice_menu which +setvar VAR_0x8004, 7 +setvar VAR_0x8005, \which +special sub_81A085C +waitstate +.endm + EventScript_Apprentice:: @ 82B688D lock faceplayer @@ -32,46 +53,25 @@ BattleFrontier_BattleTowerLobby_EventScript_2B68BE: end BattleFrontier_BattleTowerLobby_EventScript_2B6900: - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 6 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 0 - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_NAME + apprentice_msg FALSE, 0 waitstate BattleFrontier_BattleTowerLobby_EventScript_2B6925: - setvar VAR_0x8004, 7 - setvar VAR_0x8005, APPRENTICE_ASK_YES_NO - special sub_81A085C - waitstate + apprentice_menu APPRENTICE_ASK_YES_NO compare VAR_RESULT, 1 goto_eq BattleFrontier_BattleTowerLobby_EventScript_2B69BB - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 2 - special sub_81A085C - waitstate - setvar VAR_0x8004, 7 - setvar VAR_0x8005, APPRENTICE_ASK_WHICH_LEVEL - special sub_81A085C + apprentice_msg FALSE, 2 waitstate + apprentice_menu APPRENTICE_ASK_WHICH_LEVEL setvar VAR_0x8004, 1 setorcopyvar VAR_0x8005, VAR_RESULT addvar VAR_0x8005, 1 special sub_81A085C setvar VAR_0x8004, 3 special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 8 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 3 - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_LEVEL + apprentice_msg TRUE, 3 waitstate call BattleFrontier_BattleTowerLobby_EventScript_2B6E4D release @@ -82,10 +82,7 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6925: end BattleFrontier_BattleTowerLobby_EventScript_2B69BB: - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 1 - special sub_81A085C + apprentice_msg FALSE, 1 waitstate goto BattleFrontier_BattleTowerLobby_EventScript_2B6925 @@ -93,23 +90,11 @@ BattleFrontier_BattleTowerLobby_EventScript_2B69D3: setvar VAR_0x8004, 14 setvar VAR_0x8005, 2 special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 0 - special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 1 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 6 - special sub_81A085C - waitstate - setvar VAR_0x8004, 7 - setvar VAR_0x8005, APPRENTICE_ASK_2SPECIES - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_SPECIES1 + apprentice_buff 1, APPRENTICE_BUFF_SPECIES2 + apprentice_msg FALSE, 6 waitstate + apprentice_menu APPRENTICE_ASK_2SPECIES copyvar VAR_0x8005, VAR_RESULT compare VAR_0x8005, 0 call_if 1, BattleFrontier_BattleTowerLobby_EventScript_2B6ABA @@ -132,10 +117,7 @@ BattleFrontier_BattleTowerLobby_EventScript_2B69D3: special sub_81A085C setvar VAR_0x8004, 15 special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 7 - special sub_81A085C + apprentice_msg TRUE, 7 waitstate call BattleFrontier_BattleTowerLobby_EventScript_2B6E4D release @@ -162,14 +144,8 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6ACF: setvar VAR_0x8004, 14 setvar VAR_0x8005, 4 special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 2 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 10 - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_SPECIES3 + apprentice_msg TRUE, 10 waitstate setvar VAR_0x8004, 15 special sub_81A085C @@ -186,14 +162,8 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6B09: special sub_81A085C compare VAR_RESULT, 0 goto_eq BattleFrontier_BattleTowerLobby_EventScript_2B6C0C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 5 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 12 - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_ITEM + apprentice_msg TRUE, 12 waitstate setvar VAR_0x8004, 5 special sub_81A085C @@ -209,29 +179,17 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6B81: setvar VAR_0x8004, 14 setvar VAR_0x8005, 4 special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 2 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 13 - special sub_81A085C - waitstate - setvar VAR_0x8004, 7 - setvar VAR_0x8005, APPRENTICE_ASK_GIVE - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_SPECIES3 + apprentice_msg FALSE, 13 waitstate + apprentice_menu APPRENTICE_ASK_GIVE setvar VAR_0x8004, 15 special sub_81A085C compare VAR_RESULT, 0 goto_eq BattleFrontier_BattleTowerLobby_EventScript_2B6B09 BattleFrontier_BattleTowerLobby_EventScript_2B6BD4: - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 14 - special sub_81A085C + apprentice_msg TRUE, 14 waitstate setvar VAR_0x8004, 5 special sub_81A085C @@ -247,23 +205,11 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6C0C: setvar VAR_0x8004, 14 setvar VAR_0x8005, 4 special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 5 - special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 2 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 16 - special sub_81A085C - waitstate - setvar VAR_0x8004, 7 - setvar VAR_0x8005, APPRENTICE_ASK_GIVE - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_ITEM + apprentice_buff 1, APPRENTICE_BUFF_SPECIES3 + apprentice_msg FALSE, 16 waitstate + apprentice_menu APPRENTICE_ASK_GIVE setvar VAR_0x8004, 15 special sub_81A085C compare VAR_RESULT, 0 @@ -275,27 +221,12 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6C77: setvar VAR_0x8004, 14 setvar VAR_0x8005, 3 special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 2 - special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 3 - special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 2 - setvar VAR_0x8006, 4 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 8 - special sub_81A085C - waitstate - setvar VAR_0x8004, 7 - setvar VAR_0x8005, APPRENTICE_ASK_MOVES - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_SPECIES3 + apprentice_buff 1, APPRENTICE_BUFF_MOVE1 + apprentice_buff 2, APPRENTICE_BUFF_MOVE2 + apprentice_msg FALSE, 8 waitstate + apprentice_menu APPRENTICE_ASK_MOVES copyvar VAR_0x8005, VAR_RESULT compare VAR_0x8005, 0 call_if 1, BattleFrontier_BattleTowerLobby_EventScript_2B6D50 @@ -311,10 +242,7 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6C77: special sub_81A085C setvar VAR_0x8004, 15 special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 9 - special sub_81A085C + apprentice_msg TRUE, 9 waitstate call BattleFrontier_BattleTowerLobby_EventScript_2B6E4D release @@ -333,28 +261,16 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6D56: return BattleFrontier_BattleTowerLobby_EventScript_2B6D5C: - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 4 - special sub_81A085C - waitstate - setvar VAR_0x8004, 7 - setvar VAR_0x8005, APPRENTICE_ASK_3SPECIES - special sub_81A085C + apprentice_msg FALSE, 4 waitstate + apprentice_menu APPRENTICE_ASK_3SPECIES copyvar VAR_0x8005, VAR_RESULT setvar VAR_0x8004, 18 special sub_81A085C setvar VAR_0x8004, 5 special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 9 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 5 - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_SPECIES4 + apprentice_msg TRUE, 5 waitstate call BattleFrontier_BattleTowerLobby_EventScript_2B6E4D release @@ -365,10 +281,7 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6D5C: end BattleFrontier_BattleTowerLobby_EventScript_2B6DD4: - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 11 - special sub_81A085C + apprentice_msg TRUE, 11 waitstate setvar VAR_0x8004, 25 special sub_81A085C @@ -378,14 +291,8 @@ BattleFrontier_BattleTowerLobby_EventScript_2B6DD4: faceplayer setvar VAR_0x8004, 21 special sub_81A085C - setvar VAR_0x8004, 16 - setvar VAR_0x8005, 0 - setvar VAR_0x8006, 7 - special sub_81A085C - setvar VAR_0x8004, 8 - setvar VAR_0x8005, 1 - setvar VAR_0x8006, 15 - special sub_81A085C + apprentice_buff 0, APPRENTICE_BUFF_EASY_CHAT + apprentice_msg TRUE, 15 waitstate setvar VAR_0x8004, 9 special sub_81A085C 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; diff --git a/src/apprentice.c b/src/apprentice.c index 9f26b561c..b4b20f672 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -78,21 +78,19 @@ static u8 CreateAndShowWindow(u8 left, u8 top, u8 width, u8 height); static void RemoveAndHideWindow(u8 windowId); static void ExecuteFuncAfterButtonPress(void (*func)(void)); -void sub_819F99C(u8 id) +void CopyFriendsApprenticeChallengeText(u8 saveblockApprenticeId) { u8 i, var; const u8 *str; - var = gSaveBlock2Ptr->field_DC[id].field_2; - for (i = 0; var != 0 && i < 4; i++) - { - var /= 10; - } + var = gSaveBlock2Ptr->apprentices[saveblockApprenticeId].number; + for (i = 0; var != 0 && i < 4; var /= 10, i++) + ; - StringCopy7(gStringVar1, gSaveBlock2Ptr->field_DC[id].playerName); - ConvertInternationalString(gStringVar1, gSaveBlock2Ptr->field_DC[id].language); - ConvertIntToDecimalStringN(gStringVar2, gSaveBlock2Ptr->field_DC[id].field_2, STR_CONV_MODE_RIGHT_ALIGN, i); - str = gUnknown_08611330[gSaveBlock2Ptr->field_DC[id].field_0_0]; + StringCopy7(gStringVar1, gSaveBlock2Ptr->apprentices[saveblockApprenticeId].playerName); + ConvertInternationalString(gStringVar1, gSaveBlock2Ptr->apprentices[saveblockApprenticeId].language); + ConvertIntToDecimalStringN(gStringVar2, gSaveBlock2Ptr->apprentices[saveblockApprenticeId].number, STR_CONV_MODE_RIGHT_ALIGN, i); + str = gUnknown_08611330[gSaveBlock2Ptr->apprentices[saveblockApprenticeId].id]; StringExpandPlaceholders(gStringVar4, str); } @@ -109,7 +107,7 @@ void sub_819FA5C(struct Apprentice *apprentice) apprentice->easyChatWords[i] |= 0xFFFF; apprentice->playerName[0] = EOS; - apprentice->field_0_0 = 16; + apprentice->id = 16; } void sub_819FAA0(void) @@ -120,16 +118,16 @@ void sub_819FAA0(void) for (i = 0; i < 4; i++) { for (j = 0; j < 6; j++) - gSaveBlock2Ptr->field_DC[i].easyChatWords[j] |= 0xFFFF; - gSaveBlock2Ptr->field_DC[i].field_0_0 = 16; - gSaveBlock2Ptr->field_DC[i].playerName[0] = EOS; - gSaveBlock2Ptr->field_DC[i].field_0_1 = 0; - gSaveBlock2Ptr->field_DC[i].field_2 = 0; - gSaveBlock2Ptr->field_DC[i].field_1 = 0; + gSaveBlock2Ptr->apprentices[i].easyChatWords[j] |= 0xFFFF; + gSaveBlock2Ptr->apprentices[i].id = 16; + gSaveBlock2Ptr->apprentices[i].playerName[0] = EOS; + gSaveBlock2Ptr->apprentices[i].lvlMode = 0; + gSaveBlock2Ptr->apprentices[i].number = 0; + gSaveBlock2Ptr->apprentices[i].field_1 = 0; for (j = 0; j < 4; j++) - gSaveBlock2Ptr->field_DC[i].playerId[j] = 0; - gSaveBlock2Ptr->field_DC[i].language = gGameLanguage; - gSaveBlock2Ptr->field_DC[i].unk40 = 0; + gSaveBlock2Ptr->apprentices[i].playerId[j] = 0; + gSaveBlock2Ptr->apprentices[i].language = gGameLanguage; + gSaveBlock2Ptr->apprentices[i].unk40 = 0; } sub_81A087C(); @@ -142,19 +140,19 @@ bool8 sub_819FBB0(void) void sub_819FBC8(void) { - if (gSaveBlock2Ptr->field_DC[0].field_2 == 0) + if (gSaveBlock2Ptr->apprentices[0].number == 0) { do { gSaveBlock2Ptr->field_B0 = gUnknown_08611548[Random() % ARRAY_COUNT(gUnknown_08611548)]; - } while (gSaveBlock2Ptr->field_B0 == gSaveBlock2Ptr->field_DC[0].field_0_0); + } while (gSaveBlock2Ptr->field_B0 == gSaveBlock2Ptr->apprentices[0].id); } else { do { gSaveBlock2Ptr->field_B0 = Random() % 16; - } while (gSaveBlock2Ptr->field_B0 == gSaveBlock2Ptr->field_DC[0].field_0_0); + } while (gSaveBlock2Ptr->field_B0 == gSaveBlock2Ptr->apprentices[0].id); } } @@ -472,16 +470,16 @@ void sub_81A0390(u8 arg0) for (i = 0; i < 3; i++) { - gSaveBlock2Ptr->field_DC[0].monData[i].species = 0; - gSaveBlock2Ptr->field_DC[0].monData[i].item = 0; + gSaveBlock2Ptr->apprentices[0].monData[i].species = 0; + gSaveBlock2Ptr->apprentices[0].monData[i].item = 0; for (j = 0; j < 4; j++) - gSaveBlock2Ptr->field_DC[0].monData[i].moves[j] = 0; + gSaveBlock2Ptr->apprentices[0].monData[i].moves[j] = 0; } j = gSaveBlock2Ptr->field_B1_2; for (i = 0; i < 3; i++) { - apprenticeMons[j] = &gSaveBlock2Ptr->field_DC[0].monData[i]; + apprenticeMons[j] = &gSaveBlock2Ptr->apprentices[0].monData[i]; j = (j + 1) % 3; } @@ -983,39 +981,39 @@ void sub_81A0FFC(void) switch (gSpecialVar_0x8006) { - case 0: + case APPRENTICE_BUFF_SPECIES1: StringCopy(stringDst, gSpeciesNames[gUnknown_030062F0->unk0]); break; - case 1: + case APPRENTICE_BUFF_SPECIES2: StringCopy(stringDst, gSpeciesNames[gUnknown_030062F0->unk2]); break; - case 2: + case APPRENTICE_BUFF_SPECIES3: StringCopy(stringDst, gSpeciesNames[gUnknown_030062F0->unk0]); break; - case 3: + case APPRENTICE_BUFF_MOVE1: StringCopy(stringDst, gMoveNames[gUnknown_030062F0->unk4]); break; - case 4: + case APPRENTICE_BUFF_MOVE2: StringCopy(stringDst, gMoveNames[gUnknown_030062F0->unk6]); break; - case 5: + case APPRENTICE_BUFF_ITEM: StringCopy(stringDst, ItemId_GetName(gSaveBlock2Ptr->field_B8[gSaveBlock2Ptr->field_B1_1 - 3].unk2)); break; - case 6: + case APPRENTICE_BUFF_NAME: TVShowConvertInternationalString(text, GetApprenticeNameInLanguage(gSaveBlock2Ptr->field_B0, LANGUAGE_ENGLISH), LANGUAGE_ENGLISH); StringCopy(stringDst, text); break; - case 8: + case APPRENTICE_BUFF_LEVEL: if (gSaveBlock2Ptr->field_B1_0 == 1) StringCopy(stringDst, gText_Lv50); else StringCopy(stringDst, gText_OpenLevel); break; - case 7: - ConvertBattleFrontierTrainerSpeechToString(gSaveBlock2Ptr->field_DC[0].easyChatWords); + case APPRENTICE_BUFF_EASY_CHAT: + ConvertBattleFrontierTrainerSpeechToString(gSaveBlock2Ptr->apprentices[0].easyChatWords); StringCopy(stringDst, gStringVar4); break; - case 9: + case APPRENTICE_BUFF_SPECIES4: if (gSaveBlock2Ptr->field_B1_2 < 3) { APPRENTICE_SPECIES_ID(speciesArrayId, gSaveBlock2Ptr->field_B1_2); @@ -1250,14 +1248,14 @@ void sub_81A1370(void) s32 r10; s32 r9; - if (gSaveBlock2Ptr->field_DC[0].playerName[0] == EOS) + if (gSaveBlock2Ptr->apprentices[0].playerName[0] == EOS) return; for (i = 0; i < 3; i++) { - if (gSaveBlock2Ptr->field_DC[i + 1].playerName[0] == EOS) + if (gSaveBlock2Ptr->apprentices[i + 1].playerName[0] == EOS) { - gSaveBlock2Ptr->field_DC[i + 1] = gSaveBlock2Ptr->field_DC[0]; + gSaveBlock2Ptr->apprentices[i + 1] = gSaveBlock2Ptr->apprentices[0]; return; } } @@ -1266,46 +1264,46 @@ void sub_81A1370(void) r9 = -1; for (i = 1; i < 4; i++) { - if (ReadUnalignedWord(gSaveBlock2Ptr->field_DC[i].playerId) == ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId) - && gSaveBlock2Ptr->field_DC[i].field_2 < r10) + if (ReadUnalignedWord(gSaveBlock2Ptr->apprentices[i].playerId) == ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId) + && gSaveBlock2Ptr->apprentices[i].number < r10) { - r10 = gSaveBlock2Ptr->field_DC[i].field_2; + r10 = gSaveBlock2Ptr->apprentices[i].number; r9 = i; } } if (r9 > 0) - gSaveBlock2Ptr->field_DC[r9] = gSaveBlock2Ptr->field_DC[0]; + gSaveBlock2Ptr->apprentices[r9] = gSaveBlock2Ptr->apprentices[0]; } void sub_81A1438(void) { u8 i; - gSaveBlock2Ptr->field_DC[0].field_0_0 = gSaveBlock2Ptr->field_B0; - gSaveBlock2Ptr->field_DC[0].field_0_1 = gSaveBlock2Ptr->field_B1_0; + gSaveBlock2Ptr->apprentices[0].id = gSaveBlock2Ptr->field_B0; + gSaveBlock2Ptr->apprentices[0].lvlMode = gSaveBlock2Ptr->field_B1_0; for (i = 0; i < 9 && gSaveBlock2Ptr->field_B8[i].unk0_0; i++) ; - gSaveBlock2Ptr->field_DC[0].field_1 = i; - if (gSaveBlock2Ptr->field_DC[0].field_2 < 255) - gSaveBlock2Ptr->field_DC[0].field_2++; + gSaveBlock2Ptr->apprentices[0].field_1 = i; + if (gSaveBlock2Ptr->apprentices[0].number < 255) + gSaveBlock2Ptr->apprentices[0].number++; - sub_81A0390(gSaveBlock2Ptr->field_DC[0].field_1); + sub_81A0390(gSaveBlock2Ptr->apprentices[0].field_1); for (i = 0; i < 4; i++) - gSaveBlock2Ptr->field_DC[0].playerId[i] = gSaveBlock2Ptr->playerTrainerId[i]; + gSaveBlock2Ptr->apprentices[0].playerId[i] = gSaveBlock2Ptr->playerTrainerId[i]; - StringCopy(gSaveBlock2Ptr->field_DC[0].playerName, gSaveBlock2Ptr->playerName); - gSaveBlock2Ptr->field_DC[0].language = gGameLanguage; - sub_8165AE8(&gSaveBlock2Ptr->field_DC[0]); + StringCopy(gSaveBlock2Ptr->apprentices[0].playerName, gSaveBlock2Ptr->playerName); + gSaveBlock2Ptr->apprentices[0].language = gGameLanguage; + sub_8165AE8(&gSaveBlock2Ptr->apprentices[0]); } void sub_81A150C(void) { u8 i; u8 mapObjectGfxId; - u8 class = gApprentices[gSaveBlock2Ptr->field_DC[0].field_0_0].facilityClass; + u8 class = gApprentices[gSaveBlock2Ptr->apprentices[0].id].facilityClass; for (i = 0; i < 30 && gUnknown_085DCEDC[i] != class; i++) ; diff --git a/src/pokemon.c b/src/pokemon.c index 327b76a7b..40f7e94b2 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2877,13 +2877,13 @@ void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 m s32 i; u16 evAmount; u8 language; - u32 otId = gApprentices[src->field_0_0].otId; - u32 personality = ((gApprentices[src->field_0_0].otId >> 8) | ((gApprentices[src->field_0_0].otId & 0xFF) << 8)) - + src->monData[monId].species + src->field_2; + u32 otId = gApprentices[src->id].otId; + u32 personality = ((gApprentices[src->id].otId >> 8) | ((gApprentices[src->id].otId & 0xFF) << 8)) + + src->monData[monId].species + src->number; CreateMon(mon, src->monData[monId].species, - GetFrontierEnemyMonLevel(src->field_0_1 - 1), + GetFrontierEnemyMonLevel(src->lvlMode - 1), 0x1F, TRUE, personality, @@ -2900,7 +2900,7 @@ void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 m language = src->language; SetMonData(mon, MON_DATA_LANGUAGE, &language); - SetMonData(mon, MON_DATA_OT_NAME, GetApprenticeNameInLanguage(src->field_0_0, language)); + SetMonData(mon, MON_DATA_OT_NAME, GetApprenticeNameInLanguage(src->id, language)); CalculateMonStats(mon); } diff --git a/src/record_mixing.c b/src/record_mixing.c index 8d0022f17..2f28ff360 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -199,7 +199,7 @@ static void SetSrcLookupPointers(void) gUnknown_03001148 = &gUnknown_02039F9C; sBattleTowerSave = &gSaveBlock2Ptr->frontier.battleTower; sLilycoveLadySave = &gSaveBlock1Ptr->lilycoveLady; - gUnknown_03001154 = gSaveBlock2Ptr->field_DC; + gUnknown_03001154 = gSaveBlock2Ptr->apprentices; sBattleTowerSave_Duplicate = &gSaveBlock2Ptr->frontier.battleTower; } @@ -1675,7 +1675,7 @@ static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2 r8 = 0; for (i = 0; i < 2; i++) { - if (structPtr[i].playerName[0] != EOS && !sub_80E841C(&structPtr[i], gSaveBlock2Ptr->field_DC)) + if (structPtr[i].playerName[0] != EOS && !sub_80E841C(&structPtr[i], gSaveBlock2Ptr->apprentices)) { r7++; r8 = i; @@ -1686,14 +1686,14 @@ static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2 { case 1: structId = gSaveBlock2Ptr->field_B2_1 + 1; - gSaveBlock2Ptr->field_DC[structId] = structPtr[r8]; + gSaveBlock2Ptr->apprentices[structId] = structPtr[r8]; gSaveBlock2Ptr->field_B2_1 = (gSaveBlock2Ptr->field_B2_1 + 1) % 3; break; case 2: for (i = 0; i < 2; i++) { structId = ((i ^ 1) + gSaveBlock2Ptr->field_B2_1) % 3 + 1; - gSaveBlock2Ptr->field_DC[structId] = structPtr[i]; + gSaveBlock2Ptr->apprentices[structId] = structPtr[i]; } gSaveBlock2Ptr->field_B2_1 = (gSaveBlock2Ptr->field_B2_1 + 2) % 3; break;