Finish documenting trainer hill

Trainer hill isn't anywhere close to done, but I figured out enough
to name the VAR. That's all this PR should do.
This commit is contained in:
Phlosioneer 2019-02-27 22:16:01 -05:00
parent 66f0616a2d
commit 782979f1fc
8 changed files with 53 additions and 42 deletions

View File

@ -17,6 +17,7 @@
#include "constants/vars.h" #include "constants/vars.h"
#include "constants/weather.h" #include "constants/weather.h"
#include "constants/trainer_hill.h" #include "constants/trainer_hill.h"
#include "constants/battle.h"
.include "asm/macros.inc" .include "asm/macros.inc"
.include "asm/macros/event.inc" .include "asm/macros/event.inc"
.include "constants/constants.inc" .include "constants/constants.inc"
@ -6926,16 +6927,16 @@ TrainerHill_3F_MapScript1_2C8336: @ 82C8336
TrainerHill_4F_MapScript1_2C8336: @ 82C8336 TrainerHill_4F_MapScript1_2C8336: @ 82C8336
TrainerHill_Roof_MapScript1_2C8336: @ 82C8336 TrainerHill_Roof_MapScript1_2C8336: @ 82C8336
setvar VAR_TEMP_2, 0 setvar VAR_TEMP_2, 0
setvar VAR_0x8004, TRAINER_HILL_FUNC_4 setvar VAR_0x8004, TRAINER_HILL_FUNC_RESUME_TIMER
special CallTrainerHillFunction special CallTrainerHillFunction
setvar VAR_0x8004, 1 setvar VAR_0x8004, 1
setvar VAR_0x8005, 5 setvar VAR_0x8005, 5
special CallFrontierUtilFunc special CallFrontierUtilFunc
compare VAR_RESULT, 2 compare VAR_RESULT, B_OUTCOME_LOST
goto_if_eq TrainerHill_1F_EventScript_2C83C9 goto_if_eq TrainerHill_1F_EventScript_2C83C9
compare VAR_RESULT, 3 compare VAR_RESULT, B_OUTCOME_DREW
goto_if_eq TrainerHill_1F_EventScript_2C83C9 goto_if_eq TrainerHill_1F_EventScript_2C83C9
compare VAR_RESULT, 9 compare VAR_RESULT, B_OUTCOME_FORFEITED
goto_if_eq TrainerHill_1F_EventScript_2C83C9 goto_if_eq TrainerHill_1F_EventScript_2C83C9
end end
@ -6981,7 +6982,7 @@ TrainerHill_1F_EventScript_2C83BF:: @ 82C83BF
TrainerHill_1F_EventScript_2C83C9:: @ 82C83C9 TrainerHill_1F_EventScript_2C83C9:: @ 82C83C9
setvar VAR_0x8004, TRAINER_HILL_FUNC_12 setvar VAR_0x8004, TRAINER_HILL_FUNC_12
special CallTrainerHillFunction special CallTrainerHillFunction
setvar VAR_0x8004, TRAINER_HILL_FUNC_5 setvar VAR_0x8004, TRAINER_HILL_FUNC_SET_LOST
special CallTrainerHillFunction special CallTrainerHillFunction
setvar VAR_TEMP_1, 1 setvar VAR_TEMP_1, 1
end end

View File

@ -38,7 +38,7 @@ Route111_EventScript_1F0CE4:: @ 81F0CE4
return return
Route111_MapScript1_1F0D87: @ 81F0D87 Route111_MapScript1_1F0D87: @ 81F0D87
setvar VAR_0x40D6, 0 setvar VAR_TRAINER_HILL_IS_ACTIVE, 0
special SetMirageTowerVisibility special SetMirageTowerVisibility
call_if_unset FLAG_MIRAGE_TOWER_VISIBLE, Route111_EventScript_1F0E3C call_if_unset FLAG_MIRAGE_TOWER_VISIBLE, Route111_EventScript_1F0E3C
compare VAR_ROUTE_111_STATE, 1 compare VAR_ROUTE_111_STATE, 1

View File

@ -109,7 +109,7 @@
"x": 9, "x": 9,
"y": 6, "y": 6,
"elevation": 3, "elevation": 3,
"var": "VAR_0x40D6", "var": "VAR_TRAINER_HILL_IS_ACTIVE",
"var_value": "0", "var_value": "0",
"script": "TrainerHill_Entrance_EventScript_268229" "script": "TrainerHill_Entrance_EventScript_268229"
} }

