diff --git a/asm/include/unk_02018380.inc b/asm/include/unk_02018380.inc deleted file mode 100644 index 5618ece3eb..0000000000 --- a/asm/include/unk_02018380.inc +++ /dev/null @@ -1,8 +0,0 @@ -#include -#pragma once -.public sub_02018380 -.public sub_0201838C -.public sub_020183B0 -.public sub_020254FC -.public sub_02025504 -.public AddIGTSeconds diff --git a/asm/unk_02018380.s b/asm/unk_02018380.s deleted file mode 100644 index b9af8f43f6..0000000000 --- a/asm/unk_02018380.s +++ /dev/null @@ -1,75 +0,0 @@ - .include "asm/macros.inc" - .include "unk_02018380.inc" - .include "global.inc" - - .bss - -_021D10E8: - .space 0x20 - - .text - - thumb_func_start sub_02018380 -sub_02018380: ; 0x02018380 - ldr r0, _02018388 ; =_021D10E8 - mov r1, #0 - str r1, [r0] - bx lr - .balign 4, 0 -_02018388: .word _021D10E8 - thumb_func_end sub_02018380 - - thumb_func_start sub_0201838C -sub_0201838C: ; 0x0201838C - push {r3, lr} - ldr r1, _020183AC ; =_021D10E8 - mov r2, #1 - str r2, [r1] - mov r2, #0 - str r2, [r1, #0x10] - str r2, [r1, #0x14] - str r2, [r1, #8] - str r2, [r1, #0xc] - str r0, [r1, #4] - bl sub_020254FC - ldr r2, _020183AC ; =_021D10E8 - str r0, [r2, #0x18] - str r1, [r2, #0x1c] - pop {r3, pc} - .balign 4, 0 -_020183AC: .word _021D10E8 - thumb_func_end sub_0201838C - - thumb_func_start sub_020183B0 -sub_020183B0: ; 0x020183B0 - push {r3, r4, r5, lr} - ldr r0, _020183EC ; =_021D10E8 - ldr r0, [r0] - cmp r0, #0 - beq _020183EA - bl sub_020254FC - ldr r2, _020183EC ; =_021D10E8 - ldr r3, [r2, #0x18] - ldr r2, [r2, #0x1c] - sub r0, r0, r3 - sbc r1, r2 - bl sub_02025504 - add r5, r1, #0 - ldr r1, _020183EC ; =_021D10E8 - add r4, r0, #0 - ldr r3, [r1, #8] - ldr r2, [r1, #0xc] - sub r0, r3, r4 - sbc r2, r5 - bhs _020183EA - ldr r0, [r1, #4] - sub r1, r4, r3 - bl AddIGTSeconds - ldr r0, _020183EC ; =_021D10E8 - str r4, [r0, #8] - str r5, [r0, #0xc] -_020183EA: - pop {r3, r4, r5, pc} - .balign 4, 0 -_020183EC: .word _021D10E8 - thumb_func_end sub_020183B0 diff --git a/include/unk_02018380.h b/include/unk_02018380.h index 5363b6c61c..6cf0f3935a 100644 --- a/include/unk_02018380.h +++ b/include/unk_02018380.h @@ -3,8 +3,17 @@ #include "igt.h" +typedef struct UnkStruct_021D10E8 { + u32 unk0; + IGT *igt; + u64 unk8; + u32 unk10; + u32 unk14; + u64 unk18; +} UnkStruct_021D10E8; + void sub_02018380(void); void sub_020183B0(void); -void sub_0201838C(IGT* igt); +void sub_0201838C(IGT *igt); #endif //POKEHEARTGOLD_UNK_02018380_H diff --git a/main.lsf b/main.lsf index efa6006939..a4bfc48394 100644 --- a/main.lsf +++ b/main.lsf @@ -57,7 +57,7 @@ Static main Object asm/unk_02016EDC.o Object asm/unk_02017FAC.o Object asm/unk_02018000.o - Object asm/unk_02018380.o + Object src/unk_02018380.o Object asm/unk_020183F0.o Object src/camera_translation.o Object asm/unk_020192D0.o diff --git a/src/unk_02018380.c b/src/unk_02018380.c new file mode 100644 index 0000000000..8d58494c39 --- /dev/null +++ b/src/unk_02018380.c @@ -0,0 +1,33 @@ +#include "global.h" +#include "unk_02018380.h" +#include "timer_3.h" + +static UnkStruct_021D10E8 s_021D10E8; + +void sub_02018380(void) { + s_021D10E8.unk0 = 0; +} + +void sub_0201838C(IGT *igt) { + s_021D10E8.unk0 = 1; + s_021D10E8.unk10 = 0; + s_021D10E8.unk14 = 0; + s_021D10E8.unk8 = 0; + s_021D10E8.igt = igt; + s_021D10E8.unk18 = sub_020254FC(); +} + +void sub_020183B0(void) { + if (s_021D10E8.unk0 == 0) { + return; + } + + u64 val = sub_020254FC(); + u64 val2 = sub_02025504(val - s_021D10E8.unk18); + if (s_021D10E8.unk8 >= val2) { + return; + } + + AddIGTSeconds(s_021D10E8.igt, val2 - s_021D10E8.unk8); + s_021D10E8.unk8 = val2; +}