I guess I'm documenting Trainer Hill now

This commit is contained in:
Phlosioneer 2019-02-27 21:28:34 -05:00
parent e77e7844ea
commit 66f0616a2d
13 changed files with 90 additions and 66 deletions

View File

@ -16,6 +16,7 @@
#include "constants/trainers.h"
#include "constants/vars.h"
#include "constants/weather.h"
#include "constants/trainer_hill.h"
.include "asm/macros.inc"
.include "asm/macros/event.inc"
.include "constants/constants.inc"
@ -2758,7 +2759,7 @@ EventScript_2736F8:: @ 82736F8
goto_if_eq BattleFrontier_BattlePyramidTop_EventScript_252B42
compare VAR_RESULT, 2
goto_if_eq BattleFrontier_BattlePyramidTop_EventScript_252B42
setvar VAR_0x8004, 10
setvar VAR_0x8004, TRAINER_HILL_FUNC_10
special CallTrainerHillFunction
compare VAR_RESULT, 1
goto_if_eq TrainerHill_1F_EventScript_2C83C9
@ -6925,7 +6926,7 @@ TrainerHill_3F_MapScript1_2C8336: @ 82C8336
TrainerHill_4F_MapScript1_2C8336: @ 82C8336
TrainerHill_Roof_MapScript1_2C8336: @ 82C8336
setvar VAR_TEMP_2, 0
setvar VAR_0x8004, 4
setvar VAR_0x8004, TRAINER_HILL_FUNC_4
special CallTrainerHillFunction
setvar VAR_0x8004, 1
setvar VAR_0x8005, 5
@ -6958,7 +6959,7 @@ TrainerHill_Roof_MapScript2_2C8381: @ 82C8381
EventScript_TrainerHillTimer:: @ 82C8393
lockall
setvar VAR_0x8004, 7
setvar VAR_0x8004, TRAINER_HILL_FUNC_7
special CallTrainerHillFunction
msgbox TrainerHill_Entrance_Text_268D47, MSGBOX_DEFAULT
releaseall
@ -6966,7 +6967,7 @@ EventScript_TrainerHillTimer:: @ 82C8393
TrainerHill_1F_EventScript_2C83A6:: @ 82C83A6
setvar VAR_TEMP_2, 1
setvar VAR_0x8004, 9
setvar VAR_0x8004, TRAINER_HILL_FUNC_9
special CallTrainerHillFunction
compare VAR_RESULT, 1
goto_if_eq TrainerHill_1F_EventScript_2C83BF
@ -6978,9 +6979,9 @@ TrainerHill_1F_EventScript_2C83BF:: @ 82C83BF
end
TrainerHill_1F_EventScript_2C83C9:: @ 82C83C9
setvar VAR_0x8004, 12
setvar VAR_0x8004, TRAINER_HILL_FUNC_12
special CallTrainerHillFunction
setvar VAR_0x8004, 5
setvar VAR_0x8004, TRAINER_HILL_FUNC_5
special CallTrainerHillFunction
setvar VAR_TEMP_1, 1
end
@ -6998,7 +6999,7 @@ TrainerHill_1F_Movement_2C83EE:: @ 82C83EE
EventScript_2C83F0:: @ 82C83F0
trainerbattle TRAINER_BATTLE_12, TRAINER_PHILLIP, 0, BattleFacility_TrainerBattle_PlaceholderText, BattleFacility_TrainerBattle_PlaceholderText
setvar VAR_0x8004, 11
setvar VAR_0x8004, TRAINER_HILL_FUNC_11
special CallTrainerHillFunction
waitmessage
waitbuttonpress

View File

@ -8,6 +8,7 @@
#include "constants/secret_bases.h"
#include "constants/vars.h"
#include "constants/weather.h"
#include "constants/trainer_hill.h"
.include "asm/macros.inc"
.include "constants/constants.inc"

View File

@ -4,7 +4,7 @@
#include "constants/weather.h"
#include "constants/region_map_sections.h"
#include "constants/songs.h"
#include "constants/weather.h"
#include "constants/trainer_hill.h"
.include "asm/macros.inc"
.include "constants/constants.inc"

View File

