From aad090e154d4cb1397468f3b19071ddad688a7bc Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 25 Apr 2021 17:22:45 -0400 Subject: [PATCH] Document TV --- .../scripts.inc | 2 +- data/scripts/gabby_and_ty.inc | 6 +- data/scripts/tv.inc | 8 +- data/specials.inc | 10 +- include/constants/battle_frontier.h | 15 + include/constants/easy_chat.h | 2 +- include/constants/metatile_labels.h | 2 + include/constants/tv.h | 38 +- include/daycare.h | 2 +- include/global.h | 8 +- include/global.tv.h | 22 +- include/mauville_old_man.h | 2 +- include/tv.h | 30 +- src/battle_main.c | 4 +- src/battle_tower.c | 1 - src/contest.c | 1 - src/contest_util.c | 1 - src/daycare.c | 12 +- src/decoration.c | 4 +- src/easy_chat.c | 4 +- src/field_specials.c | 3 +- src/fldeff_misc.c | 1 - src/frontier_util.c | 26 +- src/item.c | 1 - src/mauville_old_man.c | 52 +- src/menu.c | 6 +- src/post_battle_event_funcs.c | 1 - src/record_mixing.c | 106 +- src/roulette.c | 2 +- src/safari_zone.c | 2 +- src/script_pokemon_util.c | 1 - src/secret_base.c | 1 - src/shop.c | 5 +- src/slot_machine.c | 2 +- src/tv.c | 6062 ++++++++--------- 35 files changed, 3028 insertions(+), 3417 deletions(-) diff --git a/data/maps/LilycoveCity_PokemonTrainerFanClub/scripts.inc b/data/maps/LilycoveCity_PokemonTrainerFanClub/scripts.inc index 6ff869db3a..86544d3e92 100644 --- a/data/maps/LilycoveCity_PokemonTrainerFanClub/scripts.inc +++ b/data/maps/LilycoveCity_PokemonTrainerFanClub/scripts.inc @@ -173,7 +173,7 @@ LilycoveCity_PokemonTrainerFanClub_EventScript_CountNotPlayersFan:: @ 821C9AE return LilycoveCity_PokemonTrainerFanClub_EventScript_TrySetUpTVShow:: @ 821C9B4 - special TrySetUpTrainerFanClubSpecial + special TryPutTrainerFanClubOnAir return LilycoveCity_PokemonTrainerFanClub_EventScript_MoveMember1ToFarTable:: @ 821C9B8 diff --git a/data/scripts/gabby_and_ty.inc b/data/scripts/gabby_and_ty.inc index c7f576aba7..60854a8010 100644 --- a/data/scripts/gabby_and_ty.inc +++ b/data/scripts/gabby_and_ty.inc @@ -1,6 +1,6 @@ @ Gabby and Ty always move to the same spots for the first 5 battles @ From the 6th battle onwards, they move randomly between locations 6-8 -@ Note: The local IDs of Gabby and Ty are hard-coded in GabbyAndTySetScriptVarsToObjectEventLocalIds +@ Note: The local IDs of Gabby and Ty are hard-coded in GetGabbyAndTyLocalIds GabbyAndTy_EventScript_UpdateLocation:: @ 828CCC7 cleartrainerflag TRAINER_GABBY_AND_TY_6 specialvar VAR_RESULT, GabbyAndTyGetBattleNum @@ -198,7 +198,7 @@ GabbyAndTy_EventScript_TyBattle6:: @ 828CF36 GabbyAndTy_EventScript_FirstInterview:: @ 828CF56 special GabbyAndTyBeforeInterview - special GabbyAndTySetScriptVarsToObjectEventLocalIds + special GetGabbyAndTyLocalIds compare VAR_FACING, DIR_NORTH call_if_eq GabbyAndTy_EventScript_FacePlayerNorth compare VAR_FACING, DIR_SOUTH @@ -229,7 +229,7 @@ GabbyAndTy_EventScript_FacePlayerEast:: @ 828CFB1 GabbyAndTy_EventScript_RequestInterview:: @ 828CFC3 special GabbyAndTyBeforeInterview - special GabbyAndTySetScriptVarsToObjectEventLocalIds + special GetGabbyAndTyLocalIds compare VAR_FACING, DIR_NORTH call_if_eq GabbyAndTy_EventScript_FacePlayerNorth compare VAR_FACING, DIR_SOUTH diff --git a/data/scripts/tv.inc b/data/scripts/tv.inc index a2d5473b19..1dfc1884bf 100644 --- a/data/scripts/tv.inc +++ b/data/scripts/tv.inc @@ -2,14 +2,14 @@ EventScript_TV:: @ 827EE0B lockall incrementgamestat GAME_STAT_WATCHED_TV special ResetTVShowState - specialvar VAR_RESULT, CheckForBigMovieOrEmergencyNewsOnTV - compare VAR_RESULT, 2 + specialvar VAR_RESULT, CheckForPlayersHouseNews + compare VAR_RESULT, PLAYERS_HOUSE_TV_MOVIE goto_if_eq EventScript_PlayersHouseMovie - compare VAR_RESULT, 1 + compare VAR_RESULT, PLAYERS_HOUSE_TV_LATI goto_if_eq EventScript_PlayersHouseLatiNewsFlash goto_if_unset FLAG_SYS_TV_START, EventScript_MomDadMightLikeThis1 goto_if_set FLAG_SYS_TV_WATCH, EventScript_MomDadMightLikeThis1 - specialvar VAR_RESULT, IsTVShowInSearchOfTrainersAiring + specialvar VAR_RESULT, IsGabbyAndTyShowOnTheAir compare VAR_RESULT, TRUE goto_if_eq EventScript_DoInSearchOfTrainers goto EventScript_TryDoPokeNews diff --git a/data/specials.inc b/data/specials.inc index f672a7b870..e8315c013d 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -83,8 +83,8 @@ gSpecials:: @ 81DBA64 def_special IsLeadMonNicknamedOrNotEnglish def_special SetContestCategoryStringVarForInterview def_special GetNextActiveShowIfMassOutbreak - def_special TV_IsScriptShowKindAlreadyInQueue - def_special CheckForBigMovieOrEmergencyNewsOnTV + def_special IsTVShowAlreadyInQueue + def_special CheckForPlayersHouseNews def_special GetMomOrDadStringForTVMessage def_special ResetTVShowState def_special GetContestWinnerId @@ -187,10 +187,10 @@ gSpecials:: @ 81DBA64 def_special GabbyAndTyAfterInterview def_special GabbyAndTyBeforeInterview def_special DoTVShowInSearchOfTrainers - def_special IsTVShowInSearchOfTrainersAiring + def_special IsGabbyAndTyShowOnTheAir def_special GabbyAndTyGetLastQuote def_special GabbyAndTyGetLastBattleTrivia - def_special GabbyAndTySetScriptVarsToObjectEventLocalIds + def_special GetGabbyAndTyLocalIds def_special GetBattleOutcome def_special GetDaycareMonNicknames def_special GetDaycareState @@ -354,7 +354,7 @@ gSpecials:: @ 81DBA64 def_special SetChampionSaveWarp def_special TryPutTreasureInvestigatorsOnAir def_special TryPutLotteryWinnerReportOnAir - def_special TrySetUpTrainerFanClubSpecial + def_special TryPutTrainerFanClubOnAir def_special ShouldHideFanClubInterviewer def_special ShowGlassWorkshopMenu def_special PutFanClubSpecialOnTheAir diff --git a/include/constants/battle_frontier.h b/include/constants/battle_frontier.h index bbe6db81c9..68c5a42ef3 100644 --- a/include/constants/battle_frontier.h +++ b/include/constants/battle_frontier.h @@ -78,6 +78,21 @@ #define FRONTIER_MANIAC_MESSAGE_COUNT 3 +// Frontier TV Show +#define FRONTIER_SHOW_TOWER_SINGLES 1 +#define FRONTIER_SHOW_TOWER_DOUBLES 2 +#define FRONTIER_SHOW_TOWER_MULTIS 3 +#define FRONTIER_SHOW_TOWER_LINK_MULTIS 4 +#define FRONTIER_SHOW_DOME_SINGLES 5 +#define FRONTIER_SHOW_DOME_DOUBLES 6 +#define FRONTIER_SHOW_FACTORY_SINGLES 7 +#define FRONTIER_SHOW_FACTORY_DOUBLES 8 +#define FRONTIER_SHOW_PIKE 9 +#define FRONTIER_SHOW_ARENA 10 +#define FRONTIER_SHOW_PALACE_SINGLES 11 +#define FRONTIER_SHOW_PALACE_DOUBLES 12 +#define FRONTIER_SHOW_PYRAMID 13 + // Frontier Gambler #define FRONTIER_GAMBLER_WAITING 0 #define FRONTIER_GAMBLER_PLACED_BET 1 diff --git a/include/constants/easy_chat.h b/include/constants/easy_chat.h index 069f17fcb2..f98cedbb71 100644 --- a/include/constants/easy_chat.h +++ b/include/constants/easy_chat.h @@ -9,7 +9,7 @@ #define EASY_CHAT_TYPE_INTERVIEW 5 #define EASY_CHAT_TYPE_BARD_SONG 6 #define EASY_CHAT_TYPE_FAN_CLUB 7 -#define EASY_CHAT_TYPE_UNK_8 8 +#define EASY_CHAT_TYPE_DUMMY_SHOW 8 #define EASY_CHAT_TYPE_TRENDY_PHRASE 9 #define EASY_CHAT_TYPE_GABBY_AND_TY 10 #define EASY_CHAT_TYPE_CONTEST_INTERVIEW 11 diff --git a/include/constants/metatile_labels.h b/include/constants/metatile_labels.h index 836ab6ef2d..b5ef690469 100644 --- a/include/constants/metatile_labels.h +++ b/include/constants/metatile_labels.h @@ -42,6 +42,8 @@ #define METATILE_General_BlueCaveOpen 0x1B1 // gTileset_Building +#define METATILE_Building_TV_Off 0x002 +#define METATILE_Building_TV_On 0x003 #define METATILE_Building_PC_Off 0x004 #define METATILE_Building_PC_On 0x005 diff --git a/include/constants/tv.h b/include/constants/tv.h index f7b091f494..1b28f6e6ed 100644 --- a/include/constants/tv.h +++ b/include/constants/tv.h @@ -6,12 +6,22 @@ #define POKENEWS_GAME_CORNER 2 #define POKENEWS_LILYCOVE 3 #define POKENEWS_BLENDMASTER 4 +#define NUM_POKENEWS_TYPES 4 // Excludes NONE + +// TV shows are categorized as being in one of 3 groups +// - TVGROUP_NORMAL, TV shows that can appear without Record Mixing +// - TVGROUP_RECORD_MIX, TV shows that can only appear via Record Mixing +// - TVGROUP_OUTBREAK, just contains TVSHOW_MASS_OUTBREAK +// Each group was allotted 20 spaces arbitrarily, though none use all 20 #define TVSHOW_OFF_AIR 0 + +// TVGROUP_NORMAL +#define TVGROUP_NORMAL_START 1 #define TVSHOW_FAN_CLUB_LETTER 1 #define TVSHOW_RECENT_HAPPENINGS 2 #define TVSHOW_PKMN_FAN_CLUB_OPINIONS 3 -#define TVSHOW_UNKN_SHOWTYPE_04 4 +#define TVSHOW_DUMMY 4 #define TVSHOW_NAME_RATER_SHOW 5 #define TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE 6 #define TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE 7 @@ -20,7 +30,11 @@ #define TVSHOW_BATTLE_UPDATE 10 #define TVSHOW_FAN_CLUB_SPECIAL 11 #define TVSHOW_LILYCOVE_CONTEST_LADY 12 -// // +// +#define TVGROUP_NORMAL_END 20 + +// TVGROUP_RECORD_MIX +#define TVGROUP_RECORD_MIX_START 21 #define TVSHOW_POKEMON_TODAY_CAUGHT 21 #define TVSHOW_SMART_SHOPPER 22 #define TVSHOW_POKEMON_TODAY_FAILED 23 @@ -40,8 +54,22 @@ #define TVSHOW_NUMBER_ONE 37 #define TVSHOW_SECRET_BASE_SECRETS 38 #define TVSHOW_SAFARI_FAN_CLUB 39 -// // -#define TVSHOW_MASS_OUTBREAK 41 +#define TVGROUP_RECORD_MIX_END 40 + +// TVGROUP_OUTBREAK +#define TVGROUP_OUTBREAK_START 41 +#define TVSHOW_MASS_OUTBREAK 41 +// +#define TVGROUP_OUTBREAK_END 60 + +// The first 5 elements of gSaveBlock1Ptr->tvShows are reserved +// for TV shows from TVGROUP_NORMAL. The remainder are for TV +// shows from TVGROUP_RECORD_MIX. +#define NUM_NORMAL_TVSHOW_SLOTS 5 + +#define PLAYERS_HOUSE_TV_NONE 0 +#define PLAYERS_HOUSE_TV_LATI 1 +#define PLAYERS_HOUSE_TV_MOVIE 2 // Number of ribbons to put Spot the Cuties on air #define NUM_CUTIES_RIBBONS 4 @@ -221,4 +249,6 @@ #define CONTESTLADYLIVE_STATE_LOST 2 #define CONTESTLADYLIVE_STATE_LOST_BADLY 3 +#define SMARTSHOPPER_NUM_ITEMS 3 + #endif //GUARD_CONSTANTS_TV_H diff --git a/include/daycare.h b/include/daycare.h index 7d6f2fb193..d6c0d42017 100644 --- a/include/daycare.h +++ b/include/daycare.h @@ -6,7 +6,7 @@ u8 *GetMonNickname2(struct Pokemon *mon, u8 *dest); u8 *GetBoxMonNickname(struct BoxPokemon *mon, u8 *dest); u8 CountPokemonInDaycare(struct DayCare *daycare); -void InitDaycareMailRecordMixing(struct DayCare *daycare, struct RecordMixingDayCareMail *daycareMail); +void InitDaycareMailRecordMixing(struct DayCare *daycare, struct RecordMixingDaycareMail *daycareMail); void StoreSelectedPokemonInDaycare(void); u16 TakePokemonFromDaycare(void); void GetDaycareCost(void); diff --git a/include/global.h b/include/global.h index 19605ca57c..e4c11f9ef2 100644 --- a/include/global.h +++ b/include/global.h @@ -727,7 +727,7 @@ struct ContestWinner u8 contestRank; }; -struct DayCareMail +struct DaycareMail { struct MailStruct message; u8 OT_name[PLAYER_NAME_LENGTH + 1]; @@ -739,7 +739,7 @@ struct DayCareMail struct DaycareMon { struct BoxPokemon mon; - struct DayCareMail mail; + struct DaycareMail mail; u32 steps; }; @@ -750,9 +750,9 @@ struct DayCare u8 stepCounter; }; -struct RecordMixingDayCareMail +struct RecordMixingDaycareMail { - struct DayCareMail mail[DAYCARE_MON_COUNT]; + struct DaycareMail mail[DAYCARE_MON_COUNT]; u32 numDaycareMons; bool16 holdsItem[DAYCARE_MON_COUNT]; }; diff --git a/include/global.tv.h b/include/global.tv.h index 64e6a984ed..2bc7dda998 100644 --- a/include/global.tv.h +++ b/include/global.tv.h @@ -1,13 +1,15 @@ #ifndef GUARD_GLOBAL_TV_H #define GUARD_GLOBAL_TV_H +#include "constants/tv.h" + typedef union // size = 0x24 { // Common struct { /*0x00*/ u8 kind; /*0x01*/ bool8 active; - /*0x02*/ u8 pad02[26]; + /*0x02*/ u8 data[26]; /*0x1C*/ u8 srcTrainerId3Lo; /*0x1D*/ u8 srcTrainerId3Hi; /*0x1E*/ u8 srcTrainerId2Lo; @@ -22,7 +24,7 @@ typedef union // size = 0x24 struct { /*0x00*/ u8 kind; /*0x01*/ bool8 active; - /*0x02*/ u8 pad02[34]; + /*0x02*/ u8 data[34]; } commonInit; // Local shows @@ -40,7 +42,7 @@ typedef union // size = 0x24 struct { /*0x00*/ u8 kind; /*0x01*/ bool8 active; - /*0x02*/ u16 var02; + /*0x02*/ u16 species; /*0x04*/ u16 words[6]; /*0x10*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x18*/ u8 language; @@ -62,16 +64,16 @@ typedef union // size = 0x24 /*0x1C*/ u16 words[4]; } fanclubOpinions; - // TVSHOW_UNKN_SHOWTYPE_04 (dummied out) + // TVSHOW_DUMMY struct { /*0x00*/ u8 kind; /*0x01*/ bool8 active; /*0x02*/ u16 words[2]; - /*0x06*/ u16 var06; + /*0x06*/ u16 species; /*0x08*/ u8 pad_08[3]; - /*0x0b*/ u8 string_0b[12]; + /*0x0b*/ u8 name[12]; /*0x17*/ u8 language; - } unkShow04; + } dummy; // TVSHOW_NAME_RATER_SHOW struct { @@ -212,8 +214,8 @@ typedef union // size = 0x24 /*0x02*/ u8 priceReduced; /*0x03*/ u8 language; /*0x04*/ u8 pad04[2]; - /*0x06*/ u16 itemIds[3]; - /*0x0C*/ u16 itemAmounts[3]; + /*0x06*/ u16 itemIds[SMARTSHOPPER_NUM_ITEMS]; + /*0x0C*/ u16 itemAmounts[SMARTSHOPPER_NUM_ITEMS]; /*0x12*/ u8 shopLocation; /*0x13*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; } smartshopperShow; @@ -401,7 +403,7 @@ typedef union // size = 0x24 /*0x08*/ u16 species3; /*0x0a*/ u16 species4; /*0x0c*/ u8 language; - /*0x0d*/ u8 facility; + /*0x0d*/ u8 facilityAndMode; /*0x0e*/ u8 filler_0e[5]; /*0x13*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; } frontier; diff --git a/include/mauville_old_man.h b/include/mauville_old_man.h index 29c66a992a..603d585dad 100644 --- a/include/mauville_old_man.h +++ b/include/mauville_old_man.h @@ -7,7 +7,7 @@ void SetMauvilleOldMan(void); u8 GetCurrentMauvilleOldMan(void); void ScrSpecial_SetMauvilleOldManObjEventGfx(void); u8 sub_81201C8(void); -void sub_8120B70(OldMan *dest); +void SanitizeMauvilleOldManForRuby(OldMan *dest); void sub_8120670(void); void SanitizeReceivedRubyOldMan(union OldMan * oldMan, u32 r1, u32 r6); void SanitizeReceivedEmeraldOldMan(union OldMan * oldMan, u32 unused, u32 a2); diff --git a/include/tv.h b/include/tv.h index f94c5b7e50..30cd133265 100644 --- a/include/tv.h +++ b/include/tv.h @@ -1,13 +1,10 @@ #ifndef GUARD_TV_H #define GUARD_TV_H -#define SLOT_MACHINE 0 -#define ROULETTE 1 - extern u8 *const gTVStringVarPtrs[3]; void ClearTVShowData(void); -void sub_80EE184(void); +void TryPutBreakingNewsOnAir(void); void TryPutBattleSeminarOnAir(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u16 betterMove); void TryPutFrontierTVShowOnAir(u16 winStreak, u8 facility); void DoTVShow(void); @@ -23,41 +20,37 @@ void ReceiveTvShowsData(void *src, u32 size, u8 masterIdx); void TryPutSpotTheCutiesOnAir(struct Pokemon *pokemon, u8 ribbonMonDataIdx); u32 GetPlayerIDAsU32(void); bool8 GetPriceReduction(u8 newsKind); -void sub_80F14F8(TVShow *shows); +void SanitizeTVShowLocationsForRuby(TVShow *shows); size_t CountDigits(int value); u8 GetRibbonCount(struct Pokemon *pokemon); void AlertTVThatPlayerPlayedSlotMachine(u16 nCoinsSpent); void AlertTVThatPlayerPlayedRoulette(u16 nCoinsSpent); -void AlertTVOfNewCoinTotal(u16 nCoinsPaidOut); +void TryPutFindThatGamerOnAir(u16 nCoinsPaidOut); void TryPutSecretBaseSecretsOnAir(void); void TryPutTodaysRivalTrainerOnAir(void); void TryPutTrendWatcherOnAir(const u16 *words); -void sub_80EDA80(void); void ReceivePokeNewsData(void *src, u32 size, u8 masterIdx); -void sub_80F0BB8(void); +void DeactivateAllNormalTVShows(void); void RecordFishingAttemptForTV(bool8 caughtFish); void IncrementDailySlotsUses(void); void IncrementDailyRouletteUses(void); void IncrementDailyWildBattles(void); void IncrementDailyBerryBlender(void); -void sub_80F1208(TVShow *shows); -void sub_80EE44C(u8 nMonsCaught, u8 nPkblkUsed); -void sub_80F14F8(TVShow *shows); -size_t sub_80EF370(int value); +void SanitizeTVShowsForRuby(TVShow *shows); +void TryPutSafariFanClubOnAir(u8 nMonsCaught, u8 nPkblkUsed); bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unused, u8 sheen, u8 language); void SetPokemonAnglerSpecies(u16 species); void UpdateTVShowsPerDay(u16 days); -void PutPokemonTodayCaughtOnAir(void); -void TV_PutSecretBaseVisitOnTheAir(void); +void TryPutPokemonTodayOnAir(void); +void TryPutSecretBaseVisitOnAir(void); void PutBattleUpdateOnTheAir(u8 opponentLinkPlayerId, u16 move, u16 speciesPlayer, u16 speciesOpponent); void BravoTrainerPokemonProfile_BeforeInterview1(u16 move); void InterviewBefore(void); void InterviewAfter(void); void UpdateTVScreensOnMap(int, int); -void TV_PrintIntToStringVar(u8 varIdx, int value); -void SaveRecordedItemPurchasesForTVShow(void); +void ConvertIntToDecimalString(u8 varIdx, int value); +void TryPutSmartShopperOnAir(void); bool8 ShouldAirFrontierTVShow(void); -void sub_80EE8C8(u16 winStreak, u8 facilityAndMode); void BravoTrainerPokemonProfile_BeforeInterview2(u8 contestStandingPlace); void ContestLiveUpdates_Init(u8 round1Placing); void ContestLiveUpdates_SetRound2Placing(u8 round2Placing); @@ -65,5 +58,8 @@ void ContestLiveUpdates_SetWinnerAppealFlag(u8 flag); void ContestLiveUpdates_SetWinnerMoveUsed(u16 move); void ContestLiveUpdates_SetLoserData(u8 flag, u8 loser); void ResetGabbyAndTy(void); +u8 CheckForPlayersHouseNews(void); +bool8 IsGabbyAndTyShowOnTheAir(void); +void TryPutTrainerFanClubOnAir(void); #endif //GUARD_TV_H diff --git a/src/battle_main.c b/src/battle_main.c index 741461b0b2..c74de896e6 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5039,7 +5039,7 @@ static void HandleEndTurn_FinishBattle(void) } } } - PutPokemonTodayCaughtOnAir(); + TryPutPokemonTodayOnAir(); } if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK @@ -5052,7 +5052,7 @@ static void HandleEndTurn_FinishBattle(void) | BATTLE_TYPE_WALLY_TUTORIAL)) && gBattleResults.shinyWildMon) { - sub_80EE184(); + TryPutBreakingNewsOnAir(); } sub_8186444(); diff --git a/src/battle_tower.c b/src/battle_tower.c index b1e5d78172..082ea6822f 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -36,7 +36,6 @@ #include "constants/event_objects.h" #include "constants/moves.h" #include "constants/easy_chat.h" -#include "constants/tv.h" extern const u8 MossdeepCity_SpaceCenter_2F_EventScript_MaxieTrainer[]; extern const u8 MossdeepCity_SpaceCenter_2F_EventScript_TabithaTrainer[]; diff --git a/src/contest.c b/src/contest.c index 246fc1e501..1549544dfa 100644 --- a/src/contest.c +++ b/src/contest.c @@ -42,7 +42,6 @@ #include "constants/moves.h" #include "constants/rgb.h" #include "constants/songs.h" -#include "constants/tv.h" // This file's functions. static void LoadContestPalettes(void); diff --git a/src/contest_util.c b/src/contest_util.c index 98854c4c68..40c964bac8 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -44,7 +44,6 @@ #include "constants/game_stat.h" #include "constants/rgb.h" #include "constants/songs.h" -#include "constants/tv.h" #include "contest.h" enum { diff --git a/src/daycare.c b/src/daycare.c index 14cf578064..34b8649816 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -24,7 +24,7 @@ #include "constants/region_map_sections.h" // this file's functions -static void ClearDaycareMonMail(struct DayCareMail *mail); +static void ClearDaycareMonMail(struct DaycareMail *mail); static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare); static u8 GetDaycareCompatibilityScore(struct DayCare *daycare); static void DaycarePrintMonInfo(u8 windowId, s32 daycareSlotId, u8 y); @@ -120,7 +120,7 @@ u8 CountPokemonInDaycare(struct DayCare *daycare) return count; } -void InitDaycareMailRecordMixing(struct DayCare *daycare, struct RecordMixingDayCareMail *daycareMail) +void InitDaycareMailRecordMixing(struct DayCare *daycare, struct RecordMixingDaycareMail *daycareMail) { u8 i; u8 numDaycareMons = 0; @@ -131,13 +131,9 @@ void InitDaycareMailRecordMixing(struct DayCare *daycare, struct RecordMixingDay { numDaycareMons++; if (GetBoxMonData(&daycare->mons[i].mon, MON_DATA_HELD_ITEM) == ITEM_NONE) - { daycareMail->holdsItem[i] = FALSE; - } else - { daycareMail->holdsItem[i] = TRUE; - } } else { @@ -154,7 +150,7 @@ static s8 Daycare_FindEmptySpot(struct DayCare *daycare) for (i = 0; i < DAYCARE_MON_COUNT; i++) { - if (GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES) == 0) + if (GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES) == SPECIES_NONE) return i; } @@ -349,7 +345,7 @@ u8 GetNumLevelsGainedFromDaycare(void) return 0; } -static void ClearDaycareMonMail(struct DayCareMail *mail) +static void ClearDaycareMonMail(struct DaycareMail *mail) { s32 i; diff --git a/src/decoration.c b/src/decoration.c index b9a2437088..6b6cf21e88 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -1652,7 +1652,7 @@ static void PlaceDecoration(u8 taskId) gSprites[sDecor_CameraSpriteObjectIdx1].pos1.y += 2; if (gMapHeader.regionMapSectionId == MAPSEC_SECRET_BASE) - TV_PutSecretBaseVisitOnTheAir(); + TryPutSecretBaseVisitOnAir(); CancelDecorating_(taskId); } @@ -2260,7 +2260,7 @@ static void Task_PutAwayDecoration(u8 taskId) StringExpandPlaceholders(gStringVar4, gText_DecorationReturnedToPC); DisplayItemMessageOnField(taskId, gStringVar4, ContinuePuttingAwayDecorationsPrompt); if (gMapHeader.regionMapSectionId == MAPSEC_SECRET_BASE) - TV_PutSecretBaseVisitOnTheAir(); + TryPutSecretBaseVisitOnAir(); } break; } diff --git a/src/easy_chat.c b/src/easy_chat.c index 96d6808400..753c2df767 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -1474,8 +1474,8 @@ void ShowEasyChatScreen(void) words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.words[gSpecialVar_0x8006]; displayedPersonType = EASY_CHAT_PERSON_REPORTER_FEMALE; break; - case EASY_CHAT_TYPE_UNK_8: - words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].unkShow04.words; + case EASY_CHAT_TYPE_DUMMY_SHOW: + words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].dummy.words; displayedPersonType = EASY_CHAT_PERSON_REPORTER_MALE; break; case EASY_CHAT_TYPE_TRENDY_PHRASE: diff --git a/src/field_specials.c b/src/field_specials.c index df16583ed1..13fad83b1f 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -57,7 +57,6 @@ #include "constants/map_types.h" #include "constants/maps.h" #include "constants/mevent.h" -#include "constants/tv.h" #include "constants/script_menu.h" #include "constants/slot_machine.h" #include "constants/songs.h" @@ -1622,7 +1621,7 @@ void BufferLottoTicketNumber(void) { if (gSpecialVar_Result >= 10000) { - TV_PrintIntToStringVar(0, gSpecialVar_Result); + ConvertIntToDecimalString(0, gSpecialVar_Result); } else if (gSpecialVar_Result >= 1000) { diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c index 914ba28807..3d3b83fefc 100644 --- a/src/fldeff_misc.c +++ b/src/fldeff_misc.c @@ -22,7 +22,6 @@ #include "constants/metatile_behaviors.h" #include "constants/metatile_labels.h" #include "constants/songs.h" -#include "constants/tv.h" EWRAM_DATA struct MapPosition gPlayerFacingPosition = {0}; diff --git a/src/frontier_util.c b/src/frontier_util.c index 491aef9367..4aec27944d 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -1552,16 +1552,16 @@ static void CheckPutFrontierTVShowOnAir(void) switch (battleMode) { case FRONTIER_MODE_SINGLES: - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], 1); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_TOWER_SINGLES); break; case FRONTIER_MODE_DOUBLES: - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], 2); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_TOWER_DOUBLES); break; case FRONTIER_MODE_MULTIS: - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], 3); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_TOWER_MULTIS); break; case FRONTIER_MODE_LINK_MULTIS: - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], 4); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_TOWER_LINK_MULTIS); break; } } @@ -1575,9 +1575,9 @@ static void CheckPutFrontierTVShowOnAir(void) && ShouldAirFrontierTVShow()) { if (battleMode == FRONTIER_MODE_SINGLES) - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode], 5); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_DOME_SINGLES); else - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode], 6); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.domeWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_DOME_DOUBLES); } } break; @@ -1589,9 +1589,9 @@ static void CheckPutFrontierTVShowOnAir(void) && ShouldAirFrontierTVShow()) { if (battleMode == FRONTIER_MODE_SINGLES) - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode], 11); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_PALACE_SINGLES); else - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode], 12); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.palaceWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_PALACE_DOUBLES); } } break; @@ -1602,7 +1602,7 @@ static void CheckPutFrontierTVShowOnAir(void) if (gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode] > 1 && ShouldAirFrontierTVShow()) { - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode], 10); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.arenaWinStreaks[lvlMode], FRONTIER_SHOW_ARENA); } } break; @@ -1615,9 +1615,9 @@ static void CheckPutFrontierTVShowOnAir(void) && ShouldAirFrontierTVShow()) { if (battleMode == FRONTIER_MODE_SINGLES) - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode], 7); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_FACTORY_SINGLES); else - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode], 8); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode], FRONTIER_SHOW_FACTORY_DOUBLES); } } break; @@ -1628,7 +1628,7 @@ static void CheckPutFrontierTVShowOnAir(void) if (gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode] > 1 && ShouldAirFrontierTVShow()) { - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode], 9); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.pikeWinStreaks[lvlMode], FRONTIER_SHOW_PIKE); } } break; @@ -1639,7 +1639,7 @@ static void CheckPutFrontierTVShowOnAir(void) if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode] > 1 && ShouldAirFrontierTVShow()) { - TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode], 13); + TryPutFrontierTVShowOnAir(gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode], FRONTIER_SHOW_PYRAMID); } } break; diff --git a/src/item.c b/src/item.c index 8920921849..8259d1cd58 100644 --- a/src/item.c +++ b/src/item.c @@ -14,7 +14,6 @@ #include "battle_pyramid_bag.h" #include "constants/items.h" #include "constants/hold_effects.h" -#include "constants/tv.h" extern u16 gUnknown_0203CF30[]; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 2284156283..239639e0b6 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -680,45 +680,43 @@ void ScrSpecial_SetMauvilleOldManObjEventGfx(void) // Language fixers? -void sub_8120B70(union OldMan * oldMan) +void SanitizeMauvilleOldManForRuby(union OldMan * oldMan) { s32 i; u8 playerName[PLAYER_NAME_LENGTH + 1]; switch (oldMan->common.id) { - case MAUVILLE_MAN_TRADER: + case MAUVILLE_MAN_TRADER: + { + struct MauvilleOldManTrader * trader = &oldMan->trader; + for (i = 0; i < NUM_TRADER_ITEMS; i++) { - struct MauvilleOldManTrader * trader = &oldMan->trader; - for (i = 0; i < NUM_TRADER_ITEMS; i++) + if (trader->language[i] == LANGUAGE_JAPANESE) + ConvertInternationalString(trader->playerNames[i], LANGUAGE_JAPANESE); + } + break; + } + case MAUVILLE_MAN_STORYTELLER: + { + struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; + for (i = 0; i < NUM_STORYTELLER_TALES; i++) + { + if (storyteller->gameStatIDs[i] != 0) { - if (trader->language[i] == LANGUAGE_JAPANESE) + memcpy(playerName, storyteller->trainerNames[i], PLAYER_NAME_LENGTH); + playerName[PLAYER_NAME_LENGTH] = EOS; + if (IsStringJapanese(playerName)) { - ConvertInternationalString(trader->playerNames[i], LANGUAGE_JAPANESE); + memset(playerName, CHAR_SPACE, PLAYER_NAME_LENGTH + 1); + StringCopy(playerName, gText_Friend); + memcpy(storyteller->trainerNames[i], playerName, PLAYER_NAME_LENGTH); + storyteller->language[i] = GAME_LANGUAGE; } } } - break; - case MAUVILLE_MAN_STORYTELLER: - { - struct MauvilleManStoryteller * storyteller = &oldMan->storyteller; - for (i = 0; i < NUM_STORYTELLER_TALES; i++) - { - if (storyteller->gameStatIDs[i] != 0) - { - memcpy(playerName, storyteller->trainerNames[i], PLAYER_NAME_LENGTH); - playerName[PLAYER_NAME_LENGTH] = EOS; - if (IsStringJapanese(playerName)) - { - memset(playerName, CHAR_SPACE, PLAYER_NAME_LENGTH + 1); - StringCopy(playerName, gText_Friend); - memcpy(storyteller->trainerNames[i], playerName, PLAYER_NAME_LENGTH); - storyteller->language[i] = GAME_LANGUAGE; - } - } - } - } - break; + break; + } } } diff --git a/src/menu.c b/src/menu.c index 44b39d762d..c01a69b12f 100644 --- a/src/menu.c +++ b/src/menu.c @@ -509,12 +509,14 @@ void RemoveStartMenuWindow(void) } } -u16 sub_8197A30(void) +// Unused +static u16 GetDialogFrameBaseTileNum(void) { return DLG_WINDOW_BASE_TILE_NUM; } -u16 sub_8197A38(void) +// Unused +static u16 GetStandardFrameBaseTileNum(void) { return STD_WINDOW_BASE_TILE_NUM; } diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c index 78ebe02e4d..081a402188 100644 --- a/src/post_battle_event_funcs.c +++ b/src/post_battle_event_funcs.c @@ -8,7 +8,6 @@ #include "script_pokemon_util.h" #include "tv.h" #include "constants/heal_locations.h" -#include "constants/tv.h" int GameClear(void) { diff --git a/src/record_mixing.c b/src/record_mixing.c index 7cc88a54c1..aa6e4eef2a 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -51,7 +51,7 @@ struct PlayerRecordsRS PokeNews pokeNews[POKE_NEWS_COUNT]; OldMan oldMan; struct DewfordTrend dewfordTrends[SAVED_TRENDS_COUNT]; - struct RecordMixingDayCareMail dayCareMail; + struct RecordMixingDaycareMail daycareMail; struct RSBattleTowerRecord battleTowerRecord; u16 giftItem; u16 filler11C8[0x32]; @@ -64,7 +64,7 @@ struct PlayerRecordsEmerald /* 0x1004 */ PokeNews pokeNews[POKE_NEWS_COUNT]; /* 0x1044 */ OldMan oldMan; /* 0x1084 */ struct DewfordTrend dewfordTrends[SAVED_TRENDS_COUNT]; - /* 0x10ac */ struct RecordMixingDayCareMail dayCareMail; + /* 0x10ac */ struct RecordMixingDaycareMail daycareMail; /* 0x1124 */ struct EmeraldBattleTowerRecord battleTowerRecord; /* 0x1210 */ u16 giftItem; /* 0x1214 */ LilycoveLady lilycoveLady; @@ -87,7 +87,7 @@ static TVShow *sTvShowsSave; static PokeNews *sPokeNewsSave; static OldMan *sOldManSave; static struct DewfordTrend *sDewfordTrendsSave; -static struct RecordMixingDayCareMail *gUnknown_03001148; +static struct RecordMixingDaycareMail *sDaycareMailSave; static void *sBattleTowerSave; static LilycoveLady *sLilycoveLadySave; static void *sApprenticesSave; @@ -96,7 +96,7 @@ static u32 sRecordStructSize; static u8 gUnknown_03001160; static struct PlayerHallRecords *gUnknown_03001168[3]; -static EWRAM_DATA struct RecordMixingDayCareMail gUnknown_02039F9C = {0}; +static EWRAM_DATA struct RecordMixingDaycareMail sDaycareMail = {0}; static EWRAM_DATA union PlayerRecords *sReceivedRecords = NULL; static EWRAM_DATA union PlayerRecords *sSentRecord = NULL; @@ -115,14 +115,14 @@ static void ReceiveOldManData(OldMan *, size_t, u8); static void ReceiveBattleTowerData(void *battleTowerRecord, size_t, u8); static void ReceiveLilycoveLadyData(LilycoveLady *, size_t, u8); static void sub_80E7B2C(const u8 *); -static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *, size_t, u8, TVShow *); +static void ReceiveDaycareMailData(struct RecordMixingDaycareMail *, size_t, u8, TVShow *); static void ReceiveGiftItem(u16 *item, u8 which); static void Task_DoRecordMixing(u8 taskId); static void GetSavedApprentices(struct Apprentice *dst, struct Apprentice *src); static void ReceiveApprenticeData(struct Apprentice *mixApprentice, size_t recordSize, u32 multiplayerId); static void ReceiveRankingHallRecords(struct PlayerHallRecords *hallRecords, size_t arg1, u32 arg2); -static void sub_80E89F8(struct RecordMixingDayCareMail *dst); -static void SanitizeDayCareMailForRuby(struct RecordMixingDayCareMail *src); +static void GetRecordMixingDaycareMail(struct RecordMixingDaycareMail *dst); +static void SanitizeDaycareMailForRuby(struct RecordMixingDaycareMail *src); static void SanitizeEmeraldBattleTowerRecord(struct EmeraldBattleTowerRecord *arg0); static void SanitizeRubyBattleTowerRecord(struct RSBattleTowerRecord *src); @@ -180,7 +180,7 @@ static void SetSrcLookupPointers(void) sPokeNewsSave = gSaveBlock1Ptr->pokeNews; sOldManSave = &gSaveBlock1Ptr->oldMan; sDewfordTrendsSave = gSaveBlock1Ptr->dewfordTrends; - gUnknown_03001148 = &gUnknown_02039F9C; + sDaycareMailSave = &sDaycareMail; sBattleTowerSave = &gSaveBlock2Ptr->frontier.towerPlayer; sLilycoveLadySave = &gSaveBlock1Ptr->lilycoveLady; sApprenticesSave = gSaveBlock2Ptr->apprentices; @@ -191,11 +191,11 @@ static void PrepareUnknownExchangePacket(struct PlayerRecordsRS *dest) { memcpy(dest->secretBases, sSecretBasesSave, sizeof(dest->secretBases)); memcpy(dest->tvShows, sTvShowsSave, sizeof(dest->tvShows)); - sub_80F14F8(dest->tvShows); + SanitizeTVShowLocationsForRuby(dest->tvShows); memcpy(dest->pokeNews, sPokeNewsSave, sizeof(dest->pokeNews)); memcpy(&dest->oldMan, sOldManSave, sizeof(dest->oldMan)); memcpy(dest->dewfordTrends, sDewfordTrendsSave, sizeof(dest->dewfordTrends)); - sub_80E89F8(&dest->dayCareMail); + GetRecordMixingDaycareMail(&dest->daycareMail); EmeraldBattleTowerRecordToRuby(sBattleTowerSave, &dest->battleTowerRecord); if (GetMultiplayerId() == 0) @@ -207,13 +207,13 @@ static void PrepareExchangePacketForRubySapphire(struct PlayerRecordsRS *dest) memcpy(dest->secretBases, sSecretBasesSave, sizeof(dest->secretBases)); ClearJapaneseSecretBases(dest->secretBases); memcpy(dest->tvShows, sTvShowsSave, sizeof(dest->tvShows)); - sub_80F1208(dest->tvShows); + SanitizeTVShowsForRuby(dest->tvShows); memcpy(dest->pokeNews, sPokeNewsSave, sizeof(dest->pokeNews)); memcpy(&dest->oldMan, sOldManSave, sizeof(dest->oldMan)); - sub_8120B70(&dest->oldMan); + SanitizeMauvilleOldManForRuby(&dest->oldMan); memcpy(dest->dewfordTrends, sDewfordTrendsSave, sizeof(dest->dewfordTrends)); - sub_80E89F8(&dest->dayCareMail); - SanitizeDayCareMailForRuby(&dest->dayCareMail); + GetRecordMixingDaycareMail(&dest->daycareMail); + SanitizeDaycareMailForRuby(&dest->daycareMail); EmeraldBattleTowerRecordToRuby(sBattleTowerSave, &dest->battleTowerRecord); SanitizeRubyBattleTowerRecord(&dest->battleTowerRecord); @@ -224,7 +224,7 @@ static void PrepareExchangePacketForRubySapphire(struct PlayerRecordsRS *dest) static void PrepareExchangePacket(void) { SetPlayerSecretBaseParty(); - sub_80F0BB8(); + DeactivateAllNormalTVShows(); SetSrcLookupPointers(); if (Link_AnyPartnersPlayingRubyOrSapphire()) @@ -242,7 +242,7 @@ static void PrepareExchangePacket(void) memcpy(&sSentRecord->emerald.oldMan, sOldManSave, sizeof(sSentRecord->emerald.oldMan)); memcpy(&sSentRecord->emerald.lilycoveLady, sLilycoveLadySave, sizeof(sSentRecord->emerald.lilycoveLady)); memcpy(sSentRecord->emerald.dewfordTrends, sDewfordTrendsSave, sizeof(sSentRecord->emerald.dewfordTrends)); - sub_80E89F8(&sSentRecord->emerald.dayCareMail); + GetRecordMixingDaycareMail(&sSentRecord->emerald.daycareMail); memcpy(&sSentRecord->emerald.battleTowerRecord, sBattleTowerSave, sizeof(sSentRecord->emerald.battleTowerRecord)); SanitizeEmeraldBattleTowerRecord(&sSentRecord->emerald.battleTowerRecord); @@ -261,7 +261,7 @@ static void ReceiveExchangePacket(u32 which) // Ruby/Sapphire sub_80E7B2C((void *)sReceivedRecords->ruby.tvShows); ReceiveSecretBasesData(sReceivedRecords->ruby.secretBases, sizeof(struct PlayerRecordsRS), which); - ReceiveDaycareMailData(&sReceivedRecords->ruby.dayCareMail, sizeof(struct PlayerRecordsRS), which, sReceivedRecords->ruby.tvShows); + ReceiveDaycareMailData(&sReceivedRecords->ruby.daycareMail, sizeof(struct PlayerRecordsRS), which, sReceivedRecords->ruby.tvShows); ReceiveBattleTowerData(&sReceivedRecords->ruby.battleTowerRecord, sizeof(struct PlayerRecordsRS), which); ReceiveTvShowsData(sReceivedRecords->ruby.tvShows, sizeof(struct PlayerRecordsRS), which); ReceivePokeNewsData(sReceivedRecords->ruby.pokeNews, sizeof(struct PlayerRecordsRS), which); @@ -278,7 +278,7 @@ static void ReceiveExchangePacket(u32 which) ReceivePokeNewsData(sReceivedRecords->emerald.pokeNews, sizeof(struct PlayerRecordsEmerald), which); ReceiveOldManData(&sReceivedRecords->emerald.oldMan, sizeof(struct PlayerRecordsEmerald), which); ReceiveDewfordTrendData(sReceivedRecords->emerald.dewfordTrends, sizeof(struct PlayerRecordsEmerald), which); - ReceiveDaycareMailData(&sReceivedRecords->emerald.dayCareMail, sizeof(struct PlayerRecordsEmerald), which, sReceivedRecords->emerald.tvShows); + ReceiveDaycareMailData(&sReceivedRecords->emerald.daycareMail, sizeof(struct PlayerRecordsEmerald), which, sReceivedRecords->emerald.tvShows); ReceiveBattleTowerData(&sReceivedRecords->emerald.battleTowerRecord, sizeof(struct PlayerRecordsEmerald), which); ReceiveGiftItem(&sReceivedRecords->emerald.giftItem, which); ReceiveLilycoveLadyData(&sReceivedRecords->emerald.lilycoveLady, sizeof(struct PlayerRecordsEmerald), which); @@ -319,7 +319,7 @@ static void Task_RecordMixing_Main(u8 taskId) { case 0: // init sSentRecord = malloc(sizeof(union PlayerRecords)); - sReceivedRecords = malloc(sizeof(union PlayerRecords) * 4); + sReceivedRecords = malloc(sizeof(union PlayerRecords) * MAX_LINK_PLAYERS); SetLocalLinkPlayerId(gSpecialVar_0x8005); VarSet(VAR_TEMP_0, 1); gUnknown_03001130 = FALSE; @@ -665,7 +665,7 @@ static void ReceiveBattleTowerData(void *battleTowerRecord, size_t recordSize, u { memcpy((void *)battleTowerRecord + recordSize * which, (void *)battleTowerRecord + recordSize * mixIndices[which], sizeof(struct EmeraldBattleTowerRecord)); dest = (void *)battleTowerRecord + recordSize * which; - for (i = 0; i < 4; i ++) + for (i = 0; i < MAX_FRONTIER_PARTY_SIZE; i++) { btPokemon = &dest->party[i]; if (btPokemon->species != SPECIES_NONE && IsStringJapanese(btPokemon->nickname)) @@ -706,22 +706,22 @@ static void ReceiveLilycoveLadyData(LilycoveLady *lilycoveLady, size_t recordSiz } } -static u8 sub_80E7A9C(struct DayCareMail *rmMail) +static u8 sub_80E7A9C(struct DaycareMail *rmMail) { return rmMail->message.itemId; } -static void sub_80E7AA4(struct RecordMixingDayCareMail *src, size_t recordSize, u8 (*idxs)[2], u8 which0, u8 which1) +static void sub_80E7AA4(struct RecordMixingDaycareMail *src, size_t recordSize, u8 (*idxs)[2], u8 which0, u8 which1) { - struct DayCareMail buffer; - struct RecordMixingDayCareMail *mail1; - struct RecordMixingDayCareMail *mail2; + struct DaycareMail buffer; + struct RecordMixingDaycareMail *mail1; + struct RecordMixingDaycareMail *mail2; mail1 = (void *)src + recordSize * idxs[which0][0]; - memcpy(&buffer, &mail1->mail[idxs[which0][1]], sizeof(struct DayCareMail)); + memcpy(&buffer, &mail1->mail[idxs[which0][1]], sizeof(struct DaycareMail)); mail2 = (void *)src + recordSize * idxs[which1][0]; - memcpy(&mail1->mail[idxs[which0][1]], &mail2->mail[idxs[which1][1]], sizeof(struct DayCareMail)); - memcpy(&mail2->mail[idxs[which1][1]], &buffer, sizeof(struct DayCareMail)); + memcpy(&mail1->mail[idxs[which0][1]], &mail2->mail[idxs[which1][1]], sizeof(struct DaycareMail)); + memcpy(&mail2->mail[idxs[which1][1]], &buffer, sizeof(struct DaycareMail)); } static void sub_80E7B2C(const u8 *src) @@ -730,7 +730,7 @@ static void sub_80E7B2C(const u8 *src) s32 i; sum = 0; - for (i = 0; i < 256; i ++) + for (i = 0; i < 256; i++) sum += src[i]; gUnknown_03001160 = sum; @@ -741,17 +741,17 @@ static u8 sub_80E7B54(void) return gUnknown_03001160; } -static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t recordSize, u8 which, TVShow *shows) +static void ReceiveDaycareMailData(struct RecordMixingDaycareMail *src, size_t recordSize, u8 which, TVShow *shows) { u16 i, j; u8 linkPlayerCount; u8 tableId; - struct RecordMixingDayCareMail *_src; + struct RecordMixingDaycareMail *_src; u8 which0, which1; void *ptr; u8 sp04[4]; u8 sp08[4]; - struct RecordMixingDayCareMail *sp0c[4]; + struct RecordMixingDaycareMail *sp0c[4]; u8 sp1c[4][2]; u8 sp24[4][2]; u8 sp34; @@ -777,10 +777,10 @@ static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t r _src = (void *)src + i * recordSize; language = gLinkPlayers[i].language; version = gLinkPlayers[i].version & 0xFF; - for (j = 0; j < _src->numDaycareMons; j ++) + for (j = 0; j < _src->numDaycareMons; j++) { u16 otNameLanguage, nicknameLanguage; - struct DayCareMail *recordMixingMail = &_src->mail[j]; + struct DaycareMail *recordMixingMail = &_src->mail[j]; if (!recordMixingMail->message.itemId) continue; @@ -835,7 +835,7 @@ static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t r if (_src->numDaycareMons == 0) continue; - for (j = 0; j < _src->numDaycareMons; j ++) + for (j = 0; j < _src->numDaycareMons; j++) { if (!_src->holdsItem[j]) sp1c[i][j] = 1; @@ -913,8 +913,8 @@ static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t r } _src = (void *)src + which * recordSize; - memcpy(&gSaveBlock1Ptr->daycare.mons[0].mail, &_src->mail[0], sizeof(struct DayCareMail)); - memcpy(&gSaveBlock1Ptr->daycare.mons[1].mail, &_src->mail[1], sizeof(struct DayCareMail)); + memcpy(&gSaveBlock1Ptr->daycare.mons[0].mail, &_src->mail[0], sizeof(struct DaycareMail)); + memcpy(&gSaveBlock1Ptr->daycare.mons[1].mail, &_src->mail[1], sizeof(struct DaycareMail)); SeedRng(oldSeed); } @@ -957,7 +957,7 @@ static void Task_DoRecordMixing(u8 taskId) case 2: SetContinueGameWarpStatusToDynamicWarp(); FullSaveGame(); - task->data[0] ++; + task->data[0]++; break; case 3: if (CheckSaveFile()) @@ -971,7 +971,7 @@ static void Task_DoRecordMixing(u8 taskId) if (++task->data[1] > 10) { SetCloseLinkCallback(); - task->data[0] ++; + task->data[0]++; } break; case 5: @@ -984,7 +984,7 @@ static void Task_DoRecordMixing(u8 taskId) if (!sub_801048C(FALSE)) { CreateTask(Task_LinkSave, 5); - task->data[0] ++; + task->data[0]++; } break; case 7: // wait for Task_LinkSave to finish. @@ -1003,7 +1003,7 @@ static void Task_DoRecordMixing(u8 taskId) break; case 8: SetLinkStandbyCallback(); - task->data[0] ++; + task->data[0]++; break; case 9: if (IsLinkTaskFinished()) @@ -1061,13 +1061,9 @@ static void GetSavedApprentices(struct Apprentice *dst, struct Apprentice *src) break; case 2: if (Random2() > 0x3333) - { dst[1] = src[gSaveBlock2Ptr->playerApprentice.saveId + 1]; - } else - { dst[1] = src[((gSaveBlock2Ptr->playerApprentice.saveId + 1) % (APPRENTICE_COUNT - 1) + 1)]; - } break; } } @@ -1221,7 +1217,7 @@ static void sub_80E8578(struct RecordMixingHallRecords *dst, void *hallRecords, for (l = 0; l < 3; l++) { if (GetTrainerId(dst->hallRecords2P[j][l].id1) == GetTrainerId(gUnknown_03001168[k]->twoPlayers[j].id1) - && GetTrainerId(dst->hallRecords2P[j][l].id2) == GetTrainerId(gUnknown_03001168[k]->twoPlayers[j].id2)) + && GetTrainerId(dst->hallRecords2P[j][l].id2) == GetTrainerId(gUnknown_03001168[k]->twoPlayers[j].id2)) { var_68++; if (dst->hallRecords2P[j][l].winStreak < gUnknown_03001168[k]->twoPlayers[j].winStreak) @@ -1308,21 +1304,21 @@ static void ReceiveRankingHallRecords(struct PlayerHallRecords *hallRecords, siz Free(largeStructPtr); } -static void sub_80E89F8(struct RecordMixingDayCareMail *dst) +static void GetRecordMixingDaycareMail(struct RecordMixingDaycareMail *dst) { - gUnknown_02039F9C.mail[0] = gSaveBlock1Ptr->daycare.mons[0].mail; - gUnknown_02039F9C.mail[1] = gSaveBlock1Ptr->daycare.mons[1].mail; - InitDaycareMailRecordMixing(&gSaveBlock1Ptr->daycare, &gUnknown_02039F9C); - *dst = *gUnknown_03001148; + sDaycareMail.mail[0] = gSaveBlock1Ptr->daycare.mons[0].mail; + sDaycareMail.mail[1] = gSaveBlock1Ptr->daycare.mons[1].mail; + InitDaycareMailRecordMixing(&gSaveBlock1Ptr->daycare, &sDaycareMail); + *dst = *sDaycareMailSave; } -static void SanitizeDayCareMailForRuby(struct RecordMixingDayCareMail *src) +static void SanitizeDaycareMailForRuby(struct RecordMixingDaycareMail *src) { s32 i; for (i = 0; i < src->numDaycareMons; i++) { - struct DayCareMail *mail = &src->mail[i]; + struct DaycareMail *mail = &src->mail[i]; if (mail->message.itemId != 0) { if (mail->gameLanguage != LANGUAGE_JAPANESE) @@ -1342,10 +1338,10 @@ static void SanitizeEmeraldBattleTowerRecord(struct EmeraldBattleTowerRecord *ds { s32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_FRONTIER_PARTY_SIZE; i++) { struct BattleTowerPokemon *towerMon = &dst->party[i]; - if (towerMon->species != 0) + if (towerMon->species != SPECIES_NONE) StripExtCtrlCodes(towerMon->nickname); } diff --git a/src/roulette.c b/src/roulette.c index f0b484fe8d..cf27fdf9b8 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -1968,7 +1968,7 @@ static void ExitRoulette(u8 taskId) gSpecialVar_0x8004 = TRUE; else gSpecialVar_0x8004 = FALSE; - AlertTVOfNewCoinTotal(GetCoins()); + TryPutFindThatGamerOnAir(GetCoins()); BeginHardwarePaletteFade(0xFF, 0, 0, 16, 0); gTasks[taskId].func = Task_ExitRoulette; } diff --git a/src/safari_zone.c b/src/safari_zone.c index 3b86bc4640..1f13976569 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -65,7 +65,7 @@ void EnterSafariMode(void) void ExitSafariMode(void) { - sub_80EE44C(sSafariZoneCaughtMons, sSafariZonePkblkUses); + TryPutSafariFanClubOnAir(sSafariZoneCaughtMons, sSafariZonePkblkUses); ResetSafariZoneFlag(); ClearAllPokeblockFeeders(); gNumSafariBalls = 0; diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index ad1a55230e..93a7477720 100755 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -22,7 +22,6 @@ #include "string_util.h" #include "tv.h" #include "constants/items.h" -#include "constants/tv.h" #include "constants/battle_frontier.h" static void CB2_ReturnFromChooseHalfParty(void); diff --git a/src/secret_base.c b/src/secret_base.c index ddc051dca7..e1c62e2f2b 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -47,7 +47,6 @@ #include "constants/secret_bases.h" #include "constants/songs.h" #include "constants/trainers.h" -#include "constants/tv.h" // Values for registryStatus enum { diff --git a/src/shop.c b/src/shop.c index dac43c96d1..55b421928c 100755 --- a/src/shop.c +++ b/src/shop.c @@ -38,7 +38,6 @@ #include "constants/metatile_behaviors.h" #include "constants/rgb.h" #include "constants/songs.h" -#include "constants/tv.h" #define TAG_SCROLL_ARROW 2100 #define TAG_ITEM_ICON_BASE 2110 @@ -48,7 +47,7 @@ static EWRAM_DATA struct ShopData *sShopData = NULL; static EWRAM_DATA struct ListMenuItem *sListMenuItems = NULL; static EWRAM_DATA u8 (*sItemNames)[16] = {0}; static EWRAM_DATA u8 sPurchaseHistoryId = 0; -EWRAM_DATA struct ItemSlot gMartPurchaseHistory[3] = {0}; +EWRAM_DATA struct ItemSlot gMartPurchaseHistory[SMARTSHOPPER_NUM_ITEMS] = {0}; static void Task_ShopMenu(u8 taskId); static void Task_HandleShopMenuQuit(u8 taskId); @@ -373,7 +372,7 @@ static void Task_HandleShopMenuQuit(u8 taskId) { ClearStdWindowAndFrameToTransparent(sMartInfo.windowId, 2); RemoveWindow(sMartInfo.windowId); - SaveRecordedItemPurchasesForTVShow(); + TryPutSmartShopperOnAir(); ScriptContext2_Disable(); DestroyTask(taskId); diff --git a/src/slot_machine.c b/src/slot_machine.c index aa32d5d954..9a3a9ee06b 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -1592,7 +1592,7 @@ static bool8 SlotAction_WaitMsg_NoMoreCoins(struct Task *task) static bool8 SlotAction_EndGame(struct Task *task) { SetCoins(sSlotMachine->coins); - AlertTVOfNewCoinTotal(GetCoins()); + TryPutFindThatGamerOnAir(GetCoins()); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB(0, 0, 0)); sSlotMachine->state++; // SLOT_ACTION_FREE return FALSE; diff --git a/src/tv.c b/src/tv.c index 0466ee713a..50adde3f43 100644 --- a/src/tv.c +++ b/src/tv.c @@ -41,18 +41,27 @@ #include "constants/lilycove_lady.h" #include "constants/maps.h" #include "constants/metatile_behaviors.h" +#include "constants/metatile_labels.h" #include "constants/moves.h" #include "constants/region_map_sections.h" #include "constants/script_menu.h" -#include "constants/tv.h" - -// Static type declarations #define LAST_TVSHOW_IDX (TV_SHOWS_COUNT - 1) -#define rbernoulli(num, den) TV_BernoulliTrial(0xFFFF * (num) / (den)) +#define rbernoulli(num, den) BernoulliTrial(0xFFFF * (num) / (den)) -// Static RAM declarations +enum { + TVGROUP_NONE, + TVGROUP_UNUSED, + TVGROUP_NORMAL, + TVGROUP_RECORD_MIX, + TVGROUP_OUTBREAK, +}; + +enum { + SLOT_MACHINE, + ROULETTE, +}; s8 sCurTVShowSlot; u16 sTV_SecretBaseVisitMovesTemp[8]; @@ -67,79 +76,77 @@ static u8 sTVShowMixingNumPlayers; static u8 sTVShowNewsMixingNumPlayers; static s8 sTVShowMixingCurSlot; -EWRAM_DATA u16 sPokemonAnglerSpecies = 0; -EWRAM_DATA u16 sPokemonAnglerAttemptCounters = 0; -EWRAM_DATA u16 sFindThatGamerCoinsSpent = 0; -EWRAM_DATA u8 sFindThatGamerWhichGame = SLOT_MACHINE; -EWRAM_DATA ALIGNED(4) u8 sRecordMixingPartnersWithoutShowsToShare = 0; -EWRAM_DATA ALIGNED(4) u8 sTVShowState = 0; -EWRAM_DATA u8 sTVSecretBaseSecretsRandomValues[3] = {}; +static EWRAM_DATA u16 sPokemonAnglerSpecies = 0; +static EWRAM_DATA u16 sPokemonAnglerAttemptCounters = 0; +static EWRAM_DATA u16 sFindThatGamerCoinsSpent = 0; +static EWRAM_DATA u8 sFindThatGamerWhichGame = SLOT_MACHINE; +static EWRAM_DATA ALIGNED(4) u8 sRecordMixingPartnersWithoutShowsToShare = 0; +static EWRAM_DATA ALIGNED(4) u8 sTVShowState = 0; +static EWRAM_DATA u8 sTVSecretBaseSecretsRandomValues[3] = {}; -// Static ROM declarations -void ClearPokemonNews(void); -u8 GetTVChannelByShowType(u8 kind); -u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void); -u8 CheckForBigMovieOrEmergencyNewsOnTV(void); -void SetTVMetatilesOnMap(int width, int height, u16 tileId); -u8 FindAnyTVNewsOnTheAir(void); -bool8 IsTVShowInSearchOfTrainersAiring(void); -void TakeTVShowInSearchOfTrainersOffTheAir(void); -bool8 TV_BernoulliTrial(u16 ratio); -s8 FindEmptyTVSlotBeyondFirstFiveShowsOfArray(TVShow *shows); -bool8 HasMixableShowAlreadyBeenSpawnedWithPlayerID(u8 kind, bool8 flag); -void tv_store_id_3x(TVShow *show); -void DeleteTVShowInArrayByIdx(TVShow *shows, u8 idx); -s8 FindEmptyTVSlotWithinFirstFiveShowsOfArray(TVShow *shows); -void FindActiveBroadcastByShowType_SetScriptResult(u8 kind); +static void ClearPokeNews(void); +static u8 GetTVGroupByShowId(u8); +static u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void); +static void SetTVMetatilesOnMap(int, int, u16); +static u8 FindAnyPokeNewsOnTheAir(void); +static void TakeGabbyAndTyOffTheAir(void); +static bool8 BernoulliTrial(u16 ratio); +static s8 FindFirstEmptyRecordMixTVShowSlot(TVShow *); +static bool8 IsRecordMixShowAlreadySpawned(u8, bool8); +static void StorePlayerIdInRecordMixShow(TVShow *); +static void DeleteTVShowInArrayByIdx(TVShow *, u8); +static s8 FindFirstEmptyNormalTVShowSlot(TVShow *); +static void TryReplaceOldTVShowOfKind(u8); static void InterviewBefore_BravoTrainerPkmnProfile(void); static void InterviewBefore_NameRater(void); -u16 TV_GetSomeOtherSpeciesAlreadySeenByPlayer(u16 passedSpecies); -static void sub_80EFA88(void); -static void sub_80EF93C(TVShow *shows); -s8 sub_80EEE30(PokeNews *pokeNews); -bool8 sub_80EF0E4(u8 newsKind); -void ClearPokemonNewsI(u8 i); -static void sub_80F1254(TVShow *shows); -static void sub_80F12A4(TVShow *shows); -static void sub_80F0358(TVShow *player1, TVShow *player2, TVShow *player3, TVShow *player4); -static void sub_80F0C04(void); -static void sub_80F0708(void); -static void sub_80F0B64(void); -static s8 sub_80F06D0(TVShow *tvShows); -static bool8 sub_80F049C(TVShow *dest[], TVShow *src[], u8 idx); -static bool8 sub_80F0580(TVShow *tv1, TVShow *tv2, u8 idx); -static bool8 sub_80F05E8(TVShow *tv1, TVShow *tv2, u8 idx); -static bool8 sub_80F0668(TVShow *tv1, TVShow *tv2, u8 idx); -void SetTvShowInactive(u8 showIdx); -static void sub_80F0B24(u16 species, u8 showIdx); -static void sub_80F0D60(PokeNews *player1, PokeNews *player2, PokeNews *player3, PokeNews *player4); -static void sub_80F0EEC(void); -static void sub_80F0F24(void); -static s8 sub_80F0ECC(PokeNews *pokeNews, u8 idx); -static void sub_80F0E58(PokeNews *dest[], PokeNews *src[]); -static bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot); -void TVShowDone(void); +static u16 GetRandomDifferentSpeciesSeenByPlayer(u16); +static void Script_FindFirstEmptyNormalTVShowSlot(void); +static void CompactTVShowArray(TVShow *); +static s8 GetFirstEmptyPokeNewsSlot(PokeNews *); +static bool8 IsAddingPokeNewsDisallowed(u8); +static void ClearPokeNewsBySlot(u8); +static void TranslateRubyShows(TVShow *); +static void TranslateJapaneseEmeraldShows(TVShow *); +static void SetMixedTVShows(TVShow *, TVShow *, TVShow *, TVShow *); +static void DeleteExcessMixedShows(void); +static void DeactivateShowsWithUnseenSpecies(void); +static void DeactivateGameCompleteShowsIfNotUnlocked(void); +static s8 FindInactiveShowInArray(TVShow *); +static bool8 TryMixTVShow(TVShow *[], TVShow *[], u8); +static bool8 TryMixNormalTVShow(TVShow *, TVShow *, u8); +static bool8 TryMixRecordMixTVShow(TVShow *, TVShow *, u8); +static bool8 TryMixOutbreakTVShow(TVShow *, TVShow *, u8); +static void DeactivateShow(u8 showIdx); +static void DeactivateShowIfNotSeenSpecies(u16, u8); +static void SetMixedPokeNews(PokeNews *, PokeNews *, PokeNews *, PokeNews *); +static void ClearInvalidPokeNews(void); +static void ClearPokeNewsIfGameNotComplete(void); +static s8 GetPokeNewsSlotIfActive(PokeNews *, u8); +static void InitTryMixPokeNewsShow(PokeNews *[], PokeNews *[]); +static bool8 TryMixPokeNewsShow(PokeNews *, PokeNews *, s8); +static void TVShowDone(void); static void InterviewAfter_FanClubLetter(void); static void InterviewAfter_RecentHappenings(void); static void InterviewAfter_PkmnFanClubOpinions(void); -static void InterviewAfter_DummyShow4(void); +static void InterviewAfter_Dummy(void); static void InterviewAfter_BravoTrainerPokemonProfile(void); static void InterviewAfter_BravoTrainerBattleTowerProfile(void); static void InterviewAfter_ContestLiveUpdates(void); -void UpdateWorldOfMastersAndPutItOnTheAir(void); -void PutPokemonTodayFailedOnTheAir(void); -static void sub_80ED718(void); -static void sub_80EED88(void); -void TV_SortPurchasesByQuantity(void); -static void UpdateMassOutbreakTimeLeft(u16 days); -static void TryEndMassOutbreak(u16 days); -static void sub_80EF120(u16 days); -static void sub_80EDA48(u16 days); -static void sub_80EEB98(u16 days); -void PutFishingAdviceShowOnTheAir(void); -static u8 MonDataIdxToRibbon(u8 monDataIdx); -static void sub_80EEBF4(u8 actionIdx); -bool8 IsPriceDiscounted(u8 newsKind); +static void InitWorldOfMastersShowAttempt(void); +static void TryPutPokemonTodayFailedOnTheAir(void); +static void TryStartRandomMassOutbreak(void); +static void TryPutRandomPokeNewsOnAir(void); +static void SortPurchasesByQuantity(void); +static void UpdateMassOutbreakTimeLeft(u16); +static void TryEndMassOutbreak(u16); +static void UpdatePokeNewsTimeLeft(u16); +static void ResolveWorldOfMastersShow(u16); +static void ResolveNumberOneShow(u16); +static void TryPutFishingAdviceOnAir(void); +static u8 MonDataIdxToRibbon(u8); +static void TryPutNumberOneOnAir(u8); +static bool8 IsPriceDiscounted(u8); +static void TryPutWorldOfMastersOnAir(void); static void InterviewBefore_FanClubLetter(void); static void InterviewBefore_RecentHappenings(void); static void InterviewBefore_PkmnFanClubOpinions(void); @@ -148,7 +155,7 @@ static void InterviewBefore_BravoTrainerBTProfile(void); static void InterviewBefore_ContestLiveUpdates(void); static void InterviewBefore_3CheersForPokeblocks(void); static void InterviewBefore_FanClubSpecial(void); -void ChangeBoxPokemonNickname_CB(void); +static void ChangeBoxPokemonNickname_CB(void); static void DoTVShowPokemonFanClubLetter(void); static void DoTVShowRecentHappenings(void); static void DoTVShowPokemonFanClubOpinions(void); @@ -182,8 +189,6 @@ static void DoTVShowSecretBaseSecrets(void); static void DoTVShowSafariFanClub(void); static void DoTVShowLilycoveContestLady(void); -// .rodata - static const struct { u16 species; u16 moves[MAX_MON_MOVES]; @@ -753,23 +758,18 @@ const u8 sTVSecretBaseSecretsActions[NUM_SECRET_BASE_FLAGS] = SBSECRETS_NUM_STATES // SECRET_BASE_UNUSED_FLAG. Odd that this is included, if it were used it would overflow sTVSecretBaseSecretsTextGroup }; -// .text - void ClearTVShowData(void) { - u8 i; - u8 j; + u8 i, j; - for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows); i ++) + for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows); i++) { gSaveBlock1Ptr->tvShows[i].commonInit.kind = 0; gSaveBlock1Ptr->tvShows[i].commonInit.active = 0; - for (j = 0; j < ARRAY_COUNT(gSaveBlock1Ptr->tvShows[i].commonInit.pad02); j ++) - { - gSaveBlock1Ptr->tvShows[i].commonInit.pad02[j] = 0; - } + for (j = 0; j < ARRAY_COUNT(gSaveBlock1Ptr->tvShows[i].commonInit.data); j++) + gSaveBlock1Ptr->tvShows[i].commonInit.data[j] = 0; } - ClearPokemonNews(); + ClearPokeNews(); } u8 GetRandomActiveShowIdx(void) @@ -779,7 +779,8 @@ u8 GetRandomActiveShowIdx(void) u8 selIdx; TVShow *show; - for (i = 5; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows) - 1; i ++) + // Include all normal TV shows, and up through any present Record Mix shows + for (i = NUM_NORMAL_TVSHOW_SLOTS; i < LAST_TVSHOW_IDX; i++) { if (gSaveBlock1Ptr->tvShows[i].common.kind == TVSHOW_OFF_AIR) break; @@ -788,7 +789,7 @@ u8 GetRandomActiveShowIdx(void) selIdx = j; do { - if (GetTVChannelByShowType(gSaveBlock1Ptr->tvShows[j].common.kind) != 4) + if (GetTVGroupByShowId(gSaveBlock1Ptr->tvShows[j].common.kind) != TVGROUP_OUTBREAK) { if (gSaveBlock1Ptr->tvShows[j].common.active == TRUE) return j; @@ -803,7 +804,7 @@ u8 GetRandomActiveShowIdx(void) if (j == 0) j = ARRAY_COUNT(gSaveBlock1Ptr->tvShows) - 2; else - j --; + j--; } while (j != selIdx); return 0xFF; @@ -811,88 +812,88 @@ u8 GetRandomActiveShowIdx(void) u8 FindAnyTVShowOnTheAir(void) { - u8 show; - - show = GetRandomActiveShowIdx(); - if (show == 0xFF) - { + u8 slot = GetRandomActiveShowIdx(); + if (slot == 0xFF) return 0xFF; - } - if (gSaveBlock1Ptr->outbreakPokemonSpecies != SPECIES_NONE && gSaveBlock1Ptr->tvShows[show].common.kind == TVSHOW_MASS_OUTBREAK) - { + + if (gSaveBlock1Ptr->outbreakPokemonSpecies != SPECIES_NONE + && gSaveBlock1Ptr->tvShows[slot].common.kind == TVSHOW_MASS_OUTBREAK) return FindFirstActiveTVShowThatIsNotAMassOutbreak(); - } - return show; + + return slot; } void UpdateTVScreensOnMap(int width, int height) { FlagSet(FLAG_SYS_TV_WATCH); - switch (CheckForBigMovieOrEmergencyNewsOnTV()) + switch (CheckForPlayersHouseNews()) { - case 1: - SetTVMetatilesOnMap(width, height, 0x3); - break; - case 2: - break; - default: - if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(LILYCOVE_CITY_COVE_LILY_MOTEL_1F) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(LILYCOVE_CITY_COVE_LILY_MOTEL_1F)) - { - SetTVMetatilesOnMap(width, height, 0x3); - } - else if (FlagGet(FLAG_SYS_TV_START) && (FindAnyTVShowOnTheAir() != 0xFF || FindAnyTVNewsOnTheAir() != 0xFF || IsTVShowInSearchOfTrainersAiring())) - { - FlagClear(FLAG_SYS_TV_WATCH); - SetTVMetatilesOnMap(width, height, 0x3); - } - break; + case PLAYERS_HOUSE_TV_LATI: + SetTVMetatilesOnMap(width, height, METATILE_Building_TV_On); + break; + case PLAYERS_HOUSE_TV_MOVIE: + // Don't flash TV for movie text in player's house + break; +// case PLAYERS_HOUSE_TV_NONE: + default: + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(LILYCOVE_CITY_COVE_LILY_MOTEL_1F) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(LILYCOVE_CITY_COVE_LILY_MOTEL_1F)) + { + // NPC in Lilycove Hotel is always watching TV + SetTVMetatilesOnMap(width, height, METATILE_Building_TV_On); + } + else if (FlagGet(FLAG_SYS_TV_START) && (FindAnyTVShowOnTheAir() != 0xFF || FindAnyPokeNewsOnTheAir() != 0xFF || IsGabbyAndTyShowOnTheAir())) + { + FlagClear(FLAG_SYS_TV_WATCH); + SetTVMetatilesOnMap(width, height, METATILE_Building_TV_On); + } + break; } } -void SetTVMetatilesOnMap(int width, int height, u16 tileId) +static void SetTVMetatilesOnMap(int width, int height, u16 tileId) { int x; int y; - for (y = 0; y < height; y ++) + for (y = 0; y < height; y++) { - for (x = 0; x < width; x ++) + for (x = 0; x < width; x++) { if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION) - { MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK); - } } } } void TurnOffTVScreen(void) { - SetTVMetatilesOnMap(gBackupMapLayout.width, gBackupMapLayout.height, 0x0002); + SetTVMetatilesOnMap(gBackupMapLayout.width, gBackupMapLayout.height, METATILE_Building_TV_Off); DrawWholeMapView(); } void TurnOnTVScreen(void) { - SetTVMetatilesOnMap(gBackupMapLayout.width, gBackupMapLayout.height, 0x0003); + SetTVMetatilesOnMap(gBackupMapLayout.width, gBackupMapLayout.height, METATILE_Building_TV_On); DrawWholeMapView(); } +// gSpecialVar_0x8004 here is set from GetRandomActiveShowIdx in EventScript_TryDoTVShow u8 GetSelectedTVShow(void) { return gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004].common.kind; } -u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void) +static u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void) { u8 i; - for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows) - 1; i ++) + for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows) - 1; i++) { - if (gSaveBlock1Ptr->tvShows[i].common.kind != TVSHOW_OFF_AIR && gSaveBlock1Ptr->tvShows[i].common.kind != TVSHOW_MASS_OUTBREAK && gSaveBlock1Ptr->tvShows[i].common.active == TRUE) - { + if (gSaveBlock1Ptr->tvShows[i].common.kind != TVSHOW_OFF_AIR + && gSaveBlock1Ptr->tvShows[i].common.kind != TVSHOW_MASS_OUTBREAK + && gSaveBlock1Ptr->tvShows[i].common.active == TRUE) return i; - } } return 0xFF; } @@ -903,9 +904,8 @@ u8 GetNextActiveShowIfMassOutbreak(void) tvShow = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004]; if (tvShow->common.kind == TVSHOW_MASS_OUTBREAK && gSaveBlock1Ptr->outbreakPokemonSpecies != SPECIES_NONE) - { return FindFirstActiveTVShowThatIsNotAMassOutbreak(); - } + return gSpecialVar_0x8004; } @@ -941,28 +941,23 @@ void GabbyAndTyBeforeInterview(void) gSaveBlock1Ptr->gabbyAndTyData.lastMove = gBattleResults.lastUsedMovePlayer; if (gSaveBlock1Ptr->gabbyAndTyData.battleNum != 0xFF) { - gSaveBlock1Ptr->gabbyAndTyData.battleNum ++; + gSaveBlock1Ptr->gabbyAndTyData.battleNum++; } gSaveBlock1Ptr->gabbyAndTyData.battleTookMoreThanOneTurn = gBattleResults.playerMonWasDamaged; + if (gBattleResults.playerFaintCounter != 0) - { gSaveBlock1Ptr->gabbyAndTyData.playerLostAMon = TRUE; - } else - { gSaveBlock1Ptr->gabbyAndTyData.playerLostAMon = FALSE; - } + if (gBattleResults.numHealingItemsUsed != 0) - { gSaveBlock1Ptr->gabbyAndTyData.playerUsedHealingItem = TRUE; - } else - { gSaveBlock1Ptr->gabbyAndTyData.playerUsedHealingItem = FALSE; - } + if (!gBattleResults.usedMasterBall) { - for (i = 0; i < POKEBALL_COUNT - 1; i ++) + for (i = 0; i < POKEBALL_COUNT - 1; i++) { if (gBattleResults.catchAttempts[i]) { @@ -973,9 +968,11 @@ void GabbyAndTyBeforeInterview(void) } else { + // Player threw a Master Ball at Gabby and Ty gSaveBlock1Ptr->gabbyAndTyData.playerThrewABall = TRUE; } - TakeTVShowInSearchOfTrainersOffTheAir(); + + TakeGabbyAndTyOffTheAir(); if (gSaveBlock1Ptr->gabbyAndTyData.lastMove == MOVE_NONE) { FlagSet(FLAG_TEMP_1); @@ -993,7 +990,7 @@ void GabbyAndTyAfterInterview(void) IncrementGameStat(GAME_STAT_GOT_INTERVIEWED); } -void TakeTVShowInSearchOfTrainersOffTheAir(void) +static void TakeGabbyAndTyOffTheAir(void) { gSaveBlock1Ptr->gabbyAndTyData.onAir = FALSE; } @@ -1001,13 +998,12 @@ void TakeTVShowInSearchOfTrainersOffTheAir(void) u8 GabbyAndTyGetBattleNum(void) { if (gSaveBlock1Ptr->gabbyAndTyData.battleNum > 5) - { return (gSaveBlock1Ptr->gabbyAndTyData.battleNum % 3) + 6; - } + return gSaveBlock1Ptr->gabbyAndTyData.battleNum; } -bool8 IsTVShowInSearchOfTrainersAiring(void) +bool8 IsGabbyAndTyShowOnTheAir(void) { return gSaveBlock1Ptr->gabbyAndTyData.onAir; } @@ -1026,60 +1022,56 @@ bool8 GabbyAndTyGetLastQuote(void) u8 GabbyAndTyGetLastBattleTrivia(void) { if (!gSaveBlock1Ptr->gabbyAndTyData.battleTookMoreThanOneTurn2) - { return 1; - } + if (gSaveBlock1Ptr->gabbyAndTyData.playerThrewABall2) - { return 2; - } + if (gSaveBlock1Ptr->gabbyAndTyData.playerUsedHealingItem2) - { return 3; - } + if (gSaveBlock1Ptr->gabbyAndTyData.playerLostAMon2) - { return 4; - } + return 0; } -void GabbyAndTySetScriptVarsToObjectEventLocalIds(void) +void GetGabbyAndTyLocalIds(void) { switch (GabbyAndTyGetBattleNum()) { - case 1: - gSpecialVar_0x8004 = 14; - gSpecialVar_0x8005 = 13; - break; - case 2: - gSpecialVar_0x8004 = 5; - gSpecialVar_0x8005 = 6; - break; - case 3: - gSpecialVar_0x8004 = 18; - gSpecialVar_0x8005 = 17; - break; - case 4: - gSpecialVar_0x8004 = 21; - gSpecialVar_0x8005 = 22; - break; - case 5: - gSpecialVar_0x8004 = 8; - gSpecialVar_0x8005 = 9; - break; - case 6: - gSpecialVar_0x8004 = 19; - gSpecialVar_0x8005 = 20; - break; - case 7: - gSpecialVar_0x8004 = 23; - gSpecialVar_0x8005 = 24; - break; - case 8: - gSpecialVar_0x8004 = 10; - gSpecialVar_0x8005 = 11; - break; + case 1: + gSpecialVar_0x8004 = 14; + gSpecialVar_0x8005 = 13; + break; + case 2: + gSpecialVar_0x8004 = 5; + gSpecialVar_0x8005 = 6; + break; + case 3: + gSpecialVar_0x8004 = 18; + gSpecialVar_0x8005 = 17; + break; + case 4: + gSpecialVar_0x8004 = 21; + gSpecialVar_0x8005 = 22; + break; + case 5: + gSpecialVar_0x8004 = 8; + gSpecialVar_0x8005 = 9; + break; + case 6: + gSpecialVar_0x8004 = 19; + gSpecialVar_0x8005 = 20; + break; + case 7: + gSpecialVar_0x8004 = 23; + gSpecialVar_0x8005 = 24; + break; + case 8: + gSpecialVar_0x8004 = 10; + gSpecialVar_0x8005 = 11; + break; } } @@ -1087,88 +1079,85 @@ void InterviewAfter(void) { switch (gSpecialVar_0x8005) { - case TVSHOW_FAN_CLUB_LETTER: - InterviewAfter_FanClubLetter(); - break; - case TVSHOW_RECENT_HAPPENINGS: - InterviewAfter_RecentHappenings(); - break; - case TVSHOW_PKMN_FAN_CLUB_OPINIONS: - InterviewAfter_PkmnFanClubOpinions(); - break; - case TVSHOW_UNKN_SHOWTYPE_04: - InterviewAfter_DummyShow4(); - break; - case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: - InterviewAfter_BravoTrainerPokemonProfile(); - break; - case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: - InterviewAfter_BravoTrainerBattleTowerProfile(); - break; - case TVSHOW_CONTEST_LIVE_UPDATES: - InterviewAfter_ContestLiveUpdates(); - break; + case TVSHOW_FAN_CLUB_LETTER: + InterviewAfter_FanClubLetter(); + break; + case TVSHOW_RECENT_HAPPENINGS: + InterviewAfter_RecentHappenings(); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + InterviewAfter_PkmnFanClubOpinions(); + break; + case TVSHOW_DUMMY: + InterviewAfter_Dummy(); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + InterviewAfter_BravoTrainerPokemonProfile(); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + InterviewAfter_BravoTrainerBattleTowerProfile(); + break; + case TVSHOW_CONTEST_LIVE_UPDATES: + InterviewAfter_ContestLiveUpdates(); + break; } } -void PutPokemonTodayCaughtOnAir(void) +void TryPutPokemonTodayOnAir(void) { u8 i; - u16 ct; + u16 ballsUsed; TVShow *show; u32 language2; u16 itemLastUsed; - ct = 0; - sub_80EED88(); - sub_80ED718(); + ballsUsed = 0; + TryPutRandomPokeNewsOnAir(); + TryStartRandomMassOutbreak(); + + // Try either the Failed or Caught version of the show if (gBattleResults.caughtMonSpecies == SPECIES_NONE) { - PutPokemonTodayFailedOnTheAir(); + TryPutPokemonTodayFailedOnTheAir(); } else { - UpdateWorldOfMastersAndPutItOnTheAir(); + InitWorldOfMastersShowAttempt(); if (!rbernoulli(1, 1) && StringCompare(gSpeciesNames[gBattleResults.caughtMonSpecies], gBattleResults.caughtMonNick)) { - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_CAUGHT, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_POKEMON_TODAY_CAUGHT, FALSE) != TRUE) { - for (i = 0; i < POKEBALL_COUNT - 1; i ++) + for (i = 0; i < POKEBALL_COUNT - 1; i++) + ballsUsed += gBattleResults.catchAttempts[i]; + + if (ballsUsed != 0 || gBattleResults.usedMasterBall) { - ct += gBattleResults.catchAttempts[i]; - } - if (ct != 0 || gBattleResults.usedMasterBall) - { - ct = 0; + ballsUsed = 0; show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->pokemonToday.kind = TVSHOW_POKEMON_TODAY_CAUGHT; - show->pokemonToday.active = FALSE; + show->pokemonToday.active = FALSE; // NOTE: Show is not active until passed via Record Mix. if (gBattleResults.usedMasterBall) { - ct = 1; + ballsUsed = 1; itemLastUsed = ITEM_MASTER_BALL; } else { - for (i = 0; i < POKEBALL_COUNT - 1; i ++) - { - ct += gBattleResults.catchAttempts[i]; - } - if (ct > 0xFF) - { - ct = 0xFF; - } + for (i = 0; i < POKEBALL_COUNT - 1; i++) + ballsUsed += gBattleResults.catchAttempts[i]; + if (ballsUsed > 255) + ballsUsed = 255; itemLastUsed = gLastUsedItem; } - show->pokemonToday.nBallsUsed = ct; + show->pokemonToday.nBallsUsed = ballsUsed; show->pokemonToday.ball = itemLastUsed; StringCopy(show->pokemonToday.playerName, gSaveBlock2Ptr->playerName); StringCopy(show->pokemonToday.nickname, gBattleResults.caughtMonNick); language2 = sub_81DB604(show->pokemonToday.nickname); StripExtCtrlCodes(show->pokemonToday.nickname); show->pokemonToday.species = gBattleResults.caughtMonSpecies; - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->pokemonToday.language = gGameLanguage; show->pokemonToday.language2 = language2; } @@ -1177,65 +1166,60 @@ void PutPokemonTodayCaughtOnAir(void) } } -void UpdateWorldOfMastersAndPutItOnTheAir(void) +// Show is initialized in last slot and updated there until it's +// either triggered or deleted at the end of the day by ResolveWorldOfMastersShow +static void InitWorldOfMastersShowAttempt(void) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; - if (show->worldOfMasters.kind != TVSHOW_WORLD_OF_MASTERS) + TVShow *show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; + if (show->common.kind != TVSHOW_WORLD_OF_MASTERS) { DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, LAST_TVSHOW_IDX); show->worldOfMasters.steps = GetGameStat(GAME_STAT_STEPS); show->worldOfMasters.kind = TVSHOW_WORLD_OF_MASTERS; } - show->worldOfMasters.numPokeCaught ++; + show->worldOfMasters.numPokeCaught++; show->worldOfMasters.caughtPoke = gBattleResults.caughtMonSpecies; show->worldOfMasters.species = gBattleResults.playerMon1Species; show->worldOfMasters.location = gMapHeader.regionMapSectionId; } -void PutPokemonTodayFailedOnTheAir(void) +static void TryPutPokemonTodayFailedOnTheAir(void) { - u16 ct; + u16 ballsUsed; u8 i; TVShow *show; if (!rbernoulli(1, 1)) { - for (i = 0, ct = 0; i < POKEBALL_COUNT - 1; i ++) + for (i = 0, ballsUsed = 0; i < POKEBALL_COUNT - 1; i++) + ballsUsed += gBattleResults.catchAttempts[i]; + if (ballsUsed > 255) + ballsUsed = 255; + + if (ballsUsed > 2 && (gBattleOutcome == B_OUTCOME_MON_FLED || gBattleOutcome == B_OUTCOME_WON)) { - ct += gBattleResults.catchAttempts[i]; - } - if (ct > 0xFF) - { - ct = 0xFF; - } - if (ct > 2 && (gBattleOutcome == B_OUTCOME_MON_FLED || gBattleOutcome == B_OUTCOME_WON)) - { - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_FAILED, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_POKEMON_TODAY_FAILED, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->pokemonTodayFailed.kind = TVSHOW_POKEMON_TODAY_FAILED; - show->pokemonTodayFailed.active = FALSE; + show->pokemonTodayFailed.active = FALSE; // NOTE: Show is not active until passed via Record Mix. show->pokemonTodayFailed.species = gBattleResults.playerMon1Species; show->pokemonTodayFailed.species2 = gBattleResults.lastOpponentSpecies; - show->pokemonTodayFailed.nBallsUsed = ct; + show->pokemonTodayFailed.nBallsUsed = ballsUsed; show->pokemonTodayFailed.outcome = gBattleOutcome; show->pokemonTodayFailed.location = gMapHeader.regionMapSectionId; StringCopy(show->pokemonTodayFailed.playerName, gSaveBlock2Ptr->playerName); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->pokemonTodayFailed.language = gGameLanguage; } } } } -void tv_store_id_3x(TVShow *show) +static void StorePlayerIdInRecordMixShow(TVShow *show) { - u32 id; - - id = GetPlayerIDAsU32(); + u32 id = GetPlayerIDAsU32(); show->common.srcTrainerId2Lo = id; show->common.srcTrainerId2Hi = id >> 8; show->common.srcTrainerIdLo = id; @@ -1244,11 +1228,9 @@ void tv_store_id_3x(TVShow *show) show->common.trainerIdHi = id >> 8; } -void tv_store_id_2x(TVShow *show) +static void StorePlayerIdInNormalShow(TVShow *show) { - u32 id; - - id = GetPlayerIDAsU32(); + u32 id = GetPlayerIDAsU32(); show->common.srcTrainerIdLo = id; show->common.srcTrainerIdHi = id >> 8; show->common.trainerIdLo = id; @@ -1276,7 +1258,7 @@ static void InterviewAfter_ContestLiveUpdates(void) show2->contestLiveUpdates.move = show->contestLiveUpdates.move; show2->contestLiveUpdates.winnerAppealFlag = show->contestLiveUpdates.winnerAppealFlag; StringCopy(show2->contestLiveUpdates.losingTrainerName, show->contestLiveUpdates.losingTrainerName); - tv_store_id_2x(show2); + StorePlayerIdInNormalShow(show2); show2->contestLiveUpdates.winningTrainerLanguage = gGameLanguage; show2->contestLiveUpdates.losingTrainerLanguage = show->contestLiveUpdates.losingTrainerLanguage; DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, LAST_TVSHOW_IDX); @@ -1288,44 +1270,36 @@ void PutBattleUpdateOnTheAir(u8 opponentLinkPlayerId, u16 move, u16 speciesPlaye TVShow *show; u8 name[32]; - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BATTLE_UPDATE); - if (gSpecialVar_Result != 1) + TryReplaceOldTVShowOfKind(TVSHOW_BATTLE_UPDATE); + if (gSpecialVar_Result != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->battleUpdate.kind = TVSHOW_BATTLE_UPDATE; show->battleUpdate.active = TRUE; StringCopy(show->battleUpdate.playerName, gSaveBlock2Ptr->playerName); + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) - { show->battleUpdate.battleType = 2; - } else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - { show->battleUpdate.battleType = 1; - } else - { show->battleUpdate.battleType = 0; - } + show->battleUpdate.move = move; show->battleUpdate.speciesPlayer = speciesPlayer; show->battleUpdate.speciesOpponent = speciesOpponent; StringCopy(name, gLinkPlayers[opponentLinkPlayerId].name); StripExtCtrlCodes(name); StringCopy(show->battleUpdate.linkOpponentName, name); - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); show->battleUpdate.language = gGameLanguage; if (show->battleUpdate.language == LANGUAGE_JAPANESE || gLinkPlayers[opponentLinkPlayerId].language == LANGUAGE_JAPANESE) - { show->battleUpdate.linkOpponentLanguage = LANGUAGE_JAPANESE; - } else - { show->battleUpdate.linkOpponentLanguage = gLinkPlayers[opponentLinkPlayerId].language; - } } } } @@ -1335,16 +1309,14 @@ bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 colo TVShow *show; u8 name[32]; - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot == -1) - { return FALSE; - } - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_3_CHEERS_FOR_POKEBLOCKS); - if (gSpecialVar_Result == 1) - { - return FALSE; - } + + TryReplaceOldTVShowOfKind(TVSHOW_3_CHEERS_FOR_POKEBLOCKS); + if (gSpecialVar_Result == TRUE) + return FALSE; // Old show is still active + show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->threeCheers.kind = TVSHOW_3_CHEERS_FOR_POKEBLOCKS; show->threeCheers.active = TRUE; @@ -1355,16 +1327,12 @@ bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 colo show->threeCheers.flavor = flavor; show->threeCheers.color = color; show->threeCheers.sheen = sheen; - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); show->threeCheers.language = gGameLanguage; if (show->threeCheers.language == LANGUAGE_JAPANESE || language == LANGUAGE_JAPANESE) - { show->threeCheers.worstBlenderLanguage = LANGUAGE_JAPANESE; - } else - { show->threeCheers.worstBlenderLanguage = language; - } return TRUE; } @@ -1385,16 +1353,12 @@ void PutFanClubSpecialOnTheAir(void) StringCopy(name, gStringVar1); StripExtCtrlCodes(name); StringCopy(show->fanClubSpecial.idolName, name); - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); show->fanClubSpecial.language = gGameLanguage; if (show->fanClubSpecial.language == LANGUAGE_JAPANESE || gSaveBlock1Ptr->linkBattleRecords.languages[0] == LANGUAGE_JAPANESE) - { show->fanClubSpecial.idolNameLanguage = LANGUAGE_JAPANESE; - } else - { show->fanClubSpecial.idolNameLanguage = gSaveBlock1Ptr->linkBattleRecords.languages[0]; - } } void ContestLiveUpdates_Init(u8 round1Placing) @@ -1402,7 +1366,7 @@ void ContestLiveUpdates_Init(u8 round1Placing) TVShow *show; DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, LAST_TVSHOW_IDX); - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; @@ -1413,64 +1377,45 @@ void ContestLiveUpdates_Init(u8 round1Placing) void ContestLiveUpdates_SetRound2Placing(u8 round2Placing) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + TVShow *show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) - { show->contestLiveUpdates.round2Placing = round2Placing; - } } void ContestLiveUpdates_SetWinnerAppealFlag(u8 flag) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + TVShow *show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) - { show->contestLiveUpdates.winnerAppealFlag = flag; - } } void ContestLiveUpdates_SetWinnerMoveUsed(u16 move) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + TVShow *show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) - { show->contestLiveUpdates.move = move; - } } void ContestLiveUpdates_SetLoserData(u8 flag, u8 loser) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + TVShow *show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { show->contestLiveUpdates.losingSpecies = gContestMons[loser].species; StringCopy(show->contestLiveUpdates.losingTrainerName, gContestMons[loser].trainerName); StripExtCtrlCodes(show->contestLiveUpdates.losingTrainerName); show->contestLiveUpdates.loserAppealFlag = flag; + if (loser + 1 > gNumLinkContestPlayers) - { show->contestLiveUpdates.losingTrainerLanguage = gLinkPlayers[0].language; - } else if (gGameLanguage == LANGUAGE_JAPANESE || gLinkPlayers[loser].language == LANGUAGE_JAPANESE) - { show->contestLiveUpdates.losingTrainerLanguage = LANGUAGE_JAPANESE; - } else - { show->contestLiveUpdates.losingTrainerLanguage = gLinkPlayers[loser].language; - } } } @@ -1493,27 +1438,21 @@ static void InterviewAfter_BravoTrainerPokemonProfile(void) show2->bravoTrainer.move = show->bravoTrainer.move; show2->bravoTrainer.contestResult = show->bravoTrainer.contestResult; show2->bravoTrainer.contestCategory = show->bravoTrainer.contestCategory; - tv_store_id_2x(show2); + StorePlayerIdInNormalShow(show2); show2->bravoTrainer.language = gGameLanguage; if (show2->bravoTrainer.language == LANGUAGE_JAPANESE || show->bravoTrainer.pokemonNameLanguage == LANGUAGE_JAPANESE) - { show2->bravoTrainer.pokemonNameLanguage = LANGUAGE_JAPANESE; - } else - { show2->bravoTrainer.pokemonNameLanguage = show->bravoTrainer.pokemonNameLanguage; - } DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, LAST_TVSHOW_IDX); } } void BravoTrainerPokemonProfile_BeforeInterview1(u16 a0) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; + TVShow *show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; InterviewBefore_BravoTrainerPkmnProfile(); - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, LAST_TVSHOW_IDX); @@ -1524,10 +1463,8 @@ void BravoTrainerPokemonProfile_BeforeInterview1(u16 a0) void BravoTrainerPokemonProfile_BeforeInterview2(u8 contestStandingPlace) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + TVShow *show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { show->bravoTrainer.contestResult = contestStandingPlace; @@ -1542,9 +1479,7 @@ void BravoTrainerPokemonProfile_BeforeInterview2(u8 contestStandingPlace) static void InterviewAfter_BravoTrainerBattleTowerProfile(void) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; + TVShow *show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->bravoTrainerTower.kind = TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE; show->bravoTrainerTower.active = TRUE; StringCopy(show->bravoTrainerTower.trainerName, gSaveBlock2Ptr->playerName); @@ -1554,27 +1489,19 @@ static void InterviewAfter_BravoTrainerBattleTowerProfile(void) show->bravoTrainerTower.numFights = GetCurrentBattleTowerWinStreak(gSaveBlock2Ptr->frontier.towerLvlMode, 0); show->bravoTrainerTower.wonTheChallenge = gSaveBlock2Ptr->frontier.towerBattleOutcome; if (gSaveBlock2Ptr->frontier.towerLvlMode == FRONTIER_LVL_50) - { show->bravoTrainerTower.btLevel = 50; - } else - { show->bravoTrainerTower.btLevel = 100; - } show->bravoTrainerTower.interviewResponse = gSpecialVar_0x8004; - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); show->bravoTrainerTower.language = gGameLanguage; if (show->bravoTrainerTower.language == LANGUAGE_JAPANESE || gSaveBlock2Ptr->frontier.towerInterview.opponentLanguage == LANGUAGE_JAPANESE) - { show->bravoTrainerTower.pokemonNameLanguage = LANGUAGE_JAPANESE; - } else - { show->bravoTrainerTower.pokemonNameLanguage = gSaveBlock2Ptr->frontier.towerInterview.opponentLanguage; - } } -void SaveRecordedItemPurchasesForTVShow(void) +void TryPutSmartShopperOnAir(void) { TVShow *show; u8 i; @@ -1583,24 +1510,24 @@ void SaveRecordedItemPurchasesForTVShow(void) && !(gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(BATTLE_FRONTIER_MART) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(BATTLE_FRONTIER_MART)) && !rbernoulli(1, 3)) { - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SMART_SHOPPER, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_SMART_SHOPPER, FALSE) != TRUE) { - TV_SortPurchasesByQuantity(); + SortPurchasesByQuantity(); if (gMartPurchaseHistory[0].quantity >= 20) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->smartshopperShow.kind = TVSHOW_SMART_SHOPPER; - show->smartshopperShow.active = FALSE; + show->smartshopperShow.active = FALSE; // NOTE: Show is not active until passed via Record Mix. show->smartshopperShow.shopLocation = gMapHeader.regionMapSectionId; - for (i = 0; i < 3; i ++) + for (i = 0; i < SMARTSHOPPER_NUM_ITEMS; i++) { show->smartshopperShow.itemIds[i] = gMartPurchaseHistory[i].itemId; show->smartshopperShow.itemAmounts[i] = gMartPurchaseHistory[i].quantity; } show->smartshopperShow.priceReduced = GetPriceReduction(POKENEWS_SLATEPORT); StringCopy(show->smartshopperShow.playerName, gSaveBlock2Ptr->playerName); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->smartshopperShow.language = gGameLanguage; } } @@ -1623,11 +1550,11 @@ void PutNameRaterShowOnTheAir(void) show->nameRaterShow.species = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES, NULL); show->nameRaterShow.random = Random() % 3; show->nameRaterShow.random2 = Random() % 2; - show->nameRaterShow.randomSpecies = TV_GetSomeOtherSpeciesAlreadySeenByPlayer(show->nameRaterShow.species); + show->nameRaterShow.randomSpecies = GetRandomDifferentSpeciesSeenByPlayer(show->nameRaterShow.species); StringCopy(show->nameRaterShow.trainerName, gSaveBlock2Ptr->playerName); GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_NICKNAME, show->nameRaterShow.pokemonName); StripExtCtrlCodes(show->nameRaterShow.pokemonName); - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); show->nameRaterShow.language = gGameLanguage; show->nameRaterShow.pokemonNameLanguage = GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_LANGUAGE); } @@ -1636,9 +1563,7 @@ void PutNameRaterShowOnTheAir(void) void StartMassOutbreak(void) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004]; + TVShow *show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004]; gSaveBlock1Ptr->outbreakPokemonSpecies = show->massOutbreak.species; gSaveBlock1Ptr->outbreakLocationMapNum = show->massOutbreak.locationMapNum; gSaveBlock1Ptr->outbreakLocationMapGroup = show->massOutbreak.locationMapGroup; @@ -1658,7 +1583,7 @@ void PutLilycoveContestLadyShowOnTheAir(void) { TVShow *show; - sub_80EFA88(); + Script_FindFirstEmptyNormalTVShowSlot(); if (gSpecialVar_Result != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; @@ -1669,41 +1594,35 @@ void PutLilycoveContestLadyShowOnTheAir(void) BufferContestLadyPlayerName(show->contestLady.playerName); BufferContestLadyMonName(&show->contestLady.contestCategory, show->contestLady.nickname); show->contestLady.pokeblockState = GetContestLadyPokeblockState(); - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); } } static void InterviewAfter_FanClubLetter(void) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; + TVShow *show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->fanclubLetter.kind = TVSHOW_FAN_CLUB_LETTER; show->fanclubLetter.active = TRUE; StringCopy(show->fanclubLetter.playerName, gSaveBlock2Ptr->playerName); show->fanclubLetter.species = GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL); - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); show->fanclubLetter.language = gGameLanguage; } static void InterviewAfter_RecentHappenings(void) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; + TVShow *show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->recentHappenings.kind = TVSHOW_RECENT_HAPPENINGS; show->recentHappenings.active = TRUE; StringCopy(show->recentHappenings.playerName, gSaveBlock2Ptr->playerName); - show->recentHappenings.var02 = 0; - tv_store_id_2x(show); + show->recentHappenings.species = SPECIES_NONE; + StorePlayerIdInNormalShow(show); show->recentHappenings.language = gGameLanguage; } static void InterviewAfter_PkmnFanClubOpinions(void) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; + TVShow *show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->fanclubOpinions.kind = TVSHOW_PKMN_FAN_CLUB_OPINIONS; show->fanclubOpinions.active = TRUE; show->fanclubOpinions.friendshipHighNybble = GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_FRIENDSHIP, NULL) >> 4; @@ -1712,26 +1631,20 @@ static void InterviewAfter_PkmnFanClubOpinions(void) GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_NICKNAME, show->fanclubOpinions.nickname); StripExtCtrlCodes(show->fanclubOpinions.nickname); show->fanclubOpinions.species = GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL); - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); show->fanclubOpinions.language = gGameLanguage; if (gGameLanguage == LANGUAGE_JAPANESE || GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_LANGUAGE) == LANGUAGE_JAPANESE) - { show->fanclubOpinions.pokemonNameLanguage = LANGUAGE_JAPANESE; - } else - { show->fanclubOpinions.pokemonNameLanguage = GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_LANGUAGE); - } } -static void InterviewAfter_DummyShow4(void) +static void InterviewAfter_Dummy(void) { - TVShow *show; - - show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; + TVShow *show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; } -static void sub_80ED718(void) +static void TryStartRandomMassOutbreak(void) { u8 i; u16 outbreakIdx; @@ -1739,16 +1652,14 @@ static void sub_80ED718(void) if (FlagGet(FLAG_SYS_GAME_CLEAR)) { - for (i = 0; i < LAST_TVSHOW_IDX; i ++) + for (i = 0; i < LAST_TVSHOW_IDX; i++) { if (gSaveBlock1Ptr->tvShows[i].common.kind == TVSHOW_MASS_OUTBREAK) - { return; - } } if (!rbernoulli(1, 200)) { - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { outbreakIdx = Random() % ARRAY_COUNT(sPokeOutbreakSpeciesList); @@ -1770,7 +1681,7 @@ static void sub_80ED718(void) show->massOutbreak.probability = 50; show->massOutbreak.var15 = 0; show->massOutbreak.daysLeft = 1; - tv_store_id_2x(show); + StorePlayerIdInNormalShow(show); show->massOutbreak.language = gGameLanguage; } } @@ -1798,9 +1709,9 @@ void UpdateTVShowsPerDay(u16 days) { UpdateMassOutbreakTimeLeft(days); TryEndMassOutbreak(days); - sub_80EF120(days); - sub_80EDA48(days); - sub_80EEB98(days); + UpdatePokeNewsTimeLeft(days); + ResolveWorldOfMastersShow(days); + ResolveNumberOneShow(days); } static void UpdateMassOutbreakTimeLeft(u16 days) @@ -1810,7 +1721,7 @@ static void UpdateMassOutbreakTimeLeft(u16 days) if (gSaveBlock1Ptr->outbreakPokemonSpecies == SPECIES_NONE) { - for (i = 0; i < LAST_TVSHOW_IDX; i ++) + for (i = 0; i < LAST_TVSHOW_IDX; i++) { if (gSaveBlock1Ptr->tvShows[i].massOutbreak.kind == TVSHOW_MASS_OUTBREAK && gSaveBlock1Ptr->tvShows[i].massOutbreak.active == TRUE) { @@ -1839,7 +1750,7 @@ void RecordFishingAttemptForTV(bool8 caughtFish) if (caughtFish) { if (sPokemonAnglerAttemptCounters >> 8 > 4) - PutFishingAdviceShowOnTheAir(); + TryPutFishingAdviceOnAir(); sPokemonAnglerAttemptCounters &= 0xFF; if (sPokemonAnglerAttemptCounters != 0xFF) @@ -1848,7 +1759,7 @@ void RecordFishingAttemptForTV(bool8 caughtFish) else { if ((u8)sPokemonAnglerAttemptCounters > 4) - PutFishingAdviceShowOnTheAir(); + TryPutFishingAdviceOnAir(); sPokemonAnglerAttemptCounters &= 0xFF00; if (sPokemonAnglerAttemptCounters >> 8 != 0xFF) @@ -1856,21 +1767,21 @@ void RecordFishingAttemptForTV(bool8 caughtFish) } } -void PutFishingAdviceShowOnTheAir(void) +static void TryPutFishingAdviceOnAir(void) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_FISHING_ADVICE, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_FISHING_ADVICE, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->pokemonAngler.kind = TVSHOW_FISHING_ADVICE; - show->pokemonAngler.active = FALSE; + show->pokemonAngler.active = FALSE; // NOTE: Show is not active until passed via Record Mix. show->pokemonAngler.nBites = sPokemonAnglerAttemptCounters; show->pokemonAngler.nFails = sPokemonAnglerAttemptCounters >> 8; show->pokemonAngler.species = sPokemonAnglerSpecies; StringCopy(show->pokemonAngler.playerName, gSaveBlock2Ptr->playerName); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->pokemonAngler.language = gGameLanguage; } } @@ -1880,7 +1791,11 @@ void SetPokemonAnglerSpecies(u16 species) sPokemonAnglerSpecies = species; } -static void sub_80EDA48(u16 days) +// World of Masters is initialized in the last slot by InitWorldOfMastersShowAttempt +// If enough Pokémon were caught during the day the show can be put on air (and will +// be moved out of the last slot). +// Either way the temporary version of the show in the last slot is deleted. +static void ResolveWorldOfMastersShow(u16 days) { TVShow *show; @@ -1888,14 +1803,13 @@ static void sub_80EDA48(u16 days) if (show->worldOfMasters.kind == TVSHOW_WORLD_OF_MASTERS) { if (show->worldOfMasters.numPokeCaught >= 20) - { - sub_80EDA80(); - } + TryPutWorldOfMastersOnAir(); + DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, LAST_TVSHOW_IDX); } } -void sub_80EDA80(void) +static void TryPutWorldOfMastersOnAir(void) { TVShow *show; TVShow *show2; @@ -1903,19 +1817,19 @@ void sub_80EDA80(void) show = &gSaveBlock1Ptr->tvShows[LAST_TVSHOW_IDX]; if (!rbernoulli(1, 1)) { - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_WORLD_OF_MASTERS, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_WORLD_OF_MASTERS, FALSE) != TRUE) { show2 = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show2->worldOfMasters.kind = TVSHOW_WORLD_OF_MASTERS; - show2->worldOfMasters.active = FALSE; + show2->worldOfMasters.active = FALSE; // NOTE: Show is not active until passed via Record Mix. show2->worldOfMasters.numPokeCaught = show->worldOfMasters.numPokeCaught; show2->worldOfMasters.steps = GetGameStat(GAME_STAT_STEPS) - show->worldOfMasters.steps; show2->worldOfMasters.caughtPoke = show->worldOfMasters.caughtPoke; show2->worldOfMasters.species = show->worldOfMasters.species; show2->worldOfMasters.location = show->worldOfMasters.location; StringCopy(show2->worldOfMasters.playerName, gSaveBlock2Ptr->playerName); - tv_store_id_3x(show2); + StorePlayerIdInRecordMixShow(show2); show2->worldOfMasters.language = gGameLanguage; DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, LAST_TVSHOW_IDX); } @@ -1928,47 +1842,38 @@ void TryPutTodaysRivalTrainerOnAir(void) u32 i; u8 nBadges; - HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TODAYS_RIVAL_TRAINER, TRUE); - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + IsRecordMixShowAlreadySpawned(TVSHOW_TODAYS_RIVAL_TRAINER, TRUE); // Delete old version of show + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->rivalTrainer.kind = TVSHOW_TODAYS_RIVAL_TRAINER; - show->rivalTrainer.active = FALSE; - for (i = FLAG_BADGE01_GET, nBadges = 0; i < FLAG_BADGE01_GET + NUM_BADGES; i ++) + show->rivalTrainer.active = FALSE; // NOTE: Show is not active until passed via Record Mix. + for (i = FLAG_BADGE01_GET, nBadges = 0; i < FLAG_BADGE01_GET + NUM_BADGES; i++) { if (FlagGet(i)) - { - nBadges ++; - } + nBadges++; } show->rivalTrainer.badgeCount = nBadges; if (IsNationalPokedexEnabled()) - { show->rivalTrainer.dexCount = GetNationalPokedexCount(FLAG_GET_CAUGHT); - } else - { show->rivalTrainer.dexCount = GetHoennPokedexCount(FLAG_GET_CAUGHT); - } show->rivalTrainer.location = gMapHeader.regionMapSectionId; show->rivalTrainer.mapLayoutId = gMapHeader.mapLayoutId; show->rivalTrainer.nSilverSymbols = 0; show->rivalTrainer.nGoldSymbols = 0; - for (i = 0; i < 7; i ++) + for (i = 0; i < 7; i++) { if (FlagGet(sSilverSymbolFlags[i]) == TRUE) - { - show->rivalTrainer.nSilverSymbols ++; - } + show->rivalTrainer.nSilverSymbols++; + if (FlagGet(sGoldSymbolFlags[i]) == TRUE) - { - show->rivalTrainer.nGoldSymbols ++; - } + show->rivalTrainer.nGoldSymbols++; } show->rivalTrainer.battlePoints = gSaveBlock2Ptr->frontier.battlePoints; StringCopy(show->rivalTrainer.playerName, gSaveBlock2Ptr->playerName); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->rivalTrainer.language = gGameLanguage; } } @@ -1977,17 +1882,17 @@ void TryPutTrendWatcherOnAir(const u16 *words) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TREND_WATCHER, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_TREND_WATCHER, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->trendWatcher.kind = TVSHOW_TREND_WATCHER; - show->trendWatcher.active = FALSE; + show->trendWatcher.active = FALSE; // NOTE: Show is not active until passed via Record Mix. show->trendWatcher.gender = gSaveBlock2Ptr->playerGender; show->trendWatcher.words[0] = words[0]; show->trendWatcher.words[1] = words[1]; StringCopy(show->trendWatcher.playerName, gSaveBlock2Ptr->playerName); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->trendWatcher.language = gGameLanguage; } } @@ -1996,70 +1901,70 @@ void TryPutTreasureInvestigatorsOnAir(void) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TREASURE_INVESTIGATORS, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_TREASURE_INVESTIGATORS, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->treasureInvestigators.kind = TVSHOW_TREASURE_INVESTIGATORS; - show->treasureInvestigators.active = FALSE; + show->treasureInvestigators.active = FALSE; // NOTE: Show is not active until passed via Record Mix. show->treasureInvestigators.item = gSpecialVar_0x8005; show->treasureInvestigators.location = gMapHeader.regionMapSectionId; show->treasureInvestigators.mapLayoutId = gMapHeader.mapLayoutId; StringCopy(show->treasureInvestigators.playerName, gSaveBlock2Ptr->playerName); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->treasureInvestigators.language = gGameLanguage; } } -void AlertTVOfNewCoinTotal(u16 nCoinsPaidOut) +void TryPutFindThatGamerOnAir(u16 nCoinsPaidOut) { TVShow *show; bool8 flag; u16 nCoinsWon; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_FIND_THAT_GAMER, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_FIND_THAT_GAMER, FALSE) != TRUE) { flag = FALSE; switch (sFindThatGamerWhichGame) { - case SLOT_MACHINE: - if (nCoinsPaidOut >= sFindThatGamerCoinsSpent + 200) - { - flag = TRUE; - nCoinsWon = nCoinsPaidOut - sFindThatGamerCoinsSpent; - break; - } - if (sFindThatGamerCoinsSpent >= 100 && nCoinsPaidOut <= sFindThatGamerCoinsSpent - 100) - { - nCoinsWon = sFindThatGamerCoinsSpent - nCoinsPaidOut; - break; - } - return; - case ROULETTE: - if (nCoinsPaidOut >= sFindThatGamerCoinsSpent + 50) - { - flag = TRUE; - nCoinsWon = nCoinsPaidOut - sFindThatGamerCoinsSpent; - break; - } - if (sFindThatGamerCoinsSpent >= 50 && nCoinsPaidOut <= sFindThatGamerCoinsSpent - 50) - { - nCoinsWon = sFindThatGamerCoinsSpent - nCoinsPaidOut; - break; - } - return; - default: - return; + case SLOT_MACHINE: + if (nCoinsPaidOut >= sFindThatGamerCoinsSpent + 200) + { + flag = TRUE; + nCoinsWon = nCoinsPaidOut - sFindThatGamerCoinsSpent; + break; + } + if (sFindThatGamerCoinsSpent >= 100 && nCoinsPaidOut <= sFindThatGamerCoinsSpent - 100) + { + nCoinsWon = sFindThatGamerCoinsSpent - nCoinsPaidOut; + break; + } + return; + case ROULETTE: + if (nCoinsPaidOut >= sFindThatGamerCoinsSpent + 50) + { + flag = TRUE; + nCoinsWon = nCoinsPaidOut - sFindThatGamerCoinsSpent; + break; + } + if (sFindThatGamerCoinsSpent >= 50 && nCoinsPaidOut <= sFindThatGamerCoinsSpent - 50) + { + nCoinsWon = sFindThatGamerCoinsSpent - nCoinsPaidOut; + break; + } + return; + default: + return; } show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->findThatGamer.kind = TVSHOW_FIND_THAT_GAMER; - show->findThatGamer.active = FALSE; + show->findThatGamer.active = FALSE; // NOTE: Show is not active until passed via Record Mix. show->findThatGamer.nCoins = nCoinsWon; show->findThatGamer.whichGame = sFindThatGamerWhichGame; show->findThatGamer.won = flag; StringCopy(show->findThatGamer.playerName, gSaveBlock2Ptr->playerName); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->findThatGamer.language = gGameLanguage; } } @@ -2076,71 +1981,64 @@ void AlertTVThatPlayerPlayedRoulette(u16 nCoinsSpent) sFindThatGamerCoinsSpent = nCoinsSpent; } -static void sub_80EDE98(TVShow *show) +static void SecretBaseVisit_CalculateDecorationData(TVShow *show) { - u8 i; - u8 j; + u8 i, j; u16 k; u8 n; - u8 deco; + u8 decoration; - for (i = 0; i < DECOR_MAX_SECRET_BASE; i ++) - { + for (i = 0; i < DECOR_MAX_SECRET_BASE; i++) sTV_DecorationsBuffer[i] = 0; - } - for (i = 0, n = 0; i < DECOR_MAX_SECRET_BASE; i ++) + + for (i = 0, n = 0; i < DECOR_MAX_SECRET_BASE; i++) { - deco = gSaveBlock1Ptr->secretBases[0].decorations[i]; - if (deco) + decoration = gSaveBlock1Ptr->secretBases[0].decorations[i]; + if (decoration) { - for (j = 0; j < DECOR_MAX_SECRET_BASE; j ++) + for (j = 0; j < DECOR_MAX_SECRET_BASE; j++) { if (sTV_DecorationsBuffer[j] == 0) { - sTV_DecorationsBuffer[j] = deco; - n ++; + sTV_DecorationsBuffer[j] = decoration; + n++; break; } - if (sTV_DecorationsBuffer[j] == deco) - { + if (sTV_DecorationsBuffer[j] == decoration) break; - } } } } + if (n > 4) - { show->secretBaseVisit.nDecorations = 4; - } else - { show->secretBaseVisit.nDecorations = n; - } + switch (show->secretBaseVisit.nDecorations) { - case 0: - break; - case 1: - show->secretBaseVisit.decorations[0] = sTV_DecorationsBuffer[0]; - break; - default: - for (k = 0; k < n * n; k ++) - { - deco = Random() % n; - j = Random() % n; - i = sTV_DecorationsBuffer[deco]; - sTV_DecorationsBuffer[deco] = sTV_DecorationsBuffer[j]; - sTV_DecorationsBuffer[j] = i; - } - for (i = 0; i < show->secretBaseVisit.nDecorations; i ++) - { - show->secretBaseVisit.decorations[i] = sTV_DecorationsBuffer[i]; - } - break; + case 0: + break; + case 1: + show->secretBaseVisit.decorations[0] = sTV_DecorationsBuffer[0]; + break; + default: + for (k = 0; k < n * n; k++) + { + decoration = Random() % n; + j = Random() % n; + i = sTV_DecorationsBuffer[decoration]; + sTV_DecorationsBuffer[decoration] = sTV_DecorationsBuffer[j]; + sTV_DecorationsBuffer[j] = i; + } + + for (i = 0; i < show->secretBaseVisit.nDecorations; i++) + show->secretBaseVisit.decorations[i] = sTV_DecorationsBuffer[i]; + break; } } -static void sub_80EDFB4(TVShow *show) +static void SecretBaseVisit_CalculatePartyData(TVShow *show) { u8 i; u16 move; @@ -2149,7 +2047,7 @@ static void sub_80EDFB4(TVShow *show) u8 nPokemon; u16 sum; - for (i = 0, nPokemon = 0; i < PARTY_SIZE; i ++) + for (i = 0, nPokemon = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) { @@ -2160,128 +2058,119 @@ static void sub_80EDFB4(TVShow *show) if (move != MOVE_NONE) { sTV_SecretBaseVisitMovesTemp[nMoves] = move; - nMoves ++; + nMoves++; } move = GetMonData(&gPlayerParty[i], MON_DATA_MOVE2); if (move != MOVE_NONE) { sTV_SecretBaseVisitMovesTemp[nMoves] = move; - nMoves ++; + nMoves++; } move = GetMonData(&gPlayerParty[i], MON_DATA_MOVE3); if (move != MOVE_NONE) { sTV_SecretBaseVisitMovesTemp[nMoves] = move; - nMoves ++; + nMoves++; } move = GetMonData(&gPlayerParty[i], MON_DATA_MOVE4); if (move != MOVE_NONE) { sTV_SecretBaseVisitMovesTemp[nMoves] = move; - nMoves ++; + nMoves++; } sTV_SecretBaseVisitMonsTemp[nPokemon].move = sTV_SecretBaseVisitMovesTemp[Random() % nMoves]; - nPokemon ++; + nPokemon++; } } - for (i = 0, sum = 0; i < nPokemon; i ++) - { + for (i = 0, sum = 0; i < nPokemon; i++) sum += sTV_SecretBaseVisitMonsTemp[i].level; - } + show->secretBaseVisit.avgLevel = sum / nPokemon; j = Random() % nPokemon; show->secretBaseVisit.species = sTV_SecretBaseVisitMonsTemp[j].species; show->secretBaseVisit.move = sTV_SecretBaseVisitMonsTemp[j].move; } -void TV_PutSecretBaseVisitOnTheAir(void) +void TryPutSecretBaseVisitOnAir(void) { TVShow *show; - HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SECRET_BASE_VISIT, TRUE); - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + IsRecordMixShowAlreadySpawned(TVSHOW_SECRET_BASE_VISIT, TRUE); // Delete old version of show + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->secretBaseVisit.kind = TVSHOW_SECRET_BASE_VISIT; - show->secretBaseVisit.active = FALSE; + show->secretBaseVisit.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->secretBaseVisit.playerName, gSaveBlock2Ptr->playerName); - sub_80EDE98(show); - sub_80EDFB4(show); - tv_store_id_3x(show); + SecretBaseVisit_CalculateDecorationData(show); + SecretBaseVisit_CalculatePartyData(show); + StorePlayerIdInRecordMixShow(show); show->secretBaseVisit.language = gGameLanguage; } } -void sub_80EE184(void) +void TryPutBreakingNewsOnAir(void) { TVShow *show; u8 i; u16 balls; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_BREAKING_NEWS, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_BREAKING_NEWS, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->breakingNews.kind = TVSHOW_BREAKING_NEWS; - show->breakingNews.active = FALSE; + show->breakingNews.active = FALSE; // NOTE: Show is not active until passed via Record Mix. balls = 0; - for (i = 0; i < POKEBALL_COUNT - 1; i ++) - { + for (i = 0; i < POKEBALL_COUNT - 1; i++) balls += gBattleResults.catchAttempts[i]; - } + if (gBattleResults.usedMasterBall) - { - balls ++; - } + balls++; show->breakingNews.location = gMapHeader.regionMapSectionId; StringCopy(show->breakingNews.playerName, gSaveBlock2Ptr->playerName); show->breakingNews.poke1Species = gBattleResults.playerMon1Species; switch (gBattleOutcome) { - case B_OUTCOME_LOST: - case B_OUTCOME_DREW: - show->breakingNews.kind = TVSHOW_OFF_AIR; - return; - case B_OUTCOME_CAUGHT: - show->breakingNews.outcome = 0; - break; - case B_OUTCOME_WON: - show->breakingNews.outcome = 1; - break; - case B_OUTCOME_RAN: - case B_OUTCOME_PLAYER_TELEPORTED: - case B_OUTCOME_NO_SAFARI_BALLS: - show->breakingNews.outcome = 2; - break; - case B_OUTCOME_MON_FLED: - case B_OUTCOME_MON_TELEPORTED: - show->breakingNews.outcome = 3; - break; + case B_OUTCOME_LOST: + case B_OUTCOME_DREW: + show->breakingNews.kind = TVSHOW_OFF_AIR; + return; + case B_OUTCOME_CAUGHT: + show->breakingNews.outcome = 0; + break; + case B_OUTCOME_WON: + show->breakingNews.outcome = 1; + break; + case B_OUTCOME_RAN: + case B_OUTCOME_PLAYER_TELEPORTED: + case B_OUTCOME_NO_SAFARI_BALLS: + show->breakingNews.outcome = 2; + break; + case B_OUTCOME_MON_FLED: + case B_OUTCOME_MON_TELEPORTED: + show->breakingNews.outcome = 3; + break; } show->breakingNews.lastOpponentSpecies = gBattleResults.lastOpponentSpecies; switch (show->breakingNews.outcome) { - case 0: - if (gBattleResults.usedMasterBall) - { - show->breakingNews.caughtMonBall = ITEM_MASTER_BALL; - } - else - { - show->breakingNews.caughtMonBall = gBattleResults.caughtMonBall; - } - show->breakingNews.balls = balls; - break; - case 1: - show->breakingNews.lastUsedMove = gBattleResults.lastUsedMovePlayer; - break; - case 2: - break; - case 3: - break; + case 0: + if (gBattleResults.usedMasterBall) + show->breakingNews.caughtMonBall = ITEM_MASTER_BALL; + else + show->breakingNews.caughtMonBall = gBattleResults.caughtMonBall; + show->breakingNews.balls = balls; + break; + case 1: + show->breakingNews.lastUsedMove = gBattleResults.lastUsedMovePlayer; + break; + case 2: + case 3: + break; } - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->breakingNews.language = gGameLanguage; } } @@ -2290,16 +2179,16 @@ void TryPutLotteryWinnerReportOnAir(void) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_LOTTO_WINNER, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_LOTTO_WINNER, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->lottoWinner.kind = TVSHOW_LOTTO_WINNER; - show->lottoWinner.active = FALSE; + show->lottoWinner.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->lottoWinner.playerName, gSaveBlock2Ptr->playerName); show->lottoWinner.whichPrize = 4 - gSpecialVar_0x8004; show->lottoWinner.item = gSpecialVar_0x8005; - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->lottoWinner.language = gGameLanguage; } } @@ -2310,45 +2199,45 @@ void TryPutBattleSeminarOnAir(u16 foeSpecies, u16 species, u8 moveIdx, const u16 u8 i; u8 j; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_BATTLE_SEMINAR, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_BATTLE_SEMINAR, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->battleSeminar.kind = TVSHOW_BATTLE_SEMINAR; - show->battleSeminar.active = FALSE; + show->battleSeminar.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->battleSeminar.playerName, gSaveBlock2Ptr->playerName); show->battleSeminar.foeSpecies = foeSpecies; show->battleSeminar.species = species; show->battleSeminar.move = movePtr[moveIdx]; - for (i = 0, j = 0; i < MAX_MON_MOVES; i ++) + for (i = 0, j = 0; i < MAX_MON_MOVES; i++) { if (i != moveIdx && movePtr[i]) { show->battleSeminar.otherMoves[j] = movePtr[i]; - j ++; + j++; } } show->battleSeminar.nOtherMoves = j; show->battleSeminar.betterMove = betterMove; - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->battleSeminar.language = gGameLanguage; } } -void sub_80EE44C(u8 nMonsCaught, u8 nPkblkUsed) +void TryPutSafariFanClubOnAir(u8 nMonsCaught, u8 nPkblkUsed) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SAFARI_FAN_CLUB, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_SAFARI_FAN_CLUB, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->safariFanClub.kind = TVSHOW_SAFARI_FAN_CLUB; - show->safariFanClub.active = FALSE; + show->safariFanClub.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->safariFanClub.playerName, gSaveBlock2Ptr->playerName); show->safariFanClub.nMonsCaught = nMonsCaught; show->safariFanClub.nPkblkUsed = nPkblkUsed; - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->safariFanClub.language = gGameLanguage; } } @@ -2357,27 +2246,23 @@ void TryPutSpotTheCutiesOnAir(struct Pokemon *pokemon, u8 ribbonMonDataIdx) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_CUTIES, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_CUTIES, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->cuties.kind = TVSHOW_CUTIES; - show->cuties.active = FALSE; + show->cuties.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->cuties.playerName, gSaveBlock2Ptr->playerName); GetMonData(pokemon, MON_DATA_NICKNAME, show->cuties.nickname); StripExtCtrlCodes(show->cuties.nickname); show->cuties.nRibbons = GetRibbonCount(pokemon); show->cuties.selectedRibbon = MonDataIdxToRibbon(ribbonMonDataIdx); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->cuties.language = gGameLanguage; if (show->cuties.language == LANGUAGE_JAPANESE || GetMonData(pokemon, MON_DATA_LANGUAGE) == LANGUAGE_JAPANESE) - { show->cuties.pokemonNameLanguage = LANGUAGE_JAPANESE; - } else - { show->cuties.pokemonNameLanguage = GetMonData(pokemon, MON_DATA_LANGUAGE); - } } } @@ -2428,31 +2313,31 @@ static u8 MonDataIdxToRibbon(u8 monDataIdx) return CHAMPION_RIBBON; } -void TrySetUpTrainerFanClubSpecial(void) +void TryPutTrainerFanClubOnAir(void) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); - if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TRAINER_FAN_CLUB, FALSE) != TRUE) + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); + if (sCurTVShowSlot != -1 && IsRecordMixShowAlreadySpawned(TVSHOW_TRAINER_FAN_CLUB, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->trainerFanClub.kind = TVSHOW_TRAINER_FAN_CLUB; - show->trainerFanClub.active = FALSE; + show->trainerFanClub.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->trainerFanClub.playerName, gSaveBlock2Ptr->playerName); show->trainerFanClub.words[0] = gSaveBlock1Ptr->easyChatProfile[0]; show->trainerFanClub.words[1] = gSaveBlock1Ptr->easyChatProfile[1]; - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->trainerFanClub.language = gGameLanguage; } } bool8 ShouldHideFanClubInterviewer(void) { - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot == -1) return TRUE; - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_SPECIAL); + TryReplaceOldTVShowOfKind(TVSHOW_FAN_CLUB_SPECIAL); if (gSpecialVar_Result == TRUE) return TRUE; @@ -2468,25 +2353,24 @@ bool8 ShouldAirFrontierTVShow(void) u8 showIdx; TVShow *shows; - if (HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_FRONTIER, FALSE) == TRUE) + if (IsRecordMixShowAlreadySpawned(TVSHOW_FRONTIER, FALSE) == TRUE) { shows = gSaveBlock1Ptr->tvShows; playerId = GetPlayerIDAsU32(); - for (showIdx = 5; showIdx < LAST_TVSHOW_IDX; showIdx ++) + for (showIdx = NUM_NORMAL_TVSHOW_SLOTS; showIdx < LAST_TVSHOW_IDX; showIdx++) { if (shows[showIdx].common.kind == TVSHOW_FRONTIER && (playerId & 0xFF) == shows[showIdx].common.trainerIdLo && ((playerId >> 8) & 0xFF) == shows[showIdx].common.trainerIdHi) { DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, showIdx); - sub_80EF93C(gSaveBlock1Ptr->tvShows); + CompactTVShowArray(gSaveBlock1Ptr->tvShows); return TRUE; } } } - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot == -1) - { return FALSE; - } + return TRUE; } @@ -2494,47 +2378,47 @@ void TryPutFrontierTVShowOnAir(u16 winStreak, u8 facilityAndMode) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->frontier.kind = TVSHOW_FRONTIER; - show->frontier.active = FALSE; + show->frontier.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->frontier.playerName, gSaveBlock2Ptr->playerName); show->frontier.winStreak = winStreak; - show->frontier.facility = facilityAndMode; + show->frontier.facilityAndMode = facilityAndMode; switch (facilityAndMode) { - case 1: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - show->frontier.species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); - show->frontier.species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); - show->frontier.species3 = GetMonData(&gPlayerParty[2], MON_DATA_SPECIES, NULL); - break; - case 2: - show->frontier.species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); - show->frontier.species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); - show->frontier.species3 = GetMonData(&gPlayerParty[2], MON_DATA_SPECIES, NULL); - show->frontier.species4 = GetMonData(&gPlayerParty[3], MON_DATA_SPECIES, NULL); - break; - case 3: - show->frontier.species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); - show->frontier.species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); - break; - case 4: - show->frontier.species1 = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[0] - 1], MON_DATA_SPECIES, NULL); - show->frontier.species2 = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[1] - 1], MON_DATA_SPECIES, NULL); - break; + case FRONTIER_SHOW_TOWER_SINGLES: + case FRONTIER_SHOW_DOME_SINGLES: + case FRONTIER_SHOW_DOME_DOUBLES: + case FRONTIER_SHOW_FACTORY_SINGLES: + case FRONTIER_SHOW_FACTORY_DOUBLES: + case FRONTIER_SHOW_PIKE: + case FRONTIER_SHOW_ARENA: + case FRONTIER_SHOW_PALACE_SINGLES: + case FRONTIER_SHOW_PALACE_DOUBLES: + case FRONTIER_SHOW_PYRAMID: + show->frontier.species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); + show->frontier.species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); + show->frontier.species3 = GetMonData(&gPlayerParty[2], MON_DATA_SPECIES, NULL); + break; + case FRONTIER_SHOW_TOWER_DOUBLES: + show->frontier.species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); + show->frontier.species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); + show->frontier.species3 = GetMonData(&gPlayerParty[2], MON_DATA_SPECIES, NULL); + show->frontier.species4 = GetMonData(&gPlayerParty[3], MON_DATA_SPECIES, NULL); + break; + case FRONTIER_SHOW_TOWER_MULTIS: + show->frontier.species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); + show->frontier.species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); + break; + case FRONTIER_SHOW_TOWER_LINK_MULTIS: + show->frontier.species1 = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[0] - 1], MON_DATA_SPECIES, NULL); + show->frontier.species2 = GetMonData(&gSaveBlock1Ptr->playerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[1] - 1], MON_DATA_SPECIES, NULL); + break; } - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->frontier.language = gGameLanguage; } } @@ -2544,14 +2428,14 @@ void TryPutSecretBaseSecretsOnAir(void) TVShow *show; u8 strbuf[32]; - if (HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SECRET_BASE_SECRETS, FALSE) != TRUE) + if (IsRecordMixShowAlreadySpawned(TVSHOW_SECRET_BASE_SECRETS, FALSE) != TRUE) { - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->secretBaseSecrets.kind = TVSHOW_SECRET_BASE_SECRETS; - show->secretBaseSecrets.active = FALSE; + show->secretBaseSecrets.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->secretBaseSecrets.playerName, gSaveBlock2Ptr->playerName); show->secretBaseSecrets.stepsInBase = VarGet(VAR_SECRET_BASE_STEP_COUNTER); CopyCurSecretBaseOwnerName_StrVar1(); @@ -2560,53 +2444,50 @@ void TryPutSecretBaseSecretsOnAir(void) StringCopy(show->secretBaseSecrets.baseOwnersName, strbuf); show->secretBaseSecrets.item = VarGet(VAR_SECRET_BASE_LAST_ITEM_USED); show->secretBaseSecrets.flags = VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) + (VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) << 16); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->secretBaseSecrets.language = gGameLanguage; if (show->secretBaseSecrets.language == LANGUAGE_JAPANESE || gSaveBlock1Ptr->secretBases[VarGet(VAR_CURRENT_SECRET_BASE)].language == LANGUAGE_JAPANESE) - { show->secretBaseSecrets.baseOwnersNameLanguage = LANGUAGE_JAPANESE; - } else - { show->secretBaseSecrets.baseOwnersNameLanguage = gSaveBlock1Ptr->secretBases[VarGet(VAR_CURRENT_SECRET_BASE)].language; - } } } } -static void sub_80EEB98(u16 days) +// Check var thresholds required to trigger the Number One show +// The vars are reset afterwards regardless +static void ResolveNumberOneShow(u16 days) { u8 i; - for (i = 0; i < ARRAY_COUNT(sNumberOneVarsAndThresholds); i ++) + for (i = 0; i < ARRAY_COUNT(sNumberOneVarsAndThresholds); i++) { if (VarGet(sNumberOneVarsAndThresholds[i][0]) >= sNumberOneVarsAndThresholds[i][1]) { - sub_80EEBF4(i); + TryPutNumberOneOnAir(i); break; } } - for (i = 0; i < ARRAY_COUNT(sNumberOneVarsAndThresholds); i ++) - { + + for (i = 0; i < ARRAY_COUNT(sNumberOneVarsAndThresholds); i++) VarSet(sNumberOneVarsAndThresholds[i][0], 0); - } } -static void sub_80EEBF4(u8 actionIdx) +static void TryPutNumberOneOnAir(u8 actionIdx) { TVShow *show; - HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_NUMBER_ONE, TRUE); - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + IsRecordMixShowAlreadySpawned(TVSHOW_NUMBER_ONE, TRUE); // Delete old version of show + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; show->numberOne.kind = TVSHOW_NUMBER_ONE; - show->numberOne.active = FALSE; + show->numberOne.active = FALSE; // NOTE: Show is not active until passed via Record Mix. StringCopy(show->numberOne.playerName, gSaveBlock2Ptr->playerName); show->numberOne.actionIdx = actionIdx; show->numberOne.count = VarGet(sNumberOneVarsAndThresholds[actionIdx][0]); - tv_store_id_3x(show); + StorePlayerIdInRecordMixShow(show); show->numberOne.language = gGameLanguage; } } @@ -2648,72 +2529,66 @@ void IncrementDailyBattlePoints(u16 delta) // PokeNews -static void sub_80EED88(void) +static void TryPutRandomPokeNewsOnAir(void) { - u8 newsKind; - if (FlagGet(FLAG_SYS_GAME_CLEAR)) { - sCurTVShowSlot = sub_80EEE30(gSaveBlock1Ptr->pokeNews); + sCurTVShowSlot = GetFirstEmptyPokeNewsSlot(gSaveBlock1Ptr->pokeNews); if (sCurTVShowSlot != -1 && rbernoulli(1, 100) != TRUE) { - newsKind = (Random() % 4) + POKENEWS_SLATEPORT; - if (sub_80EF0E4(newsKind) != TRUE) + u8 newsKind = (Random() % NUM_POKENEWS_TYPES) + POKENEWS_SLATEPORT; + if (IsAddingPokeNewsDisallowed(newsKind) != TRUE) { gSaveBlock1Ptr->pokeNews[sCurTVShowSlot].kind = newsKind; gSaveBlock1Ptr->pokeNews[sCurTVShowSlot].days = 4; - gSaveBlock1Ptr->pokeNews[sCurTVShowSlot].state = TRUE; + gSaveBlock1Ptr->pokeNews[sCurTVShowSlot].state = 1; } } } } -s8 sub_80EEE30(PokeNews *pokeNews) +static s8 GetFirstEmptyPokeNewsSlot(PokeNews *pokeNews) { s8 i; - for (i = 0; i < POKE_NEWS_COUNT; i ++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { - if (pokeNews[i].kind == 0) - { + if (pokeNews[i].kind == POKENEWS_NONE) return i; - } } return -1; } -void ClearPokemonNews(void) +static void ClearPokeNews(void) { u8 i; - for (i = 0; i < POKE_NEWS_COUNT; i ++) - { - ClearPokemonNewsI(i); - } + for (i = 0; i < POKE_NEWS_COUNT; i++) + ClearPokeNewsBySlot(i); } -void ClearPokemonNewsI(u8 i) +static void ClearPokeNewsBySlot(u8 i) { gSaveBlock1Ptr->pokeNews[i].kind = POKENEWS_NONE; gSaveBlock1Ptr->pokeNews[i].state = FALSE; gSaveBlock1Ptr->pokeNews[i].days = 0; } -static void sub_80EEEB8(void) +static void CompactPokeNews(void) { u8 i; u8 j; - for (i = 0; i < POKE_NEWS_COUNT - 1; i ++) + for (i = 0; i < POKE_NEWS_COUNT - 1; i++) { if (gSaveBlock1Ptr->pokeNews[i].kind == POKENEWS_NONE) { - for (j = i + 1; j < POKE_NEWS_COUNT; j ++) + for (j = i + 1; j < POKE_NEWS_COUNT; j++) { if (gSaveBlock1Ptr->pokeNews[j].kind != POKENEWS_NONE) { gSaveBlock1Ptr->pokeNews[i] = gSaveBlock1Ptr->pokeNews[j]; - ClearPokemonNewsI(j); + ClearPokeNewsBySlot(j); break; } } @@ -2721,16 +2596,16 @@ static void sub_80EEEB8(void) } } -u8 FindAnyTVNewsOnTheAir(void) +static u8 FindAnyPokeNewsOnTheAir(void) { u8 i; - for (i = 0; i < POKE_NEWS_COUNT; i ++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { - if (gSaveBlock1Ptr->pokeNews[i].kind != POKENEWS_NONE && gSaveBlock1Ptr->pokeNews[i].state == TRUE && gSaveBlock1Ptr->pokeNews[i].days < 3) - { + if (gSaveBlock1Ptr->pokeNews[i].kind != POKENEWS_NONE + && gSaveBlock1Ptr->pokeNews[i].state == 1 + && gSaveBlock1Ptr->pokeNews[i].days < 3) return i; - } } return 0xFF; } @@ -2740,7 +2615,7 @@ void DoPokeNews(void) u8 i; u16 n; - i = FindAnyTVNewsOnTheAir(); + i = FindAnyPokeNewsOnTheAir(); if (i == 0xFF) { gSpecialVar_Result = FALSE; @@ -2751,13 +2626,9 @@ void DoPokeNews(void) { gSaveBlock1Ptr->pokeNews[i].state = 2; if (gLocalTime.hours < 20) - { ShowFieldMessage(sPokeNewsTextGroup_Ongoing[gSaveBlock1Ptr->pokeNews[i].kind]); - } else - { ShowFieldMessage(sPokeNewsTextGroup_Ending[gSaveBlock1Ptr->pokeNews[i].kind]); - } } else { @@ -2775,101 +2646,92 @@ bool8 GetPriceReduction(u8 newsKind) u8 i; if (newsKind == POKENEWS_NONE) - { return FALSE; - } - for (i = 0; i < POKE_NEWS_COUNT; i ++) + + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (gSaveBlock1Ptr->pokeNews[i].kind == newsKind) { if (gSaveBlock1Ptr->pokeNews[i].state == 2 && IsPriceDiscounted(newsKind)) - { return TRUE; - } + return FALSE; } } return FALSE; } -bool8 IsPriceDiscounted(u8 newsKind) +static bool8 IsPriceDiscounted(u8 newsKind) { switch (newsKind) { - case POKENEWS_SLATEPORT: - if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SLATEPORT_CITY) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SLATEPORT_CITY) && gSpecialVar_LastTalked == 25) - { - return TRUE; - } - return FALSE; - case POKENEWS_LILYCOVE: - if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP)) - { - return TRUE; - } - return FALSE; + case POKENEWS_SLATEPORT: + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SLATEPORT_CITY) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(SLATEPORT_CITY) && gSpecialVar_LastTalked == 25) + return TRUE; + return FALSE; + case POKENEWS_LILYCOVE: + if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP)) + return TRUE; + return FALSE; } return TRUE; } -bool8 sub_80EF0E4(u8 newsKind) +static bool8 IsAddingPokeNewsDisallowed(u8 newsKind) { u8 i; if (newsKind == POKENEWS_NONE) - { return TRUE; - } - for (i = 0; i < POKE_NEWS_COUNT; i ++) + + // Check if this type of news is already active + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (gSaveBlock1Ptr->pokeNews[i].kind == newsKind) - { return TRUE; - } } return FALSE; } -static void sub_80EF120(u16 days) +static void UpdatePokeNewsTimeLeft(u16 days) { u8 i; - for (i = 0; i < POKE_NEWS_COUNT; i ++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (gSaveBlock1Ptr->pokeNews[i].kind != POKENEWS_NONE) { if (gSaveBlock1Ptr->pokeNews[i].days < days) { - ClearPokemonNewsI(i); + ClearPokeNewsBySlot(i); } else { if (gSaveBlock1Ptr->pokeNews[i].state == 0 && FlagGet(FLAG_SYS_GAME_CLEAR) == TRUE) - { gSaveBlock1Ptr->pokeNews[i].state = 1; - } + gSaveBlock1Ptr->pokeNews[i].days -= days; } } } - sub_80EEEB8(); + CompactPokeNews(); } void CopyContestRankToStringVar(u8 varIdx, u8 rank) { switch (rank) { - case CONTEST_RANK_NORMAL: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_NORMAL]); - break; - case CONTEST_RANK_SUPER: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_SUPER]); - break; - case CONTEST_RANK_HYPER: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_HYPER]); - break; - case CONTEST_RANK_MASTER: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_MASTER]); - break; + case CONTEST_RANK_NORMAL: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_NORMAL]); + break; + case CONTEST_RANK_SUPER: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_SUPER]); + break; + case CONTEST_RANK_HYPER: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_HYPER]); + break; + case CONTEST_RANK_MASTER: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_MASTER]); + break; } } @@ -2877,21 +2739,21 @@ void CopyContestCategoryToStringVar(u8 varIdx, u8 category) { switch (category) { - case CONTEST_CATEGORY_COOL: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_COOL]); - break; - case CONTEST_CATEGORY_BEAUTY: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_BEAUTY]); - break; - case CONTEST_CATEGORY_CUTE: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_CUTE]); - break; - case CONTEST_CATEGORY_SMART: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_SMART]); - break; - case CONTEST_CATEGORY_TOUGH: - StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_TOUGH]); - break; + case CONTEST_CATEGORY_COOL: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_COOL]); + break; + case CONTEST_CATEGORY_BEAUTY: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_BEAUTY]); + break; + case CONTEST_CATEGORY_CUTE: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_CUTE]); + break; + case CONTEST_CATEGORY_SMART: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_SMART]); + break; + case CONTEST_CATEGORY_TOUGH: + StringCopy(gTVStringVarPtrs[varIdx], gStdStrings[STDSTRING_TOUGH]); + break; } } @@ -2903,11 +2765,9 @@ void SetContestCategoryStringVarForInterview(void) CopyContestCategoryToStringVar(1, show->bravoTrainer.contestCategory); } -void TV_PrintIntToStringVar(u8 varIdx, int value) +void ConvertIntToDecimalString(u8 varIdx, int value) { - int nDigits; - - nDigits = CountDigits(value); + int nDigits = CountDigits(value); ConvertIntToDecimalStringN(gTVStringVarPtrs[varIdx], value, STR_CONV_MODE_LEFT_ALIGN, nDigits); } @@ -2931,24 +2791,19 @@ static void sub_80EF40C(u8 varIdx, TVShow *show) int price; price = 0; - for (i = 0; i < 3; i ++) + for (i = 0; i < SMARTSHOPPER_NUM_ITEMS; i++) { if (show->smartshopperShow.itemIds[i] != ITEM_NONE) - { price += ItemId_GetPrice(show->smartshopperShow.itemIds[i]) * show->smartshopperShow.itemAmounts[i]; - } } + if (show->smartshopperShow.priceReduced == TRUE) - { - TV_PrintIntToStringVar(varIdx, price >> 1); - } + ConvertIntToDecimalString(varIdx, price >> 1); else - { - TV_PrintIntToStringVar(varIdx, price); - } + ConvertIntToDecimalString(varIdx, price); } -bool8 HasMixableShowAlreadyBeenSpawnedWithPlayerID(u8 kind, bool8 flag) +static bool8 IsRecordMixShowAlreadySpawned(u8 kind, bool8 delete) { u32 playerId; TVShow *shows; @@ -2956,14 +2811,16 @@ bool8 HasMixableShowAlreadyBeenSpawnedWithPlayerID(u8 kind, bool8 flag) shows = gSaveBlock1Ptr->tvShows; playerId = GetPlayerIDAsU32(); - for (i = 5; i < LAST_TVSHOW_IDX; i ++) + for (i = NUM_NORMAL_TVSHOW_SLOTS; i < LAST_TVSHOW_IDX; i++) { - if (shows[i].common.kind == kind && (playerId & 0xFF) == shows[i].common.trainerIdLo && ((playerId >> 8) & 0xFF) == shows[i].common.trainerIdHi) + if (shows[i].common.kind == kind + && (playerId & 0xFF) == shows[i].common.trainerIdLo + && ((playerId >> 8) & 0xFF) == shows[i].common.trainerIdHi) { - if (flag == TRUE) + if (delete == TRUE) { DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, i); - sub_80EF93C(gSaveBlock1Ptr->tvShows); + CompactTVShowArray(gSaveBlock1Ptr->tvShows); } return TRUE; } @@ -2971,16 +2828,15 @@ bool8 HasMixableShowAlreadyBeenSpawnedWithPlayerID(u8 kind, bool8 flag) return FALSE; } -void TV_SortPurchasesByQuantity(void) +static void SortPurchasesByQuantity(void) { - u8 i; - u8 j; + u8 i, j; u16 tmpId; u16 tmpQn; - for (i = 0; i < 2; i ++) + for (i = 0; i < SMARTSHOPPER_NUM_ITEMS - 1; i++) { - for (j = i + 1; j < 3; j ++) + for (j = i + 1; j < SMARTSHOPPER_NUM_ITEMS; j++) { if (gMartPurchaseHistory[i].quantity < gMartPurchaseHistory[j].quantity) { @@ -2995,27 +2851,31 @@ void TV_SortPurchasesByQuantity(void) } } -void FindActiveBroadcastByShowType_SetScriptResult(u8 kind) +static void TryReplaceOldTVShowOfKind(u8 kind) { u8 i; - for (i = 0; i < 5; i ++) + for (i = 0; i < NUM_NORMAL_TVSHOW_SLOTS; i++) { if (gSaveBlock1Ptr->tvShows[i].common.kind == kind) { if (gSaveBlock1Ptr->tvShows[i].common.active == TRUE) { + // Old TV show is still active, don't replace gSpecialVar_Result = TRUE; } else { + // Old TV show is inactive, replace it and get new slot DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, i); - sub_80EF93C(gSaveBlock1Ptr->tvShows); - sub_80EFA88(); + CompactTVShowArray(gSaveBlock1Ptr->tvShows); + Script_FindFirstEmptyNormalTVShowSlot(); } return; } } - sub_80EFA88(); + + // Old TV show doesn't exist, just get new slot + Script_FindFirstEmptyNormalTVShowSlot(); } void InterviewBefore(void) @@ -3023,42 +2883,42 @@ void InterviewBefore(void) gSpecialVar_Result = FALSE; switch (gSpecialVar_0x8005) { - case TVSHOW_FAN_CLUB_LETTER: - InterviewBefore_FanClubLetter(); - break; - case TVSHOW_RECENT_HAPPENINGS: - InterviewBefore_RecentHappenings(); - break; - case TVSHOW_PKMN_FAN_CLUB_OPINIONS: - InterviewBefore_PkmnFanClubOpinions(); - break; - case TVSHOW_UNKN_SHOWTYPE_04: - InterviewBefore_Dummy(); - break; - case TVSHOW_NAME_RATER_SHOW: - InterviewBefore_NameRater(); - break; - case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: - InterviewBefore_BravoTrainerPkmnProfile(); - break; - case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: - InterviewBefore_BravoTrainerBTProfile(); - break; - case TVSHOW_CONTEST_LIVE_UPDATES: - InterviewBefore_ContestLiveUpdates(); - break; - case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: - InterviewBefore_3CheersForPokeblocks(); - break; - case TVSHOW_FAN_CLUB_SPECIAL: - InterviewBefore_FanClubSpecial(); - break; + case TVSHOW_FAN_CLUB_LETTER: + InterviewBefore_FanClubLetter(); + break; + case TVSHOW_RECENT_HAPPENINGS: + InterviewBefore_RecentHappenings(); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + InterviewBefore_PkmnFanClubOpinions(); + break; + case TVSHOW_DUMMY: + InterviewBefore_Dummy(); + break; + case TVSHOW_NAME_RATER_SHOW: + InterviewBefore_NameRater(); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + InterviewBefore_BravoTrainerPkmnProfile(); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + InterviewBefore_BravoTrainerBTProfile(); + break; + case TVSHOW_CONTEST_LIVE_UPDATES: + InterviewBefore_ContestLiveUpdates(); + break; + case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: + InterviewBefore_3CheersForPokeblocks(); + break; + case TVSHOW_FAN_CLUB_SPECIAL: + InterviewBefore_FanClubSpecial(); + break; } } static void InterviewBefore_FanClubLetter(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_LETTER); + TryReplaceOldTVShowOfKind(TVSHOW_FAN_CLUB_LETTER); if (!gSpecialVar_Result) { StringCopy(gStringVar1, gSpeciesNames[GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL)]); @@ -3068,7 +2928,7 @@ static void InterviewBefore_FanClubLetter(void) static void InterviewBefore_RecentHappenings(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_RECENT_HAPPENINGS); + TryReplaceOldTVShowOfKind(TVSHOW_RECENT_HAPPENINGS); if (!gSpecialVar_Result) { InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].recentHappenings.words, 6); @@ -3077,7 +2937,7 @@ static void InterviewBefore_RecentHappenings(void) static void InterviewBefore_PkmnFanClubOpinions(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_PKMN_FAN_CLUB_OPINIONS); + TryReplaceOldTVShowOfKind(TVSHOW_PKMN_FAN_CLUB_OPINIONS); if (!gSpecialVar_Result) { StringCopy(gStringVar1, gSpeciesNames[GetMonData(&gPlayerParty[GetLeadMonIndex()], MON_DATA_SPECIES, NULL)]); @@ -3094,44 +2954,38 @@ static void InterviewBefore_Dummy(void) static void InterviewBefore_NameRater(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_NAME_RATER_SHOW); + TryReplaceOldTVShowOfKind(TVSHOW_NAME_RATER_SHOW); } static void InterviewBefore_BravoTrainerPkmnProfile(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE); + TryReplaceOldTVShowOfKind(TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE); if (!gSpecialVar_Result) - { InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].bravoTrainer.words, 2); - } } static void InterviewBefore_ContestLiveUpdates(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_CONTEST_LIVE_UPDATES); + TryReplaceOldTVShowOfKind(TVSHOW_CONTEST_LIVE_UPDATES); } static void InterviewBefore_3CheersForPokeblocks(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_3_CHEERS_FOR_POKEBLOCKS); + TryReplaceOldTVShowOfKind(TVSHOW_3_CHEERS_FOR_POKEBLOCKS); } static void InterviewBefore_BravoTrainerBTProfile(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE); + TryReplaceOldTVShowOfKind(TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE); if (!gSpecialVar_Result) - { InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].bravoTrainerTower.words, 1); - } } static void InterviewBefore_FanClubSpecial(void) { - FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_SPECIAL); + TryReplaceOldTVShowOfKind(TVSHOW_FAN_CLUB_SPECIAL); if (!gSpecialVar_Result) - { InitializeEasyChatWordArray(gSaveBlock1Ptr->tvShows[sCurTVShowSlot].fanClubSpecial.words, 1); - } } static bool8 IsPartyMonNicknamedOrNotEnglish(u8 monIdx) @@ -3143,9 +2997,8 @@ static bool8 IsPartyMonNicknamedOrNotEnglish(u8 monIdx) GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1); language = GetMonData(pokemon, MON_DATA_LANGUAGE, &language); if (language == GAME_LANGUAGE && !StringCompare(gSpeciesNames[GetMonData(pokemon, MON_DATA_SPECIES, NULL)], gStringVar1)) - { return FALSE; - } + return TRUE; } @@ -3154,28 +3007,27 @@ bool8 IsLeadMonNicknamedOrNotEnglish(void) return IsPartyMonNicknamedOrNotEnglish(GetLeadMonIndex()); } -void DeleteTVShowInArrayByIdx(TVShow *shows, u8 idx) +static void DeleteTVShowInArrayByIdx(TVShow *shows, u8 idx) { u8 i; shows[idx].commonInit.kind = TVSHOW_OFF_AIR; shows[idx].commonInit.active = FALSE; - for (i = 0; i < ARRAY_COUNT(shows[idx].commonInit.pad02); i++) - { - shows[idx].commonInit.pad02[i] = 0; - } + for (i = 0; i < ARRAY_COUNT(shows[idx].commonInit.data); i++) + shows[idx].commonInit.data[i] = 0; } -static void sub_80EF93C(TVShow *shows) +static void CompactTVShowArray(TVShow *shows) { u8 i; u8 j; - for (i = 0; i < 4; i ++) + // Compact normal TV shows + for (i = 0; i < NUM_NORMAL_TVSHOW_SLOTS - 1; i++) { if (shows[i].common.kind == TVSHOW_OFF_AIR) { - for (j = i + 1; j < 5; j ++) + for (j = i + 1; j < NUM_NORMAL_TVSHOW_SLOTS; j++) { if (shows[j].common.kind != TVSHOW_OFF_AIR) { @@ -3186,11 +3038,13 @@ static void sub_80EF93C(TVShow *shows) } } } - for (i = 5; i < LAST_TVSHOW_IDX; i ++) + + // Compact Record Mix TV shows + for (i = NUM_NORMAL_TVSHOW_SLOTS; i < LAST_TVSHOW_IDX; i++) { if (shows[i].common.kind == TVSHOW_OFF_AIR) { - for (j = i + 1; j < LAST_TVSHOW_IDX; j ++) + for (j = i + 1; j < LAST_TVSHOW_IDX; j++) { if (shows[j].common.kind != TVSHOW_OFF_AIR) { @@ -3203,16 +3057,16 @@ static void sub_80EF93C(TVShow *shows) } } -u16 TV_GetSomeOtherSpeciesAlreadySeenByPlayer_AndPrintName(u8 varIdx, u16 passedSpecies) +static u16 GetRandomDifferentSpeciesAndNameSeenByPlayer(u8 varIdx, u16 passedSpecies) { u16 species; - species = TV_GetSomeOtherSpeciesAlreadySeenByPlayer(passedSpecies); + species = GetRandomDifferentSpeciesSeenByPlayer(passedSpecies); StringCopy(gTVStringVarPtrs[varIdx], gSpeciesNames[species]); return species; } -u16 TV_GetSomeOtherSpeciesAlreadySeenByPlayer(u16 passedSpecies) +static u16 GetRandomDifferentSpeciesSeenByPlayer(u16 passedSpecies) { u16 species; u16 initSpecies; @@ -3222,13 +3076,10 @@ u16 TV_GetSomeOtherSpeciesAlreadySeenByPlayer(u16 passedSpecies) while (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_SEEN) != TRUE || species == passedSpecies) { if (species == SPECIES_NONE + 1) - { species = NUM_SPECIES - 1; - } else - { - species --; - } + species--; + if (species == initSpecies) { species = passedSpecies; @@ -3238,65 +3089,60 @@ u16 TV_GetSomeOtherSpeciesAlreadySeenByPlayer(u16 passedSpecies) return species; } -static void sub_80EFA88(void) +static void Script_FindFirstEmptyNormalTVShowSlot(void) { - sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindFirstEmptyNormalTVShowSlot(gSaveBlock1Ptr->tvShows); gSpecialVar_0x8006 = sCurTVShowSlot; if (sCurTVShowSlot == -1) - { - gSpecialVar_Result = TRUE; - } + gSpecialVar_Result = TRUE; // Failed to find empty slot else - { - gSpecialVar_Result = FALSE; - } + gSpecialVar_Result = FALSE; // Found empty slot } -s8 FindEmptyTVSlotWithinFirstFiveShowsOfArray(TVShow *shows) +static s8 FindFirstEmptyNormalTVShowSlot(TVShow *shows) { u8 i; - for (i = 0; i < 5; i ++) + for (i = 0; i < NUM_NORMAL_TVSHOW_SLOTS; i++) { if (shows[i].common.kind == TVSHOW_OFF_AIR) - { return i; - } } return -1; } -s8 FindEmptyTVSlotBeyondFirstFiveShowsOfArray(TVShow *shows) +static s8 FindFirstEmptyRecordMixTVShowSlot(TVShow *shows) { s8 i; - for (i = 5; i < LAST_TVSHOW_IDX; i ++) + for (i = NUM_NORMAL_TVSHOW_SLOTS; i < LAST_TVSHOW_IDX; i++) { if (shows[i].common.kind == TVSHOW_OFF_AIR) - { return i; - } } return -1; } -bool8 TV_BernoulliTrial(u16 ratio) +static bool8 BernoulliTrial(u16 ratio) { if (Random() <= ratio) - { return FALSE; - } + return TRUE; } -void TV_FanClubLetter_RandomWordToStringVar3(TVShow *show) +// For TVSHOW_FAN_CLUB_LETTER / TVSHOW_RECENT_HAPPENINGS +// Both are assumed to have the same struct layout +static void GetRandomWordFromShow(TVShow *show) { u8 i; - i = Random() % 6; + i = Random() % ARRAY_COUNT(show->fanclubLetter.words); + + // From random point, get first non-empty word while (TRUE) { - if (i == 6) + if (i == ARRAY_COUNT(show->fanclubLetter.words)) i = 0; if (show->fanclubLetter.words[i] != EC_EMPTY_WORD) @@ -3306,33 +3152,31 @@ void TV_FanClubLetter_RandomWordToStringVar3(TVShow *show) CopyEasyChatWord(gStringVar3, show->fanclubLetter.words[i]); } -u8 TV_GetNicknameSumMod8(TVShow *show) +static u8 GetRandomNameRaterStateFromName(TVShow *show) { u8 i; - u16 ct; + u16 nameSum; - ct = 0; - for (i = 0; i < 11; i ++) + nameSum = 0; + for (i = 0; i < POKEMON_NAME_LENGTH + 1; i++) { if (show->nameRaterShow.pokemonName[i] == EOS) - { break; - } - ct += show->nameRaterShow.pokemonName[i]; + + nameSum += show->nameRaterShow.pokemonName[i]; } - return ct & 7; + return nameSum & 7; } -void TV_GetNicknameSubstring(u8 varIdx, u8 whichPosition, u8 charParam, u16 whichString, u16 species, TVShow *show) +static void GetNicknameSubstring(u8 varIdx, u8 whichPosition, u8 charParam, u16 whichString, u16 species, TVShow *show) { u8 buff[16]; u8 i; u16 strlen; - for (i = 0; i < 3; i ++) - { + for (i = 0; i < 3; i++) buff[i] = EOS; - } + if (whichString == 0) { strlen = StringLength(show->nameRaterShow.trainerName); @@ -3404,16 +3248,15 @@ void TV_GetNicknameSubstring(u8 varIdx, u8 whichPosition, u8 charParam, u16 whic StringCopy(gTVStringVarPtrs[varIdx], buff); } -bool8 TV_IsScriptShowKindAlreadyInQueue(void) +// Unused script special +bool8 IsTVShowAlreadyInQueue(void) { u8 i; - for (i = 0; i < 5; i ++) + for (i = 0; i < NUM_NORMAL_TVSHOW_SLOTS; i++) { if (gSaveBlock1Ptr->tvShows[i].common.kind == gSpecialVar_0x8004) - { return TRUE; - } } return FALSE; } @@ -3455,7 +3298,7 @@ void ChangeBoxPokemonNickname(void) DoNamingScreen(NAMING_SCREEN_NICKNAME, gStringVar2, GetBoxMonData(boxMon, MON_DATA_SPECIES, NULL), GetBoxMonGender(boxMon), GetBoxMonData(boxMon, MON_DATA_PERSONALITY, NULL), ChangeBoxPokemonNickname_CB); } -void ChangeBoxPokemonNickname_CB(void) +static void ChangeBoxPokemonNickname_CB(void) { SetBoxMonNickAt(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2); CB2_ReturnToFieldContinueScriptPlayMapMusic(); @@ -3475,25 +3318,21 @@ void IsMonOTIDNotPlayers(void) gSpecialVar_Result = TRUE; } -u8 GetTVChannelByShowType(u8 kind) +static u8 GetTVGroupByShowId(u8 kind) { if (kind == TVSHOW_OFF_AIR) - { - return 0; - } - if (kind >= TVSHOW_FAN_CLUB_LETTER && kind < TVSHOW_POKEMON_TODAY_CAUGHT) - { - return 2; - } - if (kind >= TVSHOW_POKEMON_TODAY_CAUGHT && kind < TVSHOW_MASS_OUTBREAK) - { - return 3; - } - if (kind >= TVSHOW_MASS_OUTBREAK && kind < 61) - { - return 4; - } - return 0; + return TVGROUP_NONE; + + if (kind >= TVGROUP_NORMAL_START && kind <= TVGROUP_NORMAL_END) + return TVGROUP_NORMAL; + + if (kind >= TVGROUP_RECORD_MIX_START && kind <= TVGROUP_RECORD_MIX_END) + return TVGROUP_RECORD_MIX; + + if (kind >= TVGROUP_OUTBREAK_START && kind <= TVGROUP_OUTBREAK_END) + return TVGROUP_OUTBREAK; + + return TVGROUP_NONE; } u32 GetPlayerIDAsU32(void) @@ -3501,35 +3340,31 @@ u32 GetPlayerIDAsU32(void) return (gSaveBlock2Ptr->playerTrainerId[3] << 24) | (gSaveBlock2Ptr->playerTrainerId[2] << 16) | (gSaveBlock2Ptr->playerTrainerId[1] << 8) | gSaveBlock2Ptr->playerTrainerId[0]; } -u8 CheckForBigMovieOrEmergencyNewsOnTV(void) +u8 CheckForPlayersHouseNews(void) { + // Check if not in Littleroot house map group if (gSaveBlock1Ptr->location.mapGroup != MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F)) - { - return 0; - } + return PLAYERS_HOUSE_TV_NONE; + + // Check if not in player's house (dependent on gender) if (gSaveBlock2Ptr->playerGender == MALE) { if (gSaveBlock1Ptr->location.mapNum != MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_1F)) - { - return 0; - } + return PLAYERS_HOUSE_TV_NONE; } else { if (gSaveBlock1Ptr->location.mapNum != MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_1F)) - { - return 0; - } + return PLAYERS_HOUSE_TV_NONE; } + if (FlagGet(FLAG_SYS_TV_LATIAS_LATIOS) == TRUE) - { - return 1; - } + return PLAYERS_HOUSE_TV_LATI; + if (FlagGet(FLAG_SYS_TV_HOME) == TRUE) - { - return 2; - } - return 1; + return PLAYERS_HOUSE_TV_MOVIE; + + return PLAYERS_HOUSE_TV_LATI; } void GetMomOrDadStringForTVMessage(void) @@ -3590,129 +3425,120 @@ void HideBattleTowerReporter(void) FlagSet(FLAG_HIDE_BATTLE_TOWER_REPORTER); } -void ReceiveTvShowsData(void *src, u32 size, u8 masterIdx) +void ReceiveTvShowsData(void *src, u32 size, u8 playersLinkId) { u8 i; u16 version; - TVShow (*rmBuffer2)[4][25]; - TVShow (*rmBuffer)[4][25]; + TVShow (*rmBuffer2)[MAX_LINK_PLAYERS][TV_SHOWS_COUNT]; + TVShow (*rmBuffer)[MAX_LINK_PLAYERS][TV_SHOWS_COUNT]; - rmBuffer2 = malloc(4 * 25 * sizeof(TVShow)); + rmBuffer2 = malloc(MAX_LINK_PLAYERS * TV_SHOWS_COUNT * sizeof(TVShow)); if (rmBuffer2 != NULL) { - for (i = 0; i < 4; i ++) - { + for (i = 0; i < MAX_LINK_PLAYERS; i++) memcpy((*rmBuffer2)[i], src + i * size, sizeof((*rmBuffer2)[i])); - } + rmBuffer = rmBuffer2; - for (i = 0; i < GetLinkPlayerCount(); i ++) + for (i = 0; i < GetLinkPlayerCount(); i++) { version = (u8)gLinkPlayers[i].version; if (version == VERSION_RUBY || version == VERSION_SAPPHIRE) - { - sub_80F1254((*rmBuffer)[i]); - } + TranslateRubyShows((*rmBuffer)[i]); else if (version == VERSION_EMERALD && gLinkPlayers[i].language == LANGUAGE_JAPANESE) - { - sub_80F12A4((*rmBuffer)[i]); - } + TranslateJapaneseEmeraldShows((*rmBuffer)[i]); } - switch (masterIdx) + + // Position player's TV shows in argument list depending on link id + switch (playersLinkId) { - case 0: - sub_80F0358(gSaveBlock1Ptr->tvShows, (*rmBuffer)[1], (*rmBuffer)[2], (*rmBuffer)[3]); - break; - case 1: - sub_80F0358((*rmBuffer)[0], gSaveBlock1Ptr->tvShows, (*rmBuffer)[2], (*rmBuffer)[3]); - break; - case 2: - sub_80F0358((*rmBuffer)[0], (*rmBuffer)[1], gSaveBlock1Ptr->tvShows, (*rmBuffer)[3]); - break; - case 3: - sub_80F0358((*rmBuffer)[0], (*rmBuffer)[1], (*rmBuffer)[2], gSaveBlock1Ptr->tvShows); - break; + case 0: + SetMixedTVShows(gSaveBlock1Ptr->tvShows, (*rmBuffer)[1], (*rmBuffer)[2], (*rmBuffer)[3]); + break; + case 1: + SetMixedTVShows((*rmBuffer)[0], gSaveBlock1Ptr->tvShows, (*rmBuffer)[2], (*rmBuffer)[3]); + break; + case 2: + SetMixedTVShows((*rmBuffer)[0], (*rmBuffer)[1], gSaveBlock1Ptr->tvShows, (*rmBuffer)[3]); + break; + case 3: + SetMixedTVShows((*rmBuffer)[0], (*rmBuffer)[1], (*rmBuffer)[2], gSaveBlock1Ptr->tvShows); + break; } - sub_80EF93C(gSaveBlock1Ptr->tvShows); - sub_80F0C04(); - sub_80EF93C(gSaveBlock1Ptr->tvShows); - sub_80F0708(); - sub_80F0B64(); + + CompactTVShowArray(gSaveBlock1Ptr->tvShows); + DeleteExcessMixedShows(); + CompactTVShowArray(gSaveBlock1Ptr->tvShows); + DeactivateShowsWithUnseenSpecies(); + DeactivateGameCompleteShowsIfNotUnlocked(); free(rmBuffer2); } } -static void sub_80F0358(TVShow player1[25], TVShow player2[25], TVShow player3[25], TVShow player4[25]) +static void SetMixedTVShows(TVShow player1[TV_SHOWS_COUNT], TVShow player2[TV_SHOWS_COUNT], TVShow player3[TV_SHOWS_COUNT], TVShow player4[TV_SHOWS_COUNT]) { u8 i; u8 j; - TVShow **argslist[4]; + TVShow **tvShows[MAX_LINK_PLAYERS]; - argslist[0] = &player1; - argslist[1] = &player2; - argslist[2] = &player3; - argslist[3] = &player4; + tvShows[0] = &player1; + tvShows[1] = &player2; + tvShows[2] = &player3; + tvShows[3] = &player4; sTVShowMixingNumPlayers = GetLinkPlayerCount(); while (1) { - for (i = 0; i < sTVShowMixingNumPlayers; i ++) + for (i = 0; i < sTVShowMixingNumPlayers; i++) { if (i == 0) - { - sRecordMixingPartnersWithoutShowsToShare = i; - } - sTVShowMixingCurSlot = sub_80F06D0(argslist[i][0]); + sRecordMixingPartnersWithoutShowsToShare = 0; + + sTVShowMixingCurSlot = FindInactiveShowInArray(tvShows[i][0]); if (sTVShowMixingCurSlot == -1) { - sRecordMixingPartnersWithoutShowsToShare ++; + sRecordMixingPartnersWithoutShowsToShare++; if (sRecordMixingPartnersWithoutShowsToShare == sTVShowMixingNumPlayers) - { return; - } } else { - for (j = 0; j < sTVShowMixingNumPlayers - 1; j ++) + for (j = 0; j < sTVShowMixingNumPlayers - 1; j++) { - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(argslist[(i + j + 1) % sTVShowMixingNumPlayers][0]); + sCurTVShowSlot = FindFirstEmptyRecordMixTVShowSlot(tvShows[(i + j + 1) % sTVShowMixingNumPlayers][0]); if (sCurTVShowSlot != -1 - && sub_80F049C(&argslist[(i + j + 1) % sTVShowMixingNumPlayers][0], &argslist[i][0], (i + j + 1) % sTVShowMixingNumPlayers) == 1) - { + && TryMixTVShow(&tvShows[(i + j + 1) % sTVShowMixingNumPlayers][0], &tvShows[i][0], (i + j + 1) % sTVShowMixingNumPlayers) == 1) break; - } } if (j == sTVShowMixingNumPlayers - 1) - { - DeleteTVShowInArrayByIdx(argslist[i][0], sTVShowMixingCurSlot); - } + DeleteTVShowInArrayByIdx(tvShows[i][0], sTVShowMixingCurSlot); } } } } -static bool8 sub_80F049C(TVShow *dest[25], TVShow *src[25], u8 idx) +static bool8 TryMixTVShow(TVShow *dest[TV_SHOWS_COUNT], TVShow *src[TV_SHOWS_COUNT], u8 idx) { - u8 value; - u8 switchval; - TVShow *tv1; - TVShow *tv2; + bool8 success; + u8 type; + TVShow *tv1 = *dest; + TVShow *tv2 = *src; - tv1 = *dest; - tv2 = *src; - value = FALSE; - switchval = GetTVChannelByShowType(tv2[sTVShowMixingCurSlot].common.kind); - switch (switchval) + success = FALSE; + type = GetTVGroupByShowId(tv2[sTVShowMixingCurSlot].common.kind); + switch (type) { - case 2: - value = sub_80F0580(&tv1[sCurTVShowSlot], &tv2[sTVShowMixingCurSlot], idx); - break; - case 3: - value = sub_80F05E8(&tv1[sCurTVShowSlot], &tv2[sTVShowMixingCurSlot], idx); - break; - case 4: - value = sub_80F0668(&tv1[sCurTVShowSlot], &tv2[sTVShowMixingCurSlot], idx); - break; + case TVGROUP_NORMAL: + success = TryMixNormalTVShow(&tv1[sCurTVShowSlot], &tv2[sTVShowMixingCurSlot], idx); + break; + case TVGROUP_RECORD_MIX: + success = TryMixRecordMixTVShow(&tv1[sCurTVShowSlot], &tv2[sTVShowMixingCurSlot], idx); + break; + case TVGROUP_OUTBREAK: + success = TryMixOutbreakTVShow(&tv1[sCurTVShowSlot], &tv2[sTVShowMixingCurSlot], idx); + break; } - if (value == TRUE) + + // Show was mixed, delete from array + if (success == TRUE) { DeleteTVShowInArrayByIdx(tv2, sTVShowMixingCurSlot); return TRUE; @@ -3720,385 +3546,354 @@ static bool8 sub_80F049C(TVShow *dest[25], TVShow *src[25], u8 idx) return FALSE; } -static bool8 sub_80F0580(TVShow *tv1, TVShow *tv2, u8 idx) +static bool8 TryMixNormalTVShow(TVShow *dest, TVShow *src, u8 idx) { u32 linkTrainerId = GetLinkPlayerTrainerId(idx); - if ((linkTrainerId & 0xFF) == tv2->common.trainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.trainerIdHi) - { + if ((linkTrainerId & 0xFF) == src->common.trainerIdLo + && ((linkTrainerId >> 8) & 0xFF) == src->common.trainerIdHi) return FALSE; - } - tv2->common.trainerIdLo = tv2->common.srcTrainerIdLo; - tv2->common.trainerIdHi = tv2->common.srcTrainerIdHi; - tv2->common.srcTrainerIdLo = linkTrainerId & 0xFF; - tv2->common.srcTrainerIdHi = linkTrainerId >> 8; - *tv1 = *tv2; - tv1->common.active = TRUE; + + src->common.trainerIdLo = src->common.srcTrainerIdLo; + src->common.trainerIdHi = src->common.srcTrainerIdHi; + src->common.srcTrainerIdLo = linkTrainerId & 0xFF; + src->common.srcTrainerIdHi = linkTrainerId >> 8; + *dest = *src; + dest->common.active = TRUE; return TRUE; } -static bool8 sub_80F05E8(TVShow *tv1, TVShow *tv2, u8 idx) +static bool8 TryMixRecordMixTVShow(TVShow *dest, TVShow *src, u8 idx) { u32 linkTrainerId = GetLinkPlayerTrainerId(idx); - if ((linkTrainerId & 0xFF) == tv2->common.srcTrainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.srcTrainerIdHi) - { + + if ((linkTrainerId & 0xFF) == src->common.srcTrainerIdLo + && ((linkTrainerId >> 8) & 0xFF) == src->common.srcTrainerIdHi) return FALSE; - } - if ((linkTrainerId & 0xFF) == tv2->common.trainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.trainerIdHi) - { + + if ((linkTrainerId & 0xFF) == src->common.trainerIdLo + && ((linkTrainerId >> 8) & 0xFF) == src->common.trainerIdHi) return FALSE; - } - tv2->common.srcTrainerIdLo = tv2->common.srcTrainerId2Lo; - tv2->common.srcTrainerIdHi = tv2->common.srcTrainerId2Hi; - tv2->common.srcTrainerId2Lo = linkTrainerId & 0xFF; - tv2->common.srcTrainerId2Hi = linkTrainerId >> 8; - *tv1 = *tv2; - tv1->common.active = TRUE; + + src->common.srcTrainerIdLo = src->common.srcTrainerId2Lo; + src->common.srcTrainerIdHi = src->common.srcTrainerId2Hi; + src->common.srcTrainerId2Lo = linkTrainerId & 0xFF; + src->common.srcTrainerId2Hi = linkTrainerId >> 8; + *dest = *src; + dest->common.active = TRUE; return TRUE; } -static bool8 sub_80F0668(TVShow *tv1, TVShow *tv2, u8 idx) +static bool8 TryMixOutbreakTVShow(TVShow *dest, TVShow *src, u8 idx) { u32 linkTrainerId = GetLinkPlayerTrainerId(idx); - if ((linkTrainerId & 0xFF) == tv2->common.trainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.trainerIdHi) - { + + if ((linkTrainerId & 0xFF) == src->common.trainerIdLo + && ((linkTrainerId >> 8) & 0xFF) == src->common.trainerIdHi) return FALSE; - } - tv2->common.trainerIdLo = tv2->common.srcTrainerIdLo; - tv2->common.trainerIdHi = tv2->common.srcTrainerIdHi; - tv2->common.srcTrainerIdLo = linkTrainerId & 0xFF; - tv2->common.srcTrainerIdHi = linkTrainerId >> 8; - *tv1 = *tv2; - tv1->common.active = TRUE; - tv1->massOutbreak.daysLeft = 1; + + src->common.trainerIdLo = src->common.srcTrainerIdLo; + src->common.trainerIdHi = src->common.srcTrainerIdHi; + src->common.srcTrainerIdLo = linkTrainerId & 0xFF; + src->common.srcTrainerIdHi = linkTrainerId >> 8; + *dest = *src; + dest->common.active = TRUE; + dest->massOutbreak.daysLeft = 1; return TRUE; } -static s8 sub_80F06D0(TVShow *tvShows) +static s8 FindInactiveShowInArray(TVShow *tvShows) { u8 i; - for (i = 0; i < LAST_TVSHOW_IDX; i ++) + for (i = 0; i < LAST_TVSHOW_IDX; i++) { - if (tvShows[i].common.active == FALSE && (u8)(tvShows[i].common.kind - 1) < 60) - { + // Second check is to make sure its a valid show (not too high, not TVSHOW_OFF_AIR) + if (tvShows[i].common.active == FALSE && (u8)(tvShows[i].common.kind - 1) < TVGROUP_OUTBREAK_END) return i; - } } return -1; } -static void sub_80F0708(void) // FIXME: register allocation shenanigans +static void DeactivateShowsWithUnseenSpecies(void) { u16 i; - u16 j; + u16 species; - for (i = 0; i < LAST_TVSHOW_IDX; i ++) + for (i = 0; i < LAST_TVSHOW_IDX; i++) { switch (gSaveBlock1Ptr->tvShows[i].common.kind) { - case TVSHOW_CONTEST_LIVE_UPDATES: - j = (&gSaveBlock1Ptr->tvShows[i])->contestLiveUpdates.winningSpecies; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->contestLiveUpdates.losingSpecies; - sub_80F0B24(j, i); + case TVSHOW_CONTEST_LIVE_UPDATES: + species = (&gSaveBlock1Ptr->tvShows[i])->contestLiveUpdates.winningSpecies; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->contestLiveUpdates.losingSpecies; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_BATTLE_UPDATE: + species = (&gSaveBlock1Ptr->tvShows[i])->battleUpdate.speciesPlayer; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->battleUpdate.speciesOpponent; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_FAN_CLUB_LETTER: + species = (&gSaveBlock1Ptr->tvShows[i])->fanclubLetter.species; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + species = (&gSaveBlock1Ptr->tvShows[i])->fanclubOpinions.species; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_DUMMY: + species = (&gSaveBlock1Ptr->tvShows[i])->dummy.species; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_NAME_RATER_SHOW: + species = (&gSaveBlock1Ptr->tvShows[i])->nameRaterShow.species; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->nameRaterShow.randomSpecies; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + species = (&gSaveBlock1Ptr->tvShows[i])->bravoTrainer.species; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + species = (&gSaveBlock1Ptr->tvShows[i])->bravoTrainerTower.species; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->bravoTrainerTower.defeatedSpecies; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_POKEMON_TODAY_CAUGHT: + species = (&gSaveBlock1Ptr->tvShows[i])->pokemonToday.species; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_POKEMON_TODAY_FAILED: + species = (&gSaveBlock1Ptr->tvShows[i])->pokemonTodayFailed.species; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->pokemonTodayFailed.species2; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_FISHING_ADVICE: + species = (&gSaveBlock1Ptr->tvShows[i])->pokemonAngler.species; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_WORLD_OF_MASTERS: + species = (&gSaveBlock1Ptr->tvShows[i])->worldOfMasters.species; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->worldOfMasters.caughtPoke; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_BREAKING_NEWS: + species = (&gSaveBlock1Ptr->tvShows[i])->breakingNews.lastOpponentSpecies; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->breakingNews.poke1Species; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_SECRET_BASE_VISIT: + species = (&gSaveBlock1Ptr->tvShows[i])->secretBaseVisit.species; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_BATTLE_SEMINAR: + species = (&gSaveBlock1Ptr->tvShows[i])->battleSeminar.species; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->battleSeminar.foeSpecies; + DeactivateShowIfNotSeenSpecies(species, i); + break; + case TVSHOW_FRONTIER: + species = (&gSaveBlock1Ptr->tvShows[i])->frontier.species1; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->frontier.species2; + DeactivateShowIfNotSeenSpecies(species, i); + // Species var re-used here + species = (&gSaveBlock1Ptr->tvShows[i])->frontier.facilityAndMode; + switch (species) + { + case FRONTIER_SHOW_TOWER_MULTIS: + case FRONTIER_SHOW_TOWER_LINK_MULTIS: break; - case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: + case FRONTIER_SHOW_TOWER_SINGLES: + case FRONTIER_SHOW_DOME_SINGLES: + case FRONTIER_SHOW_DOME_DOUBLES: + case FRONTIER_SHOW_FACTORY_SINGLES: + case FRONTIER_SHOW_FACTORY_DOUBLES: + case FRONTIER_SHOW_PIKE: + case FRONTIER_SHOW_ARENA: + case FRONTIER_SHOW_PALACE_SINGLES: + case FRONTIER_SHOW_PALACE_DOUBLES: + case FRONTIER_SHOW_PYRAMID: + species = (&gSaveBlock1Ptr->tvShows[i])->frontier.species3; + DeactivateShowIfNotSeenSpecies(species, i); break; - case TVSHOW_BATTLE_UPDATE: - j = (&gSaveBlock1Ptr->tvShows[i])->battleUpdate.speciesPlayer; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->battleUpdate.speciesOpponent; - sub_80F0B24(j, i); - break; - case TVSHOW_FAN_CLUB_SPECIAL: - break; - case TVSHOW_LILYCOVE_CONTEST_LADY: - break; - case TVSHOW_OFF_AIR: - break; - case TVSHOW_FAN_CLUB_LETTER: - j = (&gSaveBlock1Ptr->tvShows[i])->fanclubLetter.species; - sub_80F0B24(j, i); - break; - case TVSHOW_RECENT_HAPPENINGS: - break; - case TVSHOW_PKMN_FAN_CLUB_OPINIONS: - j = (&gSaveBlock1Ptr->tvShows[i])->fanclubOpinions.species; - sub_80F0B24(j, i); - break; - case TVSHOW_UNKN_SHOWTYPE_04: - j = (&gSaveBlock1Ptr->tvShows[i])->unkShow04.var06; - sub_80F0B24(j, i); - break; - case TVSHOW_NAME_RATER_SHOW: - j = (&gSaveBlock1Ptr->tvShows[i])->nameRaterShow.species; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->nameRaterShow.randomSpecies; - sub_80F0B24(j, i); - break; - case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: - j = (&gSaveBlock1Ptr->tvShows[i])->bravoTrainer.species; - sub_80F0B24(j, i); - break; - case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: - j = (&gSaveBlock1Ptr->tvShows[i])->bravoTrainerTower.species; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->bravoTrainerTower.defeatedSpecies; - sub_80F0B24(j, i); - break; - - case TVSHOW_POKEMON_TODAY_CAUGHT: - j = (&gSaveBlock1Ptr->tvShows[i])->pokemonToday.species; - sub_80F0B24(j, i); - break; - case TVSHOW_SMART_SHOPPER: - break; - case TVSHOW_POKEMON_TODAY_FAILED: - j = (&gSaveBlock1Ptr->tvShows[i])->pokemonTodayFailed.species; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->pokemonTodayFailed.species2; - sub_80F0B24(j, i); - break; - case TVSHOW_FISHING_ADVICE: - j = (&gSaveBlock1Ptr->tvShows[i])->pokemonAngler.species; - sub_80F0B24(j, i); - break; - case TVSHOW_WORLD_OF_MASTERS: - j = (&gSaveBlock1Ptr->tvShows[i])->worldOfMasters.species; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->worldOfMasters.caughtPoke; - sub_80F0B24(j, i); - break; - - case TVSHOW_TODAYS_RIVAL_TRAINER: - break; - case TVSHOW_TREND_WATCHER: - break; - case TVSHOW_TREASURE_INVESTIGATORS: - break; - case TVSHOW_FIND_THAT_GAMER: - break; - case TVSHOW_BREAKING_NEWS: - j = (&gSaveBlock1Ptr->tvShows[i])->breakingNews.lastOpponentSpecies; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->breakingNews.poke1Species; - sub_80F0B24(j, i); - break; - case TVSHOW_SECRET_BASE_VISIT: - j = (&gSaveBlock1Ptr->tvShows[i])->secretBaseVisit.species; - sub_80F0B24(j, i); - break; - case TVSHOW_LOTTO_WINNER: - break; - case TVSHOW_BATTLE_SEMINAR: - j = (&gSaveBlock1Ptr->tvShows[i])->battleSeminar.species; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->battleSeminar.foeSpecies; - sub_80F0B24(j, i); - break; - case TVSHOW_TRAINER_FAN_CLUB: - break; - case TVSHOW_CUTIES: - break; - case TVSHOW_FRONTIER: - j = (&gSaveBlock1Ptr->tvShows[i])->frontier.species1; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->frontier.species2; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->frontier.facility; - switch (j) - { - case 3: - case 4: - break; - case 1: - case 5 ... 13: - j = (&gSaveBlock1Ptr->tvShows[i])->frontier.species3; - sub_80F0B24(j, i); - break; - case 2: - j = (&gSaveBlock1Ptr->tvShows[i])->frontier.species3; - sub_80F0B24(j, i); - j = (&gSaveBlock1Ptr->tvShows[i])->frontier.species4; - sub_80F0B24(j, i); - break; - } - break; - case TVSHOW_NUMBER_ONE: - break; - case TVSHOW_SECRET_BASE_SECRETS: - break; - case TVSHOW_SAFARI_FAN_CLUB: - break; - - case TVSHOW_MASS_OUTBREAK: - break; - - default: - SetTvShowInactive(i); + case FRONTIER_SHOW_TOWER_DOUBLES: + species = (&gSaveBlock1Ptr->tvShows[i])->frontier.species3; + DeactivateShowIfNotSeenSpecies(species, i); + species = (&gSaveBlock1Ptr->tvShows[i])->frontier.species4; + DeactivateShowIfNotSeenSpecies(species, i); break; + } + break; + // Shows with no species + case TVSHOW_OFF_AIR: + case TVSHOW_RECENT_HAPPENINGS: + case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: + case TVSHOW_TODAYS_RIVAL_TRAINER: + case TVSHOW_TREND_WATCHER: + case TVSHOW_TREASURE_INVESTIGATORS: + case TVSHOW_FIND_THAT_GAMER: + case TVSHOW_TRAINER_FAN_CLUB: + case TVSHOW_CUTIES: + case TVSHOW_SMART_SHOPPER: + case TVSHOW_FAN_CLUB_SPECIAL: + case TVSHOW_LILYCOVE_CONTEST_LADY: + case TVSHOW_LOTTO_WINNER: + case TVSHOW_NUMBER_ONE: + case TVSHOW_SECRET_BASE_SECRETS: + case TVSHOW_SAFARI_FAN_CLUB: + case TVSHOW_MASS_OUTBREAK: + break; + default: + DeactivateShow(i); + break; } } } -void SetTvShowInactive(u8 showIdx) +static void DeactivateShow(u8 showIdx) { gSaveBlock1Ptr->tvShows[showIdx].common.active = FALSE; } -static void sub_80F0B24(u16 species, u8 showIdx) +static void DeactivateShowIfNotSeenSpecies(u16 species, u8 showIdx) { if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_SEEN)) - { gSaveBlock1Ptr->tvShows[showIdx].common.active = FALSE; - } } -static void sub_80F0B64(void) +static void DeactivateGameCompleteShowsIfNotUnlocked(void) { u16 i; if (FlagGet(FLAG_SYS_GAME_CLEAR) != TRUE) { - for (i = 0; i < LAST_TVSHOW_IDX; i ++) + for (i = 0; i < LAST_TVSHOW_IDX; i++) { if (gSaveBlock1Ptr->tvShows[i].common.kind == TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE) - { gSaveBlock1Ptr->tvShows[i].common.active = FALSE; - } else if (gSaveBlock1Ptr->tvShows[i].common.kind == TVSHOW_MASS_OUTBREAK) - { gSaveBlock1Ptr->tvShows[i].common.active = FALSE; - } } } } -void sub_80F0BB8(void) +void DeactivateAllNormalTVShows(void) { u8 i; - for (i = 0; i < 5; i ++) + for (i = 0; i < NUM_NORMAL_TVSHOW_SLOTS; i++) { - if (GetTVChannelByShowType(gSaveBlock1Ptr->tvShows[i].common.kind) == 2) - { + if (GetTVGroupByShowId(gSaveBlock1Ptr->tvShows[i].common.kind) == TVGROUP_NORMAL) gSaveBlock1Ptr->tvShows[i].common.active = FALSE; - } } } -static void sub_80F0C04(void) +// Ensures a minimum of 5 empty mixed show slots +static void DeleteExcessMixedShows(void) { s8 i; - s8 ct; - - ct = 0; - for (i = 5; i < LAST_TVSHOW_IDX; i ++) + s8 numEmptyMixSlots = 0; + for (i = NUM_NORMAL_TVSHOW_SLOTS; i < LAST_TVSHOW_IDX; i++) { if (gSaveBlock1Ptr->tvShows[i].common.kind == TVSHOW_OFF_AIR) - { - ct ++; - } - } - for (i = 0; i < 5 - ct; i ++) - { - DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, i + 5); + numEmptyMixSlots++; } + for (i = 0; i < NUM_NORMAL_TVSHOW_SLOTS - numEmptyMixSlots; i++) + DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, i + NUM_NORMAL_TVSHOW_SLOTS); } -void ReceivePokeNewsData(void *src, u32 size, u8 masterIdx) +void ReceivePokeNewsData(void *src, u32 size, u8 playersLinkId) { u8 i; - PokeNews (*rmBuffer2)[4][16]; - PokeNews (*rmBuffer)[4][16]; + PokeNews (*rmBuffer2)[MAX_LINK_PLAYERS][POKE_NEWS_COUNT]; + PokeNews (*rmBuffer)[MAX_LINK_PLAYERS][POKE_NEWS_COUNT]; - rmBuffer2 = malloc(4 * 16 * sizeof(PokeNews)); + rmBuffer2 = malloc(MAX_LINK_PLAYERS * POKE_NEWS_COUNT * sizeof(PokeNews)); if (rmBuffer2 != NULL) { - for (i = 0; i < 4; i ++) - { + for (i = 0; i < MAX_LINK_PLAYERS; i++) memcpy((*rmBuffer2)[i], src + i * size, sizeof((*rmBuffer2)[i])); - } + rmBuffer = rmBuffer2; - switch (masterIdx) + + // Position player's PokeNews in argument list depending on link id + switch (playersLinkId) { - case 0: - sub_80F0D60(gSaveBlock1Ptr->pokeNews, (*rmBuffer)[1], (*rmBuffer)[2], (*rmBuffer)[3]); - break; - case 1: - sub_80F0D60((*rmBuffer)[0], gSaveBlock1Ptr->pokeNews, (*rmBuffer)[2], (*rmBuffer)[3]); - break; - case 2: - sub_80F0D60((*rmBuffer)[0], (*rmBuffer)[1], gSaveBlock1Ptr->pokeNews, (*rmBuffer)[3]); - break; - case 3: - sub_80F0D60((*rmBuffer)[0], (*rmBuffer)[1], (*rmBuffer)[2], gSaveBlock1Ptr->pokeNews); - break; + case 0: + SetMixedPokeNews(gSaveBlock1Ptr->pokeNews, (*rmBuffer)[1], (*rmBuffer)[2], (*rmBuffer)[3]); + break; + case 1: + SetMixedPokeNews((*rmBuffer)[0], gSaveBlock1Ptr->pokeNews, (*rmBuffer)[2], (*rmBuffer)[3]); + break; + case 2: + SetMixedPokeNews((*rmBuffer)[0], (*rmBuffer)[1], gSaveBlock1Ptr->pokeNews, (*rmBuffer)[3]); + break; + case 3: + SetMixedPokeNews((*rmBuffer)[0], (*rmBuffer)[1], (*rmBuffer)[2], gSaveBlock1Ptr->pokeNews); + break; } - sub_80F0EEC(); - sub_80F0F24(); + ClearInvalidPokeNews(); + ClearPokeNewsIfGameNotComplete(); free(rmBuffer2); } } -static void sub_80F0D60(PokeNews player1[16], PokeNews player2[16], PokeNews player3[16], PokeNews player4[16]) +static void SetMixedPokeNews(PokeNews player1[POKE_NEWS_COUNT], PokeNews player2[POKE_NEWS_COUNT], PokeNews player3[POKE_NEWS_COUNT], PokeNews player4[POKE_NEWS_COUNT]) { - u8 i; - u8 j; - u8 k; - PokeNews **argslist[4]; + u8 i, j, k; + PokeNews **pokeNews[MAX_LINK_PLAYERS]; - argslist[0] = &player1; - argslist[1] = &player2; - argslist[2] = &player3; - argslist[3] = &player4; + pokeNews[0] = &player1; + pokeNews[1] = &player2; + pokeNews[2] = &player3; + pokeNews[3] = &player4; sTVShowNewsMixingNumPlayers = GetLinkPlayerCount(); - for (i = 0; i < POKE_NEWS_COUNT; i ++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { - for (j = 0; j < sTVShowNewsMixingNumPlayers; j ++) + for (j = 0; j < sTVShowNewsMixingNumPlayers; j++) { - sTVShowMixingCurSlot = sub_80F0ECC(*argslist[j], i); + sTVShowMixingCurSlot = GetPokeNewsSlotIfActive(*pokeNews[j], i); if (sTVShowMixingCurSlot != -1) { for (k = 0; k < sTVShowNewsMixingNumPlayers - 1; k++) { - sCurTVShowSlot = sub_80EEE30(*argslist[(j + k + 1) % sTVShowNewsMixingNumPlayers]); + sCurTVShowSlot = GetFirstEmptyPokeNewsSlot(*pokeNews[(j + k + 1) % sTVShowNewsMixingNumPlayers]); if (sCurTVShowSlot != -1) - { - sub_80F0E58(argslist[(j + k + 1) % sTVShowNewsMixingNumPlayers], argslist[j]); - } + InitTryMixPokeNewsShow(pokeNews[(j + k + 1) % sTVShowNewsMixingNumPlayers], pokeNews[j]); } } } } } -static void sub_80F0E58(PokeNews *dest[16], PokeNews *src[16]) +static void InitTryMixPokeNewsShow(PokeNews *dest[POKE_NEWS_COUNT], PokeNews *src[POKE_NEWS_COUNT]) { - PokeNews *ptr1; - PokeNews *ptr2; - - ptr1 = *dest; - ptr2 = *src; + PokeNews *ptr1 = *dest; + PokeNews *ptr2 = *src; ptr2 += sTVShowMixingCurSlot; - sub_80F0E84(ptr1, ptr2, sCurTVShowSlot); + TryMixPokeNewsShow(ptr1, ptr2, sCurTVShowSlot); } -static bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot) +static bool8 TryMixPokeNewsShow(PokeNews *dest, PokeNews *src, s8 slot) { u8 i; if (src->kind == POKENEWS_NONE) - { return FALSE; - } - for (i = 0; i < POKE_NEWS_COUNT; i ++) + + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (dest[i].kind == src->kind) - { return FALSE; - } } dest[slot].kind = src->kind; dest[slot].state = 1; @@ -4106,43 +3901,38 @@ static bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot) return TRUE; } -static s8 sub_80F0ECC(PokeNews *pokeNews, u8 idx) +static s8 GetPokeNewsSlotIfActive(PokeNews *pokeNews, u8 idx) { if (pokeNews[idx].kind == POKENEWS_NONE) - { return -1; - } + return idx; } -static void sub_80F0EEC(void) +static void ClearInvalidPokeNews(void) { u8 i; - for (i = 0; i < POKE_NEWS_COUNT; i ++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (gSaveBlock1Ptr->pokeNews[i].kind > POKENEWS_BLENDMASTER) - { - ClearPokemonNewsI(i); - } + ClearPokeNewsBySlot(i); } - sub_80EEEB8(); + CompactPokeNews(); } -static void sub_80F0F24(void) +static void ClearPokeNewsIfGameNotComplete(void) { u8 i; if (FlagGet(FLAG_SYS_GAME_CLEAR) != TRUE) { - for (i = 0; i < POKE_NEWS_COUNT; i ++) - { + for (i = 0; i < POKE_NEWS_COUNT; i++) gSaveBlock1Ptr->pokeNews[i].state = 0; - } } } -#define tvlangfix(strptr, langptr, langfix) \ +#define SetStrLanguage(strptr, langptr, langfix) \ if (IsStringJapanese(strptr)) \ { \ (langptr) = LANGUAGE_JAPANESE; \ @@ -4152,348 +3942,341 @@ else \ (langptr) = langfix; \ } -static void sub_80F0F64(TVShow *show, u32 language) +// Unused +static void TranslateShowNames(TVShow *show, u32 language) { int i; - TVShow **r4; + TVShow **shows; - r4 = calloc(11, sizeof(TVShow *)); - for (i = 0; i < LAST_TVSHOW_IDX; i ++) + shows = calloc(11, sizeof(TVShow *)); + for (i = 0; i < LAST_TVSHOW_IDX; i++) { switch (show[i].common.kind) { - case TVSHOW_FAN_CLUB_LETTER: - case TVSHOW_RECENT_HAPPENINGS: - r4[0] = &show[i]; - tvlangfix(r4[0]->fanclubLetter.playerName, r4[0]->fanclubLetter.language, language); - break; - case TVSHOW_PKMN_FAN_CLUB_OPINIONS: - r4[1] = &show[i]; - tvlangfix(r4[1]->fanclubOpinions.playerName, r4[1]->fanclubOpinions.language, language); - tvlangfix(r4[1]->fanclubOpinions.nickname, r4[1]->fanclubOpinions.pokemonNameLanguage, language); - break; - case TVSHOW_POKEMON_TODAY_CAUGHT: - r4[6] = &show[i]; - tvlangfix(r4[6]->pokemonToday.playerName, r4[6]->pokemonToday.language, language); - tvlangfix(r4[6]->pokemonToday.nickname, r4[6]->pokemonToday.language2, language); - break; - case TVSHOW_SMART_SHOPPER: - r4[7] = &show[i]; - tvlangfix(r4[7]->smartshopperShow.playerName, r4[7]->smartshopperShow.language, language); - break; - case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: - r4[5] = &show[i]; - tvlangfix(r4[5]->bravoTrainerTower.trainerName, r4[5]->bravoTrainerTower.language, language); - tvlangfix(r4[5]->bravoTrainerTower.pokemonName, r4[5]->bravoTrainerTower.pokemonNameLanguage, language); - break; - case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: - r4[4] = &show[i]; - tvlangfix(r4[4]->bravoTrainer.playerName, r4[4]->bravoTrainer.language, language); - tvlangfix(r4[4]->bravoTrainer.pokemonNickname, r4[4]->bravoTrainer.pokemonNameLanguage, language); - break; - case TVSHOW_NAME_RATER_SHOW: - r4[3] = &show[i]; - tvlangfix(r4[3]->nameRaterShow.trainerName, r4[3]->nameRaterShow.language, language); - tvlangfix(r4[3]->nameRaterShow.pokemonName, r4[3]->nameRaterShow.pokemonNameLanguage, language); - break; - case TVSHOW_POKEMON_TODAY_FAILED: - r4[2] = &show[i]; - tvlangfix(r4[2]->pokemonTodayFailed.playerName, r4[2]->pokemonTodayFailed.language, language); - break; - case TVSHOW_FISHING_ADVICE: - r4[8] = &show[i]; - tvlangfix(r4[8]->pokemonAngler.playerName, r4[8]->pokemonAngler.language, language); - break; - case TVSHOW_WORLD_OF_MASTERS: - r4[9] = &show[i]; - tvlangfix(r4[9]->worldOfMasters.playerName, r4[9]->worldOfMasters.language, language); - break; - case TVSHOW_MASS_OUTBREAK: - r4[10] = &show[i]; - r4[10]->massOutbreak.language = language; - break; + case TVSHOW_FAN_CLUB_LETTER: + case TVSHOW_RECENT_HAPPENINGS: // NOTE: These two shows are assumed to have the same struct layout + shows[0] = &show[i]; + SetStrLanguage(shows[0]->fanclubLetter.playerName, shows[0]->fanclubLetter.language, language); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + shows[1] = &show[i]; + SetStrLanguage(shows[1]->fanclubOpinions.playerName, shows[1]->fanclubOpinions.language, language); + SetStrLanguage(shows[1]->fanclubOpinions.nickname, shows[1]->fanclubOpinions.pokemonNameLanguage, language); + break; + case TVSHOW_POKEMON_TODAY_CAUGHT: + shows[6] = &show[i]; + SetStrLanguage(shows[6]->pokemonToday.playerName, shows[6]->pokemonToday.language, language); + SetStrLanguage(shows[6]->pokemonToday.nickname, shows[6]->pokemonToday.language2, language); + break; + case TVSHOW_SMART_SHOPPER: + shows[7] = &show[i]; + SetStrLanguage(shows[7]->smartshopperShow.playerName, shows[7]->smartshopperShow.language, language); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + shows[5] = &show[i]; + SetStrLanguage(shows[5]->bravoTrainerTower.trainerName, shows[5]->bravoTrainerTower.language, language); + SetStrLanguage(shows[5]->bravoTrainerTower.pokemonName, shows[5]->bravoTrainerTower.pokemonNameLanguage, language); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + shows[4] = &show[i]; + SetStrLanguage(shows[4]->bravoTrainer.playerName, shows[4]->bravoTrainer.language, language); + SetStrLanguage(shows[4]->bravoTrainer.pokemonNickname, shows[4]->bravoTrainer.pokemonNameLanguage, language); + break; + case TVSHOW_NAME_RATER_SHOW: + shows[3] = &show[i]; + SetStrLanguage(shows[3]->nameRaterShow.trainerName, shows[3]->nameRaterShow.language, language); + SetStrLanguage(shows[3]->nameRaterShow.pokemonName, shows[3]->nameRaterShow.pokemonNameLanguage, language); + break; + case TVSHOW_POKEMON_TODAY_FAILED: + shows[2] = &show[i]; + SetStrLanguage(shows[2]->pokemonTodayFailed.playerName, shows[2]->pokemonTodayFailed.language, language); + break; + case TVSHOW_FISHING_ADVICE: + shows[8] = &show[i]; + SetStrLanguage(shows[8]->pokemonAngler.playerName, shows[8]->pokemonAngler.language, language); + break; + case TVSHOW_WORLD_OF_MASTERS: + shows[9] = &show[i]; + SetStrLanguage(shows[9]->worldOfMasters.playerName, shows[9]->worldOfMasters.language, language); + break; + case TVSHOW_MASS_OUTBREAK: + shows[10] = &show[i]; + shows[10]->massOutbreak.language = language; + break; } } - free(r4); + free(shows); } -void sub_80F1208(TVShow *shows) +void SanitizeTVShowsForRuby(TVShow *shows) { TVShow *curShow; - sub_80F14F8(shows); - for (curShow = shows; curShow < shows + LAST_TVSHOW_IDX; curShow ++) + SanitizeTVShowLocationsForRuby(shows); + for (curShow = shows; curShow < shows + LAST_TVSHOW_IDX; curShow++) { if (curShow->bravoTrainerTower.kind == TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE) { - if ((curShow->bravoTrainerTower.language == LANGUAGE_JAPANESE && curShow->bravoTrainerTower.pokemonNameLanguage != LANGUAGE_JAPANESE) || (curShow->bravoTrainerTower.language != LANGUAGE_JAPANESE && curShow->bravoTrainerTower.pokemonNameLanguage == LANGUAGE_JAPANESE)) - { + if ((curShow->bravoTrainerTower.language == LANGUAGE_JAPANESE && curShow->bravoTrainerTower.pokemonNameLanguage != LANGUAGE_JAPANESE) + || (curShow->bravoTrainerTower.language != LANGUAGE_JAPANESE && curShow->bravoTrainerTower.pokemonNameLanguage == LANGUAGE_JAPANESE)) memset(curShow, 0, sizeof(TVShow)); - } } } } -static void sub_80F1254(TVShow *shows) +static void TranslateRubyShows(TVShow *shows) { TVShow *curShow; - for (curShow = shows; curShow < shows + LAST_TVSHOW_IDX; curShow ++) + for (curShow = shows; curShow < shows + LAST_TVSHOW_IDX; curShow++) { if (curShow->bravoTrainerTower.kind == TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE) { if (IsStringJapanese(curShow->bravoTrainerTower.pokemonName)) - { curShow->bravoTrainerTower.pokemonNameLanguage = LANGUAGE_JAPANESE; - } else - { curShow->bravoTrainerTower.pokemonNameLanguage = GAME_LANGUAGE; - } } } } -u8 TV_GetStringLanguage(u8 *str) +static u8 GetStringLanguage(u8 *str) { return IsStringJapanese(str) ? LANGUAGE_JAPANESE : GAME_LANGUAGE; } -static void sub_80F12A4(TVShow *shows) +static void TranslateJapaneseEmeraldShows(TVShow *shows) { TVShow *curShow; - for (curShow = shows; curShow < shows + LAST_TVSHOW_IDX; curShow ++) + for (curShow = shows; curShow < shows + LAST_TVSHOW_IDX; curShow++) { switch(curShow->common.kind) { - case TVSHOW_FAN_CLUB_LETTER: - curShow->fanclubLetter.language = TV_GetStringLanguage(curShow->fanclubLetter.playerName); - break; - case TVSHOW_RECENT_HAPPENINGS: - curShow->recentHappenings.language = TV_GetStringLanguage(curShow->recentHappenings.playerName); - break; - case TVSHOW_PKMN_FAN_CLUB_OPINIONS: - curShow->fanclubOpinions.language = TV_GetStringLanguage(curShow->fanclubOpinions.playerName); - curShow->fanclubOpinions.pokemonNameLanguage = TV_GetStringLanguage(curShow->fanclubOpinions.nickname); - break; - case TVSHOW_UNKN_SHOWTYPE_04: - curShow->unkShow04.language = TV_GetStringLanguage(curShow->unkShow04.string_0b); - break; - case TVSHOW_NAME_RATER_SHOW: - curShow->nameRaterShow.language = TV_GetStringLanguage(curShow->nameRaterShow.trainerName); - curShow->nameRaterShow.pokemonNameLanguage = TV_GetStringLanguage(curShow->nameRaterShow.pokemonName); - break; - case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: - curShow->bravoTrainer.language = TV_GetStringLanguage(curShow->bravoTrainer.playerName); - curShow->bravoTrainer.pokemonNameLanguage = TV_GetStringLanguage(curShow->bravoTrainer.pokemonNickname); - break; - case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: - curShow->bravoTrainerTower.language = TV_GetStringLanguage(curShow->bravoTrainerTower.trainerName); - curShow->bravoTrainerTower.pokemonNameLanguage = TV_GetStringLanguage(curShow->bravoTrainerTower.pokemonName); - break; - case TVSHOW_CONTEST_LIVE_UPDATES: - curShow->contestLiveUpdates.winningTrainerLanguage = TV_GetStringLanguage(curShow->contestLiveUpdates.winningTrainerName); - curShow->contestLiveUpdates.losingTrainerLanguage = TV_GetStringLanguage(curShow->contestLiveUpdates.losingTrainerName); - break; - case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: - curShow->threeCheers.language = TV_GetStringLanguage(curShow->threeCheers.playerName); - curShow->threeCheers.worstBlenderLanguage = TV_GetStringLanguage(curShow->threeCheers.worstBlenderName); - break; - case TVSHOW_BATTLE_UPDATE: - curShow->battleUpdate.language = TV_GetStringLanguage(curShow->battleUpdate.playerName); - curShow->battleUpdate.linkOpponentLanguage = TV_GetStringLanguage(curShow->battleUpdate.linkOpponentName); - break; - case TVSHOW_FAN_CLUB_SPECIAL: - curShow->fanClubSpecial.language = TV_GetStringLanguage(curShow->fanClubSpecial.playerName); - curShow->fanClubSpecial.idolNameLanguage = TV_GetStringLanguage(curShow->fanClubSpecial.idolName); - break; - case TVSHOW_LILYCOVE_CONTEST_LADY: - curShow->contestLady.language = TV_GetStringLanguage(curShow->contestLady.playerName); - curShow->contestLady.pokemonNameLanguage = TV_GetStringLanguage(curShow->contestLady.nickname); - break; - case TVSHOW_POKEMON_TODAY_CAUGHT: - curShow->pokemonToday.language = TV_GetStringLanguage(curShow->pokemonToday.playerName); - curShow->pokemonToday.language2 = TV_GetStringLanguage(curShow->pokemonToday.nickname); - break; - case TVSHOW_SMART_SHOPPER: - curShow->smartshopperShow.language = TV_GetStringLanguage(curShow->smartshopperShow.playerName); - break; - case TVSHOW_POKEMON_TODAY_FAILED: - curShow->pokemonTodayFailed.language = TV_GetStringLanguage(curShow->pokemonTodayFailed.playerName); - break; - case TVSHOW_FISHING_ADVICE: - curShow->pokemonAngler.language = TV_GetStringLanguage(curShow->pokemonAngler.playerName); - break; - case TVSHOW_WORLD_OF_MASTERS: - curShow->worldOfMasters.language = TV_GetStringLanguage(curShow->worldOfMasters.playerName); - break; - case TVSHOW_TREND_WATCHER: - curShow->trendWatcher.language = TV_GetStringLanguage(curShow->trendWatcher.playerName); - break; - case TVSHOW_BREAKING_NEWS: - curShow->breakingNews.language = TV_GetStringLanguage(curShow->breakingNews.playerName); - break; - case TVSHOW_BATTLE_SEMINAR: - curShow->battleSeminar.language = TV_GetStringLanguage(curShow->battleSeminar.playerName); - break; - case TVSHOW_FIND_THAT_GAMER: - case TVSHOW_TRAINER_FAN_CLUB: - curShow->trainerFanClub.language = TV_GetStringLanguage(curShow->trainerFanClub.playerName); - break; - case TVSHOW_CUTIES: - curShow->cuties.language = TV_GetStringLanguage(curShow->cuties.playerName); - curShow->cuties.pokemonNameLanguage = TV_GetStringLanguage(curShow->cuties.nickname); - break; - case TVSHOW_TODAYS_RIVAL_TRAINER: - case TVSHOW_SECRET_BASE_VISIT: - case TVSHOW_FRONTIER: - curShow->rivalTrainer.language = TV_GetStringLanguage(curShow->rivalTrainer.playerName); - break; - case TVSHOW_TREASURE_INVESTIGATORS: - case TVSHOW_LOTTO_WINNER: - case TVSHOW_NUMBER_ONE: - curShow->treasureInvestigators.language = TV_GetStringLanguage(curShow->treasureInvestigators.playerName); - break; - case TVSHOW_SECRET_BASE_SECRETS: - curShow->secretBaseSecrets.language = TV_GetStringLanguage(curShow->secretBaseSecrets.playerName); - curShow->secretBaseSecrets.baseOwnersNameLanguage = TV_GetStringLanguage(curShow->secretBaseSecrets.baseOwnersName); - break; - case TVSHOW_SAFARI_FAN_CLUB: - curShow->safariFanClub.language = TV_GetStringLanguage(curShow->safariFanClub.playerName); - break; - case TVSHOW_MASS_OUTBREAK: - break; + case TVSHOW_FAN_CLUB_LETTER: + curShow->fanclubLetter.language = GetStringLanguage(curShow->fanclubLetter.playerName); + break; + case TVSHOW_RECENT_HAPPENINGS: + curShow->recentHappenings.language = GetStringLanguage(curShow->recentHappenings.playerName); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + curShow->fanclubOpinions.language = GetStringLanguage(curShow->fanclubOpinions.playerName); + curShow->fanclubOpinions.pokemonNameLanguage = GetStringLanguage(curShow->fanclubOpinions.nickname); + break; + case TVSHOW_DUMMY: + curShow->dummy.language = GetStringLanguage(curShow->dummy.name); + break; + case TVSHOW_NAME_RATER_SHOW: + curShow->nameRaterShow.language = GetStringLanguage(curShow->nameRaterShow.trainerName); + curShow->nameRaterShow.pokemonNameLanguage = GetStringLanguage(curShow->nameRaterShow.pokemonName); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + curShow->bravoTrainer.language = GetStringLanguage(curShow->bravoTrainer.playerName); + curShow->bravoTrainer.pokemonNameLanguage = GetStringLanguage(curShow->bravoTrainer.pokemonNickname); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + curShow->bravoTrainerTower.language = GetStringLanguage(curShow->bravoTrainerTower.trainerName); + curShow->bravoTrainerTower.pokemonNameLanguage = GetStringLanguage(curShow->bravoTrainerTower.pokemonName); + break; + case TVSHOW_CONTEST_LIVE_UPDATES: + curShow->contestLiveUpdates.winningTrainerLanguage = GetStringLanguage(curShow->contestLiveUpdates.winningTrainerName); + curShow->contestLiveUpdates.losingTrainerLanguage = GetStringLanguage(curShow->contestLiveUpdates.losingTrainerName); + break; + case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: + curShow->threeCheers.language = GetStringLanguage(curShow->threeCheers.playerName); + curShow->threeCheers.worstBlenderLanguage = GetStringLanguage(curShow->threeCheers.worstBlenderName); + break; + case TVSHOW_BATTLE_UPDATE: + curShow->battleUpdate.language = GetStringLanguage(curShow->battleUpdate.playerName); + curShow->battleUpdate.linkOpponentLanguage = GetStringLanguage(curShow->battleUpdate.linkOpponentName); + break; + case TVSHOW_FAN_CLUB_SPECIAL: + curShow->fanClubSpecial.language = GetStringLanguage(curShow->fanClubSpecial.playerName); + curShow->fanClubSpecial.idolNameLanguage = GetStringLanguage(curShow->fanClubSpecial.idolName); + break; + case TVSHOW_LILYCOVE_CONTEST_LADY: + curShow->contestLady.language = GetStringLanguage(curShow->contestLady.playerName); + curShow->contestLady.pokemonNameLanguage = GetStringLanguage(curShow->contestLady.nickname); + break; + case TVSHOW_POKEMON_TODAY_CAUGHT: + curShow->pokemonToday.language = GetStringLanguage(curShow->pokemonToday.playerName); + curShow->pokemonToday.language2 = GetStringLanguage(curShow->pokemonToday.nickname); + break; + case TVSHOW_SMART_SHOPPER: + curShow->smartshopperShow.language = GetStringLanguage(curShow->smartshopperShow.playerName); + break; + case TVSHOW_POKEMON_TODAY_FAILED: + curShow->pokemonTodayFailed.language = GetStringLanguage(curShow->pokemonTodayFailed.playerName); + break; + case TVSHOW_FISHING_ADVICE: + curShow->pokemonAngler.language = GetStringLanguage(curShow->pokemonAngler.playerName); + break; + case TVSHOW_WORLD_OF_MASTERS: + curShow->worldOfMasters.language = GetStringLanguage(curShow->worldOfMasters.playerName); + break; + case TVSHOW_TREND_WATCHER: + curShow->trendWatcher.language = GetStringLanguage(curShow->trendWatcher.playerName); + break; + case TVSHOW_BREAKING_NEWS: + curShow->breakingNews.language = GetStringLanguage(curShow->breakingNews.playerName); + break; + case TVSHOW_BATTLE_SEMINAR: + curShow->battleSeminar.language = GetStringLanguage(curShow->battleSeminar.playerName); + break; + case TVSHOW_FIND_THAT_GAMER: + case TVSHOW_TRAINER_FAN_CLUB: + curShow->trainerFanClub.language = GetStringLanguage(curShow->trainerFanClub.playerName); + break; + case TVSHOW_CUTIES: + curShow->cuties.language = GetStringLanguage(curShow->cuties.playerName); + curShow->cuties.pokemonNameLanguage = GetStringLanguage(curShow->cuties.nickname); + break; + case TVSHOW_TODAYS_RIVAL_TRAINER: + case TVSHOW_SECRET_BASE_VISIT: + case TVSHOW_FRONTIER: + curShow->rivalTrainer.language = GetStringLanguage(curShow->rivalTrainer.playerName); + break; + case TVSHOW_TREASURE_INVESTIGATORS: + case TVSHOW_LOTTO_WINNER: + case TVSHOW_NUMBER_ONE: + curShow->treasureInvestigators.language = GetStringLanguage(curShow->treasureInvestigators.playerName); + break; + case TVSHOW_SECRET_BASE_SECRETS: + curShow->secretBaseSecrets.language = GetStringLanguage(curShow->secretBaseSecrets.playerName); + curShow->secretBaseSecrets.baseOwnersNameLanguage = GetStringLanguage(curShow->secretBaseSecrets.baseOwnersName); + break; + case TVSHOW_SAFARI_FAN_CLUB: + curShow->safariFanClub.language = GetStringLanguage(curShow->safariFanClub.playerName); + break; + case TVSHOW_MASS_OUTBREAK: + break; } } } -void sub_80F14F8(TVShow *shows) +void SanitizeTVShowLocationsForRuby(TVShow *shows) { int i; - for (i = 0; i < LAST_TVSHOW_IDX; i ++) + for (i = 0; i < LAST_TVSHOW_IDX; i++) { switch (shows[i].common.kind) { - case TVSHOW_WORLD_OF_MASTERS: - if (shows[i].worldOfMasters.location > KANTO_MAPSEC_START) - { - memset(&shows[i], 0, sizeof(TVShow)); - } - break; - case TVSHOW_POKEMON_TODAY_FAILED: - if (shows[i].pokemonTodayFailed.location > KANTO_MAPSEC_START) - { - memset(&shows[i], 0, sizeof(TVShow)); - } - break; + case TVSHOW_WORLD_OF_MASTERS: + if (shows[i].worldOfMasters.location > KANTO_MAPSEC_START) + memset(&shows[i], 0, sizeof(TVShow)); + break; + case TVSHOW_POKEMON_TODAY_FAILED: + if (shows[i].pokemonTodayFailed.location > KANTO_MAPSEC_START) + memset(&shows[i], 0, sizeof(TVShow)); + break; } } } +// gSpecialVar_0x8004 here is set from GetRandomActiveShowIdx in EventScript_TryDoTVShow void DoTVShow(void) { if (gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004].common.active) { switch (gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004].common.kind) { - case TVSHOW_FAN_CLUB_LETTER: - DoTVShowPokemonFanClubLetter(); - break; - case TVSHOW_RECENT_HAPPENINGS: - DoTVShowRecentHappenings(); - break; - case TVSHOW_PKMN_FAN_CLUB_OPINIONS: - DoTVShowPokemonFanClubOpinions(); - break; - case TVSHOW_UNKN_SHOWTYPE_04: - DoTVShowDummiedOut(); - break; - case TVSHOW_MASS_OUTBREAK: - DoTVShowPokemonNewsMassOutbreak(); - break; - case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: - DoTVShowBravoTrainerPokemonProfile(); - break; - case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: - DoTVShowBravoTrainerBattleTower(); - break; - case TVSHOW_POKEMON_TODAY_CAUGHT: - DoTVShowPokemonTodaySuccessfulCapture(); - break; - case TVSHOW_SMART_SHOPPER: - DoTVShowTodaysSmartShopper(); - break; - case TVSHOW_NAME_RATER_SHOW: - DoTVShowTheNameRaterShow(); - break; - case TVSHOW_CONTEST_LIVE_UPDATES: - DoTVShowPokemonContestLiveUpdates(); - break; - case TVSHOW_BATTLE_UPDATE: - DoTVShowPokemonBattleUpdate(); - break; - case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: - DoTVShow3CheersForPokeblocks(); - break; - case TVSHOW_POKEMON_TODAY_FAILED: - DoTVShowPokemonTodayFailedCapture(); - break; - case TVSHOW_FISHING_ADVICE: - DoTVShowPokemonAngler(); - break; - case TVSHOW_WORLD_OF_MASTERS: - DoTVShowTheWorldOfMasters(); - break; - case TVSHOW_TODAYS_RIVAL_TRAINER: - DoTVShowTodaysRivalTrainer(); - break; - case TVSHOW_TREND_WATCHER: - DoTVShowDewfordTrendWatcherNetwork(); - break; - case TVSHOW_TREASURE_INVESTIGATORS: - DoTVShowHoennTreasureInvestigators(); - break; - case TVSHOW_FIND_THAT_GAMER: - DoTVShowFindThatGamer(); - break; - case TVSHOW_BREAKING_NEWS: - DoTVShowBreakingNewsTV(); - break; - case TVSHOW_SECRET_BASE_VISIT: - DoTVShowSecretBaseVisit(); - break; - case TVSHOW_LOTTO_WINNER: - DoTVShowPokemonLotteryWinnerFlashReport(); - break; - case TVSHOW_BATTLE_SEMINAR: - DoTVShowThePokemonBattleSeminar(); - break; - case TVSHOW_FAN_CLUB_SPECIAL: - DoTVShowTrainerFanClubSpecial(); - break; - case TVSHOW_TRAINER_FAN_CLUB: - DoTVShowTrainerFanClub(); - break; - case TVSHOW_CUTIES: - DoTVShowSpotTheCuties(); - break; - case TVSHOW_FRONTIER: - DoTVShowPokemonNewsBattleFrontier(); - break; - case TVSHOW_NUMBER_ONE: - DoTVShowWhatsNo1InHoennToday(); - break; - case TVSHOW_SECRET_BASE_SECRETS: - DoTVShowSecretBaseSecrets(); - break; - case TVSHOW_SAFARI_FAN_CLUB: - DoTVShowSafariFanClub(); - break; - case TVSHOW_LILYCOVE_CONTEST_LADY: - DoTVShowLilycoveContestLady(); - break; + case TVSHOW_FAN_CLUB_LETTER: + DoTVShowPokemonFanClubLetter(); + break; + case TVSHOW_RECENT_HAPPENINGS: + DoTVShowRecentHappenings(); + break; + case TVSHOW_PKMN_FAN_CLUB_OPINIONS: + DoTVShowPokemonFanClubOpinions(); + break; + case TVSHOW_DUMMY: + DoTVShowDummiedOut(); + break; + case TVSHOW_MASS_OUTBREAK: + DoTVShowPokemonNewsMassOutbreak(); + break; + case TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE: + DoTVShowBravoTrainerPokemonProfile(); + break; + case TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE: + DoTVShowBravoTrainerBattleTower(); + break; + case TVSHOW_POKEMON_TODAY_CAUGHT: + DoTVShowPokemonTodaySuccessfulCapture(); + break; + case TVSHOW_SMART_SHOPPER: + DoTVShowTodaysSmartShopper(); + break; + case TVSHOW_NAME_RATER_SHOW: + DoTVShowTheNameRaterShow(); + break; + case TVSHOW_CONTEST_LIVE_UPDATES: + DoTVShowPokemonContestLiveUpdates(); + break; + case TVSHOW_BATTLE_UPDATE: + DoTVShowPokemonBattleUpdate(); + break; + case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: + DoTVShow3CheersForPokeblocks(); + break; + case TVSHOW_POKEMON_TODAY_FAILED: + DoTVShowPokemonTodayFailedCapture(); + break; + case TVSHOW_FISHING_ADVICE: + DoTVShowPokemonAngler(); + break; + case TVSHOW_WORLD_OF_MASTERS: + DoTVShowTheWorldOfMasters(); + break; + case TVSHOW_TODAYS_RIVAL_TRAINER: + DoTVShowTodaysRivalTrainer(); + break; + case TVSHOW_TREND_WATCHER: + DoTVShowDewfordTrendWatcherNetwork(); + break; + case TVSHOW_TREASURE_INVESTIGATORS: + DoTVShowHoennTreasureInvestigators(); + break; + case TVSHOW_FIND_THAT_GAMER: + DoTVShowFindThatGamer(); + break; + case TVSHOW_BREAKING_NEWS: + DoTVShowBreakingNewsTV(); + break; + case TVSHOW_SECRET_BASE_VISIT: + DoTVShowSecretBaseVisit(); + break; + case TVSHOW_LOTTO_WINNER: + DoTVShowPokemonLotteryWinnerFlashReport(); + break; + case TVSHOW_BATTLE_SEMINAR: + DoTVShowThePokemonBattleSeminar(); + break; + case TVSHOW_FAN_CLUB_SPECIAL: + DoTVShowTrainerFanClubSpecial(); + break; + case TVSHOW_TRAINER_FAN_CLUB: + DoTVShowTrainerFanClub(); + break; + case TVSHOW_CUTIES: + DoTVShowSpotTheCuties(); + break; + case TVSHOW_FRONTIER: + DoTVShowPokemonNewsBattleFrontier(); + break; + case TVSHOW_NUMBER_ONE: + DoTVShowWhatsNo1InHoennToday(); + break; + case TVSHOW_SECRET_BASE_SECRETS: + DoTVShowSecretBaseSecrets(); + break; + case TVSHOW_SAFARI_FAN_CLUB: + DoTVShowSafariFanClub(); + break; + case TVSHOW_LILYCOVE_CONTEST_LADY: + DoTVShowLilycoveContestLady(); + break; } } } @@ -4508,64 +4291,64 @@ static void DoTVShowBravoTrainerPokemonProfile(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); - CopyContestCategoryToStringVar(1, show->bravoTrainer.contestCategory); - CopyContestRankToStringVar(2, show->bravoTrainer.contestRank); - if (!StringCompare(gSpeciesNames[show->bravoTrainer.species], show->bravoTrainer.pokemonNickname)) - sTVShowState = 8; - else - sTVShowState = 1; - break; - case 1: - StringCopy(gStringVar1, gSpeciesNames[show->bravoTrainer.species]); - TVShowConvertInternationalString(gStringVar2, show->bravoTrainer.pokemonNickname, show->bravoTrainer.pokemonNameLanguage); - CopyContestCategoryToStringVar(2, show->bravoTrainer.contestCategory); - sTVShowState = 2; - break; - case 2: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); - if (show->bravoTrainer.contestResult == 0) // placed first - sTVShowState = 3; - else - sTVShowState = 4; - break; - case 3: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); - CopyEasyChatWord(gStringVar2, show->bravoTrainer.words[0]); - TV_PrintIntToStringVar(2, show->bravoTrainer.contestResult + 1); - sTVShowState = 5; - break; - case 4: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); - CopyEasyChatWord(gStringVar2, show->bravoTrainer.words[0]); - TV_PrintIntToStringVar(2, show->bravoTrainer.contestResult + 1); - sTVShowState = 5; - break; - case 5: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); - CopyContestCategoryToStringVar(1, show->bravoTrainer.contestCategory); - CopyEasyChatWord(gStringVar3, show->bravoTrainer.words[1]); - if (show->bravoTrainer.move) - sTVShowState = 6; - else - sTVShowState = 7; - break; - case 6: - StringCopy(gStringVar1, gSpeciesNames[show->bravoTrainer.species]); - StringCopy(gStringVar2, gMoveNames[show->bravoTrainer.move]); - CopyEasyChatWord(gStringVar3, show->bravoTrainer.words[1]); + case 0: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); + CopyContestCategoryToStringVar(1, show->bravoTrainer.contestCategory); + CopyContestRankToStringVar(2, show->bravoTrainer.contestRank); + if (!StringCompare(gSpeciesNames[show->bravoTrainer.species], show->bravoTrainer.pokemonNickname)) + sTVShowState = 8; + else + sTVShowState = 1; + break; + case 1: + StringCopy(gStringVar1, gSpeciesNames[show->bravoTrainer.species]); + TVShowConvertInternationalString(gStringVar2, show->bravoTrainer.pokemonNickname, show->bravoTrainer.pokemonNameLanguage); + CopyContestCategoryToStringVar(2, show->bravoTrainer.contestCategory); + sTVShowState = 2; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); + if (show->bravoTrainer.contestResult == 0) // placed first + sTVShowState = 3; + else + sTVShowState = 4; + break; + case 3: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); + CopyEasyChatWord(gStringVar2, show->bravoTrainer.words[0]); + ConvertIntToDecimalString(2, show->bravoTrainer.contestResult + 1); + sTVShowState = 5; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); + CopyEasyChatWord(gStringVar2, show->bravoTrainer.words[0]); + ConvertIntToDecimalString(2, show->bravoTrainer.contestResult + 1); + sTVShowState = 5; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); + CopyContestCategoryToStringVar(1, show->bravoTrainer.contestCategory); + CopyEasyChatWord(gStringVar3, show->bravoTrainer.words[1]); + if (show->bravoTrainer.move) + sTVShowState = 6; + else sTVShowState = 7; - break; - case 7: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); - StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainer.species]); - TVShowDone(); - break; - case 8: - StringCopy(gStringVar1, gSpeciesNames[show->bravoTrainer.species]); - sTVShowState = 2; - break; + break; + case 6: + StringCopy(gStringVar1, gSpeciesNames[show->bravoTrainer.species]); + StringCopy(gStringVar2, gMoveNames[show->bravoTrainer.move]); + CopyEasyChatWord(gStringVar3, show->bravoTrainer.words[1]); + sTVShowState = 7; + break; + case 7: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainer.playerName, show->bravoTrainer.language); + StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainer.species]); + TVShowDone(); + break; + case 8: + StringCopy(gStringVar1, gSpeciesNames[show->bravoTrainer.species]); + sTVShowState = 2; + break; } ShowFieldMessage(sTVBravoTrainerTextGroup[state]); } @@ -4580,89 +4363,89 @@ static void DoTVShowBravoTrainerBattleTower(void) state = sTVShowState; switch(state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); - StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]); - if (show->bravoTrainerTower.numFights >= 7) - sTVShowState = 1; - else - sTVShowState = 2; - break; - case 1: - if (show->bravoTrainerTower.btLevel == 50) - { - StringCopy(gStringVar1, gText_Lv50); - } - else - { - StringCopy(gStringVar1, gText_OpenLevel); - } - TV_PrintIntToStringVar(1, show->bravoTrainerTower.numFights); - if (show->bravoTrainerTower.wonTheChallenge == TRUE) - sTVShowState = 3; - else - sTVShowState = 4; - break; - case 2: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - TV_PrintIntToStringVar(1, show->bravoTrainerTower.numFights + 1); - if (show->bravoTrainerTower.interviewResponse == 0) - sTVShowState = 5; - else - sTVShowState = 6; - break; - case 3: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]); - if (show->bravoTrainerTower.interviewResponse == 0) - sTVShowState = 5; - else - sTVShowState = 6; - break; - case 4: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]); - if (show->bravoTrainerTower.interviewResponse == 0) - sTVShowState = 5; - else - sTVShowState = 6; - break; - case 5: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - sTVShowState = 11; - break; - case 6: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - sTVShowState = 11; - break; - case 7: - sTVShowState = 11; - break; - case 8: - case 9: - case 10: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); - sTVShowState = 11; - break; - case 11: - CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]); - if (show->bravoTrainerTower.interviewResponse == 0) - sTVShowState = 12; - else - sTVShowState = 13; - break; - case 12: - case 13: - CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]); - TVShowConvertInternationalString(gStringVar2, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); - TVShowConvertInternationalString(gStringVar3, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); - sTVShowState = 14; - break; - case 14: - TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); - StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]); - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); + StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]); + if (show->bravoTrainerTower.numFights >= 7) + sTVShowState = 1; + else + sTVShowState = 2; + break; + case 1: + if (show->bravoTrainerTower.btLevel == 50) + { + StringCopy(gStringVar1, gText_Lv50); + } + else + { + StringCopy(gStringVar1, gText_OpenLevel); + } + ConvertIntToDecimalString(1, show->bravoTrainerTower.numFights); + if (show->bravoTrainerTower.wonTheChallenge == TRUE) + sTVShowState = 3; + else + sTVShowState = 4; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); + ConvertIntToDecimalString(1, show->bravoTrainerTower.numFights + 1); + if (show->bravoTrainerTower.interviewResponse == 0) + sTVShowState = 5; + else + sTVShowState = 6; + break; + case 3: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); + StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]); + if (show->bravoTrainerTower.interviewResponse == 0) + sTVShowState = 5; + else + sTVShowState = 6; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); + StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.defeatedSpecies]); + if (show->bravoTrainerTower.interviewResponse == 0) + sTVShowState = 5; + else + sTVShowState = 6; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); + sTVShowState = 11; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); + sTVShowState = 11; + break; + case 7: + sTVShowState = 11; + break; + case 8: + case 9: + case 10: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); + sTVShowState = 11; + break; + case 11: + CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]); + if (show->bravoTrainerTower.interviewResponse == 0) + sTVShowState = 12; + else + sTVShowState = 13; + break; + case 12: + case 13: + CopyEasyChatWord(gStringVar1, show->bravoTrainerTower.words[0]); + TVShowConvertInternationalString(gStringVar2, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); + TVShowConvertInternationalString(gStringVar3, show->bravoTrainerTower.pokemonName, show->bravoTrainerTower.pokemonNameLanguage); + sTVShowState = 14; + break; + case 14: + TVShowConvertInternationalString(gStringVar1, show->bravoTrainerTower.trainerName, show->bravoTrainerTower.language); + StringCopy(gStringVar2, gSpeciesNames[show->bravoTrainerTower.species]); + TVShowDone(); + break; } ShowFieldMessage(sTVBravoTrainerBattleTowerTextGroup[state]); } @@ -4677,115 +4460,81 @@ static void DoTVShowTodaysSmartShopper(void) state = sTVShowState; switch(state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language); - GetMapName(gStringVar2, show->smartshopperShow.shopLocation, 0); - if (show->smartshopperShow.itemAmounts[0] >= 255) - { - sTVShowState = 11; - } - else - { - sTVShowState = 1; - } - break; - case 1: - TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language); - StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[0])); - TV_PrintIntToStringVar(2, show->smartshopperShow.itemAmounts[0]); - sTVShowState += 1 + (Random() % 4); - break; - case 2: - case 4: - case 5: - if (show->smartshopperShow.itemIds[1] != ITEM_NONE) - { - sTVShowState = 6; - } - else - { - sTVShowState = 10; - } - break; - case 3: - TV_PrintIntToStringVar(2, show->smartshopperShow.itemAmounts[0] + 1); - if (show->smartshopperShow.itemIds[1] != ITEM_NONE) - { - sTVShowState = 6; - } - else - { - sTVShowState = 10; - } - break; - case 6: - StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[1])); - TV_PrintIntToStringVar(2, show->smartshopperShow.itemAmounts[1]); - if (show->smartshopperShow.itemIds[2] != ITEM_NONE) - { - sTVShowState = 7; - } - else if (show->smartshopperShow.priceReduced == TRUE) - { - sTVShowState = 8; - } - else - { - sTVShowState = 9; - } - break; - case 7: - StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[2])); - TV_PrintIntToStringVar(2, show->smartshopperShow.itemAmounts[2]); - if (show->smartshopperShow.priceReduced == TRUE) - { - sTVShowState = 8; - } - else - { - sTVShowState = 9; - } - break; - case 8: - if (show->smartshopperShow.itemAmounts[0] >= 255) - { - sTVShowState = 12; - } - else - { - sTVShowState = 9; - } - break; - case 9: - sub_80EF40C(1, show); - TVShowDone(); - break; - case 10: - if (show->smartshopperShow.priceReduced == TRUE) - { - sTVShowState = 8; - } - else - { - sTVShowState = 9; - } - break; - case 11: - TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language); - StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[0])); - if (show->smartshopperShow.priceReduced == TRUE) - { - sTVShowState = 8; - } - else - { - sTVShowState = 12; - } - break; - case 12: - TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language); - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language); + GetMapName(gStringVar2, show->smartshopperShow.shopLocation, 0); + if (show->smartshopperShow.itemAmounts[0] >= 255) + sTVShowState = 11; + else + sTVShowState = 1; + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language); + StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[0])); + ConvertIntToDecimalString(2, show->smartshopperShow.itemAmounts[0]); + sTVShowState += 1 + (Random() % 4); + break; + case 2: + case 4: + case 5: + if (show->smartshopperShow.itemIds[1] != ITEM_NONE) + sTVShowState = 6; + else + sTVShowState = 10; + break; + case 3: + ConvertIntToDecimalString(2, show->smartshopperShow.itemAmounts[0] + 1); + if (show->smartshopperShow.itemIds[1] != ITEM_NONE) + sTVShowState = 6; + else + sTVShowState = 10; + break; + case 6: + StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[1])); + ConvertIntToDecimalString(2, show->smartshopperShow.itemAmounts[1]); + if (show->smartshopperShow.itemIds[2] != ITEM_NONE) + sTVShowState = 7; + else if (show->smartshopperShow.priceReduced == TRUE) + sTVShowState = 8; + else + sTVShowState = 9; + break; + case 7: + StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[2])); + ConvertIntToDecimalString(2, show->smartshopperShow.itemAmounts[2]); + if (show->smartshopperShow.priceReduced == TRUE) + sTVShowState = 8; + else + sTVShowState = 9; + break; + case 8: + if (show->smartshopperShow.itemAmounts[0] >= 255) + sTVShowState = 12; + else + sTVShowState = 9; + break; + case 9: + sub_80EF40C(1, show); + TVShowDone(); + break; + case 10: + if (show->smartshopperShow.priceReduced == TRUE) + sTVShowState = 8; + else + sTVShowState = 9; + break; + case 11: + TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language); + StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[0])); + if (show->smartshopperShow.priceReduced == TRUE) + sTVShowState = 8; + else + sTVShowState = 12; + break; + case 12: + TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language); + TVShowDone(); + break; } ShowFieldMessage(sTVTodaysSmartShopperTextGroup[state]); } @@ -4800,90 +4549,78 @@ static void DoTVShowTheNameRaterShow(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.trainerName, show->nameRaterShow.language); - StringCopy(gStringVar2, gSpeciesNames[show->nameRaterShow.species]); - TVShowConvertInternationalString(gStringVar3, show->nameRaterShow.pokemonName, show->nameRaterShow.pokemonNameLanguage); - sTVShowState = TV_GetNicknameSumMod8(show) + 1; - break; - case 1: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - if (show->nameRaterShow.random == 0) - { - sTVShowState = 9; - } - else if (show->nameRaterShow.random == 1) - { - sTVShowState = 10; - } - else if (show->nameRaterShow.random == 2) - { - sTVShowState = 11; - } - break; - case 2: - TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.trainerName, show->nameRaterShow.language); - if (show->nameRaterShow.random == 0) - { - sTVShowState = 9; - } - else if (show->nameRaterShow.random == 1) - { - sTVShowState = 10; - } - else if (show->nameRaterShow.random == 2) - { - sTVShowState = 11; - } - break; - case 9: - case 10: - case 11: - TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.pokemonName, show->nameRaterShow.pokemonNameLanguage); - TV_GetNicknameSubstring(1, 0, 0, 1, 0, show); - TV_GetNicknameSubstring(2, 1, 0, 1, 0, show); - sTVShowState = 12; - break; - case 13: - TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.trainerName, show->nameRaterShow.language); - TV_GetNicknameSubstring(1, 0, 2, 0, 0, show); - TV_GetNicknameSubstring(2, 0, 3, 1, 0, show); - sTVShowState = 14; - break; - case 14: - TV_GetNicknameSubstring(1, 0, 2, 1, 0, show); - TV_GetNicknameSubstring(2, 0, 3, 0, 0, show); - sTVShowState = 18; - break; - case 15: - TV_GetNicknameSubstring(0, 0, 2, 1, 0, show); - StringCopy(gStringVar2, gSpeciesNames[show->nameRaterShow.species]); - TV_GetNicknameSubstring(2, 0, 3, 2, show->nameRaterShow.species, show); - sTVShowState = 16; - break; - case 16: - TV_GetNicknameSubstring(0, 0, 2, 2, show->nameRaterShow.species, show); - TV_GetNicknameSubstring(2, 0, 3, 1, 0, show); - sTVShowState = 17; - break; - case 17: - TV_GetNicknameSubstring(0, 0, 2, 1, 0, show); - StringCopy(gStringVar2, gSpeciesNames[show->nameRaterShow.randomSpecies]); - TV_GetNicknameSubstring(2, 0, 3, 2, show->nameRaterShow.randomSpecies, show); - sTVShowState = 18; - break; - case 12: - state = 18; - sTVShowState = 18; - case 18: - TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.pokemonName, show->nameRaterShow.pokemonNameLanguage); - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.trainerName, show->nameRaterShow.language); + StringCopy(gStringVar2, gSpeciesNames[show->nameRaterShow.species]); + TVShowConvertInternationalString(gStringVar3, show->nameRaterShow.pokemonName, show->nameRaterShow.pokemonNameLanguage); + sTVShowState = GetRandomNameRaterStateFromName(show) + 1; + break; + case 1: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + if (show->nameRaterShow.random == 0) + sTVShowState = 9; + else if (show->nameRaterShow.random == 1) + sTVShowState = 10; + else if (show->nameRaterShow.random == 2) + sTVShowState = 11; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.trainerName, show->nameRaterShow.language); + if (show->nameRaterShow.random == 0) + sTVShowState = 9; + else if (show->nameRaterShow.random == 1) + sTVShowState = 10; + else if (show->nameRaterShow.random == 2) + sTVShowState = 11; + break; + case 9: + case 10: + case 11: + TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.pokemonName, show->nameRaterShow.pokemonNameLanguage); + GetNicknameSubstring(1, 0, 0, 1, 0, show); + GetNicknameSubstring(2, 1, 0, 1, 0, show); + sTVShowState = 12; + break; + case 13: + TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.trainerName, show->nameRaterShow.language); + GetNicknameSubstring(1, 0, 2, 0, 0, show); + GetNicknameSubstring(2, 0, 3, 1, 0, show); + sTVShowState = 14; + break; + case 14: + GetNicknameSubstring(1, 0, 2, 1, 0, show); + GetNicknameSubstring(2, 0, 3, 0, 0, show); + sTVShowState = 18; + break; + case 15: + GetNicknameSubstring(0, 0, 2, 1, 0, show); + StringCopy(gStringVar2, gSpeciesNames[show->nameRaterShow.species]); + GetNicknameSubstring(2, 0, 3, 2, show->nameRaterShow.species, show); + sTVShowState = 16; + break; + case 16: + GetNicknameSubstring(0, 0, 2, 2, show->nameRaterShow.species, show); + GetNicknameSubstring(2, 0, 3, 1, 0, show); + sTVShowState = 17; + break; + case 17: + GetNicknameSubstring(0, 0, 2, 1, 0, show); + StringCopy(gStringVar2, gSpeciesNames[show->nameRaterShow.randomSpecies]); + GetNicknameSubstring(2, 0, 3, 2, show->nameRaterShow.randomSpecies, show); + sTVShowState = 18; + break; + case 12: + state = 18; + sTVShowState = 18; + case 18: + TVShowConvertInternationalString(gStringVar1, show->nameRaterShow.pokemonName, show->nameRaterShow.pokemonNameLanguage); + TVShowDone(); + break; } ShowFieldMessage(sTVNameRaterTextGroup[state]); } @@ -4898,70 +4635,62 @@ static void DoTVShowPokemonTodaySuccessfulCapture(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->pokemonToday.playerName, show->pokemonToday.language); - StringCopy(gStringVar2, gSpeciesNames[show->pokemonToday.species]); - TVShowConvertInternationalString(gStringVar3, show->pokemonToday.nickname, show->pokemonToday.language2); - if (show->pokemonToday.ball == ITEM_MASTER_BALL) - { - sTVShowState = 5; - } - else - { - sTVShowState = 1; - } - break; - case 1: - sTVShowState = 2; - break; - case 2: - StringCopy(gStringVar2, ItemId_GetName(show->pokemonToday.ball)); - TV_PrintIntToStringVar(2, show->pokemonToday.nBallsUsed); - if (show->pokemonToday.nBallsUsed < 4) - { - sTVShowState = 3; - } - else - { - sTVShowState = 4; - } - break; - case 3: - TVShowConvertInternationalString(gStringVar1, show->pokemonToday.playerName, show->pokemonToday.language); - StringCopy(gStringVar2, gSpeciesNames[show->pokemonToday.species]); - TVShowConvertInternationalString(gStringVar3, show->pokemonToday.nickname, show->pokemonToday.language2); - sTVShowState = 6; - break; - case 4: - sTVShowState = 6; - break; - case 5: - TVShowConvertInternationalString(gStringVar1, show->pokemonToday.playerName, show->pokemonToday.language); - StringCopy(gStringVar2, gSpeciesNames[show->pokemonToday.species]); - sTVShowState = 6; - break; - case 6: - TVShowConvertInternationalString(gStringVar1, show->pokemonToday.playerName, show->pokemonToday.language); - StringCopy(gStringVar2, gSpeciesNames[show->pokemonToday.species]); - TVShowConvertInternationalString(gStringVar3, show->pokemonToday.nickname, show->pokemonToday.language2); - sTVShowState += 1 + (Random() % 4); - break; - case 7: - case 8: - StringCopy(gStringVar1, gSpeciesNames[show->pokemonToday.species]); - TVShowConvertInternationalString(gStringVar2, show->pokemonToday.nickname, show->pokemonToday.language2); - TV_GetSomeOtherSpeciesAlreadySeenByPlayer_AndPrintName(2, show->pokemonToday.species); - sTVShowState = 11; - break; - case 9: - case 10: - StringCopy(gStringVar1, gSpeciesNames[show->pokemonToday.species]); - TVShowConvertInternationalString(gStringVar2, show->pokemonToday.nickname, show->pokemonToday.language2); - sTVShowState = 11; - break; - case 11: - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->pokemonToday.playerName, show->pokemonToday.language); + StringCopy(gStringVar2, gSpeciesNames[show->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar3, show->pokemonToday.nickname, show->pokemonToday.language2); + if (show->pokemonToday.ball == ITEM_MASTER_BALL) + sTVShowState = 5; + else + sTVShowState = 1; + break; + case 1: + sTVShowState = 2; + break; + case 2: + StringCopy(gStringVar2, ItemId_GetName(show->pokemonToday.ball)); + ConvertIntToDecimalString(2, show->pokemonToday.nBallsUsed); + if (show->pokemonToday.nBallsUsed < 4) + sTVShowState = 3; + else + sTVShowState = 4; + break; + case 3: + TVShowConvertInternationalString(gStringVar1, show->pokemonToday.playerName, show->pokemonToday.language); + StringCopy(gStringVar2, gSpeciesNames[show->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar3, show->pokemonToday.nickname, show->pokemonToday.language2); + sTVShowState = 6; + break; + case 4: + sTVShowState = 6; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->pokemonToday.playerName, show->pokemonToday.language); + StringCopy(gStringVar2, gSpeciesNames[show->pokemonToday.species]); + sTVShowState = 6; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, show->pokemonToday.playerName, show->pokemonToday.language); + StringCopy(gStringVar2, gSpeciesNames[show->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar3, show->pokemonToday.nickname, show->pokemonToday.language2); + sTVShowState += 1 + (Random() % 4); + break; + case 7: + case 8: + StringCopy(gStringVar1, gSpeciesNames[show->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar2, show->pokemonToday.nickname, show->pokemonToday.language2); + GetRandomDifferentSpeciesAndNameSeenByPlayer(2, show->pokemonToday.species); + sTVShowState = 11; + break; + case 9: + case 10: + StringCopy(gStringVar1, gSpeciesNames[show->pokemonToday.species]); + TVShowConvertInternationalString(gStringVar2, show->pokemonToday.nickname, show->pokemonToday.language2); + sTVShowState = 11; + break; + case 11: + TVShowDone(); + break; } ShowFieldMessage(sTVPokemonTodaySuccessfulTextGroup[state]); } @@ -4976,45 +4705,37 @@ static void DoTVShowPokemonTodayFailedCapture(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->pokemonTodayFailed.playerName, show->pokemonTodayFailed.language); - StringCopy(gStringVar2, gSpeciesNames[show->pokemonTodayFailed.species]); - sTVShowState = 1; - break; - case 1: - TVShowConvertInternationalString(gStringVar1, show->pokemonTodayFailed.playerName, show->pokemonTodayFailed.language); - GetMapName(gStringVar2, show->pokemonTodayFailed.location, 0); - StringCopy(gStringVar3, gSpeciesNames[show->pokemonTodayFailed.species2]); - if (show->pokemonTodayFailed.outcome == 1) - { - sTVShowState = 3; - } - else - { - sTVShowState = 2; - } - break; - case 2: - case 3: - TVShowConvertInternationalString(gStringVar1, show->pokemonTodayFailed.playerName, show->pokemonTodayFailed.language); - TV_PrintIntToStringVar(1, show->pokemonTodayFailed.nBallsUsed); - if (Random() % 3 == 0) - { - sTVShowState = 5; - } - else - { - sTVShowState = 4; - } - break; - case 4: - case 5: - TVShowConvertInternationalString(gStringVar1, show->pokemonTodayFailed.playerName, show->pokemonTodayFailed.language); - sTVShowState = 6; - break; - case 6: - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->pokemonTodayFailed.playerName, show->pokemonTodayFailed.language); + StringCopy(gStringVar2, gSpeciesNames[show->pokemonTodayFailed.species]); + sTVShowState = 1; + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->pokemonTodayFailed.playerName, show->pokemonTodayFailed.language); + GetMapName(gStringVar2, show->pokemonTodayFailed.location, 0); + StringCopy(gStringVar3, gSpeciesNames[show->pokemonTodayFailed.species2]); + if (show->pokemonTodayFailed.outcome == 1) + sTVShowState = 3; + else + sTVShowState = 2; + break; + case 2: + case 3: + TVShowConvertInternationalString(gStringVar1, show->pokemonTodayFailed.playerName, show->pokemonTodayFailed.language); + ConvertIntToDecimalString(1, show->pokemonTodayFailed.nBallsUsed); + if (Random() % 3 == 0) + sTVShowState = 5; + else + sTVShowState = 4; + break; + case 4: + case 5: + TVShowConvertInternationalString(gStringVar1, show->pokemonTodayFailed.playerName, show->pokemonTodayFailed.language); + sTVShowState = 6; + break; + case 6: + TVShowDone(); + break; } ShowFieldMessage(sTVPokemonTodayFailedTextGroup[state]); } @@ -5030,45 +4751,45 @@ static void DoTVShowPokemonFanClubLetter(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->fanclubLetter.playerName, show->fanclubLetter.language); - StringCopy(gStringVar2, gSpeciesNames[show->fanclubLetter.species]); - sTVShowState = 50; - break; - case 1: - rval = (Random() % 4) + 1; - if (rval == 1) - sTVShowState = 2; - else - sTVShowState = rval + 2; - break; - case 2: - sTVShowState = 51; - break; - case 3: - sTVShowState += (Random() % 3) + 1; - break; - case 4: - case 5: - case 6: - TV_FanClubLetter_RandomWordToStringVar3(show); - sTVShowState = 7; - break; - case 7: - rval = (Random() % 0x1f) + 0x46; - TV_PrintIntToStringVar(2, rval); - TVShowDone(); - break; - case 50: - ConvertEasyChatWordsToString(gStringVar4, show->fanclubLetter.words, 2, 2); - ShowFieldMessage(gStringVar4); - sTVShowState = 1; - return; - case 51: - ConvertEasyChatWordsToString(gStringVar4, show->fanclubLetter.words, 2, 2); - ShowFieldMessage(gStringVar4); - sTVShowState = 3; - return; + case 0: + TVShowConvertInternationalString(gStringVar1, show->fanclubLetter.playerName, show->fanclubLetter.language); + StringCopy(gStringVar2, gSpeciesNames[show->fanclubLetter.species]); + sTVShowState = 50; + break; + case 1: + rval = (Random() % 4) + 1; + if (rval == 1) + sTVShowState = 2; + else + sTVShowState = rval + 2; + break; + case 2: + sTVShowState = 51; + break; + case 3: + sTVShowState += (Random() % 3) + 1; + break; + case 4: + case 5: + case 6: + GetRandomWordFromShow(show); + sTVShowState = 7; + break; + case 7: + rval = (Random() % 0x1f) + 0x46; + ConvertIntToDecimalString(2, rval); + TVShowDone(); + break; + case 50: + ConvertEasyChatWordsToString(gStringVar4, show->fanclubLetter.words, 2, 2); + ShowFieldMessage(gStringVar4); + sTVShowState = 1; + return; + case 51: + ConvertEasyChatWordsToString(gStringVar4, show->fanclubLetter.words, 2, 2); + ShowFieldMessage(gStringVar4); + sTVShowState = 3; + return; } ShowFieldMessage(sTVFanClubTextGroup[state]); } @@ -5083,27 +4804,27 @@ static void DoTVShowRecentHappenings(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->recentHappenings.playerName, show->recentHappenings.language); - TV_FanClubLetter_RandomWordToStringVar3(show); - sTVShowState = 50; - break; - case 1: - sTVShowState += 1 + (Random() % 3); - break; - case 2: - case 3: - case 4: - sTVShowState = 5; - break; - case 5: - TVShowDone(); - break; - case 50: - ConvertEasyChatWordsToString(gStringVar4, show->recentHappenings.words, 2, 2); - ShowFieldMessage(gStringVar4); - sTVShowState = 1; - return; + case 0: + TVShowConvertInternationalString(gStringVar1, show->recentHappenings.playerName, show->recentHappenings.language); + GetRandomWordFromShow(show); + sTVShowState = 50; + break; + case 1: + sTVShowState += 1 + (Random() % 3); + break; + case 2: + case 3: + case 4: + sTVShowState = 5; + break; + case 5: + TVShowDone(); + break; + case 50: + ConvertEasyChatWordsToString(gStringVar4, show->recentHappenings.words, 2, 2); + ShowFieldMessage(gStringVar4); + sTVShowState = 1; + return; } ShowFieldMessage(sTVRecentHappeninssTextGroup[state]); } @@ -5118,25 +4839,25 @@ static void DoTVShowPokemonFanClubOpinions(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->fanclubOpinions.playerName, show->fanclubOpinions.language); - StringCopy(gStringVar2, gSpeciesNames[show->fanclubOpinions.species]); - TVShowConvertInternationalString(gStringVar3, show->fanclubOpinions.nickname, show->fanclubOpinions.pokemonNameLanguage); - sTVShowState = show->fanclubOpinions.questionAsked + 1; - break; - case 1: - case 2: - case 3: - TVShowConvertInternationalString(gStringVar1, show->fanclubOpinions.playerName, show->fanclubOpinions.language); - StringCopy(gStringVar2, gSpeciesNames[show->fanclubOpinions.species]); - CopyEasyChatWord(gStringVar3, show->fanclubOpinions.words[0]); - sTVShowState = 4; - break; - case 4: - TVShowConvertInternationalString(gStringVar1, show->fanclubOpinions.playerName, show->fanclubOpinions.language); - CopyEasyChatWord(gStringVar3, show->fanclubOpinions.words[1]); - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->fanclubOpinions.playerName, show->fanclubOpinions.language); + StringCopy(gStringVar2, gSpeciesNames[show->fanclubOpinions.species]); + TVShowConvertInternationalString(gStringVar3, show->fanclubOpinions.nickname, show->fanclubOpinions.pokemonNameLanguage); + sTVShowState = show->fanclubOpinions.questionAsked + 1; + break; + case 1: + case 2: + case 3: + TVShowConvertInternationalString(gStringVar1, show->fanclubOpinions.playerName, show->fanclubOpinions.language); + StringCopy(gStringVar2, gSpeciesNames[show->fanclubOpinions.species]); + CopyEasyChatWord(gStringVar3, show->fanclubOpinions.words[0]); + sTVShowState = 4; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->fanclubOpinions.playerName, show->fanclubOpinions.language); + CopyEasyChatWord(gStringVar3, show->fanclubOpinions.words[1]); + TVShowDone(); + break; } ShowFieldMessage(sTVFanClubOpinionsTextGroup[state]); } @@ -5181,13 +4902,9 @@ static void DoTVShowPokemonContestLiveUpdates(void) if (show->contestLiveUpdates.round1Placing == show->contestLiveUpdates.round2Placing) { if (show->contestLiveUpdates.round1Placing == 0) - { sTVShowState = CONTESTLIVE_STATE_WON_BOTH_ROUNDS; - } else - { sTVShowState = CONTESTLIVE_STATE_EQUAL_ROUNDS; - } } else if (show->contestLiveUpdates.round1Placing > show->contestLiveUpdates.round2Placing) { @@ -5520,64 +5237,64 @@ static void DoTVShowPokemonBattleUpdate(void) state = sTVShowState; switch (state) { + case 0: + switch (show->battleUpdate.battleType) + { case 0: - switch (show->battleUpdate.battleType) - { - case 0: - case 1: - sTVShowState = 1; - break; - case 2: - sTVShowState = 5; - break; - } - break; case 1: - TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); - TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); - if (show->battleUpdate.battleType == 0) - { - StringCopy(gStringVar3, gText_Single); - } - else - { - StringCopy(gStringVar3, gText_Double); - } - sTVShowState = 2; + sTVShowState = 1; break; case 2: - TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); - StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesPlayer]); - StringCopy(gStringVar3, gMoveNames[show->battleUpdate.move]); - sTVShowState = 3; - break; - case 3: - TVShowConvertInternationalString(gStringVar1, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); - StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesOpponent]); - sTVShowState = 4; - break; - case 4: - TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); - TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); - TVShowDone(); - break; - case 5: - TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); - TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); - sTVShowState = 6; - break; - case 6: - TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); - StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesPlayer]); - StringCopy(gStringVar3, gMoveNames[show->battleUpdate.move]); - sTVShowState = 7; - break; - case 7: - TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); - TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); - StringCopy(gStringVar3, gSpeciesNames[show->battleUpdate.speciesOpponent]); - TVShowDone(); + sTVShowState = 5; break; + } + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); + TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); + if (show->battleUpdate.battleType == 0) + { + StringCopy(gStringVar3, gText_Single); + } + else + { + StringCopy(gStringVar3, gText_Double); + } + sTVShowState = 2; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); + StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesPlayer]); + StringCopy(gStringVar3, gMoveNames[show->battleUpdate.move]); + sTVShowState = 3; + break; + case 3: + TVShowConvertInternationalString(gStringVar1, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); + StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesOpponent]); + sTVShowState = 4; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); + TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); + TVShowDone(); + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); + TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); + sTVShowState = 6; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); + StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesPlayer]); + StringCopy(gStringVar3, gMoveNames[show->battleUpdate.move]); + sTVShowState = 7; + break; + case 7: + TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); + TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); + StringCopy(gStringVar3, gSpeciesNames[show->battleUpdate.speciesOpponent]); + TVShowDone(); + break; } ShowFieldMessage(sTVPokemonBattleUpdateTextGroup[state]); } @@ -5592,95 +5309,88 @@ static void DoTVShow3CheersForPokeblocks(void) state = sTVShowState; switch (state) { + case 0: + TVShowConvertInternationalString(gStringVar1, show->threeCheers.playerName, show->threeCheers.language); + if (show->threeCheers.sheen > 20) + sTVShowState = 1; + else + sTVShowState = 3; + break; + case 1: + switch (show->threeCheers.flavor) + { case 0: - TVShowConvertInternationalString(gStringVar1, show->threeCheers.playerName, show->threeCheers.language); - if (show->threeCheers.sheen > 20) - { - sTVShowState = 1; - } - else - { - sTVShowState = 3; - } + StringCopy(gStringVar1, gText_Spicy2); break; case 1: - switch (show->threeCheers.flavor) - { - case 0: - StringCopy(gStringVar1, gText_Spicy2); - break; - case 1: - StringCopy(gStringVar1, gText_Dry2); - break; - case 2: - StringCopy(gStringVar1, gText_Sweet2); - break; - case 3: - StringCopy(gStringVar1, gText_Bitter2); - break; - case 4: - StringCopy(gStringVar1, gText_Sour2); - break; - } - if (show->threeCheers.sheen > 24) - { - StringCopy(gStringVar2, gText_Excellent); - } else if (show->threeCheers.sheen > 22) - { - StringCopy(gStringVar2, gText_VeryGood); - } - else - { - StringCopy(gStringVar2, gText_Good); - } - TVShowConvertInternationalString(gStringVar3, show->threeCheers.playerName, show->threeCheers.language); - sTVShowState = 2; + StringCopy(gStringVar1, gText_Dry2); break; case 2: - TVShowConvertInternationalString(gStringVar1, show->threeCheers.worstBlenderName, show->threeCheers.worstBlenderLanguage); - sTVShowState = 5; + StringCopy(gStringVar1, gText_Sweet2); break; case 3: - switch (show->threeCheers.flavor) - { - case 0: - StringCopy(gStringVar1, gText_Spicy2); - break; - case 1: - StringCopy(gStringVar1, gText_Dry2); - break; - case 2: - StringCopy(gStringVar1, gText_Sweet2); - break; - case 3: - StringCopy(gStringVar1, gText_Bitter2); - break; - case 4: - StringCopy(gStringVar1, gText_Sour2); - break; - } - if (show->threeCheers.sheen > 16) - { - StringCopy(gStringVar2, gText_SoSo); - } else if (show->threeCheers.sheen > 13) - { - StringCopy(gStringVar2, gText_Bad); - } - else - { - StringCopy(gStringVar2, gText_TheWorst); - } - TVShowConvertInternationalString(gStringVar3, show->threeCheers.playerName, show->threeCheers.language); - sTVShowState = 4; + StringCopy(gStringVar1, gText_Bitter2); break; case 4: - TVShowConvertInternationalString(gStringVar1, show->threeCheers.worstBlenderName, show->threeCheers.worstBlenderLanguage); - TVShowConvertInternationalString(gStringVar2, show->threeCheers.playerName, show->threeCheers.language); - sTVShowState = 5; + StringCopy(gStringVar1, gText_Sour2); break; - case 5: - TVShowDone(); + } + if (show->threeCheers.sheen > 24) + { + StringCopy(gStringVar2, gText_Excellent); + } else if (show->threeCheers.sheen > 22) + { + StringCopy(gStringVar2, gText_VeryGood); + } + else + { + StringCopy(gStringVar2, gText_Good); + } + TVShowConvertInternationalString(gStringVar3, show->threeCheers.playerName, show->threeCheers.language); + sTVShowState = 2; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->threeCheers.worstBlenderName, show->threeCheers.worstBlenderLanguage); + sTVShowState = 5; + break; + case 3: + switch (show->threeCheers.flavor) + { + case 0: + StringCopy(gStringVar1, gText_Spicy2); break; + case 1: + StringCopy(gStringVar1, gText_Dry2); + break; + case 2: + StringCopy(gStringVar1, gText_Sweet2); + break; + case 3: + StringCopy(gStringVar1, gText_Bitter2); + break; + case 4: + StringCopy(gStringVar1, gText_Sour2); + break; + } + + if (show->threeCheers.sheen > 16) + StringCopy(gStringVar2, gText_SoSo); + else if (show->threeCheers.sheen > 13) + StringCopy(gStringVar2, gText_Bad); + else + StringCopy(gStringVar2, gText_TheWorst); + + TVShowConvertInternationalString(gStringVar3, show->threeCheers.playerName, show->threeCheers.language); + sTVShowState = 4; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->threeCheers.worstBlenderName, show->threeCheers.worstBlenderLanguage); + TVShowConvertInternationalString(gStringVar2, show->threeCheers.playerName, show->threeCheers.language); + sTVShowState = 5; + break; + case 5: + TVShowDone(); + break; } ShowFieldMessage(sTV3CheersForPokeblocksTextGroup[state]); } @@ -5693,62 +5403,48 @@ void DoTVShowInSearchOfTrainers(void) state = sTVShowState; switch (state) { - case 0: - GetMapName(gStringVar1, gSaveBlock1Ptr->gabbyAndTyData.mapnum, 0); - if (gSaveBlock1Ptr->gabbyAndTyData.battleNum > 1) - { - sTVShowState = 1; - } - else - { - sTVShowState = 2; - } - break; - case 1: + case 0: + GetMapName(gStringVar1, gSaveBlock1Ptr->gabbyAndTyData.mapnum, 0); + if (gSaveBlock1Ptr->gabbyAndTyData.battleNum > 1) + sTVShowState = 1; + else sTVShowState = 2; - break; - case 2: - if (!gSaveBlock1Ptr->gabbyAndTyData.battleTookMoreThanOneTurn) - { - sTVShowState = 4; - } - else if (gSaveBlock1Ptr->gabbyAndTyData.playerThrewABall) - { - sTVShowState = 5; - } - else if (gSaveBlock1Ptr->gabbyAndTyData.playerUsedHealingItem) - { - sTVShowState = 6; - } - else if (gSaveBlock1Ptr->gabbyAndTyData.playerLostAMon) - { - sTVShowState = 7; - } - else - { - sTVShowState = 3; - } - break; - case 3: - StringCopy(gStringVar1, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon1]); - StringCopy(gStringVar2, gMoveNames[gSaveBlock1Ptr->gabbyAndTyData.lastMove]); - StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon2]); - sTVShowState = 8; - break; - case 4: - case 5: - case 6: - case 7: - sTVShowState = 8; - break; - case 8: - CopyEasyChatWord(gStringVar1, gSaveBlock1Ptr->gabbyAndTyData.quote[0]); - StringCopy(gStringVar2, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon1]); - StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon2]); - gSpecialVar_Result = TRUE; - sTVShowState = 0; - TakeTVShowInSearchOfTrainersOffTheAir(); - break; + break; + case 1: + sTVShowState = 2; + break; + case 2: + if (!gSaveBlock1Ptr->gabbyAndTyData.battleTookMoreThanOneTurn) + sTVShowState = 4; + else if (gSaveBlock1Ptr->gabbyAndTyData.playerThrewABall) + sTVShowState = 5; + else if (gSaveBlock1Ptr->gabbyAndTyData.playerUsedHealingItem) + sTVShowState = 6; + else if (gSaveBlock1Ptr->gabbyAndTyData.playerLostAMon) + sTVShowState = 7; + else + sTVShowState = 3; + break; + case 3: + StringCopy(gStringVar1, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon1]); + StringCopy(gStringVar2, gMoveNames[gSaveBlock1Ptr->gabbyAndTyData.lastMove]); + StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon2]); + sTVShowState = 8; + break; + case 4: + case 5: + case 6: + case 7: + sTVShowState = 8; + break; + case 8: + CopyEasyChatWord(gStringVar1, gSaveBlock1Ptr->gabbyAndTyData.quote[0]); + StringCopy(gStringVar2, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon1]); + StringCopy(gStringVar3, gSpeciesNames[gSaveBlock1Ptr->gabbyAndTyData.mon2]); + gSpecialVar_Result = TRUE; + sTVShowState = 0; + TakeGabbyAndTyOffTheAir(); + break; } ShowFieldMessage(sTVInSearchOfTrainersTextGroup[state]); } @@ -5761,28 +5457,24 @@ static void DoTVShowPokemonAngler(void) show = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8004]; gSpecialVar_Result = FALSE; if (show->pokemonAngler.nBites < show->pokemonAngler.nFails) - { sTVShowState = 0; - } else - { sTVShowState = 1; - } state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->pokemonAngler.playerName, show->pokemonAngler.language); - StringCopy(gStringVar2, gSpeciesNames[show->pokemonAngler.species]); - TV_PrintIntToStringVar(2, show->pokemonAngler.nFails); - TVShowDone(); - break; - case 1: - TVShowConvertInternationalString(gStringVar1, show->pokemonAngler.playerName, show->pokemonAngler.language); - StringCopy(gStringVar2, gSpeciesNames[show->pokemonAngler.species]); - TV_PrintIntToStringVar(2, show->pokemonAngler.nBites); - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->pokemonAngler.playerName, show->pokemonAngler.language); + StringCopy(gStringVar2, gSpeciesNames[show->pokemonAngler.species]); + ConvertIntToDecimalString(2, show->pokemonAngler.nFails); + TVShowDone(); + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->pokemonAngler.playerName, show->pokemonAngler.language); + StringCopy(gStringVar2, gSpeciesNames[show->pokemonAngler.species]); + ConvertIntToDecimalString(2, show->pokemonAngler.nBites); + TVShowDone(); + break; } ShowFieldMessage(sTVPokemonAnslerTextGroup[state]); } @@ -5797,22 +5489,22 @@ static void DoTVShowTheWorldOfMasters(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->worldOfMasters.playerName, show->worldOfMasters.language); - TV_PrintIntToStringVar(1, show->worldOfMasters.steps); - TV_PrintIntToStringVar(2, show->worldOfMasters.numPokeCaught); - sTVShowState = 1; - break; - case 1: - StringCopy(gStringVar1, gSpeciesNames[show->worldOfMasters.species]); - sTVShowState = 2; - break; - case 2: - TVShowConvertInternationalString(gStringVar1, show->worldOfMasters.playerName, show->worldOfMasters.language); - GetMapName(gStringVar2, show->worldOfMasters.location, 0); - StringCopy(gStringVar3, gSpeciesNames[show->worldOfMasters.caughtPoke]); - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->worldOfMasters.playerName, show->worldOfMasters.language); + ConvertIntToDecimalString(1, show->worldOfMasters.steps); + ConvertIntToDecimalString(2, show->worldOfMasters.numPokeCaught); + sTVShowState = 1; + break; + case 1: + StringCopy(gStringVar1, gSpeciesNames[show->worldOfMasters.species]); + sTVShowState = 2; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->worldOfMasters.playerName, show->worldOfMasters.language); + GetMapName(gStringVar2, show->worldOfMasters.location, 0); + StringCopy(gStringVar3, gSpeciesNames[show->worldOfMasters.caughtPoke]); + TVShowDone(); + break; } ShowFieldMessage(sTVWorldOfMastersTextGroup[state]); } @@ -5827,143 +5519,111 @@ static void DoTVShowTodaysRivalTrainer(void) state = sTVShowState; switch (state) { - case 0: - switch (show->rivalTrainer.location) + case 0: + switch (show->rivalTrainer.location) + { + default: + sTVShowState = 7; + break; + case MAPSEC_SECRET_BASE: + sTVShowState = 8; + break; + case MAPSEC_DYNAMIC: + switch (show->rivalTrainer.mapLayoutId) { - default: - sTVShowState = 7; - break; - case MAPSEC_SECRET_BASE: - sTVShowState = 8; - break; - case MAPSEC_DYNAMIC: - switch (show->rivalTrainer.mapLayoutId) - { - case LAYOUT_SS_TIDAL_CORRIDOR: - case LAYOUT_SS_TIDAL_LOWER_DECK: - case LAYOUT_SS_TIDAL_ROOMS: - sTVShowState = 10; - break; - default: - sTVShowState = 9; - break; - } - break; + case LAYOUT_SS_TIDAL_CORRIDOR: + case LAYOUT_SS_TIDAL_LOWER_DECK: + case LAYOUT_SS_TIDAL_ROOMS: + sTVShowState = 10; + break; + default: + sTVShowState = 9; + break; } break; - case 7: - TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); - TV_PrintIntToStringVar(1, show->rivalTrainer.dexCount); - GetMapName(gStringVar3, show->rivalTrainer.location, 0); - if (show->rivalTrainer.badgeCount != 0) - { - sTVShowState = 1; - } + } + break; + case 7: + TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); + ConvertIntToDecimalString(1, show->rivalTrainer.dexCount); + GetMapName(gStringVar3, show->rivalTrainer.location, 0); + if (show->rivalTrainer.badgeCount != 0) + sTVShowState = 1; + else + sTVShowState = 2; + break; + case 8: + TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); + ConvertIntToDecimalString(1, show->rivalTrainer.dexCount); + if (show->rivalTrainer.badgeCount != 0) + sTVShowState = 1; + else + sTVShowState = 2; + break; + case 9: + TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); + ConvertIntToDecimalString(1, show->rivalTrainer.dexCount); + if (show->rivalTrainer.badgeCount != 0) + sTVShowState = 1; + else + sTVShowState = 2; + break; + case 10: + TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); + ConvertIntToDecimalString(1, show->rivalTrainer.dexCount); + if (show->rivalTrainer.badgeCount != 0) + sTVShowState = 1; + else + sTVShowState = 2; + break; + case 1: + ConvertIntToDecimalString(0, show->rivalTrainer.badgeCount); + if (FlagGet(FLAG_LANDMARK_BATTLE_FRONTIER)) + { + if (show->rivalTrainer.nSilverSymbols || show->rivalTrainer.nGoldSymbols) + sTVShowState = 4; else - { - sTVShowState = 2; - } - break; - case 8: - TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); - TV_PrintIntToStringVar(1, show->rivalTrainer.dexCount); - if (show->rivalTrainer.badgeCount != 0) - { - sTVShowState = 1; - } - else - { - sTVShowState = 2; - } - break; - case 9: - TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); - TV_PrintIntToStringVar(1, show->rivalTrainer.dexCount); - if (show->rivalTrainer.badgeCount != 0) - { - sTVShowState = 1; - } - else - { - sTVShowState = 2; - } - break; - case 10: - TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); - TV_PrintIntToStringVar(1, show->rivalTrainer.dexCount); - if (show->rivalTrainer.badgeCount != 0) - { - sTVShowState = 1; - } - else - { - sTVShowState = 2; - } - break; - case 1: - TV_PrintIntToStringVar(0, show->rivalTrainer.badgeCount); - if (FlagGet(FLAG_LANDMARK_BATTLE_FRONTIER)) - { - if (show->rivalTrainer.nSilverSymbols || show->rivalTrainer.nGoldSymbols) - { - sTVShowState = 4; - } - else - { - sTVShowState = 3; - } - } - else - { - sTVShowState = 6; - } - break; - case 2: - if (FlagGet(FLAG_LANDMARK_BATTLE_FRONTIER)) - { - if (show->rivalTrainer.nSilverSymbols || show->rivalTrainer.nGoldSymbols) - { - sTVShowState = 4; - } - else - { - sTVShowState = 3; - } - } - else - { - sTVShowState = 6; - } - break; - case 3: - if (show->rivalTrainer.battlePoints == 0) - { - sTVShowState = 6; - } - else - { - sTVShowState = 5; - } - break; - case 4: - TV_PrintIntToStringVar(0, show->rivalTrainer.nGoldSymbols); - TV_PrintIntToStringVar(1, show->rivalTrainer.nSilverSymbols); - if (show->rivalTrainer.battlePoints == 0) - { - sTVShowState = 6; - } - else - { - sTVShowState = 5; - } - break; - case 5: - TV_PrintIntToStringVar(0, show->rivalTrainer.battlePoints); + sTVShowState = 3; + } + else + { sTVShowState = 6; - break; - case 6: - TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); - TVShowDone(); + } + break; + case 2: + if (FlagGet(FLAG_LANDMARK_BATTLE_FRONTIER)) + { + if (show->rivalTrainer.nSilverSymbols || show->rivalTrainer.nGoldSymbols) + sTVShowState = 4; + else + sTVShowState = 3; + } + else + { + sTVShowState = 6; + } + break; + case 3: + if (show->rivalTrainer.battlePoints == 0) + sTVShowState = 6; + else + sTVShowState = 5; + break; + case 4: + ConvertIntToDecimalString(0, show->rivalTrainer.nGoldSymbols); + ConvertIntToDecimalString(1, show->rivalTrainer.nSilverSymbols); + if (show->rivalTrainer.battlePoints == 0) + sTVShowState = 6; + else + sTVShowState = 5; + break; + case 5: + ConvertIntToDecimalString(0, show->rivalTrainer.battlePoints); + sTVShowState = 6; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, show->rivalTrainer.playerName, show->rivalTrainer.language); + TVShowDone(); } ShowFieldMessage(sTVTodaysRivalTrainerTextGroup[state]); } @@ -6026,38 +5686,38 @@ static void DoTVShowHoennTreasureInvestigators(void) state = sTVShowState; switch (state) { - case 0: - StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item)); - if (show->treasureInvestigators.location == MAPSEC_DYNAMIC) - { - switch (show->treasureInvestigators.mapLayoutId) - { - case LAYOUT_SS_TIDAL_CORRIDOR: - case LAYOUT_SS_TIDAL_LOWER_DECK: - case LAYOUT_SS_TIDAL_ROOMS: - sTVShowState = 2; - break; - default: - sTVShowState = 1; - break; - } - } - else + case 0: + StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item)); + if (show->treasureInvestigators.location == MAPSEC_DYNAMIC) + { + switch (show->treasureInvestigators.mapLayoutId) { + case LAYOUT_SS_TIDAL_CORRIDOR: + case LAYOUT_SS_TIDAL_LOWER_DECK: + case LAYOUT_SS_TIDAL_ROOMS: + sTVShowState = 2; + break; + default: sTVShowState = 1; + break; } - break; - case 1: - StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item)); - TVShowConvertInternationalString(gStringVar2, show->treasureInvestigators.playerName, show->treasureInvestigators.language); - GetMapName(gStringVar3, show->treasureInvestigators.location, 0); - TVShowDone(); - break; - case 2: - StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item)); - TVShowConvertInternationalString(gStringVar2, show->treasureInvestigators.playerName, show->treasureInvestigators.language); - TVShowDone(); - break; + } + else + { + sTVShowState = 1; + } + break; + case 1: + StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item)); + TVShowConvertInternationalString(gStringVar2, show->treasureInvestigators.playerName, show->treasureInvestigators.language); + GetMapName(gStringVar3, show->treasureInvestigators.location, 0); + TVShowDone(); + break; + case 2: + StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item)); + TVShowConvertInternationalString(gStringVar2, show->treasureInvestigators.playerName, show->treasureInvestigators.language); + TVShowDone(); + break; } ShowFieldMessage(sTVHoennTreasureInvestisatorsTextGroup[state]); } @@ -6072,66 +5732,62 @@ static void DoTVShowFindThatGamer(void) state = sTVShowState; switch (state) { + case 0: + TVShowConvertInternationalString(gStringVar1, show->findThatGamer.playerName, show->findThatGamer.language); + switch (show->findThatGamer.whichGame) + { case 0: - TVShowConvertInternationalString(gStringVar1, show->findThatGamer.playerName, show->findThatGamer.language); - switch (show->findThatGamer.whichGame) - { - case 0: - StringCopy(gStringVar2, gText_Slots); - break; - case 1: - StringCopy(gStringVar2, gText_Roulette); - break; - } - if (show->findThatGamer.won == TRUE) - { - sTVShowState = 1; - } - else - { - sTVShowState = 2; - } + StringCopy(gStringVar2, gText_Slots); break; case 1: - TVShowConvertInternationalString(gStringVar1, show->findThatGamer.playerName, show->findThatGamer.language); - switch (show->findThatGamer.whichGame) - { - case 0: - StringCopy(gStringVar2, gText_Slots); - break; - case 1: - StringCopy(gStringVar2, gText_Roulette); - break; - } - TV_PrintIntToStringVar(2, show->findThatGamer.nCoins); - TVShowDone(); break; - case 2: - TVShowConvertInternationalString(gStringVar1, show->findThatGamer.playerName, show->findThatGamer.language); - switch (show->findThatGamer.whichGame) - { - case 0: - StringCopy(gStringVar2, gText_Slots); - break; - case 1: - StringCopy(gStringVar2, gText_Roulette); - break; - } - TV_PrintIntToStringVar(2, show->findThatGamer.nCoins); - sTVShowState = 3; + StringCopy(gStringVar2, gText_Roulette); break; - case 3: - TVShowConvertInternationalString(gStringVar1, show->findThatGamer.playerName, show->findThatGamer.language); - switch (show->findThatGamer.whichGame) - { - case 0: - StringCopy(gStringVar2, gText_Roulette); - break; - case 1: - StringCopy(gStringVar2, gText_Slots); - break; - } - TVShowDone(); + } + if (show->findThatGamer.won == TRUE) + sTVShowState = 1; + else + sTVShowState = 2; + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->findThatGamer.playerName, show->findThatGamer.language); + switch (show->findThatGamer.whichGame) + { + case 0: + StringCopy(gStringVar2, gText_Slots); break; + case 1: + StringCopy(gStringVar2, gText_Roulette); + break; + } + ConvertIntToDecimalString(2, show->findThatGamer.nCoins); + TVShowDone(); break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->findThatGamer.playerName, show->findThatGamer.language); + switch (show->findThatGamer.whichGame) + { + case 0: + StringCopy(gStringVar2, gText_Slots); + break; + case 1: + StringCopy(gStringVar2, gText_Roulette); + break; + } + ConvertIntToDecimalString(2, show->findThatGamer.nCoins); + sTVShowState = 3; + break; + case 3: + TVShowConvertInternationalString(gStringVar1, show->findThatGamer.playerName, show->findThatGamer.language); + switch (show->findThatGamer.whichGame) + { + case 0: + StringCopy(gStringVar2, gText_Roulette); + break; + case 1: + StringCopy(gStringVar2, gText_Slots); + break; + } + TVShowDone(); + break; } ShowFieldMessage(sTVFindThatGamerTextGroup[state]); } @@ -6146,95 +5802,87 @@ static void DoTVShowBreakingNewsTV(void) state = sTVShowState; switch (state) { - case 0: - if (show->breakingNews.outcome == 0) - { - sTVShowState = 1; - } - else - { - sTVShowState = 5; - } - break; + case 0: + if (show->breakingNews.outcome == 0) + sTVShowState = 1; + else + sTVShowState = 5; + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); + GetMapName(gStringVar3, show->breakingNews.location, 0); + sTVShowState = 2; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); + StringCopy(gStringVar3, gSpeciesNames[show->breakingNews.poke1Species]); + sTVShowState = 3; + break; + case 3: + ConvertIntToDecimalString(0, show->breakingNews.balls); + StringCopy(gStringVar2, ItemId_GetName(show->breakingNews.caughtMonBall)); + sTVShowState = 4; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + GetMapName(gStringVar2, show->breakingNews.location, 0); + TVShowDone(); + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); + GetMapName(gStringVar3, show->breakingNews.location, 0); + sTVShowState = 6; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); + StringCopy(gStringVar3, gSpeciesNames[show->breakingNews.poke1Species]); + switch (show->breakingNews.outcome) + { case 1: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); - GetMapName(gStringVar3, show->breakingNews.location, 0); - sTVShowState = 2; + if (show->breakingNews.lastUsedMove == MOVE_NONE) + sTVShowState = 12; + else + sTVShowState = 7; break; case 2: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); - StringCopy(gStringVar3, gSpeciesNames[show->breakingNews.poke1Species]); - sTVShowState = 3; + sTVShowState = 9; break; case 3: - TV_PrintIntToStringVar(0, show->breakingNews.balls); - StringCopy(gStringVar2, ItemId_GetName(show->breakingNews.caughtMonBall)); - sTVShowState = 4; - break; - case 4: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - GetMapName(gStringVar2, show->breakingNews.location, 0); - TVShowDone(); - break; - case 5: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); - GetMapName(gStringVar3, show->breakingNews.location, 0); - sTVShowState = 6; - break; - case 6: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); - StringCopy(gStringVar3, gSpeciesNames[show->breakingNews.poke1Species]); - switch (show->breakingNews.outcome) - { - case 1: - if (show->breakingNews.lastUsedMove == MOVE_NONE) - { - sTVShowState = 12; - } - else - { - sTVShowState = 7; - } - break; - case 2: - sTVShowState = 9; - break; - case 3: - sTVShowState = 10; - break; - } - break; - case 7: - StringCopy(gStringVar1, gMoveNames[show->breakingNews.lastUsedMove]); - StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.poke1Species]); - sTVShowState = 8; - break; - case 12: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); - StringCopy(gStringVar3, gSpeciesNames[show->breakingNews.poke1Species]); - sTVShowState = 8; - break; - case 8: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - GetMapName(gStringVar2, show->breakingNews.location, 0); - sTVShowState = 11; - break; - case 9: - case 10: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); - GetMapName(gStringVar3, show->breakingNews.location, 0); - sTVShowState = 11; - break; - case 11: - TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); - TVShowDone(); + sTVShowState = 10; break; + } + break; + case 7: + StringCopy(gStringVar1, gMoveNames[show->breakingNews.lastUsedMove]); + StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.poke1Species]); + sTVShowState = 8; + break; + case 12: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); + StringCopy(gStringVar3, gSpeciesNames[show->breakingNews.poke1Species]); + sTVShowState = 8; + break; + case 8: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + GetMapName(gStringVar2, show->breakingNews.location, 0); + sTVShowState = 11; + break; + case 9: + case 10: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + StringCopy(gStringVar2, gSpeciesNames[show->breakingNews.lastOpponentSpecies]); + GetMapName(gStringVar3, show->breakingNews.location, 0); + sTVShowState = 11; + break; + case 11: + TVShowConvertInternationalString(gStringVar1, show->breakingNews.playerName, show->breakingNews.language); + TVShowDone(); + break; } ShowFieldMessage(sTVBreakingNewsTextGroup[state]); } @@ -6249,88 +5897,72 @@ static void DoTVShowSecretBaseVisit(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->secretBaseVisit.playerName, show->secretBaseVisit.language); - if (show->secretBaseVisit.nDecorations == 0) - { - sTVShowState = 2; - } - else - { - sTVShowState = 1; - } - break; - case 1: - StringCopy(gStringVar2, gDecorations[show->secretBaseVisit.decorations[0]].name); - if (show->secretBaseVisit.nDecorations == 1) - { - sTVShowState = 4; - } - else - { - sTVShowState = 3; - } + case 0: + TVShowConvertInternationalString(gStringVar1, show->secretBaseVisit.playerName, show->secretBaseVisit.language); + if (show->secretBaseVisit.nDecorations == 0) + sTVShowState = 2; + else + sTVShowState = 1; + break; + case 1: + StringCopy(gStringVar2, gDecorations[show->secretBaseVisit.decorations[0]].name); + if (show->secretBaseVisit.nDecorations == 1) + sTVShowState = 4; + else + sTVShowState = 3; + break; + case 3: + StringCopy(gStringVar2, gDecorations[show->secretBaseVisit.decorations[1]].name); + switch (show->secretBaseVisit.nDecorations) + { + case 2: + sTVShowState = 7; break; case 3: - StringCopy(gStringVar2, gDecorations[show->secretBaseVisit.decorations[1]].name); - switch (show->secretBaseVisit.nDecorations) - { - case 2: - sTVShowState = 7; - break; - case 3: - sTVShowState = 6; - break; - case 4: - sTVShowState = 5; - break; - } + sTVShowState = 6; break; - case 5: - StringCopy(gStringVar2, gDecorations[show->secretBaseVisit.decorations[2]].name); - StringCopy(gStringVar3, gDecorations[show->secretBaseVisit.decorations[3]].name); - sTVShowState = 8; - break; - case 6: - StringCopy(gStringVar2, gDecorations[show->secretBaseVisit.decorations[2]].name); - sTVShowState = 8; - break; - case 2: case 4: - case 7: - sTVShowState = 8; - break; - case 8: - TVShowConvertInternationalString(gStringVar1, show->secretBaseVisit.playerName, show->secretBaseVisit.language); - if (show->secretBaseVisit.avgLevel < 25) - { - sTVShowState = 12; - } - else if (show->secretBaseVisit.avgLevel < 50) - { - sTVShowState = 11; - } - else if (show->secretBaseVisit.avgLevel < 70) - { - sTVShowState = 10; - } - else - { - sTVShowState = 9; - } - break; - case 9: - case 10: - case 11: - case 12: - TVShowConvertInternationalString(gStringVar1, show->secretBaseVisit.playerName, show->secretBaseVisit.language); - StringCopy(gStringVar2, gSpeciesNames[show->secretBaseVisit.species]); - StringCopy(gStringVar3, gMoveNames[show->secretBaseVisit.move]); - sTVShowState = 13; - break; - case 13: - TVShowDone(); + sTVShowState = 5; break; + } + break; + case 5: + StringCopy(gStringVar2, gDecorations[show->secretBaseVisit.decorations[2]].name); + StringCopy(gStringVar3, gDecorations[show->secretBaseVisit.decorations[3]].name); + sTVShowState = 8; + break; + case 6: + StringCopy(gStringVar2, gDecorations[show->secretBaseVisit.decorations[2]].name); + sTVShowState = 8; + break; + case 2: + case 4: + case 7: + sTVShowState = 8; + break; + case 8: + TVShowConvertInternationalString(gStringVar1, show->secretBaseVisit.playerName, show->secretBaseVisit.language); + if (show->secretBaseVisit.avgLevel < 25) + sTVShowState = 12; + else if (show->secretBaseVisit.avgLevel < 50) + sTVShowState = 11; + else if (show->secretBaseVisit.avgLevel < 70) + sTVShowState = 10; + else + sTVShowState = 9; + break; + case 9: + case 10: + case 11: + case 12: + TVShowConvertInternationalString(gStringVar1, show->secretBaseVisit.playerName, show->secretBaseVisit.language); + StringCopy(gStringVar2, gSpeciesNames[show->secretBaseVisit.species]); + StringCopy(gStringVar3, gMoveNames[show->secretBaseVisit.move]); + sTVShowState = 13; + break; + case 13: + TVShowDone(); + break; } ShowFieldMessage(sTVSecretBaseVisitTextGroup[state]); } @@ -6375,56 +6007,56 @@ static void DoTVShowThePokemonBattleSeminar(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->battleSeminar.playerName, show->battleSeminar.language); - StringCopy(gStringVar2, gSpeciesNames[show->battleSeminar.species]); - StringCopy(gStringVar3, gSpeciesNames[show->battleSeminar.foeSpecies]); - sTVShowState = 1; - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->battleSeminar.playerName, show->battleSeminar.language); + StringCopy(gStringVar2, gSpeciesNames[show->battleSeminar.species]); + StringCopy(gStringVar3, gSpeciesNames[show->battleSeminar.foeSpecies]); + sTVShowState = 1; + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->battleSeminar.playerName, show->battleSeminar.language); + StringCopy(gStringVar2, gSpeciesNames[show->battleSeminar.foeSpecies]); + StringCopy(gStringVar3, gMoveNames[show->battleSeminar.move]); + sTVShowState = 2; + break; + case 2: + StringCopy(gStringVar1, gSpeciesNames[show->battleSeminar.species]); + switch (show->battleSeminar.nOtherMoves) + { case 1: - TVShowConvertInternationalString(gStringVar1, show->battleSeminar.playerName, show->battleSeminar.language); - StringCopy(gStringVar2, gSpeciesNames[show->battleSeminar.foeSpecies]); - StringCopy(gStringVar3, gMoveNames[show->battleSeminar.move]); - sTVShowState = 2; + sTVShowState = 5; break; case 2: - StringCopy(gStringVar1, gSpeciesNames[show->battleSeminar.species]); - switch (show->battleSeminar.nOtherMoves) - { - case 1: - sTVShowState = 5; - break; - case 2: - sTVShowState = 4; - break; - case 3: - sTVShowState = 3; - break; - default: - sTVShowState = 6; - break; - } + sTVShowState = 4; break; case 3: - StringCopy(gStringVar1, gMoveNames[show->battleSeminar.otherMoves[0]]); - StringCopy(gStringVar2, gMoveNames[show->battleSeminar.otherMoves[1]]); - StringCopy(gStringVar3, gMoveNames[show->battleSeminar.otherMoves[2]]); + sTVShowState = 3; + break; + default: sTVShowState = 6; break; - case 4: - StringCopy(gStringVar1, gMoveNames[show->battleSeminar.otherMoves[0]]); - StringCopy(gStringVar2, gMoveNames[show->battleSeminar.otherMoves[1]]); - sTVShowState = 6; - break; - case 5: - StringCopy(gStringVar2, gMoveNames[show->battleSeminar.otherMoves[0]]); - sTVShowState = 6; - break; - case 6: - StringCopy(gStringVar1, gMoveNames[show->battleSeminar.betterMove]); - StringCopy(gStringVar2, gMoveNames[show->battleSeminar.move]); - TVShowDone(); - break; + } + break; + case 3: + StringCopy(gStringVar1, gMoveNames[show->battleSeminar.otherMoves[0]]); + StringCopy(gStringVar2, gMoveNames[show->battleSeminar.otherMoves[1]]); + StringCopy(gStringVar3, gMoveNames[show->battleSeminar.otherMoves[2]]); + sTVShowState = 6; + break; + case 4: + StringCopy(gStringVar1, gMoveNames[show->battleSeminar.otherMoves[0]]); + StringCopy(gStringVar2, gMoveNames[show->battleSeminar.otherMoves[1]]); + sTVShowState = 6; + break; + case 5: + StringCopy(gStringVar2, gMoveNames[show->battleSeminar.otherMoves[0]]); + sTVShowState = 6; + break; + case 6: + StringCopy(gStringVar1, gMoveNames[show->battleSeminar.betterMove]); + StringCopy(gStringVar2, gMoveNames[show->battleSeminar.move]); + TVShowDone(); + break; } ShowFieldMessage(sTVThePokemonBattleSeminarTextGroup[state]); } @@ -6439,57 +6071,49 @@ static void DoTVShowTrainerFanClubSpecial(void) state = sTVShowState; switch (state) { - case 0: - TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); - CopyEasyChatWord(gStringVar3, show->fanClubSpecial.words[0]); - if (show->fanClubSpecial.score >= 90) - { - sTVShowState = 1; - } - else if (show->fanClubSpecial.score >= 70) - { - sTVShowState = 2; - } - else if (show->fanClubSpecial.score >= 30) - { - sTVShowState = 3; - } - else - { - sTVShowState = 4; - } - break; - case 1: - TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); - TV_PrintIntToStringVar(2, show->fanClubSpecial.score); - sTVShowState = 5; - break; - case 2: - TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); - TV_PrintIntToStringVar(2, show->fanClubSpecial.score); - sTVShowState = 5; - break; - case 3: - TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); - TV_PrintIntToStringVar(2, show->fanClubSpecial.score); - sTVShowState = 5; - break; - case 4: - TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); - TV_PrintIntToStringVar(2, show->fanClubSpecial.score); - sTVShowState = 5; - break; - case 5: - TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); - CopyEasyChatWord(gStringVar3, show->fanClubSpecial.words[0]); - TVShowDone(); - break; + case 0: + TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); + CopyEasyChatWord(gStringVar3, show->fanClubSpecial.words[0]); + if (show->fanClubSpecial.score >= 90) + sTVShowState = 1; + else if (show->fanClubSpecial.score >= 70) + sTVShowState = 2; + else if (show->fanClubSpecial.score >= 30) + sTVShowState = 3; + else + sTVShowState = 4; + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); + ConvertIntToDecimalString(2, show->fanClubSpecial.score); + sTVShowState = 5; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); + ConvertIntToDecimalString(2, show->fanClubSpecial.score); + sTVShowState = 5; + break; + case 3: + TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); + ConvertIntToDecimalString(2, show->fanClubSpecial.score); + sTVShowState = 5; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); + ConvertIntToDecimalString(2, show->fanClubSpecial.score); + sTVShowState = 5; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->fanClubSpecial.idolName, show->fanClubSpecial.idolNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->fanClubSpecial.playerName, show->fanClubSpecial.language); + CopyEasyChatWord(gStringVar3, show->fanClubSpecial.words[0]); + TVShowDone(); + break; } ShowFieldMessage(sTVTrainerFanClubSpecialTextGroup[state]); } @@ -6505,78 +6129,79 @@ static void DoTVShowTrainerFanClub(void) state = sTVShowState; switch (state) { + case 0: + TVShowConvertInternationalString(gStringVar1, show->trainerFanClub.playerName, show->trainerFanClub.language); + playerId = ((show->common.trainerIdHi << 8) + show->common.trainerIdLo); + switch (playerId % 10) + { case 0: - TVShowConvertInternationalString(gStringVar1, show->trainerFanClub.playerName, show->trainerFanClub.language); - playerId = ((show->common.trainerIdHi << 8) + show->common.trainerIdLo); - switch (playerId % 10) - { - case 0: - sTVShowState = 1; - break; - case 1: - sTVShowState = 2; - break; - case 2: - sTVShowState = 3; - break; - case 3: - sTVShowState = 4; - break; - case 4: - sTVShowState = 5; - break; - case 5: - sTVShowState = 6; - break; - case 6: - sTVShowState = 7; - break; - case 7: - sTVShowState = 8; - break; - case 8: - sTVShowState = 9; - break; - case 9: - sTVShowState = 10; - break; - } + sTVShowState = 1; break; case 1: - sTVShowState = 11; + sTVShowState = 2; break; case 2: - sTVShowState = 11; + sTVShowState = 3; break; case 3: - sTVShowState = 11; + sTVShowState = 4; break; case 4: - sTVShowState = 11; + sTVShowState = 5; break; case 5: - sTVShowState = 11; + sTVShowState = 6; break; case 6: - sTVShowState = 11; + sTVShowState = 7; break; case 7: - sTVShowState = 11; + sTVShowState = 8; break; case 8: - sTVShowState = 11; + sTVShowState = 9; break; case 9: - sTVShowState = 11; + sTVShowState = 10; break; - case 10: - sTVShowState = 11; - break; - case 11: - TVShowConvertInternationalString(gStringVar1, show->trainerFanClub.playerName, show->trainerFanClub.language); - CopyEasyChatWord(gStringVar2, show->trainerFanClub.words[0]); - CopyEasyChatWord(gStringVar3, show->trainerFanClub.words[1]); - TVShowDone(); + } + break; + case 1: + sTVShowState = 11; + break; + case 2: + sTVShowState = 11; + break; + case 3: + sTVShowState = 11; + break; + case 4: + sTVShowState = 11; + break; + case 5: + sTVShowState = 11; + break; + case 6: + sTVShowState = 11; + break; + case 7: + sTVShowState = 11; + break; + case 8: + sTVShowState = 11; + break; + case 9: + sTVShowState = 11; + break; + case 10: + sTVShowState = 11; + break; + case 11: + TVShowConvertInternationalString(gStringVar1, show->trainerFanClub.playerName, show->trainerFanClub.language); + CopyEasyChatWord(gStringVar2, show->trainerFanClub.words[0]); + CopyEasyChatWord(gStringVar3, show->trainerFanClub.words[1]); + TVShowDone(); + break; } ShowFieldMessage(sTVTrainerFanClubTextGroup[state]); } @@ -6594,95 +6219,95 @@ static void DoTVShowSpotTheCuties(void) state = sTVShowState; switch (state) { - case SPOTCUTIES_STATE_INTRO: - TVShowConvertInternationalString(gStringVar1, show->cuties.playerName, show->cuties.language); - TVShowConvertInternationalString(gStringVar2, show->cuties.nickname, show->cuties.pokemonNameLanguage); + case SPOTCUTIES_STATE_INTRO: + TVShowConvertInternationalString(gStringVar1, show->cuties.playerName, show->cuties.language); + TVShowConvertInternationalString(gStringVar2, show->cuties.nickname, show->cuties.pokemonNameLanguage); - // Comments following the intro depend on how many ribbons the pokemon has - if (show->cuties.nRibbons < 10) - sTVShowState = SPOTCUTIES_STATE_RIBBONS_LOW; - else if (show->cuties.nRibbons < 20) - sTVShowState = SPOTCUTIES_STATE_RIBBONS_MID; - else - sTVShowState = SPOTCUTIES_STATE_RIBBONS_HIGH; + // Comments following the intro depend on how many ribbons the pokemon has + if (show->cuties.nRibbons < 10) + sTVShowState = SPOTCUTIES_STATE_RIBBONS_LOW; + else if (show->cuties.nRibbons < 20) + sTVShowState = SPOTCUTIES_STATE_RIBBONS_MID; + else + sTVShowState = SPOTCUTIES_STATE_RIBBONS_HIGH; + break; + case SPOTCUTIES_STATE_RIBBONS_LOW: + case SPOTCUTIES_STATE_RIBBONS_MID: + case SPOTCUTIES_STATE_RIBBONS_HIGH: + TVShowConvertInternationalString(gStringVar1, show->cuties.playerName, show->cuties.language); + TVShowConvertInternationalString(gStringVar2, show->cuties.nickname, show->cuties.pokemonNameLanguage); + ConvertIntToDecimalString(2, show->cuties.nRibbons); + sTVShowState = SPOTCUTIES_STATE_RIBBON_INTRO; + break; + case SPOTCUTIES_STATE_RIBBON_INTRO: + TVShowConvertInternationalString(gStringVar2, show->cuties.nickname, show->cuties.pokemonNameLanguage); + switch (show->cuties.selectedRibbon) + { + case CHAMPION_RIBBON: + sTVShowState = SPOTCUTIES_STATE_RIBBON_CHAMPION; break; - case SPOTCUTIES_STATE_RIBBONS_LOW: - case SPOTCUTIES_STATE_RIBBONS_MID: - case SPOTCUTIES_STATE_RIBBONS_HIGH: - TVShowConvertInternationalString(gStringVar1, show->cuties.playerName, show->cuties.language); - TVShowConvertInternationalString(gStringVar2, show->cuties.nickname, show->cuties.pokemonNameLanguage); - TV_PrintIntToStringVar(2, show->cuties.nRibbons); - sTVShowState = SPOTCUTIES_STATE_RIBBON_INTRO; + case COOL_RIBBON_NORMAL: + case COOL_RIBBON_SUPER: + case COOL_RIBBON_HYPER: + case COOL_RIBBON_MASTER: + sTVShowState = SPOTCUTIES_STATE_RIBBON_COOL; break; - case SPOTCUTIES_STATE_RIBBON_INTRO: - TVShowConvertInternationalString(gStringVar2, show->cuties.nickname, show->cuties.pokemonNameLanguage); - switch (show->cuties.selectedRibbon) - { - case CHAMPION_RIBBON: - sTVShowState = SPOTCUTIES_STATE_RIBBON_CHAMPION; - break; - case COOL_RIBBON_NORMAL: - case COOL_RIBBON_SUPER: - case COOL_RIBBON_HYPER: - case COOL_RIBBON_MASTER: - sTVShowState = SPOTCUTIES_STATE_RIBBON_COOL; - break; - case BEAUTY_RIBBON_NORMAL: - case BEAUTY_RIBBON_SUPER: - case BEAUTY_RIBBON_HYPER: - case BEAUTY_RIBBON_MASTER: - sTVShowState = SPOTCUTIES_STATE_RIBBON_BEAUTY; - break; - case CUTE_RIBBON_NORMAL: - case CUTE_RIBBON_SUPER: - case CUTE_RIBBON_HYPER: - case CUTE_RIBBON_MASTER: - sTVShowState = SPOTCUTIES_STATE_RIBBON_CUTE; - break; - case SMART_RIBBON_NORMAL: - case SMART_RIBBON_SUPER: - case SMART_RIBBON_HYPER: - case SMART_RIBBON_MASTER: - sTVShowState = SPOTCUTIES_STATE_RIBBON_SMART; - break; - case TOUGH_RIBBON_NORMAL: - case TOUGH_RIBBON_SUPER: - case TOUGH_RIBBON_HYPER: - case TOUGH_RIBBON_MASTER: - sTVShowState = SPOTCUTIES_STATE_RIBBON_TOUGH; - break; - case WINNING_RIBBON: - sTVShowState = SPOTCUTIES_STATE_RIBBON_WINNING; - break; - case VICTORY_RIBBON: - sTVShowState = SPOTCUTIES_STATE_RIBBON_VICTORY; - break; - case ARTIST_RIBBON: - sTVShowState = SPOTCUTIES_STATE_RIBBON_ARTIST; - break; - case EFFORT_RIBBON: - sTVShowState = SPOTCUTIES_STATE_RIBBON_EFFORT; - break; - // No comment is made for any of the gift ribbons. - // If the show is created for a gift ribbon - // then this state will repeat indefinitely - } + case BEAUTY_RIBBON_NORMAL: + case BEAUTY_RIBBON_SUPER: + case BEAUTY_RIBBON_HYPER: + case BEAUTY_RIBBON_MASTER: + sTVShowState = SPOTCUTIES_STATE_RIBBON_BEAUTY; break; - case SPOTCUTIES_STATE_RIBBON_CHAMPION: - case SPOTCUTIES_STATE_RIBBON_COOL: - case SPOTCUTIES_STATE_RIBBON_BEAUTY: - case SPOTCUTIES_STATE_RIBBON_CUTE: - case SPOTCUTIES_STATE_RIBBON_SMART: - case SPOTCUTIES_STATE_RIBBON_TOUGH: - case SPOTCUTIES_STATE_RIBBON_WINNING: - case SPOTCUTIES_STATE_RIBBON_VICTORY: - case SPOTCUTIES_STATE_RIBBON_ARTIST: - case SPOTCUTIES_STATE_RIBBON_EFFORT: - TVShowConvertInternationalString(gStringVar2, show->cuties.nickname, show->cuties.pokemonNameLanguage); - sTVShowState = SPOTCUTIES_STATE_OUTRO; + case CUTE_RIBBON_NORMAL: + case CUTE_RIBBON_SUPER: + case CUTE_RIBBON_HYPER: + case CUTE_RIBBON_MASTER: + sTVShowState = SPOTCUTIES_STATE_RIBBON_CUTE; break; - case SPOTCUTIES_STATE_OUTRO: - TVShowDone(); + case SMART_RIBBON_NORMAL: + case SMART_RIBBON_SUPER: + case SMART_RIBBON_HYPER: + case SMART_RIBBON_MASTER: + sTVShowState = SPOTCUTIES_STATE_RIBBON_SMART; + break; + case TOUGH_RIBBON_NORMAL: + case TOUGH_RIBBON_SUPER: + case TOUGH_RIBBON_HYPER: + case TOUGH_RIBBON_MASTER: + sTVShowState = SPOTCUTIES_STATE_RIBBON_TOUGH; + break; + case WINNING_RIBBON: + sTVShowState = SPOTCUTIES_STATE_RIBBON_WINNING; + break; + case VICTORY_RIBBON: + sTVShowState = SPOTCUTIES_STATE_RIBBON_VICTORY; + break; + case ARTIST_RIBBON: + sTVShowState = SPOTCUTIES_STATE_RIBBON_ARTIST; + break; + case EFFORT_RIBBON: + sTVShowState = SPOTCUTIES_STATE_RIBBON_EFFORT; + break; + // No comment is made for any of the gift ribbons. + // If the show is created for a gift ribbon + // then this state will repeat indefinitely + } + break; + case SPOTCUTIES_STATE_RIBBON_CHAMPION: + case SPOTCUTIES_STATE_RIBBON_COOL: + case SPOTCUTIES_STATE_RIBBON_BEAUTY: + case SPOTCUTIES_STATE_RIBBON_CUTE: + case SPOTCUTIES_STATE_RIBBON_SMART: + case SPOTCUTIES_STATE_RIBBON_TOUGH: + case SPOTCUTIES_STATE_RIBBON_WINNING: + case SPOTCUTIES_STATE_RIBBON_VICTORY: + case SPOTCUTIES_STATE_RIBBON_ARTIST: + case SPOTCUTIES_STATE_RIBBON_EFFORT: + TVShowConvertInternationalString(gStringVar2, show->cuties.nickname, show->cuties.pokemonNameLanguage); + sTVShowState = SPOTCUTIES_STATE_OUTRO; + break; + case SPOTCUTIES_STATE_OUTRO: + TVShowDone(); } ShowFieldMessage(sTVCutiesTextGroup[state]); } @@ -6697,140 +6322,140 @@ static void DoTVShowPokemonNewsBattleFrontier(void) state = sTVShowState; switch (state) { - case 0: - switch (show->frontier.facility) - { - case 1: - sTVShowState = 1; - break; - case 2: - sTVShowState = 2; - break; - case 3: - sTVShowState = 3; - break; - case 4: - sTVShowState = 4; - break; - case 5: - sTVShowState = 5; - break; - case 6: - sTVShowState = 6; - break; - case 7: - sTVShowState = 7; - break; - case 8: - sTVShowState = 8; - break; - case 9: - sTVShowState = 9; - break; - case 10: - sTVShowState = 10; - break; - case 11: - sTVShowState = 11; - break; - case 12: - sTVShowState = 12; - break; - case 13: - sTVShowState = 13; - break; - } - break; + case 0: + switch (show->frontier.facilityAndMode) + { case 1: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 1; break; case 2: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 16; + sTVShowState = 2; break; case 3: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 15; + sTVShowState = 3; break; case 4: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 15; + sTVShowState = 4; break; case 5: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 5; break; case 6: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 6; break; case 7: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 7; break; case 8: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 8; break; case 9: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 9; break; case 10: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 10; break; case 11: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 11; break; case 12: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; + sTVShowState = 12; break; case 13: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TV_PrintIntToStringVar(1, show->frontier.winStreak); - sTVShowState = 14; - break; - case 14: - StringCopy(gStringVar1, gSpeciesNames[show->frontier.species1]); - StringCopy(gStringVar2, gSpeciesNames[show->frontier.species2]); - StringCopy(gStringVar3, gSpeciesNames[show->frontier.species3]); - sTVShowState = 18; - break; - case 15: - StringCopy(gStringVar1, gSpeciesNames[show->frontier.species1]); - StringCopy(gStringVar2, gSpeciesNames[show->frontier.species2]); - sTVShowState = 18; - break; - case 16: - StringCopy(gStringVar1, gSpeciesNames[show->frontier.species1]); - StringCopy(gStringVar2, gSpeciesNames[show->frontier.species2]); - StringCopy(gStringVar3, gSpeciesNames[show->frontier.species3]); - sTVShowState = 17; - break; - case 17: - StringCopy(gStringVar1, gSpeciesNames[show->frontier.species4]); - sTVShowState = 18; - break; - case 18: - TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); - TVShowDone(); + sTVShowState = 13; break; + } + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 16; + break; + case 3: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 15; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 15; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 7: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 8: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 9: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 10: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 11: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 12: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 13: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + ConvertIntToDecimalString(1, show->frontier.winStreak); + sTVShowState = 14; + break; + case 14: + StringCopy(gStringVar1, gSpeciesNames[show->frontier.species1]); + StringCopy(gStringVar2, gSpeciesNames[show->frontier.species2]); + StringCopy(gStringVar3, gSpeciesNames[show->frontier.species3]); + sTVShowState = 18; + break; + case 15: + StringCopy(gStringVar1, gSpeciesNames[show->frontier.species1]); + StringCopy(gStringVar2, gSpeciesNames[show->frontier.species2]); + sTVShowState = 18; + break; + case 16: + StringCopy(gStringVar1, gSpeciesNames[show->frontier.species1]); + StringCopy(gStringVar2, gSpeciesNames[show->frontier.species2]); + StringCopy(gStringVar3, gSpeciesNames[show->frontier.species3]); + sTVShowState = 17; + break; + case 17: + StringCopy(gStringVar1, gSpeciesNames[show->frontier.species4]); + sTVShowState = 18; + break; + case 18: + TVShowConvertInternationalString(gStringVar1, show->frontier.playerName, show->frontier.language); + TVShowDone(); + break; } ShowFieldMessage(sTVPokemonNewsBattleFrontierTextGroup[state]); } @@ -6845,72 +6470,72 @@ static void DoTVShowWhatsNo1InHoennToday(void) state = sTVShowState; switch (state) { + case 0: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + switch (show->numberOne.actionIdx) + { case 0: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - switch (show->numberOne.actionIdx) - { - case 0: - sTVShowState = 1; - break; - case 1: - sTVShowState = 2; - break; - case 2: - sTVShowState = 3; - break; - case 3: - sTVShowState = 4; - break; - case 4: - sTVShowState = 5; - break; - case 5: - sTVShowState = 6; - break; - case 6: - sTVShowState = 7; - break; - } + sTVShowState = 1; break; case 1: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - TV_PrintIntToStringVar(1, show->numberOne.count); - sTVShowState = 8; + sTVShowState = 2; break; case 2: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - TV_PrintIntToStringVar(1, show->numberOne.count); - sTVShowState = 8; + sTVShowState = 3; break; case 3: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - TV_PrintIntToStringVar(1, show->numberOne.count); - sTVShowState = 8; + sTVShowState = 4; break; case 4: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - TV_PrintIntToStringVar(1, show->numberOne.count); - sTVShowState = 8; + sTVShowState = 5; break; case 5: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - TV_PrintIntToStringVar(1, show->numberOne.count); - sTVShowState = 8; + sTVShowState = 6; break; case 6: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - TV_PrintIntToStringVar(1, show->numberOne.count); - sTVShowState = 8; - break; - case 7: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - TV_PrintIntToStringVar(1, show->numberOne.count); - sTVShowState = 8; - break; - case 8: - TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); - TVShowDone(); + sTVShowState = 7; break; + } + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + ConvertIntToDecimalString(1, show->numberOne.count); + sTVShowState = 8; + break; + case 2: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + ConvertIntToDecimalString(1, show->numberOne.count); + sTVShowState = 8; + break; + case 3: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + ConvertIntToDecimalString(1, show->numberOne.count); + sTVShowState = 8; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + ConvertIntToDecimalString(1, show->numberOne.count); + sTVShowState = 8; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + ConvertIntToDecimalString(1, show->numberOne.count); + sTVShowState = 8; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + ConvertIntToDecimalString(1, show->numberOne.count); + sTVShowState = 8; + break; + case 7: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + ConvertIntToDecimalString(1, show->numberOne.count); + sTVShowState = 8; + break; + case 8: + TVShowConvertInternationalString(gStringVar1, show->numberOne.playerName, show->numberOne.language); + TVShowDone(); + break; } ShowFieldMessage(sTVWhatsNo1InHoennTodayTextGroup[state]); } @@ -6920,7 +6545,7 @@ u8 SecretBaseSecrets_GetNumActionsTaken(TVShow *show) u8 i; u8 flagsSet; - for (i = 0, flagsSet = 0; i < NUM_SECRET_BASE_FLAGS; i ++) + for (i = 0, flagsSet = 0; i < NUM_SECRET_BASE_FLAGS; i++) { if ((show->secretBaseSecrets.flags >> i) & 1) flagsSet++; @@ -6933,7 +6558,7 @@ static u8 SecretBaseSecrets_GetStateByFlagNumber(TVShow *show, u8 flagId) u8 i; u8 flagsSet; - for (i = 0, flagsSet = 0; i < NUM_SECRET_BASE_FLAGS; i ++) + for (i = 0, flagsSet = 0; i < NUM_SECRET_BASE_FLAGS; i++) { if ((show->secretBaseSecrets.flags >> i) & 1) { @@ -6958,130 +6583,112 @@ static void DoTVShowSecretBaseSecrets(void) state = sTVShowState; switch (state) { - case SBSECRETS_STATE_INTRO: - TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); - numActions = SecretBaseSecrets_GetNumActionsTaken(show); - if (numActions == 0) - { - sTVShowState = SBSECRETS_STATE_NOTHING_USED1; - } - else - { - show->secretBaseSecrets.savedState = SBSECRETS_STATE_DO_NEXT1; - sTVSecretBaseSecretsRandomValues[0] = Random() % numActions; - sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, sTVSecretBaseSecretsRandomValues[0]); - } + case SBSECRETS_STATE_INTRO: + TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); + numActions = SecretBaseSecrets_GetNumActionsTaken(show); + if (numActions == 0) + { + sTVShowState = SBSECRETS_STATE_NOTHING_USED1; + } + else + { + show->secretBaseSecrets.savedState = SBSECRETS_STATE_DO_NEXT1; + sTVSecretBaseSecretsRandomValues[0] = Random() % numActions; + sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, sTVSecretBaseSecretsRandomValues[0]); + } + break; + case SBSECRETS_STATE_DO_NEXT1: + TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); + numActions = SecretBaseSecrets_GetNumActionsTaken(show); + switch (numActions) + { + case 1: + sTVShowState = SBSECRETS_STATE_NOTHING_USED2; break; - case SBSECRETS_STATE_DO_NEXT1: - TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); - numActions = SecretBaseSecrets_GetNumActionsTaken(show); - switch (numActions) + case 2: + show->secretBaseSecrets.savedState = SBSECRETS_STATE_DO_NEXT2; + if (sTVSecretBaseSecretsRandomValues[0] == 0) + sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, 1); + else + sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, 0); + break; + default: + for (i = 0; i < 0xFFFF; i++) { - case 1: - sTVShowState = SBSECRETS_STATE_NOTHING_USED2; - break; - case 2: - show->secretBaseSecrets.savedState = SBSECRETS_STATE_DO_NEXT2; - if (sTVSecretBaseSecretsRandomValues[0] == 0) - { - sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, 1); - } - else - { - sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, 0); - } - break; - default: - for (i = 0; i < 0xFFFF; i ++) - { - sTVSecretBaseSecretsRandomValues[1] = Random() % numActions; - if (sTVSecretBaseSecretsRandomValues[1] != sTVSecretBaseSecretsRandomValues[0]) - { - break; - } - } - show->secretBaseSecrets.savedState = SBSECRETS_STATE_DO_NEXT2; - sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, sTVSecretBaseSecretsRandomValues[1]); + sTVSecretBaseSecretsRandomValues[1] = Random() % numActions; + if (sTVSecretBaseSecretsRandomValues[1] != sTVSecretBaseSecretsRandomValues[0]) break; } + show->secretBaseSecrets.savedState = SBSECRETS_STATE_DO_NEXT2; + sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, sTVSecretBaseSecretsRandomValues[1]); break; - case SBSECRETS_STATE_DO_NEXT2: - TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); - numActions = SecretBaseSecrets_GetNumActionsTaken(show); - if (numActions == 2) + } + break; + case SBSECRETS_STATE_DO_NEXT2: + TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); + numActions = SecretBaseSecrets_GetNumActionsTaken(show); + if (numActions == 2) + { + sTVShowState = SBSECRETS_STATE_NOTHING_USED2; + } + else + { + for (i = 0; i < 0xFFFF; i++) { - sTVShowState = SBSECRETS_STATE_NOTHING_USED2; + sTVSecretBaseSecretsRandomValues[2] = Random() % numActions; + if (sTVSecretBaseSecretsRandomValues[2] != sTVSecretBaseSecretsRandomValues[0] && sTVSecretBaseSecretsRandomValues[2] != sTVSecretBaseSecretsRandomValues[1]) + break; } - else - { - for (i = 0; i < 0xFFFF; i ++) - { - sTVSecretBaseSecretsRandomValues[2] = Random() % numActions; - if (sTVSecretBaseSecretsRandomValues[2] != sTVSecretBaseSecretsRandomValues[0] && sTVSecretBaseSecretsRandomValues[2] != sTVSecretBaseSecretsRandomValues[1]) - { - break; - } - } - show->secretBaseSecrets.savedState = SBSECRETS_STATE_TOOK_X_STEPS; - sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, sTVSecretBaseSecretsRandomValues[2]); - } - break; - case SBSECRETS_STATE_TOOK_X_STEPS: - TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); - TV_PrintIntToStringVar(2, show->secretBaseSecrets.stepsInBase); - if (show->secretBaseSecrets.stepsInBase <= 30) - { - sTVShowState = SBSECRETS_STATE_BASE_INTEREST_LOW; - } - else if (show->secretBaseSecrets.stepsInBase <= 100) - { - sTVShowState = SBSECRETS_STATE_BASE_INTEREST_MED; - } - else - { - sTVShowState = SBSECRETS_STATE_BASE_INTEREST_HIGH; - } - break; - case SBSECRETS_STATE_BASE_INTEREST_LOW ... SBSECRETS_STATE_BASE_INTEREST_HIGH: - TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); - sTVShowState = SBSECRETS_STATE_OUTRO; - break; - case SBSECRETS_STATE_OUTRO: - TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage); - TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); - TVShowDone(); - break; - // All below states are descriptions of what the player interacted with while in the secret base - case SBSECRETS_STATE_NOTHING_USED1: - sTVShowState = SBSECRETS_STATE_TOOK_X_STEPS; - break; - case SBSECRETS_STATE_NOTHING_USED2: - sTVShowState = SBSECRETS_STATE_TOOK_X_STEPS; - break; - case SBSECRETS_STATE_USED_CHAIR ... SBSECRETS_STATE_USED_MUD_BALL: - sTVShowState = show->secretBaseSecrets.savedState; - break; - case SBSECRETS_STATE_USED_BAG: - StringCopy(gStringVar2, ItemId_GetName(show->secretBaseSecrets.item)); - sTVShowState = show->secretBaseSecrets.savedState; - break; - case SBSECRETS_STATE_USED_CUSHION: - // Randomly decide based on trainer ID if the player hugged or hit the cushion - if (show->common.trainerIdLo & 1) - { - sTVShowState = SBSECRETS_STATE_HUGGED_CUSHION; - } - else - { - sTVShowState = SBSECRETS_STATE_HIT_CUSHION; - } - break; - case SBSECRETS_STATE_HIT_CUSHION ... SBSECRETS_NUM_STATES: - sTVShowState = show->secretBaseSecrets.savedState; - break; + show->secretBaseSecrets.savedState = SBSECRETS_STATE_TOOK_X_STEPS; + sTVShowState = SecretBaseSecrets_GetStateByFlagNumber(show, sTVSecretBaseSecretsRandomValues[2]); + } + break; + case SBSECRETS_STATE_TOOK_X_STEPS: + TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); + ConvertIntToDecimalString(2, show->secretBaseSecrets.stepsInBase); + if (show->secretBaseSecrets.stepsInBase <= 30) + sTVShowState = SBSECRETS_STATE_BASE_INTEREST_LOW; + else if (show->secretBaseSecrets.stepsInBase <= 100) + sTVShowState = SBSECRETS_STATE_BASE_INTEREST_MED; + else + sTVShowState = SBSECRETS_STATE_BASE_INTEREST_HIGH; + break; + case SBSECRETS_STATE_BASE_INTEREST_LOW ... SBSECRETS_STATE_BASE_INTEREST_HIGH: + TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); + sTVShowState = SBSECRETS_STATE_OUTRO; + break; + case SBSECRETS_STATE_OUTRO: + TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage); + TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language); + TVShowDone(); + break; + // All below states are descriptions of what the player interacted with while in the secret base + case SBSECRETS_STATE_NOTHING_USED1: + sTVShowState = SBSECRETS_STATE_TOOK_X_STEPS; + break; + case SBSECRETS_STATE_NOTHING_USED2: + sTVShowState = SBSECRETS_STATE_TOOK_X_STEPS; + break; + case SBSECRETS_STATE_USED_CHAIR ... SBSECRETS_STATE_USED_MUD_BALL: + sTVShowState = show->secretBaseSecrets.savedState; + break; + case SBSECRETS_STATE_USED_BAG: + StringCopy(gStringVar2, ItemId_GetName(show->secretBaseSecrets.item)); + sTVShowState = show->secretBaseSecrets.savedState; + break; + case SBSECRETS_STATE_USED_CUSHION: + // Randomly decide based on trainer ID if the player hugged or hit the cushion + if (show->common.trainerIdLo & 1) + sTVShowState = SBSECRETS_STATE_HUGGED_CUSHION; + else + sTVShowState = SBSECRETS_STATE_HIT_CUSHION; + break; + case SBSECRETS_STATE_HIT_CUSHION ... SBSECRETS_NUM_STATES: + sTVShowState = show->secretBaseSecrets.savedState; + break; } ShowFieldMessage(sTVSecretBaseSecretsTextGroup[state]); } @@ -7096,79 +6703,62 @@ static void DoTVShowSafariFanClub(void) state = sTVShowState; switch (state) { - case 0: - if (show->safariFanClub.nMonsCaught == 0) - { - sTVShowState = 6; - } - else if (show->safariFanClub.nMonsCaught < 4) - { - sTVShowState = 5; - } - else - { - sTVShowState = 1; - } - break; - case 1: - TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); - TV_PrintIntToStringVar(1, show->safariFanClub.nMonsCaught); - if (show->safariFanClub.nPkblkUsed == 0) - { - sTVShowState = 3; - } - else - { - sTVShowState = 2; - } - break; - case 2: - TV_PrintIntToStringVar(1, show->safariFanClub.nPkblkUsed); - sTVShowState = 4; - break; - case 3: - sTVShowState = 4; - break; - case 4: - TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); - sTVShowState = 10; - break; - case 5: - TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); - TV_PrintIntToStringVar(1, show->safariFanClub.nMonsCaught); - if (show->safariFanClub.nPkblkUsed == 0) - { - sTVShowState = 8; - } - else - { - sTVShowState = 7; - } - break; - case 6: - TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); - if (show->safariFanClub.nPkblkUsed == 0) - { - sTVShowState = 8; - } - else - { - sTVShowState = 7; - } - break; - case 7: - TV_PrintIntToStringVar(1, show->safariFanClub.nPkblkUsed); - sTVShowState = 9; - break; - case 8: - sTVShowState = 9; - break; - case 9: - TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); - sTVShowState = 10; - break; - case 10: - TVShowDone(); + case 0: + if (show->safariFanClub.nMonsCaught == 0) + sTVShowState = 6; + else if (show->safariFanClub.nMonsCaught < 4) + sTVShowState = 5; + else + sTVShowState = 1; + break; + case 1: + TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); + ConvertIntToDecimalString(1, show->safariFanClub.nMonsCaught); + if (show->safariFanClub.nPkblkUsed == 0) + sTVShowState = 3; + else + sTVShowState = 2; + break; + case 2: + ConvertIntToDecimalString(1, show->safariFanClub.nPkblkUsed); + sTVShowState = 4; + break; + case 3: + sTVShowState = 4; + break; + case 4: + TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); + sTVShowState = 10; + break; + case 5: + TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); + ConvertIntToDecimalString(1, show->safariFanClub.nMonsCaught); + if (show->safariFanClub.nPkblkUsed == 0) + sTVShowState = 8; + else + sTVShowState = 7; + break; + case 6: + TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); + if (show->safariFanClub.nPkblkUsed == 0) + sTVShowState = 8; + else + sTVShowState = 7; + break; + case 7: + ConvertIntToDecimalString(1, show->safariFanClub.nPkblkUsed); + sTVShowState = 9; + break; + case 8: + sTVShowState = 9; + break; + case 9: + TVShowConvertInternationalString(gStringVar1, show->safariFanClub.playerName, show->safariFanClub.language); + sTVShowState = 10; + break; + case 10: + TVShowDone(); + break; } ShowFieldMessage(sTVSafariFanClubTextGroup[state]); } @@ -7187,17 +6777,11 @@ static void DoTVShowLilycoveContestLady(void) case CONTESTLADYLIVE_STATE_INTRO: BufferContestName(gStringVar1, show->contestLady.contestCategory); if (show->contestLady.pokeblockState == CONTEST_LADY_GOOD) - { sTVShowState = CONTESTLADYLIVE_STATE_WON; - } else if (show->contestLady.pokeblockState == CONTEST_LADY_NORMAL) - { sTVShowState = CONTESTLADYLIVE_STATE_LOST; - } else // CONTEST_LADY_BAD - { sTVShowState = CONTESTLADYLIVE_STATE_LOST_BADLY; - } break; case CONTESTLADYLIVE_STATE_WON: case CONTESTLADYLIVE_STATE_LOST: @@ -7210,7 +6794,7 @@ static void DoTVShowLilycoveContestLady(void) ShowFieldMessage(sTVLilycoveContestLadyTextGroup[state]); } -void TVShowDone(void) +static void TVShowDone(void) { gSpecialVar_Result = TRUE; sTVShowState = 0;