From ed943b1e536524c02501e3b462acfc3664347315 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 08:59:47 +0100 Subject: [PATCH 01/51] change type of gUnk_02034490 --- include/structures.h | 2 +- src/executeScriptCommandSet.c | 2 +- src/manager/manager15.c | 4 ++-- src/manager/manager7.c | 6 +++--- src/object/cloud.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/structures.h b/include/structures.h index 534f0d98..9f4b32bf 100644 --- a/include/structures.h +++ b/include/structures.h @@ -176,6 +176,6 @@ static_assert(sizeof(BG3Buffer) == 0x1000); */ extern u8 gUnk_02022740[]; -extern u8 gUnk_02034490; +extern u8 gUnk_02034490[]; #endif diff --git a/src/executeScriptCommandSet.c b/src/executeScriptCommandSet.c index de8ea781..7895c28f 100644 --- a/src/executeScriptCommandSet.c +++ b/src/executeScriptCommandSet.c @@ -832,7 +832,7 @@ void sub_0807E9F0(Entity* unk1, ScriptExecutionContext* unk2) { switch (gUnk_02022740[0]) { case 2: gPlayerState.field_0x8b = 3; - gUnk_02034490 = tmp; + gUnk_02034490[0] = tmp; unk2->unk_14 = tmp; break; case 1: diff --git a/src/manager/manager15.c b/src/manager/manager15.c index 23abd03e..44b38fb4 100644 --- a/src/manager/manager15.c +++ b/src/manager/manager15.c @@ -3,6 +3,7 @@ #include "screen.h" #include "manager.h" #include "functions.h" +#include "structures.h" typedef struct { Manager manager; @@ -293,7 +294,6 @@ void sub_0805A758(Manager15* this) { } } -extern u8 gUnk_02034490; extern void sub_0805E4E0(Manager*, u32); extern void sub_08077B20(void); @@ -308,7 +308,7 @@ void sub_0805A76C(Manager15* this) { gPlayerEntity.animationState = 4; sub_0805E4E0(&this->manager, 0x258); sub_08078A90(0xFF); - gUnk_02034490 = 1; + gUnk_02034490[0] = 1; gRoomControls.cameraTarget = 0; sub_08077B20(); } diff --git a/src/manager/manager7.c b/src/manager/manager7.c index 55e88f7d..6a0fe97d 100644 --- a/src/manager/manager7.c +++ b/src/manager/manager7.c @@ -1,6 +1,7 @@ #include "global.h" #include "manager.h" #include "functions.h" +#include "structures.h" #include "gba/gba.h" typedef struct { @@ -18,7 +19,6 @@ extern void sub_08052D74(); extern u32 sub_08056300(const u16*); extern void sub_0805E3A0(); -extern u8 gUnk_02034490; extern const u8 gGlobalGfxAndPalettes[]; const u16 gUnk_08108050[0x2A] = { 0, 0, 0x20, 0xE0, 0xE0, 1, 0, 0x1D0, 0x80, 0x60, 2, @@ -63,7 +63,7 @@ void Manager7_Main(Manager7* this) { tmp2 = &gUnk_081080A4[tmp << 4]; switch (this->manager.unk_0e) { case 0: - gUnk_02034490 = 1; + gUnk_02034490[0] = 1; LoadAssetAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000); LoadPaletteGroup(gUnk_081081E4[tmp]); this->manager.unk_0e++; @@ -80,7 +80,7 @@ void Manager7_Main(Manager7* this) { this->manager.unk_0e++; break; case 8: - gUnk_02034490 = 0; + gUnk_02034490[0] = 0; this->manager.unk_0e++; break; } diff --git a/src/object/cloud.c b/src/object/cloud.c index 8a133c2e..631e6605 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -4,6 +4,7 @@ #include "player.h" #include "flags.h" #include "functions.h" +#include "structures.h" extern void sub_0809F7BC(Entity*); extern void PlaySFX(u32); @@ -22,7 +23,6 @@ extern Entity* CreateObject(u32, u32, u32); extern void PositionEntityOnTop(Entity*, Entity*); extern void sub_0807BB68(u32*, u32, u32); -extern u8 gUnk_02034490; extern void* gUnk_080DD750; extern Entity gPlayerEntity; extern PlayerState gPlayerState; @@ -48,7 +48,7 @@ void sub_0809F514(Entity* this) { this->spriteSettings.b.draw = 0; this->field_0x68.HALF.LO = 12; gRoomControls.cameraTarget = this; - gUnk_02034490 = 255; + gUnk_02034490[0] = 255; sub_0809F7BC(this); } From 77b8ff337866f96597224becffc358d99a243b6e Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 09:00:02 +0100 Subject: [PATCH 02/51] matched sub_0807DF50 --- asm/code_0807CC3C.s | 17 ----------------- linker.ld | 1 + src/code_0807CC3C.c | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 17 deletions(-) create mode 100644 src/code_0807CC3C.c diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index fa09e5b8..b05ddf0a 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -2197,20 +2197,3 @@ sub_0807DF38: @ 0x0807DF38 .align 2, 0 _0807DF48: .4byte gUnk_0200AF00 _0807DF4C: .4byte gUnk_02034490 - - thumb_func_start sub_0807DF50 -sub_0807DF50: @ 0x0807DF50 - push {lr} - ldr r0, _0807DF6C @ =gUnk_02034490 - movs r1, #0 - strb r1, [r0] - ldr r0, _0807DF70 @ =gUnk_0200AF00 - strb r1, [r0, #1] - movs r0, #0 - bl sub_0801C4A0 - bl sub_080791D0 - bl sub_08079184 - pop {pc} - .align 2, 0 -_0807DF6C: .4byte gUnk_02034490 -_0807DF70: .4byte gUnk_0200AF00 diff --git a/linker.ld b/linker.ld index 528c2783..8b282a19 100644 --- a/linker.ld +++ b/linker.ld @@ -676,6 +676,7 @@ SECTIONS { src/flags.o(.text); src/save.o(.text); asm/code_0807CC3C.o(.text); + src/code_0807CC3C.o(.text); src/executeScriptCommandSet.o(.text); asm/code_0807F0D8.o(.text); src/code_0808091C.o(.text); diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c new file mode 100644 index 00000000..13136574 --- /dev/null +++ b/src/code_0807CC3C.c @@ -0,0 +1,14 @@ +#include "global.h" +#include "structures.h" +#include "functions.h" + +extern void sub_0801C4A0(int arg0); + +void sub_0807DF50() +{ + gUnk_02034490[0] = 0; + gUnk_0200AF00.filler0[1] = 0; + sub_0801C4A0(0); + sub_080791D0(); + sub_08079184(); +} \ No newline at end of file From 6885278d4b38900b7bcfe12478fa36efbc1d8a90 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 09:06:52 +0100 Subject: [PATCH 03/51] fixed formatting --- src/code_0807CC3C.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 13136574..07174792 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -4,8 +4,7 @@ extern void sub_0801C4A0(int arg0); -void sub_0807DF50() -{ +void sub_0807DF50() { gUnk_02034490[0] = 0; gUnk_0200AF00.filler0[1] = 0; sub_0801C4A0(0); From 56ba21b875e94fbb9f326d7e9bfd1da9a31d5a76 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 09:22:58 +0100 Subject: [PATCH 04/51] matched sub_0807DF28 and sub_0807DF38 --- asm/code_0807CC3C.s | 22 ---------------------- src/code_0807CC3C.c | 14 +++++++++++++- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index b05ddf0a..d1d2a2af 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -2175,25 +2175,3 @@ sub_0807DEDC: @ 0x0807DEDC pop {r4, r5, r6, pc} .align 2, 0 _0807DF24: .4byte gUnk_0811E514 - - thumb_func_start sub_0807DF28 -sub_0807DF28: @ 0x0807DF28 - push {lr} - bl sub_0807DF38 - bl sub_08079184 - bl sub_08077B20 - pop {pc} - - thumb_func_start sub_0807DF38 -sub_0807DF38: @ 0x0807DF38 - ldr r1, _0807DF48 @ =gUnk_0200AF00 - movs r0, #0xff - strb r0, [r1, #1] - ldr r1, _0807DF4C @ =gUnk_02034490 - movs r0, #1 - rsbs r0, r0, #0 - strb r0, [r1] - bx lr - .align 2, 0 -_0807DF48: .4byte gUnk_0200AF00 -_0807DF4C: .4byte gUnk_02034490 diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 07174792..254b13f1 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -2,9 +2,21 @@ #include "structures.h" #include "functions.h" +void sub_0807DF38(void); extern void sub_0801C4A0(int arg0); -void sub_0807DF50() { +void sub_0807DF28(void) { + sub_0807DF38(); + sub_08079184(); + sub_08077B20(); +} + +void sub_0807DF38(void) { + gUnk_0200AF00.filler0[1] = 0xff; + gUnk_02034490[0] = 0xff; +} + +void sub_0807DF50(void) { gUnk_02034490[0] = 0; gUnk_0200AF00.filler0[1] = 0; sub_0801C4A0(0); From fa3339a8c2dc8a840d1427abf202c59b4a03d70d Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 10:09:46 +0100 Subject: [PATCH 05/51] matched sub_0807DEDC --- asm/code_0807CC3C.s | 40 ---------------------------------------- src/code_0807CC3C.c | 22 +++++++++++++++++++++- src/npc/postman.c | 6 +++--- 3 files changed, 24 insertions(+), 44 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index d1d2a2af..bd7e1630 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -2135,43 +2135,3 @@ _0807DED4: adds r0, r4, #0 bl sub_080042BA pop {r4, pc} - - thumb_func_start sub_0807DEDC -sub_0807DEDC: @ 0x0807DEDC - push {r4, r5, r6, lr} - adds r5, r0, #0 - movs r6, #0 - movs r0, #8 - strb r0, [r1, #0x19] - ldr r0, [r1, #8] - movs r4, #2 - orrs r0, r4 - str r0, [r1, #8] - str r6, [r1, #0x14] - strh r2, [r1, #0x1e] - strh r3, [r1, #0x22] - movs r2, #0x1e - ldrsh r0, [r1, r2] - movs r3, #0x2e - ldrsh r2, [r5, r3] - subs r0, r0, r2 - movs r2, #0x22 - ldrsh r1, [r1, r2] - movs r3, #0x32 - ldrsh r2, [r5, r3] - subs r1, r1, r2 - bl sub_080045DA - strb r0, [r5, #0x15] - ldrb r2, [r5, #0x14] - movs r1, #0x80 - ands r1, r2 - ldr r2, _0807DF24 @ =gUnk_0811E514 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x1c - adds r0, r0, r2 - ldrb r0, [r0] - orrs r1, r0 - strb r1, [r5, #0x14] - pop {r4, r5, r6, pc} - .align 2, 0 -_0807DF24: .4byte gUnk_0811E514 diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 254b13f1..8d3c5892 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -1,9 +1,29 @@ #include "global.h" #include "structures.h" #include "functions.h" +#include "script.h" + +extern u8 gUnk_0811E514[]; void sub_0807DF38(void); -extern void sub_0801C4A0(int arg0); +extern void sub_0801C4A0(u32); + +void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 arg3) +{ + int temp; + s32 t0, t1; + + context->unk_19 = 8; + context->unk_08 |= 2; + context->unk_14 = 0; + context->unk_1C.HALF.HI = arg2; + context->unk_20.HALF.HI = arg3; + t0 = context->unk_1C.HALF.HI - entity->x.HALF.HI; + t1 = context->unk_20.HALF.HI - entity->y.HALF.HI; + temp = sub_080045DA(t0, t1); + entity->direction = temp; + entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(temp <<0x18)>>0x1c]; +} void sub_0807DF28(void) { sub_0807DF38(); diff --git a/src/npc/postman.c b/src/npc/postman.c index 836bb5d5..8f387f04 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -7,6 +7,7 @@ #include "room.h" #include "structures.h" #include "save.h" +#include "script.h" extern void sub_08060528(Entity*); extern void* GetCurrentRoomProperty(u32); @@ -27,7 +28,6 @@ extern void EnqueueSFX(u32); extern void sub_080606C0(Entity*); extern void sub_0800451C(Entity*); extern void sub_08078784(Entity*, u32); -extern void sub_0807DEDC(Entity*, u32, u32, u32); typedef struct { s16 x; @@ -202,12 +202,12 @@ void sub_080606D8(Entity* this) { ShowNPCDialogue(this, &gUnk_0810AA30[index]); } -void sub_08060700(Entity* entity, u32 arg1) { +void sub_08060700(Entity* entity, ScriptExecutionContext* context) { s8* var0 = gUnk_0810A918[(s8)entity->field_0x68.HALF.LO]; Coords16* coords = &gUnk_0810A66C[var0[(s8)entity->field_0x68.HALF.HI]]; u32 x = coords->x + gRoomControls.roomOriginX; u32 y = coords->y + gRoomControls.roomOriginY; - sub_0807DEDC(entity, arg1, x, y); + sub_0807DEDC(entity, context, x, y); gUnk_02033280.unk_07 |= 1; } From 6917076fdcd0498f9ab156e629ecf67abe3c68a0 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 10:41:38 +0100 Subject: [PATCH 06/51] matched sub_0807DE80 --- asm/code_0807CC3C.s | 51 --------------------------------------------- src/code_0807CC3C.c | 38 ++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 54 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index bd7e1630..f468bf14 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -2084,54 +2084,3 @@ _0807DE70: _0807DE7C: pop {r4, r5, pc} .align 2, 0 - - thumb_func_start sub_0807DE80 -sub_0807DE80: @ 0x0807DE80 - push {r4, lr} - adds r4, r0, #0 - adds r0, #0x80 - ldrh r3, [r0] - cmp r3, #7 - bhi _0807DEB0 - adds r0, #2 - ldrh r1, [r0] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _0807DEA4 - movs r1, #0xfc - ands r1, r3 - ldrb r0, [r4, #0xf] - lsrs r0, r0, #1 - adds r3, r1, r0 - b _0807DEB0 -_0807DEA4: - movs r0, #0xfc - ands r0, r3 - ldrb r2, [r4, #0x14] - lsrs r1, r2, #1 - adds r3, r0, r1 - strb r2, [r4, #0xf] -_0807DEB0: - adds r0, r4, #0 - adds r0, #0x58 - ldrb r0, [r0] - cmp r3, r0 - beq _0807DEC2 - adds r0, r4, #0 - adds r1, r3, #0 - bl InitAnimationForceUpdate -_0807DEC2: - adds r0, r4, #0 - adds r0, #0x82 - ldrh r1, [r0] - movs r0, #4 - ands r0, r1 - movs r1, #1 - cmp r0, #0 - beq _0807DED4 - movs r1, #2 -_0807DED4: - adds r0, r4, #0 - bl sub_080042BA - pop {r4, pc} diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 8d3c5892..37d476e2 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -2,14 +2,46 @@ #include "structures.h" #include "functions.h" #include "script.h" +#include "entity.h" extern u8 gUnk_0811E514[]; void sub_0807DF38(void); extern void sub_0801C4A0(u32); -void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 arg3) -{ +void sub_0807DE80(Entity* entity) { + u32 local1; + u16 local2; + + u32 temp; + + local2 = entity->field_0x80.HWORD; + if (local2 < 8) { + if (entity->field_0x82.HWORD & 1) { + u32 t1, t2; + t1 = local2 & 0xfc; + t2 = entity->field_0xf >> 1; + local2 = t1 + t2; + } else { + u32 t1, t2; + t1 = local2 & 0xfc; + t2 = entity->animationState >> 1; + local2 = t1 + t2; + entity->field_0xf = entity->animationState; + } + } + if (local2 != entity->animIndex) { + InitAnimationForceUpdate(entity, local2); + } + temp = entity->field_0x82.HWORD & 4; + local1 = 1; + if (temp) { + local1 = 2; + } + sub_080042BA(entity, local1); +} + +void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 arg3) { int temp; s32 t0, t1; @@ -22,7 +54,7 @@ void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 t1 = context->unk_20.HALF.HI - entity->y.HALF.HI; temp = sub_080045DA(t0, t1); entity->direction = temp; - entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(temp <<0x18)>>0x1c]; + entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(temp << 0x18) >> 0x1c]; } void sub_0807DF28(void) { From 6c2b1a89b8f5f2009e001094bb6ff448f01ea73f Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 14:20:45 +0100 Subject: [PATCH 07/51] matched sub_0807DDE4 --- asm/code_0807CC3C.s | 83 --------------------------------------------- src/code_0807CC3C.c | 37 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 83 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index f468bf14..ed92563e 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -2001,86 +2001,3 @@ _0807DDD6: _0807DDE0: pop {r4, r5, r6, pc} .align 2, 0 - - thumb_func_start sub_0807DDE4 -sub_0807DDE4: @ 0x0807DDE4 - push {r4, r5, lr} - adds r4, r0, #0 - adds r0, #0x82 - ldrh r5, [r0] -_0807DDEC: - cmp r5, #0 - beq _0807DE7C - mvns r0, r5 - adds r0, #1 - ands r0, r5 - eors r5, r0 - cmp r0, #8 - beq _0807DE26 - cmp r0, #8 - bhi _0807DE06 - cmp r0, #2 - beq _0807DE10 - b _0807DDEC -_0807DE06: - cmp r0, #0x10 - beq _0807DE44 - cmp r0, #0x20 - beq _0807DE70 - b _0807DDEC -_0807DE10: - ldrb r0, [r4, #8] - cmp r0, #7 - bne _0807DE1E - adds r0, r4, #0 - bl sub_0806ED78 - b _0807DDEC -_0807DE1E: - adds r0, r4, #0 - bl sub_0800445C - b _0807DDEC -_0807DE26: - ldr r0, _0807DE40 @ =gScreenTransition - ldr r0, [r0] - movs r1, #3 - ands r0, r1 - cmp r0, #0 - bne _0807DDEC - ldrb r0, [r4, #0xf] - adds r0, #2 - movs r1, #7 - ands r0, r1 - strb r0, [r4, #0x14] - strb r0, [r4, #0xf] - b _0807DDEC - .align 2, 0 -_0807DE40: .4byte gScreenTransition -_0807DE44: - ldr r0, _0807DE68 @ =gScreenTransition - ldr r0, [r0] - movs r1, #1 - ands r0, r1 - cmp r0, #0 - bne _0807DDEC - bl Random - ldr r2, _0807DE6C @ =gUnk_0811E510 - movs r1, #3 - ands r1, r0 - adds r1, r1, r2 - ldrb r0, [r1] - adds r1, r4, #0 - adds r1, #0x62 - strb r0, [r1] - b _0807DDEC - .align 2, 0 -_0807DE68: .4byte gScreenTransition -_0807DE6C: .4byte gUnk_0811E510 -_0807DE70: - adds r0, r4, #0 - movs r1, #0x80 - lsls r1, r1, #6 - bl sub_08003FC4 - b _0807DDEC -_0807DE7C: - pop {r4, r5, pc} - .align 2, 0 diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 37d476e2..3f316cc1 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -5,10 +5,47 @@ #include "entity.h" extern u8 gUnk_0811E514[]; +extern u8 gUnk_0811E510[]; void sub_0807DF38(void); extern void sub_0801C4A0(u32); +void sub_0807DDE4(Entity* entity) { + u32 temp; + u32 switchVar; + u32 loopVar; + + loopVar = entity->field_0x82.HWORD; + while (loopVar) { + switchVar = (~loopVar + 1) & loopVar; + loopVar = loopVar ^ switchVar; + switch (switchVar) { + case 2: + if (entity->entityType.type == 7) { + sub_0806ED78(entity); + } else { + sub_0800445C(entity); + } + break; + case 8: + if ((gScreenTransition.frameCount & 3) == 0) { + temp = (entity->field_0xf + 2U) & 7; + entity->animationState = temp; + entity->field_0xf = temp; + } + break; + case 0x10: + if ((gScreenTransition.frameCount & 1) == 0) { + entity->spriteOffsetX = gUnk_0811E510[Random() & 3]; + } + break; + case 0x20: + sub_08003FC4(entity, 0x2000); + break; + } + } +} + void sub_0807DE80(Entity* entity) { u32 local1; u16 local2; From 1d68e9db592f6061cae6d44d1c46ab884818c76b Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 14:42:07 +0100 Subject: [PATCH 08/51] matched sub_0807DDAC --- asm/code_0807CC3C.s | 30 ------------------------------ src/code_0807CC3C.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index ed92563e..cdc22ea6 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1971,33 +1971,3 @@ sub_0807DD94: @ 0x0807DD94 bl sub_0807DE80 pop {r4, pc} .align 2, 0 - - thumb_func_start sub_0807DDAC -sub_0807DDAC: @ 0x0807DDAC - push {r4, r5, r6, lr} - adds r5, r0, #0 - adds r6, r1, #0 - adds r4, r5, #0 - adds r4, #0x84 - ldr r1, [r4] - cmp r1, #0 - beq _0807DDE0 - bl ExecuteScriptCommandSet - cmp r6, #0 - beq _0807DDCE - ldr r1, [r4] - adds r0, r5, #0 - bl _call_via_r6 - b _0807DDD6 -_0807DDCE: - ldr r1, [r4] - adds r0, r5, #0 - bl sub_0807DB98 -_0807DDD6: - ldr r0, [r5, #4] - cmp r0, #0 - bne _0807DDE0 - bl DeleteThisEntity -_0807DDE0: - pop {r4, r5, r6, pc} - .align 2, 0 diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 3f316cc1..e189a2a8 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -9,6 +9,31 @@ extern u8 gUnk_0811E510[]; void sub_0807DF38(void); extern void sub_0801C4A0(u32); +extern void sub_0807DB98(Entity*, ScriptExecutionContext*); +extern void _call_via_r6(Entity*, ScriptExecutionContext*); + +/** + * + * @param entity + * @param address this is the fuction called via r6 + */ +void sub_0807DDAC(Entity* entity, u32 address) +{ + ScriptExecutionContext **piVar1; + + piVar1 = (ScriptExecutionContext **)&entity->cutsceneBeh; + if (*piVar1) { + ExecuteScriptCommandSet(entity, *piVar1); + if (address) { + _call_via_r6(entity, *piVar1); + } else { + sub_0807DB98(entity, *piVar1); + } + if (!entity->next) { + DeleteThisEntity(); + } + } +} void sub_0807DDE4(Entity* entity) { u32 temp; From 9dbbd208c9c77754e58370b59dafce237c668da6 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 14:43:20 +0100 Subject: [PATCH 09/51] matched sub_0807DD94 --- asm/code_0807CC3C.s | 12 ------------ src/code_0807CC3C.c | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index cdc22ea6..dbffbeb0 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1959,15 +1959,3 @@ sub_0807DD80: @ 0x0807DD80 adds r0, r4, #0 bl sub_0807DD64 pop {r4, pc} - - thumb_func_start sub_0807DD94 -sub_0807DD94: @ 0x0807DD94 - push {r4, lr} - adds r4, r0, #0 - bl sub_0807DDAC - adds r0, r4, #0 - bl sub_0807DDE4 - adds r0, r4, #0 - bl sub_0807DE80 - pop {r4, pc} - .align 2, 0 diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index e189a2a8..70211d78 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -7,21 +7,28 @@ extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; -void sub_0807DF38(void); extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern void _call_via_r6(Entity*, ScriptExecutionContext*); +void sub_0807DF38(void); +void sub_0807DE80(Entity* entity); + +void sub_0807DD94(Entity* entity, u32 param_2) { + sub_0807DDAC(entity, param_2); + sub_0807DDE4(entity); + sub_0807DE80(entity); +} + /** * * @param entity * @param address this is the fuction called via r6 */ -void sub_0807DDAC(Entity* entity, u32 address) -{ - ScriptExecutionContext **piVar1; +void sub_0807DDAC(Entity* entity, u32 address) { + ScriptExecutionContext** piVar1; - piVar1 = (ScriptExecutionContext **)&entity->cutsceneBeh; + piVar1 = (ScriptExecutionContext**)&entity->cutsceneBeh; if (*piVar1) { ExecuteScriptCommandSet(entity, *piVar1); if (address) { From f6423768b59f7bee7a8e2db2a74ef4820d8be692 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 14:54:40 +0100 Subject: [PATCH 10/51] matched sub_0807DD80 --- asm/code_0807CC3C.s | 11 ----------- src/code_0807CC3C.c | 8 ++++++++ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index dbffbeb0..d8835d50 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1948,14 +1948,3 @@ sub_0807DD64: @ 0x0807DD64 adds r0, #2 strh r2, [r0] bx lr - - thumb_func_start sub_0807DD80 -sub_0807DD80: @ 0x0807DD80 - push {r4, lr} - adds r4, r0, #0 - adds r0, #0x84 - ldr r0, [r0] - bl sub_0807DB88 - adds r0, r4, #0 - bl sub_0807DD64 - pop {r4, pc} diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 70211d78..319ddb22 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -7,6 +7,7 @@ extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; +extern void sub_0807DB88(Entity*); extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern void _call_via_r6(Entity*, ScriptExecutionContext*); @@ -14,6 +15,13 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DF38(void); void sub_0807DE80(Entity* entity); +void sub_0807DD80(Entity *param_1) + +{ + sub_0807DB88(*(Entity**)¶m_1->cutsceneBeh); + sub_0807DD64(param_1); +} + void sub_0807DD94(Entity* entity, u32 param_2) { sub_0807DDAC(entity, param_2); sub_0807DDE4(entity); From 80e361a33e70a7c7c05c1c59e5f5f8d9aca909c5 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 14:56:41 +0100 Subject: [PATCH 11/51] matched sub_0807DD64 --- asm/code_0807CC3C.s | 17 ----------------- src/code_0807CC3C.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index d8835d50..924dfa2c 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1931,20 +1931,3 @@ sub_0807DD50: @ 0x0807DD50 bl sub_0807DD94 pop {r4, pc} .align 2, 0 - - thumb_func_start sub_0807DD64 -sub_0807DD64: @ 0x0807DD64 - adds r3, r0, #0 - ldrb r0, [r3, #0x14] - movs r2, #0 - strb r0, [r3, #0xf] - adds r1, r3, #0 - adds r1, #0x58 - movs r0, #0xff - strb r0, [r1] - adds r0, r3, #0 - adds r0, #0x80 - strh r2, [r0] - adds r0, #2 - strh r2, [r0] - bx lr diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 319ddb22..904074d6 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -15,11 +15,16 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DF38(void); void sub_0807DE80(Entity* entity); -void sub_0807DD80(Entity *param_1) +void sub_0807DD64(Entity* entity) { + entity->field_0xf = entity->animationState; + entity->animIndex = 0xff; + entity->field_0x80.HWORD = 0; + entity->field_0x82.HWORD = 0; +} -{ - sub_0807DB88(*(Entity**)¶m_1->cutsceneBeh); - sub_0807DD64(param_1); +void sub_0807DD80(Entity* entity) { + sub_0807DB88(*(Entity**)&entity->cutsceneBeh); + sub_0807DD64(entity); } void sub_0807DD94(Entity* entity, u32 param_2) { From 7ce43b9a690a7fd8e85cbef436cab73e33510173 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 14:59:55 +0100 Subject: [PATCH 12/51] matched sub_0807DD50 --- asm/code_0807CC3C.s | 11 ----------- src/code_0807CC3C.c | 5 +++++ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 924dfa2c..8a374b29 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1920,14 +1920,3 @@ _0807DD48: pop {r4, r5, r6, r7, pc} .align 2, 0 _0807DD4C: .4byte 0x0000FFDF - - thumb_func_start sub_0807DD50 -sub_0807DD50: @ 0x0807DD50 - push {r4, lr} - adds r4, r0, #0 - bl sub_0807DD64 - adds r0, r4, #0 - movs r1, #0 - bl sub_0807DD94 - pop {r4, pc} - .align 2, 0 diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 904074d6..d7e48487 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -15,6 +15,11 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DF38(void); void sub_0807DE80(Entity* entity); +void sub_0807DD50(Entity* entity) { + sub_0807DD64(entity); + sub_0807DD94(entity, 0); +} + void sub_0807DD64(Entity* entity) { entity->field_0xf = entity->animationState; entity->animIndex = 0xff; From f2855ee21a198af373f5bc162ecd5c8d1b9ee2e6 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 01:23:57 +0100 Subject: [PATCH 13/51] matched sub_0807DB98 --- asm/code_0807CC3C.s | 253 -------------------------------------------- src/code_0807CC3C.c | 78 ++++++++++++++ 2 files changed, 78 insertions(+), 253 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 8a374b29..43b15025 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1667,256 +1667,3 @@ sub_0807DB88: @ 0x0807DB88 bl _DmaZero str r5, [r4] pop {r4, r5, pc} - - thumb_func_start sub_0807DB98 -sub_0807DB98: @ 0x0807DB98 - push {r4, r5, r6, r7, lr} - adds r5, r0, #0 - adds r6, r1, #0 - ldr r0, [r6, #8] - cmp r0, #0 - bne _0807DBA6 - b _0807DD48 -_0807DBA6: - movs r7, #0 - adds r4, r5, #0 - adds r4, #0x82 -_0807DBAC: - ldr r1, [r6, #8] - mvns r0, r1 - adds r2, r0, #1 - ands r2, r1 - eors r1, r2 - str r1, [r6, #8] - movs r0, #0x80 - lsls r0, r0, #2 - cmp r2, r0 - bne _0807DBC2 - b _0807DCC8 -_0807DBC2: - cmp r2, r0 - bhi _0807DC04 - cmp r2, #0x10 - beq _0807DC82 - cmp r2, #0x10 - bhi _0807DBE8 - cmp r2, #2 - beq _0807DC70 - cmp r2, #2 - bhi _0807DBDC - cmp r2, #1 - beq _0807DC68 - b _0807DD40 -_0807DBDC: - cmp r2, #4 - bne _0807DBE2 - b _0807DD40 -_0807DBE2: - cmp r2, #8 - beq _0807DC7A - b _0807DD40 -_0807DBE8: - cmp r2, #0x40 - beq _0807DC9E - cmp r2, #0x40 - bhi _0807DBF6 - cmp r2, #0x20 - beq _0807DC90 - b _0807DD40 -_0807DBF6: - cmp r2, #0x80 - beq _0807DCA8 - movs r0, #0x80 - lsls r0, r0, #1 - cmp r2, r0 - beq _0807DCBA - b _0807DD40 -_0807DC04: - movs r0, #0x80 - lsls r0, r0, #7 - cmp r2, r0 - beq _0807DCFC - cmp r2, r0 - bhi _0807DC38 - movs r0, #0x80 - lsls r0, r0, #4 - cmp r2, r0 - beq _0807DCDE - cmp r2, r0 - bhi _0807DC26 - movs r0, #0x80 - lsls r0, r0, #3 - cmp r2, r0 - beq _0807DCD6 - b _0807DD40 -_0807DC26: - movs r0, #0x80 - lsls r0, r0, #5 - cmp r2, r0 - beq _0807DCE8 - movs r0, #0x80 - lsls r0, r0, #6 - cmp r2, r0 - beq _0807DCF4 - b _0807DD40 -_0807DC38: - movs r0, #0x80 - lsls r0, r0, #0xa - cmp r2, r0 - beq _0807DD14 - cmp r2, r0 - bhi _0807DC56 - movs r0, #0x80 - lsls r0, r0, #8 - cmp r2, r0 - beq _0807DD04 - movs r0, #0x80 - lsls r0, r0, #9 - cmp r2, r0 - beq _0807DD0C - b _0807DD40 -_0807DC56: - movs r0, #0x80 - lsls r0, r0, #0xb - cmp r2, r0 - beq _0807DD2E - movs r0, #0x80 - lsls r0, r0, #0xc - cmp r2, r0 - beq _0807DD36 - b _0807DD40 -_0807DC68: - adds r0, r5, #0 - adds r0, #0x80 - strh r7, [r0] - b _0807DD40 -_0807DC70: - adds r1, r5, #0 - adds r1, #0x80 - movs r0, #4 - strh r0, [r1] - b _0807DD40 -_0807DC7A: - movs r0, #0xc0 - lsls r0, r0, #9 - str r0, [r5, #0x20] - b _0807DD40 -_0807DC82: - adds r0, r5, #0 - movs r1, #8 - movs r2, #0x18 - rsbs r2, r2, #0 - bl CreateSpeechBubbleExclamationMark - b _0807DD40 -_0807DC90: - adds r0, r5, #0 - movs r1, #8 - movs r2, #0x18 - rsbs r2, r2, #0 - bl CreateSpeechBubbleQuestionMark - b _0807DD40 -_0807DC9E: - adds r0, r6, #0 - bl sub_0807DAC4 - bl DeleteThisEntity -_0807DCA8: - ldrb r0, [r5, #0x18] - movs r2, #4 - rsbs r2, r2, #0 - adds r1, r2, #0 - ands r0, r1 - movs r1, #1 - orrs r0, r1 - strb r0, [r5, #0x18] - b _0807DD40 -_0807DCBA: - ldrb r0, [r5, #0x18] - movs r3, #4 - rsbs r3, r3, #0 - adds r1, r3, #0 - ands r0, r1 - strb r0, [r5, #0x18] - b _0807DD40 -_0807DCC8: - adds r0, r5, #0 - adds r0, #0x63 - strb r7, [r0] - subs r0, #1 - strb r7, [r0] - strh r7, [r4] - b _0807DD40 -_0807DCD6: - ldrh r0, [r4] - movs r1, #2 - orrs r0, r1 - b _0807DD3E -_0807DCDE: - ldrh r0, [r4] - ldr r2, _0807DCE4 @ =0x0000FFFD - b _0807DD3A - .align 2, 0 -_0807DCE4: .4byte 0x0000FFFD -_0807DCE8: - ldrh r0, [r4] - ldr r3, _0807DCF0 @ =0x0000FFFE - adds r1, r3, #0 - b _0807DD3C - .align 2, 0 -_0807DCF0: .4byte 0x0000FFFE -_0807DCF4: - ldrh r0, [r4] - movs r1, #1 - orrs r0, r1 - b _0807DD3E -_0807DCFC: - ldrh r0, [r4] - movs r1, #8 - orrs r0, r1 - b _0807DD3E -_0807DD04: - ldrh r0, [r4] - movs r1, #4 - eors r0, r1 - b _0807DD3E -_0807DD0C: - ldrh r0, [r4] - movs r1, #0x10 - eors r0, r1 - b _0807DD3E -_0807DD14: - ldrb r2, [r5, #0x18] - lsls r0, r2, #0x19 - lsrs r0, r0, #0x1f - movs r1, #1 - eors r0, r1 - lsls r0, r0, #6 - movs r3, #0x41 - rsbs r3, r3, #0 - adds r1, r3, #0 - ands r2, r1 - orrs r2, r0 - strb r2, [r5, #0x18] - b _0807DD40 -_0807DD2E: - ldrh r0, [r4] - movs r1, #0x20 - orrs r0, r1 - b _0807DD3E -_0807DD36: - ldrh r0, [r4] - ldr r2, _0807DD4C @ =0x0000FFDF -_0807DD3A: - adds r1, r2, #0 -_0807DD3C: - ands r0, r1 -_0807DD3E: - strh r0, [r4] -_0807DD40: - ldr r0, [r6, #8] - cmp r0, #0 - beq _0807DD48 - b _0807DBAC -_0807DD48: - pop {r4, r5, r6, r7, pc} - .align 2, 0 -_0807DD4C: .4byte 0x0000FFDF diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index d7e48487..5cef7e15 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -7,11 +7,89 @@ extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; +extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); +extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); +extern void sub_0807DAC4(ScriptExecutionContext*); +extern void DeleteThisEntity(void); extern void sub_0807DB88(Entity*); extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern void _call_via_r6(Entity*, ScriptExecutionContext*); +void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) { + u32 switchVar; + + while (context->unk_08) { + switchVar = (~context->unk_08 + 1) & context->unk_08; + context->unk_08 ^= switchVar; + switch (switchVar) { + case 1: + entity->field_0x80.HWORD = 0; + break; + case 2: + entity->field_0x80.HWORD = 4; + break; + case 4: + break; + case 8: + entity->field_0x20 = 0x18000; + break; + case 0x10: + CreateSpeechBubbleExclamationMark(entity, 8, -0x18); + break; + case 0x20: + CreateSpeechBubbleQuestionMark(entity, 8, -0x18); + break; + case 0x40: + sub_0807DAC4(context); + DeleteThisEntity(); + case 0x80: + entity->spriteSettings.b.draw = 1; + break; + case 0x100: + entity->spriteSettings.b.draw = 0; + break; + case 0x200: + entity->spriteOffsetY = 0; + entity->spriteOffsetX = 0; + entity->field_0x82.HWORD = 0; + break; + case 0x400: + entity->field_0x82.HWORD |= 2; + break; + case 0x800: + entity->field_0x82.HWORD &= 0xfffd; + break; + case 0x1000: + entity->field_0x82.HWORD &= 0xfffe; + break; + case 0x2000: + entity->field_0x82.HWORD |= 1; + break; + case 0x4000: + entity->field_0x82.HWORD |= 8; + break; + case 0x8000: + entity->field_0x82.HWORD ^= 4; + break; + case 0x10000: + entity->field_0x82.HWORD ^= 0x10; + break; + case 0x20000: + entity->spriteSettings.b.flipX ^= 1; + break; + case 0x40000: + entity->field_0x82.HWORD |= 0x20; + break; + case 0x80000: + entity->field_0x82.HWORD &= 0xffdf; + break; + default: + break; + } + } +} + void sub_0807DF38(void); void sub_0807DE80(Entity* entity); From 2948cf8d07bf155ec4a6554e676e05d72df058fb Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 01:34:52 +0100 Subject: [PATCH 14/51] matched sub_0807DB88 --- asm/code_0807CC3C.s | 9 --------- src/code_0807CC3C.c | 10 +++++++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 43b15025..5715aa7b 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1658,12 +1658,3 @@ _0807DB84: adds r0, r2, #0 pop {r4, r5, pc} - thumb_func_start sub_0807DB88 -sub_0807DB88: @ 0x0807DB88 - push {r4, r5, lr} - adds r4, r0, #0 - adds r5, r1, #0 - movs r1, #0x24 - bl _DmaZero - str r5, [r4] - pop {r4, r5, pc} diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 5cef7e15..28cde049 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -11,11 +11,15 @@ extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); extern void sub_0807DAC4(ScriptExecutionContext*); extern void DeleteThisEntity(void); -extern void sub_0807DB88(Entity*); extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern void _call_via_r6(Entity*, ScriptExecutionContext*); +void sub_0807DB88(ScriptExecutionContext* context, u32 unk1) { + _DmaZero(context, 0x24); + context->unk_00 = (u16*)unk1; +} + void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) { u32 switchVar; @@ -105,8 +109,8 @@ void sub_0807DD64(Entity* entity) { entity->field_0x82.HWORD = 0; } -void sub_0807DD80(Entity* entity) { - sub_0807DB88(*(Entity**)&entity->cutsceneBeh); +void sub_0807DD80(Entity* entity, u32 unk1) { + sub_0807DB88(*(ScriptExecutionContext**)&entity->cutsceneBeh, unk1); sub_0807DD64(entity); } From a41cedf985af8e0791ca1dc27246ec787947073d Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 01:52:26 +0100 Subject: [PATCH 15/51] matched sub_0807DB68 --- asm/code_0807CC3C.s | 19 ------------------- src/code_0807CC3C.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 5715aa7b..593374d7 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1639,22 +1639,3 @@ _0807DB5C: .4byte gUnk_02022750 _0807DB60: .4byte gPlayerEntity _0807DB64: .4byte gPlayerState - thumb_func_start sub_0807DB68 -sub_0807DB68: @ 0x0807DB68 - push {r4, r5, lr} - adds r4, r0, #0 - adds r5, r1, #0 - bl sub_0807DAA0 - adds r2, r0, #0 - cmp r2, #0 - beq _0807DB84 - ldrb r1, [r4, #0x10] - movs r0, #2 - orrs r0, r1 - strb r0, [r4, #0x10] - str r2, [r4, #0x3c] - str r5, [r2] -_0807DB84: - adds r0, r2, #0 - pop {r4, r5, pc} - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 28cde049..4309cca4 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -15,6 +15,20 @@ extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern void _call_via_r6(Entity*, ScriptExecutionContext*); +extern u32* sub_0807DAA0(); + +u32* sub_0807DB68(Entity* entity, u32 unk1) { + u32* puVar1; + + puVar1 = sub_0807DAA0(); + if (puVar1) { + entity->flags |= 2; + *(u32**)&entity->field_0x3c = puVar1; + *puVar1 = unk1; + } + return puVar1; +} + void sub_0807DB88(ScriptExecutionContext* context, u32 unk1) { _DmaZero(context, 0x24); context->unk_00 = (u16*)unk1; From 945a3fe944239cad64ca7b38cf018efbbedbb616 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 02:24:26 +0100 Subject: [PATCH 16/51] matched StartPlayerScript --- asm/code_0807CC3C.s | 29 ----------------------------- src/code_0807CC3C.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 593374d7..14036c1a 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1610,32 +1610,3 @@ _0807DB28: pop {r4, r5, pc} .align 2, 0 - thumb_func_start StartPlayerScript -StartPlayerScript: @ 0x0807DB2C - push {r4, r5, lr} - adds r5, r0, #0 - ldr r4, _0807DB5C @ =gUnk_02022750 - adds r0, r4, #0 - movs r1, #0x24 - bl _DmaZero - str r5, [r4] - ldr r0, _0807DB60 @ =gPlayerEntity - adds r0, #0x84 - str r4, [r0] - ldr r2, _0807DB64 @ =gPlayerState - movs r1, #0 - movs r0, #0x1c - strb r0, [r2, #0xc] - adds r0, r2, #0 - adds r0, #0x3a - strb r1, [r0] - subs r0, #1 - strb r1, [r0] - subs r0, #1 - strb r1, [r0] - pop {r4, r5, pc} - .align 2, 0 -_0807DB5C: .4byte gUnk_02022750 -_0807DB60: .4byte gPlayerEntity -_0807DB64: .4byte gPlayerState - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 4309cca4..87c4775c 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -6,6 +6,8 @@ extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; +// the type is just a guess based on size and teh fact that these are around a lot in this file +extern ScriptExecutionContext gUnk_02022750; extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); @@ -17,6 +19,19 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); extern u32* sub_0807DAA0(); +void StartPlayerScript(u32 unk1) { + Entity* player; + + _DmaZero(&gUnk_02022750, 0x24); + gUnk_02022750.unk_00 = (u16*)unk1; + player = &gPlayerEntity; + *(ScriptExecutionContext**)&player->cutsceneBeh = &gUnk_02022750; + gPlayerState.playerAction = 0x1c; + gPlayerState.field_0x3a = 0; + gPlayerState.field_0x39 = 0; + gPlayerState.field_0x38 = 0; +} + u32* sub_0807DB68(Entity* entity, u32 unk1) { u32* puVar1; From 363efaaf86418ce583b46ae51e0d91d707b002d6 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 02:30:47 +0100 Subject: [PATCH 17/51] matched UnloadCutsceneData --- asm/code_0807CC3C.s | 21 --------------------- src/code_0807CC3C.c | 8 ++++++++ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 14036c1a..7e6930bc 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1589,24 +1589,3 @@ sub_0807DAF0: @ 0x0807DAF0 bl sub_0807DB88 pop {r4, pc} - thumb_func_start UnloadCutsceneData -UnloadCutsceneData: @ 0x0807DB08 - push {r4, r5, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x10] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _0807DB28 - movs r0, #0xfd - ands r0, r1 - movs r5, #0 - strb r0, [r4, #0x10] - adds r4, #0x84 - ldr r0, [r4] - bl sub_0807DAC4 - str r5, [r4] -_0807DB28: - pop {r4, r5, pc} - .align 2, 0 - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 87c4775c..54ed3e38 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -19,6 +19,14 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); extern u32* sub_0807DAA0(); +void UnloadCutsceneData(Entity* entity) { + if ((entity->flags & 2)) { + entity->flags = entity->flags & 0xfd; + sub_0807DAC4(*(ScriptExecutionContext**)&entity->cutsceneBeh); + *(ScriptExecutionContext**)&entity->cutsceneBeh = NULL; + } +} + void StartPlayerScript(u32 unk1) { Entity* player; From 38691d8e47e8a82e81bda6f2bcad1220a4870285 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 02:33:49 +0100 Subject: [PATCH 18/51] matched sub_0807DAF0 --- asm/code_0807CC3C.s | 14 -------------- src/code_0807CC3C.c | 7 +++++++ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 7e6930bc..aa61f8d0 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1575,17 +1575,3 @@ _0807DAEA: pop {r4, r5, r6, pc} .align 2, 0 - thumb_func_start sub_0807DAF0 -sub_0807DAF0: @ 0x0807DAF0 - push {r4, lr} - ldrb r4, [r0, #0x10] - movs r3, #2 - orrs r3, r4 - strb r3, [r0, #0x10] - adds r0, #0x84 - str r1, [r0] - adds r0, r1, #0 - adds r1, r2, #0 - bl sub_0807DB88 - pop {r4, pc} - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 54ed3e38..5765f9cf 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -17,8 +17,15 @@ extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern void _call_via_r6(Entity*, ScriptExecutionContext*); +void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); extern u32* sub_0807DAA0(); +void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1) { + entity->flags = entity->flags | 2; + *(ScriptExecutionContext**)&entity->cutsceneBeh = context; + sub_0807DB88(context, unk1); +} + void UnloadCutsceneData(Entity* entity) { if ((entity->flags & 2)) { entity->flags = entity->flags & 0xfd; From 7dffe8147d1178638d339cd825251b311967afb0 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 02:39:27 +0100 Subject: [PATCH 19/51] matched StartCutscene --- asm/code_0807CC3C.s | 18 ------------------ src/code_0807CC3C.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index aa61f8d0..21d02984 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1557,21 +1557,3 @@ sub_0807DAC4: @ 0x0807DAC4 pop {pc} .align 2, 0 - thumb_func_start StartCutscene -StartCutscene: @ 0x0807DAD0 - push {r4, r5, r6, lr} - adds r5, r0, #0 - adds r6, r1, #0 - bl sub_0807DAA0 - adds r4, r0, #0 - cmp r4, #0 - beq _0807DAEA - adds r0, r5, #0 - adds r1, r4, #0 - adds r2, r6, #0 - bl sub_0807DAF0 -_0807DAEA: - adds r0, r4, #0 - pop {r4, r5, r6, pc} - .align 2, 0 - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 5765f9cf..a9b57fe3 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -18,8 +18,19 @@ extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); +void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); extern u32* sub_0807DAA0(); +u32* StartCutscene(Entity* param_1, u8* param_2) { + ScriptExecutionContext* puVar1; + + puVar1 = (ScriptExecutionContext*)sub_0807DAA0(); + if (puVar1) { + sub_0807DAF0(param_1, puVar1, (u32)param_2); + } + return (u32*)puVar1; +} + void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1) { entity->flags = entity->flags | 2; *(ScriptExecutionContext**)&entity->cutsceneBeh = context; From be9c1b41314003a413697467256b437e31998216 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 02:40:55 +0100 Subject: [PATCH 20/51] matched sub_0807DAC4 --- asm/code_0807CC3C.s | 8 -------- src/code_0807CC3C.c | 5 ++++- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 21d02984..1cc3b632 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1549,11 +1549,3 @@ _0807DAC0: _0807DAC2: pop {pc} - thumb_func_start sub_0807DAC4 -sub_0807DAC4: @ 0x0807DAC4 - push {lr} - movs r1, #0x24 - bl _DmaZero - pop {pc} - .align 2, 0 - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index a9b57fe3..f84d40d1 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -11,7 +11,6 @@ extern ScriptExecutionContext gUnk_02022750; extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); -extern void sub_0807DAC4(ScriptExecutionContext*); extern void DeleteThisEntity(void); extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); @@ -21,6 +20,10 @@ void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); extern u32* sub_0807DAA0(); +void sub_0807DAC4(ScriptExecutionContext* context) { + _DmaZero(context, 0x24); +} + u32* StartCutscene(Entity* param_1, u8* param_2) { ScriptExecutionContext* puVar1; From ca6aece1f420a1ff6c5e4de1ad55e366457cd8ca Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 02:51:17 +0100 Subject: [PATCH 21/51] matched sub_0807DAA0 --- asm/code_0807CC3C.s | 23 ----------------------- src/code_0807CC3C.c | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 1cc3b632..a100f9de 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1526,26 +1526,3 @@ _0807DA94: .4byte gUnk_02033280 _0807DA98: .4byte gUnk_02036570 _0807DA9C: .4byte gUnk_02022750 - thumb_func_start sub_0807DAA0 -sub_0807DAA0: @ 0x0807DAA0 - push {lr} - ldr r1, _0807DABC @ =gUnk_02036570 - movs r0, #0x90 - lsls r0, r0, #3 - adds r2, r1, r0 -_0807DAAA: - ldr r0, [r1] - cmp r0, #0 - beq _0807DAC0 - adds r1, #0x24 - cmp r1, r2 - blo _0807DAAA - movs r0, #0 - b _0807DAC2 - .align 2, 0 -_0807DABC: .4byte gUnk_02036570 -_0807DAC0: - adds r0, r1, #0 -_0807DAC2: - pop {pc} - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index f84d40d1..cc65de3d 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -6,8 +6,10 @@ extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; -// the type is just a guess based on size and teh fact that these are around a lot in this file +// the type is just a guess based on size and the fact that these are around a lot in this file extern ScriptExecutionContext gUnk_02022750; +// might be ScriptExecutionContext[0x20] +extern u32 gUnk_02036570; extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); @@ -18,7 +20,19 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); -extern u32* sub_0807DAA0(); + +u32* sub_0807DAA0(void) { + u32* puVar1; + + puVar1 = &gUnk_02036570; + do { + if (*puVar1 == 0) { + return puVar1; + } + puVar1 = puVar1 + 9; + } while (puVar1 < &gUnk_02036570 + 0x480 / 4); + return NULL; +} void sub_0807DAC4(ScriptExecutionContext* context) { _DmaZero(context, 0x24); From 923ebb1a5009479ce11ddd95ba007a28c6c14e0f Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 03:00:38 +0100 Subject: [PATCH 22/51] matched sub_0807DA70 --- asm/code_0807CC3C.s | 22 ---------------------- src/code_0807CC3C.c | 7 +++++++ 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index a100f9de..ec76f03a 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1504,25 +1504,3 @@ _0807DA62: pop {r4, r5, r6, r7, pc} .align 2, 0 - thumb_func_start sub_0807DA70 -sub_0807DA70: @ 0x0807DA70 - push {r4, lr} - ldr r4, _0807DA94 @ =gUnk_02033280 - adds r0, r4, #0 - movs r1, #0xc - bl _DmaZero - ldr r0, _0807DA98 @ =gUnk_02036570 - movs r1, #0x90 - lsls r1, r1, #3 - bl _DmaZero - ldr r0, _0807DA9C @ =gUnk_02022750 - movs r1, #0x24 - bl _DmaZero - movs r0, #8 - strb r0, [r4, #8] - pop {r4, pc} - .align 2, 0 -_0807DA94: .4byte gUnk_02033280 -_0807DA98: .4byte gUnk_02036570 -_0807DA9C: .4byte gUnk_02022750 - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index cc65de3d..23b59b3c 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -21,6 +21,13 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +void sub_0807DA70(void) { + _DmaZero(&gUnk_02033280, 0xc); + _DmaZero(&gUnk_02036570, 0x480); + _DmaZero(&gUnk_02022750, 0x24); + gUnk_02033280.unk_08 = 8; +} + u32* sub_0807DAA0(void) { u32* puVar1; From ad68925eaeac3918a66f30ea26f7c7192d70d23c Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 08:25:28 +0100 Subject: [PATCH 23/51] non match sub_0807D6D8 --- asm/code_0807CC3C.s | 478 ----------------- .../code_0807CC3C/sub_0807D6D8.inc | 485 ++++++++++++++++++ src/code_0807CC3C.c | 5 + 3 files changed, 490 insertions(+), 478 deletions(-) create mode 100644 asm/non_matching/code_0807CC3C/sub_0807D6D8.inc diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index ec76f03a..b144a7a3 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -1026,481 +1026,3 @@ _0807D6CC: mov sl, r5 pop {r4, r5, r6, r7, pc} - thumb_func_start sub_0807D6D8 -sub_0807D6D8: @ 0x0807D6D8 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x44 - str r0, [sp] - str r1, [sp, #4] - ldr r5, _0807D8BC @ =gRoomControls - ldrh r0, [r5, #0x18] - cmp r0, #0 - bne _0807D6F2 - b _0807DA62 -_0807D6F2: - ldrh r0, [r5, #0x1a] - cmp r0, #0 - bne _0807D6FA - b _0807DA62 -_0807D6FA: - movs r1, #0xa - ldrsh r0, [r5, r1] - ldrh r1, [r5, #6] - subs r0, r0, r1 - movs r4, #0x10 - rsbs r4, r4, #0 - ands r0, r4 - str r0, [sp, #0x24] - ldr r3, [r5, #0x30] - movs r2, #0x2e - ldrsh r0, [r3, r2] - subs r0, r0, r1 - movs r2, #8 - rsbs r2, r2, #0 - ands r0, r2 - str r0, [sp, #0x14] - ldr r1, [sp, #0x24] - subs r0, r0, r1 - str r0, [sp, #0x1c] - movs r1, #0xc - ldrsh r0, [r5, r1] - ldrh r1, [r5, #8] - subs r0, r0, r1 - ands r0, r4 - str r0, [sp, #0x28] - movs r4, #0x32 - ldrsh r0, [r3, r4] - subs r0, r0, r1 - ands r0, r2 - str r0, [sp, #0x18] - ldr r1, [sp, #0x28] - subs r0, r0, r1 - str r0, [sp, #0x20] - ldrh r0, [r5, #0x18] - adds r2, r0, #0 - muls r2, r0, r2 - str r2, [sp, #0xc] - ldrh r3, [r5, #0x1a] - str r3, [sp, #8] - adds r4, r3, #0 - muls r4, r3, r4 - str r4, [sp, #0x10] - adds r4, r0, #0 - movs r0, #0 - mov sb, r0 - lsls r0, r4, #1 - rsbs r0, r0, #0 - adds r0, #1 - ldr r1, [sp, #0x10] - muls r0, r1, r0 - lsls r6, r2, #1 - adds r7, r0, r6 - adds r2, r4, #0 - muls r2, r1, r2 - mov r8, r2 - mov r0, r8 - ldr r1, [sp, #0xc] - bl __divsi3 - mov ip, r0 - cmp sb, ip - ble _0807D778 - b _0807D8D8 -_0807D778: - mov sl, r5 - ldr r3, [sp, #0xc] - adds r0, r6, r3 - lsls r0, r0, #1 - str r0, [sp, #0x3c] - mov r0, r8 - str r0, [sp, #0x40] - ldr r1, [sp, #0x14] - subs r1, r1, r4 - mov r8, r1 - ldr r2, [sp, #0x14] - adds r6, r4, r2 - movs r0, #0x80 - lsls r0, r0, #1 - ldr r3, [sp, #0x24] - adds r0, r3, r0 - str r0, [sp, #0x2c] -_0807D79A: - ldr r0, [sp, #0x28] - adds r0, #0xb0 - ldr r1, [sp, #0x18] - add r1, sb - cmp r0, r1 - ble _0807D812 - ldr r0, [sp, #0x20] - add r0, sb - asrs r0, r0, #3 - movs r5, #0x1f - ands r0, r5 - cmp r0, #0x1f - beq _0807D812 - lsls r0, r0, #6 - ldr r3, [sp, #4] - adds r2, r3, r0 - asrs r0, r1, #3 - lsls r0, r0, #8 - ldr r1, [sp] - adds r3, r1, r0 - ldr r0, [sp, #0x2c] - cmp r0, r6 - ble _0807D7EA - ldr r0, [sp, #0x1c] - adds r1, r0, r4 - asrs r1, r1, #3 - ands r1, r5 - lsls r1, r1, #1 - adds r1, r1, r2 - asrs r0, r6, #3 - lsls r0, r0, #1 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r1] - mov r1, sl - ldrh r0, [r1, #0x1c] - movs r1, #1 - orrs r0, r1 - mov r1, sl - strh r0, [r1, #0x1c] -_0807D7EA: - ldr r0, [sp, #0x24] - cmp r0, r8 - bge _0807D812 - ldr r0, [sp, #0x1c] - subs r1, r0, r4 - asrs r1, r1, #3 - ands r1, r5 - lsls r1, r1, #1 - adds r1, r1, r2 - mov r2, r8 - asrs r0, r2, #3 - lsls r0, r0, #1 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r1] - mov r3, sl - ldrh r0, [r3, #0x1c] - movs r1, #2 - orrs r0, r1 - strh r0, [r3, #0x1c] -_0807D812: - ldr r0, [sp, #0x18] - mov r2, sb - subs r1, r0, r2 - adds r0, r1, #0 - adds r0, #8 - ldr r3, [sp, #0x28] - cmp r3, r0 - bge _0807D88E - ldr r3, [sp, #0x20] - subs r0, r3, r2 - asrs r0, r0, #3 - movs r5, #0x1f - ands r0, r5 - cmp r0, #0x1f - beq _0807D88E - lsls r0, r0, #6 - ldr r3, [sp, #4] - adds r2, r3, r0 - asrs r0, r1, #3 - lsls r0, r0, #8 - ldr r1, [sp] - adds r3, r1, r0 - ldr r0, [sp, #0x2c] - cmp r0, r6 - ble _0807D866 - ldr r0, [sp, #0x1c] - adds r1, r0, r4 - asrs r1, r1, #3 - ands r1, r5 - lsls r1, r1, #1 - adds r1, r1, r2 - asrs r0, r6, #3 - lsls r0, r0, #1 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r1] - mov r1, sl - ldrh r0, [r1, #0x1c] - movs r1, #4 - orrs r0, r1 - mov r1, sl - strh r0, [r1, #0x1c] -_0807D866: - ldr r0, [sp, #0x24] - cmp r0, r8 - bge _0807D88E - ldr r0, [sp, #0x1c] - subs r1, r0, r4 - asrs r1, r1, #3 - ands r1, r5 - lsls r1, r1, #1 - adds r1, r1, r2 - mov r2, r8 - asrs r0, r2, #3 - lsls r0, r0, #1 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r1] - mov r3, sl - ldrh r0, [r3, #0x1c] - movs r1, #8 - orrs r0, r1 - strh r0, [r3, #0x1c] -_0807D88E: - cmp r7, #0 - ble _0807D8C0 - lsls r0, r4, #2 - rsbs r0, r0, #0 - adds r0, #4 - ldr r1, [sp, #0x10] - muls r0, r1, r0 - ldr r2, [sp, #0x3c] - adds r0, r0, r2 - adds r7, r7, r0 - ldr r3, [sp, #0x40] - subs r3, r3, r1 - str r3, [sp, #0x40] - movs r0, #1 - add r8, r0 - subs r6, #1 - subs r4, #1 - adds r0, r3, #0 - ldr r1, [sp, #0xc] - bl __divsi3 - mov ip, r0 - b _0807D8C4 - .align 2, 0 -_0807D8BC: .4byte gRoomControls -_0807D8C0: - ldr r1, [sp, #0x3c] - adds r7, r7, r1 -_0807D8C4: - ldr r2, [sp, #0xc] - lsls r0, r2, #2 - ldr r3, [sp, #0x3c] - adds r3, r3, r0 - str r3, [sp, #0x3c] - movs r0, #1 - add sb, r0 - cmp sb, ip - bgt _0807D8D8 - b _0807D79A -_0807D8D8: - movs r4, #0 - ldr r1, [sp, #8] - mov sb, r1 - ldr r2, [sp, #0x10] - lsls r6, r2, #1 - lsls r0, r1, #1 - rsbs r0, r0, #0 - adds r0, #1 - ldr r3, [sp, #0xc] - muls r0, r3, r0 - adds r7, r6, r0 - mov r5, sb - muls r5, r3, r5 - adds r0, r5, #0 - adds r1, r2, #0 - bl __divsi3 - mov ip, r0 - cmp r4, ip - ble _0807D902 - b _0807DA62 -_0807D902: - ldr r0, _0807DA40 @ =gRoomControls - mov sl, r0 - ldr r1, [sp, #0x10] - adds r0, r6, r1 - lsls r0, r0, #1 - str r0, [sp, #0x34] - ldr r6, [sp, #0x14] - mov r8, r6 - str r5, [sp, #0x38] - movs r3, #0x80 - lsls r3, r3, #1 - ldr r2, [sp, #0x24] - adds r3, r2, r3 - str r3, [sp, #0x30] -_0807D91E: - ldr r0, [sp, #0x28] - adds r0, #0xb0 - ldr r1, [sp, #0x18] - add r1, sb - cmp r0, r1 - ble _0807D996 - ldr r0, [sp, #0x20] - add r0, sb - asrs r0, r0, #3 - movs r5, #0x1f - ands r0, r5 - cmp r0, #0x1f - beq _0807D996 - lsls r0, r0, #6 - ldr r3, [sp, #4] - adds r2, r3, r0 - asrs r0, r1, #3 - lsls r0, r0, #8 - ldr r1, [sp] - adds r3, r1, r0 - ldr r0, [sp, #0x30] - cmp r0, r6 - ble _0807D96E - ldr r0, [sp, #0x1c] - adds r1, r0, r4 - asrs r1, r1, #3 - ands r1, r5 - lsls r1, r1, #1 - adds r1, r1, r2 - asrs r0, r6, #3 - lsls r0, r0, #1 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r1] - mov r1, sl - ldrh r0, [r1, #0x1c] - movs r1, #0x10 - orrs r0, r1 - mov r1, sl - strh r0, [r1, #0x1c] -_0807D96E: - ldr r0, [sp, #0x24] - cmp r0, r8 - bge _0807D996 - ldr r0, [sp, #0x1c] - subs r1, r0, r4 - asrs r1, r1, #3 - ands r1, r5 - lsls r1, r1, #1 - adds r1, r1, r2 - mov r2, r8 - asrs r0, r2, #3 - lsls r0, r0, #1 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r1] - mov r3, sl - ldrh r0, [r3, #0x1c] - movs r1, #0x20 - orrs r0, r1 - strh r0, [r3, #0x1c] -_0807D996: - ldr r0, [sp, #0x18] - mov r2, sb - subs r1, r0, r2 - adds r0, r1, #0 - adds r0, #8 - ldr r3, [sp, #0x28] - cmp r3, r0 - bge _0807DA12 - ldr r3, [sp, #0x20] - subs r0, r3, r2 - asrs r0, r0, #3 - movs r5, #0x1f - ands r0, r5 - cmp r0, #0x1f - beq _0807DA12 - lsls r0, r0, #6 - ldr r3, [sp, #4] - adds r2, r3, r0 - asrs r0, r1, #3 - lsls r0, r0, #8 - ldr r1, [sp] - adds r3, r1, r0 - ldr r0, [sp, #0x30] - cmp r0, r6 - ble _0807D9EA - ldr r0, [sp, #0x1c] - adds r1, r0, r4 - asrs r1, r1, #3 - ands r1, r5 - lsls r1, r1, #1 - adds r1, r1, r2 - asrs r0, r6, #3 - lsls r0, r0, #1 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r1] - mov r1, sl - ldrh r0, [r1, #0x1c] - movs r1, #0x40 - orrs r0, r1 - mov r1, sl - strh r0, [r1, #0x1c] -_0807D9EA: - ldr r0, [sp, #0x24] - cmp r0, r8 - bge _0807DA12 - ldr r0, [sp, #0x1c] - subs r1, r0, r4 - asrs r1, r1, #3 - ands r1, r5 - lsls r1, r1, #1 - adds r1, r1, r2 - mov r2, r8 - asrs r0, r2, #3 - lsls r0, r0, #1 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r1] - mov r3, sl - ldrh r0, [r3, #0x1c] - movs r1, #0x80 - orrs r0, r1 - strh r0, [r3, #0x1c] -_0807DA12: - cmp r7, #0 - ble _0807DA44 - mov r1, sb - lsls r0, r1, #2 - rsbs r0, r0, #0 - adds r0, #4 - ldr r2, [sp, #0xc] - muls r0, r2, r0 - ldr r3, [sp, #0x34] - adds r0, r3, r0 - adds r7, r7, r0 - ldr r0, [sp, #0x38] - subs r0, r0, r2 - str r0, [sp, #0x38] - movs r1, #1 - rsbs r1, r1, #0 - add sb, r1 - ldr r1, [sp, #0x10] - bl __divsi3 - mov ip, r0 - b _0807DA48 - .align 2, 0 -_0807DA40: .4byte gRoomControls -_0807DA44: - ldr r2, [sp, #0x34] - adds r7, r7, r2 -_0807DA48: - ldr r3, [sp, #0x10] - lsls r0, r3, #2 - ldr r1, [sp, #0x34] - adds r1, r1, r0 - str r1, [sp, #0x34] - movs r2, #1 - rsbs r2, r2, #0 - add r8, r2 - adds r6, #1 - adds r4, #1 - cmp r4, ip - bgt _0807DA62 - b _0807D91E -_0807DA62: - add sp, #0x44 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - diff --git a/asm/non_matching/code_0807CC3C/sub_0807D6D8.inc b/asm/non_matching/code_0807CC3C/sub_0807D6D8.inc new file mode 100644 index 00000000..de9559d3 --- /dev/null +++ b/asm/non_matching/code_0807CC3C/sub_0807D6D8.inc @@ -0,0 +1,485 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + push {r4, r5, r6, r7, lr} + mov r7, sl + mov r6, sb + mov r5, r8 + push {r5, r6, r7} + sub sp, #0x44 + str r0, [sp] + str r1, [sp, #4] + ldr r5, _0807D8BC @ =gRoomControls + ldrh r0, [r5, #0x18] + cmp r0, #0 + bne _0807D6F2 + b _0807DA62 +_0807D6F2: + ldrh r0, [r5, #0x1a] + cmp r0, #0 + bne _0807D6FA + b _0807DA62 +_0807D6FA: + movs r1, #0xa + ldrsh r0, [r5, r1] + ldrh r1, [r5, #6] + subs r0, r0, r1 + movs r4, #0x10 + rsbs r4, r4, #0 + ands r0, r4 + str r0, [sp, #0x24] + ldr r3, [r5, #0x30] + movs r2, #0x2e + ldrsh r0, [r3, r2] + subs r0, r0, r1 + movs r2, #8 + rsbs r2, r2, #0 + ands r0, r2 + str r0, [sp, #0x14] + ldr r1, [sp, #0x24] + subs r0, r0, r1 + str r0, [sp, #0x1c] + movs r1, #0xc + ldrsh r0, [r5, r1] + ldrh r1, [r5, #8] + subs r0, r0, r1 + ands r0, r4 + str r0, [sp, #0x28] + movs r4, #0x32 + ldrsh r0, [r3, r4] + subs r0, r0, r1 + ands r0, r2 + str r0, [sp, #0x18] + ldr r1, [sp, #0x28] + subs r0, r0, r1 + str r0, [sp, #0x20] + ldrh r0, [r5, #0x18] + adds r2, r0, #0 + muls r2, r0, r2 + str r2, [sp, #0xc] + ldrh r3, [r5, #0x1a] + str r3, [sp, #8] + adds r4, r3, #0 + muls r4, r3, r4 + str r4, [sp, #0x10] + adds r4, r0, #0 + movs r0, #0 + mov sb, r0 + lsls r0, r4, #1 + rsbs r0, r0, #0 + adds r0, #1 + ldr r1, [sp, #0x10] + muls r0, r1, r0 + lsls r6, r2, #1 + adds r7, r0, r6 + adds r2, r4, #0 + muls r2, r1, r2 + mov r8, r2 + mov r0, r8 + ldr r1, [sp, #0xc] + bl __divsi3 + mov ip, r0 + cmp sb, ip + ble _0807D778 + b _0807D8D8 +_0807D778: + mov sl, r5 + ldr r3, [sp, #0xc] + adds r0, r6, r3 + lsls r0, r0, #1 + str r0, [sp, #0x3c] + mov r0, r8 + str r0, [sp, #0x40] + ldr r1, [sp, #0x14] + subs r1, r1, r4 + mov r8, r1 + ldr r2, [sp, #0x14] + adds r6, r4, r2 + movs r0, #0x80 + lsls r0, r0, #1 + ldr r3, [sp, #0x24] + adds r0, r3, r0 + str r0, [sp, #0x2c] +_0807D79A: + ldr r0, [sp, #0x28] + adds r0, #0xb0 + ldr r1, [sp, #0x18] + add r1, sb + cmp r0, r1 + ble _0807D812 + ldr r0, [sp, #0x20] + add r0, sb + asrs r0, r0, #3 + movs r5, #0x1f + ands r0, r5 + cmp r0, #0x1f + beq _0807D812 + lsls r0, r0, #6 + ldr r3, [sp, #4] + adds r2, r3, r0 + asrs r0, r1, #3 + lsls r0, r0, #8 + ldr r1, [sp] + adds r3, r1, r0 + ldr r0, [sp, #0x2c] + cmp r0, r6 + ble _0807D7EA + ldr r0, [sp, #0x1c] + adds r1, r0, r4 + asrs r1, r1, #3 + ands r1, r5 + lsls r1, r1, #1 + adds r1, r1, r2 + asrs r0, r6, #3 + lsls r0, r0, #1 + adds r0, r0, r3 + ldrh r0, [r0] + strh r0, [r1] + mov r1, sl + ldrh r0, [r1, #0x1c] + movs r1, #1 + orrs r0, r1 + mov r1, sl + strh r0, [r1, #0x1c] +_0807D7EA: + ldr r0, [sp, #0x24] + cmp r0, r8 + bge _0807D812 + ldr r0, [sp, #0x1c] + subs r1, r0, r4 + asrs r1, r1, #3 + ands r1, r5 + lsls r1, r1, #1 + adds r1, r1, r2 + mov r2, r8 + asrs r0, r2, #3 + lsls r0, r0, #1 + adds r0, r0, r3 + ldrh r0, [r0] + strh r0, [r1] + mov r3, sl + ldrh r0, [r3, #0x1c] + movs r1, #2 + orrs r0, r1 + strh r0, [r3, #0x1c] +_0807D812: + ldr r0, [sp, #0x18] + mov r2, sb + subs r1, r0, r2 + adds r0, r1, #0 + adds r0, #8 + ldr r3, [sp, #0x28] + cmp r3, r0 + bge _0807D88E + ldr r3, [sp, #0x20] + subs r0, r3, r2 + asrs r0, r0, #3 + movs r5, #0x1f + ands r0, r5 + cmp r0, #0x1f + beq _0807D88E + lsls r0, r0, #6 + ldr r3, [sp, #4] + adds r2, r3, r0 + asrs r0, r1, #3 + lsls r0, r0, #8 + ldr r1, [sp] + adds r3, r1, r0 + ldr r0, [sp, #0x2c] + cmp r0, r6 + ble _0807D866 + ldr r0, [sp, #0x1c] + adds r1, r0, r4 + asrs r1, r1, #3 + ands r1, r5 + lsls r1, r1, #1 + adds r1, r1, r2 + asrs r0, r6, #3 + lsls r0, r0, #1 + adds r0, r0, r3 + ldrh r0, [r0] + strh r0, [r1] + mov r1, sl + ldrh r0, [r1, #0x1c] + movs r1, #4 + orrs r0, r1 + mov r1, sl + strh r0, [r1, #0x1c] +_0807D866: + ldr r0, [sp, #0x24] + cmp r0, r8 + bge _0807D88E + ldr r0, [sp, #0x1c] + subs r1, r0, r4 + asrs r1, r1, #3 + ands r1, r5 + lsls r1, r1, #1 + adds r1, r1, r2 + mov r2, r8 + asrs r0, r2, #3 + lsls r0, r0, #1 + adds r0, r0, r3 + ldrh r0, [r0] + strh r0, [r1] + mov r3, sl + ldrh r0, [r3, #0x1c] + movs r1, #8 + orrs r0, r1 + strh r0, [r3, #0x1c] +_0807D88E: + cmp r7, #0 + ble _0807D8C0 + lsls r0, r4, #2 + rsbs r0, r0, #0 + adds r0, #4 + ldr r1, [sp, #0x10] + muls r0, r1, r0 + ldr r2, [sp, #0x3c] + adds r0, r0, r2 + adds r7, r7, r0 + ldr r3, [sp, #0x40] + subs r3, r3, r1 + str r3, [sp, #0x40] + movs r0, #1 + add r8, r0 + subs r6, #1 + subs r4, #1 + adds r0, r3, #0 + ldr r1, [sp, #0xc] + bl __divsi3 + mov ip, r0 + b _0807D8C4 + .align 2, 0 +_0807D8BC: .4byte gRoomControls +_0807D8C0: + ldr r1, [sp, #0x3c] + adds r7, r7, r1 +_0807D8C4: + ldr r2, [sp, #0xc] + lsls r0, r2, #2 + ldr r3, [sp, #0x3c] + adds r3, r3, r0 + str r3, [sp, #0x3c] + movs r0, #1 + add sb, r0 + cmp sb, ip + bgt _0807D8D8 + b _0807D79A +_0807D8D8: + movs r4, #0 + ldr r1, [sp, #8] + mov sb, r1 + ldr r2, [sp, #0x10] + lsls r6, r2, #1 + lsls r0, r1, #1 + rsbs r0, r0, #0 + adds r0, #1 + ldr r3, [sp, #0xc] + muls r0, r3, r0 + adds r7, r6, r0 + mov r5, sb + muls r5, r3, r5 + adds r0, r5, #0 + adds r1, r2, #0 + bl __divsi3 + mov ip, r0 + cmp r4, ip + ble _0807D902 + b _0807DA62 +_0807D902: + ldr r0, _0807DA40 @ =gRoomControls + mov sl, r0 + ldr r1, [sp, #0x10] + adds r0, r6, r1 + lsls r0, r0, #1 + str r0, [sp, #0x34] + ldr r6, [sp, #0x14] + mov r8, r6 + str r5, [sp, #0x38] + movs r3, #0x80 + lsls r3, r3, #1 + ldr r2, [sp, #0x24] + adds r3, r2, r3 + str r3, [sp, #0x30] +_0807D91E: + ldr r0, [sp, #0x28] + adds r0, #0xb0 + ldr r1, [sp, #0x18] + add r1, sb + cmp r0, r1 + ble _0807D996 + ldr r0, [sp, #0x20] + add r0, sb + asrs r0, r0, #3 + movs r5, #0x1f + ands r0, r5 + cmp r0, #0x1f + beq _0807D996 + lsls r0, r0, #6 + ldr r3, [sp, #4] + adds r2, r3, r0 + asrs r0, r1, #3 + lsls r0, r0, #8 + ldr r1, [sp] + adds r3, r1, r0 + ldr r0, [sp, #0x30] + cmp r0, r6 + ble _0807D96E + ldr r0, [sp, #0x1c] + adds r1, r0, r4 + asrs r1, r1, #3 + ands r1, r5 + lsls r1, r1, #1 + adds r1, r1, r2 + asrs r0, r6, #3 + lsls r0, r0, #1 + adds r0, r0, r3 + ldrh r0, [r0] + strh r0, [r1] + mov r1, sl + ldrh r0, [r1, #0x1c] + movs r1, #0x10 + orrs r0, r1 + mov r1, sl + strh r0, [r1, #0x1c] +_0807D96E: + ldr r0, [sp, #0x24] + cmp r0, r8 + bge _0807D996 + ldr r0, [sp, #0x1c] + subs r1, r0, r4 + asrs r1, r1, #3 + ands r1, r5 + lsls r1, r1, #1 + adds r1, r1, r2 + mov r2, r8 + asrs r0, r2, #3 + lsls r0, r0, #1 + adds r0, r0, r3 + ldrh r0, [r0] + strh r0, [r1] + mov r3, sl + ldrh r0, [r3, #0x1c] + movs r1, #0x20 + orrs r0, r1 + strh r0, [r3, #0x1c] +_0807D996: + ldr r0, [sp, #0x18] + mov r2, sb + subs r1, r0, r2 + adds r0, r1, #0 + adds r0, #8 + ldr r3, [sp, #0x28] + cmp r3, r0 + bge _0807DA12 + ldr r3, [sp, #0x20] + subs r0, r3, r2 + asrs r0, r0, #3 + movs r5, #0x1f + ands r0, r5 + cmp r0, #0x1f + beq _0807DA12 + lsls r0, r0, #6 + ldr r3, [sp, #4] + adds r2, r3, r0 + asrs r0, r1, #3 + lsls r0, r0, #8 + ldr r1, [sp] + adds r3, r1, r0 + ldr r0, [sp, #0x30] + cmp r0, r6 + ble _0807D9EA + ldr r0, [sp, #0x1c] + adds r1, r0, r4 + asrs r1, r1, #3 + ands r1, r5 + lsls r1, r1, #1 + adds r1, r1, r2 + asrs r0, r6, #3 + lsls r0, r0, #1 + adds r0, r0, r3 + ldrh r0, [r0] + strh r0, [r1] + mov r1, sl + ldrh r0, [r1, #0x1c] + movs r1, #0x40 + orrs r0, r1 + mov r1, sl + strh r0, [r1, #0x1c] +_0807D9EA: + ldr r0, [sp, #0x24] + cmp r0, r8 + bge _0807DA12 + ldr r0, [sp, #0x1c] + subs r1, r0, r4 + asrs r1, r1, #3 + ands r1, r5 + lsls r1, r1, #1 + adds r1, r1, r2 + mov r2, r8 + asrs r0, r2, #3 + lsls r0, r0, #1 + adds r0, r0, r3 + ldrh r0, [r0] + strh r0, [r1] + mov r3, sl + ldrh r0, [r3, #0x1c] + movs r1, #0x80 + orrs r0, r1 + strh r0, [r3, #0x1c] +_0807DA12: + cmp r7, #0 + ble _0807DA44 + mov r1, sb + lsls r0, r1, #2 + rsbs r0, r0, #0 + adds r0, #4 + ldr r2, [sp, #0xc] + muls r0, r2, r0 + ldr r3, [sp, #0x34] + adds r0, r3, r0 + adds r7, r7, r0 + ldr r0, [sp, #0x38] + subs r0, r0, r2 + str r0, [sp, #0x38] + movs r1, #1 + rsbs r1, r1, #0 + add sb, r1 + ldr r1, [sp, #0x10] + bl __divsi3 + mov ip, r0 + b _0807DA48 + .align 2, 0 +_0807DA40: .4byte gRoomControls +_0807DA44: + ldr r2, [sp, #0x34] + adds r7, r7, r2 +_0807DA48: + ldr r3, [sp, #0x10] + lsls r0, r3, #2 + ldr r1, [sp, #0x34] + adds r1, r1, r0 + str r1, [sp, #0x34] + movs r2, #1 + rsbs r2, r2, #0 + add r8, r2 + adds r6, #1 + adds r4, #1 + cmp r4, ip + bgt _0807DA62 + b _0807D91E +_0807DA62: + add sp, #0x44 + pop {r3, r4, r5} + mov r8, r3 + mov sb, r4 + mov sl, r5 + pop {r4, r5, r6, r7, pc} + .align 2, 0 + + .syntax divided diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 23b59b3c..6bdb490d 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -16,11 +16,16 @@ extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); extern void DeleteThisEntity(void); extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); +extern s32 __divsi3(s32, s32); extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D6D8.inc", void sub_0807D6D8(u32 unk_1, u32 unk_2)){ +} +END_NONMATCH + void sub_0807DA70(void) { _DmaZero(&gUnk_02033280, 0xc); _DmaZero(&gUnk_02036570, 0x480); From 9230625aae371c1124fbfb6977e00b4e8fdb808a Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 08:32:11 +0100 Subject: [PATCH 24/51] non match sub_0807D46C --- asm/code_0807CC3C.s | 342 ----------------- .../code_0807CC3C/sub_0807D46C.inc | 347 ++++++++++++++++++ .../code_0807CC3C/sub_0807D6D8.inc | 3 - src/code_0807CC3C.c | 6 +- 4 files changed, 352 insertions(+), 346 deletions(-) create mode 100644 asm/non_matching/code_0807CC3C/sub_0807D46C.inc diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index b144a7a3..96b685f8 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -684,345 +684,3 @@ _0807D462: pop {r4, r5, r6, r7, pc} .align 2, 0 - thumb_func_start sub_0807D46C -sub_0807D46C: @ 0x0807D46C - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #8 - str r0, [sp] - str r1, [sp, #4] - ldr r0, _0807D494 @ =gRoomControls - ldrb r2, [r0, #0x10] - mov sb, r0 - cmp r2, #1 - bne _0807D488 - b _0807D5C4 -_0807D488: - cmp r2, #1 - bgt _0807D498 - cmp r2, #0 - beq _0807D4A4 - b _0807D6CC - .align 2, 0 -_0807D494: .4byte gRoomControls -_0807D498: - cmp r2, #2 - beq _0807D4A4 - cmp r2, #3 - bne _0807D4A2 - b _0807D5C4 -_0807D4A2: - b _0807D6CC -_0807D4A4: - mov r1, sb - movs r2, #0xa - ldrsh r0, [r1, r2] - ldrh r1, [r1, #6] - subs r5, r0, r1 - cmp r5, #7 - ble _0807D4B4 - subs r5, #8 -_0807D4B4: - mov r3, sb - ldr r0, [r3, #0x30] - movs r2, #0x2e - ldrsh r0, [r0, r2] - subs r0, r0, r1 - subs r3, r0, #4 - mov r8, r3 - cmp r3, #7 - ble _0807D4CA - subs r0, #0xc - mov r8, r0 -_0807D4CA: - mov r0, sb - movs r2, #0xc - ldrsh r1, [r0, r2] - ldrh r0, [r0, #8] - subs r1, r1, r0 - mov ip, r1 - cmp r1, #7 - ble _0807D4E0 - movs r3, #8 - rsbs r3, r3, #0 - add ip, r3 -_0807D4E0: - mov r1, sb - ldrh r0, [r1, #0x18] - lsls r0, r0, #3 - mov r2, r8 - subs r0, r2, r0 - adds r7, r5, #0 - adds r7, #0xf8 - cmp r0, r5 - blt _0807D548 - mov r1, ip - asrs r3, r1, #3 - lsls r1, r3, #8 - ldr r2, [sp] - adds r1, r2, r1 - asrs r0, r0, #3 - lsls r2, r0, #1 - adds r4, r1, r2 - movs r1, #0x1f - ands r0, r1 - lsls r0, r0, #1 - ldr r2, [sp, #4] - adds r6, r2, r0 - ands r3, r1 - lsls r2, r3, #5 - mov r3, sb - ldrh r0, [r3, #0x20] - lsls r1, r0, #0x10 - lsrs r0, r1, #0x10 - cmp r0, #0xaf - bhi _0807D520 - lsrs r3, r1, #0x13 - b _0807D522 -_0807D520: - movs r3, #0x16 -_0807D522: - adds r7, r5, #0 - adds r7, #0xf8 - cmp r3, #0 - ble _0807D548 - ldr r0, _0807D55C @ =0x000003FF - mov sl, r0 -_0807D52E: - lsls r0, r2, #1 - adds r0, r0, r6 - ldrh r1, [r4] - strh r1, [r0] - movs r1, #0x80 - lsls r1, r1, #1 - adds r4, r4, r1 - adds r2, #0x20 - mov r0, sl - ands r2, r0 - subs r3, #1 - cmp r3, #0 - bgt _0807D52E -_0807D548: - mov r1, sb - ldrh r0, [r1, #0x18] - adds r0, #1 - lsls r0, r0, #3 - add r0, r8 - ldrh r2, [r1, #0x1e] - cmp r7, r2 - blt _0807D560 - adds r1, r7, #0 - b _0807D566 - .align 2, 0 -_0807D55C: .4byte 0x000003FF -_0807D560: - movs r3, #0x80 - lsls r3, r3, #1 - adds r1, r5, r3 -_0807D566: - cmp r0, r1 - blt _0807D56C - b _0807D6CC -_0807D56C: - mov r1, ip - asrs r3, r1, #3 - lsls r1, r3, #8 - ldr r2, [sp] - adds r1, r2, r1 - asrs r0, r0, #3 - lsls r2, r0, #1 - adds r4, r1, r2 - movs r1, #0x1f - ands r0, r1 - lsls r0, r0, #1 - ldr r2, [sp, #4] - adds r6, r2, r0 - ands r3, r1 - lsls r2, r3, #5 - mov r3, sb - ldrh r0, [r3, #0x20] - lsls r1, r0, #0x10 - lsrs r0, r1, #0x10 - cmp r0, #0xaf - bhi _0807D59A - lsrs r3, r1, #0x13 - b _0807D59C -_0807D59A: - movs r3, #0x16 -_0807D59C: - cmp r3, #0 - bgt _0807D5A2 - b _0807D6CC -_0807D5A2: - movs r7, #0x80 - lsls r7, r7, #1 - ldr r5, _0807D5C0 @ =0x000003FF -_0807D5A8: - lsls r0, r2, #1 - adds r0, r0, r6 - ldrh r1, [r4] - strh r1, [r0] - adds r4, r4, r7 - adds r2, #0x20 - ands r2, r5 - subs r3, #1 - cmp r3, #0 - bgt _0807D5A8 - b _0807D6CC - .align 2, 0 -_0807D5C0: .4byte 0x000003FF -_0807D5C4: - mov r1, sb - movs r2, #0xc - ldrsh r0, [r1, r2] - ldrh r2, [r1, #8] - subs r5, r0, r2 - cmp r5, #7 - ble _0807D5D4 - subs r5, #8 -_0807D5D4: - mov r3, sb - movs r0, #0xa - ldrsh r1, [r3, r0] - ldrh r0, [r3, #6] - subs r1, r1, r0 - mov r8, r1 - cmp r1, #7 - ble _0807D5EA - movs r1, #8 - rsbs r1, r1, #0 - add r8, r1 -_0807D5EA: - mov r3, sb - ldr r0, [r3, #0x30] - movs r1, #0x32 - ldrsh r0, [r0, r1] - subs r0, r0, r2 - subs r2, r0, #4 - mov ip, r2 - cmp r2, #7 - ble _0807D600 - subs r0, #0xc - mov ip, r0 -_0807D600: - mov r3, sb - ldrh r0, [r3, #0x18] - lsls r0, r0, #3 - mov r1, ip - subs r0, r1, r0 - adds r7, r5, #0 - adds r7, #0xa8 - movs r2, #0xb0 - adds r2, r2, r5 - mov sl, r2 - cmp r0, r5 - blt _0807D66A - asrs r2, r0, #3 - lsls r0, r2, #8 - ldr r3, [sp] - adds r0, r3, r0 - mov r1, r8 - asrs r3, r1, #3 - lsls r1, r3, #1 - adds r4, r0, r1 - movs r0, #0x1f - ands r2, r0 - lsls r2, r2, #6 - ldr r1, [sp, #4] - adds r6, r1, r2 - adds r2, r0, #0 - ands r2, r3 - mov r3, sb - ldrh r0, [r3, #0x1e] - lsls r1, r0, #0x10 - lsrs r0, r1, #0x10 - cmp r0, #0xff - bhi _0807D646 - lsrs r3, r1, #0x13 - b _0807D648 -_0807D646: - movs r3, #0x20 -_0807D648: - adds r7, r5, #0 - adds r7, #0xa8 - adds r5, #0xb0 - mov sl, r5 - cmp r3, #0 - ble _0807D66A - movs r5, #0x1f -_0807D656: - lsls r0, r2, #1 - adds r0, r0, r6 - ldrh r1, [r4] - strh r1, [r0] - adds r4, #2 - adds r2, #1 - ands r2, r5 - subs r3, #1 - cmp r3, #0 - bgt _0807D656 -_0807D66A: - mov r1, sb - ldrh r0, [r1, #0x18] - adds r0, #1 - lsls r0, r0, #3 - add r0, ip - mov r2, sl - ldrh r1, [r1, #0x20] - cmp r7, r1 - blt _0807D67E - adds r2, r7, #0 -_0807D67E: - cmp r0, r2 - bge _0807D6CC - asrs r2, r0, #3 - lsls r0, r2, #8 - ldr r1, [sp] - adds r0, r1, r0 - mov r1, r8 - asrs r3, r1, #3 - lsls r1, r3, #1 - adds r4, r0, r1 - movs r0, #0x1f - ands r2, r0 - lsls r2, r2, #6 - ldr r1, [sp, #4] - adds r6, r1, r2 - adds r2, r0, #0 - ands r2, r3 - mov r3, sb - ldrh r0, [r3, #0x1e] - lsls r1, r0, #0x10 - lsrs r0, r1, #0x10 - cmp r0, #0xff - bhi _0807D6B0 - lsrs r3, r1, #0x13 - b _0807D6B2 -_0807D6B0: - movs r3, #0x20 -_0807D6B2: - cmp r3, #0 - ble _0807D6CC - movs r5, #0x1f -_0807D6B8: - lsls r0, r2, #1 - adds r0, r0, r6 - ldrh r1, [r4] - strh r1, [r0] - adds r4, #2 - adds r2, #1 - ands r2, r5 - subs r3, #1 - cmp r3, #0 - bgt _0807D6B8 -_0807D6CC: - add sp, #8 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7, pc} - diff --git a/asm/non_matching/code_0807CC3C/sub_0807D46C.inc b/asm/non_matching/code_0807CC3C/sub_0807D46C.inc new file mode 100644 index 00000000..bc6c9618 --- /dev/null +++ b/asm/non_matching/code_0807CC3C/sub_0807D46C.inc @@ -0,0 +1,347 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + push {r4, r5, r6, r7, lr} + mov r7, sl + mov r6, sb + mov r5, r8 + push {r5, r6, r7} + sub sp, #8 + str r0, [sp] + str r1, [sp, #4] + ldr r0, _0807D494 @ =gRoomControls + ldrb r2, [r0, #0x10] + mov sb, r0 + cmp r2, #1 + bne _0807D488 + b _0807D5C4 +_0807D488: + cmp r2, #1 + bgt _0807D498 + cmp r2, #0 + beq _0807D4A4 + b _0807D6CC + .align 2, 0 +_0807D494: .4byte gRoomControls +_0807D498: + cmp r2, #2 + beq _0807D4A4 + cmp r2, #3 + bne _0807D4A2 + b _0807D5C4 +_0807D4A2: + b _0807D6CC +_0807D4A4: + mov r1, sb + movs r2, #0xa + ldrsh r0, [r1, r2] + ldrh r1, [r1, #6] + subs r5, r0, r1 + cmp r5, #7 + ble _0807D4B4 + subs r5, #8 +_0807D4B4: + mov r3, sb + ldr r0, [r3, #0x30] + movs r2, #0x2e + ldrsh r0, [r0, r2] + subs r0, r0, r1 + subs r3, r0, #4 + mov r8, r3 + cmp r3, #7 + ble _0807D4CA + subs r0, #0xc + mov r8, r0 +_0807D4CA: + mov r0, sb + movs r2, #0xc + ldrsh r1, [r0, r2] + ldrh r0, [r0, #8] + subs r1, r1, r0 + mov ip, r1 + cmp r1, #7 + ble _0807D4E0 + movs r3, #8 + rsbs r3, r3, #0 + add ip, r3 +_0807D4E0: + mov r1, sb + ldrh r0, [r1, #0x18] + lsls r0, r0, #3 + mov r2, r8 + subs r0, r2, r0 + adds r7, r5, #0 + adds r7, #0xf8 + cmp r0, r5 + blt _0807D548 + mov r1, ip + asrs r3, r1, #3 + lsls r1, r3, #8 + ldr r2, [sp] + adds r1, r2, r1 + asrs r0, r0, #3 + lsls r2, r0, #1 + adds r4, r1, r2 + movs r1, #0x1f + ands r0, r1 + lsls r0, r0, #1 + ldr r2, [sp, #4] + adds r6, r2, r0 + ands r3, r1 + lsls r2, r3, #5 + mov r3, sb + ldrh r0, [r3, #0x20] + lsls r1, r0, #0x10 + lsrs r0, r1, #0x10 + cmp r0, #0xaf + bhi _0807D520 + lsrs r3, r1, #0x13 + b _0807D522 +_0807D520: + movs r3, #0x16 +_0807D522: + adds r7, r5, #0 + adds r7, #0xf8 + cmp r3, #0 + ble _0807D548 + ldr r0, _0807D55C @ =0x000003FF + mov sl, r0 +_0807D52E: + lsls r0, r2, #1 + adds r0, r0, r6 + ldrh r1, [r4] + strh r1, [r0] + movs r1, #0x80 + lsls r1, r1, #1 + adds r4, r4, r1 + adds r2, #0x20 + mov r0, sl + ands r2, r0 + subs r3, #1 + cmp r3, #0 + bgt _0807D52E +_0807D548: + mov r1, sb + ldrh r0, [r1, #0x18] + adds r0, #1 + lsls r0, r0, #3 + add r0, r8 + ldrh r2, [r1, #0x1e] + cmp r7, r2 + blt _0807D560 + adds r1, r7, #0 + b _0807D566 + .align 2, 0 +_0807D55C: .4byte 0x000003FF +_0807D560: + movs r3, #0x80 + lsls r3, r3, #1 + adds r1, r5, r3 +_0807D566: + cmp r0, r1 + blt _0807D56C + b _0807D6CC +_0807D56C: + mov r1, ip + asrs r3, r1, #3 + lsls r1, r3, #8 + ldr r2, [sp] + adds r1, r2, r1 + asrs r0, r0, #3 + lsls r2, r0, #1 + adds r4, r1, r2 + movs r1, #0x1f + ands r0, r1 + lsls r0, r0, #1 + ldr r2, [sp, #4] + adds r6, r2, r0 + ands r3, r1 + lsls r2, r3, #5 + mov r3, sb + ldrh r0, [r3, #0x20] + lsls r1, r0, #0x10 + lsrs r0, r1, #0x10 + cmp r0, #0xaf + bhi _0807D59A + lsrs r3, r1, #0x13 + b _0807D59C +_0807D59A: + movs r3, #0x16 +_0807D59C: + cmp r3, #0 + bgt _0807D5A2 + b _0807D6CC +_0807D5A2: + movs r7, #0x80 + lsls r7, r7, #1 + ldr r5, _0807D5C0 @ =0x000003FF +_0807D5A8: + lsls r0, r2, #1 + adds r0, r0, r6 + ldrh r1, [r4] + strh r1, [r0] + adds r4, r4, r7 + adds r2, #0x20 + ands r2, r5 + subs r3, #1 + cmp r3, #0 + bgt _0807D5A8 + b _0807D6CC + .align 2, 0 +_0807D5C0: .4byte 0x000003FF +_0807D5C4: + mov r1, sb + movs r2, #0xc + ldrsh r0, [r1, r2] + ldrh r2, [r1, #8] + subs r5, r0, r2 + cmp r5, #7 + ble _0807D5D4 + subs r5, #8 +_0807D5D4: + mov r3, sb + movs r0, #0xa + ldrsh r1, [r3, r0] + ldrh r0, [r3, #6] + subs r1, r1, r0 + mov r8, r1 + cmp r1, #7 + ble _0807D5EA + movs r1, #8 + rsbs r1, r1, #0 + add r8, r1 +_0807D5EA: + mov r3, sb + ldr r0, [r3, #0x30] + movs r1, #0x32 + ldrsh r0, [r0, r1] + subs r0, r0, r2 + subs r2, r0, #4 + mov ip, r2 + cmp r2, #7 + ble _0807D600 + subs r0, #0xc + mov ip, r0 +_0807D600: + mov r3, sb + ldrh r0, [r3, #0x18] + lsls r0, r0, #3 + mov r1, ip + subs r0, r1, r0 + adds r7, r5, #0 + adds r7, #0xa8 + movs r2, #0xb0 + adds r2, r2, r5 + mov sl, r2 + cmp r0, r5 + blt _0807D66A + asrs r2, r0, #3 + lsls r0, r2, #8 + ldr r3, [sp] + adds r0, r3, r0 + mov r1, r8 + asrs r3, r1, #3 + lsls r1, r3, #1 + adds r4, r0, r1 + movs r0, #0x1f + ands r2, r0 + lsls r2, r2, #6 + ldr r1, [sp, #4] + adds r6, r1, r2 + adds r2, r0, #0 + ands r2, r3 + mov r3, sb + ldrh r0, [r3, #0x1e] + lsls r1, r0, #0x10 + lsrs r0, r1, #0x10 + cmp r0, #0xff + bhi _0807D646 + lsrs r3, r1, #0x13 + b _0807D648 +_0807D646: + movs r3, #0x20 +_0807D648: + adds r7, r5, #0 + adds r7, #0xa8 + adds r5, #0xb0 + mov sl, r5 + cmp r3, #0 + ble _0807D66A + movs r5, #0x1f +_0807D656: + lsls r0, r2, #1 + adds r0, r0, r6 + ldrh r1, [r4] + strh r1, [r0] + adds r4, #2 + adds r2, #1 + ands r2, r5 + subs r3, #1 + cmp r3, #0 + bgt _0807D656 +_0807D66A: + mov r1, sb + ldrh r0, [r1, #0x18] + adds r0, #1 + lsls r0, r0, #3 + add r0, ip + mov r2, sl + ldrh r1, [r1, #0x20] + cmp r7, r1 + blt _0807D67E + adds r2, r7, #0 +_0807D67E: + cmp r0, r2 + bge _0807D6CC + asrs r2, r0, #3 + lsls r0, r2, #8 + ldr r1, [sp] + adds r0, r1, r0 + mov r1, r8 + asrs r3, r1, #3 + lsls r1, r3, #1 + adds r4, r0, r1 + movs r0, #0x1f + ands r2, r0 + lsls r2, r2, #6 + ldr r1, [sp, #4] + adds r6, r1, r2 + adds r2, r0, #0 + ands r2, r3 + mov r3, sb + ldrh r0, [r3, #0x1e] + lsls r1, r0, #0x10 + lsrs r0, r1, #0x10 + cmp r0, #0xff + bhi _0807D6B0 + lsrs r3, r1, #0x13 + b _0807D6B2 +_0807D6B0: + movs r3, #0x20 +_0807D6B2: + cmp r3, #0 + ble _0807D6CC + movs r5, #0x1f +_0807D6B8: + lsls r0, r2, #1 + adds r0, r0, r6 + ldrh r1, [r4] + strh r1, [r0] + adds r4, #2 + adds r2, #1 + ands r2, r5 + subs r3, #1 + cmp r3, #0 + bgt _0807D6B8 +_0807D6CC: + add sp, #8 + pop {r3, r4, r5} + mov r8, r3 + mov sb, r4 + mov sl, r5 + pop {r4, r5, r6, r7, pc} diff --git a/asm/non_matching/code_0807CC3C/sub_0807D6D8.inc b/asm/non_matching/code_0807CC3C/sub_0807D6D8.inc index de9559d3..2e4df6c5 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D6D8.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D6D8.inc @@ -1,6 +1,3 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" .syntax unified diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 6bdb490d..3b54ebbd 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -22,7 +22,11 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); -NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D6D8.inc", void sub_0807D6D8(u32 unk_1, u32 unk_2)){ +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D46C.inc", void sub_0807D46C(u32 unk_1, u32 unk_2)) { +} +END_NONMATCH + +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D6D8.inc", void sub_0807D6D8(u32 unk_1, u32 unk_2)) { } END_NONMATCH From b3e471e95a4bba71f66521011be61d9c4c8d6068 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 08:53:28 +0100 Subject: [PATCH 25/51] non match sub_0807D280 --- asm/code_0807CC3C.s | 260 ----------------- .../code_0807CC3C/sub_0807D280.inc | 265 ++++++++++++++++++ .../code_0807CC3C/sub_0807D46C.inc | 3 - src/code_0807CC3C.c | 4 + 4 files changed, 269 insertions(+), 263 deletions(-) create mode 100644 asm/non_matching/code_0807CC3C/sub_0807D280.inc diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 96b685f8..25c5f7f4 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -424,263 +424,3 @@ _0807D27C: pop {r4, r5, r6, pc} .align 2, 0 - thumb_func_start sub_0807D280 -sub_0807D280: @ 0x0807D280 - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r6, r0, #0 - adds r5, r1, #0 - ldr r1, _0807D2B0 @ =gRoomControls - movs r0, #0xa - ldrsh r2, [r1, r0] - ldrh r0, [r1, #6] - subs r3, r2, r0 - movs r0, #0xc - ldrsh r2, [r1, r0] - ldrh r0, [r1, #8] - subs r4, r2, r0 - ldrb r0, [r1, #0x10] - mov r8, r1 - cmp r0, #1 - beq _0807D330 - cmp r0, #1 - bgt _0807D2B4 - cmp r0, #0 - beq _0807D2BA - b _0807D404 - .align 2, 0 -_0807D2B0: .4byte gRoomControls -_0807D2B4: - cmp r0, #2 - beq _0807D3A0 - b _0807D404 -_0807D2BA: - mov r2, r8 - ldrh r1, [r2, #0x18] - movs r0, #3 - ands r0, r1 - cmp r0, #1 - beq _0807D2C8 - b _0807D462 -_0807D2C8: - movs r2, #0x1c - asrs r3, r3, #4 - mov sb, r3 - movs r3, #0x40 - adds r3, r3, r5 - mov ip, r3 - ldr r4, _0807D328 @ =0x040000D4 - ldr r7, _0807D32C @ =0x80000020 - movs r0, #0xe8 - lsls r0, r0, #3 - adds r3, r5, r0 - subs r0, #0x80 - adds r1, r5, r0 -_0807D2E2: - str r1, [r4] - str r3, [r4, #4] - str r7, [r4, #8] - ldr r0, [r4, #8] - subs r3, #0x40 - subs r1, #0x40 - subs r2, #1 - cmp r2, #0 - bgt _0807D2E2 - mov r1, r8 - ldrh r0, [r1, #0x20] - lsrs r0, r0, #4 - subs r0, #1 - ldrh r1, [r1, #0x18] - lsrs r1, r1, #2 - subs r0, r0, r1 - lsls r0, r0, #8 - mov r2, sb - lsls r1, r2, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - adds r6, r6, r0 - ldr r0, _0807D328 @ =0x040000D4 - str r6, [r0] - str r5, [r0, #4] - ldr r2, _0807D32C @ =0x80000020 - str r2, [r0, #8] - ldr r1, [r0, #8] - movs r3, #0x80 - lsls r3, r3, #1 - adds r1, r6, r3 - str r1, [r0] - mov r1, ip - b _0807D3F0 - .align 2, 0 -_0807D328: .4byte 0x040000D4 -_0807D32C: .4byte 0x80000020 -_0807D330: - mov r2, r8 - ldrh r3, [r2, #0x18] - movs r0, #3 - ands r0, r3 - cmp r0, #0 - beq _0807D33E - b _0807D462 -_0807D33E: - asrs r7, r4, #4 - movs r0, #0x3c - adds r0, r0, r5 - mov sb, r0 - cmp r3, #0 - beq _0807D36A - ldr r4, _0807D398 @ =0x040000D4 - ldr r1, _0807D39C @ =0x8000001E - mov ip, r1 - adds r3, r5, #4 - adds r1, r5, #0 - movs r2, #0x15 -_0807D356: - str r3, [r4] - str r1, [r4, #4] - mov r0, ip - str r0, [r4, #8] - ldr r0, [r4, #8] - adds r3, #0x40 - adds r1, #0x40 - subs r2, #1 - cmp r2, #0 - bge _0807D356 -_0807D36A: - lsls r1, r7, #8 - mov r2, r8 - ldrh r0, [r2, #0x18] - lsrs r0, r0, #2 - lsls r0, r0, #1 - adds r1, r1, r0 - lsls r1, r1, #1 - adds r6, r6, r1 - mov r5, sb - movs r1, #0x80 - lsls r1, r1, #1 - movs r2, #0x15 -_0807D382: - ldrh r0, [r6] - strh r0, [r5] - ldrh r0, [r6, #2] - strh r0, [r5, #2] - adds r5, #0x40 - adds r6, r6, r1 - subs r2, #1 - cmp r2, #0 - bge _0807D382 - b _0807D462 - .align 2, 0 -_0807D398: .4byte 0x040000D4 -_0807D39C: .4byte 0x8000001E -_0807D3A0: - mov r0, r8 - ldrh r1, [r0, #0x18] - movs r0, #3 - ands r0, r1 - cmp r0, #0 - bne _0807D462 - lsls r2, r1, #0x10 - cmp r2, #0 - beq _0807D3C2 - ldr r1, _0807D3F8 @ =0x040000D4 - adds r0, r5, #0 - adds r0, #0x80 - str r0, [r1] - str r5, [r1, #4] - ldr r0, _0807D3FC @ =0x800003C0 - str r0, [r1, #8] - ldr r0, [r1, #8] -_0807D3C2: - lsrs r0, r2, #0x12 - lsls r0, r0, #8 - asrs r1, r3, #4 - lsls r1, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - adds r6, r6, r0 - ldr r0, _0807D3F8 @ =0x040000D4 - str r6, [r0] - movs r2, #0xa0 - lsls r2, r2, #3 - adds r1, r5, r2 - str r1, [r0, #4] - ldr r2, _0807D400 @ =0x80000020 - str r2, [r0, #8] - ldr r1, [r0, #8] - movs r3, #0x80 - lsls r3, r3, #1 - adds r1, r6, r3 - str r1, [r0] - movs r3, #0xa8 - lsls r3, r3, #3 - adds r1, r5, r3 -_0807D3F0: - str r1, [r0, #4] - str r2, [r0, #8] - ldr r0, [r0, #8] - b _0807D462 - .align 2, 0 -_0807D3F8: .4byte 0x040000D4 -_0807D3FC: .4byte 0x800003C0 -_0807D400: .4byte 0x80000020 -_0807D404: - mov r0, r8 - ldrh r1, [r0, #0x18] - movs r0, #3 - ands r0, r1 - cmp r0, #1 - bne _0807D462 - movs r2, #0 - asrs r7, r4, #4 - mov ip, r5 -_0807D416: - movs r1, #0x1d - mov r3, ip - adds r3, #0x3a -_0807D41C: - ldrh r0, [r3] - strh r0, [r3, #4] - subs r3, #2 - subs r1, #1 - cmp r1, #0 - bge _0807D41C - movs r1, #0x40 - add ip, r1 - adds r2, #1 - cmp r2, #0x15 - ble _0807D416 - lsls r0, r7, #8 - mov r2, r8 - ldrh r1, [r2, #0x1e] - lsrs r1, r1, #4 - subs r1, #1 - ldrh r2, [r2, #0x18] - lsrs r2, r2, #2 - subs r1, r1, r2 - lsls r1, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - adds r6, r6, r0 - movs r1, #0x80 - lsls r1, r1, #1 - movs r2, #0x15 -_0807D450: - ldrh r0, [r6] - strh r0, [r5] - ldrh r0, [r6, #2] - strh r0, [r5, #2] - adds r5, #0x40 - adds r6, r6, r1 - subs r2, #1 - cmp r2, #0 - bge _0807D450 -_0807D462: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - diff --git a/asm/non_matching/code_0807CC3C/sub_0807D280.inc b/asm/non_matching/code_0807CC3C/sub_0807D280.inc new file mode 100644 index 00000000..152e93de --- /dev/null +++ b/asm/non_matching/code_0807CC3C/sub_0807D280.inc @@ -0,0 +1,265 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + push {r4, r5, r6, r7, lr} + mov r7, sb + mov r6, r8 + push {r6, r7} + adds r6, r0, #0 + adds r5, r1, #0 + ldr r1, _0807D2B0 @ =gRoomControls + movs r0, #0xa + ldrsh r2, [r1, r0] + ldrh r0, [r1, #6] + subs r3, r2, r0 + movs r0, #0xc + ldrsh r2, [r1, r0] + ldrh r0, [r1, #8] + subs r4, r2, r0 + ldrb r0, [r1, #0x10] + mov r8, r1 + cmp r0, #1 + beq _0807D330 + cmp r0, #1 + bgt _0807D2B4 + cmp r0, #0 + beq _0807D2BA + b _0807D404 + .align 2, 0 +_0807D2B0: .4byte gRoomControls +_0807D2B4: + cmp r0, #2 + beq _0807D3A0 + b _0807D404 +_0807D2BA: + mov r2, r8 + ldrh r1, [r2, #0x18] + movs r0, #3 + ands r0, r1 + cmp r0, #1 + beq _0807D2C8 + b _0807D462 +_0807D2C8: + movs r2, #0x1c + asrs r3, r3, #4 + mov sb, r3 + movs r3, #0x40 + adds r3, r3, r5 + mov ip, r3 + ldr r4, _0807D328 @ =0x040000D4 + ldr r7, _0807D32C @ =0x80000020 + movs r0, #0xe8 + lsls r0, r0, #3 + adds r3, r5, r0 + subs r0, #0x80 + adds r1, r5, r0 +_0807D2E2: + str r1, [r4] + str r3, [r4, #4] + str r7, [r4, #8] + ldr r0, [r4, #8] + subs r3, #0x40 + subs r1, #0x40 + subs r2, #1 + cmp r2, #0 + bgt _0807D2E2 + mov r1, r8 + ldrh r0, [r1, #0x20] + lsrs r0, r0, #4 + subs r0, #1 + ldrh r1, [r1, #0x18] + lsrs r1, r1, #2 + subs r0, r0, r1 + lsls r0, r0, #8 + mov r2, sb + lsls r1, r2, #1 + adds r0, r0, r1 + lsls r0, r0, #1 + adds r6, r6, r0 + ldr r0, _0807D328 @ =0x040000D4 + str r6, [r0] + str r5, [r0, #4] + ldr r2, _0807D32C @ =0x80000020 + str r2, [r0, #8] + ldr r1, [r0, #8] + movs r3, #0x80 + lsls r3, r3, #1 + adds r1, r6, r3 + str r1, [r0] + mov r1, ip + b _0807D3F0 + .align 2, 0 +_0807D328: .4byte 0x040000D4 +_0807D32C: .4byte 0x80000020 +_0807D330: + mov r2, r8 + ldrh r3, [r2, #0x18] + movs r0, #3 + ands r0, r3 + cmp r0, #0 + beq _0807D33E + b _0807D462 +_0807D33E: + asrs r7, r4, #4 + movs r0, #0x3c + adds r0, r0, r5 + mov sb, r0 + cmp r3, #0 + beq _0807D36A + ldr r4, _0807D398 @ =0x040000D4 + ldr r1, _0807D39C @ =0x8000001E + mov ip, r1 + adds r3, r5, #4 + adds r1, r5, #0 + movs r2, #0x15 +_0807D356: + str r3, [r4] + str r1, [r4, #4] + mov r0, ip + str r0, [r4, #8] + ldr r0, [r4, #8] + adds r3, #0x40 + adds r1, #0x40 + subs r2, #1 + cmp r2, #0 + bge _0807D356 +_0807D36A: + lsls r1, r7, #8 + mov r2, r8 + ldrh r0, [r2, #0x18] + lsrs r0, r0, #2 + lsls r0, r0, #1 + adds r1, r1, r0 + lsls r1, r1, #1 + adds r6, r6, r1 + mov r5, sb + movs r1, #0x80 + lsls r1, r1, #1 + movs r2, #0x15 +_0807D382: + ldrh r0, [r6] + strh r0, [r5] + ldrh r0, [r6, #2] + strh r0, [r5, #2] + adds r5, #0x40 + adds r6, r6, r1 + subs r2, #1 + cmp r2, #0 + bge _0807D382 + b _0807D462 + .align 2, 0 +_0807D398: .4byte 0x040000D4 +_0807D39C: .4byte 0x8000001E +_0807D3A0: + mov r0, r8 + ldrh r1, [r0, #0x18] + movs r0, #3 + ands r0, r1 + cmp r0, #0 + bne _0807D462 + lsls r2, r1, #0x10 + cmp r2, #0 + beq _0807D3C2 + ldr r1, _0807D3F8 @ =0x040000D4 + adds r0, r5, #0 + adds r0, #0x80 + str r0, [r1] + str r5, [r1, #4] + ldr r0, _0807D3FC @ =0x800003C0 + str r0, [r1, #8] + ldr r0, [r1, #8] +_0807D3C2: + lsrs r0, r2, #0x12 + lsls r0, r0, #8 + asrs r1, r3, #4 + lsls r1, r1, #1 + adds r0, r0, r1 + lsls r0, r0, #1 + adds r6, r6, r0 + ldr r0, _0807D3F8 @ =0x040000D4 + str r6, [r0] + movs r2, #0xa0 + lsls r2, r2, #3 + adds r1, r5, r2 + str r1, [r0, #4] + ldr r2, _0807D400 @ =0x80000020 + str r2, [r0, #8] + ldr r1, [r0, #8] + movs r3, #0x80 + lsls r3, r3, #1 + adds r1, r6, r3 + str r1, [r0] + movs r3, #0xa8 + lsls r3, r3, #3 + adds r1, r5, r3 +_0807D3F0: + str r1, [r0, #4] + str r2, [r0, #8] + ldr r0, [r0, #8] + b _0807D462 + .align 2, 0 +_0807D3F8: .4byte 0x040000D4 +_0807D3FC: .4byte 0x800003C0 +_0807D400: .4byte 0x80000020 +_0807D404: + mov r0, r8 + ldrh r1, [r0, #0x18] + movs r0, #3 + ands r0, r1 + cmp r0, #1 + bne _0807D462 + movs r2, #0 + asrs r7, r4, #4 + mov ip, r5 +_0807D416: + movs r1, #0x1d + mov r3, ip + adds r3, #0x3a +_0807D41C: + ldrh r0, [r3] + strh r0, [r3, #4] + subs r3, #2 + subs r1, #1 + cmp r1, #0 + bge _0807D41C + movs r1, #0x40 + add ip, r1 + adds r2, #1 + cmp r2, #0x15 + ble _0807D416 + lsls r0, r7, #8 + mov r2, r8 + ldrh r1, [r2, #0x1e] + lsrs r1, r1, #4 + subs r1, #1 + ldrh r2, [r2, #0x18] + lsrs r2, r2, #2 + subs r1, r1, r2 + lsls r1, r1, #1 + adds r0, r0, r1 + lsls r0, r0, #1 + adds r6, r6, r0 + movs r1, #0x80 + lsls r1, r1, #1 + movs r2, #0x15 +_0807D450: + ldrh r0, [r6] + strh r0, [r5] + ldrh r0, [r6, #2] + strh r0, [r5, #2] + adds r5, #0x40 + adds r6, r6, r1 + subs r2, #1 + cmp r2, #0 + bge _0807D450 +_0807D462: + pop {r3, r4} + mov r8, r3 + mov sb, r4 + pop {r4, r5, r6, r7, pc} + .align 2, 0 diff --git a/asm/non_matching/code_0807CC3C/sub_0807D46C.inc b/asm/non_matching/code_0807CC3C/sub_0807D46C.inc index bc6c9618..b3696327 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D46C.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D46C.inc @@ -1,6 +1,3 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" .syntax unified diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 3b54ebbd..eec65bda 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -22,6 +22,10 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D280.inc", void sub_0807D280(u32 unk_1, u32 unk_2)) { +} +END_NONMATCH + NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D46C.inc", void sub_0807D46C(u32 unk_1, u32 unk_2)) { } END_NONMATCH From d067c16b37808306c467056cd36021c188e7aebe Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 17:32:38 +0100 Subject: [PATCH 26/51] nonmatch sub_0807D24C --- asm/code_0807CC3C.s | 32 ---------------- .../code_0807CC3C/sub_0807D24C.inc | 37 +++++++++++++++++++ .../code_0807CC3C/sub_0807D280.inc | 3 -- src/code_0807CC3C.c | 16 ++++++++ 4 files changed, 53 insertions(+), 35 deletions(-) create mode 100644 asm/non_matching/code_0807CC3C/sub_0807D24C.inc diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 25c5f7f4..79a61fd0 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -392,35 +392,3 @@ _0807D242: _0807D24A: pop {r4, r5, r6, r7, pc} - thumb_func_start sub_0807D24C -sub_0807D24C: @ 0x0807D24C - push {r4, r5, r6, lr} - adds r5, r0, #0 - adds r6, r1, #0 - lsrs r4, r2, #3 - adds r0, r4, #0 - lsrs r5, r5, #3 - b _0807D274 -_0807D25A: - lsls r0, r5, #0x10 - lsrs r0, r0, #0x10 - adds r1, r6, #0 - bl sub_080B180C - lsls r0, r0, #0x10 - cmp r0, #0 - beq _0807D26E - movs r0, #0 - b _0807D27C -_0807D26E: - adds r5, #1 - adds r6, #8 - adds r0, r4, #0 -_0807D274: - subs r4, #1 - cmp r0, #0 - bne _0807D25A - movs r0, #1 -_0807D27C: - pop {r4, r5, r6, pc} - .align 2, 0 - diff --git a/asm/non_matching/code_0807CC3C/sub_0807D24C.inc b/asm/non_matching/code_0807CC3C/sub_0807D24C.inc new file mode 100644 index 00000000..cc91ceb6 --- /dev/null +++ b/asm/non_matching/code_0807CC3C/sub_0807D24C.inc @@ -0,0 +1,37 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + push {r4, r5, r6, lr} + adds r5, r0, #0 + adds r6, r1, #0 + lsrs r4, r2, #3 + adds r0, r4, #0 + lsrs r5, r5, #3 + b _0807D274 +_0807D25A: + lsls r0, r5, #0x10 + lsrs r0, r0, #0x10 + adds r1, r6, #0 + bl sub_080B180C + lsls r0, r0, #0x10 + cmp r0, #0 + beq _0807D26E + movs r0, #0 + b _0807D27C +_0807D26E: + adds r5, #1 + adds r6, #8 + adds r0, r4, #0 +_0807D274: + subs r4, #1 + cmp r0, #0 + bne _0807D25A + movs r0, #1 +_0807D27C: + pop {r4, r5, r6, pc} + .align 2, 0 diff --git a/asm/non_matching/code_0807CC3C/sub_0807D280.inc b/asm/non_matching/code_0807CC3C/sub_0807D280.inc index 152e93de..a9d083ae 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D280.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D280.inc @@ -1,6 +1,3 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" .syntax unified diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index eec65bda..74b38de7 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -14,6 +14,7 @@ extern u32 gUnk_02036570; extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); extern void DeleteThisEntity(void); +extern u32 sub_080B180C(u32, const char*); extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern s32 __divsi3(s32, s32); @@ -22,6 +23,21 @@ extern void _call_via_r6(Entity*, ScriptExecutionContext*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +// this is wrong by basically one instruction in the wrong place +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D24C.inc", u32 sub_0807D24C(u32 unk_1, const char* unk_2, u32 unk_3)) { + unk_3 >>= 3; + unk_1 >>= 3; + while (unk_3-- > 0) { + if (sub_080B180C(unk_1, unk_2)) + return 0; + unk_1++; + unk_2 += 4; + } + return 1; +} +END_NONMATCH + +// these three functions use gRoomControls, maybe once that is understood better, these can be decompiled easier NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D280.inc", void sub_0807D280(u32 unk_1, u32 unk_2)) { } END_NONMATCH From 7faadfd5226090b2eaf2cf1445970413f811be1e Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 18:02:17 +0100 Subject: [PATCH 27/51] nonmatch sub_0807D20C --- asm/code_0807CC3C.s | 37 ---------------- .../code_0807CC3C/sub_0807D20C.inc | 42 +++++++++++++++++++ .../code_0807CC3C/sub_0807D24C.inc | 3 -- include/functions.h | 2 +- src/code_0807CC3C.c | 20 ++++++++- 5 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 asm/non_matching/code_0807CC3C/sub_0807D20C.inc diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 79a61fd0..11b495f8 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -355,40 +355,3 @@ _0807D208: pop {r4, r5, r6, pc} .align 2, 0 - thumb_func_start sub_0807D20C -sub_0807D20C: @ 0x0807D20C - push {r4, r5, r6, r7, lr} - adds r6, r0, #0 - adds r7, r1, #0 - lsrs r5, r2, #3 - adds r0, r5, #0 - lsrs r6, r6, #3 - b _0807D242 -_0807D21A: - lsls r0, r6, #0x10 - lsrs r4, r0, #0x10 - adds r0, r4, #0 - adds r1, r7, #0 - bl sub_080B18DC - lsls r0, r0, #0x10 - cmp r0, #0 - beq _0807D23C - adds r0, r4, #0 - ldr r1, _0807D238 @ =gUnk_0811E4B4 - bl sub_080B18DC - movs r0, #0 - b _0807D24A - .align 2, 0 -_0807D238: .4byte gUnk_0811E4B4 -_0807D23C: - adds r6, #1 - adds r7, #8 - adds r0, r5, #0 -_0807D242: - subs r5, #1 - cmp r0, #0 - bne _0807D21A - movs r0, #1 -_0807D24A: - pop {r4, r5, r6, r7, pc} - diff --git a/asm/non_matching/code_0807CC3C/sub_0807D20C.inc b/asm/non_matching/code_0807CC3C/sub_0807D20C.inc new file mode 100644 index 00000000..31a81d5b --- /dev/null +++ b/asm/non_matching/code_0807CC3C/sub_0807D20C.inc @@ -0,0 +1,42 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + push {r4, r5, r6, r7, lr} + adds r6, r0, #0 + adds r7, r1, #0 + lsrs r5, r2, #3 + adds r0, r5, #0 + lsrs r6, r6, #3 + b _0807D242 +_0807D21A: + lsls r0, r6, #0x10 + lsrs r4, r0, #0x10 + adds r0, r4, #0 + adds r1, r7, #0 + bl sub_080B18DC + lsls r0, r0, #0x10 + cmp r0, #0 + beq _0807D23C + adds r0, r4, #0 + ldr r1, _0807D238 @ =gUnk_0811E4B4 + bl sub_080B18DC + movs r0, #0 + b _0807D24A + .align 2, 0 +_0807D238: .4byte gUnk_0811E4B4 +_0807D23C: + adds r6, #1 + adds r7, #8 + adds r0, r5, #0 +_0807D242: + subs r5, #1 + cmp r0, #0 + bne _0807D21A + movs r0, #1 +_0807D24A: + pop {r4, r5, r6, r7, pc} diff --git a/asm/non_matching/code_0807CC3C/sub_0807D24C.inc b/asm/non_matching/code_0807CC3C/sub_0807D24C.inc index cc91ceb6..2de1c0ff 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D24C.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D24C.inc @@ -1,6 +1,3 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" .syntax unified diff --git a/include/functions.h b/include/functions.h index 407641c0..4866a847 100644 --- a/include/functions.h +++ b/include/functions.h @@ -222,7 +222,7 @@ extern void sub_080B1520(u32); extern struct_0807D1C4* sub_0807D1C4(u32); extern u32 sub_0807D24C(u32, const char*, u32); extern void sub_0807CF68(u32); -extern void sub_0807D20C(u32, const char*, u32); +extern u32 sub_0807D20C(u32, const char*, u32); extern u32 sub_0807CF88(u32, u8*); extern void sub_0807D184(u32, const char*); extern u32 sub_0806F520(); diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 74b38de7..69c81441 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -6,6 +6,7 @@ extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; +extern const char gUnk_0811E4B4[8]; // the type is just a guess based on size and the fact that these are around a lot in this file extern ScriptExecutionContext gUnk_02022750; // might be ScriptExecutionContext[0x20] @@ -19,11 +20,28 @@ extern void sub_0801C4A0(u32); extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern s32 __divsi3(s32, s32); extern void _call_via_r6(Entity*, ScriptExecutionContext*); +extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); + // this is wrong by basically one instruction in the wrong place +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D20C.inc",u32 sub_0807D20C(u32 unk_1, const char* unk_2, u32 unk_3)) { + unk_3 >>= 3; + unk_1 >>= 3; + while (unk_3-- > 0) { + if (sub_080B18DC(unk_1, unk_2)) { + sub_080B18DC(unk_1, gUnk_0811E4B4); + return 0; + } + unk_1++; + unk_2 += 8; + } + return 1; +} +END_NONMATCH + NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D24C.inc", u32 sub_0807D24C(u32 unk_1, const char* unk_2, u32 unk_3)) { unk_3 >>= 3; unk_1 >>= 3; @@ -31,7 +49,7 @@ NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D24C.inc", u32 sub_0807D24C(u32 if (sub_080B180C(unk_1, unk_2)) return 0; unk_1++; - unk_2 += 4; + unk_2 += 8; } return 1; } From 80f15cd75b893740db734d47c218737059a8fab9 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 18:09:14 +0100 Subject: [PATCH 28/51] nonmatch sub_0807D1D8 --- asm/code_0807CC3C.s | 32 ---------------- .../code_0807CC3C/sub_0807D1D8.inc | 37 +++++++++++++++++++ .../code_0807CC3C/sub_0807D20C.inc | 3 -- src/code_0807CC3C.c | 7 +++- 4 files changed, 42 insertions(+), 37 deletions(-) create mode 100644 asm/non_matching/code_0807CC3C/sub_0807D1D8.inc diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 11b495f8..32a1fc91 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -323,35 +323,3 @@ sub_0807D1C4: @ 0x0807D1C4 .align 2, 0 _0807D1D4: .4byte gUnk_0811E4BC - thumb_func_start sub_0807D1D8 -sub_0807D1D8: @ 0x0807D1D8 - push {r4, r5, r6, lr} - adds r5, r0, #0 - adds r6, r1, #0 - lsrs r4, r2, #3 - adds r0, r4, #0 - lsrs r5, r5, #3 - b _0807D200 -_0807D1E6: - lsls r0, r5, #0x10 - lsrs r0, r0, #0x10 - adds r1, r6, #0 - bl sub_080B15E8 - lsls r0, r0, #0x10 - cmp r0, #0 - beq _0807D1FA - movs r0, #0 - b _0807D208 -_0807D1FA: - adds r5, #1 - adds r6, #8 - adds r0, r4, #0 -_0807D200: - subs r4, #1 - cmp r0, #0 - bne _0807D1E6 - movs r0, #1 -_0807D208: - pop {r4, r5, r6, pc} - .align 2, 0 - diff --git a/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc b/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc new file mode 100644 index 00000000..f96b3810 --- /dev/null +++ b/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc @@ -0,0 +1,37 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + push {r4, r5, r6, lr} + adds r5, r0, #0 + adds r6, r1, #0 + lsrs r4, r2, #3 + adds r0, r4, #0 + lsrs r5, r5, #3 + b _0807D200 +_0807D1E6: + lsls r0, r5, #0x10 + lsrs r0, r0, #0x10 + adds r1, r6, #0 + bl sub_080B15E8 + lsls r0, r0, #0x10 + cmp r0, #0 + beq _0807D1FA + movs r0, #0 + b _0807D208 +_0807D1FA: + adds r5, #1 + adds r6, #8 + adds r0, r4, #0 +_0807D200: + subs r4, #1 + cmp r0, #0 + bne _0807D1E6 + movs r0, #1 +_0807D208: + pop {r4, r5, r6, pc} + .align 2, 0 diff --git a/asm/non_matching/code_0807CC3C/sub_0807D20C.inc b/asm/non_matching/code_0807CC3C/sub_0807D20C.inc index 31a81d5b..e1822fc3 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D20C.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D20C.inc @@ -1,6 +1,3 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" .syntax unified diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 69c81441..ef470d10 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -25,9 +25,12 @@ extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +// these three are basically the same and wrong by basically one instruction in the wrong place +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D1D8.inc", u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3)) { +} +END_NONMATCH -// this is wrong by basically one instruction in the wrong place -NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D20C.inc",u32 sub_0807D20C(u32 unk_1, const char* unk_2, u32 unk_3)) { +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D20C.inc", u32 sub_0807D20C(u32 unk_1, const char* unk_2, u32 unk_3)) { unk_3 >>= 3; unk_1 >>= 3; while (unk_3-- > 0) { From 6498e3d531fcd0edce42b2dcd66692544e2d96d3 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 18:13:41 +0100 Subject: [PATCH 29/51] nonmatch sub_0807D1C4 --- asm/code_0807CC3C.s | 12 ------------ src/code_0807CC3C.c | 5 +++++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 32a1fc91..a244a968 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -311,15 +311,3 @@ _0807D1BC: pop {pc} .align 2, 0 - thumb_func_start sub_0807D1C4 -sub_0807D1C4: @ 0x0807D1C4 - adds r1, r0, #0 - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #2 - ldr r1, _0807D1D4 @ =gUnk_0811E4BC - adds r0, r0, r1 - bx lr - .align 2, 0 -_0807D1D4: .4byte gUnk_0811E4BC - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index ef470d10..f6e531b7 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -6,6 +6,7 @@ extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; +extern u8 gUnk_0811E4BC[]; extern const char gUnk_0811E4B4[8]; // the type is just a guess based on size and the fact that these are around a lot in this file extern ScriptExecutionContext gUnk_02022750; @@ -25,6 +26,10 @@ extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +struct_0807D1C4* sub_0807D1C4(u32 param_1) { + return (struct_0807D1C4*)(gUnk_0811E4BC + param_1 * 0xc); +} + // these three are basically the same and wrong by basically one instruction in the wrong place NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D1D8.inc", u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3)) { } From f00aaa506a663159117ad3c3a13c7c488a15b7d5 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 18:16:26 +0100 Subject: [PATCH 30/51] match sub_0807D1A4 --- asm/code_0807CC3C.s | 21 --------------------- src/code_0807CC3C.c | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index a244a968..a42a1965 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -290,24 +290,3 @@ _0807D1A0: pop {r4, r5, pc} .align 2, 0 - thumb_func_start sub_0807D1A4 -sub_0807D1A4: @ 0x0807D1A4 - push {lr} - adds r2, r0, #0 - movs r3, #0 - cmp r1, #0 - beq _0807D1BC -_0807D1AE: - ldrh r0, [r2] - eors r0, r1 - adds r3, r3, r0 - adds r2, #2 - subs r1, #2 - cmp r1, #0 - bne _0807D1AE -_0807D1BC: - lsls r0, r3, #0x10 - lsrs r0, r0, #0x10 - pop {pc} - .align 2, 0 - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index f6e531b7..47233f43 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -26,8 +26,20 @@ extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); -struct_0807D1C4* sub_0807D1C4(u32 param_1) { - return (struct_0807D1C4*)(gUnk_0811E4BC + param_1 * 0xc); +u16 sub_0807D1A4(u16* unk_1, u32 unk_2) { + u32 uVar1; + + uVar1 = 0; + while (unk_2 != 0) { + uVar1 = uVar1 + (*unk_1 ^ unk_2); + unk_1 = unk_1 + 1; + unk_2 = unk_2 - 2; + } + return uVar1; +} + +struct_0807D1C4* sub_0807D1C4(u32 unk_1) { + return (struct_0807D1C4*)(gUnk_0811E4BC + unk_1 * 0xc); } // these three are basically the same and wrong by basically one instruction in the wrong place From 6fed117565f30cb3f7d61c67df08096fbe2b9ba5 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 18:18:39 +0100 Subject: [PATCH 31/51] match sub_0807D184 --- asm/code_0807CC3C.s | 18 ------------------ src/code_0807CC3C.c | 6 ++++++ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index a42a1965..9e7e4d8a 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -272,21 +272,3 @@ _0807D17E: pop {pc} .align 2, 0 - thumb_func_start sub_0807D184 -sub_0807D184: @ 0x0807D184 - push {r4, r5, lr} - adds r4, r0, #0 - adds r5, r1, #0 - movs r2, #8 - bl sub_0807D20C - cmp r0, #0 - bne _0807D1A0 - adds r0, r4, #0 - adds r0, #8 - adds r1, r5, #0 - movs r2, #8 - bl sub_0807D20C -_0807D1A0: - pop {r4, r5, pc} - .align 2, 0 - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 47233f43..c3b71781 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -26,6 +26,12 @@ extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +void sub_0807D184(u32 param_1, const char* param_2) { + if (sub_0807D20C(param_1, param_2, 8) == 0) { + sub_0807D20C(param_1 + 8, param_2, 8); + } +} + u16 sub_0807D1A4(u16* unk_1, u32 unk_2) { u32 uVar1; From a4889a17899a7a4c8b61c07d65fad584ed51acd1 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Tue, 16 Feb 2021 18:58:30 +0100 Subject: [PATCH 32/51] match sub_0807D128 --- asm/code_0807CC3C.s | 53 --------------------------------------------- src/code_0807CC3C.c | 24 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 53 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 9e7e4d8a..9a9ab84d 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -219,56 +219,3 @@ _0807D124: adds r0, r5, #0 pop {r4, r5, r6, pc} - thumb_func_start sub_0807D128 -sub_0807D128: @ 0x0807D128 - push {lr} - adds r2, r0, #0 - ldr r1, [r2, #4] - ldr r0, _0807D13C @ =0x4D435A33 - cmp r1, r0 - beq _0807D150 - cmp r1, r0 - bhi _0807D144 - ldr r0, _0807D140 @ =0x466C6544 - b _0807D146 - .align 2, 0 -_0807D13C: .4byte 0x4D435A33 -_0807D140: .4byte 0x466C6544 -_0807D144: - ldr r0, _0807D14C @ =0x54494E49 -_0807D146: - cmp r1, r0 - beq _0807D164 - b _0807D17C - .align 2, 0 -_0807D14C: .4byte 0x54494E49 -_0807D150: - ldrh r0, [r2] - ldrh r1, [r2, #2] - adds r0, r0, r1 - movs r1, #0x80 - lsls r1, r1, #9 - movs r3, #0 - cmp r0, r1 - bne _0807D17E - movs r3, #2 - b _0807D17E -_0807D164: - movs r3, #0 - ldrh r0, [r2] - ldrh r1, [r2, #2] - ands r1, r0 - ldr r0, _0807D178 @ =0x0000FFFF - cmp r1, r0 - bne _0807D17E - movs r3, #1 - b _0807D17E - .align 2, 0 -_0807D178: .4byte 0x0000FFFF -_0807D17C: - movs r3, #0 -_0807D17E: - adds r0, r3, #0 - pop {pc} - .align 2, 0 - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index c3b71781..35513d3b 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -26,6 +26,30 @@ extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +u32 sub_0807D128(u16* unk_1) { + u32 ret; + switch (((u32*)(unk_1))[1]) { + case 'MCZ3': + if (unk_1[0] + unk_1[1] == 0x10000) { + ret = 2; + } else { + ret = 0; + } + break; + case 'FleD': + case 'TINI': + ret = 0; + if ((unk_1[0] & unk_1[1]) == 0xffff) { + ret = 1; + } + break; + default: + ret = 0; + break; + } + return ret; +} + void sub_0807D184(u32 param_1, const char* param_2) { if (sub_0807D20C(param_1, param_2, 8) == 0) { sub_0807D20C(param_1 + 8, param_2, 8); From a3aa7864f5ad822810cb55707264a6b916f71b83 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 17 Feb 2021 12:45:22 +0100 Subject: [PATCH 33/51] matched sub_0807D0EC --- asm/code_0807CC3C.s | 32 -------------------------------- src/code_0807CC3C.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 9a9ab84d..3cdcaae2 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -187,35 +187,3 @@ _0807D0E8: _0807D0EA: pop {r4, r5, r6, r7, pc} - thumb_func_start sub_0807D0EC -sub_0807D0EC: @ 0x0807D0EC - push {r4, r5, r6, lr} - adds r6, r0, #0 - adds r4, r1, #0 - movs r2, #8 - bl sub_0807D1D8 - cmp r0, #0 - bne _0807D100 - movs r5, #0 - b _0807D10C -_0807D100: - adds r0, r4, #0 - bl sub_0807D128 - adds r5, r0, #0 - cmp r5, #0 - bne _0807D124 -_0807D10C: - adds r0, r6, #0 - adds r0, #8 - adds r1, r4, #0 - movs r2, #8 - bl sub_0807D1D8 - cmp r0, #0 - beq _0807D124 - adds r0, r4, #0 - bl sub_0807D128 - adds r5, r0, #0 -_0807D124: - adds r0, r5, #0 - pop {r4, r5, r6, pc} - diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 35513d3b..2bb8c81d 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -25,6 +25,23 @@ extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3); +u32 sub_0807D128(u16* unk_1); +u16 sub_0807D1A4(u16* unk_1, u32 unk_2); + +u32 sub_0807D0EC(u32 unk_1, const char* unk_2) { + u32 ret; + + if (!sub_0807D1D8(unk_1, unk_2, 8)) { + ret = 0; + } else { + ret = sub_0807D128((u16*)unk_2); + } + if (!ret && sub_0807D1D8(unk_1 + 8, unk_2, 8)) { + ret = sub_0807D128((u16*)unk_2); + } + return ret; +} u32 sub_0807D128(u16* unk_1) { u32 ret; From 31a25066be30ded65ba8c74685d1aa397b92c537 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Thu, 18 Feb 2021 15:20:16 +0100 Subject: [PATCH 34/51] nonmatch sub_0807D0A0 --- asm/code_0807CC3C.s | 41 ---------------- .../code_0807CC3C/sub_0807D0A0.inc | 48 +++++++++++++++++++ .../code_0807CC3C/sub_0807D1D8.inc | 3 -- src/code_0807CC3C.c | 29 +++++++++++ 4 files changed, 77 insertions(+), 44 deletions(-) create mode 100644 asm/non_matching/code_0807CC3C/sub_0807D0A0.inc diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 3cdcaae2..8e4a0927 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -146,44 +146,3 @@ _0807D098: mov r8, r3 pop {r4, r5, r6, r7, pc} - thumb_func_start sub_0807D0A0 -sub_0807D0A0: @ 0x0807D0A0 - push {r4, r5, r6, r7, lr} - adds r7, r0, #0 - adds r5, r1, #0 - adds r6, r2, #0 - adds r0, r7, #4 - movs r1, #4 - bl sub_0807D1A4 - adds r4, r0, #0 - lsls r4, r4, #0x10 - lsrs r4, r4, #0x10 - adds r0, r5, #0 - adds r1, r6, #0 - bl sub_0807D1A4 - adds r4, r4, r0 - lsls r4, r4, #0x10 - lsrs r4, r4, #0x10 - ldrh r0, [r7] - cmp r0, r4 - bne _0807D0DE - lsls r0, r0, #0x10 - ldrh r1, [r7, #2] - rsbs r0, r0, #0 - lsrs r0, r0, #0x10 - cmp r1, r0 - bne _0807D0DE - ldr r1, [r7, #4] - ldr r0, _0807D0E4 @ =0x4D435A33 - cmp r1, r0 - beq _0807D0E8 -_0807D0DE: - movs r0, #0 - b _0807D0EA - .align 2, 0 -_0807D0E4: .4byte 0x4D435A33 -_0807D0E8: - movs r0, #1 -_0807D0EA: - pop {r4, r5, r6, r7, pc} - diff --git a/asm/non_matching/code_0807CC3C/sub_0807D0A0.inc b/asm/non_matching/code_0807CC3C/sub_0807D0A0.inc new file mode 100644 index 00000000..a9596425 --- /dev/null +++ b/asm/non_matching/code_0807CC3C/sub_0807D0A0.inc @@ -0,0 +1,48 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + push {r4, r5, r6, r7, lr} + adds r7, r0, #0 + adds r5, r1, #0 + adds r6, r2, #0 + adds r0, r7, #4 + movs r1, #4 + bl sub_0807D1A4 + adds r4, r0, #0 + lsls r4, r4, #0x10 + lsrs r4, r4, #0x10 + adds r0, r5, #0 + adds r1, r6, #0 + bl sub_0807D1A4 + adds r4, r4, r0 + lsls r4, r4, #0x10 + lsrs r4, r4, #0x10 + ldrh r0, [r7] + cmp r0, r4 + bne _0807D0DE + lsls r0, r0, #0x10 + ldrh r1, [r7, #2] + rsbs r0, r0, #0 + lsrs r0, r0, #0x10 + cmp r1, r0 + bne _0807D0DE + ldr r1, [r7, #4] + ldr r0, _0807D0E4 @ =0x4D435A33 + cmp r1, r0 + beq _0807D0E8 +_0807D0DE: + movs r0, #0 + b _0807D0EA + .align 2, 0 +_0807D0E4: .4byte 0x4D435A33 +_0807D0E8: + movs r0, #1 +_0807D0EA: + pop {r4, r5, r6, r7, pc} + + .syntax divided diff --git a/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc b/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc index f96b3810..8537e0d1 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc @@ -1,6 +1,3 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" .syntax unified diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 2bb8c81d..d06294a4 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -29,6 +29,35 @@ u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3); u32 sub_0807D128(u16* unk_1); u16 sub_0807D1A4(u16* unk_1, u32 unk_2); +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D0A0.inc", u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3)) { + u32 r0; + + u32* u32_1 = (u32*)unk_1; + + u16 u0; + u32 u1; + + u0 = sub_0807D1A4(unk_1 + 2, 4); + u0 = u0 + sub_0807D1A4(unk_2, unk_3); + + u1 = unk_1[0]; + if (u1 != u0) { + r0 = 0; + } else { + if (unk_1[1] == (-(u1 << 0x10) >> 0x10)) { + if (*(u32_1 + 1) != 'MCZ3') { + r0 = 0; + } else { + r0 = 1; + } + } else { + r0 = 0; + } + } + return r0; +} +END_NONMATCH + u32 sub_0807D0EC(u32 unk_1, const char* unk_2) { u32 ret; From 3f54062fa5bdc3afc8bb9c8f645fc4f64bcf1de9 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Thu, 18 Feb 2021 15:22:18 +0100 Subject: [PATCH 35/51] added missing syntax directives --- asm/non_matching/code_0807CC3C/sub_0807D1D8.inc | 2 ++ asm/non_matching/code_0807CC3C/sub_0807D20C.inc | 2 ++ asm/non_matching/code_0807CC3C/sub_0807D24C.inc | 2 ++ asm/non_matching/code_0807CC3C/sub_0807D280.inc | 2 ++ asm/non_matching/code_0807CC3C/sub_0807D46C.inc | 2 ++ 5 files changed, 10 insertions(+) diff --git a/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc b/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc index 8537e0d1..f9b81bde 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc @@ -32,3 +32,5 @@ _0807D200: _0807D208: pop {r4, r5, r6, pc} .align 2, 0 + + .syntax divided diff --git a/asm/non_matching/code_0807CC3C/sub_0807D20C.inc b/asm/non_matching/code_0807CC3C/sub_0807D20C.inc index e1822fc3..954ad823 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D20C.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D20C.inc @@ -37,3 +37,5 @@ _0807D242: movs r0, #1 _0807D24A: pop {r4, r5, r6, r7, pc} + + .syntax divided diff --git a/asm/non_matching/code_0807CC3C/sub_0807D24C.inc b/asm/non_matching/code_0807CC3C/sub_0807D24C.inc index 2de1c0ff..7761d787 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D24C.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D24C.inc @@ -32,3 +32,5 @@ _0807D274: _0807D27C: pop {r4, r5, r6, pc} .align 2, 0 + + .syntax divided diff --git a/asm/non_matching/code_0807CC3C/sub_0807D280.inc b/asm/non_matching/code_0807CC3C/sub_0807D280.inc index a9d083ae..bc06cc5e 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D280.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D280.inc @@ -260,3 +260,5 @@ _0807D462: mov sb, r4 pop {r4, r5, r6, r7, pc} .align 2, 0 + + .syntax divided diff --git a/asm/non_matching/code_0807CC3C/sub_0807D46C.inc b/asm/non_matching/code_0807CC3C/sub_0807D46C.inc index b3696327..ad1dee94 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D46C.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D46C.inc @@ -342,3 +342,5 @@ _0807D6CC: mov sb, r4 mov sl, r5 pop {r4, r5, r6, r7, pc} + + .syntax divided From 809a9032071a422456dba1b0adb5bededd14f3fe Mon Sep 17 00:00:00 2001 From: Henny022p Date: Thu, 18 Feb 2021 17:09:01 +0100 Subject: [PATCH 36/51] nonmatch sub_0807D008 --- asm/code_0807CC3C.s | 77 ----------------- .../code_0807CC3C/sub_0807D008.inc | 84 +++++++++++++++++++ .../code_0807CC3C/sub_0807D0A0.inc | 3 - src/code_0807CC3C.c | 43 ++++++++++ 4 files changed, 127 insertions(+), 80 deletions(-) create mode 100644 asm/non_matching/code_0807CC3C/sub_0807D008.inc diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index 8e4a0927..5436febf 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -69,80 +69,3 @@ _0807CFFE: .align 2, 0 _0807D004: .4byte 0x4D435A33 - thumb_func_start sub_0807D008 -sub_0807D008: @ 0x0807D008 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - sub sp, #0xc - adds r7, r1, #0 - bl sub_0807D1C4 - adds r5, r0, #0 - ldrh r0, [r5, #2] - add r4, sp, #4 - adds r1, r4, #0 - bl sub_0807D0EC - adds r6, r0, #0 - mov r8, r4 - cmp r6, #2 - bne _0807D048 - ldrh r0, [r5, #6] - ldrh r2, [r5] - adds r1, r7, #0 - bl sub_0807D1D8 - cmp r0, #0 - beq _0807D046 - ldrh r2, [r5] - mov r0, r8 - adds r1, r7, #0 - bl sub_0807D0A0 - cmp r0, #0 - bne _0807D072 -_0807D046: - movs r6, #0 -_0807D048: - ldrh r0, [r5, #4] - mov r1, r8 - bl sub_0807D0EC - adds r4, r0, #0 - cmp r4, #2 - bne _0807D078 - ldrh r0, [r5, #8] - ldrh r2, [r5] - adds r1, r7, #0 - bl sub_0807D1D8 - cmp r0, #0 - beq _0807D076 - ldrh r2, [r5] - mov r0, r8 - adds r1, r7, #0 - bl sub_0807D0A0 - cmp r0, #0 - beq _0807D076 -_0807D072: - movs r0, #1 - b _0807D098 -_0807D076: - movs r4, #0 -_0807D078: - movs r0, #0 - str r0, [sp] - ldrh r2, [r5] - lsrs r2, r2, #2 - movs r0, #0xa0 - lsls r0, r0, #0x13 - orrs r2, r0 - mov r0, sp - adds r1, r7, #0 - bl CpuSet - orrs r6, r4 - movs r0, #0 - cmp r6, #0 - bne _0807D098 - subs r0, #1 -_0807D098: - add sp, #0xc - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7, pc} - diff --git a/asm/non_matching/code_0807CC3C/sub_0807D008.inc b/asm/non_matching/code_0807CC3C/sub_0807D008.inc new file mode 100644 index 00000000..c4761416 --- /dev/null +++ b/asm/non_matching/code_0807CC3C/sub_0807D008.inc @@ -0,0 +1,84 @@ + .include "asm/macros.inc" + + .include "constants/constants.inc" + + .syntax unified + + .text + + push {r4, r5, r6, r7, lr} + mov r7, r8 + push {r7} + sub sp, #0xc + adds r7, r1, #0 + bl sub_0807D1C4 + adds r5, r0, #0 + ldrh r0, [r5, #2] + add r4, sp, #4 + adds r1, r4, #0 + bl sub_0807D0EC + adds r6, r0, #0 + mov r8, r4 + cmp r6, #2 + bne _0807D048 + ldrh r0, [r5, #6] + ldrh r2, [r5] + adds r1, r7, #0 + bl sub_0807D1D8 + cmp r0, #0 + beq _0807D046 + ldrh r2, [r5] + mov r0, r8 + adds r1, r7, #0 + bl sub_0807D0A0 + cmp r0, #0 + bne _0807D072 +_0807D046: + movs r6, #0 +_0807D048: + ldrh r0, [r5, #4] + mov r1, r8 + bl sub_0807D0EC + adds r4, r0, #0 + cmp r4, #2 + bne _0807D078 + ldrh r0, [r5, #8] + ldrh r2, [r5] + adds r1, r7, #0 + bl sub_0807D1D8 + cmp r0, #0 + beq _0807D076 + ldrh r2, [r5] + mov r0, r8 + adds r1, r7, #0 + bl sub_0807D0A0 + cmp r0, #0 + beq _0807D076 +_0807D072: + movs r0, #1 + b _0807D098 +_0807D076: + movs r4, #0 +_0807D078: + movs r0, #0 + str r0, [sp] + ldrh r2, [r5] + lsrs r2, r2, #2 + movs r0, #0xa0 + lsls r0, r0, #0x13 + orrs r2, r0 + mov r0, sp + adds r1, r7, #0 + bl CpuSet + orrs r6, r4 + movs r0, #0 + cmp r6, #0 + bne _0807D098 + subs r0, #1 +_0807D098: + add sp, #0xc + pop {r3} + mov r8, r3 + pop {r4, r5, r6, r7, pc} + + .syntax divided diff --git a/asm/non_matching/code_0807CC3C/sub_0807D0A0.inc b/asm/non_matching/code_0807CC3C/sub_0807D0A0.inc index a9596425..9bec41a8 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D0A0.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D0A0.inc @@ -1,6 +1,3 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" .syntax unified diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index d06294a4..5c4220cb 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -3,6 +3,7 @@ #include "functions.h" #include "script.h" #include "entity.h" +#include "save.h" extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; @@ -28,6 +29,47 @@ void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3); u32 sub_0807D128(u16* unk_1); u16 sub_0807D1A4(u16* unk_1, u32 unk_2); +u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3); +u32 sub_0807D0EC(u32 unk_1, const char* unk_2); + +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D008.inc", u32 sub_0807D008(u32 param_1, SaveFile* saveFile)) { + u32 set_0; + char auStack32[8]; + + struct_0807D1C4* thing; + u32 t1; + u32 t2; + u32 ret; + u32 temp; + + thing = sub_0807D1C4(param_1); + t1 = sub_0807D0EC(thing->field_0x2, auStack32); + if (t1 == 2) { + if ((sub_0807D1D8(thing->field_0x6, (char*)saveFile, thing->field_0x0) == 0) || + (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)thing->field_0x0) == 0)) { + t1 = 0; + } else { + return 1; + } + } + t2 = sub_0807D0EC(thing->field_0x4, auStack32); + if (t2 == 2) { + if ((sub_0807D1D8(thing->field_0x8, (char*)saveFile, thing->field_0x0) != 0) && + (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)thing->field_0x0) != 0)) { + return 1; + } + t2 = 0; + } + set_0 = 0; + CpuSet(&set_0, saveFile, thing->field_0x0 >> 2 | CPU_SET_SRC_FIXED | CPU_SET_32BIT); + temp = t1 | t2; + ret = 0; + if (temp == 0) { + ret = -1; + } + return ret; +} +END_NONMATCH NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D0A0.inc", u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3)) { u32 r0; @@ -114,6 +156,7 @@ u16 sub_0807D1A4(u16* unk_1, u32 unk_2) { return uVar1; } +// TODO properly type this array struct_0807D1C4* sub_0807D1C4(u32 unk_1) { return (struct_0807D1C4*)(gUnk_0811E4BC + unk_1 * 0xc); } From f475bd9fa097437c478c9afd3e1a888ad12222f7 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Thu, 18 Feb 2021 17:58:42 +0100 Subject: [PATCH 37/51] nonmatch sub_0807CF88 --- .../code_0807CC3C/sub_0807CF88.inc} | 4 +- .../code_0807CC3C/sub_0807D008.inc | 3 -- include/functions.h | 2 +- linker.ld | 1 - src/code_0807CC3C.c | 43 +++++++++++++++++-- 5 files changed, 43 insertions(+), 10 deletions(-) rename asm/{code_0807CC3C.s => non_matching/code_0807CC3C/sub_0807CF88.inc} (94%) diff --git a/asm/code_0807CC3C.s b/asm/non_matching/code_0807CC3C/sub_0807CF88.inc similarity index 94% rename from asm/code_0807CC3C.s rename to asm/non_matching/code_0807CC3C/sub_0807CF88.inc index 5436febf..18546c4a 100644 --- a/asm/code_0807CC3C.s +++ b/asm/non_matching/code_0807CC3C/sub_0807CF88.inc @@ -1,12 +1,11 @@ .include "asm/macros.inc" + .include "constants/constants.inc" .syntax unified .text - thumb_func_start sub_0807CF88 -sub_0807CF88: @ 0x0807CF88 push {r4, r5, r6, r7, lr} sub sp, #8 adds r7, r1, #0 @@ -69,3 +68,4 @@ _0807CFFE: .align 2, 0 _0807D004: .4byte 0x4D435A33 + .syntax divided diff --git a/asm/non_matching/code_0807CC3C/sub_0807D008.inc b/asm/non_matching/code_0807CC3C/sub_0807D008.inc index c4761416..d5d00ffd 100644 --- a/asm/non_matching/code_0807CC3C/sub_0807D008.inc +++ b/asm/non_matching/code_0807CC3C/sub_0807D008.inc @@ -1,6 +1,3 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" .syntax unified diff --git a/include/functions.h b/include/functions.h index 4866a847..e6be13bc 100644 --- a/include/functions.h +++ b/include/functions.h @@ -224,7 +224,7 @@ extern u32 sub_0807D24C(u32, const char*, u32); extern void sub_0807CF68(u32); extern u32 sub_0807D20C(u32, const char*, u32); extern u32 sub_0807CF88(u32, u8*); -extern void sub_0807D184(u32, const char*); +extern u32 sub_0807D184(u32, const char*); extern u32 sub_0806F520(); extern void sub_0806F4E8(Entity*); extern u32 sub_0806F3E4(Entity*); diff --git a/linker.ld b/linker.ld index 8b282a19..8ac8a325 100644 --- a/linker.ld +++ b/linker.ld @@ -675,7 +675,6 @@ SECTIONS { asm/code_0807CAA0.o(.text); src/flags.o(.text); src/save.o(.text); - asm/code_0807CC3C.o(.text); src/code_0807CC3C.o(.text); src/executeScriptCommandSet.o(.text); asm/code_0807F0D8.o(.text); diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 5c4220cb..484fe575 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -32,6 +32,39 @@ u16 sub_0807D1A4(u16* unk_1, u32 unk_2); u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3); u32 sub_0807D0EC(u32 unk_1, const char* unk_2); +NONMATCH("asm/non_matching/code_0807CC3C/sub_0807CF88.inc", u32 sub_0807CF88(u32 arg0, u8* arg1)) { + u32 signature; + s16 local1[2]; + + u32 retval; + struct_0807D1C4* ptr; + u32 e0, e1; + u16 l1prep; + + ptr = sub_0807D1C4(arg0); + + signature = 'MCZ3'; + l1prep = sub_0807D1A4((u16*)&signature, 4); + l1prep += sub_0807D1A4((u16*)arg1, ptr->field_0x0); + local1[0] = l1prep; + local1[1] = -(u32)l1prep; + e0 = sub_0807D20C(ptr->field_0x6, (const char*)arg1, ptr->field_0x0); + if (e0) { + e0 = sub_0807D184(ptr->field_0x2, (const char*)local1); + } + e1 = sub_0807D20C(ptr->field_0x8, (const char*)arg1, ptr->field_0x0); + if (e1) { + e1 = sub_0807D184(ptr->field_0x4, (const char*)local1); + } + + retval = 0; + if (e0 || e1) { + retval = 1; + } + return retval; +} +END_NONMATCH + NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D008.inc", u32 sub_0807D008(u32 param_1, SaveFile* saveFile)) { u32 set_0; char auStack32[8]; @@ -138,10 +171,14 @@ u32 sub_0807D128(u16* unk_1) { return ret; } -void sub_0807D184(u32 param_1, const char* param_2) { - if (sub_0807D20C(param_1, param_2, 8) == 0) { - sub_0807D20C(param_1 + 8, param_2, 8); +u32 sub_0807D184(u32 param_1, const char* param_2) { + u32 uVar1; + + uVar1 = sub_0807D20C(param_1, param_2, 8); + if (uVar1 == 0) { + uVar1 = sub_0807D20C(param_1 + 8, param_2, 8); } + return uVar1; } u16 sub_0807D1A4(u16* unk_1, u32 unk_2) { From 1133fcb21b311f9864d6d3fbe2fa93b8bcd7c3e8 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 03:34:52 +0100 Subject: [PATCH 38/51] named ScriptExecutionContext globals and functions --- asm/code_080732D0.s | 8 +++---- asm/manager16.s | 2 +- linker.ld | 4 ++-- src/code_0807CC3C.c | 55 +++++++++++++++++++++------------------------ 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/asm/code_080732D0.s b/asm/code_080732D0.s index 2aff08e1..ee7de176 100644 --- a/asm/code_080732D0.s +++ b/asm/code_080732D0.s @@ -3437,7 +3437,7 @@ sub_08074C68: @ 0x08074C68 adds r0, r4, #0 adds r0, #0x84 ldr r1, [r0] - ldr r0, _08074CA4 @ =gUnk_02022750 + ldr r0, _08074CA4 @ =gPlayerScriptExecutionContext cmp r1, r0 bne _08074CF2 movs r0, #1 @@ -3449,7 +3449,7 @@ sub_08074C68: @ 0x08074C68 b _08074CF2 .align 2, 0 _08074CA0: .4byte gPlayerState -_08074CA4: .4byte gUnk_02022750 +_08074CA4: .4byte gPlayerScriptExecutionContext _08074CA8: ldrb r1, [r4, #0x18] movs r0, #4 @@ -4195,7 +4195,7 @@ sub_080751E8: @ 0x080751E8 adds r7, r0, #0 adds r5, r1, #0 adds r6, r2, #0 - ldr r4, _08075230 @ =gUnk_02022750 + ldr r4, _08075230 @ =gPlayerScriptExecutionContext adds r0, r4, #0 movs r1, #0x24 bl _DmaZero @@ -4226,7 +4226,7 @@ sub_080751E8: @ 0x080751E8 ldr r6, _0807523C @ =gUnk_08009ECC b _08075244 .align 2, 0 -_08075230: .4byte gUnk_02022750 +_08075230: .4byte gPlayerScriptExecutionContext _08075234: .4byte gPlayerEntity _08075238: .4byte gPlayerState _0807523C: .4byte gUnk_08009ECC diff --git a/asm/manager16.s b/asm/manager16.s index 518f9e4e..25cd6698 100644 --- a/asm/manager16.s +++ b/asm/manager16.s @@ -126,7 +126,7 @@ _0805AC1A: ldr r0, [r4, #8] cmp r0, #0 beq _0805AC48 - bl sub_0807DAA0 + bl CreateScriptExecutionContext mov sb, r0 cmp r0, #0 beq _0805ACA6 diff --git a/linker.ld b/linker.ld index 8ac8a325..e4141fdc 100644 --- a/linker.ld +++ b/linker.ld @@ -84,7 +84,7 @@ SECTIONS { . = 0x00022130; gUnk_02022130 = .; . = 0x00022730; gUnk_02022730 = .; . = 0x00022740; gUnk_02022740 = .; - . = 0x00022750; gUnk_02022750 = .; + . = 0x00022750; gPlayerScriptExecutionContext = .; . = 0x00022780; gUnk_02022780 = .; . = 0x000227DC; gUnk_020227DC = .; . = 0x000227E8; gUnk_020227E8 = .; @@ -144,7 +144,7 @@ SECTIONS { . = 0x00035540; gUnk_02035540 = .; . = 0x00035542; gUnk_02035542 = .; . = 0x00036540; gUnk_02036540 = .; - . = 0x00036570; gUnk_02036570 = .; + . = 0x00036570; gScriptExecutionContextArray = .; . = 0x000369F0; gUnk_020369F0 = .; . = 0x00036A38; gUnk_02036A38 = .; . = 0x00036A40; gUnk_02036A40 = .; diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 484fe575..e895a5bf 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -9,17 +9,14 @@ extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; extern u8 gUnk_0811E4BC[]; extern const char gUnk_0811E4B4[8]; -// the type is just a guess based on size and the fact that these are around a lot in this file -extern ScriptExecutionContext gUnk_02022750; -// might be ScriptExecutionContext[0x20] -extern u32 gUnk_02036570; +extern ScriptExecutionContext gPlayerScriptExecutionContext; +extern ScriptExecutionContext gScriptExecutionContextArray[0x20]; extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); extern void DeleteThisEntity(void); extern u32 sub_080B180C(u32, const char*); extern void sub_0801C4A0(u32); -extern void sub_0807DB98(Entity*, ScriptExecutionContext*); extern s32 __divsi3(s32, s32); extern void _call_via_r6(Entity*, ScriptExecutionContext*); extern u16 sub_080B18DC(u16, const char*); @@ -31,6 +28,9 @@ u32 sub_0807D128(u16* unk_1); u16 sub_0807D1A4(u16* unk_1, u32 unk_2); u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3); u32 sub_0807D0EC(u32 unk_1, const char* unk_2); +void sub_0807DF38(void); +void sub_0807DE80(Entity* entity); +void sub_0807DB98(Entity*, ScriptExecutionContext*); NONMATCH("asm/non_matching/code_0807CC3C/sub_0807CF88.inc", u32 sub_0807CF88(u32 arg0, u8* arg1)) { u32 signature; @@ -246,32 +246,32 @@ END_NONMATCH void sub_0807DA70(void) { _DmaZero(&gUnk_02033280, 0xc); - _DmaZero(&gUnk_02036570, 0x480); - _DmaZero(&gUnk_02022750, 0x24); + _DmaZero(&gScriptExecutionContextArray, sizeof(gScriptExecutionContextArray)); + _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); gUnk_02033280.unk_08 = 8; } -u32* sub_0807DAA0(void) { - u32* puVar1; +ScriptExecutionContext* CreateScriptExecutionContext(void) { + ScriptExecutionContext* puVar1; - puVar1 = &gUnk_02036570; + puVar1 = gScriptExecutionContextArray; do { - if (*puVar1 == 0) { + if (puVar1->unk_00 == 0) { return puVar1; } - puVar1 = puVar1 + 9; - } while (puVar1 < &gUnk_02036570 + 0x480 / 4); + puVar1++; + } while (puVar1 < gScriptExecutionContextArray + ARRAY_COUNT(gScriptExecutionContextArray)); return NULL; } -void sub_0807DAC4(ScriptExecutionContext* context) { - _DmaZero(context, 0x24); +void DestroyScriptExecutionContext(ScriptExecutionContext* context) { + _DmaZero(context, sizeof(ScriptExecutionContext)); } u32* StartCutscene(Entity* param_1, u8* param_2) { ScriptExecutionContext* puVar1; - puVar1 = (ScriptExecutionContext*)sub_0807DAA0(); + puVar1 = CreateScriptExecutionContext(); if (puVar1) { sub_0807DAF0(param_1, puVar1, (u32)param_2); } @@ -287,7 +287,7 @@ void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1) { void UnloadCutsceneData(Entity* entity) { if ((entity->flags & 2)) { entity->flags = entity->flags & 0xfd; - sub_0807DAC4(*(ScriptExecutionContext**)&entity->cutsceneBeh); + DestroyScriptExecutionContext(*(ScriptExecutionContext**)&entity->cutsceneBeh); *(ScriptExecutionContext**)&entity->cutsceneBeh = NULL; } } @@ -295,24 +295,24 @@ void UnloadCutsceneData(Entity* entity) { void StartPlayerScript(u32 unk1) { Entity* player; - _DmaZero(&gUnk_02022750, 0x24); - gUnk_02022750.unk_00 = (u16*)unk1; + _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); + gPlayerScriptExecutionContext.unk_00 = (u16*)unk1; player = &gPlayerEntity; - *(ScriptExecutionContext**)&player->cutsceneBeh = &gUnk_02022750; + *(ScriptExecutionContext**)&player->cutsceneBeh = &gPlayerScriptExecutionContext; gPlayerState.playerAction = 0x1c; gPlayerState.field_0x3a = 0; gPlayerState.field_0x39 = 0; gPlayerState.field_0x38 = 0; } -u32* sub_0807DB68(Entity* entity, u32 unk1) { - u32* puVar1; +ScriptExecutionContext* sub_0807DB68(Entity* entity, u16* unk1) { + ScriptExecutionContext* puVar1; - puVar1 = sub_0807DAA0(); + puVar1 = CreateScriptExecutionContext(); if (puVar1) { entity->flags |= 2; - *(u32**)&entity->field_0x3c = puVar1; - *puVar1 = unk1; + *(ScriptExecutionContext**)&entity->field_0x3c = puVar1; + puVar1->unk_00 = unk1; } return puVar1; } @@ -347,7 +347,7 @@ void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) { CreateSpeechBubbleQuestionMark(entity, 8, -0x18); break; case 0x40: - sub_0807DAC4(context); + DestroyScriptExecutionContext(context); DeleteThisEntity(); case 0x80: entity->spriteSettings.b.draw = 1; @@ -396,9 +396,6 @@ void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) { } } -void sub_0807DF38(void); -void sub_0807DE80(Entity* entity); - void sub_0807DD50(Entity* entity) { sub_0807DD64(entity); sub_0807DD94(entity, 0); From 42f3e2e2fe788cf3f59d51089bc6036c5d3b816f Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 05:28:01 +0100 Subject: [PATCH 39/51] code cleanup --- src/code_0807CC3C.c | 49 +++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index e895a5bf..68bea878 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -5,9 +5,15 @@ #include "entity.h" #include "save.h" +typedef struct Thing{ + u16 unk_1; + u16 unk_2; + u32 unk_3; +} Thing; + extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E510[]; -extern u8 gUnk_0811E4BC[]; +extern struct_0807D1C4 gUnk_0811E4BC[]; extern const char gUnk_0811E4B4[8]; extern ScriptExecutionContext gPlayerScriptExecutionContext; extern ScriptExecutionContext gScriptExecutionContextArray[0x20]; @@ -24,7 +30,7 @@ extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3); -u32 sub_0807D128(u16* unk_1); +u32 sub_0807D128(const Thing* unk_1); u16 sub_0807D1A4(u16* unk_1, u32 unk_2); u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3); u32 sub_0807D0EC(u32 unk_1, const char* unk_2); @@ -139,19 +145,19 @@ u32 sub_0807D0EC(u32 unk_1, const char* unk_2) { if (!sub_0807D1D8(unk_1, unk_2, 8)) { ret = 0; } else { - ret = sub_0807D128((u16*)unk_2); + ret = sub_0807D128((Thing*)unk_2); } if (!ret && sub_0807D1D8(unk_1 + 8, unk_2, 8)) { - ret = sub_0807D128((u16*)unk_2); + ret = sub_0807D128((Thing*)unk_2); } return ret; } -u32 sub_0807D128(u16* unk_1) { +u32 sub_0807D128(const Thing* thing) { u32 ret; - switch (((u32*)(unk_1))[1]) { + switch (thing->unk_3) { case 'MCZ3': - if (unk_1[0] + unk_1[1] == 0x10000) { + if (thing->unk_1 + thing->unk_2 == 0x10000) { ret = 2; } else { ret = 0; @@ -160,7 +166,7 @@ u32 sub_0807D128(u16* unk_1) { case 'FleD': case 'TINI': ret = 0; - if ((unk_1[0] & unk_1[1]) == 0xffff) { + if ((thing->unk_1 & thing->unk_2) == 0xffff) { ret = 1; } break; @@ -193,9 +199,8 @@ u16 sub_0807D1A4(u16* unk_1, u32 unk_2) { return uVar1; } -// TODO properly type this array struct_0807D1C4* sub_0807D1C4(u32 unk_1) { - return (struct_0807D1C4*)(gUnk_0811E4BC + unk_1 * 0xc); + return &gUnk_0811E4BC[unk_1]; } // these three are basically the same and wrong by basically one instruction in the wrong place @@ -268,12 +273,12 @@ void DestroyScriptExecutionContext(ScriptExecutionContext* context) { _DmaZero(context, sizeof(ScriptExecutionContext)); } -u32* StartCutscene(Entity* param_1, u8* param_2) { +u32* StartCutscene(Entity* entity, u8* param_2) { ScriptExecutionContext* puVar1; puVar1 = CreateScriptExecutionContext(); if (puVar1) { - sub_0807DAF0(param_1, puVar1, (u32)param_2); + sub_0807DAF0(entity, puVar1, (u32)param_2); } return (u32*)puVar1; } @@ -306,19 +311,19 @@ void StartPlayerScript(u32 unk1) { } ScriptExecutionContext* sub_0807DB68(Entity* entity, u16* unk1) { - ScriptExecutionContext* puVar1; + ScriptExecutionContext* context; - puVar1 = CreateScriptExecutionContext(); - if (puVar1) { + context = CreateScriptExecutionContext(); + if (context) { entity->flags |= 2; - *(ScriptExecutionContext**)&entity->field_0x3c = puVar1; - puVar1->unk_00 = unk1; + *(ScriptExecutionContext**)&entity->field_0x3c = context; + context->unk_00 = unk1; } - return puVar1; + return context; } void sub_0807DB88(ScriptExecutionContext* context, u32 unk1) { - _DmaZero(context, 0x24); + _DmaZero(context, sizeof(ScriptExecutionContext)); context->unk_00 = (u16*)unk1; } @@ -419,11 +424,7 @@ void sub_0807DD94(Entity* entity, u32 param_2) { sub_0807DE80(entity); } -/** - * - * @param entity - * @param address this is the fuction called via r6 - */ +// TODO: make this a proper function pointer void sub_0807DDAC(Entity* entity, u32 address) { ScriptExecutionContext** piVar1; From b404b02bc2fffdef953935a33fb6f38098a23585 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 05:32:39 +0100 Subject: [PATCH 40/51] cleaned some usage of ExecuteScriptCommandSet --- include/functions.h | 2 +- src/npc/festari.c | 1 - src/object/houseDoorExterior.c | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/functions.h b/include/functions.h index e6be13bc..7f5b9cc1 100644 --- a/include/functions.h +++ b/include/functions.h @@ -9,6 +9,7 @@ #include "player.h" #include "structures.h" #include "room.h" +#include "script.h" // Identified - to be sorted into header files extern u32 Random(void); @@ -43,7 +44,6 @@ extern void UpdateAnimationVariableFrames(Entity*, u32); extern void CopyPositionAndSpriteOffset(Entity*, Entity*); extern u8* GetSpriteSubEntryOffsetDataPointer(u32, u32); extern u32 LoadFixedGFX(Entity*, u32); -extern void ExecuteScriptCommandSet(); extern void _DmaFill32(u32, void*, u32); extern Entity* CreateItemEntity(u32, u32, u32); void _DmaCopy(const void* src, void* dst, u32 size); diff --git a/src/npc/festari.c b/src/npc/festari.c index 67637ec3..0c5c74f8 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -8,7 +8,6 @@ extern u32 sub_0801E99C(Entity*); extern void sub_08078784(Entity*, u32); extern void sub_0807DD50(Entity*); extern void sub_0806F118(Entity*); -extern void ExecuteScriptCommandSet(Entity*, void*); extern void sub_0805FF2C(Entity*, void*); extern void (*const gUnk_08109BBC[])(Entity*); diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index cdee3afe..170f6e33 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -116,7 +116,7 @@ static void sub_0808681C(Entity* this) { } if (this->flags & 0x2) { - ExecuteScriptCommandSet(this, *(u32**)&this->cutsceneBeh); + ExecuteScriptCommandSet(this, *(ScriptExecutionContext **)&this->cutsceneBeh); sub_080868EC(this, *(void**)&this->cutsceneBeh); } } @@ -128,7 +128,7 @@ void sub_080868B0(Entity* this) { this->boundingBox = &gUnk_081206AC; this->actionDelay = 8; } - ExecuteScriptCommandSet(this, *(u32**)&this->cutsceneBeh); + ExecuteScriptCommandSet(this, *(ScriptExecutionContext **)&this->cutsceneBeh); sub_080868EC(this, *(void**)&this->cutsceneBeh); } From 2fda11f20c830a77e73be272897351b75ba7b816 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 05:43:57 +0100 Subject: [PATCH 41/51] use proper function pointer in sub_0807DDAC --- include/functions.h | 5 ++--- src/code_0807CC3C.c | 11 +++++------ src/npc/beedle.c | 2 +- src/npc/bigGoron.c | 3 +-- src/npc/forestMinish.c | 3 +-- src/npc/mayorHagen.c | 3 +-- src/npc/melari.c | 3 +-- src/npc/mutoh.c | 3 +-- src/npc/percy.c | 2 +- src/npc/postman.c | 3 +-- src/npc/rem.c | 6 ++---- src/npc/simon.c | 2 +- src/npc/smith.c | 8 +++----- src/npc/stamp.c | 3 +-- src/npc/talon.c | 4 ++-- src/npc/teachers.c | 3 +-- src/npc/townMinish.c | 2 +- src/npc/townsperson.c | 3 +-- src/npc/windTribespeople.c | 3 +-- src/npc/zelda.c | 3 +-- src/object/windcrest.c | 3 +-- 21 files changed, 30 insertions(+), 48 deletions(-) diff --git a/include/functions.h b/include/functions.h index 7f5b9cc1..d53ca901 100644 --- a/include/functions.h +++ b/include/functions.h @@ -86,13 +86,13 @@ extern void sub_0806F69C(Entity*); extern void sub_0805E3A0(void*, u32); extern void sub_0806D0B0(Entity*); extern void sub_0807DD64(Entity*); -extern void sub_0807DDAC(Entity*, u32); +extern void sub_0807DDAC(Entity*, void(*function)(Entity*, ScriptExecutionContext*)); extern void sub_0807DDE4(Entity*); extern void sub_0806D02C(Entity*); extern u32 sub_0806F5A4(u32); extern void sub_08078784(Entity*, u32); extern void sub_0807DD50(Entity*); -extern void sub_0807DD94(Entity*, u32); +extern void sub_0807DD94(Entity*, void(*function)(Entity*, ScriptExecutionContext*)); extern s32 sub_0806ED9C(Entity*, u32, u32); extern void sub_0807000C(Entity*); extern void sub_0805E47C(Entity*); @@ -106,7 +106,6 @@ extern void sub_0806FD3C(Entity*); extern u32 sub_0801E99C(Entity*); extern void sub_0807DD50(Entity*); extern void sub_0806F118(Entity*); -extern void sub_0807DD94(Entity*, u32); extern void sub_0805ED14(u32*); extern void sub_080A7C18(u32, u32, u32); extern void sub_08068BEC(Entity*, u32); diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 68bea878..040cb763 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -418,21 +418,20 @@ void sub_0807DD80(Entity* entity, u32 unk1) { sub_0807DD64(entity); } -void sub_0807DD94(Entity* entity, u32 param_2) { - sub_0807DDAC(entity, param_2); +void sub_0807DD94(Entity* entity, void(*function)(Entity*, ScriptExecutionContext*)) { + sub_0807DDAC(entity, function); sub_0807DDE4(entity); sub_0807DE80(entity); } -// TODO: make this a proper function pointer -void sub_0807DDAC(Entity* entity, u32 address) { +void sub_0807DDAC(Entity* entity, void(*function)(Entity*, ScriptExecutionContext*)) { ScriptExecutionContext** piVar1; piVar1 = (ScriptExecutionContext**)&entity->cutsceneBeh; if (*piVar1) { ExecuteScriptCommandSet(entity, *piVar1); - if (address) { - _call_via_r6(entity, *piVar1); + if (function) { + function(entity, *piVar1); } else { sub_0807DB98(entity, *piVar1); } diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 6e6a525a..da25ab1b 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -108,7 +108,7 @@ void sub_08063410(Entity* this) { if (this->entityType.form != 0) { sub_0806346C(this); } - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); GetNextFrame(this); } diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index bb28c9f0..94a6e085 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -9,7 +9,6 @@ extern void (*gUnk_081140D4[])(Entity*); extern u16 gUnk_081140CC[]; extern void sub_0806D0B0(Entity*); extern void sub_0807DD64(Entity*); -extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern void PlaySFX(u32); extern void sub_0806D02C(Entity*); @@ -28,7 +27,7 @@ void sub_0806CF30(Entity* this) { sub_0806D0B0(this); sub_0807DD64(this); } else { - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); } diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index f127acf4..3bdc6170 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -10,7 +10,6 @@ extern void sub_0807DD50(Entity*); extern void sub_0806F118(Entity*); -extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern void sub_080600F0(Entity*); extern s32 sub_0806EDD8(Entity*, u32, u32); @@ -51,7 +50,7 @@ void ForestMinish(Entity* this) { this->interactType = 0; sub_0806F118(this); } else { - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); if (this->frameDuration != 0xf0) { sub_080600F0(this); diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index ffa5b0c6..a56ded98 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -14,7 +14,6 @@ extern void sub_0807DD50(Entity*); extern u32 sub_0806F5A4(u32); extern void sub_0806F118(Entity*); extern void sub_08078784(Entity*, u32); -extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern void sub_08078850(); extern u32 gUnk_08113F44; @@ -43,7 +42,7 @@ void MayorHagen(Entity* this) { sub_0806F118(this); break; } - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); UpdateAnimationSingleFrame(this); break; diff --git a/src/npc/melari.c b/src/npc/melari.c index ed324001..1b09ecb6 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -8,7 +8,6 @@ extern void sub_08068780(Entity*); extern void sub_08078778(Entity*); extern void sub_0807DD50(Entity*); extern void sub_0806F118(Entity*); -extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern u32 sub_080040A8(Entity*); extern void EnqueueSFX(u32); @@ -82,7 +81,7 @@ void sub_08068780(Entity* this) { this->interactType = 0; sub_0806F118(this); } else { - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); GetNextFrame(this); } diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index c3084796..deed814f 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -12,7 +12,6 @@ extern void sub_0807DD50(Entity*); extern u32 GetFacingDirection(Entity*, Entity*); extern u32 sub_0806F5A4(u32); extern void sub_0806F118(Entity*); -extern void sub_0807DD94(Entity*, u32); extern u32 UpdateFuseInteraction(Entity*); extern void sub_0807000C(Entity*); extern u32 sub_0801E99C(Entity*); @@ -43,7 +42,7 @@ void Mutoh(Entity* this) { InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4); sub_0806F118(this); } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } break; case 2: diff --git a/src/npc/percy.c b/src/npc/percy.c index 47a9fa43..3d18ed35 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -77,7 +77,7 @@ void sub_0806B41C(Entity* this) { sub_0801DFB4(this, tmp[0], tmp[1], tmp[2]); gPlayerState.field_0x8b = 3; } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } break; case 2: diff --git a/src/npc/postman.c b/src/npc/postman.c index 8f387f04..266c3fb6 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -22,7 +22,6 @@ extern void sub_0806F118(Entity*); extern u32 sub_0806F5A4(u32); extern u32 GetFacingDirection(Entity*, Entity*); extern void sub_080606D8(Entity*); -extern void sub_0807DD94(Entity*, u32); extern void sub_080788E0(Entity*); extern void EnqueueSFX(u32); extern void sub_080606C0(Entity*); @@ -145,7 +144,7 @@ void sub_08060528(Entity* this) { sub_080606D8(this); InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } } break; diff --git a/src/npc/rem.c b/src/npc/rem.c index 415f7ffa..22d13c31 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -2,11 +2,9 @@ #include "functions.h" #include "entity.h" -extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern void PlaySFX(u32); extern void sub_0806A8C8(Entity*); -extern void sub_0807DD94(Entity*, u32); extern void (*gUnk_08112260[])(Entity*); extern void (*gUnk_08112278[])(Entity*); @@ -21,7 +19,7 @@ void sub_0806a370(Entity* this) { u8* pbVar1; gUnk_08112278[this->action](this); - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); UpdateAnimationSingleFrame(this); sub_0806ED78(this); @@ -47,5 +45,5 @@ void sub_0806A3D8(Entity* this) { sub_0806A8C8(this); uVar1 = StartCutscene(this, &gUnk_08012F0C); *(u32*)&this->cutsceneBeh = (u32)uVar1; - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } diff --git a/src/npc/simon.c b/src/npc/simon.c index 7c4b7f48..deb8d73e 100644 --- a/src/npc/simon.c +++ b/src/npc/simon.c @@ -22,7 +22,7 @@ void Simon(Entity* this) { this->action++; sub_0807DD50(this); } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } } diff --git a/src/npc/smith.c b/src/npc/smith.c index 430b12af..50772b83 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -12,8 +12,6 @@ extern void PlaySFX(u32); extern void sub_0807000C(Entity*); extern u32 sub_0801E99C(Entity*); extern void sub_0807DD50(Entity*); -extern void sub_0807DD94(Entity*, u32); -extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern u32 UpdateFuseInteraction(Entity*); extern u32 GetAnimationState(Entity*); @@ -118,7 +116,7 @@ void sub_08066178(Entity* this) { } void sub_080661B0(Entity* this) { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } void sub_080661BC(Entity* this) { @@ -131,12 +129,12 @@ void sub_080661BC(Entity* this) { InitAnimationForceUpdate(this, this->field_0x80.HWORD); } } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } } void sub_08066200(Entity* this) { - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); UpdateAnimationSingleFrame(this); } diff --git a/src/npc/stamp.c b/src/npc/stamp.c index f77b1fdd..652e6710 100644 --- a/src/npc/stamp.c +++ b/src/npc/stamp.c @@ -8,7 +8,6 @@ extern void sub_0805E47C(Entity*); extern void sub_0805E584(); extern void sub_0807DD64(); extern void sub_08062CA4(); -extern void sub_0807DDAC(); extern void sub_0807DDE4(); extern u32 CheckKinstoneFused(); @@ -68,7 +67,7 @@ void sub_08062C7C(Entity* ent) { } void sub_08062CA4(Entity* ent) { - sub_0807DDAC(ent, 0); + sub_0807DDAC(ent, NULL); sub_0807DDE4(ent); GetNextFrame(ent); } diff --git a/src/npc/talon.c b/src/npc/talon.c index b4ddbe84..302321de 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -77,7 +77,7 @@ void sub_08065648(Entity* this) { this->interactType = 0; sub_0806F118(this); } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } } @@ -118,7 +118,7 @@ void sub_080656D4(Entity* this) { } } else { label2: - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } } } diff --git a/src/npc/teachers.c b/src/npc/teachers.c index 2e0e99fd..b633b3d0 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -9,7 +9,6 @@ extern void sub_0807DD50(Entity*); extern u32 GetFacingDirection(Entity*, Entity*); extern u32 sub_0806F5A4(u32); extern void sub_0806F118(Entity*); -extern void sub_0807DD94(Entity*, u32); extern void sub_08078784(Entity*, u32); extern u32 UpdateFuseInteraction(Entity*); extern void sub_0807000C(Entity*); @@ -37,7 +36,7 @@ void Teachers(Entity* this) { (this->animIndex & -4) + sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); sub_0806F118(this); } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } break; case 2: diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 3eab0a5a..6ed67b2e 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -111,7 +111,7 @@ void sub_0806ACC4(Entity* this) { this->interactType = 0; sub_0806F118(this); } else { - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0806AEA8(this); if (this->entityType.parameter == 10 && this->interactType) { this->action = 2; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 1c05c1a4..90e2490a 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -30,7 +30,6 @@ extern void sub_08061D64(Entity*); extern void sub_0806F118(Entity*); extern u32 sub_0806F5A4(u32); extern u32 GetFacingDirection(Entity*, Entity*); -extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern void sub_08062048(Entity*); extern void sub_08078784(Entity*, u32); @@ -144,7 +143,7 @@ void sub_08061D64(Entity* this) { this->field_0x68.HALF.HI = this->animIndex; InitializeAnimation(this, (this->animIndex & -4) + sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); } else { - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); if (this->frameDuration == 0xff) { this->frameDuration = gUnk_0810B680[this->entityType.form].unk2; diff --git a/src/npc/windTribespeople.c b/src/npc/windTribespeople.c index bb09a0c8..b1499f01 100644 --- a/src/npc/windTribespeople.c +++ b/src/npc/windTribespeople.c @@ -11,7 +11,6 @@ extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); extern void sub_0807DD50(Entity*); extern void sub_0806C7D4(Entity*); extern void sub_0806F118(Entity*); -extern void sub_0807DD94(Entity*, u32); extern void sub_0807DD80(Entity*, u32*); extern u32 sub_0801E99C(); extern void sub_08078784(Entity*, u32); @@ -54,7 +53,7 @@ void sub_0806C7D4(Entity* this) { this->interactType = '\0'; sub_0806F118(this); } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); if ((this->entityType.parameter == 3) && (!CheckGlobalFlag(WARP_EVENT_END)) && (CheckLocalFlag(0x63)) && (CheckRoomFlag(0))) { (this->entityType).parameter = 7; diff --git a/src/npc/zelda.c b/src/npc/zelda.c index b7dec220..ea12cf4b 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -6,7 +6,6 @@ extern void PrependEntityToList(Entity*, u32); extern void sub_0807DD50(Entity*); -extern void sub_0807DD94(Entity*, u32); extern Entity* FindEntityBySubtype(u32, u32); void CopyPosition(Entity*, Entity*); void sub_08068680(Entity*, Entity*); @@ -37,7 +36,7 @@ void sub_08066CCC(Entity* ent) { } void sub_08066CF8(Entity* ent) { - sub_0807DD94(ent, 0); + sub_0807DD94(ent, NULL); } void sub_08066D04(Entity* ent) { diff --git a/src/object/windcrest.c b/src/object/windcrest.c index ff559344..4b96f901 100644 --- a/src/object/windcrest.c +++ b/src/object/windcrest.c @@ -4,7 +4,6 @@ #include "save.h" extern void sub_0807DD64(Entity*); -extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern void sub_08078850(Entity*, u32, u32, u8*); extern void PlaySFX(u32); @@ -18,7 +17,7 @@ void Windcrest(Entity* this) { this->frameIndex = 0; sub_0807DD64(this); } - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); } From 4598ae2ae915e14b66dc16a90ad4bfe639165e7c Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 05:57:46 +0100 Subject: [PATCH 42/51] formatting --- src/code_0807CC3C.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 040cb763..de59f4f4 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -5,7 +5,7 @@ #include "entity.h" #include "save.h" -typedef struct Thing{ +typedef struct Thing { u16 unk_1; u16 unk_2; u32 unk_3; @@ -418,13 +418,13 @@ void sub_0807DD80(Entity* entity, u32 unk1) { sub_0807DD64(entity); } -void sub_0807DD94(Entity* entity, void(*function)(Entity*, ScriptExecutionContext*)) { +void sub_0807DD94(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) { sub_0807DDAC(entity, function); sub_0807DDE4(entity); sub_0807DE80(entity); } -void sub_0807DDAC(Entity* entity, void(*function)(Entity*, ScriptExecutionContext*)) { +void sub_0807DDAC(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) { ScriptExecutionContext** piVar1; piVar1 = (ScriptExecutionContext**)&entity->cutsceneBeh; From 9f3cc47f992ed1e8f989ff34481b529b22e00bdf Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 06:09:38 +0100 Subject: [PATCH 43/51] matched sub_0807CF88 --- src/code_0807CC3C.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index de59f4f4..6c4b32a6 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -38,9 +38,8 @@ void sub_0807DF38(void); void sub_0807DE80(Entity* entity); void sub_0807DB98(Entity*, ScriptExecutionContext*); -NONMATCH("asm/non_matching/code_0807CC3C/sub_0807CF88.inc", u32 sub_0807CF88(u32 arg0, u8* arg1)) { - u32 signature; - s16 local1[2]; +u32 sub_0807CF88(u32 arg0, u8* arg1) { + Thing thing; u32 retval; struct_0807D1C4* ptr; @@ -49,18 +48,18 @@ NONMATCH("asm/non_matching/code_0807CC3C/sub_0807CF88.inc", u32 sub_0807CF88(u32 ptr = sub_0807D1C4(arg0); - signature = 'MCZ3'; - l1prep = sub_0807D1A4((u16*)&signature, 4); + thing.unk_3 = 'MCZ3'; + l1prep = sub_0807D1A4((u16*)&thing.unk_3, 4); l1prep += sub_0807D1A4((u16*)arg1, ptr->field_0x0); - local1[0] = l1prep; - local1[1] = -(u32)l1prep; + thing.unk_1 = l1prep; + thing.unk_2 = -(u32)l1prep; e0 = sub_0807D20C(ptr->field_0x6, (const char*)arg1, ptr->field_0x0); if (e0) { - e0 = sub_0807D184(ptr->field_0x2, (const char*)local1); + e0 = sub_0807D184(ptr->field_0x2, (const char*)&thing.unk_1); } e1 = sub_0807D20C(ptr->field_0x8, (const char*)arg1, ptr->field_0x0); if (e1) { - e1 = sub_0807D184(ptr->field_0x4, (const char*)local1); + e1 = sub_0807D184(ptr->field_0x4, (const char*)&thing.unk_1); } retval = 0; @@ -69,7 +68,6 @@ NONMATCH("asm/non_matching/code_0807CC3C/sub_0807CF88.inc", u32 sub_0807CF88(u32 } return retval; } -END_NONMATCH NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D008.inc", u32 sub_0807D008(u32 param_1, SaveFile* saveFile)) { u32 set_0; From 91ce8f1cf8920bb0ee5d92b1dae5c598c0b21ba5 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 06:13:08 +0100 Subject: [PATCH 44/51] cleaned code --- .../code_0807CC3C/sub_0807CF88.inc | 71 ------------------- src/code_0807CC3C.c | 18 ++--- 2 files changed, 9 insertions(+), 80 deletions(-) delete mode 100644 asm/non_matching/code_0807CC3C/sub_0807CF88.inc diff --git a/asm/non_matching/code_0807CC3C/sub_0807CF88.inc b/asm/non_matching/code_0807CC3C/sub_0807CF88.inc deleted file mode 100644 index 18546c4a..00000000 --- a/asm/non_matching/code_0807CC3C/sub_0807CF88.inc +++ /dev/null @@ -1,71 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - push {r4, r5, r6, r7, lr} - sub sp, #8 - adds r7, r1, #0 - bl sub_0807D1C4 - adds r6, r0, #0 - ldr r0, _0807D004 @ =0x4D435A33 - mov r5, sp - str r0, [sp, #4] - add r0, sp, #4 - movs r1, #4 - bl sub_0807D1A4 - adds r4, r0, #0 - lsls r4, r4, #0x10 - lsrs r4, r4, #0x10 - ldrh r1, [r6] - adds r0, r7, #0 - bl sub_0807D1A4 - adds r4, r4, r0 - lsls r4, r4, #0x10 - lsrs r4, r4, #0x10 - mov r0, sp - strh r4, [r0] - lsls r4, r4, #0x10 - asrs r4, r4, #0x10 - rsbs r4, r4, #0 - strh r4, [r5, #2] - ldrh r0, [r6, #6] - ldrh r2, [r6] - adds r1, r7, #0 - bl sub_0807D20C - adds r4, r0, #0 - cmp r4, #0 - beq _0807CFDC - ldrh r0, [r6, #2] - mov r1, sp - bl sub_0807D184 - adds r4, r0, #0 -_0807CFDC: - ldrh r0, [r6, #8] - ldrh r2, [r6] - adds r1, r7, #0 - bl sub_0807D20C - cmp r0, #0 - beq _0807CFF2 - ldrh r0, [r6, #4] - mov r1, sp - bl sub_0807D184 -_0807CFF2: - movs r1, #0 - cmp r4, #0 - bne _0807CFFC - cmp r0, #0 - beq _0807CFFE -_0807CFFC: - movs r1, #1 -_0807CFFE: - adds r0, r1, #0 - add sp, #8 - pop {r4, r5, r6, r7, pc} - .align 2, 0 -_0807D004: .4byte 0x4D435A33 - - .syntax divided diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 6c4b32a6..c88fb1d9 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -73,32 +73,32 @@ NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D008.inc", u32 sub_0807D008(u32 u32 set_0; char auStack32[8]; - struct_0807D1C4* thing; + struct_0807D1C4* unk_s; u32 t1; u32 t2; u32 ret; u32 temp; - thing = sub_0807D1C4(param_1); - t1 = sub_0807D0EC(thing->field_0x2, auStack32); + unk_s = sub_0807D1C4(param_1); + t1 = sub_0807D0EC(unk_s->field_0x2, auStack32); if (t1 == 2) { - if ((sub_0807D1D8(thing->field_0x6, (char*)saveFile, thing->field_0x0) == 0) || - (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)thing->field_0x0) == 0)) { + if ((sub_0807D1D8(unk_s->field_0x6, (char*)saveFile, unk_s->field_0x0) == 0) || + (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)unk_s->field_0x0) == 0)) { t1 = 0; } else { return 1; } } - t2 = sub_0807D0EC(thing->field_0x4, auStack32); + t2 = sub_0807D0EC(unk_s->field_0x4, auStack32); if (t2 == 2) { - if ((sub_0807D1D8(thing->field_0x8, (char*)saveFile, thing->field_0x0) != 0) && - (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)thing->field_0x0) != 0)) { + if ((sub_0807D1D8(unk_s->field_0x8, (char*)saveFile, unk_s->field_0x0) != 0) && + (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)unk_s->field_0x0) != 0)) { return 1; } t2 = 0; } set_0 = 0; - CpuSet(&set_0, saveFile, thing->field_0x0 >> 2 | CPU_SET_SRC_FIXED | CPU_SET_32BIT); + CpuSet(&set_0, saveFile, unk_s->field_0x0 >> 2 | CPU_SET_SRC_FIXED | CPU_SET_32BIT); temp = t1 | t2; ret = 0; if (temp == 0) { From aaea9b89f6916be97e39920a57ad589e9a412a6b Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 06:31:07 +0100 Subject: [PATCH 45/51] improved signature of StartCutscene --- include/functions.h | 2 +- src/code_0807CC3C.c | 20 ++++++++++---------- src/npc/forestMinish.c | 2 +- src/npc/rem.c | 4 ++-- src/npc/talon.c | 2 +- src/object/houseDoorExterior.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/functions.h b/include/functions.h index d53ca901..7015294b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -24,7 +24,7 @@ extern u32 CheckKinstoneFused(u32); extern void ForceEquipItem(u8, u8); extern void LoadRoomEntityList(); void CopyPosition(Entity*, Entity*); -extern u32* StartCutscene(Entity*, u8*); +extern ScriptExecutionContext* StartCutscene(Entity*, u16*); extern void ResolveEntityOnTop(Entity*, Entity*); extern void EnemyFunctionHandler(Entity*, void (*const funcs[])(Entity*)); extern u32 GetAnimationState(Entity*); diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index c88fb1d9..2e56b920 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -27,8 +27,8 @@ extern s32 __divsi3(s32, s32); extern void _call_via_r6(Entity*, ScriptExecutionContext*); extern u16 sub_080B18DC(u16, const char*); -void sub_0807DB88(ScriptExecutionContext* context, u32 unk1); -void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1); +void sub_0807DB88(ScriptExecutionContext* context, u16* unk1); +void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* unk1); u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3); u32 sub_0807D128(const Thing* unk_1); u16 sub_0807D1A4(u16* unk_1, u32 unk_2); @@ -248,7 +248,7 @@ NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D6D8.inc", void sub_0807D6D8(u3 END_NONMATCH void sub_0807DA70(void) { - _DmaZero(&gUnk_02033280, 0xc); + _DmaZero(&gUnk_02033280, sizeof(gUnk_02033280)); _DmaZero(&gScriptExecutionContextArray, sizeof(gScriptExecutionContextArray)); _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); gUnk_02033280.unk_08 = 8; @@ -271,17 +271,17 @@ void DestroyScriptExecutionContext(ScriptExecutionContext* context) { _DmaZero(context, sizeof(ScriptExecutionContext)); } -u32* StartCutscene(Entity* entity, u8* param_2) { +ScriptExecutionContext* StartCutscene(Entity* entity, u16* unk_2) { ScriptExecutionContext* puVar1; puVar1 = CreateScriptExecutionContext(); if (puVar1) { - sub_0807DAF0(entity, puVar1, (u32)param_2); + sub_0807DAF0(entity, puVar1, unk_2); } - return (u32*)puVar1; + return puVar1; } -void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u32 unk1) { +void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* unk1) { entity->flags = entity->flags | 2; *(ScriptExecutionContext**)&entity->cutsceneBeh = context; sub_0807DB88(context, unk1); @@ -320,9 +320,9 @@ ScriptExecutionContext* sub_0807DB68(Entity* entity, u16* unk1) { return context; } -void sub_0807DB88(ScriptExecutionContext* context, u32 unk1) { +void sub_0807DB88(ScriptExecutionContext* context, u16* unk1) { _DmaZero(context, sizeof(ScriptExecutionContext)); - context->unk_00 = (u16*)unk1; + context->unk_00 = unk1; } void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) { @@ -411,7 +411,7 @@ void sub_0807DD64(Entity* entity) { entity->field_0x82.HWORD = 0; } -void sub_0807DD80(Entity* entity, u32 unk1) { +void sub_0807DD80(Entity* entity, u16* unk1) { sub_0807DB88(*(ScriptExecutionContext**)&entity->cutsceneBeh, unk1); sub_0807DD64(entity); } diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index 3bdc6170..71c84161 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -40,7 +40,7 @@ void ForestMinish(Entity* this) { this->field_0x68.HALF.HI = this->animationState = this->actionDelay << 1; this->actionDelay = 0; sub_0805E3A0(this, 2); - StartCutscene(this, gUnk_08109D18[this->entityType.parameter]); + StartCutscene(this, (u16*)gUnk_08109D18[this->entityType.parameter]); sub_0807DD50(this); } break; diff --git a/src/npc/rem.c b/src/npc/rem.c index 22d13c31..b1233acf 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -37,13 +37,13 @@ void sub_0806a370(Entity* this) { } void sub_0806A3D8(Entity* this) { - u32* uVar1; + ScriptExecutionContext* uVar1; this->action = 1; this->actionDelay = 0xb4; sub_0805E3A0(this, 2); sub_0806A8C8(this); uVar1 = StartCutscene(this, &gUnk_08012F0C); - *(u32*)&this->cutsceneBeh = (u32)uVar1; + *(ScriptExecutionContext**)&this->cutsceneBeh = uVar1; sub_0807DD94(this, NULL); } diff --git a/src/npc/talon.c b/src/npc/talon.c index 302321de..867ede74 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -106,7 +106,7 @@ void sub_080656D4(Entity* this) { } else { if (this->interactType != 0) { if (GetInventoryValue(0x37) != 0) { // keyLonLon - StartCutscene(this, &gUnk_0800B41C); + StartCutscene(this, (u16*)&gUnk_0800B41C); goto label2; } else { this->field_0x68.HALF.HI = this->action; diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 170f6e33..3c43e4b1 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -64,7 +64,7 @@ void sub_080866D8(Entity* this) { UpdateSpriteForCollisionLayer(entity); *((u32*)(&this->field_0x68)) |= mask; if (prop->unk8) { - *((u32**)(&entity->cutsceneBeh)) = StartCutscene(entity, prop->unk8); + *((ScriptExecutionContext **)(&entity->cutsceneBeh)) = StartCutscene(entity, (u16*)prop->unk8); } } } From 126feb121ff4409668f51a4a089fc87c25bb545c Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 06:33:34 +0100 Subject: [PATCH 46/51] improved signature of StartPlayerScript --- include/script.h | 8 ++++---- src/code_0807CC3C.c | 4 ++-- src/executeScriptCommandSet.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/script.h b/include/script.h index 73d860e1..a3f29c84 100644 --- a/include/script.h +++ b/include/script.h @@ -4,17 +4,17 @@ #include "global.h" typedef struct { - u16 * unk_00; + u16* unk_00; u32 unk_04; u32 unk_08; - u8 unk_0C[0x4];//unused + u8 unk_0C[0x4]; // unused u16 unk_10; u16 unk_12; u32 unk_14; u8 unk_18; u8 unk_19; u8 unk_1A; - u8 unk_1B;//unused + u8 unk_1B; // unused union SplitWord unk_1C; union SplitWord unk_20; } ScriptExecutionContext; @@ -26,7 +26,7 @@ extern u32 GetNextScriptCommandWord(u16*); extern u32 GetNextScriptCommandWordAfterCommandMetadata(u16*); extern u32 GetNextScriptCommandHalfwordAfterCommandMetadata(u16*); -extern void StartPlayerScript(u32); +extern void StartPlayerScript(u16*); extern void sub_0807DEDC(Entity*, ScriptExecutionContext*, u32, u32); diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 2e56b920..068f3e8d 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -295,11 +295,11 @@ void UnloadCutsceneData(Entity* entity) { } } -void StartPlayerScript(u32 unk1) { +void StartPlayerScript(u16* unk1) { Entity* player; _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); - gPlayerScriptExecutionContext.unk_00 = (u16*)unk1; + gPlayerScriptExecutionContext.unk_00 = unk1; player = &gPlayerEntity; *(ScriptExecutionContext**)&player->cutsceneBeh = &gPlayerScriptExecutionContext; gPlayerState.playerAction = 0x1c; diff --git a/src/executeScriptCommandSet.c b/src/executeScriptCommandSet.c index 7895c28f..3a3edc53 100644 --- a/src/executeScriptCommandSet.c +++ b/src/executeScriptCommandSet.c @@ -752,7 +752,7 @@ void sub_0807E898(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807E8C4(Entity* unk1, ScriptExecutionContext* unk2) { - StartPlayerScript(GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00)); + StartPlayerScript((u16*)GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00)); } void sub_0807E8D4(Entity* unk1, ScriptExecutionContext* unk2) { From 2a7cb5846f28320756612a7a0f9547de22e6de80 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 07:24:19 +0100 Subject: [PATCH 47/51] cleaned up some code --- src/code_0807CC3C.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 068f3e8d..db13b635 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -23,8 +23,6 @@ extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); extern void DeleteThisEntity(void); extern u32 sub_080B180C(u32, const char*); extern void sub_0801C4A0(u32); -extern s32 __divsi3(s32, s32); -extern void _call_via_r6(Entity*, ScriptExecutionContext*); extern u16 sub_080B18DC(u16, const char*); void sub_0807DB88(ScriptExecutionContext* context, u16* unk1); @@ -255,15 +253,15 @@ void sub_0807DA70(void) { } ScriptExecutionContext* CreateScriptExecutionContext(void) { - ScriptExecutionContext* puVar1; + ScriptExecutionContext* context; - puVar1 = gScriptExecutionContextArray; + context = gScriptExecutionContextArray; do { - if (puVar1->unk_00 == 0) { - return puVar1; + if (context->unk_00 == 0) { + return context; } - puVar1++; - } while (puVar1 < gScriptExecutionContextArray + ARRAY_COUNT(gScriptExecutionContextArray)); + context++; + } while (context < gScriptExecutionContextArray + ARRAY_COUNT(gScriptExecutionContextArray)); return NULL; } @@ -272,13 +270,13 @@ void DestroyScriptExecutionContext(ScriptExecutionContext* context) { } ScriptExecutionContext* StartCutscene(Entity* entity, u16* unk_2) { - ScriptExecutionContext* puVar1; + ScriptExecutionContext* context; - puVar1 = CreateScriptExecutionContext(); - if (puVar1) { - sub_0807DAF0(entity, puVar1, unk_2); + context = CreateScriptExecutionContext(); + if (context) { + sub_0807DAF0(entity, context, unk_2); } - return puVar1; + return context; } void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* unk1) { From d8b04c0887b50542b305529efa3eba567464be69 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 07:36:00 +0100 Subject: [PATCH 48/51] moved code to executeScriptCommandSet.c --- src/code_0807CC3C.c | 310 +--------------------------------- src/executeScriptCommandSet.c | 307 +++++++++++++++++++++++++++++++++ 2 files changed, 308 insertions(+), 309 deletions(-) diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index db13b635..7518f863 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -11,30 +11,17 @@ typedef struct Thing { u32 unk_3; } Thing; -extern u8 gUnk_0811E514[]; -extern u8 gUnk_0811E510[]; extern struct_0807D1C4 gUnk_0811E4BC[]; extern const char gUnk_0811E4B4[8]; -extern ScriptExecutionContext gPlayerScriptExecutionContext; -extern ScriptExecutionContext gScriptExecutionContextArray[0x20]; -extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); -extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); -extern void DeleteThisEntity(void); extern u32 sub_080B180C(u32, const char*); -extern void sub_0801C4A0(u32); extern u16 sub_080B18DC(u16, const char*); -void sub_0807DB88(ScriptExecutionContext* context, u16* unk1); -void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* unk1); u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3); -u32 sub_0807D128(const Thing* unk_1); +u32 sub_0807D128(const Thing* thing); u16 sub_0807D1A4(u16* unk_1, u32 unk_2); u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3); u32 sub_0807D0EC(u32 unk_1, const char* unk_2); -void sub_0807DF38(void); -void sub_0807DE80(Entity* entity); -void sub_0807DB98(Entity*, ScriptExecutionContext*); u32 sub_0807CF88(u32 arg0, u8* arg1) { Thing thing; @@ -244,298 +231,3 @@ END_NONMATCH NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D6D8.inc", void sub_0807D6D8(u32 unk_1, u32 unk_2)) { } END_NONMATCH - -void sub_0807DA70(void) { - _DmaZero(&gUnk_02033280, sizeof(gUnk_02033280)); - _DmaZero(&gScriptExecutionContextArray, sizeof(gScriptExecutionContextArray)); - _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); - gUnk_02033280.unk_08 = 8; -} - -ScriptExecutionContext* CreateScriptExecutionContext(void) { - ScriptExecutionContext* context; - - context = gScriptExecutionContextArray; - do { - if (context->unk_00 == 0) { - return context; - } - context++; - } while (context < gScriptExecutionContextArray + ARRAY_COUNT(gScriptExecutionContextArray)); - return NULL; -} - -void DestroyScriptExecutionContext(ScriptExecutionContext* context) { - _DmaZero(context, sizeof(ScriptExecutionContext)); -} - -ScriptExecutionContext* StartCutscene(Entity* entity, u16* unk_2) { - ScriptExecutionContext* context; - - context = CreateScriptExecutionContext(); - if (context) { - sub_0807DAF0(entity, context, unk_2); - } - return context; -} - -void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* unk1) { - entity->flags = entity->flags | 2; - *(ScriptExecutionContext**)&entity->cutsceneBeh = context; - sub_0807DB88(context, unk1); -} - -void UnloadCutsceneData(Entity* entity) { - if ((entity->flags & 2)) { - entity->flags = entity->flags & 0xfd; - DestroyScriptExecutionContext(*(ScriptExecutionContext**)&entity->cutsceneBeh); - *(ScriptExecutionContext**)&entity->cutsceneBeh = NULL; - } -} - -void StartPlayerScript(u16* unk1) { - Entity* player; - - _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); - gPlayerScriptExecutionContext.unk_00 = unk1; - player = &gPlayerEntity; - *(ScriptExecutionContext**)&player->cutsceneBeh = &gPlayerScriptExecutionContext; - gPlayerState.playerAction = 0x1c; - gPlayerState.field_0x3a = 0; - gPlayerState.field_0x39 = 0; - gPlayerState.field_0x38 = 0; -} - -ScriptExecutionContext* sub_0807DB68(Entity* entity, u16* unk1) { - ScriptExecutionContext* context; - - context = CreateScriptExecutionContext(); - if (context) { - entity->flags |= 2; - *(ScriptExecutionContext**)&entity->field_0x3c = context; - context->unk_00 = unk1; - } - return context; -} - -void sub_0807DB88(ScriptExecutionContext* context, u16* unk1) { - _DmaZero(context, sizeof(ScriptExecutionContext)); - context->unk_00 = unk1; -} - -void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) { - u32 switchVar; - - while (context->unk_08) { - switchVar = (~context->unk_08 + 1) & context->unk_08; - context->unk_08 ^= switchVar; - switch (switchVar) { - case 1: - entity->field_0x80.HWORD = 0; - break; - case 2: - entity->field_0x80.HWORD = 4; - break; - case 4: - break; - case 8: - entity->field_0x20 = 0x18000; - break; - case 0x10: - CreateSpeechBubbleExclamationMark(entity, 8, -0x18); - break; - case 0x20: - CreateSpeechBubbleQuestionMark(entity, 8, -0x18); - break; - case 0x40: - DestroyScriptExecutionContext(context); - DeleteThisEntity(); - case 0x80: - entity->spriteSettings.b.draw = 1; - break; - case 0x100: - entity->spriteSettings.b.draw = 0; - break; - case 0x200: - entity->spriteOffsetY = 0; - entity->spriteOffsetX = 0; - entity->field_0x82.HWORD = 0; - break; - case 0x400: - entity->field_0x82.HWORD |= 2; - break; - case 0x800: - entity->field_0x82.HWORD &= 0xfffd; - break; - case 0x1000: - entity->field_0x82.HWORD &= 0xfffe; - break; - case 0x2000: - entity->field_0x82.HWORD |= 1; - break; - case 0x4000: - entity->field_0x82.HWORD |= 8; - break; - case 0x8000: - entity->field_0x82.HWORD ^= 4; - break; - case 0x10000: - entity->field_0x82.HWORD ^= 0x10; - break; - case 0x20000: - entity->spriteSettings.b.flipX ^= 1; - break; - case 0x40000: - entity->field_0x82.HWORD |= 0x20; - break; - case 0x80000: - entity->field_0x82.HWORD &= 0xffdf; - break; - default: - break; - } - } -} - -void sub_0807DD50(Entity* entity) { - sub_0807DD64(entity); - sub_0807DD94(entity, 0); -} - -void sub_0807DD64(Entity* entity) { - entity->field_0xf = entity->animationState; - entity->animIndex = 0xff; - entity->field_0x80.HWORD = 0; - entity->field_0x82.HWORD = 0; -} - -void sub_0807DD80(Entity* entity, u16* unk1) { - sub_0807DB88(*(ScriptExecutionContext**)&entity->cutsceneBeh, unk1); - sub_0807DD64(entity); -} - -void sub_0807DD94(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) { - sub_0807DDAC(entity, function); - sub_0807DDE4(entity); - sub_0807DE80(entity); -} - -void sub_0807DDAC(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) { - ScriptExecutionContext** piVar1; - - piVar1 = (ScriptExecutionContext**)&entity->cutsceneBeh; - if (*piVar1) { - ExecuteScriptCommandSet(entity, *piVar1); - if (function) { - function(entity, *piVar1); - } else { - sub_0807DB98(entity, *piVar1); - } - if (!entity->next) { - DeleteThisEntity(); - } - } -} - -void sub_0807DDE4(Entity* entity) { - u32 temp; - u32 switchVar; - u32 loopVar; - - loopVar = entity->field_0x82.HWORD; - while (loopVar) { - switchVar = (~loopVar + 1) & loopVar; - loopVar = loopVar ^ switchVar; - switch (switchVar) { - case 2: - if (entity->entityType.type == 7) { - sub_0806ED78(entity); - } else { - sub_0800445C(entity); - } - break; - case 8: - if ((gScreenTransition.frameCount & 3) == 0) { - temp = (entity->field_0xf + 2U) & 7; - entity->animationState = temp; - entity->field_0xf = temp; - } - break; - case 0x10: - if ((gScreenTransition.frameCount & 1) == 0) { - entity->spriteOffsetX = gUnk_0811E510[Random() & 3]; - } - break; - case 0x20: - sub_08003FC4(entity, 0x2000); - break; - } - } -} - -void sub_0807DE80(Entity* entity) { - u32 local1; - u16 local2; - - u32 temp; - - local2 = entity->field_0x80.HWORD; - if (local2 < 8) { - if (entity->field_0x82.HWORD & 1) { - u32 t1, t2; - t1 = local2 & 0xfc; - t2 = entity->field_0xf >> 1; - local2 = t1 + t2; - } else { - u32 t1, t2; - t1 = local2 & 0xfc; - t2 = entity->animationState >> 1; - local2 = t1 + t2; - entity->field_0xf = entity->animationState; - } - } - if (local2 != entity->animIndex) { - InitAnimationForceUpdate(entity, local2); - } - temp = entity->field_0x82.HWORD & 4; - local1 = 1; - if (temp) { - local1 = 2; - } - sub_080042BA(entity, local1); -} - -void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 arg3) { - int temp; - s32 t0, t1; - - context->unk_19 = 8; - context->unk_08 |= 2; - context->unk_14 = 0; - context->unk_1C.HALF.HI = arg2; - context->unk_20.HALF.HI = arg3; - t0 = context->unk_1C.HALF.HI - entity->x.HALF.HI; - t1 = context->unk_20.HALF.HI - entity->y.HALF.HI; - temp = sub_080045DA(t0, t1); - entity->direction = temp; - entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(temp << 0x18) >> 0x1c]; -} - -void sub_0807DF28(void) { - sub_0807DF38(); - sub_08079184(); - sub_08077B20(); -} - -void sub_0807DF38(void) { - gUnk_0200AF00.filler0[1] = 0xff; - gUnk_02034490[0] = 0xff; -} - -void sub_0807DF50(void) { - gUnk_02034490[0] = 0; - gUnk_0200AF00.filler0[1] = 0; - sub_0801C4A0(0); - sub_080791D0(); - sub_08079184(); -} \ No newline at end of file diff --git a/src/executeScriptCommandSet.c b/src/executeScriptCommandSet.c index 3a3edc53..2f38b5f3 100644 --- a/src/executeScriptCommandSet.c +++ b/src/executeScriptCommandSet.c @@ -8,6 +8,10 @@ #include "functions.h" #include "save.h" +void sub_0807DAF0(Entity*, ScriptExecutionContext*, u16*); +void sub_0807DB88(ScriptExecutionContext*, u16*); +void sub_0807DE80(Entity*); +void sub_0807DF38(void); void nullsub_507 (Entity*, ScriptExecutionContext*); void sub_0807E004(Entity*, ScriptExecutionContext*); void sub_0807E014(Entity*, ScriptExecutionContext*); @@ -147,6 +151,10 @@ void sub_0807F0A4(Entity*, ScriptExecutionContext*); void sub_0807F0B4(Entity*, ScriptExecutionContext*); void sub_0807F0C8(Entity*, ScriptExecutionContext*); +extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32); +extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32); +extern void sub_0801C4A0(u32); + void (* const gUnk_0811E524[])() = { nullsub_507, sub_0807E004, @@ -290,6 +298,305 @@ void (* const gUnk_0811E524[])() = { }; extern const u16 gUnk_08016984; +extern u8 gUnk_0811E514[]; +extern u8 gUnk_0811E510[]; +extern ScriptExecutionContext gPlayerScriptExecutionContext; +extern ScriptExecutionContext gScriptExecutionContextArray[0x20]; + +void sub_0807DA70(void) { + _DmaZero(&gUnk_02033280, sizeof(gUnk_02033280)); + _DmaZero(&gScriptExecutionContextArray, sizeof(gScriptExecutionContextArray)); + _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); + gUnk_02033280.unk_08 = 8; +} + +ScriptExecutionContext* CreateScriptExecutionContext(void) { + ScriptExecutionContext* context; + + context = gScriptExecutionContextArray; + do { + if (context->unk_00 == 0) { + return context; + } + context++; + } while (context < gScriptExecutionContextArray + ARRAY_COUNT(gScriptExecutionContextArray)); + return NULL; +} + +void DestroyScriptExecutionContext(ScriptExecutionContext* context) { + _DmaZero(context, sizeof(ScriptExecutionContext)); +} + +ScriptExecutionContext* StartCutscene(Entity* entity, u16* unk_2) { + ScriptExecutionContext* context; + + context = CreateScriptExecutionContext(); + if (context) { + sub_0807DAF0(entity, context, unk_2); + } + return context; +} + +void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* unk1) { + entity->flags = entity->flags | 2; + *(ScriptExecutionContext**)&entity->cutsceneBeh = context; + sub_0807DB88(context, unk1); +} + +void UnloadCutsceneData(Entity* entity) { + if ((entity->flags & 2)) { + entity->flags = entity->flags & 0xfd; + DestroyScriptExecutionContext(*(ScriptExecutionContext**)&entity->cutsceneBeh); + *(ScriptExecutionContext**)&entity->cutsceneBeh = NULL; + } +} + +void StartPlayerScript(u16* unk1) { + Entity* player; + + _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); + gPlayerScriptExecutionContext.unk_00 = unk1; + player = &gPlayerEntity; + *(ScriptExecutionContext**)&player->cutsceneBeh = &gPlayerScriptExecutionContext; + gPlayerState.playerAction = 0x1c; + gPlayerState.field_0x3a = 0; + gPlayerState.field_0x39 = 0; + gPlayerState.field_0x38 = 0; +} + +ScriptExecutionContext* sub_0807DB68(Entity* entity, u16* unk1) { + ScriptExecutionContext* context; + + context = CreateScriptExecutionContext(); + if (context) { + entity->flags |= 2; + *(ScriptExecutionContext**)&entity->field_0x3c = context; + context->unk_00 = unk1; + } + return context; +} + +void sub_0807DB88(ScriptExecutionContext* context, u16* unk1) { + _DmaZero(context, sizeof(ScriptExecutionContext)); + context->unk_00 = unk1; +} + +void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) { + u32 switchVar; + + while (context->unk_08) { + switchVar = (~context->unk_08 + 1) & context->unk_08; + context->unk_08 ^= switchVar; + switch (switchVar) { + case 1: + entity->field_0x80.HWORD = 0; + break; + case 2: + entity->field_0x80.HWORD = 4; + break; + case 4: + break; + case 8: + entity->field_0x20 = 0x18000; + break; + case 0x10: + CreateSpeechBubbleExclamationMark(entity, 8, -0x18); + break; + case 0x20: + CreateSpeechBubbleQuestionMark(entity, 8, -0x18); + break; + case 0x40: + DestroyScriptExecutionContext(context); + DeleteThisEntity(); + case 0x80: + entity->spriteSettings.b.draw = 1; + break; + case 0x100: + entity->spriteSettings.b.draw = 0; + break; + case 0x200: + entity->spriteOffsetY = 0; + entity->spriteOffsetX = 0; + entity->field_0x82.HWORD = 0; + break; + case 0x400: + entity->field_0x82.HWORD |= 2; + break; + case 0x800: + entity->field_0x82.HWORD &= 0xfffd; + break; + case 0x1000: + entity->field_0x82.HWORD &= 0xfffe; + break; + case 0x2000: + entity->field_0x82.HWORD |= 1; + break; + case 0x4000: + entity->field_0x82.HWORD |= 8; + break; + case 0x8000: + entity->field_0x82.HWORD ^= 4; + break; + case 0x10000: + entity->field_0x82.HWORD ^= 0x10; + break; + case 0x20000: + entity->spriteSettings.b.flipX ^= 1; + break; + case 0x40000: + entity->field_0x82.HWORD |= 0x20; + break; + case 0x80000: + entity->field_0x82.HWORD &= 0xffdf; + break; + default: + break; + } + } +} + +void sub_0807DD50(Entity* entity) { + sub_0807DD64(entity); + sub_0807DD94(entity, 0); +} + +void sub_0807DD64(Entity* entity) { + entity->field_0xf = entity->animationState; + entity->animIndex = 0xff; + entity->field_0x80.HWORD = 0; + entity->field_0x82.HWORD = 0; +} + +void sub_0807DD80(Entity* entity, u16* unk1) { + sub_0807DB88(*(ScriptExecutionContext**)&entity->cutsceneBeh, unk1); + sub_0807DD64(entity); +} + +void sub_0807DD94(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) { + sub_0807DDAC(entity, function); + sub_0807DDE4(entity); + sub_0807DE80(entity); +} + +void sub_0807DDAC(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) { + ScriptExecutionContext** piVar1; + + piVar1 = (ScriptExecutionContext**)&entity->cutsceneBeh; + if (*piVar1) { + ExecuteScriptCommandSet(entity, *piVar1); + if (function) { + function(entity, *piVar1); + } else { + sub_0807DB98(entity, *piVar1); + } + if (!entity->next) { + DeleteThisEntity(); + } + } +} + +void sub_0807DDE4(Entity* entity) { + u32 temp; + u32 switchVar; + u32 loopVar; + + loopVar = entity->field_0x82.HWORD; + while (loopVar) { + switchVar = (~loopVar + 1) & loopVar; + loopVar = loopVar ^ switchVar; + switch (switchVar) { + case 2: + if (entity->entityType.type == 7) { + sub_0806ED78(entity); + } else { + sub_0800445C(entity); + } + break; + case 8: + if ((gScreenTransition.frameCount & 3) == 0) { + temp = (entity->field_0xf + 2U) & 7; + entity->animationState = temp; + entity->field_0xf = temp; + } + break; + case 0x10: + if ((gScreenTransition.frameCount & 1) == 0) { + entity->spriteOffsetX = gUnk_0811E510[Random() & 3]; + } + break; + case 0x20: + sub_08003FC4(entity, 0x2000); + break; + } + } +} + +void sub_0807DE80(Entity* entity) { + u32 local1; + u16 local2; + + u32 temp; + + local2 = entity->field_0x80.HWORD; + if (local2 < 8) { + if (entity->field_0x82.HWORD & 1) { + u32 t1, t2; + t1 = local2 & 0xfc; + t2 = entity->field_0xf >> 1; + local2 = t1 + t2; + } else { + u32 t1, t2; + t1 = local2 & 0xfc; + t2 = entity->animationState >> 1; + local2 = t1 + t2; + entity->field_0xf = entity->animationState; + } + } + if (local2 != entity->animIndex) { + InitAnimationForceUpdate(entity, local2); + } + temp = entity->field_0x82.HWORD & 4; + local1 = 1; + if (temp) { + local1 = 2; + } + sub_080042BA(entity, local1); +} + +void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 arg3) { + int temp; + s32 t0, t1; + + context->unk_19 = 8; + context->unk_08 |= 2; + context->unk_14 = 0; + context->unk_1C.HALF.HI = arg2; + context->unk_20.HALF.HI = arg3; + t0 = context->unk_1C.HALF.HI - entity->x.HALF.HI; + t1 = context->unk_20.HALF.HI - entity->y.HALF.HI; + temp = sub_080045DA(t0, t1); + entity->direction = temp; + entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(temp << 0x18) >> 0x1c]; +} + +void sub_0807DF28(void) { + sub_0807DF38(); + sub_08079184(); + sub_08077B20(); +} + +void sub_0807DF38(void) { + gUnk_0200AF00.filler0[1] = 0xff; + gUnk_02034490[0] = 0xff; +} + +void sub_0807DF50(void) { + gUnk_02034490[0] = 0; + gUnk_0200AF00.filler0[1] = 0; + sub_0801C4A0(0); + sub_080791D0(); + sub_08079184(); +} void ExecuteScriptCommandSet(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_00) return; From 39f682b74db1bffe8afa72397b70482821e75215 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 07:53:01 +0100 Subject: [PATCH 49/51] moved code to save.c --- .../{code_0807CC3C => save}/sub_0807D008.inc | 0 .../{code_0807CC3C => save}/sub_0807D0A0.inc | 0 .../{code_0807CC3C => save}/sub_0807D1D8.inc | 0 .../{code_0807CC3C => save}/sub_0807D20C.inc | 0 .../{code_0807CC3C => save}/sub_0807D24C.inc | 0 src/code_0807CC3C.c | 214 ------------------ src/save.c | 213 ++++++++++++++++- 7 files changed, 212 insertions(+), 215 deletions(-) rename asm/non_matching/{code_0807CC3C => save}/sub_0807D008.inc (100%) rename asm/non_matching/{code_0807CC3C => save}/sub_0807D0A0.inc (100%) rename asm/non_matching/{code_0807CC3C => save}/sub_0807D1D8.inc (100%) rename asm/non_matching/{code_0807CC3C => save}/sub_0807D20C.inc (100%) rename asm/non_matching/{code_0807CC3C => save}/sub_0807D24C.inc (100%) diff --git a/asm/non_matching/code_0807CC3C/sub_0807D008.inc b/asm/non_matching/save/sub_0807D008.inc similarity index 100% rename from asm/non_matching/code_0807CC3C/sub_0807D008.inc rename to asm/non_matching/save/sub_0807D008.inc diff --git a/asm/non_matching/code_0807CC3C/sub_0807D0A0.inc b/asm/non_matching/save/sub_0807D0A0.inc similarity index 100% rename from asm/non_matching/code_0807CC3C/sub_0807D0A0.inc rename to asm/non_matching/save/sub_0807D0A0.inc diff --git a/asm/non_matching/code_0807CC3C/sub_0807D1D8.inc b/asm/non_matching/save/sub_0807D1D8.inc similarity index 100% rename from asm/non_matching/code_0807CC3C/sub_0807D1D8.inc rename to asm/non_matching/save/sub_0807D1D8.inc diff --git a/asm/non_matching/code_0807CC3C/sub_0807D20C.inc b/asm/non_matching/save/sub_0807D20C.inc similarity index 100% rename from asm/non_matching/code_0807CC3C/sub_0807D20C.inc rename to asm/non_matching/save/sub_0807D20C.inc diff --git a/asm/non_matching/code_0807CC3C/sub_0807D24C.inc b/asm/non_matching/save/sub_0807D24C.inc similarity index 100% rename from asm/non_matching/code_0807CC3C/sub_0807D24C.inc rename to asm/non_matching/save/sub_0807D24C.inc diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 7518f863..4df3598d 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -5,220 +5,6 @@ #include "entity.h" #include "save.h" -typedef struct Thing { - u16 unk_1; - u16 unk_2; - u32 unk_3; -} Thing; - -extern struct_0807D1C4 gUnk_0811E4BC[]; -extern const char gUnk_0811E4B4[8]; - -extern u32 sub_080B180C(u32, const char*); -extern u16 sub_080B18DC(u16, const char*); - -u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3); -u32 sub_0807D128(const Thing* thing); -u16 sub_0807D1A4(u16* unk_1, u32 unk_2); -u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3); -u32 sub_0807D0EC(u32 unk_1, const char* unk_2); - -u32 sub_0807CF88(u32 arg0, u8* arg1) { - Thing thing; - - u32 retval; - struct_0807D1C4* ptr; - u32 e0, e1; - u16 l1prep; - - ptr = sub_0807D1C4(arg0); - - thing.unk_3 = 'MCZ3'; - l1prep = sub_0807D1A4((u16*)&thing.unk_3, 4); - l1prep += sub_0807D1A4((u16*)arg1, ptr->field_0x0); - thing.unk_1 = l1prep; - thing.unk_2 = -(u32)l1prep; - e0 = sub_0807D20C(ptr->field_0x6, (const char*)arg1, ptr->field_0x0); - if (e0) { - e0 = sub_0807D184(ptr->field_0x2, (const char*)&thing.unk_1); - } - e1 = sub_0807D20C(ptr->field_0x8, (const char*)arg1, ptr->field_0x0); - if (e1) { - e1 = sub_0807D184(ptr->field_0x4, (const char*)&thing.unk_1); - } - - retval = 0; - if (e0 || e1) { - retval = 1; - } - return retval; -} - -NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D008.inc", u32 sub_0807D008(u32 param_1, SaveFile* saveFile)) { - u32 set_0; - char auStack32[8]; - - struct_0807D1C4* unk_s; - u32 t1; - u32 t2; - u32 ret; - u32 temp; - - unk_s = sub_0807D1C4(param_1); - t1 = sub_0807D0EC(unk_s->field_0x2, auStack32); - if (t1 == 2) { - if ((sub_0807D1D8(unk_s->field_0x6, (char*)saveFile, unk_s->field_0x0) == 0) || - (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)unk_s->field_0x0) == 0)) { - t1 = 0; - } else { - return 1; - } - } - t2 = sub_0807D0EC(unk_s->field_0x4, auStack32); - if (t2 == 2) { - if ((sub_0807D1D8(unk_s->field_0x8, (char*)saveFile, unk_s->field_0x0) != 0) && - (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)unk_s->field_0x0) != 0)) { - return 1; - } - t2 = 0; - } - set_0 = 0; - CpuSet(&set_0, saveFile, unk_s->field_0x0 >> 2 | CPU_SET_SRC_FIXED | CPU_SET_32BIT); - temp = t1 | t2; - ret = 0; - if (temp == 0) { - ret = -1; - } - return ret; -} -END_NONMATCH - -NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D0A0.inc", u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3)) { - u32 r0; - - u32* u32_1 = (u32*)unk_1; - - u16 u0; - u32 u1; - - u0 = sub_0807D1A4(unk_1 + 2, 4); - u0 = u0 + sub_0807D1A4(unk_2, unk_3); - - u1 = unk_1[0]; - if (u1 != u0) { - r0 = 0; - } else { - if (unk_1[1] == (-(u1 << 0x10) >> 0x10)) { - if (*(u32_1 + 1) != 'MCZ3') { - r0 = 0; - } else { - r0 = 1; - } - } else { - r0 = 0; - } - } - return r0; -} -END_NONMATCH - -u32 sub_0807D0EC(u32 unk_1, const char* unk_2) { - u32 ret; - - if (!sub_0807D1D8(unk_1, unk_2, 8)) { - ret = 0; - } else { - ret = sub_0807D128((Thing*)unk_2); - } - if (!ret && sub_0807D1D8(unk_1 + 8, unk_2, 8)) { - ret = sub_0807D128((Thing*)unk_2); - } - return ret; -} - -u32 sub_0807D128(const Thing* thing) { - u32 ret; - switch (thing->unk_3) { - case 'MCZ3': - if (thing->unk_1 + thing->unk_2 == 0x10000) { - ret = 2; - } else { - ret = 0; - } - break; - case 'FleD': - case 'TINI': - ret = 0; - if ((thing->unk_1 & thing->unk_2) == 0xffff) { - ret = 1; - } - break; - default: - ret = 0; - break; - } - return ret; -} - -u32 sub_0807D184(u32 param_1, const char* param_2) { - u32 uVar1; - - uVar1 = sub_0807D20C(param_1, param_2, 8); - if (uVar1 == 0) { - uVar1 = sub_0807D20C(param_1 + 8, param_2, 8); - } - return uVar1; -} - -u16 sub_0807D1A4(u16* unk_1, u32 unk_2) { - u32 uVar1; - - uVar1 = 0; - while (unk_2 != 0) { - uVar1 = uVar1 + (*unk_1 ^ unk_2); - unk_1 = unk_1 + 1; - unk_2 = unk_2 - 2; - } - return uVar1; -} - -struct_0807D1C4* sub_0807D1C4(u32 unk_1) { - return &gUnk_0811E4BC[unk_1]; -} - -// these three are basically the same and wrong by basically one instruction in the wrong place -NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D1D8.inc", u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3)) { -} -END_NONMATCH - -NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D20C.inc", u32 sub_0807D20C(u32 unk_1, const char* unk_2, u32 unk_3)) { - unk_3 >>= 3; - unk_1 >>= 3; - while (unk_3-- > 0) { - if (sub_080B18DC(unk_1, unk_2)) { - sub_080B18DC(unk_1, gUnk_0811E4B4); - return 0; - } - unk_1++; - unk_2 += 8; - } - return 1; -} -END_NONMATCH - -NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D24C.inc", u32 sub_0807D24C(u32 unk_1, const char* unk_2, u32 unk_3)) { - unk_3 >>= 3; - unk_1 >>= 3; - while (unk_3-- > 0) { - if (sub_080B180C(unk_1, unk_2)) - return 0; - unk_1++; - unk_2 += 8; - } - return 1; -} -END_NONMATCH - // these three functions use gRoomControls, maybe once that is understood better, these can be decompiled easier NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D280.inc", void sub_0807D280(u32 unk_1, u32 unk_2)) { } diff --git a/src/save.c b/src/save.c index 879e5d70..281e54c5 100644 --- a/src/save.c +++ b/src/save.c @@ -1,6 +1,13 @@ #include "save.h" -extern u32 sub_0807D008(u32, SaveFile*); +typedef struct Thing { + u16 unk_1; + u16 unk_2; + u32 unk_3; +} Thing; + +extern u32 sub_080B180C(u32, const char*); +extern u16 sub_080B18DC(u16, const char*); const u16 gUnk_0811E454[] = { 0x0, 0x0, 0x100, 0x200, 0x300, 0x400, 0x500, 0x5C0, 0x680, 0x740, 0x800, 0x8C0, 0x9C0, 0xA80 }; @@ -12,6 +19,13 @@ static SaveResult HandleSaveInProgress(u32); static SaveResult HandleSaveDone(u32); static SaveResult (*const sSaveHandlers[])(u32) = { HandleSaveInit, HandleSaveInProgress, HandleSaveDone }; +u32 sub_0807D008(u32, SaveFile*); +u32 sub_0807D0A0(u16*, u16*, u32); +u32 sub_0807D0EC(u32, const char*); +u32 sub_0807D128(const Thing*); +u16 sub_0807D1A4(u16*, u32); +u32 sub_0807D1D8(u32, const char*, u32); + static const char sSignatureLong[32] = "AGBZELDA:THE MINISH CAP:ZELDA 5"; // Save file is untouched @@ -22,6 +36,7 @@ static const char sSaveDescDeleted[8] = "\xFF\xFF\xFF\xFF" "DelF"; const char gUnk_0811E4B4[8] = "DAMEDAME"; +extern struct_0807D1C4 gUnk_0811E4BC[]; extern s16 gUnk_02021EE0[6]; @@ -155,3 +170,199 @@ void sub_0807CF68(u32 arg0) { sub_0807D184(temp->field_0x4, str); sub_0807D184(temp->field_0x2, str); } + +u32 sub_0807CF88(u32 arg0, u8* arg1) { + Thing thing; + + u32 retval; + struct_0807D1C4* ptr; + u32 e0, e1; + u16 l1prep; + + ptr = sub_0807D1C4(arg0); + + thing.unk_3 = 'MCZ3'; + l1prep = sub_0807D1A4((u16*)&thing.unk_3, 4); + l1prep += sub_0807D1A4((u16*)arg1, ptr->field_0x0); + thing.unk_1 = l1prep; + thing.unk_2 = -(u32)l1prep; + e0 = sub_0807D20C(ptr->field_0x6, (const char*)arg1, ptr->field_0x0); + if (e0) { + e0 = sub_0807D184(ptr->field_0x2, (const char*)&thing.unk_1); + } + e1 = sub_0807D20C(ptr->field_0x8, (const char*)arg1, ptr->field_0x0); + if (e1) { + e1 = sub_0807D184(ptr->field_0x4, (const char*)&thing.unk_1); + } + + retval = 0; + if (e0 || e1) { + retval = 1; + } + return retval; +} + +NONMATCH("asm/non_matching/save/sub_0807D008.inc", u32 sub_0807D008(u32 param_1, SaveFile* saveFile)) { + u32 set_0; + char auStack32[8]; + + struct_0807D1C4* unk_s; + u32 t1; + u32 t2; + u32 ret; + u32 temp; + + unk_s = sub_0807D1C4(param_1); + t1 = sub_0807D0EC(unk_s->field_0x2, auStack32); + if (t1 == 2) { + if ((sub_0807D1D8(unk_s->field_0x6, (char*)saveFile, unk_s->field_0x0) == 0) || + (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)unk_s->field_0x0) == 0)) { + t1 = 0; + } else { + return 1; + } + } + t2 = sub_0807D0EC(unk_s->field_0x4, auStack32); + if (t2 == 2) { + if ((sub_0807D1D8(unk_s->field_0x8, (char*)saveFile, unk_s->field_0x0) != 0) && + (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)unk_s->field_0x0) != 0)) { + return 1; + } + t2 = 0; + } + set_0 = 0; + CpuSet(&set_0, saveFile, unk_s->field_0x0 >> 2 | CPU_SET_SRC_FIXED | CPU_SET_32BIT); + temp = t1 | t2; + ret = 0; + if (temp == 0) { + ret = -1; + } + return ret; + } +END_NONMATCH + +NONMATCH("asm/non_matching/save/sub_0807D0A0.inc", u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3)) { + u32 r0; + + u32* u32_1 = (u32*)unk_1; + + u16 u0; + u32 u1; + + u0 = sub_0807D1A4(unk_1 + 2, 4); + u0 = u0 + sub_0807D1A4(unk_2, unk_3); + + u1 = unk_1[0]; + if (u1 != u0) { + r0 = 0; + } else { + if (unk_1[1] == (-(u1 << 0x10) >> 0x10)) { + if (*(u32_1 + 1) != 'MCZ3') { + r0 = 0; + } else { + r0 = 1; + } + } else { + r0 = 0; + } + } + return r0; + } +END_NONMATCH + +u32 sub_0807D0EC(u32 unk_1, const char* unk_2) { + u32 ret; + + if (!sub_0807D1D8(unk_1, unk_2, 8)) { + ret = 0; + } else { + ret = sub_0807D128((Thing*)unk_2); + } + if (!ret && sub_0807D1D8(unk_1 + 8, unk_2, 8)) { + ret = sub_0807D128((Thing*)unk_2); + } + return ret; +} + +u32 sub_0807D128(const Thing* thing) { + u32 ret; + switch (thing->unk_3) { + case 'MCZ3': + if (thing->unk_1 + thing->unk_2 == 0x10000) { + ret = 2; + } else { + ret = 0; + } + break; + case 'FleD': + case 'TINI': + ret = 0; + if ((thing->unk_1 & thing->unk_2) == 0xffff) { + ret = 1; + } + break; + default: + ret = 0; + break; + } + return ret; +} + +u32 sub_0807D184(u32 param_1, const char* param_2) { + u32 uVar1; + + uVar1 = sub_0807D20C(param_1, param_2, 8); + if (uVar1 == 0) { + uVar1 = sub_0807D20C(param_1 + 8, param_2, 8); + } + return uVar1; +} + +u16 sub_0807D1A4(u16* unk_1, u32 unk_2) { + u32 uVar1; + + uVar1 = 0; + while (unk_2 != 0) { + uVar1 = uVar1 + (*unk_1 ^ unk_2); + unk_1 = unk_1 + 1; + unk_2 = unk_2 - 2; + } + return uVar1; +} + +struct_0807D1C4* sub_0807D1C4(u32 unk_1) { + return &gUnk_0811E4BC[unk_1]; +} + +// these three are basically the same and wrong by basically one instruction in the wrong place +NONMATCH("asm/non_matching/save/sub_0807D1D8.inc", u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3)) { + } +END_NONMATCH + +NONMATCH("asm/non_matching/save/sub_0807D20C.inc", u32 sub_0807D20C(u32 unk_1, const char* unk_2, u32 unk_3)) { + unk_3 >>= 3; + unk_1 >>= 3; + while (unk_3-- > 0) { + if (sub_080B18DC(unk_1, unk_2)) { + sub_080B18DC(unk_1, gUnk_0811E4B4); + return 0; + } + unk_1++; + unk_2 += 8; + } + return 1; + } +END_NONMATCH + +NONMATCH("asm/non_matching/save/sub_0807D24C.inc", u32 sub_0807D24C(u32 unk_1, const char* unk_2, u32 unk_3)) { + unk_3 >>= 3; + unk_1 >>= 3; + while (unk_3-- > 0) { + if (sub_080B180C(unk_1, unk_2)) + return 0; + unk_1++; + unk_2 += 8; + } + return 1; + } +END_NONMATCH From b2a06931667217640c1df4ff71e41d4d065c66a2 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 10:33:19 +0100 Subject: [PATCH 50/51] moved script related functions from functions.h to script.h --- include/functions.h | 4 ---- include/script.h | 3 +++ src/npc/beedle.c | 1 + src/npc/bigGoron.c | 1 + src/npc/bladeBrothers.c | 3 ++- src/npc/festari.c | 3 ++- src/npc/forestMinish.c | 1 + src/npc/goron.c | 3 ++- src/npc/goronMerchant.c | 3 ++- src/npc/librari.c | 3 ++- src/npc/malon.c | 3 ++- src/npc/mayorHagen.c | 1 + src/npc/melari.c | 1 + src/npc/mutoh.c | 1 + src/npc/percy.c | 1 + src/npc/rem.c | 1 + src/npc/simon.c | 1 + src/npc/smith.c | 1 + src/npc/stamp.c | 1 + src/npc/talon.c | 1 + src/npc/teachers.c | 1 + src/npc/townMinish.c | 1 + src/npc/townsperson.c | 1 + src/npc/windTribespeople.c | 1 + src/npc/zelda.c | 1 + src/object/houseDoorExterior.c | 1 + src/object/windcrest.c | 1 + 27 files changed, 34 insertions(+), 10 deletions(-) diff --git a/include/functions.h b/include/functions.h index 7015294b..f2ced8b0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -9,7 +9,6 @@ #include "player.h" #include "structures.h" #include "room.h" -#include "script.h" // Identified - to be sorted into header files extern u32 Random(void); @@ -24,7 +23,6 @@ extern u32 CheckKinstoneFused(u32); extern void ForceEquipItem(u8, u8); extern void LoadRoomEntityList(); void CopyPosition(Entity*, Entity*); -extern ScriptExecutionContext* StartCutscene(Entity*, u16*); extern void ResolveEntityOnTop(Entity*, Entity*); extern void EnemyFunctionHandler(Entity*, void (*const funcs[])(Entity*)); extern u32 GetAnimationState(Entity*); @@ -86,13 +84,11 @@ extern void sub_0806F69C(Entity*); extern void sub_0805E3A0(void*, u32); extern void sub_0806D0B0(Entity*); extern void sub_0807DD64(Entity*); -extern void sub_0807DDAC(Entity*, void(*function)(Entity*, ScriptExecutionContext*)); extern void sub_0807DDE4(Entity*); extern void sub_0806D02C(Entity*); extern u32 sub_0806F5A4(u32); extern void sub_08078784(Entity*, u32); extern void sub_0807DD50(Entity*); -extern void sub_0807DD94(Entity*, void(*function)(Entity*, ScriptExecutionContext*)); extern s32 sub_0806ED9C(Entity*, u32, u32); extern void sub_0807000C(Entity*); extern void sub_0805E47C(Entity*); diff --git a/include/script.h b/include/script.h index a3f29c84..93b7554c 100644 --- a/include/script.h +++ b/include/script.h @@ -30,4 +30,7 @@ extern void StartPlayerScript(u16*); extern void sub_0807DEDC(Entity*, ScriptExecutionContext*, u32, u32); +extern ScriptExecutionContext* StartCutscene(Entity*, u16*); +extern void sub_0807DDAC(Entity*, void(*function)(Entity*, ScriptExecutionContext*)); +extern void sub_0807DD94(Entity*, void(*function)(Entity*, ScriptExecutionContext*)); #endif diff --git a/src/npc/beedle.c b/src/npc/beedle.c index da25ab1b..98297254 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -4,6 +4,7 @@ #include "textbox.h" #include "player.h" #include "room.h" +#include "script.h" typedef struct { u32 unk_00; diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 94a6e085..4b45fe41 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -3,6 +3,7 @@ #include "player.h" #include "structures.h" #include "functions.h" +#include "script.h" extern void (*gUnk_081140D4[])(Entity*); diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index f19d4990..8211ed49 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -6,6 +6,7 @@ #include "room.h" #include "textbox.h" #include "save.h" +#include "script.h" extern void (*gUnk_081115C0[])(Entity*); extern void (*gUnk_081115D0[])(Entity*); @@ -126,7 +127,7 @@ void FUN_08068b2c(Entity* this) { InitAnimationForceUpdate(this, uVar1); sub_0806F118(this); } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } } diff --git a/src/npc/festari.c b/src/npc/festari.c index 0c5c74f8..fa1dac19 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -3,6 +3,7 @@ #include "functions.h" #include "npc.h" #include "player.h" +#include "script.h" extern u32 sub_0801E99C(Entity*); extern void sub_08078784(Entity*, u32); @@ -37,7 +38,7 @@ void sub_0805FE48(Entity* this) { InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); sub_0806F118(this); } else { - ExecuteScriptCommandSet(this, *(void**)&this->cutsceneBeh); + ExecuteScriptCommandSet(this, *(ScriptExecutionContext **)&this->cutsceneBeh); sub_0805FF2C(this, *(void**)&this->cutsceneBeh); uVar4 = this->field_0x80.HWORD; if (uVar4 < 8) { diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index 71c84161..66933ef3 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -7,6 +7,7 @@ #include "structures.h" #include "functions.h" #include "save.h" +#include "script.h" extern void sub_0807DD50(Entity*); extern void sub_0806F118(Entity*); diff --git a/src/npc/goron.c b/src/npc/goron.c index dcc0ac33..a7d4ee54 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -2,6 +2,7 @@ #include "entity.h" #include "functions.h" #include "textbox.h" +#include "script.h" extern void (*gUnk_08111A80[])(Entity*); extern void (*gUnk_08111A8C[])(Entity*); @@ -61,7 +62,7 @@ void sub_080693C4(Entity* this) { void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65); void sub_080693D0(Entity* this) { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); if (this->animIndex == 8) { u32 var0 = this->field_0x82.HWORD & 0xF; bool32 createFx65 = BOOLCAST(var0); // = !var0 diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 7cfdb685..9fd402c5 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -5,6 +5,7 @@ #include "textbox.h" #include "room.h" #include "flags.h" +#include "script.h" extern u32 sub_080696BC(Entity*); @@ -70,7 +71,7 @@ void sub_0806963C(Entity* this) { } void sub_08069654(Entity* this) { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } void sub_08069660(Entity* this) { diff --git a/src/npc/librari.c b/src/npc/librari.c index 27b20ad8..9db202b7 100644 --- a/src/npc/librari.c +++ b/src/npc/librari.c @@ -4,6 +4,7 @@ #include "flags.h" #include "textbox.h" #include "functions.h" +#include "script.h" extern u16 gUnk_08112D48[]; @@ -24,7 +25,7 @@ void Librari(Entity* this) { this->interactType = 0; sub_0806F118(this); } else { - sub_0807DDAC(this, 0); + sub_0807DDAC(this, NULL); sub_0807DDE4(this); UpdateAnimationSingleFrame(this); } diff --git a/src/npc/malon.c b/src/npc/malon.c index 340e9cf7..ca6d6eab 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -1,6 +1,7 @@ #include "global.h" #include "functions.h" #include "entity.h" +#include "script.h" extern Entity gPlayerEntity; @@ -44,7 +45,7 @@ void sub_080658BC(Entity* this) { InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); sub_0806F118(this); } else { - sub_0807DD94(this, 0); + sub_0807DD94(this, NULL); } } diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index a56ded98..df7366dd 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -9,6 +9,7 @@ #include "structures.h" #include "functions.h" #include "save.h" +#include "script.h" extern void sub_0807DD50(Entity*); extern u32 sub_0806F5A4(u32); diff --git a/src/npc/melari.c b/src/npc/melari.c index 1b09ecb6..b5101e02 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -3,6 +3,7 @@ #include "npc.h" #include "textbox.h" #include "functions.h" +#include "script.h" extern void sub_08068780(Entity*); extern void sub_08078778(Entity*); diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index deed814f..998a54a6 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -7,6 +7,7 @@ #include "structures.h" #include "functions.h" #include "save.h" +#include "script.h" extern void sub_0807DD50(Entity*); extern u32 GetFacingDirection(Entity*, Entity*); diff --git a/src/npc/percy.c b/src/npc/percy.c index 3d18ed35..484ee13b 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -4,6 +4,7 @@ #include "textbox.h" #include "functions.h" #include "flags.h" +#include "script.h" extern void sub_0806B41C(Entity*); extern void sub_0806B3CC(Entity*); diff --git a/src/npc/rem.c b/src/npc/rem.c index b1233acf..f81929ad 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -1,6 +1,7 @@ #include "global.h" #include "functions.h" #include "entity.h" +#include "script.h" extern void sub_0807DDE4(Entity*); extern void PlaySFX(u32); diff --git a/src/npc/simon.c b/src/npc/simon.c index deb8d73e..ecc57f36 100644 --- a/src/npc/simon.c +++ b/src/npc/simon.c @@ -3,6 +3,7 @@ #include "functions.h" #include "room.h" #include "flags.h" +#include "script.h" typedef struct { u8 filler[4]; diff --git a/src/npc/smith.c b/src/npc/smith.c index 50772b83..d06cedfe 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -3,6 +3,7 @@ #include "textbox.h" #include "functions.h" #include "save.h" +#include "script.h" extern u32 GetFacingDirection(Entity*, Entity*); extern u32 sub_0806F5A4(u32); diff --git a/src/npc/stamp.c b/src/npc/stamp.c index 652e6710..a30d31ad 100644 --- a/src/npc/stamp.c +++ b/src/npc/stamp.c @@ -2,6 +2,7 @@ #include "entity.h" #include "textbox.h" #include "functions.h" +#include "script.h" extern void sub_08078778(Entity*); extern void sub_0805E47C(Entity*); diff --git a/src/npc/talon.c b/src/npc/talon.c index 867ede74..24380fc9 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -3,6 +3,7 @@ #include "textbox.h" #include "functions.h" #include "player.h" +#include "script.h" extern void (*gUnk_0810FEC4[])(Entity* this); extern void (*gUnk_0810FEBC[])(Entity* this); diff --git a/src/npc/teachers.c b/src/npc/teachers.c index b633b3d0..9a9f0509 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -3,6 +3,7 @@ #include "player.h" #include "functions.h" #include "save.h" +#include "script.h" extern SpriteLoadData gUnk_08113910[]; extern void sub_0807DD50(Entity*); diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 6ed67b2e..9217fdd7 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -5,6 +5,7 @@ #include "textbox.h" #include "flags.h" #include "save.h" +#include "script.h" extern void InitializeAnimation(Entity*, u32); extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 90e2490a..a5295f93 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -7,6 +7,7 @@ #include "structures.h" #include "functions.h" #include "save.h" +#include "script.h" typedef struct { u8 frame1; diff --git a/src/npc/windTribespeople.c b/src/npc/windTribespeople.c index b1499f01..05dca467 100644 --- a/src/npc/windTribespeople.c +++ b/src/npc/windTribespeople.c @@ -6,6 +6,7 @@ #include "structures.h" #include "functions.h" #include "save.h" +#include "script.h" extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); extern void sub_0807DD50(Entity*); diff --git a/src/npc/zelda.c b/src/npc/zelda.c index ea12cf4b..00c333e6 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -3,6 +3,7 @@ #include "functions.h" #include "room.h" #include "flags.h" +#include "script.h" extern void PrependEntityToList(Entity*, u32); extern void sub_0807DD50(Entity*); diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 3c43e4b1..ddf5b87e 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -3,6 +3,7 @@ #include "flags.h" #include "functions.h" #include "room.h" +#include "script.h" typedef struct { /*0x00*/ u16 unk0; diff --git a/src/object/windcrest.c b/src/object/windcrest.c index 4b96f901..a4c4049d 100644 --- a/src/object/windcrest.c +++ b/src/object/windcrest.c @@ -2,6 +2,7 @@ #include "entity.h" #include "functions.h" #include "save.h" +#include "script.h" extern void sub_0807DD64(Entity*); extern void sub_0807DDE4(Entity*); From faa6fddc10b6021d31c1a0e793d0d4fa380f9f0d Mon Sep 17 00:00:00 2001 From: Henny022p Date: Fri, 19 Feb 2021 10:36:02 +0100 Subject: [PATCH 51/51] renamed executeScriptCommandSet.c to just script.c --- linker.ld | 4 ++-- src/{executeScriptCommandSet.c => script.c} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{executeScriptCommandSet.c => script.c} (100%) diff --git a/linker.ld b/linker.ld index ec7ef0e2..0267d7cd 100644 --- a/linker.ld +++ b/linker.ld @@ -672,7 +672,7 @@ SECTIONS { src/flags.o(.text); src/save.o(.text); src/code_0807CC3C.o(.text); - src/executeScriptCommandSet.o(.text); + src/script.o(.text); asm/code_0807F0D8.o(.text); src/code_0808091C.o(.text); asm/code_0808091C.o(.text); @@ -1018,7 +1018,7 @@ SECTIONS { data/room_headers.o(.rodata); src/save.o(.rodata); data/data_0811E454.o(.rodata); - src/executeScriptCommandSet.o(.rodata); + src/script.o(.rodata); data/data_0811E750.o(.rodata); src/object/greatFairy.o(.rodata); data/animations/greatFairy.o(.rodata); diff --git a/src/executeScriptCommandSet.c b/src/script.c similarity index 100% rename from src/executeScriptCommandSet.c rename to src/script.c