mirror of
https://github.com/pret/pokeheartgold.git
synced 2025-02-20 05:10:57 +00:00
Merge branch 'master' into scrcmd-inlines
This commit is contained in:
commit
e79e453b74
@ -5187,7 +5187,7 @@ _02248350:
|
||||
bx r3
|
||||
thumb_func_end ov02_022482BC
|
||||
|
||||
; BOOL ov02_GetRandomActiveRoamerInCurrMap(FieldSystem *fsys, ROAMER **out);
|
||||
; BOOL ov02_GetRandomActiveRoamerInCurrMap(FieldSystem *fsys, Roamer **out);
|
||||
thumb_func_start ov02_GetRandomActiveRoamerInCurrMap
|
||||
ov02_GetRandomActiveRoamerInCurrMap: ; 0x02248360
|
||||
push {r3, r4, r5, r6, r7, lr}
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
#include "roamer.h"
|
||||
|
||||
void RoamerLocationUpdateRand(ROAMER_SAVE *roamer, u8 roamer_idx);
|
||||
void Save_RandomizeRoamersLocation(ROAMER_SAVE *roamer);
|
||||
void Save_UpdateRoamersLocation(ROAMER_SAVE *roamer);
|
||||
void RoamerLocationUpdateRand(RoamerSaveData *roamer, u8 roamer_idx);
|
||||
void Save_RandomizeRoamersLocation(RoamerSaveData *roamer);
|
||||
void Save_UpdateRoamersLocation(RoamerSaveData *roamer);
|
||||
u32 GetRoamMapByLocationIdx(u8 idx);
|
||||
void UpdatePlayerLocationHistoryIfAnyRoamersActive(ROAMER_SAVE *roamers, u32 location);
|
||||
void UpdatePlayerLocationHistoryIfAnyRoamersActive(RoamerSaveData *roamers, u32 location);
|
||||
void Save_CreateRoamerByID(SAVEDATA *saveData, u8 idx);
|
||||
u8 SpeciesToRoamerIdx(u16 species);
|
||||
|
||||
|
@ -15,7 +15,7 @@ enum RoamerDataParam {
|
||||
ROAMER_DATA_ACTIVE = 8,
|
||||
};
|
||||
|
||||
typedef struct ROAMER {
|
||||
typedef struct Roamer {
|
||||
u32 met_location;
|
||||
u32 ivs;
|
||||
u32 personality;
|
||||
@ -25,38 +25,38 @@ typedef struct ROAMER {
|
||||
u8 status;
|
||||
u8 active;
|
||||
u8 dummy;
|
||||
} ROAMER;
|
||||
} Roamer;
|
||||
|
||||
typedef struct ROAMER_SAVE {
|
||||
typedef struct RoamerSaveData {
|
||||
u32 rand[2];
|
||||
u32 playerLocationHistory[2];
|
||||
ROAMER data[ROAMER_MAX];
|
||||
Roamer data[ROAMER_MAX];
|
||||
u8 unk_60[ROAMER_MAX];
|
||||
u8 unk_64;
|
||||
u8 repelSteps;
|
||||
u8 unk_66;
|
||||
u8 flutePlayed;
|
||||
} ROAMER_SAVE;
|
||||
} RoamerSaveData;
|
||||
|
||||
u32 Save_Roamers_sizeof(void);
|
||||
void Save_Roamers_Init(ROAMER_SAVE *roamer);
|
||||
void Roamers_SetRand(ROAMER_SAVE *roamer, u32 param);
|
||||
u32 Roamers_GetRand(ROAMER_SAVE *roamer, u32 which);
|
||||
ROAMER_SAVE *Save_Roamers_Get(SAVEDATA *saveData);
|
||||
void Save_Roamers_Init(RoamerSaveData *roamer);
|
||||
void Roamers_SetRand(RoamerSaveData *roamer, u32 param);
|
||||
u32 Roamers_GetRand(RoamerSaveData *roamer, u32 which);
|
||||
RoamerSaveData *Save_Roamers_Get(SAVEDATA *saveData);
|
||||
void RoamerSave_SetOutbreakActive(SAVEDATA *saveData);
|
||||
u8 RoamerSave_OutbreakActive(ROAMER_SAVE *roamerSave);
|
||||
void PlayerLocationHistoryPush(ROAMER_SAVE *roamerSave, u32 mapsec);
|
||||
u32 PlayerLocationHistoryGetBack(ROAMER_SAVE *roamerSave);
|
||||
u8 Roamer_GetLocation(ROAMER_SAVE *roamerSave, int a1);
|
||||
void Roamer_SetLocation(ROAMER_SAVE *roamerSave, int a1, u8 a2);
|
||||
u8 GetRoamerIsActiveByIndex(ROAMER_SAVE *roamerSave, int a1);
|
||||
void RoamerMon_Init(ROAMER ** roamer_p);
|
||||
ROAMER *Roamers_GetRoamMonStats(ROAMER_SAVE *roamerSave, int a1);
|
||||
int GetRoamerData(ROAMER *roamer, int a1);
|
||||
void SetRoamerData(ROAMER *roamer, int a1, int val);
|
||||
u8 *RoamerSave_GetRepelAddr(ROAMER_SAVE *roamerSave);
|
||||
BOOL RoamerSave_RepelNotInUse(ROAMER_SAVE *roamerSave);
|
||||
void RoamerSave_SetFlute(ROAMER_SAVE *roamerSave, u8 a1);
|
||||
u8 RoamerSave_GetFlute(ROAMER_SAVE *roamerSave);
|
||||
u8 RoamerSave_OutbreakActive(RoamerSaveData *roamerSave);
|
||||
void PlayerLocationHistoryPush(RoamerSaveData *roamerSave, u32 mapsec);
|
||||
u32 PlayerLocationHistoryGetBack(RoamerSaveData *roamerSave);
|
||||
u8 Roamer_GetLocation(RoamerSaveData *roamerSave, int a1);
|
||||
void Roamer_SetLocation(RoamerSaveData *roamerSave, int a1, u8 a2);
|
||||
u8 GetRoamerIsActiveByIndex(RoamerSaveData *roamerSave, int a1);
|
||||
void RoamerMon_Init(Roamer ** roamer_p);
|
||||
Roamer *Roamers_GetRoamMonStats(RoamerSaveData *roamerSave, int a1);
|
||||
int GetRoamerData(Roamer *roamer, int a1);
|
||||
void SetRoamerData(Roamer *roamer, int a1, int val);
|
||||
u8 *RoamerSave_GetRepelAddr(RoamerSaveData *roamerSave);
|
||||
BOOL RoamerSave_RepelNotInUse(RoamerSaveData *roamerSave);
|
||||
void RoamerSave_SetFlute(RoamerSaveData *roamerSave, u8 a1);
|
||||
u8 RoamerSave_GetFlute(RoamerSaveData *roamerSave);
|
||||
|
||||
#endif //POKEHEARTGOLD_ROAMER_H
|
||||
|
@ -12,10 +12,10 @@ struct RoamerAdjacency {
|
||||
u16 neighbors[MAX_ROAM_NEIGHBOR];
|
||||
};
|
||||
|
||||
static BOOL AreAnyRoamersActive(ROAMER_SAVE *roamer);
|
||||
static void RoamerLocationSetRandom(ROAMER_SAVE *roamer, u8 roamer_idx, u32 last_loc);
|
||||
static void RoamerLocationUpdateEx(ROAMER_SAVE *roamer, u8 roamer_idx, u32 last_loc);
|
||||
static void ApplyRoamerLocation(ROAMER_SAVE *roamer, u8 roamer_idx, u8 new_loc, u32 new_mapno);
|
||||
static BOOL AreAnyRoamersActive(RoamerSaveData *roamer);
|
||||
static void RoamerLocationSetRandom(RoamerSaveData *roamer, u8 roamer_idx, u32 last_loc);
|
||||
static void RoamerLocationUpdateEx(RoamerSaveData *roamer, u8 roamer_idx, u32 last_loc);
|
||||
static void ApplyRoamerLocation(RoamerSaveData *roamer, u8 roamer_idx, u8 new_loc, u32 new_mapno);
|
||||
|
||||
static const u32 sRoamerLocations[ROAMER_LOC_COUNT] = {
|
||||
// Johto
|
||||
@ -111,12 +111,12 @@ static const struct RoamerAdjacency sRoamerAdjacencyTable[ROAMER_LOC_COUNT] = {
|
||||
{3, {ROAMER_LOC_R22, ROAMER_LOC_R26, ROAMER_LOC_R09, -1,-1,-1}},
|
||||
};
|
||||
|
||||
void RoamerLocationUpdateRand(ROAMER_SAVE *roamer, u8 roamer_idx) {
|
||||
void RoamerLocationUpdateRand(RoamerSaveData *roamer, u8 roamer_idx) {
|
||||
u32 last_loc = PlayerLocationHistoryGetBack(roamer);
|
||||
RoamerLocationSetRandom(roamer, roamer_idx, last_loc);
|
||||
}
|
||||
|
||||
void Save_RandomizeRoamersLocation(ROAMER_SAVE *roamer) {
|
||||
void Save_RandomizeRoamersLocation(RoamerSaveData *roamer) {
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < ROAMER_MAX; i++) {
|
||||
@ -126,7 +126,7 @@ void Save_RandomizeRoamersLocation(ROAMER_SAVE *roamer) {
|
||||
}
|
||||
}
|
||||
|
||||
void Save_UpdateRoamersLocation(ROAMER_SAVE *roamer) {
|
||||
void Save_UpdateRoamersLocation(RoamerSaveData *roamer) {
|
||||
u8 i;
|
||||
u16 rnd;
|
||||
u32 last_loc;
|
||||
@ -149,7 +149,7 @@ u32 GetRoamMapByLocationIdx(u8 idx) {
|
||||
return sRoamerLocations[idx];
|
||||
}
|
||||
|
||||
static BOOL AreAnyRoamersActive(ROAMER_SAVE *roamers) {
|
||||
static BOOL AreAnyRoamersActive(RoamerSaveData *roamers) {
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < ROAMER_MAX; i++) {
|
||||
@ -161,7 +161,7 @@ static BOOL AreAnyRoamersActive(ROAMER_SAVE *roamers) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void UpdatePlayerLocationHistoryIfAnyRoamersActive(ROAMER_SAVE *roamers, u32 location) {
|
||||
void UpdatePlayerLocationHistoryIfAnyRoamersActive(RoamerSaveData *roamers, u32 location) {
|
||||
if (AreAnyRoamersActive(roamers)) {
|
||||
PlayerLocationHistoryPush(roamers, location);
|
||||
}
|
||||
@ -169,8 +169,8 @@ void UpdatePlayerLocationHistoryIfAnyRoamersActive(ROAMER_SAVE *roamers, u32 loc
|
||||
|
||||
void Save_CreateRoamerByID(SAVEDATA *saveData, u8 idx) {
|
||||
PLAYERPROFILE *profile;
|
||||
ROAMER_SAVE *roamerSave = Save_Roamers_Get(saveData);
|
||||
ROAMER *roamerStats = Roamers_GetRoamMonStats(roamerSave, idx);
|
||||
RoamerSaveData *roamerSave = Save_Roamers_Get(saveData);
|
||||
Roamer *roamerStats = Roamers_GetRoamMonStats(roamerSave, idx);
|
||||
Pokemon *mon;
|
||||
u16 species;
|
||||
u8 level;
|
||||
@ -224,12 +224,12 @@ u8 SpeciesToRoamerIdx(u16 species) {
|
||||
case SPECIES_LATIAS:
|
||||
return ROAMER_LATIAS;
|
||||
default:
|
||||
GF_ASSERT(0);
|
||||
GF_ASSERT(FALSE);
|
||||
return ROAMER_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
static void RoamerLocationSetRandom(ROAMER_SAVE *roamer, u8 roamer_idx, u32 last_loc) {
|
||||
static void RoamerLocationSetRandom(RoamerSaveData *roamer, u8 roamer_idx, u32 last_loc) {
|
||||
u32 roamer_cur_loc, roamer_test_loc;
|
||||
u8 loc_min, loc_num;
|
||||
u8 loc_cur_rand;
|
||||
@ -249,7 +249,7 @@ static void RoamerLocationSetRandom(ROAMER_SAVE *roamer, u8 roamer_idx, u32 last
|
||||
ApplyRoamerLocation(roamer, roamer_idx, loc_cur_rand, roamer_test_loc);
|
||||
}
|
||||
|
||||
static void RoamerLocationUpdateEx(ROAMER_SAVE *roamer, u8 roamer_idx, u32 last_loc) {
|
||||
static void RoamerLocationUpdateEx(RoamerSaveData *roamer, u8 roamer_idx, u32 last_loc) {
|
||||
u8 roamer_last_loc;
|
||||
u8 roamer_next_loc;
|
||||
u32 roamer_next_mapno;
|
||||
@ -279,8 +279,8 @@ static void RoamerLocationUpdateEx(ROAMER_SAVE *roamer, u8 roamer_idx, u32 last_
|
||||
}
|
||||
}
|
||||
|
||||
static void ApplyRoamerLocation(ROAMER_SAVE *roamer, u8 roamer_idx, u8 new_loc, u32 new_mapno) {
|
||||
ROAMER *roamerStats = Roamers_GetRoamMonStats(roamer, roamer_idx);
|
||||
static void ApplyRoamerLocation(RoamerSaveData *roamer, u8 roamer_idx, u8 new_loc, u32 new_mapno) {
|
||||
Roamer *roamerStats = Roamers_GetRoamMonStats(roamer, roamer_idx);
|
||||
Roamer_SetLocation(roamer, roamer_idx, new_loc);
|
||||
SetRoamerData(roamerStats, ROAMER_DATA_MET_LOCATION, new_mapno);
|
||||
}
|
||||
|
44
src/roamer.c
44
src/roamer.c
@ -3,11 +3,11 @@
|
||||
#include "constants/roamer.h"
|
||||
|
||||
u32 Save_Roamers_sizeof(void) {
|
||||
return sizeof(ROAMER_SAVE);
|
||||
return sizeof(RoamerSaveData);
|
||||
}
|
||||
|
||||
void Save_Roamers_Init(ROAMER_SAVE *roamer) {
|
||||
memset(roamer, 0, sizeof(ROAMER_SAVE));
|
||||
void Save_Roamers_Init(RoamerSaveData *roamer) {
|
||||
memset(roamer, 0, sizeof(RoamerSaveData));
|
||||
roamer->rand[0] = MTRandom();
|
||||
roamer->rand[1] = MTRandom();
|
||||
roamer->unk_64 = 0;
|
||||
@ -16,12 +16,12 @@ void Save_Roamers_Init(ROAMER_SAVE *roamer) {
|
||||
roamer->flutePlayed = 0;
|
||||
}
|
||||
|
||||
void Roamers_SetRand(ROAMER_SAVE *roamer, u32 param) {
|
||||
void Roamers_SetRand(RoamerSaveData *roamer, u32 param) {
|
||||
roamer->rand[0] = param;
|
||||
roamer->rand[1] = param;
|
||||
}
|
||||
|
||||
u32 Roamers_GetRand(ROAMER_SAVE *roamer, u32 which) {
|
||||
u32 Roamers_GetRand(RoamerSaveData *roamer, u32 which) {
|
||||
switch (which) {
|
||||
case 1:
|
||||
return roamer->rand[0];
|
||||
@ -33,55 +33,55 @@ u32 Roamers_GetRand(ROAMER_SAVE *roamer, u32 which) {
|
||||
}
|
||||
}
|
||||
|
||||
ROAMER_SAVE *Save_Roamers_Get(SAVEDATA *saveData) {
|
||||
RoamerSaveData *Save_Roamers_Get(SAVEDATA *saveData) {
|
||||
return SaveArray_Get(saveData, SAVE_ROAMER);
|
||||
}
|
||||
|
||||
void RoamerSave_SetOutbreakActive(SAVEDATA *saveData) {
|
||||
ROAMER_SAVE *roamer = Save_Roamers_Get(saveData);
|
||||
RoamerSaveData *roamer = Save_Roamers_Get(saveData);
|
||||
roamer->unk_64 = 1;
|
||||
}
|
||||
|
||||
u8 RoamerSave_OutbreakActive(ROAMER_SAVE *roamerSave) {
|
||||
u8 RoamerSave_OutbreakActive(RoamerSaveData *roamerSave) {
|
||||
return roamerSave->unk_64;
|
||||
}
|
||||
|
||||
void PlayerLocationHistoryPush(ROAMER_SAVE *roamerSave, u32 mapsec) {
|
||||
void PlayerLocationHistoryPush(RoamerSaveData *roamerSave, u32 mapsec) {
|
||||
if (roamerSave->playerLocationHistory[0] != mapsec) {
|
||||
roamerSave->playerLocationHistory[1] = roamerSave->playerLocationHistory[0];
|
||||
roamerSave->playerLocationHistory[0] = mapsec;
|
||||
}
|
||||
}
|
||||
|
||||
u32 PlayerLocationHistoryGetBack(ROAMER_SAVE *roamerSave) {
|
||||
u32 PlayerLocationHistoryGetBack(RoamerSaveData *roamerSave) {
|
||||
return roamerSave->playerLocationHistory[1];
|
||||
}
|
||||
|
||||
u8 Roamer_GetLocation(ROAMER_SAVE *roamerSave, int a1) {
|
||||
u8 Roamer_GetLocation(RoamerSaveData *roamerSave, int a1) {
|
||||
GF_ASSERT(a1 < ROAMER_MAX);
|
||||
return roamerSave->unk_60[a1];
|
||||
}
|
||||
|
||||
void Roamer_SetLocation(ROAMER_SAVE *roamerSave, int a1, u8 a2) {
|
||||
void Roamer_SetLocation(RoamerSaveData *roamerSave, int a1, u8 a2) {
|
||||
GF_ASSERT(a1 < ROAMER_MAX);
|
||||
roamerSave->unk_60[a1] = a2;
|
||||
}
|
||||
|
||||
u8 GetRoamerIsActiveByIndex(ROAMER_SAVE *roamerSave, int a1) {
|
||||
u8 GetRoamerIsActiveByIndex(RoamerSaveData *roamerSave, int a1) {
|
||||
GF_ASSERT(a1 < ROAMER_MAX);
|
||||
return roamerSave->data[a1].active;
|
||||
}
|
||||
|
||||
void RoamerMon_Init(ROAMER ** roamer_p) {
|
||||
memset(*roamer_p, 0, sizeof(ROAMER));
|
||||
void RoamerMon_Init(Roamer ** roamer_p) {
|
||||
memset(*roamer_p, 0, sizeof(Roamer));
|
||||
}
|
||||
|
||||
ROAMER *Roamers_GetRoamMonStats(ROAMER_SAVE *roamerSave, int a1) {
|
||||
Roamer *Roamers_GetRoamMonStats(RoamerSaveData *roamerSave, int a1) {
|
||||
GF_ASSERT(a1 < ROAMER_MAX);
|
||||
return &roamerSave->data[a1];
|
||||
}
|
||||
|
||||
int GetRoamerData(ROAMER *roamer, int a1) {
|
||||
int GetRoamerData(Roamer *roamer, int a1) {
|
||||
switch (a1) {
|
||||
case ROAMER_DATA_MET_LOCATION:
|
||||
return roamer->met_location;
|
||||
@ -105,7 +105,7 @@ int GetRoamerData(ROAMER *roamer, int a1) {
|
||||
}
|
||||
}
|
||||
|
||||
void SetRoamerData(ROAMER *roamer, int a1, int val) {
|
||||
void SetRoamerData(Roamer *roamer, int a1, int val) {
|
||||
switch (a1) {
|
||||
case ROAMER_DATA_MET_LOCATION:
|
||||
roamer->met_location = val;
|
||||
@ -137,19 +137,19 @@ void SetRoamerData(ROAMER *roamer, int a1, int val) {
|
||||
}
|
||||
}
|
||||
|
||||
u8 *RoamerSave_GetRepelAddr(ROAMER_SAVE *roamerSave) {
|
||||
u8 *RoamerSave_GetRepelAddr(RoamerSaveData *roamerSave) {
|
||||
return &roamerSave->repelSteps;
|
||||
}
|
||||
|
||||
BOOL RoamerSave_RepelNotInUse(ROAMER_SAVE *roamerSave) {
|
||||
BOOL RoamerSave_RepelNotInUse(RoamerSaveData *roamerSave) {
|
||||
return roamerSave->repelSteps == 0;
|
||||
}
|
||||
|
||||
void RoamerSave_SetFlute(ROAMER_SAVE *roamerSave, u8 a1) {
|
||||
void RoamerSave_SetFlute(RoamerSaveData *roamerSave, u8 a1) {
|
||||
GF_ASSERT(a1 <= 2);
|
||||
roamerSave->flutePlayed = a1;
|
||||
}
|
||||
|
||||
u8 RoamerSave_GetFlute(ROAMER_SAVE *roamerSave) {
|
||||
u8 RoamerSave_GetFlute(RoamerSaveData *roamerSave) {
|
||||
return roamerSave->flutePlayed;
|
||||
}
|
||||
|
@ -2361,7 +2361,7 @@ BOOL ScrCmd_UpdateAvatarState(ScriptContext *ctx) {
|
||||
}
|
||||
|
||||
BOOL ScrCmd_211(ScriptContext *ctx) {
|
||||
ROAMER_SAVE *roamerSave = Save_Roamers_Get(ctx->fsys->savedata);
|
||||
RoamerSaveData *roamerSave = Save_Roamers_Get(ctx->fsys->savedata);
|
||||
u16 *r6 = ScriptGetVarPointer(ctx);
|
||||
u16 *r4 = ScriptGetVarPointer(ctx);
|
||||
sub_02097F9C(Roamers_GetRand(roamerSave, 2), r6, r4);
|
||||
|
Loading…
x
Reference in New Issue
Block a user