View File

@ -15,7 +15,7 @@ TrainerHill_Entrance_MapScript1_2680CF: @ 82680CF
end end
TrainerHill_Entrance_MapScript1_2680D0: @ 82680D0 TrainerHill_Entrance_MapScript1_2680D0: @ 82680D0
setvar VAR_0x8004, TRAINER_HILL_FUNC_4 setvar VAR_0x8004, TRAINER_HILL_FUNC_RESUME_TIMER
special CallTrainerHillFunction special CallTrainerHillFunction
setvar VAR_TEMP_0, 0 setvar VAR_TEMP_0, 0
setvar VAR_0x8004, TRAINER_HILL_FUNC_9 setvar VAR_0x8004, TRAINER_HILL_FUNC_9
@ -74,12 +74,12 @@ TrainerHill_Entrance_EventScript_268160:: @ 8268160
TrainerHill_Entrance_EventScript_268182:: @ 8268182 TrainerHill_Entrance_EventScript_268182:: @ 8268182
setvar VAR_TEMP_0, 1 setvar VAR_TEMP_0, 1
setvar VAR_0x8004, TRAINER_HILL_FUNC_6 setvar VAR_0x8004, TRAINER_HILL_FUNC_GET_CHALLENGE_STATUS
special CallTrainerHillFunction special CallTrainerHillFunction
switch VAR_RESULT switch VAR_RESULT
case 0, TrainerHill_Entrance_EventScript_2681B5 case TRAINER_HILL_PLAYER_STATUS_LOST, TrainerHill_Entrance_EventScript_2681B5
case 1, TrainerHill_Entrance_EventScript_2681CA case TRAINER_HILL_PLAYER_STATUS_ECARD_SCANNED, TrainerHill_Entrance_EventScript_2681CA
case 2, TrainerHill_Entrance_EventScript_2681EE case TRAINER_HILL_PLAYER_STATUS_NORMAL, TrainerHill_Entrance_EventScript_2681EE
TrainerHill_Entrance_EventScript_2681B5:: @ 82681B5 TrainerHill_Entrance_EventScript_2681B5:: @ 82681B5
lockall lockall
@ -96,7 +96,7 @@ TrainerHill_Entrance_EventScript_2681DA:: @ 82681DA
closemessage closemessage
applymovement EVENT_OBJ_ID_PLAYER, TrainerHill_Entrance_Movement_268381 applymovement EVENT_OBJ_ID_PLAYER, TrainerHill_Entrance_Movement_268381
waitmovement 0 waitmovement 0
setvar VAR_0x40D6, 0 setvar VAR_TRAINER_HILL_IS_ACTIVE, 0
special HealPlayerParty special HealPlayerParty
releaseall releaseall
@ -168,14 +168,14 @@ TrainerHill_Entrance_EventScript_2682C8:: @ 82682C8
switch VAR_RESULT switch VAR_RESULT
case 4, TrainerHill_Entrance_EventScript_268314 case 4, TrainerHill_Entrance_EventScript_268314
case 127, TrainerHill_Entrance_EventScript_268314 case 127, TrainerHill_Entrance_EventScript_268314
setvar VAR_0x8004, TRAINER_HILL_FUNC_17 setvar VAR_0x8004, TRAINER_HILL_FUNC_SET_TAG
copyvar VAR_0x8005, VAR_RESULT copyvar VAR_0x8005, VAR_RESULT
special CallTrainerHillFunction special CallTrainerHillFunction
setvar VAR_0x40D6, 1 setvar VAR_TRAINER_HILL_IS_ACTIVE, 1
setvar VAR_TEMP_5, 0 setvar VAR_TEMP_5, 0
special HealPlayerParty special HealPlayerParty
msgbox TrainerHill_Entrance_Text_26862A, MSGBOX_DEFAULT msgbox TrainerHill_Entrance_Text_26862A, MSGBOX_DEFAULT
setvar VAR_0x8004, TRAINER_HILL_FUNC_0 setvar VAR_0x8004, TRAINER_HILL_FUNC_START
special CallTrainerHillFunction special CallTrainerHillFunction
releaseall releaseall
end end

View File

