Improving on previous commits (concise declarations, removing unnecessary return; and scoping, more renaming)

This commit is contained in:
Viperio19 2024-11-19 11:15:16 +01:00
parent 37ba7393bf
commit e7e7f44497
19 changed files with 191 additions and 253 deletions

View File

@ -0,0 +1,8 @@
#ifndef POKEPLATINUM_CONSTANTS_FIELD_POISON_H
#define POKEPLATINUM_CONSTANTS_FIELD_POISON_H
#define FLDPSN_NONE 0
#define FLDPSN_POISONED 1
#define FLDPSN_FAINTED 2
#endif // POKEPLATINUM_CONSTANTS_FIELD_POISON_H

View File

@ -13,28 +13,28 @@
int FieldOverworldState_Size(void);
int FieldOverworldSave_Size(void);
void FieldOverworldSave_Init(FieldOverworldSave *param0);
void FieldOverworldState_Init(FieldOverworldState *param0);
Location *FieldOverworldState_GetPlayerLocation(FieldOverworldState *param0);
Location *FieldOverworldState_GetEntranceLocation(FieldOverworldState *param0);
Location *FieldOverworldState_GetPrevLocation(FieldOverworldState *param0);
Location *FieldOverworldState_GetExitLocation(FieldOverworldState *param0);
Location *FieldOverworldState_GetSpecialLocation(FieldOverworldState *param0);
void FieldOverworldState_SetSpecialLocation(FieldOverworldState *param0, Location *param1);
u16 *FieldOverworldState_GetSpecialBGM(FieldOverworldState *param0);
u16 FieldOverworldState_GetWeather(const FieldOverworldState *param0);
void FieldOverworldState_SetWeather(FieldOverworldState *param0, u16 param1);
u16 FieldOverworldState_GetWarpId(const FieldOverworldState *param0);
void FieldOverworldState_SetWarpId(FieldOverworldState *param0, u16 param1);
UnkStruct_020556C4 *sub_0203A76C(FieldOverworldState *param0);
int FieldOverworldState_GetCameraType(const FieldOverworldState *param0);
void FieldOverworldState_SetCameraType(FieldOverworldState *param0, int param1);
PlayerData *FieldOverworldState_GetPlayerData(FieldOverworldState *param0);
u16 *FieldOverworldState_GetSafariBallCount(FieldOverworldState *param0);
u16 *FieldOverworldState_GetSafariStepCount(FieldOverworldState *param0);
u16 *FieldOverworldState_GetPoisonStepCount(FieldOverworldState *param0);
FieldOverworldState *SaveData_GetFieldOverworldState(SaveData *param0);
FieldOverworldSave *SaveData_GetFieldOverworldSave(SaveData *param0);
void FieldOverworldSave_Init(FieldOverworldSave *fieldSave);
void FieldOverworldState_Init(FieldOverworldState *fieldState);
Location *FieldOverworldState_GetPlayerLocation(FieldOverworldState *fieldState);
Location *FieldOverworldState_GetEntranceLocation(FieldOverworldState *fieldState);
Location *FieldOverworldState_GetPrevLocation(FieldOverworldState *fieldState);
Location *FieldOverworldState_GetExitLocation(FieldOverworldState *fieldState);
Location *FieldOverworldState_GetSpecialLocation(FieldOverworldState *fieldState);
void FieldOverworldState_SetSpecialLocation(FieldOverworldState *fieldState, Location *location);
u16 *FieldOverworldState_GetSpecialBGM(FieldOverworldState *fieldState);
u16 FieldOverworldState_GetWeather(const FieldOverworldState *fieldState);
void FieldOverworldState_SetWeather(FieldOverworldState *fieldState, u16 weather);
u16 FieldOverworldState_GetWarpId(const FieldOverworldState *fieldState);
void FieldOverworldState_SetWarpId(FieldOverworldState *fieldState, u16 warpId);
UnkStruct_020556C4 *sub_0203A76C(FieldOverworldState *fieldState);
int FieldOverworldState_GetCameraType(const FieldOverworldState *fieldState);
void FieldOverworldState_SetCameraType(FieldOverworldState *fieldState, int type);
PlayerData *FieldOverworldState_GetPlayerData(FieldOverworldState *fieldState);
u16 *FieldOverworldState_GetSafariBallCount(FieldOverworldState *fieldState);
u16 *FieldOverworldState_GetSafariStepCount(FieldOverworldState *fieldState);
u16 *FieldOverworldState_GetPoisonStepCount(FieldOverworldState *fieldState);
FieldOverworldState *SaveData_GetFieldOverworldState(SaveData *saveData);
FieldOverworldSave *SaveData_GetFieldOverworldSave(SaveData *saveData);
void FieldSystem_SaveObjects(FieldSystem *fieldSystem);
void FieldSystem_LoadObjects(FieldSystem *fieldSystem);

View File

@ -3,7 +3,7 @@
#include "field_task.h"
BOOL sub_02052B2C(FieldTask *param0);
void sub_02052C5C(FieldTask *param0);
BOOL sub_02052B2C(FieldTask *taskMan);
void sub_02052C5C(FieldTask *taskMan);
#endif // POKEPLATINUM_UNK_020528D0_H

View File

