Finish frontier util

This commit is contained in:
DizzyEggg
2018-11-01 21:31:10 +01:00
parent 37d742cbd8
commit 0bb51037d7
64 changed files with 1169 additions and 675 deletions

View File

@@ -2238,7 +2238,7 @@ static void sub_81A1370(void)
r9 = -1;
for (i = 1; i < 4; i++)
{
if (ReadUnalignedWord(gSaveBlock2Ptr->apprentices[i].playerId) == ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId)
if (GetTrainerId(gSaveBlock2Ptr->apprentices[i].playerId) == GetTrainerId(gSaveBlock2Ptr->playerTrainerId)
&& gSaveBlock2Ptr->apprentices[i].number < r10)
{
r10 = gSaveBlock2Ptr->apprentices[i].number;

View File

@@ -57,12 +57,12 @@ struct UnkStruct_860DD10
};
extern void sub_81B8558(void);
extern u16 sub_81A5060(u8 monId, u8 moveSlotId);
extern u8 sub_81A50F0(u8, u8);
extern u8 sub_81A50B0(u8);
extern u16 GetFrontierBrainMonMove(u8 monId, u8 moveSlotId);
extern u8 GetFrontierBrainMonEvs(u8, u8);
extern u8 GetFrontierBrainMonNature(u8);
extern void sub_81A4C30(void);
extern u8 sub_81A3610(void);
extern u16 sub_81A4FF0(u8);
extern u16 GetFrontierBrainMonSpecies(u8);
extern void ReducePlayerPartyToThree(void);
extern u8 gUnknown_0203CEF8[];
@@ -2737,7 +2737,7 @@ static void InitDomeTrainers(void)
}
for (i = 0; i < 3; i++)
gSaveBlock2Ptr->frontier.domeMonIds[j][i] = sub_81A4FF0(i);
gSaveBlock2Ptr->frontier.domeMonIds[j][i] = GetFrontierBrainMonSpecies(i);
}
Free(statSums);
@@ -2856,7 +2856,7 @@ static void CreateDomeTrainerMons(u16 tournamentTrainerId)
s32 i, bits;
ZeroEnemyPartyMons();
bits = GetTrainerMonCountInBits(tournamentTrainerId);
bits = GetDomeTrainerMonCountInBits(tournamentTrainerId);
otId = Random32();
if (Random() % 10 > 5)
{
@@ -2884,7 +2884,7 @@ static void CreateDomeTrainerMons(u16 tournamentTrainerId)
}
}
s32 GetTrainerMonCountInBits(u16 tournamentTrainerId)
s32 GetDomeTrainerMonCountInBits(u16 tournamentTrainerId)
{
s32 bits;
if (Random() & 1)
@@ -2917,7 +2917,7 @@ static s32 sub_818FCBC(u16 tournamentTrainerId, bool8 arg1)
{
if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN)
{
array[i] += GetTypeEffectivenessPoints(sub_81A5060(i, moveId),
array[i] += GetTypeEffectivenessPoints(GetFrontierBrainMonMove(i, moveId),
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 0);
}
else
@@ -2945,7 +2945,7 @@ static s32 sub_818FDB8(u16 tournamentTrainerId, bool8 arg1)
{
if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentTrainerId].trainerId == TRAINER_FRONTIER_BRAIN)
{
array[i] += GetTypeEffectivenessPoints(sub_81A5060(i, moveId),
array[i] += GetTypeEffectivenessPoints(GetFrontierBrainMonMove(i, moveId),
GetMonData(&gPlayerParty[playerMonId], MON_DATA_SPECIES, NULL), 1);
}
else
@@ -4875,7 +4875,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId)
for (k = 0; k < DOME_TOURNAMENT_TRAINERS_COUNT; k++)
{
if (trainerId == TRAINER_FRONTIER_BRAIN)
allocatedArray[k] += sMovePointsForDomeTrainers[sub_81A5060(i, j)][k];
allocatedArray[k] += sMovePointsForDomeTrainers[GetFrontierBrainMonMove(i, j)][k];
else if (trainerId == TRAINER_PLAYER)
allocatedArray[k] += sMovePointsForDomeTrainers[gSaveBlock2Ptr->frontier.field_EFC[i].moves[j]][k];
else
@@ -4916,7 +4916,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId)
for (j = 0; j < 6; j++)
{
if (trainerId == TRAINER_FRONTIER_BRAIN)
allocatedArray[j] = sub_81A50F0(i, j);
allocatedArray[j] = GetFrontierBrainMonEvs(i, j);
else
allocatedArray[j] = gSaveBlock2Ptr->frontier.field_EFC[i].evs[j];
}
@@ -4924,7 +4924,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTournamentId)
for (j = 0; j < 5; j++)
{
if (trainerId == TRAINER_FRONTIER_BRAIN)
nature = sub_81A50B0(i);
nature = GetFrontierBrainMonNature(i);
else
nature = gSaveBlock2Ptr->frontier.field_EFC[i].nature;
@@ -5564,7 +5564,7 @@ static u16 GetWinningMove(s32 winnerTournamentId, s32 loserTournamentId, u8 roun
{
moveScores[i * 4 + j] = 0;
if (gSaveBlock2Ptr->frontier.domeTrainers[winnerTournamentId].trainerId == TRAINER_FRONTIER_BRAIN)
moveIds[i * 4 + j] = sub_81A5060(i, j);
moveIds[i * 4 + j] = GetFrontierBrainMonMove(i, j);
else
moveIds[i * 4 + j] = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[winnerTournamentId][i]].moves[j];

View File

@@ -19,6 +19,8 @@ extern const u16 gBattleFrontierHeldItems[];
extern u16 gUnknown_03006298[];
extern void sub_81A4C30(void);
// This file's functions.
static void sub_81B99D4(void);
static void sub_81B9A28(void);

View File

@@ -9,7 +9,6 @@
#include "main.h"
#include "international_string_util.h"
#include "battle.h"
#include "battle_frontier_1.h"
#include "frontier_util.h"
#include "recorded_battle.h"
#include "easy_chat.h"
@@ -30,14 +29,9 @@
extern u16 gUnknown_03006298[];
extern void sub_81A3ACC(void);
extern void CreateFrontierBrainPokemon(void);
extern void sub_81A6CD0(void);
extern void SetFrontierBrainTrainerGfxId(void);
extern u8 GetFrontierBrainTrainerPicIndex(void);
extern u8 GetFrontierBrainTrainerClass(void);
extern u8 IsFrontierBrainFemale(void);
extern void CopyFrontierBrainTrainerName(u8 *dst);
extern void sub_81A4C30(void);
extern u8 sub_81A6CA8(u8, u8);
extern void SetMonMoveAvoidReturn(struct Pokemon *mon, u16 move, u8 moveSlot);
extern const u8 *const *const gUnknown_085DD690[];
@@ -525,7 +519,7 @@ void SetBattleFacilityTrainerGfxId(u16 trainerId, u8 tempVarId)
}
else if (trainerId == TRAINER_FRONTIER_BRAIN)
{
SetFrontierBrainTrainerGfxId();
SetFrontierBrainEventObjGfx_2();
return;
}
else if (trainerId < TRAINER_RECORD_MIXING_FRIEND)
@@ -1509,7 +1503,7 @@ static void sub_8163EE4(void)
}
playerRecord->lvlMode = lvlMode;
playerRecord->facilityClass = class;
CopyUnalignedWord(playerRecord->trainerId, gSaveBlock2Ptr->playerTrainerId);
CopyTrainerId(playerRecord->trainerId, gSaveBlock2Ptr->playerTrainerId);
StringCopy7(playerRecord->name, gSaveBlock2Ptr->playerName);
playerRecord->winStreak = GetCurrentBattleTowerWinStreak(lvlMode, battleMode);
@@ -2165,7 +2159,7 @@ static void FillEReaderTrainerWithPlayerData(void)
+ gSaveBlock2Ptr->playerTrainerId[2] + gSaveBlock2Ptr->playerTrainerId[3]) % ARRAY_COUNT(gTowerMaleFacilityClasses)];
}
CopyUnalignedWord(ereaderTrainer->trainerId, gSaveBlock2Ptr->playerTrainerId);
CopyTrainerId(ereaderTrainer->trainerId, gSaveBlock2Ptr->playerTrainerId);
StringCopy7(ereaderTrainer->name, gSaveBlock2Ptr->playerName);
ereaderTrainer->winStreak = 1;

