Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documenting main.c, map_header_data.c and map_header.c #342

Merged
merged 4 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
68 changes: 34 additions & 34 deletions include/map_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,40 @@ typedef struct {
u16 isFlyAllowed : 1;
} MapHeader;

u32 MapHeader_IDBoundsCheck(u32 param0);
const u16 sub_0203A038(u32 param0);
const u16 sub_0203A04C(u32 param0);
const u16 MapHeader_GetMapMatrixID(u32 param0);
u32 MapHeader_GetMsgArchiveID(u32 param0);
u32 MapHeader_GetScriptsArchiveID(u32 param0);
u32 MapHeader_GetInitScriptsArchiveID(u32 param0);
u16 MapHeader_GetDayMusicID(u32 param0);
u16 MapHeader_GetNightMusicID(u32 param0);
BOOL MapHeader_HasWildEncounters(u32 param0);
u32 MapHeader_GetWildEncountersArchiveID(u32 param0);
u32 MapHeader_GetEventsArchiveID(u32 param0);
u32 MapHeader_GetMapLabelTextID(u32 param0);
u8 MapHeader_GetMapLabelWindowID(u32 param0);
u32 MapHeader_GetWeatherType(u32 param0);
u32 MapHeader_GetCameraType(u32 param0);
u32 MapHeader_GetBattleBG(u32 param0);
BOOL MapHeader_IsEscapeRopeAllowed(u32 param0);
BOOL MapHeader_IsFlyAllowed(u32 param0);
BOOL MapHeader_IsBikeAllowed(u32 param0);
u32 MapHeader_IDBoundsCheck(u32 headerID);
const u16 sub_0203A038(u32 headerID);
const u16 sub_0203A04C(u32 headerID);
const u16 MapHeader_GetMapMatrixID(u32 headerID);
u32 MapHeader_GetMsgArchiveID(u32 headerID);
u32 MapHeader_GetScriptsArchiveID(u32 headerID);
u32 MapHeader_GetInitScriptsArchiveID(u32 headerID);
u16 MapHeader_GetDayMusicID(u32 headerID);
u16 MapHeader_GetNightMusicID(u32 headerID);
BOOL MapHeader_HasWildEncounters(u32 headerID);
u32 MapHeader_GetWildEncountersArchiveID(u32 headerID);
u32 MapHeader_GetEventsArchiveID(u32 headerID);
u32 MapHeader_GetMapLabelTextID(u32 headerID);
u8 MapHeader_GetMapLabelWindowID(u32 headerID);
u32 MapHeader_GetWeatherType(u32 headerID);
u32 MapHeader_GetCameraType(u32 headerID);
u32 MapHeader_GetBattleBG(u32 headerID);
BOOL MapHeader_IsEscapeRopeAllowed(u32 headerID);
BOOL MapHeader_IsFlyAllowed(u32 headerID);
BOOL MapHeader_IsBikeAllowed(u32 headerID);
u32 MapHeader_GetMapType(u32 headerID);
BOOL MapHeader_IsTeleportAllowed(u32 param0);
BOOL MapHeader_IsOnMainMatrix(u32 param0);
BOOL MapHeader_IsPokemonCenter(u32 param0);
BOOL MapHeader_IsCave(u32 param0);
BOOL MapHeader_IsBuilding(u32 param0);
BOOL MapHeader_IsOutdoors(u32 param0);
BOOL sub_0203A2C8(u32 param0);
BOOL MapHeader_IsUnionRoom(const u32 param0);
BOOL MapHeader_HasFeebasTiles(const u32 param0);
BOOL MapHeader_IsTrophyGarden(const u32 param0);
BOOL MapHeader_IsAmitySquare(const u32 param0);
BOOL MapHeader_IsAzureFluteAllowed(const u32 param0);
BOOL MapHeader_IsPokemonCenter2F(const u32 param0);
u32 MapHeader_GetMapEvolutionMethod(u32 param0);
BOOL MapHeader_IsTeleportAllowed(u32 headerID);
BOOL MapHeader_IsOnMainMatrix(u32 headerID);
BOOL MapHeader_IsPokemonCenter(u32 headerID);
BOOL MapHeader_IsCave(u32 headerID);
BOOL MapHeader_IsBuilding(u32 headerID);
BOOL MapHeader_IsOutdoors(u32 headerID);
BOOL sub_0203A2C8(u32 headerID);
BOOL MapHeader_IsUnionRoom(const u32 headerID);
BOOL MapHeader_HasFeebasTiles(const u32 headerID);
BOOL MapHeader_IsTrophyGarden(const u32 headerID);
BOOL MapHeader_IsAmitySquare(const u32 headerID);
BOOL MapHeader_IsAzureFluteAllowed(const u32 headerID);
BOOL MapHeader_IsPokemonCenter2F(const u32 headerID);
u32 MapHeader_GetMapEvolutionMethod(u32 headerID);