@ -9,16 +9,16 @@
#define PARTY_SLOT_NONE 0xFF
BOOL Pokemon_CanBattle(Pokemon *mon);
BOOL sub_020548B0(int param0, SaveData *param1, u16 param2, u8 param3, u16 param4, int param5, int param6);
BOOL sub_02054930(int param0, SaveData *param1, u16 param2, u8 param3, int param4, int param5);
void sub_02054988(Party *param0, int param1, int param2, u16 param3);
BOOL sub_020548B0(int heapID, SaveData *saveData, u16 param2, u8 param3, u16 param4, int param5, int param6);
BOOL sub_02054930(int unused, SaveData *saveData, u16 param2, u8 param3, int param4, int param5);
void sub_02054988(Party *party, int param1, int param2, u16 param3);
int Party_HasMonWithMove(Party *party, u16 moveID);
int Party_AliveMonsCount(const Party *party);
Pokemon *Party_FindFirstEligibleBattler(const Party *party);
Pokemon *Party_FindFirstHatchedMon(const Party *party);
BOOL Party_HasTwoAliveMons(const Party *party);
void Party_GiveChampionRibbons(Party *party);
int Pokemon_DoPoisonDamage(Party *param0, u16 param1);
int Pokemon_DoPoisonDamage(Party *party, u16 mapLabelTextID);
BOOL Pokemon_TrySurvivePoison(Pokemon *mon);
#endif // POKEPLATINUM_UNK_02054884_H

View File

@ -4,11 +4,11 @@
#include "field/field_system_decl.h"
void sub_020553DC(void);
void Sound_SetSpecialBGM(FieldSystem *fieldSystem, u16 param1);
void Sound_SetSpecialBGM(FieldSystem *fieldSystem, u16 sdatID);
u16 Sound_GetSpecialBGM(FieldSystem *fieldSystem);
void Sound_ClearSpecialBGM(FieldSystem *fieldSystem);
u16 sub_02055428(FieldSystem *fieldSystem, int param1);
u16 sub_020554A4(FieldSystem *fieldSystem, int param1);
u16 sub_020554A4(FieldSystem *fieldSystem, int headerID);
BOOL sub_02055554(FieldSystem *fieldSystem, u16 param1, int param2);
u16 sub_0205560C(int param0);
void Sound_TryFadeInBGM(FieldSystem *fieldSystem, int param1);

View File

