diff --git a/asm/non_matching/subtask2/sub_080A68D4.inc b/asm/non_matching/subtask2/sub_080A68D4.inc deleted file mode 100644 index 6028772c..00000000 --- a/asm/non_matching/subtask2/sub_080A68D4.inc +++ /dev/null @@ -1,174 +0,0 @@ - .syntax unified -.ifdef EU - push {r4, r5, r6, lr} - ldr r0, _080A6100EU @ =gPlayerState - ldr r0, [r0, #0x30] - movs r1, #8 - ands r0, r1 - movs r4, #0x64 - cmp r0, #0 - beq _080A60DA - movs r4, #0x65 -_080A60DA: - ldr r1, _080A6104EU @ =gRoomTransition - ldrh r0, [r1, #0x20] - ldrh r1, [r1, #0x22] - movs r2, #0xfd - lsls r2, r2, #1 - movs r3, #0x80 - lsls r3, r3, #1 - adds r3, r4, r3 - bl sub_080A698C - bl sub_080A6F40 - adds r6, r0, #0 - ldr r0, _080A6108 @ =gSave - ldrh r0, [r0, #0x20] - ands r6, r0 - ldr r4, _080A610C @ =gUnk_08128F58 - movs r5, #0 - b _080A612C - .align 2, 0 -_080A6100EU: .4byte gPlayerState -_080A6104EU: .4byte gRoomTransition -_080A6108: .4byte gSave -_080A610C: .4byte gUnk_08128F58 -_080A6110: - movs r0, #1 - lsls r0, r5 - ands r0, r6 - cmp r0, #0 - beq _080A6128EU - ldrh r0, [r4, #4] - ldrh r1, [r4, #6] - ldrb r3, [r4, #3] - movs r2, #0xfd - lsls r2, r2, #1 - bl sub_080A698C -_080A6128EU: - adds r5, #1 - adds r4, #8 -_080A612C: - ldrb r0, [r4] - cmp r0, #0 - bne _080A6110 - movs r5, #0xa -_080A6134: - adds r0, r5, #0 - bl CheckKinstoneFused - cmp r0, #0 - beq _080A616A - adds r0, r5, #0 - bl sub_0801E810 - cmp r0, #0 - bne _080A616A - ldr r1, _080A6174 @ =gUnk_080C9CBC - lsls r0, r5, #3 - adds r0, r0, r1 - ldrb r3, [r0, #7] - ldrb r0, [r0, #4] - lsls r1, r0, #2 - adds r1, r1, r0 - lsls r1, r1, #2 - ldr r0, _080A6178EU @ =gUnk_080FE320 - adds r1, r1, r0 - ldrh r0, [r1, #0xc] - ldrh r1, [r1, #0xe] - adds r3, #0x64 - movs r2, #0xfd - lsls r2, r2, #1 - bl sub_080A698C -_080A616A: - adds r5, #1 - cmp r5, #0x64 - bls _080A6134 - pop {r4, r5, r6, pc} - .align 2, 0 -_080A6174: .4byte gUnk_080C9CBC -_080A6178EU: .4byte gUnk_080FE320 -.else - push {r4, r5, r6, lr} - ldr r0, _080A690C @ =gPlayerState - ldr r0, [r0, #0x30] - movs r1, #8 - ands r0, r1 - movs r4, #0x64 - cmp r0, #0 - beq _080A68E6 - movs r4, #0x65 -_080A68E6: - ldr r1, _080A6910 @ =gRoomTransition - ldrh r0, [r1, #0x20] - ldrh r1, [r1, #0x22] - ldr r2, _080A6914 @ =0x000001FB - movs r3, #0x80 - lsls r3, r3, #1 - adds r3, r4, r3 - bl sub_080A698C - bl sub_080A6F40 - adds r6, r0, #0 - ldr r0, _080A6918 @ =gSave - ldrh r0, [r0, #0x20] - ands r6, r0 - ldr r4, _080A691C @ =gUnk_08128F58 - movs r5, #0 - b _080A693A - .align 2, 0 -_080A690C: .4byte gPlayerState -_080A6910: .4byte gRoomTransition -_080A6914: .4byte 0x000001FB -_080A6918: .4byte gSave -_080A691C: .4byte gUnk_08128F58 -_080A6920: - movs r0, #1 - lsls r0, r5 - ands r0, r6 - cmp r0, #0 - beq _080A6936 - ldrh r0, [r4, #4] - ldrh r1, [r4, #6] - ldrb r3, [r4, #3] - ldr r2, _080A6980 @ =0x000001FB - bl sub_080A698C -_080A6936: - adds r5, #1 - adds r4, #8 -_080A693A: - ldrb r0, [r4] - cmp r0, #0 - bne _080A6920 - movs r5, #0xa -_080A6942: - adds r0, r5, #0 - bl CheckKinstoneFused - cmp r0, #0 - beq _080A6976 - adds r0, r5, #0 - bl sub_0801E810 - cmp r0, #0 - bne _080A6976 - ldr r1, _080A6984 @ =gUnk_080C9CBC - lsls r0, r5, #3 - adds r0, r0, r1 - ldrb r3, [r0, #7] - ldrb r0, [r0, #4] - lsls r1, r0, #2 - adds r1, r1, r0 - lsls r1, r1, #2 - ldr r0, _080A6988 @ =gUnk_080FE320 - adds r1, r1, r0 - ldrh r0, [r1, #0xc] - ldrh r1, [r1, #0xe] - adds r3, #0x64 - ldr r2, _080A6980 @ =0x000001FB - bl sub_080A698C -_080A6976: - adds r5, #1 - cmp r5, #0x64 - bls _080A6942 - pop {r4, r5, r6, pc} - .align 2, 0 -_080A6980: .4byte 0x000001FB -_080A6984: .4byte gUnk_080C9CBC -_080A6988: .4byte gUnk_080FE320 -.endif - .syntax divided diff --git a/include/common.h b/include/common.h index 62f3acba..4a899e72 100644 --- a/include/common.h +++ b/include/common.h @@ -17,6 +17,20 @@ typedef struct { } Input; extern Input gInput; /**< Input instance. */ +typedef struct { + u8 evt_type; + u8 entity_idx; + u8 _2[6]; + u16 x; + u16 y; + u16 _c; + u16 _e; + u8 _10; + u8 _11; + u16 flag; +} struct_080FE320; +extern struct_080FE320 gUnk_080FE320[]; + void LoadPalettes(const u8*, s32, s32); /** @@ -122,5 +136,6 @@ void sub_0801E1B8(u32, u32); void sub_0801E738(u32); void sub_0801DFB4(struct Entity_*, u32, u32, u32); u32 sub_0801E00C(void); +bool32 sub_0801E810(u32); #endif // COMMON_H diff --git a/src/common.c b/src/common.c index 412bd202..71f9eb8b 100644 --- a/src/common.c +++ b/src/common.c @@ -61,19 +61,6 @@ typedef struct { extern struct_02017AA0 gUnk_02017AA0[]; extern u8 gUnk_03003DE4; -typedef struct { - u8 evt_type; - u8 entity_idx; - u8 _2[6]; - u16 x; - u16 y; - u8 _c[4]; - u8 _10; - u8 _11; - u16 flag; -} struct_080FE320; -extern struct_080FE320 gUnk_080FE320[]; - extern const PaletteGroup* gPaletteGroups[]; extern const u8 gGlobalGfxAndPalettes[]; extern u32 gUsedPalettes; @@ -573,9 +560,9 @@ u32 CheckKinstoneFused(u32 idx) { return ReadBit(&gSave.unk241, idx); } -u32 sub_0801E810(u32 idx) { +bool32 sub_0801E810(u32 idx) { if (idx > 100 || idx < 1) { - return 0; + return FALSE; } return ReadBit(&gSave.unk24E, idx); } diff --git a/src/subtask2.c b/src/subtask2.c index 66681f31..2dd6be06 100644 --- a/src/subtask2.c +++ b/src/subtask2.c @@ -11,6 +11,13 @@ #include "main.h" #include "message.h" #include "ui.h" +#include "kinstone.h" + +#ifdef EU +#define DRAW_DIRECT_VAL 0x1fa +#else +#define DRAW_DIRECT_VAL 0x1fb +#endif extern u8 gUnk_08128D38[]; extern u8 gUnk_08128D43[]; @@ -29,6 +36,7 @@ void sub_080A68D4(); u32 sub_080A69E0(); void sub_080A6EE0(u32 param_1); struct_08127F94* sub_080A6A80(u32 param_1, u32 param_2); +void sub_080A698C(u32 param_1, u32 param_2, u32 param_3, u32 param_4); extern void DrawDungeonMap(u32 floor, struct_02019EE0* data, u32 size); extern void LoadDungeonMap(void); @@ -45,9 +53,19 @@ void sub_080A7040(u32); extern u8 gUnk_08128DB8[]; extern u8 gUnk_08128E80[]; -extern u8 gUnk_08128F58[]; extern KeyButtonLayout gUnk_08128DBC; +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + u16 unk4; + u16 unk6; +} sturct_gUnk_08128F58; + +extern sturct_gUnk_08128F58 gUnk_08128F58[]; + extern void (*const gUnk_08128DCC[])(void); void sub_080A6378(void); @@ -436,22 +454,18 @@ ASM_FUNC("asm/non_matching/subtask2/sub_080A6378.inc", void sub_080A6378()) void sub_080A6438(void) { u32 uVar1; - u8* pcVar2; + sturct_gUnk_08128F58* pcVar2; u32 uVar3; gOamCmd._4 = 0x400; gOamCmd._6 = 0; gOamCmd._8 = 0; uVar1 = gSave.field_0x20 & gGenericMenu.unk10.h[0]; - for (pcVar2 = gUnk_08128F58, uVar3 = 0; *pcVar2 != 0; uVar3++, pcVar2 += 8) { + for (pcVar2 = gUnk_08128F58, uVar3 = 0; pcVar2->unk0 != 0; uVar3++, pcVar2++) { if ((1 << uVar3 & uVar1) != 0) { - gOamCmd.x = pcVar2[1]; - gOamCmd.y = pcVar2[2]; -#ifdef EU - DrawDirect(0x1fa, *pcVar2); -#else - DrawDirect(0x1fb, *pcVar2); -#endif + gOamCmd.x = pcVar2->unk1; + gOamCmd.y = pcVar2->unk2; + DrawDirect(DRAW_DIRECT_VAL, pcVar2->unk0); } } } @@ -467,11 +481,7 @@ void sub_080A6498(void) { gUnk_08128DE8_struct* ptr = &gUnk_08128DE8[i]; gOamCmd.x = ptr->unk6; gOamCmd.y = ptr->unk7; -#ifdef EU - DrawDirect(0x1fa, 0x28 + 3 * i); -#else - DrawDirect(0x1fb, 0x28 + 3 * i); -#endif + DrawDirect(DRAW_DIRECT_VAL, 0x28 + 3 * i); } } gScreen.controls.windowOutsideControl = 0x3d3f; @@ -583,7 +593,38 @@ ASM_FUNC("asm/non_matching/subtask2/sub_080A66D0.inc", void sub_080A66D0()) ASM_FUNC("asm/non_matching/subtask2/sub_080A67C4.inc", void sub_080A67C4(u32 param_1)) -ASM_FUNC("asm/non_matching/subtask2/sub_080A68D4.inc", void sub_080A68D4()) +void sub_080A68D4(void) { + u32 uVar1; + int iVar6; + sturct_gUnk_08128F58* pcVar4; + u32 i; + u32 uVar4; + struct_080FE320* ptr; + + if ((gPlayerState.flags & PL_NO_CAP) != 0) { + iVar6 = 101; + } else { + iVar6 = 100; + } + sub_080A698C(gRoomTransition.player_status.overworld_map_x, gRoomTransition.player_status.overworld_map_y, + DRAW_DIRECT_VAL, iVar6 + 0x100); + uVar1 = sub_080A6F40(); + uVar1 &= gSave.field_0x20; + + for (pcVar4 = gUnk_08128F58, i = 0; pcVar4->unk0 != 0; i++, pcVar4++) { + if (((1 << i) & uVar1) != 0) { + sub_080A698C(pcVar4->unk4, pcVar4->unk6, DRAW_DIRECT_VAL, pcVar4->unk3); + } + } + + for (i = 10; i <= 100; i++) { + if (CheckKinstoneFused(i) && !sub_0801E810(i)) { + uVar4 = gUnk_080C9CBC[i]._5[1]; + ptr = &gUnk_080FE320[gUnk_080C9CBC[i].evt_type]; + sub_080A698C(ptr->_c, ptr->_e, DRAW_DIRECT_VAL, uVar4 + 100); + } + } +} typedef struct { u8 unk0; @@ -836,19 +877,11 @@ void sub_080A6E70(void) { uVar1 = 0x5e; } -#ifdef EU - DrawDirect(0x1fa, uVar1); -#else - DrawDirect(0x1fb, uVar1); -#endif + DrawDirect(DRAW_DIRECT_VAL, uVar1); for (i = 0; i < 8; i++) { if ((gSave.windcrests & (1 << (i + 0x18))) != 0) { sub_080A6EE0(i); -#ifdef EU - DrawDirect(0x1fa, 0x5c); -#else - DrawDirect(0x1fb, 0x5c); -#endif + DrawDirect(DRAW_DIRECT_VAL, 0x5c); } } }