@ -15,10 +15,10 @@ TrainerHill_Entrance_MapScript1_2680CF: @ 82680CF
end
TrainerHill_Entrance_MapScript1_2680D0: @ 82680D0
setvar VAR_0x8004, 4
setvar VAR_0x8004, TRAINER_HILL_FUNC_4
special CallTrainerHillFunction
setvar VAR_TEMP_0, 0
setvar VAR_0x8004, 9
setvar VAR_0x8004, TRAINER_HILL_FUNC_9
special CallTrainerHillFunction
compare VAR_RESULT, 0
goto_if_eq TrainerHill_Entrance_EventScript_2680FF
@ -27,7 +27,7 @@ TrainerHill_Entrance_MapScript1_2680D0: @ 82680D0
end
TrainerHill_Entrance_EventScript_2680FF:: @ 82680FF
setvar VAR_0x8004, 16
setvar VAR_0x8004, TRAINER_HILL_FUNC_16
special CallTrainerHillFunction
compare VAR_RESULT, 1
goto_if_eq TrainerHill_Entrance_EventScript_26811A
@ -74,7 +74,7 @@ TrainerHill_Entrance_EventScript_268160:: @ 8268160
TrainerHill_Entrance_EventScript_268182:: @ 8268182
setvar VAR_TEMP_0, 1
setvar VAR_0x8004, 6
setvar VAR_0x8004, TRAINER_HILL_FUNC_6
special CallTrainerHillFunction
switch VAR_RESULT
case 0, TrainerHill_Entrance_EventScript_2681B5
@ -91,7 +91,6 @@ TrainerHill_Entrance_EventScript_2681CA:: @ 82681CA
lockall
applymovement EVENT_OBJ_ID_PLAYER, TrainerHill_Entrance_Movement_26837F
msgbox TrainerHill_Entrance_Text_268712, MSGBOX_DEFAULT
@ No "end" command; intentional fall-through to TrainerHill_Entrance_EventScript_2681DA.
TrainerHill_Entrance_EventScript_2681DA:: @ 82681DA
closemessage
@ -115,7 +114,7 @@ TrainerHill_Entrance_EventScript_2681EF:: @ 82681EF
TrainerHill_Entrance_EventScript_2681FD:: @ 82681FD
lock
faceplayer
setvar VAR_0x8004, 10
setvar VAR_0x8004, TRAINER_HILL_FUNC_10
special CallTrainerHillFunction
compare VAR_RESULT, 0
goto_if_eq TrainerHill_Entrance_EventScript_26821F
@ -134,11 +133,11 @@ TrainerHill_Entrance_EventScript_268229:: @ 8268229
applymovement EVENT_OBJ_ID_PLAYER, TrainerHill_Entrance_Movement_26837F
goto_if_unset FLAG_SYS_GAME_CLEAR, TrainerHill_Entrance_EventScript_26836A
msgbox TrainerHill_Entrance_Text_2684C6, MSGBOX_DEFAULT
setvar VAR_0x8004, 13
setvar VAR_0x8004, TRAINER_HILL_FUNC_13
special CallTrainerHillFunction
compare VAR_RESULT, 0
call_if_eq TrainerHill_Entrance_EventScript_26832E
setvar VAR_0x8004, 8
setvar VAR_0x8004, TRAINER_HILL_FUNC_8
special CallTrainerHillFunction
compare VAR_RESULT, 1
goto_if_eq TrainerHill_Entrance_EventScript_268275
@ -169,14 +168,14 @@ TrainerHill_Entrance_EventScript_2682C8:: @ 82682C8
switch VAR_RESULT
case 4, TrainerHill_Entrance_EventScript_268314
case 127, TrainerHill_Entrance_EventScript_268314
setvar VAR_0x8004, 17
setvar VAR_0x8004, TRAINER_HILL_FUNC_17
copyvar VAR_0x8005, VAR_RESULT
special CallTrainerHillFunction
setvar VAR_0x40D6, 1
setvar VAR_TEMP_5, 0
special HealPlayerParty
msgbox TrainerHill_Entrance_Text_26862A, MSGBOX_DEFAULT
setvar VAR_0x8004, 0
setvar VAR_0x8004, TRAINER_HILL_FUNC_0
special CallTrainerHillFunction
releaseall
end
@ -192,18 +191,18 @@ TrainerHill_Entrance_EventScript_268314:: @ 8268314
TrainerHill_Entrance_EventScript_26832E:: @ 826832E
msgbox TrainerHill_Entrance_Text_26851C, MSGBOX_DEFAULT
setvar VAR_0x8004, 14
setvar VAR_0x8004, TRAINER_HILL_FUNC_14
special CallTrainerHillFunction
setvar VAR_TEMP_5, 1
call Common_EventScript_SaveGame
compare VAR_RESULT, 0
goto_if_eq TrainerHill_Entrance_EventScript_26835C
setvar VAR_0x8004, 14
setvar VAR_0x8004, TRAINER_HILL_FUNC_14
special CallTrainerHillFunction
return
TrainerHill_Entrance_EventScript_26835C:: @ 826835C
setvar VAR_0x8004, 15
setvar VAR_0x8004, TRAINER_HILL_FUNC_15
special CallTrainerHillFunction
goto TrainerHill_Entrance_EventScript_268314
end

