From 12dafef1f0472b60e272c0c45d05b7a66f11a46a Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 31 May 2026 03:59:52 -0400 Subject: [PATCH 01/22] WeatherManager base struct --- asm/overlay_01_021EB1E8.s | 69 ----------------------------------- include/overlay_01_021EB1E8.h | 22 ++++++++++- main.lsf | 1 + src/field/weather_manager.c | 37 +++++++++++++++++++ 4 files changed, 59 insertions(+), 70 deletions(-) create mode 100644 src/field/weather_manager.c diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 14cfd14945..18a8e09d5b 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -14,75 +14,6 @@ .text - thumb_func_start ov01_021EB1E8 -ov01_021EB1E8: ; 0x021EB1E8 - mov r1, #0x62 - mov r2, #1 - lsl r1, r1, #2 - str r2, [r0, r1] - bx lr - .balign 4, 0 - thumb_func_end ov01_021EB1E8 - - thumb_func_start ov01_021EB1F4 -ov01_021EB1F4: ; 0x021EB1F4 - push {r3, r4, r5, lr} - add r5, r0, #0 - mov r0, #4 - mov r1, #0x18 - bl Heap_Alloc - add r4, r0, #0 - add r2, r4, #0 - mov r1, #0x18 - mov r0, #0 -_021EB208: - strb r0, [r2] - add r2, r2, #1 - sub r1, r1, #1 - bne _021EB208 - add r0, r5, #0 - bl ov01_021EB64C - str r0, [r4] - mov r1, #0 - str r1, [r4, #4] - str r1, [r4, #8] - mov r0, #6 - str r0, [r4, #0xc] - str r1, [r4, #0x14] - mov r0, #0xe - str r0, [r4, #0x10] - mov r0, #0x10 - mov r1, #1 - bl GfGfx_EngineATogglePlanes - add r0, r4, #0 - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EB1F4 - - thumb_func_start ov01_021EB234 -ov01_021EB234: ; 0x021EB234 - push {r4, lr} - add r4, r0, #0 - ldr r0, [r4, #0x14] - cmp r0, #0 - beq _021EB242 - bl SysTask_Destroy -_021EB242: - add r0, r4, #0 - bl ov01_021EB68C - add r2, r4, #0 - mov r1, #0x18 - mov r0, #0 -_021EB24E: - strb r0, [r2] - add r2, r2, #1 - sub r1, r1, #1 - bne _021EB24E - add r0, r4, #0 - bl Heap_Free - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov01_021EB234 - thumb_func_start ov01_021EB260 ov01_021EB260: ; 0x021EB260 push {r3, r4, r5, lr} diff --git a/include/overlay_01_021EB1E8.h b/include/overlay_01_021EB1E8.h index 194072d898..01df3b565a 100644 --- a/include/overlay_01_021EB1E8.h +++ b/include/overlay_01_021EB1E8.h @@ -1,8 +1,28 @@ #ifndef POKEHEARTGOLD_OVERLAY_01_021EB1E8_H #define POKEHEARTGOLD_OVERLAY_01_021EB1E8_H -typedef struct UnkStruct_ov01_021EB1E8 UnkStruct_ov01_021EB1E8; +#include "global.h" +#include "task.h" + +typedef struct UnkStruct_ov01_021EB1E8 { + u8 unk0[0x188]; + u32 unk188; +} UnkStruct_ov01_021EB1E8; + +typedef struct WeatherManager { + u32 unk0; + u32 unk4; + u32 unk8; + u32 unkC; + u32 unk10; + SysTask *task; +} WeatherManager; void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); +WeatherManager *ov01_021EB1F4(u32 a0); +void ov01_021EB234(WeatherManager* weatherManager); +// Not yet decompiled +u32 ov01_021EB64C(u32 a0); +void ov01_021EB68C(WeatherManager *weatherManager); #endif // POKEHEARTGOLD_OVERLAY_01_021EB1E8_H diff --git a/main.lsf b/main.lsf index d4a9e965a0..0032141634 100644 --- a/main.lsf +++ b/main.lsf @@ -498,6 +498,7 @@ Overlay field Object asm/overlay_01_021EABA8.o Object asm/overlay_01_021EAF00.o Object asm/overlay_01_021EAFD4.o + Object src/field/weather_manager.o Object asm/overlay_01_021EB1E8.o Object asm/overlay_01_021EDAFC.o Object src/field/scrcmd_message.o diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c new file mode 100644 index 0000000000..a471b19c62 --- /dev/null +++ b/src/field/weather_manager.c @@ -0,0 +1,37 @@ +#include "overlay_01_021EB1E8.h" +#include "heap.h" +#include "gf_gfx_planes.h" +#include "constants/weather.h" + +void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0) { + a0->unk188 = 1; +} + +WeatherManager *ov01_021EB1F4(u32 a0) { + WeatherManager *weatherManager = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherManager)); + + memset(weatherManager, 0, sizeof(WeatherManager)); + + weatherManager->unk0 = ov01_021EB64C(a0); + weatherManager->unk4 = WEATHER_SUNNY; + weatherManager->unk8 = WEATHER_SUNNY; + weatherManager->unkC = 6; + weatherManager->task = NULL; + weatherManager->unk10 = 14; + + GfGfx_EngineATogglePlanes(GX_PLANEMASK_OBJ, GF_PLANE_TOGGLE_ON); + + return weatherManager; +} + +void ov01_021EB234(WeatherManager* weatherManager) { + if (weatherManager->task) { + SysTask_Destroy(weatherManager->task); + } + + ov01_021EB68C(weatherManager); + + memset(weatherManager, 0, sizeof(WeatherManager)); + + Heap_Free(weatherManager); +} From 5898325c13d174c7d307ee77423669903063620e Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 31 May 2026 04:59:28 -0400 Subject: [PATCH 02/22] Locate weatherManager in FieldSystem substruct I need the renamed weather_manager.h to be part of the filesystem for replace.sh --- asm/include/overlay_01_021E5900.inc | 8 +-- asm/include/overlay_01_021EB1E8.inc | 8 +-- asm/overlay_01_021E5900.s | 8 +-- asm/overlay_01_021EB1E8.s | 104 +--------------------------- include/constants/weather.h | 1 + include/field/weather_manager.h | 35 ++++++++++ include/field_system.h | 4 +- include/overlay_01.h | 1 - include/overlay_01_021EB1E8.h | 28 -------- src/field/weather_manager.c | 50 +++++++++++-- src/field_take_photo.c | 2 + src/scrcmd_c.c | 3 +- 12 files changed, 101 insertions(+), 151 deletions(-) create mode 100644 include/field/weather_manager.h delete mode 100644 include/overlay_01_021EB1E8.h diff --git a/asm/include/overlay_01_021E5900.inc b/asm/include/overlay_01_021E5900.inc index d5fa15f0b4..67ab55cc54 100644 --- a/asm/include/overlay_01_021E5900.inc +++ b/asm/include/overlay_01_021E5900.inc @@ -150,10 +150,10 @@ .public ov01_021EB114 .public ov01_021EB1BC .public ov01_021EB1DC -.public ov01_021EB1F4 -.public ov01_021EB234 -.public ov01_021EB260 -.public FieldWeatherUpdate_UsedFlash +.public WeatherManager_New +.public WeatherManager_Delete +.public WeatherManager_SetWeather +.public WeatherManager_ChangeWeather .public FieldDrawMapNameInfo_Create .public FieldDrawMapNameInfo_Destroy .public FieldSystem_DrawMapNameAnimation diff --git a/asm/include/overlay_01_021EB1E8.inc b/asm/include/overlay_01_021EB1E8.inc index 910fb2bff1..2fdce7db8d 100644 --- a/asm/include/overlay_01_021EB1E8.inc +++ b/asm/include/overlay_01_021EB1E8.inc @@ -84,10 +84,10 @@ .public ov01_021EA89C .public ov01_021EA8C4 .public ov01_021EB1E8 -.public ov01_021EB1F4 -.public ov01_021EB234 -.public ov01_021EB260 -.public FieldWeatherUpdate_UsedFlash +.public WeatherManager_New +.public WeatherManager_Delete +.public WeatherManager_SetWeather +.public WeatherManager_ChangeWeather .public ov01_021EB31C .public ov01_02203EA0 .public ov01_02203F2C diff --git a/asm/overlay_01_021E5900.s b/asm/overlay_01_021E5900.s index 20568c9a68..07eded4f70 100644 --- a/asm/overlay_01_021E5900.s +++ b/asm/overlay_01_021E5900.s @@ -244,7 +244,7 @@ _021E5AB6: add r1, r0, #0 ldr r0, [r4, #4] ldr r0, [r0, #0xc] - bl ov01_021EB260 + bl WeatherManager_SetWeather ldr r1, [r4, #0x20] add r0, r4, #0 ldr r1, [r1] @@ -543,7 +543,7 @@ _021E5D82: bl FieldDrawMapNameInfo_Destroy ldr r0, [r4, #4] ldr r0, [r0, #0xc] - bl ov01_021EB234 + bl WeatherManager_Delete ldr r0, [r4, #4] ldr r0, [r0, #0x20] bl ov01_021FB610 @@ -741,7 +741,7 @@ _021E5F3E: add r1, r0, #0 ldr r0, [r5, #4] ldr r0, [r0, #0xc] - bl FieldWeatherUpdate_UsedFlash + bl WeatherManager_ChangeWeather add r0, r6, #0 bl MapHeader_GetMapSec add r6, r0, #0 @@ -1521,7 +1521,7 @@ _021E65D8: bl ov01_021EA220 str r0, [r4, #0x50] add r0, r4, #0 - bl ov01_021EB1F4 + bl WeatherManager_New ldr r1, [r4, #4] str r0, [r1, #0xc] ldr r0, [r4, #8] diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 18a8e09d5b..2299e111cc 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -14,105 +14,7 @@ .text - thumb_func_start ov01_021EB260 -ov01_021EB260: ; 0x021EB260 - push {r3, r4, r5, lr} - add r5, r0, #0 - ldr r0, [r5, #0xc] - add r4, r1, #0 - cmp r0, #6 - beq _021EB270 - bl GF_AssertFail -_021EB270: - cmp r4, #0xe - blt _021EB278 - bl GF_AssertFail -_021EB278: - ldr r2, [r5, #4] - cmp r2, r4 - beq _021EB2B4 - ldr r0, [r5] - mov r1, #8 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB28E - bl GF_AssertFail -_021EB28E: - ldr r0, [r5] - mov r1, #0 - add r2, r4, #0 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB2A0 - bl GF_AssertFail -_021EB2A0: - ldr r0, [r5] - mov r1, #3 - add r2, r4, #0 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB2B2 - bl GF_AssertFail -_021EB2B2: - str r4, [r5, #4] -_021EB2B4: - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end ov01_021EB260 - - thumb_func_start FieldWeatherUpdate_UsedFlash -FieldWeatherUpdate_UsedFlash: ; 0x021EB2B8 - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - cmp r4, #0xe - blt _021EB2C6 - bl GF_AssertFail -_021EB2C6: - ldr r0, [r5, #0xc] - cmp r0, #6 - beq _021EB2D2 - str r4, [r5, #0x10] - mov r0, #1 - pop {r3, r4, r5, pc} -_021EB2D2: - ldr r0, [r5, #4] - cmp r0, r4 - bne _021EB2DC - mov r0, #1 - pop {r3, r4, r5, pc} -_021EB2DC: - ldr r0, [r5, #0x14] - cmp r0, #0 - beq _021EB2E6 - bl GF_AssertFail -_021EB2E6: - str r4, [r5, #8] - ldr r0, [r5, #4] - add r1, r4, #0 - bl ov01_021EB4B4 - cmp r0, #0 - bne _021EB302 - ldr r0, _021EB314 ; =ov01_021EB320 - mov r2, #0 - add r1, r5, #0 - str r2, [r5, #0xc] - bl SysTask_CreateOnMainQueue - b _021EB30E -_021EB302: - ldr r0, _021EB318 ; =ov01_021EB3F0 - mov r2, #0 - add r1, r5, #0 - str r2, [r5, #0xc] - bl SysTask_CreateOnMainQueue -_021EB30E: - str r0, [r5, #0x14] - mov r0, #1 - pop {r3, r4, r5, pc} - .balign 4, 0 -_021EB314: .word ov01_021EB320 -_021EB318: .word ov01_021EB3F0 - thumb_func_end FieldWeatherUpdate_UsedFlash + thumb_func_start ov01_021EB31C ov01_021EB31C: ; 0x021EB31C @@ -221,7 +123,7 @@ _021EB3D2: cmp r1, #0xe beq _021EB3EE add r0, r4, #0 - bl FieldWeatherUpdate_UsedFlash + bl WeatherManager_ChangeWeather mov r0, #0xe str r0, [r4, #0x10] _021EB3EE: @@ -322,7 +224,7 @@ _021EB490: cmp r1, #0xe beq _021EB4B2 add r0, r4, #0 - bl FieldWeatherUpdate_UsedFlash + bl WeatherManager_ChangeWeather mov r0, #0xe str r0, [r4, #0x10] _021EB4B2: diff --git a/include/constants/weather.h b/include/constants/weather.h index 8dd86bd574..ba947a4c04 100644 --- a/include/constants/weather.h +++ b/include/constants/weather.h @@ -18,5 +18,6 @@ #define WEATHER_FLASH 11 #define WEATHER_FLASH_2 12 #define WEATHER_LOW_LIGHT 13 +#define WEATHER_MAX 14 #endif // POKEHEARTGOLD_CONSTANTS_WEATHER_H diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h new file mode 100644 index 0000000000..799f7d9231 --- /dev/null +++ b/include/field/weather_manager.h @@ -0,0 +1,35 @@ +#ifndef POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H +#define POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H + +#include "global.h" +#include "task.h" + +typedef struct UnkStruct_ov01_021EB1E8 { + u8 unk0[0x188]; + u32 unk188; +} UnkStruct_ov01_021EB1E8; + +typedef struct WeatherManager { + u32 unk0; + u32 weather; + u32 nextWeather; + u32 unkC; + u32 unk10; + SysTask *task; +} WeatherManager; + +void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); +WeatherManager *WeatherManager_New(u32 a0); +void WeatherManager_Delete(WeatherManager* weatherManager); +void WeatherManager_SetWeather(WeatherManager* weatherManager, int a1); +BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather); + +// Not yet decompiled +u32 ov01_021EB64C(u32 a0); +void ov01_021EB68C(WeatherManager *weatherManager); +u32 ov01_021EB700(u32 a0, u32 a1, u32 weather); +void ov01_021EB320(SysTask *task, void *data); +void ov01_021EB3F0(SysTask *task, void *data); +BOOL ov01_021EB4B4(u32 weather, u32 nextWeather); + +#endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/include/field_system.h b/include/field_system.h index 5474c28f76..de64a68a33 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -3,6 +3,7 @@ #include "field/draw_map_name.h" #include "field/overlay_01_021E66E4.h" +#include "field/weather_manager.h" #include "bag_cursor.h" #include "battle_regulation.h" @@ -15,7 +16,6 @@ #include "map_events_internal.h" #include "map_matrix.h" #include "menu_input_state.h" -#include "overlay_01_021EB1E8.h" #include "overlay_01_02204004.h" #include "overlay_manager.h" #include "photo_types_def.h" @@ -100,7 +100,7 @@ typedef struct FieldSystemUnkSub4 { u32 unk0; Field3dObjectTaskManager *field3dObjectTaskManager; FieldDrawMapNameInfo *drawMapNameInfo; - void *unk_0C; // weather related? + WeatherManager *weatherManager; // weather related? UnkStruct_ov01_021EB1E8 *unk10; u32 unk14; u32 unk18; diff --git a/include/overlay_01.h b/include/overlay_01.h index 3679ffaaba..6964c8fba4 100644 --- a/include/overlay_01.h +++ b/include/overlay_01.h @@ -87,7 +87,6 @@ void CallFieldTask_RockClimb(TaskManager *taskManager, int playerDirection, int void CallFieldTask_Surf(TaskManager *taskManager, int playerDirection, int partySlot); void CallFieldTask_Waterfall(TaskManager *taskManager, int playerDirection, int partySlot); void CallFieldTask_Whirlpool(TaskManager *taskManager, int playerDirection, int partySlot); -void FieldWeatherUpdate_UsedFlash(void *unkWeatherRelated, int weatherType); u32 ov01_021F149C(void *, int); void ov01_021F14A8(void *, int, void *); void ov01_021F1448(void *); diff --git a/include/overlay_01_021EB1E8.h b/include/overlay_01_021EB1E8.h deleted file mode 100644 index 01df3b565a..0000000000 --- a/include/overlay_01_021EB1E8.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef POKEHEARTGOLD_OVERLAY_01_021EB1E8_H -#define POKEHEARTGOLD_OVERLAY_01_021EB1E8_H - -#include "global.h" -#include "task.h" - -typedef struct UnkStruct_ov01_021EB1E8 { - u8 unk0[0x188]; - u32 unk188; -} UnkStruct_ov01_021EB1E8; - -typedef struct WeatherManager { - u32 unk0; - u32 unk4; - u32 unk8; - u32 unkC; - u32 unk10; - SysTask *task; -} WeatherManager; - -void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); -WeatherManager *ov01_021EB1F4(u32 a0); -void ov01_021EB234(WeatherManager* weatherManager); - -// Not yet decompiled -u32 ov01_021EB64C(u32 a0); -void ov01_021EB68C(WeatherManager *weatherManager); -#endif // POKEHEARTGOLD_OVERLAY_01_021EB1E8_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index a471b19c62..0a67da9199 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -1,4 +1,4 @@ -#include "overlay_01_021EB1E8.h" +#include "field/weather_manager.h" #include "heap.h" #include "gf_gfx_planes.h" #include "constants/weather.h" @@ -7,24 +7,24 @@ void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0) { a0->unk188 = 1; } -WeatherManager *ov01_021EB1F4(u32 a0) { +WeatherManager *WeatherManager_New(u32 a0) { WeatherManager *weatherManager = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherManager)); memset(weatherManager, 0, sizeof(WeatherManager)); weatherManager->unk0 = ov01_021EB64C(a0); - weatherManager->unk4 = WEATHER_SUNNY; - weatherManager->unk8 = WEATHER_SUNNY; + weatherManager->weather = WEATHER_SUNNY; + weatherManager->nextWeather = WEATHER_SUNNY; weatherManager->unkC = 6; weatherManager->task = NULL; - weatherManager->unk10 = 14; + weatherManager->unk10 = WEATHER_MAX; GfGfx_EngineATogglePlanes(GX_PLANEMASK_OBJ, GF_PLANE_TOGGLE_ON); return weatherManager; } -void ov01_021EB234(WeatherManager* weatherManager) { +void WeatherManager_Delete(WeatherManager* weatherManager) { if (weatherManager->task) { SysTask_Destroy(weatherManager->task); } @@ -35,3 +35,41 @@ void ov01_021EB234(WeatherManager* weatherManager) { Heap_Free(weatherManager); } + +void WeatherManager_SetWeather(WeatherManager* weatherManager, int weather) { + GF_ASSERT(weatherManager->unkC == 6); + GF_ASSERT(weather < WEATHER_MAX); + + if (weatherManager->weather != weather) { + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 8, weatherManager->weather)); + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 0, weather)); + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 3, weather)); + weatherManager->weather = weather; + } +} + +BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather) { + GF_ASSERT(weather < WEATHER_MAX); + + if(weatherManager->unkC != 6) { + weatherManager->unk10 = weather; + return TRUE; + } + + if (weatherManager->weather == weather) { + return TRUE; + } + + GF_ASSERT(weatherManager->task == NULL); + + weatherManager->nextWeather = weather; + if (ov01_021EB4B4(weatherManager->weather, weatherManager->nextWeather) == 0) { + weatherManager->unkC = 0; + weatherManager->task = SysTask_CreateOnMainQueue(ov01_021EB320, weatherManager, 0); + } else { + weatherManager->unkC = 0; + weatherManager->task = SysTask_CreateOnMainQueue(ov01_021EB3F0, weatherManager, 0); + } + + return TRUE; +} diff --git a/src/field_take_photo.c b/src/field_take_photo.c index ea72b1c988..4d02388a1a 100644 --- a/src/field_take_photo.c +++ b/src/field_take_photo.c @@ -6,6 +6,8 @@ #include "graphic/camera_viewfinder.naix" +#include "field/weather_manager.h" + #include "field_warp_tasks.h" #include "follow_mon.h" #include "gf_gfx_loader.h" diff --git a/src/scrcmd_c.c b/src/scrcmd_c.c index 16336e19dc..3b96ab6f14 100644 --- a/src/scrcmd_c.c +++ b/src/scrcmd_c.c @@ -6,6 +6,7 @@ #include "constants/trainers.h" #include "field/legend_cutscene_camera.h" +#include "field/weather_manager.h" #include "frontier/frontier.h" #include "msgdata/msg.naix" #include "msgdata/msg/msg_0202.h" @@ -2286,7 +2287,7 @@ BOOL ScrCmd_180(ScriptContext *ctx) { BOOL ScrCmd_FlashEffect(ScriptContext *ctx) { LocalFieldData *localFieldData = Save_LocalFieldData_Get(ctx->fieldSystem->saveData); LocalFieldData_SetWeatherType(localFieldData, 12); - FieldWeatherUpdate_UsedFlash(ctx->fieldSystem->unk4->unk_0C, LocalFieldData_GetWeatherType(localFieldData)); // CallFieldTask_Flash? + WeatherManager_ChangeWeather(ctx->fieldSystem->unk4->weatherManager, LocalFieldData_GetWeatherType(localFieldData)); // CallFieldTask_Flash? return TRUE; } From f0617033a03561a6711e9876e02574d1d3513fcc Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 31 May 2026 13:39:43 -0400 Subject: [PATCH 03/22] Document WeatherDraw struct --- asm/include/overlay_01_021EB1E8.inc | 2 +- asm/include/overlay_01_021FC05C.inc | 2 +- asm/overlay_01_021EB1E8.s | 308 +--------------------------- asm/overlay_01_021FC05C.s | 2 +- include/field/weather_manager.h | 23 ++- src/field/weather_manager.c | 131 +++++++++++- 6 files changed, 150 insertions(+), 318 deletions(-) diff --git a/asm/include/overlay_01_021EB1E8.inc b/asm/include/overlay_01_021EB1E8.inc index 2fdce7db8d..4e19e41255 100644 --- a/asm/include/overlay_01_021EB1E8.inc +++ b/asm/include/overlay_01_021EB1E8.inc @@ -88,6 +88,6 @@ .public WeatherManager_Delete .public WeatherManager_SetWeather .public WeatherManager_ChangeWeather -.public ov01_021EB31C +.public WeatherManager_GetWeather .public ov01_02203EA0 .public ov01_02203F2C diff --git a/asm/include/overlay_01_021FC05C.inc b/asm/include/overlay_01_021FC05C.inc index 977d59811b..5b40683e85 100644 --- a/asm/include/overlay_01_021FC05C.inc +++ b/asm/include/overlay_01_021FC05C.inc @@ -24,7 +24,7 @@ .public Field3dObjectTaskManager_CreateTask .public Field3dObjectTask_Delete .public Field3dObjectTask_GetData -.public ov01_021EB31C +.public WeatherManager_GetWeather .public GetHoneySweetScentWorkSize .public Task_HoneyOrSweetScent .public FieldSystem_PerformSweetScentEncounterCheck diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 2299e111cc..4343986687 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -13,312 +13,8 @@ .include "global.inc" .text - - - - thumb_func_start ov01_021EB31C -ov01_021EB31C: ; 0x021EB31C - ldr r0, [r0, #4] - bx lr - thumb_func_end ov01_021EB31C - - thumb_func_start ov01_021EB320 -ov01_021EB320: ; 0x021EB320 - push {r4, lr} - add r4, r1, #0 - ldr r1, [r4, #0xc] - cmp r1, #5 - bhi _021EB3EE - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_021EB336: ; jump table - .short _021EB342 - _021EB336 - 2 ; case 0 - .short _021EB35C - _021EB336 - 2 ; case 1 - .short _021EB382 - _021EB336 - 2 ; case 2 - .short _021EB39C - _021EB336 - 2 ; case 3 - .short _021EB3B0 - _021EB336 - 2 ; case 4 - .short _021EB3D2 - _021EB336 - 2 ; case 5 -_021EB342: - ldr r0, [r4] - ldr r2, [r4, #4] - mov r1, #5 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB354 - bl GF_AssertFail -_021EB354: - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - pop {r4, pc} -_021EB35C: - ldr r0, [r4] - ldr r1, [r4, #4] - bl ov01_021EB804 - cmp r0, #3 - beq _021EB3EE - ldr r0, [r4] - ldr r2, [r4, #4] - mov r1, #8 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB37A - bl GF_AssertFail -_021EB37A: - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - pop {r4, pc} -_021EB382: - ldr r0, [r4] - ldr r2, [r4, #8] - mov r1, #1 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB394 - bl GF_AssertFail -_021EB394: - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - pop {r4, pc} -_021EB39C: - ldr r0, [r4] - ldr r1, [r4, #8] - bl ov01_021EB804 - cmp r0, #1 - beq _021EB3EE - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - pop {r4, pc} -_021EB3B0: - ldr r0, [r4] - ldr r2, [r4, #8] - mov r1, #2 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB3C2 - bl GF_AssertFail -_021EB3C2: - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - ldr r0, [r4, #8] - str r0, [r4, #4] - mov r0, #0 - str r0, [r4, #8] - pop {r4, pc} -_021EB3D2: - mov r1, #6 - str r1, [r4, #0xc] - mov r1, #0 - str r1, [r4, #0x14] - bl SysTask_Destroy - ldr r1, [r4, #0x10] - cmp r1, #0xe - beq _021EB3EE - add r0, r4, #0 - bl WeatherManager_ChangeWeather - mov r0, #0xe - str r0, [r4, #0x10] -_021EB3EE: - pop {r4, pc} - thumb_func_end ov01_021EB320 - - thumb_func_start ov01_021EB3F0 -ov01_021EB3F0: ; 0x021EB3F0 - push {r4, lr} - add r4, r1, #0 - ldr r1, [r4, #0xc] - cmp r1, #4 - bhi _021EB4B2 - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_021EB406: ; jump table - .short _021EB410 - _021EB406 - 2 ; case 0 - .short _021EB42A - _021EB406 - 2 ; case 1 - .short _021EB43E - _021EB406 - 2 ; case 2 - .short _021EB46A - _021EB406 - 2 ; case 3 - .short _021EB490 - _021EB406 - 2 ; case 4 -_021EB410: - ldr r0, [r4] - ldr r2, [r4, #8] - mov r1, #1 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB422 - bl GF_AssertFail -_021EB422: - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - pop {r4, pc} -_021EB42A: - ldr r0, [r4] - ldr r1, [r4, #8] - bl ov01_021EB804 - cmp r0, #1 - beq _021EB4B2 - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - pop {r4, pc} -_021EB43E: - ldr r0, [r4] - ldr r2, [r4, #4] - mov r1, #7 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB450 - bl GF_AssertFail -_021EB450: - ldr r0, [r4] - ldr r2, [r4, #8] - mov r1, #4 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB462 - bl GF_AssertFail -_021EB462: - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - pop {r4, pc} -_021EB46A: - ldr r0, [r4] - ldr r1, [r4, #4] - bl ov01_021EB804 - cmp r0, #3 - beq _021EB4B2 - ldr r0, [r4] - ldr r2, [r4, #4] - mov r1, #8 - bl ov01_021EB700 - cmp r0, #0 - bne _021EB488 - bl GF_AssertFail -_021EB488: - ldr r0, [r4, #0xc] - add r0, r0, #1 - str r0, [r4, #0xc] - pop {r4, pc} -_021EB490: - ldr r1, [r4, #8] - mov r2, #0 - str r1, [r4, #4] - str r2, [r4, #8] - mov r1, #6 - str r1, [r4, #0xc] - str r2, [r4, #0x14] - bl SysTask_Destroy - ldr r1, [r4, #0x10] - cmp r1, #0xe - beq _021EB4B2 - add r0, r4, #0 - bl WeatherManager_ChangeWeather - mov r0, #0xe - str r0, [r4, #0x10] -_021EB4B2: - pop {r4, pc} - thumb_func_end ov01_021EB3F0 - - thumb_func_start ov01_021EB4B4 -ov01_021EB4B4: ; 0x021EB4B4 - mov r0, #0 - bx lr - thumb_func_end ov01_021EB4B4 - - thumb_func_start ov01_021EB4B8 -ov01_021EB4B8: ; 0x021EB4B8 - push {r4, r5, r6, r7, lr} - sub sp, #0x1c - ldr r1, _021EB564 ; =0xFFFFF000 - add r6, r0, #0 - add r0, #0x14 - bl GF_InitG2dRenderer - mov r0, #0 - add r3, r6, #0 - str r0, [sp, #0xc] - str r0, [sp, #0x10] - mov r0, #0xff - lsl r0, r0, #0xc - str r0, [sp, #0x14] - mov r0, #3 - lsl r0, r0, #0x12 - str r0, [sp, #0x18] - add r0, r6, #0 - add r0, #0xac - add r1, sp, #0xc - mov r2, #1 - add r3, #0x14 - bl sub_0200B27C - mov r4, #0 - add r5, r6, #0 - mov r7, #0xe -_021EB4EE: - add r0, r7, #0 - add r1, r4, #0 - mov r2, #4 - bl Create2DGfxResObjMan - add r4, r4, #1 - stmia r5!, {r0} - cmp r4, #4 - blt _021EB4EE - bl GF2DGfxResHeader_sizeof - add r1, r0, #0 - mov r0, #4 - lsl r1, r1, #2 - bl Heap_Alloc - str r0, [r6, #0x10] - mov r1, #0 - mov r2, #0x39 - bl ov01_021EB578 - ldr r0, [r6, #0x10] - mov r1, #1 - mov r2, #0x3a - bl ov01_021EB578 - ldr r0, [r6, #0x10] - mov r1, #2 - mov r2, #0x37 - bl ov01_021EB578 - ldr r0, [r6, #0x10] - mov r1, #3 - mov r2, #0x38 - bl ov01_021EB578 - mov r0, #0x40 - str r0, [sp] - add r0, r6, #0 - add r0, #0x14 - str r0, [sp, #4] - mov r0, #4 - str r0, [sp, #8] - add r0, sp, #0 - bl SpriteList_Create - add r1, r6, #0 - add r1, #0xf4 - str r0, [r1] - ldr r0, _021EB568 ; =ov01_021EB56C - add r1, r6, #0 - mov r2, #0xa - bl SysTask_CreateOnMainQueue - add r6, #0xf8 - str r0, [r6] - add sp, #0x1c - pop {r4, r5, r6, r7, pc} - nop -_021EB564: .word 0xFFFFF000 -_021EB568: .word ov01_021EB56C - thumb_func_end ov01_021EB4B8 - + .public ov01_021EB4B8 + thumb_func_start ov01_021EB56C ov01_021EB56C: ; 0x021EB56C ldr r3, _021EB574 ; =SpriteList_RenderAndAnimateSprites diff --git a/asm/overlay_01_021FC05C.s b/asm/overlay_01_021FC05C.s index 92ef774e6e..babea48129 100644 --- a/asm/overlay_01_021FC05C.s +++ b/asm/overlay_01_021FC05C.s @@ -357,7 +357,7 @@ ov01_021FC2C8: ; 0x021FC2C8 push {r3, lr} ldr r0, [r0, #4] ldr r0, [r0, #0xc] - bl ov01_021EB31C + bl WeatherManager_GetWeather ldr r3, _021FC2EC ; =ov01_02208BC0 mov r2, #0 _021FC2D6: diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 799f7d9231..294272cbcd 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -13,23 +13,40 @@ typedef struct WeatherManager { u32 unk0; u32 weather; u32 nextWeather; - u32 unkC; + u32 state; u32 unk10; SysTask *task; } WeatherManager; +typedef struct WeatherDraw { + GF_2DGfxResMan *resMan[4]; + GF_2DGfxResHeader *header; + NNSG2dRendererInstance instance; + NNSG2dRenderSurface surface; + SpriteList *spriteList; + SysTask *task; +} WeatherDraw; + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(u32 a0); void WeatherManager_Delete(WeatherManager* weatherManager); void WeatherManager_SetWeather(WeatherManager* weatherManager, int a1); BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather); +u32 WeatherManager_GetWeather(WeatherManager *weatherManager); + +// Static functions +void WeatherTask_ChangeWeather(SysTask* task, void *data); +void ov01_021EB3F0(SysTask* task, void *data); +BOOL ov01_021EB4B4(u32 weather, u32 nextWeather); +void ov01_021EB4B8(WeatherDraw* weatherDraw); // Not yet decompiled u32 ov01_021EB64C(u32 a0); void ov01_021EB68C(WeatherManager *weatherManager); u32 ov01_021EB700(u32 a0, u32 a1, u32 weather); -void ov01_021EB320(SysTask *task, void *data); void ov01_021EB3F0(SysTask *task, void *data); -BOOL ov01_021EB4B4(u32 weather, u32 nextWeather); +u32 ov01_021EB804(u32 a0, u32 weather); +void ov01_021EB56C(SysTask *task, void *data); +void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 0a67da9199..01281eba17 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -2,6 +2,8 @@ #include "heap.h" #include "gf_gfx_planes.h" #include "constants/weather.h" +#include "unk_02025C44.h" +#include "unk_0200B150.h" void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0) { a0->unk188 = 1; @@ -15,7 +17,7 @@ WeatherManager *WeatherManager_New(u32 a0) { weatherManager->unk0 = ov01_021EB64C(a0); weatherManager->weather = WEATHER_SUNNY; weatherManager->nextWeather = WEATHER_SUNNY; - weatherManager->unkC = 6; + weatherManager->state = 6; weatherManager->task = NULL; weatherManager->unk10 = WEATHER_MAX; @@ -37,7 +39,7 @@ void WeatherManager_Delete(WeatherManager* weatherManager) { } void WeatherManager_SetWeather(WeatherManager* weatherManager, int weather) { - GF_ASSERT(weatherManager->unkC == 6); + GF_ASSERT(weatherManager->state == 6); GF_ASSERT(weather < WEATHER_MAX); if (weatherManager->weather != weather) { @@ -51,7 +53,7 @@ void WeatherManager_SetWeather(WeatherManager* weatherManager, int weather) { BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather) { GF_ASSERT(weather < WEATHER_MAX); - if(weatherManager->unkC != 6) { + if(weatherManager->state != 6) { weatherManager->unk10 = weather; return TRUE; } @@ -64,12 +66,129 @@ BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather) { weatherManager->nextWeather = weather; if (ov01_021EB4B4(weatherManager->weather, weatherManager->nextWeather) == 0) { - weatherManager->unkC = 0; - weatherManager->task = SysTask_CreateOnMainQueue(ov01_021EB320, weatherManager, 0); + weatherManager->state = 0; + weatherManager->task = SysTask_CreateOnMainQueue(WeatherTask_ChangeWeather, weatherManager, 0); } else { - weatherManager->unkC = 0; + weatherManager->state = 0; weatherManager->task = SysTask_CreateOnMainQueue(ov01_021EB3F0, weatherManager, 0); } return TRUE; } + +u32 WeatherManager_GetWeather(WeatherManager *weatherManager) { + return weatherManager->weather; +} + +void WeatherTask_ChangeWeather(SysTask* task, void *data) { + WeatherManager *weatherManager = data; + switch (weatherManager->state) { + case 0: + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 5, weatherManager->weather)); + weatherManager->state++; + break; + case 1: + if (ov01_021EB804(weatherManager->unk0, weatherManager->weather) != 3) { + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 8, weatherManager->weather)); + weatherManager->state++; + } + break; + case 2: + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 1, weatherManager->nextWeather)); + weatherManager->state++; + break; + case 3: + if (ov01_021EB804(weatherManager->unk0, weatherManager->nextWeather) != 1) { + weatherManager->state++; + } + break; + case 4: + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 2, weatherManager->nextWeather)); + weatherManager->state++; + weatherManager->weather = weatherManager->nextWeather; + weatherManager->nextWeather = 0; + break; + case 5: + weatherManager->state = 6; + weatherManager->task = NULL; + SysTask_Destroy(task); + if (weatherManager->unk10 != 14) { + WeatherManager_ChangeWeather(weatherManager, weatherManager->unk10); + weatherManager->unk10 = 14; + } + break; + } +} + +void ov01_021EB3F0(SysTask* task, void *data) { + WeatherManager *weatherManager = data; + switch (weatherManager->state) { + case 0: + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 1, weatherManager->nextWeather)); + weatherManager->state++; + break; + case 1: + if (ov01_021EB804(weatherManager->unk0, weatherManager->nextWeather) != 1) { + weatherManager->state++; + } + break; + case 2: + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 7, weatherManager->weather)); + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 4, weatherManager->nextWeather)); + weatherManager->state++; + break; + case 3: + if (ov01_021EB804(weatherManager->unk0, weatherManager->weather) != 3) { + GF_ASSERT(ov01_021EB700(weatherManager->unk0, 8, weatherManager->weather)); + weatherManager->state++; + } + break; + case 4: + weatherManager->weather = weatherManager->nextWeather; + weatherManager->nextWeather = 0; + weatherManager->state = 6; + weatherManager->task = NULL; + SysTask_Destroy(task); + if (weatherManager->unk10 != 14) { + WeatherManager_ChangeWeather(weatherManager, weatherManager->unk10); + weatherManager->unk10 = 14; + } + break; + } +} + +BOOL ov01_021EB4B4(u32 weather, u32 nextWeather) { + return FALSE; +} + +void ov01_021EB4B8(WeatherDraw* weatherDraw) { + GF_InitG2dRenderer(&weatherDraw->instance, 0xFFFFF000); + + NNSG2dViewRect rect; + rect.posTopLeft.x = 0; + rect.posTopLeft.y = 0; + rect.sizeView.x = 0xFF000; + rect.sizeView.y = 0xC0000; + + sub_0200B27C(&weatherDraw->surface, &rect, NNS_G2D_VRAM_TYPE_2DMAIN, &weatherDraw->instance); + + for (int i = 0; i < 4; i++) { + weatherDraw->resMan[i] = Create2DGfxResObjMan(14, (GfGfxResType) i, HEAP_ID_FIELD1); + } + + weatherDraw->header = Heap_Alloc(HEAP_ID_FIELD1, 4 * GF2DGfxResHeader_sizeof()); + + ov01_021EB578(weatherDraw->header, 0, 0x39); + ov01_021EB578(weatherDraw->header, 1, 0x3A); + ov01_021EB578(weatherDraw->header, 2, 0x37); + ov01_021EB578(weatherDraw->header, 3, 0x38); + + SpriteListParam param; + param.num = 0x40; + param.rendererInstance = &weatherDraw->instance; + param.heapID = HEAP_ID_FIELD1; + + weatherDraw->spriteList = SpriteList_Create(¶m); + + weatherDraw->task = SysTask_CreateOnMainQueue(ov01_021EB56C, weatherDraw, 10); +} From 2e350145e528591c95e7d75206b4ff80e5153f49 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 31 May 2026 21:22:29 -0400 Subject: [PATCH 04/22] struct UnkWeatherStruct_021EB64C --- asm/overlay_01_021EB1E8.s | 160 ++------------------------------ include/field/weather_manager.h | 43 ++++++--- src/field/weather_manager.c | 69 +++++++++++++- 3 files changed, 101 insertions(+), 171 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 4343986687..db4179a7fc 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -13,158 +13,9 @@ .include "global.inc" .text - .public ov01_021EB4B8 - - thumb_func_start ov01_021EB56C -ov01_021EB56C: ; 0x021EB56C - ldr r3, _021EB574 ; =SpriteList_RenderAndAnimateSprites - add r1, #0xf4 - ldr r0, [r1] - bx r3 - .balign 4, 0 -_021EB574: .word SpriteList_RenderAndAnimateSprites - thumb_func_end ov01_021EB56C - - thumb_func_start ov01_021EB578 -ov01_021EB578: ; 0x021EB578 - push {r3, r4, r5, lr} - add r5, r2, #0 - bl GF2DGfxResHeader_GetByIndex - add r4, r0, #0 - mov r0, #1 - str r0, [sp] - mov r0, #0x3f - add r1, r5, #0 - mov r2, #0 - mov r3, #4 - bl GfGfxLoader_LoadFromNarc - add r5, r0, #0 - add r1, r4, #0 - mov r2, #4 - bl GF2DGfxResHeader_Init - add r0, r5, #0 - bl Heap_Free - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EB578 - - thumb_func_start ov01_021EB5A4 -ov01_021EB5A4: ; 0x021EB5A4 - push {r4, r5, r6, lr} - add r6, r0, #0 - mov r4, #0 - add r5, r6, #0 -_021EB5AC: - ldr r0, [r6, #0x10] - add r1, r4, #0 - bl GF2DGfxResHeader_GetByIndex - bl GF2DGfxResHeader_Reset - ldr r0, [r5] - bl Destroy2DGfxResObjMan - add r4, r4, #1 - add r5, r5, #4 - cmp r4, #4 - blt _021EB5AC - ldr r0, [r6, #0x10] - bl Heap_Free - mov r0, #0 - str r0, [r6, #0x10] - add r0, r6, #0 - add r0, #0xf4 - ldr r0, [r0] - bl SpriteList_Delete - add r0, r6, #0 - mov r1, #0 - add r0, #0xf4 - str r1, [r0] - add r0, r6, #0 - add r0, #0xf8 - ldr r0, [r0] - bl SysTask_Destroy - mov r0, #0 - add r6, #0xf8 - str r0, [r6] - pop {r4, r5, r6, pc} - thumb_func_end ov01_021EB5A4 - - thumb_func_start ov01_021EB5F4 -ov01_021EB5F4: ; 0x021EB5F4 - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - ldr r0, [r4] - ldr r1, _021EB644 ; =0x0013F000 - cmp r0, r1 - ble _021EB60A - bl _s32_div_f - str r1, [r4] - b _021EB614 -_021EB60A: - ldr r2, _021EB648 ; =0xFFFC0000 - cmp r0, r2 - bge _021EB614 - add r0, r0, r1 - str r0, [r4] -_021EB614: - mov r1, #1 - ldr r3, [r4, #4] - lsl r1, r1, #0x14 - cmp r3, r1 - ble _021EB62E - lsr r2, r3, #0x1f - lsl r1, r3, #0xc - sub r1, r1, r2 - mov r0, #0xc - ror r1, r0 - add r0, r2, r1 - str r0, [r4, #4] - b _021EB638 -_021EB62E: - ldr r0, _021EB648 ; =0xFFFC0000 - cmp r3, r0 - bge _021EB638 - add r0, r3, r1 - str r0, [r4, #4] -_021EB638: - add r0, r5, #0 - add r1, r4, #0 - bl Sprite_SetMatrix - pop {r3, r4, r5, pc} - nop -_021EB644: .word 0x0013F000 -_021EB648: .word 0xFFFC0000 - thumb_func_end ov01_021EB5F4 - - thumb_func_start ov01_021EB64C -ov01_021EB64C: ; 0x021EB64C - push {r3, r4, r5, lr} - mov r1, #0x43 - add r5, r0, #0 - mov r0, #4 - lsl r1, r1, #2 - bl Heap_Alloc - add r4, r0, #0 - mov r0, #0x41 - lsl r0, r0, #2 - str r5, [r4, r0] - add r0, r4, #0 - add r0, #8 - bl ov01_021EB4B8 - ldr r0, _021EB684 ; =ov01_022098B0 - mov r1, #4 - str r0, [r4] - ldr r0, _021EB688 ; =ov01_0220675C - str r0, [r4, #4] - mov r0, #0x3f ; NARC_a_0_6_3 - bl NARC_New - mov r1, #0x42 - lsl r1, r1, #2 - str r0, [r4, r1] - add r0, r4, #0 - pop {r3, r4, r5, pc} - .balign 4, 0 -_021EB684: .word ov01_022098B0 -_021EB688: .word ov01_0220675C - thumb_func_end ov01_021EB64C + .public WeatherDraw_Init + .public WeatherDraw_Delete + .public ov01_021EB5F4 thumb_func_start ov01_021EB68C ov01_021EB68C: ; 0x021EB68C @@ -205,7 +56,7 @@ _021EB69A: bl GfGfx_EngineATogglePlanes ldr r0, [r4] add r0, #8 - bl ov01_021EB5A4 + bl WeatherDraw_Delete mov r0, #0x42 ldr r1, [r4] lsl r0, r0, #2 @@ -5004,7 +4855,7 @@ ov01_0220673C: ; 0x0220673C ov01_0220674C: ; 0x0220674C .word 2, 2, 2, 2 - +.public ov01_0220675C ov01_0220675C: ; 0x0220675C .byte 0x15, 0x00, 0x00, 0x00 .byte 0x24, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00 @@ -5016,6 +4867,7 @@ ov01_0220675C: ; 0x0220675C .byte 0x30, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00 .data +.public ov01_022098B0 .balign 4, 0 ov01_022098B0: diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 294272cbcd..c082c84ba7 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -4,13 +4,31 @@ #include "global.h" #include "task.h" +typedef struct WeatherDraw { + GF_2DGfxResMan *resMan[4]; + GF_2DGfxResHeader *header; + NNSG2dRendererInstance instance; + NNSG2dRenderSurface surface; + SpriteList *spriteList; + SysTask *task; +} WeatherDraw; + +typedef struct UnkWeatherStruct_021EB64C { + u32 *unk0; + u32 *unk4; + WeatherDraw weatherDraw; + FieldSystem *fieldSystem; + NARC *narc; +} UnkWeatherStruct_021EB64C; + + typedef struct UnkStruct_ov01_021EB1E8 { u8 unk0[0x188]; u32 unk188; } UnkStruct_ov01_021EB1E8; typedef struct WeatherManager { - u32 unk0; + UnkWeatherStruct_021EB64C *unk0; u32 weather; u32 nextWeather; u32 state; @@ -18,34 +36,31 @@ typedef struct WeatherManager { SysTask *task; } WeatherManager; -typedef struct WeatherDraw { - GF_2DGfxResMan *resMan[4]; - GF_2DGfxResHeader *header; - NNSG2dRendererInstance instance; - NNSG2dRenderSurface surface; - SpriteList *spriteList; - SysTask *task; -} WeatherDraw; + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); -WeatherManager *WeatherManager_New(u32 a0); +WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); void WeatherManager_Delete(WeatherManager* weatherManager); void WeatherManager_SetWeather(WeatherManager* weatherManager, int a1); BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather); u32 WeatherManager_GetWeather(WeatherManager *weatherManager); +UnkWeatherStruct_021EB64C* ov01_021EB64C(FieldSystem *fieldSystem); // Static functions void WeatherTask_ChangeWeather(SysTask* task, void *data); void ov01_021EB3F0(SysTask* task, void *data); BOOL ov01_021EB4B4(u32 weather, u32 nextWeather); -void ov01_021EB4B8(WeatherDraw* weatherDraw); +void WeatherDraw_Init(WeatherDraw* weatherDraw); +void ov01_021EB56C(SysTask *task, void *data); +void ov01_021EB578(GF_2DGfxResHeader *headerList, u32 a1, u32 a2); +void WeatherDraw_Delete(WeatherDraw* weatherDraw); +void ov01_021EB5F4(Sprite *sprite, VecFx32* matrix); // Not yet decompiled -u32 ov01_021EB64C(u32 a0); void ov01_021EB68C(WeatherManager *weatherManager); -u32 ov01_021EB700(u32 a0, u32 a1, u32 weather); +u32 ov01_021EB700(UnkWeatherStruct_021EB64C *a0, u32 a1, u32 weather); void ov01_021EB3F0(SysTask *task, void *data); -u32 ov01_021EB804(u32 a0, u32 weather); +u32 ov01_021EB804(UnkWeatherStruct_021EB64C *a0, u32 weather); void ov01_021EB56C(SysTask *task, void *data); void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 01281eba17..c4bdba4f79 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -4,17 +4,18 @@ #include "constants/weather.h" #include "unk_02025C44.h" #include "unk_0200B150.h" +#include "gf_gfx_loader.h" void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0) { a0->unk188 = 1; } -WeatherManager *WeatherManager_New(u32 a0) { +WeatherManager *WeatherManager_New(FieldSystem *fieldSystem) { WeatherManager *weatherManager = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherManager)); memset(weatherManager, 0, sizeof(WeatherManager)); - weatherManager->unk0 = ov01_021EB64C(a0); + weatherManager->unk0 = ov01_021EB64C(fieldSystem); weatherManager->weather = WEATHER_SUNNY; weatherManager->nextWeather = WEATHER_SUNNY; weatherManager->state = 6; @@ -161,7 +162,7 @@ BOOL ov01_021EB4B4(u32 weather, u32 nextWeather) { return FALSE; } -void ov01_021EB4B8(WeatherDraw* weatherDraw) { +void WeatherDraw_Init(WeatherDraw* weatherDraw) { GF_InitG2dRenderer(&weatherDraw->instance, 0xFFFFF000); NNSG2dViewRect rect; @@ -192,3 +193,65 @@ void ov01_021EB4B8(WeatherDraw* weatherDraw) { weatherDraw->task = SysTask_CreateOnMainQueue(ov01_021EB56C, weatherDraw, 10); } + +void ov01_021EB56C(SysTask *task, void *data) { + WeatherDraw *weatherDraw = data; + SpriteList_RenderAndAnimateSprites(weatherDraw->spriteList); +} + +void ov01_021EB578(GF_2DGfxResHeader *headerList, u32 a1, u32 a2) { + GF_2DGfxResHeader *header = GF2DGfxResHeader_GetByIndex(headerList, a1); + GF_2DGfxResHeaderNarcList *headerNarcList = GfGfxLoader_LoadFromNarc(NARC_a_0_6_3, a2, 0, HEAP_ID_FIELD1, 1); + GF2DGfxResHeader_Init(headerNarcList, header, HEAP_ID_FIELD1); + Heap_Free(headerNarcList); +} + +void WeatherDraw_Delete(WeatherDraw* weatherDraw) { + for (int i = 0; i < 4; i++) { + GF2DGfxResHeader_Reset(GF2DGfxResHeader_GetByIndex(weatherDraw->header, i)); + Destroy2DGfxResObjMan(weatherDraw->resMan[i]); + } + + Heap_Free(weatherDraw->header); + weatherDraw->header = NULL; + + SpriteList_Delete(weatherDraw->spriteList); + weatherDraw->spriteList = NULL; + + SysTask_Destroy(weatherDraw->task); + weatherDraw->task = NULL; +} + +void ov01_021EB5F4(Sprite *sprite, VecFx32* matrix) { + if (matrix->x > 0x13F000) { + matrix->x %= 0x13F000; + } else if (matrix->x < (int)0xFFFC0000) { + matrix->x += 0x13F000; + } + + if (matrix->y > 0x100000) { + matrix->y %= 0x100000; + } else if (matrix->y < (int)0xFFFC0000) { + matrix->y += 0x100000; + } + + Sprite_SetMatrix(sprite, matrix); +} + +extern u32 ov01_022098B0[]; +extern u32 ov01_0220675C[]; + +UnkWeatherStruct_021EB64C* ov01_021EB64C(FieldSystem *fieldSystem) { + UnkWeatherStruct_021EB64C *v0 = Heap_Alloc(HEAP_ID_FIELD1, sizeof(UnkWeatherStruct_021EB64C)); + + v0->fieldSystem = fieldSystem; + + WeatherDraw_Init(&v0->weatherDraw); + + v0->unk0 = ov01_022098B0; + v0->unk4 = ov01_0220675C; + + v0->narc = NARC_New(NARC_a_0_6_3, HEAP_ID_FIELD1); + + return v0; +} From d86d40e15f294600011bab9a2975b70953ba8be7 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 1 Jun 2026 02:15:30 -0400 Subject: [PATCH 05/22] Identify WeatherSystem struct from UnkWeatherStruct_021EB64C I wonder if people realize I commit every 5 functions to record my progress and have to keep finding new relevant commit messages to make it seem like there's more purpose to my commits --- asm/overlay_01_021EB1E8.s | 237 +------------------------------- include/field/weather_manager.h | 36 +++-- include/field_system.h | 4 +- src/field/weather_manager.c | 136 +++++++++++++++++- 4 files changed, 161 insertions(+), 252 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index db4179a7fc..1e7cb32ea4 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -16,239 +16,10 @@ .public WeatherDraw_Init .public WeatherDraw_Delete .public ov01_021EB5F4 - - thumb_func_start ov01_021EB68C -ov01_021EB68C: ; 0x021EB68C - push {r3, r4, r5, lr} - sub sp, #8 - add r4, r0, #0 - ldr r0, [r4] - cmp r0, #0 - beq _021EB6F6 - mov r5, #0 -_021EB69A: - ldr r0, [r4] - add r1, r5, #0 - bl ov01_021EBB90 - add r5, r5, #1 - cmp r5, #0xe - blt _021EB69A - mov r2, #0 - str r2, [sp] - str r2, [sp, #4] - mov r0, #0x41 - ldr r1, [r4] - lsl r0, r0, #2 - ldr r0, [r1, r0] - mov r1, #1 - ldr r0, [r0, #0x4c] - add r3, r2, #0 - bl ov01_021EA864 - ldr r1, _021EB6FC ; =0x04000008 - mov r0, #3 - ldrh r2, [r1] - bic r2, r0 - mov r0, #1 - orr r0, r2 - strh r0, [r1] - mov r0, #4 - mov r1, #0 - bl GfGfx_EngineATogglePlanes - ldr r0, [r4] - add r0, #8 - bl WeatherDraw_Delete - mov r0, #0x42 - ldr r1, [r4] - lsl r0, r0, #2 - ldr r0, [r1, r0] - bl NARC_Delete - ldr r1, [r4] - mov r0, #4 - bl Heap_FreeExplicit - mov r0, #0 - str r0, [r4] -_021EB6F6: - add sp, #8 - pop {r3, r4, r5, pc} - nop -_021EB6FC: .word 0x04000008 - thumb_func_end ov01_021EB68C - - thumb_func_start ov01_021EB700 -ov01_021EB700: ; 0x021EB700 - push {r4, r5, r6, lr} - add r4, r2, #0 - add r5, r0, #0 - mov r6, #1 - cmp r4, #0xe - ble _021EB710 - mov r0, #0 - pop {r4, r5, r6, pc} -_021EB710: - cmp r1, #0xa - bhi _021EB7FA - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_021EB720: ; jump table - .short _021EB736 - _021EB720 - 2 ; case 0 - .short _021EB740 - _021EB720 - 2 ; case 1 - .short _021EB74A - _021EB720 - 2 ; case 2 - .short _021EB758 - _021EB720 - 2 ; case 3 - .short _021EB766 - _021EB720 - 2 ; case 4 - .short _021EB796 - _021EB720 - 2 ; case 5 - .short _021EB7A0 - _021EB720 - 2 ; case 6 - .short _021EB7A8 - _021EB720 - 2 ; case 7 - .short _021EB7B2 - _021EB720 - 2 ; case 8 - .short _021EB7BA - _021EB720 - 2 ; case 9 - .short _021EB7DA - _021EB720 - 2 ; case 10 -_021EB736: - add r1, r4, #0 - bl ov01_021EB9A8 - add r6, r0, #0 - b _021EB7FA -_021EB740: - add r1, r4, #0 - bl ov01_021EBA08 - add r6, r0, #0 - b _021EB7FA -_021EB74A: - add r1, r4, #0 - mov r2, #0 - add r3, r6, #0 - bl ov01_021EBA44 - add r6, r0, #0 - b _021EB7FA -_021EB758: - add r1, r4, #0 - mov r2, #2 - add r3, r6, #0 - bl ov01_021EBA44 - add r6, r0, #0 - b _021EB7FA -_021EB766: - mov r0, #0x41 - lsl r0, r0, #2 - ldr r0, [r5, r0] - ldr r0, [r0, #0x4c] - bl ov01_021EA854 - cmp r0, #1 - bne _021EB786 - add r0, r5, #0 - add r1, r4, #0 - mov r2, #0 - mov r3, #2 - bl ov01_021EBA44 - add r6, r0, #0 - b _021EB7FA -_021EB786: - add r0, r5, #0 - add r1, r4, #0 - mov r2, #0 - add r3, r6, #0 - bl ov01_021EBA44 - add r6, r0, #0 - b _021EB7FA -_021EB796: - add r1, r4, #0 - add r2, r6, #0 - bl ov01_021EBB40 - b _021EB7FA -_021EB7A0: - add r1, r4, #0 - bl ov01_021EBB68 - b _021EB7FA -_021EB7A8: - add r1, r4, #0 - mov r2, #0 - bl ov01_021EBB40 - b _021EB7FA -_021EB7B2: - add r1, r4, #0 - bl ov01_021EBB90 - b _021EB7FA -_021EB7BA: - mov r0, #0x1c - ldr r1, [r5] - mul r0, r4 - add r0, r1, r0 - ldr r2, [r0, #8] - cmp r2, #0 - beq _021EB7FA - ldr r0, _021EB800 ; =0x00000F5C - ldr r1, [r2, r0] - cmp r1, #1 - bne _021EB7FA - add r0, r0, #4 - ldrh r0, [r2, r0] - bl PlaySE - b _021EB7FA -_021EB7DA: - mov r0, #0x1c - ldr r1, [r5] - mul r0, r4 - add r0, r1, r0 - ldr r2, [r0, #8] - cmp r2, #0 - beq _021EB7FA - ldr r0, _021EB800 ; =0x00000F5C - ldr r1, [r2, r0] - cmp r1, #1 - bne _021EB7FA - add r0, r0, #4 - ldrh r0, [r2, r0] - mov r1, #0 - bl StopSE -_021EB7FA: - add r0, r6, #0 - pop {r4, r5, r6, pc} - nop -_021EB800: .word 0x00000F5C - thumb_func_end ov01_021EB700 - - thumb_func_start ov01_021EB804 -ov01_021EB804: ; 0x021EB804 - cmp r1, #0xe - blt _021EB80C - mov r0, #0 - bx lr -_021EB80C: - ldr r2, [r0] - mov r0, #0x1c - mul r0, r1 - add r0, r2, r0 - ldrh r0, [r0, #0x10] - bx lr - thumb_func_end ov01_021EB804 - - thumb_func_start ov01_021EB818 -ov01_021EB818: ; 0x021EB818 - push {r3, lr} - add r3, r0, #0 - str r1, [sp] - ldr r0, _021EB82C ; =0x04000050 - mov r1, #4 - mov r2, #0x21 - bl G2x_SetBlendAlpha_ - pop {r3, pc} - nop -_021EB82C: .word 0x04000050 - thumb_func_end ov01_021EB818 - - thumb_func_start ov01_021EB830 -ov01_021EB830: ; 0x021EB830 - str r1, [r0] - str r1, [r0, #4] - sub r1, r2, r1 - str r1, [r0, #8] - str r3, [r0, #0x10] - mov r1, #0 - str r1, [r0, #0xc] - bx lr - thumb_func_end ov01_021EB830 + .public ov01_021EB68C + .public ov01_021EB804 + .public ov01_021EB830 + .public ov01_021EB818 thumb_func_start ov01_021EB840 ov01_021EB840: ; 0x021EB840 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index c082c84ba7..cacfada8a9 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -13,13 +13,7 @@ typedef struct WeatherDraw { SysTask *task; } WeatherDraw; -typedef struct UnkWeatherStruct_021EB64C { - u32 *unk0; - u32 *unk4; - WeatherDraw weatherDraw; - FieldSystem *fieldSystem; - NARC *narc; -} UnkWeatherStruct_021EB64C; +typedef struct WeatherSystem WeatherSystem; typedef struct UnkStruct_ov01_021EB1E8 { @@ -28,7 +22,7 @@ typedef struct UnkStruct_ov01_021EB1E8 { } UnkStruct_ov01_021EB1E8; typedef struct WeatherManager { - UnkWeatherStruct_021EB64C *unk0; + WeatherSystem *unk0; u32 weather; u32 nextWeather; u32 state; @@ -36,7 +30,13 @@ typedef struct WeatherManager { SysTask *task; } WeatherManager; - +typedef struct UnkWeatherStruct_021EB830 { + u32 unk0; + u32 unk4; + u32 unk8; + u32 unkC; + u32 unk10; +} UnkWeatherStruct_021EB830; void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); @@ -44,7 +44,9 @@ void WeatherManager_Delete(WeatherManager* weatherManager); void WeatherManager_SetWeather(WeatherManager* weatherManager, int a1); BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather); u32 WeatherManager_GetWeather(WeatherManager *weatherManager); -UnkWeatherStruct_021EB64C* ov01_021EB64C(FieldSystem *fieldSystem); +WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem); +void ov01_021EB68C(WeatherSystem** pWeatherSystem); +BOOL ov01_021EB700(WeatherSystem *weatherSystem, int state, int weather); // Static functions void WeatherTask_ChangeWeather(SysTask* task, void *data); @@ -55,13 +57,21 @@ void ov01_021EB56C(SysTask *task, void *data); void ov01_021EB578(GF_2DGfxResHeader *headerList, u32 a1, u32 a2); void WeatherDraw_Delete(WeatherDraw* weatherDraw); void ov01_021EB5F4(Sprite *sprite, VecFx32* matrix); +u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather); +void ov01_021EB818(u32 arg0, u32 arg1); +void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3); // Not yet decompiled -void ov01_021EB68C(WeatherManager *weatherManager); -u32 ov01_021EB700(UnkWeatherStruct_021EB64C *a0, u32 a1, u32 weather); void ov01_021EB3F0(SysTask *task, void *data); -u32 ov01_021EB804(UnkWeatherStruct_021EB64C *a0, u32 weather); void ov01_021EB56C(SysTask *task, void *data); void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); +void ov01_021EBB90(WeatherSystem *weatherSystem, u32 a1); +void ov01_021EA864(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); +BOOL ov01_021EB9A8(WeatherSystem *weatherSystem, int weather); +BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); +BOOL ov01_021EBB68(WeatherSystem *weatherSystem, int weather); +BOOL ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u32 a2); +BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); +BOOL ov01_021EA854(u32 a0); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/include/field_system.h b/include/field_system.h index de64a68a33..1f3de5c663 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -127,7 +127,9 @@ struct FieldSystem { MapObjectManager *mapObjectManager; PlayerAvatar *playerAvatar; void *unk_44; - u8 filler48[0xC]; + u32 unk_48; + u32 unk_4C; + u32 unk_50; void *unk54; u32 unk58; TerrainAttributes *terrainAttributes; diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index c4bdba4f79..907c3bdd37 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -5,6 +5,33 @@ #include "unk_02025C44.h" #include "unk_0200B150.h" #include "gf_gfx_loader.h" +#include "field_system.h" +#include "unk_02005D10.h" + +typedef struct WeatherSystem_Sub0_Sub8 { + u8 unk0[0xF5C]; + u32 unkF5C; + u16 sndSeq; +} WeatherSystem_Sub0_Sub8; + +typedef struct WeatherSystem_Sub0 { + u32 unk0; + u32 unk4; + WeatherSystem_Sub0_Sub8 *unk8; + u32 unkC; + u16 unk10; + u16 unk12; + u8 unk[0x8]; +} WeatherSystem_Sub0; + +struct WeatherSystem { + WeatherSystem_Sub0 *unk0; + u32 *unk4; + WeatherDraw weatherDraw; + FieldSystem *fieldSystem; + NARC *narc; +}; + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0) { a0->unk188 = 1; @@ -15,7 +42,7 @@ WeatherManager *WeatherManager_New(FieldSystem *fieldSystem) { memset(weatherManager, 0, sizeof(WeatherManager)); - weatherManager->unk0 = ov01_021EB64C(fieldSystem); + weatherManager->unk0 = WeatherSystem_New(fieldSystem); weatherManager->weather = WEATHER_SUNNY; weatherManager->nextWeather = WEATHER_SUNNY; weatherManager->state = 6; @@ -32,7 +59,7 @@ void WeatherManager_Delete(WeatherManager* weatherManager) { SysTask_Destroy(weatherManager->task); } - ov01_021EB68C(weatherManager); + ov01_021EB68C(&weatherManager->unk0); memset(weatherManager, 0, sizeof(WeatherManager)); @@ -238,11 +265,11 @@ void ov01_021EB5F4(Sprite *sprite, VecFx32* matrix) { Sprite_SetMatrix(sprite, matrix); } -extern u32 ov01_022098B0[]; +extern WeatherSystem_Sub0 ov01_022098B0[]; extern u32 ov01_0220675C[]; -UnkWeatherStruct_021EB64C* ov01_021EB64C(FieldSystem *fieldSystem) { - UnkWeatherStruct_021EB64C *v0 = Heap_Alloc(HEAP_ID_FIELD1, sizeof(UnkWeatherStruct_021EB64C)); +WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem) { + WeatherSystem *v0 = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSystem)); v0->fieldSystem = fieldSystem; @@ -255,3 +282,102 @@ UnkWeatherStruct_021EB64C* ov01_021EB64C(FieldSystem *fieldSystem) { return v0; } + +void ov01_021EB68C(WeatherSystem** pWeatherSystem) { + if (*pWeatherSystem != NULL) { + for (int i = 0; i < 14; i++) { + ov01_021EBB90(*pWeatherSystem, i); + } + + ov01_021EA864((*pWeatherSystem)->fieldSystem->unk_4C, 1, 0, 0, 0, 0); + + reg_G2_BG0CNT = (reg_G2_BG0CNT & ~3) | 1; + + GfGfx_EngineATogglePlanes(4, 0); + + WeatherDraw_Delete(&(*pWeatherSystem)->weatherDraw); + + NARC_Delete((*pWeatherSystem)->narc); + Heap_FreeExplicit(HEAP_ID_FIELD1, *pWeatherSystem); + + *pWeatherSystem = NULL; + } +} + +BOOL ov01_021EB700(WeatherSystem *weatherSystem, int state, int weather) { + BOOL ret = TRUE; + + if (weather > 14) { + return FALSE; + } + + switch (state) { + case 0: + ret = ov01_021EB9A8(weatherSystem, weather); + break; + case 1: + ret = ov01_021EBA08(weatherSystem, weather); + break; + case 2: + ret = ov01_021EBA44(weatherSystem, weather, 0, 1); + break; + case 3: + ret = ov01_021EBA44(weatherSystem, weather, 2, 1); + break; + case 4: + if (ov01_021EA854(weatherSystem->fieldSystem->unk_4C) == 1) { + ret = ov01_021EBA44(weatherSystem, weather, 0, 2); + } else { + ret = ov01_021EBA44(weatherSystem, weather, 0, 1); + } + break; + case 5: + ov01_021EBB40(weatherSystem, weather, 1); + break; + case 6: + ov01_021EBB68(weatherSystem, weather); + break; + case 7: + ov01_021EBB40(weatherSystem, weather, 0); + break; + case 8: + ov01_021EBB90(weatherSystem, weather); + break; + case 9: + WeatherSystem_Sub0 *v1 = &weatherSystem->unk0[weather]; + if (v1->unk8 && v1->unk8->unkF5C == TRUE) { + PlaySE(v1->unk8->sndSeq); + } + break; + case 10: + WeatherSystem_Sub0 *v2 = &weatherSystem->unk0[weather]; + if (v2->unk8 && v2->unk8->unkF5C == TRUE) { + StopSE(v2->unk8->sndSeq, 0); + } + break; + default: + break; + } + + return ret; +} + +u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather) { + if (weather >= 14) { + return 0; + } + WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; + return v0->unk10; +} + +void ov01_021EB818(u32 arg0, u32 arg1) { + G2x_SetBlendAlpha_(0x04000050, 4, 0x21, arg0, arg1); +} + +void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3) { + arg0->unk0 = arg1; + arg0->unk4 = arg1; + arg0->unk8 = arg2 - arg1; + arg0->unk10 = arg3; + arg0->unkC = 0; +} From f6031fc2c92421e61d7bb8a6998a61ba8fd6cad5 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 1 Jun 2026 04:42:08 -0400 Subject: [PATCH 06/22] To ov01_021EB9A8 --- asm/overlay_01_021EB1E8.s | 246 +------------------------------- include/field/weather_manager.h | 25 +++- src/field/weather_manager.c | 110 +++++++++++++- 3 files changed, 131 insertions(+), 250 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 1e7cb32ea4..71944b0509 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -20,246 +20,12 @@ .public ov01_021EB804 .public ov01_021EB830 .public ov01_021EB818 - - thumb_func_start ov01_021EB840 -ov01_021EB840: ; 0x021EB840 - push {r4, lr} - add r4, r0, #0 - ldr r1, [r4, #8] - ldr r0, [r4, #0xc] - mul r0, r1 - ldr r1, [r4, #0x10] - bl _s32_div_f - ldr r1, [r4, #4] - add r0, r0, r1 - str r0, [r4] - ldr r0, [r4, #0xc] - ldr r1, [r4, #0x10] - add r0, r0, #1 - cmp r0, r1 - bgt _021EB866 - str r0, [r4, #0xc] - mov r0, #0 - pop {r4, pc} -_021EB866: - str r1, [r4, #0xc] - mov r0, #1 - pop {r4, pc} - thumb_func_end ov01_021EB840 - - thumb_func_start ov01_021EB86C -ov01_021EB86C: ; 0x021EB86C - push {r4, r5, r6, lr} - add r5, r0, #0 - add r4, r1, #0 - add r6, r2, #0 - bl ov01_021EBEF0 - add r0, r5, #0 - add r1, r4, #0 - add r2, r6, #0 - bl ov01_021EBF24 - add r0, r5, #0 - add r1, r4, #0 - add r2, r6, #0 - bl ov01_021EBF58 - add r0, r5, #0 - add r1, r4, #0 - add r2, r6, #0 - bl ov01_021EBF94 - pop {r4, r5, r6, pc} - thumb_func_end ov01_021EB86C - - thumb_func_start ov01_021EB898 -ov01_021EB898: ; 0x021EB898 - push {r4, r5, r6, r7, lr} - sub sp, #0x2c - add r4, r2, #0 - add r6, r1, #0 - add r7, r3, #0 - ldr r5, [sp, #0x40] - bl GF2DGfxResHeader_GetByIndex - str r0, [sp, #0x18] - add r1, r4, #0 - bl GF2DGfxResHeader_GetNarcMemberIdByIndex - str r0, [sp, #0x1c] - ldr r0, [sp, #0x18] - add r1, r4, #0 - bl GF2DGfxResHeader_GetCompressFlagByIndex - str r0, [sp, #0x20] - ldr r0, [sp, #0x18] - add r1, r4, #0 - bl GF2DGfxResHeader_GetExDat0ByIndex - str r0, [sp, #0x24] - ldr r0, [sp, #0x18] - add r1, r4, #0 - bl GF2DGfxResHeader_GetExDat1ByIndex - str r0, [sp, #0x28] - ldr r0, [sp, #0x18] - add r1, r4, #0 - bl GF2dGfxResHeader_GetObjIdByIndex - cmp r6, #3 - bhi _021EB962 - add r1, r6, r6 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_021EB8E8: ; jump table - .short _021EB8F0 - _021EB8E8 - 2 ; case 0 - .short _021EB90E - _021EB8E8 - 2 ; case 1 - .short _021EB930 - _021EB8E8 - 2 ; case 2 - .short _021EB94A - _021EB8E8 - 2 ; case 3 -_021EB8F0: - str r0, [sp] - ldr r0, [sp, #0x24] - ldr r2, [sp, #0x1c] - str r0, [sp, #4] - mov r0, #4 - str r0, [sp, #8] - ldr r0, [sp, #0x44] - ldr r3, [sp, #0x20] - str r0, [sp, #0xc] - add r0, r7, #0 - add r1, r5, #0 - bl AddCharResObjFromOpenNarcWithAtEndFlag - str r0, [sp, #0x14] - b _021EB962 -_021EB90E: - str r0, [sp] - ldr r0, [sp, #0x24] - ldr r2, [sp, #0x1c] - str r0, [sp, #4] - ldr r0, [sp, #0x28] - ldr r3, [sp, #0x20] - str r0, [sp, #8] - mov r0, #4 - str r0, [sp, #0xc] - ldr r0, [sp, #0x44] - add r1, r5, #0 - str r0, [sp, #0x10] - add r0, r7, #0 - bl AddPlttResObjFromOpenNarcWithAtEndFlag - str r0, [sp, #0x14] - b _021EB962 -_021EB930: - str r0, [sp] - mov r0, #2 - str r0, [sp, #4] - mov r0, #4 - str r0, [sp, #8] - ldr r2, [sp, #0x1c] - ldr r3, [sp, #0x20] - add r0, r7, #0 - add r1, r5, #0 - bl AddCellOrAnimResObjFromOpenNarc - str r0, [sp, #0x14] - b _021EB962 -_021EB94A: - str r0, [sp] - mov r0, #3 - str r0, [sp, #4] - mov r0, #4 - str r0, [sp, #8] - ldr r2, [sp, #0x1c] - ldr r3, [sp, #0x20] - add r0, r7, #0 - add r1, r5, #0 - bl AddCellOrAnimResObjFromOpenNarc - str r0, [sp, #0x14] -_021EB962: - ldr r0, [sp, #0x14] - add sp, #0x2c - pop {r4, r5, r6, r7, pc} - thumb_func_end ov01_021EB898 - - thumb_func_start ov01_021EB968 -ov01_021EB968: ; 0x021EB968 - push {r4, r5, r6, lr} - add r5, r0, #0 - ldr r0, _021EB9A4 ; =0x0000FFFF - add r4, r2, #0 - cmp r1, r0 - beq _021EB9A0 - ldr r0, [r4] - cmp r0, #0 - beq _021EB97E - bl sub_0200AEB0 -_021EB97E: - ldr r0, [r4, #4] - cmp r0, #0 - beq _021EB988 - bl sub_0200B0A8 -_021EB988: - mov r6, #0 -_021EB98A: - ldr r1, [r4] - cmp r1, #0 - beq _021EB996 - ldr r0, [r5, #8] - bl DestroySingle2DGfxResObj -_021EB996: - add r6, r6, #1 - add r4, r4, #4 - add r5, r5, #4 - cmp r6, #4 - blt _021EB98A -_021EB9A0: - pop {r4, r5, r6, pc} - nop -_021EB9A4: .word 0x0000FFFF - thumb_func_end ov01_021EB968 - - thumb_func_start ov01_021EB9A8 -ov01_021EB9A8: ; 0x021EB9A8 - push {r3, r4, r5, lr} - add r5, r0, #0 - mov r2, #0x1c - ldr r3, [r5] - mul r2, r1 - add r4, r3, r2 - ldr r1, [r4, #8] - cmp r1, #0 - bne _021EBA00 - add r1, r4, #0 - bl ov01_021EBE4C - cmp r0, #0 - bne _021EB9C8 - mov r0, #0 - pop {r3, r4, r5, pc} -_021EB9C8: - add r0, r5, #0 - add r1, r4, #0 - bl ov01_021EBD34 - cmp r0, #0 - bne _021EB9E0 - ldr r0, [r4, #8] - bl Heap_Free - mov r0, #0 - str r0, [r4, #8] - pop {r3, r4, r5, pc} -_021EB9E0: - ldr r1, [r4, #0xc] - ldr r0, [r4, #8] - str r1, [r0, #8] - ldrh r1, [r4] - ldr r0, _021EBA04 ; =0x0000FFFF - cmp r1, r0 - beq _021EB9F4 - ldr r0, [r4, #8] - bl ov01_021EC028 -_021EB9F4: - ldrh r1, [r4, #2] - add r0, r5, #0 - bl ov01_021EBD18 - mov r0, #2 - strh r0, [r4, #0x10] -_021EBA00: - mov r0, #1 - pop {r3, r4, r5, pc} - .balign 4, 0 -_021EBA04: .word 0x0000FFFF - thumb_func_end ov01_021EB9A8 + .public ov01_021EB840 + .public ov01_021EB86C + .public ov01_021EB898 + .public ov01_021EB968 + .public ov01_021EB9A8 + thumb_func_start ov01_021EBA08 ov01_021EBA08: ; 0x021EBA08 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index cacfada8a9..314a4fac17 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -4,6 +4,10 @@ #include "global.h" #include "task.h" +typedef struct UnkWeatherStruct_021EB968 { + SpriteResource *charResObj[4]; +} UnkWeatherStruct_021EB968; + typedef struct WeatherDraw { GF_2DGfxResMan *resMan[4]; GF_2DGfxResHeader *header; @@ -14,7 +18,8 @@ typedef struct WeatherDraw { } WeatherDraw; typedef struct WeatherSystem WeatherSystem; - +typedef struct WeatherSystem_Sub0 WeatherSystem_Sub0; +typedef struct WeatherSystem_Sub0_Sub8 WeatherSystem_Sub0_Sub8; typedef struct UnkStruct_ov01_021EB1E8 { u8 unk0[0x188]; @@ -34,8 +39,8 @@ typedef struct UnkWeatherStruct_021EB830 { u32 unk0; u32 unk4; u32 unk8; - u32 unkC; - u32 unk10; + int unkC; + int unk10; } UnkWeatherStruct_021EB830; void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); @@ -60,6 +65,11 @@ void ov01_021EB5F4(Sprite *sprite, VecFx32* matrix); u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather); void ov01_021EB818(u32 arg0, u32 arg1); void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3); +BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0); +void ov01_021EB86C(s32 arg0, s32 arg1, s32 arg2); +SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resIndex, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd); +void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, UnkWeatherStruct_021EB968* a2); +BOOL ov01_021EB9A8(WeatherSystem* weatherSystem, int weather); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -67,11 +77,18 @@ void ov01_021EB56C(SysTask *task, void *data); void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); void ov01_021EBB90(WeatherSystem *weatherSystem, u32 a1); void ov01_021EA864(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); -BOOL ov01_021EB9A8(WeatherSystem *weatherSystem, int weather); BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); BOOL ov01_021EBB68(WeatherSystem *weatherSystem, int weather); BOOL ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u32 a2); BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); BOOL ov01_021EA854(u32 a0); +void ov01_021EBEF0(u32 a0, u32 a1, u32 a2); +void ov01_021EBF24(u32 a0, u32 a1, u32 a2); +void ov01_021EBF58(u32 a0, u32 a1, u32 a2); +void ov01_021EBF94(u32 a0, u32 a1, u32 a2); +BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); +void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 907c3bdd37..3f4afa022b 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -7,22 +7,28 @@ #include "gf_gfx_loader.h" #include "field_system.h" #include "unk_02005D10.h" +#include "unk_0200ACF0.h" -typedef struct WeatherSystem_Sub0_Sub8 { - u8 unk0[0xF5C]; +struct WeatherSystem_Sub0_Sub8 { + u32 unk0; + u32 unk4; + u32 unk8; + u32 unkC; + u8 unk10[0xF4C]; u32 unkF5C; u16 sndSeq; -} WeatherSystem_Sub0_Sub8; +}; -typedef struct WeatherSystem_Sub0 { - u32 unk0; +struct WeatherSystem_Sub0 { + u16 unk0; + u16 unk2; u32 unk4; WeatherSystem_Sub0_Sub8 *unk8; u32 unkC; u16 unk10; u16 unk12; u8 unk[0x8]; -} WeatherSystem_Sub0; +}; struct WeatherSystem { WeatherSystem_Sub0 *unk0; @@ -381,3 +387,95 @@ void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3 arg0->unk10 = arg3; arg0->unkC = 0; } + +BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0) { + int v0 = a0->unk8 * a0->unkC; + v0 /= a0->unk10; + + a0->unk0 = v0 + a0->unk4; + + if (a0->unkC + 1 <= a0->unk10) { + a0->unkC++; + return FALSE; + } + + a0->unkC = a0->unk10; + return TRUE; +} + +void ov01_021EB86C(s32 arg0, s32 arg1, s32 arg2) { + ov01_021EBEF0(arg0, arg1, arg2); + ov01_021EBF24(arg0, arg1, arg2); + ov01_021EBF58(arg0, arg1, arg2); + ov01_021EBF94(arg0, arg1, arg2); +} + +SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resourceType, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd) { + GF_2DGfxResHeader *header = GF2DGfxResHeader_GetByIndex(headerList, resourceType); + u32 member = GF2DGfxResHeader_GetNarcMemberIdByIndex(header, headerIndex); + u32 compressFlag = GF2DGfxResHeader_GetCompressFlagByIndex(header, headerIndex); + u32 exDat0 = GF2DGfxResHeader_GetExDat0ByIndex(header, headerIndex); + u32 exDat1 = GF2DGfxResHeader_GetExDat1ByIndex(header, headerIndex); + u32 objID = GF2dGfxResHeader_GetObjIdByIndex(header, headerIndex); + + SpriteResource *ret; + switch (resourceType) { + case GF_GFX_RES_TYPE_CHAR: + ret = AddCharResObjFromOpenNarcWithAtEndFlag(resMan, narc, member, compressFlag, objID, exDat0, HEAP_ID_FIELD1, atEnd); + break; + case GF_GFX_RES_TYPE_PLTT: + ret = AddPlttResObjFromOpenNarcWithAtEndFlag(resMan, narc, member, compressFlag, objID, exDat0, exDat1, HEAP_ID_FIELD1, atEnd); + break; + case GF_GFX_RES_TYPE_CELL: + ret = AddCellOrAnimResObjFromOpenNarc(resMan, narc, member, compressFlag, objID, GF_GFX_RES_TYPE_CELL, HEAP_ID_FIELD1); + break; + case GF_GFX_RES_TYPE_ANIM: + ret = AddCellOrAnimResObjFromOpenNarc(resMan, narc, member, compressFlag, objID, GF_GFX_RES_TYPE_ANIM, HEAP_ID_FIELD1); + break; + } + + return ret; +} + +void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, UnkWeatherStruct_021EB968* a2) { + if (a1 != 0xFFFF) { + if (a2->charResObj[0] != 0) { + sub_0200AEB0(a2->charResObj[0]); + } + if (a2->charResObj[1] != 0) { + sub_0200B0A8(a2->charResObj[1]); + } + + for (int i = 0; i < 4; i++) { + if (a2->charResObj[i] != 0) { + DestroySingle2DGfxResObj(weatherSystem->weatherDraw.resMan[i], a2->charResObj[i]); + } + } + } +} + +BOOL ov01_021EB9A8(WeatherSystem* weatherSystem, int weather) { + WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; + if (v0->unk8 == 0) { + if (ov01_021EBE4C(weatherSystem, v0) == FALSE) { + return FALSE; + } + + if (ov01_021EBD34(weatherSystem, v0) == FALSE) { + Heap_Free(v0->unk8); + v0->unk8 = NULL; + return FALSE; + } + + v0->unk8->unk8 = v0->unkC; + + if (v0->unk0 != 0xFFFF) { + ov01_021EC028(v0->unk8); + } + + ov01_021EBD18(weatherSystem, v0->unk2); + v0->unk10 = 2; + } + + return TRUE; +} From 38dbf5d487c66d446fa70c437dcb7b3a592761d4 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 1 Jun 2026 06:57:15 -0400 Subject: [PATCH 07/22] Rework WeatherSystem_Sub0 substructs --- asm/overlay_01_021EB1E8.s | 343 +------------------------------- include/field/weather_manager.h | 13 +- src/field/weather_manager.c | 167 +++++++++++++++- 3 files changed, 171 insertions(+), 352 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 71944b0509..6507d3ed9b 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -25,350 +25,9 @@ .public ov01_021EB898 .public ov01_021EB968 .public ov01_021EB9A8 - - - thumb_func_start ov01_021EBA08 -ov01_021EBA08: ; 0x021EBA08 - push {r4, lr} - mov r2, #0x1c - ldr r3, [r0] - mul r2, r1 - add r4, r3, r2 - ldr r1, [r4, #8] - cmp r1, #0 - beq _021EBA1C - mov r0, #1 - pop {r4, pc} -_021EBA1C: - add r1, r4, #0 - bl ov01_021EBE4C - cmp r0, #0 - bne _021EBA2A - mov r0, #0 - pop {r4, pc} -_021EBA2A: - ldr r0, _021EBA40 ; =ov01_021EBD70 - add r1, r4, #0 - mov r2, #1 - bl SysTask_CreateOnMainQueue - str r0, [r4, #0x14] - mov r0, #1 - strh r0, [r4, #0x10] - mov r1, #0 - strh r1, [r4, #0x12] - pop {r4, pc} - .balign 4, 0 -_021EBA40: .word ov01_021EBD70 - thumb_func_end ov01_021EBA08 - - thumb_func_start ov01_021EBA44 -ov01_021EBA44: ; 0x021EBA44 - push {r4, r5, r6, lr} - add r5, r2, #0 - ldr r2, [r0] - mov r0, #0x1c - mul r0, r1 - ldrh r1, [r2, r0] - add r4, r2, r0 - ldr r0, _021EBB2C ; =0x0000FFFF - add r6, r3, #0 - cmp r1, r0 - beq _021EBA64 - ldr r0, [r4, #0xc] - cmp r0, #0 - bne _021EBA64 - mov r0, #0 - pop {r4, r5, r6, pc} -_021EBA64: - ldr r1, [r4, #8] - cmp r1, #0 - bne _021EBA6E - mov r0, #0 - pop {r4, r5, r6, pc} -_021EBA6E: - ldrh r0, [r4, #0x10] - cmp r0, #2 - beq _021EBA78 - mov r0, #0 - pop {r4, r5, r6, pc} -_021EBA78: - ldr r0, [r4, #0x18] - mov r2, #4 - bl SysTask_CreateOnMainQueue - ldr r1, [r4, #8] - ldr r3, _021EBB30 ; =0x00000F48 - str r0, [r1, r3] - ldr r0, [r4, #8] - ldr r0, [r0, r3] - cmp r0, #0 - bne _021EBA92 - mov r0, #0 - pop {r4, r5, r6, pc} -_021EBA92: - mov r0, #3 - strh r0, [r4, #0x10] - add r0, r3, #0 - ldr r1, [r4, #8] - add r0, #0x1a - strh r5, [r1, r0] - add r0, r3, #0 - ldr r1, [r4, #8] - mov r2, #0 - add r0, #0x1e - strh r2, [r1, r0] - ldr r1, [r4, #8] - add r0, r1, #0 - add r0, #0xc - str r0, [r1, #0x40] - ldr r1, [r4, #8] - add r0, r1, #0 - add r0, #0xc - str r0, [r1, #0x44] - add r0, r3, #0 - ldr r1, [r4, #8] - add r0, #0x1c - strh r6, [r1, r0] - add r0, r3, #0 - ldr r1, [r4, #8] - add r0, #0x14 - str r2, [r1, r0] - ldr r1, [r4, #8] - add r0, r3, #4 - ldr r6, _021EBB34 ; =NNS_G3dGlb + 0x258 - add r5, r1, r0 - ldmia r6!, {r0, r1} - stmia r5!, {r0, r1} - ldr r0, [r6] - str r0, [r5] - ldr r1, [r4, #4] - cmp r1, #0 - ble _021EBAF8 - mov r0, #4 - bl Heap_Alloc - ldr r2, [r4, #8] - ldr r1, _021EBB38 ; =0x00000F58 - str r0, [r2, r1] - ldr r0, [r4, #8] - ldr r2, [r4, #4] - ldr r0, [r0, r1] - mov r1, #0 - bl memset - b _021EBAFE -_021EBAF8: - ldr r0, [r4, #8] - add r3, #0x10 - str r2, [r0, r3] -_021EBAFE: - ldrh r1, [r4, #2] - ldr r0, _021EBB2C ; =0x0000FFFF - cmp r1, r0 - beq _021EBB28 - mov r0, #4 - mov r1, #0 - bl GfGfx_EngineATogglePlanes - ldr r2, _021EBB3C ; =0x0400000C - mov r1, #3 - ldrh r3, [r2] - mov r0, #1 - bic r3, r1 - orr r0, r3 - strh r0, [r2] - sub r2, r2, #4 - ldrh r3, [r2] - mov r0, #2 - bic r3, r1 - orr r0, r3 - strh r0, [r2] -_021EBB28: - mov r0, #1 - pop {r4, r5, r6, pc} - .balign 4, 0 -_021EBB2C: .word 0x0000FFFF -_021EBB30: .word 0x00000F48 -_021EBB34: .word NNS_G3dGlb + 0x258 -_021EBB38: .word 0x00000F58 -_021EBB3C: .word 0x0400000C - thumb_func_end ov01_021EBA44 - - thumb_func_start ov01_021EBB40 -ov01_021EBB40: ; 0x021EBB40 - push {r3, r4} - ldr r3, [r0] - mov r0, #0x1c - mul r0, r1 - add r4, r3, r0 - ldrh r0, [r4, #0x10] - cmp r0, #3 - bne _021EBB5E - ldr r1, [r4, #8] - ldr r0, _021EBB64 ; =0x00000F66 - mov r3, #5 - strh r3, [r1, r0] - ldr r1, [r4, #8] - sub r0, r0, #2 - strh r2, [r1, r0] -_021EBB5E: - pop {r3, r4} - bx lr - nop -_021EBB64: .word 0x00000F66 - thumb_func_end ov01_021EBB40 - thumb_func_start ov01_021EBB68 -ov01_021EBB68: ; 0x021EBB68 - push {r4, lr} - mov r2, #0x1c - ldr r3, [r0] - mul r2, r1 - add r4, r3, r2 - bl ov01_021EB804 - cmp r0, #3 - bne _021EBB8A - ldr r1, [r4, #8] - ldr r0, _021EBB8C ; =0x00000F62 - mov r2, #5 - strh r2, [r1, r0] - ldr r1, [r4, #8] - ldr r2, [r4, #0x18] - mov r0, #0 - blx r2 -_021EBB8A: - pop {r4, pc} - .balign 4, 0 -_021EBB8C: .word 0x00000F62 - thumb_func_end ov01_021EBB68 - thumb_func_start ov01_021EBB90 -ov01_021EBB90: ; 0x021EBB90 - push {r4, r5, r6, lr} - sub sp, #8 - add r5, r0, #0 - mov r0, #0x1c - ldr r2, [r5] - mul r0, r1 - add r4, r2, r0 - ldrh r1, [r4, #2] - ldr r0, _021EBC8C ; =0x0000FFFF - cmp r1, r0 - beq _021EBBCE - mov r0, #4 - mov r1, #0 - bl GfGfx_EngineATogglePlanes - ldr r0, _021EBC90 ; =0x0400000C - mov r2, #3 - ldrh r3, [r0] - mov r1, #3 - bic r3, r2 - orr r1, r3 - strh r1, [r0] - sub r3, r0, #4 - ldrh r6, [r3] - mov r1, #1 - add r0, #0x44 - bic r6, r2 - orr r1, r6 - strh r1, [r3] - mov r1, #0 - strh r1, [r0] -_021EBBCE: - ldr r2, [r4, #0xc] - cmp r2, #0 - beq _021EBBF6 - ldrh r1, [r4] - add r0, r5, #0 - bl ov01_021EB968 - ldr r1, [r4, #0xc] - mov r0, #4 - bl Heap_FreeExplicit - mov r0, #0 - str r0, [r4, #0xc] - ldr r0, [r4, #0x14] - cmp r0, #0 - beq _021EBBF6 - bl SysTask_Destroy - mov r0, #0 - str r0, [r4, #0x14] -_021EBBF6: - ldr r0, [r4, #8] - cmp r0, #0 - beq _021EBC70 - add r0, #0xc - bl ov01_021EC2CC - ldrh r1, [r4] - ldr r0, _021EBC8C ; =0x0000FFFF - cmp r1, r0 - beq _021EBC10 - ldr r0, [r4, #8] - bl ov01_021EC058 -_021EBC10: - ldr r0, [r4, #8] - ldr r1, _021EBC94 ; =0x00000F5C - ldr r1, [r0, r1] - cmp r1, #1 - bne _021EBC1E - bl ov01_021EDAE0 -_021EBC1E: - ldr r1, [r4, #8] - ldr r0, _021EBC98 ; =0x00000F58 - ldr r1, [r1, r0] - cmp r1, #0 - beq _021EBC36 - mov r0, #4 - bl Heap_FreeExplicit - ldr r1, [r4, #8] - ldr r0, _021EBC98 ; =0x00000F58 - mov r2, #0 - str r2, [r1, r0] -_021EBC36: - ldrh r0, [r4, #0x10] - cmp r0, #1 - bne _021EBC48 - ldr r0, [r4, #0x14] - cmp r0, #0 - beq _021EBC56 - bl SysTask_Destroy - b _021EBC56 -_021EBC48: - cmp r0, #3 - bne _021EBC56 - ldr r1, [r4, #8] - ldr r0, _021EBC9C ; =0x00000F48 - ldr r0, [r1, r0] - bl SysTask_Destroy -_021EBC56: - ldr r1, [r4, #8] - ldr r0, _021EBCA0 ; =0x00000F6C - ldr r0, [r1, r0] - cmp r0, #0 - beq _021EBC64 - bl SysTask_Destroy -_021EBC64: - ldr r1, [r4, #8] - mov r0, #4 - bl Heap_FreeExplicit - mov r0, #0 - str r0, [r4, #8] -_021EBC70: - mov r2, #0 - str r2, [sp] - mov r0, #0x41 - str r2, [sp, #4] - lsl r0, r0, #2 - ldr r0, [r5, r0] - mov r1, #1 - ldr r0, [r0, #0x4c] - add r3, r2, #0 - bl ov01_021EA864 - add sp, #8 - pop {r4, r5, r6, pc} - nop -_021EBC8C: .word 0x0000FFFF -_021EBC90: .word 0x0400000C -_021EBC94: .word 0x00000F5C -_021EBC98: .word 0x00000F58 -_021EBC9C: .word 0x00000F48 -_021EBCA0: .word 0x00000F6C - thumb_func_end ov01_021EBB90 + thumb_func_start ov01_021EBCA4 ov01_021EBCA4: ; 0x021EBCA4 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 314a4fac17..4a8a32be84 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -20,6 +20,7 @@ typedef struct WeatherDraw { typedef struct WeatherSystem WeatherSystem; typedef struct WeatherSystem_Sub0 WeatherSystem_Sub0; typedef struct WeatherSystem_Sub0_Sub8 WeatherSystem_Sub0_Sub8; +typedef struct WeatherSystem_Sub0_Sub8_LinkedList WeatherSystem_Sub0_Sub8_LinkedList; typedef struct UnkStruct_ov01_021EB1E8 { u8 unk0[0x188]; @@ -70,16 +71,16 @@ void ov01_021EB86C(s32 arg0, s32 arg1, s32 arg2); SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resIndex, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd); void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, UnkWeatherStruct_021EB968* a2); BOOL ov01_021EB9A8(WeatherSystem* weatherSystem, int weather); +BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); +void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2); +void ov01_021EBB68(WeatherSystem *weatherSystem, int weather); +void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); void ov01_021EB56C(SysTask *task, void *data); void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); -void ov01_021EBB90(WeatherSystem *weatherSystem, u32 a1); void ov01_021EA864(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); -BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); -BOOL ov01_021EBB68(WeatherSystem *weatherSystem, int weather); -BOOL ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u32 a2); BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); BOOL ov01_021EA854(u32 a0); void ov01_021EBEF0(u32 a0, u32 a1, u32 a2); @@ -90,5 +91,9 @@ BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1); +void ov01_021EBD70(SysTask *task, void *data); +void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList *linkedList); +void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); +void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 3f4afa022b..18486ede25 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -9,25 +9,43 @@ #include "unk_02005D10.h" #include "unk_0200ACF0.h" -struct WeatherSystem_Sub0_Sub8 { +struct WeatherSystem_Sub0_Sub8_LinkedList { u32 unk0; u32 unk4; u32 unk8; - u32 unkC; - u8 unk10[0xF4C]; + u32 unk10[10]; + WeatherSystem_Sub0_Sub8_LinkedList *next; + WeatherSystem_Sub0_Sub8_LinkedList *prev; +}; + +struct WeatherSystem_Sub0_Sub8 { + u32 unk0; + u32 unk4; + UnkWeatherStruct_021EB968 *unk8; + WeatherSystem_Sub0_Sub8_LinkedList linkedListDummy; + WeatherSystem_Sub0_Sub8_LinkedList linkedList[64]; + SysTask *unkF48; + VecFx32 cameraTarget; + void *unkF58; u32 unkF5C; u16 sndSeq; + u16 unkF62; + u16 unkF64; + u16 unkF66; + u32 unkF68; + SysTask *unkF6C; }; struct WeatherSystem_Sub0 { u16 unk0; u16 unk2; - u32 unk4; + int unk4; WeatherSystem_Sub0_Sub8 *unk8; - u32 unkC; + UnkWeatherStruct_021EB968 *unkC; u16 unk10; u16 unk12; - u8 unk[0x8]; + SysTask *task; + SysTaskFunc unk18; }; struct WeatherSystem { @@ -479,3 +497,140 @@ BOOL ov01_021EB9A8(WeatherSystem* weatherSystem, int weather) { return TRUE; } + +BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather) { + WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; + if (v0->unk8) { + return TRUE; + } + + if (ov01_021EBE4C(weatherSystem, v0) == 0) { + return FALSE; + } + + v0->task = SysTask_CreateOnMainQueue(ov01_021EBD70, v0, 1); + v0->unk10 = 1; + v0->unk12 = 0; + + return TRUE; +} + +BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3) { + WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; + + if (v0->unk0 != 0xFFFF && v0->unkC == 0) { + return FALSE; + } + + if (v0->unk8 == NULL) { + return FALSE; + } + + if (v0->unk10 != 2) { + return FALSE; + } + + v0->unk8->unkF48 = SysTask_CreateOnMainQueue(v0->unk18, v0->unk8, 4); + + if (v0->unk8->unkF48 == NULL) { + return FALSE; + } + + v0->unk10 = 3; + v0->unk8->unkF62 = a2; + v0->unk8->unkF66 = 0; + v0->unk8->linkedListDummy.next = &v0->unk8->linkedListDummy; + v0->unk8->linkedListDummy.prev = &v0->unk8->linkedListDummy; + v0->unk8->unkF64 = a3; + v0->unk8->unkF5C = 0; + + v0->unk8->cameraTarget = NNS_G3dGlb.camTarget; + + if (v0->unk4 > 0) { + v0->unk8->unkF58 = Heap_Alloc(HEAP_ID_FIELD1, v0->unk4); + memset(v0->unk8->unkF58, 0, v0->unk4); + } else { + v0->unk8->unkF58 = NULL; + } + + if (v0->unk2 != 0xFFFF) { + GfGfx_EngineATogglePlanes(4, 0); + G2_SetBG2Priority(1); + G2_SetBG0Priority(2); + } + + return TRUE; +} + +void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2) { + WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; + if (v0->unk10 == 3) { + v0->unk8->unkF66 = 5; + v0->unk8->unkF64 = a2; + } +} + +void ov01_021EBB68(WeatherSystem *weatherSystem, int weather) { + WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; + if (ov01_021EB804(weatherSystem, weather) == 3) { + v0->unk8->unkF62 = 5; + v0->unk18(NULL, v0->unk8); + } +} + + +void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { + WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; + + if (v0->unk2 != 0xFFFF) { + GfGfx_EngineATogglePlanes(4, 0); + + G2_SetBG2Priority(3); + G2_SetBG0Priority(1); + G2_BlendNone(); + } + + if (v0->unkC) { + ov01_021EB968(weatherSystem, v0->unk0, v0->unkC); + Heap_FreeExplicit(HEAP_ID_FIELD1, v0->unkC); + v0->unkC = NULL; + if (v0->task) { + SysTask_Destroy(v0->task); + v0->task = NULL; + } + } + + if (v0->unk8) { + ov01_021EC2CC(&v0->unk8->linkedListDummy); + + if (v0->unk0 != 0xFFFF) { + ov01_021EC058(v0->unk8); + } + + if (v0->unk8->unkF5C == 1) { + ov01_021EDAE0(v0->unk8); + } + + if (v0->unk8->unkF58) { + Heap_FreeExplicit(HEAP_ID_FIELD1, v0->unk8->unkF58); + v0->unk8->unkF58 = NULL; + } + + if (v0->unk10 == 1) { + if (v0->task) { + SysTask_Destroy(v0->task); + } + } else if (v0->unk10 == 3) { + SysTask_Destroy(v0->unk8->unkF48); + } + + if (v0->unk8->unkF6C) { + SysTask_Destroy(v0->unk8->unkF6C); + } + + Heap_FreeExplicit(HEAP_ID_FIELD1, v0->unk8); + v0->unk8 = NULL; + } + + ov01_021EA864(weatherSystem->fieldSystem->unk_4C, 1, 0, 0, 0, 0); +} \ No newline at end of file From 0bfe14b5de6a3e7c9bdc1c4b4584f10650c45015 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 1 Jun 2026 16:51:22 -0400 Subject: [PATCH 08/22] To ov01_021EBE4C --- asm/overlay_01_021EB1E8.s | 280 +------------------------------- include/field/weather_manager.h | 22 ++- src/field/weather_manager.c | 127 ++++++++++++++- 3 files changed, 135 insertions(+), 294 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 6507d3ed9b..e079c0274e 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -25,287 +25,11 @@ .public ov01_021EB898 .public ov01_021EB968 .public ov01_021EB9A8 - + .public ov01_021EBCA4 - thumb_func_start ov01_021EBCA4 -ov01_021EBCA4: ; 0x021EBCA4 - push {r3, r4, r5, lr} - add r4, r0, #0 - ldrh r1, [r4, #2] - ldr r0, _021EBD08 ; =0x0000FFFF - cmp r1, r0 - beq _021EBCD8 - mov r0, #4 - mov r1, #0 - bl GfGfx_EngineATogglePlanes - ldr r0, _021EBD0C ; =0x0400000C - mov r2, #3 - ldrh r3, [r0] - mov r1, #3 - bic r3, r2 - orr r1, r3 - strh r1, [r0] - sub r3, r0, #4 - ldrh r5, [r3] - mov r1, #1 - add r0, #0x44 - bic r5, r2 - orr r1, r5 - strh r1, [r3] - mov r1, #0 - strh r1, [r0] -_021EBCD8: - ldr r0, [r4, #8] - cmp r0, #0 - beq _021EBD06 - add r0, #0xc - bl ov01_021EC2CC - ldr r0, [r4, #8] - ldr r1, _021EBD10 ; =0x00000F5C - ldr r1, [r0, r1] - cmp r1, #1 - bne _021EBCF2 - bl ov01_021EDAE0 -_021EBCF2: - ldrh r0, [r4, #0x10] - cmp r0, #3 - bne _021EBD06 - ldr r1, [r4, #8] - ldr r0, _021EBD14 ; =0x00000F48 - ldr r0, [r1, r0] - bl SysTask_Destroy - mov r0, #2 - strh r0, [r4, #0x10] -_021EBD06: - pop {r3, r4, r5, pc} - .balign 4, 0 -_021EBD08: .word 0x0000FFFF -_021EBD0C: .word 0x0400000C -_021EBD10: .word 0x00000F5C -_021EBD14: .word 0x00000F48 - thumb_func_end ov01_021EBCA4 - - thumb_func_start ov01_021EBD18 -ov01_021EBD18: ; 0x021EBD18 - push {r3, r4, r5, lr} - add r5, r0, #0 - add r4, r1, #0 - bl ov01_021EC078 - add r0, r5, #0 - add r1, r4, #0 - bl ov01_021EC0C0 - add r0, r5, #0 - add r1, r4, #0 - bl ov01_021EC114 - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EBD18 - - thumb_func_start ov01_021EBD34 -ov01_021EBD34: ; 0x021EBD34 - push {r3, r4, r5, lr} - add r4, r1, #0 - ldrh r1, [r4] - add r5, r0, #0 - ldr r0, _021EBD6C ; =0x0000FFFF - cmp r1, r0 - beq _021EBD68 - ldr r0, [r4, #0xc] - cmp r0, #0 - bne _021EBD68 - add r0, r4, #0 - bl ov01_021EBEB8 - cmp r0, #0 - bne _021EBD56 - mov r0, #0 - pop {r3, r4, r5, pc} -_021EBD56: - ldrh r1, [r4] - ldr r2, [r4, #0xc] - add r0, r5, #0 - bl ov01_021EB86C - add r0, r5, #0 - add r1, r4, #0 - bl ov01_021EBFD0 -_021EBD68: - mov r0, #1 - pop {r3, r4, r5, pc} - .balign 4, 0 -_021EBD6C: .word 0x0000FFFF - thumb_func_end ov01_021EBD34 - - thumb_func_start ov01_021EBD70 -ov01_021EBD70: ; 0x021EBD70 - push {r3, r4, r5, lr} - add r4, r1, #0 - ldrh r2, [r4, #0x12] - add r5, r0, #0 - ldr r0, [r4, #8] - cmp r2, #8 - ldr r0, [r0] - bhi _021EBE46 - add r2, r2, r2 - add r2, pc - ldrh r2, [r2, #6] - lsl r2, r2, #0x10 - asr r2, r2, #0x10 - add pc, r2 -_021EBD8C: ; jump table - .short _021EBD9E - _021EBD8C - 2 ; case 0 - .short _021EBDB4 - _021EBD8C - 2 ; case 1 - .short _021EBDC4 - _021EBD8C - 2 ; case 2 - .short _021EBDD2 - _021EBD8C - 2 ; case 3 - .short _021EBDE2 - _021EBD8C - 2 ; case 4 - .short _021EBDF0 - _021EBD8C - 2 ; case 5 - .short _021EBE00 - _021EBD8C - 2 ; case 6 - .short _021EBE0E - _021EBD8C - 2 ; case 7 - .short _021EBE1E - _021EBD8C - 2 ; case 8 -_021EBD9E: - add r0, r4, #0 - bl ov01_021EBEB8 - cmp r0, #0 - bne _021EBDAC - bl GF_AssertFail -_021EBDAC: - ldrh r0, [r4, #0x12] - add r0, r0, #1 - strh r0, [r4, #0x12] - pop {r3, r4, r5, pc} -_021EBDB4: - ldrh r1, [r4] - ldr r2, [r4, #0xc] - bl ov01_021EBEF0 - ldrh r0, [r4, #0x12] - add r0, r0, #1 - strh r0, [r4, #0x12] - pop {r3, r4, r5, pc} -_021EBDC4: - ldrh r1, [r4, #2] - bl ov01_021EC078 - ldrh r0, [r4, #0x12] - add r0, r0, #1 - strh r0, [r4, #0x12] - pop {r3, r4, r5, pc} -_021EBDD2: - ldrh r1, [r4] - ldr r2, [r4, #0xc] - bl ov01_021EBF24 - ldrh r0, [r4, #0x12] - add r0, r0, #1 - strh r0, [r4, #0x12] - pop {r3, r4, r5, pc} -_021EBDE2: - ldrh r1, [r4, #2] - bl ov01_021EC0C0 - ldrh r0, [r4, #0x12] - add r0, r0, #1 - strh r0, [r4, #0x12] - pop {r3, r4, r5, pc} -_021EBDF0: - ldrh r1, [r4] - ldr r2, [r4, #0xc] - bl ov01_021EBF58 - ldrh r0, [r4, #0x12] - add r0, r0, #1 - strh r0, [r4, #0x12] - pop {r3, r4, r5, pc} -_021EBE00: - ldrh r1, [r4, #2] - bl ov01_021EC114 - ldrh r0, [r4, #0x12] - add r0, r0, #1 - strh r0, [r4, #0x12] - pop {r3, r4, r5, pc} -_021EBE0E: - ldrh r1, [r4] - ldr r2, [r4, #0xc] - bl ov01_021EBF94 - ldrh r0, [r4, #0x12] - add r0, r0, #1 - strh r0, [r4, #0x12] - pop {r3, r4, r5, pc} -_021EBE1E: - bl ov01_021EBFD0 - ldr r1, [r4, #0xc] - ldr r0, [r4, #8] - str r1, [r0, #8] - ldrh r1, [r4] - ldr r0, _021EBE48 ; =0x0000FFFF - cmp r1, r0 - beq _021EBE36 - ldr r0, [r4, #8] - bl ov01_021EC028 -_021EBE36: - mov r0, #2 - strh r0, [r4, #0x10] - mov r0, #0 - strh r0, [r4, #0x12] - str r0, [r4, #0x14] - add r0, r5, #0 - bl SysTask_Destroy -_021EBE46: - pop {r3, r4, r5, pc} - .balign 4, 0 -_021EBE48: .word 0x0000FFFF - thumb_func_end ov01_021EBD70 - - thumb_func_start ov01_021EBE4C -ov01_021EBE4C: ; 0x021EBE4C - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - ldr r0, [r4, #8] - cmp r0, #0 - beq _021EBE5C - mov r0, #1 - pop {r3, r4, r5, pc} -_021EBE5C: - mov r1, #0xf7 - mov r0, #4 - lsl r1, r1, #4 - bl Heap_Alloc - str r0, [r4, #8] - cmp r0, #0 - bne _021EBE70 - mov r0, #0 - pop {r3, r4, r5, pc} -_021EBE70: - mov r2, #0xf7 - mov r1, #0 - lsl r2, r2, #4 - bl memset - ldr r0, [r4, #8] - ldr r2, _021EBEB4 ; =0x00000F62 - str r5, [r0] - ldr r1, [r4, #8] - mov r0, #0 - strh r0, [r1, r2] - ldr r3, [r4, #8] - add r1, r2, #4 - strh r0, [r3, r1] - ldr r3, [r4, #8] - add r1, r3, #0 - add r1, #0xc - str r1, [r3, #0x40] - ldr r3, [r4, #8] - add r1, r3, #0 - add r1, #0xc - str r1, [r3, #0x44] - add r1, r2, #0 - ldr r3, [r4, #8] - sub r1, #0xa - str r0, [r3, r1] - ldr r1, [r4, #8] - add r2, #0xa - str r4, [r1, #4] - ldr r1, [r4, #8] - str r0, [r1, r2] - mov r0, #1 - pop {r3, r4, r5, pc} - nop -_021EBEB4: .word 0x00000F62 - thumb_func_end ov01_021EBE4C + thumb_func_start ov01_021EBEB8 ov01_021EBEB8: ; 0x021EBEB8 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 4a8a32be84..19e1f45387 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -67,7 +67,7 @@ u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather); void ov01_021EB818(u32 arg0, u32 arg1); void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3); BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0); -void ov01_021EB86C(s32 arg0, s32 arg1, s32 arg2); +void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, UnkWeatherStruct_021EB968 *arg2); SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resIndex, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd); void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, UnkWeatherStruct_021EB968* a2); BOOL ov01_021EB9A8(WeatherSystem* weatherSystem, int weather); @@ -75,6 +75,10 @@ BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2); void ov01_021EBB68(WeatherSystem *weatherSystem, int weather); void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather); +void ov01_021EBCA4(WeatherSystem_Sub0* a0); +void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1); +BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -83,17 +87,19 @@ void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); void ov01_021EA864(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); BOOL ov01_021EA854(u32 a0); -void ov01_021EBEF0(u32 a0, u32 a1, u32 a2); -void ov01_021EBF24(u32 a0, u32 a1, u32 a2); -void ov01_021EBF58(u32 a0, u32 a1, u32 a2); -void ov01_021EBF94(u32 a0, u32 a1, u32 a2); -BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); -BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); +void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); +void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); +void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); -void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1); void ov01_021EBD70(SysTask *task, void *data); void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList *linkedList); void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); +void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1); +void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1); +void ov01_021EC114(WeatherSystem *weatherSystem, u16 a1); +BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0); +void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 18486ede25..2324e91260 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -19,8 +19,8 @@ struct WeatherSystem_Sub0_Sub8_LinkedList { }; struct WeatherSystem_Sub0_Sub8 { - u32 unk0; - u32 unk4; + WeatherSystem *weatherSystem; + WeatherSystem_Sub0 *unk4; UnkWeatherStruct_021EB968 *unk8; WeatherSystem_Sub0_Sub8_LinkedList linkedListDummy; WeatherSystem_Sub0_Sub8_LinkedList linkedList[64]; @@ -421,11 +421,11 @@ BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0) { return TRUE; } -void ov01_021EB86C(s32 arg0, s32 arg1, s32 arg2) { - ov01_021EBEF0(arg0, arg1, arg2); - ov01_021EBF24(arg0, arg1, arg2); - ov01_021EBF58(arg0, arg1, arg2); - ov01_021EBF94(arg0, arg1, arg2); +void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, UnkWeatherStruct_021EB968 *arg2) { + ov01_021EBEF0(weatherSystem, arg1, arg2); + ov01_021EBF24(weatherSystem, arg1, arg2); + ov01_021EBF58(weatherSystem, arg1, arg2); + ov01_021EBF94(weatherSystem, arg1, arg2); } SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resourceType, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd) { @@ -633,4 +633,115 @@ void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { } ov01_021EA864(weatherSystem->fieldSystem->unk_4C, 1, 0, 0, 0, 0); -} \ No newline at end of file +} + +void ov01_021EBCA4(WeatherSystem_Sub0* a0) { + if (a0->unk2 != 0xFFFF) { + GfGfx_EngineATogglePlanes(4, 0); + G2_SetBG2Priority(3); + G2_SetBG0Priority(1); + G2_BlendNone(); + } + + if (a0->unk8 != NULL) { + ov01_021EC2CC(&a0->unk8->linkedListDummy); + + if (a0->unk8->unkF5C == 1) { + ov01_021EDAE0(a0->unk8); + } + + if (a0->unk10 == 3) { + SysTask_Destroy(a0->unk8->unkF48); + a0->unk10 = 2; + } + } +} + +void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1) { + ov01_021EC078(weatherSystem, a1); + ov01_021EC0C0(weatherSystem, a1); + ov01_021EC114(weatherSystem, a1); +} + +BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { + if (a1->unk0 != 0xFFFF && a1->unkC == NULL) { + if (ov01_021EBEB8(a1) == FALSE) { + return FALSE; + } + ov01_021EB86C(weatherSystem, a1->unk0, a1->unkC); + ov01_021EBFD0(weatherSystem, a1); + } + return TRUE; +} + +void ov01_021EBD70(SysTask *task, void *data) { + WeatherSystem_Sub0 *v0 = data; + WeatherSystem *weatherSystem = v0->unk8->weatherSystem; + switch (v0->unk12) { + case 0: + GF_ASSERT(ov01_021EBEB8(v0)); + v0->unk12++; + break; + case 1: + ov01_021EBEF0(weatherSystem, v0->unk0, v0->unkC); + v0->unk12++; + break; + case 2: + ov01_021EC078(weatherSystem, v0->unk2); + v0->unk12++; + break; + case 3: + ov01_021EBF24(weatherSystem, v0->unk0, v0->unkC); + v0->unk12++; + break; + case 4: + ov01_021EC0C0(weatherSystem, v0->unk2); + v0->unk12++; + break; + case 5: + ov01_021EBF58(weatherSystem, v0->unk0, v0->unkC); + v0->unk12++; + break; + case 6: + ov01_021EC114(weatherSystem, v0->unk2); + v0->unk12++; + break; + case 7: + ov01_021EBF94(weatherSystem, v0->unk0, v0->unkC); + v0->unk12++; + break; + case 8: + ov01_021EBFD0(weatherSystem, v0); + v0->unk8->unk8 = v0->unkC; + if (v0->unk0 != 0xFFFF) { + ov01_021EC028(v0->unk8); + } + v0->unk10 = 2; + v0->unk12 = 0; + v0->task = 0; + SysTask_Destroy(task); + } +} + +BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { + if (a1->unk8) { + return TRUE; + } + + a1->unk8 = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSystem_Sub0_Sub8)); + if (a1->unk8 == NULL) { + return FALSE; + } + memset(a1->unk8, 0, sizeof(WeatherSystem_Sub0_Sub8)); + + a1->unk8->weatherSystem = weatherSystem; + a1->unk8->unkF62 = 0; + a1->unk8->unkF66 = 0; + a1->unk8->linkedListDummy.next = &a1->unk8->linkedListDummy; + a1->unk8->linkedListDummy.prev = &a1->unk8->linkedListDummy; + a1->unk8->unkF58 = NULL; + a1->unk8->unk4 = a1; + a1->unk8->unkF6C = NULL; + + return TRUE; +} From ff8ebc8f7fc80c4dd1a57cf1818278627e0463d8 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 1 Jun 2026 17:59:54 -0400 Subject: [PATCH 09/22] To ov01_021EBF94 --- asm/overlay_01_021EB1E8.s | 158 -------------------------------- include/field/weather_manager.h | 11 ++- src/field/weather_manager.c | 42 +++++++++ 3 files changed, 48 insertions(+), 163 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index e079c0274e..4534220fc9 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -27,164 +27,6 @@ .public ov01_021EB9A8 .public ov01_021EBCA4 - - - - - thumb_func_start ov01_021EBEB8 -ov01_021EBEB8: ; 0x021EBEB8 - push {r4, lr} - add r4, r0, #0 - ldrh r1, [r4] - ldr r0, _021EBEEC ; =0x0000FFFF - cmp r1, r0 - beq _021EBEE8 - ldr r0, [r4, #0xc] - cmp r0, #0 - beq _021EBECE - mov r0, #1 - pop {r4, pc} -_021EBECE: - mov r0, #4 - mov r1, #0x64 - bl Heap_Alloc - str r0, [r4, #0xc] - cmp r0, #0 - bne _021EBEE0 - mov r0, #0 - pop {r4, pc} -_021EBEE0: - mov r1, #0 - mov r2, #0x64 - bl memset -_021EBEE8: - mov r0, #1 - pop {r4, pc} - .balign 4, 0 -_021EBEEC: .word 0x0000FFFF - thumb_func_end ov01_021EBEB8 - - thumb_func_start ov01_021EBEF0 -ov01_021EBEF0: ; 0x021EBEF0 - push {r3, r4, r5, lr} - sub sp, #8 - add r5, r0, #0 - ldr r0, _021EBF20 ; =0x0000FFFF - add r3, r1, #0 - add r4, r2, #0 - cmp r3, r0 - beq _021EBF1A - mov r0, #0x42 - lsl r0, r0, #2 - ldr r0, [r5, r0] - add r2, r3, #0 - str r0, [sp] - mov r0, #0 - str r0, [sp, #4] - ldr r0, [r5, #0x18] - ldr r3, [r5, #0x10] - mov r1, #2 - bl ov01_021EB898 - str r0, [r4, #8] -_021EBF1A: - add sp, #8 - pop {r3, r4, r5, pc} - nop -_021EBF20: .word 0x0000FFFF - thumb_func_end ov01_021EBEF0 - - thumb_func_start ov01_021EBF24 -ov01_021EBF24: ; 0x021EBF24 - push {r3, r4, r5, lr} - sub sp, #8 - add r5, r0, #0 - ldr r0, _021EBF54 ; =0x0000FFFF - add r3, r1, #0 - add r4, r2, #0 - cmp r3, r0 - beq _021EBF4E - mov r0, #0x42 - lsl r0, r0, #2 - ldr r0, [r5, r0] - add r2, r3, #0 - str r0, [sp] - mov r0, #0 - str r0, [sp, #4] - ldr r0, [r5, #0x18] - ldr r3, [r5, #0x14] - mov r1, #3 - bl ov01_021EB898 - str r0, [r4, #0xc] -_021EBF4E: - add sp, #8 - pop {r3, r4, r5, pc} - nop -_021EBF54: .word 0x0000FFFF - thumb_func_end ov01_021EBF24 - - thumb_func_start ov01_021EBF58 -ov01_021EBF58: ; 0x021EBF58 - push {r3, r4, r5, lr} - sub sp, #8 - add r5, r0, #0 - ldr r0, _021EBF90 ; =0x0000FFFF - add r3, r1, #0 - add r4, r2, #0 - cmp r3, r0 - beq _021EBF8C - mov r0, #0x42 - lsl r0, r0, #2 - ldr r0, [r5, r0] - add r2, r3, #0 - str r0, [sp] - mov r0, #1 - str r0, [sp, #4] - ldr r0, [r5, #0x18] - ldr r3, [r5, #8] - mov r1, #0 - bl ov01_021EB898 - str r0, [r4] - bl sub_0200ADA4 - ldr r0, [r4] - bl sub_0200A740 -_021EBF8C: - add sp, #8 - pop {r3, r4, r5, pc} - .balign 4, 0 -_021EBF90: .word 0x0000FFFF - thumb_func_end ov01_021EBF58 - - thumb_func_start ov01_021EBF94 -ov01_021EBF94: ; 0x021EBF94 - push {r3, r4, r5, lr} - sub sp, #8 - add r5, r0, #0 - ldr r0, _021EBFCC ; =0x0000FFFF - add r3, r1, #0 - add r4, r2, #0 - cmp r3, r0 - beq _021EBFC6 - mov r0, #0x42 - lsl r0, r0, #2 - ldr r0, [r5, r0] - mov r1, #1 - str r0, [sp] - str r1, [sp, #4] - add r2, r3, #0 - ldr r0, [r5, #0x18] - ldr r3, [r5, #0xc] - bl ov01_021EB898 - str r0, [r4, #4] - bl sub_0200B00C - ldr r0, [r4, #4] - bl sub_0200A740 -_021EBFC6: - add sp, #8 - pop {r3, r4, r5, pc} - nop -_021EBFCC: .word 0x0000FFFF - thumb_func_end ov01_021EBF94 - thumb_func_start ov01_021EBFD0 ov01_021EBFD0: ; 0x021EBFD0 push {r3, r4, r5, lr} diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 19e1f45387..f758c104e9 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -6,6 +6,7 @@ typedef struct UnkWeatherStruct_021EB968 { SpriteResource *charResObj[4]; + u8 unk10[0x54]; } UnkWeatherStruct_021EB968; typedef struct WeatherDraw { @@ -79,6 +80,11 @@ void ov01_021EBCA4(WeatherSystem_Sub0* a0); void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1); BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0); +void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); +void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); +void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); +void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -87,10 +93,6 @@ void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); void ov01_021EA864(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); BOOL ov01_021EA854(u32 a0); -void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); -void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); -void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); -void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EBD70(SysTask *task, void *data); void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList *linkedList); @@ -99,7 +101,6 @@ void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1); void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1); void ov01_021EC114(WeatherSystem *weatherSystem, u16 a1); -BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0); void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 2324e91260..ba6561693a 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -745,3 +745,45 @@ BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { return TRUE; } + +BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0) { + if (a0->unk0 != 0xFFFF) { + if (a0->unkC != NULL) { + return TRUE; + } + a0->unkC = Heap_Alloc(HEAP_ID_FIELD1, sizeof(UnkWeatherStruct_021EB968)); + if (a0->unkC == NULL) { + return FALSE; + } + memset(a0->unkC, 0, sizeof(UnkWeatherStruct_021EB968)); + } + return TRUE; +} + +void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2) { + if (a1 != 0xFFFF) { + a2->charResObj[2] = ov01_021EB898(weatherSystem->weatherDraw.header, 2, a1, weatherSystem->weatherDraw.resMan[2], weatherSystem->narc, 0); + } +} + +void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2) { + if (a1 != 0xFFFF) { + a2->charResObj[3] = ov01_021EB898(weatherSystem->weatherDraw.header, 3, a1, weatherSystem->weatherDraw.resMan[3], weatherSystem->narc, 0); + } +} + +void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2) { + if (a1 != 0xFFFF) { + a2->charResObj[0] = ov01_021EB898(weatherSystem->weatherDraw.header, 0, a1, weatherSystem->weatherDraw.resMan[0], weatherSystem->narc, 1); + sub_0200ADA4(a2->charResObj[0]); + sub_0200A740(a2->charResObj[0]); + } +} + +void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2) { + if (a1 != 0xFFFF) { + a2->charResObj[1] = ov01_021EB898(weatherSystem->weatherDraw.header, 1, a1, weatherSystem->weatherDraw.resMan[1], weatherSystem->narc, 1); + sub_0200B00C(a2->charResObj[1]); + sub_0200A740(a2->charResObj[1]); + } +} From c933e55a1c3283af2213897cc912f14d9902208d Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 1 Jun 2026 20:29:30 -0400 Subject: [PATCH 10/22] To ov01_021EC0C0 --- asm/overlay_01_021EB1E8.s | 175 -------------------------------- include/field/weather_manager.h | 28 ++++- src/field/weather_manager.c | 58 ++++++++++- 3 files changed, 78 insertions(+), 183 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 4534220fc9..2594915ec2 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -27,181 +27,6 @@ .public ov01_021EB9A8 .public ov01_021EBCA4 - thumb_func_start ov01_021EBFD0 -ov01_021EBFD0: ; 0x021EBFD0 - push {r3, r4, r5, lr} - add r4, r1, #0 - ldrh r1, [r4] - add r5, r0, #0 - ldr r0, _021EC024 ; =0x0000FFFF - cmp r1, r0 - beq _021EC022 - ldr r2, [r4, #0xc] - mov r0, #1 - str r0, [sp] - add r0, r2, #0 - add r0, #0x40 - add r1, r5, #0 - mov r3, #0 - bl ov01_021EC240 - ldr r0, [r4, #0xc] - mov r1, #0 - add r0, #0x10 - mov r2, #0x30 - bl memset - add r5, #0xfc - ldr r1, [r5] - ldr r0, [r4, #0xc] - str r1, [r0, #0x10] - ldr r1, [r4, #0xc] - add r0, r1, #0 - add r0, #0x40 - str r0, [r1, #0x14] - mov r1, #1 - ldr r0, [r4, #0xc] - lsl r1, r1, #0xc - str r1, [r0, #0x24] - ldr r0, [r4, #0xc] - str r1, [r0, #0x28] - ldr r0, [r4, #0xc] - str r1, [r0, #0x2c] - ldr r0, [r4, #0xc] - mov r1, #1 - str r1, [r0, #0x38] -_021EC022: - pop {r3, r4, r5, pc} - .balign 4, 0 -_021EC024: .word 0x0000FFFF - thumb_func_end ov01_021EBFD0 - - thumb_func_start ov01_021EC028 -ov01_021EC028: ; 0x021EC028 - push {r3, r4, r5, r6, r7, lr} - add r6, r0, #0 - mov r4, #0 - add r5, r6, #0 - add r7, r4, #0 -_021EC032: - ldr r0, [r6, #8] - add r0, #0x10 - bl Sprite_CreateAffine - str r0, [r5, #0x4c] - add r1, r7, #0 - bl Sprite_SetDrawFlag - ldr r0, [r5, #0x4c] - cmp r0, #0 - bne _021EC04C - bl GF_AssertFail -_021EC04C: - add r4, r4, #1 - add r5, #0x3c - cmp r4, #0x40 - blt _021EC032 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov01_021EC028 - - thumb_func_start ov01_021EC058 -ov01_021EC058: ; 0x021EC058 - push {r4, r5, r6, lr} - mov r4, #0 - add r5, r0, #0 - add r6, r4, #0 -_021EC060: - ldr r0, [r5, #0x4c] - cmp r0, #0 - beq _021EC06C - bl Sprite_Delete - str r6, [r5, #0x4c] -_021EC06C: - add r4, r4, #1 - add r5, #0x3c - cmp r4, #0x40 - blt _021EC060 - pop {r4, r5, r6, pc} - .balign 4, 0 - thumb_func_end ov01_021EC058 - - thumb_func_start ov01_021EC078 -ov01_021EC078: ; 0x021EC078 - push {r3, lr} - sub sp, #0x18 - add r2, r0, #0 - ldr r0, _021EC0BC ; =0x0000FFFF - cmp r1, r0 - beq _021EC0B8 - mov r0, #0x42 - lsl r0, r0, #2 - ldr r0, [r2, r0] - ldr r3, [r2, #4] - mov r2, #0xc - mul r2, r1 - ldr r1, [r3, r2] - mov r2, #4 - bl NARC_AllocAndReadWholeMember - add r1, sp, #0x14 - str r0, [sp] - bl NNS_G2dGetUnpackedPaletteData - ldr r1, [sp, #0x14] - mov r0, #2 - ldr r1, [r1, #0xc] - mov r2, #0x20 - mov r3, #0xc0 - bl BG_LoadPlttData - ldr r0, [sp] - bl Heap_Free - mov r0, #0 - str r0, [sp] -_021EC0B8: - add sp, #0x18 - pop {r3, pc} - .balign 4, 0 -_021EC0BC: .word 0x0000FFFF - thumb_func_end ov01_021EC078 - - thumb_func_start ov01_021EC0C0 -ov01_021EC0C0: ; 0x021EC0C0 - push {r3, r4, lr} - sub sp, #0x1c - add r4, r0, #0 - ldr r0, _021EC110 ; =0x0000FFFF - cmp r1, r0 - beq _021EC10C - mov r2, #0xc - mov r0, #0x42 - lsl r0, r0, #2 - ldr r3, [r4, #4] - mul r2, r1 - add r1, r3, r2 - ldr r0, [r4, r0] - ldr r1, [r1, #4] - mov r2, #4 - bl NARC_AllocAndReadWholeMember - add r1, sp, #0x14 - str r0, [sp, #8] - bl NNS_G2dGetUnpackedCharacterData - ldr r3, [sp, #0x14] - mov r0, #0 - str r0, [sp] - mov r0, #0x41 - lsl r0, r0, #2 - ldr r0, [r4, r0] - ldr r2, [r3, #0x14] - ldr r0, [r0, #8] - ldr r3, [r3, #0x10] - mov r1, #2 - bl BG_LoadCharTilesData - ldr r0, [sp, #8] - bl Heap_Free - mov r0, #0 - str r0, [sp, #8] -_021EC10C: - add sp, #0x1c - pop {r3, r4, pc} - .balign 4, 0 -_021EC110: .word 0x0000FFFF - thumb_func_end ov01_021EC0C0 - thumb_func_start ov01_021EC114 ov01_021EC114: ; 0x021EC114 push {r4, r5, lr} diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index f758c104e9..9b6cdb847e 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -3,12 +3,20 @@ #include "global.h" #include "task.h" +#include "sprite.h" typedef struct UnkWeatherStruct_021EB968 { SpriteResource *charResObj[4]; - u8 unk10[0x54]; + SpriteTemplate unk10; + const SpriteResourcesHeader unk40; } UnkWeatherStruct_021EB968; +typedef struct WeatherSystem_Sub4 { + u32 unk0; + u32 unk4; + u32 unk8; +} WeatherSystem_Sub4; + typedef struct WeatherDraw { GF_2DGfxResMan *resMan[4]; GF_2DGfxResHeader *header; @@ -18,6 +26,15 @@ typedef struct WeatherDraw { SysTask *task; } WeatherDraw; +typedef struct UnkWeatherStruct_021EC078 { + void *unk0; + void *unk4; + void *unk8; + u32 unkC; + NNSG2dCharacterData *unk10; + NNSG2dPaletteData *unk14; +} UnkWeatherStruct_021EC078; + typedef struct WeatherSystem WeatherSystem; typedef struct WeatherSystem_Sub0 WeatherSystem_Sub0; typedef struct WeatherSystem_Sub0_Sub8 WeatherSystem_Sub0_Sub8; @@ -85,6 +102,10 @@ void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB9 void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); +void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); +void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1); +void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -93,14 +114,11 @@ void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); void ov01_021EA864(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); BOOL ov01_021EA854(u32 a0); -void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EBD70(SysTask *task, void *data); void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList *linkedList); void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); -void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1); -void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1); void ov01_021EC114(WeatherSystem *weatherSystem, u16 a1); -void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +void ov01_021EC240(const SpriteResourcesHeader *spriteTemplate, WeatherSystem *weatherSystem, UnkWeatherStruct_021EB968 *a2, u32 a3, u32 a4); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index ba6561693a..c92a077783 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -11,7 +11,7 @@ struct WeatherSystem_Sub0_Sub8_LinkedList { u32 unk0; - u32 unk4; + Sprite *unk4; u32 unk8; u32 unk10[10]; WeatherSystem_Sub0_Sub8_LinkedList *next; @@ -50,7 +50,7 @@ struct WeatherSystem_Sub0 { struct WeatherSystem { WeatherSystem_Sub0 *unk0; - u32 *unk4; + WeatherSystem_Sub4 *unk4; WeatherDraw weatherDraw; FieldSystem *fieldSystem; NARC *narc; @@ -290,7 +290,7 @@ void ov01_021EB5F4(Sprite *sprite, VecFx32* matrix) { } extern WeatherSystem_Sub0 ov01_022098B0[]; -extern u32 ov01_0220675C[]; +extern WeatherSystem_Sub4 ov01_0220675C[]; WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem) { WeatherSystem *v0 = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSystem)); @@ -787,3 +787,55 @@ void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB9 sub_0200A740(a2->charResObj[1]); } } + +void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { + if (a1->unk0 != 0xFFFF) { + ov01_021EC240(&a1->unkC->unk40, weatherSystem, a1->unkC, 0, 1); + memset(&a1->unkC->unk10, 0, sizeof(SpriteTemplate)); + a1->unkC->unk10.spriteList = weatherSystem->weatherDraw.spriteList; + a1->unkC->unk10.header = &a1->unkC->unk40; + a1->unkC->unk10.scale.x = 1 << 12; + a1->unkC->unk10.scale.y = 1 << 12; + a1->unkC->unk10.scale.z = 1 << 12; + a1->unkC->unk10.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN; + } +} + +void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0) { + for (int i = 0; i < 64; i++) { + a0->linkedList[i].unk4 = Sprite_CreateAffine(&a0->unk8->unk10); + Sprite_SetDrawFlag(a0->linkedList[i].unk4, 0); + GF_ASSERT(a0->linkedList[i].unk4); + } +} + +void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0) { + for (int i = 0; i < 64; i++) { + if (a0->linkedList[i].unk4) { + Sprite_Delete(a0->linkedList[i].unk4); + a0->linkedList[i].unk4 = NULL; + } + } +} + +void ov01_021EC078(WeatherSystem* weatherSystem, u16 a1) { + UnkWeatherStruct_021EC078 v0; + if (a1 != 0xFFFF) { + v0.unk0 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].unk0, HEAP_ID_FIELD1); + NNS_G2dGetUnpackedPaletteData(v0.unk0, &v0.unk14); + BG_LoadPlttData(2, v0.unk14->pRawData, 32, 0xc0); + Heap_Free(v0.unk0); + v0.unk0 = NULL; + } +} + +void ov01_021EC0C0(WeatherSystem* weatherSystem, u16 a1) { + UnkWeatherStruct_021EC078 v0; + if (a1 != 0xFFFF) { + v0.unk4 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].unk4, HEAP_ID_FIELD1); + NNS_G2dGetUnpackedCharacterData(v0.unk4, &v0.unk10); + BG_LoadCharTilesData(weatherSystem->fieldSystem->bgConfig, 2, v0.unk10->pRawData, v0.unk10->szByte, 0); + Heap_Free(v0.unk4); + v0.unk4 = NULL; + } +} From b5ffa87c96a57a5c267a35dcaa8c4ba8d050ed24 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 1 Jun 2026 22:10:02 -0400 Subject: [PATCH 11/22] To ov01_021EC240 I wonder if the frequency and in-progress-ness of these commits screw with LLMs enough to ward them off from the project. --- asm/overlay_01_021EB1E8.s | 211 +------------------------------- include/field/weather_manager.h | 20 ++- src/field/weather_manager.c | 69 +++++++++-- 3 files changed, 80 insertions(+), 220 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 2594915ec2..3d7d70fa12 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -26,213 +26,10 @@ .public ov01_021EB968 .public ov01_021EB9A8 .public ov01_021EBCA4 - - thumb_func_start ov01_021EC114 -ov01_021EC114: ; 0x021EC114 - push {r4, r5, lr} - sub sp, #0x24 - add r4, r0, #0 - ldr r0, _021EC1B8 ; =0x0000FFFF - add r5, r1, #0 - cmp r5, r0 - beq _021EC1B4 - mov r0, #4 - mov r1, #0 - bl GfGfx_EngineATogglePlanes - mov r1, #0xc - mov r0, #0x42 - lsl r0, r0, #2 - ldr r2, [r4, #4] - mul r1, r5 - add r1, r2, r1 - ldr r0, [r4, r0] - ldr r1, [r1, #8] - mov r2, #4 - bl NARC_AllocAndReadWholeMember - str r0, [sp, #0x14] - cmp r0, #0 - bne _021EC14A - bl GF_AssertFail -_021EC14A: - ldr r0, [sp, #0x14] - add r1, sp, #0x18 - bl NNS_G2dGetUnpackedScreenData - ldr r3, [sp, #0x18] - mov r0, #0 - str r0, [sp] - add r2, r3, #0 - mov r0, #0x41 - lsl r0, r0, #2 - ldr r0, [r4, r0] - ldr r3, [r3, #8] - ldr r0, [r0, #8] - mov r1, #2 - add r2, #0xc - bl BgCopyOrUncompressTilemapBufferRangeToVram - mov r0, #0x41 - lsl r0, r0, #2 - ldr r3, [sp, #0x18] - ldr r0, [r4, r0] - add r2, r3, #0 - ldr r0, [r0, #8] - ldr r3, [r3, #8] - mov r1, #2 - add r2, #0xc - bl BG_LoadScreenTilemapData - mov r0, #0x20 - str r0, [sp] - str r0, [sp, #4] - mov r0, #6 - str r0, [sp, #8] - add r0, #0xfe - ldr r0, [r4, r0] - mov r2, #0 - ldr r0, [r0, #8] - mov r1, #2 - add r3, r2, #0 - bl BgTilemapRectChangePalette - mov r0, #0x41 - lsl r0, r0, #2 - ldr r0, [r4, r0] - mov r1, #2 - ldr r0, [r0, #8] - bl BgCommitTilemapBufferToVram - ldr r0, [sp, #0x14] - bl Heap_Free - mov r0, #0 - str r0, [sp, #0x14] -_021EC1B4: - add sp, #0x24 - pop {r4, r5, pc} - .balign 4, 0 -_021EC1B8: .word 0x0000FFFF - thumb_func_end ov01_021EC114 - - thumb_func_start ov01_021EC1BC -ov01_021EC1BC: ; 0x021EC1BC - push {r3, r4, r5, lr} - add r5, r0, #0 - ldr r0, [r5, #8] - add r4, r1, #0 - cmp r0, #0 - beq _021EC1CC - bl GF_AssertFail -_021EC1CC: - cmp r4, #0 - bgt _021EC1D4 - bl GF_AssertFail -_021EC1D4: - cmp r4, #0x28 - bls _021EC1DC - bl GF_AssertFail -_021EC1DC: - add r0, r5, #0 - add r0, #0xc - str r0, [r5, #8] - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EC1BC - - thumb_func_start ov01_021EC1E4 -ov01_021EC1E4: ; 0x021EC1E4 - ldr r3, _021EC1F0 ; =memset - mov r1, #0 - str r1, [r0, #8] - add r0, #0xc - mov r2, #0x28 - bx r3 - .balign 4, 0 -_021EC1F0: .word memset - thumb_func_end ov01_021EC1E4 - - thumb_func_start ov01_021EC1F4 -ov01_021EC1F4: ; 0x021EC1F4 - push {r3, r4, r5, r6, r7, lr} - add r5, r0, #0 - add r7, r1, #0 - ldr r6, [r5] - bl ov01_021EC8D8 - add r4, r0, #0 - bne _021EC208 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_021EC208: - add r1, r5, #0 - str r6, [r4] - add r1, #0xc - str r1, [r4, #0x34] - ldr r1, [r5, #0x44] - str r1, [r4, #0x38] - ldr r1, [r5, #0x44] - str r4, [r1, #0x34] - str r4, [r5, #0x44] - add r1, r7, #0 - bl ov01_021EC1BC - ldr r0, [r4, #8] - cmp r0, #0 - bne _021EC22A - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_021EC22A: - ldr r0, [r4, #4] - cmp r0, #0 - bne _021EC234 - bl GF_AssertFail -_021EC234: - ldr r0, [r4, #4] - mov r1, #1 - bl Sprite_SetDrawFlag - add r0, r4, #0 - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end ov01_021EC1F4 - - thumb_func_start ov01_021EC240 -ov01_021EC240: ; 0x021EC240 - push {r4, r5, r6, r7, lr} - sub sp, #0x44 - str r0, [sp, #0x2c] - add r7, r1, #0 - add r5, r2, #0 - str r3, [sp, #0x30] - mov r6, #0 - add r4, sp, #0x34 -_021EC250: - ldr r0, [r5] - bl GF2DGfxResObj_GetResID - add r6, r6, #1 - add r5, r5, #4 - stmia r4!, {r0} - cmp r6, #4 - blt _021EC250 - ldr r0, [sp, #0x40] - str r0, [sp] - mov r0, #0 - mvn r0, r0 - str r0, [sp, #4] - str r0, [sp, #8] - ldr r0, [sp, #0x30] - str r0, [sp, #0xc] - ldr r0, [sp, #0x58] - str r0, [sp, #0x10] - ldr r0, [r7, #8] - str r0, [sp, #0x14] - ldr r0, [r7, #0xc] - str r0, [sp, #0x18] - ldr r0, [r7, #0x10] - str r0, [sp, #0x1c] - ldr r0, [r7, #0x14] - str r0, [sp, #0x20] - mov r0, #0 - str r0, [sp, #0x24] - str r0, [sp, #0x28] - ldr r0, [sp, #0x2c] - ldr r1, [sp, #0x34] - ldr r2, [sp, #0x38] - ldr r3, [sp, #0x3c] - bl CreateSpriteResourcesHeader - add sp, #0x44 - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov01_021EC240 + .public ov01_021EC1BC + .public ov01_021EC1E4 + .public ov01_021EC1F4 + thumb_func_start ov01_021EC29C ov01_021EC29C: ; 0x021EC29C diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 9b6cdb847e..d9700f02fb 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -8,7 +8,7 @@ typedef struct UnkWeatherStruct_021EB968 { SpriteResource *charResObj[4]; SpriteTemplate unk10; - const SpriteResourcesHeader unk40; + SpriteResourcesHeader unk40; } UnkWeatherStruct_021EB968; typedef struct WeatherSystem_Sub4 { @@ -30,7 +30,7 @@ typedef struct UnkWeatherStruct_021EC078 { void *unk0; void *unk4; void *unk8; - u32 unkC; + NNSG2dScreenData *unkC; NNSG2dCharacterData *unk10; NNSG2dPaletteData *unk14; } UnkWeatherStruct_021EC078; @@ -39,6 +39,14 @@ typedef struct WeatherSystem WeatherSystem; typedef struct WeatherSystem_Sub0 WeatherSystem_Sub0; typedef struct WeatherSystem_Sub0_Sub8 WeatherSystem_Sub0_Sub8; typedef struct WeatherSystem_Sub0_Sub8_LinkedList WeatherSystem_Sub0_Sub8_LinkedList; +struct WeatherSystem_Sub0_Sub8_LinkedList { + WeatherSystem *weatherSystem; + Sprite *unk4; + u32 *unk8; + u32 unk10[10]; + WeatherSystem_Sub0_Sub8_LinkedList *next; + WeatherSystem_Sub0_Sub8_LinkedList *prev; +}; typedef struct UnkStruct_ov01_021EB1E8 { u8 unk0[0x188]; @@ -106,6 +114,10 @@ void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1); void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1); +void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1); +void ov01_021EC1BC(WeatherSystem_Sub0_Sub8_LinkedList* a0, int a1); +void ov01_021EC1E4(WeatherSystem_Sub0_Sub8_LinkedList* a0); +void ov01_021EC240(SpriteResourcesHeader *spriteTemplate, WeatherSystem *weatherSystem, UnkWeatherStruct_021EB968 *a2, u32 a3, u32 a4); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -118,7 +130,7 @@ void ov01_021EBD70(SysTask *task, void *data); void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList *linkedList); void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); -void ov01_021EC114(WeatherSystem *weatherSystem, u16 a1); -void ov01_021EC240(const SpriteResourcesHeader *spriteTemplate, WeatherSystem *weatherSystem, UnkWeatherStruct_021EB968 *a2, u32 a3, u32 a4); +void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1); +WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index c92a077783..50d9138881 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -9,15 +9,6 @@ #include "unk_02005D10.h" #include "unk_0200ACF0.h" -struct WeatherSystem_Sub0_Sub8_LinkedList { - u32 unk0; - Sprite *unk4; - u32 unk8; - u32 unk10[10]; - WeatherSystem_Sub0_Sub8_LinkedList *next; - WeatherSystem_Sub0_Sub8_LinkedList *prev; -}; - struct WeatherSystem_Sub0_Sub8 { WeatherSystem *weatherSystem; WeatherSystem_Sub0 *unk4; @@ -839,3 +830,63 @@ void ov01_021EC0C0(WeatherSystem* weatherSystem, u16 a1) { v0.unk4 = NULL; } } + +void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1) { + UnkWeatherStruct_021EC078 v0; + if (a1 != 0xFFFF) { + GfGfx_EngineATogglePlanes(4, 0); + v0.unk8 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].unk8, HEAP_ID_FIELD1); + GF_ASSERT(v0.unk8); + NNS_G2dGetUnpackedScreenData(v0.unk8, &v0.unkC); + BgCopyOrUncompressTilemapBufferRangeToVram(weatherSystem->fieldSystem->bgConfig, 2, v0.unkC->rawData, v0.unkC->szByte, 0); + BG_LoadScreenTilemapData(weatherSystem->fieldSystem->bgConfig, 2, v0.unkC->rawData, v0.unkC->szByte); + BgTilemapRectChangePalette(weatherSystem->fieldSystem->bgConfig, 2, 0, 0, 32, 32, 6); + BgCommitTilemapBufferToVram(weatherSystem->fieldSystem->bgConfig, 2); + Heap_Free(v0.unk8); + v0.unk8 = NULL; + } +} + +void ov01_021EC1BC(WeatherSystem_Sub0_Sub8_LinkedList* a0, int a1) { + GF_ASSERT(a0->unk8 == 0); + GF_ASSERT(a1 > 0); + GF_ASSERT(a1 <= 0x28u); + a0->unk8 = a0->unk10; +} + +void ov01_021EC1E4(WeatherSystem_Sub0_Sub8_LinkedList* a0) { + a0->unk8 = NULL; + memset(a0->unk10, 0, 10 * sizeof(u32)); +} + +void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1) { + WeatherSystem *weatherSystem = a0->weatherSystem; + WeatherSystem_Sub0_Sub8_LinkedList *v0 = ov01_021EC8D8(a0); + if (v0 == NULL) { + return NULL; + } + v0->weatherSystem = weatherSystem; + v0->next = &a0->linkedListDummy; + v0->prev = a0->linkedListDummy.prev; + a0->linkedListDummy.prev->next = v0; + a0->linkedListDummy.prev = v0; + + ov01_021EC1BC(v0, a1); + if (v0->unk8 == NULL) { + return NULL; + } + + GF_ASSERT(v0->unk4); + Sprite_SetDrawFlag(v0->unk4, 1); + return v0; +} + +void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, UnkWeatherStruct_021EB968 *a2, u32 a3, u32 a4) { + int resID[4]; + + for (int i = 0; i < 4; i++) { + resID[i] = GF2DGfxResObj_GetResID(a2->charResObj[i]); + } + + CreateSpriteResourcesHeader(header, resID[0], resID[1], resID[2], resID[3], -1, -1, a3, a4, weatherSystem->weatherDraw.resMan[0], weatherSystem->weatherDraw.resMan[1], weatherSystem->weatherDraw.resMan[2], weatherSystem->weatherDraw.resMan[3], NULL, NULL); +} From c678e104ec842bc13459d10859822c36c8ed9b31 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 2 Jun 2026 18:15:48 -0400 Subject: [PATCH 12/22] To ov01_021EC304 --- asm/overlay_01_021EB1E8.s | 90 ++------------------------------- include/field/weather_manager.h | 8 ++- src/field/weather_manager.c | 43 ++++++++++++++++ 3 files changed, 55 insertions(+), 86 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 3d7d70fa12..ce33440005 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -29,91 +29,11 @@ .public ov01_021EC1BC .public ov01_021EC1E4 .public ov01_021EC1F4 - - - thumb_func_start ov01_021EC29C -ov01_021EC29C: ; 0x021EC29C - push {r3, r4, r5, lr} - add r4, r0, #0 - ldr r1, [r4, #0x34] - ldr r0, [r4, #0x38] - str r1, [r0, #0x34] - ldr r1, [r4, #0x38] - ldr r0, [r4, #0x34] - str r1, [r0, #0x38] - ldr r0, [r4, #4] - mov r1, #0 - bl Sprite_SetDrawFlag - add r0, r4, #0 - bl ov01_021EC1E4 - add r0, r4, #0 - mov r1, #0 - mov r2, #0x3c - ldr r5, [r4, #4] - bl memset - str r5, [r4, #4] - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end ov01_021EC29C - - thumb_func_start ov01_021EC2CC -ov01_021EC2CC: ; 0x021EC2CC - push {r3, r4, r5, lr} - add r5, r0, #0 - ldr r0, [r5, #0x34] - cmp r0, r5 - beq _021EC2E2 -_021EC2D6: - ldr r4, [r0, #0x34] - bl ov01_021EC29C - add r0, r4, #0 - cmp r4, r5 - bne _021EC2D6 -_021EC2E2: - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EC2CC - - thumb_func_start ov01_021EC2E4 -ov01_021EC2E4: ; 0x021EC2E4 - push {r4, r5, r6, lr} - add r5, r0, #0 - ldr r0, [r5, #0x34] - add r6, r1, #0 - ldr r4, [r0, #0x34] - cmp r0, r5 - beq _021EC2FC -_021EC2F2: - blx r6 - add r0, r4, #0 - ldr r4, [r4, #0x34] - cmp r0, r5 - bne _021EC2F2 -_021EC2FC: - pop {r4, r5, r6, pc} - .balign 4, 0 - thumb_func_end ov01_021EC2E4 - - thumb_func_start ov01_021EC300 -ov01_021EC300: ; 0x021EC300 - bx lr - .balign 4, 0 - thumb_func_end ov01_021EC300 - - thumb_func_start ov01_021EC304 -ov01_021EC304: ; 0x021EC304 - push {r4, lr} - add r4, r0, #0 - ldr r0, [r1, #4] - bl Sprite_GetMatrixPtr - add r2, r0, #0 - ldmia r2!, {r0, r1} - stmia r4!, {r0, r1} - ldr r0, [r2] - str r0, [r4] - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov01_021EC304 - + .public ov01_021EC29C + .public ov01_021EC2E4 + .public ov01_021EC300 + .public ov01_021EC304 + thumb_func_start ov01_021EC31C ov01_021EC31C: ; 0x021EC31C push {r4, r5, r6, r7, lr} diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index d9700f02fb..79cfcc187b 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -70,6 +70,8 @@ typedef struct UnkWeatherStruct_021EB830 { int unk10; } UnkWeatherStruct_021EB830; +typedef void (*UnkLinkedListFunc)(WeatherSystem_Sub0_Sub8_LinkedList *); + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); void WeatherManager_Delete(WeatherManager* weatherManager); @@ -118,6 +120,11 @@ void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1); void ov01_021EC1BC(WeatherSystem_Sub0_Sub8_LinkedList* a0, int a1); void ov01_021EC1E4(WeatherSystem_Sub0_Sub8_LinkedList* a0); void ov01_021EC240(SpriteResourcesHeader *spriteTemplate, WeatherSystem *weatherSystem, UnkWeatherStruct_021EB968 *a2, u32 a3, u32 a4); +void ov01_021EC29C(WeatherSystem_Sub0_Sub8_LinkedList* a0); +void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList * a0); +void ov01_021EC2E4(WeatherSystem_Sub0_Sub8_LinkedList *a0, UnkLinkedListFunc func); +void ov01_021EC300(void *data); +VecFx32 ov01_021EC304(WeatherSystem_Sub0_Sub8_LinkedList *a0); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -127,7 +134,6 @@ void ov01_021EA864(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); BOOL ov01_021EA854(u32 a0); void ov01_021EBD70(SysTask *task, void *data); -void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList *linkedList); void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1); diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 50d9138881..69d838c11c 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -890,3 +890,46 @@ void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, CreateSpriteResourcesHeader(header, resID[0], resID[1], resID[2], resID[3], -1, -1, a3, a4, weatherSystem->weatherDraw.resMan[0], weatherSystem->weatherDraw.resMan[1], weatherSystem->weatherDraw.resMan[2], weatherSystem->weatherDraw.resMan[3], NULL, NULL); } + +void ov01_021EC29C(WeatherSystem_Sub0_Sub8_LinkedList* a0) { + a0->prev->next = a0->next; + a0->next->prev = a0->prev; + + Sprite_SetDrawFlag(a0->unk4, 0); + ov01_021EC1E4(a0); + + Sprite *temp = a0->unk4; + memset(a0, 0, sizeof(WeatherSystem_Sub0_Sub8_LinkedList)); + a0->unk4 = temp; +} + +void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList * a0) { + WeatherSystem_Sub0_Sub8_LinkedList *cur = a0->next; + WeatherSystem_Sub0_Sub8_LinkedList *next; + + while (cur != a0) { + next = cur->next; + ov01_021EC29C(cur); + cur = next; + } +} + +void ov01_021EC2E4(WeatherSystem_Sub0_Sub8_LinkedList *a0, UnkLinkedListFunc func) { + WeatherSystem_Sub0_Sub8_LinkedList *cur = a0->next; + WeatherSystem_Sub0_Sub8_LinkedList *next = cur->next; + + while (cur != a0) { + func(cur); + cur = next; + next = cur->next; + + } +} + +void ov01_021EC300(void *data) { + +} + +VecFx32 ov01_021EC304(WeatherSystem_Sub0_Sub8_LinkedList *a0) { + return *Sprite_GetMatrixPtr(a0->unk4); +} From 9397031156764a8933e85903e9eae19220c0fa68 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Wed, 3 Jun 2026 04:28:33 -0400 Subject: [PATCH 13/22] To ov01_021EC52C --- asm/overlay_01_021EB1E8.s | 286 +------------------------------- include/field/weather_manager.h | 19 +++ include/unk_02020B8C.h | 1 + src/field/weather_manager.c | 117 +++++++++++++ 4 files changed, 141 insertions(+), 282 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index ce33440005..f931620ed1 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -33,288 +33,10 @@ .public ov01_021EC2E4 .public ov01_021EC300 .public ov01_021EC304 - - thumb_func_start ov01_021EC31C -ov01_021EC31C: ; 0x021EC31C - push {r4, r5, r6, r7, lr} - sub sp, #0x24 - ldr r3, _021EC45C ; =NNS_G3dGlb + 0x258 - add r5, r2, #0 - str r0, [sp, #4] - str r1, [sp, #8] - ldmia r3!, {r0, r1} - add r2, sp, #0x18 - stmia r2!, {r0, r1} - ldr r0, [r3] - str r0, [r2] - ldr r0, _021EC460 ; =0x00000F4C - ldr r2, [sp, #0x18] - ldr r1, [r5, r0] - add r0, #8 - sub r6, r2, r1 - ldr r1, [sp, #0x20] - ldr r0, [r5, r0] - sub r4, r1, r0 - mov r0, #1 - mov r1, #3 - lsl r0, r0, #0xe - lsl r1, r1, #0xc - bl FX_Div - add r7, r0, #0 - mov r0, #0x41 - ldr r1, [r5] - lsl r0, r0, #2 - ldr r0, [r1, r0] - ldr r0, [r0, #0x24] - bl Camera_GetPerspectiveAngle - str r0, [sp, #0xc] - mov r0, #0x41 - ldr r1, [r5] - lsl r0, r0, #2 - ldr r0, [r1, r0] - ldr r0, [r0, #0x24] - bl Camera_GetDistance - add r1, r0, #0 - add r0, sp, #0x10 - str r0, [sp] - ldr r0, [sp, #0xc] - add r2, r7, #0 - add r3, sp, #0x14 - bl sub_02020E10 - mov r1, #1 - ldr r0, [sp, #0x14] - lsl r1, r1, #0x14 - bl FX_Div - str r0, [sp, #0x14] - cmp r4, #0 - bgt _021EC398 - ldr r0, [sp, #0x10] - ldr r1, _021EC464 ; =0x000BE8D0 - bl FX_Div - b _021EC3A0 -_021EC398: - ldr r0, [sp, #0x10] - ldr r1, _021EC468 ; =0x000BE811 - bl FX_Div -_021EC3A0: - mov r7, #1 - lsl r7, r7, #0xc - str r0, [sp, #0x10] - cmp r6, #0 - bge _021EC3C8 - ldr r7, _021EC46C ; =0xFFFFF000 - asr r1, r6, #0x1f - add r0, r6, #0 - asr r3, r7, #0xc - add r2, r7, #0 - bl _ll_mul - mov r2, #2 - mov r3, #0 - lsl r2, r2, #0xa - add r2, r0, r2 - adc r1, r3 - lsl r0, r1, #0x14 - lsr r6, r2, #0xc - orr r6, r0 -_021EC3C8: - ldr r1, [sp, #0x14] - add r0, r6, #0 - bl FX_Div - add r6, r0, #0 - cmp r7, #0 - bge _021EC3F0 - asr r1, r6, #0x1f - asr r3, r7, #0x1f - add r2, r7, #0 - bl _ll_mul - mov r2, #2 - mov r3, #0 - lsl r2, r2, #0xa - add r2, r0, r2 - adc r1, r3 - lsl r0, r1, #0x14 - lsr r6, r2, #0xc - orr r6, r0 -_021EC3F0: - mov r7, #1 - lsl r7, r7, #0xc - cmp r4, #0 - bge _021EC416 - ldr r7, _021EC46C ; =0xFFFFF000 - asr r1, r4, #0x1f - add r0, r4, #0 - asr r3, r7, #0xc - add r2, r7, #0 - bl _ll_mul - mov r2, #2 - mov r3, #0 - lsl r2, r2, #0xa - add r2, r0, r2 - adc r1, r3 - lsl r0, r1, #0x14 - lsr r4, r2, #0xc - orr r4, r0 -_021EC416: - ldr r1, [sp, #0x10] - add r0, r4, #0 - bl FX_Div - add r3, r0, #0 - cmp r7, #0 - bge _021EC43E - asr r1, r3, #0x1f - asr r3, r7, #0x1f - add r2, r7, #0 - bl _ll_mul - mov r2, #2 - mov r3, #0 - lsl r2, r2, #0xa - add r2, r0, r2 - adc r1, r3 - lsl r0, r1, #0x14 - lsr r3, r2, #0xc - orr r3, r0 -_021EC43E: - add r0, r6, r3 - beq _021EC450 - ldr r0, _021EC460 ; =0x00000F4C - add r2, sp, #0x18 - add r4, r5, r0 - ldmia r2!, {r0, r1} - stmia r4!, {r0, r1} - ldr r0, [r2] - str r0, [r4] -_021EC450: - ldr r0, [sp, #4] - str r6, [r0] - ldr r0, [sp, #8] - str r3, [r0] - add sp, #0x24 - pop {r4, r5, r6, r7, pc} - .balign 4, 0 -_021EC45C: .word NNS_G3dGlb + 0x258 -_021EC460: .word 0x00000F4C -_021EC464: .word 0x000BE8D0 -_021EC468: .word 0x000BE811 -_021EC46C: .word 0xFFFFF000 - thumb_func_end ov01_021EC31C - - thumb_func_start ov01_021EC470 -ov01_021EC470: ; 0x021EC470 - push {r3, r4, r5, lr} - sub sp, #8 - add r5, r1, #0 - add r4, r2, #0 - add r1, sp, #4 - add r2, sp, #0 - bl ov01_021EC4A8 - cmp r5, #0 - beq _021EC494 - ldr r0, [sp, #4] - asr r1, r0, #0xc - str r1, [r5] - bpl _021EC494 - mov r0, #1 - lsl r0, r0, #0xc - add r0, r1, r0 - str r0, [r5] -_021EC494: - cmp r4, #0 - beq _021EC4A4 - ldr r0, [sp] - asr r0, r0, #0xc - str r0, [r4] - bpl _021EC4A4 - add r0, r0, #1 - str r0, [r4] -_021EC4A4: - add sp, #8 - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EC470 - - thumb_func_start ov01_021EC4A8 -ov01_021EC4A8: ; 0x021EC4A8 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x18 - add r5, r0, #0 - add r7, r1, #0 - str r2, [sp] - add r0, sp, #8 - add r1, sp, #4 - add r2, r5, #0 - bl ov01_021EC31C - ldr r4, [r5, #0x40] - add r5, #0xc - cmp r4, r5 - beq _021EC4EC - add r6, sp, #0xc -_021EC4C6: - add r0, r6, #0 - add r1, r4, #0 - bl ov01_021EC304 - ldr r1, [sp, #0xc] - ldr r0, [sp, #8] - sub r0, r1, r0 - str r0, [sp, #0xc] - ldr r1, [sp, #0x10] - ldr r0, [sp, #4] - sub r0, r1, r0 - str r0, [sp, #0x10] - ldr r0, [r4, #4] - add r1, r6, #0 - bl ov01_021EB5F4 - ldr r4, [r4, #0x34] - cmp r4, r5 - bne _021EC4C6 -_021EC4EC: - cmp r7, #0 - beq _021EC4F4 - ldr r0, [sp, #8] - str r0, [r7] -_021EC4F4: - ldr r0, [sp] - cmp r0, #0 - beq _021EC4FE - ldr r1, [sp, #4] - str r1, [r0] -_021EC4FE: - add sp, #0x18 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov01_021EC4A8 - - thumb_func_start ov01_021EC504 -ov01_021EC504: ; 0x021EC504 - str r1, [r0] - strh r2, [r0, #4] - mov r1, #0 - strh r1, [r0, #6] - strh r3, [r0, #8] - strh r1, [r0, #0xa] - ldr r1, [sp] - strh r1, [r0, #0xc] - ldr r1, [sp, #4] - strh r1, [r0, #0xe] - ldr r1, [sp, #8] - strh r1, [r0, #0x10] - ldr r1, [sp, #0xc] - strh r1, [r0, #0x12] - ldr r1, [sp, #0x10] - str r1, [r0, #0x14] - ldr r1, [sp, #0x14] - str r1, [r0, #0x18] - bx lr - .balign 4, 0 - thumb_func_end ov01_021EC504 - - thumb_func_start ov01_021EC52C -ov01_021EC52C: ; 0x021EC52C - strh r1, [r0, #0xc] - strh r2, [r0, #0xe] - ldr r1, [sp] - strh r3, [r0, #0x10] - str r1, [r0, #0x14] - bx lr - thumb_func_end ov01_021EC52C + .public ov01_021EC31C + .public ov01_021EC470 + .public ov01_021EC504 + .public ov01_021EC52C thumb_func_start ov01_021EC538 ov01_021EC538: ; 0x021EC538 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 79cfcc187b..3a78ff8e47 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -70,6 +70,20 @@ typedef struct UnkWeatherStruct_021EB830 { int unk10; } UnkWeatherStruct_021EB830; +typedef struct UnkStruct_021EC504 { + s32 unk0; + s16 unk4; + s16 unk6; + s16 unk8; + s16 unkA; + s16 unkC; + s16 unkE; + s16 unk10; + s16 unk12; + s32 unk14; + s32 unk18; +} UnkStruct_021EC504; + typedef void (*UnkLinkedListFunc)(WeatherSystem_Sub0_Sub8_LinkedList *); void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); @@ -125,6 +139,11 @@ void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList * a0); void ov01_021EC2E4(WeatherSystem_Sub0_Sub8_LinkedList *a0, UnkLinkedListFunc func); void ov01_021EC300(void *data); VecFx32 ov01_021EC304(WeatherSystem_Sub0_Sub8_LinkedList *a0); +void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0); +void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut); +void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y); +void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9); +void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); diff --git a/include/unk_02020B8C.h b/include/unk_02020B8C.h index 3fdddde457..a7d7a1ec58 100644 --- a/include/unk_02020B8C.h +++ b/include/unk_02020B8C.h @@ -3,5 +3,6 @@ fx32 GetDistanceFromPointToLine(VecFx32 *a, VecFx32 *near, VecFx32 *far); void sub_02020D2C(MtxFx33 *rotation, VecFx32 *a1); +void sub_02020E10(u16 perspectiveAngle, fx32 distance, fx32 aspect, fx32 *dx, fx32 *dy); #endif // POKEHEARTGOLD_UNK_02020B8C_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 69d838c11c..8a9db4b042 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -8,6 +8,7 @@ #include "field_system.h" #include "unk_02005D10.h" #include "unk_0200ACF0.h" +#include "unk_02020B8C.h" struct WeatherSystem_Sub0_Sub8 { WeatherSystem *weatherSystem; @@ -933,3 +934,119 @@ void ov01_021EC300(void *data) { VecFx32 ov01_021EC304(WeatherSystem_Sub0_Sub8_LinkedList *a0) { return *Sprite_GetMatrixPtr(a0->unk4); } + +void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0) { + VecFx32 cameraTarget = NNS_G3dGlb.camTarget; + fx32 xScale, zScale; + fx32 dx, dz; + fx32 xDist, zDist; + int v7; + fx32 aspect; + + xDist = (cameraTarget.x - a0->cameraTarget.x); + zDist = (cameraTarget.z - a0->cameraTarget.z); + + aspect = FX_Div(FX32_CONST(4), FX32_CONST(3)); + + sub_02020E10(Camera_GetPerspectiveAngle(a0->weatherSystem->fieldSystem->camera), Camera_GetDistance(a0->weatherSystem->fieldSystem->camera), aspect, &dx, &dz); + + dx = FX_Div(dx, 256*FX32_ONE); + + if (zDist <= 0) { + dz = FX_Div(dz, 0xbe8d0); + } else { + dz = FX_Div(dz, 0xbe811); + } + + v7 = FX32_ONE; + if (xDist < 0) { + v7 = -FX32_ONE; + xDist = FX_MUL(xDist, -FX32_ONE); + } + xScale = FX_Div(xDist, dx); + if (v7 < 0) { + xScale = FX_MUL(xScale, v7); + } + + v7 = FX32_ONE; + if (zDist < 0) { + v7 = -FX32_ONE; + zDist = FX_MUL(zDist, -FX32_ONE); + } + zScale = FX_Div(zDist, dz); + if (v7 < 0) { + zScale = FX_MUL(zScale, v7); + } + + if (xScale + zScale != 0) { + a0->cameraTarget = cameraTarget; + } + + *x = xScale; + *z = zScale; +} + +void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut) { + fx32 x, z; + ov01_021EC4A8(a0, &x, &z); + + if (xOut) { + *xOut = x >> FX32_SHIFT; + if (*xOut < 0) { + *xOut += FX32_ONE; + } + } + if (zOut) { + *zOut = z >> FX32_SHIFT; + if (*zOut < 0) { + *zOut += 1; + } + } +} + +void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y) { + WeatherSystem_Sub0_Sub8_LinkedList *cur; + fx32 xScale, yScale; + VecFx32 matrix; + ov01_021EC31C(&xScale, &yScale, a0); + + cur = a0->linkedListDummy.next; + while (cur != &a0->linkedListDummy) { + matrix = ov01_021EC304(cur); + + matrix.x -= xScale; + matrix.y -= yScale; + + ov01_021EB5F4(cur->unk4, &matrix); + + cur = cur->next; + } + + if (x != NULL) { + *x = xScale; + } + if (y != NULL) { + *y = yScale; + } +} + +void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9) { + arg0->unk0 = arg1; + arg0->unk4 = arg2; + arg0->unk6 = 0; + arg0->unk8 = arg3; + arg0->unkA = 0; + arg0->unkC = (s16) arg4; + arg0->unkE = (s16) arg5; + arg0->unk10 = (s16) arg6; + arg0->unk12 = (s16) arg7; + arg0->unk14 = arg8; + arg0->unk18 = arg9; +} + +void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4) { + arg0->unkC = arg1; + arg0->unkE = arg2; + arg0->unk10 = arg3; + arg0->unk14 = arg4; +} From c22881d9471181b381a90608e62e83f202c26e5d Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Wed, 3 Jun 2026 17:34:41 -0400 Subject: [PATCH 14/22] To ov01_021EC6A4 --- asm/overlay_01_021EB1E8.s | 274 +------------------------------- include/field/weather_manager.h | 28 +++- src/field/weather_manager.c | 112 ++++++++++++- 3 files changed, 140 insertions(+), 274 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index f931620ed1..90f8e39a4e 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -37,276 +37,10 @@ .public ov01_021EC470 .public ov01_021EC504 .public ov01_021EC52C - - thumb_func_start ov01_021EC538 -ov01_021EC538: ; 0x021EC538 - push {r3, r4, r5, lr} - add r5, r0, #0 - mov r0, #0x10 - ldrsh r0, [r5, r0] - mov r4, #0 - cmp r0, #0 - bne _021EC54C - mov r0, #1 - orr r4, r0 - b _021EC572 -_021EC54C: - bgt _021EC552 - mov r2, #1 - b _021EC554 -_021EC552: - add r2, r4, #0 -_021EC554: - mov r0, #0xe - ldrsh r1, [r5, r0] - mov r0, #8 - ldrsh r0, [r5, r0] - cmp r0, r1 - blt _021EC564 - cmp r2, #0 - beq _021EC56C -_021EC564: - cmp r0, r1 - bgt _021EC572 - cmp r2, #1 - bne _021EC572 -_021EC56C: - mov r0, #1 - orr r4, r0 - strh r1, [r5, #8] -_021EC572: - ldr r0, [r5, #0x14] - cmp r0, #0 - bne _021EC57E - mov r0, #2 - orr r4, r0 - b _021EC5A4 -_021EC57E: - bgt _021EC584 - mov r2, #1 - b _021EC586 -_021EC584: - mov r2, #0 -_021EC586: - mov r0, #0xc - ldrsh r1, [r5, r0] - mov r0, #4 - ldrsh r0, [r5, r0] - cmp r0, r1 - blt _021EC596 - cmp r2, #0 - beq _021EC59E -_021EC596: - cmp r0, r1 - bgt _021EC5A4 - cmp r2, #1 - bne _021EC5A4 -_021EC59E: - mov r0, #2 - orr r4, r0 - strh r1, [r5, #4] -_021EC5A4: - mov r0, #6 - ldrsh r1, [r5, r0] - sub r1, r1, #1 - strh r1, [r5, #6] - ldrsh r0, [r5, r0] - cmp r0, #0 - bgt _021EC5F8 - mov r1, #4 - ldrsh r1, [r5, r1] - ldr r0, [r5] - ldr r2, [r5, #0x18] - blx r2 - mov r0, #8 - ldrsh r1, [r5, r0] - strh r1, [r5, #6] - mov r1, #1 - tst r1, r4 - bne _021EC5D2 - ldrsh r1, [r5, r0] - mov r0, #0x10 - ldrsh r0, [r5, r0] - add r0, r1, r0 - strh r0, [r5, #8] -_021EC5D2: - mov r0, #2 - tst r0, r4 - bne _021EC5F8 - mov r0, #0xa - ldrsh r1, [r5, r0] - add r1, r1, #1 - strh r1, [r5, #0xa] - ldrsh r1, [r5, r0] - mov r0, #0x12 - ldrsh r0, [r5, r0] - cmp r1, r0 - blt _021EC5F8 - mov r0, #0 - strh r0, [r5, #0xa] - mov r0, #4 - ldrsh r1, [r5, r0] - ldr r0, [r5, #0x14] - add r0, r1, r0 - strh r0, [r5, #4] -_021EC5F8: - add r0, r4, #0 - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EC538 - - thumb_func_start ov01_021EC5FC -ov01_021EC5FC: ; 0x021EC5FC - push {r4, lr} - sub sp, #8 - add r4, r1, #0 - ldr r1, [sp, #0x1c] - str r2, [r4] - cmp r1, #0 - beq _021EC64C - cmp r1, #1 - bne _021EC630 - add r1, r3, #0 - add r3, sp, #0 - add r0, r2, #0 - ldrh r3, [r3, #0x14] - ldr r2, [sp, #0x10] - bl ov01_021EC678 - add r0, r4, #0 - bl ov01_021EC774 - ldr r1, [sp, #0x18] - add r0, r4, #0 - mov r2, #1 - bl ov01_021EC790 - add sp, #8 - pop {r4, pc} -_021EC630: - cmp r1, #2 - bne _021EC64C - add r1, sp, #0 - ldrh r1, [r1, #0x14] - ldr r4, [sp, #0x18] - str r1, [sp] - mov r1, #0x7f - mul r1, r4 - str r1, [sp, #4] - add r1, r2, #0 - add r2, r3, #0 - ldr r3, [sp, #0x10] - bl ov01_021EC6A4 -_021EC64C: - add sp, #8 - pop {r4, pc} - thumb_func_end ov01_021EC5FC - - thumb_func_start ov01_021EC650 -ov01_021EC650: ; 0x021EC650 - push {r4, lr} - mov r4, #1 - cmp r2, #0 - beq _021EC674 - cmp r2, #1 - bne _021EC666 - add r0, r1, #0 - bl ov01_021EC7AC - add r4, r0, #0 - b _021EC674 -_021EC666: - cmp r2, #2 - bne _021EC674 - bl ov01_021EC728 - cmp r0, #0 - bne _021EC674 - mov r4, #0 -_021EC674: - add r0, r4, #0 - pop {r4, pc} - thumb_func_end ov01_021EC650 - - thumb_func_start ov01_021EC678 -ov01_021EC678: ; 0x021EC678 - push {r3, r4, r5, lr} - sub sp, #8 - str r1, [sp] - mov r1, #0 - add r4, r3, #0 - str r2, [sp, #4] - mvn r1, r1 - mov r2, #1 - mov r3, #0 - add r5, r0, #0 - bl ov01_021EA864 - mov r1, #0 - add r0, r5, #0 - mvn r1, r1 - add r2, r4, #0 - mov r3, #0x1f - bl ov01_021EA89C - add sp, #8 - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end ov01_021EC678 - - thumb_func_start ov01_021EC6A4 -ov01_021EC6A4: ; 0x021EC6A4 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x10 - add r7, r1, #0 - add r5, r0, #0 - add r0, r7, #0 - str r2, [sp] - str r3, [sp, #4] - ldr r4, [sp, #0x2c] - bl ov01_021EA858 - str r0, [sp, #8] - add r0, r7, #0 - bl ov01_021EA85C - str r0, [sp, #0xc] - add r0, r7, #0 - bl ov01_021EA860 - add r6, r0, #0 - ldr r1, [sp, #0xc] - ldr r2, [sp, #4] - add r0, r5, #4 - add r3, r4, #0 - str r7, [r5] - bl ov01_021EB830 - add r0, sp, #0x18 - ldrh r7, [r0, #0x10] - add r0, r5, #0 - mov r2, #0x1f - add r1, r6, #0 - and r1, r2 - add r0, #0x18 - and r2, r7 - add r3, r4, #0 - bl ov01_021EB830 - add r0, r5, #0 - asr r1, r6, #5 - mov r3, #0x1f - asr r2, r7, #5 - add r0, #0x2c - and r1, r3 - and r2, r3 - add r3, r4, #0 - bl ov01_021EB830 - add r0, r5, #0 - asr r1, r6, #0xa - mov r2, #0x1f - asr r3, r7, #0xa - and r1, r2 - and r2, r3 - add r0, #0x40 - add r3, r4, #0 - bl ov01_021EB830 - add r5, #0x54 - ldr r1, [sp, #8] - ldr r2, [sp] - add r0, r5, #0 - add r3, r4, #0 - bl ov01_021EB830 - add sp, #0x10 - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end ov01_021EC6A4 + .public ov01_021EC538 + .public ov01_021EC5FC + .public ov01_021EC650 + .public ov01_021EC678 thumb_func_start ov01_021EC728 ov01_021EC728: ; 0x021EC728 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 3a78ff8e47..77dbdfcb0e 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -69,7 +69,7 @@ typedef struct UnkWeatherStruct_021EB830 { int unkC; int unk10; } UnkWeatherStruct_021EB830; - +typedef void (*UnkFunc_021EC504)(s32 a0, s32 a1); typedef struct UnkStruct_021EC504 { s32 unk0; s16 unk4; @@ -81,11 +81,20 @@ typedef struct UnkStruct_021EC504 { s16 unk10; s16 unk12; s32 unk14; - s32 unk18; + UnkFunc_021EC504 unk18; } UnkStruct_021EC504; typedef void (*UnkLinkedListFunc)(WeatherSystem_Sub0_Sub8_LinkedList *); +typedef struct UnkStruct_021EC5FC { + s32 unk0; + UnkWeatherStruct_021EB830 unk4; + UnkWeatherStruct_021EB830 unk18; + UnkWeatherStruct_021EB830 unk2C; + UnkWeatherStruct_021EB830 unk40; + UnkWeatherStruct_021EB830 unk54; +} UnkStruct_021EC5FC; + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); void WeatherManager_Delete(WeatherManager* weatherManager); @@ -142,8 +151,13 @@ VecFx32 ov01_021EC304(WeatherSystem_Sub0_Sub8_LinkedList *a0); void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0); void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut); void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y); -void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9); +void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkFunc_021EC504 arg9); void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4); +s32 ov01_021EC538(UnkStruct_021EC504* arg0); +void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, s32* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb arg5, s32 arg6, s32 arg7); +s32 ov01_021EC650(s32 arg0, s32 arg1, s32 arg2); +void ov01_021EC678(s32 arg0, s32 arg1, s32 arg2, GXRgb rgb); +void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, s32 a1, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -157,5 +171,13 @@ void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1); WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); +void ov01_021EC774(s32 *a0); +void ov01_021EC790(s32 *a0, s32 a1, BOOL a2); +s32 ov01_021EC7AC(s32 a0); +BOOL ov01_021EC728(s32 a0); +int ov01_021EA858(s32 a0); +int ov01_021EA85C(s32 a0); +GXRgb ov01_021EA860(s32 a0); +void ov01_021EA89C(s32 a0, s32 a1, GXRgb rgb, s32 a2); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 8a9db4b042..91390e1715 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -1030,7 +1030,7 @@ void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y) { } } -void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9) { +void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkFunc_021EC504 arg9) { arg0->unk0 = arg1; arg0->unk4 = arg2; arg0->unk6 = 0; @@ -1050,3 +1050,113 @@ void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 a arg0->unk10 = arg3; arg0->unk14 = arg4; } + +s32 ov01_021EC538(UnkStruct_021EC504* arg0) { + s16 temp_r0; + s16 temp_r0_2; + s16 temp_r0_4; + s16 temp_r1; + s16 temp_r1_2; + s32 temp_r0_3; + s32 var_r2; + s32 var_r2_2; + s32 var_r4; + + temp_r0 = arg0->unk10; + var_r4 = 0; + if (temp_r0 == 0) { + var_r4 |= 1; + } else { + if ((s32) temp_r0 <= 0) { + var_r2 = 1; + } else { + var_r2 = 0; + } + temp_r1 = arg0->unkE; + temp_r0_2 = arg0->unk8; + if ((((s32) temp_r0_2 >= (s32) temp_r1) && (var_r2 == 0)) || (((s32) temp_r0_2 <= (s32) temp_r1) && (var_r2 == 1))) { + var_r4 |= 1; + arg0->unk8 = temp_r1; + } + } + temp_r0_3 = arg0->unk14; + if (temp_r0_3 == 0) { + var_r4 |= 2; + } else { + if (temp_r0_3 <= 0) { + var_r2_2 = 1; + } else { + var_r2_2 = 0; + } + temp_r1_2 = arg0->unkC; + temp_r0_4 = arg0->unk4; + if ((((s32) temp_r0_4 >= (s32) temp_r1_2) && (var_r2_2 == 0)) || (((s32) temp_r0_4 <= (s32) temp_r1_2) && (var_r2_2 == 1))) { + var_r4 |= 2; + arg0->unk4 = temp_r1_2; + } + } + arg0->unk6 = (s16) (arg0->unk6 - 1); + if ((s32) arg0->unk6 <= 0) { + arg0->unk18(arg0->unk0, arg0->unk4); + arg0->unk6 = (s16) arg0->unk8; + if (!(1 & var_r4)) { + arg0->unk8 = (s16) (arg0->unk8 + arg0->unk10); + } + if (!(2 & var_r4)) { + arg0->unkA = (s16) (arg0->unkA + 1); + if ((s32) arg0->unkA >= (s32) arg0->unk12) { + arg0->unkA = 0; + arg0->unk4 = (s16) (arg0->unk4 + arg0->unk14); + } + } + } + return var_r4; +} + +void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, s32* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb rgb, s32 arg6, s32 arg7) { + *arg1 = arg2; + if (arg7 != 0) { + if (arg7 == 1) { + ov01_021EC678(arg2, arg3, arg4, rgb); + ov01_021EC774(arg1); + ov01_021EC790(arg1, arg6, 1); + } else if (arg7 == 2) { + ov01_021EC6A4(arg0, arg2, arg3, arg4, rgb, 0x7F * arg6); + } + } +} + +s32 ov01_021EC650(s32 arg0, s32 arg1, s32 arg2) { + s32 var_r4; + + var_r4 = 1; + if (arg2 != 0) { + if (arg2 == 1) { + var_r4 = ov01_021EC7AC(arg1); + } else if (arg2 == 2) { + if (ov01_021EC728(arg0) == 0) { + var_r4 = 0; + } + } + } + return var_r4; +} + +void ov01_021EC678(s32 arg0, s32 arg1, s32 arg2, GXRgb rgb) { + ov01_021EA864(arg0, -1, 1, 0, arg1, arg2); + ov01_021EA89C(arg0, -1, rgb, 0x1F); +} + +void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, s32 a1, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5) { + int v0 = ov01_021EA858(a1); + int v1 = ov01_021EA85C(a1); + GXRgb v2 = ov01_021EA860(a1); + + arg0->unk0 = a1; + + ov01_021EB830(&arg0->unk4, v1, arg3, arg5); + ov01_021EB830(&arg0->unk18, v2 & GX_RGB_R_MASK, rgb & GX_RGB_R_MASK, arg5); + ov01_021EB830(&arg0->unk2C, (v2 >> GX_RGB_G_SHIFT) & 0x1F, (rgb >> GX_RGB_G_SHIFT) & 0x1F, arg5); + ov01_021EB830(&arg0->unk40, (v2 >> GX_RGB_B_SHIFT) & 0x1F, (rgb >> GX_RGB_B_SHIFT) & 0x1F, arg5); + ov01_021EB830(&arg0->unk54, v0, arg2, arg5); +} From f382f65c9b5d3800ee5df76ea6d052a7930a02d6 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 4 Jun 2026 03:07:48 -0400 Subject: [PATCH 15/22] To ov01_021EC7C8 --- asm/overlay_01_021EB1E8.s | 112 ++------------------------------ include/field/weather_manager.h | 25 +++++-- src/field/weather_manager.c | 54 ++++++++++++++- 3 files changed, 74 insertions(+), 117 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 90f8e39a4e..140d3b0c71 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -41,115 +41,11 @@ .public ov01_021EC5FC .public ov01_021EC650 .public ov01_021EC678 + .public ov01_021EC790 + .public ov01_021EC7AC + .public ov01_021EC7C8 - thumb_func_start ov01_021EC728 -ov01_021EC728: ; 0x021EC728 - push {r4, r5, r6, lr} - add r5, r0, #0 - add r0, r5, #4 - bl ov01_021EB840 - add r4, r0, #0 - add r0, r5, #0 - add r0, #0x18 - bl ov01_021EB840 - add r0, r5, #0 - add r0, #0x2c - bl ov01_021EB840 - add r0, r5, #0 - add r0, #0x40 - bl ov01_021EB840 - add r0, r5, #0 - add r0, #0x54 - bl ov01_021EB840 - ldr r3, [r5, #0x40] - ldr r0, [r5] - lsl r6, r3, #0xa - ldr r1, [r5, #0x54] - ldr r2, [r5, #4] - ldr r3, [r5, #0x18] - ldr r5, [r5, #0x2c] - lsl r5, r5, #5 - orr r3, r5 - orr r3, r6 - lsl r3, r3, #0x10 - lsr r3, r3, #0x10 - bl ov01_021EC678 - add r0, r4, #0 - pop {r4, r5, r6, pc} - thumb_func_end ov01_021EC728 - - thumb_func_start ov01_021EC774 -ov01_021EC774: ; 0x021EC774 - mov r2, #0 - add r3, r0, #0 - add r1, r2, #0 -_021EC77A: - add r0, r3, r2 - add r2, r2, #1 - strb r1, [r0, #4] - cmp r2, #0x20 - blt _021EC77A - ldr r0, [r3] - add r1, r3, #4 - ldr r3, _021EC78C ; =ov01_021EA8C4 - bx r3 - .balign 4, 0 -_021EC78C: .word ov01_021EA8C4 - thumb_func_end ov01_021EC774 - - thumb_func_start ov01_021EC790 -ov01_021EC790: ; 0x021EC790 - mov r3, #0x7f - str r3, [r0, #0x24] - mov r3, #0 - str r3, [r0, #0x28] - strh r1, [r0, #0x2c] - cmp r2, #1 - bne _021EC7A4 - mov r1, #1 - strh r1, [r0, #0x2e] - bx lr -_021EC7A4: - sub r1, r3, #1 - strh r1, [r0, #0x2e] - bx lr - .balign 4, 0 - thumb_func_end ov01_021EC790 - - thumb_func_start ov01_021EC7AC -ov01_021EC7AC: ; 0x021EC7AC - push {r3, r4, r5, lr} - add r5, r0, #0 - bl ov01_021EC7E8 - add r4, r0, #0 - ldr r0, [r5, #0x28] - cmp r0, #0 - bne _021EC7C4 - ldr r0, [r5] - add r1, r5, #4 - bl ov01_021EA8C4 -_021EC7C4: - add r0, r4, #0 - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EC7AC - - thumb_func_start ov01_021EC7C8 -ov01_021EC7C8: ; 0x021EC7C8 - push {r4, lr} - add r4, r0, #0 - mov r2, #1 - str r2, [r4, #0x24] - mov r1, #0 - str r1, [r4, #0x28] - strh r1, [r4, #0x2c] - strh r2, [r4, #0x2e] - bl ov01_021EC828 - ldr r0, [r4] - add r1, r4, #4 - bl ov01_021EA8C4 - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov01_021EC7C8 + thumb_func_start ov01_021EC7E8 ov01_021EC7E8: ; 0x021EC7E8 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 77dbdfcb0e..fdaff9efc6 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -95,6 +95,15 @@ typedef struct UnkStruct_021EC5FC { UnkWeatherStruct_021EB830 unk54; } UnkStruct_021EC5FC; +typedef struct UnkStruct_021EC774 { + u32 unk0; + u8 unk4[0x20]; + s32 unk24; + s32 unk28; + s16 unk2C; + s16 unk2E; +} UnkStruct_021EC774; + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); void WeatherManager_Delete(WeatherManager* weatherManager); @@ -154,10 +163,15 @@ void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y); void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkFunc_021EC504 arg9); void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4); s32 ov01_021EC538(UnkStruct_021EC504* arg0); -void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, s32* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb arg5, s32 arg6, s32 arg7); -s32 ov01_021EC650(s32 arg0, s32 arg1, s32 arg2); +void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb arg5, s32 arg6, s32 arg7); +BOOL ov01_021EC650(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774 *arg1, s32 arg2); void ov01_021EC678(s32 arg0, s32 arg1, s32 arg2, GXRgb rgb); void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, s32 a1, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5); +BOOL ov01_021EC728(UnkStruct_021EC5FC *arg0); +void ov01_021EC774(UnkStruct_021EC774* a0); +void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2); +s32 ov01_021EC7AC(UnkStruct_021EC774* arg0); +void ov01_021EC7C8(UnkStruct_021EC774* arg0); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -171,13 +185,12 @@ void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1); WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); -void ov01_021EC774(s32 *a0); -void ov01_021EC790(s32 *a0, s32 a1, BOOL a2); -s32 ov01_021EC7AC(s32 a0); -BOOL ov01_021EC728(s32 a0); int ov01_021EA858(s32 a0); int ov01_021EA85C(s32 a0); GXRgb ov01_021EA860(s32 a0); void ov01_021EA89C(s32 a0, s32 a1, GXRgb rgb, s32 a2); +void ov01_021EA8C4(u32 unk0, u8 *unk4); +s32 ov01_021EC7E8(UnkStruct_021EC774 *arg0); +void ov01_021EC828(UnkStruct_021EC774 *arg0); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 91390e1715..df0aa1f397 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -1113,8 +1113,8 @@ s32 ov01_021EC538(UnkStruct_021EC504* arg0) { return var_r4; } -void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, s32* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb rgb, s32 arg6, s32 arg7) { - *arg1 = arg2; +void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb rgb, s32 arg6, s32 arg7) { + arg1->unk0 = arg2; if (arg7 != 0) { if (arg7 == 1) { ov01_021EC678(arg2, arg3, arg4, rgb); @@ -1126,7 +1126,7 @@ void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, s32* arg1, s32 arg2, s32 arg3, s32 } } -s32 ov01_021EC650(s32 arg0, s32 arg1, s32 arg2) { +BOOL ov01_021EC650(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774 *arg1, s32 arg2) { s32 var_r4; var_r4 = 1; @@ -1160,3 +1160,51 @@ void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, s32 a1, s32 arg2, s32 arg3, GXRgb r ov01_021EB830(&arg0->unk40, (v2 >> GX_RGB_B_SHIFT) & 0x1F, (rgb >> GX_RGB_B_SHIFT) & 0x1F, arg5); ov01_021EB830(&arg0->unk54, v0, arg2, arg5); } + +BOOL ov01_021EC728(UnkStruct_021EC5FC *arg0) { + BOOL ret = ov01_021EB840(&arg0->unk4); + ov01_021EB840(&arg0->unk18); + ov01_021EB840(&arg0->unk2C); + ov01_021EB840(&arg0->unk40); + ov01_021EB840(&arg0->unk54); + ov01_021EC678(arg0->unk0, arg0->unk54.unk0, arg0->unk4.unk0, GX_RGB(arg0->unk18.unk0, arg0->unk2C.unk0, arg0->unk40.unk0)); + + return ret; +} + +void ov01_021EC774(UnkStruct_021EC774* a0) { + for (int i = 0; i < 32; i++) { + a0->unk4[i] = 0; + } + ov01_021EA8C4(a0->unk0, a0->unk4); +} + +void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2) { + arg0->unk24 = 0x7F; + arg0->unk28 = 0; + arg0->unk2C = arg1; + if (arg2 == 1) { + arg0->unk2E = 1; + return; + } + arg0->unk2E = -1; +} + +s32 ov01_021EC7AC(UnkStruct_021EC774* arg0) { + s32 temp_r4; + + temp_r4 = ov01_021EC7E8(arg0); + if (arg0->unk28 == 0) { + ov01_021EA8C4(arg0->unk0, arg0->unk4); + } + return temp_r4; +} + +void ov01_021EC7C8(UnkStruct_021EC774* arg0) { + arg0->unk24 = 1; + arg0->unk28 = 0; + arg0->unk2C = 0; + arg0->unk2E = 1; + ov01_021EC828(arg0); + ov01_021EA8C4(arg0->unk0, arg0->unk4); +} From 0d05fc92dcd27f10a6b080263df689cc68b4e224 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sat, 6 Jun 2026 14:54:55 -0400 Subject: [PATCH 16/22] To ov01_021EC8F8 --- asm/overlay_01_021EB1E8.s | 219 +------------------------------- include/field/weather_manager.h | 9 +- src/field/weather_manager.c | 110 +++++++++++++++- 3 files changed, 117 insertions(+), 221 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 140d3b0c71..8be1f433d1 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -44,225 +44,10 @@ .public ov01_021EC790 .public ov01_021EC7AC .public ov01_021EC7C8 - + .public ov01_021EC85C + .public ov01_021EC8F8 - thumb_func_start ov01_021EC7E8 -ov01_021EC7E8: ; 0x021EC7E8 - push {r3, r4, r5, lr} - add r5, r0, #0 - mov r1, #0x2e - ldrsh r1, [r5, r1] - mov r4, #0 - cmp r1, #0 - bne _021EC7FA - mov r4, #1 - b _021EC824 -_021EC7FA: - ldr r1, [r5, #0x24] - cmp r1, #0 - bgt _021EC804 - mov r4, #1 - b _021EC824 -_021EC804: - ldr r1, [r5, #0x28] - add r2, r1, #1 - str r2, [r5, #0x28] - mov r1, #0x2c - ldrsh r1, [r5, r1] - cmp r2, r1 - blt _021EC824 - str r4, [r5, #0x28] - bl ov01_021EC828 - ldr r0, [r5, #0x24] - sub r0, r0, #1 - str r0, [r5, #0x24] - cmp r0, #0 - bgt _021EC824 - mov r4, #1 -_021EC824: - add r0, r4, #0 - pop {r3, r4, r5, pc} - thumb_func_end ov01_021EC7E8 - - thumb_func_start ov01_021EC828 -ov01_021EC828: ; 0x021EC828 - push {r3, r4} - mov r1, #0x2e - ldrsh r1, [r0, r1] - ldr r2, [r0, #0x24] - cmp r1, #0 - bge _021EC83A - mov r1, #0x7f - sub r2, r1, r2 - b _021EC83A -_021EC83A: - asr r1, r2, #1 - lsr r1, r1, #0x1e - add r1, r2, r1 - asr r4, r1, #2 - mov r3, #0x1f - cmp r4, #0x1f - bge _021EC856 -_021EC848: - sub r1, r3, r4 - lsl r2, r1, #2 - add r1, r0, r3 - sub r3, r3, #1 - strb r2, [r1, #4] - cmp r3, r4 - bgt _021EC848 -_021EC856: - pop {r3, r4} - bx lr - .balign 4, 0 - thumb_func_end ov01_021EC828 - - thumb_func_start ov01_021EC85C -ov01_021EC85C: ; 0x021EC85C - push {r4, r5, r6, r7, lr} - sub sp, #0x14 - add r4, r1, #0 - ldr r1, [sp, #0x28] - str r0, [sp] - str r1, [sp, #0x28] - add r1, r2, #0 - str r2, [sp, #4] - str r3, [sp, #8] - ldr r7, [sp, #0x2c] - blx r4 - ldr r0, [sp] - mov r6, #0 - ldr r5, [r0, #0x40] - str r6, [sp, #0x10] - ldr r0, [r5, #0x34] - str r0, [sp, #0xc] - ldr r0, [sp, #4] - cmp r0, #0 - ble _021EC8D2 - ldr r0, [sp] - add r0, #0xc - str r0, [sp] -_021EC88A: - ldr r0, [sp] - cmp r5, r0 - beq _021EC8D2 - mov r4, #0 - cmp r6, #0 - ble _021EC8A6 -_021EC896: - add r0, r5, #0 - blx r7 - ldr r0, [r5, #8] - cmp r0, #0 - beq _021EC8A6 - add r4, r4, #1 - cmp r4, r6 - blt _021EC896 -_021EC8A6: - ldr r5, [sp, #0xc] - ldr r1, [sp, #0x10] - add r0, r5, #0 - ldr r0, [r0, #0x34] - str r0, [sp, #0xc] - ldr r0, [sp, #8] - cmp r1, r0 - blt _021EC8C6 - add r0, r1, #0 - ldr r1, [sp, #8] - bl _s32_div_f - cmp r1, #0 - bne _021EC8C6 - ldr r0, [sp, #0x28] - add r6, r6, r0 -_021EC8C6: - ldr r0, [sp, #0x10] - add r1, r0, #1 - ldr r0, [sp, #4] - str r1, [sp, #0x10] - cmp r1, r0 - blt _021EC88A -_021EC8D2: - add sp, #0x14 - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov01_021EC85C - - thumb_func_start ov01_021EC8D8 -ov01_021EC8D8: ; 0x021EC8D8 - mov r2, #0 - add r3, r0, #0 -_021EC8DC: - ldr r1, [r3, #0x48] - cmp r1, #0 - bne _021EC8EC - mov r1, #0x3c - add r0, #0x48 - mul r1, r2 - add r0, r0, r1 - bx lr -_021EC8EC: - add r2, r2, #1 - add r3, #0x3c - cmp r2, #0x40 - blt _021EC8DC - mov r0, #0 - bx lr - thumb_func_end ov01_021EC8D8 - - thumb_func_start ov01_021EC8F8 -ov01_021EC8F8: ; 0x021EC8F8 - push {r3, lr} - ldr r0, _021EC948 ; =0x00000F62 - ldrh r2, [r1, r0] - cmp r2, #5 - bhi _021EC946 - add r2, r2, r2 - add r2, pc - ldrh r2, [r2, #6] - lsl r2, r2, #0x10 - asr r2, r2, #0x10 - add pc, r2 -_021EC90E: ; jump table - .short _021EC91A - _021EC90E - 2 ; case 0 - .short _021EC920 - _021EC90E - 2 ; case 1 - .short _021EC926 - _021EC90E - 2 ; case 2 - .short _021EC92C - _021EC90E - 2 ; case 3 - .short _021EC93A - _021EC90E - 2 ; case 4 - .short _021EC940 - _021EC90E - 2 ; case 5 -_021EC91A: - mov r2, #1 - strh r2, [r1, r0] - pop {r3, pc} -_021EC920: - mov r2, #3 - strh r2, [r1, r0] - pop {r3, pc} -_021EC926: - mov r2, #3 - strh r2, [r1, r0] - pop {r3, pc} -_021EC92C: - add r2, r0, #4 - ldrh r2, [r1, r2] - cmp r2, #5 - bne _021EC946 - mov r2, #4 - strh r2, [r1, r0] - pop {r3, pc} -_021EC93A: - mov r2, #5 - strh r2, [r1, r0] - pop {r3, pc} -_021EC940: - ldr r0, [r1, #4] - bl ov01_021EBCA4 -_021EC946: - pop {r3, pc} - .balign 4, 0 -_021EC948: .word 0x00000F62 - thumb_func_end ov01_021EC8F8 - thumb_func_start ov01_021EC94C ov01_021EC94C: ; 0x021EC94C push {r4, r5, r6, lr} diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index fdaff9efc6..0d351c8cbb 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -85,6 +85,7 @@ typedef struct UnkStruct_021EC504 { } UnkStruct_021EC504; typedef void (*UnkLinkedListFunc)(WeatherSystem_Sub0_Sub8_LinkedList *); +typedef void (*UnkWeatherSystemSub0Sub8Func)(WeatherSystem_Sub0_Sub8 *, int); typedef struct UnkStruct_021EC5FC { s32 unk0; @@ -172,6 +173,11 @@ void ov01_021EC774(UnkStruct_021EC774* a0); void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2); s32 ov01_021EC7AC(UnkStruct_021EC774* arg0); void ov01_021EC7C8(UnkStruct_021EC774* arg0); +s32 ov01_021EC7E8(UnkStruct_021EC774 *arg0); +void ov01_021EC828(UnkStruct_021EC774 *arg0); +void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int a2, int a3, int a4, UnkLinkedListFunc a5); +WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); +void ov01_021EC8F8(SysTask *task, void* data); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -184,13 +190,10 @@ void ov01_021EBD70(SysTask *task, void *data); void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1); -WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); int ov01_021EA858(s32 a0); int ov01_021EA85C(s32 a0); GXRgb ov01_021EA860(s32 a0); void ov01_021EA89C(s32 a0, s32 a1, GXRgb rgb, s32 a2); void ov01_021EA8C4(u32 unk0, u8 *unk4); -s32 ov01_021EC7E8(UnkStruct_021EC774 *arg0); -void ov01_021EC828(UnkStruct_021EC774 *arg0); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index df0aa1f397..e80a7ff0e5 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -923,7 +923,6 @@ void ov01_021EC2E4(WeatherSystem_Sub0_Sub8_LinkedList *a0, UnkLinkedListFunc fun func(cur); cur = next; next = cur->next; - } } @@ -1208,3 +1207,112 @@ void ov01_021EC7C8(UnkStruct_021EC774* arg0) { ov01_021EC828(arg0); ov01_021EA8C4(arg0->unk0, arg0->unk4); } + +s32 ov01_021EC7E8(UnkStruct_021EC774* arg0) { + s32 temp_r0; + s32 temp_r2; + s32 var_r4; + + var_r4 = 0; + if (arg0->unk2E == 0) { + var_r4 = 1; + } else if ((s32) arg0->unk24 <= 0) { + var_r4 = 1; + } else { + temp_r2 = arg0->unk28 + 1; + arg0->unk28 = temp_r2; + if (temp_r2 >= (s32) arg0->unk2C) { + arg0->unk28 = 0; + ov01_021EC828(arg0); + temp_r0 = arg0->unk24 - 1; + arg0->unk24 = temp_r0; + if (temp_r0 <= 0) { + var_r4 = 1; + } + } + } + return var_r4; +} + +void ov01_021EC828(UnkStruct_021EC774 *arg0) { + int i; + int v0; + int v1; + + if (arg0->unk2E < 0) { + v1 = 0x7F - arg0->unk24; + } else { + v1 = arg0->unk24; + } + + v0 = v1/4; + for (i = 31; i > v0; i--) { + arg0->unk4[i] = (i - v0)*4; + } +} + +void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int a2, int a3, int a4, UnkLinkedListFunc a5) { + a1(a0, a2); + + int i, j; + int v0 = 0; + WeatherSystem_Sub0_Sub8_LinkedList *cur = a0->linkedListDummy.next; + WeatherSystem_Sub0_Sub8_LinkedList *next = cur->next; + + for (i = 0; i < a2; i++) { + if (cur == &a0->linkedListDummy) { + break; + } + + for (j = 0; j < v0; j++) { + a5(cur); + + if (cur->unk8 == NULL) { + break; + } + } + + cur = next; + next = cur->next; + + if (i >= a3 && (i % a3) == 0) { + v0 += a4; + } + } +} + +WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 * a0) { + for (int i = 0; i < 64; i++) { + if (a0->linkedList[i].weatherSystem == NULL) { + return &a0->linkedList[i]; + } + } + return NULL; +} + +void ov01_021EC8F8(SysTask *task, void* data) { + WeatherSystem_Sub0_Sub8 *arg1 = data; + u16 temp_r2 = arg1->unkF62; + switch (temp_r2) { + case 0: + arg1->unkF62 = 1; + break; + case 1: + arg1->unkF62 = 3; + break; + case 2: + arg1->unkF62 = 3; + break; + case 3: + if (arg1->unkF66 == 5) { + arg1->unkF62 = 4; + } + break; + case 4: + arg1->unkF62 = 5; + break; + case 5: + ov01_021EBCA4(arg1->unk4); + break; + } +} From d447c3e1d865e0702b93d10851770c5d38b39b32 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 7 Jun 2026 19:28:59 -0400 Subject: [PATCH 17/22] To ov01_021ECF4C --- asm/overlay_01_021EB1E8.s | 908 +------------------------------- include/field/weather_manager.h | 23 +- src/field/weather_manager.c | 310 ++++++++++- 3 files changed, 332 insertions(+), 909 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 8be1f433d1..e1dfa62ff0 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -46,910 +46,11 @@ .public ov01_021EC7C8 .public ov01_021EC85C .public ov01_021EC8F8 + .public ov01_021EC94C + .public ov01_021ECD08 + .public ov01_021ECD08 - thumb_func_start ov01_021EC94C -ov01_021EC94C: ; 0x021EC94C - push {r4, r5, r6, lr} - sub sp, #0x18 - ldr r0, _021ECB8C ; =0x00000F58 - add r4, r1, #0 - add r2, r0, #0 - add r2, #0xa - ldrh r2, [r4, r2] - ldr r5, [r4, r0] - cmp r2, #5 - bhi _021ECA1A - add r2, r2, r2 - add r2, pc - ldrh r2, [r2, #6] - lsl r2, r2, #0x10 - asr r2, r2, #0x10 - add pc, r2 -_021EC96C: ; jump table - .short _021EC978 - _021EC96C - 2 ; case 0 - .short _021EC9E2 - _021EC96C - 2 ; case 1 - .short _021ECA24 - _021EC96C - 2 ; case 2 - .short _021ECA96 - _021EC96C - 2 ; case 3 - .short _021ECAF4 - _021EC96C - 2 ; case 4 - .short _021ECB42 - _021EC96C - 2 ; case 5 -_021EC978: - mov r0, #0x14 - str r0, [sp] - mov r2, #1 - str r2, [sp, #4] - sub r0, r2, #2 - str r0, [sp, #8] - str r2, [sp, #0xc] - mov r0, #2 - str r0, [sp, #0x10] - ldr r0, _021ECB90 ; =ov01_021ECBB4 - mov r3, #8 - str r0, [sp, #0x14] - add r0, r5, #0 - bl ov01_021EC504 - ldr r0, _021ECB94 ; =0x0000726F - mov r2, #0x41 - str r0, [sp] - ldr r0, _021ECB98 ; =0x00006B5A - lsl r2, r2, #2 - str r0, [sp, #4] - mov r0, #1 - str r0, [sp, #8] - ldr r0, _021ECB9C ; =0x00000F64 - add r1, r5, #0 - ldrh r0, [r4, r0] - add r1, #0x1c - str r0, [sp, #0xc] - ldr r3, [r4] - add r0, r5, #0 - ldr r2, [r3, r2] - add r0, #0x4c - ldr r2, [r2, #0x4c] - mov r3, #3 - bl ov01_021EC5FC - mov r0, #0 - add r5, #0xb4 - str r0, [r5] - ldr r0, _021ECBA0 ; =ov01_021EDA7C - add r1, r4, #0 - mov r2, #0x64 - bl SysTask_CreateOnMainQueue - ldr r1, _021ECBA4 ; =0x00000F6C - mov r2, #0x1e - str r0, [r4, r1] - sub r0, r1, #4 - str r2, [r4, r0] - mov r0, #1 - sub r1, #0xa - strh r0, [r4, r1] - b _021ECB60 -_021EC9E2: - add r0, r5, #0 - bl ov01_021EC538 - add r6, r0, #0 - add r0, r5, #0 - add r0, #0xb4 - ldr r0, [r0] - cmp r0, #0 - ble _021ECA02 - add r0, r5, #0 - add r0, #0xb4 - ldr r0, [r0] - add r5, #0xb4 - sub r0, r0, #1 - str r0, [r5] - b _021ECB60 -_021ECA02: - ldr r2, _021ECB9C ; =0x00000F64 - add r0, r5, #0 - ldrh r2, [r4, r2] - add r5, #0x1c - add r0, #0x4c - add r1, r5, #0 - bl ov01_021EC650 - cmp r0, #1 - bne _021ECA1A - cmp r6, #3 - beq _021ECA1C -_021ECA1A: - b _021ECB60 -_021ECA1C: - ldr r0, _021ECBA8 ; =0x00000F62 - mov r1, #3 - strh r1, [r4, r0] - b _021ECB60 -_021ECA24: - mov r2, #0x14 - mov r3, #1 - str r2, [sp] - str r3, [sp, #4] - sub r0, r3, #2 - str r0, [sp, #8] - str r3, [sp, #0xc] - mov r0, #2 - str r0, [sp, #0x10] - ldr r0, _021ECB90 ; =ov01_021ECBB4 - str r0, [sp, #0x14] - add r0, r5, #0 - bl ov01_021EC504 - ldr r0, _021ECB9C ; =0x00000F64 - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ECA66 - mov r0, #0x41 - ldr r1, [r4] - lsl r0, r0, #2 - ldr r0, [r1, r0] - ldr r2, _021ECB94 ; =0x0000726F - ldr r0, [r0, #0x4c] - ldr r3, _021ECB98 ; =0x00006B5A - mov r1, #3 - str r0, [r5, #0x1c] - bl ov01_021EC678 - add r5, #0x1c - add r0, r5, #0 - bl ov01_021EC7C8 -_021ECA66: - mov r0, #1 - str r0, [sp] - ldr r0, _021ECBAC ; =ov01_021ECC70 - ldr r1, _021ECB90 ; =ov01_021ECBB4 - str r0, [sp, #4] - add r0, r4, #0 - mov r2, #0x14 - mov r3, #0xa - bl ov01_021EC85C - ldr r0, _021ECBA0 ; =ov01_021EDA7C - add r1, r4, #0 - mov r2, #0x64 - bl SysTask_CreateOnMainQueue - ldr r1, _021ECBA4 ; =0x00000F6C - mov r2, #0x1e - str r0, [r4, r1] - sub r0, r1, #4 - str r2, [r4, r0] - mov r0, #3 - sub r1, #0xa - strh r0, [r4, r1] - b _021ECB60 -_021ECA96: - mov r0, #6 - ldrsh r1, [r5, r0] - sub r0, r1, #1 - strh r0, [r5, #6] - cmp r1, #0 - bgt _021ECAB2 - mov r1, #4 - ldrsh r1, [r5, r1] - add r0, r4, #0 - bl ov01_021ECBB4 - mov r0, #8 - ldrsh r0, [r5, r0] - strh r0, [r5, #6] -_021ECAB2: - ldr r0, _021ECBB0 ; =0x00000F66 - ldrh r0, [r4, r0] - cmp r0, #5 - bne _021ECB60 - mov r0, #1 - mvn r0, r0 - str r0, [sp] - add r0, r5, #0 - mov r1, #0 - mov r2, #8 - mov r3, #1 - bl ov01_021EC52C - ldr r0, _021ECB9C ; =0x00000F64 - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ECAE0 - add r0, r5, #0 - add r0, #0x1c - mov r1, #1 - mov r2, #0 - bl ov01_021EC790 -_021ECAE0: - mov r0, #0 - add r5, #0xb4 - str r0, [r5] - ldr r0, _021ECBA8 ; =0x00000F62 - mov r1, #4 - strh r1, [r4, r0] - add r0, r4, #0 - bl ov01_021EDAE0 - b _021ECB60 -_021ECAF4: - add r0, r5, #0 - bl ov01_021EC538 - add r6, r0, #0 - add r0, r5, #0 - add r0, #0xb4 - ldr r0, [r0] - cmp r0, #0 - ble _021ECB14 - add r0, r5, #0 - add r0, #0xb4 - ldr r0, [r0] - add r5, #0xb4 - sub r0, r0, #1 - str r0, [r5] - b _021ECB60 -_021ECB14: - ldr r0, _021ECB9C ; =0x00000F64 - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ECB26 - add r5, #0x1c - add r0, r5, #0 - bl ov01_021EC7AC - b _021ECB28 -_021ECB26: - mov r0, #1 -_021ECB28: - cmp r0, #1 - bne _021ECB60 - cmp r6, #3 - bne _021ECB60 - add r0, r4, #0 - ldr r1, [r4, #0x40] - add r0, #0xc - cmp r1, r0 - bne _021ECB60 - ldr r0, _021ECBA8 ; =0x00000F62 - mov r1, #5 - strh r1, [r4, r0] - b _021ECB60 -_021ECB42: - add r0, #0xc - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ECB5A - mov r2, #0 - str r2, [sp] - str r2, [sp, #4] - ldr r0, [r5, #0x1c] - mov r1, #1 - add r3, r2, #0 - bl ov01_021EA864 -_021ECB5A: - ldr r0, [r4, #4] - bl ov01_021EBCA4 -_021ECB60: - ldr r0, _021ECBA8 ; =0x00000F62 - ldrh r0, [r4, r0] - cmp r0, #5 - beq _021ECB86 - cmp r0, #0 - beq _021ECB86 - add r0, r4, #0 - ldr r1, _021ECBAC ; =ov01_021ECC70 - add r0, #0xc - bl ov01_021EC2E4 - mov r1, #0 - add r0, r4, #0 - add r2, r1, #0 - bl ov01_021EC470 - add r0, r4, #0 - bl ov01_021EC300 -_021ECB86: - add sp, #0x18 - pop {r4, r5, r6, pc} - nop -_021ECB8C: .word 0x00000F58 -_021ECB90: .word ov01_021ECBB4 -_021ECB94: .word 0x0000726F -_021ECB98: .word 0x00006B5A -_021ECB9C: .word 0x00000F64 -_021ECBA0: .word ov01_021EDA7C -_021ECBA4: .word 0x00000F6C -_021ECBA8: .word 0x00000F62 -_021ECBAC: .word ov01_021ECC70 -_021ECBB0: .word 0x00000F66 - thumb_func_end ov01_021EC94C - - thumb_func_start ov01_021ECBB4 -ov01_021ECBB4: ; 0x021ECBB4 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x18 - str r0, [sp] - mov r0, #0 - str r0, [sp, #8] - add r0, r1, #0 - str r1, [sp, #4] - cmp r0, #0 - ble _021ECC62 -_021ECBC6: - ldr r0, [sp] - mov r1, #0x20 - bl ov01_021EC1F4 - add r6, r0, #0 - beq _021ECC62 - ldr r4, [r6, #8] - bl MTRandom - mov r1, #0 - str r1, [r4] - mov r1, #3 - add r7, r0, #0 - bl _u32_div_f - add r5, r1, #0 - lsl r1, r5, #0x10 - ldr r0, [r6, #4] - lsr r1, r1, #0x10 - bl Sprite_SetAnimationFrame - add r0, r7, #0 - mov r1, #0x14 - bl _u32_div_f - add r2, r5, #1 - mov r0, #0xa - mul r0, r2 - add r0, r1, r0 - str r0, [r4, #8] - cmp r5, #2 - bne _021ECC0C - ldr r0, [r4, #8] - add r0, #0xa - str r0, [r4, #8] -_021ECC0C: - add r0, r1, #0 - mov r1, #4 - mvn r1, r1 - bl _s32_div_f - mov r1, #4 - add r2, r5, #1 - mvn r1, r1 - mul r1, r2 - add r0, r0, r1 - str r0, [r4, #0x10] - cmp r5, #2 - bne _021ECC2C - ldr r0, [r4, #0x10] - sub r0, r0, #5 - str r0, [r4, #0x10] -_021ECC2C: - mov r0, #0 - str r0, [r4, #0xc] - add r0, r5, #1 - str r0, [r4, #4] - ldr r1, _021ECC68 ; =0x0000010E - add r0, r7, #0 - bl _u32_div_f - mov r0, #0xf - mul r0, r5 - add r0, r1, r0 - lsl r0, r0, #0xc - str r0, [sp, #0xc] - ldr r0, _021ECC6C ; =0xFFFA0000 - add r1, sp, #0xc - str r0, [sp, #0x10] - mov r0, #0 - str r0, [sp, #0x14] - ldr r0, [r6, #4] - bl ov01_021EB5F4 - ldr r0, [sp, #8] - add r1, r0, #1 - ldr r0, [sp, #4] - str r1, [sp, #8] - cmp r1, r0 - blt _021ECBC6 -_021ECC62: - add sp, #0x18 - pop {r3, r4, r5, r6, r7, pc} - nop -_021ECC68: .word 0x0000010E -_021ECC6C: .word 0xFFFA0000 - thumb_func_end ov01_021ECBB4 - - thumb_func_start ov01_021ECC70 -ov01_021ECC70: ; 0x021ECC70 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r6, r0, #0 - ldr r5, [r6, #8] - add r0, sp, #0 - add r1, r6, #0 - bl ov01_021EC304 - ldr r0, [r5, #0xc] - cmp r0, #0 - beq _021ECC92 - cmp r0, #1 - beq _021ECCEA - cmp r0, #2 - beq _021ECCFC - add sp, #0xc - pop {r4, r5, r6, r7, pc} -_021ECC92: - mov r4, #0 - mov r7, #2 -_021ECC96: - ldr r0, [r5, #0x10] - ldr r1, [sp] - lsl r0, r0, #0xc - add r0, r1, r0 - str r0, [sp] - ldr r0, [r5, #8] - ldr r1, [sp, #4] - lsl r0, r0, #0xc - add r0, r1, r0 - str r0, [sp, #4] - ldr r1, [r5] - add r0, r1, #1 - str r0, [r5] - ldr r0, [r5, #4] - cmp r1, r0 - ble _021ECCD8 - bl MTRandom - mov r1, #0xa - bl _u32_div_f - cmp r1, #7 - bhs _021ECCC8 - str r7, [r5, #0xc] - b _021ECCD8 -_021ECCC8: - mov r0, #1 - str r0, [r5, #0xc] - mov r0, #4 - str r0, [r5] - ldr r0, [r6, #4] - mov r1, #3 - bl Sprite_SetAnimationFrame -_021ECCD8: - add r4, r4, #1 - cmp r4, #2 - blt _021ECC96 - ldr r0, [r6, #4] - add r1, sp, #0 - bl ov01_021EB5F4 - add sp, #0xc - pop {r4, r5, r6, r7, pc} -_021ECCEA: - ldr r1, [r5] - sub r0, r1, #1 - str r0, [r5] - cmp r1, #0 - bgt _021ECD02 - mov r0, #2 - add sp, #0xc - str r0, [r5, #0xc] - pop {r4, r5, r6, r7, pc} -_021ECCFC: - add r0, r6, #0 - bl ov01_021EC29C -_021ECD02: - add sp, #0xc - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov01_021ECC70 - - thumb_func_start ov01_021ECD08 -ov01_021ECD08: ; 0x021ECD08 - push {r4, r5, r6, lr} - sub sp, #0x18 - ldr r0, _021ECF2C ; =0x00000F58 - add r5, r1, #0 - add r2, r0, #0 - add r2, #0xa - ldrh r2, [r5, r2] - ldr r4, [r5, r0] - cmp r2, #5 - bhi _021ECDCC - add r2, r2, r2 - add r2, pc - ldrh r2, [r2, #6] - lsl r2, r2, #0x10 - asr r2, r2, #0x10 - add pc, r2 -_021ECD28: ; jump table - .short _021ECD34 - _021ECD28 - 2 ; case 0 - .short _021ECD94 - _021ECD28 - 2 ; case 1 - .short _021ECDD6 - _021ECD28 - 2 ; case 2 - .short _021ECE3E - _021ECD28 - 2 ; case 3 - .short _021ECE96 - _021ECD28 - 2 ; case 4 - .short _021ECEE4 - _021ECD28 - 2 ; case 5 -_021ECD34: - mov r0, #6 - str r0, [sp] - mov r0, #3 - str r0, [sp, #4] - sub r0, #8 - str r0, [sp, #8] - mov r0, #2 - str r0, [sp, #0xc] - mov r2, #1 - ldr r0, _021ECF30 ; =ov01_021ECF4C - str r2, [sp, #0x10] - str r0, [sp, #0x14] - add r0, r4, #0 - mov r3, #0x1e - bl ov01_021EC504 - ldr r0, _021ECF34 ; =0x0000726F - mov r2, #0x41 - str r0, [sp] - ldr r0, _021ECF38 ; =0x00006318 - add r1, r4, #0 - str r0, [sp, #4] - mov r0, #2 - str r0, [sp, #8] - ldr r0, _021ECF3C ; =0x00000F64 - lsl r2, r2, #2 - ldrh r0, [r5, r0] - add r1, #0x1c - str r0, [sp, #0xc] - ldr r3, [r5] - add r0, r4, #0 - ldr r2, [r3, r2] - add r0, #0x4c - ldr r2, [r2, #0x4c] - mov r3, #3 - bl ov01_021EC5FC - add r0, r4, #0 - mov r1, #8 - add r0, #0xb4 - str r1, [r0] - mov r0, #0 - add r4, #0xb8 - str r0, [r4] - ldr r0, _021ECF40 ; =0x00000F62 - mov r1, #1 - strh r1, [r5, r0] - b _021ECF02 -_021ECD94: - add r0, r4, #0 - bl ov01_021EC538 - add r6, r0, #0 - add r0, r4, #0 - add r0, #0xb4 - ldr r0, [r0] - cmp r0, #0 - ble _021ECDB4 - add r0, r4, #0 - add r0, #0xb4 - ldr r0, [r0] - add r4, #0xb4 - sub r0, r0, #1 - str r0, [r4] - b _021ECF02 -_021ECDB4: - ldr r2, _021ECF3C ; =0x00000F64 - add r0, r4, #0 - ldrh r2, [r5, r2] - add r4, #0x1c - add r0, #0x4c - add r1, r4, #0 - bl ov01_021EC650 - cmp r0, #1 - bne _021ECDCC - cmp r6, #3 - beq _021ECDCE -_021ECDCC: - b _021ECF02 -_021ECDCE: - ldr r0, _021ECF40 ; =0x00000F62 - mov r1, #3 - strh r1, [r5, r0] - b _021ECF02 -_021ECDD6: - mov r2, #6 - mov r3, #3 - str r2, [sp] - add r0, r3, #0 - str r3, [sp, #4] - sub r0, #8 - str r0, [sp, #8] - mov r0, #2 - str r0, [sp, #0xc] - mov r0, #1 - str r0, [sp, #0x10] - ldr r0, _021ECF30 ; =ov01_021ECF4C - str r0, [sp, #0x14] - add r0, r4, #0 - bl ov01_021EC504 - ldr r0, _021ECF3C ; =0x00000F64 - ldrh r0, [r5, r0] - cmp r0, #0 - beq _021ECE1C - mov r0, #0x41 - ldr r1, [r5] - lsl r0, r0, #2 - ldr r0, [r1, r0] - ldr r2, _021ECF34 ; =0x0000726F - ldr r0, [r0, #0x4c] - ldr r3, _021ECF38 ; =0x00006318 - mov r1, #3 - str r0, [r4, #0x1c] - bl ov01_021EC678 - add r0, r4, #0 - add r0, #0x1c - bl ov01_021EC7C8 -_021ECE1C: - mov r0, #0 - add r4, #0xb8 - str r0, [r4] - mov r0, #3 - str r0, [sp] - ldr r0, _021ECF44 ; =ov01_021ED070 - ldr r1, _021ECF30 ; =ov01_021ECF4C - str r0, [sp, #4] - add r0, r5, #0 - mov r2, #0x14 - mov r3, #2 - bl ov01_021EC85C - ldr r0, _021ECF40 ; =0x00000F62 - mov r1, #3 - strh r1, [r5, r0] - b _021ECF02 -_021ECE3E: - mov r0, #6 - ldrsh r1, [r4, r0] - sub r0, r1, #1 - strh r0, [r4, #6] - cmp r1, #0 - bgt _021ECE5A - mov r1, #4 - ldrsh r1, [r4, r1] - add r0, r5, #0 - bl ov01_021ECF4C - mov r0, #8 - ldrsh r0, [r4, r0] - strh r0, [r4, #6] -_021ECE5A: - ldr r0, _021ECF48 ; =0x00000F66 - ldrh r0, [r5, r0] - cmp r0, #5 - bne _021ECF02 - mov r0, #2 - mvn r0, r0 - str r0, [sp] - add r0, r4, #0 - mov r1, #0 - mov r2, #0x1e - mov r3, #5 - bl ov01_021EC52C - ldr r0, _021ECF3C ; =0x00000F64 - ldrh r0, [r5, r0] - cmp r0, #0 - beq _021ECE88 - add r0, r4, #0 - add r0, #0x1c - mov r1, #1 - mov r2, #0 - bl ov01_021EC790 -_021ECE88: - mov r0, #0 - add r4, #0xb4 - str r0, [r4] - ldr r0, _021ECF40 ; =0x00000F62 - mov r1, #4 - strh r1, [r5, r0] - b _021ECF02 -_021ECE96: - add r0, r4, #0 - bl ov01_021EC538 - add r6, r0, #0 - add r0, r4, #0 - add r0, #0xb4 - ldr r0, [r0] - cmp r0, #0 - ble _021ECEB6 - add r0, r4, #0 - add r0, #0xb4 - ldr r0, [r0] - add r4, #0xb4 - sub r0, r0, #1 - str r0, [r4] - b _021ECF02 -_021ECEB6: - ldr r0, _021ECF3C ; =0x00000F64 - ldrh r0, [r5, r0] - cmp r0, #0 - beq _021ECEC8 - add r4, #0x1c - add r0, r4, #0 - bl ov01_021EC7AC - b _021ECECA -_021ECEC8: - mov r0, #1 -_021ECECA: - cmp r0, #1 - bne _021ECF02 - cmp r6, #3 - bne _021ECF02 - add r0, r5, #0 - ldr r1, [r5, #0x40] - add r0, #0xc - cmp r1, r0 - bne _021ECF02 - ldr r0, _021ECF40 ; =0x00000F62 - mov r1, #5 - strh r1, [r5, r0] - b _021ECF02 -_021ECEE4: - add r0, #0xc - ldrh r0, [r5, r0] - cmp r0, #0 - beq _021ECEFC - mov r2, #0 - str r2, [sp] - str r2, [sp, #4] - ldr r0, [r4, #0x1c] - mov r1, #1 - add r3, r2, #0 - bl ov01_021EA864 -_021ECEFC: - ldr r0, [r5, #4] - bl ov01_021EBCA4 -_021ECF02: - ldr r0, _021ECF40 ; =0x00000F62 - ldrh r0, [r5, r0] - cmp r0, #5 - beq _021ECF28 - cmp r0, #0 - beq _021ECF28 - add r0, r5, #0 - ldr r1, _021ECF44 ; =ov01_021ED070 - add r0, #0xc - bl ov01_021EC2E4 - mov r1, #0 - add r0, r5, #0 - add r2, r1, #0 - bl ov01_021EC470 - add r0, r5, #0 - bl ov01_021EC300 -_021ECF28: - add sp, #0x18 - pop {r4, r5, r6, pc} - .balign 4, 0 -_021ECF2C: .word 0x00000F58 -_021ECF30: .word ov01_021ECF4C -_021ECF34: .word 0x0000726F -_021ECF38: .word 0x00006318 -_021ECF3C: .word 0x00000F64 -_021ECF40: .word 0x00000F62 -_021ECF44: .word ov01_021ED070 -_021ECF48: .word 0x00000F66 - thumb_func_end ov01_021ECD08 - - thumb_func_start ov01_021ECF4C -ov01_021ECF4C: ; 0x021ECF4C - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x58 - ldr r3, _021ED064 ; =ov01_0220673C - add r2, sp, #0x48 - str r0, [sp] - str r1, [sp, #4] - ldmia r3!, {r0, r1} - str r2, [sp, #0x10] - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldr r3, _021ED068 ; =ov01_0220674C - add r2, sp, #0x38 - str r2, [sp, #0x14] - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldr r1, _021ED06C ; =0x00000F58 - ldr r0, [sp] - ldr r6, [r0, r1] - mov r0, #0 - str r0, [sp, #0xc] - ldr r0, [sp, #4] - cmp r0, #0 - ble _021ED060 - add r0, r6, #0 - str r0, [sp, #0x18] - add r0, #0xb8 - str r0, [sp, #0x18] - mov r0, #7 - mvn r0, r0 - lsl r0, r0, #0xc - str r0, [sp, #0x1c] -_021ECF90: - ldr r0, [sp] - mov r1, #0x20 - bl ov01_021EC1F4 - add r4, r0, #0 - beq _021ED060 - ldr r0, [sp, #0x18] - ldr r5, [r4, #8] - ldr r0, [r0] - add r1, r0, #1 - ldr r0, [sp, #0x18] - str r1, [r0] - add r0, r6, #0 - add r0, #0xb8 - ldr r1, [r0] - mov r0, #0x32 - lsl r0, r0, #4 - cmp r1, r0 - blt _021ECFBE - add r1, r6, #0 - add r1, #0xb8 - mov r0, #0 - str r0, [r1] -_021ECFBE: - add r0, r6, #0 - add r0, #0xb8 - ldr r0, [r0] - mov r1, #0xc8 - bl _s32_div_f - lsl r0, r0, #2 - ldr r1, [sp, #0x10] - str r0, [sp, #8] - ldr r0, [r1, r0] - str r0, [r5, #0x14] - mov r0, #0 - str r0, [r5] - bl MTRandom - mov r1, #0x2a - bl _u32_div_f - add r0, r1, #4 - str r0, [r5, #4] - sub r0, r0, #4 - mov r1, #0xf - bl _s32_div_f - add r7, r0, #0 - lsl r1, r7, #0x10 - ldr r0, [r4, #4] - lsr r1, r1, #0x10 - bl Sprite_SetAnimationFrame - add r0, r7, #1 - neg r1, r0 - str r1, [r5, #0x10] - ldr r2, [sp, #0x14] - ldr r1, [sp, #8] - ldr r1, [r2, r1] - mul r1, r0 - str r1, [r5, #8] - mov r0, #0 - str r0, [r5, #0xc] - add r0, sp, #0x20 - add r1, r4, #0 - bl ov01_021EC304 - add r3, sp, #0x20 - ldmia r3!, {r0, r1} - add r2, sp, #0x2c - stmia r2!, {r0, r1} - ldr r0, [r3] - str r0, [r2] - bl MTRandom - mov r1, #0x69 - lsl r1, r1, #2 - bl _u32_div_f - mov r0, #1 - sub r2, r0, r7 - sub r0, #0x15 - mul r0, r2 - add r1, r0, r1 - mov r0, #7 - mvn r0, r0 - str r0, [sp, #0x30] - mov r0, #0 - str r0, [sp, #0x34] - str r1, [sp, #0x2c] - lsl r0, r1, #0xc - str r0, [sp, #0x2c] - ldr r0, [sp, #0x1c] - add r1, sp, #0x2c - str r0, [sp, #0x30] - ldr r0, [r4, #4] - bl ov01_021EB5F4 - ldr r0, [sp, #0xc] - add r1, r0, #1 - ldr r0, [sp, #4] - str r1, [sp, #0xc] - cmp r1, r0 - blt _021ECF90 -_021ED060: - add sp, #0x58 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_021ED064: .word ov01_0220673C -_021ED068: .word ov01_0220674C -_021ED06C: .word 0x00000F58 - thumb_func_end ov01_021ECF4C - thumb_func_start ov01_021ED070 ov01_021ED070: ; 0x021ED070 push {r3, r4, r5, lr} @@ -2291,9 +1392,10 @@ _021EDAF8: .word 0x00000F5C .rodata +.public ov01_0220673C ov01_0220673C: ; 0x0220673C .word 16, 32, 16, 10 - +.public ov01_0220674C ov01_0220674C: ; 0x0220674C .word 2, 2, 2, 2 .public ov01_0220675C diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 0d351c8cbb..40378d66c4 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -69,9 +69,9 @@ typedef struct UnkWeatherStruct_021EB830 { int unkC; int unk10; } UnkWeatherStruct_021EB830; -typedef void (*UnkFunc_021EC504)(s32 a0, s32 a1); +typedef void (*UnkWeatherSystemSub0Sub8Func)(WeatherSystem_Sub0_Sub8 *, int); typedef struct UnkStruct_021EC504 { - s32 unk0; + WeatherSystem_Sub0_Sub8 *unk0; s16 unk4; s16 unk6; s16 unk8; @@ -81,11 +81,10 @@ typedef struct UnkStruct_021EC504 { s16 unk10; s16 unk12; s32 unk14; - UnkFunc_021EC504 unk18; + UnkWeatherSystemSub0Sub8Func unk18; } UnkStruct_021EC504; typedef void (*UnkLinkedListFunc)(WeatherSystem_Sub0_Sub8_LinkedList *); -typedef void (*UnkWeatherSystemSub0Sub8Func)(WeatherSystem_Sub0_Sub8 *, int); typedef struct UnkStruct_021EC5FC { s32 unk0; @@ -105,6 +104,13 @@ typedef struct UnkStruct_021EC774 { s16 unk2E; } UnkStruct_021EC774; +typedef struct UnkStruct_021EC94C { + UnkStruct_021EC504 unk0; + UnkStruct_021EC774 unk1C; + UnkStruct_021EC5FC unk50; + s32 data[10]; +} UnkStruct_021EC94C; + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); void WeatherManager_Delete(WeatherManager* weatherManager); @@ -161,7 +167,7 @@ VecFx32 ov01_021EC304(WeatherSystem_Sub0_Sub8_LinkedList *a0); void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0); void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut); void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y); -void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkFunc_021EC504 arg9); +void ov01_021EC504(UnkStruct_021EC504* arg0, WeatherSystem_Sub0_Sub8 *arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkWeatherSystemSub0Sub8Func arg9); void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4); s32 ov01_021EC538(UnkStruct_021EC504* arg0); void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb arg5, s32 arg6, s32 arg7); @@ -178,6 +184,11 @@ void ov01_021EC828(UnkStruct_021EC774 *arg0); void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int a2, int a3, int a4, UnkLinkedListFunc a5); WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EC8F8(SysTask *task, void* data); +void ov01_021EC94C(SysTask *task, void *data); +void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *, int); +void ov01_021ECC70(WeatherSystem_Sub0_Sub8_LinkedList *a0); +void ov01_021ECD08(SysTask *task, void* data); +void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -195,5 +206,7 @@ int ov01_021EA85C(s32 a0); GXRgb ov01_021EA860(s32 a0); void ov01_021EA89C(s32 a0, s32 a1, GXRgb rgb, s32 a2); void ov01_021EA8C4(u32 unk0, u8 *unk4); +void ov01_021EDA7C(SysTask *task, void *data); +void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList *); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index e80a7ff0e5..51a0020bd1 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -9,6 +9,7 @@ #include "unk_02005D10.h" #include "unk_0200ACF0.h" #include "unk_02020B8C.h" +#include "math_util.h" struct WeatherSystem_Sub0_Sub8 { WeatherSystem *weatherSystem; @@ -1029,7 +1030,7 @@ void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y) { } } -void ov01_021EC504(UnkStruct_021EC504* arg0, s32 arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkFunc_021EC504 arg9) { +void ov01_021EC504(UnkStruct_021EC504* arg0, WeatherSystem_Sub0_Sub8 *arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkWeatherSystemSub0Sub8Func arg9) { arg0->unk0 = arg1; arg0->unk4 = arg2; arg0->unk6 = 0; @@ -1316,3 +1317,310 @@ void ov01_021EC8F8(SysTask *task, void* data) { break; } } + +void ov01_021EC94C(SysTask *task, void *data) { + WeatherSystem_Sub0_Sub8 *v0 = data; + + UnkStruct_021EC94C *v1 = v0->unkF58; + + switch (v0->unkF62) { + case 0: + ov01_021EC504(&v1->unk0, v0, 1, 8, 20, 1, -1, 1, 2, ov01_021ECBB4); + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->unk_4C, 3, 0x726F, 0x6b5a, 1, v0->unkF64); + + v1->data[0] = 0; + v0->unkF6C = SysTask_CreateOnMainQueue(ov01_021EDA7C, v0, 100); + v0->unkF68 = 30; + v0->unkF62 = 1; + break; + case 1: + int v2 = ov01_021EC538(&v1->unk0); + if (v1->data[0] > 0) { + v1->data[0]--; + } else { + int v3 = ov01_021EC650(&v1->unk50, &v1->unk1C, v0->unkF64); + if (v3 == 1 && v2 == 3) { + v0->unkF62 = 3; + } + } + break; + case 2: + ov01_021EC504(&v1->unk0, v0, 20, 1, 20, 1, -1, 1, 2, ov01_021ECBB4); + + if (v0->unkF64) { + v1->unk1C.unk0 = v0->weatherSystem->fieldSystem->unk_4C; + ov01_021EC678(v1->unk1C.unk0, 3, 0x726f, GX_RGB(26,26,26)); + ov01_021EC7C8(&v1->unk1C); + } + + ov01_021EC85C(v0, ov01_021ECBB4, 20, 10, 1, ov01_021ECC70); + + v0->unkF6C = SysTask_CreateOnMainQueue(ov01_021EDA7C, v0, 100); + v0->unkF68 = 30; + v0->unkF62 = 3; + break; + case 3: + if (v1->unk0.unk6-- <= 0) { + ov01_021ECBB4(v0, v1->unk0.unk4); + v1->unk0.unk6 = v1->unk0.unk8; + } + + if (v0->unkF66 == 5) { + ov01_021EC52C(&v1->unk0, 0, 8, 1, -2); + + + if (v0->unkF64) { + ov01_021EC790(&v1->unk1C, 1, 0); + } + v1->data[0] = 0; + v0->unkF62 = 4; + ov01_021EDAE0(v0); + } + break; + case 4: + int ret = ov01_021EC538(&v1->unk0); + if (v1->data[0] > 0) { + v1->data[0]--; + } else { + int vUnk; + if (v0->unkF64) { + vUnk = ov01_021EC7AC(&v1->unk1C); + } else { + vUnk = 1; + } + + if (vUnk == 1 && ret == 3) { + if (v0->linkedListDummy.next == &v0->linkedListDummy) { + v0->unkF62 = 5; + } + } + + } + break; + case 5: + if (v0->unkF64) { + ov01_021EA864(v1->unk1C.unk0, 1, 0, 0, 0, 0); + } + ov01_021EBCA4(v0->unk4); + break; + } + + if (v0->unkF62 != 5 && v0->unkF62 != 0) { + ov01_021EC2E4(&v0->linkedListDummy, ov01_021ECC70); + ov01_021EC470(v0, NULL, NULL); + ov01_021EC300(v0); + } +} + +void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1) { + for (int i = 0; i < arg1; i++) { + WeatherSystem_Sub0_Sub8_LinkedList *v0 = ov01_021EC1F4(a0, 32); + if (v0 == NULL) { + break; + } + + u32 *data = v0->unk8; + u32 rand = MTRandom(); + + data[0] = 0; + int frame = rand % 3; + Sprite_SetAnimationFrame(v0->unk4, frame); + + int v1 = rand % 20; + data[2] = 10 * (frame + 1) + v1; + if (frame == 2) { + data[2] += 10; + } + + v1 /= -5; + data[4] = -5 * (frame + 1) + v1; + if (frame == 2) { + data[4] -= 5; + } + data[3] = 0; + data[1] = 1 + (rand % 3); + + VecFx32 vec; + + vec.x = (15 * frame + (rand % 270)) << FX32_SHIFT; + vec.y = 0xFFFA0 << FX32_SHIFT; + vec.z = 0; + ov01_021EB5F4(v0->unk4, &vec); + } +} + +void ov01_021ECC70(WeatherSystem_Sub0_Sub8_LinkedList *a0) { + int i; + s32 *data = a0->unk8; + VecFx32 vec; + vec = ov01_021EC304(a0); + switch (data[3]) { + case 0: + for (i = 0; i < 2; i++) { + vec.x += data[4] << FX32_SHIFT; + vec.y += data[2] << FX32_SHIFT; + + if (data[0]++ > data[1]) { + if (((u32)MTRandom() % 10) < 7) { + data[3] = 2; + } else { + data[3] = 1; + data[0] = 4; + Sprite_SetAnimationFrame(a0->unk4, 3); + } + } + } + ov01_021EB5F4(a0->unk4, &vec); + break; + case 1: + if (data[0]-- <= 0) { + data[3] = 2; + } + break; + case 2: + ov01_021EC29C(a0); + break; + } +} + +void ov01_021ECD08(SysTask *task, void* data) { + WeatherSystem_Sub0_Sub8 *v0 = data; + + UnkStruct_021EC94C *v1 = v0->unkF58; + + switch (v0->unkF62) { + case 0: + ov01_021EC504(&v1->unk0, v0, 1, 30, 6, 3, -5, 2, 1, ov01_021ECF4C); + + + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->unk_4C, 3, 0x726F, GX_RGB(24,24,24), 2, v0->unkF64); + + v1->data[0] = 8; + v1->data[1] = 0; + v0->unkF62 = 1; + break; + case 1: + int v2 = ov01_021EC538(&v1->unk0); + if (v1->data[0] > 0) { + v1->data[0]--; + } else { + int v3 = ov01_021EC650(&v1->unk50, &v1->unk1C, v0->unkF64); + if (v3 == 1 && v2 == 3) { + v0->unkF62 = 3; + } + } + break; + case 2: + ov01_021EC504(&v1->unk0, v0, 6, 3, 6, 3, -5, 2, 1, ov01_021ECF4C); + + if (v0->unkF64) { + v1->unk1C.unk0 = v0->weatherSystem->fieldSystem->unk_4C; + ov01_021EC678(v1->unk1C.unk0, 3, 0x726f, GX_RGB(24,24,24)); + ov01_021EC7C8(&v1->unk1C); + } + + v1->data[1] = 0; + + ov01_021EC85C(v0, ov01_021ECF4C, 20, 2, 3, ov01_021ED070); + + v0->unkF62 = 3; + break; + case 3: + if (v1->unk0.unk6-- <= 0) { + ov01_021ECF4C(v0, v1->unk0.unk4); + v1->unk0.unk6 = v1->unk0.unk8; + } + + if (v0->unkF66 == 5) { + ov01_021EC52C(&v1->unk0, 0, 30, 5, -3); + + + if (v0->unkF64) { + ov01_021EC790(&v1->unk1C, 1, 0); + } + v1->data[0] = 0; + v0->unkF62 = 4; + } + break; + case 4: + int ret = ov01_021EC538(&v1->unk0); + if (v1->data[0] > 0) { + v1->data[0]--; + } else { + int vUnk; + if (v0->unkF64) { + vUnk = ov01_021EC7AC(&v1->unk1C); + } else { + vUnk = 1; + } + + if (vUnk == 1 && ret == 3) { + if (v0->linkedListDummy.next == &v0->linkedListDummy) { + v0->unkF62 = 5; + } + } + + } + break; + case 5: + if (v0->unkF64) { + ov01_021EA864(v1->unk1C.unk0, 1, 0, 0, 0, 0); + } + ov01_021EBCA4(v0->unk4); + break; + } + + if (v0->unkF62 != 5 && v0->unkF62 != 0) { + ov01_021EC2E4(&v0->linkedListDummy, ov01_021ED070); + ov01_021EC470(v0, NULL, NULL); + ov01_021EC300(v0); + } +} + +//NOTE: make these direct inlines rather than external data +extern int ov01_0220673C[4]; +extern int ov01_0220674C[4]; + +void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1) { + int table0[4]; + table0 = ov01_0220673C; + int table1[4]; + table1 = ov01_0220674C; + UnkStruct_021EC94C *v0 = a0->unkF58; + + for (int i = 0; i < a1; i++) { + WeatherSystem_Sub0_Sub8_LinkedList *v1 = ov01_021EC1F4(a0, 32); + if (v1 == NULL) { + break; + } + + s32 *data = v1->unk8; + + v0->data[1]++; + if (v0->data[1] >= 800) { + v0->data[1] = 0; + } + int index = v0->data[1] / 200; + data[5] = table0[index]; + + data[0] = 0; + data[1] = 4 + (MTRandom() % 42); + + int frame = (data[1] - 4) / 15; + Sprite_SetAnimationFrame(v1->unk4, frame); + + data[4] = -(frame + 1); + data[2] = table1[index] * (frame + 1); + data[3] = 0; + + VecFx32 vec = ov01_021EC304(v1); + + vec.x = -20 + (frame * 20) + (MTRandom() % 420); + vec.y = -8; + vec.z = 0; + vec.x <<= FX32_SHIFT; + vec.y <<= FX32_SHIFT; + + ov01_021EB5F4(v1->unk4, &vec); + } +} \ No newline at end of file From 34682fd1c2bb356b4371de615e42ac95ff920fcd Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 8 Jun 2026 18:31:52 -0400 Subject: [PATCH 18/22] To ov01_021ED584 --- asm/overlay_01_021EB1E8.s | 851 +------------------------------- include/field/weather_manager.h | 19 +- src/field/weather_manager.c | 292 ++++++++++- 3 files changed, 313 insertions(+), 849 deletions(-) diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index e1dfa62ff0..fce9697115 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -49,853 +49,10 @@ .public ov01_021EC94C .public ov01_021ECD08 .public ov01_021ECD08 - - - thumb_func_start ov01_021ED070 -ov01_021ED070: ; 0x021ED070 - push {r3, r4, r5, lr} - sub sp, #0x18 - add r5, r0, #0 - add r0, sp, #0 - add r1, r5, #0 - ldr r4, [r5, #8] - bl ov01_021EC304 - add r3, sp, #0 - ldmia r3!, {r0, r1} - add r2, sp, #0xc - stmia r2!, {r0, r1} - ldr r0, [r3] - str r0, [r2] - ldr r0, [r4, #0xc] - cmp r0, #0 - beq _021ED09A - cmp r0, #1 - beq _021ED0E6 - add sp, #0x18 - pop {r3, r4, r5, pc} -_021ED09A: - ldr r0, [r4, #0x10] - ldr r1, [sp, #0xc] - lsl r0, r0, #0xc - add r0, r1, r0 - str r0, [sp, #0xc] - ldr r0, [r4, #8] - ldr r1, [sp, #0x10] - lsl r0, r0, #0xc - add r0, r1, r0 - str r0, [sp, #0x10] - ldr r1, [r4] - add r0, r1, #1 - str r0, [r4] - ldr r0, [r4, #4] - cmp r1, r0 - ble _021ED0BE - mov r0, #1 - str r0, [r4, #0xc] -_021ED0BE: - ldr r0, [r4] - ldr r1, [r4, #0x14] - bl _s32_div_f - cmp r1, #0 - bne _021ED0DA - ldr r0, [r4, #0x10] - sub r0, r0, #1 - str r0, [r4, #0x10] - ldr r0, [r4, #8] - cmp r0, #1 - ble _021ED0DA - sub r0, r0, #1 - str r0, [r4, #8] -_021ED0DA: - ldr r0, [r5, #4] - add r1, sp, #0xc - bl ov01_021EB5F4 - add sp, #0x18 - pop {r3, r4, r5, pc} -_021ED0E6: - add r0, r5, #0 - bl ov01_021EC29C - add sp, #0x18 - pop {r3, r4, r5, pc} - thumb_func_end ov01_021ED070 - - thumb_func_start ov01_021ED0F0 -ov01_021ED0F0: ; 0x021ED0F0 - push {r4, r5, r6, lr} - sub sp, #0x18 - ldr r0, _021ED2FC ; =0x00000F58 - add r5, r1, #0 - add r2, r0, #0 - add r2, #0xa - ldrh r2, [r5, r2] - ldr r4, [r5, r0] - cmp r2, #5 - bhi _021ED1AA - add r2, r2, r2 - add r2, pc - ldrh r2, [r2, #6] - lsl r2, r2, #0x10 - asr r2, r2, #0x10 - add pc, r2 -_021ED110: ; jump table - .short _021ED11C - _021ED110 - 2 ; case 0 - .short _021ED172 - _021ED110 - 2 ; case 1 - .short _021ED1B4 - _021ED110 - 2 ; case 2 - .short _021ED212 - _021ED110 - 2 ; case 3 - .short _021ED26A - _021ED110 - 2 ; case 4 - .short _021ED2B4 - _021ED110 - 2 ; case 5 -_021ED11C: - mov r0, #0x14 - str r0, [sp] - mov r2, #2 - str r2, [sp, #4] - sub r0, r2, #4 - str r0, [sp, #8] - mov r0, #4 - str r0, [sp, #0xc] - ldr r0, _021ED300 ; =ov01_021ED31C - str r2, [sp, #0x10] - str r0, [sp, #0x14] - add r0, r4, #0 - mov r3, #0x10 - bl ov01_021EC504 - ldr r0, _021ED304 ; =0x0000716F - mov r2, #0x41 - str r0, [sp] - ldr r0, _021ED308 ; =0x00006B5A - lsl r2, r2, #2 - str r0, [sp, #4] - mov r0, #1 - str r0, [sp, #8] - ldr r0, _021ED30C ; =0x00000F64 - add r1, r4, #0 - ldrh r0, [r5, r0] - add r1, #0x1c - str r0, [sp, #0xc] - ldr r3, [r5] - add r0, r4, #0 - ldr r2, [r3, r2] - add r0, #0x4c - ldr r2, [r2, #0x4c] - mov r3, #3 - bl ov01_021EC5FC - mov r0, #0 - add r4, #0xb4 - str r0, [r4] - ldr r0, _021ED310 ; =0x00000F62 - mov r1, #1 - strh r1, [r5, r0] - b _021ED2D2 -_021ED172: - add r0, r4, #0 - bl ov01_021EC538 - add r6, r0, #0 - add r0, r4, #0 - add r0, #0xb4 - ldr r0, [r0] - cmp r0, #0 - ble _021ED192 - add r0, r4, #0 - add r0, #0xb4 - ldr r0, [r0] - add r4, #0xb4 - sub r0, r0, #1 - str r0, [r4] - b _021ED2D2 -_021ED192: - ldr r2, _021ED30C ; =0x00000F64 - add r0, r4, #0 - ldrh r2, [r5, r2] - add r4, #0x1c - add r0, #0x4c - add r1, r4, #0 - bl ov01_021EC650 - cmp r0, #1 - bne _021ED1AA - cmp r6, #3 - beq _021ED1AC -_021ED1AA: - b _021ED2D2 -_021ED1AC: - ldr r0, _021ED310 ; =0x00000F62 - mov r1, #3 - strh r1, [r5, r0] - b _021ED2D2 -_021ED1B4: - mov r2, #0x14 - mov r3, #2 - str r2, [sp] - str r3, [sp, #4] - sub r0, r3, #4 - str r0, [sp, #8] - mov r0, #4 - str r0, [sp, #0xc] - ldr r0, _021ED300 ; =ov01_021ED31C - str r3, [sp, #0x10] - str r0, [sp, #0x14] - add r0, r4, #0 - bl ov01_021EC504 - ldr r0, _021ED30C ; =0x00000F64 - ldrh r0, [r5, r0] - cmp r0, #0 - beq _021ED1F6 - mov r0, #0x41 - ldr r1, [r5] - lsl r0, r0, #2 - ldr r0, [r1, r0] - ldr r2, _021ED304 ; =0x0000716F - ldr r0, [r0, #0x4c] - ldr r3, _021ED308 ; =0x00006B5A - mov r1, #3 - str r0, [r4, #0x1c] - bl ov01_021EC678 - add r4, #0x1c - add r0, r4, #0 - bl ov01_021EC7C8 -_021ED1F6: - mov r0, #1 - str r0, [sp] - ldr r0, _021ED314 ; =ov01_021ED44C - ldr r1, _021ED300 ; =ov01_021ED31C - str r0, [sp, #4] - add r0, r5, #0 - mov r2, #0x14 - mov r3, #0xa - bl ov01_021EC85C - ldr r0, _021ED310 ; =0x00000F62 - mov r1, #3 - strh r1, [r5, r0] - b _021ED2D2 -_021ED212: - mov r0, #6 - ldrsh r1, [r4, r0] - sub r0, r1, #1 - strh r0, [r4, #6] - cmp r1, #0 - bgt _021ED22E - mov r1, #4 - ldrsh r1, [r4, r1] - add r0, r5, #0 - bl ov01_021ED31C - mov r0, #8 - ldrsh r0, [r4, r0] - strh r0, [r4, #6] -_021ED22E: - ldr r0, _021ED318 ; =0x00000F66 - ldrh r0, [r5, r0] - cmp r0, #5 - bne _021ED2D2 - mov r0, #9 - mvn r0, r0 - str r0, [sp] - add r0, r4, #0 - mov r1, #0 - mov r2, #0x10 - mov r3, #6 - bl ov01_021EC52C - ldr r0, _021ED30C ; =0x00000F64 - ldrh r0, [r5, r0] - cmp r0, #0 - beq _021ED25C - add r0, r4, #0 - add r0, #0x1c - mov r1, #1 - mov r2, #0 - bl ov01_021EC790 -_021ED25C: - mov r0, #0x14 - add r4, #0xb4 - str r0, [r4] - ldr r0, _021ED310 ; =0x00000F62 - mov r1, #4 - strh r1, [r5, r0] - b _021ED2D2 -_021ED26A: - add r0, r4, #0 - bl ov01_021EC538 - add r6, r0, #0 - add r0, r4, #0 - add r0, #0xb4 - ldr r0, [r0] - cmp r0, #0 - ble _021ED28A - add r0, r4, #0 - add r0, #0xb4 - ldr r0, [r0] - add r4, #0xb4 - sub r0, r0, #1 - str r0, [r4] - b _021ED2D2 -_021ED28A: - ldr r2, _021ED30C ; =0x00000F64 - add r0, r4, #0 - ldrh r2, [r5, r2] - add r4, #0x1c - add r0, #0x4c - add r1, r4, #0 - bl ov01_021EC650 - cmp r0, #1 - bne _021ED2D2 - cmp r6, #3 - bne _021ED2D2 - add r0, r5, #0 - ldr r1, [r5, #0x40] - add r0, #0xc - cmp r1, r0 - bne _021ED2D2 - ldr r0, _021ED310 ; =0x00000F62 - mov r1, #5 - strh r1, [r5, r0] - b _021ED2D2 -_021ED2B4: - add r0, #0xc - ldrh r0, [r5, r0] - cmp r0, #0 - beq _021ED2CC - mov r2, #0 - str r2, [sp] - str r2, [sp, #4] - ldr r0, [r4, #0x1c] - mov r1, #1 - add r3, r2, #0 - bl ov01_021EA864 -_021ED2CC: - ldr r0, [r5, #4] - bl ov01_021EBCA4 -_021ED2D2: - ldr r0, _021ED310 ; =0x00000F62 - ldrh r0, [r5, r0] - cmp r0, #5 - beq _021ED2F8 - cmp r0, #0 - beq _021ED2F8 - add r0, r5, #0 - ldr r1, _021ED314 ; =ov01_021ED44C - add r0, #0xc - bl ov01_021EC2E4 - mov r1, #0 - add r0, r5, #0 - add r2, r1, #0 - bl ov01_021EC470 - add r0, r5, #0 - bl ov01_021EC300 -_021ED2F8: - add sp, #0x18 - pop {r4, r5, r6, pc} - .balign 4, 0 -_021ED2FC: .word 0x00000F58 -_021ED300: .word ov01_021ED31C -_021ED304: .word 0x0000716F -_021ED308: .word 0x00006B5A -_021ED30C: .word 0x00000F64 -_021ED310: .word 0x00000F62 -_021ED314: .word ov01_021ED44C -_021ED318: .word 0x00000F66 - thumb_func_end ov01_021ED0F0 - - thumb_func_start ov01_021ED31C -ov01_021ED31C: ; 0x021ED31C - push {r4, r5, r6, r7, lr} - sub sp, #0x1c - str r0, [sp] - mov r0, #0 - str r0, [sp, #0xc] - add r0, r1, #0 - str r1, [sp, #4] - cmp r0, #0 - bgt _021ED330 - b _021ED448 -_021ED330: - ldr r0, [sp] - mov r1, #0x20 - bl ov01_021EC1F4 - add r4, r0, #0 - bne _021ED33E - b _021ED448 -_021ED33E: - ldr r5, [r4, #8] - mov r0, #0 - str r0, [r5] - bl MTRandom - mov r1, #5 - bl _u32_div_f - add r0, r1, #7 - str r0, [r5, #4] - bl MTRandom - mov r1, #0xfa - lsl r1, r1, #2 - bl _u32_div_f - lsr r2, r1, #0x1f - lsl r1, r1, #0x1f - sub r1, r1, r2 - mov r0, #0x1f - ror r1, r0 - add r0, r2, r1 - bne _021ED370 - mov r0, #1 - b _021ED374 -_021ED370: - mov r0, #0 - mvn r0, r0 -_021ED374: - str r0, [r5, #8] - mov r0, #1 - str r0, [r5, #0xc] - bl MTRandom - mov r1, #6 - bl _u32_div_f - add r0, r1, #3 - str r0, [r5, #0x10] - bl MTRandom - mov r1, #5 - bl _u32_div_f - add r0, r1, #4 - str r0, [r5, #0x14] - bl MTRandom - mov r1, #0x14 - bl _u32_div_f - str r1, [sp, #8] - add r0, sp, #0x10 - add r1, r4, #0 - bl ov01_021EC304 - bl MTRandom - mov r1, #6 - lsl r1, r1, #6 - bl _u32_div_f - sub r1, #0x40 - str r1, [sp, #0x10] - bl MTRandom - lsl r0, r0, #0x18 - lsr r1, r0, #0x18 - ldr r0, [sp, #0x10] - sub r1, #8 - lsl r0, r0, #0xc - str r0, [sp, #0x10] - str r1, [sp, #0x14] - lsl r0, r1, #0xc - str r0, [sp, #0x14] - mov r0, #0 - str r0, [sp, #0x18] - ldr r0, [r4, #4] - add r1, sp, #0x10 - bl ov01_021EB5F4 - ldr r1, [sp, #0x14] - ldr r0, [sp, #0x10] - asr r1, r1, #0xc - asr r0, r0, #0xc - str r1, [sp, #0x14] - mov r1, #3 - str r0, [sp, #0x10] - bl _s32_div_f - mov r1, #0x32 - sub r6, r1, r0 - mov r1, #0xce - sub r7, r1, r0 - bpl _021ED406 - bl MTRandom - neg r1, r7 - bl _u32_div_f - sub r1, r6, r1 - b _021ED412 -_021ED406: - bl MTRandom - add r1, r7, #0 - bl _u32_div_f - add r1, r6, r1 -_021ED412: - ldr r0, [sp, #0x14] - cmp r6, r0 - bgt _021ED424 - cmp r1, r0 - blt _021ED424 - ldr r0, [r5, #4] - lsl r0, r0, #1 - str r0, [r5, #4] - b _021ED42E -_021ED424: - bl MTRandom - mov r1, #3 - and r0, r1 - str r0, [sp, #8] -_021ED42E: - ldr r1, [sp, #8] - ldr r0, [r4, #4] - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - bl Sprite_SetAnimationFrame - ldr r0, [sp, #0xc] - add r1, r0, #1 - ldr r0, [sp, #4] - str r1, [sp, #0xc] - cmp r1, r0 - bge _021ED448 - b _021ED330 -_021ED448: - add sp, #0x1c - pop {r4, r5, r6, r7, pc} - thumb_func_end ov01_021ED31C - - thumb_func_start ov01_021ED44C -ov01_021ED44C: ; 0x021ED44C - push {r4, r5, lr} - sub sp, #0xc - add r5, r0, #0 - ldr r4, [r5, #8] - add r0, sp, #0 - add r1, r5, #0 - bl ov01_021EC304 - ldr r0, [r4] - add r1, r0, #1 - str r1, [r4] - ldr r0, [r4, #4] - cmp r1, r0 - blt _021ED46E - add r0, r5, #0 - bl ov01_021EC29C -_021ED46E: - add sp, #0xc - pop {r4, r5, pc} - .balign 4, 0 - thumb_func_end ov01_021ED44C - - thumb_func_start ov01_021ED474 -ov01_021ED474: ; 0x021ED474 - push {r4, r5, r6, lr} - sub sp, #0x10 - add r6, r2, #0 - ldr r2, _021ED580 ; =0x00000F62 - add r4, r0, #0 - ldrh r0, [r4, r2] - add r5, r1, #0 - cmp r0, #5 - bhi _021ED57A - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_021ED492: ; jump table - .short _021ED49E - _021ED492 - 2 ; case 0 - .short _021ED4CE - _021ED492 - 2 ; case 1 - .short _021ED4E8 - _021ED492 - 2 ; case 2 - .short _021ED518 - _021ED492 - 2 ; case 3 - .short _021ED53C - _021ED492 - 2 ; case 4 - .short _021ED55C - _021ED492 - 2 ; case 5 -_021ED49E: - str r3, [sp] - add r0, sp, #0x10 - ldrh r0, [r0, #0x10] - add r5, #0x30 - str r0, [sp, #4] - ldr r0, [sp, #0x24] - str r0, [sp, #8] - add r0, r2, #2 - ldrh r0, [r4, r0] - mov r2, #0x41 - lsl r2, r2, #2 - str r0, [sp, #0xc] - ldr r3, [r4] - add r0, r5, #0 - ldr r2, [r3, r2] - add r3, r6, #0 - ldr r2, [r2, #0x4c] - bl ov01_021EC5FC - ldr r0, _021ED580 ; =0x00000F62 - mov r1, #1 - add sp, #0x10 - strh r1, [r4, r0] - pop {r4, r5, r6, pc} -_021ED4CE: - add r2, r2, #2 - ldrh r2, [r4, r2] - add r5, #0x30 - add r0, r5, #0 - bl ov01_021EC650 - cmp r0, #1 - bne _021ED57A - ldr r0, _021ED580 ; =0x00000F62 - mov r1, #3 - add sp, #0x10 - strh r1, [r4, r0] - pop {r4, r5, r6, pc} -_021ED4E8: - add r0, r2, #2 - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ED50E - mov r0, #0x41 - ldr r1, [r4] - lsl r0, r0, #2 - ldr r0, [r1, r0] - add r2, r3, #0 - ldr r0, [r0, #0x4c] - add r3, sp, #0x10 - str r0, [r5] - ldrh r3, [r3, #0x10] - add r1, r6, #0 - bl ov01_021EC678 - add r0, r5, #0 - bl ov01_021EC7C8 -_021ED50E: - ldr r0, _021ED580 ; =0x00000F62 - mov r1, #3 - add sp, #0x10 - strh r1, [r4, r0] - pop {r4, r5, r6, pc} -_021ED518: - add r0, r2, #4 - ldrh r0, [r4, r0] - cmp r0, #5 - bne _021ED57A - add r0, r2, #2 - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ED532 - ldr r1, [sp, #0x28] - add r0, r5, #0 - mov r2, #0 - bl ov01_021EC790 -_021ED532: - ldr r0, _021ED580 ; =0x00000F62 - mov r1, #4 - add sp, #0x10 - strh r1, [r4, r0] - pop {r4, r5, r6, pc} -_021ED53C: - add r0, r2, #2 - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ED54C - add r0, r5, #0 - bl ov01_021EC7AC - b _021ED54E -_021ED54C: - mov r0, #1 -_021ED54E: - cmp r0, #1 - bne _021ED57A - ldr r0, _021ED580 ; =0x00000F62 - mov r1, #5 - add sp, #0x10 - strh r1, [r4, r0] - pop {r4, r5, r6, pc} -_021ED55C: - add r0, r2, #2 - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ED574 - mov r2, #0 - str r2, [sp] - str r2, [sp, #4] - ldr r0, [r5] - mov r1, #1 - add r3, r2, #0 - bl ov01_021EA864 -_021ED574: - ldr r0, [r4, #4] - bl ov01_021EBCA4 -_021ED57A: - add sp, #0x10 - pop {r4, r5, r6, pc} - nop -_021ED580: .word 0x00000F62 - thumb_func_end ov01_021ED474 - - thumb_func_start ov01_021ED584 -ov01_021ED584: ; 0x021ED584 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x10 - ldr r0, _021ED700 ; =0x00000F58 - add r4, r1, #0 - add r1, r0, #0 - add r1, #0xa - ldrh r1, [r4, r1] - ldr r5, [r4, r0] - cmp r1, #5 - bls _021ED59A - b _021ED6FC -_021ED59A: - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_021ED5A6: ; jump table - .short _021ED5B2 - _021ED5A6 - 2 ; case 0 - .short _021ED602 - _021ED5A6 - 2 ; case 1 - .short _021ED630 - _021ED5A6 - 2 ; case 2 - .short _021ED670 - _021ED5A6 - 2 ; case 3 - .short _021ED6A4 - _021ED5A6 - 2 ; case 4 - .short _021ED6DE - _021ED5A6 - 2 ; case 5 -_021ED5B2: - ldr r1, _021ED704 ; =0x00007555 - mov r2, #0x41 - str r1, [sp] - ldr r1, _021ED708 ; =0x00007FFF - add r0, #0xc - str r1, [sp, #4] - mov r1, #1 - str r1, [sp, #8] - ldrh r0, [r4, r0] - add r1, r5, #0 - lsl r2, r2, #2 - str r0, [sp, #0xc] - ldr r3, [r4] - add r0, r5, #0 - ldr r2, [r3, r2] - add r0, #0x44 - ldr r2, [r2, #0x4c] - add r1, #0x14 - mov r3, #6 - bl ov01_021EC5FC - add r0, r5, #0 - mov r1, #0 - mov r2, #9 - mov r3, #0x1e - bl ov01_021EB830 - mov r0, #0 - mov r1, #0x10 - bl ov01_021EB818 - mov r0, #4 - mov r1, #1 - bl GfGfx_EngineATogglePlanes - ldr r0, _021ED70C ; =0x00000F62 - mov r1, #1 - add sp, #0x10 - strh r1, [r4, r0] - pop {r3, r4, r5, r6, r7, pc} -_021ED602: - add r0, r5, #0 - add r0, #0x14 - bl ov01_021EC7AC - add r6, r0, #0 - add r0, r5, #0 - bl ov01_021EB840 - add r7, r0, #0 - ldr r0, [r5] - mov r1, #0x10 - sub r1, r1, r0 - bl ov01_021EB818 - cmp r6, #1 - bne _021ED6FC - cmp r7, #1 - bne _021ED6FC - ldr r0, _021ED70C ; =0x00000F62 - mov r1, #3 - add sp, #0x10 - strh r1, [r4, r0] - pop {r3, r4, r5, r6, r7, pc} -_021ED630: - add r0, #0xc - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ED656 - mov r0, #0x41 - ldr r1, [r4] - lsl r0, r0, #2 - ldr r0, [r1, r0] - ldr r2, _021ED704 ; =0x00007555 - ldr r0, [r0, #0x4c] - ldr r3, _021ED708 ; =0x00007FFF - mov r1, #6 - str r0, [r5, #0x14] - bl ov01_021EC678 - add r5, #0x14 - add r0, r5, #0 - bl ov01_021EC7C8 -_021ED656: - mov r0, #9 - mov r1, #7 - bl ov01_021EB818 - mov r0, #4 - mov r1, #1 - bl GfGfx_EngineATogglePlanes - ldr r0, _021ED70C ; =0x00000F62 - mov r1, #3 - add sp, #0x10 - strh r1, [r4, r0] - pop {r3, r4, r5, r6, r7, pc} -_021ED670: - add r1, r0, #0 - add r1, #0xe - ldrh r1, [r4, r1] - cmp r1, #5 - bne _021ED6FC - add r0, #0xc - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ED68E - add r0, r5, #0 - add r0, #0x14 - mov r1, #1 - mov r2, #0 - bl ov01_021EC790 -_021ED68E: - add r0, r5, #0 - mov r1, #9 - mov r2, #0 - mov r3, #0x1e - bl ov01_021EB830 - ldr r0, _021ED70C ; =0x00000F62 - mov r1, #4 - add sp, #0x10 - strh r1, [r4, r0] - pop {r3, r4, r5, r6, r7, pc} -_021ED6A4: - add r0, #0xc - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ED6B8 - add r0, r5, #0 - add r0, #0x14 - bl ov01_021EC7AC - add r6, r0, #0 - b _021ED6BA -_021ED6B8: - mov r6, #1 -_021ED6BA: - add r0, r5, #0 - bl ov01_021EB840 - add r7, r0, #0 - ldr r0, [r5] - mov r1, #0x10 - sub r1, r1, r0 - bl ov01_021EB818 - cmp r6, #1 - bne _021ED6FC - cmp r7, #1 - bne _021ED6FC - ldr r0, _021ED70C ; =0x00000F62 - mov r1, #5 - add sp, #0x10 - strh r1, [r4, r0] - pop {r3, r4, r5, r6, r7, pc} -_021ED6DE: - add r0, #0xc - ldrh r0, [r4, r0] - cmp r0, #0 - beq _021ED6F6 - mov r2, #0 - str r2, [sp] - str r2, [sp, #4] - ldr r0, [r5, #0x14] - mov r1, #1 - add r3, r2, #0 - bl ov01_021EA864 -_021ED6F6: - ldr r0, [r4, #4] - bl ov01_021EBCA4 -_021ED6FC: - add sp, #0x10 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_021ED700: .word 0x00000F58 -_021ED704: .word 0x00007555 -_021ED708: .word 0x00007FFF -_021ED70C: .word 0x00000F62 - thumb_func_end ov01_021ED584 + .public ov01_021ED0F0 + .public ov01_021ED31C + .public ov01_021ED474 + .public ov01_021ED584 thumb_func_start ov01_021ED710 ov01_021ED710: ; 0x021ED710 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 40378d66c4..07d8eb250a 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -111,6 +111,18 @@ typedef struct UnkStruct_021EC94C { s32 data[10]; } UnkStruct_021EC94C; +typedef struct UnkStruct_021ED474 { + UnkStruct_021EC774 unk1C; + UnkStruct_021EC5FC unk50; + s32 data[10]; +} UnkStruct_021ED474; + +typedef struct UnkStruct_021ED584 { + UnkWeatherStruct_021EB830 unk0; + UnkStruct_021EC774 unk1C; + UnkStruct_021EC5FC unk50; +} UnkStruct_021ED584; + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); void WeatherManager_Delete(WeatherManager* weatherManager); @@ -189,6 +201,12 @@ void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *, int); void ov01_021ECC70(WeatherSystem_Sub0_Sub8_LinkedList *a0); void ov01_021ECD08(SysTask *task, void* data); void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1); +void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList *a0); +void ov01_021ED0F0(SysTask *task, void* data); +void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1); +void ov01_021ED44C(WeatherSystem_Sub0_Sub8_LinkedList *a0); +void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, s32 arg2, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6); +void ov01_021ED584(SysTask *task, void* data); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -207,6 +225,5 @@ GXRgb ov01_021EA860(s32 a0); void ov01_021EA89C(s32 a0, s32 a1, GXRgb rgb, s32 a2); void ov01_021EA8C4(u32 unk0, u8 *unk4); void ov01_021EDA7C(SysTask *task, void *data); -void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList *); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 51a0020bd1..29c4edbee8 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -1623,4 +1623,294 @@ void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1) { ov01_021EB5F4(v1->unk4, &vec); } -} \ No newline at end of file +} + +void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList* a0) { + s32 *data = a0->unk8; + VecFx32 vec = ov01_021EC304(a0); + + switch (data[3]) { + case 0: + vec.x += data[4] << FX32_SHIFT; + vec.y += data[2] << FX32_SHIFT; + + if (data[0]++ > data[1]) { + data[3] = 1; + } + + if (data[0] % data[5] == 0) { + data[4]--; + + if (data[2] > 1) { + data[2]--; + } + } + + ov01_021EB5F4(a0->unk4, &vec); + break; + case 1: + ov01_021EC29C(a0); + break; + } +} + +void ov01_021ED0F0(SysTask *task, void* data) { + WeatherSystem_Sub0_Sub8 *v0 = data; + + UnkStruct_021EC94C *v1 = v0->unkF58; + + switch (v0->unkF62) { + case 0: + ov01_021EC504(&v1->unk0, v0, 2, 16, 20, 2, -2, 4, 2, ov01_021ED31C); + + + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->unk_4C, 3, 0x716F, GX_RGB(26,26,26), 1, v0->unkF64); + + v1->data[0] = 0; + v0->unkF62 = 1; + break; + case 1: + int v2 = ov01_021EC538(&v1->unk0); + if (v1->data[0] > 0) { + v1->data[0]--; + } else { + int v3 = ov01_021EC650(&v1->unk50, &v1->unk1C, v0->unkF64); + if (v3 == 1 && v2 == 3) { + v0->unkF62 = 3; + } + } + break; + case 2: + ov01_021EC504(&v1->unk0, v0, 20, 2, 20, 2, -2, 4, 2, ov01_021ED31C); + + if (v0->unkF64) { + v1->unk1C.unk0 = v0->weatherSystem->fieldSystem->unk_4C; + ov01_021EC678(v1->unk1C.unk0, 3, 0x716f, GX_RGB(26,26,26)); + ov01_021EC7C8(&v1->unk1C); + } + + ov01_021EC85C(v0, ov01_021ED31C, 20, 10, 1, ov01_021ED44C); + + v0->unkF62 = 3; + break; + case 3: + if (v1->unk0.unk6-- <= 0) { + ov01_021ED31C(v0, v1->unk0.unk4); + v1->unk0.unk6 = v1->unk0.unk8; + } + + if (v0->unkF66 == 5) { + ov01_021EC52C(&v1->unk0, 0, 16, 6, -10); + + if (v0->unkF64) { + ov01_021EC790(&v1->unk1C, 1, 0); + } + v1->data[0] = 20; + v0->unkF62 = 4; + } + break; + case 4: + int ret = ov01_021EC538(&v1->unk0); + if (v1->data[0] > 0) { + v1->data[0]--; + } else { + int vUnk = ov01_021EC650(&v1->unk50, &v1->unk1C, v0->unkF64); + + if (vUnk == 1 && ret == 3) { + if (v0->linkedListDummy.next == &v0->linkedListDummy) { + v0->unkF62 = 5; + } + } + + } + break; + case 5: + if (v0->unkF64) { + ov01_021EA864(v1->unk1C.unk0, 1, 0, 0, 0, 0); + } + ov01_021EBCA4(v0->unk4); + break; + } + + if (v0->unkF62 != 5 && v0->unkF62 != 0) { + ov01_021EC2E4(&v0->linkedListDummy, ov01_021ED44C); + ov01_021EC470(v0, NULL, NULL); + ov01_021EC300(v0); + } +} + +void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { + VecFx32 vec; + for (int i = 0; i < a1; i++) { + WeatherSystem_Sub0_Sub8_LinkedList *v0 = ov01_021EC1F4(a0, 32); + if (v0 == NULL) { + break; + } + + u32 *data = v0->unk8; + + data[0] = 0; + data[1] = 7 + (MTRandom() % 5); + + int rand = MTRandom() % 1000; + + if ((rand % 2) == 0) { + data[2] = 1; + } else { + data[2] = -1; + } + + data[3] = 1; + data[4] = 3 + (MTRandom() % 6); + data[5] = 4 + (MTRandom() % 5); + + int frame = MTRandom() % 20; + + vec = ov01_021EC304(v0); + vec.x = -64 + (MTRandom() % 384); + vec.y = -8 + ((u32)MTRandom() % 256); + vec.x <<= FX32_SHIFT; + vec.y <<= FX32_SHIFT; + vec.z = 0; + ov01_021EB5F4(v0->unk4, &vec); + vec.x >>= FX32_SHIFT; + vec.y >>= FX32_SHIFT; + + int v1 = 50 - vec.x/3; + int v2 = 206 - vec.x/3; + int v3; + if (v2 < 0) { + v2 *= -1; + v3 = v1 - (MTRandom() % v2); + } else { + v3 = v1 + (MTRandom() % v2); + } + + if (v1 <= vec.y && v3 >= vec.y) { + data[1] *= 2; + } else { + frame = MTRandom() & 3; + } + Sprite_SetAnimationFrame(v0->unk4, frame); + } +} + +void ov01_021ED44C(WeatherSystem_Sub0_Sub8_LinkedList *a0) { + s32 *data = a0->unk8; + ov01_021EC304(a0); + if (++data[0] >= data[1]) { + ov01_021EC29C(a0); + } +} + +void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, s32 arg2, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6) { + switch (a0->unkF62) { + case 0: + ov01_021EC5FC(&a1->unk50, &a1->unk1C, a0->weatherSystem->fieldSystem->unk_4C, arg2, arg3, arg4, arg5, a0->unkF64); + a0->unkF62 = 1; + break; + case 1: + int v3 = ov01_021EC650(&a1->unk50, &a1->unk1C, a0->unkF64); + if (v3 == 1) { + a0->unkF62 = 3; + } + break; + case 2: + if (a0->unkF64 != 0) { + a1->unk1C.unk0 = a0->weatherSystem->fieldSystem->unk_4C; + ov01_021EC678(a1->unk1C.unk0, arg2, arg3, arg4); + ov01_021EC7C8(&a1->unk1C); + } + a0->unkF62 = 3; + break; + case 3: + if (a0->unkF66 == 5) { + if (a0->unkF64 != 0) { + ov01_021EC790(&a1->unk1C, arg6, 0); + } + a0->unkF62 = 4; + } + break; + case 4: + int ret; + if (a0->unkF64 != 0) { + ret = ov01_021EC7AC(&a1->unk1C); + } else { + ret = 1; + } + + if (ret == 1) { + a0->unkF62 = 5; + } + break; + case 5: + if (a0->unkF64 != 0) { + ov01_021EA864(a1->unk1C.unk0, 1, 0, 0, 0, 0); + } + ov01_021EBCA4(a0->unk4); + break; + } +} + +void ov01_021ED584(SysTask *task, void* data) { + WeatherSystem_Sub0_Sub8 *v0 = data; + UnkStruct_021ED584 *v1 = v0->unkF58; + + switch (v0->unkF62) { + case 0: + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->unk_4C, 6, 0x7555, 0x7fff, 1, v0->unkF64); + ov01_021EB830(&v1->unk0, 0, 9, 30); + ov01_021EB818(0, 16); + GfGfx_EngineATogglePlanes(4, 1); + v0->unkF62 = 1; + break; + case 1: + int v2 = ov01_021EC7AC(&v1->unk1C); + int v3 = ov01_021EB840(&v1->unk0); + ov01_021EB818(v1->unk0.unk0, 16 - v1->unk0.unk0); + if (v2 == 1 && v3 == 1) { + v0->unkF62 = 3; + } + break; + case 2: + if (v0->unkF64 != 0) { + v1->unk1C.unk0 = v0->weatherSystem->fieldSystem->unk_4C; + ov01_021EC678(v1->unk1C.unk0, 6, 0x7555, 0x7fff); + ov01_021EC7C8(&v1->unk1C); + } + ov01_021EB818(9, 7); + GfGfx_EngineATogglePlanes(4, 1); + v0->unkF62 = 3; + break; + case 3: + if (v0->unkF66 == 5) { + if (v0->unkF64 != 0) { + ov01_021EC790(&v1->unk1C, 1, 0); + } + ov01_021EB830(&v1->unk0, 9, 0, 30); + v0->unkF62 = 4; + } + break; + case 4: + int v4; + if (v0->unkF64 != 0) { + v4 = ov01_021EC7AC(&v1->unk1C); + } else { + v4 = 1; + } + + int v5 = ov01_021EB840(&v1->unk0); + ov01_021EB818(v1->unk0.unk0, 16 - v1->unk0.unk0); + if (v4 == 1 && v5 == 1) { + v0->unkF62 = 5; + } + break; + case 5: + if (v0->unkF64 != 0) { + ov01_021EA864(v1->unk1C.unk0, 1, 0, 0, 0, 0); + } + ov01_021EBCA4(v0->unk4); + break; + } +} + From ae1386e4ed7bae98aed662d538e4ea21b7d84689 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 9 Jun 2026 01:16:04 -0400 Subject: [PATCH 19/22] Identify field/fog.c --- asm/include/overlay_01_021E5900.inc | 2 +- asm/include/overlay_01_021EB1E8.inc | 6 +- asm/overlay_01_021E5900.s | 2 +- asm/overlay_01_021EB1E8.s | 6 +- include/field/fog.h | 31 +++++ include/field/weather_manager.h | 40 +++---- include/field_system.h | 3 +- include/overlay_01_021EA824.h | 31 ----- main.lsf | 2 +- src/field/fog.c | 61 ++++++++++ src/field/weather_manager.c | 174 ++++++++++++++-------------- src/overlay_01_021EA824.c | 61 ---------- 12 files changed, 207 insertions(+), 212 deletions(-) create mode 100644 include/field/fog.h delete mode 100644 include/overlay_01_021EA824.h create mode 100644 src/field/fog.c delete mode 100644 src/overlay_01_021EA824.c diff --git a/asm/include/overlay_01_021E5900.inc b/asm/include/overlay_01_021E5900.inc index 67ab55cc54..925f987e33 100644 --- a/asm/include/overlay_01_021E5900.inc +++ b/asm/include/overlay_01_021E5900.inc @@ -129,7 +129,7 @@ .public ov01_021EA220 .public ov01_021EA284 .public ov01_021EA2A4 -.public ov01_021EA824 +.public Fog_New .public ov01_021EA840 .public ov01_021EA8E0 .public ov01_021EA8FC diff --git a/asm/include/overlay_01_021EB1E8.inc b/asm/include/overlay_01_021EB1E8.inc index 4e19e41255..f121de4b38 100644 --- a/asm/include/overlay_01_021EB1E8.inc +++ b/asm/include/overlay_01_021EB1E8.inc @@ -76,9 +76,9 @@ .public _u32_div_f .public _ddiv .public NNS_G3dGlb -.public ov01_021EA854 -.public ov01_021EA858 -.public ov01_021EA85C +.public Fog_CheckActive +.public Fog_GetSlope +.public Fog_GetOffset .public ov01_021EA860 .public ov01_021EA864 .public ov01_021EA89C diff --git a/asm/overlay_01_021E5900.s b/asm/overlay_01_021E5900.s index 07eded4f70..04136928ac 100644 --- a/asm/overlay_01_021E5900.s +++ b/asm/overlay_01_021E5900.s @@ -1492,7 +1492,7 @@ ov01_021E6580: ; 0x021E6580 bl ov01_021EA8E0 str r0, [r4, #0x48] bl ov01_021E61A4 - bl ov01_021EA824 + bl Fog_New str r0, [r4, #0x4c] ldr r0, [r4, #0xc] bl Save_LocalFieldData_Get diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index fce9697115..9ae1118a99 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -15,8 +15,8 @@ .text .public WeatherDraw_Init .public WeatherDraw_Delete - .public ov01_021EB5F4 - .public ov01_021EB68C + .public WeatherDraw_SetSpriteMatrix + .public WeatherSystem_Delete .public ov01_021EB804 .public ov01_021EB830 .public ov01_021EB818 @@ -24,7 +24,7 @@ .public ov01_021EB86C .public ov01_021EB898 .public ov01_021EB968 - .public ov01_021EB9A8 + .public WeatherSystem_Init .public ov01_021EBCA4 .public ov01_021EC1BC .public ov01_021EC1E4 diff --git a/include/field/fog.h b/include/field/fog.h new file mode 100644 index 0000000000..ffaceeb500 --- /dev/null +++ b/include/field/fog.h @@ -0,0 +1,31 @@ +#ifndef POKEHEARTGOLD_FIELD_FOG_H +#define POKEHEARTGOLD_FIELD_FOG_H + +#include "global.h" + +#include "gf_3d_vramman.h" +#include "gf_gfx_planes.h" + +void G3X_SetFogTable(u32 *fogTable); + +typedef struct FogData { + BOOL enable; + GXFogBlend fogMode; + GXFogSlope fogSlope; + int fogOffset; + u16 unk10; + u32 unk14; + u32 fogTable[8]; +} FogData; + +FogData *Fog_New(); +void ov01_021EA840(s32 *arg0); +BOOL Fog_CheckActive(FogData *arg0); +GXFogSlope Fog_GetSlope(FogData *arg0); +int Fog_GetOffset(FogData *arg0); +u16 ov01_021EA860(FogData *arg0); +void ov01_021EA864(FogData *arg0, s32 arg1, BOOL enable, GXFogBlend fogMode, GXFogSlope fogSlope, int fogOffset); +void ov01_021EA89C(FogData *arg0, u32 arg1, u16 arg2, u32 arg3); +void ov01_021EA8C4(FogData *arg0, u8 *src); + +#endif // POKEHEARTGOLD_FIELD_FOG_H diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 07d8eb250a..e19c90f962 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -4,6 +4,7 @@ #include "global.h" #include "task.h" #include "sprite.h" +#include "field/fog.h" typedef struct UnkWeatherStruct_021EB968 { SpriteResource *charResObj[4]; @@ -54,7 +55,7 @@ typedef struct UnkStruct_ov01_021EB1E8 { } UnkStruct_ov01_021EB1E8; typedef struct WeatherManager { - WeatherSystem *unk0; + WeatherSystem *weatherSystem; u32 weather; u32 nextWeather; u32 state; @@ -87,7 +88,7 @@ typedef struct UnkStruct_021EC504 { typedef void (*UnkLinkedListFunc)(WeatherSystem_Sub0_Sub8_LinkedList *); typedef struct UnkStruct_021EC5FC { - s32 unk0; + FogData *fog; UnkWeatherStruct_021EB830 unk4; UnkWeatherStruct_021EB830 unk18; UnkWeatherStruct_021EB830 unk2C; @@ -96,7 +97,7 @@ typedef struct UnkStruct_021EC5FC { } UnkStruct_021EC5FC; typedef struct UnkStruct_021EC774 { - u32 unk0; + FogData *fog; u8 unk4[0x20]; s32 unk24; s32 unk28; @@ -130,18 +131,18 @@ void WeatherManager_SetWeather(WeatherManager* weatherManager, int a1); BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather); u32 WeatherManager_GetWeather(WeatherManager *weatherManager); WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem); -void ov01_021EB68C(WeatherSystem** pWeatherSystem); -BOOL ov01_021EB700(WeatherSystem *weatherSystem, int state, int weather); +void WeatherSystem_Delete(WeatherSystem** pWeatherSystem); +BOOL WeatherSystem_Process(WeatherSystem *weatherSystem, int state, int weather); // Static functions void WeatherTask_ChangeWeather(SysTask* task, void *data); void ov01_021EB3F0(SysTask* task, void *data); BOOL ov01_021EB4B4(u32 weather, u32 nextWeather); void WeatherDraw_Init(WeatherDraw* weatherDraw); -void ov01_021EB56C(SysTask *task, void *data); -void ov01_021EB578(GF_2DGfxResHeader *headerList, u32 a1, u32 a2); +void WeatherDrawTask_RendAndAnimateSprites(SysTask *task, void *data); +void Weather_Init2DGfxRes(GF_2DGfxResHeader *headerList, u32 a1, u32 a2); void WeatherDraw_Delete(WeatherDraw* weatherDraw); -void ov01_021EB5F4(Sprite *sprite, VecFx32* matrix); +void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32* matrix); u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather); void ov01_021EB818(u32 arg0, u32 arg1); void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3); @@ -149,7 +150,7 @@ BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0); void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, UnkWeatherStruct_021EB968 *arg2); SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resIndex, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd); void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, UnkWeatherStruct_021EB968* a2); -BOOL ov01_021EB9A8(WeatherSystem* weatherSystem, int weather); +BOOL WeatherSystem_Init(WeatherSystem* weatherSystem, int weather); BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2); void ov01_021EBB68(WeatherSystem *weatherSystem, int weather); @@ -182,10 +183,10 @@ void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y); void ov01_021EC504(UnkStruct_021EC504* arg0, WeatherSystem_Sub0_Sub8 *arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkWeatherSystemSub0Sub8Func arg9); void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4); s32 ov01_021EC538(UnkStruct_021EC504* arg0); -void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb arg5, s32 arg6, s32 arg7); +void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7); BOOL ov01_021EC650(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774 *arg1, s32 arg2); -void ov01_021EC678(s32 arg0, s32 arg1, s32 arg2, GXRgb rgb); -void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, s32 a1, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5); +void ov01_021EC678(FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb); +void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5); BOOL ov01_021EC728(UnkStruct_021EC5FC *arg0); void ov01_021EC774(UnkStruct_021EC774* a0); void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2); @@ -205,25 +206,18 @@ void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList *a0); void ov01_021ED0F0(SysTask *task, void* data); void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1); void ov01_021ED44C(WeatherSystem_Sub0_Sub8_LinkedList *a0); -void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, s32 arg2, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6); +void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, GXFogSlope fogSlope, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6); void ov01_021ED584(SysTask *task, void* data); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); -void ov01_021EB56C(SysTask *task, void *data); -void ov01_021EB578(GF_2DGfxResHeader *header, u32 a1, u32 a2); -void ov01_021EA864(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 a5); -BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); -BOOL ov01_021EA854(u32 a0); +void WeatherDrawTask_RendAndAnimateSprites(SysTask *task, void *data); +void Weather_Init2DGfxRes(GF_2DGfxResHeader *header, u32 a1, u32 a2); +BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); void ov01_021EBD70(SysTask *task, void *data); void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1); -int ov01_021EA858(s32 a0); -int ov01_021EA85C(s32 a0); -GXRgb ov01_021EA860(s32 a0); -void ov01_021EA89C(s32 a0, s32 a1, GXRgb rgb, s32 a2); -void ov01_021EA8C4(u32 unk0, u8 *unk4); void ov01_021EDA7C(SysTask *task, void *data); #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/include/field_system.h b/include/field_system.h index 1f3de5c663..60430f19db 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -25,6 +25,7 @@ #include "sys_task_api.h" #include "terrain_attributes.h" #include "unk_02092BB8.h" +#include "field/fog.h" typedef struct FollowMon { LocalMapObject *mapObject; @@ -128,7 +129,7 @@ struct FieldSystem { PlayerAvatar *playerAvatar; void *unk_44; u32 unk_48; - u32 unk_4C; + FogData *fog; u32 unk_50; void *unk54; u32 unk58; diff --git a/include/overlay_01_021EA824.h b/include/overlay_01_021EA824.h deleted file mode 100644 index 54fbcb80d1..0000000000 --- a/include/overlay_01_021EA824.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef POKEHEARTGOLD_OVERLAY_01_021EA824_H -#define POKEHEARTGOLD_OVERLAY_01_021EA824_H - -#include "global.h" - -#include "gf_3d_vramman.h" -#include "gf_gfx_planes.h" - -void G3X_SetFogTable(u32 *fogTable); - -typedef struct { - BOOL enable; - GXFogBlend fogMode; - GXFogSlope fogSlope; - int fogOffset; - u16 unk10; - u32 unk14; - u32 fogTable[8]; -} UnkStruct_Ov01_021EA824; - -UnkStruct_Ov01_021EA824 *ov01_021EA824(); -void ov01_021EA840(s32 *arg0); -BOOL ov01_021EA854(UnkStruct_Ov01_021EA824 *arg0); -GXFogSlope ov01_021EA858(UnkStruct_Ov01_021EA824 *arg0); -int ov01_021EA85C(UnkStruct_Ov01_021EA824 *arg0); -u16 ov01_021EA860(UnkStruct_Ov01_021EA824 *arg0); -void ov01_021EA864(UnkStruct_Ov01_021EA824 *arg0, s32 arg1, BOOL enable, GXFogBlend fogMode, GXFogSlope fogSlope, int fogOffset); -void ov01_021EA89C(UnkStruct_Ov01_021EA824 *arg0, u32 arg1, u16 arg2, u32 arg3); -void ov01_021EA8C4(UnkStruct_Ov01_021EA824 *arg0, const u32 *src); - -#endif // POKEHEARTGOLD_OVERLAY_01_021EA824_H diff --git a/main.lsf b/main.lsf index 0032141634..01b08e2a49 100644 --- a/main.lsf +++ b/main.lsf @@ -493,7 +493,7 @@ Overlay field Object asm/overlay_01_021E8744.o Object asm/overlay_01_021E90C0.o Object asm/overlay_01_021EA6C4.o - Object src/overlay_01_021EA824.o + Object src/field/fog.o Object asm/overlay_01_021EA8E0.o Object asm/overlay_01_021EABA8.o Object asm/overlay_01_021EAF00.o diff --git a/src/field/fog.c b/src/field/fog.c new file mode 100644 index 0000000000..303b647f22 --- /dev/null +++ b/src/field/fog.c @@ -0,0 +1,61 @@ +#include "field/fog.h" + +#include "global.h" + +FogData *Fog_New() { + FogData *dst = Heap_Alloc(HEAP_ID_FIELD1, sizeof(FogData)); + MIi_CpuClear32(0, (void *)dst, sizeof(FogData)); + return dst; +} + +void ov01_021EA840(s32 *arg0) { + Heap_FreeExplicit(HEAP_ID_FIELD1, (void *)*arg0); + *arg0 = 0; +} + +BOOL Fog_CheckActive(FogData *fog) { + return fog->enable; +} + +GXFogSlope Fog_GetSlope(FogData *fog) { + return fog->fogSlope; +} + +int Fog_GetOffset(FogData *fog) { + return fog->fogOffset; +} + +u16 ov01_021EA860(FogData *fog) { + return fog->unk10; +} + +void ov01_021EA864(FogData *fog, s32 arg1, BOOL enable, GXFogBlend fogMode, GXFogSlope fogSlope, int fogOffset) { + if (arg1 & 1 << 0) { + fog->enable = enable; + } + if (arg1 & 1 << 1) { + fog->fogMode = fogMode; + } + if (arg1 & 1 << 2) { + fog->fogSlope = fogSlope; + } + if (arg1 & 1 << 3) { + fog->fogOffset = fogOffset; + } + G3X_SetFog(fog->enable, fog->fogMode, fog->fogSlope, fog->fogOffset); +} + +void ov01_021EA89C(FogData *fog, u32 arg1, u16 arg2, u32 arg3) { + if (arg1 & 1 << 4) { + fog->unk10 = arg2; + } + if (arg1 & 1 << 5) { + fog->unk14 = arg3; + } + reg_G3X_FOG_COLOR = fog->unk10 | (fog->unk14 << 16); +} + +void ov01_021EA8C4(FogData *fog, u8 *src) { + MIi_CpuCopy32((const s32 *)src, fog->fogTable, 32); + G3X_SetFogTable(fog->fogTable); +} diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 29c4edbee8..fddb579726 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -59,7 +59,7 @@ WeatherManager *WeatherManager_New(FieldSystem *fieldSystem) { memset(weatherManager, 0, sizeof(WeatherManager)); - weatherManager->unk0 = WeatherSystem_New(fieldSystem); + weatherManager->weatherSystem = WeatherSystem_New(fieldSystem); weatherManager->weather = WEATHER_SUNNY; weatherManager->nextWeather = WEATHER_SUNNY; weatherManager->state = 6; @@ -76,7 +76,7 @@ void WeatherManager_Delete(WeatherManager* weatherManager) { SysTask_Destroy(weatherManager->task); } - ov01_021EB68C(&weatherManager->unk0); + WeatherSystem_Delete(&weatherManager->weatherSystem); memset(weatherManager, 0, sizeof(WeatherManager)); @@ -88,9 +88,9 @@ void WeatherManager_SetWeather(WeatherManager* weatherManager, int weather) { GF_ASSERT(weather < WEATHER_MAX); if (weatherManager->weather != weather) { - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 8, weatherManager->weather)); - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 0, weather)); - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 3, weather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 8, weatherManager->weather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 0, weather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 3, weather)); weatherManager->weather = weather; } } @@ -129,26 +129,26 @@ void WeatherTask_ChangeWeather(SysTask* task, void *data) { WeatherManager *weatherManager = data; switch (weatherManager->state) { case 0: - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 5, weatherManager->weather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 5, weatherManager->weather)); weatherManager->state++; break; case 1: - if (ov01_021EB804(weatherManager->unk0, weatherManager->weather) != 3) { - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 8, weatherManager->weather)); + if (ov01_021EB804(weatherManager->weatherSystem, weatherManager->weather) != 3) { + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 8, weatherManager->weather)); weatherManager->state++; } break; case 2: - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 1, weatherManager->nextWeather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 1, weatherManager->nextWeather)); weatherManager->state++; break; case 3: - if (ov01_021EB804(weatherManager->unk0, weatherManager->nextWeather) != 1) { + if (ov01_021EB804(weatherManager->weatherSystem, weatherManager->nextWeather) != 1) { weatherManager->state++; } break; case 4: - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 2, weatherManager->nextWeather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 2, weatherManager->nextWeather)); weatherManager->state++; weatherManager->weather = weatherManager->nextWeather; weatherManager->nextWeather = 0; @@ -169,22 +169,22 @@ void ov01_021EB3F0(SysTask* task, void *data) { WeatherManager *weatherManager = data; switch (weatherManager->state) { case 0: - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 1, weatherManager->nextWeather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 1, weatherManager->nextWeather)); weatherManager->state++; break; case 1: - if (ov01_021EB804(weatherManager->unk0, weatherManager->nextWeather) != 1) { + if (ov01_021EB804(weatherManager->weatherSystem, weatherManager->nextWeather) != 1) { weatherManager->state++; } break; case 2: - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 7, weatherManager->weather)); - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 4, weatherManager->nextWeather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 7, weatherManager->weather)); + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 4, weatherManager->nextWeather)); weatherManager->state++; break; case 3: - if (ov01_021EB804(weatherManager->unk0, weatherManager->weather) != 3) { - GF_ASSERT(ov01_021EB700(weatherManager->unk0, 8, weatherManager->weather)); + if (ov01_021EB804(weatherManager->weatherSystem, weatherManager->weather) != 3) { + GF_ASSERT(WeatherSystem_Process(weatherManager->weatherSystem, 8, weatherManager->weather)); weatherManager->state++; } break; @@ -223,10 +223,10 @@ void WeatherDraw_Init(WeatherDraw* weatherDraw) { weatherDraw->header = Heap_Alloc(HEAP_ID_FIELD1, 4 * GF2DGfxResHeader_sizeof()); - ov01_021EB578(weatherDraw->header, 0, 0x39); - ov01_021EB578(weatherDraw->header, 1, 0x3A); - ov01_021EB578(weatherDraw->header, 2, 0x37); - ov01_021EB578(weatherDraw->header, 3, 0x38); + Weather_Init2DGfxRes(weatherDraw->header, 0, 0x39); + Weather_Init2DGfxRes(weatherDraw->header, 1, 0x3A); + Weather_Init2DGfxRes(weatherDraw->header, 2, 0x37); + Weather_Init2DGfxRes(weatherDraw->header, 3, 0x38); SpriteListParam param; param.num = 0x40; @@ -235,15 +235,15 @@ void WeatherDraw_Init(WeatherDraw* weatherDraw) { weatherDraw->spriteList = SpriteList_Create(¶m); - weatherDraw->task = SysTask_CreateOnMainQueue(ov01_021EB56C, weatherDraw, 10); + weatherDraw->task = SysTask_CreateOnMainQueue(WeatherDrawTask_RendAndAnimateSprites, weatherDraw, 10); } -void ov01_021EB56C(SysTask *task, void *data) { +void WeatherDrawTask_RendAndAnimateSprites(SysTask *task, void *data) { WeatherDraw *weatherDraw = data; SpriteList_RenderAndAnimateSprites(weatherDraw->spriteList); } -void ov01_021EB578(GF_2DGfxResHeader *headerList, u32 a1, u32 a2) { +void Weather_Init2DGfxRes(GF_2DGfxResHeader *headerList, u32 a1, u32 a2) { GF_2DGfxResHeader *header = GF2DGfxResHeader_GetByIndex(headerList, a1); GF_2DGfxResHeaderNarcList *headerNarcList = GfGfxLoader_LoadFromNarc(NARC_a_0_6_3, a2, 0, HEAP_ID_FIELD1, 1); GF2DGfxResHeader_Init(headerNarcList, header, HEAP_ID_FIELD1); @@ -266,7 +266,7 @@ void WeatherDraw_Delete(WeatherDraw* weatherDraw) { weatherDraw->task = NULL; } -void ov01_021EB5F4(Sprite *sprite, VecFx32* matrix) { +void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32* matrix) { if (matrix->x > 0x13F000) { matrix->x %= 0x13F000; } else if (matrix->x < (int)0xFFFC0000) { @@ -286,27 +286,27 @@ extern WeatherSystem_Sub0 ov01_022098B0[]; extern WeatherSystem_Sub4 ov01_0220675C[]; WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem) { - WeatherSystem *v0 = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSystem)); + WeatherSystem *weatherSystem = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSystem)); - v0->fieldSystem = fieldSystem; + weatherSystem->fieldSystem = fieldSystem; - WeatherDraw_Init(&v0->weatherDraw); + WeatherDraw_Init(&weatherSystem->weatherDraw); - v0->unk0 = ov01_022098B0; - v0->unk4 = ov01_0220675C; + weatherSystem->unk0 = ov01_022098B0; + weatherSystem->unk4 = ov01_0220675C; - v0->narc = NARC_New(NARC_a_0_6_3, HEAP_ID_FIELD1); + weatherSystem->narc = NARC_New(NARC_a_0_6_3, HEAP_ID_FIELD1); - return v0; + return weatherSystem; } -void ov01_021EB68C(WeatherSystem** pWeatherSystem) { +void WeatherSystem_Delete(WeatherSystem** pWeatherSystem) { if (*pWeatherSystem != NULL) { for (int i = 0; i < 14; i++) { ov01_021EBB90(*pWeatherSystem, i); } - ov01_021EA864((*pWeatherSystem)->fieldSystem->unk_4C, 1, 0, 0, 0, 0); + ov01_021EA864((*pWeatherSystem)->fieldSystem->fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); reg_G2_BG0CNT = (reg_G2_BG0CNT & ~3) | 1; @@ -321,7 +321,7 @@ void ov01_021EB68C(WeatherSystem** pWeatherSystem) { } } -BOOL ov01_021EB700(WeatherSystem *weatherSystem, int state, int weather) { +BOOL WeatherSystem_Process(WeatherSystem *weatherSystem, int state, int weather) { BOOL ret = TRUE; if (weather > 14) { @@ -330,22 +330,22 @@ BOOL ov01_021EB700(WeatherSystem *weatherSystem, int state, int weather) { switch (state) { case 0: - ret = ov01_021EB9A8(weatherSystem, weather); + ret = WeatherSystem_Init(weatherSystem, weather); break; case 1: ret = ov01_021EBA08(weatherSystem, weather); break; case 2: - ret = ov01_021EBA44(weatherSystem, weather, 0, 1); + ret = WeatherSystem_Start(weatherSystem, weather, 0, 1); break; case 3: - ret = ov01_021EBA44(weatherSystem, weather, 2, 1); + ret = WeatherSystem_Start(weatherSystem, weather, 2, 1); break; case 4: - if (ov01_021EA854(weatherSystem->fieldSystem->unk_4C) == 1) { - ret = ov01_021EBA44(weatherSystem, weather, 0, 2); + if (Fog_CheckActive(weatherSystem->fieldSystem->fog) == 1) { + ret = WeatherSystem_Start(weatherSystem, weather, 0, 2); } else { - ret = ov01_021EBA44(weatherSystem, weather, 0, 1); + ret = WeatherSystem_Start(weatherSystem, weather, 0, 1); } break; case 5: @@ -465,7 +465,7 @@ void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, UnkWeatherStruct_021EB9 } } -BOOL ov01_021EB9A8(WeatherSystem* weatherSystem, int weather) { +BOOL WeatherSystem_Init(WeatherSystem* weatherSystem, int weather) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; if (v0->unk8 == 0) { if (ov01_021EBE4C(weatherSystem, v0) == FALSE) { @@ -508,7 +508,7 @@ BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather) { return TRUE; } -BOOL ov01_021EBA44(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3) { +BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; if (v0->unk0 != 0xFFFF && v0->unkC == 0) { @@ -625,7 +625,7 @@ void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { v0->unk8 = NULL; } - ov01_021EA864(weatherSystem->fieldSystem->unk_4C, 1, 0, 0, 0, 0); + ov01_021EA864(weatherSystem->fieldSystem->fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } void ov01_021EBCA4(WeatherSystem_Sub0* a0) { @@ -1017,7 +1017,7 @@ void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y) { matrix.x -= xScale; matrix.y -= yScale; - ov01_021EB5F4(cur->unk4, &matrix); + WeatherDraw_SetSpriteMatrix(cur->unk4, &matrix); cur = cur->next; } @@ -1113,15 +1113,15 @@ s32 ov01_021EC538(UnkStruct_021EC504* arg0) { return var_r4; } -void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, s32 arg2, s32 arg3, s32 arg4, GXRgb rgb, s32 arg6, s32 arg7) { - arg1->unk0 = arg2; +void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7) { + arg1->fog = fog; if (arg7 != 0) { if (arg7 == 1) { - ov01_021EC678(arg2, arg3, arg4, rgb); + ov01_021EC678(fog, fogSlope, fogOffset, rgb); ov01_021EC774(arg1); ov01_021EC790(arg1, arg6, 1); } else if (arg7 == 2) { - ov01_021EC6A4(arg0, arg2, arg3, arg4, rgb, 0x7F * arg6); + ov01_021EC6A4(arg0, fog, fogSlope, fogOffset, rgb, 0x7F * arg6); } } } @@ -1142,17 +1142,17 @@ BOOL ov01_021EC650(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774 *arg1, s32 arg2) return var_r4; } -void ov01_021EC678(s32 arg0, s32 arg1, s32 arg2, GXRgb rgb) { - ov01_021EA864(arg0, -1, 1, 0, arg1, arg2); - ov01_021EA89C(arg0, -1, rgb, 0x1F); +void ov01_021EC678(FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb) { + ov01_021EA864(fog, -1, TRUE, GX_FOGBLEND_COLOR_ALPHA, fogSlope, fogOffset); + ov01_021EA89C(fog, -1, rgb, 0x1F); } -void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, s32 a1, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5) { - int v0 = ov01_021EA858(a1); - int v1 = ov01_021EA85C(a1); - GXRgb v2 = ov01_021EA860(a1); +void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5) { + int v0 = Fog_GetSlope(fog); + int v1 = Fog_GetOffset(fog); + GXRgb v2 = ov01_021EA860(fog); - arg0->unk0 = a1; + arg0->fog = fog; ov01_021EB830(&arg0->unk4, v1, arg3, arg5); ov01_021EB830(&arg0->unk18, v2 & GX_RGB_R_MASK, rgb & GX_RGB_R_MASK, arg5); @@ -1167,7 +1167,7 @@ BOOL ov01_021EC728(UnkStruct_021EC5FC *arg0) { ov01_021EB840(&arg0->unk2C); ov01_021EB840(&arg0->unk40); ov01_021EB840(&arg0->unk54); - ov01_021EC678(arg0->unk0, arg0->unk54.unk0, arg0->unk4.unk0, GX_RGB(arg0->unk18.unk0, arg0->unk2C.unk0, arg0->unk40.unk0)); + ov01_021EC678(arg0->fog, (GXFogSlope)arg0->unk54.unk0, arg0->unk4.unk0, GX_RGB(arg0->unk18.unk0, arg0->unk2C.unk0, arg0->unk40.unk0)); return ret; } @@ -1176,7 +1176,7 @@ void ov01_021EC774(UnkStruct_021EC774* a0) { for (int i = 0; i < 32; i++) { a0->unk4[i] = 0; } - ov01_021EA8C4(a0->unk0, a0->unk4); + ov01_021EA8C4(a0->fog, a0->unk4); } void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2) { @@ -1195,7 +1195,7 @@ s32 ov01_021EC7AC(UnkStruct_021EC774* arg0) { temp_r4 = ov01_021EC7E8(arg0); if (arg0->unk28 == 0) { - ov01_021EA8C4(arg0->unk0, arg0->unk4); + ov01_021EA8C4(arg0->fog, arg0->unk4); } return temp_r4; } @@ -1206,7 +1206,7 @@ void ov01_021EC7C8(UnkStruct_021EC774* arg0) { arg0->unk2C = 0; arg0->unk2E = 1; ov01_021EC828(arg0); - ov01_021EA8C4(arg0->unk0, arg0->unk4); + ov01_021EA8C4(arg0->fog, arg0->unk4); } s32 ov01_021EC7E8(UnkStruct_021EC774* arg0) { @@ -1326,7 +1326,7 @@ void ov01_021EC94C(SysTask *task, void *data) { switch (v0->unkF62) { case 0: ov01_021EC504(&v1->unk0, v0, 1, 8, 20, 1, -1, 1, 2, ov01_021ECBB4); - ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->unk_4C, 3, 0x726F, 0x6b5a, 1, v0->unkF64); + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x1000, 0x726F, 0x6b5a, 1, v0->unkF64); v1->data[0] = 0; v0->unkF6C = SysTask_CreateOnMainQueue(ov01_021EDA7C, v0, 100); @@ -1348,8 +1348,8 @@ void ov01_021EC94C(SysTask *task, void *data) { ov01_021EC504(&v1->unk0, v0, 20, 1, 20, 1, -1, 1, 2, ov01_021ECBB4); if (v0->unkF64) { - v1->unk1C.unk0 = v0->weatherSystem->fieldSystem->unk_4C; - ov01_021EC678(v1->unk1C.unk0, 3, 0x726f, GX_RGB(26,26,26)); + v1->unk1C.fog = v0->weatherSystem->fieldSystem->fog; + ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x726f, GX_RGB(26,26,26)); ov01_021EC7C8(&v1->unk1C); } @@ -1399,7 +1399,7 @@ void ov01_021EC94C(SysTask *task, void *data) { break; case 5: if (v0->unkF64) { - ov01_021EA864(v1->unk1C.unk0, 1, 0, 0, 0, 0); + ov01_021EA864(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(v0->unk4); break; @@ -1445,7 +1445,7 @@ void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1) { vec.x = (15 * frame + (rand % 270)) << FX32_SHIFT; vec.y = 0xFFFA0 << FX32_SHIFT; vec.z = 0; - ov01_021EB5F4(v0->unk4, &vec); + WeatherDraw_SetSpriteMatrix(v0->unk4, &vec); } } @@ -1470,7 +1470,7 @@ void ov01_021ECC70(WeatherSystem_Sub0_Sub8_LinkedList *a0) { } } } - ov01_021EB5F4(a0->unk4, &vec); + WeatherDraw_SetSpriteMatrix(a0->unk4, &vec); break; case 1: if (data[0]-- <= 0) { @@ -1493,7 +1493,7 @@ void ov01_021ECD08(SysTask *task, void* data) { ov01_021EC504(&v1->unk0, v0, 1, 30, 6, 3, -5, 2, 1, ov01_021ECF4C); - ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->unk_4C, 3, 0x726F, GX_RGB(24,24,24), 2, v0->unkF64); + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x1000, 0x726F, GX_RGB(24,24,24), 2, v0->unkF64); v1->data[0] = 8; v1->data[1] = 0; @@ -1514,8 +1514,8 @@ void ov01_021ECD08(SysTask *task, void* data) { ov01_021EC504(&v1->unk0, v0, 6, 3, 6, 3, -5, 2, 1, ov01_021ECF4C); if (v0->unkF64) { - v1->unk1C.unk0 = v0->weatherSystem->fieldSystem->unk_4C; - ov01_021EC678(v1->unk1C.unk0, 3, 0x726f, GX_RGB(24,24,24)); + v1->unk1C.fog = v0->weatherSystem->fieldSystem->fog; + ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x726f, GX_RGB(24,24,24)); ov01_021EC7C8(&v1->unk1C); } @@ -1564,7 +1564,7 @@ void ov01_021ECD08(SysTask *task, void* data) { break; case 5: if (v0->unkF64) { - ov01_021EA864(v1->unk1C.unk0, 1, 0, 0, 0, 0); + ov01_021EA864(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(v0->unk4); break; @@ -1621,7 +1621,7 @@ void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1) { vec.x <<= FX32_SHIFT; vec.y <<= FX32_SHIFT; - ov01_021EB5F4(v1->unk4, &vec); + WeatherDraw_SetSpriteMatrix(v1->unk4, &vec); } } @@ -1646,7 +1646,7 @@ void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList* a0) { } } - ov01_021EB5F4(a0->unk4, &vec); + WeatherDraw_SetSpriteMatrix(a0->unk4, &vec); break; case 1: ov01_021EC29C(a0); @@ -1664,7 +1664,7 @@ void ov01_021ED0F0(SysTask *task, void* data) { ov01_021EC504(&v1->unk0, v0, 2, 16, 20, 2, -2, 4, 2, ov01_021ED31C); - ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->unk_4C, 3, 0x716F, GX_RGB(26,26,26), 1, v0->unkF64); + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x1000, 0x716F, GX_RGB(26,26,26), 1, v0->unkF64); v1->data[0] = 0; v0->unkF62 = 1; @@ -1684,8 +1684,8 @@ void ov01_021ED0F0(SysTask *task, void* data) { ov01_021EC504(&v1->unk0, v0, 20, 2, 20, 2, -2, 4, 2, ov01_021ED31C); if (v0->unkF64) { - v1->unk1C.unk0 = v0->weatherSystem->fieldSystem->unk_4C; - ov01_021EC678(v1->unk1C.unk0, 3, 0x716f, GX_RGB(26,26,26)); + v1->unk1C.fog = v0->weatherSystem->fieldSystem->fog; + ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x716f, GX_RGB(26,26,26)); ov01_021EC7C8(&v1->unk1C); } @@ -1726,7 +1726,7 @@ void ov01_021ED0F0(SysTask *task, void* data) { break; case 5: if (v0->unkF64) { - ov01_021EA864(v1->unk1C.unk0, 1, 0, 0, 0, 0); + ov01_021EA864(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(v0->unk4); break; @@ -1772,7 +1772,7 @@ void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { vec.x <<= FX32_SHIFT; vec.y <<= FX32_SHIFT; vec.z = 0; - ov01_021EB5F4(v0->unk4, &vec); + WeatherDraw_SetSpriteMatrix(v0->unk4, &vec); vec.x >>= FX32_SHIFT; vec.y >>= FX32_SHIFT; @@ -1803,10 +1803,10 @@ void ov01_021ED44C(WeatherSystem_Sub0_Sub8_LinkedList *a0) { } } -void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, s32 arg2, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6) { +void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, GXFogSlope fogSlope, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6) { switch (a0->unkF62) { case 0: - ov01_021EC5FC(&a1->unk50, &a1->unk1C, a0->weatherSystem->fieldSystem->unk_4C, arg2, arg3, arg4, arg5, a0->unkF64); + ov01_021EC5FC(&a1->unk50, &a1->unk1C, a0->weatherSystem->fieldSystem->fog, fogSlope, arg3, arg4, arg5, a0->unkF64); a0->unkF62 = 1; break; case 1: @@ -1817,8 +1817,8 @@ void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, s32 arg2 break; case 2: if (a0->unkF64 != 0) { - a1->unk1C.unk0 = a0->weatherSystem->fieldSystem->unk_4C; - ov01_021EC678(a1->unk1C.unk0, arg2, arg3, arg4); + a1->unk1C.fog = a0->weatherSystem->fieldSystem->fog; + ov01_021EC678(a1->unk1C.fog, fogSlope, arg3, arg4); ov01_021EC7C8(&a1->unk1C); } a0->unkF62 = 3; @@ -1845,7 +1845,7 @@ void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, s32 arg2 break; case 5: if (a0->unkF64 != 0) { - ov01_021EA864(a1->unk1C.unk0, 1, 0, 0, 0, 0); + ov01_021EA864(a1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(a0->unk4); break; @@ -1858,7 +1858,7 @@ void ov01_021ED584(SysTask *task, void* data) { switch (v0->unkF62) { case 0: - ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->unk_4C, 6, 0x7555, 0x7fff, 1, v0->unkF64); + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x0200, 0x7555, 0x7fff, 1, v0->unkF64); ov01_021EB830(&v1->unk0, 0, 9, 30); ov01_021EB818(0, 16); GfGfx_EngineATogglePlanes(4, 1); @@ -1874,8 +1874,8 @@ void ov01_021ED584(SysTask *task, void* data) { break; case 2: if (v0->unkF64 != 0) { - v1->unk1C.unk0 = v0->weatherSystem->fieldSystem->unk_4C; - ov01_021EC678(v1->unk1C.unk0, 6, 0x7555, 0x7fff); + v1->unk1C.fog = v0->weatherSystem->fieldSystem->fog; + ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x0200, 0x7555, 0x7fff); ov01_021EC7C8(&v1->unk1C); } ov01_021EB818(9, 7); @@ -1907,7 +1907,7 @@ void ov01_021ED584(SysTask *task, void* data) { break; case 5: if (v0->unkF64 != 0) { - ov01_021EA864(v1->unk1C.unk0, 1, 0, 0, 0, 0); + ov01_021EA864(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(v0->unk4); break; diff --git a/src/overlay_01_021EA824.c b/src/overlay_01_021EA824.c deleted file mode 100644 index 2f9c151963..0000000000 --- a/src/overlay_01_021EA824.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "overlay_01_021EA824.h" - -#include "global.h" - -UnkStruct_Ov01_021EA824 *ov01_021EA824() { - UnkStruct_Ov01_021EA824 *dst = Heap_Alloc(HEAP_ID_FIELD1, sizeof(UnkStruct_Ov01_021EA824)); - MIi_CpuClear32(0, (void *)dst, sizeof(UnkStruct_Ov01_021EA824)); - return dst; -} - -void ov01_021EA840(s32 *arg0) { - Heap_FreeExplicit(HEAP_ID_FIELD1, (void *)*arg0); - *arg0 = 0; -} - -BOOL ov01_021EA854(UnkStruct_Ov01_021EA824 *arg0) { - return arg0->enable; -} - -GXFogSlope ov01_021EA858(UnkStruct_Ov01_021EA824 *arg0) { - return arg0->fogSlope; -} - -int ov01_021EA85C(UnkStruct_Ov01_021EA824 *arg0) { - return arg0->fogOffset; -} - -u16 ov01_021EA860(UnkStruct_Ov01_021EA824 *arg0) { - return arg0->unk10; -} - -void ov01_021EA864(UnkStruct_Ov01_021EA824 *arg0, s32 arg1, BOOL enable, GXFogBlend fogMode, GXFogSlope fogSlope, int fogOffset) { - if (arg1 & 1 << 0) { - arg0->enable = enable; - } - if (arg1 & 1 << 1) { - arg0->fogMode = fogMode; - } - if (arg1 & 1 << 2) { - arg0->fogSlope = fogSlope; - } - if (arg1 & 1 << 3) { - arg0->fogOffset = fogOffset; - } - G3X_SetFog(arg0->enable, arg0->fogMode, arg0->fogSlope, arg0->fogOffset); -} - -void ov01_021EA89C(UnkStruct_Ov01_021EA824 *arg0, u32 arg1, u16 arg2, u32 arg3) { - if (arg1 & 1 << 4) { - arg0->unk10 = arg2; - } - if (arg1 & 1 << 5) { - arg0->unk14 = arg3; - } - reg_G3X_FOG_COLOR = arg0->unk10 | (arg0->unk14 << 16); -} - -void ov01_021EA8C4(UnkStruct_Ov01_021EA824 *arg0, const u32 *src) { - MIi_CpuCopy32(src, arg0->fogTable, 32); - G3X_SetFogTable(arg0->fogTable); -} From 2ab12f45552ee027de4de4e74b035fbcdd5c5309 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:44:02 -0400 Subject: [PATCH 20/22] Finish decomping functions --- asm/include/overlay_01_021EB1E8.inc | 2 +- asm/include/overlay_04.inc | 2 +- asm/overlay_01_021EB1E8.s | 501 +--------------------------- asm/overlay_04.s | 2 +- include/field/fog.h | 2 +- include/field/weather_manager.h | 124 ++++--- src/field/fog.c | 2 +- src/field/weather_manager.c | 388 +++++++++++++++------ 8 files changed, 369 insertions(+), 654 deletions(-) diff --git a/asm/include/overlay_01_021EB1E8.inc b/asm/include/overlay_01_021EB1E8.inc index f121de4b38..0a07673b04 100644 --- a/asm/include/overlay_01_021EB1E8.inc +++ b/asm/include/overlay_01_021EB1E8.inc @@ -80,7 +80,7 @@ .public Fog_GetSlope .public Fog_GetOffset .public ov01_021EA860 -.public ov01_021EA864 +.public Fog_Set .public ov01_021EA89C .public ov01_021EA8C4 .public ov01_021EB1E8 diff --git a/asm/include/overlay_04.inc b/asm/include/overlay_04.inc index 5d2ac92864..e957ad3939 100644 --- a/asm/include/overlay_04.inc +++ b/asm/include/overlay_04.inc @@ -80,7 +80,7 @@ .public ov01_021E8DE8 .public ov01_021E8E70 .public ov01_021E8ED0 -.public ov01_021EA864 +.public Fog_Set .public ov01_021EA89C .public ov01_021EA8C4 .public ov01_021F3B04 diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s index 9ae1118a99..eec19541b5 100644 --- a/asm/overlay_01_021EB1E8.s +++ b/asm/overlay_01_021EB1E8.s @@ -22,14 +22,14 @@ .public ov01_021EB818 .public ov01_021EB840 .public ov01_021EB86C - .public ov01_021EB898 + .public Weather_AddResObjFromOpenNarc .public ov01_021EB968 .public WeatherSystem_Init .public ov01_021EBCA4 .public ov01_021EC1BC .public ov01_021EC1E4 .public ov01_021EC1F4 - .public ov01_021EC29C + .public WeatherObject_Delete .public ov01_021EC2E4 .public ov01_021EC300 .public ov01_021EC304 @@ -53,499 +53,10 @@ .public ov01_021ED31C .public ov01_021ED474 .public ov01_021ED584 - - thumb_func_start ov01_021ED710 -ov01_021ED710: ; 0x021ED710 - push {r3, r4, r5, r6, lr} - sub sp, #0x4c - add r6, r1, #0 - mov r0, #0x41 - ldr r1, [r6] - lsl r0, r0, #2 - ldr r5, [r1, r0] - ldr r0, _021ED900 ; =0x00000F58 - add r1, r0, #0 - add r1, #0xa - ldrh r1, [r6, r1] - ldr r4, [r6, r0] - cmp r1, #5 - bls _021ED72E - b _021ED8FA -_021ED72E: - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_021ED73A: ; jump table - .short _021ED746 - _021ED73A - 2 ; case 0 - .short _021ED79E - _021ED73A - 2 ; case 1 - .short _021ED7A8 - _021ED73A - 2 ; case 2 - .short _021ED800 - _021ED73A - 2 ; case 3 - .short _021ED81A - _021ED73A - 2 ; case 4 - .short _021ED8F4 - _021ED73A - 2 ; case 5 -_021ED746: - ldr r0, [r5, #0x40] - bl PlayerAvatar_GetMapObject - bl ov01_02203EA0 - ldr r1, _021ED904 ; =0x0000062C - mov r3, #0 - str r0, [r4, r1] - mov r0, #0xa - str r0, [sp] - str r3, [sp, #4] - ldr r0, [r5, #0x4c] - sub r1, r3, #1 - mov r2, #1 - bl ov01_021EA864 - mov r1, #0 - mov r2, #0 - ldr r0, [r5, #0x4c] - mvn r1, r1 - add r3, r2, #0 - bl ov01_021EA89C - mov r1, #0 - add r2, sp, #0x2c - sub r0, r1, #1 -_021ED77A: - add r1, r1, #1 - strb r0, [r2] - add r2, r2, #1 - cmp r1, #0x20 - blt _021ED77A - ldr r0, [r5, #0x4c] - add r1, sp, #0x2c - bl ov01_021EA8C4 - mov r0, #0x63 - mov r1, #0 - lsl r0, r0, #4 - strh r1, [r4, r0] - ldr r0, _021ED908 ; =0x00000F62 - mov r1, #1 - add sp, #0x4c - strh r1, [r6, r0] - pop {r3, r4, r5, r6, pc} -_021ED79E: - mov r1, #3 - add r0, #0xa - add sp, #0x4c - strh r1, [r6, r0] - pop {r3, r4, r5, r6, pc} -_021ED7A8: - ldr r0, [r5, #0x40] - bl PlayerAvatar_GetMapObject - bl ov01_02203EA0 - ldr r1, _021ED904 ; =0x0000062C - mov r3, #0 - str r0, [r4, r1] - mov r0, #0xa - str r0, [sp] - str r3, [sp, #4] - ldr r0, [r5, #0x4c] - sub r1, r3, #1 - mov r2, #1 - bl ov01_021EA864 - mov r1, #0 - mov r2, #0 - ldr r0, [r5, #0x4c] - mvn r1, r1 - add r3, r2, #0 - bl ov01_021EA89C - mov r1, #0 - add r2, sp, #0xc - sub r0, r1, #1 -_021ED7DC: - add r1, r1, #1 - strb r0, [r2] - add r2, r2, #1 - cmp r1, #0x20 - blt _021ED7DC - ldr r0, [r5, #0x4c] - add r1, sp, #0xc - bl ov01_021EA8C4 - mov r0, #0x63 - mov r1, #0 - lsl r0, r0, #4 - strh r1, [r4, r0] - ldr r0, _021ED908 ; =0x00000F62 - mov r1, #3 - add sp, #0x4c - strh r1, [r6, r0] - pop {r3, r4, r5, r6, pc} -_021ED800: - add r1, r0, #0 - add r1, #0xe - ldrh r1, [r6, r1] - cmp r1, #5 - bne _021ED8FA - ldr r1, _021ED90C ; =0x00000632 - mov r2, #0 - strh r2, [r4, r1] - mov r1, #4 - add r0, #0xa - add sp, #0x4c - strh r1, [r6, r0] - pop {r3, r4, r5, r6, pc} -_021ED81A: - ldr r0, _021ED90C ; =0x00000632 - ldrh r1, [r4, r0] - cmp r1, #3 - bhi _021ED8FA - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_021ED82E: ; jump table - .short _021ED836 - _021ED82E - 2 ; case 0 - .short _021ED85A - _021ED82E - 2 ; case 1 - .short _021ED884 - _021ED82E - 2 ; case 2 - .short _021ED898 - _021ED82E - 2 ; case 3 -_021ED836: - mov r0, #6 - str r0, [sp] - mov r0, #1 - str r0, [sp, #4] - mov r0, #4 - mov r1, #0 - str r0, [sp, #8] - ldr r3, _021ED910 ; =0x00007FFF - mov r0, #3 - add r2, r1, #0 - bl BeginNormalPaletteFade - ldr r0, _021ED90C ; =0x00000632 - add sp, #0x4c - ldrh r1, [r4, r0] - add r1, r1, #1 - strh r1, [r4, r0] - pop {r3, r4, r5, r6, pc} -_021ED85A: - bl IsPaletteFadeFinished - cmp r0, #0 - beq _021ED8FA - mov r0, #6 - str r0, [sp] - mov r1, #1 - str r1, [sp, #4] - mov r0, #4 - str r0, [sp, #8] - ldr r3, _021ED910 ; =0x00007FFF - mov r0, #3 - add r2, r1, #0 - bl BeginNormalPaletteFade - ldr r0, _021ED90C ; =0x00000632 - add sp, #0x4c - ldrh r1, [r4, r0] - add r1, r1, #1 - strh r1, [r4, r0] - pop {r3, r4, r5, r6, pc} -_021ED884: - bl IsPaletteFadeFinished - cmp r0, #0 - beq _021ED8FA - ldr r0, _021ED90C ; =0x00000632 - add sp, #0x4c - ldrh r1, [r4, r0] - add r1, r1, #1 - strh r1, [r4, r0] - pop {r3, r4, r5, r6, pc} -_021ED898: - sub r1, r0, #2 - ldrh r1, [r4, r1] - add r2, r1, #1 - sub r1, r0, #2 - strh r2, [r4, r1] - sub r0, r0, #2 - ldrh r0, [r4, r0] - bl _dfltu - add r3, r1, #0 - add r2, r0, #0 - ldr r1, _021ED914 ; =0x40080000 - mov r0, #0 - bl _dmul - ldr r3, _021ED918 ; =0x40380000 - mov r2, #0 - bl _ddiv - add r3, r1, #0 - add r2, r0, #0 - ldr r1, _021ED91C ; =0x3FF00000 - mov r0, #0 - bl _dadd - bl _d2f - add r5, r0, #0 - ldr r0, _021ED904 ; =0x0000062C - add r1, r5, #0 - ldr r0, [r4, r0] - bl ov01_02203F2C - add r0, r5, #0 - bl _f2d - ldr r3, _021ED920 ; =0x40100000 - mov r2, #0 - bl _dgeq - blo _021ED8FA - ldr r0, _021ED908 ; =0x00000F62 - mov r1, #5 - add sp, #0x4c - strh r1, [r6, r0] - pop {r3, r4, r5, r6, pc} -_021ED8F4: - ldr r0, [r6, #4] - bl ov01_021EBCA4 -_021ED8FA: - add sp, #0x4c - pop {r3, r4, r5, r6, pc} - nop -_021ED900: .word 0x00000F58 -_021ED904: .word 0x0000062C -_021ED908: .word 0x00000F62 -_021ED90C: .word 0x00000632 -_021ED910: .word 0x00007FFF -_021ED914: .word 0x40080000 -_021ED918: .word 0x40380000 -_021ED91C: .word 0x3FF00000 -_021ED920: .word 0x40100000 - thumb_func_end ov01_021ED710 - - thumb_func_start ov01_021ED924 -ov01_021ED924: ; 0x021ED924 - push {r4, r5, r6, lr} - sub sp, #0x48 - add r5, r1, #0 - mov r0, #0x41 - ldr r1, [r5] - lsl r0, r0, #2 - ldr r4, [r1, r0] - ldr r0, _021EDA40 ; =0x00000F58 - add r1, r0, #0 - add r1, #0xa - ldrh r1, [r5, r1] - ldr r6, [r5, r0] - cmp r1, #5 - bhi _021EDA3A - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_021ED94C: ; jump table - .short _021ED958 - _021ED94C - 2 ; case 0 - .short _021ED9B2 - _021ED94C - 2 ; case 1 - .short _021ED9BC - _021ED94C - 2 ; case 2 - .short _021EDA16 - _021ED94C - 2 ; case 3 - .short _021EDA2A - _021ED94C - 2 ; case 4 - .short _021EDA34 - _021ED94C - 2 ; case 5 -_021ED958: - ldr r0, [r4, #0x40] - bl PlayerAvatar_GetMapObject - bl ov01_02203EA0 - ldr r1, _021EDA44 ; =0x0000062C - mov r3, #0 - str r0, [r6, r1] - mov r0, #0xa - str r0, [sp] - str r3, [sp, #4] - ldr r0, [r4, #0x4c] - sub r1, r3, #1 - mov r2, #1 - bl ov01_021EA864 - mov r1, #0 - mov r2, #0 - ldr r0, [r4, #0x4c] - mvn r1, r1 - add r3, r2, #0 - bl ov01_021EA89C - mov r1, #0 - add r2, sp, #0x28 - sub r0, r1, #1 -_021ED98C: - add r1, r1, #1 - strb r0, [r2] - add r2, r2, #1 - cmp r1, #0x20 - blt _021ED98C - ldr r0, [r4, #0x4c] - add r1, sp, #0x28 - bl ov01_021EA8C4 - ldr r0, _021EDA44 ; =0x0000062C - ldr r1, _021EDA48 ; =0x40800000 - ldr r0, [r6, r0] - bl ov01_02203F2C - ldr r0, _021EDA4C ; =0x00000F62 - mov r1, #1 - add sp, #0x48 - strh r1, [r5, r0] - pop {r4, r5, r6, pc} -_021ED9B2: - mov r1, #3 - add r0, #0xa - add sp, #0x48 - strh r1, [r5, r0] - pop {r4, r5, r6, pc} -_021ED9BC: - ldr r0, [r4, #0x40] - bl PlayerAvatar_GetMapObject - bl ov01_02203EA0 - ldr r1, _021EDA44 ; =0x0000062C - mov r3, #0 - str r0, [r6, r1] - mov r0, #0xa - str r0, [sp] - str r3, [sp, #4] - ldr r0, [r4, #0x4c] - sub r1, r3, #1 - mov r2, #1 - bl ov01_021EA864 - mov r1, #0 - mov r2, #0 - ldr r0, [r4, #0x4c] - mvn r1, r1 - add r3, r2, #0 - bl ov01_021EA89C - mov r1, #0 - add r2, sp, #8 - sub r0, r1, #1 -_021ED9F0: - add r1, r1, #1 - strb r0, [r2] - add r2, r2, #1 - cmp r1, #0x20 - blt _021ED9F0 - ldr r0, [r4, #0x4c] - add r1, sp, #8 - bl ov01_021EA8C4 - ldr r0, _021EDA44 ; =0x0000062C - ldr r1, _021EDA48 ; =0x40800000 - ldr r0, [r6, r0] - bl ov01_02203F2C - ldr r0, _021EDA4C ; =0x00000F62 - mov r1, #3 - add sp, #0x48 - strh r1, [r5, r0] - pop {r4, r5, r6, pc} -_021EDA16: - add r1, r0, #0 - add r1, #0xe - ldrh r1, [r5, r1] - cmp r1, #5 - bne _021EDA3A - mov r1, #4 - add r0, #0xa - add sp, #0x48 - strh r1, [r5, r0] - pop {r4, r5, r6, pc} -_021EDA2A: - mov r1, #5 - add r0, #0xa - add sp, #0x48 - strh r1, [r5, r0] - pop {r4, r5, r6, pc} -_021EDA34: - ldr r0, [r5, #4] - bl ov01_021EBCA4 -_021EDA3A: - add sp, #0x48 - pop {r4, r5, r6, pc} - nop -_021EDA40: .word 0x00000F58 -_021EDA44: .word 0x0000062C -_021EDA48: .word 0x40800000 -_021EDA4C: .word 0x00000F62 - thumb_func_end ov01_021ED924 - - thumb_func_start ov01_021EDA50 -ov01_021EDA50: ; 0x021EDA50 - push {lr} - sub sp, #0xc - ldr r0, _021EDA70 ; =0x00000421 - ldr r2, _021EDA74 ; =0x00000F58 - str r0, [sp] - mov r0, #0 - str r0, [sp, #4] - str r0, [sp, #8] - add r0, r1, #0 - ldr r1, [r1, r2] - ldr r3, _021EDA78 ; =0x00004B6F - mov r2, #1 - bl ov01_021ED474 - add sp, #0xc - pop {pc} - .balign 4, 0 -_021EDA70: .word 0x00000421 -_021EDA74: .word 0x00000F58 -_021EDA78: .word 0x00004B6F - thumb_func_end ov01_021EDA50 - - thumb_func_start ov01_021EDA7C -ov01_021EDA7C: ; 0x021EDA7C - push {r3, r4, r5, lr} - add r5, r0, #0 - ldr r0, _021EDAA8 ; =0x00000F68 - add r4, r1, #0 - ldr r1, [r4, r0] - sub r1, r1, #1 - str r1, [r4, r0] - ldr r0, [r4, r0] - cmp r0, #0 - bgt _021EDAA4 - ldr r1, _021EDAAC ; =0x00000638 - add r0, r4, #0 - bl ov01_021EDAB4 - add r0, r5, #0 - bl SysTask_Destroy - ldr r0, _021EDAB0 ; =0x00000F6C - mov r1, #0 - str r1, [r4, r0] -_021EDAA4: - pop {r3, r4, r5, pc} - nop -_021EDAA8: .word 0x00000F68 -_021EDAAC: .word 0x00000638 -_021EDAB0: .word 0x00000F6C - thumb_func_end ov01_021EDA7C - - thumb_func_start ov01_021EDAB4 -ov01_021EDAB4: ; 0x021EDAB4 - push {r3, r4, r5, lr} - add r5, r0, #0 - ldr r0, _021EDADC ; =0x00000F5C - add r4, r1, #0 - ldr r0, [r5, r0] - cmp r0, #0 - beq _021EDAC6 - bl GF_AssertFail -_021EDAC6: - ldr r1, _021EDADC ; =0x00000F5C - mov r0, #1 - str r0, [r5, r1] - lsl r0, r4, #0x10 - lsr r0, r0, #0x10 - add r1, r1, #4 - strh r0, [r5, r1] - bl PlaySE - pop {r3, r4, r5, pc} - nop -_021EDADC: .word 0x00000F5C - thumb_func_end ov01_021EDAB4 - - thumb_func_start ov01_021EDAE0 -ov01_021EDAE0: ; 0x021EDAE0 - push {r4, lr} - add r4, r0, #0 - mov r0, #0xf6 - lsl r0, r0, #4 - ldrh r0, [r4, r0] - mov r1, #0 - bl StopSE - ldr r0, _021EDAF8 ; =0x00000F5C - mov r1, #0 - str r1, [r4, r0] - pop {r4, pc} - .balign 4, 0 -_021EDAF8: .word 0x00000F5C - thumb_func_end ov01_021EDAE0 + .public ov01_021ED710 + .public ov01_021ED924 + .public ov01_021EDA50 + .rodata diff --git a/asm/overlay_04.s b/asm/overlay_04.s index e913952865..a4eb161d04 100644 --- a/asm/overlay_04.s +++ b/asm/overlay_04.s @@ -1838,7 +1838,7 @@ ov04_02254CBC: ; 0x02254CBC ldr r0, [r5, #0x4c] sub r1, r3, #1 mov r2, #1 - bl ov01_021EA864 + bl Fog_Set mov r1, #0 ldr r0, [r5, #0x4c] mvn r1, r1 diff --git a/include/field/fog.h b/include/field/fog.h index ffaceeb500..0e8899fdde 100644 --- a/include/field/fog.h +++ b/include/field/fog.h @@ -24,7 +24,7 @@ BOOL Fog_CheckActive(FogData *arg0); GXFogSlope Fog_GetSlope(FogData *arg0); int Fog_GetOffset(FogData *arg0); u16 ov01_021EA860(FogData *arg0); -void ov01_021EA864(FogData *arg0, s32 arg1, BOOL enable, GXFogBlend fogMode, GXFogSlope fogSlope, int fogOffset); +void Fog_Set(FogData *arg0, s32 arg1, BOOL enable, GXFogBlend fogMode, GXFogSlope fogSlope, int fogOffset); void ov01_021EA89C(FogData *arg0, u32 arg1, u16 arg2, u32 arg3); void ov01_021EA8C4(FogData *arg0, u8 *src); diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index e19c90f962..67b8170dec 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -6,17 +6,21 @@ #include "sprite.h" #include "field/fog.h" -typedef struct UnkWeatherStruct_021EB968 { +enum WeatherSystemProcess { + WEATHER_SYS_PROC_INIT = 0, +}; + +typedef struct WeatherSpriteResources { SpriteResource *charResObj[4]; - SpriteTemplate unk10; - SpriteResourcesHeader unk40; -} UnkWeatherStruct_021EB968; + SpriteTemplate spriteTemplate; + SpriteResourcesHeader spriteResHeader; +} WeatherSpriteResources; -typedef struct WeatherSystem_Sub4 { - u32 unk0; - u32 unk4; - u32 unk8; -} WeatherSystem_Sub4; +typedef struct WeatherGfxNarcData { + u32 paletteId; + u32 charId; + u32 screenId; +} WeatherGfxNarcData; typedef struct WeatherDraw { GF_2DGfxResMan *resMan[4]; @@ -39,14 +43,14 @@ typedef struct UnkWeatherStruct_021EC078 { typedef struct WeatherSystem WeatherSystem; typedef struct WeatherSystem_Sub0 WeatherSystem_Sub0; typedef struct WeatherSystem_Sub0_Sub8 WeatherSystem_Sub0_Sub8; -typedef struct WeatherSystem_Sub0_Sub8_LinkedList WeatherSystem_Sub0_Sub8_LinkedList; -struct WeatherSystem_Sub0_Sub8_LinkedList { +typedef struct WeatherObject WeatherObject; +struct WeatherObject { WeatherSystem *weatherSystem; Sprite *unk4; u32 *unk8; u32 unk10[10]; - WeatherSystem_Sub0_Sub8_LinkedList *next; - WeatherSystem_Sub0_Sub8_LinkedList *prev; + WeatherObject *next; + WeatherObject *prev; }; typedef struct UnkStruct_ov01_021EB1E8 { @@ -85,16 +89,16 @@ typedef struct UnkStruct_021EC504 { UnkWeatherSystemSub0Sub8Func unk18; } UnkStruct_021EC504; -typedef void (*UnkLinkedListFunc)(WeatherSystem_Sub0_Sub8_LinkedList *); +typedef void (*UnkLinkedListFunc)(WeatherObject *); -typedef struct UnkStruct_021EC5FC { +typedef struct WeatherFogChange { FogData *fog; UnkWeatherStruct_021EB830 unk4; UnkWeatherStruct_021EB830 unk18; UnkWeatherStruct_021EB830 unk2C; UnkWeatherStruct_021EB830 unk40; UnkWeatherStruct_021EB830 unk54; -} UnkStruct_021EC5FC; +} WeatherFogChange; typedef struct UnkStruct_021EC774 { FogData *fog; @@ -108,22 +112,48 @@ typedef struct UnkStruct_021EC774 { typedef struct UnkStruct_021EC94C { UnkStruct_021EC504 unk0; UnkStruct_021EC774 unk1C; - UnkStruct_021EC5FC unk50; + WeatherFogChange unk50; s32 data[10]; } UnkStruct_021EC94C; typedef struct UnkStruct_021ED474 { UnkStruct_021EC774 unk1C; - UnkStruct_021EC5FC unk50; + WeatherFogChange unk50; s32 data[10]; } UnkStruct_021ED474; typedef struct UnkStruct_021ED584 { UnkWeatherStruct_021EB830 unk0; UnkStruct_021EC774 unk1C; - UnkStruct_021EC5FC unk50; + WeatherFogChange unk50; } UnkStruct_021ED584; +typedef struct UnkStruct_021ED710_Sub_Sub4 { + fx32 unk0; + fx32 unk4; + fx32 unk8; + s16 unkC; + s16 unkE; +} UnkStruct_021ED710_Sub_Sub4; + +typedef struct UnkStruct_021ED710_Sub { + s16 x; + s16 z; + UnkStruct_021ED710_Sub_Sub4 unk4; + void *unk14; + void *unk18; + void *unk1C[2]; + SysTask *task; + u32 unk2C; + u16 unk30[4][192]; +} UnkStruct_021ED710_Sub; +typedef struct UnkStruct_021ED710 { + UnkStruct_021ED710_Sub unk0; + void *unk62C; + u16 unk630; + u16 unk632; +} UnkStruct_021ED710; + void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); void WeatherManager_Delete(WeatherManager* weatherManager); @@ -147,9 +177,9 @@ u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather); void ov01_021EB818(u32 arg0, u32 arg1); void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3); BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0); -void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, UnkWeatherStruct_021EB968 *arg2); -SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resIndex, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd); -void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, UnkWeatherStruct_021EB968* a2); +void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, WeatherSpriteResources *arg2); +SpriteResource *Weather_AddResObjFromOpenNarc(GF_2DGfxResHeader *headerList, s32 resIndex, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd); +void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, WeatherSpriteResources* a2); BOOL WeatherSystem_Init(WeatherSystem* weatherSystem, int weather); BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2); @@ -160,34 +190,34 @@ void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1); BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0); -void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); -void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); -void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); -void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2); +void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, WeatherSpriteResources *a2); +void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, WeatherSpriteResources *a2); +void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, WeatherSpriteResources *a2); +void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, WeatherSpriteResources *a2); void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1); void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1); void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1); -void ov01_021EC1BC(WeatherSystem_Sub0_Sub8_LinkedList* a0, int a1); -void ov01_021EC1E4(WeatherSystem_Sub0_Sub8_LinkedList* a0); -void ov01_021EC240(SpriteResourcesHeader *spriteTemplate, WeatherSystem *weatherSystem, UnkWeatherStruct_021EB968 *a2, u32 a3, u32 a4); -void ov01_021EC29C(WeatherSystem_Sub0_Sub8_LinkedList* a0); -void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList * a0); -void ov01_021EC2E4(WeatherSystem_Sub0_Sub8_LinkedList *a0, UnkLinkedListFunc func); +void ov01_021EC1BC(WeatherObject* a0, int a1); +void ov01_021EC1E4(WeatherObject* a0); +void ov01_021EC240(SpriteResourcesHeader *spriteTemplate, WeatherSystem *weatherSystem, WeatherSpriteResources *a2, u32 a3, u32 a4); +void WeatherObject_Delete(WeatherObject* a0); +void WeatherObject_DeleteAll(WeatherObject * a0); +void ov01_021EC2E4(WeatherObject *a0, UnkLinkedListFunc func); void ov01_021EC300(void *data); -VecFx32 ov01_021EC304(WeatherSystem_Sub0_Sub8_LinkedList *a0); +VecFx32 ov01_021EC304(WeatherObject *a0); void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0); void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut); void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y); void ov01_021EC504(UnkStruct_021EC504* arg0, WeatherSystem_Sub0_Sub8 *arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkWeatherSystemSub0Sub8Func arg9); void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4); s32 ov01_021EC538(UnkStruct_021EC504* arg0); -void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7); -BOOL ov01_021EC650(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774 *arg1, s32 arg2); +void ov01_021EC5FC(WeatherFogChange *arg0, UnkStruct_021EC774* arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7); +BOOL ov01_021EC650(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, s32 arg2); void ov01_021EC678(FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb); -void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5); -BOOL ov01_021EC728(UnkStruct_021EC5FC *arg0); +void ov01_021EC6A4(WeatherFogChange* arg0, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5); +BOOL ov01_021EC728(WeatherFogChange *arg0); void ov01_021EC774(UnkStruct_021EC774* a0); void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2); s32 ov01_021EC7AC(UnkStruct_021EC774* arg0); @@ -195,19 +225,25 @@ void ov01_021EC7C8(UnkStruct_021EC774* arg0); s32 ov01_021EC7E8(UnkStruct_021EC774 *arg0); void ov01_021EC828(UnkStruct_021EC774 *arg0); void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int a2, int a3, int a4, UnkLinkedListFunc a5); -WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); +WeatherObject *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); void ov01_021EC8F8(SysTask *task, void* data); void ov01_021EC94C(SysTask *task, void *data); void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *, int); -void ov01_021ECC70(WeatherSystem_Sub0_Sub8_LinkedList *a0); +void ov01_021ECC70(WeatherObject *a0); void ov01_021ECD08(SysTask *task, void* data); void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1); -void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList *a0); +void ov01_021ED070(WeatherObject *a0); void ov01_021ED0F0(SysTask *task, void* data); void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1); -void ov01_021ED44C(WeatherSystem_Sub0_Sub8_LinkedList *a0); +void ov01_021ED44C(WeatherObject *a0); void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, GXFogSlope fogSlope, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6); void ov01_021ED584(SysTask *task, void* data); +void ov01_021ED710(SysTask *task, void *data); +void ov01_021ED924(SysTask *task, void *data); +void ov01_021EDA50(SysTask *task, void *data); +void ov01_021EDA7C(SysTask *task, void* data); +void ov01_021EDAB4(WeatherSystem_Sub0_Sub8* a0, u32 sndSeq); +void ov01_021EDAE0(WeatherSystem_Sub0_Sub8* arg0); // Not yet decompiled void ov01_021EB3F0(SysTask *task, void *data); @@ -216,8 +252,8 @@ void Weather_Init2DGfxRes(GF_2DGfxResHeader *header, u32 a1, u32 a2); BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); void ov01_021EBD70(SysTask *task, void *data); void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); -void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *a0); void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1); -void ov01_021EDA7C(SysTask *task, void *data); - +void *ov01_02203EA0(); +void ov01_02203F2C(void *, float a0); + #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/src/field/fog.c b/src/field/fog.c index 303b647f22..859e0179af 100644 --- a/src/field/fog.c +++ b/src/field/fog.c @@ -29,7 +29,7 @@ u16 ov01_021EA860(FogData *fog) { return fog->unk10; } -void ov01_021EA864(FogData *fog, s32 arg1, BOOL enable, GXFogBlend fogMode, GXFogSlope fogSlope, int fogOffset) { +void Fog_Set(FogData *fog, s32 arg1, BOOL enable, GXFogBlend fogMode, GXFogSlope fogSlope, int fogOffset) { if (arg1 & 1 << 0) { fog->enable = enable; } diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index fddb579726..1ce8703845 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -10,13 +10,14 @@ #include "unk_0200ACF0.h" #include "unk_02020B8C.h" #include "math_util.h" +#include "unk_0200FA24.h" struct WeatherSystem_Sub0_Sub8 { WeatherSystem *weatherSystem; WeatherSystem_Sub0 *unk4; - UnkWeatherStruct_021EB968 *unk8; - WeatherSystem_Sub0_Sub8_LinkedList linkedListDummy; - WeatherSystem_Sub0_Sub8_LinkedList linkedList[64]; + WeatherSpriteResources *unk8; + WeatherObject linkedListDummy; + WeatherObject linkedList[64]; SysTask *unkF48; VecFx32 cameraTarget; void *unkF58; @@ -25,7 +26,7 @@ struct WeatherSystem_Sub0_Sub8 { u16 unkF62; u16 unkF64; u16 unkF66; - u32 unkF68; + s32 unkF68; SysTask *unkF6C; }; @@ -34,7 +35,7 @@ struct WeatherSystem_Sub0 { u16 unk2; int unk4; WeatherSystem_Sub0_Sub8 *unk8; - UnkWeatherStruct_021EB968 *unkC; + WeatherSpriteResources *weatherSpriteResources; u16 unk10; u16 unk12; SysTask *task; @@ -43,7 +44,7 @@ struct WeatherSystem_Sub0 { struct WeatherSystem { WeatherSystem_Sub0 *unk0; - WeatherSystem_Sub4 *unk4; + WeatherGfxNarcData *unk4; WeatherDraw weatherDraw; FieldSystem *fieldSystem; NARC *narc; @@ -54,6 +55,13 @@ void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0) { a0->unk188 = 1; } +/** + * @brief Creates the weather manager and initializes with default values + * + * @param fieldSystem + * + * @return WeatherManager * + */ WeatherManager *WeatherManager_New(FieldSystem *fieldSystem) { WeatherManager *weatherManager = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherManager)); @@ -71,6 +79,11 @@ WeatherManager *WeatherManager_New(FieldSystem *fieldSystem) { return weatherManager; } +/** + * @brief Deletes and frees the weather manager and embedded structs + * + * @param weatherManager + */ void WeatherManager_Delete(WeatherManager* weatherManager) { if (weatherManager->task) { SysTask_Destroy(weatherManager->task); @@ -283,7 +296,7 @@ void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32* matrix) { } extern WeatherSystem_Sub0 ov01_022098B0[]; -extern WeatherSystem_Sub4 ov01_0220675C[]; +extern WeatherGfxNarcData ov01_0220675C[]; WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem) { WeatherSystem *weatherSystem = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSystem)); @@ -306,7 +319,7 @@ void WeatherSystem_Delete(WeatherSystem** pWeatherSystem) { ov01_021EBB90(*pWeatherSystem, i); } - ov01_021EA864((*pWeatherSystem)->fieldSystem->fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + Fog_Set((*pWeatherSystem)->fieldSystem->fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); reg_G2_BG0CNT = (reg_G2_BG0CNT & ~3) | 1; @@ -329,7 +342,7 @@ BOOL WeatherSystem_Process(WeatherSystem *weatherSystem, int state, int weather) } switch (state) { - case 0: + case WEATHER_SYS_PROC_INIT: ret = WeatherSystem_Init(weatherSystem, weather); break; case 1: @@ -414,14 +427,14 @@ BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0) { return TRUE; } -void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, UnkWeatherStruct_021EB968 *arg2) { +void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, WeatherSpriteResources *arg2) { ov01_021EBEF0(weatherSystem, arg1, arg2); ov01_021EBF24(weatherSystem, arg1, arg2); ov01_021EBF58(weatherSystem, arg1, arg2); ov01_021EBF94(weatherSystem, arg1, arg2); } -SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resourceType, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd) { +SpriteResource *Weather_AddResObjFromOpenNarc(GF_2DGfxResHeader *headerList, s32 resourceType, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd) { GF_2DGfxResHeader *header = GF2DGfxResHeader_GetByIndex(headerList, resourceType); u32 member = GF2DGfxResHeader_GetNarcMemberIdByIndex(header, headerIndex); u32 compressFlag = GF2DGfxResHeader_GetCompressFlagByIndex(header, headerIndex); @@ -448,13 +461,13 @@ SpriteResource *ov01_021EB898(GF_2DGfxResHeader *headerList, s32 resourceType, s return ret; } -void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, UnkWeatherStruct_021EB968* a2) { +void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, WeatherSpriteResources* a2) { if (a1 != 0xFFFF) { - if (a2->charResObj[0] != 0) { - sub_0200AEB0(a2->charResObj[0]); + if (a2->charResObj[GF_GFX_RES_TYPE_CHAR] != 0) { + sub_0200AEB0(a2->charResObj[GF_GFX_RES_TYPE_CHAR]); } - if (a2->charResObj[1] != 0) { - sub_0200B0A8(a2->charResObj[1]); + if (a2->charResObj[GF_GFX_RES_TYPE_PLTT] != 0) { + sub_0200B0A8(a2->charResObj[GF_GFX_RES_TYPE_PLTT]); } for (int i = 0; i < 4; i++) { @@ -478,7 +491,7 @@ BOOL WeatherSystem_Init(WeatherSystem* weatherSystem, int weather) { return FALSE; } - v0->unk8->unk8 = v0->unkC; + v0->unk8->unk8 = v0->weatherSpriteResources; if (v0->unk0 != 0xFFFF) { ov01_021EC028(v0->unk8); @@ -511,7 +524,7 @@ BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather) { BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; - if (v0->unk0 != 0xFFFF && v0->unkC == 0) { + if (v0->unk0 != 0xFFFF && v0->weatherSpriteResources == 0) { return FALSE; } @@ -583,10 +596,10 @@ void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { G2_BlendNone(); } - if (v0->unkC) { - ov01_021EB968(weatherSystem, v0->unk0, v0->unkC); - Heap_FreeExplicit(HEAP_ID_FIELD1, v0->unkC); - v0->unkC = NULL; + if (v0->weatherSpriteResources) { + ov01_021EB968(weatherSystem, v0->unk0, v0->weatherSpriteResources); + Heap_FreeExplicit(HEAP_ID_FIELD1, v0->weatherSpriteResources); + v0->weatherSpriteResources = NULL; if (v0->task) { SysTask_Destroy(v0->task); v0->task = NULL; @@ -594,7 +607,7 @@ void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { } if (v0->unk8) { - ov01_021EC2CC(&v0->unk8->linkedListDummy); + WeatherObject_DeleteAll(&v0->unk8->linkedListDummy); if (v0->unk0 != 0xFFFF) { ov01_021EC058(v0->unk8); @@ -625,7 +638,7 @@ void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { v0->unk8 = NULL; } - ov01_021EA864(weatherSystem->fieldSystem->fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + Fog_Set(weatherSystem->fieldSystem->fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } void ov01_021EBCA4(WeatherSystem_Sub0* a0) { @@ -637,7 +650,7 @@ void ov01_021EBCA4(WeatherSystem_Sub0* a0) { } if (a0->unk8 != NULL) { - ov01_021EC2CC(&a0->unk8->linkedListDummy); + WeatherObject_DeleteAll(&a0->unk8->linkedListDummy); if (a0->unk8->unkF5C == 1) { ov01_021EDAE0(a0->unk8); @@ -657,11 +670,11 @@ void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1) { } BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { - if (a1->unk0 != 0xFFFF && a1->unkC == NULL) { + if (a1->unk0 != 0xFFFF && a1->weatherSpriteResources == NULL) { if (ov01_021EBEB8(a1) == FALSE) { return FALSE; } - ov01_021EB86C(weatherSystem, a1->unk0, a1->unkC); + ov01_021EB86C(weatherSystem, a1->unk0, a1->weatherSpriteResources); ov01_021EBFD0(weatherSystem, a1); } return TRUE; @@ -676,7 +689,7 @@ void ov01_021EBD70(SysTask *task, void *data) { v0->unk12++; break; case 1: - ov01_021EBEF0(weatherSystem, v0->unk0, v0->unkC); + ov01_021EBEF0(weatherSystem, v0->unk0, v0->weatherSpriteResources); v0->unk12++; break; case 2: @@ -684,7 +697,7 @@ void ov01_021EBD70(SysTask *task, void *data) { v0->unk12++; break; case 3: - ov01_021EBF24(weatherSystem, v0->unk0, v0->unkC); + ov01_021EBF24(weatherSystem, v0->unk0, v0->weatherSpriteResources); v0->unk12++; break; case 4: @@ -692,7 +705,7 @@ void ov01_021EBD70(SysTask *task, void *data) { v0->unk12++; break; case 5: - ov01_021EBF58(weatherSystem, v0->unk0, v0->unkC); + ov01_021EBF58(weatherSystem, v0->unk0, v0->weatherSpriteResources); v0->unk12++; break; case 6: @@ -700,12 +713,12 @@ void ov01_021EBD70(SysTask *task, void *data) { v0->unk12++; break; case 7: - ov01_021EBF94(weatherSystem, v0->unk0, v0->unkC); + ov01_021EBF94(weatherSystem, v0->unk0, v0->weatherSpriteResources); v0->unk12++; break; case 8: ov01_021EBFD0(weatherSystem, v0); - v0->unk8->unk8 = v0->unkC; + v0->unk8->unk8 = v0->weatherSpriteResources; if (v0->unk0 != 0xFFFF) { ov01_021EC028(v0->unk8); } @@ -741,62 +754,62 @@ BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0) { if (a0->unk0 != 0xFFFF) { - if (a0->unkC != NULL) { + if (a0->weatherSpriteResources != NULL) { return TRUE; } - a0->unkC = Heap_Alloc(HEAP_ID_FIELD1, sizeof(UnkWeatherStruct_021EB968)); - if (a0->unkC == NULL) { + a0->weatherSpriteResources = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSpriteResources)); + if (a0->weatherSpriteResources == NULL) { return FALSE; } - memset(a0->unkC, 0, sizeof(UnkWeatherStruct_021EB968)); + memset(a0->weatherSpriteResources, 0, sizeof(WeatherSpriteResources)); } return TRUE; } -void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2) { - if (a1 != 0xFFFF) { - a2->charResObj[2] = ov01_021EB898(weatherSystem->weatherDraw.header, 2, a1, weatherSystem->weatherDraw.resMan[2], weatherSystem->narc, 0); +void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { + if (headerIndex != 0xFFFF) { + a2->charResObj[GF_GFX_RES_TYPE_CELL] = Weather_AddResObjFromOpenNarc(weatherSystem->weatherDraw.header, GF_GFX_RES_TYPE_CELL, headerIndex, weatherSystem->weatherDraw.resMan[GF_GFX_RES_TYPE_CELL], weatherSystem->narc, 0); } } -void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2) { - if (a1 != 0xFFFF) { - a2->charResObj[3] = ov01_021EB898(weatherSystem->weatherDraw.header, 3, a1, weatherSystem->weatherDraw.resMan[3], weatherSystem->narc, 0); +void ov01_021EBF24(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { + if (headerIndex != 0xFFFF) { + a2->charResObj[GF_GFX_RES_TYPE_ANIM] = Weather_AddResObjFromOpenNarc(weatherSystem->weatherDraw.header, GF_GFX_RES_TYPE_ANIM, headerIndex, weatherSystem->weatherDraw.resMan[GF_GFX_RES_TYPE_ANIM], weatherSystem->narc, 0); } } -void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2) { - if (a1 != 0xFFFF) { - a2->charResObj[0] = ov01_021EB898(weatherSystem->weatherDraw.header, 0, a1, weatherSystem->weatherDraw.resMan[0], weatherSystem->narc, 1); - sub_0200ADA4(a2->charResObj[0]); - sub_0200A740(a2->charResObj[0]); +void ov01_021EBF58(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { + if (headerIndex != 0xFFFF) { + a2->charResObj[GF_GFX_RES_TYPE_CHAR] = Weather_AddResObjFromOpenNarc(weatherSystem->weatherDraw.header, GF_GFX_RES_TYPE_CHAR, headerIndex, weatherSystem->weatherDraw.resMan[GF_GFX_RES_TYPE_CHAR], weatherSystem->narc, 1); + sub_0200ADA4(a2->charResObj[GF_GFX_RES_TYPE_CHAR]); + sub_0200A740(a2->charResObj[GF_GFX_RES_TYPE_CHAR]); } } -void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, UnkWeatherStruct_021EB968 *a2) { - if (a1 != 0xFFFF) { - a2->charResObj[1] = ov01_021EB898(weatherSystem->weatherDraw.header, 1, a1, weatherSystem->weatherDraw.resMan[1], weatherSystem->narc, 1); - sub_0200B00C(a2->charResObj[1]); - sub_0200A740(a2->charResObj[1]); +void ov01_021EBF94(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { + if (headerIndex != 0xFFFF) { + a2->charResObj[GF_GFX_RES_TYPE_PLTT] = Weather_AddResObjFromOpenNarc(weatherSystem->weatherDraw.header, GF_GFX_RES_TYPE_PLTT, headerIndex, weatherSystem->weatherDraw.resMan[GF_GFX_RES_TYPE_PLTT], weatherSystem->narc, 1); + sub_0200B00C(a2->charResObj[GF_GFX_RES_TYPE_PLTT]); + sub_0200A740(a2->charResObj[GF_GFX_RES_TYPE_PLTT]); } } void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { if (a1->unk0 != 0xFFFF) { - ov01_021EC240(&a1->unkC->unk40, weatherSystem, a1->unkC, 0, 1); - memset(&a1->unkC->unk10, 0, sizeof(SpriteTemplate)); - a1->unkC->unk10.spriteList = weatherSystem->weatherDraw.spriteList; - a1->unkC->unk10.header = &a1->unkC->unk40; - a1->unkC->unk10.scale.x = 1 << 12; - a1->unkC->unk10.scale.y = 1 << 12; - a1->unkC->unk10.scale.z = 1 << 12; - a1->unkC->unk10.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN; + ov01_021EC240(&a1->weatherSpriteResources->spriteResHeader, weatherSystem, a1->weatherSpriteResources, 0, 1); + memset(&a1->weatherSpriteResources->spriteTemplate, 0, sizeof(SpriteTemplate)); + a1->weatherSpriteResources->spriteTemplate.spriteList = weatherSystem->weatherDraw.spriteList; + a1->weatherSpriteResources->spriteTemplate.header = &a1->weatherSpriteResources->spriteResHeader; + a1->weatherSpriteResources->spriteTemplate.scale.x = 1 << 12; + a1->weatherSpriteResources->spriteTemplate.scale.y = 1 << 12; + a1->weatherSpriteResources->spriteTemplate.scale.z = 1 << 12; + a1->weatherSpriteResources->spriteTemplate.whichScreen = NNS_G2D_VRAM_TYPE_2DMAIN; } } void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0) { for (int i = 0; i < 64; i++) { - a0->linkedList[i].unk4 = Sprite_CreateAffine(&a0->unk8->unk10); + a0->linkedList[i].unk4 = Sprite_CreateAffine(&a0->unk8->spriteTemplate); Sprite_SetDrawFlag(a0->linkedList[i].unk4, 0); GF_ASSERT(a0->linkedList[i].unk4); } @@ -814,7 +827,7 @@ void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0) { void ov01_021EC078(WeatherSystem* weatherSystem, u16 a1) { UnkWeatherStruct_021EC078 v0; if (a1 != 0xFFFF) { - v0.unk0 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].unk0, HEAP_ID_FIELD1); + v0.unk0 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].paletteId, HEAP_ID_FIELD1); NNS_G2dGetUnpackedPaletteData(v0.unk0, &v0.unk14); BG_LoadPlttData(2, v0.unk14->pRawData, 32, 0xc0); Heap_Free(v0.unk0); @@ -825,7 +838,7 @@ void ov01_021EC078(WeatherSystem* weatherSystem, u16 a1) { void ov01_021EC0C0(WeatherSystem* weatherSystem, u16 a1) { UnkWeatherStruct_021EC078 v0; if (a1 != 0xFFFF) { - v0.unk4 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].unk4, HEAP_ID_FIELD1); + v0.unk4 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].charId, HEAP_ID_FIELD1); NNS_G2dGetUnpackedCharacterData(v0.unk4, &v0.unk10); BG_LoadCharTilesData(weatherSystem->fieldSystem->bgConfig, 2, v0.unk10->pRawData, v0.unk10->szByte, 0); Heap_Free(v0.unk4); @@ -837,7 +850,7 @@ void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1) { UnkWeatherStruct_021EC078 v0; if (a1 != 0xFFFF) { GfGfx_EngineATogglePlanes(4, 0); - v0.unk8 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].unk8, HEAP_ID_FIELD1); + v0.unk8 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].screenId, HEAP_ID_FIELD1); GF_ASSERT(v0.unk8); NNS_G2dGetUnpackedScreenData(v0.unk8, &v0.unkC); BgCopyOrUncompressTilemapBufferRangeToVram(weatherSystem->fieldSystem->bgConfig, 2, v0.unkC->rawData, v0.unkC->szByte, 0); @@ -849,21 +862,21 @@ void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1) { } } -void ov01_021EC1BC(WeatherSystem_Sub0_Sub8_LinkedList* a0, int a1) { +void ov01_021EC1BC(WeatherObject* a0, int a1) { GF_ASSERT(a0->unk8 == 0); GF_ASSERT(a1 > 0); GF_ASSERT(a1 <= 0x28u); a0->unk8 = a0->unk10; } -void ov01_021EC1E4(WeatherSystem_Sub0_Sub8_LinkedList* a0) { +void ov01_021EC1E4(WeatherObject* a0) { a0->unk8 = NULL; memset(a0->unk10, 0, 10 * sizeof(u32)); } void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1) { WeatherSystem *weatherSystem = a0->weatherSystem; - WeatherSystem_Sub0_Sub8_LinkedList *v0 = ov01_021EC8D8(a0); + WeatherObject *v0 = ov01_021EC8D8(a0); if (v0 == NULL) { return NULL; } @@ -883,7 +896,7 @@ void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1) { return v0; } -void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, UnkWeatherStruct_021EB968 *a2, u32 a3, u32 a4) { +void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, WeatherSpriteResources *a2, u32 a3, u32 a4) { int resID[4]; for (int i = 0; i < 4; i++) { @@ -893,7 +906,7 @@ void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, CreateSpriteResourcesHeader(header, resID[0], resID[1], resID[2], resID[3], -1, -1, a3, a4, weatherSystem->weatherDraw.resMan[0], weatherSystem->weatherDraw.resMan[1], weatherSystem->weatherDraw.resMan[2], weatherSystem->weatherDraw.resMan[3], NULL, NULL); } -void ov01_021EC29C(WeatherSystem_Sub0_Sub8_LinkedList* a0) { +void WeatherObject_Delete(WeatherObject* a0) { a0->prev->next = a0->next; a0->next->prev = a0->prev; @@ -901,24 +914,24 @@ void ov01_021EC29C(WeatherSystem_Sub0_Sub8_LinkedList* a0) { ov01_021EC1E4(a0); Sprite *temp = a0->unk4; - memset(a0, 0, sizeof(WeatherSystem_Sub0_Sub8_LinkedList)); + memset(a0, 0, sizeof(WeatherObject)); a0->unk4 = temp; } -void ov01_021EC2CC(WeatherSystem_Sub0_Sub8_LinkedList * a0) { - WeatherSystem_Sub0_Sub8_LinkedList *cur = a0->next; - WeatherSystem_Sub0_Sub8_LinkedList *next; +void WeatherObject_DeleteAll(WeatherObject * a0) { + WeatherObject *cur = a0->next; + WeatherObject *next; while (cur != a0) { next = cur->next; - ov01_021EC29C(cur); + WeatherObject_Delete(cur); cur = next; } } -void ov01_021EC2E4(WeatherSystem_Sub0_Sub8_LinkedList *a0, UnkLinkedListFunc func) { - WeatherSystem_Sub0_Sub8_LinkedList *cur = a0->next; - WeatherSystem_Sub0_Sub8_LinkedList *next = cur->next; +void ov01_021EC2E4(WeatherObject *a0, UnkLinkedListFunc func) { + WeatherObject *cur = a0->next; + WeatherObject *next = cur->next; while (cur != a0) { func(cur); @@ -931,7 +944,7 @@ void ov01_021EC300(void *data) { } -VecFx32 ov01_021EC304(WeatherSystem_Sub0_Sub8_LinkedList *a0) { +VecFx32 ov01_021EC304(WeatherObject *a0) { return *Sprite_GetMatrixPtr(a0->unk4); } @@ -1005,7 +1018,7 @@ void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut) { } void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y) { - WeatherSystem_Sub0_Sub8_LinkedList *cur; + WeatherObject *cur; fx32 xScale, yScale; VecFx32 matrix; ov01_021EC31C(&xScale, &yScale, a0); @@ -1113,7 +1126,7 @@ s32 ov01_021EC538(UnkStruct_021EC504* arg0) { return var_r4; } -void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7) { +void ov01_021EC5FC(WeatherFogChange *arg0, UnkStruct_021EC774* arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7) { arg1->fog = fog; if (arg7 != 0) { if (arg7 == 1) { @@ -1126,7 +1139,7 @@ void ov01_021EC5FC(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774* arg1, FogData * } } -BOOL ov01_021EC650(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774 *arg1, s32 arg2) { +BOOL ov01_021EC650(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, s32 arg2) { s32 var_r4; var_r4 = 1; @@ -1143,25 +1156,25 @@ BOOL ov01_021EC650(UnkStruct_021EC5FC *arg0, UnkStruct_021EC774 *arg1, s32 arg2) } void ov01_021EC678(FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb) { - ov01_021EA864(fog, -1, TRUE, GX_FOGBLEND_COLOR_ALPHA, fogSlope, fogOffset); + Fog_Set(fog, -1, TRUE, GX_FOGBLEND_COLOR_ALPHA, fogSlope, fogOffset); ov01_021EA89C(fog, -1, rgb, 0x1F); } -void ov01_021EC6A4(UnkStruct_021EC5FC* arg0, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5) { - int v0 = Fog_GetSlope(fog); - int v1 = Fog_GetOffset(fog); - GXRgb v2 = ov01_021EA860(fog); +void ov01_021EC6A4(WeatherFogChange* fogChange, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5) { + int slope = Fog_GetSlope(fog); + int offset = Fog_GetOffset(fog); + GXRgb rgb2 = ov01_021EA860(fog); - arg0->fog = fog; + fogChange->fog = fog; - ov01_021EB830(&arg0->unk4, v1, arg3, arg5); - ov01_021EB830(&arg0->unk18, v2 & GX_RGB_R_MASK, rgb & GX_RGB_R_MASK, arg5); - ov01_021EB830(&arg0->unk2C, (v2 >> GX_RGB_G_SHIFT) & 0x1F, (rgb >> GX_RGB_G_SHIFT) & 0x1F, arg5); - ov01_021EB830(&arg0->unk40, (v2 >> GX_RGB_B_SHIFT) & 0x1F, (rgb >> GX_RGB_B_SHIFT) & 0x1F, arg5); - ov01_021EB830(&arg0->unk54, v0, arg2, arg5); + ov01_021EB830(&fogChange->unk4, offset, arg3, arg5); + ov01_021EB830(&fogChange->unk18, rgb2 & GX_RGB_R_MASK, rgb & GX_RGB_R_MASK, arg5); + ov01_021EB830(&fogChange->unk2C, (rgb2 >> GX_RGB_G_SHIFT) & 0x1F, (rgb >> GX_RGB_G_SHIFT) & 0x1F, arg5); + ov01_021EB830(&fogChange->unk40, (rgb2 >> GX_RGB_B_SHIFT) & 0x1F, (rgb >> GX_RGB_B_SHIFT) & 0x1F, arg5); + ov01_021EB830(&fogChange->unk54, slope, arg2, arg5); } -BOOL ov01_021EC728(UnkStruct_021EC5FC *arg0) { +BOOL ov01_021EC728(WeatherFogChange *arg0) { BOOL ret = ov01_021EB840(&arg0->unk4); ov01_021EB840(&arg0->unk18); ov01_021EB840(&arg0->unk2C); @@ -1257,8 +1270,8 @@ void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int i, j; int v0 = 0; - WeatherSystem_Sub0_Sub8_LinkedList *cur = a0->linkedListDummy.next; - WeatherSystem_Sub0_Sub8_LinkedList *next = cur->next; + WeatherObject *cur = a0->linkedListDummy.next; + WeatherObject *next = cur->next; for (i = 0; i < a2; i++) { if (cur == &a0->linkedListDummy) { @@ -1282,7 +1295,7 @@ void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, } } -WeatherSystem_Sub0_Sub8_LinkedList *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 * a0) { +WeatherObject *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 * a0) { for (int i = 0; i < 64; i++) { if (a0->linkedList[i].weatherSystem == NULL) { return &a0->linkedList[i]; @@ -1399,7 +1412,7 @@ void ov01_021EC94C(SysTask *task, void *data) { break; case 5: if (v0->unkF64) { - ov01_021EA864(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + Fog_Set(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(v0->unk4); break; @@ -1414,7 +1427,7 @@ void ov01_021EC94C(SysTask *task, void *data) { void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1) { for (int i = 0; i < arg1; i++) { - WeatherSystem_Sub0_Sub8_LinkedList *v0 = ov01_021EC1F4(a0, 32); + WeatherObject *v0 = ov01_021EC1F4(a0, 32); if (v0 == NULL) { break; } @@ -1449,7 +1462,7 @@ void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1) { } } -void ov01_021ECC70(WeatherSystem_Sub0_Sub8_LinkedList *a0) { +void ov01_021ECC70(WeatherObject *a0) { int i; s32 *data = a0->unk8; VecFx32 vec; @@ -1478,7 +1491,7 @@ void ov01_021ECC70(WeatherSystem_Sub0_Sub8_LinkedList *a0) { } break; case 2: - ov01_021EC29C(a0); + WeatherObject_Delete(a0); break; } } @@ -1564,7 +1577,7 @@ void ov01_021ECD08(SysTask *task, void* data) { break; case 5: if (v0->unkF64) { - ov01_021EA864(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + Fog_Set(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(v0->unk4); break; @@ -1589,7 +1602,7 @@ void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1) { UnkStruct_021EC94C *v0 = a0->unkF58; for (int i = 0; i < a1; i++) { - WeatherSystem_Sub0_Sub8_LinkedList *v1 = ov01_021EC1F4(a0, 32); + WeatherObject *v1 = ov01_021EC1F4(a0, 32); if (v1 == NULL) { break; } @@ -1625,7 +1638,7 @@ void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1) { } } -void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList* a0) { +void ov01_021ED070(WeatherObject* a0) { s32 *data = a0->unk8; VecFx32 vec = ov01_021EC304(a0); @@ -1649,7 +1662,7 @@ void ov01_021ED070(WeatherSystem_Sub0_Sub8_LinkedList* a0) { WeatherDraw_SetSpriteMatrix(a0->unk4, &vec); break; case 1: - ov01_021EC29C(a0); + WeatherObject_Delete(a0); break; } } @@ -1726,7 +1739,7 @@ void ov01_021ED0F0(SysTask *task, void* data) { break; case 5: if (v0->unkF64) { - ov01_021EA864(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + Fog_Set(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(v0->unk4); break; @@ -1742,7 +1755,7 @@ void ov01_021ED0F0(SysTask *task, void* data) { void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { VecFx32 vec; for (int i = 0; i < a1; i++) { - WeatherSystem_Sub0_Sub8_LinkedList *v0 = ov01_021EC1F4(a0, 32); + WeatherObject *v0 = ov01_021EC1F4(a0, 32); if (v0 == NULL) { break; } @@ -1795,11 +1808,11 @@ void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { } } -void ov01_021ED44C(WeatherSystem_Sub0_Sub8_LinkedList *a0) { +void ov01_021ED44C(WeatherObject *a0) { s32 *data = a0->unk8; ov01_021EC304(a0); if (++data[0] >= data[1]) { - ov01_021EC29C(a0); + WeatherObject_Delete(a0); } } @@ -1845,7 +1858,7 @@ void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, GXFogSlo break; case 5: if (a0->unkF64 != 0) { - ov01_021EA864(a1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + Fog_Set(a1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } ov01_021EBCA4(a0->unk4); break; @@ -1907,10 +1920,165 @@ void ov01_021ED584(SysTask *task, void* data) { break; case 5: if (v0->unkF64 != 0) { - ov01_021EA864(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + Fog_Set(v1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); + } + ov01_021EBCA4(v0->unk4); + break; + } +} + +void ov01_021ED710(SysTask *task, void *data) { + WeatherSystem_Sub0_Sub8 *v0 = data; + WeatherSystem *weatherSystem = v0->weatherSystem; + FieldSystem *fieldSystem = weatherSystem->fieldSystem; + UnkStruct_021ED710 *v1 = v0->unkF58; + + switch (v0->unkF62) { + case 0: + v1->unk62C = ov01_02203EA0(PlayerAvatar_GetMapObject(fieldSystem->playerAvatar)); + Fog_Set(fieldSystem->fog, -1, TRUE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x0020, 0); + ov01_021EA89C(fieldSystem->fog, -1, 0, 0); + { + s8 v2[32]; + for (int i = 0; i < 32; i++) { + v2[i] = -1; + } + ov01_021EA8C4(fieldSystem->fog, v2); + } + v1->unk630 = 0; + v0->unkF62 = 1; + break; + case 1: + v0->unkF62 = 3; + break; + case 2: + v1->unk62C = ov01_02203EA0(PlayerAvatar_GetMapObject(fieldSystem->playerAvatar)); + Fog_Set(fieldSystem->fog, -1, TRUE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x0020, 0); + ov01_021EA89C(fieldSystem->fog, -1, 0, 0); + { + s8 v2[32]; + for (int i = 0; i < 32; i++) { + v2[i] = -1; + } + ov01_021EA8C4(fieldSystem->fog, v2); } + v1->unk630 = 0; + v0->unkF62 = 3; + break; + case 3: + if (v0->unkF66 == 5) { + v1->unk632 = 0; + v0->unkF62 = 4; + } + break; + case 4: + switch (v1->unk632) { + case 0: + BeginNormalPaletteFade(3, 0, 0, 0x7FFF, 6, 1, HEAP_ID_FIELD1); + v1->unk632++; + break; + case 1: + if (IsPaletteFadeFinished()) { + BeginNormalPaletteFade(3, 1, 1, 0x7FFF, 6, 1, HEAP_ID_FIELD1); + v1->unk632++; + } + break; + case 2: + if (IsPaletteFadeFinished()) { + v1->unk632++; + } + break; + case 3: + v1->unk630++; + float v3 = 1.0 + (v1->unk630*3.0) / 24.0; + ov01_02203F2C(v1->unk62C, v3); + if (v3 >= 4.0) { + v0->unkF62 = 5; + } + break; + } + break; + case 5: ov01_021EBCA4(v0->unk4); break; } } +void ov01_021ED924(SysTask *task, void *data) { + WeatherSystem_Sub0_Sub8 *v0 = data; + WeatherSystem *weatherSystem = v0->weatherSystem; + FieldSystem *fieldSystem = weatherSystem->fieldSystem; + UnkStruct_021ED710 *v1 = v0->unkF58; + + switch (v0->unkF62) { + case 0: + v1->unk62C = ov01_02203EA0(PlayerAvatar_GetMapObject(fieldSystem->playerAvatar)); + Fog_Set(fieldSystem->fog, -1, TRUE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x0020, 0); + ov01_021EA89C(fieldSystem->fog, -1, 0, 0); + { + s8 v2[32]; + for (int i = 0; i < 32; i++) { + v2[i] = -1; + } + ov01_021EA8C4(fieldSystem->fog, v2); + } + ov01_02203F2C(v1->unk62C, 4); + v0->unkF62 = 1; + break; + case 1: + v0->unkF62 = 3; + break; + case 2: + v1->unk62C = ov01_02203EA0(PlayerAvatar_GetMapObject(fieldSystem->playerAvatar)); + Fog_Set(fieldSystem->fog, -1, TRUE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x0020, 0); + ov01_021EA89C(fieldSystem->fog, -1, 0, 0); + { + s8 v2[32]; + for (int i = 0; i < 32; i++) { + v2[i] = -1; + } + ov01_021EA8C4(fieldSystem->fog, v2); + } + ov01_02203F2C(v1->unk62C, 4); + v0->unkF62 = 3; + break; + case 3: + if (v0->unkF66 == 5) { + v0->unkF62 = 4; + } + break; + case 4: + v0->unkF62 = 5; + break; + case 5: + ov01_021EBCA4(v0->unk4); + break; + } +} + +void ov01_021EDA50(SysTask *task, void *data) { + WeatherSystem_Sub0_Sub8 *v0 = data; + ov01_021ED474(v0, v0->unkF58, GX_FOGSLOPE_0x4000, 0x4B6F, 0x421, 0, 0); +} + +void ov01_021EDA7C(SysTask *task, void* data) { + WeatherSystem_Sub0_Sub8 *v0 = data; + if (--v0->unkF68 <= 0) { + ov01_021EDAB4(v0, SEQ_SE_DP_T_AME); + SysTask_Destroy(task); + v0->unkF6C = 0; + } +} + +void ov01_021EDAB4(WeatherSystem_Sub0_Sub8* a0, u32 sndSeq) { + GF_ASSERT(a0->unkF5C == 0); + + a0->unkF5C = 1; + a0->sndSeq = sndSeq; + PlaySE(sndSeq); +} + +void ov01_021EDAE0(WeatherSystem_Sub0_Sub8* arg0) { + StopSE(arg0->sndSeq, 0); + arg0->unkF5C = 0; +} From 091c931fe1cc2429069016eb7b3e151de9ad7eb7 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 11 Jun 2026 16:11:47 -0400 Subject: [PATCH 21/22] Decompile weather manager data --- asm/overlay_01_021EB1E8.s | 112 ----------------- include/field/weather_manager.h | 1 + main.lsf | 1 - src/field/weather_manager.c | 213 +++++++++++++++++++++++++++++++- 4 files changed, 208 insertions(+), 119 deletions(-) delete mode 100644 asm/overlay_01_021EB1E8.s diff --git a/asm/overlay_01_021EB1E8.s b/asm/overlay_01_021EB1E8.s deleted file mode 100644 index eec19541b5..0000000000 --- a/asm/overlay_01_021EB1E8.s +++ /dev/null @@ -1,112 +0,0 @@ -#include "constants/sndseq.h" -#include "constants/moves.h" -#include "constants/std_script.h" -#include "constants/species.h" -#include "constants/sprites.h" -#include "constants/maps.h" -#include "constants/mmodel.h" -#include "constants/items.h" -#include "msgdata/msg/msg_0096_D31R0201.h" -#include "msgdata/msg/msg_0066_D23R0102.h" - .include "asm/macros.inc" - .include "overlay_01_021EB1E8.inc" - .include "global.inc" - - .text - .public WeatherDraw_Init - .public WeatherDraw_Delete - .public WeatherDraw_SetSpriteMatrix - .public WeatherSystem_Delete - .public ov01_021EB804 - .public ov01_021EB830 - .public ov01_021EB818 - .public ov01_021EB840 - .public ov01_021EB86C - .public Weather_AddResObjFromOpenNarc - .public ov01_021EB968 - .public WeatherSystem_Init - .public ov01_021EBCA4 - .public ov01_021EC1BC - .public ov01_021EC1E4 - .public ov01_021EC1F4 - .public WeatherObject_Delete - .public ov01_021EC2E4 - .public ov01_021EC300 - .public ov01_021EC304 - .public ov01_021EC31C - .public ov01_021EC470 - .public ov01_021EC504 - .public ov01_021EC52C - .public ov01_021EC538 - .public ov01_021EC5FC - .public ov01_021EC650 - .public ov01_021EC678 - .public ov01_021EC790 - .public ov01_021EC7AC - .public ov01_021EC7C8 - .public ov01_021EC85C - .public ov01_021EC8F8 - .public ov01_021EC94C - .public ov01_021ECD08 - .public ov01_021ECD08 - .public ov01_021ED0F0 - .public ov01_021ED31C - .public ov01_021ED474 - .public ov01_021ED584 - .public ov01_021ED710 - .public ov01_021ED924 - .public ov01_021EDA50 - - - .rodata - -.public ov01_0220673C -ov01_0220673C: ; 0x0220673C - .word 16, 32, 16, 10 -.public ov01_0220674C -ov01_0220674C: ; 0x0220674C - .word 2, 2, 2, 2 -.public ov01_0220675C -ov01_0220675C: ; 0x0220675C - .byte 0x15, 0x00, 0x00, 0x00 - .byte 0x24, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00 - .byte 0x26, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00 - .byte 0x2A, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00 - .byte 0x1D, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x2D, 0x00, 0x00, 0x00 - .byte 0x2F, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x2D, 0x00, 0x00, 0x00, 0x2F, 0x00, 0x00, 0x00 - .byte 0x34, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00 - .byte 0x30, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00 - - .data -.public ov01_022098B0 - - .balign 4, 0 -ov01_022098B0: - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021EC8F8 - .byte 0x00, 0x00, 0xFF, 0xFF, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021EC94C - .byte 0x00, 0x00, 0xFF, 0xFF, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021EC94C - .byte 0x00, 0x00, 0xFF, 0xFF, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021EC94C - .byte 0x01, 0x00, 0xFF, 0xFF, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021ECD08 - .byte 0x01, 0x00, 0xFF, 0xFF, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021ECD08 - .byte 0x01, 0x00, 0xFF, 0xFF, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021ECD08 - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021EC8F8 - .byte 0x04, 0x00, 0xFF, 0xFF, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021ED0F0 - .byte 0xFF, 0xFF, 0x06, 0x00, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021ED584 - .byte 0xFF, 0xFF, 0x06, 0x00, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021ED584 - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x34, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021ED710 - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0x34, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021ED924 - .byte 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .word ov01_021EDA50 diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 67b8170dec..4241bbb741 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -147,6 +147,7 @@ typedef struct UnkStruct_021ED710_Sub { u32 unk2C; u16 unk30[4][192]; } UnkStruct_021ED710_Sub; + typedef struct UnkStruct_021ED710 { UnkStruct_021ED710_Sub unk0; void *unk62C; diff --git a/main.lsf b/main.lsf index 01b08e2a49..7845f9d911 100644 --- a/main.lsf +++ b/main.lsf @@ -499,7 +499,6 @@ Overlay field Object asm/overlay_01_021EAF00.o Object asm/overlay_01_021EAFD4.o Object src/field/weather_manager.o - Object asm/overlay_01_021EB1E8.o Object asm/overlay_01_021EDAFC.o Object src/field/scrcmd_message.o Object src/field/draw_map_name.o diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 1ce8703845..24a0951f36 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -44,7 +44,7 @@ struct WeatherSystem_Sub0 { struct WeatherSystem { WeatherSystem_Sub0 *unk0; - WeatherGfxNarcData *unk4; + const WeatherGfxNarcData *unk4; WeatherDraw weatherDraw; FieldSystem *fieldSystem; NARC *narc; @@ -295,8 +295,210 @@ void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32* matrix) { Sprite_SetMatrix(sprite, matrix); } -extern WeatherSystem_Sub0 ov01_022098B0[]; -extern WeatherGfxNarcData ov01_0220675C[]; +static WeatherSystem_Sub0 ov01_022098B0[] = { + { + .unk0 = 0xFFFF, + .unk2 = 0xFFFF, + .unk4 = 4, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021EC8F8, + }, + { + .unk0 = 0, + .unk2 = 0xFFFF, + .unk4 = 0xDC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021EC94C, + }, + { + .unk0 = 0, + .unk2 = 0xFFFF, + .unk4 = 0xDC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021EC94C, + }, + { + .unk0 = 0, + .unk2 = 0xFFFF, + .unk4 = 0xDC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021EC94C, + }, + { + .unk0 = 1, + .unk2 = 0xFFFF, + .unk4 = 0xDC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021ECD08, + }, + { + .unk0 = 1, + .unk2 = 0xFFFF, + .unk4 = 0xDC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021ECD08, + }, + { + .unk0 = 1, + .unk2 = 0xFFFF, + .unk4 = 0xDC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021ECD08, + }, + { + .unk0 = 0xFFFF, + .unk2 = 0xFFFF, + .unk4 = 4, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021EC8F8, + }, + { + .unk0 = 4, + .unk2 = 0xFFFF, + .unk4 = 0xDC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021ED0F0, + }, + { + .unk0 = 0xFFFF, + .unk2 = 6, + .unk4 = 0xAC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021ED584, + }, + { + .unk0 = 0xFFFF, + .unk2 = 6, + .unk4 = 0xAC, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021ED584, + }, + { + .unk0 = 0xFFFF, + .unk2 = 0xFFFF, + .unk4 = 0x634, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021ED710, + }, + { + .unk0 = 0xFFFF, + .unk2 = 0xFFFF, + .unk4 = 0x634, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021ED924, + }, + { + .unk0 = 0xFFFF, + .unk2 = 0xFFFF, + .unk4 = 0xC0, + .unk8 = NULL, + .weatherSpriteResources = NULL, + .unk10 = 0, + .unk12 = 0, + .task = NULL, + .unk18 = ov01_021EDA50, + }, +}; + +static const WeatherGfxNarcData ov01_0220675C[] = { + { + .paletteId = 0x15, + .charId = 0x24, + .screenId = 0x26, + }, + { + .paletteId = 0x25, + .charId = 0x24, + .screenId = 0x26, + }, + { + .paletteId = 0x9, + .charId = 0x8, + .screenId = 0xA, + }, + { + .paletteId = 0x2A, + .charId = 0x2C, + .screenId = 0x2B, + }, + { + .paletteId = 0x1E, + .charId = 0x1D, + .screenId = 0x1F, + }, + { + .paletteId = 0x2E, + .charId = 0x2D, + .screenId = 0x2F, + }, + { + .paletteId = 0x33, + .charId = 0x2D, + .screenId = 0x2F, + }, + { + .paletteId = 0x34, + .charId = 0x35, + .screenId = 0x36, + }, + { + .paletteId = 0x31, + .charId = 0x30, + .screenId = 0x32, + }, +}; WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem) { WeatherSystem *weatherSystem = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSystem)); @@ -1590,9 +1792,8 @@ void ov01_021ECD08(SysTask *task, void* data) { } } -//NOTE: make these direct inlines rather than external data -extern int ov01_0220673C[4]; -extern int ov01_0220674C[4]; +static const ov01_0220674C[] = {2, 2, 2, 2}; +static const ov01_0220673C[] = {16, 32, 16, 10}; void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1) { int table0[4]; From a9bf3b2ac2e66b925c3c0ec2bea9ca0cfa6f40c0 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 11 Jun 2026 20:18:35 -0400 Subject: [PATCH 22/22] Make functions static and run formater --- asm/include/overlay_01_021EB1E8.inc | 93 ----- include/constants/pokemon.h | 2 +- include/dwcaccount.h | 2 +- include/field/weather_manager.h | 107 +----- include/field_system.h | 2 +- include/overlay_01_02203E40.h | 7 + include/unk_0202C034.h | 8 +- include/unk_02037C94.h | 6 +- src/field/weather_manager.c | 472 +++++++++++++++----------- src/field_take_photo.c | 3 +- src/get_egg.c | 2 +- src/voltorb_flip/voltorb_flip_input.c | 6 +- 12 files changed, 306 insertions(+), 404 deletions(-) delete mode 100644 asm/include/overlay_01_021EB1E8.inc create mode 100644 include/overlay_01_02203E40.h diff --git a/asm/include/overlay_01_021EB1E8.inc b/asm/include/overlay_01_021EB1E8.inc deleted file mode 100644 index 0a07673b04..0000000000 --- a/asm/include/overlay_01_021EB1E8.inc +++ /dev/null @@ -1,93 +0,0 @@ -#include -#pragma once -.public PlaySE -.public StopSE -.public NARC_New -.public NARC_Delete -.public NARC_AllocAndReadWholeMember -.public GfGfxLoader_LoadFromNarc -.public CreateSpriteResourcesHeader -.public Create2DGfxResObjMan -.public Destroy2DGfxResObjMan -.public AddCharResObjFromOpenNarcWithAtEndFlag -.public AddPlttResObjFromOpenNarcWithAtEndFlag -.public AddCellOrAnimResObjFromOpenNarc -.public sub_0200A740 -.public DestroySingle2DGfxResObj -.public GF2DGfxResObj_GetResID -.public GF2DGfxResHeader_sizeof -.public GF2DGfxResHeader_GetByIndex -.public GF2DGfxResHeader_Init -.public GF2DGfxResHeader_Reset -.public GF2dGfxResHeader_GetObjIdByIndex -.public GF2DGfxResHeader_GetNarcMemberIdByIndex -.public GF2DGfxResHeader_GetCompressFlagByIndex -.public GF2DGfxResHeader_GetExDat0ByIndex -.public GF2DGfxResHeader_GetExDat1ByIndex -.public sub_0200ADA4 -.public sub_0200AEB0 -.public sub_0200B00C -.public sub_0200B0A8 -.public sub_0200B27C -.public SysTask_CreateOnMainQueue -.public SysTask_Destroy -.public BeginNormalPaletteFade -.public IsPaletteFadeFinished -.public Heap_Alloc -.public Heap_Free -.public Heap_FreeExplicit -.public BgCommitTilemapBufferToVram -.public BgCopyOrUncompressTilemapBufferRangeToVram -.public BG_LoadScreenTilemapData -.public BG_LoadCharTilesData -.public BG_LoadPlttData -.public BgTilemapRectChangePalette -.public MTRandom -.public sub_02020E10 -.public GfGfx_EngineATogglePlanes -.public Camera_GetPerspectiveAngle -.public Camera_GetDistance -.public SpriteList_Create -.public SpriteList_Delete -.public SpriteList_RenderAndAnimateSprites -.public Sprite_CreateAffine -.public Sprite_Delete -.public Sprite_SetMatrix -.public Sprite_SetDrawFlag -.public Sprite_GetMatrixPtr -.public Sprite_SetAnimationFrame -.public GF_AssertFail -.public GF_InitG2dRenderer -.public PlayerAvatar_GetMapObject -.public NNS_G2dGetUnpackedCharacterData -.public NNS_G2dGetUnpackedPaletteData -.public NNS_G2dGetUnpackedScreenData -.public FX_Div -.public G2x_SetBlendAlpha_ -.public memset -.public _dadd -.public _d2f -.public _dfltu -.public _dmul -.public _dgeq -.public _f2d -.public _ll_mul -.public _s32_div_f -.public _u32_div_f -.public _ddiv -.public NNS_G3dGlb -.public Fog_CheckActive -.public Fog_GetSlope -.public Fog_GetOffset -.public ov01_021EA860 -.public Fog_Set -.public ov01_021EA89C -.public ov01_021EA8C4 -.public ov01_021EB1E8 -.public WeatherManager_New -.public WeatherManager_Delete -.public WeatherManager_SetWeather -.public WeatherManager_ChangeWeather -.public WeatherManager_GetWeather -.public ov01_02203EA0 -.public ov01_02203F2C diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index cf6f2cf5fc..d5b52d8644 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -169,7 +169,7 @@ #define MON_DATA_OT_ID 7 #define MON_DATA_EXPERIENCE 8 #define MON_DATA_FRIENDSHIP 9 -#define MON_DATA_EGG_CYCLES 9 // Eggs track their remaining cycles in the same place that Pokemon track friendship. +#define MON_DATA_EGG_CYCLES 9 // Eggs track their remaining cycles in the same place that Pokemon track friendship. #define MON_DATA_ABILITY 10 #define MON_DATA_MARKINGS 11 #define MON_DATA_LANGUAGE 12 diff --git a/include/dwcaccount.h b/include/dwcaccount.h index e198d8d979..bfc58f2ad0 100644 --- a/include/dwcaccount.h +++ b/include/dwcaccount.h @@ -6,4 +6,4 @@ BOOL DWC_CheckValidConsole(void); BOOL DWC_CheckHasProfile(void); -#endif // POKEHEARTGOLD_DWCACCOUNT_H \ No newline at end of file +#endif // POKEHEARTGOLD_DWCACCOUNT_H diff --git a/include/field/weather_manager.h b/include/field/weather_manager.h index 4241bbb741..7f762bf608 100644 --- a/include/field/weather_manager.h +++ b/include/field/weather_manager.h @@ -2,10 +2,12 @@ #define POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H #include "global.h" -#include "task.h" -#include "sprite.h" + #include "field/fog.h" +#include "sprite.h" +#include "task.h" + enum WeatherSystemProcess { WEATHER_SYS_PROC_INIT = 0, }; @@ -157,104 +159,9 @@ typedef struct UnkStruct_021ED710 { void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0); WeatherManager *WeatherManager_New(FieldSystem *fieldSystem); -void WeatherManager_Delete(WeatherManager* weatherManager); -void WeatherManager_SetWeather(WeatherManager* weatherManager, int a1); -BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather); +void WeatherManager_Delete(WeatherManager *weatherManager); +void WeatherManager_SetWeather(WeatherManager *weatherManager, int a1); +BOOL WeatherManager_ChangeWeather(WeatherManager *weatherManager, s32 weather); u32 WeatherManager_GetWeather(WeatherManager *weatherManager); -WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem); -void WeatherSystem_Delete(WeatherSystem** pWeatherSystem); -BOOL WeatherSystem_Process(WeatherSystem *weatherSystem, int state, int weather); - -// Static functions -void WeatherTask_ChangeWeather(SysTask* task, void *data); -void ov01_021EB3F0(SysTask* task, void *data); -BOOL ov01_021EB4B4(u32 weather, u32 nextWeather); -void WeatherDraw_Init(WeatherDraw* weatherDraw); -void WeatherDrawTask_RendAndAnimateSprites(SysTask *task, void *data); -void Weather_Init2DGfxRes(GF_2DGfxResHeader *headerList, u32 a1, u32 a2); -void WeatherDraw_Delete(WeatherDraw* weatherDraw); -void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32* matrix); -u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather); -void ov01_021EB818(u32 arg0, u32 arg1); -void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3); -BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0); -void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, WeatherSpriteResources *arg2); -SpriteResource *Weather_AddResObjFromOpenNarc(GF_2DGfxResHeader *headerList, s32 resIndex, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd); -void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, WeatherSpriteResources* a2); -BOOL WeatherSystem_Init(WeatherSystem* weatherSystem, int weather); -BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); -void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2); -void ov01_021EBB68(WeatherSystem *weatherSystem, int weather); -void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather); -void ov01_021EBCA4(WeatherSystem_Sub0* a0); -void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1); -BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); -BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); -BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0); -void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 a1, WeatherSpriteResources *a2); -void ov01_021EBF24(WeatherSystem *weatherSystem, u32 a1, WeatherSpriteResources *a2); -void ov01_021EBF58(WeatherSystem *weatherSystem, u32 a1, WeatherSpriteResources *a2); -void ov01_021EBF94(WeatherSystem *weatherSystem, u32 a1, WeatherSpriteResources *a2); -void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); -void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); -void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1); -void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1); -void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1); -void ov01_021EC1BC(WeatherObject* a0, int a1); -void ov01_021EC1E4(WeatherObject* a0); -void ov01_021EC240(SpriteResourcesHeader *spriteTemplate, WeatherSystem *weatherSystem, WeatherSpriteResources *a2, u32 a3, u32 a4); -void WeatherObject_Delete(WeatherObject* a0); -void WeatherObject_DeleteAll(WeatherObject * a0); -void ov01_021EC2E4(WeatherObject *a0, UnkLinkedListFunc func); -void ov01_021EC300(void *data); -VecFx32 ov01_021EC304(WeatherObject *a0); -void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0); -void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut); -void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y); -void ov01_021EC504(UnkStruct_021EC504* arg0, WeatherSystem_Sub0_Sub8 *arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkWeatherSystemSub0Sub8Func arg9); -void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4); -s32 ov01_021EC538(UnkStruct_021EC504* arg0); -void ov01_021EC5FC(WeatherFogChange *arg0, UnkStruct_021EC774* arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7); -BOOL ov01_021EC650(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, s32 arg2); -void ov01_021EC678(FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb); -void ov01_021EC6A4(WeatherFogChange* arg0, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5); -BOOL ov01_021EC728(WeatherFogChange *arg0); -void ov01_021EC774(UnkStruct_021EC774* a0); -void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2); -s32 ov01_021EC7AC(UnkStruct_021EC774* arg0); -void ov01_021EC7C8(UnkStruct_021EC774* arg0); -s32 ov01_021EC7E8(UnkStruct_021EC774 *arg0); -void ov01_021EC828(UnkStruct_021EC774 *arg0); -void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int a2, int a3, int a4, UnkLinkedListFunc a5); -WeatherObject *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); -void ov01_021EC8F8(SysTask *task, void* data); -void ov01_021EC94C(SysTask *task, void *data); -void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *, int); -void ov01_021ECC70(WeatherObject *a0); -void ov01_021ECD08(SysTask *task, void* data); -void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1); -void ov01_021ED070(WeatherObject *a0); -void ov01_021ED0F0(SysTask *task, void* data); -void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1); -void ov01_021ED44C(WeatherObject *a0); -void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, GXFogSlope fogSlope, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6); -void ov01_021ED584(SysTask *task, void* data); -void ov01_021ED710(SysTask *task, void *data); -void ov01_021ED924(SysTask *task, void *data); -void ov01_021EDA50(SysTask *task, void *data); -void ov01_021EDA7C(SysTask *task, void* data); -void ov01_021EDAB4(WeatherSystem_Sub0_Sub8* a0, u32 sndSeq); -void ov01_021EDAE0(WeatherSystem_Sub0_Sub8* arg0); -// Not yet decompiled -void ov01_021EB3F0(SysTask *task, void *data); -void WeatherDrawTask_RendAndAnimateSprites(SysTask *task, void *data); -void Weather_Init2DGfxRes(GF_2DGfxResHeader *header, u32 a1, u32 a2); -BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); -void ov01_021EBD70(SysTask *task, void *data); -void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); -void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1); -void *ov01_02203EA0(); -void ov01_02203F2C(void *, float a0); - #endif // POKEHEARTGOLD_FIELD_WEATHER_MANAGER_H diff --git a/include/field_system.h b/include/field_system.h index 60430f19db..fd9ec90f19 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -2,6 +2,7 @@ #define POKEHEARTGOLD_FIELD_SYSTEM_H #include "field/draw_map_name.h" +#include "field/fog.h" #include "field/overlay_01_021E66E4.h" #include "field/weather_manager.h" @@ -25,7 +26,6 @@ #include "sys_task_api.h" #include "terrain_attributes.h" #include "unk_02092BB8.h" -#include "field/fog.h" typedef struct FollowMon { LocalMapObject *mapObject; diff --git a/include/overlay_01_02203E40.h b/include/overlay_01_02203E40.h new file mode 100644 index 0000000000..c0e79ff72f --- /dev/null +++ b/include/overlay_01_02203E40.h @@ -0,0 +1,7 @@ +#ifndef POKEHEARTGOLD_OVERLAY_01_02203E40_H +#define POKEHEARTGOLD_OVERLAY_01_02203E40_H + +void *ov01_02203EA0(); +void ov01_02203F2C(void *, float a0); + +#endif // POKEHEARTGOLD_OVERLAY_01_02203E40_H diff --git a/include/unk_0202C034.h b/include/unk_0202C034.h index 6296db6713..6919865b09 100644 --- a/include/unk_0202C034.h +++ b/include/unk_0202C034.h @@ -10,13 +10,13 @@ void sub_0202C714(SaveData *saveData); UnkStruct_021D2230 *sub_0202C6F4(SaveData *saveData); int sub_0202C2F8(struct UnkStruct_021D2230 *a0); void *sub_0202C08C(UnkStruct_021D2230 *a0); -u16* sub_0202C254(struct UnkStruct_021D2230 *a0, s32 a1); -u16* sub_0202C298(struct UnkStruct_021D2230 *a0, s32 a1); +u16 *sub_0202C254(struct UnkStruct_021D2230 *a0, s32 a1); +u16 *sub_0202C298(struct UnkStruct_021D2230 *a0, s32 a1); s32 sub_0202C090(struct UnkStruct_021D2230 *a0, s32 a1, s32 a2); void sub_0202C46C(struct UnkStruct_021D2230 *a0); void sub_0202C4B0(struct UnkStruct_021D2230 *a0, s32 a1); u16 sub_0202C318(struct UnkStruct_021D2230 *a0); -void sub_0202C190(UnkStruct_021D2230* a0, int a1, int a2, u8 a3); -void sub_0202C03C(struct UnkStruct_021D2230* a0); +void sub_0202C190(UnkStruct_021D2230 *a0, int a1, int a2, u8 a3); +void sub_0202C03C(struct UnkStruct_021D2230 *a0); #endif // POKEHEARTGOLD_UNK_0202C034_H diff --git a/include/unk_02037C94.h b/include/unk_02037C94.h index 1cef31176b..887b7adca5 100644 --- a/include/unk_02037C94.h +++ b/include/unk_02037C94.h @@ -1,9 +1,9 @@ #ifndef POKEHEARTGOLD_UNK_02037C94_H #define POKEHEARTGOLD_UNK_02037C94_H +#include "overlay_44_02232E9C.h" #include "save.h" #include "unk_0202C034.h" -#include "overlay_44_02232E9C.h" BOOL sub_02037D78(void); void sub_02037FF0(void); @@ -33,10 +33,10 @@ UnkStruct_ov44_0223197C *sub_020398C8(void); void sub_020393B4(void); BOOL sub_02039274(void); void sub_02039330(void); -void sub_0203A1C4(SaveData* saveData, void* a1, enum HeapID heapID); +void sub_0203A1C4(SaveData *saveData, void *a1, enum HeapID heapID); void sub_02039B7C(void); BOOL sub_020392A0(void); -UnkStruct_ov44_0223197C* sub_020396FC(SaveData*, int); +UnkStruct_ov44_0223197C *sub_020396FC(SaveData *, int); void sub_02039378(void); void sub_02039FD8(enum HeapID heapID); void sub_02039E9C(void); diff --git a/src/field/weather_manager.c b/src/field/weather_manager.c index 24a0951f36..a75d9269da 100644 --- a/src/field/weather_manager.c +++ b/src/field/weather_manager.c @@ -1,16 +1,106 @@ #include "field/weather_manager.h" -#include "heap.h" -#include "gf_gfx_planes.h" + #include "constants/weather.h" -#include "unk_02025C44.h" -#include "unk_0200B150.h" -#include "gf_gfx_loader.h" + #include "field_system.h" +#include "gf_gfx_loader.h" +#include "gf_gfx_planes.h" +#include "heap.h" +#include "math_util.h" +#include "overlay_01_02203E40.h" #include "unk_02005D10.h" #include "unk_0200ACF0.h" -#include "unk_02020B8C.h" -#include "math_util.h" +#include "unk_0200B150.h" #include "unk_0200FA24.h" +#include "unk_02020B8C.h" +#include "unk_02025C44.h" + +static void WeatherTask_ChangeWeather(SysTask *task, void *data); +static void ov01_021EB3F0(SysTask *task, void *data); +static BOOL ov01_021EB4B4(u32 weather, u32 nextWeather); +static void WeatherDraw_Init(WeatherDraw *weatherDraw); +static void WeatherDrawTask_RendAndAnimateSprites(SysTask *task, void *data); +static void Weather_Init2DGfxRes(GF_2DGfxResHeader *headerList, u32 a1, u32 a2); +static void WeatherDraw_Delete(WeatherDraw *weatherDraw); +static void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32 *matrix); +static WeatherSystem *WeatherSystem_New(FieldSystem *fieldSystem); +static void WeatherSystem_Delete(WeatherSystem **pWeatherSystem); +static BOOL WeatherSystem_Process(WeatherSystem *weatherSystem, int state, int weather); +static u16 ov01_021EB804(WeatherSystem *weatherSystem, int weather); +static void ov01_021EB818(u32 arg0, u32 arg1); +static void ov01_021EB830(UnkWeatherStruct_021EB830 *arg0, s32 arg1, s32 arg2, s32 arg3); +static BOOL ov01_021EB840(UnkWeatherStruct_021EB830 *a0); +static void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, WeatherSpriteResources *arg2); +static SpriteResource *Weather_AddResObjFromOpenNarc(GF_2DGfxResHeader *headerList, s32 resourceType, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd); +static void ov01_021EB968(WeatherSystem *weatherSystem, s32 a1, WeatherSpriteResources *a2); +static BOOL WeatherSystem_Init(WeatherSystem *weatherSystem, int weather); +static BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather); +static BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3); +static void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2); +static void ov01_021EBB68(WeatherSystem *weatherSystem, int weather); +static void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather); +static void ov01_021EBCA4(WeatherSystem_Sub0 *a0); +static void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1); +static BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +static void ov01_021EBD70(SysTask *task, void *data); +static BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +static BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0); +static void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2); +static void ov01_021EBF24(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2); +static void ov01_021EBF58(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2); +static void ov01_021EBF94(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2); +static void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1); +static void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0); +static void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0); +static void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1); +static void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1); +static void ov01_021EC114(WeatherSystem *weatherSystem, u16 a1); +static void ov01_021EC1BC(WeatherObject *a0, int a1); +static void ov01_021EC1E4(WeatherObject *a0); +static void *ov01_021EC1F4(WeatherSystem_Sub0_Sub8 *a0, int a1); +static void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, WeatherSpriteResources *a2, u32 a3, u32 a4); +static void WeatherObject_Delete(WeatherObject *a0); +static void WeatherObject_DeleteAll(WeatherObject *a0); +static void ov01_021EC2E4(WeatherObject *a0, UnkLinkedListFunc func); +static void ov01_021EC300(void *data); +static VecFx32 ov01_021EC304(WeatherObject *a0); +static void ov01_021EC31C(fx32 *x, fx32 *z, WeatherSystem_Sub0_Sub8 *a0); +static void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut); +static void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y); +static void ov01_021EC504(UnkStruct_021EC504 *arg0, WeatherSystem_Sub0_Sub8 *arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkWeatherSystemSub0Sub8Func arg9); +static void ov01_021EC52C(UnkStruct_021EC504 *arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4); +static s32 ov01_021EC538(UnkStruct_021EC504 *arg0); +static void ov01_021EC5FC(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7); +static BOOL ov01_021EC650(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, s32 arg2); +static void ov01_021EC678(FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb); +static void ov01_021EC6A4(WeatherFogChange *fogChange, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5); +static BOOL ov01_021EC728(WeatherFogChange *arg0); +static void ov01_021EC774(UnkStruct_021EC774 *a0); +static void ov01_021EC790(UnkStruct_021EC774 *arg0, s32 arg1, s32 arg2); +static s32 ov01_021EC7AC(UnkStruct_021EC774 *arg0); +static void ov01_021EC7C8(UnkStruct_021EC774 *arg0); +static s32 ov01_021EC7E8(UnkStruct_021EC774 *arg0); +static void ov01_021EC828(UnkStruct_021EC774 *arg0); +static void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int a2, int a3, int a4, UnkLinkedListFunc a5); +static WeatherObject *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0); +static void ov01_021EC8F8(SysTask *task, void *data); +static void ov01_021EC94C(SysTask *task, void *data); +static void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1); +static void ov01_021ECC70(WeatherObject *a0); +static void ov01_021ECD08(SysTask *task, void *data); +static void ov01_021ECF4C(WeatherSystem_Sub0_Sub8 *a0, int a1); +static void ov01_021ED070(WeatherObject *a0); +static void ov01_021ED0F0(SysTask *task, void *data); +static void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1); +static void ov01_021ED44C(WeatherObject *a0); +static void ov01_021ED474(WeatherSystem_Sub0_Sub8 *a0, UnkStruct_021ED474 *a1, GXFogSlope fogSlope, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6); +static void ov01_021ED584(SysTask *task, void *data); +static void ov01_021ED710(SysTask *task, void *data); +static void ov01_021ED924(SysTask *task, void *data); +static void ov01_021EDA50(SysTask *task, void *data); +static void ov01_021EDA7C(SysTask *task, void *data); +static void ov01_021EDAB4(WeatherSystem_Sub0_Sub8 *a0, u32 sndSeq); +static void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *arg0); struct WeatherSystem_Sub0_Sub8 { WeatherSystem *weatherSystem; @@ -50,7 +140,6 @@ struct WeatherSystem { NARC *narc; }; - void ov01_021EB1E8(UnkStruct_ov01_021EB1E8 *a0) { a0->unk188 = 1; } @@ -66,16 +155,16 @@ WeatherManager *WeatherManager_New(FieldSystem *fieldSystem) { WeatherManager *weatherManager = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherManager)); memset(weatherManager, 0, sizeof(WeatherManager)); - + weatherManager->weatherSystem = WeatherSystem_New(fieldSystem); weatherManager->weather = WEATHER_SUNNY; weatherManager->nextWeather = WEATHER_SUNNY; weatherManager->state = 6; weatherManager->task = NULL; weatherManager->unk10 = WEATHER_MAX; - + GfGfx_EngineATogglePlanes(GX_PLANEMASK_OBJ, GF_PLANE_TOGGLE_ON); - + return weatherManager; } @@ -84,19 +173,19 @@ WeatherManager *WeatherManager_New(FieldSystem *fieldSystem) { * * @param weatherManager */ -void WeatherManager_Delete(WeatherManager* weatherManager) { +void WeatherManager_Delete(WeatherManager *weatherManager) { if (weatherManager->task) { SysTask_Destroy(weatherManager->task); } - + WeatherSystem_Delete(&weatherManager->weatherSystem); memset(weatherManager, 0, sizeof(WeatherManager)); - + Heap_Free(weatherManager); } -void WeatherManager_SetWeather(WeatherManager* weatherManager, int weather) { +void WeatherManager_SetWeather(WeatherManager *weatherManager, int weather) { GF_ASSERT(weatherManager->state == 6); GF_ASSERT(weather < WEATHER_MAX); @@ -108,10 +197,10 @@ void WeatherManager_SetWeather(WeatherManager* weatherManager, int weather) { } } -BOOL WeatherManager_ChangeWeather(WeatherManager* weatherManager, s32 weather) { +BOOL WeatherManager_ChangeWeather(WeatherManager *weatherManager, s32 weather) { GF_ASSERT(weather < WEATHER_MAX); - if(weatherManager->state != 6) { + if (weatherManager->state != 6) { weatherManager->unk10 = weather; return TRUE; } @@ -138,7 +227,7 @@ u32 WeatherManager_GetWeather(WeatherManager *weatherManager) { return weatherManager->weather; } -void WeatherTask_ChangeWeather(SysTask* task, void *data) { +static void WeatherTask_ChangeWeather(SysTask *task, void *data) { WeatherManager *weatherManager = data; switch (weatherManager->state) { case 0: @@ -178,7 +267,7 @@ void WeatherTask_ChangeWeather(SysTask* task, void *data) { } } -void ov01_021EB3F0(SysTask* task, void *data) { +static void ov01_021EB3F0(SysTask *task, void *data) { WeatherManager *weatherManager = data; switch (weatherManager->state) { case 0: @@ -215,23 +304,23 @@ void ov01_021EB3F0(SysTask* task, void *data) { } } -BOOL ov01_021EB4B4(u32 weather, u32 nextWeather) { +static BOOL ov01_021EB4B4(u32 weather, u32 nextWeather) { return FALSE; } -void WeatherDraw_Init(WeatherDraw* weatherDraw) { +static void WeatherDraw_Init(WeatherDraw *weatherDraw) { GF_InitG2dRenderer(&weatherDraw->instance, 0xFFFFF000); - + NNSG2dViewRect rect; rect.posTopLeft.x = 0; rect.posTopLeft.y = 0; rect.sizeView.x = 0xFF000; rect.sizeView.y = 0xC0000; - + sub_0200B27C(&weatherDraw->surface, &rect, NNS_G2D_VRAM_TYPE_2DMAIN, &weatherDraw->instance); for (int i = 0; i < 4; i++) { - weatherDraw->resMan[i] = Create2DGfxResObjMan(14, (GfGfxResType) i, HEAP_ID_FIELD1); + weatherDraw->resMan[i] = Create2DGfxResObjMan(14, (GfGfxResType)i, HEAP_ID_FIELD1); } weatherDraw->header = Heap_Alloc(HEAP_ID_FIELD1, 4 * GF2DGfxResHeader_sizeof()); @@ -245,41 +334,41 @@ void WeatherDraw_Init(WeatherDraw* weatherDraw) { param.num = 0x40; param.rendererInstance = &weatherDraw->instance; param.heapID = HEAP_ID_FIELD1; - + weatherDraw->spriteList = SpriteList_Create(¶m); weatherDraw->task = SysTask_CreateOnMainQueue(WeatherDrawTask_RendAndAnimateSprites, weatherDraw, 10); } -void WeatherDrawTask_RendAndAnimateSprites(SysTask *task, void *data) { +static void WeatherDrawTask_RendAndAnimateSprites(SysTask *task, void *data) { WeatherDraw *weatherDraw = data; SpriteList_RenderAndAnimateSprites(weatherDraw->spriteList); } -void Weather_Init2DGfxRes(GF_2DGfxResHeader *headerList, u32 a1, u32 a2) { +static void Weather_Init2DGfxRes(GF_2DGfxResHeader *headerList, u32 a1, u32 a2) { GF_2DGfxResHeader *header = GF2DGfxResHeader_GetByIndex(headerList, a1); GF_2DGfxResHeaderNarcList *headerNarcList = GfGfxLoader_LoadFromNarc(NARC_a_0_6_3, a2, 0, HEAP_ID_FIELD1, 1); GF2DGfxResHeader_Init(headerNarcList, header, HEAP_ID_FIELD1); Heap_Free(headerNarcList); } -void WeatherDraw_Delete(WeatherDraw* weatherDraw) { +static void WeatherDraw_Delete(WeatherDraw *weatherDraw) { for (int i = 0; i < 4; i++) { GF2DGfxResHeader_Reset(GF2DGfxResHeader_GetByIndex(weatherDraw->header, i)); Destroy2DGfxResObjMan(weatherDraw->resMan[i]); } - + Heap_Free(weatherDraw->header); weatherDraw->header = NULL; - + SpriteList_Delete(weatherDraw->spriteList); weatherDraw->spriteList = NULL; - + SysTask_Destroy(weatherDraw->task); weatherDraw->task = NULL; } -void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32* matrix) { +static void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32 *matrix) { if (matrix->x > 0x13F000) { matrix->x %= 0x13F000; } else if (matrix->x < (int)0xFFFC0000) { @@ -291,10 +380,11 @@ void WeatherDraw_SetSpriteMatrix(Sprite *sprite, VecFx32* matrix) { } else if (matrix->y < (int)0xFFFC0000) { matrix->y += 0x100000; } - + Sprite_SetMatrix(sprite, matrix); } +// clang-format off static WeatherSystem_Sub0 ov01_022098B0[] = { { .unk0 = 0xFFFF, @@ -499,23 +589,24 @@ static const WeatherGfxNarcData ov01_0220675C[] = { .screenId = 0x32, }, }; +// clang-format on -WeatherSystem* WeatherSystem_New(FieldSystem *fieldSystem) { +static WeatherSystem *WeatherSystem_New(FieldSystem *fieldSystem) { WeatherSystem *weatherSystem = Heap_Alloc(HEAP_ID_FIELD1, sizeof(WeatherSystem)); weatherSystem->fieldSystem = fieldSystem; - + WeatherDraw_Init(&weatherSystem->weatherDraw); weatherSystem->unk0 = ov01_022098B0; weatherSystem->unk4 = ov01_0220675C; - + weatherSystem->narc = NARC_New(NARC_a_0_6_3, HEAP_ID_FIELD1); return weatherSystem; } -void WeatherSystem_Delete(WeatherSystem** pWeatherSystem) { +static void WeatherSystem_Delete(WeatherSystem **pWeatherSystem) { if (*pWeatherSystem != NULL) { for (int i = 0; i < 14; i++) { ov01_021EBB90(*pWeatherSystem, i); @@ -536,9 +627,9 @@ void WeatherSystem_Delete(WeatherSystem** pWeatherSystem) { } } -BOOL WeatherSystem_Process(WeatherSystem *weatherSystem, int state, int weather) { - BOOL ret = TRUE; - +static BOOL WeatherSystem_Process(WeatherSystem *weatherSystem, int state, int weather) { + BOOL ret = TRUE; + if (weather > 14) { return FALSE; } @@ -590,11 +681,11 @@ BOOL WeatherSystem_Process(WeatherSystem *weatherSystem, int state, int weather) default: break; } - + return ret; } -u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather) { +static u16 ov01_021EB804(WeatherSystem *weatherSystem, int weather) { if (weather >= 14) { return 0; } @@ -602,11 +693,11 @@ u16 ov01_021EB804(WeatherSystem* weatherSystem, int weather) { return v0->unk10; } -void ov01_021EB818(u32 arg0, u32 arg1) { +static void ov01_021EB818(u32 arg0, u32 arg1) { G2x_SetBlendAlpha_(0x04000050, 4, 0x21, arg0, arg1); } -void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3) { +static void ov01_021EB830(UnkWeatherStruct_021EB830 *arg0, s32 arg1, s32 arg2, s32 arg3) { arg0->unk0 = arg1; arg0->unk4 = arg1; arg0->unk8 = arg2 - arg1; @@ -614,7 +705,7 @@ void ov01_021EB830(UnkWeatherStruct_021EB830* arg0, s32 arg1, s32 arg2, s32 arg3 arg0->unkC = 0; } -BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0) { +static BOOL ov01_021EB840(UnkWeatherStruct_021EB830 *a0) { int v0 = a0->unk8 * a0->unkC; v0 /= a0->unk10; @@ -629,14 +720,14 @@ BOOL ov01_021EB840(UnkWeatherStruct_021EB830* a0) { return TRUE; } -void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, WeatherSpriteResources *arg2) { +static void ov01_021EB86C(WeatherSystem *weatherSystem, s32 arg1, WeatherSpriteResources *arg2) { ov01_021EBEF0(weatherSystem, arg1, arg2); ov01_021EBF24(weatherSystem, arg1, arg2); ov01_021EBF58(weatherSystem, arg1, arg2); ov01_021EBF94(weatherSystem, arg1, arg2); } -SpriteResource *Weather_AddResObjFromOpenNarc(GF_2DGfxResHeader *headerList, s32 resourceType, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd) { +static SpriteResource *Weather_AddResObjFromOpenNarc(GF_2DGfxResHeader *headerList, s32 resourceType, s32 headerIndex, GF_2DGfxResMan *resMan, NARC *narc, BOOL atEnd) { GF_2DGfxResHeader *header = GF2DGfxResHeader_GetByIndex(headerList, resourceType); u32 member = GF2DGfxResHeader_GetNarcMemberIdByIndex(header, headerIndex); u32 compressFlag = GF2DGfxResHeader_GetCompressFlagByIndex(header, headerIndex); @@ -663,7 +754,7 @@ SpriteResource *Weather_AddResObjFromOpenNarc(GF_2DGfxResHeader *headerList, s32 return ret; } -void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, WeatherSpriteResources* a2) { +static void ov01_021EB968(WeatherSystem *weatherSystem, s32 a1, WeatherSpriteResources *a2) { if (a1 != 0xFFFF) { if (a2->charResObj[GF_GFX_RES_TYPE_CHAR] != 0) { sub_0200AEB0(a2->charResObj[GF_GFX_RES_TYPE_CHAR]); @@ -680,7 +771,7 @@ void ov01_021EB968(WeatherSystem* weatherSystem, s32 a1, WeatherSpriteResources* } } -BOOL WeatherSystem_Init(WeatherSystem* weatherSystem, int weather) { +static BOOL WeatherSystem_Init(WeatherSystem *weatherSystem, int weather) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; if (v0->unk8 == 0) { if (ov01_021EBE4C(weatherSystem, v0) == FALSE) { @@ -694,7 +785,7 @@ BOOL WeatherSystem_Init(WeatherSystem* weatherSystem, int weather) { } v0->unk8->unk8 = v0->weatherSpriteResources; - + if (v0->unk0 != 0xFFFF) { ov01_021EC028(v0->unk8); } @@ -706,7 +797,7 @@ BOOL WeatherSystem_Init(WeatherSystem* weatherSystem, int weather) { return TRUE; } -BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather) { +static BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; if (v0->unk8) { return TRUE; @@ -723,7 +814,7 @@ BOOL ov01_021EBA08(WeatherSystem *weatherSystem, int weather) { return TRUE; } -BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3) { +static BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 a3) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; if (v0->unk0 != 0xFFFF && v0->weatherSpriteResources == 0) { @@ -737,7 +828,7 @@ BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 if (v0->unk10 != 2) { return FALSE; } - + v0->unk8->unkF48 = SysTask_CreateOnMainQueue(v0->unk18, v0->unk8, 4); if (v0->unk8->unkF48 == NULL) { @@ -751,26 +842,26 @@ BOOL WeatherSystem_Start(WeatherSystem *weatherSystem, int weather, u32 a2, u32 v0->unk8->linkedListDummy.prev = &v0->unk8->linkedListDummy; v0->unk8->unkF64 = a3; v0->unk8->unkF5C = 0; - + v0->unk8->cameraTarget = NNS_G3dGlb.camTarget; - + if (v0->unk4 > 0) { v0->unk8->unkF58 = Heap_Alloc(HEAP_ID_FIELD1, v0->unk4); memset(v0->unk8->unkF58, 0, v0->unk4); } else { v0->unk8->unkF58 = NULL; } - + if (v0->unk2 != 0xFFFF) { GfGfx_EngineATogglePlanes(4, 0); G2_SetBG2Priority(1); G2_SetBG0Priority(2); } - + return TRUE; } -void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2) { +static void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; if (v0->unk10 == 3) { v0->unk8->unkF66 = 5; @@ -778,7 +869,7 @@ void ov01_021EBB40(WeatherSystem *weatherSystem, int weather, u16 a2) { } } -void ov01_021EBB68(WeatherSystem *weatherSystem, int weather) { +static void ov01_021EBB68(WeatherSystem *weatherSystem, int weather) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; if (ov01_021EB804(weatherSystem, weather) == 3) { v0->unk8->unkF62 = 5; @@ -786,18 +877,17 @@ void ov01_021EBB68(WeatherSystem *weatherSystem, int weather) { } } - -void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { +static void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { WeatherSystem_Sub0 *v0 = &weatherSystem->unk0[weather]; if (v0->unk2 != 0xFFFF) { GfGfx_EngineATogglePlanes(4, 0); - + G2_SetBG2Priority(3); - G2_SetBG0Priority(1); + G2_SetBG0Priority(1); G2_BlendNone(); } - + if (v0->weatherSpriteResources) { ov01_021EB968(weatherSystem, v0->unk0, v0->weatherSpriteResources); Heap_FreeExplicit(HEAP_ID_FIELD1, v0->weatherSpriteResources); @@ -807,7 +897,7 @@ void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { v0->task = NULL; } } - + if (v0->unk8) { WeatherObject_DeleteAll(&v0->unk8->linkedListDummy); @@ -843,12 +933,12 @@ void ov01_021EBB90(WeatherSystem *weatherSystem, u32 weather) { Fog_Set(weatherSystem->fieldSystem->fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); } -void ov01_021EBCA4(WeatherSystem_Sub0* a0) { +static void ov01_021EBCA4(WeatherSystem_Sub0 *a0) { if (a0->unk2 != 0xFFFF) { GfGfx_EngineATogglePlanes(4, 0); G2_SetBG2Priority(3); - G2_SetBG0Priority(1); - G2_BlendNone(); + G2_SetBG0Priority(1); + G2_BlendNone(); } if (a0->unk8 != NULL) { @@ -865,13 +955,13 @@ void ov01_021EBCA4(WeatherSystem_Sub0* a0) { } } -void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1) { +static void ov01_021EBD18(WeatherSystem *weatherSystem, u16 a1) { ov01_021EC078(weatherSystem, a1); ov01_021EC0C0(weatherSystem, a1); ov01_021EC114(weatherSystem, a1); } -BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { +static BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { if (a1->unk0 != 0xFFFF && a1->weatherSpriteResources == NULL) { if (ov01_021EBEB8(a1) == FALSE) { return FALSE; @@ -882,7 +972,7 @@ BOOL ov01_021EBD34(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { return TRUE; } -void ov01_021EBD70(SysTask *task, void *data) { +static void ov01_021EBD70(SysTask *task, void *data) { WeatherSystem_Sub0 *v0 = data; WeatherSystem *weatherSystem = v0->unk8->weatherSystem; switch (v0->unk12) { @@ -931,7 +1021,7 @@ void ov01_021EBD70(SysTask *task, void *data) { } } -BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { +static BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { if (a1->unk8) { return TRUE; } @@ -954,7 +1044,7 @@ BOOL ov01_021EBE4C(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { return TRUE; } -BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0) { +static BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0) { if (a0->unk0 != 0xFFFF) { if (a0->weatherSpriteResources != NULL) { return TRUE; @@ -968,19 +1058,19 @@ BOOL ov01_021EBEB8(WeatherSystem_Sub0 *a0) { return TRUE; } -void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { +static void ov01_021EBEF0(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { if (headerIndex != 0xFFFF) { a2->charResObj[GF_GFX_RES_TYPE_CELL] = Weather_AddResObjFromOpenNarc(weatherSystem->weatherDraw.header, GF_GFX_RES_TYPE_CELL, headerIndex, weatherSystem->weatherDraw.resMan[GF_GFX_RES_TYPE_CELL], weatherSystem->narc, 0); } } -void ov01_021EBF24(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { +static void ov01_021EBF24(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { if (headerIndex != 0xFFFF) { a2->charResObj[GF_GFX_RES_TYPE_ANIM] = Weather_AddResObjFromOpenNarc(weatherSystem->weatherDraw.header, GF_GFX_RES_TYPE_ANIM, headerIndex, weatherSystem->weatherDraw.resMan[GF_GFX_RES_TYPE_ANIM], weatherSystem->narc, 0); } } -void ov01_021EBF58(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { +static void ov01_021EBF58(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { if (headerIndex != 0xFFFF) { a2->charResObj[GF_GFX_RES_TYPE_CHAR] = Weather_AddResObjFromOpenNarc(weatherSystem->weatherDraw.header, GF_GFX_RES_TYPE_CHAR, headerIndex, weatherSystem->weatherDraw.resMan[GF_GFX_RES_TYPE_CHAR], weatherSystem->narc, 1); sub_0200ADA4(a2->charResObj[GF_GFX_RES_TYPE_CHAR]); @@ -988,7 +1078,7 @@ void ov01_021EBF58(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteR } } -void ov01_021EBF94(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { +static void ov01_021EBF94(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteResources *a2) { if (headerIndex != 0xFFFF) { a2->charResObj[GF_GFX_RES_TYPE_PLTT] = Weather_AddResObjFromOpenNarc(weatherSystem->weatherDraw.header, GF_GFX_RES_TYPE_PLTT, headerIndex, weatherSystem->weatherDraw.resMan[GF_GFX_RES_TYPE_PLTT], weatherSystem->narc, 1); sub_0200B00C(a2->charResObj[GF_GFX_RES_TYPE_PLTT]); @@ -996,7 +1086,7 @@ void ov01_021EBF94(WeatherSystem *weatherSystem, u32 headerIndex, WeatherSpriteR } } -void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { +static void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { if (a1->unk0 != 0xFFFF) { ov01_021EC240(&a1->weatherSpriteResources->spriteResHeader, weatherSystem, a1->weatherSpriteResources, 0, 1); memset(&a1->weatherSpriteResources->spriteTemplate, 0, sizeof(SpriteTemplate)); @@ -1009,7 +1099,7 @@ void ov01_021EBFD0(WeatherSystem *weatherSystem, WeatherSystem_Sub0 *a1) { } } -void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0) { +static void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0) { for (int i = 0; i < 64; i++) { a0->linkedList[i].unk4 = Sprite_CreateAffine(&a0->unk8->spriteTemplate); Sprite_SetDrawFlag(a0->linkedList[i].unk4, 0); @@ -1017,7 +1107,7 @@ void ov01_021EC028(WeatherSystem_Sub0_Sub8 *a0) { } } -void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0) { +static void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0) { for (int i = 0; i < 64; i++) { if (a0->linkedList[i].unk4) { Sprite_Delete(a0->linkedList[i].unk4); @@ -1026,7 +1116,7 @@ void ov01_021EC058(WeatherSystem_Sub0_Sub8 *a0) { } } -void ov01_021EC078(WeatherSystem* weatherSystem, u16 a1) { +static void ov01_021EC078(WeatherSystem *weatherSystem, u16 a1) { UnkWeatherStruct_021EC078 v0; if (a1 != 0xFFFF) { v0.unk0 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].paletteId, HEAP_ID_FIELD1); @@ -1037,7 +1127,7 @@ void ov01_021EC078(WeatherSystem* weatherSystem, u16 a1) { } } -void ov01_021EC0C0(WeatherSystem* weatherSystem, u16 a1) { +static void ov01_021EC0C0(WeatherSystem *weatherSystem, u16 a1) { UnkWeatherStruct_021EC078 v0; if (a1 != 0xFFFF) { v0.unk4 = NARC_AllocAndReadWholeMember(weatherSystem->narc, weatherSystem->unk4[a1].charId, HEAP_ID_FIELD1); @@ -1048,7 +1138,7 @@ void ov01_021EC0C0(WeatherSystem* weatherSystem, u16 a1) { } } -void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1) { +static void ov01_021EC114(WeatherSystem *weatherSystem, u16 a1) { UnkWeatherStruct_021EC078 v0; if (a1 != 0xFFFF) { GfGfx_EngineATogglePlanes(4, 0); @@ -1064,19 +1154,19 @@ void ov01_021EC114(WeatherSystem* weatherSystem, u16 a1) { } } -void ov01_021EC1BC(WeatherObject* a0, int a1) { +static void ov01_021EC1BC(WeatherObject *a0, int a1) { GF_ASSERT(a0->unk8 == 0); GF_ASSERT(a1 > 0); GF_ASSERT(a1 <= 0x28u); a0->unk8 = a0->unk10; } -void ov01_021EC1E4(WeatherObject* a0) { +static void ov01_021EC1E4(WeatherObject *a0) { a0->unk8 = NULL; memset(a0->unk10, 0, 10 * sizeof(u32)); } -void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1) { +static void *ov01_021EC1F4(WeatherSystem_Sub0_Sub8 *a0, int a1) { WeatherSystem *weatherSystem = a0->weatherSystem; WeatherObject *v0 = ov01_021EC8D8(a0); if (v0 == NULL) { @@ -1098,7 +1188,7 @@ void* ov01_021EC1F4(WeatherSystem_Sub0_Sub8* a0, int a1) { return v0; } -void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, WeatherSpriteResources *a2, u32 a3, u32 a4) { +static void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, WeatherSpriteResources *a2, u32 a3, u32 a4) { int resID[4]; for (int i = 0; i < 4; i++) { @@ -1108,10 +1198,10 @@ void ov01_021EC240(SpriteResourcesHeader *header, WeatherSystem *weatherSystem, CreateSpriteResourcesHeader(header, resID[0], resID[1], resID[2], resID[3], -1, -1, a3, a4, weatherSystem->weatherDraw.resMan[0], weatherSystem->weatherDraw.resMan[1], weatherSystem->weatherDraw.resMan[2], weatherSystem->weatherDraw.resMan[3], NULL, NULL); } -void WeatherObject_Delete(WeatherObject* a0) { +static void WeatherObject_Delete(WeatherObject *a0) { a0->prev->next = a0->next; a0->next->prev = a0->prev; - + Sprite_SetDrawFlag(a0->unk4, 0); ov01_021EC1E4(a0); @@ -1120,7 +1210,7 @@ void WeatherObject_Delete(WeatherObject* a0) { a0->unk4 = temp; } -void WeatherObject_DeleteAll(WeatherObject * a0) { +static void WeatherObject_DeleteAll(WeatherObject *a0) { WeatherObject *cur = a0->next; WeatherObject *next; @@ -1131,7 +1221,7 @@ void WeatherObject_DeleteAll(WeatherObject * a0) { } } -void ov01_021EC2E4(WeatherObject *a0, UnkLinkedListFunc func) { +static void ov01_021EC2E4(WeatherObject *a0, UnkLinkedListFunc func) { WeatherObject *cur = a0->next; WeatherObject *next = cur->next; @@ -1142,15 +1232,14 @@ void ov01_021EC2E4(WeatherObject *a0, UnkLinkedListFunc func) { } } -void ov01_021EC300(void *data) { - +static void ov01_021EC300(void *data) { } -VecFx32 ov01_021EC304(WeatherObject *a0) { +static VecFx32 ov01_021EC304(WeatherObject *a0) { return *Sprite_GetMatrixPtr(a0->unk4); } -void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0) { +static void ov01_021EC31C(fx32 *x, fx32 *z, WeatherSystem_Sub0_Sub8 *a0) { VecFx32 cameraTarget = NNS_G3dGlb.camTarget; fx32 xScale, zScale; fx32 dx, dz; @@ -1162,17 +1251,17 @@ void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0) { zDist = (cameraTarget.z - a0->cameraTarget.z); aspect = FX_Div(FX32_CONST(4), FX32_CONST(3)); - + sub_02020E10(Camera_GetPerspectiveAngle(a0->weatherSystem->fieldSystem->camera), Camera_GetDistance(a0->weatherSystem->fieldSystem->camera), aspect, &dx, &dz); - dx = FX_Div(dx, 256*FX32_ONE); + dx = FX_Div(dx, 256 * FX32_ONE); if (zDist <= 0) { dz = FX_Div(dz, 0xbe8d0); } else { dz = FX_Div(dz, 0xbe811); } - + v7 = FX32_ONE; if (xDist < 0) { v7 = -FX32_ONE; @@ -1201,7 +1290,7 @@ void ov01_021EC31C(fx32* x, fx32* z, WeatherSystem_Sub0_Sub8* a0) { *z = zScale; } -void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut) { +static void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut) { fx32 x, z; ov01_021EC4A8(a0, &x, &z); @@ -1219,7 +1308,7 @@ void ov01_021EC470(WeatherSystem_Sub0_Sub8 *a0, int *xOut, int *zOut) { } } -void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y) { +static void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y) { WeatherObject *cur; fx32 xScale, yScale; VecFx32 matrix; @@ -1245,28 +1334,28 @@ void ov01_021EC4A8(WeatherSystem_Sub0_Sub8 *a0, fx32 *x, fx32 *y) { } } -void ov01_021EC504(UnkStruct_021EC504* arg0, WeatherSystem_Sub0_Sub8 *arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkWeatherSystemSub0Sub8Func arg9) { +static void ov01_021EC504(UnkStruct_021EC504 *arg0, WeatherSystem_Sub0_Sub8 *arg1, s16 arg2, s16 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, UnkWeatherSystemSub0Sub8Func arg9) { arg0->unk0 = arg1; arg0->unk4 = arg2; arg0->unk6 = 0; arg0->unk8 = arg3; arg0->unkA = 0; - arg0->unkC = (s16) arg4; - arg0->unkE = (s16) arg5; - arg0->unk10 = (s16) arg6; - arg0->unk12 = (s16) arg7; + arg0->unkC = (s16)arg4; + arg0->unkE = (s16)arg5; + arg0->unk10 = (s16)arg6; + arg0->unk12 = (s16)arg7; arg0->unk14 = arg8; arg0->unk18 = arg9; } -void ov01_021EC52C(UnkStruct_021EC504* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4) { +static void ov01_021EC52C(UnkStruct_021EC504 *arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4) { arg0->unkC = arg1; arg0->unkE = arg2; arg0->unk10 = arg3; arg0->unk14 = arg4; } -s32 ov01_021EC538(UnkStruct_021EC504* arg0) { +static s32 ov01_021EC538(UnkStruct_021EC504 *arg0) { s16 temp_r0; s16 temp_r0_2; s16 temp_r0_4; @@ -1282,14 +1371,14 @@ s32 ov01_021EC538(UnkStruct_021EC504* arg0) { if (temp_r0 == 0) { var_r4 |= 1; } else { - if ((s32) temp_r0 <= 0) { + if ((s32)temp_r0 <= 0) { var_r2 = 1; } else { var_r2 = 0; } temp_r1 = arg0->unkE; temp_r0_2 = arg0->unk8; - if ((((s32) temp_r0_2 >= (s32) temp_r1) && (var_r2 == 0)) || (((s32) temp_r0_2 <= (s32) temp_r1) && (var_r2 == 1))) { + if ((((s32)temp_r0_2 >= (s32)temp_r1) && (var_r2 == 0)) || (((s32)temp_r0_2 <= (s32)temp_r1) && (var_r2 == 1))) { var_r4 |= 1; arg0->unk8 = temp_r1; } @@ -1305,30 +1394,30 @@ s32 ov01_021EC538(UnkStruct_021EC504* arg0) { } temp_r1_2 = arg0->unkC; temp_r0_4 = arg0->unk4; - if ((((s32) temp_r0_4 >= (s32) temp_r1_2) && (var_r2_2 == 0)) || (((s32) temp_r0_4 <= (s32) temp_r1_2) && (var_r2_2 == 1))) { + if ((((s32)temp_r0_4 >= (s32)temp_r1_2) && (var_r2_2 == 0)) || (((s32)temp_r0_4 <= (s32)temp_r1_2) && (var_r2_2 == 1))) { var_r4 |= 2; arg0->unk4 = temp_r1_2; } } - arg0->unk6 = (s16) (arg0->unk6 - 1); - if ((s32) arg0->unk6 <= 0) { + arg0->unk6 = (s16)(arg0->unk6 - 1); + if ((s32)arg0->unk6 <= 0) { arg0->unk18(arg0->unk0, arg0->unk4); - arg0->unk6 = (s16) arg0->unk8; + arg0->unk6 = (s16)arg0->unk8; if (!(1 & var_r4)) { - arg0->unk8 = (s16) (arg0->unk8 + arg0->unk10); + arg0->unk8 = (s16)(arg0->unk8 + arg0->unk10); } if (!(2 & var_r4)) { - arg0->unkA = (s16) (arg0->unkA + 1); - if ((s32) arg0->unkA >= (s32) arg0->unk12) { + arg0->unkA = (s16)(arg0->unkA + 1); + if ((s32)arg0->unkA >= (s32)arg0->unk12) { arg0->unkA = 0; - arg0->unk4 = (s16) (arg0->unk4 + arg0->unk14); + arg0->unk4 = (s16)(arg0->unk4 + arg0->unk14); } } } return var_r4; } -void ov01_021EC5FC(WeatherFogChange *arg0, UnkStruct_021EC774* arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7) { +static void ov01_021EC5FC(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb, s32 arg6, s32 arg7) { arg1->fog = fog; if (arg7 != 0) { if (arg7 == 1) { @@ -1341,7 +1430,7 @@ void ov01_021EC5FC(WeatherFogChange *arg0, UnkStruct_021EC774* arg1, FogData *fo } } -BOOL ov01_021EC650(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, s32 arg2) { +static BOOL ov01_021EC650(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, s32 arg2) { s32 var_r4; var_r4 = 1; @@ -1357,12 +1446,12 @@ BOOL ov01_021EC650(WeatherFogChange *arg0, UnkStruct_021EC774 *arg1, s32 arg2) { return var_r4; } -void ov01_021EC678(FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb) { +static void ov01_021EC678(FogData *fog, GXFogSlope fogSlope, s32 fogOffset, GXRgb rgb) { Fog_Set(fog, -1, TRUE, GX_FOGBLEND_COLOR_ALPHA, fogSlope, fogOffset); ov01_021EA89C(fog, -1, rgb, 0x1F); } -void ov01_021EC6A4(WeatherFogChange* fogChange, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5) { +static void ov01_021EC6A4(WeatherFogChange *fogChange, FogData *fog, s32 arg2, s32 arg3, GXRgb rgb, s32 arg5) { int slope = Fog_GetSlope(fog); int offset = Fog_GetOffset(fog); GXRgb rgb2 = ov01_021EA860(fog); @@ -1376,7 +1465,7 @@ void ov01_021EC6A4(WeatherFogChange* fogChange, FogData *fog, s32 arg2, s32 arg3 ov01_021EB830(&fogChange->unk54, slope, arg2, arg5); } -BOOL ov01_021EC728(WeatherFogChange *arg0) { +static BOOL ov01_021EC728(WeatherFogChange *arg0) { BOOL ret = ov01_021EB840(&arg0->unk4); ov01_021EB840(&arg0->unk18); ov01_021EB840(&arg0->unk2C); @@ -1387,14 +1476,14 @@ BOOL ov01_021EC728(WeatherFogChange *arg0) { return ret; } -void ov01_021EC774(UnkStruct_021EC774* a0) { +static void ov01_021EC774(UnkStruct_021EC774 *a0) { for (int i = 0; i < 32; i++) { a0->unk4[i] = 0; } ov01_021EA8C4(a0->fog, a0->unk4); } -void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2) { +static void ov01_021EC790(UnkStruct_021EC774 *arg0, s32 arg1, s32 arg2) { arg0->unk24 = 0x7F; arg0->unk28 = 0; arg0->unk2C = arg1; @@ -1405,7 +1494,7 @@ void ov01_021EC790(UnkStruct_021EC774* arg0, s32 arg1, s32 arg2) { arg0->unk2E = -1; } -s32 ov01_021EC7AC(UnkStruct_021EC774* arg0) { +static s32 ov01_021EC7AC(UnkStruct_021EC774 *arg0) { s32 temp_r4; temp_r4 = ov01_021EC7E8(arg0); @@ -1415,7 +1504,7 @@ s32 ov01_021EC7AC(UnkStruct_021EC774* arg0) { return temp_r4; } -void ov01_021EC7C8(UnkStruct_021EC774* arg0) { +static void ov01_021EC7C8(UnkStruct_021EC774 *arg0) { arg0->unk24 = 1; arg0->unk28 = 0; arg0->unk2C = 0; @@ -1424,7 +1513,7 @@ void ov01_021EC7C8(UnkStruct_021EC774* arg0) { ov01_021EA8C4(arg0->fog, arg0->unk4); } -s32 ov01_021EC7E8(UnkStruct_021EC774* arg0) { +static s32 ov01_021EC7E8(UnkStruct_021EC774 *arg0) { s32 temp_r0; s32 temp_r2; s32 var_r4; @@ -1432,12 +1521,12 @@ s32 ov01_021EC7E8(UnkStruct_021EC774* arg0) { var_r4 = 0; if (arg0->unk2E == 0) { var_r4 = 1; - } else if ((s32) arg0->unk24 <= 0) { + } else if ((s32)arg0->unk24 <= 0) { var_r4 = 1; } else { temp_r2 = arg0->unk28 + 1; arg0->unk28 = temp_r2; - if (temp_r2 >= (s32) arg0->unk2C) { + if (temp_r2 >= (s32)arg0->unk2C) { arg0->unk28 = 0; ov01_021EC828(arg0); temp_r0 = arg0->unk24 - 1; @@ -1450,26 +1539,26 @@ s32 ov01_021EC7E8(UnkStruct_021EC774* arg0) { return var_r4; } -void ov01_021EC828(UnkStruct_021EC774 *arg0) { +static void ov01_021EC828(UnkStruct_021EC774 *arg0) { int i; int v0; int v1; - + if (arg0->unk2E < 0) { v1 = 0x7F - arg0->unk24; } else { v1 = arg0->unk24; } - v0 = v1/4; + v0 = v1 / 4; for (i = 31; i > v0; i--) { - arg0->unk4[i] = (i - v0)*4; + arg0->unk4[i] = (i - v0) * 4; } } -void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int a2, int a3, int a4, UnkLinkedListFunc a5) { +static void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, int a2, int a3, int a4, UnkLinkedListFunc a5) { a1(a0, a2); - + int i, j; int v0 = 0; WeatherObject *cur = a0->linkedListDummy.next; @@ -1497,7 +1586,7 @@ void ov01_021EC85C(WeatherSystem_Sub0_Sub8 *a0, UnkWeatherSystemSub0Sub8Func a1, } } -WeatherObject *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 * a0) { +static WeatherObject *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 *a0) { for (int i = 0; i < 64; i++) { if (a0->linkedList[i].weatherSystem == NULL) { return &a0->linkedList[i]; @@ -1506,7 +1595,7 @@ WeatherObject *ov01_021EC8D8(WeatherSystem_Sub0_Sub8 * a0) { return NULL; } -void ov01_021EC8F8(SysTask *task, void* data) { +static void ov01_021EC8F8(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *arg1 = data; u16 temp_r2 = arg1->unkF62; switch (temp_r2) { @@ -1533,16 +1622,16 @@ void ov01_021EC8F8(SysTask *task, void* data) { } } -void ov01_021EC94C(SysTask *task, void *data) { +static void ov01_021EC94C(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *v0 = data; UnkStruct_021EC94C *v1 = v0->unkF58; - + switch (v0->unkF62) { case 0: ov01_021EC504(&v1->unk0, v0, 1, 8, 20, 1, -1, 1, 2, ov01_021ECBB4); ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x1000, 0x726F, 0x6b5a, 1, v0->unkF64); - + v1->data[0] = 0; v0->unkF6C = SysTask_CreateOnMainQueue(ov01_021EDA7C, v0, 100); v0->unkF68 = 30; @@ -1564,12 +1653,12 @@ void ov01_021EC94C(SysTask *task, void *data) { if (v0->unkF64) { v1->unk1C.fog = v0->weatherSystem->fieldSystem->fog; - ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x726f, GX_RGB(26,26,26)); + ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x726f, GX_RGB(26, 26, 26)); ov01_021EC7C8(&v1->unk1C); } - + ov01_021EC85C(v0, ov01_021ECBB4, 20, 10, 1, ov01_021ECC70); - + v0->unkF6C = SysTask_CreateOnMainQueue(ov01_021EDA7C, v0, 100); v0->unkF68 = 30; v0->unkF62 = 3; @@ -1582,8 +1671,7 @@ void ov01_021EC94C(SysTask *task, void *data) { if (v0->unkF66 == 5) { ov01_021EC52C(&v1->unk0, 0, 8, 1, -2); - - + if (v0->unkF64) { ov01_021EC790(&v1->unk1C, 1, 0); } @@ -1609,7 +1697,6 @@ void ov01_021EC94C(SysTask *task, void *data) { v0->unkF62 = 5; } } - } break; case 5: @@ -1627,13 +1714,13 @@ void ov01_021EC94C(SysTask *task, void *data) { } } -void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1) { +static void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1) { for (int i = 0; i < arg1; i++) { WeatherObject *v0 = ov01_021EC1F4(a0, 32); if (v0 == NULL) { break; } - + u32 *data = v0->unk8; u32 rand = MTRandom(); @@ -1656,7 +1743,7 @@ void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1) { data[1] = 1 + (rand % 3); VecFx32 vec; - + vec.x = (15 * frame + (rand % 270)) << FX32_SHIFT; vec.y = 0xFFFA0 << FX32_SHIFT; vec.z = 0; @@ -1664,7 +1751,7 @@ void ov01_021ECBB4(WeatherSystem_Sub0_Sub8 *a0, int arg1) { } } -void ov01_021ECC70(WeatherObject *a0) { +static void ov01_021ECC70(WeatherObject *a0) { int i; s32 *data = a0->unk8; VecFx32 vec; @@ -1698,18 +1785,17 @@ void ov01_021ECC70(WeatherObject *a0) { } } -void ov01_021ECD08(SysTask *task, void* data) { +static void ov01_021ECD08(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *v0 = data; UnkStruct_021EC94C *v1 = v0->unkF58; - + switch (v0->unkF62) { case 0: ov01_021EC504(&v1->unk0, v0, 1, 30, 6, 3, -5, 2, 1, ov01_021ECF4C); - - ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x1000, 0x726F, GX_RGB(24,24,24), 2, v0->unkF64); - + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x1000, 0x726F, GX_RGB(24, 24, 24), 2, v0->unkF64); + v1->data[0] = 8; v1->data[1] = 0; v0->unkF62 = 1; @@ -1730,14 +1816,14 @@ void ov01_021ECD08(SysTask *task, void* data) { if (v0->unkF64) { v1->unk1C.fog = v0->weatherSystem->fieldSystem->fog; - ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x726f, GX_RGB(24,24,24)); + ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x726f, GX_RGB(24, 24, 24)); ov01_021EC7C8(&v1->unk1C); } v1->data[1] = 0; - + ov01_021EC85C(v0, ov01_021ECF4C, 20, 2, 3, ov01_021ED070); - + v0->unkF62 = 3; break; case 3: @@ -1748,8 +1834,7 @@ void ov01_021ECD08(SysTask *task, void* data) { if (v0->unkF66 == 5) { ov01_021EC52C(&v1->unk0, 0, 30, 5, -3); - - + if (v0->unkF64) { ov01_021EC790(&v1->unk1C, 1, 0); } @@ -1774,7 +1859,6 @@ void ov01_021ECD08(SysTask *task, void* data) { v0->unkF62 = 5; } } - } break; case 5: @@ -1792,16 +1876,16 @@ void ov01_021ECD08(SysTask *task, void* data) { } } -static const ov01_0220674C[] = {2, 2, 2, 2}; -static const ov01_0220673C[] = {16, 32, 16, 10}; +static const ov01_0220674C[] = { 2, 2, 2, 2 }; +static const ov01_0220673C[] = { 16, 32, 16, 10 }; -void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1) { +static void ov01_021ECF4C(WeatherSystem_Sub0_Sub8 *a0, int a1) { int table0[4]; table0 = ov01_0220673C; int table1[4]; table1 = ov01_0220674C; UnkStruct_021EC94C *v0 = a0->unkF58; - + for (int i = 0; i < a1; i++) { WeatherObject *v1 = ov01_021EC1F4(a0, 32); if (v1 == NULL) { @@ -1834,12 +1918,12 @@ void ov01_021ECF4C(WeatherSystem_Sub0_Sub8* a0, int a1) { vec.z = 0; vec.x <<= FX32_SHIFT; vec.y <<= FX32_SHIFT; - + WeatherDraw_SetSpriteMatrix(v1->unk4, &vec); } } -void ov01_021ED070(WeatherObject* a0) { +static void ov01_021ED070(WeatherObject *a0) { s32 *data = a0->unk8; VecFx32 vec = ov01_021EC304(a0); @@ -1859,7 +1943,7 @@ void ov01_021ED070(WeatherObject* a0) { data[2]--; } } - + WeatherDraw_SetSpriteMatrix(a0->unk4, &vec); break; case 1: @@ -1868,18 +1952,17 @@ void ov01_021ED070(WeatherObject* a0) { } } -void ov01_021ED0F0(SysTask *task, void* data) { +static void ov01_021ED0F0(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *v0 = data; UnkStruct_021EC94C *v1 = v0->unkF58; - + switch (v0->unkF62) { case 0: ov01_021EC504(&v1->unk0, v0, 2, 16, 20, 2, -2, 4, 2, ov01_021ED31C); - - ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x1000, 0x716F, GX_RGB(26,26,26), 1, v0->unkF64); - + ov01_021EC5FC(&v1->unk50, &v1->unk1C, v0->weatherSystem->fieldSystem->fog, GX_FOGSLOPE_0x1000, 0x716F, GX_RGB(26, 26, 26), 1, v0->unkF64); + v1->data[0] = 0; v0->unkF62 = 1; break; @@ -1899,12 +1982,12 @@ void ov01_021ED0F0(SysTask *task, void* data) { if (v0->unkF64) { v1->unk1C.fog = v0->weatherSystem->fieldSystem->fog; - ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x716f, GX_RGB(26,26,26)); + ov01_021EC678(v1->unk1C.fog, GX_FOGSLOPE_0x1000, 0x716f, GX_RGB(26, 26, 26)); ov01_021EC7C8(&v1->unk1C); } - + ov01_021EC85C(v0, ov01_021ED31C, 20, 10, 1, ov01_021ED44C); - + v0->unkF62 = 3; break; case 3: @@ -1915,7 +1998,7 @@ void ov01_021ED0F0(SysTask *task, void* data) { if (v0->unkF66 == 5) { ov01_021EC52C(&v1->unk0, 0, 16, 6, -10); - + if (v0->unkF64) { ov01_021EC790(&v1->unk1C, 1, 0); } @@ -1929,13 +2012,12 @@ void ov01_021ED0F0(SysTask *task, void* data) { v1->data[0]--; } else { int vUnk = ov01_021EC650(&v1->unk50, &v1->unk1C, v0->unkF64); - + if (vUnk == 1 && ret == 3) { if (v0->linkedListDummy.next == &v0->linkedListDummy) { v0->unkF62 = 5; } } - } break; case 5: @@ -1953,14 +2035,14 @@ void ov01_021ED0F0(SysTask *task, void* data) { } } -void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { +static void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { VecFx32 vec; for (int i = 0; i < a1; i++) { WeatherObject *v0 = ov01_021EC1F4(a0, 32); if (v0 == NULL) { break; } - + u32 *data = v0->unk8; data[0] = 0; @@ -1973,7 +2055,7 @@ void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { } else { data[2] = -1; } - + data[3] = 1; data[4] = 3 + (MTRandom() % 6); data[5] = 4 + (MTRandom() % 5); @@ -1990,8 +2072,8 @@ void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { vec.x >>= FX32_SHIFT; vec.y >>= FX32_SHIFT; - int v1 = 50 - vec.x/3; - int v2 = 206 - vec.x/3; + int v1 = 50 - vec.x / 3; + int v2 = 206 - vec.x / 3; int v3; if (v2 < 0) { v2 *= -1; @@ -2009,7 +2091,7 @@ void ov01_021ED31C(WeatherSystem_Sub0_Sub8 *a0, int a1) { } } -void ov01_021ED44C(WeatherObject *a0) { +static void ov01_021ED44C(WeatherObject *a0) { s32 *data = a0->unk8; ov01_021EC304(a0); if (++data[0] >= data[1]) { @@ -2017,7 +2099,7 @@ void ov01_021ED44C(WeatherObject *a0) { } } -void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, GXFogSlope fogSlope, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6) { +static void ov01_021ED474(WeatherSystem_Sub0_Sub8 *a0, UnkStruct_021ED474 *a1, GXFogSlope fogSlope, s32 arg3, GXRgb arg4, s32 arg5, s32 arg6) { switch (a0->unkF62) { case 0: ov01_021EC5FC(&a1->unk50, &a1->unk1C, a0->weatherSystem->fieldSystem->fog, fogSlope, arg3, arg4, arg5, a0->unkF64); @@ -2060,13 +2142,13 @@ void ov01_021ED474(WeatherSystem_Sub0_Sub8* a0, UnkStruct_021ED474* a1, GXFogSlo case 5: if (a0->unkF64 != 0) { Fog_Set(a1->unk1C.fog, 1, FALSE, GX_FOGBLEND_COLOR_ALPHA, GX_FOGSLOPE_0x8000, 0); - } + } ov01_021EBCA4(a0->unk4); break; } } -void ov01_021ED584(SysTask *task, void* data) { +static void ov01_021ED584(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *v0 = data; UnkStruct_021ED584 *v1 = v0->unkF58; @@ -2128,7 +2210,7 @@ void ov01_021ED584(SysTask *task, void* data) { } } -void ov01_021ED710(SysTask *task, void *data) { +static void ov01_021ED710(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *v0 = data; WeatherSystem *weatherSystem = v0->weatherSystem; FieldSystem *fieldSystem = weatherSystem->fieldSystem; @@ -2191,7 +2273,7 @@ void ov01_021ED710(SysTask *task, void *data) { break; case 3: v1->unk630++; - float v3 = 1.0 + (v1->unk630*3.0) / 24.0; + float v3 = 1.0 + (v1->unk630 * 3.0) / 24.0; ov01_02203F2C(v1->unk62C, v3); if (v3 >= 4.0) { v0->unkF62 = 5; @@ -2205,7 +2287,7 @@ void ov01_021ED710(SysTask *task, void *data) { } } -void ov01_021ED924(SysTask *task, void *data) { +static void ov01_021ED924(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *v0 = data; WeatherSystem *weatherSystem = v0->weatherSystem; FieldSystem *fieldSystem = weatherSystem->fieldSystem; @@ -2257,12 +2339,12 @@ void ov01_021ED924(SysTask *task, void *data) { } } -void ov01_021EDA50(SysTask *task, void *data) { +static void ov01_021EDA50(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *v0 = data; ov01_021ED474(v0, v0->unkF58, GX_FOGSLOPE_0x4000, 0x4B6F, 0x421, 0, 0); } -void ov01_021EDA7C(SysTask *task, void* data) { +static void ov01_021EDA7C(SysTask *task, void *data) { WeatherSystem_Sub0_Sub8 *v0 = data; if (--v0->unkF68 <= 0) { ov01_021EDAB4(v0, SEQ_SE_DP_T_AME); @@ -2271,7 +2353,7 @@ void ov01_021EDA7C(SysTask *task, void* data) { } } -void ov01_021EDAB4(WeatherSystem_Sub0_Sub8* a0, u32 sndSeq) { +static void ov01_021EDAB4(WeatherSystem_Sub0_Sub8 *a0, u32 sndSeq) { GF_ASSERT(a0->unkF5C == 0); a0->unkF5C = 1; @@ -2279,7 +2361,7 @@ void ov01_021EDAB4(WeatherSystem_Sub0_Sub8* a0, u32 sndSeq) { PlaySE(sndSeq); } -void ov01_021EDAE0(WeatherSystem_Sub0_Sub8* arg0) { +static void ov01_021EDAE0(WeatherSystem_Sub0_Sub8 *arg0) { StopSE(arg0->sndSeq, 0); arg0->unkF5C = 0; } diff --git a/src/field_take_photo.c b/src/field_take_photo.c index 4d02388a1a..743fa5b002 100644 --- a/src/field_take_photo.c +++ b/src/field_take_photo.c @@ -4,9 +4,8 @@ #include "constants/scrcmd.h" -#include "graphic/camera_viewfinder.naix" - #include "field/weather_manager.h" +#include "graphic/camera_viewfinder.naix" #include "field_warp_tasks.h" #include "follow_mon.h" diff --git a/src/get_egg.c b/src/get_egg.c index 40201bc308..3127e0e101 100644 --- a/src/get_egg.c +++ b/src/get_egg.c @@ -304,7 +304,7 @@ static void InheritIVs(Pokemon *egg, Daycare *dayCare) { for (i = STAT_HP; i < NUM_STATS; i++) { statList[i] = i; } - + if (Daycare_TryGetForcedInheritedIV(dayCare, &powerItemStat, &daycareSlot)) { statsToInherit[0] = powerItemStat; startNum = 1; diff --git a/src/voltorb_flip/voltorb_flip_input.c b/src/voltorb_flip/voltorb_flip_input.c index 9b92b08f69..bfc59672f3 100644 --- a/src/voltorb_flip/voltorb_flip_input.c +++ b/src/voltorb_flip/voltorb_flip_input.c @@ -390,7 +390,7 @@ static void VoltorbFlipInputHandler_HandleChangeFocus(VoltorbFlipInputHandler *i static void VoltorbFlipInputCB_OnButtonPress(void *data, int nextInput, int prevInput_unused) { VoltorbFlipInputHandler *inputHandler = data; - GridInputHandler_SetNextInput(inputHandler->gridInputHandler, (u8) nextInput); + GridInputHandler_SetNextInput(inputHandler->gridInputHandler, (u8)nextInput); VoltorbFlipInputHandler_SetFocus(inputHandler, nextInput); PlaySE(SEQ_SE_DP_SELECT); } @@ -405,11 +405,11 @@ static void VoltorbFlipInputCB_OnKeyMove(void *data, int nextInput, int prevInpu if (nextInput == VOLTORB_FLIP_COL4_ROWLAST) { // wrap around left nextInput = inputHandler->selectedRow * 5 + 4; GF_ASSERT(nextInput < VOLTORB_FLIP_INPUT_GRID_NUM); - GridInputHandler_SetNextInput(inputHandler->gridInputHandler, (u8) nextInput); + GridInputHandler_SetNextInput(inputHandler->gridInputHandler, (u8)nextInput); } else if (nextInput == VOLTORB_FLIP_COL0_ROWLAST) { // wrap around right nextInput = inputHandler->selectedRow * 5; GF_ASSERT(nextInput < VOLTORB_FLIP_INPUT_GRID_NUM); - GridInputHandler_SetNextInput(inputHandler->gridInputHandler, (u8) nextInput); + GridInputHandler_SetNextInput(inputHandler->gridInputHandler, (u8)nextInput); } if (nextInput != VOLTORB_FLIP_INPUT_MEMO && nextInput != VOLTORB_FLIP_INPUT_QUIT) {