#endif // POKEPLATINUM_UNK_0203A024_H
18 changes: 7 additions & 11 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void RunApplication(void);
static void WaitFrame(void);
static void TrySystemReset(enum OSResetParameter resetParam);
static void SoftReset(enum OSResetParameter resetParam);
static void HeapCanaryFailed(int param0, int param1);
static void HeapCanaryFailed(int resetParam, int param1);
static void CheckHeapCanary(void);

static Application sApplication;
Expand Down Expand Up @@ -92,7 +92,7 @@ void NitroMain(void)
sub_02039A64(3, 0);
}

if (SaveData_BackupExists(sApplication.args.saveData) == 0) {
if (SaveData_BackupExists(sApplication.args.saveData) == FALSE) {
sub_0209A74C(0);
} else {
switch (OS_GetResetParameter()) {
Expand Down Expand Up @@ -224,10 +224,8 @@ static void WaitFrame(void)

static void TrySystemReset(enum OSResetParameter resetParam)
{
if (sub_02038AB8()) {
if (CARD_TryWaitBackupAsync() == TRUE) {
OS_ResetSystem(resetParam);
}
if (sub_02038AB8() && CARD_TryWaitBackupAsync() == TRUE) {
OS_ResetSystem(resetParam);
}

WaitFrame();
Expand Down Expand Up @@ -271,7 +269,7 @@ static void HeapCanaryFailed(int resetParam, int param1)

if (param1 == 3) {
sub_02039834(0, 3, 0);
} else if (0 == resetParam) {
} else if (resetParam == 0) {
if (sub_020389B8() == TRUE) {
sub_02039834(0, 6, 0);
} else {
Expand All @@ -295,10 +293,8 @@ static void HeapCanaryFailed(int resetParam, int param1)
HandleConsoleFold();
ReadKeypadAndTouchpad();

if (elapsed >= 30) {
if (gCoreSys.pressedKeys & PAD_BUTTON_A) {
break;
}
if (elapsed >= 30 && gCoreSys.pressedKeys & PAD_BUTTON_A) {
break;
}

WaitFrame();
Expand Down
160 changes: 81 additions & 79 deletions src/map_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include <nitro.h>
#include <string.h>

#include "consts/map.h"
#include "consts/pokemon.h"

#include "data/map_headers.h"
#include "global/pm_version.h"

u32 MapHeader_IDBoundsCheck(u32 headerID)
{
Expand Down Expand Up @@ -34,10 +38,8 @@ const u16 MapHeader_GetMapMatrixID(u32 headerID)
headerID = MapHeader_IDBoundsCheck(headerID);
mapMatrixID = sMapHeaders[headerID].mapMatrixID;

if (mapMatrixID == 22) {
if (gGameVersion == 11) {
mapMatrixID = 23;
}
if (mapMatrixID == 22 && gGameVersion == PEARL) {
mapMatrixID = 23;
}

return mapMatrixID;
Expand Down Expand Up @@ -147,7 +149,7 @@ u32 MapHeader_GetMapType(u32 headerID)

BOOL MapHeader_IsTeleportAllowed(u32 headerID)
{
if (MapHeader_IsFlyAllowed(headerID) == 0) {
if (MapHeader_IsFlyAllowed(headerID) == FALSE) {
return FALSE;
}

Expand Down Expand Up @@ -190,27 +192,27 @@ BOOL sub_0203A2C8(u32 headerID)

BOOL MapHeader_IsUnionRoom(const u32 headerID)
{
return headerID == 466;
return headerID == MAP_HEADER_UNION_ROOM;
}

BOOL MapHeader_HasFeebasTiles(const u32 headerID)
{
return headerID == 219;
return headerID == MAP_HEADER_MT_CORONET_B1F;
}

BOOL MapHeader_IsTrophyGarden(const u32 headerID)
{
return headerID == 287;
return headerID == MAP_HEADER_TROPHY_GARDEN;
}

BOOL MapHeader_IsAmitySquare(const u32 headerID)
{
return headerID == 253;
return headerID == MAP_HEADER_AMITY_SQUARE;
}

BOOL MapHeader_IsAzureFluteAllowed(const u32 headerID)
{
if ((headerID == 220) || (headerID == 584) || (headerID == 585)) {
if (headerID == MAP_HEADER_SPEAR_PILLAR || headerID == MAP_HEADER_SPEAR_PILLAR_DIALGA || headerID == MAP_HEADER_SPEAR_PILLAR_PALKIA) {
return TRUE;
}

Expand All @@ -219,88 +221,88 @@ BOOL MapHeader_IsAzureFluteAllowed(const u32 headerID)

BOOL MapHeader_IsPokemonCenter2F(const u32 headerID)
{
static const u16 v0[] = {
0x1A5,
0x1AD,
0x1B4,
0x1BC,
0x1C5,
0x1CC,
0x7,
0x25,
0x31,
0x1EF,
0x46,
0x66,
0x7C,
0x87,
0x98,
0xA9,
0xAE,
0xBE
static const u16 pokecenters2F[] = {
MAP_HEADER_SANDGEM_TOWN_POKECENTER_2F,
MAP_HEADER_FLOAROMA_TOWN_POKECENTER_2F,
MAP_HEADER_SOLACEON_TOWN_POKECENTER_2F,
MAP_HEADER_CELESTIC_TOWN_POKECENTER_2F,
MAP_HEADER_SURVIVAL_AREA_POKECENTER_2F,
MAP_HEADER_RESORT_AREA_POKECENTER_2F,
MAP_HEADER_JUBILIFE_CITY_POKECENTER_2F,
MAP_HEADER_CANALAVE_CITY_POKECENTER_2F,
MAP_HEADER_OREBURGH_CITY_POKECENTER_2F,
MAP_HEADER_POKEMON_LEAGUE_NORTH_POKECENTER_2F,
MAP_HEADER_ETERNA_CITY_POKECENTER_2F,
MAP_HEADER_HEARTHOME_CITY_POKECENTER_2F,
MAP_HEADER_PASTORIA_CITY_POKECENTER_2F,
MAP_HEADER_VEILSTONE_CITY_POKECENTER_2F,
MAP_HEADER_SUNYSHORE_CITY_POKECENTER_2F,
MAP_HEADER_SNOWPOINT_CITY_POKECENTER_2F,
MAP_HEADER_POKEMON_LEAGUE_SOUTH_POKECENTER_2F,
MAP_HEADER_FIGHT_AREA_POKECENTER_2F
};
int i;

for (i = 0; i < NELEMS(v0); i++) {
if (headerID == v0[i]) {
return 1;
for (i = 0; i < NELEMS(pokecenters2F); i++) {
if (headerID == pokecenters2F[i]) {
return TRUE;
}
}

return 0;
return FALSE;
}

u32 MapHeader_GetMapEvolutionMethod(u32 headerID)
lhearachel marked this conversation as resolved.
Show resolved Hide resolved
{
static const u16 v0[] = {
0x181,
0x1A,
0xCB,
0x19,
0xCF,
0x18,
0xD0,
0x18,
0xD1,
0x18,
0xD2,
0x18,
0xD3,
0x18,
0xD4,
0x18,
0xD5,
0x18,
0xD6,
0x18,
0xD7,
0x18,
0xD8,
0x18,
0xD9,
0x18,
0xDA,
0x18,
0xDB,
0x18,
0xDC,
0x18,
0xDD,
0x18,
0x1FE,
0x18,
0x1FF,
0x18,
0x248,
0x18,
0x249,
0x18
static const u16 mapEvolutionMethods[] = {
MAP_HEADER_ROUTE_217,
EVO_ICY_STONE,
MAP_HEADER_ETERNA_FOREST,
EVO_MOSSY_STONE,
MAP_HEADER_MT_CORONET_1F_SOUTH,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_2F,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_3F,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_OUTSIDE_NORTH,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_OUTSIDE_SOUTH,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_4F_ROOMS_1_AND_2,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_4F_ROOM_3,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_5F,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_6F,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_1F_TUNNEL_ROOM,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_1F_NORTH_ROOM_2,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_1F_NORTH_ROOM_1,
EVO_ELECTRIC_FIELD,
MAP_HEADER_MT_CORONET_B1F,
EVO_ELECTRIC_FIELD,
MAP_HEADER_SPEAR_PILLAR,
EVO_ELECTRIC_FIELD,
MAP_HEADER_SPEAR_PILLAR_DISTORTED,
EVO_ELECTRIC_FIELD,
MAP_HEADER_HALL_OF_ORIGIN,
EVO_ELECTRIC_FIELD,
MAP_HEADER_UNKNOWN_511,
EVO_ELECTRIC_FIELD,
MAP_HEADER_SPEAR_PILLAR_DIALGA,
EVO_ELECTRIC_FIELD,
MAP_HEADER_SPEAR_PILLAR_PALKIA,
EVO_ELECTRIC_FIELD
};
int i;

for (i = 0; i < NELEMS(v0); i += 2) {
if (v0[i] == headerID) {
return v0[i + 1];
for (i = 0; i < NELEMS(mapEvolutionMethods); i += 2) {
if (mapEvolutionMethods[i] == headerID) {
return mapEvolutionMethods[i + 1];
}
}

Expand Down
Loading
Loading