View File

@ -4,11 +4,11 @@ TrainerHill_Roof_MapScripts:: @ 8268FA7
.byte 0
TrainerHill_Roof_EventScript_268FB2:: @ 8268FB2
setvar VAR_0x8004, 12
setvar VAR_0x8004, TRAINER_HILL_FUNC_12
special CallTrainerHillFunction
lock
faceplayer
setvar VAR_0x8004, 1
setvar VAR_0x8004, TRAINER_HILL_FUNC_1
special CallTrainerHillFunction
switch VAR_RESULT
case 0, TrainerHill_Roof_EventScript_268FEA
@ -19,7 +19,7 @@ TrainerHill_Roof_EventScript_268FEA:: @ 8268FEA
msgbox TrainerHill_Roof_Text_268986, MSGBOX_DEFAULT
TrainerHill_Roof_EventScript_268FF2:: @ 8268FF2
setvar VAR_0x8004, 2
setvar VAR_0x8004, TRAINER_HILL_FUNC_2
special CallTrainerHillFunction
switch VAR_RESULT
case 0, TrainerHill_Roof_EventScript_269020
@ -41,7 +41,7 @@ TrainerHill_Roof_EventScript_269037:: @ 8269037
goto TrainerHill_Roof_EventScript_269054
TrainerHill_Roof_EventScript_269054:: @ 8269054
setvar VAR_0x8004, 3
setvar VAR_0x8004, TRAINER_HILL_FUNC_3
special CallTrainerHillFunction
switch VAR_RESULT
case 0, TrainerHill_Roof_EventScript_269082

View File

@ -0,0 +1,23 @@
#ifndef GUARD_CONSTANTS_TRAINER_HILL_H
#define GUARD_CONSTANTS_TRAINER_HILL_H
#define TRAINER_HILL_FUNC_0 0
#define TRAINER_HILL_FUNC_1 1
#define TRAINER_HILL_FUNC_2 2
#define TRAINER_HILL_FUNC_3 3
#define TRAINER_HILL_FUNC_4 4
#define TRAINER_HILL_FUNC_5 5
#define TRAINER_HILL_FUNC_6 6
#define TRAINER_HILL_FUNC_7 7
#define TRAINER_HILL_FUNC_8 8
#define TRAINER_HILL_FUNC_9 9
#define TRAINER_HILL_FUNC_10 10
#define TRAINER_HILL_FUNC_11 11
#define TRAINER_HILL_FUNC_12 12
#define TRAINER_HILL_FUNC_13 13
#define TRAINER_HILL_FUNC_14 14
#define TRAINER_HILL_FUNC_15 15
#define TRAINER_HILL_FUNC_16 16
#define TRAINER_HILL_FUNC_17 17
#endif

View File

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

View File

@ -61,8 +61,8 @@ void SetHBlankCallback(IntrCallback callback);
void SetVCountCallback(IntrCallback callback);
void SetSerialCallback(IntrCallback callback);
void InitFlashTimer(void);
void sub_80008DC(u32 *var);
void sub_80008E8(void);
void SetVBlankCounterPointer(u32 *var);
void ClearVBlankCounterPointer(void);
void DoSoftReset(void);
void ClearPokemonCrySongs(void);
void RestoreSerialTimer3IntrHandlers(void);

View File

@ -1,7 +1,7 @@
#ifndef GUARD_TRAINER_HILL_H
#define GUARD_TRAINER_HILL_H
extern u32 *gUnknown_0203CF5C;
extern u32 *gVBlankCounterPointer;
void CallTrainerHillFunction(void);
void ResetTrainerHillResults(void);

View File

@ -99,7 +99,7 @@ void MoveSaveBlocks_ResetHeap(void)
hblankCB = gMain.hblankCallback;
gMain.vblankCallback = NULL;
gMain.hblankCallback = NULL;
gUnknown_0203CF5C = NULL;
gVBlankCounterPointer = NULL;
saveBlock2Copy = (struct SaveBlock2 *)(gHeap);
saveBlock1Copy = (struct SaveBlock1 *)(gHeap + sizeof(struct SaveBlock2));

