summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2020-01-23 14:46:03 -0500
committerGriffinR <griffin.g.richards@gmail.com>2020-01-24 02:57:45 -0500
commitef1f9ead0ba44c67185dccc616846646d7ce9257 (patch)
treeea1dea4c196acfc062cbe144911fa979e96218b2 /include
parente97d3532d4d72a1fe9aec755cd2a3c6527484e27 (diff)
Document Trainer Tower scripts
Diffstat (limited to 'include')
-rw-r--r--include/battle_tower.h2
-rw-r--r--include/cereader_tool.h9
-rw-r--r--include/constants/flags.h2
-rw-r--r--include/constants/global.h2
-rw-r--r--include/constants/layouts.h54
-rw-r--r--include/constants/map_groups.h22
-rw-r--r--include/constants/metatile_labels.h4
-rw-r--r--include/constants/trainer_tower.h46
-rw-r--r--include/global.h23
-rw-r--r--include/renewable_hidden_items.h2
-rw-r--r--include/trainer_tower.h6
11 files changed, 112 insertions, 60 deletions
diff --git a/include/battle_tower.h b/include/battle_tower.h
index 87f847aa4..be07320c9 100644
--- a/include/battle_tower.h
+++ b/include/battle_tower.h
@@ -33,8 +33,6 @@ void ValidateEReaderTrainer(void);
u8 GetBattleTowerTrainerFrontSpriteId(void);
u8 GetEreaderTrainerFrontSpriteId(void);
void CopyEReaderTrainerName5(u8 *dest);
-void sub_815DC40(u8 *dest, u8 opponentIdx);
-void sub_815DBF4(u8 *dest, u8 opponentIdx);
void GetBattleTowerTrainerName(u8 *text);
u8 GetEreaderTrainerClassId(void);
u8 GetBattleTowerTrainerClassNameId(void);
diff --git a/include/cereader_tool.h b/include/cereader_tool.h
index 6275eaabf..db1dd04fa 100644
--- a/include/cereader_tool.h
+++ b/include/cereader_tool.h
@@ -2,6 +2,7 @@
#define GUARD_CEREADER_TOOL_H
#include "global.h"
+#include "constants/trainer_tower.h"
struct TrainerTowerTrainer
{
@@ -21,13 +22,13 @@ struct TrainerTowerFloor
/* 0x001 */ u8 floorIdx;
/* 0x002 */ u8 challengeType;
/* 0x003 */ u8 prize;
- /* 0x004 */ struct TrainerTowerTrainer trainers[3];
+ /* 0x004 */ struct TrainerTowerTrainer trainers[MAX_TRAINERS_PER_FLOOR];
/* 0x3DC */ u32 checksum;
};
struct EReaderTrainerHillSetSubstruct
{
- u8 count;
+ u8 numFloors;
u8 id;
u16 dummy;
u32 checksum;
@@ -35,11 +36,11 @@ struct EReaderTrainerHillSetSubstruct
struct EReaderTrainerHillSet
{
- u8 count;
+ u8 numFloors;
u8 id;
u16 dummy;
u32 checksum;
- struct TrainerTowerFloor floors[8];
+ struct TrainerTowerFloor floors[MAX_TRAINER_TOWER_FLOORS];
};
bool32 ValidateTrainerTowerData(struct EReaderTrainerHillSet * ttdata);
diff --git a/include/constants/flags.h b/include/constants/flags.h
index 26ffa8a7c..85cd4d850 100644
--- a/include/constants/flags.h
+++ b/include/constants/flags.h
@@ -1415,7 +1415,7 @@
#define FLAG_WORLD_MAP_THREE_ISLAND_BERRY_FOREST (SYS_FLAGS + 0xB7)
#define FLAG_WORLD_MAP_FOUR_ISLAND_ICEFALL_CAVE_ENTRANCE (SYS_FLAGS + 0xB8)
#define FLAG_WORLD_MAP_FIVE_ISLAND_ROCKET_WAREHOUSE (SYS_FLAGS + 0xB9)
-#define FLAG_WORLD_MAP_SEVEN_ISLAND_TRAINER_TOWER_LOBBY (SYS_FLAGS + 0xBA)
+#define FLAG_WORLD_MAP_TRAINER_TOWER_LOBBY (SYS_FLAGS + 0xBA)
#define FLAG_WORLD_MAP_SIX_ISLAND_DOTTED_HOLE_1F (SYS_FLAGS + 0xBB)
#define FLAG_WORLD_MAP_FIVE_ISLAND_LOST_CAVE_ENTRANCE (SYS_FLAGS + 0xBC)
#define FLAG_WORLD_MAP_SIX_ISLAND_PATTERN_BUSH (SYS_FLAGS + 0xBD)
diff --git a/include/constants/global.h b/include/constants/global.h
index 77ef6f203..1ecaf0201 100644
--- a/include/constants/global.h
+++ b/include/constants/global.h
@@ -34,6 +34,8 @@
#define QUEST_LOG_SCENE_COUNT 4
+#define NUM_TOWER_CHALLENGE_TYPES 4
+
#define MALE 0
#define FEMALE 1
#define GENDER_COUNT 2
diff --git a/include/constants/layouts.h b/include/constants/layouts.h
index 657d531e8..967a4619c 100644
--- a/include/constants/layouts.h
+++ b/include/constants/layouts.h
@@ -279,17 +279,17 @@
#define LAYOUT_FOUR_ISLAND_ICEFALL_CAVE_1F 294
#define LAYOUT_FOUR_ISLAND_ICEFALL_CAVE_B1F 295
#define LAYOUT_FOUR_ISLAND_ICEFALL_CAVE_BACK 296
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_LOBBY 297
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_1F 298
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_2F 299
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_3F 300
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_4F 301
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_5F 302
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_6F 303
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_7F 304
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_8F 305
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_ROOF 306
-#define LAYOUT_SEVEN_ISLAND_TRAINER_TOWER_ELEVATOR 307
+#define LAYOUT_TRAINER_TOWER_LOBBY 297
+#define LAYOUT_TRAINER_TOWER_1F 298
+#define LAYOUT_TRAINER_TOWER_2F 299
+#define LAYOUT_TRAINER_TOWER_3F 300
+#define LAYOUT_TRAINER_TOWER_4F 301
+#define LAYOUT_TRAINER_TOWER_5F 302
+#define LAYOUT_TRAINER_TOWER_6F 303
+#define LAYOUT_TRAINER_TOWER_7F 304
+#define LAYOUT_TRAINER_TOWER_8F 305
+#define LAYOUT_TRAINER_TOWER_ROOF 306
+#define LAYOUT_TRAINER_TOWER_ELEVATOR 307
#define LAYOUT_CERULEAN_CITY_HOUSE5 308
#define LAYOUT_SIX_ISLAND_DOTTED_HOLE_1F 309
#define LAYOUT_SIX_ISLAND_DOTTED_HOLE_B1F 310
@@ -348,22 +348,22 @@
#define LAYOUT_SEVEN_ISLAND_TANOBY_RUINS_VIAPOIS_CHAMBER 363
#define LAYOUT_NAVEL_ROCK_B1F 364
#define LAYOUT_NAVEL_ROCK_FORK 365
-#define LAYOUT_UNUSED_LAYOUT_834BC2C 366
-#define LAYOUT_UNUSED_LAYOUT_834BEB4 367
-#define LAYOUT_UNUSED_LAYOUT_834C13C 368
-#define LAYOUT_UNUSED_LAYOUT_834C3C4 369
-#define LAYOUT_UNUSED_LAYOUT_834C64C 370
-#define LAYOUT_UNUSED_LAYOUT_834C8D4 371
-#define LAYOUT_UNUSED_LAYOUT_834CB5C 372
-#define LAYOUT_UNUSED_LAYOUT_834CDE4 373
-#define LAYOUT_UNUSED_LAYOUT_834D06C 374
-#define LAYOUT_UNUSED_LAYOUT_834D2F4 375
-#define LAYOUT_UNUSED_LAYOUT_834D57C 376
-#define LAYOUT_UNUSED_LAYOUT_834D804 377
-#define LAYOUT_UNUSED_LAYOUT_834DA8C 378
-#define LAYOUT_UNUSED_LAYOUT_834DD14 379
-#define LAYOUT_UNUSED_LAYOUT_834DF9C 380
-#define LAYOUT_UNUSED_LAYOUT_834E224 381
+#define LAYOUT_TRAINER_TOWER_1F_DOUBLES 366
+#define LAYOUT_TRAINER_TOWER_2F_DOUBLES 367
+#define LAYOUT_TRAINER_TOWER_3F_DOUBLES 368
+#define LAYOUT_TRAINER_TOWER_4F_DOUBLES 369
+#define LAYOUT_TRAINER_TOWER_5F_DOUBLES 370
+#define LAYOUT_TRAINER_TOWER_6F_DOUBLES 371
+#define LAYOUT_TRAINER_TOWER_7F_DOUBLES 372
+#define LAYOUT_TRAINER_TOWER_8F_DOUBLES 373
+#define LAYOUT_TRAINER_TOWER_1F_KNOCKOUT 374
+#define LAYOUT_TRAINER_TOWER_2F_KNOCKOUT 375
+#define LAYOUT_TRAINER_TOWER_3F_KNOCKOUT 376
+#define LAYOUT_TRAINER_TOWER_4F_KNOCKOUT 377
+#define LAYOUT_TRAINER_TOWER_5F_KNOCKOUT 378
+#define LAYOUT_TRAINER_TOWER_6F_KNOCKOUT 379
+#define LAYOUT_TRAINER_TOWER_7F_KNOCKOUT 380
+#define LAYOUT_TRAINER_TOWER_8F_KNOCKOUT 381
#define LAYOUT_SEVEN_ISLAND_HOUSE_ROOM1 382
#define LAYOUT_ONE_ISLAND_KINDLE_ROAD_EMBER_SPA 383
diff --git a/include/constants/map_groups.h b/include/constants/map_groups.h
index 0cc1c27fb..1b1b74d37 100644
--- a/include/constants/map_groups.h
+++ b/include/constants/map_groups.h
@@ -135,17 +135,17 @@
// Map Group 2
#define MAP_NAVEL_ROCK_EXTERIOR (0 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_1F (1 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_2F (2 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_3F (3 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_4F (4 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_5F (5 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_6F (6 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_7F (7 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_8F (8 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_ROOF (9 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_LOBBY (10 | (2 << 8))
-#define MAP_SEVEN_ISLAND_TRAINER_TOWER_ELEVATOR (11 | (2 << 8))
+#define MAP_TRAINER_TOWER_1F (1 | (2 << 8))
+#define MAP_TRAINER_TOWER_2F (2 | (2 << 8))
+#define MAP_TRAINER_TOWER_3F (3 | (2 << 8))
+#define MAP_TRAINER_TOWER_4F (4 | (2 << 8))
+#define MAP_TRAINER_TOWER_5F (5 | (2 << 8))
+#define MAP_TRAINER_TOWER_6F (6 | (2 << 8))
+#define MAP_TRAINER_TOWER_7F (7 | (2 << 8))
+#define MAP_TRAINER_TOWER_8F (8 | (2 << 8))
+#define MAP_TRAINER_TOWER_ROOF (9 | (2 << 8))
+#define MAP_TRAINER_TOWER_LOBBY (10 | (2 << 8))
+#define MAP_TRAINER_TOWER_ELEVATOR (11 | (2 << 8))
#define MAP_FIVE_ISLAND_LOST_CAVE_ENTRANCE (12 | (2 << 8))
#define MAP_FIVE_ISLAND_LOST_CAVE_ROOM1 (13 | (2 << 8))
#define MAP_FIVE_ISLAND_LOST_CAVE_ROOM2 (14 | (2 << 8))
diff --git a/include/constants/metatile_labels.h b/include/constants/metatile_labels.h
index f2bf4b865..292852b4f 100644
--- a/include/constants/metatile_labels.h
+++ b/include/constants/metatile_labels.h
@@ -40,4 +40,8 @@
// gTileset_82D504C. Below metatile probably needs generic name
#define METATILE_MtEmber_CaveEntrance 0x346
+// Trainer Tower
+#define METATILE_TrainerTower_Floor_ShadeBottomLeft 0x287
+#define METATILE_TrainerTower_CounterBarrier 0x2B4
+
#endif // GUARD_METATILE_LABELS_H
diff --git a/include/constants/trainer_tower.h b/include/constants/trainer_tower.h
new file mode 100644
index 000000000..52c9bb3a0
--- /dev/null
+++ b/include/constants/trainer_tower.h
@@ -0,0 +1,46 @@
+#ifndef GUARD_CONSTANTS_TRAINER_TOWER_H
+#define GUARD_CONSTANTS_TRAINER_TOWER_H
+
+#define CHALLENGE_TYPE_SINGLE 0
+#define CHALLENGE_TYPE_DOUBLE 1
+#define CHALLENGE_TYPE_KNOCKOUT 2
+// Mixed challenges use one of the above 3 for each floor
+
+#define CHALLENGE_STATUS_LOST 0
+#define CHALLENGE_STATUS_UNK 1 // Never set, possibly e-Card related
+#define CHALLENGE_STATUS_NORMAL 2 // Not started or ongoing
+
+#define MAX_TRAINER_TOWER_FLOORS 8
+
+#define MAX_TRAINERS_PER_FLOOR 3
+
+#define TRAINER_TOWER_FUNC_INIT_FLOOR 0
+#define TRAINER_TOWER_FUNC_GET_SPEECH 1
+#define TRAINER_TOWER_FUNC_DO_BATTLE 2
+#define TRAINER_TOWER_FUNC_GET_CHALLENGE_TYPE 3
+#define TRAINER_TOWER_FUNC_CLEARED_FLOOR 4
+#define TRAINER_TOWER_FUNC_GET_FLOOR_BEATEN 5
+#define TRAINER_TOWER_FUNC_START_CHALLENGE 6
+#define TRAINER_TOWER_FUNC_GET_OWNER_STATE 7
+#define TRAINER_TOWER_FUNC_GIVE_PRIZE 8
+#define TRAINER_TOWER_FUNC_CHECK_FINAL_TIME 9
+#define TRAINER_TOWER_FUNC_RESUME_TIMER 10
+#define TRAINER_TOWER_FUNC_SET_LOST 11
+#define TRAINER_TOWER_FUNC_GET_CHALLENGE_STATUS 12
+#define TRAINER_TOWER_FUNC_GET_TIME 13
+#define TRAINER_TOWER_FUNC_SHOW_RESULTS 14
+#define TRAINER_TOWER_FUNC_CLOSE_RESULTS 15
+#define TRAINER_TOWER_FUNC_CHECK_DOUBLES 16
+#define TRAINER_TOWER_FUNC_GET_NUM_FLOORS 17
+#define TRAINER_TOWER_FUNC_SHOULD_WARP_TO_COUNTER 18
+#define TRAINER_TOWER_FUNC_ENCOUNTER_MUSIC 19
+#define TRAINER_TOWER_FUNC_GET_BEAT_CHALLENGE 20
+
+#define TRAINER_TOWER_TEXT_INTRO 2
+#define TRAINER_TOWER_TEXT_PLAYER_LOST 3
+#define TRAINER_TOWER_TEXT_PLAYER_WON 4
+#define TRAINER_TOWER_TEXT_AFTER 5
+
+#define TRAINER_TOWER_MAX_TIME 215999 // 60 * 60 * 60 - 1
+
+#endif //GUARD_CONSTANTS_TRAINER_TOWER_H
diff --git a/include/global.h b/include/global.h
index 180a1e0a3..561410a45 100644
--- a/include/global.h
+++ b/include/global.h
@@ -691,19 +691,18 @@ struct MEventBuffers
/*0x344 0x3464*/ u32 unk_344[2][5];
}; // 0x36C 0x348C
-struct TrainerTowerLog
+struct TrainerTower
{
- u32 unk0;
- u32 unk4;
- u8 unk8;
+ u32 timer;
+ u32 bestTime;
+ u8 floorsCleared;
u8 unk9;
- u8 unkA_0:1;
- u8 unkA_1:1;
- u8 unkA_2:1;
- u8 unkA_3:1;
+ u8 receivedPrize:1;
+ u8 checkedFinalTime:1;
+ u8 spokeToOwner:1;
+ u8 hasLost:1;
u8 unkA_4:1;
- u8 unkA_5:1;
- u8 unkA_6:2;
+ u8 validated:1;
};
struct TrainerRematchState
@@ -776,8 +775,8 @@ struct SaveBlock1
/*0x3BA8*/ struct TrainerNameRecord trainerNameRecords[20];
/*0x3C98*/ struct DaycareMon route5DayCareMon;
/*0x3D24*/ u8 filler3D24[0x10];
- /*0x3D34*/ u32 unkArrayIdx;
- /*0x3D38*/ struct TrainerTowerLog unkArray[4];
+ /*0x3D34*/ u32 towerChallengeId;
+ /*0x3D38*/ struct TrainerTower trainerTower[NUM_TOWER_CHALLENGE_TYPES];
};
struct MapPosition
diff --git a/include/renewable_hidden_items.h b/include/renewable_hidden_items.h
index 0de109528..b88c44b6b 100644
--- a/include/renewable_hidden_items.h
+++ b/include/renewable_hidden_items.h
@@ -1,7 +1,7 @@
#ifndef GUARD_RENEWABLE_HIDDEN_ITEMS_H
#define GUARD_RENEWABLE_HIDDEN_ITEMS_H
-bool32 sub_815D834(void);
+bool32 ReadTrainerHillAndValidate(void);
void IncrementRenewableHiddenItemStepCounter(void);
void TryRegenerateRenewableHiddenItems(void);
void SetAllRenewableItemFlags(void);
diff --git a/include/trainer_tower.h b/include/trainer_tower.h
index 9c1ac0631..72c0f236c 100644
--- a/include/trainer_tower.h
+++ b/include/trainer_tower.h
@@ -6,7 +6,9 @@ void InitTrainerTowerBattleStruct(void);
void FreeTrainerTowerBattleStruct(void);
u8 GetTrainerTowerTrainerFrontSpriteId(void);
void ResetTrainerTowerResults(void);
-void sub_815DA28(u8 *text);
-u8 sub_815DA10(void);
+void GetTrainerTowerOpponentWinText(u8 *dest, u8 opponentIdx);
+void GetTrainerTowerOpponentLoseText(u8 *dest, u8 opponentIdx);
+void GetTrainerTowerOpponentName(u8 *text);
+u8 GetTrainerTowerOpponentClass(void);
#endif //GUARD_TRAINER_TOWER_H