Label remaining subs in battle_tower.c

This commit is contained in:
GriffinR 2020-12-24 16:18:47 -05:00
parent 49bdaeb940
commit 769ddf22c2
10 changed files with 60 additions and 47 deletions

View File

@ -72,9 +72,9 @@
special CallBattleTowerFunc
.endm
@ Unknown. Destroys some link task if using wireless link. Wait for link?
.macro tower_unklink
setvar VAR_0x8004, BATTLE_TOWER_FUNC_13
@ Attempts to close link connection. Used when finishing a link multi challenge.
.macro tower_closelink
setvar VAR_0x8004, BATTLE_TOWER_FUNC_TRY_CLOSE_LINK
special CallBattleTowerFunc
.endm

View File

@ -443,7 +443,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobbyMultis:: @ 82421F2
end
BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobbyLinkMultis:: @ 82421FC
tower_unklink
tower_closelink
warp MAP_BATTLE_FRONTIER_BATTLE_TOWER_LOBBY, 255, 18, 6
waitstate
end

View File

@ -83,6 +83,6 @@ u8 GetFrontierEnemyMonLevel(u8 lvlMode);
s32 GetHighestLevelInPlayerParty(void);
u8 FacilityClassToGraphicsId(u8 facilityClass);
bool32 ValidateBattleTowerRecord(u8 recordId); // unused
void sub_8166188(void);
void TrySetLinkBattleTowerEnemyPartyLevel(void);
#endif //GUARD_BATTLE_TOWER_H

View File

@ -14,7 +14,7 @@
#define BATTLE_TOWER_FUNC_LOAD_PARTNERS 10
#define BATTLE_TOWER_FUNC_PARTNER_MSG 11
#define BATTLE_TOWER_FUNC_LOAD_LINK_OPPONENTS 12
#define BATTLE_TOWER_FUNC_13 13
#define BATTLE_TOWER_FUNC_TRY_CLOSE_LINK 13
#define BATTLE_TOWER_FUNC_SET_PARTNER_GFX 14
#define BATTLE_TOWER_FUNC_SET_INTERVIEW_DATA 15

View File

@ -275,7 +275,7 @@ void CreateBattleTowerMon(struct Pokemon *mon, struct BattleTowerPokemon *src);
void CreateBattleTowerMon2(struct Pokemon *mon, struct BattleTowerPokemon *src, bool8 lvl50);
void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId);
void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId);
void sub_80686FC(struct Pokemon *mon, struct BattleTowerPokemon *dest);
void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest);
void CreateObedientMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId);
bool8 sub_80688F8(u8 caseId, u8 battlerId);
void SetDeoxysStats(void);
@ -381,7 +381,7 @@ void ClearBattleMonForms(void);
u16 GetBattleBGM(void);
void PlayBattleBGM(void);
void PlayMapChosenOrBattleBGM(u16 songId);
void sub_806E694(u16 songId);
void CreateTask_PlayMapChosenOrBattleBGM(u16 songId);
const u32 *GetMonFrontSpritePal(struct Pokemon *mon);
const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 personality);
const struct CompressedSpritePalette *GetMonSpritePalStruct(struct Pokemon *mon);

View File

@ -30,7 +30,7 @@ void sub_818603C(u8 arg0);
u32 GetAiScriptsInRecordedBattle(void);
void sub_8186444(void);
bool8 sub_8186450(void);
void sub_8186468(u8 *dst);
void GetRecordedBattleRecordMixFriendName(u8 *dst);
u8 GetRecordedBattleRecordMixFriendClass(void);
u8 GetRecordedBattleApprenticeId(void);
u8 GetRecordedBattleRecordMixFriendLanguage(void);

View File