View File

@ -163,7 +163,7 @@ static void UpdateLinkAndCallCallbacks(void)
static void InitMainCallbacks(void)
{
gMain.vblankCounter1 = 0;
gUnknown_0203CF5C = NULL;
gVBlankCounterPointer = NULL;
gMain.vblankCounter2 = 0;
gMain.callback1 = NULL;
SetMainCallback2(CB2_InitCopyrightScreenAfterBootup);
@ -324,8 +324,8 @@ static void VBlankIntr(void)
gMain.vblankCounter1++;
if (gUnknown_0203CF5C && *gUnknown_0203CF5C < 0xFFFFFFFF)
(*gUnknown_0203CF5C)++;
if (gVBlankCounterPointer && *gVBlankCounterPointer < 0xFFFFFFFF)
(*gVBlankCounterPointer)++;
if (gMain.vblankCallback)
gMain.vblankCallback();
@ -393,14 +393,14 @@ static void WaitForVBlank(void)
;
}
void sub_80008DC(u32 *var)
void SetVBlankCounterPointer(u32 *var)
{
gUnknown_0203CF5C = var;
gVBlankCounterPointer = var;
}
void sub_80008E8(void)
void ClearVBlankCounterPointer(void)
{
gUnknown_0203CF5C = NULL;
gVBlankCounterPointer = NULL;
}
void DoSoftReset(void)

View File

@ -659,10 +659,10 @@ static void UpdateSaveAddresses(void)
u8 HandleSavingData(u8 saveType)
{
u8 i;
u32 *backupVar = gUnknown_0203CF5C;
u32 *backupVar = gVBlankCounterPointer;
u8 *tempAddr;
gUnknown_0203CF5C = NULL;
gVBlankCounterPointer = NULL;
UpdateSaveAddresses();
switch (saveType)
{
@ -705,7 +705,7 @@ u8 HandleSavingData(u8 saveType)
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
break;
}
gUnknown_0203CF5C = backupVar;
gVBlankCounterPointer = backupVar;
return 0;
}

View File