View File

@@ -1,6 +1,5 @@
#include "global.h"
#include "battle_setup.h"
#include "battle_frontier_1.h"
#include "bike.h"
#include "coord_event_weather.h"
#include "daycare.h"
@@ -31,6 +30,8 @@
#include "constants/map_types.h"
#include "constants/songs.h"
extern bool32 sub_8196034(void);
static EWRAM_DATA u8 sWildEncounterImmunitySteps = 0;
static EWRAM_DATA u16 sPreviousPlayerMetatileBehavior = 0;

View File

@@ -14,6 +14,8 @@
#include "fldeff_80F9BCC.h"
#include "field_poison.h"
extern bool8 InBattlePike(void);
static bool32 sub_80F9568(struct Pokemon *pokemon)
{
u16 species = GetMonData(pokemon, MON_DATA_SPECIES2);

View File

@@ -14,6 +14,8 @@
#include "secret_base.h"
#include "tv.h"
extern void sub_81AA078(u16*, u8);
struct ConnectionFlags
{
u8 south:1;

File diff suppressed because it is too large Load Diff

View File

@@ -48,6 +48,8 @@
#include "window.h"
#include "apprentice.h"
extern bool8 InBattlePike(void);
void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)());
void CB2_Bag(void);
bool8 setup_bag_menu(void);