@ -1,13 +1,13 @@
#ifndef GUARD_CONSTANTS_TRAINER_HILL_H #ifndef GUARD_CONSTANTS_TRAINER_HILL_H
#define GUARD_CONSTANTS_TRAINER_HILL_H #define GUARD_CONSTANTS_TRAINER_HILL_H
#define TRAINER_HILL_FUNC_0 0 #define TRAINER_HILL_FUNC_START 0
#define TRAINER_HILL_FUNC_1 1 #define TRAINER_HILL_FUNC_1 1
#define TRAINER_HILL_FUNC_2 2 #define TRAINER_HILL_FUNC_2 2
#define TRAINER_HILL_FUNC_3 3 #define TRAINER_HILL_FUNC_3 3
#define TRAINER_HILL_FUNC_4 4 #define TRAINER_HILL_FUNC_RESUME_TIMER 4
#define TRAINER_HILL_FUNC_5 5 #define TRAINER_HILL_FUNC_SET_LOST 5
#define TRAINER_HILL_FUNC_6 6 #define TRAINER_HILL_FUNC_GET_CHALLENGE_STATUS 6
#define TRAINER_HILL_FUNC_7 7 #define TRAINER_HILL_FUNC_7 7
#define TRAINER_HILL_FUNC_8 8 #define TRAINER_HILL_FUNC_8 8
#define TRAINER_HILL_FUNC_9 9 #define TRAINER_HILL_FUNC_9 9
@ -18,6 +18,12 @@
#define TRAINER_HILL_FUNC_14 14 #define TRAINER_HILL_FUNC_14 14
#define TRAINER_HILL_FUNC_15 15 #define TRAINER_HILL_FUNC_15 15
#define TRAINER_HILL_FUNC_16 16 #define TRAINER_HILL_FUNC_16 16
#define TRAINER_HILL_FUNC_17 17 #define TRAINER_HILL_FUNC_SET_TAG 17
// Values returned by the TrainerHillGetChallengeStatus
// function.
#define TRAINER_HILL_PLAYER_STATUS_LOST 0
#define TRAINER_HILL_PLAYER_STATUS_ECARD_SCANNED 1
#define TRAINER_HILL_PLAYER_STATUS_NORMAL 2
#endif #endif

View File

@ -230,7 +230,7 @@
#define VAR_0x40D3 0x40D3 #define VAR_0x40D3 0x40D3
#define VAR_SS_TIDAL_SCOTT_STATE 0x40D4 // Always equal to FLAG_MET_SCOTT_ON_SS_TIDAL #define VAR_SS_TIDAL_SCOTT_STATE 0x40D4 // Always equal to FLAG_MET_SCOTT_ON_SS_TIDAL
#define VAR_ROAMER_POKEMON 0x40D5 // 0 = Latias, 1 = Latios #define VAR_ROAMER_POKEMON 0x40D5 // 0 = Latias, 1 = Latios
#define VAR_0x40D6 0x40D6 #define VAR_TRAINER_HILL_IS_ACTIVE 0x40D6
#define VAR_0x40D7 0x40D7 #define VAR_0x40D7 0x40D7
#define VAR_0x40D8 0x40D8 #define VAR_0x40D8 0x40D8
#define VAR_0x40D9 0x40D9 #define VAR_0x40D9 0x40D9

View File

@ -796,14 +796,14 @@ struct TrainerNameRecord
struct SaveTrainerHill struct SaveTrainerHill
{ {
/*0x3D64*/ u32 timer; /*0x3D64*/ u32 timer;
/*0x3D68*/ u32 field_3D68; /*0x3D68*/ u32 bestTime;
/*0x3D6C*/ u8 field_3D6C; /*0x3D6C*/ u8 field_3D6C;
/*0x3D6D*/ u8 unused; /*0x3D6D*/ u8 unused;
/*0x3D6E*/ u16 field_3D6E_0a:1; // 1 /*0x3D6E*/ u16 field_3D6E_0a:1; // 1
/*0x3D6E*/ u16 field_3D6E_0b:1; // 2 /*0x3D6E*/ u16 field_3D6E_0b:1; // 2
/*0x3D6E*/ u16 field_3D6E_0c:1; // 4 /*0x3D6E*/ u16 field_3D6E_0c:1; // 4
/*0x3D6E*/ u16 hasLost:1; // 8 /*0x3D6E*/ u16 hasLost:1; // 8
/*0x3D6E*/ u16 field_3D6E_0e:1; // x10 /*0x3D6E*/ u16 maybeECardScanDuringChallenge:1; // x10
/*0x3D6E*/ u16 field_3D6E_0f:1; // x20 /*0x3D6E*/ u16 field_3D6E_0f:1; // x20
/*0x3D6E*/ u16 tag:2; // x40, x80 = xC0 /*0x3D6E*/ u16 tag:2; // x40, x80 = xC0
}; };

