From 3bbdee61b823d7a6c54792062b7fd27e8c574f00 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 13 Nov 2019 16:31:01 -0500 Subject: [PATCH] Clean up Trainer Hill doc --- data/maps/TrainerHill_Entrance/scripts.inc | 3 ++- include/constants/trainer_hill.h | 7 +++--- include/trainer_hill.h | 2 +- src/data/battle_frontier/trainer_hill.h | 26 +++++++++++----------- src/ereader_helpers.c | 2 +- src/trainer_hill.c | 13 ++++++----- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/data/maps/TrainerHill_Entrance/scripts.inc b/data/maps/TrainerHill_Entrance/scripts.inc index 77cd8daa0..909aaaf9f 100644 --- a/data/maps/TrainerHill_Entrance/scripts.inc +++ b/data/maps/TrainerHill_Entrance/scripts.inc @@ -220,7 +220,8 @@ TrainerHill_Entrance_Movement_PushPlayerBackFromCounter: @ 8268381 walk_down step_end -TrainerHill_Entrance_Movement_268383: @ 8268383 +@ Unused +TrainerHill_Entrance_Movement_FaceUp: @ 8268383 face_up step_end diff --git a/include/constants/trainer_hill.h b/include/constants/trainer_hill.h index 09dad5212..f7a270428 100644 --- a/include/constants/trainer_hill.h +++ b/include/constants/trainer_hill.h @@ -8,7 +8,8 @@ #define TRAINER_HILL_ROOF 5 #define TRAINER_HILL_ENTRANCE 6 -#define NUM_TRAINER_HILL_FLOORS 4 +#define NUM_TRAINER_HILL_FLOORS 4 +#define NUM_TRAINER_HILL_FLOORS_JP 2 #define NUM_TRAINER_HILL_PRIZE_LISTS 10 @@ -36,8 +37,8 @@ #define TRAINER_HILL_TEXT_PLAYER_WON 4 #define TRAINER_HILL_TEXT_AFTER 5 -#define HILL_TRAINER_TYPE_EREADER 4 -#define HILL_TRAINER_TYPE_NPC 8 +#define NUM_TRAINER_HILL_TRAINERS (NUM_TRAINER_HILL_FLOORS * 2) +#define NUM_TRAINER_HILL_TRAINERS_JP (NUM_TRAINER_HILL_FLOORS_JP * 2) // Values returned by TrainerHillGetChallengeStatus #define TRAINER_HILL_PLAYER_STATUS_LOST 0 diff --git a/include/trainer_hill.h b/include/trainer_hill.h index dec38b2f3..c07aeb6d7 100644 --- a/include/trainer_hill.h +++ b/include/trainer_hill.h @@ -40,7 +40,7 @@ struct TrHillFloor struct TrHillTag { - u8 trainerType; + u8 numTrainers; u8 unused1; u8 numFloors; u32 checksum; diff --git a/src/data/battle_frontier/trainer_hill.h b/src/data/battle_frontier/trainer_hill.h index fe98477b9..f38cfcc38 100644 --- a/src/data/battle_frontier/trainer_hill.h +++ b/src/data/battle_frontier/trainer_hill.h @@ -1,14 +1,14 @@ #define TRAINER_HILL_OTID 0x10000000 -static const struct TrHillTag sDataTagEReader = { - .trainerType = HILL_TRAINER_TYPE_EREADER, +static const struct TrHillTag sDataTagJPDefault = { + .numTrainers = NUM_TRAINER_HILL_TRAINERS_JP, .unused1 = 1, - .numFloors = 2, + .numFloors = NUM_TRAINER_HILL_FLOORS_JP, .checksum = 0x0 }; -// In the JP Version of Trainer Hill, if there was an odd number of E-Reader trainers then one would be paired with an NPC -static const struct TrHillFloor sDataTagEReader_Floors[] = { + +static const struct TrHillFloor sDataTagJPDefault_Floors[] = { [0] = { .trainerNum1 = 0, .trainerNum2 = 0, @@ -383,9 +383,9 @@ static const struct TrHillFloor sDataTagEReader_Floors[] = { static const struct TrHillTag sDataTagNormal = { - .trainerType = HILL_TRAINER_TYPE_NPC, + .numTrainers = NUM_TRAINER_HILL_TRAINERS, .unused1 = 2, - .numFloors = 4, + .numFloors = NUM_TRAINER_HILL_FLOORS, .checksum = 0x00051E05 }; @@ -1603,9 +1603,9 @@ static const struct TrHillFloor sDataTagNormal_Floors[] = static const struct TrHillTag sDataTagVariety = { - .trainerType = HILL_TRAINER_TYPE_NPC, + .numTrainers = NUM_TRAINER_HILL_TRAINERS, .unused1 = 1, - .numFloors = 4, + .numFloors = NUM_TRAINER_HILL_FLOORS, .checksum = 0x00054C15 }; @@ -2829,9 +2829,9 @@ static const struct TrHillFloor sDataTagVariety_Floors[] = { static const struct TrHillTag sDataTagUnique = { - .trainerType = HILL_TRAINER_TYPE_NPC, + .numTrainers = NUM_TRAINER_HILL_TRAINERS, .unused1 = 3, - .numFloors = 4, + .numFloors = NUM_TRAINER_HILL_FLOORS, .checksum = 0x000652F3 }; @@ -4040,9 +4040,9 @@ static const struct TrHillFloor sDataTagUnique_Floors[] = { static const struct TrHillTag sDataTagExpert = { - .trainerType = HILL_TRAINER_TYPE_NPC, + .numTrainers = NUM_TRAINER_HILL_TRAINERS, .unused1 = 1, - .numFloors = 4, + .numFloors = NUM_TRAINER_HILL_FLOORS, .checksum = 0x00061F3F }; diff --git a/src/ereader_helpers.c b/src/ereader_helpers.c index 229c214ad..2419c2806 100755 --- a/src/ereader_helpers.c +++ b/src/ereader_helpers.c @@ -448,7 +448,7 @@ static bool32 TryWriteTrainerHill_r(struct EReaderTrainerHillSet *ttdata, struct AGB_ASSERT_EX(ttdata->id == 0, "cereader_tool.c", 452); memset(buffer2, 0, 0x1000); - buffer2->trainerType = ttdata->count; + buffer2->numTrainers = ttdata->count; buffer2->unused1 = sub_81D38D4(); buffer2->numFloors = (ttdata->count + 1) / 2; diff --git a/src/trainer_hill.c b/src/trainer_hill.c index 40b5750f4..b3463b0b0 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -286,7 +286,7 @@ void ResetTrainerHillResults(void) { s32 i; - gSaveBlock2Ptr->frontier.savedGame = FALSE; + gSaveBlock2Ptr->frontier.savedGame = 0; gSaveBlock2Ptr->frontier.neverRead = 0; gSaveBlock1Ptr->trainerHill.bestTime = 0; for (i = 0; i < 4; i++) @@ -528,6 +528,7 @@ static void BufferChallengeTime(void) // Returns TRUE if all 4 floors are used // Returns FALSE otherwise, and buffers the number of floors used +// The only time fewer than all 4 floors are used is for the JP-exclusive E-Reader and Default modes static void GetAllFloorsUsed(void) { SetUpDataStruct(); @@ -838,7 +839,7 @@ const struct WarpEvent* SetWarpDestinationTrainerHill4F(void) } // For warping from the roof in challenges where the 4F is not the final challenge floor -// This would only occur in an E-Reader challenge, which is exclusive to JP Emerald +// This would only occur in the JP-exclusive Default and E-Reader challenges const struct WarpEvent* SetWarpDestinationTrainerHillFinalFloor(u8 warpEventId) { u8 numFloors; @@ -1045,7 +1046,7 @@ static void TrainerHillSetTag(void) gSaveBlock1Ptr->trainerHill.bestTime = gSaveBlock1Ptr->trainerHillTimes[gSpecialVar_0x8005]; } -static u8 GetPrizeListId(bool8 npcChallenge) +static u8 GetPrizeListId(bool8 maxTrainers) { u8 prizeListId, i, modBy; @@ -1056,8 +1057,8 @@ static u8 GetPrizeListId(bool8 npcChallenge) prizeListId ^= sHillData->floors[i].trainerNum2 & 0x1F; } - // Not possible to win TMs from E-Reader challenges - if (npcChallenge) + // Not possible to win TMs with fewer than 8 trainers + if (maxTrainers) modBy = NUM_TRAINER_HILL_PRIZE_LISTS; else modBy = NUM_TRAINER_HILL_PRIZE_LISTS / 2; @@ -1080,7 +1081,7 @@ static u16 GetPrizeItemId(void) prizeListSetId = var / 256; prizeListSetId %= 2; - if (FlagGet(FLAG_SYS_GAME_CLEAR) && sHillData->tag.trainerType == HILL_TRAINER_TYPE_NPC) + if (FlagGet(FLAG_SYS_GAME_CLEAR) && sHillData->tag.numTrainers == NUM_TRAINER_HILL_TRAINERS) i = GetPrizeListId(TRUE); else i = GetPrizeListId(FALSE);