View File

@@ -69,30 +69,30 @@ static const struct ContestWinner sContestWinnerPicDummy =
};
// code
void WriteUnalignedWord(u32 var, u8 *dataPtr)
void SetTrainerId(u32 trainerId, u8 *dst)
{
dataPtr[0] = var;
dataPtr[1] = var >> 8;
dataPtr[2] = var >> 16;
dataPtr[3] = var >> 24;
dst[0] = trainerId;
dst[1] = trainerId >> 8;
dst[2] = trainerId >> 16;
dst[3] = trainerId >> 24;
}
u32 ReadUnalignedWord(u8* dataPtr)
u32 GetTrainerId(u8 *trainerId)
{
return (dataPtr[3] << 24) | (dataPtr[2] << 16) | (dataPtr[1] << 8) | (dataPtr[0]);
return (trainerId[3] << 24) | (trainerId[2] << 16) | (trainerId[1] << 8) | (trainerId[0]);
}
void CopyUnalignedWord(u8 *copyTo, u8 *copyFrom)
void CopyTrainerId(u8 *dst, u8 *src)
{
s32 i;
for (i = 0; i < 4; i++)
copyTo[i] = copyFrom[i];
dst[i] = src[i];
}
static void InitPlayerTrainerId(void)
{
u32 trainerId = (Random() << 0x10) | GetGeneratedTrainerIdLower();
WriteUnalignedWord(trainerId, gSaveBlock2Ptr->playerTrainerId);
SetTrainerId(trainerId, gSaveBlock2Ptr->playerTrainerId);
}
// L=A isnt set here for some reason.

View File