View File

@ -30,6 +30,7 @@
#include "constants/species.h" #include "constants/species.h"
#include "constants/trainers.h" #include "constants/trainers.h"
#include "constants/easy_chat.h" #include "constants/easy_chat.h"
#include "constants/trainer_hill.h"
extern bool32 sub_81D3B34(void); extern bool32 sub_81D3B34(void);
@ -101,7 +102,7 @@ static void sub_81D5924(void);
static void sub_81D59D0(void); static void sub_81D59D0(void);
static void TrainerHillResumeTimer(void); static void TrainerHillResumeTimer(void);
static void TrainerHillSetPlayerLost(void); static void TrainerHillSetPlayerLost(void);
static void sub_81D5AD0(void); static void TrainerHillGetChallengeStatus(void);
static void sub_81D5B2C(void); static void sub_81D5B2C(void);
static void sub_81D5BBC(void); static void sub_81D5BBC(void);
static void sub_81D5C00(void); static void sub_81D5C00(void);
@ -112,7 +113,7 @@ static void sub_81D64DC(void);
static void sub_81D64FC(void); static void sub_81D64FC(void);
static void sub_81D6518(void); static void sub_81D6518(void);
static void sub_81D6568(void); static void sub_81D6568(void);
static void sub_81D65A0(void); static void TrainerHillSetTag(void);
static void SetUpDataStruct(void); static void SetUpDataStruct(void);
static void FreeDataStruct(void); static void FreeDataStruct(void);
static void nullsub_2(void); static void nullsub_2(void);
@ -269,7 +270,7 @@ static void (* const sHillFunctions[])(void) =
sub_81D59D0, sub_81D59D0,
TrainerHillResumeTimer, TrainerHillResumeTimer,
TrainerHillSetPlayerLost, TrainerHillSetPlayerLost,
sub_81D5AD0, TrainerHillGetChallengeStatus,
sub_81D5B2C, sub_81D5B2C,
sub_81D5BBC, sub_81D5BBC,
sub_81D5C00, sub_81D5C00,
@ -280,7 +281,7 @@ static void (* const sHillFunctions[])(void) =
sub_81D64FC, sub_81D64FC,
sub_81D6518, sub_81D6518,
sub_81D6568, sub_81D6568,
sub_81D65A0, TrainerHillSetTag,
}; };
static const u8 *const sTagMatchStrings[] = static const u8 *const sTagMatchStrings[] =
@ -318,7 +319,7 @@ void ResetTrainerHillResults(void)
gSaveBlock2Ptr->frontier.field_EF9_1 = 0; gSaveBlock2Ptr->frontier.field_EF9_1 = 0;
gSaveBlock2Ptr->frontier.field_EF9_0 = 0; gSaveBlock2Ptr->frontier.field_EF9_0 = 0;
gSaveBlock1Ptr->trainerHill.field_3D68 = 0; gSaveBlock1Ptr->trainerHill.bestTime = 0;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
SetTimerValue(&gSaveBlock1Ptr->trainerHillTimes[i], HILL_MAX_TIME); SetTimerValue(&gSaveBlock1Ptr->trainerHillTimes[i], HILL_MAX_TIME);
} }
@ -438,7 +439,7 @@ static void TrainerHillStartChallenge(void)
gSaveBlock1Ptr->trainerHill.timer = 0; gSaveBlock1Ptr->trainerHill.timer = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0c = 0; gSaveBlock1Ptr->trainerHill.field_3D6E_0c = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0b = 0; gSaveBlock1Ptr->trainerHill.field_3D6E_0b = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0e = 0; gSaveBlock1Ptr->trainerHill.maybeECardScanDuringChallenge = 0;
gSaveBlock2Ptr->frontier.field_EE0 = 0; gSaveBlock2Ptr->frontier.field_EE0 = 0;
gBattleOutcome = 0; gBattleOutcome = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0a = 0; gSaveBlock1Ptr->trainerHill.field_3D6E_0a = 0;
@ -483,10 +484,10 @@ static void sub_81D59D0(void)
{ {
gSpecialVar_Result = 2; gSpecialVar_Result = 2;
} }
else if (GetTimerValue(&gSaveBlock1Ptr->trainerHill.field_3D68) > gSaveBlock1Ptr->trainerHill.timer) else if (GetTimerValue(&gSaveBlock1Ptr->trainerHill.bestTime) > gSaveBlock1Ptr->trainerHill.timer)
{ {
SetTimerValue(&gSaveBlock1Ptr->trainerHill.field_3D68, gSaveBlock1Ptr->trainerHill.timer); SetTimerValue(&gSaveBlock1Ptr->trainerHill.bestTime, gSaveBlock1Ptr->trainerHill.timer);
gSaveBlock1Ptr->trainerHillTimes[gSaveBlock1Ptr->trainerHill.tag] = gSaveBlock1Ptr->trainerHill.field_3D68; gSaveBlock1Ptr->trainerHillTimes[gSaveBlock1Ptr->trainerHill.tag] = gSaveBlock1Ptr->trainerHill.bestTime;
gSpecialVar_Result = 0; gSpecialVar_Result = 0;
} }
else else
@ -513,21 +514,24 @@ static void TrainerHillSetPlayerLost(void)
gSaveBlock1Ptr->trainerHill.hasLost = 1; gSaveBlock1Ptr->trainerHill.hasLost = 1;
} }
static void sub_81D5AD0(void) static void TrainerHillGetChallengeStatus(void)
{ {
if (gSaveBlock1Ptr->trainerHill.hasLost) if (gSaveBlock1Ptr->trainerHill.hasLost)
{ {
// The player lost their last match.
gSaveBlock1Ptr->trainerHill.hasLost = 0; gSaveBlock1Ptr->trainerHill.hasLost = 0;
gSpecialVar_Result = 0; gSpecialVar_Result = TRAINER_HILL_PLAYER_STATUS_LOST;
} }
else if (gSaveBlock1Ptr->trainerHill.field_3D6E_0e) else if (gSaveBlock1Ptr->trainerHill.maybeECardScanDuringChallenge)
{ {
gSaveBlock1Ptr->trainerHill.field_3D6E_0e = 0; // Unreachable code. Something relating to eCards?
gSpecialVar_Result = 1; gSaveBlock1Ptr->trainerHill.maybeECardScanDuringChallenge = 0;
gSpecialVar_Result = TRAINER_HILL_PLAYER_STATUS_ECARD_SCANNED;
} }
else else
{ {
gSpecialVar_Result = 2; // Continue playing.
gSpecialVar_Result = TRAINER_HILL_PLAYER_STATUS_NORMAL;
} }
} }
@ -575,7 +579,7 @@ static void sub_81D5C00(void)
bool8 sub_81D5C18(void) bool8 sub_81D5C18(void)
{ {
if (VarGet(VAR_0x40D6) == 0) if (VarGet(VAR_TRAINER_HILL_IS_ACTIVE) == 0)
return FALSE; return FALSE;
else if (gSaveBlock1Ptr->trainerHill.field_3D6E_0c) else if (gSaveBlock1Ptr->trainerHill.field_3D6E_0c)
return FALSE; return FALSE;
@ -1054,10 +1058,10 @@ static void sub_81D6568(void)
gSpecialVar_Result = 1; gSpecialVar_Result = 1;
} }
static void sub_81D65A0(void) static void TrainerHillSetTag(void)
{ {
gSaveBlock1Ptr->trainerHill.tag = gSpecialVar_0x8005; gSaveBlock1Ptr->trainerHill.tag = gSpecialVar_0x8005;
gSaveBlock1Ptr->trainerHill.field_3D68 = gSaveBlock1Ptr->trainerHillTimes[gSpecialVar_0x8005]; gSaveBlock1Ptr->trainerHill.bestTime = gSaveBlock1Ptr->trainerHillTimes[gSpecialVar_0x8005];
} }
static u8 sub_81D65E8(u8 arg0) static u8 sub_81D65E8(u8 arg0)