Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions asm/macros/frscrcmd.inc
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,9 @@
.short \partySlot2
.endm

.macro FrontierScrCmd_8C arg0
.short FRSCRCMD_8C
.short \arg0
.macro BattleHall_SetupNextOpponent unused=VAR_0x8003
.short FRSCRCMD_BATTLEHALL_SETUP_NEXT_OPPONENT
.short \unused
.endm

.macro FreeBattleHall
Expand Down Expand Up @@ -800,21 +800,21 @@
.short \destVar
.endm

.macro FrontierScrCmd_93 arg0, arg1, arg2
.short FRSCRCMD_93
.short \arg0
.short \arg1
.short \arg2
.macro BattleHall_SendCommMessage command, arg, returnVar

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I would like to annotate the arguments to script-commands with :req to denote that they are required. Otherwise, it's a pretty big foot-gun for an end-user. That can be a separate PR, but we should definitely do it.

I have a basic awk-script for this, if that interests you:

#!/usr/bin/env -vS awk -f

! /\.macro/ { print $0 }

/\.macro/ {
    for (i = 3; i <= NF; i++) {
        if ($i ~ /.*,/) {
            sub(/,/, ":req,", $i)
        } else {
            $i = $i ":req"
        }
    }

    print "    " $0
}

Stick this in a file, make it executable, and run it against the input file:

./annotate.awk asm/macros/frscrcmd.inc > asm/macros/frscrcmd.inc.new

Then you can check the output and replace the old file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, but as you say, I think this should be in a separate PR.

.short FRSCRCMD_BATTLEHALL_SENDCOMMMESSAGE
.short \command
.short \arg
.short \returnVar
.endm

.macro FrontierScrCmd_94 arg0
.short FRSCRCMD_94
.short \arg0
.endm

.macro FrontierScrCmd_95 arg0
.short FRSCRCMD_95
.byte \arg0
.macro BattleHall_PrintTrainerIntro index
.short FRSCRCMD_BATTLEHALL_PRINTTRAINERINTRO
.byte \index
.endm

.macro FrontierScrCmd_Dummy96 arg0
Expand Down
2 changes: 1 addition & 1 deletion include/applications/frontier/battle_hall/main.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef POKEPLATINUM_APPLICATIONS_BATTLE_HALL_MAIN_H
#define POKEPLATINUM_APPLICATIONS_BATTLE_HALL_MAIN_H

#include "overlay104/struct_battle_hall.h"
#include "overlay104/battle_hall.h"

#include "overlay_manager.h"
#include "party.h"
Expand Down
4 changes: 2 additions & 2 deletions include/battle_frontier.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ extern const ApplicationManagerTemplate gBattleFrontierAppTemplate;

FieldFrontierDTO *BattleFrontier_GetFieldData(BattleFrontier *frontier);
FrontierGraphics *BattleFrontier_GetGraphics(BattleFrontier *frontier);
void *sub_0209B978(BattleFrontier *frontier);
void sub_0209B980(BattleFrontier *frontier, void *param1);
void *BattleFrontier_GetFacilityStruct(BattleFrontier *frontier);
void BattleFrontier_SetFacilityStruct(BattleFrontier *frontier, void *param1);
void sub_0209B988(BattleFrontier *frontier, const ApplicationManagerTemplate *param1, void *param2, int param3, UnkFuncPtr_0209B988 param4);
void sub_0209B9B4(BattleFrontier *frontier);
void sub_0209B9BC(BattleFrontier *frontier, u16 sceneID, u16 param2);
Expand Down
21 changes: 11 additions & 10 deletions include/battle_hall_save.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#ifndef POKEPLATINUM_BATTLE_HALL_SAVE_H
#define POKEPLATINUM_BATTLE_HALL_SAVE_H

#include "constants/battle_frontier.h"

#include "savedata.h"

#define HALL_SAVE_CHALLENGE_TYPE 0
#define HALL_SAVE_UNK_1 1
#define HALL_SAVE_TRAINER_IDS 2
#define HALL_SAVE_PARTY_SLOTS 3
#define HALL_SAVE_UNK_4 4
#define HALL_SAVE_STREAK_FLAGS 5
#define HALL_SAVE_CHALLENGE_TYPE 0
#define HALL_SAVE_CURRENT_BATTLE 1
#define HALL_SAVE_TRAINER_IDS 2
#define HALL_SAVE_PARTY_SLOTS 3
#define HALL_SAVE_POKEMON_INDICES 4
#define HALL_SAVE_STREAK_FLAGS 5

