decompile_coord_event_weather

This commit is contained in:
DizzyEggg 2018-01-29 16:46:56 +01:00
parent 10037ac0e1
commit e6fb626c1f
9 changed files with 181 additions and 193 deletions

View File

@ -1,156 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_809D7BC
sub_809D7BC: @ 809D7BC
push {lr}
movs r0, 0x1
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D7BC
thumb_func_start sub_809D7C8
sub_809D7C8: @ 809D7C8
push {lr}
movs r0, 0x2
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D7C8
thumb_func_start sub_809D7D4
sub_809D7D4: @ 809D7D4
push {lr}
movs r0, 0x3
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D7D4
thumb_func_start sub_809D7E0
sub_809D7E0: @ 809D7E0
push {lr}
movs r0, 0x4
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D7E0
thumb_func_start sub_809D7EC
sub_809D7EC: @ 809D7EC
push {lr}
movs r0, 0x5
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D7EC
thumb_func_start sub_809D7F8
sub_809D7F8: @ 809D7F8
push {lr}
movs r0, 0x6
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D7F8
thumb_func_start sub_809D804
sub_809D804: @ 809D804
push {lr}
movs r0, 0x9
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D804
thumb_func_start sub_809D810
sub_809D810: @ 809D810
push {lr}
movs r0, 0x7
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D810
thumb_func_start sub_809D81C
sub_809D81C: @ 809D81C
push {lr}
movs r0, 0x8
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D81C
thumb_func_start sub_809D828
sub_809D828: @ 809D828
push {lr}
movs r0, 0xB
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D828
thumb_func_start sub_809D834
sub_809D834: @ 809D834
push {lr}
movs r0, 0xC
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D834
thumb_func_start sub_809D840
sub_809D840: @ 809D840
push {lr}
movs r0, 0x14
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D840
thumb_func_start sub_809D84C
sub_809D84C: @ 809D84C
push {lr}
movs r0, 0x15
bl sub_80AEDF0
pop {r0}
bx r0
thumb_func_end sub_809D84C
thumb_func_start trigger_activate_weather
trigger_activate_weather: @ 809D858
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
movs r2, 0
ldr r3, =gUnknown_085102E0
_0809D862:
lsls r1, r2, 3
adds r0, r1, r3
ldrb r0, [r0]
cmp r0, r4
bne _0809D87C
adds r0, r3, 0x4
adds r0, r1, r0
ldr r0, [r0]
bl _call_via_r0
b _0809D886
.pool
_0809D87C:
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0xC
bls _0809D862
_0809D886:
pop {r4}
pop {r0}
bx r0
thumb_func_end trigger_activate_weather
.align 2, 0 @ Don't pad with nop.

View File

@ -2155,7 +2155,7 @@ trigger_activate: @ 809D04C
cmp r1, 0
bne _0809D062
ldrb r0, [r4, 0x6]
bl trigger_activate_weather
bl DoCoordEventWeather
b _0809D082
_0809D062:
ldrh r0, [r4, 0x6]

View File

@ -2339,43 +2339,43 @@ _080AC290:
.4byte _080AC300
_080AC2B8:
movs r0, 0x1
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC2C0:
movs r0, 0x2
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC2C8:
movs r0, 0x3
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC2D0:
movs r0, 0x4
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC2D8:
movs r0, 0x5
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC2E0:
movs r0, 0x6
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC2E8:
movs r0, 0x9
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC2F0:
movs r0, 0x7
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC2F8:
movs r0, 0x8
bl sub_80AEDF0
bl SetWeather
b _080AC306
_080AC300:
movs r0, 0xB
bl sub_80AEDF0
bl SetWeather
_080AC306:
pop {r0}
bx r0
@ -7561,8 +7561,8 @@ sub_80AEDBC: @ 80AEDBC
.pool
thumb_func_end sub_80AEDBC
thumb_func_start sub_80AEDF0
sub_80AEDF0: @ 80AEDF0
thumb_func_start SetWeather
SetWeather: @ 80AEDF0
push {lr}
bl SetSav1Weather
bl GetSav1Weather
@ -7571,7 +7571,7 @@ sub_80AEDF0: @ 80AEDF0
bl weather_set
pop {r0}
bx r0
thumb_func_end sub_80AEDF0
thumb_func_end SetWeather
thumb_func_start sub_80AEE08
sub_80AEE08: @ 80AEE08

