diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/data/field_event_obj/event_object_graphics_info_pointers.h | 14 | ||||
-rw-r--r-- | src/easy_chat.c | 54 | ||||
-rw-r--r-- | src/event_object_movement.c | 1 | ||||
-rw-r--r-- | src/mauville_old_man.c | 328 | ||||
-rw-r--r-- | src/mystery_event_script.c | 2 | ||||
-rw-r--r-- | src/record_mixing.c | 2 | ||||
-rw-r--r-- | src/trader.c | 8 |
7 files changed, 297 insertions, 112 deletions
diff --git a/src/data/field_event_obj/event_object_graphics_info_pointers.h b/src/data/field_event_obj/event_object_graphics_info_pointers.h index 0b8aa79b2..661539d57 100755 --- a/src/data/field_event_obj/event_object_graphics_info_pointers.h +++ b/src/data/field_event_obj/event_object_graphics_info_pointers.h @@ -489,11 +489,11 @@ const struct EventObjectGraphicsInfo *const gEventObjectGraphicsInfoPointers[] = }; const struct EventObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[] = { - &gEventObjectGraphicsInfo_Bard, - &gEventObjectGraphicsInfo_Hipster, - &gEventObjectGraphicsInfo_Trader, - &gEventObjectGraphicsInfo_Storyteller, - &gEventObjectGraphicsInfo_Giddy, - &gEventObjectGraphicsInfo_UnusedMauvilleOldMan1, - &gEventObjectGraphicsInfo_UnusedMauvilleOldMan2, + [MAUVILLE_MAN_BARD] = &gEventObjectGraphicsInfo_Bard, + [MAUVILLE_MAN_HIPSTER] = &gEventObjectGraphicsInfo_Hipster, + [MAUVILLE_MAN_TRADER] = &gEventObjectGraphicsInfo_Trader, + [MAUVILLE_MAN_STORYTELLER] = &gEventObjectGraphicsInfo_Storyteller, + [MAUVILLE_MAN_GIDDY] = &gEventObjectGraphicsInfo_Giddy, + [MAUVILLE_MAN_UNUSED1] = &gEventObjectGraphicsInfo_UnusedMauvilleOldMan1, + [MAUVILLE_MAN_UNUSED2] = &gEventObjectGraphicsInfo_UnusedMauvilleOldMan2, }; diff --git a/src/easy_chat.c b/src/easy_chat.c index 827b47085..05f51ed4e 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -31,6 +31,7 @@ #include "constants/event_objects.h" #include "constants/flags.h" #include "constants/lilycove_lady.h" +#include "constants/mauville_old_man.h" #include "constants/songs.h" #include "constants/species.h" #include "constants/rgb.h" @@ -220,7 +221,7 @@ static void sub_811E0EC(s8, s8); static void sub_811E1A4(s8, s8); static void sub_811E2DC(struct Sprite *); static void sub_811E34C(u8, u8); -static bool8 sub_811F0F8(void); +static bool8 EasyChatIsNationalPokedexEnabled(void); static u16 sub_811F108(void); static void sub_811F2D4(void); static void sub_811F46C(void); @@ -1263,7 +1264,7 @@ void ShowEasyChatScreen(void) break; case EASY_CHAT_TYPE_BARD_SONG: bard = &gSaveBlock1Ptr->oldMan.bard; - for (i = 0; i < 6; i ++) + for (i = 0; i < BARD_SONG_LENGTH; i ++) bard->temporaryLyrics[i] = bard->songLyrics[i]; words = bard->temporaryLyrics; @@ -4809,7 +4810,7 @@ static void sub_811E948(void) PutWindowTilemap(windowId); } -static bool8 sub_811EA28(u8 groupId) +static bool8 IsEasyChatGroupUnlocked(u8 groupId) { switch (groupId) { @@ -4820,7 +4821,7 @@ static bool8 sub_811EA28(u8 groupId) case EC_GROUP_MOVE_2: return FlagGet(FLAG_SYS_GAME_CLEAR); case EC_GROUP_POKEMON_2: - return sub_811F0F8(); + return EasyChatIsNationalPokedexEnabled(); default: return TRUE; } @@ -4831,7 +4832,7 @@ u16 EasyChat_GetNumWordsInGroup(u8 groupId) if (groupId == EC_GROUP_POKEMON) return GetNationalPokedexCount(FLAG_GET_SEEN); - if (sub_811EA28(groupId)) + if (IsEasyChatGroupUnlocked(groupId)) return gEasyChatGroups[groupId].numEnabledWords; return 0; @@ -5071,7 +5072,7 @@ u16 sub_811EE38(u16 groupId) u16 sub_811EE90(u16 groupId) { - if (!sub_811EA28(groupId)) + if (!IsEasyChatGroupUnlocked(groupId)) return 0xFFFF; if (groupId == EC_GROUP_POKEMON) @@ -5129,16 +5130,16 @@ void sub_811EF6C(void) CopyEasyChatWord(gStringVar2, easyChatWord); } -static bool8 sub_811EF98(u8 additionalPhraseId) +static bool8 IsAdditionalPhraseUnlocked(u8 additionalPhraseId) { int byteOffset = additionalPhraseId / 8; int shift = additionalPhraseId % 8; return (gSaveBlock1Ptr->additionalPhrases[byteOffset] >> shift) & 1; } -void sub_811EFC0(u8 additionalPhraseId) +void UnlockAdditionalPhrase(u8 additionalPhraseId) { - if (additionalPhraseId < 33) + if (additionalPhraseId < NUM_ADDITIONAL_PHRASES) { int byteOffset = additionalPhraseId / 8; int shift = additionalPhraseId % 8; @@ -5146,32 +5147,32 @@ void sub_811EFC0(u8 additionalPhraseId) } } -u8 sub_811EFF0(void) +static u8 GetNumAdditionalPhrasesUnlocked(void) { u8 i; u8 numAdditionalPhrasesUnlocked; - for (i = 0, numAdditionalPhrasesUnlocked = 0; i < 33; i++) + for (i = 0, numAdditionalPhrasesUnlocked = 0; i < NUM_ADDITIONAL_PHRASES; i++) { - if (sub_811EF98(i)) + if (IsAdditionalPhraseUnlocked(i)) numAdditionalPhrasesUnlocked++; } return numAdditionalPhrasesUnlocked; } -u16 sub_811F01C(void) +u16 GetNewHipsterPhraseToTeach(void) { u16 i; u16 additionalPhraseId; - u8 numAdditionalPhrasesUnlocked = sub_811EFF0(); - if (numAdditionalPhrasesUnlocked == 33) + u8 numAdditionalPhrasesUnlocked = GetNumAdditionalPhrasesUnlocked(); + if (numAdditionalPhrasesUnlocked == NUM_ADDITIONAL_PHRASES) return 0xFFFF; - additionalPhraseId = Random() % (33 - numAdditionalPhrasesUnlocked); - for (i = 0; i < 33; i++) + additionalPhraseId = Random() % (NUM_ADDITIONAL_PHRASES - numAdditionalPhrasesUnlocked); + for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++) { - if (!sub_811EF98(i)) + if (!IsAdditionalPhraseUnlocked(i)) { if (additionalPhraseId) { @@ -5179,7 +5180,7 @@ u16 sub_811F01C(void) } else { - sub_811EFC0(i); + UnlockAdditionalPhrase(i); return EC_WORD(EC_GROUP_TRENDY_SAYING, i); } } @@ -5188,17 +5189,18 @@ u16 sub_811F01C(void) return 0xFFFF; } -u16 sub_811F090(void) +// Unused +u16 GetRandomTaughtHipsterPhrase(void) { u16 i; - u16 additionalPhraseId = sub_811EFF0(); + u16 additionalPhraseId = GetNumAdditionalPhrasesUnlocked(); if (additionalPhraseId == 0) return 0xFFFF; additionalPhraseId = Random() % additionalPhraseId; - for (i = 0; i < 33; i++) + for (i = 0; i < NUM_ADDITIONAL_PHRASES; i++) { - if (sub_811EF98(i)) + if (IsAdditionalPhraseUnlocked(i)) { if (additionalPhraseId) additionalPhraseId--; @@ -5210,7 +5212,7 @@ u16 sub_811F090(void) return 0xFFFF; } -static bool8 sub_811F0F8(void) +static bool8 EasyChatIsNationalPokedexEnabled(void) { return IsNationalPokedexEnabled(); } @@ -5497,7 +5499,7 @@ static bool8 sub_811F764(u16 wordIndex, u8 groupId) case EC_GROUP_MOVE_2: return TRUE; case EC_GROUP_TRENDY_SAYING: - return sub_811EF98(wordIndex); + return IsAdditionalPhraseUnlocked(wordIndex); default: return gEasyChatGroups[groupId].wordData.words[wordIndex].enabled; } @@ -5545,7 +5547,7 @@ bool32 sub_811F8D8(int easyChatWord) int groupId = EC_GROUP(easyChatWord); int mask = 0x7F; int index = EC_INDEX(easyChatWord); - if (!sub_811EA28(groupId & mask)) + if (!IsEasyChatGroupUnlocked(groupId & mask)) return FALSE; else return sub_811F764(index, groupId & mask); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index b3daaad67..c746f08b1 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -26,6 +26,7 @@ #include "constants/event_objects.h" #include "constants/field_effects.h" #include "constants/items.h" +#include "constants/mauville_old_man.h" // this file was known as evobjmv.c in Game Freak's original source diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index f55dd2b8b..4c3066e04 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -22,6 +22,7 @@ #include "field_message_box.h" #include "script_menu.h" #include "trader.h" +#include "constants/mauville_old_man.h" #define CHAR_SONG_WORD_SEPARATOR 0x37 @@ -41,7 +42,7 @@ static EWRAM_DATA u16 sUnknownBardRelated = 0; static EWRAM_DATA struct MauvilleManStoryteller * sStorytellerPtr = NULL; static EWRAM_DATA u8 sStorytellerWindowId = 0; -static const u16 sDefaultBardSongLyrics[6] = { +static const u16 sDefaultBardSongLyrics[BARD_SONG_LENGTH] = { EC_WORD_SHAKE, EC_WORD_IT, EC_WORD_DO, @@ -80,7 +81,7 @@ static void SetupBard(void) bard->id = MAUVILLE_MAN_BARD; bard->hasChangedSong = FALSE; bard->language = gGameLanguage; - for (i = 0; i < 6; i++) + for (i = 0; i < BARD_SONG_LENGTH; i++) bard->songLyrics[i] = sDefaultBardSongLyrics[i]; } @@ -166,10 +167,10 @@ void ScrSpecial_SaveBardSongLyrics(void) StringCopy(bard->playerName, gSaveBlock2Ptr->playerName); - for (i = 0; i < 4; i++) + for (i = 0; i < TRAINER_ID_LENGTH; i++) bard->playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i]; - for (i = 0; i < 6; i++) + for (i = 0; i < BARD_SONG_LENGTH; i++) bard->songLyrics[i] = bard->temporaryLyrics[i]; bard->hasChangedSong = TRUE; @@ -248,15 +249,15 @@ void ScrSpecial_SetHipsterSpokenFlag(void) void ScrSpecial_HipsterTeachWord(void) { - u16 var = sub_811F01C(); + u16 phrase = GetNewHipsterPhraseToTeach(); - if (var == 0xFFFF) + if (phrase == 0xFFFF) { gSpecialVar_Result = FALSE; } else { - CopyEasyChatWord(gStringVar1, var); + CopyEasyChatWord(gStringVar1, phrase); gSpecialVar_Result = TRUE; } } @@ -458,7 +459,7 @@ static void BardSing(struct Task *task, struct BardSong *song) lyrics = bard->songLyrics; else lyrics = bard->temporaryLyrics; - for (i = 0; i < 6; i++) + for (i = 0; i < BARD_SONG_LENGTH; i++) song->lyrics[i] = lyrics[i]; song->currWord = 0; } @@ -690,7 +691,7 @@ void sub_8120B70(union OldMan * oldMan) case MAUVILLE_MAN_TRADER: { struct MauvilleOldManTrader * trader = &oldMan->trader; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { if (trader->language[i] == LANGUAGE_JAPANESE) { @@ -702,17 +703,17 @@ void sub_8120B70(union OldMan * oldMan) case MAUVILLE_MAN_STORYTELLER: { struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (storyteller->gameStatIDs[i] != 0) { - memcpy(sp00, storyteller->trainerNames[i], 7); - sp00[7] = EOS; + memcpy(sp00, storyteller->trainerNames[i], PLAYER_NAME_LENGTH); + sp00[PLAYER_NAME_LENGTH] = EOS; if (IsStringJapanese(sp00)) { - memset(sp00, CHAR_SPACE, 8); + memset(sp00, CHAR_SPACE, PLAYER_NAME_LENGTH + 1); StringCopy(sp00, gText_Friend); - memcpy(storyteller->trainerNames[i], sp00, 7); + memcpy(storyteller->trainerNames[i], sp00, PLAYER_NAME_LENGTH); storyteller->language[i] = GAME_LANGUAGE; } } @@ -732,7 +733,7 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) { struct MauvilleOldManTrader * trader = &oldMan->trader; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { if (IsStringJapanese(trader->playerNames[i])) { @@ -749,7 +750,7 @@ void sub_8120C0C(union OldMan * oldMan, u32 r8, u32 r7, u32 r3) { struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (IsStringJapanese(storyteller->trainerNames[i])) { @@ -803,12 +804,12 @@ void SanitizeReceivedEmeraldOldMan(union OldMan * oldMan, u32 version, u32 langu { struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (storyteller->gameStatIDs[i] != 0) { - memcpy(sp00, storyteller->trainerNames[i], 7); - sp00[7] = EOS; + memcpy(sp00, storyteller->trainerNames[i], PLAYER_NAME_LENGTH); + sp00[PLAYER_NAME_LENGTH] = EOS; if (IsStringJapanese(sp00)) storyteller->language[i] = LANGUAGE_JAPANESE; else @@ -831,7 +832,7 @@ void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 version, u32 language if (isRuby) { - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { u8 * str = trader->playerNames[i]; if (str[0] == EXT_CTRL_CODE_BEGIN && str[1] == EXT_CTRL_CODE_JPN) @@ -845,7 +846,7 @@ void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 version, u32 language } else { - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_TRADER_ITEMS; i++) { if (trader->language[i] == LANGUAGE_JAPANESE) { @@ -863,7 +864,7 @@ void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 version, u32 language if (isRuby) { - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (storyteller->gameStatIDs[i] != 0) storyteller->language[i] = language; @@ -914,42 +915,223 @@ struct Story }; static const struct Story sStorytellerStories[] = { - {GAME_STAT_NUM_UNION_ROOM_BATTLES, 1, MauvilleCity_PokemonCenter_1F_Text_28E930, MauvilleCity_PokemonCenter_1F_Text_28E947, MauvilleCity_PokemonCenter_1F_Text_28E956}, - {GAME_STAT_STARTED_TRENDS, 1, MauvilleCity_PokemonCenter_1F_Text_28E9D7, MauvilleCity_PokemonCenter_1F_Text_28E9EF, MauvilleCity_PokemonCenter_1F_Text_28E9FE}, - {GAME_STAT_PLANTED_BERRIES, 1, MauvilleCity_PokemonCenter_1F_Text_28EA7D, MauvilleCity_PokemonCenter_1F_Text_28EA98, MauvilleCity_PokemonCenter_1F_Text_28EAA8}, - {GAME_STAT_TRADED_BIKES, 1, MauvilleCity_PokemonCenter_1F_Text_28EB19, MauvilleCity_PokemonCenter_1F_Text_28EB31, MauvilleCity_PokemonCenter_1F_Text_28EB3E}, - {GAME_STAT_GOT_INTERVIEWED, 1, MauvilleCity_PokemonCenter_1F_Text_28EBB5, MauvilleCity_PokemonCenter_1F_Text_28EBCD, MauvilleCity_PokemonCenter_1F_Text_28EBDD}, - {GAME_STAT_TRAINER_BATTLES, 1, MauvilleCity_PokemonCenter_1F_Text_28EC60, MauvilleCity_PokemonCenter_1F_Text_28EC79, MauvilleCity_PokemonCenter_1F_Text_28EC81}, - {GAME_STAT_POKEMON_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28ED04, MauvilleCity_PokemonCenter_1F_Text_28ED21, MauvilleCity_PokemonCenter_1F_Text_28ED30}, - {GAME_STAT_FISHING_CAPTURES, 1, MauvilleCity_PokemonCenter_1F_Text_28EDA1, MauvilleCity_PokemonCenter_1F_Text_28EDB5, MauvilleCity_PokemonCenter_1F_Text_28EDCF}, - {GAME_STAT_HATCHED_EGGS, 1, MauvilleCity_PokemonCenter_1F_Text_28EE45, MauvilleCity_PokemonCenter_1F_Text_28EE5D, MauvilleCity_PokemonCenter_1F_Text_28EE6A}, - {GAME_STAT_EVOLVED_POKEMON, 1, MauvilleCity_PokemonCenter_1F_Text_28EEDD, MauvilleCity_PokemonCenter_1F_Text_28EEF1, MauvilleCity_PokemonCenter_1F_Text_28EF01}, - {GAME_STAT_USED_POKECENTER, 1, MauvilleCity_PokemonCenter_1F_Text_28EF73, MauvilleCity_PokemonCenter_1F_Text_28EF95, MauvilleCity_PokemonCenter_1F_Text_28EFAA}, - {GAME_STAT_RESTED_AT_HOME, 1, MauvilleCity_PokemonCenter_1F_Text_28F045, MauvilleCity_PokemonCenter_1F_Text_28F05A, MauvilleCity_PokemonCenter_1F_Text_28F071}, - {GAME_STAT_ENTERED_SAFARI_ZONE, 1, MauvilleCity_PokemonCenter_1F_Text_28F0F3, MauvilleCity_PokemonCenter_1F_Text_28F10D, MauvilleCity_PokemonCenter_1F_Text_28F125}, - {GAME_STAT_USED_CUT, 1, MauvilleCity_PokemonCenter_1F_Text_28F1BE, MauvilleCity_PokemonCenter_1F_Text_28F1D5, MauvilleCity_PokemonCenter_1F_Text_28F1DE}, - {GAME_STAT_USED_ROCK_SMASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F24F, MauvilleCity_PokemonCenter_1F_Text_28F269, MauvilleCity_PokemonCenter_1F_Text_28F277}, - {GAME_STAT_MOVED_SECRET_BASE, 1, MauvilleCity_PokemonCenter_1F_Text_28F2FC, MauvilleCity_PokemonCenter_1F_Text_28F314, MauvilleCity_PokemonCenter_1F_Text_28F32A}, - {GAME_STAT_USED_SPLASH, 1, MauvilleCity_PokemonCenter_1F_Text_28F3AD, MauvilleCity_PokemonCenter_1F_Text_28F3C6, MauvilleCity_PokemonCenter_1F_Text_28F3D2}, - {GAME_STAT_USED_STRUGGLE, 1, MauvilleCity_PokemonCenter_1F_Text_28F44B, MauvilleCity_PokemonCenter_1F_Text_28F461, MauvilleCity_PokemonCenter_1F_Text_28F47C}, - {GAME_STAT_SLOT_JACKPOTS, 1, MauvilleCity_PokemonCenter_1F_Text_28F50C, MauvilleCity_PokemonCenter_1F_Text_28F51B, MauvilleCity_PokemonCenter_1F_Text_28F538}, - {GAME_STAT_CONSECUTIVE_ROULETTE_WINS, 2, MauvilleCity_PokemonCenter_1F_Text_28F5BE, MauvilleCity_PokemonCenter_1F_Text_28F5D1, MauvilleCity_PokemonCenter_1F_Text_28F5F2}, - {GAME_STAT_ENTERED_BATTLE_TOWER, 1, MauvilleCity_PokemonCenter_1F_Text_28F678, MauvilleCity_PokemonCenter_1F_Text_28F694, MauvilleCity_PokemonCenter_1F_Text_28F6B4}, - {GAME_STAT_POKEBLOCKS, 1, MauvilleCity_PokemonCenter_1F_Text_28F751, MauvilleCity_PokemonCenter_1F_Text_28F76A, MauvilleCity_PokemonCenter_1F_Text_28F776}, - {GAME_STAT_ENTERED_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F7F6, MauvilleCity_PokemonCenter_1F_Text_28F811, MauvilleCity_PokemonCenter_1F_Text_28F822}, - {GAME_STAT_WON_CONTEST, 1, MauvilleCity_PokemonCenter_1F_Text_28F89C, MauvilleCity_PokemonCenter_1F_Text_28F8AF, MauvilleCity_PokemonCenter_1F_Text_28F8BC}, - {GAME_STAT_SHOPPED, 1, MauvilleCity_PokemonCenter_1F_Text_28F92F, MauvilleCity_PokemonCenter_1F_Text_28F941, MauvilleCity_PokemonCenter_1F_Text_28F949}, - {GAME_STAT_USED_ITEMFINDER, 1, MauvilleCity_PokemonCenter_1F_Text_28F9D1, MauvilleCity_PokemonCenter_1F_Text_28F9EA, MauvilleCity_PokemonCenter_1F_Text_28F9FD}, - {GAME_STAT_GOT_RAINED_ON, 1, MauvilleCity_PokemonCenter_1F_Text_28FA81, MauvilleCity_PokemonCenter_1F_Text_28FA99, MauvilleCity_PokemonCenter_1F_Text_28FAA7}, - {GAME_STAT_CHECKED_POKEDEX, 1, MauvilleCity_PokemonCenter_1F_Text_28FB1D, MauvilleCity_PokemonCenter_1F_Text_28FB35, MauvilleCity_PokemonCenter_1F_Text_28FB47}, - {GAME_STAT_RECEIVED_RIBBONS, 1, MauvilleCity_PokemonCenter_1F_Text_28FBC4, MauvilleCity_PokemonCenter_1F_Text_28FBD9, MauvilleCity_PokemonCenter_1F_Text_28FBEA}, - {GAME_STAT_JUMPED_DOWN_LEDGES, 1, MauvilleCity_PokemonCenter_1F_Text_28FC6B, MauvilleCity_PokemonCenter_1F_Text_28FC85, MauvilleCity_PokemonCenter_1F_Text_28FC98}, - {GAME_STAT_WATCHED_TV, 1, MauvilleCity_PokemonCenter_1F_Text_28FD1D, MauvilleCity_PokemonCenter_1F_Text_28FD35, MauvilleCity_PokemonCenter_1F_Text_28FD40}, - {GAME_STAT_CHECKED_CLOCK, 1, MauvilleCity_PokemonCenter_1F_Text_28FDA2, MauvilleCity_PokemonCenter_1F_Text_28FDBD, MauvilleCity_PokemonCenter_1F_Text_28FDCE}, - {GAME_STAT_WON_POKEMON_LOTTERY, 1, MauvilleCity_PokemonCenter_1F_Text_28FE57, MauvilleCity_PokemonCenter_1F_Text_28FE72, MauvilleCity_PokemonCenter_1F_Text_28FE88}, - {GAME_STAT_USED_DAYCARE, 1, MauvilleCity_PokemonCenter_1F_Text_28FF0C, MauvilleCity_PokemonCenter_1F_Text_28FF27, MauvilleCity_PokemonCenter_1F_Text_28FF44}, - {GAME_STAT_RODE_CABLE_CAR, 1, MauvilleCity_PokemonCenter_1F_Text_28FFDD, MauvilleCity_PokemonCenter_1F_Text_28FFFA, MauvilleCity_PokemonCenter_1F_Text_29000D}, - {GAME_STAT_ENTERED_HOT_SPRINGS, 1, MauvilleCity_PokemonCenter_1F_Text_290097, MauvilleCity_PokemonCenter_1F_Text_2900B5, MauvilleCity_PokemonCenter_1F_Text_2900CB} + // The 50 below is replaced with GAME_STAT_SAVED_GAME + { + 50, 1, + MauvilleCity_PokemonCenter_1F_Text_SavedGameTitle, + MauvilleCity_PokemonCenter_1F_Text_SavedGameAction, + MauvilleCity_PokemonCenter_1F_Text_SavedGameStory + }, + { + GAME_STAT_STARTED_TRENDS, 1, + MauvilleCity_PokemonCenter_1F_Text_TrendsStartedTitle, + MauvilleCity_PokemonCenter_1F_Text_TrendsStartedAction, + MauvilleCity_PokemonCenter_1F_Text_TrendsStartedStory + }, + { + GAME_STAT_PLANTED_BERRIES, 1, + MauvilleCity_PokemonCenter_1F_Text_BerriesPlantedTitle, + MauvilleCity_PokemonCenter_1F_Text_BerriesPlantedAction, + MauvilleCity_PokemonCenter_1F_Text_BerriesPlantedStory + }, + { + GAME_STAT_TRADED_BIKES, 1, + MauvilleCity_PokemonCenter_1F_Text_BikeTradesTitle, + MauvilleCity_PokemonCenter_1F_Text_BikeTradesAction, + MauvilleCity_PokemonCenter_1F_Text_BikeTradesStory + }, + { + GAME_STAT_GOT_INTERVIEWED, 1, + MauvilleCity_PokemonCenter_1F_Text_InterviewsTitle, + MauvilleCity_PokemonCenter_1F_Text_InterviewsAction, + MauvilleCity_PokemonCenter_1F_Text_InterviewsStory + }, + { + GAME_STAT_TRAINER_BATTLES, 1, + MauvilleCity_PokemonCenter_1F_Text_TrainerBattlesTitle, + MauvilleCity_PokemonCenter_1F_Text_TrainerBattlesAction, + MauvilleCity_PokemonCenter_1F_Text_TrainerBattlesStory + }, + { + GAME_STAT_POKEMON_CAPTURES, 1, + MauvilleCity_PokemonCenter_1F_Text_PokemonCaughtTitle, + MauvilleCity_PokemonCenter_1F_Text_PokemonCaughtAction, + MauvilleCity_PokemonCenter_1F_Text_PokemonCaughtStory + }, + { + GAME_STAT_FISHING_CAPTURES, 1, + MauvilleCity_PokemonCenter_1F_Text_FishingPokemonCaughtTitle, + MauvilleCity_PokemonCenter_1F_Text_FishingPokemonCaughtAction, + MauvilleCity_PokemonCenter_1F_Text_FishingPokemonCaughtStory + }, + { + GAME_STAT_HATCHED_EGGS, 1, + MauvilleCity_PokemonCenter_1F_Text_EggsHatchedTitle, + MauvilleCity_PokemonCenter_1F_Text_EggsHatchedAction, + MauvilleCity_PokemonCenter_1F_Text_EggsHatchedStory + }, + { + GAME_STAT_EVOLVED_POKEMON, 1, + MauvilleCity_PokemonCenter_1F_Text_PokemonEvolvedTitle, + MauvilleCity_PokemonCenter_1F_Text_PokemonEvolvedAction, + MauvilleCity_PokemonCenter_1F_Text_PokemonEvolvedStory + }, + { + GAME_STAT_USED_POKECENTER, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedPokemonCenterTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedPokemonCenterAction, + MauvilleCity_PokemonCenter_1F_Text_UsedPokemonCenterStory + }, + { + GAME_STAT_RESTED_AT_HOME, 1, + MauvilleCity_PokemonCenter_1F_Text_RestedAtHomeTitle, + MauvilleCity_PokemonCenter_1F_Text_RestedAtHomeAction, + MauvilleCity_PokemonCenter_1F_Text_RestedAtHomeStory + }, + { + GAME_STAT_ENTERED_SAFARI_ZONE, 1, + MauvilleCity_PokemonCenter_1F_Text_SafariGamesTitle, + MauvilleCity_PokemonCenter_1F_Text_SafariGamesAction, + MauvilleCity_PokemonCenter_1F_Text_SafariGamesStory + }, + { + GAME_STAT_USED_CUT, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedCutTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedCutAction, + MauvilleCity_PokemonCenter_1F_Text_UsedCutStory + }, + { + GAME_STAT_USED_ROCK_SMASH, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedRockSmashTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedRockSmashAction, + MauvilleCity_PokemonCenter_1F_Text_UsedRockSmashStory + }, + { + GAME_STAT_MOVED_SECRET_BASE, 1, + MauvilleCity_PokemonCenter_1F_Text_MovedBasesTitle, + MauvilleCity_PokemonCenter_1F_Text_MovedBasesAction, + MauvilleCity_PokemonCenter_1F_Text_MovedBasesStory + }, + { + GAME_STAT_USED_SPLASH, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedSplashTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedSplashAction, + MauvilleCity_PokemonCenter_1F_Text_UsedSplashStory + }, + { + GAME_STAT_USED_STRUGGLE, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedStruggleTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedStruggleAction, + MauvilleCity_PokemonCenter_1F_Text_UsedStruggleStory + }, + { + GAME_STAT_SLOT_JACKPOTS, 1, + MauvilleCity_PokemonCenter_1F_Text_SlotJackpotsTitle, + MauvilleCity_PokemonCenter_1F_Text_SlotJackpotsAction, + MauvilleCity_PokemonCenter_1F_Text_SlotJackpotsStory + }, + { + GAME_STAT_CONSECUTIVE_ROULETTE_WINS, 2, + MauvilleCity_PokemonCenter_1F_Text_RouletteWinsTitle, + MauvilleCity_PokemonCenter_1F_Text_RouletteWinsAction, + MauvilleCity_PokemonCenter_1F_Text_RouletteWinsStory + }, + { + GAME_STAT_ENTERED_BATTLE_TOWER, 1, + MauvilleCity_PokemonCenter_1F_Text_BattleTowerChallengesTitle, + MauvilleCity_PokemonCenter_1F_Text_BattleTowerChallengesAction, + MauvilleCity_PokemonCenter_1F_Text_BattleTowerChallengesStory + }, + { + GAME_STAT_POKEBLOCKS, 1, + MauvilleCity_PokemonCenter_1F_Text_MadePokeblocksTitle, + MauvilleCity_PokemonCenter_1F_Text_MadePokeblocksAction, + MauvilleCity_PokemonCenter_1F_Text_MadePokeblocksStory + }, + { + GAME_STAT_ENTERED_CONTEST, 1, + MauvilleCity_PokemonCenter_1F_Text_EnteredContestsTitle, + MauvilleCity_PokemonCenter_1F_Text_EnteredContestsAction, + MauvilleCity_PokemonCenter_1F_Text_EnteredContestsStory + }, + { + GAME_STAT_WON_CONTEST, 1, + MauvilleCity_PokemonCenter_1F_Text_WonContestsTitle, + MauvilleCity_PokemonCenter_1F_Text_WonContestsAction, + MauvilleCity_PokemonCenter_1F_Text_WonContestsStory + }, + { + GAME_STAT_SHOPPED, 1, + MauvilleCity_PokemonCenter_1F_Text_TimesShoppedTitle, + MauvilleCity_PokemonCenter_1F_Text_TimesShoppedAction, + MauvilleCity_PokemonCenter_1F_Text_TimesShoppedStory + }, + { + GAME_STAT_USED_ITEMFINDER, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedItemFinderTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedItemFinderAction, + MauvilleCity_PokemonCenter_1F_Text_UsedItemFinderStory + }, + { + GAME_STAT_GOT_RAINED_ON, 1, + MauvilleCity_PokemonCenter_1F_Text_TimesRainedTitle, + MauvilleCity_PokemonCenter_1F_Text_TimesRainedAction, + MauvilleCity_PokemonCenter_1F_Text_TimesRainedStory + }, + { + GAME_STAT_CHECKED_POKEDEX, 1, + MauvilleCity_PokemonCenter_1F_Text_CheckedPokedexTitle, + MauvilleCity_PokemonCenter_1F_Text_CheckedPokedexAction, + MauvilleCity_PokemonCenter_1F_Text_CheckedPokedexStory + }, + { + GAME_STAT_RECEIVED_RIBBONS, 1, + MauvilleCity_PokemonCenter_1F_Text_ReceivedRibbonsTitle, + MauvilleCity_PokemonCenter_1F_Text_ReceivedRibbonsAction, + MauvilleCity_PokemonCenter_1F_Text_ReceivedRibbonsStory + }, + { + GAME_STAT_JUMPED_DOWN_LEDGES, 1, + MauvilleCity_PokemonCenter_1F_Text_LedgesJumpedTitle, + MauvilleCity_PokemonCenter_1F_Text_LedgesJumpedAction, + MauvilleCity_PokemonCenter_1F_Text_LedgesJumpedStory + }, + { + GAME_STAT_WATCHED_TV, 1, + MauvilleCity_PokemonCenter_1F_Text_TVWatchedTitle, + MauvilleCity_PokemonCenter_1F_Text_TVWatchedAction, + MauvilleCity_PokemonCenter_1F_Text_TVWatchedStory + }, + { + GAME_STAT_CHECKED_CLOCK, 1, + MauvilleCity_PokemonCenter_1F_Text_CheckedClockTitle, + MauvilleCity_PokemonCenter_1F_Text_CheckedClockAction, + MauvilleCity_PokemonCenter_1F_Text_CheckedClockStory + }, + { + GAME_STAT_WON_POKEMON_LOTTERY, 1, + MauvilleCity_PokemonCenter_1F_Text_WonLotteryTitle, + MauvilleCity_PokemonCenter_1F_Text_WonLotteryAction, + MauvilleCity_PokemonCenter_1F_Text_WonLotteryStory + }, + { + GAME_STAT_USED_DAYCARE, 1, + MauvilleCity_PokemonCenter_1F_Text_UsedDaycareTitle, + MauvilleCity_PokemonCenter_1F_Text_UsedDaycareAction, + MauvilleCity_PokemonCenter_1F_Text_UsedDaycareStory + }, + { + GAME_STAT_RODE_CABLE_CAR, 1, + MauvilleCity_PokemonCenter_1F_Text_RodeCableCarTitle, + MauvilleCity_PokemonCenter_1F_Text_RodeCableCarAction, + MauvilleCity_PokemonCenter_1F_Text_RodeCableCarStory + }, + { + GAME_STAT_ENTERED_HOT_SPRINGS, 1, + MauvilleCity_PokemonCenter_1F_Text_HotSpringsTitle, + MauvilleCity_PokemonCenter_1F_Text_HotSpringsAction, + MauvilleCity_PokemonCenter_1F_Text_HotSpringsStory + } }; static void StorytellerSetup(void) @@ -959,7 +1141,7 @@ static void StorytellerSetup(void) sStorytellerPtr->id = MAUVILLE_MAN_STORYTELLER; sStorytellerPtr->alreadyRecorded = FALSE; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { sStorytellerPtr->gameStatIDs[i] = 0; sStorytellerPtr->trainerNames[0][i] = EOS; // Maybe they meant storyteller->trainerNames[i][0] instead? @@ -977,7 +1159,7 @@ static void Storyteller_ResetFlag(void) static u32 StorytellerGetGameStat(u8 stat) { if (stat == 50) - stat = 0; + stat = GAME_STAT_SAVED_GAME; return GetGameStat(stat); } @@ -985,12 +1167,12 @@ static const struct Story *GetStoryByStat(u32 stat) { s32 i; - for (i = 0; i < 36; i++) + for (i = 0; i < (int)ARRAY_COUNT(sStorytellerStories); i++) { if (sStorytellerStories[i].stat == stat) return &sStorytellerStories[i]; } - return &sStorytellerStories[35]; + return &sStorytellerStories[ARRAY_COUNT(sStorytellerStories) - 1]; } static const u8 *GetStoryTitleByStat(u32 stat) @@ -1012,7 +1194,7 @@ static u8 GetFreeStorySlot(void) { u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { if (sStorytellerPtr->gameStatIDs[i] == 0) break; @@ -1049,15 +1231,15 @@ static void GetStoryByStattellerPlayerName(u32 player, void *dst) { u8 *name = sStorytellerPtr->trainerNames[player]; - memset(dst, EOS, 8); - memcpy(dst, name, 7); + memset(dst, EOS, PLAYER_NAME_LENGTH + 1); + memcpy(dst, name, PLAYER_NAME_LENGTH); } static void StorytellerSetPlayerName(u32 player, const u8 * src) { u8 * name = sStorytellerPtr->trainerNames[player]; - memset(name, EOS, 7); - memcpy(name, src, 7); + memset(name, EOS, PLAYER_NAME_LENGTH); + memcpy(name, src, PLAYER_NAME_LENGTH); } @@ -1110,15 +1292,15 @@ static bool8 StorytellerInitializeRandomStat(void) u8 stat = sStorytellerStories[arr[i]].stat; u8 minVal = sStorytellerStories[arr[i]].minVal; - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_STORYTELLER_TALES; j++) { if (sStorytellerPtr->gameStatIDs[j] == stat) break; } - if (j == 4 && StorytellerGetGameStat(stat) >= minVal) + if (j == NUM_STORYTELLER_TALES && StorytellerGetGameStat(stat) >= minVal) { sStorytellerPtr->alreadyRecorded = TRUE; - if (GetFreeStorySlot() == 4) + if (GetFreeStorySlot() == NUM_STORYTELLER_TALES) StorytellerRecordNewStat(sSelectedStory, stat); else StorytellerRecordNewStat(GetFreeStorySlot(), stat); @@ -1144,7 +1326,7 @@ static void PrintStoryList(void) s32 i; s32 width = GetStringWidth(1, gText_Exit, 0); u8 tileWidth; - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { s32 curWidth; u16 gameStatID = sStorytellerPtr->gameStatIDs[i]; @@ -1157,7 +1339,7 @@ static void PrintStoryList(void) } sStorytellerWindowId = CreateWindowFromRect(0, 0, ConvertPixelWidthToTileWidth(width), GetFreeStorySlot() * 2 + 2); SetStandardWindowBorderStyle(sStorytellerWindowId, 0); - for (i = 0; i < 4; i++) + for (i = 0; i < NUM_STORYTELLER_TALES; i++) { u16 gameStatID = sStorytellerPtr->gameStatIDs[i]; if (gameStatID == 0) @@ -1169,7 +1351,7 @@ static void PrintStoryList(void) CopyWindowToVram(sStorytellerWindowId, 3); } -static void Task_StoryListMenu(u8 taskId) // Task_StoryListMenu +static void Task_StoryListMenu(u8 taskId) { struct Task *task = &gTasks[taskId]; s32 selection; diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index dba914b51..76f340c60 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -286,7 +286,7 @@ bool8 MEScrCmd_givenationaldex(struct ScriptContext *ctx) bool8 MEScrCmd_addrareword(struct ScriptContext *ctx) { - sub_811EFC0(ScriptReadByte(ctx)); + UnlockAdditionalPhrase(ScriptReadByte(ctx)); StringExpandPlaceholders(gStringVar4, gText_MysteryGiftRareWord); ctx->data[2] = 2; return FALSE; diff --git a/src/record_mixing.c b/src/record_mixing.c index 8df0a8a8b..8a1e8b1ee 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -631,7 +631,7 @@ static void ReceiveOldManData(OldMan *oldMan, size_t recordSize, u8 which) u8 version; u16 language; OldMan *dest; - u32 mixIndices[4]; + u32 mixIndices[MAX_LINK_PLAYERS]; ShufflePlayerIndices(mixIndices); dest = (void *)oldMan + recordSize * mixIndices[which]; diff --git a/src/trader.c b/src/trader.c index a3794a539..e0b780d25 100644 --- a/src/trader.c +++ b/src/trader.c @@ -1,6 +1,6 @@ #include "global.h" #include "constants/decorations.h" -#include "constants/mauville_man.h" +#include "constants/mauville_old_man.h" #include "decoration.h" #include "decoration_inventory.h" #include "event_data.h" @@ -86,7 +86,7 @@ void CreateAvailableDecorationsMenu(u8 taskId) schedule_bg_copy_tilemap_to_vram(0); } -void sub_8133BE4(u8 taskId, u8 decorationId) +void Task_BufferDecorSelectionAndCloseWindow(u8 taskId, u8 decorationId) { s16 * data = gTasks[taskId].data; if (decorationId > NUM_DECORATIONS) @@ -118,14 +118,14 @@ void Task_HandleGetDecorationMenuInput(u8 taskId) case MENU_B_PRESSED: case 4: PlaySE(SE_SELECT); - sub_8133BE4(taskId, 0); + Task_BufferDecorSelectionAndCloseWindow(taskId, 0); break; default: PlaySE(SE_SELECT); gSpecialVar_0x8005 = input; StringCopy(gStringVar1, trader->playerNames[input]); ConvertInternationalString(gStringVar1, trader->language[input]); - sub_8133BE4(taskId, trader->decorIds[input]); + Task_BufferDecorSelectionAndCloseWindow(taskId, trader->decorIds[input]); break; } } |