@@ -45,6 +45,8 @@
#include "constants/songs.h"
#include "constants/species.h"
extern bool8 sub_81A6BF4(void);
static EWRAM_DATA struct UnkSummaryStruct
{
/*0x00*/ union {

View File

@@ -1557,12 +1557,12 @@ static void sub_80E8110(struct Apprentice *dst, struct Apprentice *src)
id = ((i + gSaveBlock2Ptr->playerApprentice.field_B2_1) % 3) + 1;
if (src[id].playerName[0] != EOS)
{
if (ReadUnalignedWord(src[id].playerId) != ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId))
if (GetTrainerId(src[id].playerId) != GetTrainerId(gSaveBlock2Ptr->playerTrainerId))
{
r8++;
var_2C = id;
}
if (ReadUnalignedWord(src[id].playerId) == ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId))
if (GetTrainerId(src[id].playerId) == GetTrainerId(gSaveBlock2Ptr->playerTrainerId))
{
var_24++;
var_28 = id;
@@ -1602,7 +1602,7 @@ void GetPlayerHallRecords(struct PlayerHallRecords *dst)
{
for (j = 0; j < 2; j++)
{
CopyUnalignedWord(dst->onePlayer[i][j].id, gSaveBlock2Ptr->playerTrainerId);
CopyTrainerId(dst->onePlayer[i][j].id, gSaveBlock2Ptr->playerTrainerId);
dst->onePlayer[i][j].language = GAME_LANGUAGE;
StringCopy(dst->onePlayer[i][j].name, gSaveBlock2Ptr->playerName);
}
@@ -1611,8 +1611,8 @@ void GetPlayerHallRecords(struct PlayerHallRecords *dst)
for (j = 0; j < 2; j++)
{
dst->twoPlayers[j].language = GAME_LANGUAGE;
CopyUnalignedWord(dst->twoPlayers[j].id1, gSaveBlock2Ptr->playerTrainerId);
CopyUnalignedWord(dst->twoPlayers[j].id2, gSaveBlock2Ptr->frontier.field_EF1[j]);
CopyTrainerId(dst->twoPlayers[j].id1, gSaveBlock2Ptr->playerTrainerId);
CopyTrainerId(dst->twoPlayers[j].id2, gSaveBlock2Ptr->frontier.field_EF1[j]);
StringCopy(dst->twoPlayers[j].name1, gSaveBlock2Ptr->playerName);
StringCopy(dst->twoPlayers[j].name2, gSaveBlock2Ptr->frontier.field_EE1[j]);
}
@@ -1639,7 +1639,7 @@ static bool32 sub_80E841C(struct Apprentice *arg0, struct Apprentice *arg1)
for (i = 0; i < 4; i++)
{
if (ReadUnalignedWord(arg0->playerId) == ReadUnalignedWord(arg1[i].playerId)
if (GetTrainerId(arg0->playerId) == GetTrainerId(arg1[i].playerId)
&& arg0->number == arg1[i].number)
{
return TRUE;
@@ -1821,13 +1821,13 @@ _080E8666:\n\
ldr r6, [sp, 0x1C]\n\
adds r0, r6, r0\n\
str r3, [sp, 0x4C]\n\
bl ReadUnalignedWord\n\
bl GetTrainerId\n\
adds r4, r0, 0\n\
ldr r1, [sp, 0x50]\n\
ldr r0, [r1]\n\
add r0, r9\n\
adds r0, r7\n\
bl ReadUnalignedWord\n\
bl GetTrainerId\n\
ldr r3, [sp, 0x4C]\n\
cmp r4, r0\n\
bne _080E86A8\n\
@@ -1983,7 +1983,7 @@ _080E878E:\n\
adds r5, r0, r6\n\
adds r0, r5, 0\n\
str r3, [sp, 0x4C]\n\
bl ReadUnalignedWord\n\
bl GetTrainerId\n\
adds r4, r0, 0\n\
movs r6, 0x90\n\
lsls r6, 1\n\
@@ -1991,18 +1991,18 @@ _080E878E:\n\
mov r1, r9\n\
ldr r0, [r1]\n\
adds r0, r6\n\
bl ReadUnalignedWord\n\
bl GetTrainerId\n\
ldr r3, [sp, 0x4C]\n\
cmp r4, r0\n\
bne _080E8808\n\
adds r0, r5, 0x4\n\
bl ReadUnalignedWord\n\
bl GetTrainerId\n\
adds r4, r0, 0\n\
mov r2, r9\n\
ldr r0, [r2]\n\
adds r0, r6\n\
adds r0, 0x4\n\
bl ReadUnalignedWord\n\
bl GetTrainerId\n\
ldr r3, [sp, 0x4C]\n\
cmp r4, r0\n\
bne _080E8808\n\

View File

@@ -19,14 +19,11 @@
#define BATTLER_RECORD_SIZE 664
#define ILLEGAL_BATTLE_TYPES ((BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_FIRST_BATTLE \
| BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_ROAMER | BATTLE_TYPE_EREADER_TRAINER \
| BATTLE_TYPE_KYOGRE_GROUDON | BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI \
| BATTLE_TYPE_RECORDED | BATTLE_TYPE_TRAINER_HILL | BATTLE_TYPE_SECRET_BASE \
| BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_ROAMER | BATTLE_TYPE_EREADER_TRAINER \
| BATTLE_TYPE_KYOGRE_GROUDON | BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_REGI \
| BATTLE_TYPE_RECORDED | BATTLE_TYPE_TRAINER_HILL | BATTLE_TYPE_SECRET_BASE \
| BATTLE_TYPE_GROUDON | BATTLE_TYPE_KYOGRE | BATTLE_TYPE_RAYQUAZA))
extern u8 gUnknown_03001278;
extern u8 gUnknown_03001279;
struct PlayerInfo
{
u32 trainerId;
@@ -101,6 +98,9 @@ EWRAM_DATA static u8 sApprenticeId = 0;
EWRAM_DATA static u16 sEasyChatSpeech[6] = {0};
EWRAM_DATA static u8 sBattleOutcome = 0;
IWRAM_DATA static u8 sRecordMixFriendLanguage;
IWRAM_DATA static u8 sApprenticeLanguage;
// this file's functions
static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2);
static bool32 CopyRecordedBattleFromSave(struct RecordedBattleSave *dst);
@@ -586,8 +586,8 @@ static void SetVariablesForRecordedBattle(struct RecordedBattleSave *src)
sRecordMixFriendClass = src->recordMixFriendClass;
sApprenticeId = src->apprenticeId;
gUnknown_03001278 = src->recordMixFriendLanguage;
gUnknown_03001279 = src->apprenticeLanguage;
sRecordMixFriendLanguage = src->recordMixFriendLanguage;
sApprenticeLanguage = src->apprenticeLanguage;
for (i = 0; i < 6; i++)
{
@@ -852,7 +852,7 @@ void sub_8186468(u8 *dst)
dst[i] = sRecordMixFriendName[i];
dst[7] = EOS;
ConvertInternationalString(dst, gUnknown_03001278);
ConvertInternationalString(dst, sRecordMixFriendLanguage);
}
u8 GetRecordedBattleRecordMixFriendClass(void)
@@ -867,12 +867,12 @@ u8 GetRecordedBattleApprenticeId(void)
u8 GetRecordedBattleRecordMixFriendLanguage(void)
{
return gUnknown_03001278;
return sRecordMixFriendLanguage;
}
u8 GetRecordedBattleApprenticeLanguage(void)
{
return gUnknown_03001279;
return sApprenticeLanguage;
}
void RecordedBattle_SaveBattleOutcome(void)

View File

@@ -49,6 +49,11 @@
#include "tv.h"
#include "window.h"
extern u16 sub_81A89A0(u8);
extern void sub_81A8AF8(void);
extern void sub_81A895C(void);
extern void sub_81A8934(u8);
typedef u16 (*SpecialFunc)(void);
typedef void (*NativeFunc)(void);

View File

@@ -35,6 +35,8 @@
#include "field_player_avatar.h"
#include "battle_pyramid_bag.h"
extern bool8 InBattlePike(void);
// Menu actions
enum
{

View File

@@ -95,7 +95,7 @@ u16 TryGetWallpaperWithWaldaPhrase(void)
{
u16 backgroundClr, foregroundClr;
u8 patternId, iconId;
u16 trainerId = ReadUnalignedWord(gSaveBlock2Ptr->playerTrainerId);
u16 trainerId = GetTrainerId(gSaveBlock2Ptr->playerTrainerId);
gSpecialVar_Result = TryCalculateWallpaper(&backgroundClr, &foregroundClr, &iconId, &patternId, trainerId, GetWaldaPhrasePtr());
if (gSpecialVar_Result)