@ -92,15 +92,15 @@ struct TrHillStruct2
// EWRAM
static EWRAM_DATA struct TrHillStruct2 *sHillData = NULL;
static EWRAM_DATA struct TrHillRoomTrainers *sRoomTrainers = NULL;
EWRAM_DATA u32 *gUnknown_0203CF5C = NULL;
EWRAM_DATA u32 *gVBlankCounterPointer = NULL;
// This file's functions.
static void sub_81D581C(void);
static void TrainerHillStartChallenge(void);
static void sub_81D58D8(void);
static void sub_81D5924(void);
static void sub_81D59D0(void);
static void sub_81D5A70(void);
static void sub_81D5AB4(void);
static void TrainerHillResumeTimer(void);
static void TrainerHillSetPlayerLost(void);
static void sub_81D5AD0(void);
static void sub_81D5B2C(void);
static void sub_81D5BBC(void);
@ -263,12 +263,12 @@ static const u8 *const sFloorStrings[] =
static void (* const sHillFunctions[])(void) =
{
sub_81D581C,
TrainerHillStartChallenge,
sub_81D58D8,
sub_81D5924,
sub_81D59D0,
sub_81D5A70,
sub_81D5AB4,
TrainerHillResumeTimer,
TrainerHillSetPlayerLost,
sub_81D5AD0,
sub_81D5B2C,
sub_81D5BBC,
@ -371,7 +371,7 @@ void InitTrainerHillBattleStruct(void)
}
sRoomTrainers->facilityClass[i] = sHillData->tag.floors[sHillData->floorId].trainers[i].facilityClass;
}
sub_80008DC(&gSaveBlock1Ptr->trainerHill.field_3D64);
SetVBlankCounterPointer(&gSaveBlock1Ptr->trainerHill.timer);
FreeDataStruct();
}
@ -425,7 +425,7 @@ void CopyTrainerHillTrainerText(u8 which, u16 trainerId)
FreeDataStruct();
}
static void sub_81D581C(void)
static void TrainerHillStartChallenge(void)
{
nullsub_2();
if (!sub_81D3B34())
@ -434,8 +434,8 @@ static void sub_81D581C(void)
gSaveBlock1Ptr->trainerHill.field_3D6E_0f = 0;
gSaveBlock1Ptr->trainerHill.field_3D6C = 0;
sub_80008DC(&gSaveBlock1Ptr->trainerHill.field_3D64);
gSaveBlock1Ptr->trainerHill.field_3D64 = 0;
SetVBlankCounterPointer(&gSaveBlock1Ptr->trainerHill.timer);
gSaveBlock1Ptr->trainerHill.timer = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0c = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0b = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0e = 0;
@ -446,7 +446,7 @@ static void sub_81D581C(void)
static void sub_81D58D8(void)
{
sub_80008E8();
ClearVBlankCounterPointer();
gSpecialVar_Result = 0;
if (gSaveBlock1Ptr->trainerHill.field_3D6E_0c)
gSpecialVar_Result++;
@ -483,9 +483,9 @@ static void sub_81D59D0(void)
{
gSpecialVar_Result = 2;
}
else if (GetTimerValue(&gSaveBlock1Ptr->trainerHill.field_3D68) > gSaveBlock1Ptr->trainerHill.field_3D64)
else if (GetTimerValue(&gSaveBlock1Ptr->trainerHill.field_3D68) > gSaveBlock1Ptr->trainerHill.timer)
{
SetTimerValue(&gSaveBlock1Ptr->trainerHill.field_3D68, gSaveBlock1Ptr->trainerHill.field_3D64);
SetTimerValue(&gSaveBlock1Ptr->trainerHill.field_3D68, gSaveBlock1Ptr->trainerHill.timer);
gSaveBlock1Ptr->trainerHillTimes[gSaveBlock1Ptr->trainerHill.tag] = gSaveBlock1Ptr->trainerHill.field_3D68;
gSpecialVar_Result = 0;
}
@ -497,27 +497,27 @@ static void sub_81D59D0(void)
gSaveBlock1Ptr->trainerHill.field_3D6E_0b = 1;
}
static void sub_81D5A70(void)
static void TrainerHillResumeTimer(void)
{
if (!gSaveBlock1Ptr->trainerHill.field_3D6E_0c)
{
if (gSaveBlock1Ptr->trainerHill.field_3D64 >= HILL_MAX_TIME)
gSaveBlock1Ptr->trainerHill.field_3D64 = HILL_MAX_TIME;
if (gSaveBlock1Ptr->trainerHill.timer >= HILL_MAX_TIME)
gSaveBlock1Ptr->trainerHill.timer = HILL_MAX_TIME;
else
sub_80008DC(&gSaveBlock1Ptr->trainerHill.field_3D64);
SetVBlankCounterPointer(&gSaveBlock1Ptr->trainerHill.timer);
}
}
static void sub_81D5AB4(void)
static void TrainerHillSetPlayerLost(void)
{
gSaveBlock1Ptr->trainerHill.field_3D6E_0d = 1;
gSaveBlock1Ptr->trainerHill.hasLost = 1;
}
static void sub_81D5AD0(void)
{
if (gSaveBlock1Ptr->trainerHill.field_3D6E_0d)
if (gSaveBlock1Ptr->trainerHill.hasLost)
{
gSaveBlock1Ptr->trainerHill.field_3D6E_0d = 0;
gSaveBlock1Ptr->trainerHill.hasLost = 0;
gSpecialVar_Result = 0;
}
else if (gSaveBlock1Ptr->trainerHill.field_3D6E_0e)
@ -535,7 +535,7 @@ static void sub_81D5B2C(void)
{
s32 total, minutes, secondsWhole, secondsFraction;
total = gSaveBlock1Ptr->trainerHill.field_3D64;
total = gSaveBlock1Ptr->trainerHill.timer;
if (total >= HILL_MAX_TIME)
total = HILL_MAX_TIME;
@ -1048,7 +1048,7 @@ bool32 sub_81D6534(void)
static void sub_81D6568(void)
{
if (gSaveBlock1Ptr->trainerHill.field_3D6E_0d)
if (gSaveBlock1Ptr->trainerHill.hasLost)
gSpecialVar_Result = 0;
else
gSpecialVar_Result = 1;
@ -1103,7 +1103,7 @@ static u16 sub_81D6640(void)
i = (i + 1) % 10;
ptr = gUnknown_0862A5CC[var2][i];
minutes = (signed)(gSaveBlock1Ptr->trainerHill.field_3D64) / (60 * 60);
minutes = (signed)(gSaveBlock1Ptr->trainerHill.timer) / (60 * 60);
if (minutes < 12)
id = 0;
else if (minutes < 13)