View File

@ -1,21 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2, 0
gUnknown_085102E0:: @ 85102E0
.4byte 0x00000001, sub_809D7BC
.4byte 0x00000002, sub_809D7C8
.4byte 0x00000003, sub_809D7D4
.4byte 0x00000004, sub_809D7E0
.4byte 0x00000005, sub_809D7EC
.4byte 0x00000006, sub_809D7F8
.4byte 0x00000007, sub_809D804
.4byte 0x00000008, sub_809D810
.4byte 0x00000009, sub_809D81C
.4byte 0x0000000a, sub_809D828
.4byte 0x0000000b, sub_809D834
.4byte 0x00000014, sub_809D840
.4byte 0x00000015, sub_809D84C

View File

@ -0,0 +1,39 @@
#ifndef GUARD_CONSTANTS_WEATHER_H
#define GUARD_CONSTANTS_WEATHER_H
#define WEATHER_NONE 0
#define WEATHER_CLOUDS 1
#define WEATHER_SUNNY 2
#define WEATHER_RAIN_LIGHT 3
#define WEATHER_SNOW 4
#define WEATHER_RAIN_MED 5
#define WEATHER_FOG_1 6
#define WEATHER_ASH 7
#define WEATHER_SANDSTORM 8
#define WEATHER_FOG_2 9
#define WEATHER_FOG_3 10
#define WEATHER_SHADE 11
#define WEATHER_DROUGHT 12
#define WEATHER_RAIN_HEAVY 13
#define WEATHER_BUBBLES 14
#define WEATHER_ROUTE119_CYCLE 20
#define WEATHER_ROUTE123_CYCLE 21
// These are used in maps' coord_weather_event entries.
// They are not a one-to-one mapping with the engine's
// internal weather constants above.
#define COORD_EVENT_WEATHER_CLOUDS 1
#define COORD_EVENT_WEATHER_SUNNY 2
#define COORD_EVENT_WEATHER_RAIN_LIGHT 3
#define COORD_EVENT_WEATHER_SNOW 4
#define COORD_EVENT_WEATHER_RAIN_MED 5
#define COORD_EVENT_WEATHER_FOG_1 6
#define COORD_EVENT_WEATHER_FOG_2 7
#define COORD_EVENT_WEATHER_ASH 8
#define COORD_EVENT_WEATHER_SANDSTORM 9
#define COORD_EVENT_WEATHER_SHADE 10
#define COORD_EVENT_WEATHER_DROUGHT 11
#define COORD_EVENT_WEATHER_ROUTE119_CYCLE 20
#define COORD_EVENT_WEATHER_ROUTE123_CYCLE 21
#endif // GUARD_CONSTANTS_WEATHER_H

View File

@ -0,0 +1,6 @@
#ifndef GUARD_COORD_EVENT_WEATHER_H
#define GUARD_COORD_EVENT_WEATHER_H
void DoCoordEventWeather(u8);
#endif // GUARD_COORD_EVENT_WEATHER_H

View File

@ -6,6 +6,7 @@ void fade_screen(u8, s8);
void SetSav1Weather(u32);
u8 GetSav1Weather(void);
void sub_80AEDBC(void);
void SetWeather(u32);
void DoCurrentWeather(void);

View File