@ -1357,7 +1357,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
case 16:
if (BattleInitAllSprites(&gBattleCommunication[SPRITES_INIT_STATE1], &gBattleCommunication[SPRITES_INIT_STATE2]))
{
sub_8166188();
TrySetLinkBattleTowerEnemyPartyLevel();
gPreBattleCallback1 = gMain.callback1;
gMain.callback1 = BattleMainCB1;
SetMainCallback2(BattleMainCB2);

View File

@ -57,12 +57,12 @@ static void SetTowerBattleWon(void);
static void AwardBattleTowerRibbons(void);
static void SaveTowerChallenge(void);
static void GetOpponentIntroSpeech(void);
static void nullsub_61(void);
static void nullsub_116(void);
static void BattleTowerNop1(void);
static void BattleTowerNop2(void);
static void LoadMultiPartnerCandidatesData(void);
static void ShowPartnerCandidateMessage(void);
static void LoadLinkMultiOpponentsData(void);
static void sub_8164DCC(void);
static void TowerTryCloseLink(void);
static void SetMultiPartnerGfx(void);
static void SetTowerInterviewData(void);
static void ValidateBattleTowerRecordChecksums(void);
@ -811,12 +811,12 @@ static void (* const sBattleTowerFuncs[])(void) =
[BATTLE_TOWER_FUNC_GIVE_RIBBONS] = AwardBattleTowerRibbons,
[BATTLE_TOWER_FUNC_SAVE] = SaveTowerChallenge,
[BATTLE_TOWER_FUNC_GET_OPPONENT_INTRO] = GetOpponentIntroSpeech,
[BATTLE_TOWER_FUNC_NOP] = nullsub_61,
[BATTLE_TOWER_FUNC_NOP2] = nullsub_116,
[BATTLE_TOWER_FUNC_NOP] = BattleTowerNop1,
[BATTLE_TOWER_FUNC_NOP2] = BattleTowerNop2,
[BATTLE_TOWER_FUNC_LOAD_PARTNERS] = LoadMultiPartnerCandidatesData,
[BATTLE_TOWER_FUNC_PARTNER_MSG] = ShowPartnerCandidateMessage,
[BATTLE_TOWER_FUNC_LOAD_LINK_OPPONENTS] = LoadLinkMultiOpponentsData,
[BATTLE_TOWER_FUNC_13] = sub_8164DCC,
[BATTLE_TOWER_FUNC_TRY_CLOSE_LINK] = TowerTryCloseLink,
[BATTLE_TOWER_FUNC_SET_PARTNER_GFX] = SetMultiPartnerGfx,
[BATTLE_TOWER_FUNC_SET_INTERVIEW_DATA] = SetTowerInterviewData,
};
@ -1547,7 +1547,7 @@ void GetFrontierTrainerName(u8 *dst, u16 trainerId)
{
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
{
sub_8186468(dst);
GetRecordedBattleRecordMixFriendName(dst);
return;
}
else
@ -2059,7 +2059,7 @@ void DoSpecialTrainerBattle(void)
if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
FillFrontierTrainerParty(DOME_BATTLE_PARTY_SIZE);
CreateTask(Task_StartBattleAfterTransition, 1);
sub_806E694(0);
CreateTask_PlayMapChosenOrBattleBGM(0);
BattleTransition_StartOnField(GetSpecialBattleTransition(3));
break;
case SPECIAL_BATTLE_PALACE:
@ -2139,7 +2139,7 @@ static void SaveCurrentWinStreak(void)
gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] = winStreak;
}
static void sub_8163EE4(void)
static void SaveBattleTowerRecord(void)
{
s32 i;
u8 lvlMode, battleMode, class;
@ -2178,7 +2178,7 @@ static void sub_8163EE4(void)
for (i = 0; i < MAX_FRONTIER_PARTY_SIZE; i++)
{
if (gSaveBlock2Ptr->frontier.selectedPartyMons[i] != 0)
sub_80686FC(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], &playerRecord->party[i]);
ConvertPokemonToBattleTowerPokemon(&gPlayerParty[gSaveBlock2Ptr->frontier.selectedPartyMons[i] - 1], &playerRecord->party[i]);
}
playerRecord->language = gGameLanguage;
@ -2193,7 +2193,7 @@ static void SaveTowerChallenge(void)
s32 challengeNum = (signed)(gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] / 7);
if (gSpecialVar_0x8005 == 0 && (challengeNum > 1 || gSaveBlock2Ptr->frontier.curChallengeBattleNum != 0))
sub_8163EE4();
SaveBattleTowerRecord();
gSaveBlock2Ptr->frontier.challengeStatus = gSpecialVar_0x8005;
VarSet(VAR_TEMP_0, 0);
@ -2201,12 +2201,12 @@ static void SaveTowerChallenge(void)
SaveGameFrontier();
}
static void nullsub_61(void)
static void BattleTowerNop1(void)
{
}
static void nullsub_116(void)
static void BattleTowerNop2(void)
{
}
@ -2410,7 +2410,7 @@ static void LoadMultiPartnerCandidatesData(void)
}
}
static void sub_81646BC(u16 trainerId, u16 monId)
static void GetPotentialPartnerMoveAndSpecies(u16 trainerId, u16 monId)
{
u16 move = 0;
u16 species = 0;
@ -2445,6 +2445,14 @@ static void sub_81646BC(u16 trainerId, u16 monId)
StringCopy(gStringVar2, gSpeciesNames[species]);
}
// For multi battles in the Battle Tower, the player may choose a partner by talking to them
// These partners can be an NPC or a former/record-mixed Apprentice
// When talked to, their response consists of:
// PARTNER_MSGID_INTRO - A greeting
// PARTNER_MSGID_MON1 - Naming one pokemon on their team, and a move it has
// PARTNER_MSGID_MON2_ASK - Naming a second pokemon on their team, a move it has, and asking if they'd like to be their partner
// PARTNER_MSGID_ACCEPT - If the player agrees to be their partner
// PARTNER_MSGID_REJECT - If the player declines to be their partner
static void ShowPartnerCandidateMessage(void)
{
s32 i, j, partnerId;
@ -2487,11 +2495,11 @@ static void ShowPartnerCandidateMessage(void)
break;
case PARTNER_MSGID_MON1:
monId = gSaveBlock2Ptr->frontier.trainerIds[8 + k * 2];
sub_81646BC(trainerId, monId);
GetPotentialPartnerMoveAndSpecies(trainerId, monId);
break;
case PARTNER_MSGID_MON2_ASK:
monId = gSaveBlock2Ptr->frontier.trainerIds[9 + k * 2];
sub_81646BC(trainerId, monId);
GetPotentialPartnerMoveAndSpecies(trainerId, monId);
break;
case PARTNER_MSGID_ACCEPT:
gPartnerTrainerId = trainerId;
@ -2643,7 +2651,7 @@ static void LoadLinkMultiOpponentsData(void)
}
}
static void sub_8164DCC(void)
static void TowerTryCloseLink(void)
{
if (gWirelessCommType != 0)
SetCloseLinkCallback();
@ -2838,7 +2846,7 @@ static void FillEReaderTrainerWithPlayerData(void)
}
for (i = 0; i < 3; i++)
sub_80686FC(&gPlayerParty[i], &ereaderTrainer->party[i]);
ConvertPokemonToBattleTowerPokemon(&gPlayerParty[i], &ereaderTrainer->party[i]);
SetEReaderTrainerChecksum(ereaderTrainer);
}
@ -3292,16 +3300,16 @@ static u8 GetFrontierTrainerFixedIvs(u16 trainerId)
return fixedIv;
}
static u16 sub_8165D40(void)
static u16 GetBattleTentTrainerId(void)
{
u32 facility = VarGet(VAR_FRONTIER_FACILITY);
if (facility == FRONTIER_FACILITY_PALACE)
return Random() % 30;
else if (facility == FRONTIER_FACILITY_ARENA)
return Random() % 30;
else if (facility == FRONTIER_FACILITY_FACTORY)
return Random() % 30;
if (facility == FRONTIER_FACILITY_PALACE) // Verdanturf Tent; uses Palace mechanics
return Random() % NUM_BATTLE_TENT_TRAINERS;
else if (facility == FRONTIER_FACILITY_ARENA) // Fallarbor Tent; uses Arena mechanics
return Random() % NUM_BATTLE_TENT_TRAINERS;
else if (facility == FRONTIER_FACILITY_FACTORY) // Slateport Tent; uses Factory mechanics
return Random() % NUM_BATTLE_TENT_TRAINERS;
else if (facility == FRONTIER_FACILITY_TOWER)
return 0;
else
@ -3348,7 +3356,7 @@ static void SetNextBattleTentOpponent(void)
do
{
trainerId = sub_8165D40();
trainerId = GetBattleTentTrainerId();
for (i = 0; i < gSaveBlock2Ptr->frontier.curChallengeBattleNum; i++)
{
if (gSaveBlock2Ptr->frontier.trainerIds[i] == trainerId)
@ -3511,7 +3519,7 @@ bool32 ValidateBattleTowerRecord(u8 recordId) // unused
}
}
void sub_8166188(void)
void TrySetLinkBattleTowerEnemyPartyLevel(void)
{
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
{

View File

@ -57,7 +57,7 @@ static u16 CalculateBoxMonChecksum(struct BoxPokemon *boxMon);
static union PokemonSubstruct *GetSubstruct(struct BoxPokemon *boxMon, u32 personality, u8 substructType);
static void EncryptBoxMon(struct BoxPokemon *boxMon);
static void DecryptBoxMon(struct BoxPokemon *boxMon);
static void sub_806E6CC(u8 taskId);
static void Task_PlayMapChosenOrBattleBGM(u8 taskId);
static bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move);
static bool8 ShouldSkipFriendshipChange(void);
@ -2578,7 +2578,7 @@ void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level,
CalculateMonStats(mon);
}
void sub_80686FC(struct Pokemon *mon, struct BattleTowerPokemon *dest)
void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest)
{
s32 i;
u16 heldItem;
@ -2587,7 +2587,7 @@ void sub_80686FC(struct Pokemon *mon, struct BattleTowerPokemon *dest)
heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, NULL);
if (heldItem == ITEM_ENIGMA_BERRY)
heldItem = 0;
heldItem = ITEM_NONE;
dest->heldItem = heldItem;
@ -6334,26 +6334,31 @@ void PlayMapChosenOrBattleBGM(u16 songId)
PlayNewMapMusic(GetBattleBGM());
}
void sub_806E694(u16 songId)
// Identical to PlayMapChosenOrBattleBGM, but uses a task instead
// Only used by Battle Dome
#define tSongId data[0]
void CreateTask_PlayMapChosenOrBattleBGM(u16 songId)
{
u8 taskId;
ResetMapMusic();
m4aMPlayAllStop();
taskId = CreateTask(sub_806E6CC, 0);
gTasks[taskId].data[0] = songId;
taskId = CreateTask(Task_PlayMapChosenOrBattleBGM, 0);
gTasks[taskId].tSongId = songId;
}
static void sub_806E6CC(u8 taskId)
static void Task_PlayMapChosenOrBattleBGM(u8 taskId)
{
if (gTasks[taskId].data[0])
PlayNewMapMusic(gTasks[taskId].data[0]);
if (gTasks[taskId].tSongId)
PlayNewMapMusic(gTasks[taskId].tSongId);
else
PlayNewMapMusic(GetBattleBGM());
DestroyTask(taskId);
}
#undef tSongId
const u32 *GetMonFrontSpritePal(struct Pokemon *mon)
{
u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0);

View File

@ -846,7 +846,7 @@ bool8 sub_8186450(void)
return (sUnknown_0203CCD0 == 0);
}
void sub_8186468(u8 *dst)
void GetRecordedBattleRecordMixFriendName(u8 *dst)
{
s32 i;