typedef struct BattleHallSave {
u8 challengeType : 3;
u8 didSave : 1;
u8 unk_00_4 : 4;
u8 unk_01;
u8 currentBattleNum;
u8 partySlots[2];
u16 trainerIDs[20];
u16 unk_2C[20];
u16 trainerIDs[HALL_BATTLES_PER_ROUND * 2];
u16 monIndices[HALL_BATTLES_PER_ROUND * 2];
} BattleHallSave;

typedef struct BattleHallStreakFlags {
Expand Down
11 changes: 10 additions & 1 deletion include/constants/battle_frontier.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ enum BattleFrontierScene {
#define FRONTIER_RECORDS_APP_HALL 5
#define FRONTIER_RECORDS_APP_ARCADE 6

#define BATTLES_PER_ROUND_HALL 10
#define HALL_BATTLES_PER_ROUND 10
#define HALL_STREAK_SILVER_BATTLE 50
#define HALL_STREAK_GOLD_BATTLE 170
#define HALL_MAX_DISTINCT_ROUNDS ((HALL_STREAK_GOLD_BATTLE / HALL_BATTLES_PER_ROUND) + 1)

#define HALL_NEXT_BATTLE_NORMAL 0
#define HALL_NEXT_BATTLE_SILVER 1
#define HALL_NEXT_BATTLE_GOLD 2

#define HALL_MAX_TYPE_RANK 10

#define BATTLES_PER_ROUND_ARCADE 7

Expand Down
28 changes: 14 additions & 14 deletions include/constants/battle_hall_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ enum BattleHallFunction {
BH_FUNC_UNK_6,
BH_FUNC_RESET_SYSTEM,
BH_FUNC_UNK_8,
BH_FUNC_UNK_9,
BH_FUNC_CHECK_HAS_SAVED,
BH_FUNC_QUICKSAVE,
BH_FUNC_UNK_11,
BH_FUNC_UNK_12,
BH_FUNC_UNK_13,
BH_FUNC_UNK_14,
BH_FUNC_UNK_15,
BH_FUNC_INCREMENT_CURRENT_BATTLE,
BH_FUNC_GET_PLAYERS_MONS_SPECIES,
BH_FUNC_UNK_16,
BH_FUNC_GET_CHALLENGE_TYPE,
BH_FUNC_UNK_18,
BH_FUNC_UNK_19,
BH_FUNC_UNK_20,
BH_FUNC_UNK_21,
BH_FUNC_UNK_22,
BH_FUNC_UNK_23,
BH_FUNC_GET_CURRENT_ROUND,
BH_FUNC_GET_OPPONENT_OBJECT_ID,
BH_FUNC_SAVE_ON_LOSS,
BH_FUNC_SAVE_ON_COMPLETING_ROUND,
BH_FUNC_GET_CURRENT_BATTLE,
BH_FUNC_UNK_24,
BH_FUNC_UNK_25,
BH_FUNC_UNK_26,
BH_FUNC_RESTORE_HELD_ITEMS,
BH_FUNC_UNK_28,
BH_FUNC_INCREMENT_RANK_OF_BEATEN_TYPE,
BH_FUNC_UNK_29,
BH_FUNC_IS_MULTIPLAYER_CHALLENGE,
BH_FUNC_TOGGLE_ENGINE_LAYER,
BH_FUNC_UNK_32,
BH_FUNC_UNK_33,
BH_FUNC_UNK_34,
BH_FUNC_UNK_35,
BH_FUNC_LOAD_TRAINERS,
BH_FUNC_GET_RANK_OF_BEATEN_TYPE,
BH_FUNC_GET_EARNED_BP,
BH_FUNC_CAP_TYPE_RANKS,
BH_FUNC_SET_BASE_LEVEL,
BH_FUNC_UNK_37,
BH_FUNC_GET_NEXT_BATTLE_TYPE,
BH_FUNC_DUMMY,
};

Expand Down
6 changes: 3 additions & 3 deletions include/data/scripts/frscrcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ ScriptCommand(FRSCRCMD_BATTLETOWER_CHECKWONBATTLE, FrontierScrCmd_BattleTo
ScriptCommand(FRSCRCMD_89, FrontierScrCmd_89)
ScriptCommand(FRSCRCMD_8A, FrontierScrCmd_8A)
ScriptCommand(FRSCRCMD_INITBATTLEHALL, FrontierScrCmd_InitBattleHall)
ScriptCommand(FRSCRCMD_8C, FrontierScrCmd_8C)
ScriptCommand(FRSCRCMD_BATTLEHALL_SETUP_NEXT_OPPONENT, FrontierScrCmd_BattleHall_SetupNextOpponent)
ScriptCommand(FRSCRCMD_FREEBATTLEHALL, FrontierScrCmd_FreeBattleHall)
ScriptCommand(FRSCRCMD_OPENBATTLEHALLAPP, FrontierScrCmd_OpenBattleHallApp)
ScriptCommand(FRSCRCMD_BATTLEHALL_CLEANUPBATTLE, FrontierScrCmd_BattleHall_CleanupBattle)
ScriptCommand(FRSCRCMD_BATTLEHALL_STARTBATTLE, FrontierScrCmd_BattleHall_StartBattle)
ScriptCommand(FRSCRCMD_CALLBATTLEHALLFUNCTION, FrontierScrCmd_CallBattleHallFunction)
ScriptCommand(FRSCRCMD_BATTLEHALL_CHECKWONBATTLE, FrontierScrCmd_BattleHall_CheckWonBattle)
ScriptCommand(FRSCRCMD_93, FrontierScrCmd_93)
ScriptCommand(FRSCRCMD_BATTLEHALL_SENDCOMMMESSAGE, FrontierScrCmd_BattleHall_SendCommMessage)
ScriptCommand(FRSCRCMD_94, FrontierScrCmd_94)
ScriptCommand(FRSCRCMD_95, FrontierScrCmd_95)
ScriptCommand(FRSCRCMD_BATTLEHALL_PRINTTRAINERINTRO, FrontierScrCmd_BattleHall_PrintTrainerIntro)
ScriptCommand(FRSCRCMD_DUMMY96, FrontierScrCmd_Dummy96)
ScriptCommand(FRSCRCMD_97, FrontierScrCmd_97)
ScriptCommand(FRSCRCMD_98, FrontierScrCmd_98)
Expand Down
67 changes: 67 additions & 0 deletions include/overlay104/battle_hall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef POKEPLATINUM_BATTLE_HALL_H
#define POKEPLATINUM_BATTLE_HALL_H

#include "constants/battle_frontier.h"

#include "struct_defs/pokemon.h"

#include "overlay104/frontier_data_transfer.h"

#include "battle_hall_save.h"
#include "field_battle_data_transfer.h"
#include "party.h"
#include "savedata.h"

typedef struct BattleHall {
int unused;
u8 challengeType;
u8 currentBattle;
u8 saveStreak;
u8 opponentsLevel;
u16 currentStreak;
u16 currentRound;
fx32 playerLevelSqrt;
u32 unk_10;
int wonBattle;
u16 trainerIDs[HALL_BATTLES_PER_ROUND * 2];
FrontierDataDTO opponents[2];
u8 partySlots[2];
Party *party;
u16 monIndices[HALL_BATTLES_PER_ROUND * 2];
FrontierPokemonDataDTO opponentMons[HALL_BATTLES_PER_ROUND * 2];
u16 unk_6F0;
u16 selectedTypeIdx2;
u8 selectedType;
u8 selectedTypeIdx;
BattleHallSave *hallSave;
SaveData *saveData;
FieldBattleDTO *dto;
u8 typeRanks[4][9];
u16 heldItems[2];
u16 unk_72C[44];
u8 unk_784[512];
u8 unk_984[2][512];
u16 unk_D84[2];
u8 unk_D88;
Pokemon *partnersMon;
u8 unk_D90;
u32 unk_D94;
} BattleHall;

BattleHall *BattleHall_Init(SaveData *saveData, u16 resumingFromSave, u8 challengeType, u8 partySlot1, u8 partySlot2);
void BattleHall_SetupNextOpponent(BattleHall *battleHall, u16 unused);
void BattleHall_Free(BattleHall *battleHall);
void BattleHall_GetTypeSelectionAppResult(BattleHall *battleHall, void *args);
void BattleHall_UpdateWinRecordForCurrentMon(BattleHall *battleHall, u16 *updated);
void BattleHall_Save(BattleHall *battleHall, u8 saveType);
u16 BattleHall_IncrementCurrentBattle(BattleHall *battleHall);
u16 BattleHall_GetCurrentBattle(BattleHall *battleHall);
u16 BattleHall_GetNextOpponentObjectID(BattleHall *battleHall, u8 trainerSlot);
void BattleHall_SaveOnLoss(BattleHall *battleHall);
void BattleHall_SaveOnCompletingRound(BattleHall *battleHall);
BOOL BattleHall_SendCommMessage(BattleHall *battleHall, u16 command, u16 arg);
u16 BattleHall_GetEarnedBP(BattleHall *battleHall);
void BattleHall_CapTypeRanks(BattleHall *battleHall);
void BattleHall_CalcPlayerLevelSqrt(BattleHall *battleHall);

#endif // POKEPLATINUM_BATTLE_HALL_H
23 changes: 23 additions & 0 deletions include/overlay104/battle_hall_helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef POKEPLATINUM_BATTLE_HALL_HELPERS_H
#define POKEPLATINUM_BATTLE_HALL_HELPERS_H

#include "overlay104/battle_hall.h"
#include "overlay104/struct_ov104_02230BE4.h"

#include "field_battle_data_transfer.h"

#define BATTLE_HALL_MON_SUMMARY 0xfe

void BattleHall_PickOpponentTrainerClasses(u8 selectedTypeIdx, u8 numTrainers, u8 typeRank, u8 currentBattle, u16 trainerIDs[]);
void BattleHall_PickOpponentTrainers(u8 challengeType, u8 numTrainers, int currentRound, u8 rank, u8 currentBattle, u16 trainerIDs[]);
void BattleHall_PickNextOpponentPokemon(u8 numOpponentsToPick, u8 selectedType, u8 typeRank, u8 currentBattle, u16 playersSpecies, u16 opponentIndices[], u8 battleType);
FieldBattleDTO *BattleHall_SetupBattle(BattleHall *battleHall, FieldFrontierDTO *fieldData);
u8 BattleHall_GetPlayerPartySize(u8 challengeType);
u8 BattleHall_GetOpponentPartySize(u8 challengeType);
u8 BattleHall_CursorPosToType(u8 cursorPos);
BOOL BattleHall_IsMultiPlayerChallenge(u8 challengeType);
u8 BattleHall_GetHallMatronTypeRank(BattleHall *battleHall);
u16 BattleHall_GetHighestLevelInParty(BattleHall *battleHall);
fx32 BattleHall_GetLevelSquareRoot(u32 level);

#endif // POKEPLATINUM_BATTLE_HALL_HELPERS_H
6 changes: 3 additions & 3 deletions include/overlay104/frscrcmd_battle_hall.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
#include "overlay104/defs.h"

BOOL FrontierScrCmd_InitBattleHall(FrontierScriptContext *ctx);
BOOL FrontierScrCmd_8C(FrontierScriptContext *param0);
BOOL FrontierScrCmd_BattleHall_SetupNextOpponent(FrontierScriptContext *param0);
BOOL FrontierScrCmd_FreeBattleHall(FrontierScriptContext *ctx);
BOOL FrontierScrCmd_OpenBattleHallApp(FrontierScriptContext *ctx);
BOOL FrontierScrCmd_BattleHall_CleanupBattle(FrontierScriptContext *ctx);
BOOL FrontierScrCmd_BattleHall_StartBattle(FrontierScriptContext *ctx);
BOOL FrontierScrCmd_CallBattleHallFunction(FrontierScriptContext *ctx);
BOOL FrontierScrCmd_BattleHall_CheckWonBattle(FrontierScriptContext *ctx);
BOOL FrontierScrCmd_93(FrontierScriptContext *param0);
BOOL FrontierScrCmd_BattleHall_SendCommMessage(FrontierScriptContext *param0);
BOOL FrontierScrCmd_94(FrontierScriptContext *param0);
BOOL FrontierScrCmd_95(FrontierScriptContext *param0);
BOOL FrontierScrCmd_BattleHall_PrintTrainerIntro(FrontierScriptContext *param0);
BOOL FrontierScrCmd_BattleHall_UpdateWinRecord(FrontierScriptContext *ctx);
BOOL FrontierScrCmd_C7(FrontierScriptContext *param0);

Expand Down
10 changes: 5 additions & 5 deletions include/overlay104/ov104_0222DCE0.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
#include "trainer_info.h"

BattleFrontierTrainerData *BattleFrontier_GetTrainerDataFromTrainerIDAndNarcID(u16 battleTowerTrainerID, enum HeapID heapID, enum NarcID narcID);
void BattleTower_GetMonDataFromSetIDAndNarcID(BattleFrontierPokemonData *monData, int setID, enum NarcID narcID);
void BattleTower_GetMonDataFromSetIDAndNarcID(BattleFrontierPokemonData *monData, int narcIdx, enum NarcID narcID);
BattleFrontierTrainerData *BattleFrontier_GetTrainerData(FrontierTrainerDataDTO *trDataDTO, int battleTowerTrainerID, enum HeapID heapID, enum NarcID narcID);
u32 ov104_0222DD6C(FrontierPokemonDataDTO *param0, u16 param1, u32 param2, u32 param3, u8 param4, u8 param5, BOOL param6, int param7, enum NarcID narcID);
u32 ov104_0222DD6C(FrontierPokemonDataDTO *param0, u16 narcIdx, u32 otID, u32 param3, u8 ivs, u8 param5, BOOL param6, int heapID, enum NarcID narcID);
void FrontierPokemonDataDTO_InitPokemon(const FrontierPokemonDataDTO *pokemonDTO, Pokemon *mon, u8 param2);
u16 BattleTower_GetObjectIDFromTrainerClass(u8 trainerClass);
void ov104_0222E134(SaveData *saveData, Pokemon *param1);
void ov104_0222E1C0(SaveData *saveData, Party *party, Pokemon *param2);
void BattleCastle_UpdateMonSpriteAnimID(Sprite *sprite, u8 animID);
void BattleCastle_UpdateMonSpritePosition(Sprite *sprite, s16 x, s16 y, u8 isSelected);
u8 BattleCastle_GetPokeIconAnimID(u16 hp, u16 maxHp);
void ov104_0222E278(FrontierDataDTO *param0, u16 param1, enum HeapID heapID, int param3);
void BattleFrontier_LoadTrainer(FrontierDataDTO *opponent, u16 trainerID, enum HeapID heapID, enum NarcID narcID);
void FieldBattleDTO_InitFrontierTrainer(FieldBattleDTO *battleDTO, FrontierTrainerDataDTO *trDataDTO, int unused, int battlerId, enum HeapID heapID);
u32 ov104_0222E2F0(FrontierPokemonDataDTO *param0, u16 param1, int param2, u8 param3, u32 param4, int param5, int param6);
u32 BattleFrontier_LoadOpponentMonData(FrontierPokemonDataDTO *mon, u16 narcIdx, int item, u8 ivs, u32 personality, int heapID, int narcID);
void ov104_0222E330(FrontierPokemonDataDTO *param0, u16 param1[], u8 param2[], u32 param3[], u32 param4[], int param5, int param6, int param7);
u8 ov104_0222E3A8(u16 param0);
BOOL ov104_0222E3E4(BattleFrontierTrainerData *param0, const u16 param1[], const u16 param2[], int param3, int param4, u16 param5[], int param6);
void ov104_0222E4BC(u8 param0, u16 param1, u16 param2, u16 *param3, FrontierPokemonDataDTO *param4, u8 *param5, u32 *param6, u8 param7);
void BattleFrontier_SetPartnerInStrTemplate(StringTemplate *template, u32 idx);
enum ObjectEventGfx BattleFrontier_GetPlayerObjEventGfx(const TrainerInfo *param0);
enum ObjectEventGfx BattleFrontier_GetPlayerObjEventGfx(const TrainerInfo *playerInfo);
void BattleFrontier_FlagGeonetLinkInfo(SaveData *saveData);

#endif // POKEPLATINUM_OV104_0222DCE0_H
2 changes: 1 addition & 1 deletion include/overlay104/ov104_0222ECE8.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef POKEPLATINUM_OV104_0222ECE8_H
#define POKEPLATINUM_OV104_0222ECE8_H

#include "overlay104/battle_hall.h"
#include "overlay104/struct_battle_arcade.h"
#include "overlay104/struct_battle_castle.h"
#include "overlay104/struct_battle_factory.h"
#include "overlay104/struct_battle_hall.h"

void ov104_0222ECE8(int param0, int param1, void *param2, void *param3);
BOOL ov104_0222ED00(BattleHall *param0);
Expand Down
4 changes: 2 additions & 2 deletions include/overlay104/ov104_02231F74.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void ov104_02232FEC(FrontierGraphics *param0);
void ov104_0223307C(FrontierGraphics *param0);
ManagedSprite *ov104_022330AC(FrontierGraphics *param0, int param1, int param2);
void ov104_022330F0(FrontierGraphics *param0, ManagedSprite *param1);
void ov104_022330FC(FrontierScriptContext *ctx, u16 *args);
void ov104_0223310C(FrontierScriptContext *ctx, u16 *args, u32 bankID);
void BattleFrontier_PrintNormalTrainerMessage(FrontierScriptContext *ctx, u16 *args);
void BattleFrontier_PrintTrainerMessage(FrontierScriptContext *ctx, u16 *args, u32 bankID);
void ov104_0223319C(SysTask *param0, void *param1);
void ov104_022331E8(SysTask *param0, void *param1);
void FrontierMenuManager_SetHorizontalAnchor(FrontierMenuManager *menuManager, BOOL anchorRight);
Expand Down
24 changes: 0 additions & 24 deletions include/overlay104/ov104_02234DB4.h

This file was deleted.

Loading