@ -105,7 +105,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);
src/clock.o(.text);
asm/reset_rtc_screen.o(.text);
@ -407,7 +407,7 @@ SECTIONS {
data/map_obj_8097404.o(.rodata);
src/text_window.o(.rodata);
src/scrcmd.o(.rodata);
data/coord_event_weather.o(.rodata);
src/coord_event_weather.o(.rodata);
data/field_tasks.o(.rodata);
data/reset_rtc_screen.o(.rodata);
src/start_menu.o(.rodata);

119
src/coord_event_weather.c Normal file
View File

@ -0,0 +1,119 @@
#include "global.h"
#include "constants/weather.h"
#include "coord_event_weather.h"
#include "field_weather.h"
struct CoordEventWeather
{
u8 coordEventWeather;
void (*func)(void);
};
static void CoordEventWeather_Clouds(void);
static void CoordEventWeather_Sunny(void);
static void CoordEventWeather_LightRain(void);
static void CoordEventWeather_Snow(void);
static void CoordEventWeather_Thunderstorm(void);
static void CoordEventWeather_Fog(void);
static void CoordEventWeather_DiagonalFog(void);
static void CoordEventWeather_Ash(void);
static void CoordEventWeather_Sandstorm(void);
static void CoordEventWeather_Dark(void);
static void CoordEventWeather_Drought(void);
static void CoordEventWeather_Route119Cycle(void);
static void CoordEventWeather_Route123Cycle(void);
static const struct CoordEventWeather sCoordEventWeatherFuncs[] =
{
{ COORD_EVENT_WEATHER_CLOUDS, CoordEventWeather_Clouds },
{ COORD_EVENT_WEATHER_SUNNY, CoordEventWeather_Sunny },
{ COORD_EVENT_WEATHER_RAIN_LIGHT, CoordEventWeather_LightRain },
{ COORD_EVENT_WEATHER_SNOW, CoordEventWeather_Snow },
{ COORD_EVENT_WEATHER_RAIN_MED, CoordEventWeather_Thunderstorm },
{ COORD_EVENT_WEATHER_FOG_1, CoordEventWeather_Fog },
{ COORD_EVENT_WEATHER_FOG_2, CoordEventWeather_DiagonalFog },
{ COORD_EVENT_WEATHER_ASH, CoordEventWeather_Ash },
{ COORD_EVENT_WEATHER_SANDSTORM, CoordEventWeather_Sandstorm },
{ COORD_EVENT_WEATHER_SHADE, CoordEventWeather_Dark },
{ COORD_EVENT_WEATHER_DROUGHT, CoordEventWeather_Drought },
{ COORD_EVENT_WEATHER_ROUTE119_CYCLE, CoordEventWeather_Route119Cycle },
{ COORD_EVENT_WEATHER_ROUTE123_CYCLE, CoordEventWeather_Route123Cycle },
};
static void CoordEventWeather_Clouds(void)
{
SetWeather(WEATHER_CLOUDS);
}
static void CoordEventWeather_Sunny(void)
{
SetWeather(WEATHER_SUNNY);
}
static void CoordEventWeather_LightRain(void)
{
SetWeather(WEATHER_RAIN_LIGHT);
}
static void CoordEventWeather_Snow(void)
{
SetWeather(WEATHER_SNOW);
}
static void CoordEventWeather_Thunderstorm(void)
{
SetWeather(WEATHER_RAIN_MED);
}
static void CoordEventWeather_Fog(void)
{
SetWeather(WEATHER_FOG_1);
}
static void CoordEventWeather_DiagonalFog(void)
{
SetWeather(WEATHER_FOG_2);
}
static void CoordEventWeather_Ash(void)
{
SetWeather(WEATHER_ASH);
}
static void CoordEventWeather_Sandstorm(void)
{
SetWeather(WEATHER_SANDSTORM);
}
static void CoordEventWeather_Dark(void)
{
SetWeather(WEATHER_SHADE);
}
static void CoordEventWeather_Drought(void)
{
SetWeather(WEATHER_DROUGHT);
}
static void CoordEventWeather_Route119Cycle(void)
{
SetWeather(WEATHER_ROUTE119_CYCLE);
}
static void CoordEventWeather_Route123Cycle(void)
{
SetWeather(WEATHER_ROUTE123_CYCLE);
}
void DoCoordEventWeather(u8 coordEventWeather)
{
u8 i;
for (i = 0; i < ARRAY_COUNT(sCoordEventWeatherFuncs); i++)
{
if (sCoordEventWeatherFuncs[i].coordEventWeather == coordEventWeather)
{
sCoordEventWeatherFuncs[i].func();
return;
}
}
}