diff options
author | YamaArashi <shadow962@live.com> | 2017-01-02 23:23:23 -0800 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2017-01-02 23:23:23 -0800 |
commit | 6f64e68814206dc6082fd8dc3fceed79e5e63928 (patch) | |
tree | 287bfa6541b746758d61d6049abf4874e2a6451c | |
parent | bb2c7f3e07fe9fe9ae72b361b93f106af1259124 (diff) |
decompile coord_event_weather.c
-rw-r--r-- | asm/coord_event_weather.s | 158 | ||||
-rw-r--r-- | data/data_83760F0.s | 16 | ||||
-rw-r--r-- | include/asm.inc.h | 3 | ||||
-rw-r--r-- | ld_script.txt | 3 | ||||
-rw-r--r-- | src/coord_event_weather.c | 117 |
5 files changed, 122 insertions, 175 deletions
diff --git a/asm/coord_event_weather.s b/asm/coord_event_weather.s deleted file mode 100644 index b43311848..000000000 --- a/asm/coord_event_weather.s +++ /dev/null @@ -1,158 +0,0 @@ - .include "constants/gba_constants.inc" - .include "constants/species_constants.inc" - .include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start CoordEventWeather_Indoor -CoordEventWeather_Indoor: @ 806936C - push {lr} - movs r0, 0x1 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Indoor - - thumb_func_start CoordEventWeather_Sunny -CoordEventWeather_Sunny: @ 8069378 - push {lr} - movs r0, 0x2 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Sunny - - thumb_func_start CoordEventWeather_Rain -CoordEventWeather_Rain: @ 8069384 - push {lr} - movs r0, 0x3 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Rain - - thumb_func_start CoordEventWeather_Snowflakes -CoordEventWeather_Snowflakes: @ 8069390 - push {lr} - movs r0, 0x4 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Snowflakes - - thumb_func_start CoordEventWeather_Thunderstorm -CoordEventWeather_Thunderstorm: @ 806939C - push {lr} - movs r0, 0x5 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Thunderstorm - - thumb_func_start CoordEventWeather_Fog -CoordEventWeather_Fog: @ 80693A8 - push {lr} - movs r0, 0x6 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Fog - - thumb_func_start CoordEventWeather_DiagonalFog -CoordEventWeather_DiagonalFog: @ 80693B4 - push {lr} - movs r0, 0x9 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_DiagonalFog - - thumb_func_start CoordEventWeather_Snow -CoordEventWeather_Snow: @ 80693C0 - push {lr} - movs r0, 0x7 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Snow - - thumb_func_start CoordEventWeather_Sandstorm -CoordEventWeather_Sandstorm: @ 80693CC - push {lr} - movs r0, 0x8 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Sandstorm - - thumb_func_start CoordEventWeather_Cloudy -CoordEventWeather_Cloudy: @ 80693D8 - push {lr} - movs r0, 0xB - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Cloudy - - thumb_func_start CoordEventWeather_Drought -CoordEventWeather_Drought: @ 80693E4 - push {lr} - movs r0, 0xC - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_Drought - - thumb_func_start CoordEventWeather_UnderwaterFog -CoordEventWeather_UnderwaterFog: @ 80693F0 - push {lr} - movs r0, 0x14 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_UnderwaterFog - - thumb_func_start CoordEventWeather_UnderwaterBubbles -CoordEventWeather_UnderwaterBubbles: @ 80693FC - push {lr} - movs r0, 0x15 - bl SetWeather - pop {r0} - bx r0 - thumb_func_end CoordEventWeather_UnderwaterBubbles - - thumb_func_start DoCoordEventWeather -DoCoordEventWeather: @ 8069408 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - movs r2, 0 - ldr r3, _08069428 @ =gCoordEventWeatherFuncs -_08069412: - lsls r1, r2, 3 - adds r0, r1, r3 - ldrb r0, [r0] - cmp r0, r4 - bne _0806942C - adds r0, r3, 0x4 - adds r0, r1, r0 - ldr r0, [r0] - bl _call_via_r0 - b _08069436 - .align 2, 0 -_08069428: .4byte gCoordEventWeatherFuncs -_0806942C: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xC - bls _08069412 -_08069436: - pop {r4} - pop {r0} - bx r0 - thumb_func_end DoCoordEventWeather - - .align 2, 0 @ Don't pad with nop. diff --git a/data/data_83760F0.s b/data/data_83760F0.s index cea6c4c2e..aaac72802 100644 --- a/data/data_83760F0.s +++ b/data/data_83760F0.s @@ -4,22 +4,6 @@ .section .rodata .align 2 -gCoordEventWeatherFuncs:: @ 83762FC - .4byte 0x1, CoordEventWeather_Indoor - .4byte 0x2, CoordEventWeather_Sunny - .4byte 0x3, CoordEventWeather_Rain - .4byte 0x4, CoordEventWeather_Snowflakes - .4byte 0x5, CoordEventWeather_Thunderstorm - .4byte 0x6, CoordEventWeather_Fog - .4byte 0x7, CoordEventWeather_DiagonalFog - .4byte 0x8, CoordEventWeather_Snow - .4byte 0x9, CoordEventWeather_Sandstorm - .4byte 0xa, CoordEventWeather_Cloudy - .4byte 0xb, CoordEventWeather_Drought - .4byte 0x14, CoordEventWeather_UnderwaterFog - .4byte 0x15, CoordEventWeather_UnderwaterBubbles - - .align 2 gUnknown_08376364:: @ 8376364 .4byte DummyPerStepCallback .4byte PerStepCallback_8069F64 diff --git a/include/asm.inc.h b/include/asm.inc.h index 86d16066b..9cf316079 100644 --- a/include/asm.inc.h +++ b/include/asm.inc.h @@ -170,6 +170,9 @@ u8 battle_side_get_owner(u8); u8 battle_get_per_side_status(u8); u8 battle_get_side_with_given_state(u8); +// asm/weather.o +void SetWeather(u32); + // asm/rom_8080874.o void pal_fill_black(); void sub_8080990(void); diff --git a/ld_script.txt b/ld_script.txt index f475b02db..6946b9971 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -86,7 +86,7 @@ SECTIONS { src/scrcmd.o(.text); asm/field_control_avatar.o(.text); src/event_data.o(.text); - asm/coord_event_weather.o(.text); + src/coord_event_weather.o(.text); asm/field_tasks.o(.text); asm/clock.o(.text); asm/reset_rtc_screen.o(.text); @@ -311,6 +311,7 @@ SECTIONS { data/text_window.o(.rodata); data/script.o(.rodata); data/scrcmd.o(.rodata); + src/coord_event_weather.o(.rodata); data/data_83760F0.o(.rodata); src/m4a_tables.o(.rodata); data/sound_data.o(.rodata); diff --git a/src/coord_event_weather.c b/src/coord_event_weather.c new file mode 100644 index 000000000..f033e5391 --- /dev/null +++ b/src/coord_event_weather.c @@ -0,0 +1,117 @@ +#include "global.h" +#include "asm.h" + +struct CoordEventWeather +{ + u8 weather; + void (*func)(void); +}; + +static void CoordEventWeather_Indoor(void); +static void CoordEventWeather_Sunny(void); +static void CoordEventWeather_Rain(void); +static void CoordEventWeather_Snowflakes(void); +static void CoordEventWeather_Thunderstorm(void); +static void CoordEventWeather_Fog(void); +static void CoordEventWeather_DiagonalFog(void); +static void CoordEventWeather_Snow(void); +static void CoordEventWeather_Sandstorm(void); +static void CoordEventWeather_Cloudy(void); +static void CoordEventWeather_Drought(void); +static void CoordEventWeather_UnderwaterFog(void); +static void CoordEventWeather_UnderwaterBubbles(void); + +static const struct CoordEventWeather sCoordEventWeatherFuncs[] = +{ + { 0x1, CoordEventWeather_Indoor }, + { 0x2, CoordEventWeather_Sunny }, + { 0x3, CoordEventWeather_Rain }, + { 0x4, CoordEventWeather_Snowflakes }, + { 0x5, CoordEventWeather_Thunderstorm }, + { 0x6, CoordEventWeather_Fog }, + { 0x7, CoordEventWeather_DiagonalFog }, + { 0x8, CoordEventWeather_Snow }, + { 0x9, CoordEventWeather_Sandstorm }, + { 0xa, CoordEventWeather_Cloudy }, + { 0xb, CoordEventWeather_Drought }, + { 0x14, CoordEventWeather_UnderwaterFog }, + { 0x15, CoordEventWeather_UnderwaterBubbles }, +}; + +static void CoordEventWeather_Indoor(void) +{ + SetWeather(1); +} + +static void CoordEventWeather_Sunny(void) +{ + SetWeather(2); +} + +static void CoordEventWeather_Rain(void) +{ + SetWeather(3); +} + +static void CoordEventWeather_Snowflakes(void) +{ + SetWeather(4); +} + +static void CoordEventWeather_Thunderstorm(void) +{ + SetWeather(5); +} + +static void CoordEventWeather_Fog(void) +{ + SetWeather(6); +} + +static void CoordEventWeather_DiagonalFog(void) +{ + SetWeather(9); +} + +static void CoordEventWeather_Snow(void) +{ + SetWeather(7); +} + +static void CoordEventWeather_Sandstorm(void) +{ + SetWeather(8); +} + +static void CoordEventWeather_Cloudy(void) +{ + SetWeather(11); +} + +static void CoordEventWeather_Drought(void) +{ + SetWeather(12); +} + +static void CoordEventWeather_UnderwaterFog(void) +{ + SetWeather(20); +} + +static void CoordEventWeather_UnderwaterBubbles(void) +{ + SetWeather(21); +} + +void DoCoordEventWeather(u8 n) +{ + u8 i; + for (i = 0; i < ARRAY_COUNT(sCoordEventWeatherFuncs); i++) + { + if (sCoordEventWeatherFuncs[i].weather == n) + { + sCoordEventWeatherFuncs[i].func(); + return; + } + } +} |