diff --git a/asm/code_807E5AC.s b/asm/code_807E5AC.s index f38ad3e7f..4012fcf22 100644 --- a/asm/code_807E5AC.s +++ b/asm/code_807E5AC.s @@ -5,196 +5,6 @@ .text - thumb_func_start sub_807EAA0 -sub_807EAA0: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - lsls r1, 24 - lsrs r1, 24 - str r1, [sp, 0x4] - movs r0, 0 - mov r8, r0 - movs r1, 0x1 - negs r1, r1 - mov r9, r1 - movs r2, 0 - str r2, [sp, 0x8] - bl GetApparentWeather - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - movs r5, 0 - ldr r7, _0807EAF0 - ldr r6, _0807EAF4 -_0807EAD6: - ldr r3, [r7] - adds r0, r3, r6 - adds r4, r0, r5 - ldr r1, _0807EAF8 - adds r0, r3, r1 - adds r0, r5 - ldrb r0, [r0] - ldrb r2, [r4] - adds r1, r0, 0 - cmp r2, r1 - bcs _0807EAFC - strb r0, [r4] - b _0807EB08 - .align 2, 0 -_0807EAF0: .4byte gDungeon -_0807EAF4: .4byte 0x0000e267 -_0807EAF8: .4byte 0x0000e26f -_0807EAFC: - cmp r2, r1 - bls _0807EB08 - adds r0, r5, r6 - adds r0, r3, r0 - bl sub_80838EC -_0807EB08: - ldr r0, [r7] - ldr r2, _0807EB38 - adds r0, r2 - adds r0, r5 - ldrb r1, [r0] - ldr r0, _0807EB3C - cmp r8, r1 - bge _0807EB1C - mov r8, r1 - mov r9, r5 -_0807EB1C: - adds r5, 0x1 - cmp r5, 0x7 - ble _0807EAD6 - mov r1, r9 - cmp r1, 0 - bge _0807EB44 - ldr r0, [r0] - ldr r2, _0807EB40 - adds r1, r0, r2 - ldrb r1, [r1] - subs r2, 0x1 - adds r0, r2 - strb r1, [r0] - b _0807EB4E - .align 2, 0 -_0807EB38: .4byte 0x0000e267 -_0807EB3C: .4byte gDungeon -_0807EB40: .4byte 0x0000e265 -_0807EB44: - ldr r0, [r0] - ldr r1, _0807EB94 - adds r0, r1 - mov r2, r9 - strb r2, [r0] -_0807EB4E: - ldr r0, _0807EB98 - ldr r1, [r0] - ldr r2, _0807EB9C - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0 - beq _0807EB64 - ldr r0, _0807EB94 - adds r1, r0 - movs r0, 0 - strb r0, [r1] -_0807EB64: - movs r0, 0 - bl GetApparentWeather - lsls r0, 24 - lsrs r0, 24 - cmp r10, r0 - bne _0807EB78 - ldr r1, [sp, 0x4] - cmp r1, 0 - beq _0807EB82 -_0807EB78: - movs r2, 0x1 - str r2, [sp, 0x8] - ldr r0, [sp] - bl sub_807E698 -_0807EB82: - ldr r0, _0807EB98 - ldr r0, [r0] - ldr r2, _0807EBA0 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0 - beq _0807EBA4 - subs r0, 0x1 - b _0807EBA6 - .align 2, 0 -_0807EB94: .4byte 0x0000e264 -_0807EB98: .4byte gDungeon -_0807EB9C: .4byte 0x0000e279 -_0807EBA0: .4byte 0x0000e266 -_0807EBA4: - movs r0, 0x9 -_0807EBA6: - strb r0, [r1] - ldr r4, _0807EC14 - ldr r0, [r4] - ldr r2, _0807EC18 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0 - beq _0807EBD4 - adds r0, r1, 0 - bl sub_80838EC - ldr r0, [r4] - ldr r1, _0807EC18 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _0807EBD4 - bl GetLeader - ldr r1, _0807EC1C - ldr r1, [r1] - bl LogMessageByIdWithPopupCheckUser -_0807EBD4: - ldr r4, _0807EC14 - ldr r0, [r4] - ldr r2, _0807EC20 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0 - beq _0807EC00 - adds r0, r1, 0 - bl sub_80838EC - ldr r0, [r4] - ldr r1, _0807EC20 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _0807EC00 - bl GetLeader - ldr r1, _0807EC24 - ldr r1, [r1] - bl LogMessageByIdWithPopupCheckUser -_0807EC00: - ldr r0, [sp, 0x8] - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_0807EC14: .4byte gDungeon -_0807EC18: .4byte 0x0000e277 -_0807EC1C: .4byte gUnknown_80FA778 -_0807EC20: .4byte 0x0000e278 -_0807EC24: .4byte gUnknown_80FA758 - thumb_func_end sub_807EAA0 thumb_func_start sub_807EC28 sub_807EC28: diff --git a/data/data_80F4D44.s b/data/data_80F4D44.s index be09bee4f..2ea765fd9 100644 --- a/data/data_80F4D44.s +++ b/data/data_80F4D44.s @@ -16,4 +16,4 @@ gUnknown_80F4D64: @ 80F4D64 gUnknown_80F4D8C: @ 80F4D8C @ replacing .incbin "baserom.gba", 0x000f4d8c, 0x14 .string "mapparam\0" - .align 2,0 \ No newline at end of file + .align 2,0 diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index c751ce3a0..78c4bd342 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -20,7 +20,7 @@ #define DUNGEON_MAX_ITEMS 64 // size: 0x18 -typedef struct Weather +typedef struct Weather // 0xE264 { /* 0x0 */ u8 weather; // Uses the weather constants in weather.h. /* 0x1 */ u8 unkE265; // Uses the weather constants in weather.h diff --git a/src/code_807E5AC.c b/src/code_807E5AC.c index 34e6de0fb..ed75d107d 100644 --- a/src/code_807E5AC.c +++ b/src/code_807E5AC.c @@ -26,11 +26,14 @@ extern s32 GetMonsterApparentID(Entity *pokemon, s32 id); void sub_803E874(bool8 r10, s32 r9); void GetWeatherName(u8 *dst, u8 weatherId); extern s32 CalculateStatusTurns(Entity *target, const s16 *turnRange, bool8 factorCurerSkills); +extern void sub_80838EC(u8 *a); void sub_807E7FC(bool8 arg0); void sub_807E8F0(Entity *pokemon); extern const u8 *const gUnknown_80FC5E0; +extern const u8 *const gUnknown_80FA778; +extern const u8 *const gUnknown_80FA758; // Note: gUnknown_202ECA0 file's 2d array is read as 1d array in functions below, be careful! void sub_807E698(bool8 arg0) @@ -202,3 +205,64 @@ void MudWaterSportEffect(u8 which) LogMessageByIdWithPopupCheckUser(GetLeader(), gUnknown_80FADB0); } } + +bool8 sub_807EAA0(bool8 arg0, bool8 arg1) +{ + s32 i; + s32 var = 0; + s32 index = -1; + bool8 ret = FALSE; + s32 weatherBefore = GetApparentWeather(NULL); + + for (i = 0; i < 8; i++) { + if (gDungeon->weather.unkE267[i] < gDungeon->weather.naturalWeather[i]) { + gDungeon->weather.unkE267[i] = gDungeon->weather.naturalWeather[i]; + } + else if (gDungeon->weather.unkE267[i] > gDungeon->weather.naturalWeather[i]) { + sub_80838EC(&gDungeon->weather.unkE267[i]); + } + + if (var < gDungeon->weather.unkE267[i]) { + var = gDungeon->weather.unkE267[i]; + index = i; + } + } + + if (index < 0) { + gDungeon->weather.weather = gDungeon->weather.unkE265; + } + else { + gDungeon->weather.weather = index; + } + + if (gDungeon->weather.nullifyWeather) { + gDungeon->weather.weather = 0; + } + + if (weatherBefore != GetApparentWeather(NULL) || arg1) { + ret = TRUE; + sub_807E698(arg0); + } + + if (gDungeon->weather.weatherDamageCounter != 0) { + gDungeon->weather.weatherDamageCounter--; + } + else { + gDungeon->weather.weatherDamageCounter = 9; + } + + if (gDungeon->weather.mudSportTurns != 0) { + sub_80838EC(&gDungeon->weather.mudSportTurns); + if (gDungeon->weather.mudSportTurns == 0) { + LogMessageByIdWithPopupCheckUser(GetLeader(), gUnknown_80FA778); + } + } + if (gDungeon->weather.waterSportTurns != 0) { + sub_80838EC(&gDungeon->weather.waterSportTurns); + if (gDungeon->weather.waterSportTurns == 0) { + LogMessageByIdWithPopupCheckUser(GetLeader(), gUnknown_80FA758); + } + } + + return ret; +} diff --git a/src/dungeon_config.c b/src/dungeon_config.c index d6408c0d6..ca4fc5ed9 100644 --- a/src/dungeon_config.c +++ b/src/dungeon_config.c @@ -1130,4 +1130,3 @@ const struct CalledMove gNaturePowerCalledMoves[] = {MOVE_SURF, HandleRegularDamagingMove}, {MOVE_ROCK_SLIDE, HandleRegularDamagingMove}, }; -