@ -631,13 +631,13 @@ static int CommPlayer_Direction(u16 unused, u16 keys)
BOOL CommPlayer_CheckNPCCollision(int x, int z)
{
int npcCnt, i;
const ObjectEvent *npcList;
const ObjectEvent *objEventList;
npcCnt = MapHeaderData_GetNumObjectEvents(sCommPlayerManager->fieldSystem);
npcList = MapHeaderData_GetObjectEvents(sCommPlayerManager->fieldSystem);
objEventList = MapHeaderData_GetObjectEvents(sCommPlayerManager->fieldSystem);
for (i = 0; i < npcCnt; i++) {
if ((npcList[i].x == x) && (npcList[i].z == z)) {
if ((objEventList[i].x == x) && (objEventList[i].z == z)) {
return 1;
}
}

View File

@ -49,9 +49,9 @@ int FieldOverworldSave_Size(void)
return sizeof(FieldOverworldSave);
}
void FieldOverworldSave_Init(FieldOverworldSave *fieldState)
void FieldOverworldSave_Init(FieldOverworldSave *fieldSave)
{
MI_CpuClear32(fieldState, sizeof(FieldOverworldSave));
MI_CpuClear32(fieldSave, sizeof(FieldOverworldSave));
}
void FieldOverworldState_Init(FieldOverworldState *fieldState)

View File

@ -3,6 +3,7 @@
#include <nitro.h>
#include <string.h>
#include "constants/field_poison.h"
#include "constants/player_avatar.h"
#include "consts/game_records.h"
#include "consts/sdat.h"
@ -906,12 +907,12 @@ static BOOL Field_UpdatePoison(FieldSystem *fieldSystem)
}
switch (Pokemon_DoPoisonDamage(party, MapHeader_GetMapLabelTextID(fieldSystem->location->mapId))) {
case 0:
case FLDPSN_NONE:
return FALSE;
case 1:
case FLDPSN_POISONED:
Field_DoPoisonEffect(fieldSystem->unk_04->unk_20);
return FALSE;
case 2:
case FLDPSN_FAINTED:
Field_DoPoisonEffect(fieldSystem->unk_04->unk_20);
ScriptManager_Set(fieldSystem, 2003, NULL);
return TRUE;

View File

@ -418,29 +418,26 @@ static BOOL FieldMap_ChangeZone(FieldSystem *fieldSystem)
}
fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData);
{
fieldSystem->location->mapId = v0;
MapHeaderData_Load(fieldSystem, v0);
FieldMapChange_UpdateGameData(fieldSystem, 1);
fieldSystem->location->mapId = v0;
MapHeaderData_Load(fieldSystem, v0);
FieldMapChange_UpdateGameData(fieldSystem, 1);
{
int objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
const ObjectEvent *objEventList = MapHeaderData_GetObjectEvents(fieldSystem);
sub_0206184C(fieldSystem->mapObjMan, mapId, v0, objEventCount, objEventList);
}
{
int npcCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
const ObjectEvent *npcList = MapHeaderData_GetObjectEvents(fieldSystem);
RadarChain_Clear(fieldSystem->chain);
sub_02055554(fieldSystem, sub_02055428(fieldSystem, fieldSystem->location->mapId), 1);
sub_0203A418(fieldSystem);
sub_0206184C(fieldSystem->mapObjMan, mapId, v0, npcCount, npcList);
}
{
RadarChain_Clear(fieldSystem->chain);
sub_02055554(fieldSystem, sub_02055428(fieldSystem, fieldSystem->location->mapId), 1);
sub_0203A418(fieldSystem);
if (fieldSystem->unk_04->unk_0C != NULL) {
ov5_021D5F7C(
fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(fieldState));
}
if (fieldSystem->unk_04->unk_0C != NULL) {
ov5_021D5F7C(
fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(fieldState));
}
{
@ -479,10 +476,10 @@ void ov5_021D12D0(FieldSystem *fieldSystem, u32 param1)
}
{
int npcCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
const ObjectEvent *npcList = MapHeaderData_GetObjectEvents(fieldSystem);
int objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
const ObjectEvent *objEventList = MapHeaderData_GetObjectEvents(fieldSystem);
sub_0206184C(fieldSystem->mapObjMan, mapId, param1, npcCount, npcList);
sub_0206184C(fieldSystem->mapObjMan, mapId, param1, objEventCount, objEventList);
}
{

View File

@ -500,11 +500,11 @@ static void VsSeekerSystem_CollectViableNpcs(VsSeekerSystem *vsSeeker)
int trainerX, trainerZ;
int numVisibleTrainers;
int xMin, xMax, zMin, zMax;
u32 npcCount = MapHeaderData_GetNumObjectEvents(vsSeeker->fieldSystem);
u32 objEventCount = MapHeaderData_GetNumObjectEvents(vsSeeker->fieldSystem);
numVisibleTrainers = 0;
for (int i = 0; i < npcCount; i++) {
for (int i = 0; i < objEventCount; i++) {
vsSeeker->trainers[i] = NULL;
}
@ -523,7 +523,7 @@ static void VsSeekerSystem_CollectViableNpcs(VsSeekerSystem *vsSeeker)
zMin = 0;
}
for (int i = 0; i < npcCount; i++) {
for (int i = 0; i < objEventCount; i++) {
MapObject *mapObj = MapObjMan_LocalMapObjByIndex(vsSeeker->fieldSystem->mapObjMan, i);
if (mapObj == NULL) {
@ -598,9 +598,9 @@ BOOL VsSeeker_UpdateStepCount(FieldSystem *fieldSystem)
static void VsSeeker_ClearRematchMoveCode(FieldSystem *fieldSystem)
{
u32 npcCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
u32 objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
for (int i = 0; i < npcCount; i++) {
for (int i = 0; i < objEventCount; i++) {
MapObject *mapObj = MapObjMan_LocalMapObjByIndex(fieldSystem->mapObjMan, i);
if (mapObj == NULL) {
@ -812,10 +812,10 @@ void VsSeeker_SetMoveCodeForFacingDirection(FieldSystem *fieldSystem, MapObject
static BOOL VsSeeker_WaitForNpcsToPause(FieldSystem *fieldSystem)
{
u32 npcCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
u32 objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
BOOL anyMoving = FALSE;
for (int i = 0; i < npcCount; i++) {
for (int i = 0; i < objEventCount; i++) {
MapObject *mapObj = MapObjMan_LocalMapObjByIndex(fieldSystem->mapObjMan, i);
if (mapObj == NULL) {
@ -836,7 +836,7 @@ static BOOL VsSeeker_WaitForNpcsToPause(FieldSystem *fieldSystem)
static MapObject *VsSeeker_GetSecondDoubleBattleTrainer(FieldSystem *fieldSystem, MapObject *trainerObj, enum VsSeeker2v2TrainerSearchMode mode)
{
u32 secondTrainerEventID, secondTrainerID;
u32 npcCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
u32 objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem);
u16 eventID = MapObject_GetEventID(trainerObj);
u16 trainerID = Script_GetTrainerID(eventID);
@ -844,7 +844,7 @@ static MapObject *VsSeeker_GetSecondDoubleBattleTrainer(FieldSystem *fieldSystem
return NULL;
}
for (u32 i = 0; i < npcCount; i++) {
for (u32 i = 0; i < objEventCount; i++) {
MapObject *mapObj = MapObjMan_LocalMapObjByIndex(fieldSystem->mapObjMan, i);
if (mapObj == NULL) {

View File

@ -937,15 +937,15 @@ void ov23_022534A0(FieldSystem *fieldSystem)
ov23_022431EC(v4, v4->unk_04, ov23_02251270);
{
int npcCount, i;
const ObjectEvent *npcList;
int objEventCount, i;
const ObjectEvent *objEventList;
MapObject *mapObj;
npcCount = MapHeaderData_GetNumObjectEvents(v4->fieldSystem);
npcList = MapHeaderData_GetObjectEvents(v4->fieldSystem);
objEventCount = MapHeaderData_GetNumObjectEvents(v4->fieldSystem);
objEventList = MapHeaderData_GetObjectEvents(v4->fieldSystem);
for (i = 0; i < npcCount; i++) {
if ((npcList[i].x == v1) && (npcList[i].z == v2)) {
for (i = 0; i < objEventCount; i++) {
if (objEventList[i].x == v1 && objEventList[i].z == v2) {
mapObj = MapObjMan_LocalMapObjByIndex(v4->fieldSystem->mapObjMan, i);
MapObject_SetDir(mapObj, v3);
}

View File

@ -3,6 +3,7 @@
#include <nitro.h>
#include <string.h>
#include "constants/heap.h"
#include "constants/species.h"
#include "struct_decls/struct_party_decl.h"
@ -155,7 +156,7 @@ static BOOL sub_0204BA50(FieldSystem *fieldSystem, void *param1)
static void sub_0204BA68(FieldSystem *fieldSystem, void *param1)
{
sub_02054930(32, fieldSystem->saveData, 490, 1, 2, 1);
sub_02054930(HEAP_ID_FIELD_TASK, fieldSystem->saveData, 490, 1, 2, 1);
}
static void sub_0204BA88(UnkStruct_0204B830 *param0, u16 *param1, u16 *param2)

View File

@ -3,6 +3,8 @@
#include <nitro.h>
#include <string.h>
#include "constants/heap.h"
#include "struct_decls/struct_020797DC_decl.h"
#include "struct_decls/struct_party_decl.h"
@ -39,7 +41,7 @@ BOOL ScrCmd_096(ScriptContext *param0)
u16 *v7 = ScriptContext_GetVarPointer(param0);
v2 = Party_GetFromSavedata(fieldSystem->saveData);
*v7 = sub_020548B0(11, fieldSystem->saveData, v4, v5, v6, v0, v1);
*v7 = sub_020548B0(HEAP_ID_FIELDMAP, fieldSystem->saveData, v4, v5, v6, v0, v1);
return 0;
}

View File

@ -45,8 +45,8 @@ typedef struct {
StringTemplate *unk_20;
} UnkStruct_02052AA4;
static void sub_02052914(FieldSystem *fieldSystem, FieldTask *param1);
static BOOL sub_020529C4(FieldTask *param0);
static void sub_02052914(FieldSystem *fieldSystem, FieldTask *taskMan);
static BOOL sub_020529C4(FieldTask *taskMan);
static void sub_02052AA4(UnkStruct_02052AA4 *param0, u16 param1, u8 param2, u8 param3);
static const WindowTemplate Unk_020EC2F0 = {
@ -101,11 +101,9 @@ static void sub_020528D0(BgConfig *param0)
Graphics_LoadPalette(14, 6, 0, 13 * 0x20, 0x20, 11);
}
static void sub_02052914(FieldSystem *fieldSystem, FieldTask *param1)
static void sub_02052914(FieldSystem *fieldSystem, FieldTask *taskMan)
{
UnkStruct_02052AA4 *v0;
v0 = Heap_AllocFromHeap(11, sizeof(UnkStruct_02052AA4));
UnkStruct_02052AA4 *v0 = Heap_AllocFromHeap(11, sizeof(UnkStruct_02052AA4));
if (v0 == NULL) {
GF_ASSERT(FALSE);
@ -132,14 +130,14 @@ static void sub_02052914(FieldSystem *fieldSystem, FieldTask *param1)
}
Window_CopyToVRAM(&v0->unk_0C);
FieldTask_InitCall(param1, sub_020529C4, v0);
FieldTask_InitCall(taskMan, sub_020529C4, v0);
return;
}
static BOOL sub_020529C4(FieldTask *param0)
static BOOL sub_020529C4(FieldTask *taskMan)
{
UnkStruct_02052AA4 *v0 = FieldTask_GetEnv(param0);
UnkStruct_02052AA4 *v0 = FieldTask_GetEnv(taskMan);
switch (v0->unk_00) {
case 0:
@ -199,13 +197,10 @@ static void sub_02052AA4(UnkStruct_02052AA4 *param0, u16 param1, u8 param2, u8 p
return;
}
BOOL sub_02052B2C(FieldTask *param0)
BOOL sub_02052B2C(FieldTask *taskMan)
{
FieldSystem *fieldSystem;
int *state;
fieldSystem = FieldTask_GetFieldSystem(param0);
state = FieldTask_GetState(param0);
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan);
int *state = FieldTask_GetState(taskMan);
switch (*state) {
case 0: {
@ -221,7 +216,7 @@ BOOL sub_02052B2C(FieldTask *param0)
sub_0203A824(warpId, &location);
sub_0203A7F0(warpId, FieldOverworldState_GetExitLocation(fieldState));
FieldTask_ChangeMapByLocation(param0, &location);
FieldTask_ChangeMapByLocation(taskMan, &location);
sub_020705B4(fieldSystem);
}
(*state)++;
@ -239,11 +234,11 @@ BOOL sub_02052B2C(FieldTask *param0)
case 3:
sub_0200AB4C(-16, ((GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD) ^ GX_BLEND_PLANEMASK_BG3), 1);
sub_0200AB4C(-16, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 2);
sub_02052914(fieldSystem, param0);
sub_02052914(fieldSystem, taskMan);
(*state)++;
break;
case 4:
FieldTransition_StartMap(param0);
FieldTransition_StartMap(taskMan);
(*state)++;
break;
case 5:
@ -251,9 +246,9 @@ BOOL sub_02052B2C(FieldTask *param0)
if (sub_0203A7EC()
== FieldOverworldState_GetWarpId(SaveData_GetFieldOverworldState(fieldSystem->saveData))) {
ScriptManager_Start(param0, 2020, NULL, NULL);
ScriptManager_Start(taskMan, 2020, NULL, NULL);
} else {
ScriptManager_Start(param0, 2021, NULL, NULL);
ScriptManager_Start(taskMan, 2021, NULL, NULL);
}
(*state)++;
@ -265,7 +260,7 @@ BOOL sub_02052B2C(FieldTask *param0)
return 0;
}
void sub_02052C5C(FieldTask *param0)
void sub_02052C5C(FieldTask *taskMan)
{
FieldTask_InitCall(param0, sub_02052B2C, NULL);
FieldTask_InitCall(taskMan, sub_02052B2C, NULL);
}

View File

@ -4,6 +4,8 @@
#include <string.h>
#include "constants/battle/condition.h"
#include "constants/field_poison.h"
#include "constants/heap.h"
#include "constants/items.h"
#include "struct_decls/struct_party_decl.h"
@ -29,28 +31,27 @@ BOOL Pokemon_CanBattle(Pokemon *mon)
return !Pokemon_GetValue(mon, MON_DATA_IS_EGG, NULL);
}
BOOL sub_020548B0(int param0, SaveData *param1, u16 param2, u8 param3, u16 param4, int param5, int param6)
BOOL sub_020548B0(int heapID, SaveData *saveData, u16 param2, u8 param3, u16 param4, int param5, int param6)
{
BOOL result;
Pokemon *mon;
u32 v2;
Party *party;
TrainerInfo *trainerInfo;
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(saveData);
trainerInfo = SaveData_GetTrainerInfo(param1);
party = Party_GetFromSavedata(param1);
mon = Pokemon_New(param0);
party = Party_GetFromSavedata(saveData);
mon = Pokemon_New(heapID);
Pokemon_Init(mon);
Pokemon_InitWith(mon, param2, param3, 32, FALSE, 0, OTID_NOT_SET, 0);
Pokemon_SetCatchData(mon, trainerInfo, ITEM_POKE_BALL, param5, param6, param0);
Pokemon_SetCatchData(mon, trainerInfo, ITEM_POKE_BALL, param5, param6, heapID);
v2 = param4;
Pokemon_SetValue(mon, MON_DATA_HELD_ITEM, &v2);
result = Party_AddPokemon(party, mon);
if (result) {
sub_0202F180(param1, mon);
sub_0202F180(saveData, mon);
}
Heap_FreeToHeap(mon);
@ -58,13 +59,13 @@ BOOL sub_020548B0(int param0, SaveData *param1, u16 param2, u8 param3, u16 param
return result;
}
BOOL sub_02054930(int param0, SaveData *param1, u16 param2, u8 param3, int param4, int param5)
BOOL sub_02054930(int unused, SaveData *saveData, u16 param2, u8 param3, int param4, int param5)
{
int v0;
BOOL result;
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(param1);
Party *party = Party_GetFromSavedata(param1);
Pokemon *mon = Pokemon_New(32);
TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(saveData);
Party *party = Party_GetFromSavedata(saveData);
Pokemon *mon = Pokemon_New(HEAP_ID_FIELD_TASK);
Pokemon_Init(mon);
@ -175,44 +176,41 @@ void Party_GiveChampionRibbons(Party *party)
}
}
int Pokemon_DoPoisonDamage(Party *party, u16 param1)
int Pokemon_DoPoisonDamage(Party *party, u16 mapLabelTextID)
{
int numPoisoned = 0;
int numFainted = 0;
int i, partyCount;
int i, partyCount = Party_GetCurrentCount(party);
Pokemon *mon;
partyCount = Party_GetCurrentCount(party);
for (i = 0; i < partyCount; i++) {
mon = Party_GetPokemonBySlotIndex(party, i);
if (Pokemon_CanBattle(mon)) {
if (Pokemon_GetValue(mon, MON_DATA_STATUS_CONDITION, NULL) & (MON_CONDITION_TOXIC | MON_CONDITION_POISON)) {
u32 hp = Pokemon_GetValue(mon, MON_DATA_CURRENT_HP, NULL);
if (Pokemon_CanBattle(mon)
&& (Pokemon_GetValue(mon, MON_DATA_STATUS_CONDITION, NULL) & (MON_CONDITION_TOXIC | MON_CONDITION_POISON))) {
u32 hp = Pokemon_GetValue(mon, MON_DATA_CURRENT_HP, NULL);
if (hp > 1) {
hp--;
}
Pokemon_SetValue(mon, MON_DATA_CURRENT_HP, &hp);
if (hp == 1) {
numFainted++;
Pokemon_UpdateFriendship(mon, 7, param1);
}
numPoisoned++;
if (hp > 1) {
hp--;
}
Pokemon_SetValue(mon, MON_DATA_CURRENT_HP, &hp);
if (hp == 1) {
numFainted++;
Pokemon_UpdateFriendship(mon, 7, mapLabelTextID);
}
numPoisoned++;
}
}
if (numFainted) {
return 2;
return FLDPSN_FAINTED;
} else if (numPoisoned) {
return 1;
return FLDPSN_POISONED;
} else {
return 0;
return FLDPSN_NONE;
}
}

View File

@ -115,39 +115,34 @@ void sub_020553DC()
sub_0200569C();
sub_02004A3C();
sub_02004234(0);
return;
}
void Sound_SetSpecialBGM(FieldSystem *fieldSystem, u16 param1)
void Sound_SetSpecialBGM(FieldSystem *fieldSystem, u16 sdatID)
{
u16 *v0 = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData));
u16 *bgm = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData));
*v0 = param1;
return;
*bgm = sdatID;
}
u16 Sound_GetSpecialBGM(FieldSystem *fieldSystem)
{
u16 *v0 = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData));
return *v0;
u16 *bgm = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData));
return *bgm;
}
void Sound_ClearSpecialBGM(FieldSystem *fieldSystem)
{
u16 *v0 = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData));
u16 *bgm = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData));
*v0 = 0;
return;
*bgm = 0;
}
u16 sub_02055428(FieldSystem *fieldSystem, int param1)
{
PlayerAvatar *playerAvatar;
PlayerAvatar *playerAvatar = fieldSystem->playerAvatar;
int v1;
u16 v2, v3;
playerAvatar = fieldSystem->playerAvatar;
v1 = PlayerAvatar_GetPlayerState(playerAvatar);
if (v1 == 0x2) {
@ -284,21 +279,16 @@ static void sub_020555CC(FieldSystem *fieldSystem, int param1, int *param2, int
*param3 = 0;
break;
}
return;
}
u16 sub_0205560C(int param0)
{
u8 v0;
u16 v1, v2;
u8 v0 = (u8)TrainerData_LoadParam(param0, 1);
u16 i, v1 = 1101;
v0 = (u8)TrainerData_LoadParam(param0, 1);
v1 = 1101;
for (v2 = 0; v2 < 79; v2++) {
if (Unk_020EC3E0[v2][0] == v0) {
v1 = Unk_020EC3E0[v2][1];
for (i = 0; i < 79; i++) {
if (Unk_020EC3E0[i][0] == v0) {
v1 = Unk_020EC3E0[i][1];
break;
}
}
@ -315,8 +305,6 @@ void Sound_TryFadeInBGM(FieldSystem *fieldSystem, int param1)
if (sub_020041FC() != sub_020554A4(fieldSystem, param1)) {
sub_0200564C(0, 40);
}
return;
}
void Sound_PlayMapBGM(FieldSystem *fieldSystem, int param1)
@ -333,18 +321,12 @@ void Sound_PlayMapBGM(FieldSystem *fieldSystem, int param1)
sub_02004224(v0);
sub_02004550(4, v0, 1);
return;
}
void sub_020556A0(FieldSystem *fieldSystem, int param1)
{
u16 v0;
v0 = sub_02055428(fieldSystem, param1);
u16 v0 = sub_02055428(fieldSystem, param1);
sub_02004224(sub_020554A4(fieldSystem, param1));
sub_02004550(4, v0, 1);
return;
}

View File

@ -157,12 +157,12 @@ static u32 sub_02068D68(const UnkStruct_020684D0 *param0);
static u32 sub_02068E94(const UnkStruct_020684D0 *param0);
static u32 sub_020690C4(const UnkStruct_020684D0 *param0);
static u32 sub_02069130(const UnkStruct_020684D0 *param0);
static BOOL sub_02068884(FieldTask *param0);
static BOOL sub_02068F48(FieldTask *param0);
static BOOL sub_02068884(FieldTask *taskMan);
static BOOL sub_02068F48(FieldTask *taskMan);
static void sub_020693F8(UnkStruct_02068870 *param0, UnkFuncPtr_02068870 param1);
static BOOL sub_0206932C(FieldTask *param0);
static BOOL sub_020690F0(FieldTask *param0);
static BOOL sub_020685AC(FieldTask *param0);
static BOOL sub_0206932C(FieldTask *taskMan);
static BOOL sub_020690F0(FieldTask *taskMan);
static BOOL sub_020685AC(FieldTask *taskMan);
static void sub_020692E4(UnkStruct_02068870 *param0, u32 param1);
static const UnkStruct_020EF79C Unk_020EF79C[] = {
@ -473,17 +473,14 @@ static BOOL sub_02068870(UnkStruct_02068870 *param0)
return 0;
}
static BOOL sub_02068884(FieldTask *param0)
static BOOL sub_02068884(FieldTask *taskMan)
{
FieldSystem *fieldSystem;
int *v1;
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan);
int *state = FieldTask_GetState(taskMan);
fieldSystem = FieldTask_GetFieldSystem(param0);
v1 = FieldTask_GetState(param0);
switch (*v1) {
switch (*state) {
case 0:
(*v1)++;
(*state)++;
break;
case 1:
if (PlayerAvatar_GetPlayerState(fieldSystem->playerAvatar) == 0x1) {
@ -505,10 +502,10 @@ static BOOL sub_02068884(FieldTask *param0)
RadarChain_Clear(fieldSystem->chain);
}
(*v1)++;
(*state)++;
break;
case 2:
(*v1)++;
(*state)++;
break;
case 3:
MapObjectMan_UnpauseAllMovement(fieldSystem->mapObjMan);
@ -940,13 +937,10 @@ static BOOL sub_02068EFC(UnkStruct_02068870 *param0)
return 0;
}
static BOOL sub_02068F48(FieldTask *param0)
static BOOL sub_02068F48(FieldTask *taskMan)
{
FieldSystem *fieldSystem;
UnkStruct_02068EFC *v1;
fieldSystem = FieldTask_GetFieldSystem(param0);
v1 = FieldTask_GetEnv(param0);
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan);
UnkStruct_02068EFC *v1 = FieldTask_GetEnv(taskMan);
switch (v1->unk_16) {
case 0:
@ -1039,12 +1033,12 @@ static u32 sub_020690C4(const UnkStruct_020684D0 *param0)
return -1;
}
static BOOL sub_020690F0(FieldTask *param0)
static BOOL sub_020690F0(FieldTask *taskMan)
{
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0);
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan);
void *v1 = ov6_02247100(fieldSystem, 11);
FieldTask_InitJump(param0, ov6_02247120, v1);
FieldTask_InitJump(taskMan, ov6_02247120, v1);
return 0;
}
@ -1202,11 +1196,8 @@ static void sub_020692E4(UnkStruct_02068870 *param0, u32 param1)
static BOOL sub_0206932C(FieldTask *taskMan)
{
FieldSystem *fieldSystem;
UnkStruct_02068870 *v1;
fieldSystem = FieldTask_GetFieldSystem(taskMan);
v1 = FieldTask_GetEnv(taskMan);
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan);
UnkStruct_02068870 *v1 = FieldTask_GetEnv(taskMan);
switch (v1->unk_2A) {
case 0:

View File

@ -32,15 +32,15 @@ static BOOL sub_0206AFE0(VarsFlags *param0, u16 param1, u16 param2)
if ((param1 < VARS_START) || (param1 > SPECIAL_VARS_START)) {
GF_ASSERT(FALSE);
return 0;
return FALSE;
}
if (v0 == NULL) {
return 0;
return FALSE;
}
*v0 = param2;
return 1;
return TRUE;
}
static u16 sub_0206B010(VarsFlags *param0, u16 param1)
@ -162,11 +162,7 @@ void sub_0206B144(VarsFlags *param0, int param1)
BOOL sub_0206B16C(VarsFlags *param0, int param1)
{
if (sub_0206B010(param0, (19 + (((0 + VARS_START) + 32) + 16)) + param1) == sub_0206B128(param1)) {
return 1;
} else {
return 0;
}
return sub_0206B010(param0, (19 + (((0 + VARS_START) + 32) + 16)) + param1) == sub_0206B128(param1);
}
static int sub_0206B194(int param0)
@ -194,11 +190,7 @@ void sub_0206B1D8(VarsFlags *param0, int param1)
BOOL VarFlags_HiddenLocationsUnlocked(VarsFlags *varFlags, int hiddenLocation)
{
if (sub_0206B010(varFlags, (6 + (((0 + VARS_START) + 32) + 16)) + hiddenLocation) == sub_0206B194(hiddenLocation)) {
return 1;
} else {
return 0;
}
return sub_0206B010(varFlags, (6 + (((0 + VARS_START) + 32) + 16)) + hiddenLocation) == sub_0206B194(hiddenLocation);
}
BOOL sub_0206B218(VarsFlags *param0)
@ -213,9 +205,7 @@ u16 sub_0206B228(VarsFlags *param0)
BOOL sub_0206B238(VarsFlags *param0)
{
u16 v0;
v0 = sub_0206B010(param0, (10 + (((0 + VARS_START) + 32) + 16)));
u16 v0 = sub_0206B010(param0, (10 + (((0 + VARS_START) + 32) + 16)));
if (v0 < 10000) {
v0++;
@ -238,30 +228,24 @@ BOOL sub_0206B270(VarsFlags *param0, u16 param1)
void sub_0206B280(VarsFlags *param0, u32 param1)
{
u16 v0, v1;
v1 = (param1 >> 16) & 0xffff;
v0 = param1 & 0xffff;
u16 v1 = (param1 >> 16) & 0xffff;
u16 v0 = param1 & 0xffff;
sub_0206AFE0(param0, (12 + (((0 + VARS_START) + 32) + 16)), v0);
sub_0206AFE0(param0, (12 + (((0 + VARS_START) + 32) + 16)), v1);
}
u32 sub_0206B2A4(VarsFlags *param0)
{
u16 v0, v1;
v0 = sub_0206B010(param0, (12 + (((0 + VARS_START) + 32) + 16)));
v1 = sub_0206B010(param0, (13 + (((0 + VARS_START) + 32) + 16)));
u16 v0 = sub_0206B010(param0, (12 + (((0 + VARS_START) + 32) + 16)));
u16 v1 = sub_0206B010(param0, (13 + (((0 + VARS_START) + 32) + 16)));
return (v1 << 16) | v0;
}
void sub_0206B2C8(VarsFlags *param0)
{
u16 v0, v1;
v0 = LCRNG_Next();
v1 = LCRNG_Next();
u16 v0 = LCRNG_Next();
u16 v1 = LCRNG_Next();
sub_0206B280(param0, (v1 << 16) | v0);
}
@ -269,10 +253,7 @@ void sub_0206B2C8(VarsFlags *param0)
void sub_0206B2E4(SaveData *param0, u16 param1)
{
VarsFlags *v0 = SaveData_GetVarsFlags(param0);
u32 v1;
v1 = RecordMixedRNG_GetRand(SaveData_GetRecordMixedRNG(param0));
v1 = v1 * 1103515245L + 12345;
u32 v1 = RecordMixedRNG_GetRand(SaveData_GetRecordMixedRNG(param0)) * 1103515245L + 12345;
sub_0206B280(v0, v1);
}
@ -290,18 +271,13 @@ BOOL sub_0206B324(VarsFlags *param0, u16 param1)
void sub_0206B334(SaveData *param0)
{
VarsFlags *v0 = SaveData_GetVarsFlags(param0);
u32 v1;
v1 = (LCRNG_Next() % 98) + 2;
u32 v1 = (LCRNG_Next() % 98) + 2;
sub_0206B324(v0, v1);
}
u16 sub_0206B354(VarsFlags *param0)
{
u16 v0;
v0 = sub_0206B010(param0, (14 + (((0 + VARS_START) + 32) + 16)));
return v0;
return sub_0206B010(param0, (14 + (((0 + VARS_START) + 32) + 16)));
}
BOOL sub_0206B364(VarsFlags *param0, u16 param1)
@ -311,10 +287,7 @@ BOOL sub_0206B364(VarsFlags *param0, u16 param1)
u16 sub_0206B374(VarsFlags *param0)
{
u16 v0;
v0 = sub_0206B010(param0, (25 + (((0 + VARS_START) + 32) + 16)));
return v0;
return sub_0206B010(param0, (25 + (((0 + VARS_START) + 32) + 16)));
}
BOOL sub_0206B384(VarsFlags *param0, u16 param1)
@ -324,10 +297,7 @@ BOOL sub_0206B384(VarsFlags *param0, u16 param1)
u16 sub_0206B394(VarsFlags *param0)
{
u16 v0;
v0 = sub_0206B010(param0, (16 + (((0 + VARS_START) + 32) + 16)));
return v0;
return sub_0206B010(param0, (16 + (((0 + VARS_START) + 32) + 16)));
}
BOOL sub_0206B3A4(VarsFlags *param0, u16 param1)
@ -337,9 +307,7 @@ BOOL sub_0206B3A4(VarsFlags *param0, u16 param1)
BOOL sub_0206B3B4(VarsFlags *param0)
{
u16 v0;
v0 = sub_0206B010(param0, (18 + (((0 + VARS_START) + 32) + 16)));
u16 v0 = sub_0206B010(param0, (18 + (((0 + VARS_START) + 32) + 16)));
if (v0 < 10000) {
v0++;
@ -425,9 +393,7 @@ static const u8 Unk_020EFA6C[] = {
static u8 sub_0206B4A4(VarsFlags *param0)
{
int v0;
u16 v1, v2, v3;
v1 = 0;
u16 v1 = 0, v2, v3;
for (v0 = 0; v0 < VILLA_FURNITURE_MAX; v0++) {
if (SystemFlag_HandleOwnsVillaFurniture(param0, HANDLE_FLAG_CHECK, v0) == TRUE) {
@ -455,7 +421,6 @@ static u8 sub_0206B4A4(VarsFlags *param0)
void sub_0206B514(SaveData *param0)
{
u32 unused;
VarsFlags *v1 = SaveData_GetVarsFlags(param0);
FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(param0);
Location *location = FieldOverworldState_GetPlayerLocation(fieldState);

View File

@ -87,7 +87,7 @@ void sub_0206B70C(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, int para
x = Player_GetXPos(fieldSystem->playerAvatar);
z = Player_GetZPos(fieldSystem->playerAvatar);
int v11 = 10 - 1;
int v11 = 9;
Location *location = FieldOverworldState_GetPlayerLocation(fieldState);
v6 = location->mapId;
@ -153,7 +153,7 @@ void sub_0206B70C(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, int para
static void sub_0206B878(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, const char *param2)
{
FSFile v0;
int v1, v2;
int v1, i;
int v3;
UnkStruct_0206B878 *v4;
UnkUnion_0206B878 *v5;
@ -174,8 +174,8 @@ static void sub_0206B878(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, c
param1->unk_13A = v3;
for (v2 = 0; v2 < v3; v2++) {
v5 = &(param1->unk_5C[v2]);
for (i = 0; i < v3; i++) {
v5 = &(param1->unk_5C[i]);
v1 = FS_ReadFile(&v0, v4, sizeof(UnkStruct_0206B878));
switch (v4->unk_00) {
@ -203,6 +203,4 @@ static void sub_0206B878(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, c
(void)FS_CloseFile(&v0);
Heap_FreeToHeap(v4);
return;
}