diff --git a/data/data_8115F5C_2_1.s b/data/data_8115F5C_2_1.s index 9c49edd39..d943e0c5c 100644 --- a/data/data_8115F5C_2_1.s +++ b/data/data_8115F5C_2_1.s @@ -188,19 +188,4 @@ gUnknown_8117770: @ 8117770 .4byte GroundMap_FileText .byte 0x7f, 0x05, 0x00, 0x00 .4byte GroundMap_Action_Text -.string "pksdir0\0" -.align 2,0 -.global gUnknown_8117784 -gUnknown_8117784: @ 8117784 -.byte 0x0d, 0x00, 0x01, 0x00, 0x80, 0x03, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0xbc, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - -.global gGroundWeatherSelect -gGroundWeatherSelect: @ 811779C -.string "GroundWeather Select %3d %3d\0" -.align 2,0 - -.global gUnknown_81177BC -gUnknown_81177BC: @ 81177BC -.byte 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x00, 0x00 diff --git a/include/ground_map.h b/include/ground_map.h index 2f9df06a1..2190f08a0 100644 --- a/include/ground_map.h +++ b/include/ground_map.h @@ -18,5 +18,6 @@ void GroundMap_ExecuteStation(s32 _map, s32 _group, s32 _sector, bool32 _setScri bool8 GroundMapNotifyAll(s16); bool8 sub_80A4D48(s16 index); void GroundMap_Action(void); +void sub_80A5E70(void); #endif // GUARD_GROUND_MAP_H diff --git a/include/ground_map_1.h b/include/ground_map_1.h deleted file mode 100644 index c725b3a82..000000000 --- a/include/ground_map_1.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GUARD_GROUND_MAP_1_H -#define GUARD_GROUND_MAP_1_H - -// size: 0x24 -#include "structs/str_position.h" - -typedef struct unkStruct_3001B74 -{ - s16 unk0; - u8 unk2; - s32 unk4; - s32 unk8; - PixelPos unkC; - u32 unk14; - u32 unk18; - u32 unk1C; - u32 unk20; -} unkStruct_3001B74; - -void GroundWeather_Select(s16); -void nullsub_121(void); -void nullsub_122(void); -void nullsub_123(void); - -void sub_80A5E70(void); -void sub_80A5E8C(u8); -void sub_80A5EBC(void); -void sub_80A5EDC(u8); -void sub_80A60D8(void); - -#endif // GUARD_GROUND_MAP_1_H diff --git a/include/ground_weather.h b/include/ground_weather.h new file mode 100644 index 000000000..81eeb3a58 --- /dev/null +++ b/include/ground_weather.h @@ -0,0 +1,14 @@ +#ifndef GUARD_GROUND_WEATHER_H +#define GUARD_GROUND_WEATHER_H + +void sub_80A5E8C(bool8 param_1); +void sub_80A5EBC(void); +void sub_80A5EDC(bool8 param_1); +void nullsub_121(void); +void nullsub_122(void); +void GroundWeather_Select(s16 param_1); +void nullsub_123(void); +void sub_80A60D8(void); +void sub_80A62D0(void); + +#endif /* GUARD_GROUND_WEATHER_H */ diff --git a/ld_script.ld b/ld_script.ld index c3eb14ea0..8413b66df 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -346,7 +346,7 @@ SECTIONS { src/ground_place.o(.text); src/ground_bg.o(.text); src/ground_map.o(.text); - src/ground_map_1.o(.text); + src/ground_weather.o(.text); src/ground_sprite.o(.text); src/ground_sprite_data.o(.text); src/ground_sprite_monster.o(.text); @@ -735,6 +735,7 @@ SECTIONS { src/ground_place.o(.rodata); src/ground_bg.o(.rodata); data/data_8115F5C_2_1.o(.rodata); + src/ground_weather.o(.rodata); src/ground_sprite.o(.rodata); src/ground_sprite_data.o(.rodata); src/ground_sprite_monster.o(.rodata); diff --git a/src/debug_field_map.c b/src/debug_field_map.c index 6d6cffe2c..cec6be9ea 100644 --- a/src/debug_field_map.c +++ b/src/debug_field_map.c @@ -10,7 +10,6 @@ #include "text_2.h" #include "text_3.h" #include "ground_map.h" -#include "ground_map_1.h" #include "palette_util.h" #include "string_format.h" #include "sprite.h" diff --git a/src/ground_main.c b/src/ground_main.c index 743f0fc2a..f0d99e8ad 100644 --- a/src/ground_main.c +++ b/src/ground_main.c @@ -15,7 +15,6 @@ #include "debug.h" #include "event_flag.h" #include "ground_map.h" -#include "ground_map_1.h" #include "play_time.h" #include "pokemon.h" #include "text_util.h" diff --git a/src/ground_map.c b/src/ground_map.c index 38b90b974..a728a7287 100644 --- a/src/ground_map.c +++ b/src/ground_map.c @@ -4,9 +4,9 @@ #include "ground_bg.h" #include "ground_main.h" #include "ground_map.h" -#include "ground_map_1.h" #include "ground_script.h" #include "ground_script_file.h" +#include "ground_weather.h" #include "memory.h" #include "ground_map_conversion_table.h" #include "code_800558C.h" @@ -56,6 +56,7 @@ extern u8 sub_80A4660(GroundBg *, u32, s32, s32); void GroundMap_SelectDungeon(s32 mapId, const DungeonLocation *loc, u32 param_2); void sub_80A56D8(const PixelPos*); +extern void sub_80A62D0(void); void AllocGroundMapAction(void) { @@ -1217,7 +1218,7 @@ void sub_80A59A0(s32 param_1, PixelPos *param_2, u32 param_3) void GroundMap_Action(void) { nullsub_123(); - HandleAction((Action *)gGroundMapAction, &gUnknown_8117770); + HandleAction(&gGroundMapAction->action, &gUnknown_8117770); } void sub_80A59DC(void) @@ -1231,9 +1232,9 @@ void sub_80A59DC(void) } switch (gGroundMapAction->groundMapId) { - case 0xA2: - case 0xA3: - case 0xDF: { + case MAP_PERSONALITY_TEST_CYAN: + case MAP_PERSONALITY_TEST_PURPLE: + case MAP_PERSONALITY_TEST_MULTICOLOR: { PixelPos pixPos2; gGroundMapAction->unkF4 += 2; @@ -1249,8 +1250,8 @@ void sub_80A59DC(void) SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 1, &pixPos2); break; } - case 0xA8: - case 0xAA: { + case MAP_FUGITIVES_SNOW_ROAD: + case MAP_FUGITIVES_BLIZZARD_ROAD: { PixelPos pixPos2; gGroundMapAction->unkF0 += gGroundMapAction->unkE8.x; @@ -1262,7 +1263,7 @@ void sub_80A59DC(void) SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 0, &pixPos2); break; } - case 0xAE: { + case MAP_NIGHTMARE: { PixelPos pixPos2; gGroundMapAction->unkF0 += gGroundMapAction->unkE8.x; @@ -1275,14 +1276,14 @@ void sub_80A59DC(void) SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 1, &pixPos2); break; } - case 0xAB: { + case MAP_SUMMIT_SUNSET: { PixelPos pixPos2 = pixPos; sub_80A4580(gGroundMapDungeon_3001B70, 0, &pixPos2); SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 0, &pixPos2); break; } - case 0xAF: { + case MAP_NIGHT_SKY_1: { PixelPos pixPos2; SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 0, &pixPos); @@ -1298,7 +1299,7 @@ void sub_80A59DC(void) SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 1, &pixPos2); break; } - case 0xB0: { + case MAP_NIGHT_SKY_2: { PixelPos pixPos2; gGroundMapAction->unkF0 += gGroundMapAction->unkE8.x; @@ -1313,7 +1314,7 @@ void sub_80A59DC(void) SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 0, &pixPos2); break; } - case 0xBA: { + case MAP_SILENT_CHASM_ENTRY: { PixelPos pixPos2; SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 1, &pixPos); @@ -1326,7 +1327,7 @@ void sub_80A59DC(void) SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 0, &pixPos2); break; } - case 4: { + case MAP_PELIPPER_POST_OFFICE: { PixelPos pixPos2; SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 0, &pixPos); @@ -1339,7 +1340,7 @@ void sub_80A59DC(void) SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 1, &pixPos2); break; } - case 0xE0: { + case MAP_TITLE_SCREEN: { PixelPos pixPos2; SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 0, &pixPos); @@ -1351,7 +1352,7 @@ void sub_80A59DC(void) SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 1, &pixPos2); break; } - case 0xA1: { + case MAP_FRIEND_AREA_FINAL_ISLAND: { PixelPos pixPos2; SetCameraPositionForLayer(gGroundMapDungeon_3001B70, 0, &pixPos); @@ -1370,3 +1371,10 @@ void sub_80A59DC(void) sub_80A60D8(); } +void sub_80A5E70(void) +{ + if (gGroundMapDungeon_3001B70 != NULL) + sub_80A49E8(gGroundMapDungeon_3001B70); + + sub_80A62D0(); +} diff --git a/src/ground_script.c b/src/ground_script.c index d7af35d93..ffc6e2894 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -23,7 +23,6 @@ #include "ground_lives.h" #include "ground_main.h" #include "ground_map.h" -#include "ground_map_1.h" #include "ground_script.h" #include "ground_sprite.h" #include "input.h" @@ -53,12 +52,12 @@ #include "ground_event.h" #include "ground_effect.h" #include "ground_object.h" +#include "ground_weather.h" #include "code_809D148.h" void GroundMap_Select(s16); void GroundMap_SelectDungeon(s32, DungeonLocation*, u32); void GroundMap_GetStationScript(ScriptInfoSmall *out, s16, s32, s32); -void GroundWeather_Select(s16); // Beware of the declarations without specified arguments, returning u32 or s32, these were quickly hacked in to get the code to compile and link // The return values are almost certainly NOT correct and will need to be rechecked when moving to header files diff --git a/src/ground_map_1.c b/src/ground_weather.c similarity index 68% rename from src/ground_map_1.c rename to src/ground_weather.c index 06bac87f5..cd6458ca8 100644 --- a/src/ground_map_1.c +++ b/src/ground_weather.c @@ -1,31 +1,46 @@ #include "global.h" +#include "globaldata.h" +#include "ground_weather.h" #include "code_800558C.h" #include "debug.h" #include "event_flag.h" #include "ground_bg.h" #include "ground_map.h" -#include "ground_map_1.h" #include "memory.h" +typedef struct unkStruct_3001B74 +{ + s16 unk0; + u8 unk2; + s32 unk4; + s32 unk8; + PixelPos unkC; + u32 unk14; + u32 unk18; + u32 unk1C; + u32 unk20; +} unkStruct_3001B74; + IWRAM_INIT unkStruct_3001B74 *gUnknown_3001B74 = {NULL}; IWRAM_INIT GroundBg *gUnknown_3001B78 = {NULL}; -extern const SubStruct_52C gUnknown_8117784; extern const s16 gUnknown_811E5F4[][2]; -extern const u8 gGroundWeatherSelect[]; -extern const PixelPos gUnknown_81177BC; -static void sub_80A62D0(void); +static const SubStruct_52C gUnknown_8117784 = { + .unk0 = 13, + .unk2 = 1, + .unk4 = 0x380, + .unk6 = 0x80, + .unk8 = 0x80, + .unkA = 0, + .numLayers = 1, + .unkE = 0xbc, + .unk10 = 0x5e, + .unk12 = 0, + .unk14 = NULL, +}; -void sub_80A5E70(void) -{ - if (gGroundMapDungeon_3001B70 != NULL) - sub_80A49E8(gGroundMapDungeon_3001B70); - - sub_80A62D0(); -} - -void sub_80A5E8C(u8 param_1) +void sub_80A5E8C(bool8 param_1) { gUnknown_3001B74 = MemoryAlloc(sizeof(unkStruct_3001B74), 6); gUnknown_3001B74->unk0 = -1; @@ -40,7 +55,7 @@ void sub_80A5EBC(void) gUnknown_3001B74 = NULL; } -void sub_80A5EDC(u8 param_1) +void sub_80A5EDC(bool8 param_1) { SetScriptVarValue(NULL, WEATHER_KIND, -1); gUnknown_3001B74->unk0 = -1; @@ -48,8 +63,7 @@ void sub_80A5EDC(u8 param_1) if (gUnknown_3001B78 != NULL) { GroundBg_FreeAll(gUnknown_3001B78); - MemoryFree(gUnknown_3001B78); - gUnknown_3001B78 = NULL; + FREE_AND_SET_NULL(gUnknown_3001B78); } if (param_1) { @@ -73,7 +87,7 @@ void GroundWeather_Select(s16 param_1) iVar2 = param_1; iVar3 = iVar2; - Log(0, gGroundWeatherSelect, iVar2, gUnknown_3001B74->unk2); + Log(0, "GroundWeather Select %3d %3d", iVar2, gUnknown_3001B74->unk2); SetScriptVarValue(NULL, WEATHER_KIND, iVar2); gUnknown_3001B74->unk0 = iVar2; @@ -144,7 +158,7 @@ void sub_80A60D8(void) switch ((s16)(gUnknown_3001B74->unk0 + 1)) { case 10: { - PixelPos localArray; + PixelPos pixPos; gUnknown_3001B74->unk4 += 2; gUnknown_3001B74->unk8 += 1; @@ -153,70 +167,73 @@ void sub_80A60D8(void) sub_80A4580(gUnknown_3001B78, 0, &gUnknown_3001B74->unkC); gUnknown_3001B74->unk4 &= 3; gUnknown_3001B74->unk8 &= 3; - sub_80A56C0(&localArray); - localArray.x -= gUnknown_3001B74->unkC.x; - localArray.y += gUnknown_3001B74->unkC.y; - sub_80A4580(gUnknown_3001B78, 0, &localArray); - SetCameraPositionForLayer(gUnknown_3001B78, 0, &localArray); + sub_80A56C0(&pixPos); + pixPos.x -= gUnknown_3001B74->unkC.x; + pixPos.y += gUnknown_3001B74->unkC.y; + sub_80A4580(gUnknown_3001B78, 0, &pixPos); + SetCameraPositionForLayer(gUnknown_3001B78, 0, &pixPos); break; } case 11: case 12: case 13: case 14: { - PixelPos localArray; + PixelPos pixPos; - sub_80A56C0(&localArray); - SetCameraPositionForLayer(gUnknown_3001B78,0,&localArray); + sub_80A56C0(&pixPos); + SetCameraPositionForLayer(gUnknown_3001B78,0,&pixPos); break; } case 15: { - PixelPos localArray; + PixelPos pixPos; gUnknown_3001B74->unk4++; gUnknown_3001B74->unkC.x += gUnknown_3001B74->unk4 / 4; sub_80A4580(gUnknown_3001B78, 0, &gUnknown_3001B74->unkC); gUnknown_3001B74->unk4 &= 3; - sub_80A56C0(&localArray); - localArray.x -= gUnknown_3001B74->unkC.x; - localArray.y = 0; - sub_80A4580(gUnknown_3001B78, 0, &localArray); - SetCameraPositionForLayer(gUnknown_3001B78, 0, &localArray); + sub_80A56C0(&pixPos); + pixPos.x -= gUnknown_3001B74->unkC.x; + pixPos.y = 0; + sub_80A4580(gUnknown_3001B78, 0, &pixPos); + SetCameraPositionForLayer(gUnknown_3001B78, 0, &pixPos); break; } case 16: { - PixelPos localArray; + PixelPos pixPos; gUnknown_3001B74->unk4 += 2; gUnknown_3001B74->unkC.x += gUnknown_3001B74->unk4 / 4; sub_80A4580(gUnknown_3001B78, 0, &gUnknown_3001B74->unkC); gUnknown_3001B74->unk4 &= 3; - sub_80A56C0(&localArray); - localArray.x -= gUnknown_3001B74->unkC.x; - localArray.y = 0; - sub_80A4580(gUnknown_3001B78, 0, &localArray); - SetCameraPositionForLayer(gUnknown_3001B78, 0, &localArray); + sub_80A56C0(&pixPos); + pixPos.x -= gUnknown_3001B74->unkC.x; + pixPos.y = 0; + sub_80A4580(gUnknown_3001B78, 0, &pixPos); + SetCameraPositionForLayer(gUnknown_3001B78, 0, &pixPos); break; } default: { - PixelPos localArray; + PixelPos pixPos; const s16 *puVar1 = gUnknown_811E5F4[gUnknown_3001B74->unk0]; if (puVar1[0] == 0) { - sub_80A56C0(&localArray); - SetCameraPositionForLayer(gUnknown_3001B78,0,&localArray); + sub_80A56C0(&pixPos); + SetCameraPositionForLayer(gUnknown_3001B78,0,&pixPos); break; } } // NOTE: Fallthrough needed here. - case 0: - SetCameraPositionForLayer(gUnknown_3001B78, 0, &gUnknown_81177BC); + case 0: { + static const PixelPos pixPos = {0, 0}; + + SetCameraPositionForLayer(gUnknown_3001B78, 0, &pixPos); break; + } } sub_80A4764(gUnknown_3001B78); } -static void sub_80A62D0(void) +void sub_80A62D0(void) { if (gUnknown_3001B74->unk2 != 0) sub_80A49E8(gUnknown_3001B78); diff --git a/sym_iwram_init.txt b/sym_iwram_init.txt index fad124f42..f22a3d294 100644 --- a/sym_iwram_init.txt +++ b/sym_iwram_init.txt @@ -6,7 +6,7 @@ .include "src/textbox.o" .include "src/unk_ds_only_feature.o" .include "src/ground_map.o" -.include "src/ground_map_1.o" +.include "src/ground_weather.o" .include "src/ground_sprite.o" .include "src/ground_lives.o" .include "src/ground_object.o"