summaryrefslogtreecommitdiff
path: root/asm
diff options
context:
space:
mode:
Diffstat (limited to 'asm')
-rw-r--r--asm/field_control_avatar.s4
-rw-r--r--asm/macros.inc1
-rw-r--r--asm/macros/trainer_tower.inc133
-rw-r--r--asm/overworld.s10
4 files changed, 141 insertions, 7 deletions
diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s
index 83f9a5700..b74e60d1f 100644
--- a/asm/field_control_avatar.s
+++ b/asm/field_control_avatar.s
@@ -1330,10 +1330,10 @@ _0806D2F0:
lsrs r0, 24
cmp r0, 0x1
bne _0806D308
- ldr r0, _0806D304 @ =EventScript_1C549C
+ ldr r0, _0806D304 @ =TrainerTower_EventScript_ShowTime
b _0806D53E
.align 2, 0
-_0806D304: .4byte EventScript_1C549C
+_0806D304: .4byte TrainerTower_EventScript_ShowTime
_0806D308:
adds r0, r4, 0
adds r1, r5, 0
diff --git a/asm/macros.inc b/asm/macros.inc
index ffbe3db29..0e53dc2a2 100644
--- a/asm/macros.inc
+++ b/asm/macros.inc
@@ -5,6 +5,7 @@
.include "asm/macros/ec.inc"
.include "asm/macros/map.inc"
.include "asm/macros/m4a.inc"
+ .include "asm/macros/trainer_tower.inc"
.macro region_map_location x, y, width, height, name
.byte \x
diff --git a/asm/macros/trainer_tower.inc b/asm/macros/trainer_tower.inc
new file mode 100644
index 000000000..8e5f606ee
--- /dev/null
+++ b/asm/macros/trainer_tower.inc
@@ -0,0 +1,133 @@
+ @ Sets NPC gfx and the floor layout depending on current challenge and floor
+ .macro ttower_initfloor
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_INIT_FLOOR
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Buffers the opponents battle speech to gStringVar4. speech is any TRAINER_TOWER_TEXT_*.
+ .macro ttower_getspeech speech:req, trainer=0xFF
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_SPEECH
+ setvar VAR_0x8005, \speech
+ .if \trainer >= VARS_START && \trainer != 0xFF
+ copyvar VAR_0x8006, \trainer
+ .elseif \trainer != 0xFF
+ setvar VAR_0x8006, \trainer
+ .endif
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Starts a trainer tower battle. VAR_0x8005 is unused
+ .macro ttower_dobattle
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_DO_BATTLE
+ setvar VAR_0x8005, 0
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Returns the current challenge type (CHALLENGE_TYPE_*). Mixed challenges use different types for each floor. If VAR_0x8005 is != FALSE, does nothing
+ .macro ttower_getchallengetype
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_CHALLENGE_TYPE
+ setvar VAR_0x8005, FALSE
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Adds 1 to the number of floors cleared (all trainers on floor defeated)
+ .macro ttower_clearedfloor
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_CLEARED_FLOOR
+ special CallTrainerTowerFunc
+ .endm
+
+ @ TRUE if the trainers on this floor were already beaten, FALSE otherwise
+ .macro ttower_isfloorcleared
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_FLOOR_CLEARED
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Initializes the Trainer Tower challenge and starts the timer
+ .macro ttower_startchallenge
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_START_CHALLENGE
+ special CallTrainerTowerFunc
+ .endm
+
+ @ 0 if not spoken to yet, 1 if spoken to but not received prize, 2 if received prize
+ .macro ttower_getownerstate
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_OWNER_STATE
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Tries to give prize. 0 if given successfully, 1 if no room for prize, 2 if giving prize should be skipped
+ .macro ttower_giveprize
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GIVE_PRIZE
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Checks the final challenge time. 0 if new record, 1 if not, 2 if time has already been checked
+ .macro ttower_checkfinaltime
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_CHECK_FINAL_TIME
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Resumes the challenge timer (or starts, if the timer is 0)
+ .macro ttower_resumetimer
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_RESUME_TIMER
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Sets that the player lost the challenge
+ .macro ttower_setlost
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_SET_LOST
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Returns the status of the current Trainer Tower challenge (CHALLENGE_STATUS_*)
+ .macro ttower_getchallengestatus
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_CHALLENGE_STATUS
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Buffers the current challenge time (min in gStringVar1, sec in gStringVar2, fraction sec in gStringVar3)
+ .macro ttower_gettime
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_TIME
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Unused. Displays Trainer Tower results. Handled by Special_BattleRecords instead
+ .macro ttower_showresults
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_SHOW_RESULTS
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Unused. See above
+ .macro ttower_closeresults
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_CLOSE_RESULTS
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Returns the eligibility of the players party for a double battle (using GetMonsStateToDoubles)
+ .macro ttower_checkdoubles
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_CHECK_DOUBLES
+ special CallTrainerTowerFunc
+ .endm
+
+ @ For the unused E-Reader challenges, gets the number of floors used. Otherwise returns FALSE (all floors used)
+ .macro ttower_getnumfloors
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_NUM_FLOORS
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Dummied, always returns FALSE
+ .macro ttower_shouldexit
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_SHOULD_WARP_TO_COUNTER
+ special CallTrainerTowerFunc
+ .endm
+
+ @ Plays the encounter music for the trainer number in VAR_TEMP_1
+ .macro ttower_encountermusic
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_ENCOUNTER_MUSIC
+ special CallTrainerTowerFunc
+ .endm
+
+ @ TRUE if the player reached the Battle Tower owner, FALSE otherwise
+ .macro ttower_getbeatchallenge
+ setvar VAR_0x8004, TRAINER_TOWER_FUNC_GET_BEAT_CHALLENGE
+ special CallTrainerTowerFunc
+ .endm
diff --git a/asm/overworld.s b/asm/overworld.s
index f68782acf..5b3c01652 100644
--- a/asm/overworld.s
+++ b/asm/overworld.s
@@ -1718,7 +1718,7 @@ sub_8055864: @ 8055864
bl sav1_reset_battle_music_maybe
bl mapheader_run_script_with_tag_x3
bl TryRegenerateRenewableHiddenItems
- bl not_trainer_hill_battle_pyramid
+ bl InitMap
ldr r4, _0805591C @ =gMapHeader
ldr r0, [r4]
bl copy_map_tileset2_to_vram_2
@@ -1798,7 +1798,7 @@ _08055974:
bl UpdateLocationHistoryForRoamer
bl RoamerMoveToOtherLocationSet
bl sub_8110920
- bl not_trainer_hill_battle_pyramid
+ bl InitMap
pop {r4}
pop {r0}
bx r0
@@ -1823,7 +1823,7 @@ sub_80559A8: @ 80559A8
bl sub_8110920
bl sub_8111708
bl set_current_map_header_from_sav1
- bl not_trainer_hill_battle_pyramid
+ bl InitMap
pop {r0}
bx r0
.align 2, 0
@@ -3843,7 +3843,7 @@ CB2_ContinueSavedGame: @ 8056938
bl sub_80550A8
bl UnfreezeObjectEvents
bl sub_8054E40
- bl sub_80589E8
+ bl InitMapFromSavedGame
bl PlayTimeCounter_Start
bl ScriptContext1_Init
bl ScriptContext2_Disable
@@ -5128,7 +5128,7 @@ sub_8057430: @ 8057430
bl sub_80550A8
bl UnfreezeObjectEvents
bl sub_8054E40
- bl sub_80589E8
+ bl InitMapFromSavedGame
bl PlayTimeCounter_Start
bl ScriptContext1_Init
ldr r1, _08057488 @ =gUnknown_2031DE0