diff --git a/asm/code_800DAC0.s b/asm/code_800DAC0.s index dea1cccc4..baa4ad415 100644 --- a/asm/code_800DAC0.s +++ b/asm/code_800DAC0.s @@ -7,181 +7,6 @@ - thumb_func_start sub_800E0B4 -sub_800E0B4: - push {r4-r6,lr} - sub sp, 0x8 - adds r5, r0, 0 - ldr r0, [r5, 0xC] - bl sub_800ECA4 - adds r6, r0, 0 - ldr r0, [r6] - str r0, [r5, 0x34] - ldr r0, [r6, 0x4] - str r0, [r5, 0x38] - ldr r0, [r6, 0x10] - str r0, [r5, 0x4C] - ldr r0, [r5, 0x10] - ldr r1, [r6, 0x14] - adds r0, r1 - str r0, [r5, 0x50] - adds r0, r6, 0 - adds r0, 0x21 - ldrb r0, [r0] - adds r1, r5, 0 - adds r1, 0x55 - strb r0, [r1] - adds r0, r6, 0 - adds r0, 0x20 - ldrb r1, [r0] - adds r0, r5, 0 - adds r0, 0x54 - strb r1, [r0] - adds r0, 0x64 - ldr r0, [r0] - bl sub_800E2B8 - adds r2, r0, 0 - str r2, [r5, 0x8] - ldr r3, [r6, 0xC] - str r3, [r5, 0x40] - ldr r1, [r5, 0x14] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - beq _0800E114 - movs r0, 0x7 - ands r0, r2 - cmp r0, 0 - bne _0800E114 - adds r0, r3, r1 - str r0, [r5, 0x40] -_0800E114: - ldr r0, [r5, 0x34] - cmp r0, 0x3 - beq _0800E12E - cmp r0, 0x3 - bhi _0800E128 - cmp r0, 0x1 - bcc _0800E184 - movs r0, 0x92 - lsls r0, 2 - b _0800E132 -_0800E128: - cmp r0, 0x4 - beq _0800E140 - b _0800E184 -_0800E12E: - movs r0, 0xDC - lsls r0, 2 -_0800E132: - str r0, [r5, 0x48] - ldr r0, [r6, 0x8] - str r0, [r5, 0x3C] - movs r0, 0x1 - negs r0, r0 - str r0, [r5, 0x44] - b _0800E184 -_0800E140: - movs r0, 0x1 - negs r0, r0 - str r0, [r5, 0x48] - ldr r0, [r6, 0x8] - str r0, [r5, 0x3C] - movs r0, 0xF0 - lsls r0, 4 - str r0, [r5, 0x44] - ldr r4, _0800E194 - ldr r0, [r4] - ldr r2, _0800E198 - adds r1, r0, r2 - movs r2, 0 - str r2, [r1] - ldr r3, _0800E19C - adds r0, r3 - str r2, [r0] - bl sub_800CDC8 - ldr r2, [r4] - ldr r4, _0800E1A0 - adds r1, r2, r4 - str r0, [r1] - ldr r0, _0800E1A4 - ldrh r0, [r0] - ldr r1, _0800E1A8 - adds r2, r1 - strh r0, [r2] - ldrb r0, [r6, 0x18] - cmp r0, 0 - beq _0800E184 - movs r0, 0x5 - bl sub_800CDA8 -_0800E184: - ldr r0, [r5, 0x34] - cmp r0, 0x3 - beq _0800E1C2 - cmp r0, 0x3 - bls _0800E1AC - cmp r0, 0x4 - beq _0800E1E4 - b _0800E200 - .align 2, 0 -_0800E194: .4byte gUnknown_203B0CC -_0800E198: .4byte 0x00001a08 -_0800E19C: .4byte 0x00001a0c -_0800E1A0: .4byte 0x00001a10 -_0800E1A4: .4byte gUnknown_2026E4E -_0800E1A8: .4byte 0x00001a14 -_0800E1AC: - cmp r0, 0x1 - bcc _0800E200 - adds r0, r5, 0 - adds r0, 0x58 - adds r1, r5, 0 - adds r1, 0xB8 - ldr r1, [r1] - ldr r2, [r5, 0x40] - movs r3, 0x92 - lsls r3, 2 - b _0800E1D2 -_0800E1C2: - adds r0, r5, 0 - adds r0, 0x58 - adds r1, r5, 0 - adds r1, 0xB8 - ldr r1, [r1] - ldr r2, [r5, 0x40] - movs r3, 0xDC - lsls r3, 2 -_0800E1D2: - movs r4, 0 - str r4, [sp] - adds r4, r5, 0 - adds r4, 0x55 - ldrb r4, [r4] - str r4, [sp, 0x4] - bl AxResInitUnorientedFile - b _0800E200 -_0800E1E4: - adds r0, r5, 0 - adds r0, 0xB8 - ldr r0, [r0] - adds r1, r5, 0 - adds r1, 0x94 - ldr r0, [r0, 0x4] - ldm r0!, {r2-r4} - stm r1!, {r2-r4} - ldm r0!, {r2,r3} - stm r1!, {r2,r3} - adds r1, r5, 0 - adds r1, 0xB4 - movs r0, 0 - strb r0, [r1] -_0800E200: - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_800E0B4 - thumb_func_start sub_800E208 sub_800E208: push {r4-r7,lr} diff --git a/include/code_800E9A8.h b/include/code_800E9A8.h index 3724336db..b9a7ddebf 100644 --- a/include/code_800E9A8.h +++ b/include/code_800E9A8.h @@ -5,12 +5,11 @@ #include "structs/sprite_oam.h" #include "structs/str_position.h" #include "structs/str_file_system.h" +#include "structs/str_8009A7C.h" struct unkStruct_203B0CC_x94 { - s32 unk0; - u16 **unk4; - u8 fill8[0x14-0x8]; + struct Struct_8009A7C sub; s32 unk14; s32 unk18; s32 fill1C; @@ -34,11 +33,13 @@ struct unkStruct_203B0CC_sub u32 unk34; u32 effectID; s32 paletteNum; - u8 fill40[0x4C - 0x40]; + s32 unk40; + s32 unk44; + s32 unk48; u32 unk4C; s32 unk50; u8 unk54; - u8 fill55[0x58 - 0x55]; + u8 unk55; axdata unk58; struct unkStruct_203B0CC_x94 unk94; OpenedFile *unkB8; diff --git a/include/code_800E9E4.h b/include/code_800E9E4.h index 7cdfae283..09883eee9 100644 --- a/include/code_800E9E4.h +++ b/include/code_800E9E4.h @@ -10,7 +10,7 @@ typedef struct unkStruct_80B9CC4 s32 animId; s32 unk10; s32 unk14; - s8 unk18; + u8 unk18; // padding: 3 bytes s32 unk1c; s8 unk20; diff --git a/include/graphics_memory.h b/include/graphics_memory.h index 69386a328..c2b00847b 100644 --- a/include/graphics_memory.h +++ b/include/graphics_memory.h @@ -2,6 +2,7 @@ #define GUARD_GRAPHICS_MEMORY_H #include "structs/axdata.h" +#include "structs/str_8009A7C.h" extern RGB gFontPalette[128]; @@ -20,5 +21,6 @@ void ScheduleBgTilemapCopy(u32); void DoScheduledMemCopies(void); void CopyBgTilemaps0And1(void); void SetFontsBaseColor(RGB); +bool8 sub_8009A7C(struct Struct_8009A7C *a0, s32 a1, s32 a2, s32 a3, bool8 a4, s32 *a5, s16 *a6); #endif // GUARD_GRAPHICS_MEMORY_H diff --git a/include/structs/str_8009A7C.h b/include/structs/str_8009A7C.h new file mode 100644 index 000000000..ba20e04d3 --- /dev/null +++ b/include/structs/str_8009A7C.h @@ -0,0 +1,11 @@ +#ifndef GUARD_STR_8009A7C_H +#define GUARD_STR_8009A7C_H + +struct Struct_8009A7C +{ + s32 unk0; + u16 **unk4; + u8 fill8[0x14-0x8]; +}; + +#endif // GUARD_STR_8009A7C_H diff --git a/src/code_800DAC0.c b/src/code_800DAC0.c index 20644d26f..b45d1f0ca 100644 --- a/src/code_800DAC0.c +++ b/src/code_800DAC0.c @@ -13,6 +13,8 @@ #include "sprite.h" #include "bg_palette_buffer.h" #include "cpu.h" +#include "code_800E9E4.h" +#include "graphics_memory.h" EWRAM_INIT struct unkStruct_203B0CC *gUnknown_203B0CC = NULL; @@ -176,6 +178,7 @@ void sub_800DCD0(struct unkStruct_203B0CC_sub *param_1) } #ifdef NONMATCHING +// https://decomp.me/scratch/OBo48 bool8 sub_800DD0C(struct unkStruct_203B0CC_sub *param_1, DungeonPos *posArg) { struct axObject *axObj = ¶m_1->unk58; @@ -425,7 +428,6 @@ bool8 sub_800DE38(struct unkStruct_203B0CC_sub *a1) } extern s16 gUnknown_2026E4E; -extern bool8 sub_8009A7C(void *a0, s32 a1, s32 a2, s32 a3, bool8 a4, s32 *a5, s16 *a6); extern void sub_809971C(u16 a0, const RGB *a1, int a2); static inline const EfoFileData *GetFileEfo(struct unkStruct_203B0CC_sub *a0) @@ -439,7 +441,7 @@ bool8 sub_800DE8C(struct unkStruct_203B0CC_sub *a0, DungeonPos *unused) struct unkStruct_203B0CC_x94 *r8 = &a0->unk94; if (r8->unk18 == 0) { - if (sub_8009A7C(r8, r8->unk14, 0, 0, TRUE, &r8->unk18, sp)) { + if (sub_8009A7C(&r8->sub, r8->unk14, 0, 0, TRUE, &r8->unk18, sp)) { if (sp[0] != 0) { r8->unk20 = 1; gUnknown_203B0CC->unk1A08 = 0; @@ -510,4 +512,64 @@ bool8 sub_800DE8C(struct unkStruct_203B0CC_sub *a0, DungeonPos *unused) return TRUE; } +s32 sub_800E2B8(OpenedFile *a0); + +void sub_800E0B4(struct unkStruct_203B0CC_sub *r5) +{ + s32 r2; + unkStruct_80B9CC4 *r6 = sub_800ECA4(r5->unkC); + r5->unk34 = r6->animType; + r5->effectID = r6->effectId; + r5->unk4C = r6->unk10; + r5->unk50 = r5->unk10 + r6->unk14; + r5->unk55 = r6->loop; + r5->unk54 = r6->unk20; + r2 = sub_800E2B8(r5->unkB8); + r5->unk8 = r2; + r5->unk40 = r6->animId; + if (r5->unk14 != -1 && (r2 % 8) == 0) { + r5->unk40 += r5->unk14; + } + + switch (r5->unk34) { + case 3: + r5->unk48 = 0x370; + r5->paletteNum = r6->unk8; + r5->unk44 = -1; + break; + case 4: + r5->unk48 = -1; + r5->paletteNum = r6->unk8; + r5->unk44 = 3840; + gUnknown_203B0CC->unk1A08 = 0; + gUnknown_203B0CC->unk1A0C = 0; + gUnknown_203B0CC->unk1A10 = sub_800CDC8(); + gUnknown_203B0CC->unk1A14 = gUnknown_2026E4E; + if (r6->unk18 != 0) { + sub_800CDA8(5); + } + break; + case 1: + case 2: + r5->unk48 = 0x248; + r5->paletteNum = r6->unk8; + r5->unk44 = -1; + break; + } + + switch (r5->unk34) { + case 1: + case 2: + AxResInitUnorientedFile(&r5->unk58, r5->unkB8, r5->unk40, 0x248, 0, r5->unk55); + break; + case 3: + AxResInitUnorientedFile(&r5->unk58, r5->unkB8, r5->unk40, 0x370, 0, r5->unk55); + break; + case 4: + r5->unk94.sub = (*(struct Struct_8009A7C*)(r5->unkB8->data)); + r5->unk94.unk20 = 0; + break; + } +} + // diff --git a/src/graphics_memory.c b/src/graphics_memory.c index bfe0f66da..174b75c2c 100644 --- a/src/graphics_memory.c +++ b/src/graphics_memory.c @@ -250,13 +250,6 @@ void sub_8009A1C(const EfoFileData *r0, u32 palId, u32 vramDstOffset, u32 r3) } } -// Todo: Merge this struct with others once sub_800DE8C is decompiled(if possible) -struct Struct_8009A7C -{ - s32 unk0; - u16 **unk4; -}; - bool8 sub_8009A7C(struct Struct_8009A7C *a0, s32 a1, s32 a2, s32 a3, bool8 a4, s32 *a5, s16 *a6) { s32 countY;