diff --git a/asm/non_matching/manager16/Manager16_Main.inc b/asm/non_matching/delayedEntityLoadManager/DelayedEntityLoadManager_Main.inc similarity index 100% rename from asm/non_matching/manager16/Manager16_Main.inc rename to asm/non_matching/delayedEntityLoadManager/DelayedEntityLoadManager_Main.inc diff --git a/asm/non_matching/manager16/sub_0805ACC0.inc b/asm/non_matching/delayedEntityLoadManager/sub_0805ACC0.inc similarity index 100% rename from asm/non_matching/manager16/sub_0805ACC0.inc rename to asm/non_matching/delayedEntityLoadManager/sub_0805ACC0.inc diff --git a/asm/non_matching/manager1/sub_08057174.inc b/asm/non_matching/lightRayManager/sub_08057174.inc similarity index 100% rename from asm/non_matching/manager1/sub_08057174.inc rename to asm/non_matching/lightRayManager/sub_08057174.inc diff --git a/asm/non_matching/playerUtils/LoadRoomGfx.inc b/asm/non_matching/playerUtils/LoadRoomGfx.inc deleted file mode 100644 index 47639977..00000000 --- a/asm/non_matching/playerUtils/LoadRoomGfx.inc +++ /dev/null @@ -1,383 +0,0 @@ - .syntax unified - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - bl sub_0807BFA8 - ldr r7, _0807C158 @ =gRoomControls - ldrb r1, [r7, #0xf] - movs r0, #0xfc - ands r0, r1 - strb r0, [r7, #0xf] - ldr r5, _0807C15C @ =gMapDataTop - movs r6, #0x80 - lsls r6, r6, #6 - adds r0, r5, #0 - adds r1, r6, #0 - bl MemClear - adds r0, r5, r6 - movs r1, #0x80 - lsls r1, r1, #5 - bl MemClear - ldr r0, _0807C160 @ =gMapDataBottomSpecial - movs r4, #0x80 - lsls r4, r4, #8 - adds r1, r4, #0 - bl MemClear - ldr r0, _0807C164 @ =gMapDataTopSpecial - adds r1, r4, #0 - bl MemClear - ldr r0, _0807C168 @ =gArea - ldr r1, _0807C16C @ =0x0000085C - adds r0, r0, r1 - ldr r0, [r0] - ldr r0, [r0, #0xc] - bl sub_080197D4 - ldr r2, _0807C170 @ =gMapBottom - ldrh r1, [r2, #4] - ldr r0, _0807C174 @ =0x0000FFFF - cmp r1, r0 - beq _0807C178 - adds r0, r2, #4 - ldrh r1, [r7, #0x1e] - lsrs r1, r1, #4 - ldrh r2, [r7, #0x20] - lsrs r2, r2, #4 - bl sub_0807C8B0 - ldrh r1, [r7, #0x1e] - lsrs r1, r1, #4 - ldrh r2, [r7, #0x20] - lsrs r2, r2, #4 - adds r0, r5, #0 - bl sub_0807C8B0 - movs r2, #0 - mov sb, r2 - b _0807C184 - .align 2, 0 -_0807C158: .4byte gRoomControls -_0807C15C: .4byte gMapDataTop -_0807C160: .4byte gMapDataBottomSpecial -_0807C164: .4byte gMapDataTopSpecial -_0807C168: .4byte gArea -_0807C16C: .4byte 0x0000085C -_0807C170: .4byte gMapBottom -_0807C174: .4byte 0x0000FFFF -_0807C178: - adds r0, r2, #4 - adds r1, r6, #0 - bl MemClear - movs r3, #1 - mov sb, r3 -_0807C184: - ldr r0, _0807C1B0 @ =gRoomTransition - adds r0, #0x2d - ldrb r0, [r0] - cmp r0, #0 - bne _0807C1BC - ldr r0, _0807C1B4 @ =gMapDataBottom - movs r2, #0xc0 - lsls r2, r2, #6 - adds r1, r0, r2 - movs r4, #0x80 - lsls r4, r4, #6 - adds r2, r4, #0 - bl MemCopy - ldr r0, _0807C1B8 @ =gMapDataTop - movs r3, #0xc0 - lsls r3, r3, #6 - adds r1, r0, r3 - adds r2, r4, #0 - bl MemCopy - b _0807C26C - .align 2, 0 -_0807C1B0: .4byte gRoomTransition -_0807C1B4: .4byte gMapDataBottom -_0807C1B8: .4byte gMapDataTop -_0807C1BC: - cmp r0, #2 - bne _0807C26C - ldr r4, _0807C278 @ =gMapDataBottom - movs r0, #0xb0 - lsls r0, r0, #8 - adds r0, r0, r4 - mov r8, r0 - movs r5, #0x80 - lsls r5, r5, #5 - adds r0, r4, #0 - mov r1, r8 - adds r2, r5, #0 - bl MemCopy - movs r1, #0xc0 - lsls r1, r1, #6 - adds r6, r4, r1 - adds r0, r6, #0 - adds r1, r4, #0 - adds r2, r5, #0 - bl MemCopy - mov r0, r8 - adds r1, r6, #0 - adds r2, r5, #0 - bl MemCopy - adds r6, r4, r5 - adds r0, r6, #0 - mov r1, r8 - adds r2, r5, #0 - bl MemCopy - movs r2, #0x80 - lsls r2, r2, #7 - adds r4, r4, r2 - adds r0, r4, #0 - adds r1, r6, #0 - adds r2, r5, #0 - bl MemCopy - mov r0, r8 - adds r1, r4, #0 - adds r2, r5, #0 - bl MemCopy - ldr r4, _0807C27C @ =gMapDataTop - movs r3, #0xb0 - lsls r3, r3, #8 - adds r3, r3, r4 - mov r8, r3 - adds r0, r4, #0 - mov r1, r8 - adds r2, r5, #0 - bl MemCopy - movs r0, #0xc0 - lsls r0, r0, #6 - adds r6, r4, r0 - adds r0, r6, #0 - adds r1, r4, #0 - adds r2, r5, #0 - bl MemCopy - mov r0, r8 - adds r1, r6, #0 - adds r2, r5, #0 - bl MemCopy - adds r6, r4, r5 - adds r0, r6, #0 - mov r1, r8 - adds r2, r5, #0 - bl MemCopy - movs r1, #0x80 - lsls r1, r1, #7 - adds r4, r4, r1 - adds r0, r4, #0 - adds r1, r6, #0 - adds r2, r5, #0 - bl MemCopy - mov r0, r8 - adds r1, r4, #0 - adds r2, r5, #0 - bl MemCopy -_0807C26C: - mov r2, sb - cmp r2, #0 - bne _0807C280 - bl sub_0807BBE4 - b _0807C2A0 - .align 2, 0 -_0807C278: .4byte gMapDataBottom -_0807C27C: .4byte gMapDataTop -_0807C280: - ldr r0, _0807C2CC @ =gUnk_02027EB4 - ldrh r1, [r7, #0x1e] - lsrs r1, r1, #4 - ldrh r2, [r7, #0x20] - lsrs r2, r2, #4 - bl sub_0807C69C - ldr r0, _0807C2D0 @ =gUnk_0200D654 - ldrh r1, [r7, #0x1e] - lsrs r1, r1, #4 - ldrh r2, [r7, #0x20] - lsrs r2, r2, #4 - bl sub_0807C69C - bl sub_0807C460 -_0807C2A0: - bl sub_0807BC84 - ldr r4, _0807C2D4 @ =gMapBottom - adds r0, r4, #0 - bl sub_08080B60 - ldr r5, _0807C2D8 @ =gMapTop - adds r0, r5, #0 - bl sub_08080B60 - mov r3, sb - cmp r3, #0 - bne _0807C2E4 - ldr r0, _0807C2DC @ =gMapDataBottomSpecial - adds r1, r4, #0 - bl sub_0801AB08 - ldr r0, _0807C2E0 @ =gMapDataTopSpecial - adds r1, r5, #0 - bl sub_0801AB08 - b _0807C326 - .align 2, 0 -_0807C2CC: .4byte gUnk_02027EB4 -_0807C2D0: .4byte gUnk_0200D654 -_0807C2D4: .4byte gMapBottom -_0807C2D8: .4byte gMapTop -_0807C2DC: .4byte gMapDataBottomSpecial -_0807C2E0: .4byte gMapDataTopSpecial -_0807C2E4: - ldr r4, _0807C34C @ =gMapDataBottomSpecial - movs r0, #0x80 - lsls r0, r0, #7 - adds r5, r4, r0 - adds r6, r0, #0 - adds r0, r4, #0 - adds r1, r5, #0 - adds r2, r6, #0 - bl MemCopy - adds r0, r4, #0 - adds r1, r5, #0 - bl sub_0807C5F4 - adds r0, r5, #0 - adds r1, r6, #0 - bl MemClear - ldr r4, _0807C350 @ =gMapDataTopSpecial - adds r5, r4, r6 - adds r0, r4, #0 - adds r1, r5, #0 - adds r2, r6, #0 - bl MemCopy - adds r0, r4, #0 - adds r1, r5, #0 - bl sub_0807C5F4 - adds r0, r5, #0 - adds r1, r6, #0 - bl MemClear -_0807C326: - mov r1, sb - cmp r1, #0 - bne _0807C332 - ldrb r0, [r7, #4] - cmp r0, #0x71 - bne _0807C33A -_0807C332: - ldrb r1, [r7, #0xf] - movs r0, #1 - orrs r0, r1 - strb r0, [r7, #0xf] -_0807C33A: - ldrb r0, [r7, #4] - subs r0, #0x20 - cmp r0, #0x18 - bhi _0807C400 - lsls r0, r0, #2 - ldr r1, _0807C354 @ =_0807C358 - adds r0, r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0807C34C: .4byte gMapDataBottomSpecial -_0807C350: .4byte gMapDataTopSpecial -_0807C354: .4byte _0807C358 -_0807C358: @ jump table - .4byte _0807C3BC @ case 0 - .4byte _0807C3E4 @ case 1 - .4byte _0807C3E4 @ case 2 - .4byte _0807C3E4 @ case 3 - .4byte _0807C3E4 @ case 4 - .4byte _0807C3E4 @ case 5 - .4byte _0807C400 @ case 6 - .4byte _0807C3E4 @ case 7 - .4byte _0807C3E4 @ case 8 - .4byte _0807C400 @ case 9 - .4byte _0807C400 @ case 10 - .4byte _0807C400 @ case 11 - .4byte _0807C400 @ case 12 - .4byte _0807C3BC @ case 13 - .4byte _0807C400 @ case 14 - .4byte _0807C400 @ case 15 - .4byte _0807C3E4 @ case 16 - .4byte _0807C400 @ case 17 - .4byte _0807C400 @ case 18 - .4byte _0807C400 @ case 19 - .4byte _0807C400 @ case 20 - .4byte _0807C400 @ case 21 - .4byte _0807C400 @ case 22 - .4byte _0807C400 @ case 23 - .4byte _0807C3E4 @ case 24 -_0807C3BC: - ldr r0, _0807C3D8 @ =gMapBottom - ldr r2, [r0] - cmp r2, #0 - beq _0807C3CC - ldrh r1, [r2] - movs r0, #0x80 - orrs r0, r1 - strh r0, [r2] -_0807C3CC: - ldr r2, _0807C3DC @ =gScreen - ldrh r1, [r2] - ldr r0, _0807C3E0 @ =0x0000FDFF - ands r0, r1 - strh r0, [r2] - b _0807C444 - .align 2, 0 -_0807C3D8: .4byte gMapBottom -_0807C3DC: .4byte gScreen -_0807C3E0: .4byte 0x0000FDFF -_0807C3E4: - ldr r0, _0807C3F8 @ =gMapTop - ldr r1, [r0] - cmp r1, #0 - beq _0807C3F2 - ldr r0, _0807C3FC @ =gUnk_080B77C0 - ldrh r0, [r0, #4] - strh r0, [r1] -_0807C3F2: - bl sub_0807C5B0 - b _0807C444 - .align 2, 0 -_0807C3F8: .4byte gMapTop -_0807C3FC: .4byte gUnk_080B77C0 -_0807C400: - ldr r0, _0807C44C @ =gMapBottom - ldr r1, [r0] - cmp r1, #0 - beq _0807C40E - ldr r0, _0807C450 @ =gUnk_080B77C0 - ldrh r0, [r0] - strh r0, [r1] -_0807C40E: - ldr r0, _0807C454 @ =gMapTop - ldr r1, [r0] - cmp r1, #0 - beq _0807C41C - ldr r0, _0807C450 @ =gUnk_080B77C0 - ldrh r0, [r0, #2] - strh r0, [r1] -_0807C41C: - ldr r2, _0807C458 @ =gScreen - ldrh r0, [r2] - movs r1, #0x80 - lsls r1, r1, #4 - ands r1, r0 - movs r3, #0xba - lsls r3, r3, #5 - adds r0, r3, #0 - movs r3, #0 - orrs r1, r0 - strh r1, [r2] - ldr r0, _0807C45C @ =gArea - ldrb r0, [r0, #0xc] - cmp r0, #0 - beq _0807C444 - movs r3, #0xa0 - lsls r3, r3, #8 - adds r0, r3, #0 - orrs r1, r0 - strh r1, [r2] -_0807C444: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 -_0807C44C: .4byte gMapBottom -_0807C450: .4byte gUnk_080B77C0 -_0807C454: .4byte gMapTop -_0807C458: .4byte gScreen -_0807C45C: .4byte gArea - .syntax divided diff --git a/asm/non_matching/playerUtils/sub_08079550.inc b/asm/non_matching/playerUtils/sub_08079550.inc index a4647d85..0dcf64c4 100644 --- a/asm/non_matching/playerUtils/sub_08079550.inc +++ b/asm/non_matching/playerUtils/sub_08079550.inc @@ -3,7 +3,7 @@ mov r7, sb mov r6, r8 push {r6, r7} - ldr r0, _080795A8 @ =gUnk_03004030 + ldr r0, _080795A8 @ =gDiggingCaveEntranceTransition ldrb r0, [r0, #8] cmp r0, #0 beq _08079562 @@ -47,7 +47,7 @@ _080795A0: strb r0, [r5, #0xf] b _080796FE .align 2, 0 -_080795A8: .4byte gUnk_03004030 +_080795A8: .4byte gDiggingCaveEntranceTransition _080795AC: .4byte gPlayerState _080795B0: .4byte gPlayerEntity _080795B4: diff --git a/asm/non_matching/playerUtils/sub_0807BBE4.inc b/asm/non_matching/playerUtils/sub_0807BBE4.inc deleted file mode 100644 index 343f9ae3..00000000 --- a/asm/non_matching/playerUtils/sub_0807BBE4.inc +++ /dev/null @@ -1,79 +0,0 @@ - .syntax unified - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - ldr r0, _0807BC28 @ =gMetatileTypesBottom - mov sl, r0 - ldr r0, _0807BC2C @ =gMetatileTypesTop - mov sb, r0 - ldr r5, _0807BC30 @ =0xFFFFB000 - add r5, sl - ldr r4, _0807BC30 @ =0xFFFFB000 - add r4, sb - ldr r2, _0807BC34 @ =0xFFFFD000 - add r2, sl - ldr r1, _0807BC34 @ =0xFFFFD000 - add r1, sb - movs r3, #0 - ldr r0, _0807BC38 @ =0x00003FFF - mov r8, r0 - ldr r0, _0807BC3C @ =gUnk_080B3E80 - mov ip, r0 - ldr r7, _0807BC40 @ =gUnk_080B79A7 - ldr r6, _0807BC44 @ =0xFFFFC000 -_0807BC14: - ldrh r0, [r5] - adds r5, #2 - cmp r0, r8 - bhi _0807BC48 - lsls r0, r0, #1 - add r0, sl - ldrh r0, [r0] - add r0, ip - b _0807BC4C - .align 2, 0 -_0807BC28: .4byte gMetatileTypesBottom -_0807BC2C: .4byte gMetatileTypesTop -_0807BC30: .4byte 0xFFFFB000 -_0807BC34: .4byte 0xFFFFD000 -_0807BC38: .4byte 0x00003FFF -_0807BC3C: .4byte gUnk_080B3E80 -_0807BC40: .4byte gUnk_080B79A7 -_0807BC44: .4byte 0xFFFFC000 -_0807BC48: - adds r0, r0, r6 - adds r0, r0, r7 -_0807BC4C: - ldrb r0, [r0] - strb r0, [r2] - adds r2, #1 - ldrh r0, [r4] - adds r4, #2 - cmp r0, r8 - bhi _0807BC64 - lsls r0, r0, #1 - add r0, sb - ldrh r0, [r0] - add r0, ip - b _0807BC68 -_0807BC64: - adds r0, r0, r6 - adds r0, r0, r7 -_0807BC68: - ldrb r0, [r0] - strb r0, [r1] - adds r1, #1 - adds r3, #1 - ldr r0, _0807BC80 @ =0x00000FFF - cmp r3, r0 - bls _0807BC14 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7, pc} - .align 2, 0 -_0807BC80: .4byte 0x00000FFF - .syntax divided diff --git a/asm/non_matching/playerUtils/sub_0807C5B0.inc b/asm/non_matching/playerUtils/sub_0807C5B0.inc deleted file mode 100644 index ea4867e2..00000000 --- a/asm/non_matching/playerUtils/sub_0807C5B0.inc +++ /dev/null @@ -1,36 +0,0 @@ - .syntax unified - push {r4, r5, r6, lr} - ldr r5, _0807C5E8 @ =gUnk_0200D654 - movs r4, #0x80 - lsls r4, r4, #5 - movs r3, #0 - ldr r6, _0807C5EC @ =gRoomControls - ldr r2, _0807C5F0 @ =gUnk_02027EB4 -_0807C5BE: - adds r0, r5, r3 - ldrb r0, [r0] - cmp r0, #0 - beq _0807C5D4 - cmp r0, #0xf - bhi _0807C5D2 - ldrb r1, [r2] - cmp r1, #0xf - bhi _0807C5D4 - orrs r0, r1 -_0807C5D2: - strb r0, [r2] -_0807C5D4: - adds r2, #1 - adds r3, #1 - cmp r3, r4 - blo _0807C5BE - ldrb r1, [r6, #0xf] - movs r0, #2 - orrs r0, r1 - strb r0, [r6, #0xf] - pop {r4, r5, r6, pc} - .align 2, 0 -_0807C5E8: .4byte gUnk_0200D654 -_0807C5EC: .4byte gRoomControls -_0807C5F0: .4byte gUnk_02027EB4 - .syntax divided diff --git a/asm/non_matching/scroll/sub_08080368.inc b/asm/non_matching/scroll/sub_08080368.inc index f86b2383..5dd28da6 100644 --- a/asm/non_matching/scroll/sub_08080368.inc +++ b/asm/non_matching/scroll/sub_08080368.inc @@ -1,6 +1,6 @@ .syntax unified push {r4, r5, r6, r7, lr} - ldr r0, _08080384 @ =gUnk_03004030 + ldr r0, _08080384 @ =gDiggingCaveEntranceTransition ldr r1, _08080388 @ =gRoomControls ldrb r0, [r0, #0xa] ldrb r1, [r1, #4] @@ -13,7 +13,7 @@ strh r0, [r1] b _080803BE .align 2, 0 -_08080384: .4byte gUnk_03004030 +_08080384: .4byte gDiggingCaveEntranceTransition _08080388: .4byte gRoomControls _0808038C: .4byte gUnk_02034480 _08080390: diff --git a/assets/assets.json b/assets/assets.json index 877b59ca..c3879663 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -32284,7 +32284,7 @@ } }, { - "path": "manager1A/gUnk_08108670_EU.bin", + "path": "holeManager/gUnk_08108670_EU.bin", "variants": [ "EU" ], @@ -32294,7 +32294,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_08108670_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_08108670_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32305,7 +32305,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_0810867C_EU.bin", + "path": "holeManager/gUnk_0810867C_EU.bin", "variants": [ "EU" ], @@ -32315,7 +32315,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_0810867C_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_0810867C_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32326,7 +32326,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_08108688_EU.bin", + "path": "holeManager/gUnk_08108688_EU.bin", "variants": [ "EU" ], @@ -32336,7 +32336,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_08108688_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_08108688_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32347,7 +32347,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_08108694_EU.bin", + "path": "holeManager/gUnk_08108694_EU.bin", "variants": [ "EU" ], @@ -32357,7 +32357,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_08108694_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_08108694_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32368,7 +32368,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_081086A0_EU.bin", + "path": "holeManager/gUnk_081086A0_EU.bin", "variants": [ "EU" ], @@ -32378,7 +32378,7 @@ "size": 9 }, { - "path": "manager1A/gUnk_081086A0_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_081086A0_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32389,12 +32389,12 @@ "size": 9 }, { - "path": "manager1A/gUnk_081086A0_2.bin", + "path": "holeManager/gUnk_081086A0_2.bin", "start": 1083049, "size": 3 }, { - "path": "manager1A/gUnk_081086AC_EU.bin", + "path": "holeManager/gUnk_081086AC_EU.bin", "variants": [ "EU" ], @@ -32404,7 +32404,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_081086AC_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_081086AC_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32415,7 +32415,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_081086B8_EU.bin", + "path": "holeManager/gUnk_081086B8_EU.bin", "variants": [ "EU" ], @@ -32425,7 +32425,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_081086B8_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_081086B8_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32436,7 +32436,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_081086C4_EU.bin", + "path": "holeManager/gUnk_081086C4_EU.bin", "variants": [ "EU" ], @@ -32446,7 +32446,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_081086C4_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_081086C4_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32457,7 +32457,7 @@ "size": 12 }, { - "path": "manager1A/gUnk_081086D0_EU.bin", + "path": "holeManager/gUnk_081086D0_EU.bin", "variants": [ "EU" ], @@ -32467,7 +32467,7 @@ "size": 1 }, { - "path": "manager1A/gUnk_081086D0_1_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_081086D0_1_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32478,7 +32478,7 @@ "size": 1 }, { - "path": "manager1A/gUnk_081086D0_2_EU.bin", + "path": "holeManager/gUnk_081086D0_2_EU.bin", "variants": [ "EU" ], @@ -32488,7 +32488,7 @@ "size": 11 }, { - "path": "manager1A/gUnk_081086D0_3_USA-JP-DEMO_USA-DEMO_JP.bin", + "path": "holeManager/gUnk_081086D0_3_USA-JP-DEMO_USA-DEMO_JP.bin", "variants": [ "USA", "JP", @@ -32499,242 +32499,242 @@ "size": 11 }, { - "path": "manager1A/gUnk_081086DC.bin", + "path": "holeManager/gUnk_081086DC.bin", "start": 1083100, "size": 8 }, { - "path": "manager1A/gUnk_081086E4.bin", + "path": "holeManager/gUnk_081086E4.bin", "start": 1083108, "size": 8 }, { - "path": "manager1A/gUnk_081086EC.bin", + "path": "holeManager/gUnk_081086EC.bin", "start": 1083116, "size": 8 }, { - "path": "manager1A/gUnk_081086F4.bin", + "path": "holeManager/gUnk_081086F4.bin", "start": 1083124, "size": 8 }, { - "path": "manager1A/gUnk_081086FC.bin", + "path": "holeManager/gUnk_081086FC.bin", "start": 1083132, "size": 8 }, { - "path": "manager1A/gUnk_08108704.bin", + "path": "holeManager/gUnk_08108704.bin", "start": 1083140, "size": 8 }, { - "path": "manager1A/gUnk_0810870C.bin", + "path": "holeManager/gUnk_0810870C.bin", "start": 1083148, "size": 8 }, { - "path": "manager1A/gUnk_08108714.bin", + "path": "holeManager/gUnk_08108714.bin", "start": 1083156, "size": 8 }, { - "path": "manager1A/gUnk_0810871C.bin", + "path": "holeManager/gUnk_0810871C.bin", "start": 1083164, "size": 8 }, { - "path": "manager1A/gUnk_08108724.bin", + "path": "holeManager/gUnk_08108724.bin", "start": 1083172, "size": 8 }, { - "path": "manager1A/gUnk_0810872C.bin", + "path": "holeManager/gUnk_0810872C.bin", "start": 1083180, "size": 8 }, { - "path": "manager1A/gUnk_08108734.bin", + "path": "holeManager/gUnk_08108734.bin", "start": 1083188, "size": 8 }, { - "path": "manager1A/gUnk_0810873C.bin", + "path": "holeManager/gUnk_0810873C.bin", "start": 1083196, "size": 8 }, { - "path": "manager1A/gUnk_08108744.bin", + "path": "holeManager/gUnk_08108744.bin", "start": 1083204, "size": 8 }, { - "path": "manager1A/gUnk_0810874C.bin", + "path": "holeManager/gUnk_0810874C.bin", "start": 1083212, "size": 8 }, { - "path": "manager1A/gUnk_08108754.bin", + "path": "holeManager/gUnk_08108754.bin", "start": 1083220, "size": 8 }, { - "path": "manager1A/gUnk_0810875C.bin", + "path": "holeManager/gUnk_0810875C.bin", "start": 1083228, "size": 8 }, { - "path": "manager1A/gUnk_08108764.bin", + "path": "holeManager/gUnk_08108764.bin", "start": 1083236, "size": 32 }, { - "path": "manager1A/gUnk_08108764_1.bin", + "path": "holeManager/gUnk_08108764_1.bin", "start": 1083272, "size": 16 }, { - "path": "manager1A/gUnk_08108764_2.bin", + "path": "holeManager/gUnk_08108764_2.bin", "start": 1083292, "size": 20 }, { - "path": "manager1A/gUnk_08108764_3.bin", + "path": "holeManager/gUnk_08108764_3.bin", "start": 1083316, "size": 12 }, { - "path": "manager1A/gUnk_08108764_4.bin", + "path": "holeManager/gUnk_08108764_4.bin", "start": 1083332, "size": 16 }, { - "path": "manager1A/gUnk_08108764_5.bin", + "path": "holeManager/gUnk_08108764_5.bin", "start": 1083352, "size": 16 }, { - "path": "manager1A/gUnk_08108764_6.bin", + "path": "holeManager/gUnk_08108764_6.bin", "start": 1083372, "size": 40 }, { - "path": "manager1A/gUnk_08108764_7.bin", + "path": "holeManager/gUnk_08108764_7.bin", "start": 1083416, "size": 16 }, { - "path": "manager1A/gUnk_08108764_8.bin", + "path": "holeManager/gUnk_08108764_8.bin", "start": 1083436, "size": 16 }, { - "path": "manager1A/gUnk_08108764_9.bin", + "path": "holeManager/gUnk_08108764_9.bin", "start": 1083456, "size": 16 }, { - "path": "manager1A/gUnk_08108764_10.bin", + "path": "holeManager/gUnk_08108764_10.bin", "start": 1083476, "size": 32 }, { - "path": "manager1A/gUnk_08108764_11.bin", + "path": "holeManager/gUnk_08108764_11.bin", "start": 1083512, "size": 440 }, { - "path": "manager1A/gUnk_08108764_12.bin", + "path": "holeManager/gUnk_08108764_12.bin", "start": 1083956, "size": 16 }, { - "path": "manager1A/gUnk_08108764_13.bin", + "path": "holeManager/gUnk_08108764_13.bin", "start": 1083976, "size": 36 }, { - "path": "manager1A/gUnk_08108764_14.bin", + "path": "holeManager/gUnk_08108764_14.bin", "start": 1084016, "size": 16 }, { - "path": "manager1A/gUnk_08108764_15.bin", + "path": "holeManager/gUnk_08108764_15.bin", "start": 1084036, "size": 16 }, { - "path": "manager1A/gUnk_08108764_16.bin", + "path": "holeManager/gUnk_08108764_16.bin", "start": 1084056, "size": 36 }, { - "path": "manager1A/gUnk_08108764_17.bin", + "path": "holeManager/gUnk_08108764_17.bin", "start": 1084096, "size": 16 }, { - "path": "manager1A/gUnk_08108764_18.bin", + "path": "holeManager/gUnk_08108764_18.bin", "start": 1084116, "size": 36 }, { - "path": "manager1A/gUnk_08108764_19.bin", + "path": "holeManager/gUnk_08108764_19.bin", "start": 1084156, "size": 36 }, { - "path": "manager1A/gUnk_08108764_20.bin", + "path": "holeManager/gUnk_08108764_20.bin", "start": 1084196, "size": 16 }, { - "path": "manager1A/gUnk_08108764_21.bin", + "path": "holeManager/gUnk_08108764_21.bin", "start": 1084216, "size": 16 }, { - "path": "manager1A/gUnk_08108764_22.bin", + "path": "holeManager/gUnk_08108764_22.bin", "start": 1084236, "size": 16 }, { - "path": "manager1A/gUnk_08108764_23.bin", + "path": "holeManager/gUnk_08108764_23.bin", "start": 1084256, "size": 32 }, { - "path": "manager1A/gUnk_08108764_24.bin", + "path": "holeManager/gUnk_08108764_24.bin", "start": 1084292, "size": 16 }, { - "path": "manager1A/gUnk_08108764_25.bin", + "path": "holeManager/gUnk_08108764_25.bin", "start": 1084312, "size": 16 }, { - "path": "manager1A/gUnk_08108764_26.bin", + "path": "holeManager/gUnk_08108764_26.bin", "start": 1084332, "size": 124 }, { - "path": "manager39/gUnk_08108DE8.bin", + "path": "enterRoomTextboxManager/gUnk_08108DE8.bin", "start": 1084904, "size": 64 }, { - "path": "manager39/gUnk_08108E30.bin", + "path": "enterRoomTextboxManager/gUnk_08108E30.bin", "start": 1084976, "size": 24 }, { - "path": "manager39/gUnk_08108E48.bin", + "path": "enterRoomTextboxManager/gUnk_08108E48.bin", "start": 1085000, "size": 24 }, { - "path": "manager39/gUnk_08108E60.bin", + "path": "enterRoomTextboxManager/gUnk_08108E60.bin", "start": 1085024, "size": 12 }, diff --git a/data/const/manager/enterRoomTextboxManager.s b/data/const/manager/enterRoomTextboxManager.s new file mode 100644 index 00000000..9b1984ac --- /dev/null +++ b/data/const/manager/enterRoomTextboxManager.s @@ -0,0 +1,21 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + .align 2 + +gUnk_08108DE8:: @ 08108DE8 + .incbin "enterRoomTextboxManager/gUnk_08108DE8.bin" + +EnterRoomTextboxManager_Actions:: @ 08108E28 + .4byte sub_0805E140 + .4byte sub_0805E18C + +gUnk_08108E30:: @ 08108E30 + .incbin "enterRoomTextboxManager/gUnk_08108E30.bin" + +gUnk_08108E48:: @ 08108E48 + .incbin "enterRoomTextboxManager/gUnk_08108E48.bin" + +gUnk_08108E60:: @ 08108E60 + .incbin "enterRoomTextboxManager/gUnk_08108E60.bin" diff --git a/data/const/manager/holeManager.s b/data/const/manager/holeManager.s new file mode 100644 index 00000000..1ad9d330 --- /dev/null +++ b/data/const/manager/holeManager.s @@ -0,0 +1,194 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + .align 2 + +HoleManager_Actions:: @ 08108668 + .4byte sub_0805B048 + .4byte sub_0805B168 + +gUnk_08108670:: @ 08108670 +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_08108670_EU.bin" +.else + .incbin "holeManager/gUnk_08108670_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + +gUnk_0810867C:: @ 0810867C +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_0810867C_EU.bin" +.else + .incbin "holeManager/gUnk_0810867C_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + +gUnk_08108688:: @ 08108688 +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_08108688_EU.bin" +.else + .incbin "holeManager/gUnk_08108688_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + +gUnk_08108694:: @ 08108694 +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_08108694_EU.bin" +.else + .incbin "holeManager/gUnk_08108694_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + +gUnk_081086A0:: @ 081086A0 +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_081086A0_EU.bin" +.else + .incbin "holeManager/gUnk_081086A0_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + .incbin "holeManager/gUnk_081086A0_2.bin" + +gUnk_081086AC:: @ 081086AC +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_081086AC_EU.bin" +.else + .incbin "holeManager/gUnk_081086AC_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + +gUnk_081086B8:: @ 081086B8 +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_081086B8_EU.bin" +.else + .incbin "holeManager/gUnk_081086B8_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + +gUnk_081086C4:: @ 081086C4 +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_081086C4_EU.bin" +.else + .incbin "holeManager/gUnk_081086C4_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + +gUnk_081086D0:: @ 081086D0 +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_081086D0_EU.bin" +.else + .incbin "holeManager/gUnk_081086D0_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif +.ifdef EU + @ TODO only small differences + .incbin "holeManager/gUnk_081086D0_2_EU.bin" +.else + .incbin "holeManager/gUnk_081086D0_3_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif + +gUnk_081086DC:: @ 081086DC + .incbin "holeManager/gUnk_081086DC.bin" + +gUnk_081086E4:: @ 081086E4 + .incbin "holeManager/gUnk_081086E4.bin" + +gUnk_081086EC:: @ 081086EC + .incbin "holeManager/gUnk_081086EC.bin" + +gUnk_081086F4:: @ 081086F4 + .incbin "holeManager/gUnk_081086F4.bin" + +gUnk_081086FC:: @ 081086FC + .incbin "holeManager/gUnk_081086FC.bin" + +gUnk_08108704:: @ 08108704 + .incbin "holeManager/gUnk_08108704.bin" + +gUnk_0810870C:: @ 0810870C + .incbin "holeManager/gUnk_0810870C.bin" + +gUnk_08108714:: @ 08108714 + .incbin "holeManager/gUnk_08108714.bin" + +gUnk_0810871C:: @ 0810871C + .incbin "holeManager/gUnk_0810871C.bin" + +gUnk_08108724:: @ 08108724 + .incbin "holeManager/gUnk_08108724.bin" + +gUnk_0810872C:: @ 0810872C + .incbin "holeManager/gUnk_0810872C.bin" + +gUnk_08108734:: @ 08108734 + .incbin "holeManager/gUnk_08108734.bin" + +gUnk_0810873C:: @ 0810873C + .incbin "holeManager/gUnk_0810873C.bin" + +gUnk_08108744:: @ 08108744 + .incbin "holeManager/gUnk_08108744.bin" + +gUnk_0810874C:: @ 0810874C + .incbin "holeManager/gUnk_0810874C.bin" + +gUnk_08108754:: @ 08108754 + .incbin "holeManager/gUnk_08108754.bin" + +gUnk_0810875C:: @ 0810875C + .incbin "holeManager/gUnk_0810875C.bin" + +gUnk_08108764:: @ 08108764 + .incbin "holeManager/gUnk_08108764.bin" + .4byte gUnk_08108670 + .incbin "holeManager/gUnk_08108764_1.bin" + .4byte gUnk_08108688 + .incbin "holeManager/gUnk_08108764_2.bin" + .4byte gUnk_0810875C + .incbin "holeManager/gUnk_08108764_3.bin" + .4byte gUnk_08108694 + .incbin "holeManager/gUnk_08108764_4.bin" + .4byte gUnk_081086A0 + .incbin "holeManager/gUnk_08108764_5.bin" + .4byte gUnk_081086AC + .incbin "holeManager/gUnk_08108764_6.bin" + .4byte gUnk_081086DC + .incbin "holeManager/gUnk_08108764_7.bin" + .4byte gUnk_081086E4 + .incbin "holeManager/gUnk_08108764_8.bin" + .4byte gUnk_081086EC + .incbin "holeManager/gUnk_08108764_9.bin" + .4byte gUnk_081086F4 + .incbin "holeManager/gUnk_08108764_10.bin" + .4byte gUnk_0810867C + .incbin "holeManager/gUnk_08108764_11.bin" + .4byte gUnk_081086FC + .incbin "holeManager/gUnk_08108764_12.bin" + .4byte gUnk_08108704 + .incbin "holeManager/gUnk_08108764_13.bin" + .4byte gUnk_0810870C + .incbin "holeManager/gUnk_08108764_14.bin" + .4byte gUnk_08108714 + .incbin "holeManager/gUnk_08108764_15.bin" + .4byte gUnk_0810871C + .incbin "holeManager/gUnk_08108764_16.bin" + .4byte gUnk_08108724 + .incbin "holeManager/gUnk_08108764_17.bin" + .4byte gUnk_0810872C + .incbin "holeManager/gUnk_08108764_18.bin" + .4byte gUnk_08108734 + .incbin "holeManager/gUnk_08108764_19.bin" + .4byte gUnk_0810873C + .incbin "holeManager/gUnk_08108764_20.bin" + .4byte gUnk_08108744 + .incbin "holeManager/gUnk_08108764_21.bin" + .4byte gUnk_0810874C + .incbin "holeManager/gUnk_08108764_22.bin" + .4byte gUnk_08108754 + .incbin "holeManager/gUnk_08108764_23.bin" + .4byte gUnk_081086B8 + .incbin "holeManager/gUnk_08108764_24.bin" + .4byte gUnk_081086C4 + .incbin "holeManager/gUnk_08108764_25.bin" + .4byte gUnk_081086D0 + .incbin "holeManager/gUnk_08108764_26.bin" diff --git a/data/const/manager/manager1A.s b/data/const/manager/manager1A.s deleted file mode 100644 index 72ee0c84..00000000 --- a/data/const/manager/manager1A.s +++ /dev/null @@ -1,194 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08108668:: @ 08108668 - .4byte sub_0805B048 - .4byte sub_0805B168 - -gUnk_08108670:: @ 08108670 -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_08108670_EU.bin" -.else - .incbin "manager1A/gUnk_08108670_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_0810867C:: @ 0810867C -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_0810867C_EU.bin" -.else - .incbin "manager1A/gUnk_0810867C_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_08108688:: @ 08108688 -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_08108688_EU.bin" -.else - .incbin "manager1A/gUnk_08108688_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_08108694:: @ 08108694 -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_08108694_EU.bin" -.else - .incbin "manager1A/gUnk_08108694_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_081086A0:: @ 081086A0 -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_081086A0_EU.bin" -.else - .incbin "manager1A/gUnk_081086A0_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - .incbin "manager1A/gUnk_081086A0_2.bin" - -gUnk_081086AC:: @ 081086AC -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_081086AC_EU.bin" -.else - .incbin "manager1A/gUnk_081086AC_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_081086B8:: @ 081086B8 -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_081086B8_EU.bin" -.else - .incbin "manager1A/gUnk_081086B8_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_081086C4:: @ 081086C4 -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_081086C4_EU.bin" -.else - .incbin "manager1A/gUnk_081086C4_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_081086D0:: @ 081086D0 -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_081086D0_EU.bin" -.else - .incbin "manager1A/gUnk_081086D0_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif -.ifdef EU - @ TODO only small differences - .incbin "manager1A/gUnk_081086D0_2_EU.bin" -.else - .incbin "manager1A/gUnk_081086D0_3_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_081086DC:: @ 081086DC - .incbin "manager1A/gUnk_081086DC.bin" - -gUnk_081086E4:: @ 081086E4 - .incbin "manager1A/gUnk_081086E4.bin" - -gUnk_081086EC:: @ 081086EC - .incbin "manager1A/gUnk_081086EC.bin" - -gUnk_081086F4:: @ 081086F4 - .incbin "manager1A/gUnk_081086F4.bin" - -gUnk_081086FC:: @ 081086FC - .incbin "manager1A/gUnk_081086FC.bin" - -gUnk_08108704:: @ 08108704 - .incbin "manager1A/gUnk_08108704.bin" - -gUnk_0810870C:: @ 0810870C - .incbin "manager1A/gUnk_0810870C.bin" - -gUnk_08108714:: @ 08108714 - .incbin "manager1A/gUnk_08108714.bin" - -gUnk_0810871C:: @ 0810871C - .incbin "manager1A/gUnk_0810871C.bin" - -gUnk_08108724:: @ 08108724 - .incbin "manager1A/gUnk_08108724.bin" - -gUnk_0810872C:: @ 0810872C - .incbin "manager1A/gUnk_0810872C.bin" - -gUnk_08108734:: @ 08108734 - .incbin "manager1A/gUnk_08108734.bin" - -gUnk_0810873C:: @ 0810873C - .incbin "manager1A/gUnk_0810873C.bin" - -gUnk_08108744:: @ 08108744 - .incbin "manager1A/gUnk_08108744.bin" - -gUnk_0810874C:: @ 0810874C - .incbin "manager1A/gUnk_0810874C.bin" - -gUnk_08108754:: @ 08108754 - .incbin "manager1A/gUnk_08108754.bin" - -gUnk_0810875C:: @ 0810875C - .incbin "manager1A/gUnk_0810875C.bin" - -gUnk_08108764:: @ 08108764 - .incbin "manager1A/gUnk_08108764.bin" - .4byte gUnk_08108670 - .incbin "manager1A/gUnk_08108764_1.bin" - .4byte gUnk_08108688 - .incbin "manager1A/gUnk_08108764_2.bin" - .4byte gUnk_0810875C - .incbin "manager1A/gUnk_08108764_3.bin" - .4byte gUnk_08108694 - .incbin "manager1A/gUnk_08108764_4.bin" - .4byte gUnk_081086A0 - .incbin "manager1A/gUnk_08108764_5.bin" - .4byte gUnk_081086AC - .incbin "manager1A/gUnk_08108764_6.bin" - .4byte gUnk_081086DC - .incbin "manager1A/gUnk_08108764_7.bin" - .4byte gUnk_081086E4 - .incbin "manager1A/gUnk_08108764_8.bin" - .4byte gUnk_081086EC - .incbin "manager1A/gUnk_08108764_9.bin" - .4byte gUnk_081086F4 - .incbin "manager1A/gUnk_08108764_10.bin" - .4byte gUnk_0810867C - .incbin "manager1A/gUnk_08108764_11.bin" - .4byte gUnk_081086FC - .incbin "manager1A/gUnk_08108764_12.bin" - .4byte gUnk_08108704 - .incbin "manager1A/gUnk_08108764_13.bin" - .4byte gUnk_0810870C - .incbin "manager1A/gUnk_08108764_14.bin" - .4byte gUnk_08108714 - .incbin "manager1A/gUnk_08108764_15.bin" - .4byte gUnk_0810871C - .incbin "manager1A/gUnk_08108764_16.bin" - .4byte gUnk_08108724 - .incbin "manager1A/gUnk_08108764_17.bin" - .4byte gUnk_0810872C - .incbin "manager1A/gUnk_08108764_18.bin" - .4byte gUnk_08108734 - .incbin "manager1A/gUnk_08108764_19.bin" - .4byte gUnk_0810873C - .incbin "manager1A/gUnk_08108764_20.bin" - .4byte gUnk_08108744 - .incbin "manager1A/gUnk_08108764_21.bin" - .4byte gUnk_0810874C - .incbin "manager1A/gUnk_08108764_22.bin" - .4byte gUnk_08108754 - .incbin "manager1A/gUnk_08108764_23.bin" - .4byte gUnk_081086B8 - .incbin "manager1A/gUnk_08108764_24.bin" - .4byte gUnk_081086C4 - .incbin "manager1A/gUnk_08108764_25.bin" - .4byte gUnk_081086D0 - .incbin "manager1A/gUnk_08108764_26.bin" diff --git a/data/const/manager/manager39.s b/data/const/manager/manager39.s deleted file mode 100644 index fe22ce51..00000000 --- a/data/const/manager/manager39.s +++ /dev/null @@ -1,21 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08108DE8:: @ 08108DE8 - .incbin "manager39/gUnk_08108DE8.bin" - -gUnk_08108E28:: @ 08108E28 - .4byte sub_0805E140 - .4byte sub_0805E18C - -gUnk_08108E30:: @ 08108E30 - .incbin "manager39/gUnk_08108E30.bin" - -gUnk_08108E48:: @ 08108E48 - .incbin "manager39/gUnk_08108E48.bin" - -gUnk_08108E60:: @ 08108E60 - .incbin "manager39/gUnk_08108E60.bin" diff --git a/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc b/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc index 702005bb..41c30e2c 100644 --- a/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc +++ b/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc @@ -25,7 +25,7 @@ SCRIPT_START script_Npc4EMonsters SetFadeTime 0x0002 SetFade6 WaitForFadeFinish - CallWithArg DeleteManager36, 0x00000002 + CallWithArg DeleteRepeatedSoundManager, 0x00000002 _0807F0C8 0x0000, 0x0000 Call NPC4E_SaveEquippedItems Call SetPlayerActionNormal @@ -52,5 +52,5 @@ SCRIPT_START script_Npc4EMonsters WaitUntilTextboxCloses MessageFromTargetPos TEXT_PROLOGUE, 0x46, 0x0000 WaitUntilTextboxCloses - CallWithArg CreateManager36, 0x00000002 + CallWithArg CreateRepeatedSoundManager, 0x00000002 _0807F0C8 0xffff, 0x0000 diff --git a/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc b/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc index ab1afa7b..ceb2a7d6 100644 --- a/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc +++ b/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc @@ -23,7 +23,7 @@ SCRIPT_START script_Npc4EVaatiAttacking Wait 0x000f PlaySound SFX_125 CallWithArg sub_0807FB28, 0x00000003 - CallWithArg DeleteManager36, 0x00000002 + CallWithArg DeleteRepeatedSoundManager, 0x00000002 _0807F0C8 0x0000, 0x0000 SetSyncFlag 0x00000010 WaitForSyncFlagAndClear 0x00000020 diff --git a/data/scripts/cutscene/introCeremony/script_VaatiIntroCeremony.inc b/data/scripts/cutscene/introCeremony/script_VaatiIntroCeremony.inc index 5236e03b..d34dd18e 100644 --- a/data/scripts/cutscene/introCeremony/script_VaatiIntroCeremony.inc +++ b/data/scripts/cutscene/introCeremony/script_VaatiIntroCeremony.inc @@ -77,7 +77,7 @@ SCRIPT_START script_VaatiIntroCeremony Wait 0x001e SetSyncFlag 0x00000200 WaitForSyncFlagAndClear 0x00000100 - Call sub_08066CA4 + Call Vaati_Evaporate DoPostScriptAction 0x0008 Wait 0x0078 SetSyncFlag 0x00000200 diff --git a/data/scripts/cutscene/introTown/script_Npc4EIntroCastle.inc b/data/scripts/cutscene/introTown/script_Npc4EIntroCastle.inc index cc1a7213..e0d5f3de 100644 --- a/data/scripts/cutscene/introTown/script_Npc4EIntroCastle.inc +++ b/data/scripts/cutscene/introTown/script_Npc4EIntroCastle.inc @@ -117,5 +117,5 @@ SCRIPT_START script_Npc4EIntroCastle SetSyncFlag 0x08000000 SetSyncFlag 0x00800000 WaitForSyncFlagAndClear 0x01000000 - CallWithArg CreateManager36, 0x00000002 + CallWithArg CreateRepeatedSoundManager, 0x00000002 _0807F0C8 0xffff, 0x0000 diff --git a/data/scripts/cutscene/originStory/script_Object69CameraTarget.inc b/data/scripts/cutscene/originStory/script_Object69CameraTarget.inc index 0f02d560..71f644a8 100644 --- a/data/scripts/cutscene/originStory/script_Object69CameraTarget.inc +++ b/data/scripts/cutscene/originStory/script_Object69CameraTarget.inc @@ -12,7 +12,7 @@ SCRIPT_START script_Object69CameraTarget WaitForSyncFlagAndClear 0x00010000 SetSyncFlag 0x00048000 WaitForSyncFlagAndClear 0x00010000 - CallWithArg DeleteManager36, 0x00000001 + CallWithArg DeleteRepeatedSoundManager, 0x00000001 _0807F0C8 0x0000, 0x0000 MessageFromTargetPos TEXT_VAATI, 0x12, 0x000c WaitUntilTextboxCloses diff --git a/data/scripts/cutscene/originStory/script_Object69MinishVaati.inc b/data/scripts/cutscene/originStory/script_Object69MinishVaati.inc index d856f427..7260dc62 100644 --- a/data/scripts/cutscene/originStory/script_Object69MinishVaati.inc +++ b/data/scripts/cutscene/originStory/script_Object69MinishVaati.inc @@ -33,5 +33,5 @@ SCRIPT_START script_Object69MinishVaati WaitUntilTextboxCloses MessageFromTargetPos TEXT_VAATI, 0x10, 0x000c WaitUntilTextboxCloses - CallWithArg CreateManager36, 0x00000001 + CallWithArg CreateRepeatedSoundManager, 0x00000001 _0807F0C8 0xffff, 0x0000 diff --git a/data/scripts/cutscene/originStory/script_Object6AMinishCap.inc b/data/scripts/cutscene/originStory/script_Object6AMinishCap.inc index 2d149f47..e2bdafd8 100644 --- a/data/scripts/cutscene/originStory/script_Object6AMinishCap.inc +++ b/data/scripts/cutscene/originStory/script_Object6AMinishCap.inc @@ -6,13 +6,13 @@ SCRIPT_START script_Object6AMinishCap Call sub_08094B80 EndBlock WaitForSyncFlagAndClear 0x00000080 - CallWithArg CreateManager36, 0x00000003 + CallWithArg CreateRepeatedSoundManager, 0x00000003 Call sub_08094B0C _0807EDD4 0x0078, 0x0068 SetSyncFlag 0x00000100 WaitForSyncFlagAndClear 0x00000080 _0807EF3C 0xff80, 0x0000 - CallWithArg DeleteManager36, 0x00000003 + CallWithArg DeleteRepeatedSoundManager, 0x00000003 Wait 0x003c SetSyncFlag 0x00000100 WaitForSyncFlagAndClear 0x00000080 diff --git a/data/scripts/cutscene/originStory/script_Vaati.inc b/data/scripts/cutscene/originStory/script_Vaati.inc index ac8c49a7..7028936b 100644 --- a/data/scripts/cutscene/originStory/script_Vaati.inc +++ b/data/scripts/cutscene/originStory/script_Vaati.inc @@ -39,7 +39,7 @@ SCRIPT_START script_Vaati DoPostScriptAction 0x0000 SetSyncFlag 0x00001000 WaitForSyncFlagAndClear 0x00000800 - Call sub_08066CA4 + Call Vaati_Evaporate DoPostScriptAction 0x0008 Wait 0x0078 SetSyncFlag 0x00001000 diff --git a/data/scripts/cutscene/originStory/script_VaatiAppearsAgain.inc b/data/scripts/cutscene/originStory/script_VaatiAppearsAgain.inc index f356d65f..b84a1abf 100644 --- a/data/scripts/cutscene/originStory/script_VaatiAppearsAgain.inc +++ b/data/scripts/cutscene/originStory/script_VaatiAppearsAgain.inc @@ -7,7 +7,7 @@ SCRIPT_START script_VaatiAppearsAgain Call SetPriorityPlayerEvent EndBlock WaitForSyncFlagAndClear 0x00000002 - Call sub_08066C94 + Call Vaati_Apparate Wait 0x00e9 DoPostScriptAction 0x0007 DoPostScriptAction 0x001e diff --git a/data/scripts/cutscene/outro/script_Npc4EFixedEverything.inc b/data/scripts/cutscene/outro/script_Npc4EFixedEverything.inc index 539958c6..443859c8 100644 --- a/data/scripts/cutscene/outro/script_Npc4EFixedEverything.inc +++ b/data/scripts/cutscene/outro/script_Npc4EFixedEverything.inc @@ -18,5 +18,5 @@ SCRIPT_START script_Npc4EFixedEverything WaitUntilTextboxCloses MessageFromTargetPos TEXT_VAATI2, 0x5e, 0x000e WaitUntilTextboxCloses - CallWithArg CreateManager36, 0x00000001 + CallWithArg CreateRepeatedSoundManager, 0x00000001 _0807F0C8 0xffff, 0x0000 diff --git a/data/scripts/cutscene/outro/script_Npc4EMinishPortalClosing.inc b/data/scripts/cutscene/outro/script_Npc4EMinishPortalClosing.inc index 502217ac..4ad2e6eb 100644 --- a/data/scripts/cutscene/outro/script_Npc4EMinishPortalClosing.inc +++ b/data/scripts/cutscene/outro/script_Npc4EMinishPortalClosing.inc @@ -9,7 +9,7 @@ SCRIPT_START script_Npc4EMinishPortalClosing OffsetEntityPosition 0x0000, 0xffe0 Call WaitForCameraTouchRoomBorder Wait 0x003c - CallWithArg DeleteManager36, 0x00000001 + CallWithArg DeleteRepeatedSoundManager, 0x00000001 _0807F0C8 0x0000, 0x0000 Wait 0x003c SetSyncFlag 0x00000002 diff --git a/data/scripts/cutscene/reveal/script_VaatiSanctuary.inc b/data/scripts/cutscene/reveal/script_VaatiSanctuary.inc index 7619f004..fe207440 100644 --- a/data/scripts/cutscene/reveal/script_VaatiSanctuary.inc +++ b/data/scripts/cutscene/reveal/script_VaatiSanctuary.inc @@ -8,7 +8,7 @@ SCRIPT_START script_VaatiSanctuary EndBlock WaitForSyncFlagAndClear 0x00000020 SetEntityPositionRelative 0x0098, 0x0048 - Call sub_08066C94 + Call Vaati_Apparate Wait 0x00e9 DoPostScriptAction 0x0007 SetSyncFlag 0x00000040 @@ -26,7 +26,7 @@ SCRIPT_START script_VaatiSanctuary DoPostScriptAction 0x0000 SetSyncFlag 0x00000040 WaitForSyncFlagAndClear 0x00000020 - Call sub_08066CA4 + Call Vaati_Evaporate DoPostScriptAction 0x0008 Wait 0x0078 SetSyncFlag 0x00000040 diff --git a/data/scripts/cutscene/takeover/script_VaatiTakeover.inc b/data/scripts/cutscene/takeover/script_VaatiTakeover.inc index 8e730e8f..73e49128 100644 --- a/data/scripts/cutscene/takeover/script_VaatiTakeover.inc +++ b/data/scripts/cutscene/takeover/script_VaatiTakeover.inc @@ -7,7 +7,7 @@ SCRIPT_START script_VaatiTakeover DoPostScriptAction 0x001d EndBlock WaitForSyncFlagAndClear 0x00000010 - Call sub_08066C94 + Call Vaati_Apparate Wait 0x00e9 DoPostScriptAction 0x0007 DoPostScriptAction 0x001e @@ -18,13 +18,13 @@ SCRIPT_START script_VaatiTakeover DoPostScriptAction 0x0000 SetSyncFlag 0x00000020 WaitForSyncFlagAndClear 0x00000010 - Call sub_08066CA4 + Call Vaati_Evaporate DoPostScriptAction 0x0008 Wait 0x00bc SetSyncFlag 0x00000020 WaitForSyncFlagAndClear 0x00000010 SetEntityPositionRelative 0x0088, 0x0068 - Call sub_08066C94 + Call Vaati_Apparate Wait 0x00e8 DoPostScriptAction 0x0007 DoPostScriptAction 0x001e diff --git a/data/scripts/dhc/script_Npc4EAfterDefeatingV2.inc b/data/scripts/dhc/script_Npc4EAfterDefeatingV2.inc index cdab5391..41879a11 100644 --- a/data/scripts/dhc/script_Npc4EAfterDefeatingV2.inc +++ b/data/scripts/dhc/script_Npc4EAfterDefeatingV2.inc @@ -43,5 +43,5 @@ script_0800DBCA: SetSyncFlag 0x00000001 StopBgm Call sub_08094F98 - CallWithArg CreateManager36, 0x00000001 + CallWithArg CreateRepeatedSoundManager, 0x00000001 _0807F0C8 0xffff, 0x0000 diff --git a/data/scripts/dhc/script_Npc4ECastleCollapsing.inc b/data/scripts/dhc/script_Npc4ECastleCollapsing.inc index 018b2feb..47ac41a5 100644 --- a/data/scripts/dhc/script_Npc4ECastleCollapsing.inc +++ b/data/scripts/dhc/script_Npc4ECastleCollapsing.inc @@ -12,7 +12,7 @@ SCRIPT_START script_Npc4ECastleCollapsing SetFadeTime 0x0004 _0807E80C 0x00000000 WaitForFadeFinish - CallWithArg DeleteManager36, 0x00000001 + CallWithArg DeleteRepeatedSoundManager, 0x00000001 _0807F0C8 0x0000, 0x0000 SetLocalFlag 0x0079 CallWithArg sub_0806DA1C, 0x00000002 diff --git a/data/scripts/dhc/script_Vaati1Intro.inc b/data/scripts/dhc/script_Vaati1Intro.inc index c5af958a..5d465b53 100644 --- a/data/scripts/dhc/script_Vaati1Intro.inc +++ b/data/scripts/dhc/script_Vaati1Intro.inc @@ -17,7 +17,7 @@ SCRIPT_START script_Vaati1Intro _0807F0B4 0x0001 CameraTargetEntity Call WaitForCameraTouchRoomBorder - Call sub_08066C94 + Call Vaati_Apparate Wait 0x00e9 DoPostScriptAction 0x0007 MessageFromTargetPos TEXT_VAATI2, 0x2f, 0x0002 diff --git a/data/scripts/sanctuary/script_Npc4EFinalSwordRumble.inc b/data/scripts/sanctuary/script_Npc4EFinalSwordRumble.inc index 46d7f708..2c8bed4b 100644 --- a/data/scripts/sanctuary/script_Npc4EFinalSwordRumble.inc +++ b/data/scripts/sanctuary/script_Npc4EFinalSwordRumble.inc @@ -10,7 +10,7 @@ SCRIPT_START script_Npc4EFinalSwordRumble .endif SetSyncFlag 0x00000008 Wait 0x0078 - CallWithArg DeleteManager36, 0x00000001 + CallWithArg DeleteRepeatedSoundManager, 0x00000001 _0807F0C8 0x0000, 0x0000 Wait 0x003c _0807F0B4 0x0004 diff --git a/data/scripts/sanctuary/script_Npc4EPedestal.inc b/data/scripts/sanctuary/script_Npc4EPedestal.inc index ee42d5ef..a5b9e51e 100644 --- a/data/scripts/sanctuary/script_Npc4EPedestal.inc +++ b/data/scripts/sanctuary/script_Npc4EPedestal.inc @@ -35,7 +35,7 @@ script_080134F8: CallWithArg sub_08095D8C, script_Object6ASwordCharge6 EndBlock Wait 0x003c - CallWithArg CreateManager36, 0x00000000 + CallWithArg CreateRepeatedSoundManager, 0x00000000 SetSyncFlag 0x00000200 WaitForSyncFlagAndClear 0x00002000 PlaySound SFX_1D2 @@ -45,7 +45,7 @@ script_080134F8: WaitForSyncFlagAndClear 0x00004000 Wait 0x0078 SetSyncFlag 0x00000060 - CallWithArg DeleteManager36, 0x00000000 + CallWithArg DeleteRepeatedSoundManager, 0x00000000 Wait 0x0078 SetSyncFlag 0x00000080 WaitForSyncFlagAndClear 0x00000100 @@ -70,5 +70,5 @@ script_080134F8: MessageFromTargetPos TEXT_ITEM_GET, 0x03, 0x000c WaitUntilTextboxCloses SetSyncFlag 0x00040000 - CallWithArg CreateManager36, 0x00000001 + CallWithArg CreateRepeatedSoundManager, 0x00000001 _0807F0C8 0xffff, 0x0000 diff --git a/data/scripts/sanctuary/script_Npc4ESecondSanctuary.inc b/data/scripts/sanctuary/script_Npc4ESecondSanctuary.inc index 46453d34..3b76a072 100644 --- a/data/scripts/sanctuary/script_Npc4ESecondSanctuary.inc +++ b/data/scripts/sanctuary/script_Npc4ESecondSanctuary.inc @@ -36,7 +36,7 @@ script_0801373C: CallWithArg sub_08095D8C, script_Objet6ASwordCharge7 EndBlock Wait 0x003c - CallWithArg CreateManager36, 0x00000000 + CallWithArg CreateRepeatedSoundManager, 0x00000000 SetSyncFlag 0x00000200 WaitForSyncFlagAndClear 0x00002000 PlaySound SFX_1D2 @@ -48,7 +48,7 @@ script_0801373C: WaitForSyncFlagAndClear 0x00008000 Wait 0x0078 SetSyncFlag 0x00000060 - CallWithArg DeleteManager36, 0x00000000 + CallWithArg DeleteRepeatedSoundManager, 0x00000000 Wait 0x0078 SetSyncFlag 0x00000080 WaitForSyncFlagAndClear 0x00000100 diff --git a/data/scripts/sanctuary/script_Npc4ESpawnTextBoard.inc b/data/scripts/sanctuary/script_Npc4ESpawnTextBoard.inc index 4ba0ef71..ecd6d4b6 100644 --- a/data/scripts/sanctuary/script_Npc4ESpawnTextBoard.inc +++ b/data/scripts/sanctuary/script_Npc4ESpawnTextBoard.inc @@ -8,7 +8,7 @@ SCRIPT_START script_Npc4ESpawnTextBoard Wait 0x003c SetSyncFlag 0x00000004 Wait 0x0078 - CallWithArg DeleteManager36, 0x00000001 + CallWithArg DeleteRepeatedSoundManager, 0x00000001 _0807F0C8 0x0000, 0x0000 StartPlayerScript script_PlayerTextBoardAppears WaitForSyncFlagAndClear 0x00000002 diff --git a/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc b/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc index 02c82868..bd8b7e61 100644 --- a/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc +++ b/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc @@ -38,7 +38,7 @@ script_080138D0: CallWithArg sub_08095D8C, script_Object6ASwordCharge8 EndBlock Wait 0x003c - CallWithArg CreateManager36, 0x00000000 + CallWithArg CreateRepeatedSoundManager, 0x00000000 SetSyncFlag 0x00000200 WaitForSyncFlagAndClear 0x00002000 PlaySound SFX_1D2 @@ -52,7 +52,7 @@ script_080138D0: WaitForSyncFlagAndClear 0x00010000 Wait 0x0078 SetSyncFlag 0x00000060 - CallWithArg DeleteManager36, 0x00000000 + CallWithArg DeleteRepeatedSoundManager, 0x00000000 Wait 0x0078 SetSyncFlag 0x00000080 WaitForSyncFlagAndClear 0x00000100 @@ -94,5 +94,5 @@ script_08013A8E: CheckRoomFlag 0x0004 JumpIfNot script_08013A8E .endif - CallWithArg CreateManager36, 0x00000001 + CallWithArg CreateRepeatedSoundManager, 0x00000001 _0807F0C8 0xffff, 0x0000 diff --git a/include/area.h b/include/area.h index 30efcb1f..d8be7fc1 100644 --- a/include/area.h +++ b/include/area.h @@ -240,4 +240,4 @@ typedef enum { AREA_98, } AreaID; -#endif +#endif // AREA_H diff --git a/include/beanstalkSubtask.h b/include/beanstalkSubtask.h index 8735475a..e8d6c3b2 100644 --- a/include/beanstalkSubtask.h +++ b/include/beanstalkSubtask.h @@ -1,5 +1,5 @@ -#ifndef BEANSTALK_SUBTASK_H -#define BEANSTALK_SUBTASK_H +#ifndef BEANSTALKSUBTASK_H +#define BEANSTALKSUBTASK_H #include "global.h" @@ -33,4 +33,4 @@ typedef struct { #define MAX_BG_ANIMATIONS 8 extern BgAnimation gBgAnimations[MAX_BG_ANIMATIONS]; -#endif // BEANSTALK_SUBTASK_H \ No newline at end of file +#endif // BEANSTALKSUBTASK_H diff --git a/include/collision.h b/include/collision.h index 4a591e6a..9e17ae2d 100644 --- a/include/collision.h +++ b/include/collision.h @@ -1,4 +1,3 @@ - #ifndef COLLISION_H #define COLLISION_H @@ -32,4 +31,4 @@ bool32 IsCollidingPlayer(Entity*); void CalculateEntityTileCollisions(Entity*, u32, u32); bool32 ProcessMovementInternal(Entity*, s32, s32, u32); -#endif +#endif // COLLISION_H diff --git a/include/definitions.h b/include/definitions.h index 7a18b709..978b3a31 100644 --- a/include/definitions.h +++ b/include/definitions.h @@ -1,5 +1,5 @@ -#ifndef SPRITEDATA_H -#define SPRITEDATA_H +#ifndef DEFINITIONS_H +#define DEFINITIONS_H #include "gba/types.h" #include "entity.h" @@ -436,7 +436,7 @@ typedef enum { SPRITE_FILESCREENOBJECTS, SPRITE_OBJECTA2, SPRITE_OBJECT6A_10, - SPRITE_VAATI_1, - + SPRITE_VAATI_1 } Sprites; -#endif \ No newline at end of file + +#endif // DEFINITIONS_H diff --git a/include/droptables.h b/include/droptables.h index 78d75970..63213f98 100644 --- a/include/droptables.h +++ b/include/droptables.h @@ -1,5 +1,5 @@ -#ifndef TMC_DROPTABLES_H -#define TMC_DROPTABLES_H +#ifndef DROPTABLES_H +#define DROPTABLES_H #include "global.h" @@ -37,4 +37,4 @@ enum { }; extern const Droptable gDroptableModifiers[]; -#endif // TMC_DROPTABLES_H +#endif // DROPTABLES_H diff --git a/include/effects.h b/include/effects.h index 95ad4105..396f4eaf 100644 --- a/include/effects.h +++ b/include/effects.h @@ -112,7 +112,7 @@ typedef enum { FX_69, FX_6A, FX_6B, - FX_6C, + FX_6C } Effect; #endif // EFFECTS_H diff --git a/include/enemy.h b/include/enemy.h index a392ee82..7183030a 100644 --- a/include/enemy.h +++ b/include/enemy.h @@ -253,4 +253,4 @@ void Enemy66(Entity*); extern void (*const gUnk_080012C8[])(Entity*); -#endif +#endif // ENEMY_H diff --git a/include/entity.h b/include/entity.h index 30bc9a75..ddeef86c 100644 --- a/include/entity.h +++ b/include/entity.h @@ -526,6 +526,8 @@ extern u8 gManagerCount; /** @name Tile Macros */ /// @{ #define TILE(x, y) (((((x)-gRoomControls.origin_x) >> 4) & 0x3F) | ((((y)-gRoomControls.origin_y) >> 4) & 0x3F) << 6) #define TILE_POS(x, y) (x + (y << 6)) +#define TILE_POS_X_COMPONENT 0x3f +#define TILE_POS_Y_COMPONENT 0xfc0 #define COORD_TO_TILE(entity) TILE((entity)->x.HALF.HI, (entity)->y.HALF.HI) #define COORD_TO_TILE_OFFSET(entity, xOff, yOff) TILE((entity)->x.HALF.HI - (xOff), (entity)->y.HALF.HI - (yOff)) /// @} diff --git a/include/fileselect.h b/include/fileselect.h index f6a2547d..c1868b2b 100644 --- a/include/fileselect.h +++ b/include/fileselect.h @@ -72,4 +72,4 @@ extern u32 gUsedPalettes; extern u8 gTextGfxBuffer[]; extern u8 gUnk_02022030; -#endif \ No newline at end of file +#endif // FILESELECT_H \ No newline at end of file diff --git a/include/flags.h b/include/flags.h index 1ee02ce7..681e1b8c 100644 --- a/include/flags.h +++ b/include/flags.h @@ -1741,4 +1741,4 @@ typedef enum { END_12, } LocalFlags12; -#endif +#endif // FLAGS_H diff --git a/include/functions.h b/include/functions.h index 10d18e30..18cc67e7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1,4 +1,3 @@ - #ifndef FUNCTIONS_H #define FUNCTIONS_H @@ -112,4 +111,5 @@ extern void sub_080A57F4(void); extern void sub_080A71C4(u32, u32, u32, u32); extern void sub_080ADD70(void); extern void sub_080AF284(void); -#endif + +#endif // FUNCTIONS_H diff --git a/include/gba/syscall.h b/include/gba/syscall.h index eca78eb4..48f35863 100644 --- a/include/gba/syscall.h +++ b/include/gba/syscall.h @@ -1,5 +1,5 @@ -#ifndef GUARD_GBA_SYSCALL_H -#define GUARD_GBA_SYSCALL_H +#ifndef SYSCALL_H +#define SYSCALL_H #include "types.h" @@ -62,4 +62,4 @@ int MultiBoot(struct MultiBootParam* mp); s32 Div(s32 num, s32 denom); -#endif // GUARD_GBA_SYSCALL_H +#endif // SYSCALL_H diff --git a/include/global.h b/include/global.h index 5664b1f5..08ef97f4 100644 --- a/include/global.h +++ b/include/global.h @@ -1,12 +1,14 @@ -#ifndef GUARD_GLOBAL_H -#define GUARD_GLOBAL_H +#ifndef GLOBAL_H +#define GLOBAL_H /** * @defgroup Tasks Tasks * @defgroup Subtasks Subtasks */ -/** @defgroup Entities Entities */ +/** + * @defgroup Entities Entities + */ ///@{ /** * @defgroup Player Player @@ -16,6 +18,7 @@ * @defgroup NPCs NPCs * @defgroup Items Items * @defgroup Managers Managers + * @brief Entities with a smaller footprint of 0x40 bytes */ ///@} @@ -122,4 +125,4 @@ union SplitHWord { /* forward decls */ struct Entity_; -#endif // GUARD_GLOBAL_H +#endif // GLOBAL_H diff --git a/include/hitbox.h b/include/hitbox.h index 0426c992..b2b601ea 100644 --- a/include/hitbox.h +++ b/include/hitbox.h @@ -137,4 +137,5 @@ extern const Hitbox gUnk_080FD580; extern const Hitbox gUnk_080FD588; extern const Hitbox gPlayerHitbox; -#endif + +#endif // HITBOX_H diff --git a/include/item.h b/include/item.h index 20516e0f..e8e3917c 100644 --- a/include/item.h +++ b/include/item.h @@ -151,4 +151,4 @@ typedef enum { ITEM_ENEMY_BEETLE } Item; -#endif +#endif // ITEM_H diff --git a/include/itemMetaData.h b/include/itemMetaData.h index 805a204f..fca0ef69 100644 --- a/include/itemMetaData.h +++ b/include/itemMetaData.h @@ -1,5 +1,5 @@ -#ifndef TMC_ITEMMETADATA_H -#define TMC_ITEMMETADATA_H +#ifndef ITEMMETADATA_H +#define ITEMMETADATA_H #include "global.h" @@ -38,4 +38,4 @@ typedef struct ItemMetaData { extern const ItemMetaData gItemMetaData[]; -#endif // TMC_ITEMMETADATA_H +#endif // ITEMMETADATA_H diff --git a/include/main.h b/include/main.h index 134ca8e0..3017b9ab 100644 --- a/include/main.h +++ b/include/main.h @@ -5,6 +5,7 @@ #include "structures.h" #include "room.h" #include "script.h" +#include "screen.h" /** File signature */ #define SIGNATURE 'MCZ3' @@ -86,8 +87,8 @@ typedef struct { /*0x00E*/ u8 unk_e; /*0x00F*/ u8 unk_f; /*0x010*/ void** currentRoomProperties; - /*0x014*/ u16* mapBottomBgControlPtr; - /*0x018*/ u16* mapTopBgControlPtr; + /*0x014*/ BgSettings* mapBottomBgSettings; + /*0x018*/ BgSettings* mapTopBgSettings; /*0x01C*/ RoomControls roomControls; /*0x054*/ GfxSlotList gfxSlotList; /*0x268*/ Palette palettes[0x10]; @@ -126,7 +127,7 @@ void DoSoftReset(void); */ void SetSleepMode(void); -extern void sub_0805622C(void* a1, u32 a2, u32 a3); +extern void sub_0805622C(struct BgAffineDstData* a1, u32 a2, u32 a3); extern void sub_08056208(void); extern void ResetPalettes(void); extern void VBlankIntrWait(); @@ -151,7 +152,9 @@ extern void DemoTask(void); #endif /// @} -extern u8 gUnk_03003DE4; +extern u8 gUnk_03003DE4[0xC]; extern u16 gPaletteBuffer[]; -#endif +extern u32 CheckRegionsOnScreen(const u16* arr); + +#endif // MAIN_H diff --git a/include/manager.h b/include/manager.h index 94df1639..ac43dd63 100644 --- a/include/manager.h +++ b/include/manager.h @@ -12,224 +12,143 @@ union SplitSHWord { } PACKED; typedef struct Manager { - /*0x00*/ struct Manager* prev; - /*0x00*/ struct Manager* next; - /*0x08*/ u8 type; - /*0x09*/ u8 subtype; - /*0x0a*/ u8 unk_0a; - /*0x0b*/ u8 unk_0b; - /*0x0c*/ u8 action; - /*0x0d*/ u8 unk_0d; - /*0x0e*/ u8 unk_0e; - /*0x0f*/ u8 unk_0f; - /*0x10*/ u8 unk_10; - /*0x11*/ u8 unk_11[3]; - /*0x14*/ struct Manager* parent; - /*0x18*/ u8 unk_18[0x8]; - // union SplitHWord y; - // u16 unk_22; - // u16 unk_24; - // u16 unk_26; - // u8 unk_28[0x0D]; - // u8 unk_35; - // u16 unk_36; - // union SplitSHWord unk_38; - // union SplitSHWord unk_3a; - // u16 unk_3c; - // u16 unk_3e; + /*0x00*/ struct Manager* prev; /**< previous Manager */ + /*0x00*/ struct Manager* next; /**< next Manager */ + /*0x08*/ u8 kind; /**< @see EntityKind */ + /*0x09*/ u8 id; /**< Manager id. @see Managers */ + /*0x0a*/ u8 type; /**< For use internally to allow different variations. */ + /*0x0b*/ u8 type2; /**< For use internally. */ + /*0x0c*/ u8 action; /**< Current action. Usually used to index a function table. */ + /*0x0d*/ u8 subAction; /**< Optional sub-action. */ + /*0x0e*/ u8 timer; /**< General purpose timer. */ + /*0x0f*/ u8 subtimer; /**< General purpose timer. */ + /*0x10*/ u8 flags; /**< @see EntityFlags */ + /*0x11*/ u8 unused[3]; /**< Not used by any manager. */ + /*0x14*/ Entity* parent; /**< Parent Entity. */ + /*0x18*/ Entity* child; /**< Child Entity. */ + /*0x1c*/ u8 unused2[0x4]; /**< Not used by any manager. */ } Manager; -typedef struct { - u16 posX; - u16 posY; - u8 width; - u8 height; - u8 unk_06; - union { - u8 all; - struct { - u8 layer : 2; - u8 unk1 : 2; - u8 unk2 : 1; - u8 unk3 : 3; - } PACKED b; - } PACKED unk_07; -} Manager6WarpData; +typedef enum { + MANAGER_NONE, + LIGHT_RAY_MANAGER, + VERTICAL_MINISH_PATH_BACKGROUND_MANAGER, + MINISH_PORTAL_MANAGER, + DIGGING_CAVE_ENTRANCE_MANAGER, + BRIDGE_MANAGER, + SPECIAL_WARP_MANAGER, + MINISH_VILLAGE_MANAGER, + HORIZONTAL_MINISH_PATH_BACKGROUND_MANAGER, + MINISH_RAFTERS_BACKGROUND_MANAGER, + EZLO_HINT_MANAGER, + FIGHT_MANAGER, + ROLLING_BARREL_MANAGER, + TILE_CHANGE_OBSERVE_MANAGER, + ENTITY_SPAWN_MANAGER, + MISC_MANAGER, + WEATHER_CHANGE_MANAGER, + FLAG_AND_OPERATOR_MANAGER, + HYRULE_TOWN_TILESET_MANAGER, + HOUSE_SIGN_MANAGER, + STEAM_OVERLAY_MANAGER, + TEMPLE_OF_DROPLETS_MANAGER, + DELAYED_ENTITY_LOAD_MANAGER, + FALLING_ITEM_MANAGER, + CLOUD_OVERLAY_MANAGER, + POW_BACKGROUND_MANAGER, + HOLE_MANAGER, + STATIC_BACKGROUND_MANAGER, + RAINFALL_MANAGER, + ANIMATED_BACKGROUND_MANAGER, + REGION_TRIGGER_MANAGER, + RAIL_INTERSECTION_MANAGER, + MOVEABLE_OBJECT_MANAGER, + MINISH_SIZED_ENTRANCE_MANAGER, + LIGHT_MANAGER, + LIGHT_LEVEL_SET_MANAGER, + BOMBABLE_WALL_MANAGER, + FLAME_MANAGER, + PUSHABLE_FURNITURE_MANAGER, + ARMOS_INTERIOR_MANAGER, + ENEMY_INTERACTION_MANAGER, + MANAGER_29, + DESTRUCTIBLE_TILE_OBSERVE_MANAGER, + ANGRY_STATUE_MANAGER, + CLOUD_STAIRCASE_TRANSITION_MANAGER, + WATERFALL_BOTTOM_MANAGER, + SECRET_MANAGER, + VAATI3_BACKGROUND_MANAGER, + TILE_PUZZLE_MANAGER, + GORON_MERCHANT_SHOP_MANAGER, + VAATI_APPARATE_MANAGER, + HYRULE_TOWN_BELL_MANAGER, + VAATI3_INSIDE_ARM_MANAGER, + CAMERA_TARGET_MANAGER, + REPEATED_SOUND_MANAGER, + VAATI3_START_MANAGER, + FLOATING_PLATFORM_MANAGER, + ENTER_ROOM_TEXTBOX_MANAGER +} Managers; -typedef struct { - Manager manager; - Manager6WarpData* warpList; -} Manager6; - -typedef struct { - Manager manager; - u16 x; - u16 y; - u16 rx; - u16 ry; - u8 unk_28[13]; - u8 msg_height; - u16 msg_idx; - u8 x_raw; - u8 y_raw; - u8 rx_raw; - u8 ry_raw; - u16 flag1; - u16 flag2; -} ManagerA; - -typedef struct { - Manager manager; - u8 unk_20; - u8 unk_21[0x14]; - u8 unk_35; - u8 unk_36[0x4]; - u16 unk_3a; - u16 unk_3c; - u16 unk_3e; -} ManagerB; - -typedef struct { - Manager manager; - Entity* enemies[8]; -} ManagerBHelper; - -typedef struct { - Manager manager; - u8 unk_20[0x18]; - s16 unk_38; - s16 unk_3a; - u16 unk_3c; - u16 unk_3e; -} ManagerE; - -typedef struct { - Manager manager; - u8 unk_20[0x18]; - s16 unk_38; - s16 unk_3a; - u16 unk_3c; - u16 unk_3e; -} ManagerF; - -typedef struct { - Manager manager; - u8 unk_20; - u8 unk_21; - u8 unk_22; - u8 unk_23; - u8 filler_0x24[0x1C]; -} Manager10; - -typedef struct Manager11 { - Manager manager; - u8 unk_20[0x1C]; - u16 unk_3c; - u16 unk_3e; -} Manager11; - -typedef struct { - u16 unk_00; - u8 source_room; - u8 unk_03; - u8 target_area; - u8 target_room; - u16 unk_06; -} DiggingCaveEntrance; - -typedef struct { - const DiggingCaveEntrance* unk_00; - u16 unk_04; - u16 unk_06; - u8 isDiggingCave; - u8 unk_09; - u8 unk_0a; - u8 unk_0b; -} struct_03004030; -extern struct_03004030 gUnk_03004030; - -extern const DiggingCaveEntrance* const diggingCaveEntrances[]; - -typedef struct { - Manager manager; - u8 field_0x20[0x15]; - u8 field_0x35; - u8 field_0x36; - u8 field_0x37; - s16 x; - u16 y; - u16 tile; - u16 field_0x3e; -} Manager24; - -typedef struct { - u8 unk_00; - u8 unk_01; - u8 unk_02; - u8 unk_03; - u16 unk_04; - u16 unk_06; -} UnkManager26HelperStruct; - -extern void Manager1_Main(); -extern void Manager2_Main(); -extern void Manager3_Main(); -extern void Manager4_Main(); -extern void Manager5_Main(); -extern void Manager6_Main(); -extern void Manager7_Main(); -extern void Manager8_Main(); -extern void Manager9_Main(); -extern void ManagerA_Main(); -extern void ManagerB_Main(); -extern void ManagerC_Main(); -extern void ManagerD_Main(); -extern void ManagerE_Main(); -extern void sub_08058ECC(ManagerF*); -extern void Manager10_Main(Manager10*); -extern void Manager11_Main(Manager11*); -extern void Manager12_Main(); -extern void Manager13_Main(); -extern void Manager14_Main(); -extern void Manager15_Main(); -extern void Manager16_Main(); -extern void Manager17_Main(); -extern void Manager18_Main(); -extern void Manager19_Main(); -extern void Manager1A_Main(); -extern void Manager1B_Main(); -extern void Manager1C_Main(Manager*); -extern void Manager1D_Main(); -extern void Manager1E_Main(); -extern void Manager1F_Main(); -extern void Manager20_Main(); -extern void Manager21_Main(); -extern void Manager22_Main(); -extern void Manager23_Main(); -extern void Manager24_Main(); -extern void Manager25_Main(); -extern void Manager26_Main(); -extern void Manager27_Main(); -extern void Manager28_Main(); +extern void LightRayManager_Main(); +extern void VerticalMinishPathBackgroundManager_Main(); +extern void MinishPortalManager_Main(); +extern void DiggingCaveEntranceManager_Main(); +extern void BridgeManager_Main(); +extern void SpecialWarpManager_Main(); +extern void MinishVillageTilesetManager_Main(); +extern void HorizontalMinishPathBackgroundManager_Main(); +extern void MinishRaftersBackgroundManager_Main(); +extern void EzloHintManager_Main(); +extern void FightManager_Main(); +extern void RollingBarrelManager_Main(); +extern void TileChangeObserveManager_Main(); +extern void EntitySpawnManager_Main(); +extern void MiscManager_Main(); +extern void WeatherChangeManager_Main(); +extern void FlagAndOperatorManager_Main(); +extern void HyruleTownTilesetManager_Main(); +extern void HouseSignManager_Main(); +extern void SteamOverlayManager_Main(); +extern void TempleOfDropletsManager_Main(); +extern void DelayedEntityLoadManager_Main(); +extern void FallingItemManager_Main(); +extern void CloudOverlayManager_Main(); +extern void PowBackgroundManager_Main(); +extern void HoleManager_Main(); +extern void StaticBackgroundManager_Main(); +extern void RainfallManager_Main(); +extern void AnimatedBackgroundManager_Main(); +extern void RegionTriggerManager_Main(); +extern void RailIntersectionManager_Main(); +extern void MoveableObjectManager_Main(); +extern void MinishSizedEntranceManager_Main(); +extern void LightManager_Main(); +extern void LightLevelSetManager_Main(); +extern void BombableWallManager_Main(); +extern void FlameManager_Main(); +extern void PushableFurnitureManager_Main(); +extern void ArmosInteriorManager_Main(); +extern void EnemyInteractionManager_Main(); extern void Manager29_Main(); -extern void Manager2A_Main(Manager*); -extern void Manager2B_Main(); -extern void Manager2C_Main(); -extern void Manager2D_Main(Entity*); -extern void Manager2E_Main(); -extern void Manager2F_Main(); -extern void Manager30_Main(); -extern void Manager31_Main(); -extern void Manager32_Main(); -extern void Manager33_Main(); -extern void Manager34_Main(); -extern void Manager35_Main(); -extern void Manager36_Main(Manager*); -extern void Manager37_Main(); -extern void Manager38_Main(Entity*); -extern void Manager39_Main(); +extern void DestructibleTileObserveManager_Main(); +extern void AngryStatueManager_Main(); +extern void CloudStaircaseTransitionManager_Main(); +extern void WaterfallBottomManager_Main(); +extern void SecretManager_Main(); +extern void Vaati3BackgroundManager_Main(); +extern void TilePuzzleManager_Main(); +extern void GoronMerchantShopManager_Main(); +extern void VaatiAppearingManager_Main(); +extern void HyruleTownBellManager_Main(); +extern void Vaati3InsideArmManager_Main(); +extern void CameraTargetManager_Main(); +extern void RepeatedSoundManager_Main(); +extern void Vaati3StartManager_Main(); +extern void FloatingPlatformManager_Main(); +extern void EnterRoomTextboxManager_Main(); -extern void (*const gManagerFunctions[58])(); +extern void (*const gMiscManagerunctions[58])(); Manager* GetEmptyManager(void); @@ -242,4 +161,4 @@ extern u32 sub_0805ACC0(Entity*); extern void sub_0801855C(void); extern void sub_080186C0(u32); -#endif +#endif // MANAGER_H diff --git a/include/manager/angryStatueManager.h b/include/manager/angryStatueManager.h new file mode 100644 index 00000000..b2b3f9c8 --- /dev/null +++ b/include/manager/angryStatueManager.h @@ -0,0 +1,26 @@ +#ifndef ANGRYSTATUEMANAGER_H +#define ANGRYSTATUEMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + Entity* field_0x20[4]; + u8 field_0x30; + u8 field_0x31; + u8 field_0x32; + u8 field_0x33; + u8 field_0x34; + u8 field_0x35; + u8 field_0x36; + u8 field_0x37; + u8 field_0x38; + u8 field_0x39; + u8 field_0x3a; + u8 field_0x3b; + u8 field_0x3c; + u8 field_0x3d; + u16 field_0x3e; +} AngryStatueManager; + +#endif // ANGRYSTATUEMANAGER_H diff --git a/include/manager/animatedBackgroundManager.h b/include/manager/animatedBackgroundManager.h new file mode 100644 index 00000000..c5807445 --- /dev/null +++ b/include/manager/animatedBackgroundManager.h @@ -0,0 +1,10 @@ +#ifndef ANIMATEDBACKGROUNDMANAGER_H +#define ANIMATEDBACKGROUNDMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} AnimatedBackgroundManager; + +#endif // ANIMATEDBACKGROUNDMANAGER_H diff --git a/include/manager/armosInteriorManager.h b/include/manager/armosInteriorManager.h new file mode 100644 index 00000000..09ff6c96 --- /dev/null +++ b/include/manager/armosInteriorManager.h @@ -0,0 +1,10 @@ +#ifndef ARMOSINTERIORMANAGER_H +#define ARMOSINTERIORMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} ArmosInteriorManager; + +#endif // ARMOSINTERIORMANAGER_H diff --git a/include/manager/bombableWallManager.h b/include/manager/bombableWallManager.h new file mode 100644 index 00000000..8d41bde4 --- /dev/null +++ b/include/manager/bombableWallManager.h @@ -0,0 +1,18 @@ +#ifndef BOMBABLEWALLMANAGER_H +#define BOMBABLEWALLMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 field_0x20[0x15]; + u8 field_0x35; + u8 field_0x36; + u8 field_0x37; + s16 x; + u16 y; + u16 tile; + u16 field_0x3e; +} BombableWallManager; + +#endif // BOMBABLEWALLMANAGER_H diff --git a/include/manager/bridgeManager.h b/include/manager/bridgeManager.h new file mode 100644 index 00000000..aab1f1ab --- /dev/null +++ b/include/manager/bridgeManager.h @@ -0,0 +1,22 @@ +#ifndef BRIDGEMANAGER_H +#define BRIDGEMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20[0x08]; + u16 unk_28; + u16 unk_2a; + u16 unk_2c; + u16 unk_2e; + u16 unk_30; + u16 unk_32; + u8 unk_34[0x04]; + s16 x; + s16 y; + u16 unk_3c; + u16 flags; +} BridgeManager; + +#endif // BRIDGEMANAGER_H diff --git a/include/manager/cameraTargetManager.h b/include/manager/cameraTargetManager.h new file mode 100644 index 00000000..156dad8f --- /dev/null +++ b/include/manager/cameraTargetManager.h @@ -0,0 +1,18 @@ +#ifndef CAMERATARGETMANAGER_H +#define CAMERATARGETMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 field_0x20[0x15]; + u8 field_0x35; + u8 field_0x36; + u8 field_0x37; + s16 field_0x38; + s16 field_0x3a; + u16 field_0x3c; + u16 field_0x3e; +} CameraTargetManager; + +#endif // CAMERATARGETMANAGER_H diff --git a/include/manager/cloudOverlayManager.h b/include/manager/cloudOverlayManager.h new file mode 100644 index 00000000..e4b9ae71 --- /dev/null +++ b/include/manager/cloudOverlayManager.h @@ -0,0 +1,11 @@ +#ifndef CLOUDOVERLAYMANAGER_H +#define CLOUDOVERLAYMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u16 field_0x20; +} CloudOverlayManager; + +#endif // CLOUDOVERLAYMANAGER_H diff --git a/include/manager/cloudStaircaseTransitionManager.h b/include/manager/cloudStaircaseTransitionManager.h new file mode 100644 index 00000000..3a276801 --- /dev/null +++ b/include/manager/cloudStaircaseTransitionManager.h @@ -0,0 +1,17 @@ +#ifndef CLOUDSTAIRCASETRANSITIONMANAGER_H +#define CLOUDSTAIRCASETRANSITIONMANAGER_H + +#include "manager.h" + +typedef struct { + struct Manager base; + u8 field_0x20[0x16]; + u8 field_0x36; + u8 field_0x37; + s16 x; + s16 y; + u16 field_0x3c; + u16 field_0x3e; +} CloudStaircaseTransitionManager; + +#endif // CLOUDSTAIRCASETRANSITIONMANAGER_H diff --git a/include/manager/delayedEntityLoadManager.h b/include/manager/delayedEntityLoadManager.h new file mode 100644 index 00000000..4546090b --- /dev/null +++ b/include/manager/delayedEntityLoadManager.h @@ -0,0 +1,6 @@ +#ifndef DELAYEDENTITYLOADMANAGER_H +#define DELAYEDENTITYLOADMANAGER_H + +#include "manager.h" + +#endif // DELAYEDENTITYLOADMANAGER_H diff --git a/include/manager/destructibleTileObserveManager.h b/include/manager/destructibleTileObserveManager.h new file mode 100644 index 00000000..7a60c768 --- /dev/null +++ b/include/manager/destructibleTileObserveManager.h @@ -0,0 +1,18 @@ +#ifndef DESTRUCTIBLETILEOBSERVEMANAGER_H +#define DESTRUCTIBLETILEOBSERVEMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} DestructibleTileObserveManager; + +typedef struct { + u8 field_0x0; + u8 tileLayer; + u16 flag; + u16 tilePos; + u16 tileType; // If the tile type at tilePos, tileLayer is tileType, set the local flag. +} DestructibleTileObserveManager_unk; // TODO result of GetCurrentRoomProperty(3)? + +#endif // DESTRUCTIBLETILEOBSERVEMANAGER_H diff --git a/include/manager/diggingCaveEntranceManager.h b/include/manager/diggingCaveEntranceManager.h new file mode 100644 index 00000000..6f9c8914 --- /dev/null +++ b/include/manager/diggingCaveEntranceManager.h @@ -0,0 +1,32 @@ +#ifndef DIGGINGCAVEENTRANCEMANAGER_H +#define DIGGINGCAVEENTRANCEMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} DiggingCaveEntranceManager; + +typedef struct { + u16 sourceTilePosition; /**< Tile position for the entrance in the source room. */ + u8 sourceRoom; + u8 type; // TODO some sort of type that is used to index gUnk_08109194 + u8 targetArea; + u8 targetRoom; + u16 targetTilePosition; /**< Tile position for the entrance in the target room. */ +} DiggingCaveEntrance; + +typedef struct { + const DiggingCaveEntrance* entrance; + u16 offsetX; /**< X offset from the player to the entrance. */ + u16 offsetY; /**< Y offset from the player to the entrance. */ + bool8 isDiggingCave; + u8 currentArea; /**< Area the player was in before the transition. */ + u8 previousArea; /**< Previous value of currentArea. */ + u8 targetRoom; /**< targetRoom | 0x80 ? */ +} DiggingCaveEntranceTransition; +extern DiggingCaveEntranceTransition gDiggingCaveEntranceTransition; + +extern const DiggingCaveEntrance* const diggingCaveEntrances[]; + +#endif // DIGGINGCAVEENTRANCEMANAGER_H diff --git a/include/manager/enemyInteractionManager.h b/include/manager/enemyInteractionManager.h new file mode 100644 index 00000000..8356ecdb --- /dev/null +++ b/include/manager/enemyInteractionManager.h @@ -0,0 +1,13 @@ +#ifndef ENEMYINTERACTIONMANAGER_H +#define ENEMYINTERACTIONMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + struct { + Entity* enemies[8]; + } d; +} EnemyInteractionManager; + +#endif // ENEMYINTERACTIONMANAGER_H diff --git a/include/manager/enterRoomTextboxManager.h b/include/manager/enterRoomTextboxManager.h new file mode 100644 index 00000000..f823a612 --- /dev/null +++ b/include/manager/enterRoomTextboxManager.h @@ -0,0 +1,18 @@ +#ifndef ENTERROOMTEXTBOXMANAGER_H +#define ENTERROOMTEXTBOXMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20; // unused + u8 unk_21[0x13]; // unused + u16 unk_34; // unused + u16 unk_36; // unused + s16 unk_38; // unused + s16 unk_3A; // unused + u16 unk_3C; // unused + u16 unk_3E; // unused +} EnterRoomTextboxManager; + +#endif // ENTERROOMTEXTBOXMANAGER_H diff --git a/include/manager/entitySpawnManager.h b/include/manager/entitySpawnManager.h new file mode 100644 index 00000000..02abba52 --- /dev/null +++ b/include/manager/entitySpawnManager.h @@ -0,0 +1,15 @@ +#ifndef ENTITYSPAWNMANAGER_H +#define ENTITYSPAWNMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20[0x18]; + s16 sound; + s16 spawnTimer; /**< Timer until the entity list is loaded. */ + u16 unk_3c; + u16 flag; +} EntitySpawnManager; + +#endif // ENTITYSPAWNMANAGER_H diff --git a/include/manager/ezloHintManager.h b/include/manager/ezloHintManager.h new file mode 100644 index 00000000..a06ea474 --- /dev/null +++ b/include/manager/ezloHintManager.h @@ -0,0 +1,23 @@ +#ifndef EZLOHINTMANAGER_H +#define EZLOHINTMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u16 x; + u16 y; + u16 rx; + u16 ry; + u8 unk_28[13]; + u8 msg_height; + u16 msg_idx; + u8 x_raw; + u8 y_raw; + u8 rx_raw; + u8 ry_raw; + u16 flag1; + u16 flag2; +} EzloHintManager; + +#endif // EZLOHINTMANAGER_H diff --git a/include/manager/fallingItemManager.h b/include/manager/fallingItemManager.h new file mode 100644 index 00000000..77c79aa5 --- /dev/null +++ b/include/manager/fallingItemManager.h @@ -0,0 +1,18 @@ +#ifndef FALLINGITEMMANAGER_H +#define FALLINGITEMMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 field_0x20[0x15]; + u8 field_0x35; + u8 field_0x36; + u8 field_0x37; + s16 field_0x38; + s16 field_0x3a; + u16 field_0x3c; + u16 field_0x3e; +} FallingItemManager; + +#endif // FALLINGITEMMANAGER_H diff --git a/include/manager/fightManager.h b/include/manager/fightManager.h new file mode 100644 index 00000000..2d3968de --- /dev/null +++ b/include/manager/fightManager.h @@ -0,0 +1,22 @@ +#ifndef FIGHTMANAGER_H +#define FIGHTMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20; + u8 unk_21[0x14]; + u8 unk_35; + u8 unk_36[0x4]; + u16 unk_3a; + u16 fightStartFlag; + u16 fightCompletedFlag; +} FightManager; + +typedef struct { + Manager base; + Entity* enemies[8]; +} FightManagerHelper; + +#endif // FIGHTMANAGER_H diff --git a/include/manager/flagAndOperatorManager.h b/include/manager/flagAndOperatorManager.h new file mode 100644 index 00000000..f41a129a --- /dev/null +++ b/include/manager/flagAndOperatorManager.h @@ -0,0 +1,13 @@ +#ifndef FLAGANDOPERATORMANAGER_H +#define FLAGANDOPERATORMANAGER_H + +#include "manager.h" + +typedef struct FlagAndOperatorManager { + Manager base; + u8 unk_20[0x1C]; + u16 unk_3c; + u16 unk_3e; +} FlagAndOperatorManager; + +#endif // FLAGANDOPERATORMANAGER_H diff --git a/include/manager/flameManager.h b/include/manager/flameManager.h new file mode 100644 index 00000000..2c5ebe7c --- /dev/null +++ b/include/manager/flameManager.h @@ -0,0 +1,13 @@ +#ifndef FLAMEMANAGER_H +#define FLAMEMANAGER_H + +#include "manager.h" + +typedef struct { + struct Manager base; + u8 field_0x20[0x18]; + s16 field_0x38; + s16 field_0x3a; +} FlameManager; + +#endif // FLAMEMANAGER_H diff --git a/include/manager/floatingPlatformManager.h b/include/manager/floatingPlatformManager.h new file mode 100644 index 00000000..deb7235f --- /dev/null +++ b/include/manager/floatingPlatformManager.h @@ -0,0 +1,10 @@ +#ifndef FLOATINGPLATFORMMANAGER_H +#define FLOATINGPLATFORMMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} FloatingPlatformManager; + +#endif // FLOATINGPLATFORMMANAGER_H diff --git a/include/manager/goronMerchantShopManager.h b/include/manager/goronMerchantShopManager.h new file mode 100644 index 00000000..dcc78c55 --- /dev/null +++ b/include/manager/goronMerchantShopManager.h @@ -0,0 +1,11 @@ +#ifndef GORONMERCHANTSHOPMANAGER_H +#define GORONMERCHANTSHOPMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 itemActive[3]; +} GoronMerchantShopManager; + +#endif // GORONMERCHANTSHOPMANAGER_H diff --git a/include/manager/holeManager.h b/include/manager/holeManager.h new file mode 100644 index 00000000..59bb8d66 --- /dev/null +++ b/include/manager/holeManager.h @@ -0,0 +1,21 @@ +#ifndef HOLEMANAGER_H +#define HOLEMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + s16 unk_20; + s16 unk_22; + u16 unk_24; + u16 unk_26; + u8 unk_28[8]; + u16 unk_30; + u16 unk_32; + u16 unk_34; + u16 unk_36; + u8 unk_38[7]; + u8 unk_3f; +} HoleManager; + +#endif // HOLEMANAGER_H diff --git a/include/manager/horizontalMinishPathBackgroundManager.h b/include/manager/horizontalMinishPathBackgroundManager.h new file mode 100644 index 00000000..f67d4841 --- /dev/null +++ b/include/manager/horizontalMinishPathBackgroundManager.h @@ -0,0 +1,14 @@ +#ifndef HORIZONTALMINISHPATHBACKGROUNDMANAGER_H +#define HORIZONTALMINISHPATHBACKGROUNDMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20; + u8 unk_21[0x17]; + u32 unk_38; + u32 unk_3c; +} HorizontalMinishPathBackgroundManager; + +#endif // HORIZONTALMINISHPATHBACKGROUNDMANAGER_H diff --git a/include/manager/houseSignManager.h b/include/manager/houseSignManager.h new file mode 100644 index 00000000..7402bc0d --- /dev/null +++ b/include/manager/houseSignManager.h @@ -0,0 +1,11 @@ +#ifndef HOUSESIGNMANAGER_H +#define HOUSESIGNMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u32 bitfield; +} HouseSignManager; + +#endif // HOUSESIGNMANAGER_H diff --git a/include/manager/hyruleTownBellManager.h b/include/manager/hyruleTownBellManager.h new file mode 100644 index 00000000..976a639e --- /dev/null +++ b/include/manager/hyruleTownBellManager.h @@ -0,0 +1,10 @@ +#ifndef HYRULETOWNBELLMANAGER_H +#define HYRULETOWNBELLMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} HyruleTownBellManager; + +#endif // HYRULETOWNBELLMANAGER_H diff --git a/include/manager/hyruleTownTilesetManager.h b/include/manager/hyruleTownTilesetManager.h new file mode 100644 index 00000000..8e269355 --- /dev/null +++ b/include/manager/hyruleTownTilesetManager.h @@ -0,0 +1,13 @@ +#ifndef HYRULETOWNTILESETMANAGER_H +#define HYRULETOWNTILESETMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 field_0x20; + u8 field_0x21; + u8 field_0x22; +} HyruleTownTilesetManager; + +#endif // HYRULETOWNTILESETMANAGER_H diff --git a/include/manager/lightLevelSetManager.h b/include/manager/lightLevelSetManager.h new file mode 100644 index 00000000..73170ffe --- /dev/null +++ b/include/manager/lightLevelSetManager.h @@ -0,0 +1,19 @@ +#ifndef LIGHTLEVELSETMANAGER_H +#define LIGHTLEVELSETMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u16 field_0x20; + u16 field_0x22; + u8 field_0x24[0x12]; + u8 field_0x36; + u8 field_0x37; + u16 field_0x38; + u16 field_0x3a; + u16 field_0x3c; + u16 field_0x3e; +} LightLevelSetManager; + +#endif // LIGHTLEVELSETMANAGER_H diff --git a/include/manager/lightManager.h b/include/manager/lightManager.h new file mode 100644 index 00000000..9bbb1c6b --- /dev/null +++ b/include/manager/lightManager.h @@ -0,0 +1,11 @@ +#ifndef LIGHTMANAGER_H +#define LIGHTMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + s32 unk20; +} LightManager; + +#endif // LIGHTMANAGER_H diff --git a/include/manager/lightRayManager.h b/include/manager/lightRayManager.h new file mode 100644 index 00000000..c36ba862 --- /dev/null +++ b/include/manager/lightRayManager.h @@ -0,0 +1,17 @@ +#ifndef LIGHTRAYMANAGER_H +#define LIGHTRAYMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20; + u8 unk_21; + u8 unk_22; + u8 unk_23; + u8 unk_24; + u8 unk_25[15]; + void* unk_34; +} LightRayManager; + +#endif // LIGHTRAYMANAGER_H diff --git a/include/manager/manager29.h b/include/manager/manager29.h new file mode 100644 index 00000000..a26f291c --- /dev/null +++ b/include/manager/manager29.h @@ -0,0 +1,22 @@ +#ifndef MANAGER29_H +#define MANAGER29_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20[0x8]; + u16* unk_28; + u16* unk_2c; + u8 filler[0x4]; + u8 unk_34; + u8 unk_35; + u8 unk_36; + u8 unk_37; + s16 unk_38; + u16 unk_3a; + u16 unk_3c; + u16 unk_3e; +} Manager29; + +#endif // MANAGER29_H diff --git a/include/manager/minishPortalManager.h b/include/manager/minishPortalManager.h new file mode 100644 index 00000000..35a40027 --- /dev/null +++ b/include/manager/minishPortalManager.h @@ -0,0 +1,20 @@ +#ifndef MINISHPORTALMANAGER_H +#define MINISHPORTALMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u32 unk_20; + u32 unk_24; + u8 unk_28[0xC]; + u8 unk_34; + u8 unk_35; + u16 unk_36; + u16 unk_38; + u16 unk_3a; + u16 unk_3c; + u16 unk_3e; +} MinishPortalManager; + +#endif // MINISHPORTALMANAGER_H diff --git a/include/manager/minishRaftersBackgroundManager.h b/include/manager/minishRaftersBackgroundManager.h new file mode 100644 index 00000000..1c746870 --- /dev/null +++ b/include/manager/minishRaftersBackgroundManager.h @@ -0,0 +1,12 @@ +#ifndef MINISHRAFTERSBACKGROUNDMANAGER_H +#define MINISHRAFTERSBACKGROUNDMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_00[0x1C]; + u32 unk_3c; +} MinishRaftersBackgroundManager; + +#endif // MINISHRAFTERSBACKGROUNDMANAGER_H diff --git a/include/manager/minishSizedEntranceManager.h b/include/manager/minishSizedEntranceManager.h new file mode 100644 index 00000000..1da3f4d5 --- /dev/null +++ b/include/manager/minishSizedEntranceManager.h @@ -0,0 +1,11 @@ +#ifndef MINISHSIZEDENTRANCEMANAGER_H +#define MINISHSIZEDENTRANCEMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u32 field_0x20; +} MinishSizedEntranceManager; + +#endif // MINISHSIZEDENTRANCEMANAGER_H diff --git a/include/manager/minishVillageTilesetManager.h b/include/manager/minishVillageTilesetManager.h new file mode 100644 index 00000000..50c01f54 --- /dev/null +++ b/include/manager/minishVillageTilesetManager.h @@ -0,0 +1,12 @@ +#ifndef MINISHVILLAGETILESETMANAGER_H +#define MINISHVILLAGETILESETMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20; + u8 unk_21[0x1F]; +} MinishVillageTilesetManager; + +#endif // MINISHVILLAGETILESETMANAGER_H diff --git a/include/manager/miscManager.h b/include/manager/miscManager.h new file mode 100644 index 00000000..6c763ca1 --- /dev/null +++ b/include/manager/miscManager.h @@ -0,0 +1,15 @@ +#ifndef MISCMANAGER_H +#define MISCMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20[0x18]; + s16 unk_38; + s16 unk_3a; + u16 unk_3c; + u16 unk_3e; +} MiscManager; + +#endif // MISCMANAGER_H diff --git a/include/manager/moveableObjectManager.h b/include/manager/moveableObjectManager.h new file mode 100644 index 00000000..9d742a59 --- /dev/null +++ b/include/manager/moveableObjectManager.h @@ -0,0 +1,19 @@ +#ifndef MOVEABLEOBJECTMANAGER_H +#define MOVEABLEOBJECTMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20[0x12]; + u16 unk_32; + u8 unk_34[2]; + u8 unk_36; + u8 unk_37; + u16 unk_38; + u16 unk_3a; + u16 unk_3c; + u16 flags; +} MoveableObjectManager; + +#endif // MOVEABLEOBJECTMANAGER_H diff --git a/include/manager/powBackgroundManager.h b/include/manager/powBackgroundManager.h new file mode 100644 index 00000000..300022c8 --- /dev/null +++ b/include/manager/powBackgroundManager.h @@ -0,0 +1,10 @@ +#ifndef POWBACKGROUNDMANAGER_H +#define POWBACKGROUNDMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} PowBackgroundManager; + +#endif // POWBACKGROUNDMANAGER_H diff --git a/include/manager/pushableFurnitureManager.h b/include/manager/pushableFurnitureManager.h new file mode 100644 index 00000000..590be85b --- /dev/null +++ b/include/manager/pushableFurnitureManager.h @@ -0,0 +1,23 @@ +#ifndef PUSHABLEFURNITUREMANAGER_H +#define PUSHABLEFURNITUREMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20[0x8]; + u8 unk_28; + u8 unk_29; + u16 unk_2a; +} PushableFurnitureManager; + +typedef struct { + u8 unk_00; + u8 unk_01; + u8 unk_02; + u8 unk_03; + u16 unk_04; + u16 unk_06; +} UnkPushableFurnitureManagerHelperStruct; + +#endif // PUSHABLEFURNITUREMANAGER_H diff --git a/include/manager/railIntersectionManager.h b/include/manager/railIntersectionManager.h new file mode 100644 index 00000000..9de3c0ad --- /dev/null +++ b/include/manager/railIntersectionManager.h @@ -0,0 +1,18 @@ +#ifndef RAILINTERSECTIONMANAGER_H +#define RAILINTERSECTIONMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 field_0x20[0x16]; + u8 field_0x36; + u8 field_0x37; + s16 field_0x38; + u16 field_0x3a; + u8 field_0x3c; + u8 field_0x3d; + u16 flags; +} RailIntersectionManager; + +#endif // RAILINTERSECTIONMANAGER_H diff --git a/include/manager/rainfallManager.h b/include/manager/rainfallManager.h new file mode 100644 index 00000000..217bc10a --- /dev/null +++ b/include/manager/rainfallManager.h @@ -0,0 +1,10 @@ +#ifndef RAINFALLMANAGER_H +#define RAINFALLMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} RainfallManager; + +#endif // RAINFALLMANAGER_H diff --git a/include/manager/regionTriggerManager.h b/include/manager/regionTriggerManager.h new file mode 100644 index 00000000..0c7a3be2 --- /dev/null +++ b/include/manager/regionTriggerManager.h @@ -0,0 +1,17 @@ +#ifndef REGIONTRIGGERMANAGER_H +#define REGIONTRIGGERMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20[0x14]; // unused + u16 radiusX; + u16 radiusY; + s16 posX; + s16 posY; + u8 unk_3c[2]; // unused + u16 playerInRegionFlag; +} RegionTriggerManager; + +#endif // REGIONTRIGGERMANAGER_H diff --git a/include/manager/repeatedSoundManager.h b/include/manager/repeatedSoundManager.h new file mode 100644 index 00000000..6ac1dfb3 --- /dev/null +++ b/include/manager/repeatedSoundManager.h @@ -0,0 +1,10 @@ +#ifndef REPEATEDSOUNDMANAGER_H +#define REPEATEDSOUNDMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} RepeatedSoundManager; + +#endif // REPEATEDSOUNDMANAGER_H diff --git a/include/manager/rollingBarrelManager.h b/include/manager/rollingBarrelManager.h new file mode 100644 index 00000000..614d935c --- /dev/null +++ b/include/manager/rollingBarrelManager.h @@ -0,0 +1,22 @@ +#ifndef ROLLINGBARRELMANAGER_H +#define ROLLINGBARRELMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + s32 unk_20; + union SplitWord unk_24; + u32 unk_28; + u32 unk_2c; + u8 unk_30[0x10]; +} RollingBarrelManager; + +typedef struct { + u16 unk_0; + u16 unk_2; + u16 unk_4; + u16 unk_6; +} struct_08108228; + +#endif // ROLLINGBARRELMANAGER_H diff --git a/include/manager/secretManager.h b/include/manager/secretManager.h new file mode 100644 index 00000000..96a94048 --- /dev/null +++ b/include/manager/secretManager.h @@ -0,0 +1,16 @@ +#ifndef SECRETMANAGER_H +#define SECRETMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 field_0x20[0x18]; + s16 field_0x38; + u8 field_0x3a; + u8 field_0x3b; + u16 field_0x3c; + u16 field_0x3e; +} SecretManager; + +#endif // SECRETMANAGER_H diff --git a/include/manager/specialWarpManager.h b/include/manager/specialWarpManager.h new file mode 100644 index 00000000..200edcf1 --- /dev/null +++ b/include/manager/specialWarpManager.h @@ -0,0 +1,28 @@ +#ifndef SPECIALWARPMANAGER_H +#define SPECIALWARPMANAGER_H + +#include "manager.h" + +typedef struct { + u16 posX; + u16 posY; + u8 width; + u8 height; + u8 roomProperty; + union { + u8 all; + struct { + u8 layer : 2; + u8 unk1 : 2; + u8 unk2 : 1; + u8 unk3 : 3; + } PACKED b; + } PACKED unk_07; +} SpecialWarpManagerWarpData; + +typedef struct { + Manager base; + SpecialWarpManagerWarpData* warpList; +} SpecialWarpManager; + +#endif // SPECIALWARPMANAGER_H diff --git a/include/manager/staticBackgroundManager.h b/include/manager/staticBackgroundManager.h new file mode 100644 index 00000000..f2cab28a --- /dev/null +++ b/include/manager/staticBackgroundManager.h @@ -0,0 +1,11 @@ +#ifndef STATICBACKGROUNDMANAGER_H +#define STATICBACKGROUNDMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u32 field_0x20; +} StaticBackgroundManager; + +#endif // STATICBACKGROUNDMANAGER_H diff --git a/include/manager/steamOverlayManager.h b/include/manager/steamOverlayManager.h new file mode 100644 index 00000000..4ab2b455 --- /dev/null +++ b/include/manager/steamOverlayManager.h @@ -0,0 +1,15 @@ +#ifndef STEAMOVERLAYMANAGER_H +#define STEAMOVERLAYMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u16 unk_20; + u8 unk_22; + u8 unk_23[1]; + u8 unk_24; + u8 unk_25[0x1b]; +} SteamOverlayManager; + +#endif // STEAMOVERLAYMANAGER_H diff --git a/include/manager/templeOfDropletsManager.h b/include/manager/templeOfDropletsManager.h new file mode 100644 index 00000000..da1e8f66 --- /dev/null +++ b/include/manager/templeOfDropletsManager.h @@ -0,0 +1,25 @@ +#ifndef TEMPLEOFDROPLETSMANAGER_H +#define TEMPLEOFDROPLETSMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20; + u8 unk_21; + u8 unk_22; + u8 unk_23; // used + u16 unk_24; + u16 unk_26; + void* unk_28; + u16 unk_2c; + u8 unk_2e[0x6]; + s16 unk_34; + s16 unk_36; + s16 unk_38; + s16 unk_3a; + u16 unk_3c; + u16 unk_3e; // used +} TempleOfDropletsManager; + +#endif // TEMPLEOFDROPLETSMANAGER_H diff --git a/include/manager/tileChangeObserveManager.h b/include/manager/tileChangeObserveManager.h new file mode 100644 index 00000000..fda2c35a --- /dev/null +++ b/include/manager/tileChangeObserveManager.h @@ -0,0 +1,35 @@ +#ifndef TILECHANGEOBSERVEMANAGER_H +#define TILECHANGEOBSERVEMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 field_0x20; + u8 field_0x21; + u8 field_0x22; + u8 field_0x23; + u8 field_0x24; + u8 field_0x25; + u8 field_0x26; + u8 field_0x27; + u16 initialTile; + u8 field_0x2a; + u8 field_0x2b; + u8 field_0x2c; + u8 field_0x2d; + u8 field_0x2e; + u8 field_0x2f; + u16* observedTile; + u8 field_0x34; + u8 field_0x35; + u8 field_0x36; + u8 field_0x37; + u16 tilePosition; + u16 field_0x3a; + u8 field_0x3c; + u8 field_0x3d; + u16 flag; +} TileChangeObserveManager; + +#endif // TILECHANGEOBSERVEMANAGER_H diff --git a/include/manager/tilePuzzleManager.h b/include/manager/tilePuzzleManager.h new file mode 100644 index 00000000..bbf2e2cf --- /dev/null +++ b/include/manager/tilePuzzleManager.h @@ -0,0 +1,22 @@ +#ifndef TILEPUZZLEMANAGER_H +#define TILEPUZZLEMANAGER_H + +#include "manager.h" + +typedef struct TilePuzzleManager { + Manager base; + u8 unk_20[8]; // unused + u16 own_tile; + u8 unk_2a[0x2]; // unused + u16 player_previous_tile; + u16 player_current_tile; + u8 unk_30[0x6]; // unused + u8 width; + u8 height; + s16 x; + s16 y; + u16 flag_succeeded; + u16 flag_reset; +} TilePuzzleManager; + +#endif // TILEPUZZLEMANAGER_H diff --git a/include/manager/vaati3BackgroundManager.h b/include/manager/vaati3BackgroundManager.h new file mode 100644 index 00000000..58f167a4 --- /dev/null +++ b/include/manager/vaati3BackgroundManager.h @@ -0,0 +1,10 @@ +#ifndef VAATI3BACKGROUNDMANAGER_H +#define VAATI3BACKGROUNDMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} Vaati3BackgroundManager; + +#endif // VAATI3BACKGROUNDMANAGER_H diff --git a/include/manager/vaati3InsideArmManager.h b/include/manager/vaati3InsideArmManager.h new file mode 100644 index 00000000..54510841 --- /dev/null +++ b/include/manager/vaati3InsideArmManager.h @@ -0,0 +1,11 @@ +#ifndef VAATI3INSIDEARMMANAGER_H +#define VAATI3INSIDEARMMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u16 field_0x20; +} Vaati3InsideArmManager; + +#endif // VAATI3INSIDEARMMANAGER_H diff --git a/include/manager/vaati3StartManager.h b/include/manager/vaati3StartManager.h new file mode 100644 index 00000000..30d8e1bf --- /dev/null +++ b/include/manager/vaati3StartManager.h @@ -0,0 +1,10 @@ +#ifndef VAATI3STARTMANAGER_H +#define VAATI3STARTMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} Vaati3StartManager; + +#endif // VAATI3STARTMANAGER_H diff --git a/include/manager/vaatiAppearingManager.h b/include/manager/vaatiAppearingManager.h new file mode 100644 index 00000000..305ab528 --- /dev/null +++ b/include/manager/vaatiAppearingManager.h @@ -0,0 +1,13 @@ +#ifndef VAATIAPPEARINGMANAGER_H +#define VAATIAPPEARINGMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u32 field_0x20; + u32 field_0x24; + u32 field_0x28; +} VaatiAppearingManager; + +#endif // VAATIAPPEARINGMANAGER_H diff --git a/include/manager/verticalMinishPathBackgroundManager.h b/include/manager/verticalMinishPathBackgroundManager.h new file mode 100644 index 00000000..34a80080 --- /dev/null +++ b/include/manager/verticalMinishPathBackgroundManager.h @@ -0,0 +1,13 @@ +#ifndef VERTICALMINISHPATHBACKGROUNDMANAGER_H +#define VERTICALMINISHPATHBACKGROUNDMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u32 field_0x20[0x6]; + void* field_0x38; + void* field_0x3c; +} VerticalMinishPathBackgroundManager; + +#endif // VERTICALMINISHPATHBACKGROUNDMANAGER_H diff --git a/include/manager/waterfallBottomManager.h b/include/manager/waterfallBottomManager.h new file mode 100644 index 00000000..88d35f7a --- /dev/null +++ b/include/manager/waterfallBottomManager.h @@ -0,0 +1,10 @@ +#ifndef WATERFALLBOTTOMMANAGER_H +#define WATERFALLBOTTOMMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; +} WaterfallBottomManager; + +#endif // WATERFALLBOTTOMMANAGER_H diff --git a/include/manager/weatherChangeManager.h b/include/manager/weatherChangeManager.h new file mode 100644 index 00000000..d0a7744c --- /dev/null +++ b/include/manager/weatherChangeManager.h @@ -0,0 +1,15 @@ +#ifndef WEATHERCHANGEMANAGER_H +#define WEATHERCHANGEMANAGER_H + +#include "manager.h" + +typedef struct { + Manager base; + u8 unk_20; + u8 unk_21; + u8 unk_22; + u8 unk_23; + u8 filler_0x24[0x1C]; +} WeatherChangeManager; + +#endif // WEATHERCHANGEMANAGER_H diff --git a/include/map.h b/include/map.h index 8c8adb46..b943ca2e 100644 --- a/include/map.h +++ b/include/map.h @@ -2,9 +2,10 @@ #define MAP_H #include "global.h" +#include "screen.h" typedef struct { - /*0x0000*/ u16* bgControlPtr; // Points to the BgSettings.control field for the bg belonging to this layer? + /*0x0000*/ BgSettings* bgSettings; /*0x0004*/ u16 mapData[0x1000]; // tilemap data? <-- gMapDataTop / gMapDataBottom /*0x2004*/ u8 collisionData[0x1000]; // more tilemap data? <-- gUnk_0200D654 / gUnk_02027EB4 /*0x3004*/ u16 mapDataClone[0x1000]; // more tilemap data? <-- gUnk_0200E654 / gUnk_02028EB4 @@ -19,4 +20,4 @@ extern LayerStruct gMapBottom; LayerStruct* GetLayerByIndex(u32); -#endif // MAP_H \ No newline at end of file +#endif // MAP_H diff --git a/include/menu.h b/include/menu.h index 609aad82..df97c884 100644 --- a/include/menu.h +++ b/include/menu.h @@ -125,4 +125,4 @@ extern Menu gMenu; #define gFigurineMenu (*(FigurineMenu*)&gMenu) #define gPauseMenu (*(PauseMenu*)&gMenu) -#endif +#endif // MENU_H diff --git a/include/new_player.h b/include/new_player.h index a70122ca..bae1ed2f 100644 --- a/include/new_player.h +++ b/include/new_player.h @@ -23,4 +23,4 @@ typedef struct { #define gNewPlayerEntity (*(PlayerEntity*)&gPlayerEntity) -#endif \ No newline at end of file +#endif // NEW_PLAYER_H diff --git a/include/npc.h b/include/npc.h index 2be97262..05ee9e36 100644 --- a/include/npc.h +++ b/include/npc.h @@ -372,4 +372,4 @@ void NPC58_Head(Entity*); extern void (*const gNPCFunctions[128][3])(Entity*); -#endif +#endif // NPC_H diff --git a/include/object.h b/include/object.h index cf38190c..a0046526 100644 --- a/include/object.h +++ b/include/object.h @@ -427,4 +427,4 @@ void ObjectC1(); extern void (*const gObjectFunctions[194])(Entity*); -#endif +#endif // OBJECT_H diff --git a/include/object/deathFx.h b/include/object/deathFx.h index 99cffc86..ba8c69dc 100644 --- a/include/object/deathFx.h +++ b/include/object/deathFx.h @@ -1,5 +1,5 @@ -#ifndef TMC_DEATHFX_H -#define TMC_DEATHFX_H +#ifndef DEATHFX_H +#define DEATHFX_H #ifndef NENT_DEPRECATED #error "deathFx.h requires new entities" @@ -14,4 +14,4 @@ typedef struct { u8 item; } DeathFxObject; -#endif // TMC_DEATHFX_H +#endif // DEATHFX_H diff --git a/include/physics.h b/include/physics.h index a5aee40d..9389ea22 100644 --- a/include/physics.h +++ b/include/physics.h @@ -1,5 +1,5 @@ -#ifndef POSITION_H -#define POSITION_H +#ifndef PHYSICS_H +#define PHYSICS_H #include "global.h" #include "entity.h" @@ -55,4 +55,5 @@ extern bool32 ProcessMovementInternal(Entity*, s32, s32, u32); extern const s16 gSineTable[64]; extern const s16 gCosineTable[256]; -#endif + +#endif // PHYSICS_H diff --git a/include/player.h b/include/player.h index ef6129fc..df2ee028 100644 --- a/include/player.h +++ b/include/player.h @@ -480,4 +480,4 @@ void SetZeldaFollowTarget(Entity*); #define COPY_FLAG_FROM_TO(base, src, dest) (base) = ((base) & ~(dest)) | (((dest) * ((base) & (src))) / src) -#endif +#endif // PLAYER_H diff --git a/include/playeritem.h b/include/playeritem.h index fcf643d9..8ca8d783 100644 --- a/include/playeritem.h +++ b/include/playeritem.h @@ -29,4 +29,4 @@ typedef enum { PLAYER_ITEM_CELL_OVERWRITE_SET2, } PlayerItem; -#endif +#endif // PLAYERITEM_H diff --git a/include/projectile.h b/include/projectile.h index 64df8ac4..c8186e2b 100644 --- a/include/projectile.h +++ b/include/projectile.h @@ -84,4 +84,4 @@ typedef enum { /*24*/ V3_TENNIS_BALL_PROJECTILE, } Projectile; -#endif \ No newline at end of file +#endif // PROJECTILE_H diff --git a/include/projectile/winder.h b/include/projectile/winder.h index 1fe479ff..face0213 100644 --- a/include/projectile/winder.h +++ b/include/projectile/winder.h @@ -1,5 +1,5 @@ -#ifndef PROJECTILE_WINDER_H -#define PROJECTILE_WINDER_H +#ifndef WINDER_H +#define WINDER_H #include "enemy.h" #define WINDER_NUM_SEGMENTS 8 @@ -9,4 +9,4 @@ typedef struct { s16 positions[2 * WINDER_NUM_SEGMENTS]; } WinderEntity; -#endif +#endif // WINDER_H diff --git a/include/room.h b/include/room.h index d4c35300..d1becf0b 100644 --- a/include/room.h +++ b/include/room.h @@ -238,4 +238,4 @@ void sub_0804B0B0(u32 arg0, u32 arg1); void DoExitTransition(const ScreenTransitionData* data); -#endif +#endif // ROOM_H diff --git a/include/roomid.h b/include/roomid.h index db520bdd..14bc46c9 100644 --- a/include/roomid.h +++ b/include/roomid.h @@ -1,5 +1,5 @@ -#ifndef TMC_ROOMID_H -#define TMC_ROOMID_H +#ifndef ROOMID_H +#define ROOMID_H typedef enum { // AREA_MINISH_WOODS @@ -990,4 +990,4 @@ typedef enum { ROOM_8F_0 = 0, } RoomID; -#endif // TMC_ROOMID_H +#endif // ROOMID_H diff --git a/include/save.h b/include/save.h index 1941a722..4e1c1335 100644 --- a/include/save.h +++ b/include/save.h @@ -135,4 +135,4 @@ extern const u8* const demoPointers[]; extern const u8 demoUnknown1[]; #endif -#endif +#endif // SAVE_H diff --git a/include/screen.h b/include/screen.h index fe17b183..9b6b3f7a 100644 --- a/include/screen.h +++ b/include/screen.h @@ -1,5 +1,5 @@ -#ifndef BG_H -#define BG_H +#ifndef SCREEN_H +#define SCREEN_H #include "global.h" #include "fade.h" @@ -80,4 +80,4 @@ extern OAMCommand gOamCmd; extern void sub_080ADA04(OAMCommand*, void*); -#endif +#endif // SCREEN_H diff --git a/include/script.h b/include/script.h index 3c4e5bfe..4591ac27 100644 --- a/include/script.h +++ b/include/script.h @@ -49,4 +49,5 @@ void ExecuteScriptForEntity(Entity* entity, void (*postScriptCallback)(Entity*, void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context); void HandleEntity0x82Actions(Entity* entity); void sub_0807DD94(Entity*, void (*function)(Entity*, ScriptExecutionContext*)); -#endif + +#endif // SCRIPT_H diff --git a/include/scroll.h b/include/scroll.h new file mode 100644 index 00000000..3f6d47b4 --- /dev/null +++ b/include/scroll.h @@ -0,0 +1,9 @@ +#ifndef SCROLL_H +#define SCROLL_H + +#include "global.h" + +void UpdateIsDiggingCave(void); +void sub_08080930(u32); + +#endif // SCROLL_H diff --git a/include/sprite.h b/include/sprite.h index 7539891f..6a8b620b 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -35,4 +35,4 @@ typedef struct { u8 unk; } SpriteLoadData; -#endif +#endif // SPRITE_H diff --git a/include/structures.h b/include/structures.h index 88798071..3b717180 100644 --- a/include/structures.h +++ b/include/structures.h @@ -324,4 +324,4 @@ typedef struct { s16 position; } TileData; -#endif +#endif // STRUCTURES_H diff --git a/include/transitions.h b/include/transitions.h index 0d536e5a..3da9d77e 100644 --- a/include/transitions.h +++ b/include/transitions.h @@ -1,5 +1,6 @@ -#ifndef TMC_TRANSITIONS_H -#define TMC_TRANSITIONS_H +#ifndef TRANSITIONS_H +#define TRANSITIONS_H + #include "global.h" #include "roomid.h" @@ -51,4 +52,4 @@ extern const Transition gUnk_08135190[]; extern const Transition gUnk_0813A76C[]; extern const Transition* const* const gExitLists[]; -#endif // TMC_TRANSITIONS_H +#endif // TRANSITIONS_H diff --git a/include/ui.h b/include/ui.h index fd836001..2a4994ee 100644 --- a/include/ui.h +++ b/include/ui.h @@ -12,4 +12,4 @@ extern void InitUI(bool32); extern void RefreshUI(void); extern void RecoverUI(u32 bottomPt, u32 topPt); -#endif \ No newline at end of file +#endif // UI_H diff --git a/linker.ld b/linker.ld index 443d0cff..96545965 100644 --- a/linker.ld +++ b/linker.ld @@ -186,7 +186,7 @@ SECTIONS { . = 0x00003DF0; gUnk_03003DF0 = .; . = 0x00003DF8; gUnk_03003DF8 = .; . = 0x00003F80; gPlayerState = .; - . = 0x00004030; gUnk_03004030 = .; + . = 0x00004030; gDiggingCaveEntranceTransition = .; . = 0x00004040; gPlayerClones = .; . = 0x0000404C; SoundMainRAM_Buffer = .; . = 0x0000404D; gUnk_0300404D = .; @@ -438,63 +438,63 @@ SECTIONS { src/sub_08055E08.o(.text); src/main.o(.text); src/message.o(.text); - src/manager/manager1.o(.text); - src/manager/manager2.o(.text); - src/manager/manager3.o(.text); - src/manager/manager4.o(.text); - src/manager/manager5.o(.text); - src/manager/manager6.o(.text); - src/manager/manager7.o(.text); - src/manager/manager8.o(.text); - src/manager/manager9.o(.text); - src/manager/managerA.o(.text); - src/manager/managerB.o(.text); - src/manager/managerC.o(.text); - src/manager/managerD.o(.text); - src/manager/managerE.o(.text); - src/manager/managerF.o(.text); - src/manager/manager10.o(.text); - src/manager/manager11.o(.text); - src/manager/manager12.o(.text); - src/manager/manager13.o(.text); - src/manager/manager14.o(.text); - src/manager/manager15.o(.text); - src/manager/manager16.o(.text); - src/manager/manager17.o(.text); - src/manager/manager18.o(.text); - src/manager/manager19.o(.text); - src/manager/manager1A.o(.text); - src/manager/manager1B.o(.text); - src/manager/manager1C.o(.text); - src/manager/manager1D.o(.text); - src/manager/manager1E.o(.text); - src/manager/manager1F.o(.text); - src/manager/manager20.o(.text); - src/manager/manager21.o(.text); - src/manager/manager22.o(.text); - src/manager/manager23.o(.text); - src/manager/manager24.o(.text); - src/manager/manager25.o(.text); - src/manager/manager26.o(.text); - src/manager/manager27.o(.text); - src/manager/manager28.o(.text); + src/manager/lightRayManager.o(.text); + src/manager/verticalMinishPathBackgroundManager.o(.text); + src/manager/minishPortalManager.o(.text); + src/manager/diggingCaveEntranceManager.o(.text); + src/manager/bridgeManager.o(.text); + src/manager/specialWarpManager.o(.text); + src/manager/minishVillageTilesetManager.o(.text); + src/manager/horizontalMinishPathBackgroundManager.o(.text); + src/manager/minishRaftersBackgroundManager.o(.text); + src/manager/ezloHintManager.o(.text); + src/manager/fightManager.o(.text); + src/manager/rollingBarrelManager.o(.text); + src/manager/tileChangeObserveManager.o(.text); + src/manager/entitySpawnManager.o(.text); + src/manager/miscManager.o(.text); + src/manager/weatherChangeManager.o(.text); + src/manager/flagAndOperatorManager.o(.text); + src/manager/hyruleTownTilesetManager.o(.text); + src/manager/houseSignManager.o(.text); + src/manager/steamOverlayManager.o(.text); + src/manager/templeOfDropletsManager.o(.text); + src/manager/delayedEntityLoadManager.o(.text); + src/manager/fallingItemManager.o(.text); + src/manager/cloudOverlayManager.o(.text); + src/manager/powBackgroundManager.o(.text); + src/manager/holeManager.o(.text); + src/manager/staticBackgroundManager.o(.text); + src/manager/rainfallManager.o(.text); + src/manager/animatedBackgroundManager.o(.text); + src/manager/regionTriggerManager.o(.text); + src/manager/railIntersectionManager.o(.text); + src/manager/moveableObjectManager.o(.text); + src/manager/minishSizedEntranceManager.o(.text); + src/manager/lightManager.o(.text); + src/manager/lightLevelSetManager.o(.text); + src/manager/bombableWallManager.o(.text); + src/manager/flameManager.o(.text); + src/manager/pushableFurnitureManager.o(.text); + src/manager/armosInteriorManager.o(.text); + src/manager/enemyInteractionManager.o(.text); src/manager/manager29.o(.text); - src/manager/manager2A.o(.text); - src/manager/manager2B.o(.text); - src/manager/manager2C.o(.text); - src/manager/manager2D.o(.text); - src/manager/manager2E.o(.text); - src/manager/manager2F.o(.text); - src/manager/manager30.o(.text); - src/manager/manager31.o(.text); - src/manager/manager32.o(.text); - src/manager/manager33.o(.text); - src/manager/manager34.o(.text); - src/manager/manager35.o(.text); - src/manager/manager36.o(.text); - src/manager/manager37.o(.text); - src/manager/manager38.o(.text); - src/manager/manager39.o(.text); + src/manager/destructibleTileObserveManager.o(.text); + src/manager/angryStatueManager.o(.text); + src/manager/cloudStaircaseTransitionManager.o(.text); + src/manager/waterfallBottomManager.o(.text); + src/manager/secretManager.o(.text); + src/manager/vaati3BackgroundManager.o(.text); + src/manager/tilePuzzleManager.o(.text); + src/manager/goronMerchantShopManager.o(.text); + src/manager/vaatiAppearingManager.o(.text); + src/manager/hyruleTownBellManager.o(.text); + src/manager/vaati3InsideArmManager.o(.text); + src/manager/cameraTargetManager.o(.text); + src/manager/repeatedSoundManager.o(.text); + src/manager/vaati3StartManager.o(.text); + src/manager/floatingPlatformManager.o(.text); + src/manager/enterRoomTextboxManager.o(.text); src/entity.o(.text); src/code_0805EC04.o(.text); /* objaffine? */ src/text.o(.text); @@ -1102,47 +1102,47 @@ SECTIONS { data/map/map_headers.o(.rodata); src/message.o(.rodata); . = ALIGN(4); - src/manager/manager1.o(.rodata); - src/manager/manager3.o(.rodata); - src/manager/manager4.o(.rodata); - src/manager/manager5.o(.rodata); - src/manager/manager7.o(.rodata); + src/manager/lightRayManager.o(.rodata); + src/manager/minishPortalManager.o(.rodata); + src/manager/diggingCaveEntranceManager.o(.rodata); + src/manager/bridgeManager.o(.rodata); + src/manager/minishVillageTilesetManager.o(.rodata); . = ALIGN(4); - src/manager/manager9.o(.rodata); - src/manager/managerA.o(.rodata); - src/manager/managerB.o(.rodata); - src/manager/managerC.o(.rodata); - src/manager/managerD.o(.rodata); - src/manager/managerF.o(.rodata); - src/manager/manager10.o(.rodata); - src/manager/manager12.o(.rodata); - src/manager/manager13.o(.rodata); - src/manager/manager14.o(.rodata); - src/manager/manager15.o(.rodata); - src/manager/manager17.o(.rodata); - src/manager/manager18.o(.rodata); - data/const/manager/manager1A.o(.rodata); - src/manager/manager1B.o(.rodata); - src/manager/manager1C.o(.rodata); - src/manager/manager1D.o(.rodata); - src/manager/manager1E.o(.rodata); - src/manager/manager1F.o(.rodata); - src/manager/manager22.o(.rodata); - src/manager/manager23.o(.rodata); - src/manager/manager24.o(.rodata); - src/manager/manager26.o(.rodata); - src/manager/manager27.o(.rodata); - src/manager/manager28.o(.rodata); - src/manager/manager2B.o(.rodata); - src/manager/manager2E.o(.rodata); - src/manager/manager31.o(.rodata); - src/manager/manager32.o(.rodata); - src/manager/manager34.o(.rodata); - src/manager/manager35.o(.rodata); - src/manager/manager36.o(.rodata); - src/manager/manager37.o(.rodata); - src/manager/manager38.o(.rodata); - data/const/manager/manager39.o(.rodata); + src/manager/minishRaftersBackgroundManager.o(.rodata); + src/manager/ezloHintManager.o(.rodata); + src/manager/fightManager.o(.rodata); + src/manager/rollingBarrelManager.o(.rodata); + src/manager/tileChangeObserveManager.o(.rodata); + src/manager/miscManager.o(.rodata); + src/manager/weatherChangeManager.o(.rodata); + src/manager/hyruleTownTilesetManager.o(.rodata); + src/manager/houseSignManager.o(.rodata); + src/manager/steamOverlayManager.o(.rodata); + src/manager/templeOfDropletsManager.o(.rodata); + src/manager/fallingItemManager.o(.rodata); + src/manager/cloudOverlayManager.o(.rodata); + data/const/manager/holeManager.o(.rodata); + src/manager/staticBackgroundManager.o(.rodata); + src/manager/rainfallManager.o(.rodata); + src/manager/animatedBackgroundManager.o(.rodata); + src/manager/regionTriggerManager.o(.rodata); + src/manager/railIntersectionManager.o(.rodata); + src/manager/lightManager.o(.rodata); + src/manager/lightLevelSetManager.o(.rodata); + src/manager/bombableWallManager.o(.rodata); + src/manager/pushableFurnitureManager.o(.rodata); + src/manager/armosInteriorManager.o(.rodata); + src/manager/enemyInteractionManager.o(.rodata); + src/manager/angryStatueManager.o(.rodata); + src/manager/secretManager.o(.rodata); + src/manager/goronMerchantShopManager.o(.rodata); + src/manager/vaatiAppearingManager.o(.rodata); + src/manager/vaati3InsideArmManager.o(.rodata); + src/manager/cameraTargetManager.o(.rodata); + src/manager/repeatedSoundManager.o(.rodata); + src/manager/vaati3StartManager.o(.rodata); + src/manager/floatingPlatformManager.o(.rodata); + data/const/manager/enterRoomTextboxManager.o(.rodata); data/data_08108E6C.o(.rodata); src/playerItem/playerItemSpiralBeam.o(.rodata); data/animations/npc/gentari.o(.rodata); diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index df9a668e..334a4811 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -12,8 +12,9 @@ #include "object.h" #include "screen.h" #include "structures.h" +#include "manager/diggingCaveEntranceManager.h" +#include "scroll.h" -extern void UpdateIsDiggingCave(void); extern void sub_0807C898(void); extern void sub_0805BB74(s32); extern void LoadRoomGfx(void); @@ -95,10 +96,10 @@ void sub_080197A0(void) { } void SetBGDefaults(void) { - gMapBottom.bgControlPtr = (u16*)&gScreen.bg2; - *gMapBottom.bgControlPtr = gUnk_080B77C0[0]; - gMapTop.bgControlPtr = (u16*)&gScreen.bg1; - *gMapTop.bgControlPtr = gUnk_080B77C0[1]; + gMapBottom.bgSettings = (BgSettings*)&gScreen.bg2; + gMapBottom.bgSettings->control = gUnk_080B77C0[0]; + gMapTop.bgSettings = &gScreen.bg1; + gMapTop.bgSettings->control = gUnk_080B77C0[1]; } void sub_080197D4(u32* param_1) { @@ -417,7 +418,7 @@ void sub_0801AD6C(u16* param_1, u32 param_2) { s32 tmpX2; s32 tmpY2; - if (param_1[1] != 9) { + if (param_1[1] != MANAGER) { entity = GetEmptyEntity(); if (entity != NULL) { entity->kind = (u8)param_1[1]; @@ -435,15 +436,16 @@ void sub_0801AD6C(u16* param_1, u32 param_2) { } else { manager = GetEmptyManager(); if (manager != NULL) { - manager->type = (u8)param_1[1]; - manager->subtype = (u8)param_1[2]; - manager->unk_0a = (u8)param_1[3]; - manager->unk_0b = (u8)param_1[4]; + manager->kind = (u8)param_1[1]; + manager->id = (u8)param_1[2]; + manager->type = (u8)param_1[3]; + manager->type2 = (u8)param_1[4]; + // TODO are these fields common for all managers or does this usually create managers of certain types? tmpX2 = ((u16)param_2 & 0x3f) * 0x10 + 8; - *(u16*)(&manager[1].unk_0e + 10) = tmpX2 + gRoomControls.origin_x; + *(u16*)(&manager[1].timer + 10) = tmpX2 + gRoomControls.origin_x; tmpY2 = (s16)((param_2 & 0xfc0) >> 2) + 8; - *(u16*)(&manager[1].unk_0e + 12) = tmpY2 + gRoomControls.origin_y; - AppendEntityToList((Entity*)manager, gUnk_081091E4[manager->type]); + *(u16*)(&manager[1].timer + 12) = tmpY2 + gRoomControls.origin_y; + AppendEntityToList((Entity*)manager, gUnk_081091E4[manager->kind]); } } } @@ -476,14 +478,14 @@ void sub_0801AE44(s32 param_1) { if (func != NULL) { func(); } - if ((gUnk_03004030.isDiggingCave == 0) && (gArea.onEnter != NULL)) { + if ((gDiggingCaveEntranceTransition.isDiggingCave == 0) && (gArea.onEnter != NULL)) { gArea.onEnter(gArea.transitionManager); } if ((gRoomControls.scroll_flags & 1) == 0) { - if (gMapBottom.bgControlPtr != NULL) { + if (gMapBottom.bgSettings != NULL) { sub_0801AB08(gMapDataBottomSpecial, &gMapBottom); } - if (gMapTop.bgControlPtr != NULL) { + if (gMapTop.bgSettings != NULL) { sub_0801AB08(gMapDataTopSpecial, &gMapTop); } } else { diff --git a/src/common.c b/src/common.c index 954ffa4e..ee50370b 100644 --- a/src/common.c +++ b/src/common.c @@ -59,7 +59,6 @@ typedef struct { u8 filler[0xA00]; } struct_02017AA0; extern struct_02017AA0 gUnk_02017AA0[]; -extern u8 gUnk_03003DE4; extern const PaletteGroup* gPaletteGroups[]; extern const u8 gGlobalGfxAndPalettes[]; @@ -509,9 +508,9 @@ void sub_0801E154(u32 a1) { } void sub_0801E160(u32 a1, u32 a2, u32 a3) { - MemClear(&gUnk_02017AA0[gUnk_03003DE4], sizeof(gUnk_02017AA0[gUnk_03003DE4])); + MemClear(&gUnk_02017AA0[gUnk_03003DE4[0]], sizeof(gUnk_02017AA0[gUnk_03003DE4[0]])); sub_0801E290(a1, a2, a3); - sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4], 0x4000040, 0xA2600001); + sub_0805622C((struct BgAffineDstData*)&gUnk_02017AA0[gUnk_03003DE4[0]], 0x4000040, 0xA2600001); } void sub_0801E1B8(u32 a1, u32 a2) { @@ -523,10 +522,10 @@ void sub_0801E1B8(u32 a1, u32 a2) { } void sub_0801E1EC(u32 a1, u32 a2, u32 a3) { - MemClear(&gUnk_02017AA0[gUnk_03003DE4], sizeof(gUnk_02017AA0[gUnk_03003DE4])); + MemClear(&gUnk_02017AA0[gUnk_03003DE4[0]], sizeof(gUnk_02017AA0[gUnk_03003DE4[0]])); sub_0801E24C(a3, 0); sub_0801E290(a1, a2, a3); - sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4], 0x4000040, 0xA2600001); + sub_0805622C((struct BgAffineDstData*)&gUnk_02017AA0[gUnk_03003DE4[0]], 0x4000040, 0xA2600001); } ASM_FUNC("asm/non_matching/common/sub_0801E24C.inc", void sub_0801E24C(u32 a1, u32 a2)); diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c index 0d4d067d..3bf2b7f4 100644 --- a/src/enemy/vaatiEyesMacro.c +++ b/src/enemy/vaatiEyesMacro.c @@ -102,9 +102,9 @@ void VaatiEyesMacroFunction0Type0Action0(Entity* this) { Entity* enemy; if ((gEntCount < 0x47) && (manager = GetEmptyManager(), manager != NULL)) { - manager->type = 9; - manager->subtype = 0x34; - manager->parent = (Manager*)this; + manager->kind = MANAGER; + manager->id = VAATI3_INSIDE_ARM_MANAGER; + manager->parent = (Entity*)this; AppendEntityToList((Entity*)manager, 8); enemy = CreateEnemy(VAATI_EYES_MACRO, 2); enemy->parent = this; diff --git a/src/entity.c b/src/entity.c index f85ccb3f..5e3d20bd 100644 --- a/src/entity.c +++ b/src/entity.c @@ -4,6 +4,7 @@ #include "area.h" #include "message.h" #include "npc.h" +#include "manager/diggingCaveEntranceManager.h" extern u8 gUnk_081091F8[]; extern u8 gUnk_081091EE[]; @@ -38,27 +39,27 @@ extern UpdateContext gUpdateContext; void sub_0805E248(void) { s32 v0; - v0 = gUnk_03004030.unk_00->unk_06; + v0 = gDiggingCaveEntranceTransition.entrance->targetTilePosition; if (gRoomControls.area == AREA_VEIL_FALLS || gRoomControls.area == AREA_VEIL_FALLS_DIG_CAVE) { - SetTileType(636, v0 - 65, 1); - SetTileType(643, v0 - 65, 2); - SetTileType(637, v0 - 64, 1); - SetTileType(644, v0 - 64, 2); - SetTileType(638, v0 - 63, 1); - SetTileType(645, v0 - 63, 2); - SetTileType(639, v0 - 1, 1); - SetTileType(640, v0, 1); - SetTileType(642, v0 + 1, 1); + SetTileType(0x27c, v0 + TILE_POS(-1, -1), 1); + SetTileType(0x283, v0 + TILE_POS(-1, -1), 2); + SetTileType(0x27d, v0 + TILE_POS(0, -1), 1); + SetTileType(0x284, v0 + TILE_POS(0, -1), 2); + SetTileType(0x27e, v0 + TILE_POS(1, -1), 1); + SetTileType(0x285, v0 + TILE_POS(1, -1), 2); + SetTileType(0x27f, v0 + TILE_POS(-1, 0), 1); + SetTileType(0x280, v0 + TILE_POS(0, 0), 1); + SetTileType(0x282, v0 + TILE_POS(1, 0), 1); } else { - SetTileType(620, v0 - 65, 1); - SetTileType(627, v0 - 65, 2); - SetTileType(621, v0 - 64, 1); - SetTileType(628, v0 - 64, 2); - SetTileType(622, v0 - 63, 1); - SetTileType(629, v0 - 63, 2); - SetTileType(623, v0 - 1, 1); - SetTileType(624, v0, 1); - SetTileType(626, v0 + 1, 1); + SetTileType(0x26c, v0 + TILE_POS(-1, -1), 1); + SetTileType(0x273, v0 + TILE_POS(-1, -1), 2); + SetTileType(0x26d, v0 + TILE_POS(0, -1), 1); + SetTileType(0x274, v0 + TILE_POS(0, -1), 2); + SetTileType(0x26e, v0 + TILE_POS(1, -1), 1); + SetTileType(0x275, v0 + TILE_POS(1, -1), 2); + SetTileType(0x26f, v0 + TILE_POS(-1, 0), 1); + SetTileType(0x270, v0 + TILE_POS(0, 0), 1); + SetTileType(0x272, v0 + TILE_POS(1, 0), 1); } gUpdateVisibleTiles = 0; } diff --git a/src/game.c b/src/game.c index 0582b3d0..607c7f42 100644 --- a/src/game.c +++ b/src/game.c @@ -34,6 +34,7 @@ #include "roomid.h" #include "ui.h" #include "kinstone.h" +#include "manager/diggingCaveEntranceManager.h" // Game task @@ -97,7 +98,7 @@ extern void sub_0806FD8C(void); extern void sub_080300C4(void); extern u32 sub_0805BC04(void); extern void DeleteSleepingEntities(void); -extern u32 UpdateLightLevel(void); +extern bool32 UpdateLightLevel(void); extern void sub_080185F8(void); extern void UpdateDoorTransition(void); extern bool32 CheckInitPortal(void); @@ -132,7 +133,7 @@ static void sub_08052010(void); static void ResetTmpFlags(void); static void InitializeEntities(void); static void CheckAreaDiscovery(void); -static void CreateManagerF(void); +static void CreateMiscManager(void); static void UpdateWindcrests(void); static void UpdateFakeScroll(void); static void UpdatePlayerMapCoords(void); @@ -377,7 +378,7 @@ static void GameMain_ChangeRoom(void) { if (gArea.unk28.inventoryGfxIdx != 0xff) { sub_0801855C(); } - CreateManagerF(); + CreateMiscManager(); CheckAreaDiscovery(); #elif defined(EU) CheckAreaDiscovery(); @@ -393,7 +394,7 @@ static void GameMain_ChangeRoom(void) { if (gArea.unk28.inventoryGfxIdx != 0xff) { sub_0801855C(); } - CreateManagerF(); + CreateMiscManager(); #endif if (!gRoomVars.field_0x0) { RequestPriorityDuration(NULL, 1); @@ -496,7 +497,7 @@ static void InitializeEntities(void) { sub_0804AF90(); CallRoomProp6(); InitializePlayer(); - gUnk_03004030.unk_00 = NULL; + gDiggingCaveEntranceTransition.entrance = NULL; InitializeCamera(); gUpdateVisibleTiles = 1; LoadRoomBgm(); @@ -1317,7 +1318,7 @@ void DisplayEzloMessage(void) { } #if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP) -static void CreateManagerF(void) { +static void CreateMiscManager(void) { Entity* e = NULL; if (gRoomTransition.player_status.field_0x24[13]) @@ -1330,7 +1331,7 @@ static void CreateManagerF(void) { if (e == NULL) return; e->kind = MANAGER; - e->id = 15; + e->id = MISC_MANAGER; e->type = 15; AppendEntityToList(e, 0); } @@ -1585,7 +1586,7 @@ static void CheckAreaDiscovery(void) { Entity* e = (Entity*)GetEmptyManager(); if (e != NULL) { e->kind = MANAGER; - e->id = 0x39; + e->id = ENTER_ROOM_TEXTBOX_MANAGER; AppendEntityToList(e, 8); if (!gRoomVars.field_0x0 && !ReadBit(gSave.areaVisitFlags, gArea.locationIndex)) { e->type2 = 1; @@ -1871,8 +1872,8 @@ void sub_08053758(void) { gMenu.field_0xa = 0x1e; *((u8*)&gMenu + 0x10) = 0; // TODO gUI.field_0x6 = 1; - gMapBottom.bgControlPtr = NULL; - gMapTop.bgControlPtr = NULL; + gMapBottom.bgSettings = NULL; + gMapTop.bgSettings = NULL; gRoomControls.camera_target = NULL; gRoomControls.scroll_y = 0; gRoomControls.scroll_x = 0; diff --git a/src/interrupts.c b/src/interrupts.c index 760ec0df..d98fbf23 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -186,11 +186,11 @@ void WaitForNextFrame(void) { if (gUpdateVisibleTiles) { gUpdateVisibleTiles = 0; - if (gMapBottom.bgControlPtr != NULL) + if (gMapBottom.bgSettings != NULL) // sizeof(BGBuffer) = 0x800, what are we omitting? - DmaCopy32(3, &gBG1Buffer, VRAM + (*gMapBottom.bgControlPtr & 0x1f00) * 8, 0x5C0); - if (gMapTop.bgControlPtr != NULL) - DmaCopy32(3, &gBG2Buffer, VRAM + (*gMapTop.bgControlPtr & 0x1f00) * 8, 0x5C0); + DmaCopy32(3, &gBG1Buffer, VRAM + (gMapBottom.bgSettings->control & 0x1f00) * 8, 0x5C0); + if (gMapTop.bgSettings != NULL) + DmaCopy32(3, &gBG2Buffer, VRAM + (gMapTop.bgSettings->control & 0x1f00) * 8, 0x5C0); } FadeVBlank(); } diff --git a/src/main.c b/src/main.c index 1fa74dcd..cf9de720 100644 --- a/src/main.c +++ b/src/main.c @@ -233,12 +233,12 @@ void sub_08056208(void) { gScreen._6d = 0; } -void sub_0805622C(void* a1, u32 a2, u32 a3) { +void sub_0805622C(struct BgAffineDstData* a1, u32 a2, u32 a3) { gScreen._70 = a1; gScreen._74 = a2; gScreen._78 = a3; gScreen._6c = 1; - gUnk_03003DE4 ^= 1; + gUnk_03003DE4[0] ^= 1; } void sub_08056250(void) { @@ -278,8 +278,10 @@ u32 CheckRegionOnScreen(u32 x0, u32 y0, u32 x1, u32 y1) { return result; } -// Iterate over array of AABBs and check if any fit on screen -u16 CheckRegionsOnScreen(const u16* arr) { +/** + * Iterate over array of AABBs and check if any fit on screen + */ +u32 CheckRegionsOnScreen(const u16* arr) { const u16* i; for (i = arr; *i != 0xff; i += 5) { if (CheckRegionOnScreen(i[1], i[2], i[3], i[4])) diff --git a/src/manager.c b/src/manager.c index dc6b4138..338d2d7d 100644 --- a/src/manager.c +++ b/src/manager.c @@ -1,19 +1,66 @@ #include "manager.h" // TODO: change all manager arguments to be Entity* and cast to specific type later. -void (*const gManagerFunctions[])() = { - NULL, Manager1_Main, Manager2_Main, Manager3_Main, Manager4_Main, Manager5_Main, Manager6_Main, - Manager7_Main, Manager8_Main, Manager9_Main, ManagerA_Main, ManagerB_Main, ManagerC_Main, ManagerD_Main, - ManagerE_Main, sub_08058ECC, Manager10_Main, Manager11_Main, Manager12_Main, Manager13_Main, Manager14_Main, - Manager15_Main, Manager16_Main, Manager17_Main, Manager18_Main, Manager19_Main, Manager1A_Main, Manager1B_Main, - Manager1C_Main, Manager1D_Main, Manager1E_Main, Manager1F_Main, Manager20_Main, Manager21_Main, Manager22_Main, - Manager23_Main, Manager24_Main, Manager25_Main, Manager26_Main, Manager27_Main, Manager28_Main, Manager29_Main, - Manager2A_Main, Manager2B_Main, Manager2C_Main, Manager2D_Main, Manager2E_Main, Manager2F_Main, Manager30_Main, - Manager31_Main, Manager32_Main, Manager33_Main, Manager34_Main, Manager35_Main, Manager36_Main, Manager37_Main, - Manager38_Main, Manager39_Main -}; +void (*const gMiscManagerunctions[])() = { NULL, + LightRayManager_Main, + VerticalMinishPathBackgroundManager_Main, + MinishPortalManager_Main, + DiggingCaveEntranceManager_Main, + BridgeManager_Main, + SpecialWarpManager_Main, + MinishVillageTilesetManager_Main, + HorizontalMinishPathBackgroundManager_Main, + MinishRaftersBackgroundManager_Main, + EzloHintManager_Main, + FightManager_Main, + RollingBarrelManager_Main, + TileChangeObserveManager_Main, + EntitySpawnManager_Main, + MiscManager_Main, + WeatherChangeManager_Main, + FlagAndOperatorManager_Main, + HyruleTownTilesetManager_Main, + HouseSignManager_Main, + SteamOverlayManager_Main, + TempleOfDropletsManager_Main, + DelayedEntityLoadManager_Main, + FallingItemManager_Main, + CloudOverlayManager_Main, + PowBackgroundManager_Main, + HoleManager_Main, + StaticBackgroundManager_Main, + RainfallManager_Main, + AnimatedBackgroundManager_Main, + RegionTriggerManager_Main, + RailIntersectionManager_Main, + MoveableObjectManager_Main, + MinishSizedEntranceManager_Main, + LightManager_Main, + LightLevelSetManager_Main, + BombableWallManager_Main, + FlameManager_Main, + PushableFurnitureManager_Main, + ArmosInteriorManager_Main, + EnemyInteractionManager_Main, + Manager29_Main, + DestructibleTileObserveManager_Main, + AngryStatueManager_Main, + CloudStaircaseTransitionManager_Main, + WaterfallBottomManager_Main, + SecretManager_Main, + Vaati3BackgroundManager_Main, + TilePuzzleManager_Main, + GoronMerchantShopManager_Main, + VaatiAppearingManager_Main, + HyruleTownBellManager_Main, + Vaati3InsideArmManager_Main, + CameraTargetManager_Main, + RepeatedSoundManager_Main, + Vaati3StartManager_Main, + FloatingPlatformManager_Main, + EnterRoomTextboxManager_Main }; void ManagerUpdate(Entity* this) { if (!EntityIsDeleted(this)) - gManagerFunctions[this->id](this); + gMiscManagerunctions[this->id](this); } diff --git a/src/manager/manager2B.c b/src/manager/angryStatueManager.c similarity index 51% rename from src/manager/manager2B.c rename to src/manager/angryStatueManager.c index db812f9b..3cbb2b74 100644 --- a/src/manager/manager2B.c +++ b/src/manager/angryStatueManager.c @@ -1,44 +1,30 @@ -#include "manager.h" +/** + * @file angryStatueManager.c + * @ingroup Managers + * + * @brief Manages the synchronized shooting and destruction of the AngryStatues. + */ +#include "manager/angryStatueManager.h" #include "flags.h" -#include "room.h" #include "functions.h" #include "object.h" +#include "room.h" -typedef struct { - Manager manager; - Entity* field_0x20[4]; - u8 field_0x30; - u8 field_0x31; - u8 field_0x32; - u8 field_0x33; - u8 field_0x34; - u8 field_0x35; - u8 field_0x36; - u8 field_0x37; - u8 field_0x38; - u8 field_0x39; - u8 field_0x3a; - u8 field_0x3b; - u8 field_0x3c; - u8 field_0x3d; - u16 field_0x3e; -} Manager2B; +void sub_0805D11C(AngryStatueManager*); +void AngryStatueManager_Init(AngryStatueManager*); +void AngryStatueManager_Action1(AngryStatueManager*); +void AngryStatueManager_Action2(AngryStatueManager*); -void sub_0805D11C(Manager2B*); -void sub_0805D02C(Manager2B*); -void sub_0805D0C4(Manager2B*); -void sub_0805D0FC(Manager2B*); - -void Manager2B_Main(Manager2B* this) { - static void (*const gUnk_08108D30[])(Manager2B*) = { - sub_0805D02C, - sub_0805D0C4, - sub_0805D0FC, +void AngryStatueManager_Main(AngryStatueManager* this) { + static void (*const AngryStatueManager_Actions[])(AngryStatueManager*) = { + AngryStatueManager_Init, + AngryStatueManager_Action1, + AngryStatueManager_Action2, }; - gUnk_08108D30[this->manager.action](this); + AngryStatueManager_Actions[super->action](this); } -void sub_0805D02C(Manager2B* this) { +void AngryStatueManager_Init(AngryStatueManager* this) { u32 counter; u16* objectData; Entity* object; @@ -46,7 +32,7 @@ void sub_0805D02C(Manager2B* this) { DeleteThisEntity(); } if (gEntCount < 0x44) { - objectData = GetCurrentRoomProperty(this->manager.unk_0a); + objectData = GetCurrentRoomProperty(super->type); counter = 0; while (counter < 4) { object = CreateObject(ANGRY_STATUE, objectData[2], counter); @@ -58,33 +44,33 @@ void sub_0805D02C(Manager2B* this) { counter += 1; objectData += 3; } - this->manager.action = 1; - this->manager.unk_0f = 0x3c; + super->action = 1; + super->subtimer = 0x3c; this->field_0x36 = 0; } } -void sub_0805D0C4(Manager2B* this) { - if (--this->manager.unk_0f == 0) { - this->manager.unk_0f = 0xb4; +void AngryStatueManager_Action1(AngryStatueManager* this) { + if (--super->subtimer == 0) { + super->subtimer = 0xb4; } if (this->field_0x36 == 0xf) { - this->manager.action = 2; - this->manager.unk_0e = 8; + super->action = 2; + super->timer = 8; SoundReq(SFX_SECRET); sub_0805D11C(this); } this->field_0x36 = 0; } -void sub_0805D0FC(Manager2B* this) { - if (--this->manager.unk_0e == 0) { +void AngryStatueManager_Action2(AngryStatueManager* this) { + if (--super->timer == 0) { SetFlag(this->field_0x3e); - DeleteManager(&this->manager); + DeleteManager(super); } } -void sub_0805D11C(Manager2B* this) { +void sub_0805D11C(AngryStatueManager* this) { Entity** entity_iterator; u32 counter; for (counter = 0; counter < 4; counter++) { diff --git a/src/manager/animatedBackgroundManager.c b/src/manager/animatedBackgroundManager.c new file mode 100644 index 00000000..816ae053 --- /dev/null +++ b/src/manager/animatedBackgroundManager.c @@ -0,0 +1,50 @@ +/** + * @file animatedBackgroundManager.c + * @ingroup Managers + * + * @brief Set up bg3 for cloud tops, vaati2 and some beanstalks. + */ +#include "manager/animatedBackgroundManager.h" +#include "room.h" +#include "screen.h" + +void AnimatedBackgroundManager_Init(AnimatedBackgroundManager*); +void AnimatedBackgroundManager_Action1(AnimatedBackgroundManager*); + +void AnimatedBackgroundManager_Main(AnimatedBackgroundManager* this) { + static void (*const AnimatedBackgroundManager_Actions[])(AnimatedBackgroundManager*) = { + AnimatedBackgroundManager_Init, + AnimatedBackgroundManager_Action1, + }; + AnimatedBackgroundManager_Actions[super->action](this); +} + +void AnimatedBackgroundManager_Init(AnimatedBackgroundManager* this) { + static const u16 gUnk_08108C88[] = { 0x1e07, 0x1e07 }; + super->action = 1; + + gScreen.lcd.displayControl |= DISPCNT_BG3_ON; + gScreen.bg3.control = gUnk_08108C88[super->type]; + gRoomControls.bg3OffsetY.WORD = 0; + gRoomControls.bg3OffsetX.WORD = 0; + + switch (super->type) { + case 0: + default: + gScreen.bg3.yOffset = 0; + gScreen.bg3.xOffset = 0; + break; + case 1: + gScreen.bg3.xOffset = gRoomControls.scroll_x + gRoomControls.bg3OffsetX.HALF.HI; + gScreen.bg3.yOffset = gRoomControls.scroll_y + gRoomControls.bg3OffsetY.HALF.HI; + break; + } +} + +void AnimatedBackgroundManager_Action1(AnimatedBackgroundManager* this) { + if (super->type == 1) { + gRoomControls.bg3OffsetX.WORD = gRoomControls.bg3OffsetX.WORD + 0x2000; + gScreen.bg3.xOffset = gRoomControls.scroll_x + gRoomControls.bg3OffsetX.HALF.HI; + gScreen.bg3.yOffset = gRoomControls.scroll_y + gRoomControls.bg3OffsetY.HALF.HI; + } +} diff --git a/src/manager/armosInteriorManager.c b/src/manager/armosInteriorManager.c new file mode 100644 index 00000000..e10fa958 --- /dev/null +++ b/src/manager/armosInteriorManager.c @@ -0,0 +1,85 @@ +/** + * @file armosInteriorManager.c + * @ingroup Managers + * + * @brief Armos Interior Manager. + */ +#include "manager/armosInteriorManager.h" +#include "common.h" +#include "entity.h" +#include "flags.h" +#include "functions.h" +#include "sound.h" + +bool32 sub_0805C920(ArmosInteriorManager*); +void ArmosInteriorManager_Init(ArmosInteriorManager*); +void ArmosInteriorManager_Action1(ArmosInteriorManager*); +void ArmosInteriorManager_Action2(ArmosInteriorManager*); +void ArmosInteriorManager_Action3(ArmosInteriorManager*); + +void ArmosInteriorManager_Main(ArmosInteriorManager* this) { + static void (*const ArmosInteriorManager_Actions[])(ArmosInteriorManager*) = { + ArmosInteriorManager_Init, + ArmosInteriorManager_Action1, + ArmosInteriorManager_Action2, + ArmosInteriorManager_Action3, + }; + ArmosInteriorManager_Actions[super->action](this); + if (CheckLocalFlagByBank(FLAG_BANK_3, super->type + 0x67)) { + gRoomTransition.armos_data.field_0xac |= (1 << super->type); + } else { + gRoomTransition.armos_data.field_0xac &= ~(1 << super->type); + } +} + +void ArmosInteriorManager_Init(ArmosInteriorManager* this) { + if (sub_0805C920(this)) { + super->action = 2; + } else { + super->action = 1; + } + + super->timer = 1; + super->subtimer = 0; +} + +void ArmosInteriorManager_Action1(ArmosInteriorManager* this) { + if (sub_0805C920(this)) { + super->action = 2; + super->timer = 1; + SoundReq(SFX_EM_ARMOS_ON); + } +} + +void ArmosInteriorManager_Action2(ArmosInteriorManager* this) { + static const u8 gUnk_08108D20[] = { 0x6F, 0x70, 0x71, 0x72, 0x71, 0x70 }; + u8 bVar1; + int iVar2; + + if (--super->timer == 0) { + super->timer = 0x14; + + if (++super->subtimer > 5) { + super->subtimer = 0; + } + LoadPaletteGroup(gUnk_08108D20[super->subtimer]); + if (super->subtimer == 0) { + SoundReq(SFX_EM_ARMOS_ON); + } + } + if (sub_0805C920(this) == 0) { + super->action = 3; + } +} + +void ArmosInteriorManager_Action3(ArmosInteriorManager* this) { + if (super->subtimer == 0) { + super->action = 1; + } else { + ArmosInteriorManager_Action2(this); + } +} + +bool32 sub_0805C920(ArmosInteriorManager* this) { + return CheckLocalFlagByBank(FLAG_BANK_3, super->type + 0x67); +} diff --git a/src/manager/manager24.c b/src/manager/bombableWallManager.c similarity index 86% rename from src/manager/manager24.c rename to src/manager/bombableWallManager.c index c8e7fdc9..2259411d 100644 --- a/src/manager/manager24.c +++ b/src/manager/bombableWallManager.c @@ -1,55 +1,62 @@ +/** + * @file bombableWallManager.c + * @ingroup Managers + * + * @brief Manages bombable walls. + */ +#include "manager/bombableWallManager.h" #include "entity.h" -#include "functions.h" #include "flags.h" -#include "sound.h" +#include "functions.h" #include "game.h" #include "object.h" +#include "sound.h" u32 sub_0805BFC4(u32, u32); -void sub_0805C02C(Manager24*); +void sub_0805C02C(BombableWallManager*); extern u32 sub_080B1AE0(u16, u8); u32 getArchwayType(void); -void sub_0805BF30(Manager24*); -void sub_0805BF78(Manager24*); -void sub_0805BFA4(Manager24*); +void BombableWallManager_Init(BombableWallManager*); +void BombableWallManager_Action1(BombableWallManager*); +void BombableWallManager_Action2(BombableWallManager*); void sub_0805C050(u32, u32); void sub_0805C178(u32, u32); void sub_0805C294(u32, u32); void sub_0805C3B4(u32, u32); void sub_0805C4E0(u32, u32); -void Manager24_Main(Manager24* manager) { - static void (*const actionFuncs[])(Manager24*) = { - sub_0805BF30, - sub_0805BF78, - sub_0805BFA4, +void BombableWallManager_Main(BombableWallManager* this) { + static void (*const BombableWallManager_Actions[])(BombableWallManager*) = { + BombableWallManager_Init, + BombableWallManager_Action1, + BombableWallManager_Action2, }; - actionFuncs[manager->manager.action](manager); + BombableWallManager_Actions[super->action](this); } -void sub_0805BF30(Manager24* manager) { - manager->manager.action = 1; - manager->tile = (manager->x >> 4 & 0x3fU) | (((manager->y << 0x10) >> 0x14 & 0x3fU) << 6); - manager->manager.unk_0a = sub_0805BFC4(manager->tile, manager->field_0x35); - if (CheckLocalFlag(manager->field_0x3e) != 0) { - sub_0805C02C(manager); - DeleteManager((Manager*)manager); +void BombableWallManager_Init(BombableWallManager* this) { + super->action = 1; + this->tile = (this->x >> 4 & 0x3fU) | (((this->y << 0x10) >> 0x14 & 0x3fU) << 6); + super->type = sub_0805BFC4(this->tile, this->field_0x35); + if (CheckLocalFlag(this->field_0x3e) != 0) { + sub_0805C02C(this); + DeleteManager(super); } } -void sub_0805BF78(Manager24* this) { +void BombableWallManager_Action1(BombableWallManager* this) { if (sub_080B1AE0(this->tile, this->field_0x35) != 0x2e) { - this->manager.action = 2; - this->manager.unk_0e = 0x5a; + super->action = 2; + super->timer = 0x5a; sub_0805C02C(this); SetLocalFlag(this->field_0x3e); } } -void sub_0805BFA4(Manager24* this) { - if (--this->manager.unk_0e == 0) { +void BombableWallManager_Action2(BombableWallManager* this) { + if (--super->timer == 0) { SoundReq(SFX_SECRET); DeleteManager((Manager*)this); } @@ -83,12 +90,12 @@ u32 sub_0805BFC4(u32 pos, u32 layer) { return 0xff; } -void sub_0805C02C(Manager24* this) { +void sub_0805C02C(BombableWallManager* this) { static void (*const gUnk_08108CE8[])(u32, u32) = { sub_0805C050, sub_0805C178, sub_0805C294, sub_0805C3B4, sub_0805C4E0, }; - if (this->manager.unk_0a != 0xff) { - gUnk_08108CE8[this->manager.unk_0a](this->tile, this->field_0x35); + if (super->type != 0xff) { + gUnk_08108CE8[super->type](this->tile, this->field_0x35); } } diff --git a/src/manager/bridgeManager.c b/src/manager/bridgeManager.c new file mode 100644 index 00000000..cb37521e --- /dev/null +++ b/src/manager/bridgeManager.c @@ -0,0 +1,102 @@ +/** + * @file bridgeManager.c + * @ingroup Managers + * + * @brief Manages spawn/removal of bridges + */ +#include "manager/bridgeManager.h" +#include "flags.h" +#include "functions.h" +#include "sound.h" + +void BridgeManager_Init(BridgeManager*); +void BridgeManager_Action1(BridgeManager*); +void BridgeManager_Action2(BridgeManager*); + +static const u16 gUnk_08108024[] = { 0, -1, 1, 0, 0, 1, -1, 0 }; +static const u16 gUnk_08108034[] = { 0, 1, -1, 0, 0, -1, 1, 0 }; + +void BridgeManager_Main(BridgeManager* this) { + static void (*const BridgeManager_Actions[])(BridgeManager*) = { + BridgeManager_Init, + BridgeManager_Action1, + BridgeManager_Action2, + }; + BridgeManager_Actions[super->action](this); +} + +void sub_08057CA4(BridgeManager*, u32, u32); + +void BridgeManager_Init(BridgeManager* this) { + u32 tmp; + tmp = (super->type2 & 0x3) << 1; + if (super->timer == 1) { + this->unk_30 = 0x323; + } else { + this->unk_30 = tmp & 2 ? 0x37 : 0x36; + } + this->unk_28 = gUnk_08108024[tmp]; + this->unk_2a = gUnk_08108024[tmp + 1]; + this->unk_2c = gUnk_08108034[tmp]; + this->unk_2e = gUnk_08108034[tmp + 1]; + this->unk_32 = ((super->type2 >> 2) & 0xF) + 1; + super->timer = 0x1C; + super->subtimer = 0; + super->action = (super->type2 & 0x80) ? 2 : 1; + if (super->action != 2 || !CheckFlags(this->flags)) + return; + for (; this->unk_32; this->unk_32--) { + sub_08057CA4(this, this->unk_28, this->unk_2a); + sub_0807B7D8(this->unk_30, this->x | (this->y << 6), this->unk_3c); + } + DeleteManager(super); +} + +void BridgeManager_Action1(BridgeManager* this) { + if (--super->timer) + return; + super->timer = 8; + if (CheckFlags(this->flags)) { + if (this->unk_32 == super->subtimer) + return; + sub_08057CA4(this, this->unk_28, this->unk_2a); + sub_0807B7D8(this->unk_30, this->x | (this->y << 6), this->unk_3c); + super->subtimer++; + SoundReq(SFX_HEART_GET); + } else { + if (!super->subtimer) + return; + RestorePrevTileEntity(this->x | (this->y << 6), this->unk_3c); + sub_08057CA4(this, this->unk_2c, this->unk_2e); + super->subtimer--; + SoundReq(SFX_HEART_GET); + } +} + +void BridgeManager_Action2(BridgeManager* this) { + if (super->subAction == 0) { + if (!CheckFlags(this->flags)) + return; + super->subAction++; + } else { + if (--super->timer) + return; + super->timer = 8; + if (this->unk_32 != super->subtimer) { + sub_08057CA4(this, this->unk_28, this->unk_2a); + sub_0807B7D8(this->unk_30, this->x | (this->y << 6), this->unk_3c); + super->subtimer++; + SoundReq(SFX_HEART_GET); + } else { + if (this->unk_30 != 0x323) { + SoundReq(SFX_SECRET); + } + DeleteManager(super); + } + } +} + +void sub_08057CA4(BridgeManager* this, u32 xOffset, u32 yOffset) { + this->x += xOffset; + this->y += yOffset; +} diff --git a/src/manager/cameraTargetManager.c b/src/manager/cameraTargetManager.c new file mode 100644 index 00000000..909068ba --- /dev/null +++ b/src/manager/cameraTargetManager.c @@ -0,0 +1,85 @@ +/** + * @file cameraTargetManager.c + * @ingroup Managers + * + * @brief Creates a camera target object when a flag is set. + */ +#include "manager/cameraTargetManager.h" +#include "flags.h" +#include "object.h" +#include "room.h" + +void CameraTargetManager_Init(CameraTargetManager*); +void CameraTargetManager_Action1(CameraTargetManager*); +void CameraTargetManager_Action2(CameraTargetManager*); +void CameraTargetManager_Action3(CameraTargetManager*); + +void CameraTargetManager_Main(CameraTargetManager* this) { + static void (*const CameraTargetManager_Actions[])(CameraTargetManager*) = { + CameraTargetManager_Init, + CameraTargetManager_Action1, + CameraTargetManager_Action2, + CameraTargetManager_Action3, + }; + CameraTargetManager_Actions[super->action](this); +} + +void CameraTargetManager_Init(CameraTargetManager* this) { + if (CheckFlags(this->field_0x3c) != 0) { + DeleteThisEntity(); + } + if (CheckFlags(this->field_0x3e) != 0) { + SetFlag(this->field_0x3c); + DeleteThisEntity(); + } + super->action = 1; +} + +void CameraTargetManager_Action1(CameraTargetManager* this) { + Entity* object; + + if (CheckFlags(this->field_0x3e) != 0) { + super->action = 2; + super->timer = this->field_0x35; + if (super->timer == 0) { + super->timer = 0x1e; + } + super->parent = gRoomControls.camera_target; + object = CreateObject(OBJECT_69, 0, 0); + if (object != NULL) { + object->x.HALF.HI = this->field_0x38 + gRoomControls.origin_x; + object->y.HALF.HI = this->field_0x3a + gRoomControls.origin_y; + super->child = object; + gRoomControls.camera_target = object; + RequestPriorityDuration(object, 0x1e); + } + } +} + +void CameraTargetManager_Action2(CameraTargetManager* this) { + RequestPriorityDuration(0, 8); + if ((gRoomControls.scroll_flags & 4) == 0 && --super->timer == 0) { + super->action = 3; + SetFlag(this->field_0x3c); + if (this->field_0x36 == 0) { + this->field_0x36 = 1; + } + } +} + +void CameraTargetManager_Action3(CameraTargetManager* this) { + RequestPriorityDuration(0, 8); + if (this->field_0x36 != 0) { + if (--this->field_0x36 == 0) { + gRoomControls.camera_target = super->parent; + } + } else { + if ((gRoomControls.scroll_flags & 4) == 0) { + Entity* entity = super->child; + if (entity != NULL) { + DeleteEntity(entity); + } + DeleteThisEntity(); + } + } +} diff --git a/src/manager/manager18.c b/src/manager/cloudOverlayManager.c similarity index 65% rename from src/manager/manager18.c rename to src/manager/cloudOverlayManager.c index 16ea8a8f..3cc20ca9 100644 --- a/src/manager/manager18.c +++ b/src/manager/cloudOverlayManager.c @@ -1,17 +1,18 @@ -#include "manager.h" -#include "screen.h" +/** + * @file cloudOverlayManager.c + * @ingroup Managers + * + * @brief Cloud bg overlay for Hyrule Fields. + */ +#include "manager/cloudOverlayManager.h" #include "area.h" #include "functions.h" +#include "screen.h" -typedef struct { - Manager manager; - u16 field_0x20; -} Manager18; +void sub_0805AEDC(CloudOverlayManager*); +void sub_0805AF3C(CloudOverlayManager*); -void sub_0805AEDC(Manager18*); -void sub_0805AF3C(Manager18*); - -void Manager18_Main(Manager18* this) { +void CloudOverlayManager_Main(CloudOverlayManager* this) { static const u16 gUnk_0810865C[] = { 0xf01, 0xe02, 0xe03, 0xe04, 0, 0, }; @@ -20,11 +21,11 @@ void Manager18_Main(Manager18* this) { sub_0805AEDC(NULL); } } else { - if (this->manager.action == 0) { - this->manager.action = 1; - this->manager.unk_10 |= 0x20; - this->manager.unk_0e = 0; - this->manager.unk_0f = 8; + if (super->action == 0) { + super->action = 1; + super->flags |= ENT_PERSIST; + super->timer = 0; + super->subtimer = 8; this->field_0x20 = gUnk_0810865C[0]; SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { @@ -33,10 +34,10 @@ void Manager18_Main(Manager18* this) { DeleteThisEntity(); } } else { - if ((gUnk_0810865C[this->manager.unk_0e] != 0) && (--this->manager.unk_0f == 0)) { - this->manager.unk_0f = 4; - if (gUnk_0810865C[++this->manager.unk_0e] != 0) { - this->field_0x20 = gUnk_0810865C[this->manager.unk_0e]; + if ((gUnk_0810865C[super->timer] != 0) && (--super->subtimer == 0)) { + super->subtimer = 4; + if (gUnk_0810865C[++super->timer] != 0) { + this->field_0x20 = gUnk_0810865C[super->timer]; gScreen.controls.alphaBlend = this->field_0x20; } } @@ -48,7 +49,7 @@ void Manager18_Main(Manager18* this) { } } -void sub_0805AEDC(Manager18* this) { +void sub_0805AEDC(CloudOverlayManager* this) { gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1); gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.controls.layerFXControl = @@ -57,12 +58,12 @@ void sub_0805AEDC(Manager18* this) { gScreen.bg3.xOffset = gRoomControls.scroll_x + gRoomControls.bg3OffsetX.HALF.HI; gScreen.bg3.yOffset = gRoomControls.scroll_y + gRoomControls.bg3OffsetY.HALF.HI; if (this != NULL) { - Manager18_Main(this); + CloudOverlayManager_Main(this); } } -void sub_0805AF3C(Manager18* this) { - this->manager.unk_10 &= 0xdf; +void sub_0805AF3C(CloudOverlayManager* this) { + super->flags &= ~ENT_PERSIST; gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; gScreen.controls.layerFXControl = 0; } diff --git a/src/manager/cloudStaircaseTransitionManager.c b/src/manager/cloudStaircaseTransitionManager.c new file mode 100644 index 00000000..73dc764d --- /dev/null +++ b/src/manager/cloudStaircaseTransitionManager.c @@ -0,0 +1,31 @@ +/** + * @file cloudStaircaseTransitionManager.c + * @ingroup Managers + * + * @brief Manages the transition on top of a cloud staircase. + */ +#include "manager/cloudStaircaseTransitionManager.h" +#include "asm.h" +#include "common.h" +#include "functions.h" + +void CloudStaircaseTransitionManager_Main(CloudStaircaseTransitionManager* this) { + if (super->action == 0) { + super->action = 1; + this->y = 0; + } + if (((CheckPlayerInRegion(this->x, this->y, 0x14, 0x40) != 0) && + (((gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) + gPlayerEntity.z.HALF.HI) < 0)) && + (gRoomControls.scroll_y == gRoomControls.origin_y)) { + MemClear(&gRoomTransition.player_status, sizeof(PlayerRoomStatus)); + gRoomTransition.transitioningOut = 1; + gRoomTransition.type = TRANSITION_DEFAULT; + gRoomTransition.player_status.spawn_type = PL_SPAWN_PARACHUTE_UP; + gRoomTransition.player_status.area_next = super->type2; + gRoomTransition.player_status.room_next = super->timer; + gRoomTransition.player_status.start_anim = this->field_0x37; + gRoomTransition.player_status.start_pos_x = this->field_0x3c; + gRoomTransition.player_status.start_pos_y = this->field_0x3e; + gRoomTransition.player_status.layer = this->field_0x36; + } +} diff --git a/src/manager/delayedEntityLoadManager.c b/src/manager/delayedEntityLoadManager.c new file mode 100644 index 00000000..00a0bbde --- /dev/null +++ b/src/manager/delayedEntityLoadManager.c @@ -0,0 +1,12 @@ +/** + * @file delayedEntityLoadManager.c + * @ingroup Managers + * + * @brief Delayed entity loader. + */ +#include "manager/delayedEntityLoadManager.h" + +ASM_FUNC("asm/non_matching/delayedEntityLoadManager/DelayedEntityLoadManager_Main.inc", + void DelayedEntityLoadManager_Main()) + +ASM_FUNC("asm/non_matching/delayedEntityLoadManager/sub_0805ACC0.inc", u32 sub_0805ACC0(Entity* ent)) diff --git a/src/manager/destructibleTileObserveManager.c b/src/manager/destructibleTileObserveManager.c new file mode 100644 index 00000000..81a8ef05 --- /dev/null +++ b/src/manager/destructibleTileObserveManager.c @@ -0,0 +1,37 @@ +/** + * @file destructibleTileObserveManager.c + * @ingroup Managers + * + * @brief Sets a flag when a tile changes, e.g. to remember that grass has been cut. + */ +#include "manager/destructibleTileObserveManager.h" +#include "asm.h" +#include "flags.h" +#include "room.h" + +void sub_0805CFF0(DestructibleTileObserveManager_unk*); + +void DestructibleTileObserveManager_Main(DestructibleTileObserveManager* this) { + DestructibleTileObserveManager_unk* data; + + if (super->action == 0) { + super->action++; + } + data = (DestructibleTileObserveManager_unk*)GetCurrentRoomProperty(3); + if (data != NULL) { + for (; data->field_0x0 != 0; data = data + 1) { + if (data->field_0x0 == 10) { + sub_0805CFF0(data); + } + } + } +} + +void sub_0805CFF0(DestructibleTileObserveManager_unk* param_1) { + if (!CheckLocalFlag(param_1->flag)) { + u32 tileType = GetTileType(param_1->tilePos, param_1->tileLayer); + if (param_1->tileType == tileType) { + SetLocalFlag(param_1->flag); + } + } +} diff --git a/src/manager/diggingCaveEntranceManager.c b/src/manager/diggingCaveEntranceManager.c new file mode 100644 index 00000000..d020dd5f --- /dev/null +++ b/src/manager/diggingCaveEntranceManager.c @@ -0,0 +1,381 @@ +/** + * @file diggingCaveEntranceManager.c + * @ingroup Managers + * + * @brief Manages digging cave entrances + */ +#include "manager/diggingCaveEntranceManager.h" +#include "area.h" +#include "asm.h" +#include "functions.h" +#include "player.h" +#include "room.h" +#include "scroll.h" + +void DiggingCaveEntranceManager_Main(DiggingCaveEntranceManager*); +void DiggingCaveEntranceManager_Init(DiggingCaveEntranceManager*); +void DiggingCaveEntranceManager_Action1(DiggingCaveEntranceManager*); +bool32 DiggingCaveEntranceManager_CheckEnterEntrance(DiggingCaveEntranceManager*, const DiggingCaveEntrance*); +void DiggingCaveEntranceManager_EnterEntrance(DiggingCaveEntranceManager*, const DiggingCaveEntrance*); +const DiggingCaveEntrance* GetDiggingCaveEntranceForRoom(const DiggingCaveEntrance*, int); + +void DiggingCaveEntranceManager_Main(DiggingCaveEntranceManager* this) { + static void (*const DiggingCaveEntranceManager_Actions[])(DiggingCaveEntranceManager*) = { + DiggingCaveEntranceManager_Init, + DiggingCaveEntranceManager_Action1, + }; + DiggingCaveEntranceManager_Actions[super->action](this); +} + +void DiggingCaveEntranceManager_Init(DiggingCaveEntranceManager* this) { + const DiggingCaveEntrance* entrance; + u8 room; + u8 area; + u16 tile = 0x81 << 7; + UpdateIsDiggingCave(); + if (gDiggingCaveEntranceTransition.isDiggingCave) { + if (gDiggingCaveEntranceTransition.entrance == NULL) { + gDiggingCaveEntranceTransition.previousArea = 0xff; + room = gRoomControls.room; + entrance = diggingCaveEntrances[gRoomControls.area]; + entrance = GetDiggingCaveEntranceForRoom(entrance, room); + if (entrance != 0) { + room = entrance->targetRoom; + entrance = diggingCaveEntrances[entrance->targetArea]; + entrance = GetDiggingCaveEntranceForRoom(entrance, room); + if (entrance != 0) { + gDiggingCaveEntranceTransition.entrance = entrance; + } + } + } + room = gRoomControls.room; + entrance = diggingCaveEntrances[gRoomControls.area]; + tile = 0x81 << 7; // 0x4080 + for (entrance = GetDiggingCaveEntranceForRoom(entrance, room); entrance != 0; + entrance = GetDiggingCaveEntranceForRoom(entrance, room)) { + SetTile(tile, entrance->sourceTilePosition + TILE_POS(-1, 1), 1); + SetTile(tile, entrance->sourceTilePosition + TILE_POS(0, 1), 1); + SetTile(tile, entrance->sourceTilePosition + TILE_POS(1, 1), 1); + entrance++; + } + } + super->action = 1; +} + +void DiggingCaveEntranceManager_Action1(DiggingCaveEntranceManager* this) { + const DiggingCaveEntrance* entrance; + u8 room = gRoomControls.room; + for (entrance = diggingCaveEntrances[gRoomControls.area]; + (entrance = GetDiggingCaveEntranceForRoom(entrance, room)) != NULL && + !DiggingCaveEntranceManager_CheckEnterEntrance(this, entrance); + entrance++) + ; +} + +bool32 DiggingCaveEntranceManager_CheckEnterEntrance(DiggingCaveEntranceManager* this, + const DiggingCaveEntrance* entr) { + u16 offsetX, offsetY, offsetX2, offsetY2; + u32 tmp, tmp2; + if (gDiggingCaveEntranceTransition.isDiggingCave) { + offsetX = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x; + offsetY = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; + offsetX2 = (entr->sourceTilePosition & TILE_POS_X_COMPONENT) * 16 + 8; + offsetY2 = ((entr->sourceTilePosition & TILE_POS_Y_COMPONENT) >> 6) * 16 + 0x18; + tmp = offsetX - offsetX2; + if (tmp + 0x18 > 0x30 || offsetY - offsetY2 + 8 > 0x10U) + return FALSE; + if (offsetY < offsetY2 && tmp + 0xC <= 0x18) + return FALSE; + DiggingCaveEntranceManager_EnterEntrance(this, entr); + return TRUE; + } else { + if (COORD_TO_TILE(&gPlayerEntity) != entr->sourceTilePosition) + return FALSE; + offsetY2 = gRoomControls.origin_y + ((entr->sourceTilePosition >> 6) << 4) + 6; + if (gPlayerEntity.y.HALF.HI >= offsetY2) + return FALSE; + DiggingCaveEntranceManager_EnterEntrance(this, entr); + return TRUE; + } +} + +void DiggingCaveEntranceManager_EnterEntrance(DiggingCaveEntranceManager* this, const DiggingCaveEntrance* entr) { + u16 isDiggingCave; + SetInitializationPriority(); + gDiggingCaveEntranceTransition.previousArea = gDiggingCaveEntranceTransition.currentArea; + gDiggingCaveEntranceTransition.currentArea = gRoomControls.area; + gRoomTransition.player_status.area_next = entr->targetArea; + gRoomTransition.player_status.room_next = entr->targetRoom; + gRoomControls.area = entr->targetArea; + gRoomControls.room = entr->targetRoom; + gDiggingCaveEntranceTransition.entrance = entr; + gDiggingCaveEntranceTransition.offsetX = + gPlayerEntity.x.HALF.HI - gRoomControls.origin_x - ((entr->sourceTilePosition & TILE_POS_X_COMPONENT) * 16); + gDiggingCaveEntranceTransition.offsetY = + gPlayerEntity.y.HALF.HI - gRoomControls.origin_y - ((entr->sourceTilePosition & TILE_POS_Y_COMPONENT) >> 2); + +#ifndef EU + isDiggingCave = gDiggingCaveEntranceTransition.isDiggingCave; + if (!isDiggingCave) { + if ((entr->targetRoom | 0x80) != gDiggingCaveEntranceTransition.targetRoom) { + gUnk_02034480.unk_00 = gDiggingCaveEntranceTransition.isDiggingCave; + } + gDiggingCaveEntranceTransition.targetRoom = entr->targetRoom | 0x80; + } +#endif + + sub_08080930(entr->type); + DeleteManager(this); +} + +const DiggingCaveEntrance* GetDiggingCaveEntranceForRoom(const DiggingCaveEntrance* entr, int room) { + for (; entr->sourceTilePosition != 0xffff; entr++) { + if (entr->sourceRoom == room) + return entr; + } + return 0; +} + +#define END_OF_LIST \ + { 0xffff, 0, 0, 0, 0 } + +static const DiggingCaveEntrance diggingCaveEntrancesEmpty[] = { END_OF_LIST }; +static const DiggingCaveEntrance diggingCaveEntrancesMinishWoods[] = { + { TILE_POS(37, 19), ROOM_MINISH_WOODS_MAIN, 0x0, AREA_LAKE_WOODS_CAVE, ROOM_LAKE_WOODS_CAVE_MAIN, + TILE_POS(37, 51) }, + { TILE_POS(31, 15), ROOM_MINISH_WOODS_MAIN, 0x0, AREA_LAKE_WOODS_CAVE, ROOM_LAKE_WOODS_CAVE_MAIN, + TILE_POS(31, 47) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesHyruleField[] = { + { TILE_POS(3, 11), ROOM_HYRULE_FIELD_EASTERN_HILLLS_NORTH, 0x4, AREA_DIG_CAVES, ROOM_DIG_CAVES_EASTERN_HILLS, + TILE_POS(3, 11) }, + { TILE_POS(35, 5), ROOM_HYRULE_FIELD_LON_LON_RANCH, 0x10, AREA_HYLIA_DIG_CAVES, ROOM_HYLIA_DIG_CAVES_1, + TILE_POS(8, 17) }, + { TILE_POS(5, 14), ROOM_HYRULE_FIELD_TRILBY_HIGHLANDS, 0xa, AREA_DIG_CAVES, ROOM_DIG_CAVES_TRILBY_HIGHLANDS, + TILE_POS(5, 14) }, + { TILE_POS(16, 14), ROOM_HYRULE_FIELD_TRILBY_HIGHLANDS, 0xa, AREA_DIG_CAVES, ROOM_DIG_CAVES_TRILBY_HIGHLANDS, + TILE_POS(16, 14) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesHyruleTown[] = { { TILE_POS(45, 24), ROOM_HYRULE_TOWN_MAIN, 0x2, + AREA_HYRULE_DIG_CAVES, + ROOM_HYRULE_DIG_CAVES_TOWN, TILE_POS(45, 40) }, + END_OF_LIST }; +static const DiggingCaveEntrance diggingCaveEntrancesMtCrenel[] = { + { TILE_POS(3, 5), ROOM_MT_CRENEL_WALL_CLIMB, 0x6, AREA_CRENEL_DIG_CAVE, ROOM_CRENEL_DIG_CAVE_0, TILE_POS(3, 25) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesVeilFalls[] = { + { TILE_POS(26, 37), ROOM_VEIL_FALLS_MAIN, 0x8, AREA_VEIL_FALLS_DIG_CAVE, ROOM_VEIL_FALLS_DIG_CAVE_0, + TILE_POS(26, 37) }, + { TILE_POS(14, 39), ROOM_VEIL_FALLS_MAIN, 0x8, AREA_VEIL_FALLS_DIG_CAVE, ROOM_VEIL_FALLS_DIG_CAVE_0, + TILE_POS(14, 39) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesCastorWilds[] = { + { TILE_POS(48, 25), ROOM_CASTOR_WILDS_MAIN, 0xc, AREA_CASTOR_WILDS_DIG_CAVE, ROOM_CASTOR_WILDS_DIG_CAVE_0, + TILE_POS(48, 25) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesLakeHylia[] = { + { TILE_POS(30, 5), ROOM_LAKE_HYLIA_MAIN, 0xe, AREA_HYLIA_DIG_CAVES, ROOM_HYLIA_DIG_CAVES_1, TILE_POS(46, 17) }, + { TILE_POS(30, 30), ROOM_LAKE_HYLIA_MAIN, 0x12, AREA_HYLIA_DIG_CAVES, ROOM_HYLIA_DIG_CAVES_0, TILE_POS(8, 9) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesLakeWoodsCave[] = { + { TILE_POS(37, 51), ROOM_LAKE_WOODS_CAVE_MAIN, 0x1, AREA_MINISH_WOODS, ROOM_MINISH_WOODS_MAIN, TILE_POS(37, 19) }, + { TILE_POS(31, 47), ROOM_LAKE_WOODS_CAVE_MAIN, 0x1, AREA_MINISH_WOODS, ROOM_MINISH_WOODS_MAIN, TILE_POS(31, 15) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesHyruleDigCaves[] = { + { TILE_POS(45, 40), ROOM_HYRULE_DIG_CAVES_TOWN, 0x3, AREA_HYRULE_TOWN, ROOM_HYRULE_TOWN_MAIN, TILE_POS(45, 24) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesAreaDigCaves[] = { + { TILE_POS(3, 11), ROOM_DIG_CAVES_EASTERN_HILLS, 0x5, AREA_HYRULE_FIELD, ROOM_HYRULE_FIELD_EASTERN_HILLLS_NORTH, + TILE_POS(3, 11) }, + { TILE_POS(5, 14), ROOM_DIG_CAVES_TRILBY_HIGHLANDS, 0xb, AREA_HYRULE_FIELD, ROOM_HYRULE_FIELD_TRILBY_HIGHLANDS, + TILE_POS(5, 14) }, + { TILE_POS(16, 14), ROOM_DIG_CAVES_TRILBY_HIGHLANDS, 0xb, AREA_HYRULE_FIELD, ROOM_HYRULE_FIELD_TRILBY_HIGHLANDS, + TILE_POS(16, 14) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesCrenelDigCave[] = { + { TILE_POS(3, 25), ROOM_CRENEL_DIG_CAVE_0, 0x7, AREA_MT_CRENEL, ROOM_MT_CRENEL_WALL_CLIMB, TILE_POS(3, 5) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesVeilFallsDigCave[] = { + { TILE_POS(26, 37), ROOM_VEIL_FALLS_DIG_CAVE_0, 0x9, AREA_VEIL_FALLS, ROOM_VEIL_FALLS_MAIN, TILE_POS(26, 37) }, + { TILE_POS(14, 39), ROOM_VEIL_FALLS_DIG_CAVE_0, 0x9, AREA_VEIL_FALLS, ROOM_VEIL_FALLS_MAIN, TILE_POS(14, 39) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesCastorWildsDigCave[] = { + { TILE_POS(48, 25), ROOM_CASTOR_WILDS_DIG_CAVE_0, 0xd, AREA_CASTOR_WILDS, ROOM_CASTOR_WILDS_MAIN, + TILE_POS(48, 25) }, + END_OF_LIST +}; +static const DiggingCaveEntrance diggingCaveEntrancesHyliaDigCaves[] = { + { TILE_POS(46, 17), ROOM_HYLIA_DIG_CAVES_1, 0xf, AREA_LAKE_HYLIA, ROOM_LAKE_HYLIA_MAIN, TILE_POS(30, 5) }, + { TILE_POS(8, 17), ROOM_HYLIA_DIG_CAVES_1, 0x11, AREA_HYRULE_FIELD, ROOM_HYRULE_FIELD_LON_LON_RANCH, + TILE_POS(35, 5) }, + { TILE_POS(8, 9), ROOM_HYLIA_DIG_CAVES_0, 0x13, AREA_LAKE_HYLIA, ROOM_LAKE_HYLIA_MAIN, TILE_POS(30, 30) }, + END_OF_LIST +}; + +/** Holds the lists of DiggingCaveEntrances indexed by area id. */ +static const DiggingCaveEntrance* const diggingCaveEntrances[] = { + diggingCaveEntrancesMinishWoods, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesHyruleTown, + diggingCaveEntrancesHyruleField, + diggingCaveEntrancesCastorWilds, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesMtCrenel, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesVeilFalls, + diggingCaveEntrancesLakeHylia, + diggingCaveEntrancesLakeWoodsCave, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesHyruleDigCaves, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesAreaDigCaves, + diggingCaveEntrancesCrenelDigCave, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesVeilFallsDigCave, + diggingCaveEntrancesCastorWildsDigCave, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesHyliaDigCaves, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, + diggingCaveEntrancesEmpty, +}; diff --git a/src/manager/enemyInteractionManager.c b/src/manager/enemyInteractionManager.c new file mode 100644 index 00000000..0c8428d7 --- /dev/null +++ b/src/manager/enemyInteractionManager.c @@ -0,0 +1,137 @@ +/** + * @file enemyInteractionManager.c + * @ingroup Managers + * + * @brief Interaction between enemies. Makes them not overlap. + */ +#include "manager/enemyInteractionManager.h" +#include "asm.h" +#include "room.h" + +void EnemyInteractionManager_Init(EnemyInteractionManager*); +void EnemyInteractionManager_Action1(EnemyInteractionManager*); +u32 EnemyInteractionManager_FindMatchingEntities(EnemyInteractionManager*); +Entity* EnemyInteractionManager_FindMatchingEntity(EntityData*); +void EnemyInteractionManager_RemoveDeletedEntities(EnemyInteractionManager*); + +enum EnemyInteractionManager_Action { Init = 0, Main = 1 }; + +enum EnemyInteractionManager_InitState { DoInit = 0, DoNotInit = 1 }; + +void EnemyInteractionManager_Main(EnemyInteractionManager* this) { + static void (*const EnemyInteractionManager_Actions[])(EnemyInteractionManager*) = { + EnemyInteractionManager_Init, + EnemyInteractionManager_Action1, + }; + EnemyInteractionManager_Actions[super->action](this); +} + +void EnemyInteractionManager_Init(EnemyInteractionManager* this) { + if (super->type == DoInit) { + s32 entityCount; + int tmp4; + for (tmp4 = 0; tmp4 < 8; tmp4++) { + this->d.enemies[tmp4] = 0; + } + entityCount = EnemyInteractionManager_FindMatchingEntities(this); + if (entityCount > 1) { + EnemyInteractionManager* tmp3 = (EnemyInteractionManager*)GetEmptyManager(); + if (tmp3) { + tmp3->base.kind = MANAGER; + tmp3->base.id = ENEMY_INTERACTION_MANAGER; + tmp3->base.type = DoNotInit; + tmp3->base.timer = entityCount; + /* for (tmp4 = 0; tmp4 < 8; tmp4++) { */ + /* tmp3->enemies[tmp4] = this->enemies[tmp4]; */ + /* } */ + tmp3->d = this->d; + AppendEntityToList((Entity*)tmp3, 6); + } + } + DeleteManager(super); + } else { + super->action = Main; + super->subtimer = 0; + } +} + +void EnemyInteractionManager_Action1(EnemyInteractionManager* this) { + s32 n; + s32 i; + s32 j; + Entity* tmp; + EnemyInteractionManager_RemoveDeletedEntities(this); + n = super->timer - 1; + if ((super->subtimer++) & 1) { + for (i = 0; i < n; i++) { + tmp = this->d.enemies[i]; + for (j = i + 1; j < super->timer; j++) { + sub_08004484(tmp, this->d.enemies[j]); + } + } + } else { + for (i = 0; i < n; i++) { + tmp = this->d.enemies[i]; + for (j = i + 1; j < super->timer; j++) { + sub_08004484(this->d.enemies[j], tmp); + } + } + } +} + +u32 EnemyInteractionManager_FindMatchingEntities(EnemyInteractionManager* this) { + u32 re = 0; + EntityData* tmp = GetCurrentRoomProperty(super->type2); + if (!tmp) + return 0; + for (; *((u8*)tmp) != 0xFF && !((tmp->kind & 0xf) == 9 && tmp->id == 0x28); tmp++) { + Entity* tmp2; + u32 i; + if ((tmp->kind & 0xf) != 3) + continue; + tmp2 = EnemyInteractionManager_FindMatchingEntity(tmp); + if (!tmp2) + continue; + for (i = 0; i < re; i++) { + if (this->d.enemies[i] == tmp2) + break; + } + if (i != re) + continue; + this->d.enemies[re++] = tmp2; + if (re == 8) + return 8; + } + return re; +} + +Entity* EnemyInteractionManager_FindMatchingEntity(EntityData* unk1) { + u32 x, y; + Entity* i; + LinkedList* tmp; + x = unk1->xPos + gRoomControls.origin_x; + y = unk1->yPos + gRoomControls.origin_y; + tmp = &gEntityLists[4]; + for (i = tmp->first; (u32)i != (u32)tmp; i = i->next) { + if (x == i->x.HALF.HI && y == i->y.HALF.HI && unk1->id == i->id && ENEMY == i->kind && unk1->type == i->type) { + return i; + } + } + return 0; +} + +void EnemyInteractionManager_RemoveDeletedEntities(EnemyInteractionManager* this) { + s32 i; + for (i = 0; i < super->timer; i++) { + if (this->d.enemies[i]->next == 0) { + if (super->timer - 1 == i) { + this->d.enemies[i] = 0; + } else { + this->d.enemies[i] = this->d.enemies[super->timer - 1]; + } + super->timer--; + } + } + if (super->timer <= 1) + DeleteThisEntity(); +} diff --git a/src/manager/manager39.c b/src/manager/enterRoomTextboxManager.c similarity index 58% rename from src/manager/manager39.c rename to src/manager/enterRoomTextboxManager.c index 48b6edf7..d1a92097 100644 --- a/src/manager/manager39.c +++ b/src/manager/enterRoomTextboxManager.c @@ -1,72 +1,65 @@ -#include "global.h" -#include "manager.h" -#include "screen.h" +/** + * @file enterRoomTextboxManager.c + * @ingroup Managers + * + * @brief Shows textbox when entering the room. + */ +#include "manager/enterRoomTextboxManager.h" #include "area.h" -#include "message.h" #include "common.h" -#include "game.h" #include "functions.h" - -typedef struct { - Manager manager; - u8 unk_20; // unused - u8 unk_21[0x13]; // unused - u16 unk_34; // unused - u16 unk_36; // unused - s16 unk_38; // unused - s16 unk_3A; // unused - u16 unk_3C; // unused - u16 unk_3E; // unused -} Manager39; +#include "game.h" +#include "message.h" +#include "screen.h" extern u8 gUnk_02034DF0[0x2F2]; extern const u16 gUnk_08108DE8[]; -extern void (*const gUnk_08108E28[])(Manager39*); +extern void (*const EnterRoomTextboxManager_Actions[])(EnterRoomTextboxManager*); extern const u8 gUnk_08108E30[0x18]; extern const u8 gUnk_08108E48[0x18]; extern const u8 gUnk_08108E60[]; extern void sub_0805F46C(void*, const void*); -void sub_0805E140(Manager39*); -void sub_0805E18C(Manager39*); // unused? -void sub_0805E1D8(Manager39*); +void sub_0805E140(EnterRoomTextboxManager*); +void sub_0805E18C(EnterRoomTextboxManager*); // unused? +void sub_0805E1D8(EnterRoomTextboxManager*); void sub_0805E1F8(u32, u32); -void Manager39_Main(Manager39* this) { - gUnk_08108E28[this->manager.action](this); +void EnterRoomTextboxManager_Main(EnterRoomTextboxManager* this) { + EnterRoomTextboxManager_Actions[super->action](this); if ((gRoomControls.room != this->unk_20) || (gMessage.doTextBox & 0x7F)) { sub_0805E1D8(this); } } -void sub_0805E140(Manager39* this) { - this->manager.unk_10 |= 0x20; - this->manager.action = 1; +void sub_0805E140(EnterRoomTextboxManager* this) { + super->flags |= ENT_PERSIST; + super->action = 1; this->unk_20 = gRoomControls.room; - this->manager.unk_0e = 0x78; - this->manager.unk_0f = 0x3c; + super->timer = 0x78; + super->subtimer = 0x3c; SetDefaultPriority((Entity*)this, PRIO_HIGHEST); sub_0805E1F8(gUnk_08108DE8[gArea.locationIndex], AreaIsDungeon()); } -void sub_0805E18C(Manager39* this) { +void sub_0805E18C(EnterRoomTextboxManager* this) { if (gFadeControl.active) return; - if (this->manager.unk_0b) { - if (!--this->manager.unk_0f) { - this->manager.unk_0b = 0; + if (super->type2) { + if (--super->subtimer == 0) { + super->type2 = 0; gPlayerState.controlMode = CONTROL_1; ResetSystemPriority(); } } - if (!--this->manager.unk_0e) { + if (--super->timer == 0) { sub_0805E1D8(this); } } -void sub_0805E1D8(Manager39* this) { +void sub_0805E1D8(EnterRoomTextboxManager* this) { MemClear(&gUnk_02034DF0, 0x80); gScreen.bg0.updated = 1; DeleteThisEntity(); diff --git a/src/manager/entitySpawnManager.c b/src/manager/entitySpawnManager.c new file mode 100644 index 00000000..900b6480 --- /dev/null +++ b/src/manager/entitySpawnManager.c @@ -0,0 +1,40 @@ +/** + * @file entitySpawnManager.c + * @ingroup Managers + * + * @brief Load a entity list when a flag is set. + * + * e.g. spawns the heart container and teleporter after getting the element in DWS + */ +#include "manager/entitySpawnManager.h" +#include "entity.h" +#include "flags.h" +#include "functions.h" +#include "room.h" +#include "sound.h" + +void EntitySpawnManager_Main(EntitySpawnManager* this) { + if (super->action == 0) { + super->action = 1; + if (CheckFlags(this->flag)) { + DeleteManager(super); + return; + } + } + if (!CheckFlags(this->flag)) + return; + if (super->type2 != 0) { + super->type2 = 0; + SetPlayerControl(0xff); + sub_08078B48(); + } + if (this->spawnTimer == 0) { + if (this->sound != 0) { + SoundReq(this->sound); + } + LoadRoomEntityList(GetCurrentRoomProperty(super->type)); + DeleteThisEntity(); + } else { + this->spawnTimer--; + } +} diff --git a/src/manager/managerA.c b/src/manager/ezloHintManager.c similarity index 62% rename from src/manager/managerA.c rename to src/manager/ezloHintManager.c index b94bbe6b..bf7e4ad2 100644 --- a/src/manager/managerA.c +++ b/src/manager/ezloHintManager.c @@ -1,32 +1,33 @@ -#include "global.h" +/** + * @file ezloHintManager.c + * @ingroup Managers + * + * @brief Shows Ezlo hints + */ +#include "manager/ezloHintManager.h" +#include "area.h" #include "asm.h" #include "entity.h" -#include "player.h" -#include "manager.h" #include "flags.h" -#include "area.h" #include "functions.h" -static void sub_08058398(ManagerA*); -static void sub_080583EC(ManagerA*); -static void sub_08058408(ManagerA*); -static void sub_08058514(ManagerA*); -static void sub_080585B0(ManagerA*); +static void EzloHintManager_Init(EzloHintManager*); +static void EzloHintManager_Action1(EzloHintManager*); +static void EzloHintManager_Action2(EzloHintManager*); +static void EzloHintManager_Action3(EzloHintManager*); +static void EzloHintManager_Action4(EzloHintManager*); +static u32 PlayerStateValid(EzloHintManager*); +static void sub_080585DC(EzloHintManager*); -static u32 PlayerStateValid(ManagerA*); -static void sub_080585DC(ManagerA*); - -/** - * Ezlo hint manager - */ -void ManagerA_Main(ManagerA* this) { - static void (*const sActions[])(ManagerA*) = { sub_08058398, sub_080583EC, sub_08058408, sub_08058514, - sub_080585B0 }; - - sActions[this->manager.action](this); +void EzloHintManager_Main(EzloHintManager* this) { + static void (*const EzloHintManager_Actions[])(EzloHintManager*) = { + EzloHintManager_Init, EzloHintManager_Action1, EzloHintManager_Action2, + EzloHintManager_Action3, EzloHintManager_Action4, + }; + EzloHintManager_Actions[super->action](this); } -static void sub_08058398(ManagerA* this) { +static void EzloHintManager_Init(EzloHintManager* this) { if (CheckFlags(this->flag1) != 0) { DeleteThisEntity(); } @@ -34,33 +35,34 @@ static void sub_08058398(ManagerA* this) { this->ry = this->ry_raw << 3; this->x = this->rx + (this->x_raw << 4); this->y = this->ry + (this->y_raw << 4); - SetDefaultPriority((Entity*)&this->manager, PRIO_PLAYER_EVENT); + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (this->flag2 == 0) { - this->manager.action = 2; + super->action = 2; } else { - this->manager.action = 1; + super->action = 1; } } -static void sub_080583EC(ManagerA* this) { +static void EzloHintManager_Action1(EzloHintManager* this) { if (CheckFlags(this->flag2)) { - this->manager.action = 2; - sub_08058408(this); + super->action = 2; + EzloHintManager_Action2(this); } } -static void sub_08058408(ManagerA* this) { +static void EzloHintManager_Action2(EzloHintManager* this) { if (gPlayerState.flags & PL_NO_CAP) return; if (!CheckPlayerInRegion(this->x, this->y, this->rx, this->ry)) return; - switch (this->manager.unk_0a) { + switch (super->type) { case 1: return; case 2: sub_080585DC(this); if ((gPlayerState.flags & PL_MINISH) == 0) return; + // fallthrough case 0: default: sub_080585DC(this); @@ -69,19 +71,19 @@ static void sub_08058408(ManagerA* this) { SetPlayerControl(3); sub_08078B48(); SetPlayerEventPriority(); - this->manager.action = 3; - this->manager.unk_0d = 0; - this->manager.unk_0e = 30; + super->action = 3; + super->subAction = 0; + super->timer = 30; return; case 3: - this->manager.action = 4; - this->manager.unk_0d = 0; + super->action = 4; + super->subAction = 0; sub_080186C0(this->msg_idx); return; } } -static u32 PlayerStateValid(ManagerA* this) { +static u32 PlayerStateValid(EzloHintManager* this) { switch (gPlayerState.framestate) { case PL_STATE_THROW: case PL_STATE_SWIM: @@ -113,8 +115,8 @@ static u32 PlayerStateValid(ManagerA* this) { } } -static void sub_08058514(ManagerA* this) { - switch (this->manager.unk_0d) { +static void EzloHintManager_Action3(EzloHintManager* this) { + switch (super->subAction) { case 1: if (gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_USE_PORTAL | PL_FALLING | PL_IN_MINECART | PL_CAPTURED)) @@ -123,13 +125,13 @@ static void sub_08058514(ManagerA* this) { return; gPlayerState.jump_status = 0; CreateEzloHint(this->msg_idx, this->msg_height); - this->manager.unk_0d++; - this->manager.unk_0e = 30; + super->subAction++; + super->timer = 30; return; case 0: case 2: - if (--this->manager.unk_0e == 0) { - this->manager.unk_0d++; + if (--super->timer == 0) { + super->subAction++; } return; case 3: @@ -146,7 +148,7 @@ static void sub_08058514(ManagerA* this) { } } -static void sub_080585B0(ManagerA* this) { +static void EzloHintManager_Action4(EzloHintManager* this) { if (gArea.unk28.inventoryGfxIdx != 0xFF) { DeleteThisEntity(); } @@ -155,7 +157,8 @@ static void sub_080585B0(ManagerA* this) { DeleteThisEntity(); } } -static void sub_080585DC(ManagerA* this) { + +static void sub_080585DC(EzloHintManager* this) { if (CheckFlags(this->flag1)) { DeleteThisEntity(); } diff --git a/src/manager/fallingItemManager.c b/src/manager/fallingItemManager.c new file mode 100644 index 00000000..966a5702 --- /dev/null +++ b/src/manager/fallingItemManager.c @@ -0,0 +1,45 @@ +/** + * @file fallingItemManager.c + * @ingroup Managers + * + * @brief Item that is falling from the sky. + * + * If you leave the room without picking the item up and enter again, the item falls from the sky again. + */ +#include "manager/fallingItemManager.h" +#include "flags.h" +#include "object.h" +#include "room.h" + +void FallingItemManager_Init(FallingItemManager*); +void FallingItemManager_Action1(FallingItemManager*); + +void FallingItemManager_Main(FallingItemManager* this) { + static void (*const FallingItemManager_Actions[])(FallingItemManager*) = { + FallingItemManager_Init, + FallingItemManager_Action1, + }; + FallingItemManager_Actions[super->action](this); +} + +void FallingItemManager_Init(FallingItemManager* this) { + super->action = 1; + if (CheckFlags(this->field_0x3c)) { + DeleteThisEntity(); + } + FallingItemManager_Action1(this); +} + +void FallingItemManager_Action1(FallingItemManager* this) { + if (CheckFlags(this->field_0x3e)) { + Entity* object = CreateObject(GROUND_ITEM, super->type, super->type2); + if (object != NULL) { + object->timer = this->field_0x35; + object->collisionLayer = this->field_0x36; + object->x.HALF.HI = this->field_0x38 + gRoomControls.origin_x; + object->y.HALF.HI = this->field_0x3a + gRoomControls.origin_y; + object->field_0x86.HWORD = this->field_0x3c; + } + DeleteThisEntity(); + } +} diff --git a/src/manager/managerB.c b/src/manager/fightManager.c similarity index 54% rename from src/manager/managerB.c rename to src/manager/fightManager.c index bb9aa75e..3459bbd8 100644 --- a/src/manager/managerB.c +++ b/src/manager/fightManager.c @@ -1,44 +1,58 @@ -#include "global.h" -#include "manager.h" -#include "flags.h" -#include "room.h" -#include "area.h" -#include "common.h" -#include "sound.h" - -/* - * Manager B is used to create fights: +/** + * @file fightManager.c + * @ingroup Managers + * + * @brief Manages fights with multiple enemies + * * It possibly waits for an inhibitor flag to be set, then spawns a bunch of entities (based on room data). * Once all enemies created this way are dead, it sets a flag. * (There is also a part about changing the music and setting it back when the fight is done, which is song 0x33 (a * fight theme) by default but can be overridden through room data) */ +#include "manager/fightManager.h" +#include "area.h" +#include "common.h" +#include "flags.h" +#include "room.h" +#include "sound.h" -void (*const ManagerB_ActionFuncs[])(Manager*); +enum FightManager_State { Init, WaitForFlag, WaitForDone }; -void ManagerB_Main(Manager* this) { +void FightManager_LoadFight(FightManager*); +FightManagerHelper* FightManager_CreateHelper(FightManager*); +void FightManagerHelper_Monitor(FightManagerHelper*, Entity*, u32); +void FightManager_Init(FightManager*); +void FightManager_WaitForFlag(FightManager*); +void FightManager_WaitForDone(FightManager*); +void FightManager_Main2(FightManager*); +void FightManagerHelper_Main(FightManagerHelper*); + +void FightManager_Main(Manager* this) { + static void (*const FightManager_ActionFuncs[])(Manager*) = { + (void (*)(Manager*))FightManager_Main2, + (void (*)(Manager*))FightManagerHelper_Main, + }; // make a distincion if this is a controller (volumeMasterTarget = 0) or a helper (volumeMasterTarget = 1) - ManagerB_ActionFuncs[this->unk_0a](this); + FightManager_ActionFuncs[this->type](this); } -enum ManagerB_State { Init, WaitForFlag, WaitForDone }; - -void (*const ManagerB_StateFuncs[])(ManagerB*); - -void ManagerB_Main2(ManagerB* this) { +void FightManager_Main2(FightManager* this) { // make a distinction based on the state of this controller - ManagerB_StateFuncs[this->manager.action](this); + static void (*const FightManager_Actions[])(FightManager*) = { + FightManager_Init, + FightManager_WaitForFlag, + FightManager_WaitForDone, + }; + FightManager_Actions[super->action](this); } -void ManagerB_LoadFight(Manager*); - -void ManagerB_Init(ManagerB* this) { +void FightManager_Init(FightManager* this) { // check if the fight was already completed previously (checks the flag that gets set after the fight is done) - if (!CheckFlags(this->unk_3e)) { - this->manager.action = WaitForFlag; + if (!CheckFlags(this->fightCompletedFlag)) { + super->action = WaitForFlag; // if there is no flag that needs to be set before the fight is started, start it immediately - if (!this->unk_3c) { - ManagerB_LoadFight(&this->manager); + if (!this->fightStartFlag) { + FightManager_LoadFight(this); } SetDefaultPriority((Entity*)this, PRIO_NO_BLOCK); } else { @@ -46,10 +60,10 @@ void ManagerB_Init(ManagerB* this) { } } -void ManagerB_WaitForFlag(ManagerB* this) { +void FightManager_WaitForFlag(FightManager* this) { int tmp; - if (CheckFlags(this->unk_3c)) { - ManagerB_LoadFight(&this->manager); + if (CheckFlags(this->fightStartFlag)) { + FightManager_LoadFight(this); if (!this->unk_35) { tmp = gRoomVars.field_0x9 ? gRoomVars.field_0x9 : 0x33; this->unk_20 = gArea.bgm; @@ -60,15 +74,15 @@ void ManagerB_WaitForFlag(ManagerB* this) { } } -void ManagerB_WaitForDone(ManagerB* this) { +void FightManager_WaitForDone(FightManager* this) { // check if all helpers are done - if (this->manager.unk_0e) { + if (super->timer) { return; } // set the completion flag for the fight - SetFlag(this->unk_3e); + SetFlag(this->fightCompletedFlag); // restore music (if it was set, which apparently is only possible if there's a flag the fight waited for) - if (this->unk_3c) { + if (this->fightStartFlag) { if (!this->unk_35) { gArea.bgm = this->unk_20; SoundReq(gArea.bgm); @@ -78,35 +92,32 @@ void ManagerB_WaitForDone(ManagerB* this) { DeleteThisEntity(); } -ManagerBHelper* CreateHelper(Manager*); -void ManagerBHelper_Monitor(ManagerBHelper*, Entity*, u32); - -void ManagerB_LoadFight(Manager* this) { - ManagerBHelper* monitor; +void FightManager_LoadFight(FightManager* this) { + FightManagerHelper* monitor; EntityData* prop; Entity* ent; u32 counter; - this->action = 2; - this->unk_0e = 0; + super->action = 2; + super->timer = 0; counter = 0; // Create a helper to keep track of the created entities. - monitor = CreateHelper(this); + monitor = FightManager_CreateHelper(this); if (monitor == NULL) { DeleteThisEntity(); } - prop = (EntityData*)GetCurrentRoomProperty(this->unk_0b); + prop = (EntityData*)GetCurrentRoomProperty(super->type2); if (prop != NULL) { while (prop->kind != 0xFF) { ent = LoadRoomEntity(prop++); if ((ent != NULL) && (ent->kind == ENEMY)) { ent->field_0x6c.HALF.HI |= 0x40; - ManagerBHelper_Monitor(monitor, ent, counter++); + FightManagerHelper_Monitor(monitor, ent, counter++); } if (counter >= 7) { counter = 0; - monitor = CreateHelper(this); + monitor = FightManager_CreateHelper(this); if (monitor == NULL) return; } @@ -114,48 +125,47 @@ void ManagerB_LoadFight(Manager* this) { } } -/* +/** * Create a helper and increment the counter for the number of helpers (unk_0e). * The helper will decrease said counter when it deletes itself (when none of the enemies it monitors remain). */ -ManagerBHelper* CreateHelper(Manager* this) { - ManagerBHelper* extra; - extra = (ManagerBHelper*)GetEmptyManager(); +FightManagerHelper* FightManager_CreateHelper(FightManager* this) { + FightManagerHelper* extra; + extra = (FightManagerHelper*)GetEmptyManager(); if (extra) { - extra->manager.type = 9; - extra->manager.subtype = 0xB; - extra->manager.unk_0a = 1; - extra->manager.parent = this; - this->unk_0e++; + extra->base.kind = MANAGER; + extra->base.id = FIGHT_MANAGER; + extra->base.type = 1; + extra->base.parent = (Entity*)this; + super->timer++; MemClear(&extra->enemies, 0x20); AppendEntityToList((Entity*)extra, 8); } return extra; } -void ManagerBHelper_Monitor(ManagerBHelper* this, Entity* ent, u32 index) { +void FightManagerHelper_Monitor(FightManagerHelper* this, Entity* ent, u32 index) { this->enemies[index] = ent; - this->manager.unk_0e++; + super->timer++; } // case volumeMasterTarget is 1: The manager is a helper - -void ManagerBHelper_Main(Manager* this) { +void FightManagerHelper_Main(FightManagerHelper* this) { u8 i; bool32 anyRemaining; Entity* current; - if (this->action == 0) { - this->action = 1; + if (super->action == 0) { + super->action = 1; SetDefaultPriority((Entity*)this, PRIO_NO_BLOCK); } // go through and check all monitored enemies. anyRemaining = FALSE; for (i = 0; i < 8; i++) { - current = ((ManagerBHelper*)this)->enemies[i]; + current = this->enemies[i]; if (current != NULL) { if (current->next == NULL) { - ((ManagerBHelper*)this)->enemies[i] = 0; + this->enemies[i] = 0; } else { anyRemaining = TRUE; } @@ -163,24 +173,24 @@ void ManagerBHelper_Main(Manager* this) { } if (!anyRemaining) { // inform the parent that we're done - ManagerB* parent = (ManagerB*)this->parent; - if (parent->manager.unk_0e != 0) { - parent->manager.unk_0e--; + FightManager* parent = (FightManager*)super->parent; + if (parent->base.timer != 0) { + parent->base.timer--; } DeleteThisEntity(); } } -/* +/** * Replace an entity that is currently being monitored with a new one */ void ReplaceMonitoredEntity(Entity* old, Entity* new) { - ManagerBHelper* current; + FightManagerHelper* current; Manager* end = (Manager*)&gEntityLists[8]; u32 i; - for (current = (ManagerBHelper*)end->next; (Manager*)current != end; - current = (ManagerBHelper*)current->manager.next) { - if (current->manager.type != 0x9 || current->manager.subtype != 0xB) { + for (current = (FightManagerHelper*)end->next; (Manager*)current != end; + current = (FightManagerHelper*)current->base.next) { + if (current->base.kind != MANAGER || current->base.id != FIGHT_MANAGER) { continue; } for (i = 0; i < 8; i++) { @@ -191,7 +201,3 @@ void ReplaceMonitoredEntity(Entity* old, Entity* new) { } } } - -void (*const ManagerB_ActionFuncs[])(Manager*) = { (void (*)(Manager*))ManagerB_Main2, - (void (*)(Manager*))ManagerBHelper_Main }; -void (*const ManagerB_StateFuncs[])(ManagerB*) = { ManagerB_Init, ManagerB_WaitForFlag, ManagerB_WaitForDone }; diff --git a/src/manager/flagAndOperatorManager.c b/src/manager/flagAndOperatorManager.c new file mode 100644 index 00000000..7439830a --- /dev/null +++ b/src/manager/flagAndOperatorManager.c @@ -0,0 +1,22 @@ +/** + * @file flagAndOperatorManager.c + * @ingroup Managers + * + * @brief Sets a flag if all of the flags are set. + */ +#include "manager/flagAndOperatorManager.h" +#include "flags.h" + +void FlagAndOperatorManager_Main(FlagAndOperatorManager* this) { + if (super->action == 0) { + super->action = 1; + if (CheckFlags(this->unk_3c)) { + DeleteThisEntity(); + } + } else { + if (CheckFlags(this->unk_3e)) { + SetFlag(this->unk_3c); + DeleteThisEntity(); + } + } +} diff --git a/src/manager/manager25.c b/src/manager/flameManager.c similarity index 62% rename from src/manager/manager25.c rename to src/manager/flameManager.c index 78003bc1..880324fd 100644 --- a/src/manager/manager25.c +++ b/src/manager/flameManager.c @@ -1,20 +1,21 @@ +/** + * @file flameManager.c + * @ingroup Managers + * + * @brief Manages flame that can be ignited with the lamp. + * + * However, this manager is deleted when the flame is ignited the first time. + */ +#include "manager/flameManager.h" #include "asm.h" -#include "manager.h" -#include "room.h" #include "functions.h" +#include "room.h" -typedef struct { - struct Manager manager; - u8 field_0x20[0x18]; - s16 field_0x38; - s16 field_0x3a; -} Manager25; - -void Manager25_Main(Manager25* this) { - if (this->manager.action == 0) { +void FlameManager_Main(FlameManager* this) { + if (super->action == 0) { this->field_0x38 = TILE(this->field_0x38, this->field_0x3a); if (GetTileType(this->field_0x38, 2) == 0x75) { - this->manager.action = 1; + super->action = 1; SetTile(0x406a, this->field_0x38, 1); } else { DeleteThisEntity(); diff --git a/src/manager/floatingPlatformManager.c b/src/manager/floatingPlatformManager.c new file mode 100644 index 00000000..f46f5e66 --- /dev/null +++ b/src/manager/floatingPlatformManager.c @@ -0,0 +1,41 @@ +/** + * @file floatingPlatformManager.c + * @ingroup Managers + * + * @brief Spawns lists of floating platforms together. + */ +#include "manager/floatingPlatformManager.h" +#include "entity.h" +#include "room.h" + +void FloatingPlatformManager_Init(FloatingPlatformManager*); +void FloatingPlatformManager_Action1(FloatingPlatformManager*); + +void FloatingPlatformManager_Main(FloatingPlatformManager* this) { + static void (*const FloatingPlatformManager_Actions[])(FloatingPlatformManager*) = { + FloatingPlatformManager_Init, + FloatingPlatformManager_Action1, + }; + FloatingPlatformManager_Actions[super->action](this); +} + +void FloatingPlatformManager_Init(FloatingPlatformManager* this) { + EntityData* entityData; + Entity* entity; + + super->action = 1; + super->timer = 0; + entityData = (EntityData*)GetCurrentRoomProperty(super->type); + if (entityData == NULL) { + DeleteThisEntity(); + } + while (*(u8*)entityData != 0xff) { + entity = LoadRoomEntity(entityData++); + entity->parent = (Entity*)this; + entity->timer = 0xff; + } +} + +void FloatingPlatformManager_Action1(FloatingPlatformManager* this) { + super->timer = 0; +} diff --git a/src/manager/manager31.c b/src/manager/goronMerchantShopManager.c similarity index 90% rename from src/manager/manager31.c rename to src/manager/goronMerchantShopManager.c index eae858e8..5bb67e43 100644 --- a/src/manager/manager31.c +++ b/src/manager/goronMerchantShopManager.c @@ -1,14 +1,14 @@ - -#include "manager.h" -#include "flags.h" +/** + * @file goronMerchantShopManager.c + * @ingroup Managers + * + * @brief Spawns the shop items for the kinstones for the goron merchant. + */ +#include "manager/goronMerchantShopManager.h" #include "asm.h" +#include "flags.h" #include "object.h" -typedef struct { - Manager manager; - u8 itemActive[3]; -} Manager31; - typedef struct { u16 minType; u16 maxType; @@ -16,10 +16,7 @@ typedef struct { u16 y; } GoronShopSpawnData; -/* -Spawns the shop items for the kinstones for the goron merchant. -*/ -void Manager31_Main(Manager31* this) { +void GoronMerchantShopManager_Main(GoronMerchantShopManager* this) { static const GoronShopSpawnData gUnk_08108D5C[3] = { { 0x6e, 0x3, 0x210, 0x210 }, { 0x71, 0x2, 0x220, 0x210 }, { 0x73, 0x3, 0x230, 0x210 } }; @@ -27,8 +24,8 @@ void Manager31_Main(Manager31* this) { const GoronShopSpawnData* spawnData; s32 count; - if (this->manager.action == 0) { - this->manager.action++; + if (super->action == 0) { + super->action++; if (CheckGlobalFlag(GORON_KAKERA_L) != 0 && CheckGlobalFlag(GORON_KAKERA_M) != 0 && CheckGlobalFlag(GORON_KAKERA_R) != 0) { if (CheckGlobalFlag(GORON_KAKERA_LV2) == 0) { diff --git a/src/manager/manager1A.c b/src/manager/holeManager.c similarity index 78% rename from src/manager/manager1A.c rename to src/manager/holeManager.c index ae167838..a79dd62e 100644 --- a/src/manager/manager1A.c +++ b/src/manager/holeManager.c @@ -1,33 +1,23 @@ -#include "global.h" -#include "manager.h" +/** + * @file holeManager.c + * @ingroup Managers + * + * @brief Hole that you can fall into. + */ +#include "manager/holeManager.h" +#include "common.h" #include "flags.h" +#include "functions.h" +#include "object.h" #include "room.h" #include "screen.h" -#include "common.h" -#include "object.h" -#include "functions.h" -typedef struct { - Manager manager; - s16 unk_20; - s16 unk_22; - u16 unk_24; - u16 unk_26; - u8 unk_28[8]; - u16 unk_30; - u16 unk_32; - u16 unk_34; - u16 unk_36; - u8 unk_38[7]; - u8 unk_3f; -} Manager1A; - -extern void (*const gUnk_08108668[])(Manager1A*); +extern void (*const HoleManager_Actions[])(HoleManager*); extern u8 gGlobalGfxAndPalettes[]; -void Manager1A_Main(Manager1A* this) { - gUnk_08108668[this->manager.action](this); +void HoleManager_Main(HoleManager* this) { + HoleManager_Actions[super->action](this); } typedef struct struct_08108764 { @@ -59,19 +49,19 @@ typedef struct struct_08108764 { extern struct_08108764 gUnk_08108764[]; -u32 sub_0805B1CC(Manager1A*); -void sub_0805B210(Manager1A*); -void sub_0805B2B0(Manager1A*); -void sub_0805B328(Manager1A*); +u32 sub_0805B1CC(HoleManager*); +void sub_0805B210(HoleManager*); +void sub_0805B2B0(HoleManager*); +void sub_0805B328(HoleManager*); -void sub_0805B048(Manager1A* this) { +void sub_0805B048(HoleManager* this) { struct_08108764* tmp; Entity* obj; - SetDefaultPriority((Entity*)&this->manager, PRIO_PLAYER_EVENT); + SetDefaultPriority((Entity*)super, PRIO_PLAYER_EVENT); MemClear(&this->unk_20, 0x20); - this->manager.action = 1; + super->action = 1; this->unk_3f = gRoomControls.room; - tmp = &gUnk_08108764[this->manager.unk_0a]; + tmp = &gUnk_08108764[super->type]; if (!tmp->unk_0a) { this->unk_20 = gRoomControls.origin_x; this->unk_22 = gRoomControls.origin_y; @@ -83,9 +73,9 @@ void sub_0805B048(Manager1A* this) { this->unk_24 = (tmp->unk_0a << 4); this->unk_26 = (tmp->unk_0b << 4); } - this->manager.unk_0b = tmp->unk_0c != 0; - if (this->manager.unk_0b) { - this->manager.unk_10 |= 0x20; + super->type2 = tmp->unk_0c != 0; + if (super->type2) { + super->flags |= ENT_PERSIST; this->unk_34 = tmp->unk_0c->unk_04; this->unk_36 = tmp->unk_0c->unk_06; this->unk_30 = tmp->unk_0c->unk_08; @@ -102,7 +92,7 @@ void sub_0805B048(Manager1A* this) { obj->x.HALF.HI = tmp->unk_10->unk_04 + gRoomControls.origin_x; obj->y.HALF.HI = tmp->unk_10->unk_06 + gRoomControls.origin_y; } - if (this->manager.unk_0a != 0xa || CheckLocalFlag(0x4B)) + if (super->type != 0xa || CheckLocalFlag(0x4B)) return; obj = CreateObject(OBJECT_28, 3, 3); if (obj) { @@ -111,7 +101,7 @@ void sub_0805B048(Manager1A* this) { } } -void sub_0805B168(Manager1A* this) { +void sub_0805B168(HoleManager* this) { if (sub_0805B1CC(this)) { sub_0805B210(this); DeleteThisEntity(); @@ -119,21 +109,21 @@ void sub_0805B168(Manager1A* this) { } sub_0805B2B0(this); if (gRoomControls.reload_flags == 1) { - this->manager.unk_0d = 1; + super->subAction = 1; return; } - if (!this->manager.unk_0d) + if (super->subAction == 0) return; - this->manager.unk_0d = 0; + super->subAction = 0; if (this->unk_3f == gRoomControls.room) return; - if (this->manager.unk_0b) { + if (super->type2) { gScreen.lcd.displayControl &= ~0x800; } DeleteThisEntity(); } -u32 sub_0805B1CC(Manager1A* this) { +u32 sub_0805B1CC(HoleManager* this) { u32 re = 0; if (CheckPlayerProximity(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) { if ((gPlayerState.flags & PL_DROWNING) && (gPlayerState.flags & PL_BUSY)) { @@ -145,12 +135,12 @@ u32 sub_0805B1CC(Manager1A* this) { return re; } -void sub_0805B210(Manager1A* this) { +void sub_0805B210(HoleManager* this) { struct_08108764* tmp; gRoomTransition.transitioningOut = 1; gRoomTransition.type = TRANSITION_CUT; gRoomTransition.player_status.start_anim = 4; - tmp = &gUnk_08108764[this->manager.unk_0a]; + tmp = &gUnk_08108764[super->type]; gRoomTransition.player_status.area_next = tmp->unk_01; gRoomTransition.player_status.room_next = tmp->unk_02; gRoomTransition.player_status.layer = tmp->unk_03; @@ -176,9 +166,9 @@ void sub_0805B210(Manager1A* this) { } } -void sub_0805B2B0(Manager1A* this) { +void sub_0805B2B0(HoleManager* this) { s32 tmp, tmp2; - if (!this->manager.unk_0b) + if (!super->type2) return; tmp = (this->unk_30 - gRoomControls.scroll_x) / 4; tmp2 = (this->unk_32 - gRoomControls.scroll_y) / 4; @@ -201,11 +191,11 @@ void sub_0805B2B0(Manager1A* this) { gScreen.bg3.yOffset = gRoomControls.scroll_y + this->unk_36 + tmp2; } -void sub_0805B328(Manager1A* this) { +void sub_0805B328(HoleManager* this) { struct_08108764* tmp; - if (!this->manager.unk_0b) + if (!super->type2) return; - tmp = &gUnk_08108764[this->manager.unk_0a]; + tmp = &gUnk_08108764[super->type]; LoadResourceAsync(&gGlobalGfxAndPalettes[tmp->unk_0c->unk_00], 0x0600F000, 0x800); gScreen.bg3.control = 0x1E07; gScreen.lcd.displayControl |= DISPCNT_BG3_ON; @@ -214,12 +204,12 @@ void sub_0805B328(Manager1A* this) { gScreen.controls.layerFXControl &= ~0x8; } -void sub_0805B390(u32 unk1) { +void CreateHoleManager(u32 type) { Manager* tmp = GetEmptyManager(); if (!tmp) return; - tmp->type = 0x9; - tmp->subtype = 0x1A; - tmp->unk_0a = unk1; + tmp->kind = MANAGER; + tmp->id = HOLE_MANAGER; + tmp->type = type; AppendEntityToList((Entity*)tmp, 6); } diff --git a/src/manager/manager8.c b/src/manager/horizontalMinishPathBackgroundManager.c similarity index 79% rename from src/manager/manager8.c rename to src/manager/horizontalMinishPathBackgroundManager.c index 9e8ecc50..b5fbf6d6 100644 --- a/src/manager/manager8.c +++ b/src/manager/horizontalMinishPathBackgroundManager.c @@ -1,46 +1,42 @@ -#include "manager.h" -#include "screen.h" -#include "functions.h" +/** + * @file horizontalMinishPathBackgroundManager.c + * @ingroup Managers + * + * @brief Parallax scrolling for horizontal MinishPaths + */ +#include "manager/horizontalMinishPathBackgroundManager.h" #include "common.h" +#include "functions.h" +#include "screen.h" -typedef struct { - Manager manager; - u8 unk_20; - u8 unk_21[0x17]; - u32 unk_38; - u32 unk_3c; -} Manager8; - -void sub_08057F20(Manager8*); +void sub_08057F20(HorizontalMinishPathBackgroundManager*); void sub_08057EFC(void*); void sub_08058034(void); void sub_08058084(u16*, u16*); +void sub_08058004(u32, void*, void*); +extern u8 gUnk_02006F00[]; extern u16 gMapDataTopSpecial[]; -void Manager8_Main(Manager8* this) { +void HorizontalMinishPathBackgroundManager_Main(HorizontalMinishPathBackgroundManager* this) { sub_08057F20(this); - if (!this->manager.action) { - this->manager.action = 1; + if (super->action == 0) { + super->action = 1; gScreen.bg1.updated = 0; gScreen.bg3.updated = 0; - RegisterTransitionManager(this, sub_08057EFC, 0); + RegisterTransitionManager(this, sub_08057EFC, NULL); } } void sub_08057EFC(void* this) { LoadGfxGroup((u32)gRoomVars.unk_10[0]); sub_08058034(); - ((Manager8*)this)->unk_3c = 0; - ((Manager8*)this)->unk_38 = 0; - sub_08057F20(((Manager8*)this)); + ((HorizontalMinishPathBackgroundManager*)this)->unk_3c = 0; + ((HorizontalMinishPathBackgroundManager*)this)->unk_38 = 0; + sub_08057F20(((HorizontalMinishPathBackgroundManager*)this)); } -void sub_08058004(u32, void*, void*); - -extern u8 gUnk_02006F00[]; - -void sub_08057F20(Manager8* this) { +void sub_08057F20(HorizontalMinishPathBackgroundManager* this) { u32 tmp; tmp = gRoomControls.scroll_x - gRoomControls.origin_x; tmp = tmp + (tmp >> 3) + ((0x400 - gRoomControls.width) / 2); @@ -104,12 +100,12 @@ void sub_08058084(u16* unk1, u16* unk2) { void sub_080580B0(u32 unk1) { s32 tmp; - gMapTop.bgControlPtr = 0; + gMapTop.bgSettings = 0; REG_DISPCNT = 0; LoadGfxGroup(unk1); gRoomVars.unk_10[0] = unk1; sub_08058034(); - tmp = gRoomControls.scroll_x - gRoomControls.origin_x; // r7 + tmp = gRoomControls.scroll_x - gRoomControls.origin_x; tmp = tmp + (tmp >> 3) + (0x400 - gRoomControls.width) / 2; sub_08058004(tmp, gUnk_02006F00, gBG3Buffer); gScreen.bg3.xOffset = tmp & 0xF; @@ -117,7 +113,7 @@ void sub_080580B0(u32 unk1) { gScreen.bg3.control = 0x1D09; gScreen.bg3.tilemap = gBG3Buffer; gScreen.bg3.updated = 1; - tmp = gRoomControls.scroll_x - gRoomControls.origin_x; // r7 + tmp = gRoomControls.scroll_x - gRoomControls.origin_x; tmp = tmp + (tmp >> 2) + (0x400 - gRoomControls.width) / 2; sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x400); gScreen.bg1.xOffset = tmp & 0xF; diff --git a/src/manager/manager13.c b/src/manager/houseSignManager.c similarity index 83% rename from src/manager/manager13.c rename to src/manager/houseSignManager.c index 142a0801..1f5b3ff5 100644 --- a/src/manager/manager13.c +++ b/src/manager/houseSignManager.c @@ -1,12 +1,16 @@ +/** + * @file houseSignManager.c + * @ingroup Managers + * + * @brief Keeps track in its bitfield of whether 0x10 x 0x10 rects at certain positions are on the screen. + * + * Spawns OBJECT_1C objects that check this and unsets the value in the bitfield. + * Creates the signs on the houses in hyrule town. + */ +#include "manager/houseSignManager.h" #include "area.h" -#include "manager.h" -#include "room.h" #include "object.h" - -typedef struct { - Manager manager; - u32 bitfield; -} Manager13; +#include "room.h" typedef struct { u16 x; @@ -19,11 +23,7 @@ typedef struct { extern u32 CheckRectOnScreen(u16, u16, u32, u32); -/* -Keeps track in its bitfield of whether 0x10 x 0x10 rects at certain positions are on the screen. -Spawns OBJECT_1C objects that check this and unsets the value in the bitfield. -*/ -void Manager13_Main(Manager13* this) { +void HouseSignManager_Main(HouseSignManager* this) { static const SpawnData gUnk_081084C8[] = { { 0x48, 0x90, 0x0, 0x0, 0x2, 0x0 }, { 0x138, 0x30, 0x1, 0x1, 0x2, 0x0 }, { 0x168, 0x90, 0x2, 0x2, 0x2, 0x0 }, { 0x2c8, 0x80, 0x3, 0x3, 0x2, 0x0 }, @@ -44,8 +44,8 @@ void Manager13_Main(Manager13* this) { const SpawnData* spawnData; u32 type2; - if (this->manager.action == 0) { - this->manager.action = 1; + if (super->action == 0) { + super->action = 1; } if (gRoomControls.area == AREA_FESTIVAL_TOWN) { spawnData = gUnk_08108530; @@ -69,7 +69,7 @@ void Manager13_Main(Manager13* this) { this->bitfield |= bitfieldFlag; } } - spawnData += 1; - type2 += 1; + spawnData++; + type2++; } } diff --git a/src/manager/manager33.c b/src/manager/hyruleTownBellManager.c similarity index 68% rename from src/manager/manager33.c rename to src/manager/hyruleTownBellManager.c index de58fb00..b271053b 100644 --- a/src/manager/manager33.c +++ b/src/manager/hyruleTownBellManager.c @@ -1,23 +1,29 @@ -#include "manager.h" -#include "room.h" -#include "player.h" -#include "sound.h" +/** + * @file hyruleTownBellManager.c + * @ingroup Managers + * + * @brief Spawns the heart piece if the player jumps against the bell in Hyrule Town. + */ +#include "manager/hyruleTownBellManager.h" #include "object.h" +#include "player.h" +#include "room.h" +#include "sound.h" -void Manager33_Main(Manager* this) { +void HyruleTownBellManager_Main(HyruleTownBellManager* this) { RoomControls* roomControls = &gRoomControls; u32 a = roomControls->origin_x + 0x1f8; u32 x = (a - gPlayerEntity.x.HALF.HI) + 0x10; u32 b = roomControls->origin_y + 0x140; u32 y = (b - gPlayerEntity.y.HALF.HI) + 0x10; - if (this->action == 0) { + if (super->action == 0) { if (x < 0x20 && y < 0x20 && gPlayerEntity.z.HALF.HI < -0x18 && gPlayerState.framestate == PL_STATE_CAPE) { - this->action += 1; - this->unk_0e = 0x5a; + super->action++; + super->timer = 0x5a; SoundReq(SFX_10A); } } else { - if (--this->unk_0e == 0) { + if (--super->timer == 0) { Entity* object = CreateObject(OBJECT_96, 1, 0); if (object != NULL) { object->x.HALF.HI = roomControls->origin_x + 0x1f8; diff --git a/src/manager/manager12.c b/src/manager/hyruleTownTilesetManager.c similarity index 90% rename from src/manager/manager12.c rename to src/manager/hyruleTownTilesetManager.c index 0f947039..308204f0 100644 --- a/src/manager/manager12.c +++ b/src/manager/hyruleTownTilesetManager.c @@ -1,20 +1,19 @@ +/** + * @file hyruleTownTilesetManager.c + * @ingroup Managers + * + * @brief Swap tileset data in hyrule town depending on the position. + */ +#include "manager/hyruleTownTilesetManager.h" #include "area.h" #include "asm.h" -#include "manager.h" -#include "room.h" -#include "functions.h" #include "flags.h" +#include "functions.h" +#include "main.h" +#include "room.h" -typedef struct { - Manager manager; - u8 field_0x20; - u8 field_0x21; - u8 field_0x22; -} Manager12; - -void sub_08059A58(Manager12*); -void sub_08059A2C(Manager12*); -u32 CheckRegionsOnScreen(const u16* arr); +void sub_08059A58(HyruleTownTilesetManager*); +void sub_08059A2C(HyruleTownTilesetManager*); static const u16 gUnk_08108398[] = { 0x0, 0x0, 0x0, 0x3f0, 0x200, 0x1, 0x0, 0x280, 0x3f0, 0x140, 0xff }; static const u16 gUnk_081083AE[] = { 0x2, 0x0, 0x0, 0x180, 0x3c0, 0x3, 0x280, 0x0, 0x170, 0x3c0, 0xff }; @@ -25,7 +24,7 @@ static const u16 gUnk_081083F2[] = { 0x5, 0x0, 0x1b0, 0x190, 0x140, 0x4, 0x0, 0x void sub_08059CC0(u32, u32); void sub_08059B18(void); -bool32 sub_08059C8C(Manager12*, u32, u8*, const u16*); +bool32 sub_08059C8C(HyruleTownTilesetManager*, u32, u8*, const u16*); extern u32 gUnk_086E8460; @@ -60,9 +59,9 @@ static const Unknown gUnk_08108468[] = { }; extern const u8 gGlobalGfxAndPalettes[]; -void Manager12_Main(Manager12* this) { - if (this->manager.action == 0) { - this->manager.action = 1; +void HyruleTownTilesetManager_Main(HyruleTownTilesetManager* this) { + if (super->action == 0) { + super->action = 1; this->field_0x22 = 0xff; this->field_0x21 = 0xff; this->field_0x20 = 0xff; @@ -72,7 +71,7 @@ void Manager12_Main(Manager12* this) { sub_08059A58(this); } -void sub_08059A2C(Manager12* this) { +void sub_08059A2C(HyruleTownTilesetManager* this) { gRoomVars.unk_10[2] = 0xff; gRoomVars.unk_10[1] = 0xff; gRoomVars.unk_10[0] = 0xff; @@ -82,7 +81,7 @@ void sub_08059A2C(Manager12* this) { sub_08059A58(this); } -void sub_08059A58(Manager12* this) { +void sub_08059A58(HyruleTownTilesetManager* this) { if (gRoomControls.area != AREA_FESTIVAL_TOWN) { if (sub_08059C8C(this, 0, &this->field_0x20, gUnk_08108398) != 0) { sub_08059CC0(0, (u32)this->field_0x20); @@ -144,7 +143,7 @@ void sub_08059B18(void) { } } -bool32 sub_08059C8C(Manager12* this, u32 param_2, u8* param_3, const u16* param_4) { +bool32 sub_08059C8C(HyruleTownTilesetManager* this, u32 param_2, u8* param_3, const u16* param_4) { bool32 bVar2; *param_3 = CheckRegionsOnScreen(param_4); diff --git a/src/manager/manager23.c b/src/manager/lightLevelSetManager.c similarity index 50% rename from src/manager/manager23.c rename to src/manager/lightLevelSetManager.c index 7defd96a..8bb54507 100644 --- a/src/manager/manager23.c +++ b/src/manager/lightLevelSetManager.c @@ -1,133 +1,124 @@ - -#include "manager.h" -#include "room.h" -#include "functions.h" +/** + * @file lightLevelSetManager.c + * @ingroup Managers + * + * @brief Changes the light level when a flag is set. + */ +#include "manager/lightLevelSetManager.h" #include "flags.h" -#include "object.h" +#include "functions.h" #include "game.h" +#include "object.h" +#include "room.h" -typedef struct { - Manager manager; - u16 field_0x20; - u16 field_0x22; - u8 field_0x24[0x12]; - u8 field_0x36; - u8 field_0x37; - u16 field_0x38; - u16 field_0x3a; - u16 field_0x3c; - u16 field_0x3e; -} Manager23; +void sub_0805BE94(LightLevelSetManager*); +void sub_0805BEC4(LightLevelSetManager*); +void LightLevelSetManager_Type0(LightLevelSetManager*); +void LightLevelSetManager_Type1(LightLevelSetManager*); +void LightLevelSetManager_Type2(LightLevelSetManager*); +void LightLevelSetManager_Type3(LightLevelSetManager*); +void sub_0805BE70(LightLevelSetManager*, u32); -void sub_0805BE94(Manager23*); -void sub_0805BEC4(Manager23*); -void sub_0805BC8C(Manager23*); -void sub_0805BCD4(Manager23*); -void sub_0805BD5C(Manager23*); -void sub_0805BDB4(Manager23*); - -void sub_0805BE70(Manager23*, u32); - -void Manager23_Main(Manager* this) { - static void (*const gUnk_08108CCC[])(Manager23*) = { - sub_0805BC8C, - sub_0805BCD4, - sub_0805BD5C, - sub_0805BDB4, +void LightLevelSetManager_Main(Manager* this) { + static void (*const LightLevelSetManager_Types[])(LightLevelSetManager*) = { + LightLevelSetManager_Type0, + LightLevelSetManager_Type1, + LightLevelSetManager_Type2, + LightLevelSetManager_Type3, }; - gUnk_08108CCC[this->unk_0a]((Manager23*)this); + LightLevelSetManager_Types[this->type]((LightLevelSetManager*)this); } -void sub_0805BC8C(Manager23* this) { - if (this->manager.action == 0) { - this->manager.action = 1; - this->manager.unk_0f = 0x1e; +void LightLevelSetManager_Type0(LightLevelSetManager* this) { + if (super->action == 0) { + super->action = 1; + super->subtimer = 0x1e; if (CheckFlags(this->field_0x3e) != 0) { sub_0805BE94(this); } } - if ((CheckFlags(this->field_0x3e) != 0) && (--this->manager.unk_0f == 0)) { + if ((CheckFlags(this->field_0x3e) != 0) && (--super->subtimer == 0)) { sub_0805BEC4(this); sub_0805BE94(this); } } -void sub_0805BCD4(Manager23* this) { - switch (this->manager.action) { +void LightLevelSetManager_Type1(LightLevelSetManager* this) { + switch (super->action) { case 0: - this->manager.action = 1; - this->manager.unk_0f = 0x1e; + super->action = 1; + super->subtimer = 0x1e; if (CheckFlags(this->field_0x3e) != 0) { sub_0805BE70(this, 0x75); - this->manager.action = 2; + super->action = 2; } break; case 1: - if (CheckFlags(this->field_0x3e) != 0 && --this->manager.unk_0f == 0) { - this->manager.unk_0f = 0x1e; + if (CheckFlags(this->field_0x3e) != 0 && --super->subtimer == 0) { + super->subtimer = 0x1e; sub_0805BEC4(this); sub_0805BE70(this, 0x76); } break; case 2: - if (CheckFlags(this->field_0x3e) == 0 && --this->manager.unk_0f == 0) { - this->manager.unk_0f = 0x1e; + if (CheckFlags(this->field_0x3e) == 0 && --super->subtimer == 0) { + super->subtimer = 0x1e; sub_0805BE70(this, 0x75); } break; } } -void sub_0805BD5C(Manager23* this) { - if (this->manager.action == 0) { +void LightLevelSetManager_Type2(LightLevelSetManager* this) { + if (super->action == 0) { if (CheckFlags(this->field_0x3e) != 0) { sub_0805BE94(this); } this->field_0x20 = ((s16)this->field_0x38 >> 4 & 0x3fU) | ((s32)((this->field_0x3a << 0x10) >> 0x14 & 0x3fU) << 6); - this->manager.action = 1; + super->action = 1; } else { - if (GetTileType(this->field_0x20, this->manager.unk_0b) == 0x76) { + if (GetTileType(this->field_0x20, super->type2) == 0x76) { SetFlag(this->field_0x3e); - ChangeLightLevel(this->manager.unk_0e); + ChangeLightLevel(super->timer); DeleteThisEntity(); } } } -void sub_0805BDB4(Manager23* this) { +void LightLevelSetManager_Type3(LightLevelSetManager* this) { u8 bVar1; u16 uVar2; u32 uVar3; - switch (this->manager.action) { + switch (super->action) { case 0: if (CheckFlags(this->field_0x3e) != 0 || CheckFlags(this->field_0x3c) != 0) { sub_0805BE94(this); } this->field_0x20 = ((s16)this->field_0x38 >> 4 & 0x3fU) | (((s32)(this->field_0x3a << 0x10) >> 0x14 & 0x3fU) << 6); - this->manager.action = 1; + super->action = 1; break; case 1: - if (GetTileType(this->field_0x20, this->manager.unk_0b) != 0x76) { + if (GetTileType(this->field_0x20, super->type2) != 0x76) { return; } SetFlag(this->field_0x3e); - ChangeLightLevel(this->manager.unk_0e); - this->manager.action = 2; + ChangeLightLevel(super->timer); + super->action = 2; this->field_0x22 = this->field_0x36 * 0x3c; return; break; default: if (--this->field_0x22 == 0) { - CreateDustAt(*(s16*)&this->field_0x38, *(s16*)&this->field_0x3a, this->manager.unk_0b); + CreateDustAt(*(s16*)&this->field_0x38, *(s16*)&this->field_0x3a, super->type2); ClearFlag(this->field_0x3e); - RestorePrevTileEntity(this->field_0x20, this->manager.unk_0b); - ChangeLightLevel(-this->manager.unk_0e); - this->manager.action = 1; + RestorePrevTileEntity(this->field_0x20, super->type2); + ChangeLightLevel(-super->timer); + super->action = 1; } else { if (CheckFlags(this->field_0x3c) == 0) { return; @@ -139,26 +130,26 @@ void sub_0805BDB4(Manager23* this) { } } -void sub_0805BE70(Manager23* this, u32 param_2) { +void sub_0805BE70(LightLevelSetManager* this, u32 param_2) { SetTileType(param_2, ((this->field_0x38 << 0x10) >> 0x14 & 0x3fU) | ((this->field_0x3a << 0x10) >> 0x14 & 0x3fU) << 6, - this->manager.unk_0b); + super->type2); } -void sub_0805BE94(Manager23* this) { +void sub_0805BE94(LightLevelSetManager* this) { SetTileType(0x76, ((this->field_0x38 << 0x10) >> 0x14 & 0x3fU) | ((this->field_0x3a << 0x10) >> 0x14 & 0x3fU) << 6, - this->manager.unk_0b); - ChangeLightLevel(this->manager.unk_0e); + super->type2); + ChangeLightLevel(super->timer); DeleteThisEntity(); } -void sub_0805BEC4(Manager23* this) { +void sub_0805BEC4(LightLevelSetManager* this) { Entity* object = CreateObject(OBJECT_2A, 1, 0); if (object != NULL) { *(s8*)(&object->flags + 1) = ((*(s8*)(&object->flags + 1)) & (-0x10)) | 3; object->x.HALF.HI = this->field_0x38 + gRoomControls.origin_x; object->y.HALF.HI = this->field_0x3a + gRoomControls.origin_y; - object->collisionLayer = this->manager.unk_0b; + object->collisionLayer = super->type2; object->spritePriority.b0 = 2; } } diff --git a/src/manager/manager22.c b/src/manager/lightManager.c similarity index 84% rename from src/manager/manager22.c rename to src/manager/lightManager.c index 9f456551..89617f3e 100644 --- a/src/manager/manager22.c +++ b/src/manager/lightManager.c @@ -1,29 +1,29 @@ - -#include "manager.h" +/** + * @file lightManager.c + * @ingroup Managers + * + * @brief Manages the light in dark rooms. + */ +#include "manager/lightManager.h" #include "area.h" +#include "common.h" +#include "functions.h" +#include "game.h" #include "main.h" -#include "screen.h" +#include "physics.h" #include "player.h" #include "room.h" -#include "physics.h" -#include "functions.h" -#include "common.h" -#include "game.h" - -typedef struct { - Manager manager; - s32 unk20; -} Manager22; +#include "screen.h" extern void sub_0801E120(void); extern void sub_0801E154(u32); extern u32 CheckRectOnScreen(s32, s32, u32, u32); extern void sub_0801E160(u32, u32, u32); -u32 sub_0805BA78(); +bool32 sub_0805BA78(); void sub_0805BAD4(); -void Manager22_Main(Manager22* this) { +void LightManager_Main(LightManager* this) { s32 sVar1; u32 uVar3; @@ -32,14 +32,14 @@ void Manager22_Main(Manager22* this) { gScreen.lcd.displayControl &= ~(DISPCNT_BG3_ON | DISPCNT_WIN0_ON); DeleteThisEntity(); } - if (this->manager.action == 0) { - this->manager.action = 1; - this->manager.unk_10 |= 0x20; - this->manager.unk_0e = 17; + if (super->action == 0) { + super->action = 1; + super->flags |= ENT_PERSIST; + super->timer = 17; this->unk20 = 0; SetDefaultPriority((Entity*)this, 6); sub_0801E120(); - sub_0801E154(this->manager.unk_0e); + sub_0801E154(super->timer); } if (gMain.substate == GAMEMAIN_UPDATE) { gScreen.lcd.displayControl |= DISPCNT_BG3_ON; @@ -55,15 +55,15 @@ void Manager22_Main(Manager22* this) { } else { gScreen.lcd.displayControl &= ~DISPCNT_WIN0_ON; } - uVar3 = this->manager.unk_0e; + uVar3 = super->timer; if (((gPlayerState.flags & PL_USE_LANTERN)) && (gArea.lightType)) { if (uVar3 < 0x48) { uVar3 += 4; sub_0801E154(uVar3); this->unk20 = 0; } else if ((gRoomTransition.frameCount & 3) == 0) { - this->manager.unk_0f += 0x10; - sVar1 = gSineTable[this->manager.unk_0f]; + super->subtimer += 0x10; + sVar1 = gSineTable[super->subtimer]; this->unk20 = sVar1 >> 7; sub_0801E154(uVar3 + this->unk20); } @@ -78,7 +78,7 @@ void Manager22_Main(Manager22* this) { } } - this->manager.unk_0e = uVar3; + super->timer = uVar3; sub_0801E160(gPlayerEntity.x.HALF.HI - gRoomControls.scroll_x, gPlayerEntity.y.HALF.HI - gRoomControls.scroll_y - 9 + gPlayerEntity.z.HALF.HI, uVar3 + this->unk20); @@ -87,7 +87,7 @@ void Manager22_Main(Manager22* this) { #define ABS(x) ((unsigned)(x < 0 ? -(x) : x)) -u32 sub_0805BA78() { +bool32 sub_0805BA78() { u32 uVar1; s32 iVar1; s32 iVar2; @@ -117,9 +117,9 @@ u32 sub_0805BA78() { } gArea.lightLevel = iVar2; } else { - return 0; + return FALSE; } - return 1; + return TRUE; } extern u16 gUnk_08108CA8[]; @@ -136,8 +136,8 @@ void sub_0805BB00(s32 lightLevel, s32 param_2) { if (gArea.lightType == 0) { Manager* pManager = GetEmptyManager(); if (pManager != 0) { - pManager->type = 9; - pManager->subtype = 34; + pManager->kind = MANAGER; + pManager->id = LIGHT_MANAGER; AppendEntityToList((Entity*)pManager, 0); } } @@ -153,26 +153,26 @@ void sub_0805BB00(s32 lightLevel, s32 param_2) { } void sub_0805BB74(s32 lightLevel) { - Manager22* manager; + LightManager* manager; if (lightLevel < 0) { lightLevel = gRoomVars.lightLevel; } gArea.lightLevel = lightLevel; gRoomVars.lightLevel = gArea.lightLevel; - manager = (Manager22*)DeepFindEntityByID(MANAGER, 0x22); + manager = (LightManager*)DeepFindEntityByID(MANAGER, LIGHT_MANAGER); if (manager) { - Manager22_Main(manager); + LightManager_Main(manager); gScreen.lcd.displayControl |= DISPCNT_BG3_ON; sub_0805BA78(); sub_0805BAD4(); } } -s32 UpdateLightLevel() { - s32 iVar1; +bool32 UpdateLightLevel() { + bool32 iVar1; - iVar1 = 0; + iVar1 = FALSE; if (gArea.lightType && gRoomVars.lightLevel < (s16)gArea.lightLevel) { gScreen.lcd.displayControl |= DISPCNT_BG3_ON; iVar1 = sub_0805BA78(); diff --git a/src/manager/manager1.c b/src/manager/lightRayManager.c similarity index 50% rename from src/manager/manager1.c rename to src/manager/lightRayManager.c index 8de090f6..a738f620 100644 --- a/src/manager/manager1.c +++ b/src/manager/lightRayManager.c @@ -1,17 +1,25 @@ -#include "global.h" -#include "entity.h" -#include "screen.h" -#include "functions.h" +/** + * @file lightRayManager.c + * @ingroup Managers + * + * @brief Creates and updates light rays. + * + * Light rays at the left of minish woods + * Light rays in the barrel minish house + */ +#include "manager/lightRayManager.h" #include "common.h" +#include "functions.h" #include "main.h" +#include "screen.h" extern void sub_08056250(void); -void (*const gUnk_08107C5C[])(Entity*); -void (*const gUnk_08107C48[])(Entity*); +void (*const gUnk_08107C5C[])(LightRayManager*); +void (*const gUnk_08107C48[])(LightRayManager*); const u16 gUnk_08107C1C[]; const u16 gUnk_08107C30[]; -const u8 gManager1GfxGroups[]; +const u8 gLightRayManagerGfxGroups[]; extern u16 gUnk_02017AA0[]; extern u16 gUnk_085B4180[]; @@ -22,30 +30,29 @@ typedef struct { u8 unk2; u8 unk3; u8 unk4; -} PACKED Manager1Prop; +} PACKED LightRayManagerProp; -#define ZV(this) ((u8*)&this->zVelocity) #define ZS(this) ((u8*)&this->speed) -void Manager1_Main(Entity* this) { +void LightRayManager_Main(LightRayManager* this) { u8 bVar1; u8* pbVar2; - gUnk_08107C5C[this->action](this); - gUnk_08107C48[ZV(this)[1]](this); - bVar1 = gManager1GfxGroups[ZV(this)[1]]; - if ((bVar1 != 0) && (ZV(this)[0] != bVar1)) { - ZV(this)[0] = bVar1; + gUnk_08107C5C[super->action](this); + gUnk_08107C48[this->unk_21](this); + bVar1 = gLightRayManagerGfxGroups[this->unk_21]; + if ((bVar1 != 0) && (this->unk_20 != bVar1)) { + this->unk_20 = bVar1; LoadGfxGroup(bVar1); } } -static void sub_080570B8(Entity* this) { +static void sub_080570B8(LightRayManager* this) { u8* pbVar1; - LoadGfxGroup(ZV(this)[0]); - this->z.WORD = 0; - pbVar1 = &ZV(this)[1]; + LoadGfxGroup(this->unk_20); + this->unk_34 = NULL; + pbVar1 = &this->unk_21; if (*pbVar1 == 3) { gScreen.bg3.updated = 1; } else { @@ -59,12 +66,12 @@ static void sub_080570F8(void) { sub_08056250(); } -void sub_08057118(Entity* this) { - this->timer = 0; - ZV(this)[0] = 0; - ZV(this)[1] = 0; - ZV(this)[2] = 0; - this->action = 1; +void sub_08057118(LightRayManager* this) { + super->timer = 0; + this->unk_20 = 0; + this->unk_21 = 0; + this->unk_22 = 0; + super->action = 1; gScreen.bg3.control = 0x1e04; gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.controls.layerFXControl = 0x3648; @@ -73,8 +80,8 @@ void sub_08057118(Entity* this) { } // regalloc -NONMATCH("asm/non_matching/manager1/sub_08057174.inc", void sub_08057174(Entity* this)) { - Manager1Prop* prop = GetCurrentRoomProperty(this->type); +NONMATCH("asm/non_matching/lightRayManager/sub_08057174.inc", void sub_08057174(LightRayManager* this)) { + LightRayManagerProp* prop = GetCurrentRoomProperty(super->type); s32 temp; s32 x; s32 y; @@ -95,56 +102,56 @@ NONMATCH("asm/non_matching/manager1/sub_08057174.inc", void sub_08057174(Entity* y = temp >> 4; for (; prop->unk0 != 0xff; prop++) { - if (prop->unk0 != ZV(this)[1]) { + if (prop->unk0 != this->unk_21) { u32 x2 = (gRoomControls.origin_x >> 4) + prop->unk1; u32 y2 = (gRoomControls.origin_y >> 4) + prop->unk2; if (y - y2 < prop->unk4 && x - x2 < prop->unk3) { switch (prop->unk0) { case 1: - if (ZV(this)[1] == 2) { - this->action = 3; - this->timer = 9; + if (this->unk_21 == 2) { + super->action = 3; + super->timer = 9; } break; case 5: - if (ZV(this)[1] == 6) { - this->action = 3; - this->timer = 9; + if (this->unk_21 == 6) { + super->action = 3; + super->timer = 9; } break; case 2: - if (ZV(this)[1] == 0) { - this->action = 2; - this->timer = 0; - ZV(this)[0] = 0; + if (this->unk_21 == 0) { + super->action = 2; + super->timer = 0; + this->unk_20 = 0; } break; case 6: - if (ZV(this)[1] == 0) { - this->action = 2; - this->timer = 0; + if (this->unk_21 == 0) { + super->action = 2; + super->timer = 0; } break; case 4: - if (ZV(this)[1] == 0) { - this->action = 2; - this->timer = 0; - this->z.WORD = 0; + if (this->unk_21 == 0) { + super->action = 2; + super->timer = 0; + this->unk_34 = NULL; } break; case 3: - if (ZV(this)[1] == 4) { - this->action = 3; - this->timer = 9; + if (this->unk_21 == 4) { + super->action = 3; + super->timer = 9; } break; } - if (this->action != 1) { - this->subtimer = 8; - ZV(this)[1] = prop->unk0; - ZV(this)[2] = 1; + if (super->action != 1) { + super->subtimer = 8; + this->unk_21 = prop->unk0; + this->unk_22 = 1; return; } } @@ -153,27 +160,27 @@ NONMATCH("asm/non_matching/manager1/sub_08057174.inc", void sub_08057174(Entity* } END_NONMATCH -void sub_0805728C(Entity* this) { - if (--this->subtimer == 0) { - this->subtimer = 8; - gScreen.controls.alphaBlend = gUnk_08107C1C[this->timer++]; +void sub_0805728C(LightRayManager* this) { + if (--super->subtimer == 0) { + super->subtimer = 8; + gScreen.controls.alphaBlend = gUnk_08107C1C[super->timer++]; - if (this->timer == 10) { - this->action = 1; - ZV(this)[2] = 0; + if (super->timer == 10) { + super->action = 1; + this->unk_22 = 0; } } } -void sub_080572D4(Entity* this) { - if (--this->subtimer == 0) { - this->subtimer = 8; - gScreen.controls.alphaBlend = gUnk_08107C1C[this->timer--]; +void sub_080572D4(LightRayManager* this) { + if (--super->subtimer == 0) { + super->subtimer = 8; + gScreen.controls.alphaBlend = gUnk_08107C1C[super->timer--]; - if (this->timer == 0xff) { - this->action = 1; - ZV(this)[2] = 0; - ZV(this)[1] = 0; + if (super->timer == 0xff) { + super->action = 1; + this->unk_22 = 0; + this->unk_21 = 0; gScreen._6c = 0; } } @@ -181,19 +188,19 @@ void sub_080572D4(Entity* this) { void sub_0805732C(u32 param_1, u32 param_2) { u32 index; - u16* ptr = &gUnk_02017AA0[gUnk_03003DE4 * 0x500]; + u16* ptr = &gUnk_02017AA0[gUnk_03003DE4[0] * 0x500]; for (index = 0; index < 0xa0; ptr++, index++) { *ptr = gSineTable[(param_2 + index) & 0xff] * param_1 / 0x100 + gScreen.bg3.xOffset; } - sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4 * 0x500], REG_ADDR_BG3HOFS, 0xa2600001UL); + sub_0805622C((struct BgAffineDstData*)&gUnk_02017AA0[gUnk_03003DE4[0] * 0x500], REG_ADDR_BG3HOFS, 0xa2600001UL); } void nullsub_494() { } -void sub_080573AC(Entity* this) { +void sub_080573AC(LightRayManager* this) { s32 sin, frameCount; gRoomControls.bg3OffsetX.WORD -= 0x2000; gRoomControls.bg3OffsetY.WORD -= 0x1000; @@ -201,15 +208,15 @@ void sub_080573AC(Entity* this) { gScreen.bg3.yOffset = ((gRoomControls.scroll_y - gRoomControls.origin_y) >> 1) + gRoomControls.bg3OffsetY.HALF.HI; sin = gSineTable[(gRoomTransition.frameCount & 0xff) + 0x40]; sub_0805732C((sin >> 5) + 0x10, gRoomTransition.frameCount); - if (ZV(this)[2] == 0) { + if (this->unk_22 == 0) { if ((gRoomTransition.frameCount & 0x1f) == 0) { - ZS(this)[0] = (ZS(this)[0] + 1) & 7; - gScreen.controls.alphaBlend = gUnk_08107C30[ZS(this)[0]]; + this->unk_24 = (this->unk_24 + 1) & 7; + gScreen.controls.alphaBlend = gUnk_08107C30[this->unk_24]; } } } -void sub_08057450(Entity* this) { +void sub_08057450(LightRayManager* this) { s32 y; gScreen.bg3.xOffset = 0x10; y = gRoomControls.scroll_y; @@ -218,26 +225,26 @@ void sub_08057450(Entity* this) { gScreen.bg3.yOffset = y & 0x3f; gScreen.bg3.tilemap = &gBG3Buffer[(y / 0x40) << 8]; - if ((void*)this->z.WORD != gScreen.bg3.tilemap) { - this->z.WORD = (u32)gScreen.bg3.tilemap; + if (this->unk_34 != gScreen.bg3.tilemap) { + this->unk_34 = gScreen.bg3.tilemap; gScreen.bg3.updated = 1; } - if (ZV(this)[2] == 0 && (gRoomTransition.frameCount & 0x1f) == 0) { - ZS(this)[0] = (ZS(this)[0] + 1) & 7; - gScreen.controls.alphaBlend = gUnk_08107C30[ZS(this)[0]]; + if (this->unk_22 == 0 && (gRoomTransition.frameCount & 0x1f) == 0) { + this->unk_24 = (this->unk_24 + 1) & 7; + gScreen.controls.alphaBlend = gUnk_08107C30[this->unk_24]; } if ((gRoomTransition.frameCount & 0x7) == 0) { u32 index; - u16* ptr = &gUnk_085B4180[(ZV(this)[3] << 4)]; + u16* ptr = &gUnk_085B4180[(this->unk_23 << 4)]; for (index = 0, ptr = ptr + 7; index <= 3; index++) { SetColor(index + 0x87, *(ptr + index)); SetColor(index + 0x8c, *(ptr + index + 5)); } - ZV(this)[3] = (ZV(this)[3] + 1) & 3; + this->unk_23 = (this->unk_23 + 1) & 3; } } @@ -249,15 +256,15 @@ const u16 gUnk_08107C30[] = { 0x909, 0xA08, 0xB07, 0xC06, 0xD05, 0xC06, 0xB07, 0xA08, }; -const u8 gManager1GfxGroups[] = { +const u8 gLightRayManagerGfxGroups[] = { 0x25, 0x00, 0x24, 0x00, 0x25, 0x00, 0x00, 0x00, }; -void (*const gUnk_08107C48[])(Entity*) = { +void (*const gUnk_08107C48[])(LightRayManager*) = { nullsub_494, nullsub_494, sub_080573AC, nullsub_494, sub_08057450, }; -void (*const gUnk_08107C5C[])(Entity*) = { +void (*const gUnk_08107C5C[])(LightRayManager*) = { sub_08057118, sub_08057174, sub_0805728C, diff --git a/src/manager/manager11.c b/src/manager/manager11.c deleted file mode 100644 index 28cbfab9..00000000 --- a/src/manager/manager11.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "manager.h" -#include "flags.h" - -void Manager11_Main(Manager11* this) { - if (!this->manager.action) { - this->manager.action = 1; - if (CheckFlags(this->unk_3c)) { - DeleteThisEntity(); - } - } else { - if (CheckFlags(this->unk_3e)) { - SetFlag(this->unk_3c); - DeleteThisEntity(); - } - } -} diff --git a/src/manager/manager16.c b/src/manager/manager16.c deleted file mode 100644 index 03450bad..00000000 --- a/src/manager/manager16.c +++ /dev/null @@ -1,6 +0,0 @@ - -#include "manager.h" - -ASM_FUNC("asm/non_matching/manager16/Manager16_Main.inc", void Manager16_Main()) - -ASM_FUNC("asm/non_matching/manager16/sub_0805ACC0.inc", u32 sub_0805ACC0(Entity* ent)) diff --git a/src/manager/manager17.c b/src/manager/manager17.c deleted file mode 100644 index 61cbacd6..00000000 --- a/src/manager/manager17.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "manager.h" -#include "flags.h" -#include "room.h" -#include "object.h" - -typedef struct { - Manager manager; - u8 field_0x20[0x15]; - u8 field_0x35; - u8 field_0x36; - u8 field_0x37; - s16 field_0x38; - s16 field_0x3a; - u16 field_0x3c; - u16 field_0x3e; -} Manager17; - -void sub_0805AD60(Manager17*); -void sub_0805AD80(Manager17*); - -void Manager17_Main(Manager17* manager) { - static void (*const actionFuncs[])(Manager17*) = { - sub_0805AD60, - sub_0805AD80, - }; - actionFuncs[manager->manager.action](manager); -} - -void sub_0805AD60(Manager17* manager) { - manager->manager.action = 1; - if (CheckFlags(manager->field_0x3c) != 0) { - DeleteThisEntity(); - } - sub_0805AD80(manager); -} - -void sub_0805AD80(Manager17* manager) { - if (CheckFlags(manager->field_0x3e) != 0) { - Entity* object = CreateObject(GROUND_ITEM, manager->manager.unk_0a, manager->manager.unk_0b); - if (object != NULL) { - object->timer = manager->field_0x35; - object->collisionLayer = manager->field_0x36; - object->x.HALF.HI = manager->field_0x38 + gRoomControls.origin_x; - object->y.HALF.HI = manager->field_0x3a + gRoomControls.origin_y; - object->field_0x86.HWORD = manager->field_0x3c; - } - DeleteThisEntity(); - } -} diff --git a/src/manager/manager1C.c b/src/manager/manager1C.c deleted file mode 100644 index 5651f93f..00000000 --- a/src/manager/manager1C.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "manager.h" -#include "asm.h" -#include "room.h" -#include "enemy.h" - -void sub_0805B554(Manager*); -void sub_0805B55C(Manager*); - -void Manager1C_Main(Manager* manager) { - static void (*const actionFuncs[])(Manager*) = { - sub_0805B554, - sub_0805B55C, - }; - actionFuncs[manager->action](manager); -} - -// Initial setup -void sub_0805B554(Manager* manager) { - manager->action = 1; - manager->unk_0e = 1; -} - -// Spawn water drops every 0xf frames -void sub_0805B55C(Manager* manager) { - static const s16 gUnk_08108C6C[] = { -0x64, -0x3c, -0x14, 0x14, 0x3c, 0x64, 0x8c, 0xb4 }; - static const s8 gUnk_08108C7C[] = { -0x32, -0x19, 0x0, 0x19 }; - - if (--manager->unk_0e == 0) { - Entity* waterDrop; - manager->unk_0e = 0xf; - waterDrop = CreateEnemy(WATER_DROP, 0); - if (waterDrop != NULL) { - waterDrop->x.HALF.HI = gRoomControls.scroll_x + 0x78 + gUnk_08108C6C[Random() & 7]; - waterDrop->y.HALF.HI = gRoomControls.scroll_y + 0x50 + gUnk_08108C7C[Random() & 3]; - waterDrop->z.HALF.HI = 0xff38; - } - } -} diff --git a/src/manager/manager1D.c b/src/manager/manager1D.c deleted file mode 100644 index 7d74ef45..00000000 --- a/src/manager/manager1D.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "manager.h" -#include "room.h" -#include "screen.h" - -void sub_0805B5E0(Manager*); -void sub_0805B638(Manager*); - -void Manager1D_Main(Manager* this) { - static void (*const actionFuncs[])(Manager*) = { - sub_0805B5E0, - sub_0805B638, - }; - actionFuncs[this->action](this); -} - -void sub_0805B5E0(Manager* this) { - static const u16 gUnk_08108C88[] = { 0x1e07, 0x1e07 }; - this->action = 1; - - gScreen.lcd.displayControl |= DISPCNT_BG3_ON; - gScreen.bg3.control = gUnk_08108C88[this->unk_0a]; - gRoomControls.bg3OffsetY.WORD = 0; - gRoomControls.bg3OffsetX.WORD = 0; - - switch (this->unk_0a) { - case 0: - default: - gScreen.bg3.yOffset = 0; - gScreen.bg3.xOffset = 0; - break; - case 1: - gScreen.bg3.xOffset = gRoomControls.scroll_x + gRoomControls.bg3OffsetX.HALF.HI; - gScreen.bg3.yOffset = gRoomControls.scroll_y + gRoomControls.bg3OffsetY.HALF.HI; - break; - } -} - -void sub_0805B638(Manager* this) { - if (this->unk_0a == 1) { - gRoomControls.bg3OffsetX.WORD = gRoomControls.bg3OffsetX.WORD + 0x2000; - gScreen.bg3.xOffset = gRoomControls.scroll_x + gRoomControls.bg3OffsetX.HALF.HI; - gScreen.bg3.yOffset = gRoomControls.scroll_y + gRoomControls.bg3OffsetY.HALF.HI; - } -} diff --git a/src/manager/manager1E.c b/src/manager/manager1E.c deleted file mode 100644 index 0e272fa9..00000000 --- a/src/manager/manager1E.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "global.h" -#include "asm.h" -#include "manager.h" -#include "flags.h" - -typedef struct { - Manager manager; - u8 unk_20[0x14]; // unused - u16 radiusX; - u16 radiusY; - s16 posX; - s16 posY; - u8 unk_3c[2]; // unused - u16 playerInRegionFlag; -} Manager1E; - -enum Manager1E_State { Init, ObserveRegion }; - -void Manager1E_Init(Manager1E*); -void Manager1E_ObserveRegion(Manager1E*); - -void (*const Manager1E_ActionFuncs[2])(Manager1E*) = { Manager1E_Init, Manager1E_ObserveRegion }; - -void Manager1E_Main(Manager1E* this) { - Manager1E_ActionFuncs[this->manager.action](this); -} - -void Manager1E_Init(Manager1E* this) { - this->manager.action = ObserveRegion; - this->radiusX >>= 1; - this->posX += this->radiusX; - this->radiusY >>= 1; - this->posY += this->radiusY; - if (!this->manager.unk_0a) { - if (CheckFlags(this->playerInRegionFlag)) { - DeleteManager(&this->manager); - return; - } - } - Manager1E_ObserveRegion(this); -} - -void Manager1E_ObserveRegion(Manager1E* this) { - if (CheckPlayerInRegion(this->posX, this->posY, this->radiusX, this->radiusY)) { - SetFlag(this->playerInRegionFlag); - if (!this->manager.unk_0a) { - DeleteManager(&this->manager); - return; - } - } else { - ClearFlag(this->playerInRegionFlag); - } -} diff --git a/src/manager/manager1F.c b/src/manager/manager1F.c deleted file mode 100644 index 49effc47..00000000 --- a/src/manager/manager1F.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "manager.h" -#include "flags.h" -#include "room.h" - -typedef struct { - Manager manager; - u8 field_0x20[0x16]; - u8 field_0x36; - u8 field_0x37; - s16 field_0x38; - u16 field_0x3a; - u8 field_0x3c; - u8 field_0x3d; - u16 field_0x3e; -} Manager1F; - -void sub_0805B778(Manager1F*); -void sub_0805B70C(Manager1F*); -void sub_0805B744(Manager1F*); - -void Manager1F_Main(Manager1F* this) { - static void (*const actionFuncs[])(Manager1F*) = { - sub_0805B70C, - sub_0805B744, - }; - actionFuncs[this->manager.action](this); -} - -void sub_0805B70C(Manager1F* this) { - if (CheckFlags(this->field_0x3e) != 0) { - this->manager.unk_0b = 1; - } - this->manager.action = 1; - this->field_0x38 = (this->field_0x38 >> 4 & 0x3fU) | (((this->field_0x3a << 0x10) >> 0x14 & 0x3fU) << 6); - sub_0805B778(this); -} - -void sub_0805B744(Manager1F* this) { - if (CheckFlags(this->field_0x3e) != 0) { - if (this->manager.unk_0b == 0) { - this->manager.unk_0b = 1; - sub_0805B778(this); - } - } else { - if (this->manager.unk_0b == 1) { - this->manager.unk_0b = 0; - sub_0805B778(this); - } - } -} - -void sub_0805B778(Manager1F* this) { - static const u16 gUnk_08108C9C[] = { 0x358, 0x359, 0x356, 0x35a, 0x35a, 0x357 }; - SetTileType(gUnk_08108C9C[this->manager.unk_0a * 2 + this->manager.unk_0b], this->field_0x38, this->field_0x36); -} diff --git a/src/manager/manager20.c b/src/manager/manager20.c deleted file mode 100644 index 8f0543ad..00000000 --- a/src/manager/manager20.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "global.h" -#include "manager.h" -#include "flags.h" -#include "room.h" - -typedef struct { - Manager manager; - u8 unk_20[0x12]; - u16 unk_32; - u8 unk_34[2]; - u8 unk_36; - u8 unk_37; - u16 unk_38; - u16 unk_3a; - u16 unk_3c; - u16 unk_3e; -} Manager20; - -void Manager20_Main(Manager20* this) { - Entity* tmp = CreateObject(this->manager.unk_0e, this->manager.unk_0a, this->manager.unk_0b); - if (!tmp) - return; - tmp->field_0x86.HWORD = this->unk_3e; - if (CheckFlags(this->unk_3e)) { - tmp->x.HALF.HI = this->unk_36 | (this->unk_37 & 0xF) << 8; // r1 - tmp->y.HALF.HI = this->unk_3c & 0xFFF; - tmp->collisionLayer = this->unk_3c >> 0xC; - } else { - tmp->x.HALF.HI = this->unk_38; - tmp->y.HALF.HI = this->unk_3a; - tmp->collisionLayer = this->unk_37 >> 4; - } - tmp->x.HALF.HI += gRoomControls.origin_x; - tmp->y.HALF.HI += gRoomControls.origin_y; - DeleteManager((Manager*)this); -} diff --git a/src/manager/manager26.c b/src/manager/manager26.c deleted file mode 100644 index dc8223b6..00000000 --- a/src/manager/manager26.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "global.h" -#include "manager.h" -#include "flags.h" -#include "room.h" -#include "object.h" - -typedef struct { - Manager manager; - u8 unk_20[0x8]; - u8 unk_28; - u8 unk_29; - u16 unk_2a; -} Manager26; - -void sub_0805C6D0(Manager26*); -void sub_0805C7A0(Manager26*); -void sub_0805C7C4(Manager26*); - -void (*const gUnk_08108D04[])(Manager26*) = { sub_0805C6D0, sub_0805C7A0, sub_0805C7C4 }; - -void sub_0805C7CC(Manager26*); - -void Manager26_Main(Manager26* this) { - gUnk_08108D04[this->manager.action](this); -} - -void sub_0805C6D0(Manager26* this) { - UnkManager26HelperStruct* tmp = GetCurrentRoomProperty(this->manager.unk_0a); - if (!tmp) { - DeleteManager(&this->manager); - return; - } - this->unk_2a = gRoomControls.origin_y + this->manager.unk_0e; - this->manager.unk_0e = 0; - this->unk_28 = 0; - this->unk_29 = 0; - while (tmp->unk_00 != 0xFF && this->manager.unk_0e < 0x20) { - Entity* obj; - obj = CreateObject(PUSHABLE_FURNITURE, tmp->unk_01, tmp->unk_02); - if (obj) { - obj->timer = tmp->unk_03; - obj->x.HALF.HI = gRoomControls.origin_x + tmp->unk_04; - obj->y.HALF.HI = gRoomControls.origin_y + tmp->unk_06; - obj->parent = (Entity*)this; - obj->collisionLayer = 1; - obj->field_0x82.HALF.HI = this->manager.unk_0e; - obj->field_0x82.HALF.LO = tmp->unk_00; - this->unk_29 |= 1 << this->manager.unk_0e; - } - tmp++; - this->manager.unk_0e++; - } - if (this->manager.unk_0b == 0xFF) { - this->manager.action = 2; - } else { - if (CheckLocalFlag(this->manager.unk_0b)) { - this->manager.action = 2; - } else { - this->manager.action = 1; - } - } -} - -void sub_0805C7A0(Manager26* this) { - if (this->unk_28 == this->unk_29) { - this->manager.action = 2; - SetLocalFlag(this->manager.unk_0b); - } - sub_0805C7CC(this); -} - -void sub_0805C7C4(Manager26* this) { - sub_0805C7CC(this); -} - -void sub_0805C7CC(Manager26* this) { - if (gPlayerState.flags & PL_MINISH) { - if (gPlayerEntity.y.HALF.HI < this->unk_2a + 0x10) { - this->manager.unk_0d = 1; - } else { - this->manager.unk_0d = 0; - } - } else { - if (gPlayerEntity.y.HALF.HI < this->unk_2a + 0x28) { - this->manager.unk_0d = 3; - } else { - this->manager.unk_0d = 2; - } - } -} diff --git a/src/manager/manager27.c b/src/manager/manager27.c deleted file mode 100644 index 05f2ea7a..00000000 --- a/src/manager/manager27.c +++ /dev/null @@ -1,80 +0,0 @@ -#include "global.h" -#include "sound.h" -#include "entity.h" -#include "flags.h" -#include "functions.h" -#include "common.h" - -extern u32 sub_0805C920(Entity*); - -void sub_0805C874(Entity*); -void sub_0805C894(Entity*); -void sub_0805C8B4(Entity*); -void sub_0805C908(Entity*); - -void (*const gUnk_08108D10[])(Entity*) = { sub_0805C874, sub_0805C894, sub_0805C8B4, sub_0805C908 }; - -const u8 gUnk_08108D20[] = { 0x6F, 0x70, 0x71, 0x72, 0x71, 0x70 }; - -void Manager27_Main(Entity* this) { - - gUnk_08108D10[this->action](this); - if (CheckLocalFlagByBank(FLAG_BANK_3, this->type + 0x67)) { - gRoomTransition.armos_data.field_0xac |= (1 << this->type); - } else { - gRoomTransition.armos_data.field_0xac &= ~(1 << this->type); - } -} - -void sub_0805C874(Entity* this) { - u8 bVar1; - - if (sub_0805C920(this)) { - this->action = 2; - } else { - this->action = 1; - } - - this->timer = 1; - this->subtimer = 0; -} - -void sub_0805C894(Entity* this) { - if (sub_0805C920(this)) { - this->action = 2; - this->timer = 1; - SoundReq(SFX_EM_ARMOS_ON); - } -} - -void sub_0805C8B4(Entity* this) { - u8 bVar1; - int iVar2; - - if (--this->timer == 0) { - this->timer = 0x14; - - if (5 < ++this->subtimer) { - this->subtimer = 0; - } - LoadPaletteGroup(gUnk_08108D20[this->subtimer]); - if (this->subtimer == 0) { - SoundReq(SFX_EM_ARMOS_ON); - } - } - if (sub_0805C920(this) == 0) { - this->action = 3; - } -} - -void sub_0805C908(Entity* this) { - if (this->subtimer == 0) { - this->action = 1; - } else { - sub_0805C8B4(this); - } -} - -u32 sub_0805C920(Entity* this) { - return CheckLocalFlagByBank(FLAG_BANK_3, this->type + 0x67); -} diff --git a/src/manager/manager28.c b/src/manager/manager28.c deleted file mode 100644 index c921d4a5..00000000 --- a/src/manager/manager28.c +++ /dev/null @@ -1,137 +0,0 @@ -#include "global.h" -#include "asm.h" -#include "manager.h" -#include "room.h" - -typedef struct { - Manager manager; - struct { - Entity* enemies[8]; - } d; -} Manager28; - -void Manager28_Init(Manager28*); -void Manager28_Main2(Manager28*); -u32 Manager28_FindMatchingEntities(Manager28*); -Entity* Manager28_FindMatchingEntity(EntityData*); -void Manager28_RemoveDeletedEntities(Manager28*); - -void (*const Manager28_ActionFuncs[])(Manager28*) = { Manager28_Init, Manager28_Main2 }; - -enum Manager28_Action { Init = 0, Main = 1 }; - -enum Manager28_InitState { DoInit = 0, DoNotInit = 1 }; - -void Manager28_Main(Manager28* this) { - Manager28_ActionFuncs[this->manager.action](this); -} - -void Manager28_Init(Manager28* this) { - if (this->manager.unk_0a == DoInit) { - s32 tmp2; - int tmp4; - for (tmp4 = 0; tmp4 < 8; tmp4++) { - this->d.enemies[tmp4] = 0; - } - tmp2 = Manager28_FindMatchingEntities(this); - if (tmp2 > 1) { - Manager28* tmp3 = (Manager28*)GetEmptyManager(); - if (tmp3) { - tmp3->manager.type = 9; - tmp3->manager.subtype = 0x28; - tmp3->manager.unk_0a = DoNotInit; - tmp3->manager.unk_0e = tmp2; - /* for (tmp4 = 0; tmp4 < 8; tmp4++) { */ - /* tmp3->enemies[tmp4] = this->enemies[tmp4]; */ - /* } */ - tmp3->d = this->d; - AppendEntityToList((Entity*)tmp3, 6); - } - } - DeleteManager(&this->manager); - } else { - this->manager.action = Main; - this->manager.unk_0f = 0; - } -} - -void Manager28_Main2(Manager28* this) { - s32 n; - s32 i; - s32 j; - Entity* tmp; - Manager28_RemoveDeletedEntities(this); - n = this->manager.unk_0e - 1; - if ((this->manager.unk_0f++) & 1) { - for (i = 0; i < n; i++) { - tmp = this->d.enemies[i]; - for (j = i + 1; j < this->manager.unk_0e; j++) { - sub_08004484(tmp, this->d.enemies[j]); - } - } - } else { - for (i = 0; i < n; i++) { - tmp = this->d.enemies[i]; - for (j = i + 1; j < this->manager.unk_0e; j++) { - sub_08004484(this->d.enemies[j], tmp); - } - } - } -} - -u32 Manager28_FindMatchingEntities(Manager28* this) { - u32 re = 0; - EntityData* tmp = GetCurrentRoomProperty(this->manager.unk_0b); - if (!tmp) - return 0; - for (; *((u8*)tmp) != 0xFF && !((tmp->kind & 0xf) == 9 && tmp->id == 0x28); tmp++) { - Entity* tmp2; - u32 i; - if ((tmp->kind & 0xf) != 3) - continue; - tmp2 = Manager28_FindMatchingEntity(tmp); - if (!tmp2) - continue; - for (i = 0; i < re; i++) { - if (this->d.enemies[i] == tmp2) - break; - } - if (i != re) - continue; - this->d.enemies[re++] = tmp2; - if (re == 8) - return 8; - } - return re; -} - -Entity* Manager28_FindMatchingEntity(EntityData* unk1) { - u32 x, y; - Entity* i; - LinkedList* tmp; - x = unk1->xPos + gRoomControls.origin_x; - y = unk1->yPos + gRoomControls.origin_y; - tmp = &gEntityLists[4]; - for (i = tmp->first; (u32)i != (u32)tmp; i = i->next) { - if (x == i->x.HALF.HI && y == i->y.HALF.HI && unk1->id == i->id && ENEMY == i->kind && unk1->type == i->type) { - return i; - } - } - return 0; -} - -void Manager28_RemoveDeletedEntities(Manager28* this) { - s32 i; - for (i = 0; i < this->manager.unk_0e; i++) { - if (this->d.enemies[i]->next == 0) { - if (this->manager.unk_0e - 1 == i) { - this->d.enemies[i] = 0; - } else { - this->d.enemies[i] = this->d.enemies[this->manager.unk_0e - 1]; - } - this->manager.unk_0e--; - } - } - if (this->manager.unk_0e <= 1) - DeleteThisEntity(); -} diff --git a/src/manager/manager29.c b/src/manager/manager29.c index 010fb3ad..02ed52ba 100644 --- a/src/manager/manager29.c +++ b/src/manager/manager29.c @@ -1,31 +1,20 @@ - -#include "manager.h" -#include "flags.h" +/** + * @file manager29.c + * @ingroup Managers + * + * @brief Unused? Not yet encountered. + */ +#include "manager/manager29.h" #include "asm.h" +#include "flags.h" #include "functions.h" -typedef struct { - Manager manager; - u8 unk_20[0x8]; - u16* unk_28; - u16* unk_2c; - u8 filler[0x4]; - u8 unk_34; - u8 unk_35; - u8 unk_36; - u8 unk_37; - s16 unk_38; - u16 unk_3a; - u16 unk_3c; - u16 unk_3e; -} Manager29; - bool32 sub_0805CF80(Manager29* this); void sub_0805CBD0(Manager29* this); void sub_0805CC3C(Manager29* this); void Manager29_Main(Manager29* this) { - if (this->manager.action == 0) { + if (super->action == 0) { sub_0805CBD0(this); if (CheckFlags(this->unk_3e)) { sub_0805CC3C(this); @@ -40,7 +29,7 @@ void Manager29_Main(Manager29* this) { void sub_0805CBD0(Manager29* this) { LayerStruct* layer; - this->manager.action = 1; + super->action = 1; this->unk_38 = (this->unk_38 >> 4 & 0x3fU) | (((this->unk_3a << 0x10) >> 0x14 & 0x3fU) << 6); this->unk_3a = (this->unk_3c >> 4 & 0x3f) | (((this->unk_36 + this->unk_37 * 0x100) >> 4 & 0x3fU) << 6); this->unk_3c = GetTileType(this->unk_38, this->unk_34); @@ -63,7 +52,7 @@ void sub_0805CC3C(Manager29* this) { uVar4 = 0x322; } - switch (this->manager.unk_0a) { + switch (super->type) { default: sub_0807B7D8(uVar4, iVar3, this->unk_34); sub_0807B7D8(0x365, iVar2, this->unk_34); diff --git a/src/manager/manager2A.c b/src/manager/manager2A.c deleted file mode 100644 index a460dc16..00000000 --- a/src/manager/manager2A.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "asm.h" -#include "manager.h" -#include "room.h" -#include "flags.h" - -typedef struct { - u8 field_0x0; - u8 tileLayer; - u16 flag; - u16 tilePos; - u16 tileType; // If the tile type at tilePos, tileLayer is tileType, set the local flag. -} Manager2A_unk; // TODO result of GetCurrentRoomProperty(3)? - -void sub_0805CFF0(Manager2A_unk*); - -void Manager2A_Main(Manager* manager) { - Manager2A_unk* data; - - if (manager->action == 0) { - manager->action += 1; - } - data = (Manager2A_unk*)GetCurrentRoomProperty(3); - if (data != NULL) { - for (; data->field_0x0 != 0; data = data + 1) { - if (data->field_0x0 == 10) { - sub_0805CFF0(data); - } - } - } -} - -void sub_0805CFF0(Manager2A_unk* param_1) { - if (CheckLocalFlag(param_1->flag) == 0) { - u32 tileType = GetTileType(param_1->tilePos, param_1->tileLayer); - if (param_1->tileType == tileType) { - SetLocalFlag(param_1->flag); - } - } -} diff --git a/src/manager/manager2C.c b/src/manager/manager2C.c deleted file mode 100644 index 83601282..00000000 --- a/src/manager/manager2C.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "manager.h" -#include "asm.h" -#include "functions.h" -#include "common.h" - -typedef struct { - struct Manager manager; - u8 field_0x20[0x16]; - u8 field_0x36; - u8 field_0x37; - s16 field_0x38; - s16 field_0x3a; - u16 field_0x3c; - u16 field_0x3e; -} Manager2C; - -void Manager2C_Main(Manager2C* manager) { - if (manager->manager.action == 0) { - manager->manager.action = 1; - manager->field_0x3a = 0; - } - if (((CheckPlayerInRegion(manager->field_0x38, manager->field_0x3a, 0x14, 0x40) != 0) && - (((gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) + gPlayerEntity.z.HALF.HI) < 0)) && - (gRoomControls.scroll_y == gRoomControls.origin_y)) { - MemClear(&gRoomTransition.player_status, 0x20); - gRoomTransition.transitioningOut = 1; - gRoomTransition.type = TRANSITION_DEFAULT; - gRoomTransition.player_status.spawn_type = PL_SPAWN_PARACHUTE_UP; - gRoomTransition.player_status.area_next = manager->manager.unk_0b; - gRoomTransition.player_status.room_next = manager->manager.unk_0e; - gRoomTransition.player_status.start_anim = manager->field_0x37; - gRoomTransition.player_status.start_pos_x = manager->field_0x3c; - gRoomTransition.player_status.start_pos_y = manager->field_0x3e; - gRoomTransition.player_status.layer = manager->field_0x36; - } -} diff --git a/src/manager/manager2E.c b/src/manager/manager2E.c deleted file mode 100644 index d71f8539..00000000 --- a/src/manager/manager2E.c +++ /dev/null @@ -1,128 +0,0 @@ -#include "global.h" -#include "entity.h" -#include "manager.h" -#include "flags.h" -#include "functions.h" -#include "sound.h" - -typedef struct { - Manager manager; - u8 field_0x20[0x18]; - s16 field_0x38; - u8 field_0x3a; - u8 field_0x3b; - u16 field_0x3c; - u16 field_0x3e; -} Manager2E; - -void sub_0805D2F4(Manager2E*); -void sub_0805D268(Manager2E*); -void sub_0805D32C(Manager2E*); -void sub_0805D280(Manager2E*); -void sub_0805D2C0(Manager2E*); -void sub_0805D2F4(Manager2E*); -void sub_0805D384(Manager2E*); -void sub_0805D36C(Manager2E*); -void sub_0805D344(Manager2E*); - -void Manager2E_Main(Manager2E* this) { - static void (*const gUnk_08108D3C[])(Manager2E*) = { - sub_0805D268, - sub_0805D32C, - }; - gUnk_08108D3C[this->manager.unk_0a](this); -} - -void sub_0805D268(Manager2E* this) { - static void (*const actionFuncs[])(Manager2E*) = { - sub_0805D280, - sub_0805D2C0, - sub_0805D2F4, - }; - actionFuncs[this->manager.action](this); -} - -void sub_0805D280(Manager2E* this) { - if (CheckFlags(this->field_0x3c) != 0) { - DeleteThisEntity(); - } - if (CheckFlags(this->field_0x3e) != 0) { - SetFlag(this->field_0x3c); - DeleteThisEntity(); - } - this->manager.action = 1; - if (this->manager.unk_0e == 0) { - this->manager.unk_0e = 0x1e; - } - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); -} - -void sub_0805D2C0(Manager2E* this) { - if ((CheckFlags(this->field_0x3e) != 0) && (gPriorityHandler.priority_timer < 2)) { - this->manager.action = 2; - if (this->manager.unk_0e == 1) { - sub_0805D2F4(this); - } - RequestPriorityDuration((Entity*)this, this->manager.unk_0e); - } -} - -void sub_0805D2F4(Manager2E* this) { - if (gPriorityHandler.priority_timer == 0) { - if (this->field_0x38 != SFX_NONE) { - SoundReq(this->field_0x38); - } else { - SoundReq(SFX_SECRET); - } - if (this->field_0x3c != 0) { - SetFlag(this->field_0x3c); - } - DeleteThisEntity(); - } -} - -void sub_0805D32C(Manager2E* this) { - static void (*const actionFuncs[])(Manager2E*) = { - sub_0805D344, - sub_0805D36C, - sub_0805D384, - }; - actionFuncs[this->manager.action](this); -} - -void sub_0805D344(Manager2E* this) { - CheckFlags(this->field_0x3e); - this->manager.action = 1; - if (this->manager.unk_0e == 0) { - this->manager.unk_0e = 0x1e; - } - this->manager.unk_0f = this->manager.unk_0e; - SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); -} - -void sub_0805D36C(Manager2E* this) { - if (CheckFlags(this->field_0x3e) != 0) { - this->manager.action = 2; - this->manager.unk_0e = this->manager.unk_0f; - } -} - -void sub_0805D384(Manager2E* this) { - if (this->manager.unk_0e != 0) { - if (--this->manager.unk_0e == 0) { - Sound sound; - if (this->field_0x38 != SFX_NONE) { - sound = this->field_0x38; - } else { - sound = SFX_SECRET; - } - SoundReq(sound); - SetFlag(this->field_0x3c); - } - } else { - if (CheckFlags(this->field_0x3e) == 0) { - this->manager.action = 1; - ClearFlag(this->field_0x3c); - } - } -} diff --git a/src/manager/manager35.c b/src/manager/manager35.c deleted file mode 100644 index e913ae82..00000000 --- a/src/manager/manager35.c +++ /dev/null @@ -1,91 +0,0 @@ -#include "manager.h" -#include "flags.h" -#include "room.h" -#include "object.h" - -typedef struct { - Manager manager; - u8 field_0x20[0x15]; - u8 field_0x35; - u8 field_0x36; - u8 field_0x37; - s16 field_0x38; - s16 field_0x3a; - u16 field_0x3c; - u16 field_0x3e; -} Manager35; - -void sub_0805DC9C(Manager35*); -void sub_0805DCC8(Manager35*); -void sub_0805DD24(Manager35*); -void sub_0805DD68(Manager35*); - -void Manager35_Main(Manager35* this) { - static void (*const actionFuncs[])(Manager35*) = { - sub_0805DC9C, - sub_0805DCC8, - sub_0805DD24, - sub_0805DD68, - }; - actionFuncs[this->manager.action](this); -} - -void sub_0805DC9C(Manager35* this) { - if (CheckFlags(this->field_0x3c) != 0) { - DeleteThisEntity(); - } - if (CheckFlags(this->field_0x3e) != 0) { - SetFlag(this->field_0x3c); - DeleteThisEntity(); - } - this->manager.action = 1; -} - -void sub_0805DCC8(Manager35* this) { - Entity* object; - - if (CheckFlags(this->field_0x3e) != 0) { - this->manager.action = 2; - this->manager.unk_0e = this->field_0x35; - if (this->manager.unk_0e == 0) { - this->manager.unk_0e = 0x1e; - } - this->manager.parent = (Manager*)gRoomControls.camera_target; - object = CreateObject(OBJECT_69, 0, 0); - if (object != NULL) { - object->x.HALF.HI = this->field_0x38 + gRoomControls.origin_x; - object->y.HALF.HI = this->field_0x3a + gRoomControls.origin_y; - *(Entity**)this->manager.unk_18 = object; - gRoomControls.camera_target = object; - RequestPriorityDuration(object, 0x1e); - } - } -} - -void sub_0805DD24(Manager35* this) { - RequestPriorityDuration(0, 8); - if ((gRoomControls.scroll_flags & 4) == 0 && --this->manager.unk_0e == 0) { - this->manager.action = 3; - SetFlag(this->field_0x3c); - if (this->field_0x36 == 0) { - this->field_0x36 = 1; - } - } -} - -void sub_0805DD68(Manager35* this) { - RequestPriorityDuration(0, 8); - if (this->field_0x36 != 0) { - if (--this->field_0x36 == 0) { - gRoomControls.camera_target = (Entity*)this->manager.parent; - } - } else { - if ((gRoomControls.scroll_flags & 4) == 0) { - Entity* entity = *(Entity**)this->manager.unk_18; - if (entity != NULL) { - DeleteEntity(entity); - } - DeleteThisEntity(); - } - } -} diff --git a/src/manager/manager36.c b/src/manager/manager36.c deleted file mode 100644 index c05df49b..00000000 --- a/src/manager/manager36.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "manager.h" -#include "sound.h" -#include "script.h" - -typedef struct { - u16 waitTime; - u16 sound; -} Manager36_unk; - -// Repeatedly plays the same sound with a fixed wait time -void Manager36_Main(Manager* manager) { - static const Manager36_unk gUnk_08108DA8[] = { - { 0x10, SFX_ELEMENT_INFUSE }, { 0x20, SFX_1C8 }, { 0x20, SFX_1C8 }, { 0x40, SFX_1A9 }, { 0x20, SFX_21F } - }; - const Manager36_unk* unk = &gUnk_08108DA8[manager->unk_0a]; - if (manager->action == 0) { - manager->action += 1; - manager->unk_0e = 0; - } - if (manager->unk_0e == 0) { - manager->unk_0e = unk->waitTime; - SoundReq(unk->sound); - } else { - manager->unk_0e -= 1; - } -} - -void CreateManager36(Entity* entity, ScriptExecutionContext* context) { - Manager* manager = GetEmptyManager(); - if (manager != NULL) { - manager->type = 9; - manager->subtype = 0x36; - manager->unk_0a = context->intVariable; - AppendEntityToList((Entity*)manager, 6); - SetDefaultPriority((Entity*)manager, PRIO_PLAYER_EVENT); - } -} - -void DeleteManager36(Entity* entity, ScriptExecutionContext* context) { - Entity* manager = FindEntity(MANAGER, 0x36, 6, context->intVariable, 0); - if (manager != NULL) { - DeleteEntityAny(manager); - } -} diff --git a/src/manager/manager38.c b/src/manager/manager38.c deleted file mode 100644 index 5e377242..00000000 --- a/src/manager/manager38.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "entity.h" -#include "room.h" - -void sub_0805E0C0(Entity*); -void sub_0805E0F4(Entity*); - -void Manager38_Main(Entity* this) { - static void (*const actionFuncs[])(Entity*) = { - sub_0805E0C0, - sub_0805E0F4, - }; - actionFuncs[this->action](this); -} - -void sub_0805E0C0(Entity* this) { - EntityData* entityData; - Entity* entity; - - this->action = 1; - this->timer = 0; - entityData = (EntityData*)GetCurrentRoomProperty(this->type); - if (entityData == NULL) { - DeleteThisEntity(); - } - while (*(u8*)entityData != 0xff) { - entity = LoadRoomEntity(entityData++); - entity->parent = this; - entity->timer = 0xff; - } -} - -void sub_0805E0F4(Entity* this) { - this->timer = 0; -} diff --git a/src/manager/manager4.c b/src/manager/manager4.c deleted file mode 100644 index a94c7a5a..00000000 --- a/src/manager/manager4.c +++ /dev/null @@ -1,199 +0,0 @@ -#include "global.h" -#include "asm.h" -#include "player.h" -#include "room.h" -#include "manager.h" -#include "structures.h" -#include "functions.h" - -void Manager4_Main(Manager*); -void sub_0805786C(Manager*); -void sub_08057920(Manager*); - -void Manager4_Main(Manager* this) { - static void (*const actionFuncs[])(Manager*) = { - sub_0805786C, - sub_08057920, - }; - actionFuncs[this->action](this); -} - -extern void UpdateIsDiggingCave(void); - -extern const DiggingCaveEntrance* sub_08057AA8(const DiggingCaveEntrance*, int); - -void sub_0805786C(Manager* this) { - const DiggingCaveEntrance* tmp; - u8 room; - u8 area; - u16 uVar = 0x81 << 7; - UpdateIsDiggingCave(); - if (gUnk_03004030.isDiggingCave != 0) { - if (gUnk_03004030.unk_00 == 0) { - gUnk_03004030.unk_0a = 0xFF; - room = gRoomControls.room; - tmp = diggingCaveEntrances[gRoomControls.area]; - tmp = sub_08057AA8(tmp, room); - if (tmp != 0) { - room = tmp->target_room; - tmp = diggingCaveEntrances[tmp->target_area]; - tmp = sub_08057AA8(tmp, room); - if (tmp != 0) { - gUnk_03004030.unk_00 = tmp; - } - } - } - room = gRoomControls.room; - tmp = diggingCaveEntrances[gRoomControls.area]; - uVar = 0x81 << 7; - for (tmp = sub_08057AA8(tmp, room); tmp != 0; tmp = sub_08057AA8(tmp, room)) { - SetTile(uVar, tmp->unk_00 + 0x3F, 1); - SetTile(uVar, tmp->unk_00 + 0x40, 1); - SetTile(uVar, tmp->unk_00 + 0x41, 1); - tmp++; - } - } - this->action = 1; -} - -extern u32 sub_0805795C(Manager*, const DiggingCaveEntrance*); - -void sub_08057920(Manager* this) { - const DiggingCaveEntrance* tmp; - u8 room; - room = gRoomControls.room; - for (tmp = diggingCaveEntrances[gRoomControls.area]; - (tmp = sub_08057AA8(tmp, room)) != 0 && !sub_0805795C(this, tmp); tmp++) - ; -} - -void sub_08057A18(Manager*, const DiggingCaveEntrance*); - -u32 sub_0805795C(Manager* this, const DiggingCaveEntrance* entr) { - u16 offsetX, offsetY, offsetX2, offsetY2; - u32 tmp, tmp2; - if (gUnk_03004030.isDiggingCave) { - offsetX = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x; - offsetY = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; - offsetX2 = (entr->unk_00 & 0x3F) * 16 + 8; - offsetY2 = ((entr->unk_00 & 0xFC0) >> 6) * 16 + 0x18; - tmp = offsetX - offsetX2; - if (tmp + 0x18 > 0x30 || offsetY - offsetY2 + 8 > 0x10U) - return 0; - if (offsetY < offsetY2 && tmp + 0xC <= 0x18) - return 0; - sub_08057A18(this, entr); - return 1; - } else { - if (COORD_TO_TILE(&gPlayerEntity) != entr->unk_00) - return 0; - offsetY2 = gRoomControls.origin_y + ((entr->unk_00 >> 6) << 4) + 6; - if (gPlayerEntity.y.HALF.HI >= offsetY2) - return 0; - sub_08057A18(this, entr); - return 1; - } -} - -extern void sub_08080930(u32); - -void sub_08057A18(Manager* this, const DiggingCaveEntrance* entr) { - u16 tmp; - SetInitializationPriority(); - gUnk_03004030.unk_0a = gUnk_03004030.unk_09; - gUnk_03004030.unk_09 = gRoomControls.area; - gRoomTransition.player_status.area_next = entr->target_area; - gRoomTransition.player_status.room_next = entr->target_room; - gRoomControls.area = entr->target_area; - gRoomControls.room = entr->target_room; - gUnk_03004030.unk_00 = entr; - gUnk_03004030.unk_04 = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x - ((entr->unk_00 & 0x3F) * 16); - gUnk_03004030.unk_06 = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y - ((entr->unk_00 & 0xFC0) >> 2); - -#ifndef EU - tmp = gUnk_03004030.isDiggingCave; - if (!tmp) { - if ((entr->target_room | 0x80) != gUnk_03004030.unk_0b) { - gUnk_02034480.unk_00 = gUnk_03004030.isDiggingCave; - } - gUnk_03004030.unk_0b = entr->target_room | 0x80; - } -#endif - - sub_08080930(entr->unk_03); - DeleteManager(this); -} - -const DiggingCaveEntrance* sub_08057AA8(const DiggingCaveEntrance* entr, int room) { - for (; entr->unk_00 != 0xFFFF; entr++) { - if (entr->source_room == room) - return entr; - } - return 0; -} - -static const DiggingCaveEntrance gUnk_08107C78[] = { { -1, 0, 0, 0, 0 } }; -static const DiggingCaveEntrance gUnk_08107C80[] = { { 0x4e5, 0x0, 0x0, 0xc, 0x0, 0xce5 }, - { 0x3df, 0x0, 0x0, 0xc, 0x0, 0xbdf }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107C98[] = { { 0x2c3, 0x4, 0x4, 0x13, 0x0, 0x2c3 }, - { 0x163, 0x5, 0x10, 0x19, 0x1, 0x448 }, - { 0x385, 0x7, 0xa, 0x13, 0x3, 0x385 }, - { 0x390, 0x7, 0xa, 0x13, 0x3, 0x390 }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107CC0[] = { { 0x62d, 0x0, 0x2, 0xf, 0x0, 0xa2d }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107CD0[] = { { 0x143, 0x1, 0x6, 0x14, 0x0, 0x643 }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107CE0[] = { { 0x95a, 0x0, 0x8, 0x16, 0x0, 0x95a }, - { 0x9ce, 0x0, 0x8, 0x16, 0x0, 0x9ce }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107CF8[] = { { 0x670, 0x0, 0xc, 0x17, 0x0, 0x670 }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107D08[] = { { 0x15e, 0x0, 0xe, 0x19, 0x1, 0x46e }, - { 0x79e, 0x0, 0x12, 0x19, 0x0, 0x248 }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107D20[] = { { 0xce5, 0x0, 0x1, 0x0, 0x0, 0x4e5 }, - { 0xbdf, 0x0, 0x1, 0x0, 0x0, 0x3df }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107D38[] = { { 0xa2d, 0x0, 0x3, 0x2, 0x0, 0x62d }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107D48[] = { { 0x2c3, 0x0, 0x5, 0x3, 0x4, 0x2c3 }, - { 0x385, 0x3, 0xb, 0x3, 0x7, 0x385 }, - { 0x390, 0x3, 0xb, 0x3, 0x7, 0x390 }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107D68[] = { { 0x643, 0x0, 0x7, 0x6, 0x1, 0x143 }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107D78[] = { { 0x95a, 0x0, 0x9, 0xa, 0x0, 0x95a }, - { 0x9ce, 0x0, 0x9, 0xa, 0x0, 0x9ce }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107D90[] = { { 0x670, 0x0, 0xd, 0x4, 0x0, 0x670 }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance gUnk_08107DA0[] = { { 0x46e, 0x1, 0xf, 0xb, 0x0, 0x15e }, - { 0x448, 0x1, 0x11, 0x3, 0x5, 0x163 }, - { 0x248, 0x0, 0x13, 0xb, 0x0, 0x79e }, - { -0x1, 0x0, 0x0, 0x0, 0x0, 0x0 } }; -static const DiggingCaveEntrance* const diggingCaveEntrances[] = { - gUnk_08107C80, gUnk_08107C78, gUnk_08107CC0, gUnk_08107C98, gUnk_08107CF8, gUnk_08107C78, gUnk_08107CD0, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107CE0, gUnk_08107D08, gUnk_08107D20, gUnk_08107C78, - gUnk_08107C78, gUnk_08107D38, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107D48, gUnk_08107D68, - gUnk_08107C78, gUnk_08107D78, gUnk_08107D90, gUnk_08107C78, gUnk_08107DA0, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, - gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, gUnk_08107C78, -}; diff --git a/src/manager/manager5.c b/src/manager/manager5.c deleted file mode 100644 index 8c4e4466..00000000 --- a/src/manager/manager5.c +++ /dev/null @@ -1,110 +0,0 @@ -#include "global.h" -#include "sound.h" -#include "manager.h" -#include "flags.h" -#include "functions.h" - -typedef struct { - Manager manager; - u8 unk_20[0x08]; - u16 unk_28; - u16 unk_2a; - u16 unk_2c; - u16 unk_2e; - u16 unk_30; - u16 unk_32; - u8 unk_34[0x04]; - s16 unk_38; - s16 unk_3a; - u16 unk_3c; - u16 unk_3e; -} Manager5; - -void sub_08057AE8(Manager5*); -void sub_08057BA4(Manager5*); -void sub_08057C28(Manager5*); - -const u16 gUnk_08108024[] = { 0, -1, 1, 0, 0, 1, -1, 0 }; -const u16 gUnk_08108034[] = { 0, 1, -1, 0, 0, -1, 1, 0 }; - -void (*const gUnk_08108044[])(Manager5*) = { sub_08057AE8, sub_08057BA4, sub_08057C28 }; - -void Manager5_Main(Manager5* this) { - gUnk_08108044[this->manager.action](this); -} - -void sub_08057CA4(Manager5*, u32, u32); - -void sub_08057AE8(Manager5* this) { - u32 tmp; - tmp = (this->manager.unk_0b & 0x3) << 1; - if (this->manager.unk_0e == 1) { - this->unk_30 = 0x323; - } else { - this->unk_30 = tmp & 2 ? 0x37 : 0x36; - } - this->unk_28 = gUnk_08108024[tmp]; - this->unk_2a = gUnk_08108024[tmp + 1]; - this->unk_2c = gUnk_08108034[tmp]; - this->unk_2e = gUnk_08108034[tmp + 1]; - this->unk_32 = ((this->manager.unk_0b >> 2) & 0xF) + 1; - this->manager.unk_0e = 0x1C; - this->manager.unk_0f = 0; - this->manager.action = (this->manager.unk_0b & 0x80) ? 2 : 1; - if (this->manager.action != 2 || !CheckFlags(this->unk_3e)) - return; - for (; this->unk_32; this->unk_32--) { - sub_08057CA4(this, this->unk_28, this->unk_2a); - sub_0807B7D8(this->unk_30, this->unk_38 | (this->unk_3a << 6), this->unk_3c); - } - DeleteManager(&this->manager); -} - -void sub_08057BA4(Manager5* this) { - if (--this->manager.unk_0e) - return; - this->manager.unk_0e = 8; - if (CheckFlags(this->unk_3e)) { - if (this->unk_32 == this->manager.unk_0f) - return; - sub_08057CA4(this, this->unk_28, this->unk_2a); - sub_0807B7D8(this->unk_30, this->unk_38 | (this->unk_3a << 6), this->unk_3c); - this->manager.unk_0f++; - SoundReq(SFX_HEART_GET); - } else { - if (!this->manager.unk_0f) - return; - RestorePrevTileEntity(this->unk_38 | (this->unk_3a << 6), this->unk_3c); - sub_08057CA4(this, this->unk_2c, this->unk_2e); - this->manager.unk_0f--; - SoundReq(SFX_HEART_GET); - } -} - -void sub_08057C28(Manager5* this) { - if (!this->manager.unk_0d) { - if (!CheckFlags(this->unk_3e)) - return; - this->manager.unk_0d++; - } else { - if (--this->manager.unk_0e) - return; - this->manager.unk_0e = 8; - if (this->unk_32 != this->manager.unk_0f) { - sub_08057CA4(this, this->unk_28, this->unk_2a); - sub_0807B7D8(this->unk_30, this->unk_38 | (this->unk_3a << 6), this->unk_3c); - this->manager.unk_0f++; - SoundReq(SFX_HEART_GET); - } else { - if (this->unk_30 != 0x323) { - SoundReq(SFX_SECRET); - } - DeleteManager(&this->manager); - } - } -} - -void sub_08057CA4(Manager5* this, u32 unk1, u32 unk2) { - this->unk_38 += unk1; - this->unk_3a += unk2; -} diff --git a/src/manager/manager6.c b/src/manager/manager6.c deleted file mode 100644 index 023e93e6..00000000 --- a/src/manager/manager6.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "global.h" -#include "asm.h" -#include "player.h" -#include "manager.h" -#include "functions.h" - -void Manager6_Main(Manager6* this) { - u32 tmp; - Manager6WarpData* i; - if (this->manager.action == 0) { - this->manager.action = 1; - this->warpList = GetCurrentRoomProperty(this->manager.unk_0a); - if (!this->warpList) { - DeleteManager(&this->manager); - return; - } - } - if (this->manager.unk_0e == 0 || gPlayerState.floor_type == SURFACE_LADDER) { - for (i = this->warpList; i->posX != 0xFFFF; i++) { - tmp = (i->unk_07.all & 0x3); - if (((tmp & (gPlayerEntity.collisionLayer)) != 0) && - (((gPlayerState.flags & PL_MINISH) != 0) || ((i->unk_07.b.unk2) != 0)) && - (CheckPlayerInRegion(i->posX, i->posY, i->width, i->height) != 0) && (gPlayerEntity.z.HALF.HI == 0)) { - DoExitTransition(GetCurrentRoomProperty(i->unk_06)); - } - } - } -} diff --git a/src/manager/managerD.c b/src/manager/managerD.c deleted file mode 100644 index dec69e60..00000000 --- a/src/manager/managerD.c +++ /dev/null @@ -1,77 +0,0 @@ -#include "manager.h" -#include "flags.h" -#include "room.h" -#include "functions.h" - -typedef struct { - Manager manager; - u8 field_0x20; - u8 field_0x21; - u8 field_0x22; - u8 field_0x23; - u8 field_0x24; - u8 field_0x25; - u8 field_0x26; - u8 field_0x27; - u16 field_0x28; - u8 field_0x2a; - u8 field_0x2b; - u8 field_0x2c; - u8 field_0x2d; - u8 field_0x2e; - u8 field_0x2f; - u16* field_0x30; - u8 field_0x34; - u8 field_0x35; - u8 field_0x36; - u8 field_0x37; - u16 field_0x38; - u16 field_0x3a; - u8 field_0x3c; - u8 field_0x3d; - u16 field_0x3e; -} ManagerD; - -void sub_08058DE8(ManagerD*); -void sub_08058E18(ManagerD*); -void sub_08058E34(ManagerD*); - -void ManagerD_Main(ManagerD* this) { - static void (*const actionFuncs[])(ManagerD*) = { - sub_08058DE8, - sub_08058E18, - sub_08058E34, - }; - actionFuncs[this->manager.action](this); -} - -void sub_08058DE8(ManagerD* this) { - u16* puVar2; - u16* puVar3; - if (CheckFlags(this->field_0x3e) != 0) { - DeleteThisEntity(); - } else { - this->manager.action = 1; - puVar2 = (u16*)GetLayerByIndex(this->field_0x3a); - puVar3 = (this->field_0x38 + 2) + puVar2; - this->field_0x30 = puVar3; - this->field_0x28 = *puVar3; - } -} - -void sub_08058E18(ManagerD* this) { - if (this->field_0x28 != *this->field_0x30) { - this->manager.action += 1; - this->manager.unk_0e = 0xf; - } -} - -void sub_08058E34(ManagerD* this) { - if (--this->manager.unk_0e == 0) { - SetFlag(this->field_0x3e); - if (this->manager.unk_0a != 0) { - LoadRoomEntityList((EntityData*)GetCurrentRoomProperty(this->manager.unk_0a)); - } - DeleteManager((Manager*)this); - } -} diff --git a/src/manager/managerE.c b/src/manager/managerE.c deleted file mode 100644 index e11c664a..00000000 --- a/src/manager/managerE.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "entity.h" -#include "manager.h" -#include "flags.h" -#include "room.h" -#include "sound.h" -#include "functions.h" - -void ManagerE_Main(ManagerE* this) { - if (!this->manager.action) { - this->manager.action = 1; - if (CheckFlags(this->unk_3e)) { - DeleteManager(&this->manager); - return; - } - } - if (!CheckFlags(this->unk_3e)) - return; - if (this->manager.unk_0b != 0) { - this->manager.unk_0b = 0; - SetPlayerControl(0xff); - sub_08078B48(); - } - if (this->unk_3a == 0) { - if (this->unk_38 != 0) { - SoundReq(this->unk_38); - } - LoadRoomEntityList(GetCurrentRoomProperty(this->manager.unk_0a)); - DeleteThisEntity(); - } else { - this->unk_3a -= 1; - } -} diff --git a/src/manager/manager3.c b/src/manager/minishPortalManager.c similarity index 69% rename from src/manager/manager3.c rename to src/manager/minishPortalManager.c index eb318c3b..fe312d14 100644 --- a/src/manager/manager3.c +++ b/src/manager/minishPortalManager.c @@ -1,47 +1,37 @@ -#include "global.h" -#include "asm.h" -#include "manager.h" -#include "flags.h" +/** + * @file minishPortalManager.c + * @ingroup Managers + * + * @brief Facilitates the usage of minish portals. + */ +#include "manager/minishPortalManager.h" #include "area.h" -#include "room.h" -#include "player.h" -#include "sound.h" -#include "object.h" +#include "asm.h" +#include "flags.h" #include "functions.h" +#include "object.h" +#include "player.h" +#include "room.h" +#include "sound.h" -// Facilitates the usage of minish portals. - -typedef struct { - Manager manager; - u32 unk_20; - u32 unk_24; - u8 unk_28[0xC]; - u8 unk_34; - u8 unk_35; - u16 unk_36; - u16 unk_38; - u16 unk_3a; - u16 unk_3c; - u16 unk_3e; -} Manager3; - -extern u32 PortalReadyForMinish(void); extern u32 sub_080B1AC8(u16, u16, u8); -void Manager3_Main(Manager3* this) { +bool32 PortalReadyForMinish(void); + +void MinishPortalManager_Main(MinishPortalManager* this) { static const s8 gUnk_08107C6C[] = { -3, -3, -3, 0 }; s8 tmp; - if (this->manager.action == 0) { - this->manager.action = 1; + if (super->action == 0) { + super->action = 1; this->unk_20 = this->unk_38 + gRoomControls.origin_x - 0x20; this->unk_24 = this->unk_3a + gRoomControls.origin_y - 0x20; return; } if (CheckPlayerProximity(this->unk_20, this->unk_24, 0x40, 0x40)) { gArea.portal_x = this->unk_20 + 0x20; - gArea.portal_y = this->unk_24 + 0x20 + gUnk_08107C6C[this->manager.unk_0a]; + gArea.portal_y = this->unk_24 + 0x20 + gUnk_08107C6C[super->type]; gArea.portal_exit_dir = this->unk_34; - gArea.portal_type = this->manager.unk_0a; + gArea.portal_type = super->type; if (!CheckGlobalFlag(EZERO_1ST)) { gArea.portal_mode = 1; gArea.portal_type = 5; @@ -53,18 +43,18 @@ void Manager3_Main(Manager3* this) { gArea.portal_mode = 3; } } - if (sub_080B1AC8(this->unk_38, this->unk_3a, this->manager.unk_0e) == 0x3d) { + if (sub_080B1AC8(this->unk_38, this->unk_3a, super->timer) == 0x3d) { CreateMagicSparkles(this->unk_38 + gRoomControls.origin_x, this->unk_3a + gRoomControls.origin_y, - this->manager.unk_0e); - if (!this->manager.unk_0f) { - this->manager.unk_0f = 1; + super->timer); + if (super->subtimer == 0) { + super->subtimer = 1; SoundReq(SFX_NEAR_PORTAL); } } } } else { - this->manager.unk_0f = 0; + super->subtimer = 0; } } @@ -92,14 +82,14 @@ void CreateMagicSparkles(u32 baseX, u32 baseY, u32 layer) { UpdateSpriteForCollisionLayer(spark); } -u32 PortalReadyForMinish(void) { +bool32 PortalReadyForMinish(void) { if ((gPlayerState.flags & PL_MINISH) && !gPlayerState.field_0xaa && (gArea.portal_type != 0x6) && (gPlayerState.heldObject == 0)) { switch (gPlayerState.framestate) { case PL_STATE_IDLE: case PL_STATE_WALK: - return 1; + return TRUE; } } - return 0; + return FALSE; } diff --git a/src/manager/manager9.c b/src/manager/minishRaftersBackgroundManager.c similarity index 71% rename from src/manager/manager9.c rename to src/manager/minishRaftersBackgroundManager.c index fd8effea..a337c862 100644 --- a/src/manager/manager9.c +++ b/src/manager/minishRaftersBackgroundManager.c @@ -1,41 +1,38 @@ -#include "global.h" -#include "manager.h" -#include "room.h" -#include "screen.h" -#include "functions.h" +/** + * @file minishRaftersBackgroundManager.c + * @ingroup Managers + * + * @brief Parallax background for minish rafters + */ +#include "manager/minishRaftersBackgroundManager.h" #include "common.h" +#include "functions.h" +#include "room.h" -typedef struct { - Manager manager; - u8 unk_00[0x1C]; - u32 unk_3c; -} Manager9; - -void sub_08058204(Manager9*); -void sub_08058210(Manager9*); +void sub_08058204(MinishRaftersBackgroundManager*); +void sub_08058210(MinishRaftersBackgroundManager*); u32 sub_08058244(int); void sub_080582A0(u32, u32*, u16*); void sub_080582F8(u8*, u8*); +extern u8 gMapDataTopSpecial[]; extern u32 gUnk_02006F00[]; -const u16 gUnk_081081EC[] = { 0x30, 0x30, 0x30, 0x38 }; - -void Manager9_Main(Manager9* this) { +void MinishRaftersBackgroundManager_Main(MinishRaftersBackgroundManager* this) { sub_08058210(this); - if (!this->manager.action) { - this->manager.action = 1; + if (super->action == 0) { + super->action = 1; gScreen.bg1.updated = 0; RegisterTransitionManager(this, sub_08058204, NULL); } } -void sub_08058204(Manager9* this) { - sub_08058324(this->manager.unk_0a); +void sub_08058204(MinishRaftersBackgroundManager* this) { + sub_08058324(super->type); } -void sub_08058210(Manager9* this) { - u32 tmp = sub_08058244(this->manager.unk_0a); +void sub_08058210(MinishRaftersBackgroundManager* this) { + u32 tmp = sub_08058244(super->type); if (this->unk_3c == tmp) return; this->unk_3c = tmp; @@ -44,6 +41,7 @@ void sub_08058210(Manager9* this) { } u32 sub_08058244(int i) { + static const u16 gUnk_081081EC[] = { 0x30, 0x30, 0x30, 0x38 }; u32 tmp; s32 tmp2; u32 tmp3; @@ -65,8 +63,6 @@ void sub_080582A0(u32 unk, u32* unk2, u16* unk3) { } } -extern u8 gMapDataTopSpecial[]; - void sub_080582D0(void) { u8* tmp = gMapDataTopSpecial; u8* tmp2 = tmp + 0x4000; @@ -84,7 +80,7 @@ void sub_080582F8(u8* unk, u8* unk2) { } void sub_08058324(u32 unk) { - gMapTop.bgControlPtr = 0; + gMapTop.bgSettings = 0; LoadPaletteGroup(unk + 0x86); LoadGfxGroup(unk + 0x36); sub_080582D0(); diff --git a/src/manager/manager21.c b/src/manager/minishSizedEntranceManager.c similarity index 79% rename from src/manager/manager21.c rename to src/manager/minishSizedEntranceManager.c index e227a2ae..71776a39 100644 --- a/src/manager/manager21.c +++ b/src/manager/minishSizedEntranceManager.c @@ -1,16 +1,17 @@ - -#include "manager.h" -#include "room.h" -#include "object.h" +/** + * @file minishSizedEntranceManager.c + * @ingroup Managers + * + * @brief Spawns MINISH_SIZED_ENTRANCE at the locations in the room property super->unk_0a when they are visible on the + * screen. + */ +#include "manager/minishSizedEntranceManager.h" #include "functions.h" +#include "object.h" +#include "room.h" extern bool32 CheckRectOnScreen(u16, u16, u32, u32); -typedef struct { - Manager manager; - u32 field_0x20; -} Manager21; - typedef struct { u16 x; u16 y; @@ -20,18 +21,14 @@ typedef struct { bool32 sub_0805B8CC(u32); -/* -Spawns MINISH_SIZED_ENTRANCE at the locations in the room property this->manager.unk_0a when they are visible on the -screen. -*/ -void Manager21_Main(Manager21* this) { +void MinishSizedEntranceManager_Main(MinishSizedEntranceManager* this) { MinishEntranceSpawnData* spawnData; u32 count; - if (this->manager.action == 0) { - this->manager.action = 1; + if (super->action == 0) { + super->action = 1; this->field_0x20 = 0; } - spawnData = (MinishEntranceSpawnData*)GetCurrentRoomProperty(this->manager.unk_0a); + spawnData = (MinishEntranceSpawnData*)GetCurrentRoomProperty(super->type); for (count = 0; (spawnData->x != 0) && (count < 0x20); ++count) { if (CheckRectOnScreen(spawnData->x, spawnData->y, 4, 4) != 0) { diff --git a/src/manager/manager7.c b/src/manager/minishVillageTilesetManager.c similarity index 80% rename from src/manager/manager7.c rename to src/manager/minishVillageTilesetManager.c index 9827621c..bb8374a3 100644 --- a/src/manager/manager7.c +++ b/src/manager/minishVillageTilesetManager.c @@ -1,20 +1,19 @@ -#include "manager.h" +/** + * @file minishVillageTilesetManager.c + * @ingroup Managers + * + * @brief Swap tileset data in minish village depending on the position + */ +#include "manager/minishVillageTilesetManager.h" #include "asm.h" -#include "functions.h" #include "common.h" - -typedef struct { - Manager manager; - u8 unk_20; - u8 unk_21[0x1F]; -} Manager7; +#include "functions.h" +#include "main.h" void sub_08057E30(void*); -u32 sub_08057E40(Manager7*); +bool32 sub_08057E40(MinishVillageTilesetManager*); void sub_08057E7C(u32); -extern u32 CheckRegionsOnScreen(const u16*); - extern const u8 gGlobalGfxAndPalettes[]; const u16 gUnk_08108050[0x2A] = { @@ -55,13 +54,13 @@ const u32 gUnk_081080A4[0x50] = { const u8 gUnk_081081E4[] = { 0x16, 0x17, 0x17, 0x18, 0x18 }; #ifdef EU -void Manager7_Main(Manager7* this) { +void MinishVillageTilesetManager_Main(MinishVillageTilesetManager* this) { u32 tmp; const u32* tmp2; s32 tmp3; - if (!this->manager.action) { - this->manager.action = 1; - this->manager.unk_0e = 8; + if (super->action == 0) { + super->action = 1; + super->timer = 8; this->unk_20 = 0xFF; RegisterTransitionManager(this, sub_08057E30, 0); @@ -73,17 +72,17 @@ void Manager7_Main(Manager7* this) { tmp = (u32)gRoomVars.unk_10[0]; if (this->unk_20 != tmp) { this->unk_20 = tmp; - this->manager.unk_0e = 0; + super->timer = 0; } } tmp2 = &gUnk_081080A4[tmp << 4]; - tmp3 = this->manager.unk_0e; + tmp3 = super->timer; if (tmp3 == 0) { gPauseMenuOptions.disabled = 1; LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000); LoadPaletteGroup(gUnk_081081E4[tmp]); - this->manager.unk_0e++; + super->timer++; } else { switch (tmp3) { case 0: @@ -94,9 +93,9 @@ void Manager7_Main(Manager7* this) { case 5: case 6: case 7: - LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(this->manager.unk_0e << 1)]], - tmp2[(this->manager.unk_0e << 1) + 1], 0x1000); - this->manager.unk_0e++; + LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(super->timer << 1)]], tmp2[(super->timer << 1) + 1], + 0x1000); + super->timer++; gPauseMenuOptions.disabled = 0; case 8: break; @@ -104,12 +103,12 @@ void Manager7_Main(Manager7* this) { } } #else -void Manager7_Main(Manager7* this) { +void MinishVillageTilesetManager_Main(MinishVillageTilesetManager* this) { u32 tmp; const u32* tmp2; - if (!this->manager.action) { - this->manager.action = 1; - this->manager.unk_0e = 8; + if (super->action == 0) { + super->action = 1; + super->timer = 8; this->unk_20 = 0xFF; SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); @@ -119,7 +118,7 @@ void Manager7_Main(Manager7* this) { tmp = (u32)gRoomVars.unk_10[0]; if (this->unk_20 != tmp) { this->unk_20 = tmp; - this->manager.unk_0e = 0; + super->timer = 0; } } if (gRoomControls.reload_flags) @@ -128,12 +127,12 @@ void Manager7_Main(Manager7* this) { tmp = this->unk_20; #endif tmp2 = &gUnk_081080A4[tmp << 4]; - switch (this->manager.unk_0e) { + switch (super->timer) { case 0: gPauseMenuOptions.disabled = 1; LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000); LoadPaletteGroup(gUnk_081081E4[tmp]); - this->manager.unk_0e++; + super->timer++; break; case 1: case 2: @@ -142,13 +141,12 @@ void Manager7_Main(Manager7* this) { case 5: case 6: case 7: - LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(this->manager.unk_0e << 1)]], - tmp2[(this->manager.unk_0e << 1) + 1], 0x1000); - this->manager.unk_0e++; + LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(super->timer << 1)]], tmp2[(super->timer << 1) + 1], 0x1000); + super->timer++; break; case 8: gPauseMenuOptions.disabled = 0; - this->manager.unk_0e++; + super->timer++; break; } } @@ -158,19 +156,18 @@ void sub_08057E30(void* this) { sub_08057E7C(gRoomVars.unk_10[0]); } -u32 sub_08057E40(Manager7* this) { +bool32 sub_08057E40(MinishVillageTilesetManager* this) { u32 tmp = CheckRegionsOnScreen(gUnk_08108050); if (tmp != 0xFF) { gRoomVars.unk_10[0] = tmp; - return 1; + return TRUE; } else { - return 0; + return FALSE; } } void sub_08057E64(void) { - u32 tmp; - tmp = CheckRegionsOnScreen(gUnk_08108050); + u32 tmp = CheckRegionsOnScreen(gUnk_08108050); if (tmp != 0xFF) { sub_08057E7C(tmp); } diff --git a/src/manager/managerF.c b/src/manager/miscManager.c similarity index 63% rename from src/manager/managerF.c rename to src/manager/miscManager.c index 50c01ac7..147dfb06 100644 --- a/src/manager/managerF.c +++ b/src/manager/miscManager.c @@ -1,58 +1,63 @@ -#include "global.h" -#include "manager.h" -#include "flags.h" -#include "sound.h" -#include "room.h" -#include "player.h" -#include "functions.h" +/** + * @file miscManager.c + * @ingroup Managers + * + * @brief Various different functionalities selected with paramA/unk_0a. + */ +#include "manager/miscManager.h" #include "area.h" -#include "message.h" #include "common.h" -#include "tiles.h" -#include "object.h" +#include "flags.h" +#include "functions.h" #include "item.h" +#include "message.h" +#include "object.h" +#include "player.h" +#include "room.h" +#include "sound.h" +#include "tiles.h" -void sub_08058EE4(ManagerF*); -void sub_08058FB0(ManagerF*); -void sub_08059094(ManagerF*); -void sub_080590E0(ManagerF*); -void sub_08059124(ManagerF*); -void sub_080591CC(ManagerF*); -void sub_08059220(ManagerF*); -void sub_08059290(ManagerF*); -void sub_080592A4(ManagerF*); -void sub_08059368(ManagerF*); -void sub_0805938C(ManagerF*); -void sub_08059424(ManagerF*); -void sub_0805947C(ManagerF*); +void MiscManager_Type0(MiscManager*); +void MiscManager_Type1(MiscManager*); +void MiscManager_Type3(MiscManager*); +void MiscManager_Type4(MiscManager*); +void MiscManager_Type5(MiscManager*); +void MiscManager_Type6(MiscManager*); +void MiscManager_Type7(MiscManager*); +void MiscManager_Type8(MiscManager*); +void MiscManager_Type9(MiscManager*); +void MiscManager_TypeA(MiscManager*); +void MiscManager_TypeB(MiscManager*); +void MiscManager_TypeC(MiscManager*); +void MiscManager_TypeD(MiscManager*); #ifndef EU -void sub_080594DC(ManagerF*); +void MiscManager_TypeE(MiscManager*); #endif #if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP) -void sub_08059548(ManagerF*); +void MiscManager_TypeF(MiscManager*); #endif // clang-format off -void (*const gUnk_08108314[])(ManagerF*) = { - sub_08058EE4, - sub_08058FB0, - sub_08058FB0, // dup - sub_08059094, - sub_080590E0, - sub_08059124, - sub_080591CC, - sub_08059220, - sub_08059290, - sub_080592A4, - sub_08059368, - sub_0805938C, - sub_08059424, - sub_0805947C, +void (*const MiscManager_Types[])(MiscManager*) = { + MiscManager_Type0, + MiscManager_Type1, + MiscManager_Type1, // dup + MiscManager_Type3, + MiscManager_Type4, + MiscManager_Type5, + MiscManager_Type6, + MiscManager_Type7, + MiscManager_Type8, + MiscManager_Type9, + MiscManager_TypeA, + MiscManager_TypeB, + MiscManager_TypeC, + MiscManager_TypeD, #ifndef EU - sub_080594DC, + MiscManager_TypeE, #endif #if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP) - sub_08059548, + MiscManager_TypeF, #endif }; // clang-format on @@ -63,9 +68,9 @@ typedef struct { u16 width; u16 height; u16 unk_08; -} PACKED __attribute__((aligned(2))) ManagerF_HelperStruct; +} PACKED __attribute__((aligned(2))) MiscManager_HelperStruct; -const ManagerF_HelperStruct gUnk_08108354[] = { +const MiscManager_HelperStruct gUnk_08108354[] = { { 0xF0, 0xB0, 0xF0, 0xB0, 0x100 }, { 0x188, 0x190, 0x28, 0x30, 0x100 }, { 0xF0, 0x340, 0xF0, 0xB0, 0x80 }, @@ -88,27 +93,27 @@ u16* const gUnk_08108380[] = { void sub_08058F44(u32, u32, u32); void sub_08058F84(u32, u32); -void sub_08059064(ManagerF*); -void sub_080592EC(ManagerF*); -void sub_0805930C(ManagerF*); -u32 sub_080593CC(ManagerF*); +void sub_08059064(MiscManager*); +void sub_080592EC(MiscManager*); +void sub_0805930C(MiscManager*); +u32 sub_080593CC(MiscManager*); // to be moved to headers extern EntityData gUnk_080F4B88[]; -void sub_08058ECC(ManagerF* this) { - gUnk_08108314[this->manager.unk_0a](this); +void MiscManager_Main(MiscManager* this) { + MiscManager_Types[super->type](this); } -void sub_08058EE4(ManagerF* this) { - if (!this->manager.action) - this->manager.action = 1; - if (!CheckRoomFlag(this->manager.unk_0b)) +void MiscManager_Type0(MiscManager* this) { + if (super->action == 0) + super->action = 1; + if (!CheckRoomFlag(super->type2)) return; - sub_08058F44(0x128, 0x68, this->manager.unk_0b + 1); - sub_08058F44(0x158, 0x68, this->manager.unk_0b + 2); - sub_08058F44(0x128, 0x98, this->manager.unk_0b + 3); - sub_08058F44(0x158, 0x98, this->manager.unk_0b + 4); + sub_08058F44(0x128, 0x68, super->type2 + 1); + sub_08058F44(0x158, 0x68, super->type2 + 2); + sub_08058F44(0x128, 0x98, super->type2 + 3); + sub_08058F44(0x158, 0x98, super->type2 + 4); SoundReq(SFX_124); DeleteThisEntity(); } @@ -131,40 +136,40 @@ void sub_08058F84(u32 unk0, u32 unk1) { tmp->y.HALF.HI = gRoomControls.origin_y + unk1; } -void sub_08058FB0(ManagerF* this) { - switch (this->manager.action) { +void MiscManager_Type1(MiscManager* this) { + switch (super->action) { case 0: - this->manager.action = 1; - if (this->manager.unk_0a == 1) { - this->manager.unk_0d = 7; - this->manager.unk_0f = 6; + super->action = 1; + if (super->type == 1) { + super->subAction = 7; + super->subtimer = 6; } else { - this->manager.unk_0d = 8; - this->manager.unk_0f = 2; + super->subAction = 8; + super->subtimer = 2; } if (CheckFlags(this->unk_3e)) { - DeleteManager(&this->manager); + DeleteManager(super); } break; case 1: if (CheckFlags(this->unk_3e)) { - this->manager.action = 2; - this->manager.unk_0e = 120; + super->action = 2; + super->timer = 120; RequestPriorityDuration((Entity*)this, 0xF0); sub_08059064(this); } break; case 2: - if (this->manager.unk_0e == 90) { + if (super->timer == 90) { SetPlayerControl(2); PutAwayItems(); } - if (this->manager.unk_0e == 60) { - gPlayerEntity.animationState = this->manager.unk_0f; + if (super->timer == 60) { + gPlayerEntity.animationState = super->subtimer; } - if (!--this->manager.unk_0e) { - this->manager.action = 3; - MenuFadeIn(5, this->manager.unk_0d); + if (!--super->timer) { + super->action = 3; + MenuFadeIn(5, super->subAction); } break; default: @@ -174,7 +179,7 @@ void sub_08058FB0(ManagerF* this) { } } -void sub_08059064(ManagerF* this) { +void sub_08059064(MiscManager* this) { Entity* tmp; tmp = CreateObject(GROUND_ITEM, ITEM_SMALL_KEY, 0); if (!tmp) @@ -184,10 +189,10 @@ void sub_08059064(ManagerF* this) { tmp->y.HALF.HI = this->unk_3a + gRoomControls.origin_y; } -void sub_08059094(ManagerF* this) { +void MiscManager_Type3(MiscManager* this) { u32 tmp = 0; - if (!this->manager.action) { - this->manager.action = 1; + if (super->action == 0) { + super->action = 1; if (CheckLocalFlag(0x60)) { tmp = 1; } else { @@ -201,13 +206,13 @@ void sub_08059094(ManagerF* this) { } if (tmp) { LoadRoomEntityList(gUnk_080F4B88); - DeleteManager(&this->manager); + DeleteManager(super); } } -void sub_080590E0(ManagerF* this) { - if (!this->manager.action) { - this->manager.action = 1; +void MiscManager_Type4(MiscManager* this) { + if (super->action == 0) { + super->action = 1; SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); } if (CheckLocalFlag(0x6c)) { @@ -221,13 +226,12 @@ void sub_080590E0(ManagerF* this) { } } -void sub_08059124(ManagerF* this) { - switch (this->manager.action) { +void MiscManager_Type5(MiscManager* this) { + switch (super->action) { default: - if (!--this->manager.unk_0e) { - CreateDustAt(this->unk_38, this->unk_3a, this->manager.unk_0b); - RestorePrevTileEntity(((this->unk_38 >> 4) & 0x3f) | ((this->unk_3a >> 4) & 0x3f) << 6, - this->manager.unk_0b); + if (!--super->timer) { + CreateDustAt(this->unk_38, this->unk_3a, super->type2); + RestorePrevTileEntity(((this->unk_38 >> 4) & 0x3f) | ((this->unk_3a >> 4) & 0x3f) << 6, super->type2); SoundReq(SFX_TASK_COMPLETE); DeleteThisEntity(); } @@ -236,31 +240,31 @@ void sub_08059124(ManagerF* this) { if (CheckFlags(this->unk_3e)) { DeleteThisEntity(); } - this->manager.action = 1; - SetTileType(0x365, ((this->unk_38 >> 4) & 0x3f) | ((this->unk_3a >> 4) & 0x3f) << 6, this->manager.unk_0b); + super->action = 1; + SetTileType(0x365, ((this->unk_38 >> 4) & 0x3f) | ((this->unk_3a >> 4) & 0x3f) << 6, super->type2); break; case 1: if (CheckFlags(this->unk_3e)) { RequestPriorityDuration((Entity*)this, 0x4b); - this->manager.unk_0e = 0x2d; - this->manager.action++; + super->timer = 0x2d; + super->action++; } } } -void sub_080591CC(ManagerF* this) { - if (!this->manager.action) { - this->manager.action = 1; - this->manager.unk_0b = CheckFlags(this->unk_3e); - if (this->manager.unk_0b) { +void MiscManager_Type6(MiscManager* this) { + if (super->action == 0) { + super->action = 1; + super->type2 = CheckFlags(this->unk_3e); + if (super->type2) { gRoomVars.lightLevel = this->unk_3a; } else { gRoomVars.lightLevel = this->unk_38; } } else { u32 tmp = CheckFlags(this->unk_3e); - if (this->manager.unk_0b != tmp) { - this->manager.unk_0b = tmp; + if (super->type2 != tmp) { + super->type2 = tmp; if (tmp) { gRoomVars.lightLevel = this->unk_3a; } else { @@ -270,8 +274,8 @@ void sub_080591CC(ManagerF* this) { } } -void sub_08059220(ManagerF* this) { - const ManagerF_HelperStruct* data; +void MiscManager_Type7(MiscManager* this) { + const MiscManager_HelperStruct* data; gRoomVars.lightLevel = 0; for (data = gUnk_08108354; data->x != 0xFFFF; data++) { @@ -279,28 +283,28 @@ void sub_08059220(ManagerF* this) { gRoomVars.lightLevel = data->unk_08; } } - if (!this->manager.action) { - this->manager.action = 1; + if (super->action == 0) { + super->action = 1; gArea.lightLevel = gRoomVars.lightLevel; } } void sub_08059278(void) { - ManagerF* tmp; - tmp = (ManagerF*)FindEntityByID(MANAGER, 0xF, 0x6); + MiscManager* tmp; + tmp = (MiscManager*)FindEntityByID(MANAGER, MISC_MANAGER, 0x6); if (tmp) { - sub_08058ECC(tmp); + MiscManager_Main(tmp); } } -void sub_08059290(ManagerF* this) { - this->manager.action = 1; +void MiscManager_Type8(MiscManager* this) { + super->action = 1; gRoomControls.camera_target = &gPlayerEntity; } -void sub_080592A4(ManagerF* this) { - if (!this->manager.action) { - this->manager.action = 1; +void MiscManager_Type9(MiscManager* this) { + if (super->action == 0) { + super->action = 1; if (CheckFlags(this->unk_3e)) { sub_080592EC(this); DeleteThisEntity(); @@ -317,11 +321,11 @@ void sub_080592A4(ManagerF* this) { } } -void sub_080592EC(ManagerF* this) { +void sub_080592EC(MiscManager* this) { SetDirtTile(((this->unk_38 >> 4) & 0x3F) | (((this->unk_3a >> 4) & 0x3F) << 6)); } -void sub_0805930C(ManagerF* this) { +void sub_0805930C(MiscManager* this) { Entity* tmp; #ifdef EU tmp = CreateObject(SPECIAL_FX, FX_BIG_EXPLOSION2, 0x0); @@ -341,25 +345,25 @@ void SetDirtTile(u32 tile) { SetTileType(0, tile - 0x40, 2); } -void sub_08059368(ManagerF* this) { - this->manager.action = 1; +void MiscManager_TypeA(MiscManager* this) { + super->action = 1; if (this->unk_3c == gTextRender.curToken.textIndex) { SetFlag(this->unk_3e); DeleteThisEntity(); } } -void sub_0805938C(ManagerF* this) { +void MiscManager_TypeB(MiscManager* this) { if (sub_080593CC(this)) { - if (++this->manager.unk_0e >= 8) { + if (++super->timer >= 8) { sub_080806BC(this->unk_38 - gRoomControls.origin_x, this->unk_3a - gRoomControls.origin_y, 0xFF, 0xA); } } else { - this->manager.unk_0e = 0; + super->timer = 0; } } -u32 sub_080593CC(ManagerF* this) { +u32 sub_080593CC(MiscManager* this) { if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 && (gPlayerState.field_0x90 & 0xF00) == 0x400) { return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6); @@ -367,7 +371,7 @@ u32 sub_080593CC(ManagerF* this) { return 0; } -void sub_08059424(ManagerF* this) { +void MiscManager_TypeC(MiscManager* this) { Entity* tmp; if (CheckFlags(this->unk_3e)) { DeleteThisEntity(); @@ -384,7 +388,7 @@ void sub_08059424(ManagerF* this) { DeleteThisEntity(); } -void sub_0805947C(ManagerF* this) { +void MiscManager_TypeD(MiscManager* this) { if (!CheckFlags(this->unk_3e)) { SetPlayerControl(3); if (gRoomControls.reload_flags) @@ -399,17 +403,17 @@ void sub_0805947C(ManagerF* this) { } #ifndef EU -void sub_080594DC(ManagerF* this) { - switch (this->manager.action) { +void MiscManager_TypeE(MiscManager* this) { + switch (super->action) { case 0: - this->manager.action = 1; + super->action = 1; // fall through case 1: if (!GetInventoryValue(ITEM_FOURSWORD)) return; if (CheckLocalFlagByBank(FLAG_BANK_10, 0x85)) return; - this->manager.action = 2; + super->action = 2; sub_080186C0(0xB0F); break; case 2: @@ -426,7 +430,7 @@ void sub_080594DC(ManagerF* this) { #endif #if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP) -void sub_08059548(ManagerF* this) { +void MiscManager_TypeF(MiscManager* this) { SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gPlayerEntity.action == PLAYER_TALKEZLO) { DeleteThisEntity(); diff --git a/src/manager/moveableObjectManager.c b/src/manager/moveableObjectManager.c new file mode 100644 index 00000000..6c697777 --- /dev/null +++ b/src/manager/moveableObjectManager.c @@ -0,0 +1,30 @@ +/** + * @file moveableObjectManager.c + * @ingroup Managers + * + * @brief Create object at different place depending on if the flag is set. + * + * E.g. for pushable rock. + */ +#include "manager/moveableObjectManager.h" +#include "flags.h" +#include "room.h" + +void MoveableObjectManager_Main(MoveableObjectManager* this) { + Entity* object = CreateObject(super->timer, super->type, super->type2); + if (!object) + return; + object->field_0x86.HWORD = this->flags; + if (CheckFlags(this->flags)) { + object->x.HALF.HI = this->unk_36 | (this->unk_37 & 0xF) << 8; // r1 + object->y.HALF.HI = this->unk_3c & 0xFFF; + object->collisionLayer = this->unk_3c >> 0xC; + } else { + object->x.HALF.HI = this->unk_38; + object->y.HALF.HI = this->unk_3a; + object->collisionLayer = this->unk_37 >> 4; + } + object->x.HALF.HI += gRoomControls.origin_x; + object->y.HALF.HI += gRoomControls.origin_y; + DeleteManager(super); +} diff --git a/src/manager/manager19.c b/src/manager/powBackgroundManager.c similarity index 71% rename from src/manager/manager19.c rename to src/manager/powBackgroundManager.c index 5eee6ccb..1aa2a0e1 100644 --- a/src/manager/manager19.c +++ b/src/manager/powBackgroundManager.c @@ -1,19 +1,25 @@ -#include "manager.h" +/** + * @file powBackgroundManager.c + * @ingroup Managers + * + * @brief Palace of Wind background animation. + */ +#include "manager/powBackgroundManager.h" #include "area.h" #include "room.h" #include "screen.h" -void sub_0805AFFC(Manager*); +void sub_0805AFFC(PowBackgroundManager*); -void Manager19_Main(Manager* this) { +void PowBackgroundManager_Main(PowBackgroundManager* this) { if (this == NULL) { if ((void*)gArea.onEnter != sub_0805AFFC) { sub_0805AFFC(this); } } else { - if (this->action == 0) { - this->action = 1; - this->unk_10 |= 0x20; + if (super->action == 0) { + super->action = 1; + super->flags |= ENT_PERSIST; SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { RegisterTransitionManager(this, sub_0805AFFC, NULL); @@ -28,7 +34,7 @@ void Manager19_Main(Manager* this) { } } -void sub_0805AFFC(Manager* this) { +void sub_0805AFFC(PowBackgroundManager* this) { gScreen.bg3.control = BGCNT_PRIORITY(3) | BGCNT_SCREENBASE(30); gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.bg3.xOffset = gRoomControls.scroll_x + gRoomControls.bg3OffsetX.HALF.HI; diff --git a/src/manager/pushableFurnitureManager.c b/src/manager/pushableFurnitureManager.c new file mode 100644 index 00000000..d8cb00d9 --- /dev/null +++ b/src/manager/pushableFurnitureManager.c @@ -0,0 +1,90 @@ +/** + * @file pushableFurnitureManager.c + * @ingroup Managers + * + * @brief Creates pushable furniture based on a room property list. + */ +#include "manager/pushableFurnitureManager.h" +#include "flags.h" +#include "object.h" +#include "room.h" + +void PushableFurnitureManager_Init(PushableFurnitureManager*); +void PushableFurnitureManager_Action1(PushableFurnitureManager*); +void PushableFurnitureManager_Action2(PushableFurnitureManager*); + +void sub_0805C7CC(PushableFurnitureManager*); + +void PushableFurnitureManager_Main(PushableFurnitureManager* this) { + static void (*const PushableFurnitureManager_Actions[])(PushableFurnitureManager*) = { + PushableFurnitureManager_Init, + PushableFurnitureManager_Action1, + PushableFurnitureManager_Action2, + }; + PushableFurnitureManager_Actions[super->action](this); +} + +void PushableFurnitureManager_Init(PushableFurnitureManager* this) { + UnkPushableFurnitureManagerHelperStruct* tmp = GetCurrentRoomProperty(super->type); + if (!tmp) { + DeleteManager(super); + return; + } + this->unk_2a = gRoomControls.origin_y + super->timer; + super->timer = 0; + this->unk_28 = 0; + this->unk_29 = 0; + while (tmp->unk_00 != 0xFF && super->timer < 0x20) { + Entity* obj; + obj = CreateObject(PUSHABLE_FURNITURE, tmp->unk_01, tmp->unk_02); + if (obj) { + obj->timer = tmp->unk_03; + obj->x.HALF.HI = gRoomControls.origin_x + tmp->unk_04; + obj->y.HALF.HI = gRoomControls.origin_y + tmp->unk_06; + obj->parent = (Entity*)this; + obj->collisionLayer = 1; + obj->field_0x82.HALF.HI = super->timer; + obj->field_0x82.HALF.LO = tmp->unk_00; + this->unk_29 |= 1 << super->timer; + } + tmp++; + super->timer++; + } + if (super->type2 == 0xFF) { + super->action = 2; + } else { + if (CheckLocalFlag(super->type2)) { + super->action = 2; + } else { + super->action = 1; + } + } +} + +void PushableFurnitureManager_Action1(PushableFurnitureManager* this) { + if (this->unk_28 == this->unk_29) { + super->action = 2; + SetLocalFlag(super->type2); + } + sub_0805C7CC(this); +} + +void PushableFurnitureManager_Action2(PushableFurnitureManager* this) { + sub_0805C7CC(this); +} + +void sub_0805C7CC(PushableFurnitureManager* this) { + if (gPlayerState.flags & PL_MINISH) { + if (gPlayerEntity.y.HALF.HI < this->unk_2a + 0x10) { + super->subAction = 1; + } else { + super->subAction = 0; + } + } else { + if (gPlayerEntity.y.HALF.HI < this->unk_2a + 0x28) { + super->subAction = 3; + } else { + super->subAction = 2; + } + } +} diff --git a/src/manager/railIntersectionManager.c b/src/manager/railIntersectionManager.c new file mode 100644 index 00000000..68a16d2e --- /dev/null +++ b/src/manager/railIntersectionManager.c @@ -0,0 +1,49 @@ +/** + * @file railIntersectionManager.c + * @ingroup Managers + * + * @brief Change the rail next to the rotating rail so that it connects. + */ +#include "manager/railIntersectionManager.h" +#include "flags.h" +#include "room.h" + +void sub_0805B778(RailIntersectionManager*); +void RailIntersectionManager_Init(RailIntersectionManager*); +void RailIntersectionManager_Action1(RailIntersectionManager*); + +void RailIntersectionManager_Main(RailIntersectionManager* this) { + static void (*const RailIntersectionManager_Actions[])(RailIntersectionManager*) = { + RailIntersectionManager_Init, + RailIntersectionManager_Action1, + }; + RailIntersectionManager_Actions[super->action](this); +} + +void RailIntersectionManager_Init(RailIntersectionManager* this) { + if (CheckFlags(this->flags)) { + super->type2 = 1; + } + super->action = 1; + this->field_0x38 = (this->field_0x38 >> 4 & 0x3fU) | (((this->field_0x3a << 0x10) >> 0x14 & 0x3fU) << 6); + sub_0805B778(this); +} + +void RailIntersectionManager_Action1(RailIntersectionManager* this) { + if (CheckFlags(this->flags)) { + if (super->type2 == 0) { + super->type2 = 1; + sub_0805B778(this); + } + } else { + if (super->type2 == 1) { + super->type2 = 0; + sub_0805B778(this); + } + } +} + +void sub_0805B778(RailIntersectionManager* this) { + static const u16 gUnk_08108C9C[] = { 0x358, 0x359, 0x356, 0x35a, 0x35a, 0x357 }; + SetTileType(gUnk_08108C9C[super->type * 2 + super->type2], this->field_0x38, this->field_0x36); +} diff --git a/src/manager/rainfallManager.c b/src/manager/rainfallManager.c new file mode 100644 index 00000000..2826a2c9 --- /dev/null +++ b/src/manager/rainfallManager.c @@ -0,0 +1,44 @@ +/** + * @file rainfallManager.c + * @ingroup Managers + * + * @brief Rainfall on the crenel minish path. + */ +#include "manager/rainfallManager.h" +#include "asm.h" +#include "room.h" +#include "enemy.h" + +void RainfallManager_Init(RainfallManager*); +void RainfallManager_Action1(RainfallManager*); + +void RainfallManager_Main(RainfallManager* this) { + static void (*const RainfallManager_Actions[])(RainfallManager*) = { + RainfallManager_Init, + RainfallManager_Action1, + }; + RainfallManager_Actions[super->action](this); +} + +// Initial setup +void RainfallManager_Init(RainfallManager* this) { + super->action = 1; + super->timer = 1; +} + +// Spawn water drops every 0xf frames +void RainfallManager_Action1(RainfallManager* this) { + static const s16 gUnk_08108C6C[] = { -0x64, -0x3c, -0x14, 0x14, 0x3c, 0x64, 0x8c, 0xb4 }; + static const s8 gUnk_08108C7C[] = { -0x32, -0x19, 0x0, 0x19 }; + + if (--super->timer == 0) { + Entity* waterDrop; + super->timer = 0xf; + waterDrop = CreateEnemy(WATER_DROP, 0); + if (waterDrop != NULL) { + waterDrop->x.HALF.HI = gRoomControls.scroll_x + 0x78 + gUnk_08108C6C[Random() & 7]; + waterDrop->y.HALF.HI = gRoomControls.scroll_y + 0x50 + gUnk_08108C7C[Random() & 3]; + waterDrop->z.HALF.HI = 0xff38; + } + } +} diff --git a/src/manager/regionTriggerManager.c b/src/manager/regionTriggerManager.c new file mode 100644 index 00000000..b8e534b0 --- /dev/null +++ b/src/manager/regionTriggerManager.c @@ -0,0 +1,49 @@ +/** + * @file regionTriggerManager.c + * @ingroup Managers + * + * @brief Set a flag if the player moves into a region. + */ +#include "manager/regionTriggerManager.h" +#include "asm.h" +#include "flags.h" + +enum RegionTriggerManager_State { Init, ObserveRegion }; + +void RegionTriggerManager_Init(RegionTriggerManager*); +void RegionTriggerManager_ObserveRegion(RegionTriggerManager*); + +void RegionTriggerManager_Main(RegionTriggerManager* this) { + static void (*const RegionTriggerManager_Actions[2])(RegionTriggerManager*) = { + RegionTriggerManager_Init, + RegionTriggerManager_ObserveRegion, + }; + RegionTriggerManager_Actions[super->action](this); +} + +void RegionTriggerManager_Init(RegionTriggerManager* this) { + super->action = ObserveRegion; + this->radiusX >>= 1; + this->posX += this->radiusX; + this->radiusY >>= 1; + this->posY += this->radiusY; + if (!super->type) { + if (CheckFlags(this->playerInRegionFlag)) { + DeleteManager(super); + return; + } + } + RegionTriggerManager_ObserveRegion(this); +} + +void RegionTriggerManager_ObserveRegion(RegionTriggerManager* this) { + if (CheckPlayerInRegion(this->posX, this->posY, this->radiusX, this->radiusY)) { + SetFlag(this->playerInRegionFlag); + if (!super->type) { + DeleteManager(super); + return; + } + } else { + ClearFlag(this->playerInRegionFlag); + } +} diff --git a/src/manager/repeatedSoundManager.c b/src/manager/repeatedSoundManager.c new file mode 100644 index 00000000..d55677d6 --- /dev/null +++ b/src/manager/repeatedSoundManager.c @@ -0,0 +1,49 @@ +/** + * @file repeatedSoundManager.c + * @ingroup Managers + * + * @brief Repeatedly plays the same sound with a fixed wait time. + */ +#include "manager/repeatedSoundManager.h" +#include "script.h" +#include "sound.h" + +typedef struct { + u16 waitTime; + u16 sound; +} RepeatedSoundManager_unk; + +void RepeatedSoundManager_Main(RepeatedSoundManager* this) { + static const RepeatedSoundManager_unk gUnk_08108DA8[] = { + { 0x10, SFX_ELEMENT_INFUSE }, { 0x20, SFX_1C8 }, { 0x20, SFX_1C8 }, { 0x40, SFX_1A9 }, { 0x20, SFX_21F } + }; + const RepeatedSoundManager_unk* unk = &gUnk_08108DA8[super->type]; + if (super->action == 0) { + super->action++; + super->timer = 0; + } + if (super->timer == 0) { + super->timer = unk->waitTime; + SoundReq(unk->sound); + } else { + super->timer--; + } +} + +void CreateRepeatedSoundManager(Entity* entity, ScriptExecutionContext* context) { + Manager* manager = GetEmptyManager(); + if (manager != NULL) { + manager->kind = MANAGER; + manager->id = REPEATED_SOUND_MANAGER; + manager->type = context->intVariable; + AppendEntityToList((Entity*)manager, 6); + SetDefaultPriority((Entity*)manager, PRIO_PLAYER_EVENT); + } +} + +void DeleteRepeatedSoundManager(Entity* entity, ScriptExecutionContext* context) { + Entity* manager = FindEntity(MANAGER, REPEATED_SOUND_MANAGER, 6, context->intVariable, 0); + if (manager != NULL) { + DeleteEntityAny(manager); + } +} diff --git a/src/manager/managerC.c b/src/manager/rollingBarrelManager.c similarity index 67% rename from src/manager/managerC.c rename to src/manager/rollingBarrelManager.c index ac7203c4..580734d9 100644 --- a/src/manager/managerC.c +++ b/src/manager/rollingBarrelManager.c @@ -1,53 +1,21 @@ -#include "global.h" -#include "sound.h" -#include "manager.h" -#include "flags.h" -#include "structures.h" -#include "room.h" -#include "screen.h" -#include "physics.h" -#include "functions.h" -#include "save.h" +/** + * @file rollingBarrelManager.c + * @ingroup Managers + * + * @brief Rolling barrel in Deepwood Shrine + */ +#include "manager/rollingBarrelManager.h" #include "area.h" #include "common.h" - -typedef struct { - Manager manager; - s32 unk_20; - union SplitWord unk_24; - u32 unk_28; - u32 unk_2c; - u8 unk_30[0x10]; -} ManagerC; - -typedef struct { - u16 unk_0; - u16 unk_2; - u16 unk_4; - u16 unk_6; -} struct_08108228; - -void sub_08058D34(void); - -void (*const gUnk_0810821C[])(ManagerC*); -const struct_08108228 gUnk_08108228[6]; -const struct_08108228 gUnk_08108258[6]; -const struct_08108228 gUnk_08108288[6]; -const struct_08108228 gUnk_081082B8[6]; -const u16 gUnk_081082E8[0xC]; -const u16 gUnk_08108300[4]; - -void sub_08058BC8(ManagerC*); -void sub_08058CB0(ManagerC*); -void sub_08058CFC(void); -void sub_08058A04(ManagerC*); -void sub_080588F8(ManagerC*); -u32 sub_08058B08(ManagerC*, u32, u32, const struct_08108228*); -void sub_08058B5C(ManagerC*, u32); - -extern void sub_0805622C(struct BgAffineDstData*, u32, u32); - -extern u8 gUnk_03003DE4[0xC]; +#include "flags.h" +#include "functions.h" +#include "main.h" +#include "physics.h" +#include "room.h" +#include "save.h" +#include "screen.h" +#include "sound.h" +#include "structures.h" extern struct BgAffineDstData gUnk_02017AA0[]; extern struct BgAffineDstData gUnk_02017BA0[]; @@ -55,43 +23,54 @@ extern u8 gUnk_02017700[]; extern u8 gUpdateVisibleTiles; extern u32 gUsedPalettes; -void sub_08058894(ManagerC*); -void sub_080588CC(ManagerC*); -void nullsub_108(ManagerC*); +void sub_08058D34(void); +void sub_08058BC8(RollingBarrelManager*); +void sub_08058CB0(RollingBarrelManager*); +void sub_08058CFC(void); +void sub_08058A04(RollingBarrelManager*); +void sub_080588F8(RollingBarrelManager*); +u32 sub_08058B08(RollingBarrelManager*, u32, u32, const struct_08108228*); +void sub_08058B5C(RollingBarrelManager*, u32); +void RollingBarrelManager_Init(RollingBarrelManager*); +void RollingBarrelManager_Action1(RollingBarrelManager*); +void RollingBarrelManager_Action2(RollingBarrelManager*); -void (*const gUnk_0810821C[])(ManagerC*) = { sub_08058894, sub_080588CC, nullsub_108 }; - -void ManagerC_Main(ManagerC* this) { +void RollingBarrelManager_Main(RollingBarrelManager* this) { + static void (*const RollingBarrelManager_Actions[])(RollingBarrelManager*) = { + RollingBarrelManager_Init, + RollingBarrelManager_Action1, + RollingBarrelManager_Action2, + }; u32 tmp; - gUnk_0810821C[this->manager.action](this); + RollingBarrelManager_Actions[super->action](this); sub_08058BC8(this); sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4[0] * 0xA0], 0x04000020, 0xA2600008); } -void sub_08058894(ManagerC* this) { - this->manager.action = 1; +void RollingBarrelManager_Init(RollingBarrelManager* this) { + super->action = 1; this->unk_28 = 0x1234; - this->manager.unk_0e = CheckLocalFlags(0x15, 0x2) != 0; + super->timer = CheckLocalFlags(0x15, 0x2) != 0; sub_08058CB0(this); RegisterTransitionManager(this, sub_08058D34, 0); } -void sub_080588CC(ManagerC* this) { +void RollingBarrelManager_Action1(RollingBarrelManager* this) { sub_08058CFC(); sub_08058A04(this); if (gRoomTransition.transitioningOut) { - this->manager.action = 2; + super->action = 2; } else { sub_080588F8(this); } } -void nullsub_108(ManagerC* this) { +void RollingBarrelManager_Action2(RollingBarrelManager* this) { } #define ABS_DIFF_GT(a, b, c) ((signed)(a) - (b) >= 0 ? (a) - (b) > (c) : (b) - (a) > (c)) -void sub_080588F8(ManagerC* this) { - if (this->manager.unk_0f == 0) { +void sub_080588F8(RollingBarrelManager* this) { + if (super->subtimer == 0) { if (ABS_DIFF_GT(this->unk_28, this->unk_24.HALF.HI, 8)) { this->unk_28 = 0x1234; switch (this->unk_24.HALF.HI & 0xFFFE) { @@ -99,23 +78,23 @@ void sub_080588F8(ManagerC* this) { case 0xa0: case 0xf0: this->unk_28 = this->unk_24.HALF.HI; - this->manager.unk_0f = 0x2D; + super->subtimer = 0x2D; SoundReq(SFX_BARREL_ROLL_STOP); } } } else { - this->manager.unk_0f--; - if (this->manager.unk_0f > 0x29) { + super->subtimer--; + if (super->subtimer > 0x29) { this->unk_24.HALF.HI = this->unk_28 - 2; } else { this->unk_24.HALF.HI = this->unk_28; } } - if (this->manager.unk_0e) { + if (super->timer) { s32 tmp = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; u32 tmp2; tmp2 = (((unsigned)(tmp - 0x50 < 0 ? 0x50 - tmp : tmp - 0x50) >> 3) * 0x3000) + 0x4000; - if (this->manager.unk_0f == 0) { + if (super->subtimer == 0) { if (tmp < 0x49) { this->unk_24.WORD -= tmp2; } else if (tmp > 0x57) { @@ -136,23 +115,23 @@ void sub_080588F8(ManagerC* this) { } } -const struct_08108228 gUnk_08108228[6] = { { 0x40, 0x2A, 0x1C, 0x10 }, { 0x3C, 0x24, 0x1C, 0x12 }, - { 0x3C, 0x1C, 0x1A, 0x18 }, { 0x38, 0x16, 0x1C, 0x16 }, - { 0x34, 0x16, 0x1E, 0x0E }, { 0x30, 0x16, 0x20, 0x0A } }; +void sub_08058A04(RollingBarrelManager* this) { + static const struct_08108228 gUnk_08108228[6] = { { 0x40, 0x2A, 0x1C, 0x10 }, { 0x3C, 0x24, 0x1C, 0x12 }, + { 0x3C, 0x1C, 0x1A, 0x18 }, { 0x38, 0x16, 0x1C, 0x16 }, + { 0x34, 0x16, 0x1E, 0x0E }, { 0x30, 0x16, 0x20, 0x0A } }; -const struct_08108228 gUnk_08108258[6] = { { 0x30, 0x88, 0x20, 0x0A }, { 0x34, 0x7E, 0x1E, 0x12 }, - { 0x38, 0x78, 0x1A, 0x16 }, { 0x3A, 0x70, 0x1A, 0x18 }, - { 0x3C, 0x64, 0x1E, 0x1E }, { 0x3E, 0x6A, 0x1C, 0x10 } }; + static const struct_08108228 gUnk_08108258[6] = { { 0x30, 0x88, 0x20, 0x0A }, { 0x34, 0x7E, 0x1E, 0x12 }, + { 0x38, 0x78, 0x1A, 0x16 }, { 0x3A, 0x70, 0x1A, 0x18 }, + { 0x3C, 0x64, 0x1E, 0x1E }, { 0x3E, 0x6A, 0x1C, 0x10 } }; -const struct_08108228 gUnk_08108288[6] = { { 0x98, 0x2A, 0x1C, 0x10 }, { 0x98, 0x24, 0x1C, 0x12 }, - { 0x9C, 0x1C, 0x1A, 0x18 }, { 0x9C, 0x16, 0x1C, 0x16 }, - { 0xA0, 0x16, 0x1E, 0x0E }, { 0xA0, 0x16, 0x20, 0x0A } }; + static const struct_08108228 gUnk_08108288[6] = { { 0x98, 0x2A, 0x1C, 0x10 }, { 0x98, 0x24, 0x1C, 0x12 }, + { 0x9C, 0x1C, 0x1A, 0x18 }, { 0x9C, 0x16, 0x1C, 0x16 }, + { 0xA0, 0x16, 0x1E, 0x0E }, { 0xA0, 0x16, 0x20, 0x0A } }; -const struct_08108228 gUnk_081082B8[6] = { { 0xA0, 0x88, 0x20, 0x0A }, { 0x9E, 0x7E, 0x1E, 0x12 }, - { 0x9C, 0x78, 0x1A, 0x16 }, { 0x9A, 0x70, 0x1A, 0x18 }, - { 0x98, 0x64, 0x1E, 0x1E }, { 0x98, 0x6A, 0x1C, 0x10 } }; + static const struct_08108228 gUnk_081082B8[6] = { { 0xA0, 0x88, 0x20, 0x0A }, { 0x9E, 0x7E, 0x1E, 0x12 }, + { 0x9C, 0x78, 0x1A, 0x16 }, { 0x9A, 0x70, 0x1A, 0x18 }, + { 0x98, 0x64, 0x1E, 0x1E }, { 0x98, 0x6A, 0x1C, 0x10 } }; -void sub_08058A04(ManagerC* this) { s32 tmp = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x; s32 tmp2 = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; if ((this->unk_20 - 0x118 < 0xDu) && CheckGlobalFlag(LV1TARU_OPEN) && (tmp - 0x6d < 0x17u) && @@ -186,7 +165,7 @@ void sub_08058A04(ManagerC* this) { } } -u32 sub_08058B08(ManagerC* this, u32 unk1, u32 unk2, const struct_08108228* unk3) { +u32 sub_08058B08(RollingBarrelManager* this, u32 unk1, u32 unk2, const struct_08108228* unk3) { u32 tmp = this->unk_20; if (tmp < unk1 || tmp > unk2) { return 0; @@ -201,9 +180,8 @@ u32 sub_08058B08(ManagerC* this, u32 unk1, u32 unk2, const struct_08108228* unk3 } } -const u16 gUnk_081082E8[0xC] = { 0xB8, 0x80, 0x0, 0xB8, 0x110, 0x2, 0x118, 0x80, 0x2, 0x118, 0x110, 0x0 }; - -void sub_08058B5C(ManagerC* this, u32 unk1) { +void sub_08058B5C(RollingBarrelManager* this, u32 unk1) { + static const u16 gUnk_081082E8[0xC] = { 0xB8, 0x80, 0x0, 0xB8, 0x110, 0x2, 0x118, 0x80, 0x2, 0x118, 0x110, 0x0 }; gRoomTransition.transitioningOut = 1; gRoomTransition.type = TRANSITION_DEFAULT; gRoomTransition.player_status.spawn_type = PL_SPAWN_STEP_IN; @@ -216,7 +194,7 @@ void sub_08058B5C(ManagerC* this, u32 unk1) { SoundReq(SFX_STAIRS); } -void sub_08058BC8(ManagerC* this) { +void sub_08058BC8(RollingBarrelManager* this) { struct BgAffineDstData* tmp = &gUnk_02017AA0[gUnk_03003DE4[0] * 0xA0]; struct BgAffineSrcData tmp2; s32 tmp3; @@ -248,9 +226,8 @@ void sub_08058BC8(ManagerC* this) { gScreen.controls.bg2.yPointMostSig = ((union SplitWord*)&tmp->dy)->HALF.HI; } -const u16 gUnk_08108300[4] = { 0xA4, 0x4C, 0xF4, 0x9C }; - -void sub_08058CB0(ManagerC* this) { +void sub_08058CB0(RollingBarrelManager* this) { + static const u16 gUnk_08108300[4] = { 0xA4, 0x4C, 0xF4, 0x9C }; u32 tmp = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x; u32 tmp2 = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; u32 tmp3; diff --git a/src/manager/secretManager.c b/src/manager/secretManager.c new file mode 100644 index 00000000..f5b1f281 --- /dev/null +++ b/src/manager/secretManager.c @@ -0,0 +1,125 @@ +/** + * @file secretManager.c + * @ingroup Managers + * + * @brief Sets a flag and plays a sound if another flag is set. + * + * unk_0a = 0 for testing one flag unk_0a = 1 for testing multiple flags + */ +#include "manager/secretManager.h" +#include "entity.h" +#include "flags.h" +#include "functions.h" +#include "sound.h" + +void SecretManager_Type0_Action2(SecretManager*); +void SecretManager_Type0(SecretManager*); +void SecretManager_Type1(SecretManager*); +void SecretManager_Type0_Init(SecretManager*); +void SecretManager_Type0_Action1(SecretManager*); +void SecretManager_Type0_Action2(SecretManager*); +void SecretManager_Type1_Action2(SecretManager*); +void SecretManager_Type1_Action1(SecretManager*); +void SecretManager_Type1_Init(SecretManager*); + +void SecretManager_Main(SecretManager* this) { + static void (*const SecretManager_Types[])(SecretManager*) = { + SecretManager_Type0, + SecretManager_Type1, + }; + SecretManager_Types[super->type](this); +} + +void SecretManager_Type0(SecretManager* this) { + static void (*const SecretManager_Type0_Actions[])(SecretManager*) = { + SecretManager_Type0_Init, + SecretManager_Type0_Action1, + SecretManager_Type0_Action2, + }; + SecretManager_Type0_Actions[super->action](this); +} + +void SecretManager_Type0_Init(SecretManager* this) { + if (CheckFlags(this->field_0x3c) != 0) { + DeleteThisEntity(); + } + if (CheckFlags(this->field_0x3e) != 0) { + SetFlag(this->field_0x3c); + DeleteThisEntity(); + } + super->action = 1; + if (super->timer == 0) { + super->timer = 0x1e; + } + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); +} + +void SecretManager_Type0_Action1(SecretManager* this) { + if ((CheckFlags(this->field_0x3e) != 0) && (gPriorityHandler.priority_timer < 2)) { + super->action = 2; + if (super->timer == 1) { + SecretManager_Type0_Action2(this); + } + RequestPriorityDuration((Entity*)this, super->timer); + } +} + +void SecretManager_Type0_Action2(SecretManager* this) { + if (gPriorityHandler.priority_timer == 0) { + if (this->field_0x38 != SFX_NONE) { + SoundReq(this->field_0x38); + } else { + SoundReq(SFX_SECRET); + } + if (this->field_0x3c != 0) { + SetFlag(this->field_0x3c); + } + DeleteThisEntity(); + } +} + +void SecretManager_Type1(SecretManager* this) { + static void (*const SecretManager_Type1_Actions[])(SecretManager*) = { + SecretManager_Type1_Init, + SecretManager_Type1_Action1, + SecretManager_Type1_Action2, + }; + SecretManager_Type1_Actions[super->action](this); +} + +void SecretManager_Type1_Init(SecretManager* this) { + CheckFlags(this->field_0x3e); + super->action = 1; + if (super->timer == 0) { + super->timer = 0x1e; + } + super->subtimer = super->timer; + SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); +} + +void SecretManager_Type1_Action1(SecretManager* this) { + if (CheckFlags(this->field_0x3e) != 0) { + super->action = 2; + super->timer = super->subtimer; + } +} + +void SecretManager_Type1_Action2(SecretManager* this) { + if (super->timer != 0) { + if (--super->timer == 0) { + Sound sound; + if (this->field_0x38 != SFX_NONE) { + sound = this->field_0x38; + } else { + sound = SFX_SECRET; + } + SoundReq(sound); + SetFlag(this->field_0x3c); + } + } else { + if (CheckFlags(this->field_0x3e) == 0) { + super->action = 1; + ClearFlag(this->field_0x3c); + } + } +} diff --git a/src/manager/specialWarpManager.c b/src/manager/specialWarpManager.c new file mode 100644 index 00000000..f387761e --- /dev/null +++ b/src/manager/specialWarpManager.c @@ -0,0 +1,35 @@ +/** + * @file specialWarpManager.c + * @ingroup Managers + * + * @brief Handles some special warps, like beanstalks, minish holes or the entrances into minish village + */ +#include "manager/specialWarpManager.h" +#include "asm.h" +#include "functions.h" + +void SpecialWarpManager_Main(SpecialWarpManager* this) { + u32 collisionLayer; + SpecialWarpManagerWarpData* data; + if (super->action == 0) { + super->action = 1; + this->warpList = GetCurrentRoomProperty(super->type); + if (this->warpList == NULL) { + DeleteManager(super); + return; + } + } + if (super->timer == 0 || gPlayerState.floor_type == SURFACE_LADDER) { + for (data = this->warpList; data->posX != 0xffff; data++) { + collisionLayer = (data->unk_07.all & 0x3); + if ((collisionLayer & gPlayerEntity.collisionLayer) != 0) { + if ((gPlayerState.flags & PL_MINISH) != 0 || data->unk_07.b.unk2 != 0) { + if (CheckPlayerInRegion(data->posX, data->posY, data->width, data->height) && + gPlayerEntity.z.HALF.HI == 0) { + DoExitTransition(GetCurrentRoomProperty(data->roomProperty)); + } + } + } + } + } +} diff --git a/src/manager/manager1B.c b/src/manager/staticBackgroundManager.c similarity index 70% rename from src/manager/manager1B.c rename to src/manager/staticBackgroundManager.c index a0b80066..156aa35d 100644 --- a/src/manager/manager1B.c +++ b/src/manager/staticBackgroundManager.c @@ -1,17 +1,17 @@ - -#include "manager.h" +/** + * @file staticBackgroundManager.c + * @ingroup Managers + * + * @brief Sets up static bg 3 images? + */ +#include "manager/staticBackgroundManager.h" +#include "common.h" #include "functions.h" #include "screen.h" -#include "common.h" -typedef struct { - Manager manager; - u32 field_0x20; -} Manager1B; - -void sub_0805B4B4(Manager1B*); -void sub_0805B448(Manager1B*); -void sub_0805B474(Manager1B*); +void sub_0805B4B4(StaticBackgroundManager*); +void sub_0805B448(StaticBackgroundManager*); +void sub_0805B474(StaticBackgroundManager*); void sub_0806D0F8(void); // in bigGoron? @@ -19,8 +19,8 @@ static const u8 gUnk_08108C28[] = { 0x14, 0x0, 0x0, 0x0, 0x15, 0x0, 0x0, 0x0, 0x70, 0x0, 0x4b, 0x0, 0x0, 0x0, 0x4e, 0x0, 0x0, 0x0, 0x4d, 0x1, 0x0, 0x0 }; static const u16 gUnk_08108C44[] = { 0, 0, -0x28, 0x70, 0, 0, 0, 0 }; -void Manager1B_Main(Manager1B* this) { - static void (*const gUnk_08108C54[])(Manager1B*) = { +void StaticBackgroundManager_Main(StaticBackgroundManager* this) { + static void (*const gUnk_08108C54[])(StaticBackgroundManager*) = { sub_0805B448, sub_0805B474, }; @@ -31,12 +31,12 @@ void Manager1B_Main(Manager1B* this) { if (EntityHasDuplicateID((Entity*)this) != 0) { DeleteThisEntity(); } - tmp = gUnk_08108C28 + this->manager.unk_0a * 4; - if (this->manager.action == 0) { - this->manager.action = 1; - this->manager.unk_10 |= 0x20; + tmp = gUnk_08108C28 + super->type * 4; + if (super->action == 0) { + super->action = 1; + super->flags |= ENT_PERSIST; SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); - if (this->manager.unk_0a != 0) { + if (super->type != 0) { RegisterTransitionManager(this, sub_0805B4B4, NULL); } iVar3 = 0x100 - (u32)gRoomControls.height; @@ -51,23 +51,23 @@ void Manager1B_Main(Manager1B* this) { } } -void sub_0805B448(Manager1B* this) { +void sub_0805B448(StaticBackgroundManager* this) { gScreen.bg3.xOffset = (gRoomControls.scroll_x - gRoomControls.origin_x) >> 2; gScreen.bg3.yOffset = ((gRoomControls.scroll_y - gRoomControls.origin_y) >> 1) + this->field_0x20; } -void sub_0805B474(Manager1B* this) { +void sub_0805B474(StaticBackgroundManager* this) { s32 tmp = ((gRoomControls.scroll_y - gRoomControls.origin_y) * 0x60) / (gRoomControls.height - 0xa0); gScreen.bg3.yOffset = gRoomControls.origin_y + tmp; gScreen.bg3.xOffset = gRoomControls.scroll_x - ((gRoomControls.width - 0x100) / 2); } -void sub_0805B4B4(Manager1B* this) { - sub_0805B4D0(this->manager.unk_0a); - if (this->manager.unk_0a == 2) { +void sub_0805B4B4(StaticBackgroundManager* this) { + sub_0805B4D0(super->type); + if (super->type == 2) { sub_0806D0F8(); } - Manager1B_Main(this); + StaticBackgroundManager_Main(this); } void sub_0805B4D0(u32 param_1) { diff --git a/src/manager/manager14.c b/src/manager/steamOverlayManager.c similarity index 58% rename from src/manager/manager14.c rename to src/manager/steamOverlayManager.c index 0ca86740..7214fb0c 100644 --- a/src/manager/manager14.c +++ b/src/manager/steamOverlayManager.c @@ -1,19 +1,15 @@ -#include "global.h" -#include "manager.h" -#include "screen.h" -#include "room.h" +/** + * @file steamOverlayManager.c + * @ingroup Managers + * + * @brief Steamy overlay bg in Cave of Flames. + */ +#include "manager/steamOverlayManager.h" #include "flags.h" -#include "physics.h" #include "main.h" - -typedef struct { - Manager manager; - u16 unk_20; - u8 unk_22; - u8 unk_23[1]; - u8 unk_24; - u8 unk_25[0x1B]; -} Manager14; +#include "physics.h" +#include "room.h" +#include "screen.h" const u16 gUnk_08108588[] = { 0x1000, 0xF01, 0xE02, 0xD03, 0xC04, 0xB05, 0xA06, 0x907, 0x808 }; @@ -21,37 +17,38 @@ const u16 gUnk_0810859A[] = { 0x808, 0x907, 0xA06, 0x907 }; extern u16 gUnk_02017AA0[]; -void sub_08059E80(Manager14*); -void sub_08059EF8(Manager14*); -u32 sub_08059F9C(Manager14*); -void sub_0805A040(Manager14*); -void sub_0805A048(Manager14*); -void sub_0805A098(Manager14*); -void sub_0805A0C0(Manager14*); +void SteamOverlayManager_Init(SteamOverlayManager*); +void SteamOverlayManager_Action4(SteamOverlayManager*); +u32 sub_08059F9C(SteamOverlayManager*); +void SteamOverlayManager_Action1(SteamOverlayManager*); +void SteamOverlayManager_Action2(SteamOverlayManager*); +void sub_0805A098(SteamOverlayManager*); +void SteamOverlayManager_Action3(SteamOverlayManager*); void sub_0805A114(u32, u32); -void sub_0805A1D8(Manager14*); +void sub_0805A1D8(SteamOverlayManager*); void nullsub_495(void*); void sub_0805A25C(void*); -void Manager14_Main(Manager14* this) { - static void (*const gUnk_081085A4[])(Manager14*) = { - sub_08059E80, sub_0805A040, sub_0805A048, sub_0805A0C0, sub_08059EF8, +void SteamOverlayManager_Main(SteamOverlayManager* this) { + static void (*const SteamOverlayManager_Actions[])(SteamOverlayManager*) = { + SteamOverlayManager_Init, SteamOverlayManager_Action1, SteamOverlayManager_Action2, + SteamOverlayManager_Action3, SteamOverlayManager_Action4, }; this->unk_20++; - gUnk_081085A4[this->manager.action](this); + SteamOverlayManager_Actions[super->action](this); sub_0805A1D8(this); } -void sub_08059E80(Manager14* this) { +void SteamOverlayManager_Init(SteamOverlayManager* this) { if (EntityHasDuplicateID((Entity*)this)) { DeleteThisEntity(); } this->unk_22 = 1; this->unk_20 = 0; - this->manager.unk_0e = 0; - this->manager.unk_0f = 4; - this->manager.action = 4; - this->manager.unk_10 |= 0x20; + super->timer = 0; + super->subtimer = 4; + super->action = 4; + super->flags |= ENT_PERSIST; gScreen.bg3.control = 0x1E04; gScreen.lcd.displayControl |= DISPCNT_BG3_ON; gScreen.controls.layerFXControl = 0x3E48; @@ -61,28 +58,28 @@ void sub_08059E80(Manager14* this) { RegisterTransitionManager(this, nullsub_495, sub_0805A25C); } -void sub_08059EF8(Manager14* this) { - u32 tmp = --this->manager.unk_0f; +void SteamOverlayManager_Action4(SteamOverlayManager* this) { + u32 tmp = --super->subtimer; if (tmp == 0) { - this->manager.unk_0f = 4; + super->subtimer = 4; if (sub_08059F9C(this)) { - if (gUnk_08108588[this->manager.unk_0e] != 0x808) { + if (gUnk_08108588[super->timer] != 0x808) { this->unk_22 = 1; this->unk_24 = tmp; - gScreen.controls.alphaBlend = gUnk_08108588[++this->manager.unk_0e]; + gScreen.controls.alphaBlend = gUnk_08108588[++super->timer]; } else { this->unk_22 = tmp; } } else { this->unk_22 = 1; - if (gUnk_08108588[this->manager.unk_0e] != 0x1000) { - gScreen.controls.alphaBlend = gUnk_08108588[--this->manager.unk_0e]; + if (gUnk_08108588[super->timer] != 0x1000) { + gScreen.controls.alphaBlend = gUnk_08108588[--super->timer]; } } } } -u32 sub_08059F9C(Manager14* this) { +u32 sub_08059F9C(SteamOverlayManager* this) { switch (gRoomControls.room) { case 1: if (CheckLocalFlag(0x16)) { @@ -106,23 +103,23 @@ u32 sub_08059F9C(Manager14* this) { } } -void sub_0805A040(Manager14* this) { +void SteamOverlayManager_Action1(SteamOverlayManager* this) { sub_0805A098(this); } -void sub_0805A048(Manager14* this) { - if (--this->manager.unk_0f == 0) { - this->manager.unk_0f = 4; - gScreen.controls.alphaBlend = gUnk_08108588[this->manager.unk_0e++]; - if (this->manager.unk_0e == 9) { - this->manager.action = 1; +void SteamOverlayManager_Action2(SteamOverlayManager* this) { + if (--super->subtimer == 0) { + super->subtimer = 4; + gScreen.controls.alphaBlend = gUnk_08108588[super->timer++]; + if (super->timer == 9) { + super->action = 1; this->unk_22 = 0; } } sub_0805A098(this); } -void sub_0805A098(Manager14* this) { +void sub_0805A098(SteamOverlayManager* this) { switch (gRoomControls.room) { case 0: case 8: @@ -130,15 +127,15 @@ void sub_0805A098(Manager14* this) { case 0x17: return; default: - this->manager.action = 3; + super->action = 3; } } -void sub_0805A0C0(Manager14* this) { - if (--this->manager.unk_0f == 0) { - this->manager.unk_0f = 4; - gScreen.controls.alphaBlend = gUnk_08108588[this->manager.unk_0e--]; - if (this->manager.unk_0e == 0xFF) { +void SteamOverlayManager_Action3(SteamOverlayManager* this) { + if (--super->subtimer == 0) { + super->subtimer = 4; + gScreen.controls.alphaBlend = gUnk_08108588[super->timer--]; + if (super->timer == 0xFF) { gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; sub_08056250(); DeleteThisEntity(); @@ -148,7 +145,7 @@ void sub_0805A0C0(Manager14* this) { void sub_0805A114(u32 unk0, u32 unk1) { s32 i; - u16* p = &gUnk_02017AA0[gUnk_03003DE4 * 0x500]; + u16* p = &gUnk_02017AA0[gUnk_03003DE4[0] * 0x500]; for (i = 0; i < 0xA0; i++) { s32 tmp = i + gScreen.bg3.yOffset; switch ((tmp >> 3) & 7) { @@ -168,10 +165,10 @@ void sub_0805A114(u32 unk0, u32 unk1) { } *p++ = gScreen.bg3.xOffset + ((gSineTable[(unk1 + tmp) & 0xFF] * unk0) >> 8); } - sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4 * 0x500], 0x0400001C, 0xA2600001); + sub_0805622C((struct BgAffineDstData*)&gUnk_02017AA0[gUnk_03003DE4[0] * 0x500], 0x0400001C, 0xA2600001); } -void sub_0805A1D8(Manager14* this) { +void sub_0805A1D8(SteamOverlayManager* this) { gRoomControls.bg3OffsetX.WORD -= 0x1000; gScreen.bg3.xOffset = gRoomControls.bg3OffsetX.HALF.HI; gRoomControls.bg3OffsetY.WORD -= 0x1000; diff --git a/src/manager/manager15.c b/src/manager/templeOfDropletsManager.c similarity index 53% rename from src/manager/manager15.c rename to src/manager/templeOfDropletsManager.c index 4eaa8486..38e0aac4 100644 --- a/src/manager/manager15.c +++ b/src/manager/templeOfDropletsManager.c @@ -1,76 +1,64 @@ -#include "global.h" -#include "sound.h" -#include "flags.h" -#include "screen.h" -#include "manager.h" -#include "object.h" -#include "structures.h" -#include "functions.h" +/** + * @file templeOfDropletsManager.c + * @ingroup Managers + * + * @brief Various managers in Temple of Droplets, e.g. Light rays + */ +#include "manager/templeOfDropletsManager.h" #include "enemy.h" - -typedef struct { - Manager manager; - u8 unk_20; - u8 unk_21; - u8 unk_22; - u8 unk_23; // used - u16 unk_24; - u16 unk_26; - void* unk_28; - u16 unk_2c; - u8 unk_2e[0x6]; - s16 unk_34; - s16 unk_36; - s16 unk_38; - s16 unk_3a; - u16 unk_3c; - u16 unk_3e; // used -} Manager15; +#include "flags.h" +#include "functions.h" +#include "object.h" +#include "screen.h" +#include "sound.h" +#include "structures.h" static const u16 gUnk_081085B8[] = { 0x1008, 0x1007, 0x1006, 0x1005, 0x1006, 0x1007, 0x1008, 0x1009, 0x1008, 0x1007, 0x1006, 0x1005, 0x1006, 0x1007, 0x1008, 0x1009 }; -void sub_0805A298(Manager15*); -void sub_0805A2E4(Manager15*); -void sub_0805A3D4(Manager15*); -void sub_0805A3D4(Manager15*); -void sub_0805A500(Manager15*); -void sub_0805A660(Manager15*); -void sub_0805A664(Manager15*); -void sub_0805A804(Manager15*); -void sub_0805A464(Manager15*); -void sub_0805A370(Manager15*); -void sub_0805A394(Manager15*); -void nullsub_496(Manager15*); -void sub_0805A89C(Manager15*); -void sub_0805A8EC(Manager15*); -void sub_0805A4B4(Manager15*); -void sub_0805A498(Manager15*); -void sub_0805A480(Manager15*); -void sub_0805A464(Manager15*); +void TempleOfDropletsManager_Type0(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type1(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type2(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type2(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type4(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type5(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type6(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type7(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type1_Action1(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type1_Action2(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type1_Action3(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type1_Action4(TempleOfDropletsManager*); +void sub_0805A89C(TempleOfDropletsManager*); +void sub_0805A8EC(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type2_Action4(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type2_Action3(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type2_Action2(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type1_Action1(TempleOfDropletsManager*); void sub_0805AAF0(u32); -void sub_0805AA58(Manager15*); -void sub_0805A9CC(Manager15*); -void sub_0805A5FC(Manager15*); -void sub_0805A618(Manager15*); -void sub_0805A628(Manager15*); -void sub_0805A64C(Manager15*); -void sub_0805A65C(Manager15*); -void sub_0805A68C(Manager15*); -void sub_0805A7E4(Manager15*); -void sub_0805A76C(Manager15*); -void sub_0805A758(Manager15*); -void sub_0805A6E8(Manager15*); +void sub_0805AA58(TempleOfDropletsManager*); +void sub_0805A9CC(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type4_Action1(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type4_Action2(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type4_Action3(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type4_Action4(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type4_Action5(TempleOfDropletsManager*); +void sub_0805A68C(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type6_Action3(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type6_Action2(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type6_Action1(TempleOfDropletsManager*); +void TempleOfDropletsManager_Type6_Init(TempleOfDropletsManager*); -void Manager15_Main(Manager* this) { - static void (*const gUnk_081085D8[])(Manager15*) = { - sub_0805A298, sub_0805A2E4, sub_0805A3D4, sub_0805A3D4, sub_0805A500, sub_0805A660, sub_0805A664, sub_0805A804, +void TempleOfDropletsManager_Main(TempleOfDropletsManager* this) { + static void (*const TempleOfDropletsManager_Types[])(TempleOfDropletsManager*) = { + TempleOfDropletsManager_Type0, TempleOfDropletsManager_Type1, TempleOfDropletsManager_Type2, + TempleOfDropletsManager_Type2, TempleOfDropletsManager_Type4, TempleOfDropletsManager_Type5, + TempleOfDropletsManager_Type6, TempleOfDropletsManager_Type7, }; - gUnk_081085D8[this->unk_0a]((Manager15*)this); + TempleOfDropletsManager_Types[super->type](this); } -void sub_0805A298(Manager15* this) { - if (this->manager.action == 0) { +void TempleOfDropletsManager_Type0(TempleOfDropletsManager* this) { + if (super->action == 0) { sub_0805A89C(this); if (!CheckLocalFlag(this->unk_3e)) { this->unk_23 = 1; @@ -83,44 +71,48 @@ void sub_0805A298(Manager15* this) { sub_0805A8EC(this); } -void sub_0805A2E4(Manager15* this) { - static void (*const actionFuncs[])(Manager15*) = { - NULL, sub_0805A464, sub_0805A370, sub_0805A394, nullsub_496, +void TempleOfDropletsManager_Type1(TempleOfDropletsManager* this) { + static void (*const TempleOfDropletsManager_Type1_Actions[])(TempleOfDropletsManager*) = { + NULL, + TempleOfDropletsManager_Type1_Action1, + TempleOfDropletsManager_Type1_Action2, + TempleOfDropletsManager_Type1_Action3, + TempleOfDropletsManager_Type1_Action4, }; - if (this->manager.action == 0) { + if (super->action == 0) { sub_0805A89C(this); this->unk_23 = 1; sub_0805AAF0(1); if (!CheckLocalFlag(this->unk_3e)) { - this->manager.action = 1; + super->action = 1; gScreen.lcd.displayControl &= 0xB7FF; } else { if (CheckLocalFlag(0x48)) { - this->manager.action = 4; + super->action = 4; } else { - this->manager.action = 3; + super->action = 3; } gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } } else { - actionFuncs[this->manager.action](this); + TempleOfDropletsManager_Type1_Actions[super->action](this); } - if (this->manager.next) { + if (super->next) { sub_0805A8EC(this); } } extern Entity gUnk_080E4C08; -void sub_0805A370(Manager15* this) { - if (this->manager.unk_0d) { +void TempleOfDropletsManager_Type1_Action2(TempleOfDropletsManager* this) { + if (super->subAction != 0) { LoadRoomEntityList((EntityData*)&gUnk_080E4C08); - this->manager.action = 3; + super->action = 3; SoundReq(SONG_STOP_BGM); } } -void sub_0805A394(Manager15* this) { +void TempleOfDropletsManager_Type1_Action3(TempleOfDropletsManager* this) { Entity* ent; if ((ent = FindEntityByID(ENEMY, CHUCHU_BOSS, 0x4))) { if (ent->type != 4) { @@ -133,16 +125,20 @@ void sub_0805A394(Manager15* this) { DeleteThisEntity(); } -void nullsub_496(Manager15* this) { +void TempleOfDropletsManager_Type1_Action4(TempleOfDropletsManager* this) { } -void sub_0805A3D4(Manager15* this) { - static void (*const gUnk_0810860C[])(Manager15*) = { - NULL, sub_0805A464, sub_0805A480, sub_0805A498, sub_0805A4B4, +void TempleOfDropletsManager_Type2(TempleOfDropletsManager* this) { + static void (*const TempleOfDropletsManager_Type2_Actions[])(TempleOfDropletsManager*) = { + NULL, + TempleOfDropletsManager_Type1_Action1, + TempleOfDropletsManager_Type2_Action2, + TempleOfDropletsManager_Type2_Action3, + TempleOfDropletsManager_Type2_Action4, }; - if (this->manager.action == 0) { + if (super->action == 0) { sub_0805A89C(this); - if (this->manager.unk_0a == 3) { + if (super->type == 3) { this->unk_23 = 2; } else { this->unk_23 = 1; @@ -150,147 +146,153 @@ void sub_0805A3D4(Manager15* this) { sub_0805AAF0(this->unk_23); if (!CheckLocalFlag(this->unk_3e)) { ClearFlag(this->unk_3c); - this->manager.action = 1; + super->action = 1; gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); } else { SetFlag(this->unk_3c); - this->manager.action = 3; + super->action = 3; gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } } else { - gUnk_0810860C[this->manager.action](this); + TempleOfDropletsManager_Type2_Actions[super->action](this); } sub_0805A8EC(this); } -void sub_0805A4CC(Manager15*, u32); +void sub_0805A4CC(TempleOfDropletsManager*, u32); -void sub_0805A464(Manager15* this) { +void TempleOfDropletsManager_Type1_Action1(TempleOfDropletsManager* this) { if (CheckLocalFlag(this->unk_3e)) { - this->manager.action = 2; + super->action = 2; sub_0805A4CC(this, 0); } } -void sub_0805A480(Manager15* this) { - if (this->manager.unk_0d != 0) { - this->manager.action = 3; +void TempleOfDropletsManager_Type2_Action2(TempleOfDropletsManager* this) { + if (super->subAction != 0) { + super->action = 3; SetFlag(this->unk_3c); } } -void sub_0805A498(Manager15* this) { +void TempleOfDropletsManager_Type2_Action3(TempleOfDropletsManager* this) { if (!CheckLocalFlag(this->unk_3e)) { - this->manager.action = 4; + super->action = 4; sub_0805A4CC(this, 1); } } -void sub_0805A4B4(Manager15* this) { - if (this->manager.unk_0d != 0) { - this->manager.action = 1; +void TempleOfDropletsManager_Type2_Action4(TempleOfDropletsManager* this) { + if (super->subAction != 0) { + super->action = 1; ClearFlag(this->unk_3c); } } -void sub_0805A4CC(Manager15* this, u32 unk_0) { +void sub_0805A4CC(TempleOfDropletsManager* this, u32 unk_0) { Entity* tmp; tmp = CreateObject(OBJECT_8E, unk_0, 0); if (tmp) { tmp->x.HALF.HI = this->unk_38 + gRoomControls.origin_x; tmp->y.HALF.HI = this->unk_3a + gRoomControls.origin_y - 0x30; tmp->parent = (Entity*)this; - this->manager.unk_0d = 0; + super->subAction = 0; } } -void sub_0805A500(Manager15* this) { - static void (*const actionFuncs[])(Manager15*) = { - NULL, sub_0805A5FC, sub_0805A618, sub_0805A628, sub_0805A64C, sub_0805A65C, +void TempleOfDropletsManager_Type4(TempleOfDropletsManager* this) { + static void (*const TempleOfDropletsManager_Type4_Actions[])(TempleOfDropletsManager*) = { + NULL, + TempleOfDropletsManager_Type4_Action1, + TempleOfDropletsManager_Type4_Action2, + TempleOfDropletsManager_Type4_Action3, + TempleOfDropletsManager_Type4_Action4, + TempleOfDropletsManager_Type4_Action5, }; - if (this->manager.action == 0) { + if (super->action == 0) { sub_0805A89C(this); this->unk_28 = 0; if (CheckLocalFlag(0x36)) { this->unk_23 = 3; - this->manager.action = 5; + super->action = 5; gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } else { if (CheckLocalFlag(0x34)) { this->unk_23 = 4; - this->manager.action = 3; + super->action = 3; gScreen.lcd.displayControl |= DISPCNT_WIN1_ON | DISPCNT_BG3_ON; } else { this->unk_23 = 4; - this->manager.action = 1; + super->action = 1; gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); } } sub_0805AAF0(this->unk_23); } else { - actionFuncs[this->manager.action](this); + TempleOfDropletsManager_Type4_Actions[super->action](this); } sub_0805AA58(this); sub_0805A9CC(this); if (gRoomControls.reload_flags == 1) { gScreen.lcd.displayControl |= DISPCNT_WIN1_ON; - this->manager.unk_0d = 1; + super->subAction = 1; return; } - if (!this->manager.unk_0d) + if (super->subAction == 0) return; - this->manager.unk_0d = 0; + super->subAction = 0; if (this->unk_20 == gRoomControls.room) return; gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); DeleteThisEntity(); } -void sub_0805A5FC(Manager15* this) { +void TempleOfDropletsManager_Type4_Action1(TempleOfDropletsManager* this) { if (CheckLocalFlag(0x34)) { - this->manager.action = 2; + super->action = 2; sub_0805A4CC(this, 2); } } -void sub_0805A618(Manager15* this) { - if (this->manager.unk_0d) { - this->manager.action = 3; +void TempleOfDropletsManager_Type4_Action2(TempleOfDropletsManager* this) { + if (super->subAction != 0) { + super->action = 3; } } -void sub_0805A628(Manager15* this) { +void TempleOfDropletsManager_Type4_Action3(TempleOfDropletsManager* this) { if (CheckLocalFlag(0x36)) { - this->manager.action = 4; + super->action = 4; this->unk_23 = 3; sub_0805A4CC(this, 3); } } -void sub_0805A64C(Manager15* this) { - if (this->manager.unk_0d) { - this->manager.action = 5; +void TempleOfDropletsManager_Type4_Action4(TempleOfDropletsManager* this) { + if (super->subAction != 0) { + super->action = 5; } } -void sub_0805A65C(Manager15* this) { -} -void sub_0805A660(Manager15* this) { +void TempleOfDropletsManager_Type4_Action5(TempleOfDropletsManager* this) { } -void sub_0805A664(Manager15* this) { - static void (*const gUnk_08108638[])(Manager15*) = { - sub_0805A6E8, - sub_0805A758, - sub_0805A76C, - sub_0805A7E4, +void TempleOfDropletsManager_Type5(TempleOfDropletsManager* this) { +} + +void TempleOfDropletsManager_Type6(TempleOfDropletsManager* this) { + static void (*const TempleOfDropletsManager_Type6_Actions[])(TempleOfDropletsManager*) = { + TempleOfDropletsManager_Type6_Init, + TempleOfDropletsManager_Type6_Action1, + TempleOfDropletsManager_Type6_Action2, + TempleOfDropletsManager_Type6_Action3, }; - gUnk_08108638[this->manager.action](this); + TempleOfDropletsManager_Type6_Actions[super->action](this); sub_0805A8EC(this); sub_0805A68C(this); } -void sub_0805A68C(Manager15* this) { +void sub_0805A68C(TempleOfDropletsManager* this) { if (CheckPlayerProximity(this->unk_38 - 0x18, this->unk_3a - 0x18, 0x30, 0x30)) { if (this->unk_2c <= 0x1007) { gScreen.controls.alphaBlend = ++this->unk_2c; @@ -304,9 +306,9 @@ void sub_0805A68C(Manager15* this) { } } -u32 sub_0805A73C(Manager15*); +u32 sub_0805A73C(TempleOfDropletsManager*); -void sub_0805A6E8(Manager15* this) { +void TempleOfDropletsManager_Type6_Init(TempleOfDropletsManager* this) { u16 tmp; sub_0805A89C(this); this->unk_23 = 0; @@ -314,30 +316,30 @@ void sub_0805A6E8(Manager15* this) { this->unk_38 += gRoomControls.origin_x; this->unk_3a += gRoomControls.origin_y; if (!sub_0805A73C(this)) { - this->manager.action++; + super->action++; } this->unk_2c = 0x1000; tmp = gScreen.lcd.displayControl | DISPCNT_WIN1_ON | DISPCNT_BG3_ON; gScreen.lcd.displayControl = tmp; } -u32 sub_0805A73C(Manager15* this) { +u32 sub_0805A73C(TempleOfDropletsManager* this) { return CheckPlayerProximity(this->unk_38 - 6, this->unk_3a - 6, 12, 12); } -void sub_0805A758(Manager15* this) { +void TempleOfDropletsManager_Type6_Action1(TempleOfDropletsManager* this) { if (!sub_0805A73C(this)) { - this->manager.action++; + super->action++; } } -void sub_0805A76C(Manager15* this) { +void TempleOfDropletsManager_Type6_Action2(TempleOfDropletsManager* this) { if ((gPlayerEntity.health != 0) && (gPlayerEntity.z.HALF.HI == 0) && (!gPlayerState.item)) { switch (gPlayerState.framestate_last) { case PL_STATE_IDLE: case PL_STATE_WALK: if (sub_0805A73C(this)) { - this->manager.action++; + super->action++; sub_08004168(&gPlayerEntity); gPlayerEntity.animationState = 4; RequestPriorityDuration((Entity*)this, 600); @@ -350,7 +352,7 @@ void sub_0805A76C(Manager15* this) { } } -void sub_0805A7E4(Manager15* this) { +void TempleOfDropletsManager_Type6_Action3(TempleOfDropletsManager* this) { if (gPlayerState.queued_action != PLAYER_WARP) { gPlayerState.queued_action = PLAYER_WARP; gPlayerState.field_0x38 = 0; @@ -358,38 +360,38 @@ void sub_0805A7E4(Manager15* this) { } } -void sub_0805A804(Manager15* this) { - switch (this->manager.action) { +void TempleOfDropletsManager_Type7(TempleOfDropletsManager* this) { + switch (super->action) { case 0: if (CheckLocalFlag(this->unk_3e)) { - this->manager.action = 1; + super->action = 1; } else { - this->manager.action = 2; + super->action = 2; } - this->manager.unk_0d = 1; - this->manager.unk_10 |= 0x20; + super->subAction = 1; + super->flags |= ENT_PERSIST; SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); break; case 1: if (CheckLocalFlag(this->unk_3e)) break; - this->manager.action = 2; + super->action = 2; sub_0805A4CC(this, 4); break; case 2: - if (this->manager.unk_0d) { - this->manager.action = 3; + if (super->subAction != 0) { + super->action = 3; } break; case 3: if (!CheckLocalFlag(this->unk_3e)) break; - this->manager.action = 4; + super->action = 4; sub_0805A4CC(this, 4); break; case 4: - if (this->manager.unk_0d) { - this->manager.action = 1; + if (super->subAction != 0) { + super->action = 1; } break; default: @@ -397,14 +399,14 @@ void sub_0805A804(Manager15* this) { } } -void sub_0805AAC8(Manager15*); +void sub_0805AAC8(TempleOfDropletsManager*); -void sub_0805A89C(Manager15* this) { +void sub_0805A89C(TempleOfDropletsManager* this) { SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); - this->manager.action = 1; - this->manager.unk_10 |= 0x20; - this->manager.unk_0e = 8; - this->manager.unk_0f = 0x10; + super->action = 1; + super->flags |= ENT_PERSIST; + super->timer = 8; + super->subtimer = 0x10; this->unk_21 = 0; this->unk_22 = 0; this->unk_20 = gRoomControls.room; @@ -413,18 +415,18 @@ void sub_0805A89C(Manager15* this) { RegisterTransitionManager(this, sub_0805AAC8, 0); } -void sub_0805A94C(Manager15* this); +void sub_0805A94C(TempleOfDropletsManager* this); -void sub_0805A8EC(Manager15* this) { +void sub_0805A8EC(TempleOfDropletsManager* this) { sub_0805AA58(this); sub_0805A94C(this); if (gRoomControls.reload_flags == 1) { gScreen.lcd.displayControl |= DISPCNT_WIN1_ON; - this->manager.unk_0d = 1; + super->subAction = 1; } else { - if (!this->manager.unk_0d) + if (super->subAction == 0) return; - this->manager.unk_0d = 0; + super->subAction = 0; if (this->unk_20 == gRoomControls.room) return; gScreen.lcd.displayControl &= ~(DISPCNT_WIN1_ON | DISPCNT_BG3_ON); @@ -432,7 +434,7 @@ void sub_0805A8EC(Manager15* this) { } } -void sub_0805A94C(Manager15* this) { +void sub_0805A94C(TempleOfDropletsManager* this) { int tmp1, tmp2; gScreen.bg3.xOffset = gRoomControls.scroll_x - this->unk_24 + this->unk_34; gScreen.bg3.yOffset = gRoomControls.scroll_y - this->unk_26 + this->unk_36; @@ -460,7 +462,7 @@ void sub_0805A94C(Manager15* this) { gScreen.controls.window1VerticalDimensions = (tmp1 << 8 | tmp2); } -void sub_0805A9CC(Manager15* this) { +void sub_0805A9CC(TempleOfDropletsManager* this) { int tmp1, tmp2; void* tmp3; gScreen.bg3.xOffset = gRoomControls.scroll_x - this->unk_24 + this->unk_34; @@ -488,24 +490,24 @@ void sub_0805A9CC(Manager15* this) { extern struct { u8 unk_00[0x20]; } gUnk_085A97A0[]; -void sub_0805AA58(Manager15* this) { - if (--this->manager.unk_0e == 0) { - this->manager.unk_0e = 8; +void sub_0805AA58(TempleOfDropletsManager* this) { + if (--super->timer == 0) { + super->timer = 8; this->unk_21 += 1; this->unk_21 &= 3; LoadPalettes(gUnk_085A97A0[this->unk_21].unk_00, 5, 1); } - if (--this->manager.unk_0f == 0) { - this->manager.unk_0f = 0x10; + if (--super->subtimer == 0) { + super->subtimer = 0x10; this->unk_22 += 1; this->unk_22 &= 0xF; gScreen.controls.alphaBlend = gUnk_081085B8[this->unk_22]; } } -void sub_0805AAC8(Manager15* this) { +void sub_0805AAC8(TempleOfDropletsManager* this) { sub_0805AAF0(this->unk_23); - Manager15_Main(&this->manager); + TempleOfDropletsManager_Main(this); } void sub_0805AADC(u32 unk0) { diff --git a/src/manager/tileChangeObserveManager.c b/src/manager/tileChangeObserveManager.c new file mode 100644 index 00000000..5e5e805d --- /dev/null +++ b/src/manager/tileChangeObserveManager.c @@ -0,0 +1,55 @@ +/** + * @file tileChangeObserveManager.c + * @ingroup Managers + * + * @brief Loads entity lists when a tile changes + * + * e.g. Puffstools in DWS if you suck away the dirt + * spawns the red portal in FoW if you move the stone + */ +#include "manager/tileChangeObserveManager.h" +#include "flags.h" +#include "functions.h" +#include "room.h" + +void TileChangeObserveManager_Init(TileChangeObserveManager*); +void TileChangeObserveManager_Action1(TileChangeObserveManager*); +void TileChangeObserveManager_Action2(TileChangeObserveManager*); + +void TileChangeObserveManager_Main(TileChangeObserveManager* this) { + static void (*const TileChangeObserveManager_Actions[])(TileChangeObserveManager*) = { + TileChangeObserveManager_Init, + TileChangeObserveManager_Action1, + TileChangeObserveManager_Action2, + }; + TileChangeObserveManager_Actions[super->action](this); +} + +void TileChangeObserveManager_Init(TileChangeObserveManager* this) { + u16* tile; + if (CheckFlags(this->flag) != 0) { + DeleteThisEntity(); + } else { + super->action = 1; + tile = &GetLayerByIndex(this->field_0x3a)->mapData[this->tilePosition]; + this->observedTile = tile; + this->initialTile = tile[0]; + } +} + +void TileChangeObserveManager_Action1(TileChangeObserveManager* this) { + if (this->initialTile != this->observedTile[0]) { + super->action++; + super->timer = 0xf; + } +} + +void TileChangeObserveManager_Action2(TileChangeObserveManager* this) { + if (--super->timer == 0) { + SetFlag(this->flag); + if (super->type != 0) { + LoadRoomEntityList((EntityData*)GetCurrentRoomProperty(super->type)); + } + DeleteManager(super); + } +} diff --git a/src/manager/manager30.c b/src/manager/tilePuzzleManager.c similarity index 65% rename from src/manager/manager30.c rename to src/manager/tilePuzzleManager.c index 6e551b8d..575c350e 100644 --- a/src/manager/manager30.c +++ b/src/manager/tilePuzzleManager.c @@ -1,42 +1,28 @@ -#include "global.h" -#include "asm.h" -#include "sound.h" -#include "manager.h" -#include "flags.h" -#include "functions.h" - -typedef struct Manager30 { - Manager manager; - u8 unk_20[8]; // unused - u16 own_tile; - u8 unk_2a[0x2]; // unused - u16 player_previous_tile; - u16 player_current_tile; - u8 unk_30[0x6]; // unused - u8 width; - u8 height; - s16 x; - s16 y; - u16 flag_succeeded; - u16 flag_reset; -} Manager30; - -enum { INIT, IN_PROGRESS, FAILED, SUCCEEDED }; - -/* - * Tile puzzles (step on all blue tiles exactly once). +/** + * @file tilePuzzleManager.c + * @ingroup Managers + * + * @brief Tile puzzles (step on all blue tiles exactly once). * * The Manager's field 0xe is used for the remaining number of tiles to be changed. * field 0xf is used for the total number of tiles to be changed. */ -void Manager30_Main(Manager30* this) { +#include "manager/tilePuzzleManager.h" +#include "asm.h" +#include "flags.h" +#include "functions.h" +#include "sound.h" + +enum { INIT, IN_PROGRESS, FAILED, SUCCEEDED }; + +void TilePuzzleManager_Main(TilePuzzleManager* this) { u32 i, j, tmp, tmp2; - switch (this->manager.action) { + switch (super->action) { default: break; case INIT: - this->manager.action = IN_PROGRESS; - this->manager.unk_0f = this->manager.unk_0e; + super->action = IN_PROGRESS; + super->subtimer = super->timer; this->own_tile = (((this->x >> 4) & 0x3fU) | ((this->y >> 4) & 0x3fU) << 6); this->player_previous_tile = this->player_current_tile = COORD_TO_TILE((&gPlayerEntity)); break; @@ -44,22 +30,22 @@ void Manager30_Main(Manager30* this) { this->player_current_tile = COORD_TO_TILE((&gPlayerEntity)); if (this->player_current_tile != this->player_previous_tile) { this->player_previous_tile = this->player_current_tile; - switch (GetTileType(this->player_current_tile, this->manager.unk_0b)) { + switch (GetTileType(this->player_current_tile, super->type2)) { case 0x317: // stepped on a red tile again - this->manager.action = FAILED; + super->action = FAILED; SoundReq(SFX_MENU_ERROR); break; case 0x318: // stepped on a blue tile // turn the tile into a red tile - sub_0807B7D8(0x317, this->player_current_tile, this->manager.unk_0b); + sub_0807B7D8(0x317, this->player_current_tile, super->type2); SoundReq(SFX_6B); // decrease the number of remaining tiles and check if we're done - if (--this->manager.unk_0e == 0) { - this->manager.action = SUCCEEDED; + if (--super->timer == 0) { + super->action = SUCCEEDED; // set up delay for setting the flag/playing the success sfx - this->manager.unk_0e = 0x40; + super->timer = 0x40; } break; } @@ -71,19 +57,19 @@ void Manager30_Main(Manager30* this) { if (!CheckFlags(this->flag_reset)) return; // wait for the flag telling it to reset ClearFlag(this->flag_reset); // make sure the puzzle can be reset again later - this->manager.action = IN_PROGRESS; - this->manager.unk_0e = this->manager.unk_0f; + super->action = IN_PROGRESS; + super->timer = super->subtimer; for (i = 0; i < this->height; i++) { tmp = this->own_tile + (i << 6); for (j = 0; j < this->width; j++) { - RestorePrevTileEntity(tmp + j, this->manager.unk_0b); + RestorePrevTileEntity(tmp + j, super->type2); } } break; case SUCCEEDED: - if (this->manager.unk_0e == 0) + if (super->timer == 0) return; - tmp2 = --this->manager.unk_0e; + tmp2 = --super->timer; if (tmp2) { if (tmp2 == 0x20) { SetFlag(this->flag_succeeded); diff --git a/src/manager/manager2F.c b/src/manager/vaati3BackgroundManager.c similarity index 71% rename from src/manager/manager2F.c rename to src/manager/vaati3BackgroundManager.c index 614e418a..5b3bcc18 100644 --- a/src/manager/manager2F.c +++ b/src/manager/vaati3BackgroundManager.c @@ -1,22 +1,27 @@ - -#include "manager.h" +/** + * @file vaati3BackgroundManager.c + * @ingroup Managers + * + * @brief Scrolling background during Vaati 3. + */ +#include "manager/vaati3BackgroundManager.h" #include "area.h" +#include "common.h" +#include "functions.h" #include "room.h" #include "screen.h" -#include "functions.h" -#include "common.h" -void sub_0805D470(Manager*); +void sub_0805D470(Vaati3BackgroundManager*); -void Manager2F_Main(Manager* this) { +void Vaati3BackgroundManager_Main(Vaati3BackgroundManager* this) { if (this == NULL) { if (gArea.onEnter != sub_0805D470) { sub_0805D470(NULL); } } else { - if (this->action == 0) { - this->action = 1; - this->unk_10 |= 0x20; + if (super->action == 0) { + super->action = 1; + super->flags |= ENT_PERSIST; SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT); if (gArea.onEnter == NULL) { RegisterTransitionManager(this, sub_0805D470, NULL); @@ -32,7 +37,7 @@ void Manager2F_Main(Manager* this) { } } -void sub_0805D470(Manager* this) { +void sub_0805D470(Vaati3BackgroundManager* this) { LoadGfxGroup(0x4c); gScreen.bg3.control = 0x1e07; gScreen.lcd.displayControl |= DISPCNT_BG3_ON; diff --git a/src/manager/manager34.c b/src/manager/vaati3InsideArmManager.c similarity index 51% rename from src/manager/manager34.c rename to src/manager/vaati3InsideArmManager.c index 455730a6..abd3e474 100644 --- a/src/manager/manager34.c +++ b/src/manager/vaati3InsideArmManager.c @@ -1,47 +1,48 @@ -#include "manager.h" -#include "structures.h" +/** + * @file vaati3InsideArmManager.c + * @ingroup Managers + * + * @brief Manages the inside of the arms of Vaati3. + */ +#include "manager/vaati3InsideArmManager.h" #include "functions.h" #include "sound.h" +#include "structures.h" -typedef struct { - Manager manager; - u16 field_0x20; -} Manager34; - -void sub_0805DBF0(Manager34*); -void sub_0805DBB4(Manager34*); -void sub_0805DBCC(Manager34*); -void nullsub_498(Manager34*); +void sub_0805DBF0(Vaati3InsideArmManager*); +void Vaati3InsideArmManager_Init(Vaati3InsideArmManager*); +void Vaati3InsideArmManager_Action1(Vaati3InsideArmManager*); +void Vaati3InsideArmManager_Action2(Vaati3InsideArmManager*); extern ScreenTransitionData gUnk_0813AC48; void sub_0805DC70(void); -void Manager34_Main(Manager34* this) { - static void (*const actionFuncs[])(Manager34*) = { - sub_0805DBB4, - sub_0805DBCC, - nullsub_498, +void Vaati3InsideArmManager_Main(Vaati3InsideArmManager* this) { + static void (*const Vaati3InsideArmManager_Actions[])(Vaati3InsideArmManager*) = { + Vaati3InsideArmManager_Init, + Vaati3InsideArmManager_Action1, + Vaati3InsideArmManager_Action2, }; - actionFuncs[this->manager.action](this); + Vaati3InsideArmManager_Actions[super->action](this); sub_0805DBF0(this); } -void sub_0805DBB4(Manager34* this) { - this->manager.action = 1; +void Vaati3InsideArmManager_Init(Vaati3InsideArmManager* this) { + super->action = 1; this->field_0x20 = gRoomTransition.field_0x3d * 0x3c; } -void sub_0805DBCC(Manager34* this) { - if (((this->manager.parent)->next == NULL) && (this->manager.action = 2, 0x12d < this->field_0x20)) { +void Vaati3InsideArmManager_Action1(Vaati3InsideArmManager* this) { + if (((super->parent)->next == NULL) && (super->action = 2, 0x12d < this->field_0x20)) { this->field_0x20 = 0x12d; } } -void nullsub_498(Manager34* this) { +void Vaati3InsideArmManager_Action2(Vaati3InsideArmManager* this) { } -void sub_0805DBF0(Manager34* this) { +void sub_0805DBF0(Vaati3InsideArmManager* this) { if (--this->field_0x20 == 0) { sub_0805DC70(); } else { diff --git a/src/manager/manager37.c b/src/manager/vaati3StartManager.c similarity index 52% rename from src/manager/manager37.c rename to src/manager/vaati3StartManager.c index 884bd8b7..c0d4124e 100644 --- a/src/manager/manager37.c +++ b/src/manager/vaati3StartManager.c @@ -1,48 +1,55 @@ -#include "manager.h" -#include "structures.h" -#include "functions.h" -#include "flags.h" -#include "message.h" -#include "sound.h" -#include "save.h" -#include "object.h" +/** + * @file vaati3StartManager.c + * @ingroup Managers + * + * @brief Manages the transition to and start of Vaati3. + */ +#include "manager/vaati3StartManager.h" #include "area.h" #include "enemy.h" +#include "flags.h" +#include "functions.h" +#include "message.h" +#include "object.h" +#include "save.h" #include "screen.h" +#include "sound.h" +#include "structures.h" extern ScreenTransitionData gUnk_0813AC34; void sub_0805E094(void); -void sub_0805DE50(Manager*); -void sub_0805DFE8(Manager*); -void sub_0805DE68(Manager*); -void sub_0805DEB8(Manager*); -void sub_0805DF4C(Manager*); -void sub_0805DF98(Manager*); -void sub_0805DFCC(Manager*); -void sub_0805E078(Manager*); -void sub_0805E000(Manager*); +void Vaati3StartManager_Type0(Vaati3StartManager*); +void Vaati3StartManager_Type1(Vaati3StartManager*); +void Vaati3StartManager_Type0_Init(Vaati3StartManager*); +void Vaati3StartManager_Type0_Action1(Vaati3StartManager*); +void Vaati3StartManager_Type0_Action2(Vaati3StartManager*); +void Vaati3StartManager_Type0_Action3(Vaati3StartManager*); +void Vaati3StartManager_Type0_Action4(Vaati3StartManager*); +void Vaati3StartManager_Type1_Action1(Vaati3StartManager*); +void Vaati3StartManager_Type1_Init(Vaati3StartManager*); -void Manager37_Main(Manager* this) { - static void (*const gUnk_08108DBC[])(Manager*) = { - sub_0805DE50, - sub_0805DFE8, +void Vaati3StartManager_Main(Vaati3StartManager* this) { + static void (*const Vaati3StartManager_Types[])(Vaati3StartManager*) = { + Vaati3StartManager_Type0, + Vaati3StartManager_Type1, }; - gUnk_08108DBC[this->unk_0a](this); + Vaati3StartManager_Types[super->type](this); } -void sub_0805DE50(Manager* this) { - static void (*const actionFuncs[])(Manager*) = { - sub_0805DE68, sub_0805DEB8, sub_0805DF4C, sub_0805DF98, sub_0805DFCC, +void Vaati3StartManager_Type0(Vaati3StartManager* this) { + static void (*const Vaati3StartManager_Type0_Actions[])(Vaati3StartManager*) = { + Vaati3StartManager_Type0_Init, Vaati3StartManager_Type0_Action1, Vaati3StartManager_Type0_Action2, + Vaati3StartManager_Type0_Action3, Vaati3StartManager_Type0_Action4, }; - actionFuncs[this->action](this); + Vaati3StartManager_Type0_Actions[super->action](this); } -void sub_0805DE68(Manager* this) { +void Vaati3StartManager_Type0_Init(Vaati3StartManager* this) { if (CheckLocalFlag(0x7b) == 0) { DeleteThisEntity(); } - this->action = 1; + super->action = 1; gRoomTransition.field_0x38 = 0; gRoomTransition.field_0x39 = 0x0f; *(u8*)&gRoomTransition.field_0x3a = 0x20; @@ -52,7 +59,7 @@ void sub_0805DE68(Manager* this) { #endif } -void sub_0805DEB8(Manager* this) { +void Vaati3StartManager_Type0_Action1(Vaati3StartManager* this) { s32 distX; s32 distY; Entity* object; @@ -60,9 +67,9 @@ void sub_0805DEB8(Manager* this) { distX = gPlayerEntity.x.HALF.HI - (gRoomControls.origin_x + 0x88); distY = gPlayerEntity.y.HALF.HI - (gRoomControls.origin_y + 0x40); if (distX * distX + distY * distY < 0x901) { - this->action = 2; - this->unk_0d = 0; - this->unk_0e = 0x78; + super->action = 2; + super->subAction = 0; + super->timer = 0x78; SetPlayerControl(2); sub_08078B48(); object = CreateObject(OBJECT_64, 0, 0); @@ -78,49 +85,49 @@ void sub_0805DEB8(Manager* this) { } } -void sub_0805DF4C(Manager* this) { +void Vaati3StartManager_Type0_Action2(Vaati3StartManager* this) { gPlayerEntity.animationState = 0; if (gPlayerEntity.z.HALF.HI != 0) { if (gPlayerEntity.y.HALF.HI < (gRoomControls.origin_y + 0x48)) { gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0x48; } } else { - if (--this->unk_0e == 0) { - this->action = 3; - this->unk_0e = 0x1e; + if (--super->timer == 0) { + super->action = 3; + super->timer = 0x1e; MessageFromTarget(TEXT_INDEX(TEXT_VAATI2, 0x4f)); } } } -void sub_0805DF98(Manager* this) { +void Vaati3StartManager_Type0_Action3(Vaati3StartManager* this) { if ((gMessage.doTextBox & 0x7f) == 0) { - if (this->unk_0e != 0) { - this->unk_0e -= 1; + if (super->timer != 0) { + super->timer--; } else { - this->action = 4; + super->action = 4; SetFade(FADE_IN_OUT | FADE_BLACK_WHITE | FADE_INSTANT, 4); SoundReq(SFX_EVAPORATE); } } } -void sub_0805DFCC(Manager* this) { +void Vaati3StartManager_Type0_Action4(Vaati3StartManager* this) { if (gFadeControl.active == 0) { ClearGlobalFlag(ZELDA_CHASE); sub_0805E094(); } } -void sub_0805DFE8(Manager* this) { - static void (*const actionFuncs[])(Manager*) = { - sub_0805E000, - sub_0805E078, +void Vaati3StartManager_Type1(Vaati3StartManager* this) { + static void (*const Vaati3StartManager_Type1_Actions[])(Vaati3StartManager*) = { + Vaati3StartManager_Type1_Init, + Vaati3StartManager_Type1_Action1, }; - actionFuncs[this->action](this); + Vaati3StartManager_Type1_Actions[super->action](this); } -void sub_0805E000(Manager* this) { +void Vaati3StartManager_Type1_Init(Vaati3StartManager* this) { Entity* enemy = CreateEnemy(VAATI_WRATH, 0); if (enemy != NULL) { enemy->x.HALF.HI = gRoomControls.origin_x + 0xb0; @@ -130,8 +137,8 @@ void sub_0805E000(Manager* this) { if ((gRoomTransition.field_0x38 & 1) != 0) { DeleteThisEntity(); } - *(Entity**)this->unk_18 = enemy; - this->action = 1; + super->child = enemy; + super->action = 1; SetPlayerControl(3); gArea.queued_bgm = 0x80010000; SetFade(FADE_BLACK_WHITE | FADE_INSTANT, 4); @@ -139,9 +146,9 @@ void sub_0805E000(Manager* this) { } } -void sub_0805E078(Manager* this) { +void Vaati3StartManager_Type1_Action1(Vaati3StartManager* this) { if (gFadeControl.active == 0) { - *(u8*)(((int*)this->unk_18)[0] + 0xd) = 1; + super->child->subAction = 1; DeleteThisEntity(); } } diff --git a/src/manager/manager32.c b/src/manager/vaatiAppearingManager.c similarity index 60% rename from src/manager/manager32.c rename to src/manager/vaatiAppearingManager.c index 4ba9245b..5db57799 100644 --- a/src/manager/manager32.c +++ b/src/manager/vaatiAppearingManager.c @@ -1,23 +1,22 @@ -#include "manager.h" -#include "screen.h" -#include "room.h" -#include "functions.h" +/** + * @file vaatiAppearingManager.c + * @ingroup Managers + * + * @brief Handles the appearing and disappearing effect for Vaati. + */ +#include "manager/vaatiAppearingManager.h" #include "area.h" #include "common.h" +#include "functions.h" #include "game.h" +#include "room.h" +#include "screen.h" -typedef struct { - Manager manager; - u32 field_0x20; - u32 field_0x24; - u32 field_0x28; -} Manager32; - -void sub_0805D9D8(Manager32*); -void sub_0805D98C(Manager32*); -void sub_0805D900(Manager32*); -void sub_0805D860(Manager32*); -void sub_0805D7DC(Manager32*); +void sub_0805D9D8(VaatiAppearingManager*); +void VaatiAppearingManager_Action3(VaatiAppearingManager*); +void VaatiAppearingManager_Action2(VaatiAppearingManager*); +void VaatiAppearingManager_Action1(VaatiAppearingManager*); +void VaatiAppearingManager_Init(VaatiAppearingManager*); void sub_0805DA08(u32, u32, u32); static const u8 gUnk_08108D74[] = { 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x0 }; @@ -26,23 +25,23 @@ extern struct BgAffineDstData gUnk_02017AA0[]; extern u8 gUnk_03003DE4[0xC]; extern void sub_0805622C(struct BgAffineDstData*, u32, u32); -void Manager32_Main(Manager32* this) { - static void (*const actionFuncs[])(Manager32*) = { - sub_0805D7DC, - sub_0805D860, - sub_0805D900, - sub_0805D98C, +void VaatiAppearingManager_Main(VaatiAppearingManager* this) { + static void (*const VaatiAppearingManager_Actions[])(VaatiAppearingManager*) = { + VaatiAppearingManager_Init, + VaatiAppearingManager_Action1, + VaatiAppearingManager_Action2, + VaatiAppearingManager_Action3, }; - actionFuncs[this->manager.action](this); + VaatiAppearingManager_Actions[super->action](this); this->field_0x24 = gRoomTransition.frameCount << 4; sub_0805D9D8(this); sub_0805DA08(this->field_0x20, this->field_0x28, this->field_0x24); } -void sub_0805D7DC(Manager32* this) { +void VaatiAppearingManager_Init(VaatiAppearingManager* this) { u32 index; - this->manager.action = (this->manager.unk_0a == 0) ? 1 : 2; + super->action = (super->type == 0) ? 1 : 2; this->field_0x20 = 0; this->field_0x24 = 0; switch (gRoomControls.area) { @@ -74,32 +73,32 @@ void sub_0805D7DC(Manager32* this) { gScreen.bg3.control = 0x1e04; } -void sub_0805D860(Manager32* this) { - switch (this->manager.unk_0d) { +void VaatiAppearingManager_Action1(VaatiAppearingManager* this) { + switch (super->subAction) { case 0: - this->manager.unk_0d = 1; + super->subAction = 1; this->field_0x20 = 0x80; gScreen.lcd.displayControl |= DISPCNT_BG3_ON; break; case 1: if (--this->field_0x20 == 0x10) { - this->manager.unk_0d = 2; - this->manager.unk_0e = 0x2d; + super->subAction = 2; + super->timer = 0x2d; } break; case 2: - if (--this->manager.unk_0e == 0) { - this->manager.unk_0d = 3; + if (--super->timer == 0) { + super->subAction = 3; } break; case 3: if (--this->field_0x20 == 0) { - this->manager.unk_0d = 4; - this->manager.unk_0e = 0x3c; + super->subAction = 4; + super->timer = 0x3c; } break; default: - if (--this->manager.unk_0e == 0) { + if (--super->timer == 0) { sub_0801E104(); gScreen.lcd.displayControl &= ~DISPCNT_BG3_ON; DeleteThisEntity(); @@ -107,26 +106,26 @@ void sub_0805D860(Manager32* this) { } } -void sub_0805D900(Manager32* this) { - switch (this->manager.unk_0d) { +void VaatiAppearingManager_Action2(VaatiAppearingManager* this) { + switch (super->subAction) { case 0: - this->manager.unk_0d = 1; - this->manager.unk_0e = 0x2d; + super->subAction = 1; + super->timer = 0x2d; this->field_0x20 = 1; gScreen.lcd.displayControl |= DISPCNT_BG3_ON; break; case 1: - if (--this->manager.unk_0e == 0) { - this->manager.unk_0d = 2; - this->manager.unk_0e = 0x14; + if (--super->timer == 0) { + super->subAction = 2; + super->timer = 0x14; } break; case 2: this->field_0x20 += 1; - if (--this->manager.unk_0e != 0) { + if (--super->timer != 0) { return; } - this->manager.unk_0d = 3; + super->subAction = 3; break; default: this->field_0x20 += 4; @@ -139,7 +138,7 @@ void sub_0805D900(Manager32* this) { } } -void sub_0805D98C(Manager32* this) { +void VaatiAppearingManager_Action3(VaatiAppearingManager* this) { if ((gInput.heldKeys & 0x40) != 0) { this->field_0x20 -= 1; } @@ -154,12 +153,11 @@ void sub_0805D98C(Manager32* this) { } } -void sub_0805D9D8(Manager32* this) { - // TODO find out the actual type of the parent of this manager. - Manager* pMVar1 = this->manager.parent; - if (pMVar1 != NULL) { - gScreen.bg3.xOffset = 0x80 - (*(s16*)&pMVar1[1].unk_0e - gRoomControls.scroll_x); - gScreen.bg3.yOffset = 0x8c - (*(s16*)(pMVar1[1].unk_11 + 1) - gRoomControls.scroll_y); +void sub_0805D9D8(VaatiAppearingManager* this) { + Entity* vaati = super->parent; + if (vaati != NULL) { + gScreen.bg3.xOffset = 0x80 - (vaati->x.HALF.HI - gRoomControls.scroll_x); + gScreen.bg3.yOffset = 0x8c - (vaati->y.HALF.HI - gRoomControls.scroll_y); } } @@ -173,13 +171,13 @@ void sub_0805DA08(u32 x, u32 y, u32 param_3) { sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4[0] * 0xa0], REG_ADDR_BG3HOFS, 0xa2600001); } -void sub_0805DA90(Manager32* this, u32 param_2) { +void CreateVaatiApparateManager(VaatiAppearingManager* this, u32 type) { Manager* manager = GetEmptyManager(); if (manager != NULL) { - manager->type = 9; - manager->subtype = 0x32; - manager->unk_0a = param_2; - manager->parent = &this->manager; + manager->kind = MANAGER; + manager->id = VAATI_APPARATE_MANAGER; + manager->type = type; + manager->parent = (Entity*)super; AppendEntityToList((Entity*)manager, 8); } if (gArea.onEnter != NULL) { diff --git a/src/manager/manager2.c b/src/manager/verticalMinishPathBackgroundManager.c similarity index 76% rename from src/manager/manager2.c rename to src/manager/verticalMinishPathBackgroundManager.c index af102652..d2978bb7 100644 --- a/src/manager/manager2.c +++ b/src/manager/verticalMinishPathBackgroundManager.c @@ -1,32 +1,30 @@ -#include "global.h" -#include "screen.h" +/** + * @file verticalMinishPathBackgroundManager.c + * @ingroup Managers + * + * @brief Parallax scrolling for MinishPaths vertical. + */ +#include "manager/verticalMinishPathBackgroundManager.h" +#include "common.h" #include "functions.h" #include "game.h" -#include "common.h" - -typedef struct { - Manager manager; - u32 field_0x20[0x6]; - void* field_0x38; - void* field_0x3c; -} Manager2; - +#include "screen.h" extern void sub_080576A0(void*); -extern void sub_0805754C(Manager2*); +extern void sub_0805754C(VerticalMinishPathBackgroundManager*); extern u8 gMapDataTopSpecial[]; -void Manager2_Main(Manager2* this) { - if (this->manager.action == 0) { - this->manager.action = 1; +void VerticalMinishPathBackgroundManager_Main(VerticalMinishPathBackgroundManager* this) { + if (super->action == 0) { + super->action = 1; gScreen.bg3.updated = 0; gScreen.bg1.updated = 0; - RegisterTransitionManager(this, sub_080576A0, 0); + RegisterTransitionManager(this, sub_080576A0, NULL); } sub_0805754C(this); } -void sub_0805754C(Manager2* this) { +void sub_0805754C(VerticalMinishPathBackgroundManager* this) { s32 bgOffset; bgOffset = (gRoomControls.scroll_y - gRoomControls.origin_y); @@ -50,7 +48,7 @@ void sub_0805754C(Manager2* this) { void sub_080575C8(u32 param) { s32 bgOffset; - gMapTop.bgControlPtr = 0; + gMapTop.bgSettings = 0; REG_DISPCNT = 0; LoadGfxGroup(param); gRoomVars.unk_10[0] = param; @@ -83,7 +81,7 @@ void sub_08057688(void) { void sub_080576A0(void* this) { LoadGfxGroup(gRoomVars.unk_10[0]); - ((Manager2*)this)->field_0x38 = NULL; - ((Manager2*)this)->field_0x3c = NULL; - sub_0805754C((Manager2*)this); + ((VerticalMinishPathBackgroundManager*)this)->field_0x38 = NULL; + ((VerticalMinishPathBackgroundManager*)this)->field_0x3c = NULL; + sub_0805754C((VerticalMinishPathBackgroundManager*)this); } diff --git a/src/manager/manager2D.c b/src/manager/waterfallBottomManager.c similarity index 54% rename from src/manager/manager2D.c rename to src/manager/waterfallBottomManager.c index 2f64249d..d449a3ae 100644 --- a/src/manager/manager2D.c +++ b/src/manager/waterfallBottomManager.c @@ -1,13 +1,20 @@ +/** + * @file waterfallBottomManager.c + * @ingroup Managers + * + * @brief Sets a tile at the bottom of the climb next to the waterfall in Temple of Droplets. + */ +#include "manager/waterfallBottomManager.h" #include "asm.h" #include "entity.h" #include "functions.h" -void Manager2D_Main(Entity* this) { +void WaterfallBottomManager_Main(WaterfallBottomManager* this) { SetTile(0x4014, 0x5c3, 1); if ((gRoomControls.origin_y + 200 < gPlayerEntity.y.HALF.HI) && ((u32)(gPlayerEntity.x.HALF.HI - gRoomControls.origin_x) - 0x30 < 0x11)) { gPlayerEntity.collisionLayer = 3; UpdateSpriteForCollisionLayer(&gPlayerEntity); } - DeleteManager((Manager*)this); + DeleteManager(super); } diff --git a/src/manager/manager10.c b/src/manager/weatherChangeManager.c similarity index 81% rename from src/manager/manager10.c rename to src/manager/weatherChangeManager.c index 58aaf3aa..c6c0c3d1 100644 --- a/src/manager/manager10.c +++ b/src/manager/weatherChangeManager.c @@ -1,18 +1,23 @@ -#include "global.h" -#include "asm.h" -#include "manager.h" -#include "room.h" +/** + * @file weatherChangeManager.c + * @ingroup Managers + * + * @brief Weather change on top of Mount Crenel. + */ +#include "manager/weatherChangeManager.h" #include "area.h" -#include "sound.h" -#include "screen.h" +#include "asm.h" #include "common.h" #include "fileselect.h" #include "functions.h" +#include "room.h" +#include "screen.h" +#include "sound.h" -void sub_080595E4(Manager10*); -void sub_08059608(Manager10*); -void sub_08059690(Manager10*); -void sub_080596E0(Manager10*); +void sub_080595E4(WeatherChangeManager*); +void sub_08059608(WeatherChangeManager*); +void sub_08059690(WeatherChangeManager*); +void sub_080596E0(WeatherChangeManager*); u32 sub_08059844(void); u32 sub_0805986C(void); void sub_08059894(const u16*, const u16*, u32); @@ -28,15 +33,15 @@ extern u8 gUnk_02017700[]; extern const u16 gPalette_549[]; -void Manager10_Main(Manager10* this) { - if (!this->manager.action) { - this->manager.action = 1; +void WeatherChangeManager_Main(WeatherChangeManager* this) { + if (super->action == 0) { + super->action = 1; this->unk_21 = 0; this->unk_23 = 0; if (sub_0805986C()) { this->unk_20 = 1; this->unk_22 = 2; - gMapTop.bgControlPtr = 0; + gMapTop.bgSettings = 0; } else { this->unk_20 = 0x1F; this->unk_22 = 5; @@ -49,14 +54,14 @@ void Manager10_Main(Manager10* this) { sub_080596E0(this); } -void sub_080595E4(Manager10* this) { +void sub_080595E4(WeatherChangeManager* this) { gRoomVars.unk_10[0] = 0xFF; sub_08059690(this); sub_080596E0(this); sub_0805B4D0(0); } -void sub_08059608(Manager10* this) { +void sub_08059608(WeatherChangeManager* this) { if (this->unk_23) { if (!--this->unk_23) { gArea.bgm = gArea.queued_bgm; @@ -79,7 +84,7 @@ void sub_08059608(Manager10* this) { } } -void sub_08059690(Manager10* this) { +void sub_08059690(WeatherChangeManager* this) { if (sub_08059844()) { if (this->unk_20 == 0) return; @@ -93,7 +98,7 @@ void sub_08059690(Manager10* this) { } } -void sub_080596E0(Manager10* this) { +void sub_080596E0(WeatherChangeManager* this) { if ((gRoomTransition.frameCount & 7) == 0) { gScreen.bg1.xOffset += 8; gScreen.bg1.xOffset &= 0x1F; @@ -102,27 +107,27 @@ void sub_080596E0(Manager10* this) { if (this->unk_21 == 0 && this->unk_22 != 2) { this->unk_21 = 1; this->unk_22 = 3; - this->manager.unk_0e = gUnk_08108390[3]; - gMapTop.bgControlPtr = 0; + super->timer = gUnk_08108390[3]; + gMapTop.bgSettings = 0; } } else { if (this->unk_21 == 0 && this->unk_22 != 5) { this->unk_21 = 2; - this->manager.unk_0e = gUnk_08108390[this->unk_22]; + super->timer = gUnk_08108390[this->unk_22]; } } switch (this->unk_21) { case 1: - if (--this->manager.unk_0e == 0) { - this->manager.unk_0e = gUnk_08108390[--this->unk_22]; + if (--super->timer == 0) { + super->timer = gUnk_08108390[--this->unk_22]; if (this->unk_22 == 2) { this->unk_21 = 0; } } break; case 2: - if (--this->manager.unk_0e == 0) { - this->manager.unk_0e = gUnk_08108390[++this->unk_22]; + if (--super->timer == 0) { + super->timer = gUnk_08108390[++this->unk_22]; if (this->unk_22 == 5) { this->unk_21 = 0; } @@ -140,7 +145,7 @@ void sub_080596E0(Manager10* this) { LoadResourceAsync(gBG3Buffer, 0x600e800, 0x800); break; case 5: - gMapTop.bgControlPtr = &gScreen.bg1.control; + gMapTop.bgSettings = &gScreen.bg1; gScreen.lcd.displayControl |= 0x200; break; } diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index d121a62a..d7c41850 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -134,7 +134,7 @@ static void sub_0806D02C(Entity* this) { } void sub_0806D0B0(Entity* this) { - gMapTop.bgControlPtr = 0; + gMapTop.bgSettings = 0; LoadGfxGroup(0x30); sub_0806D110(); MemClear(&gMapDataTopSpecial, 0x2000); diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 1f897e93..37f9ef3f 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -83,11 +83,11 @@ void sub_08069660(Entity* this) { void sub_08069684(void) { Manager* mgr; - if (FindEntityByID(MANAGER, 0x31, 8) == NULL) { + if (FindEntityByID(MANAGER, GORON_MERCHANT_SHOP_MANAGER, 8) == NULL) { mgr = GetEmptyManager(); if (mgr != NULL) { - mgr->type = 9; - mgr->subtype = 0x31; + mgr->kind = MANAGER; + mgr->id = GORON_MERCHANT_SHOP_MANAGER; AppendEntityToList((Entity*)mgr, 8); } } diff --git a/src/npc/vaati.c b/src/npc/vaati.c index c3691bc7..e9197a55 100644 --- a/src/npc/vaati.c +++ b/src/npc/vaati.c @@ -5,9 +5,9 @@ #include "functions.h" extern void sub_08095CB0(Entity*); -extern void CreateManager36(Entity*); -extern void DeleteManager36(Entity*); -extern void sub_0805DA90(Entity*, u32); +extern void CreateRepeatedSoundManager(Entity*); +extern void DeleteRepeatedSoundManager(Entity*); +extern void CreateVaatiApparateManager(Entity*, u32); void VaatiAction0(Entity*); void VaatiAction1(Entity*); @@ -49,12 +49,12 @@ void VaatiAction1(Entity* this) { case 3: tmp = (*(ScriptExecutionContext**)&this->cutsceneBeh); tmp->intVariable = 4; - CreateManager36(this); + CreateRepeatedSoundManager(this); break; case 4: tmp = (*(ScriptExecutionContext**)&this->cutsceneBeh); tmp->intVariable = 4; - DeleteManager36(this); + DeleteRepeatedSoundManager(this); EnqueueSFX(SFX_21D); break; } @@ -118,12 +118,12 @@ void sub_08066B74(Entity* this, ScriptExecutionContext* context) { HandlePostScriptActions(this, *(ScriptExecutionContext**)&this->cutsceneBeh); } -void sub_08066C94(Entity* this) { - sub_0805DA90(this, 0); +void Vaati_Apparate(Entity* this) { + CreateVaatiApparateManager(this, 0); SoundReq(SFX_APPARATE); } -void sub_08066CA4(Entity* this) { - sub_0805DA90(this, 1); +void Vaati_Evaporate(Entity* this) { + CreateVaatiApparateManager(this, 1); SoundReq(SFX_EVAPORATE); } diff --git a/src/object/object1C.c b/src/object/object1C.c index be2289cb..383fa130 100644 --- a/src/object/object1C.c +++ b/src/object/object1C.c @@ -4,7 +4,7 @@ extern u32 CheckRectOnScreen(s16, s16, u32, u32); /* -This object is created by Manager13. +This object is created by HouseSignManager. It checks whether the 0x10 x 0x10 rect at field_0x80, field_0x82 is still on the screen. If not, then it deletes itselfs and unsets the this->type2 bit in the managers field_0x20 bitfield. */ diff --git a/src/object/object86.c b/src/object/object86.c index 98017cc7..44e88e88 100644 --- a/src/object/object86.c +++ b/src/object/object86.c @@ -7,7 +7,7 @@ void sub_08099E10(Entity*); void sub_08099E58(Entity*); void sub_08099E8C(Entity*); void nullsub_534(Entity*); -extern void sub_0805B390(u32); +extern void CreateHoleManager(u32); void Object86(Entity* this) { static void (*const actionFuncs[])(Entity*) = { @@ -63,7 +63,7 @@ void sub_08099E8C(Entity* this) { RequestPriorityDuration(this, 0x1e); } if (CheckLocalFlag(0x75)) { - sub_0805B390(0x7); + CreateHoleManager(0x7); } } } diff --git a/src/object/objectAB.c b/src/object/objectAB.c index 4a35930f..ce6cd1fb 100644 --- a/src/object/objectAB.c +++ b/src/object/objectAB.c @@ -5,7 +5,7 @@ #include "player.h" #include "physics.h" -extern void sub_0805B390(u32); +extern void CreateHoleManager(u32); void ObjectAB_Init(Entity*); void ObjectAB_Action1(Entity*); @@ -45,7 +45,7 @@ void ObjectAB_Action2(Entity* this) { sub_080A0190(this); RequestPriorityDuration(this, 0x1e); if (EntityInRectRadius(this, &gPlayerEntity, 0x10, 0x10)) { - sub_0805B390(0x37); + CreateHoleManager(0x37); } } } diff --git a/src/playerUtils.c b/src/playerUtils.c index 923f5db3..09a3852a 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -14,6 +14,9 @@ #include "new_player.h" #include "item.h" #include "message.h" +#include "screen.h" +#include "screen.h" +#include "manager/diggingCaveEntranceManager.h" static void sub_08077E54(ItemBehavior* beh); @@ -127,6 +130,43 @@ extern const u16* sub_0806FC50(u32 param_1, u32 param_2); bool32 sub_08079F48(u32 param_1, u32 param_2); +extern void sub_08080B60(LayerStruct*); +extern void sub_0801AB08(u16*, LayerStruct*); + +extern u8 gUnk_02006F00[]; +extern u16 gUnk_080B77C0[]; + +void sub_0807BFA8(void); +void sub_080197D4(const void*); +void sub_0807C8B0(u16*, u32, u32); +void sub_0807C69C(u8*, u32, u32); +void sub_0807C460(void); +void sub_0807BBE4(void); +void sub_0807BC84(void); +void sub_0807C5F4(u16*, u16*); +void sub_0807C5B0(void); + +// collisions for metatiles < 0x4000 +extern const u8 gUnk_080B3E80[]; +// collisions for tiles > 0x4000 +extern const u8 gUnk_080B79A7[]; + +extern void sub_08080B60(LayerStruct*); +extern void sub_0801AB08(u16*, LayerStruct*); + +extern u8 gUnk_02006F00[]; +extern u16 gUnk_080B77C0[]; + +void sub_0807BFA8(void); +void sub_080197D4(const void*); +void sub_0807C8B0(u16*, u32, u32); +void sub_0807C69C(u8*, u32, u32); +void sub_0807C460(void); +void sub_0807BBE4(void); +void sub_0807BC84(void); +void sub_0807C5F4(u16*, u16*); +void sub_0807C5B0(void); + void sub_08077698(PlayerEntity* this) { ItemBehavior* puVar2; u32 idx; @@ -2466,7 +2506,43 @@ void sub_0807BB98(s32 basePosition, u32 layer, u32 width, u32 height) { } } -ASM_FUNC("asm/non_matching/playerUtils/sub_0807BBE4.inc", void sub_0807BBE4()) +void sub_0807BBE4(void) { + u32 tile; + u8* topCollision; + u8* bottomCollision; + u32 index; + u16* topMap; + u16* bottomMap; + u16* bottomMetatiles; + u16* topMetatiles; + + bottomMetatiles = gMapBottom.metatileTypes; + topMetatiles = gMapTop.metatileTypes; + + bottomMap = gMapBottom.mapData; + topMap = gMapTop.mapData; + bottomCollision = gMapBottom.collisionData; + topCollision = gMapTop.collisionData; + index = 0; + for (index = 0; index < 0x40 * 0x40; index++) { + tile = *bottomMap; + bottomMap++; + if (tile < 0x4000) { + *bottomCollision = gUnk_080B3E80[bottomMetatiles[tile]]; + } else { + *bottomCollision = gUnk_080B79A7[tile - 0x4000]; + } + bottomCollision++; + tile = (u32)*topMap; + topMap++; + if (tile < 0x4000) { + *topCollision = gUnk_080B3E80[topMetatiles[tile]]; + } else { + *topCollision = gUnk_080B79A7[tile - 0x4000]; + } + topCollision++; + } +} void sub_0807BC84(void) { s32 height; @@ -2661,7 +2737,107 @@ void sub_0807BFA8(void) { ASM_FUNC("asm/non_matching/playerUtils/sub_0807BFD0.inc", void sub_0807BFD0()) -ASM_FUNC("asm/non_matching/playerUtils/LoadRoomGfx.inc", void LoadRoomGfx()) +void LoadRoomGfx(void) { + RoomControls* roomControls; + bool32 tmp; + + sub_0807BFA8(); + roomControls = &gRoomControls; + roomControls->scroll_flags &= 0xfc; + MemClear(gMapTop.mapData, 0x2000); + MemClear(gMapTop.collisionData, 0x1000); + MemClear(&gMapDataBottomSpecial, 0x8000); + MemClear(&gMapDataTopSpecial, 0x8000); + sub_080197D4((gArea.pCurrentRoomInfo)->map); + if (gMapBottom.mapData[0] != 0xffff) { + sub_0807C8B0(gMapBottom.mapData, roomControls->width >> 4, roomControls->height >> 4); + sub_0807C8B0(gMapTop.mapData, roomControls->width >> 4, roomControls->height >> 4); + tmp = FALSE; + } else { + MemClear(gMapBottom.mapData, 0x2000); + tmp = TRUE; + } + if (gRoomTransition.field_0x2c[0] == 0) { + MemCopy(gMapBottom.mapData, gMapBottom.mapDataClone, 0x2000); + MemCopy(gMapTop.mapData, gMapTop.mapDataClone, 0x2000); + } else if (gRoomTransition.field_0x2c[0] == 2) { + MemCopy(gMapBottom.mapData, gMapBottom.unkData3, 0x1000); + MemCopy(gMapBottom.mapDataClone, gMapBottom.mapData, 0x1000); + MemCopy(gMapBottom.unkData3, gMapBottom.mapDataClone, 0x1000); + MemCopy(gMapBottom.mapData + 0x800, gMapBottom.unkData3, 0x1000); + MemCopy(gMapBottom.mapDataClone + 0x800, gMapBottom.mapData + 0x800, 0x1000); + MemCopy(gMapBottom.unkData3, gMapBottom.mapDataClone + 0x800, 0x1000); + MemCopy(gMapTop.mapData, gMapTop.unkData3, 0x1000); + MemCopy(gMapTop.mapDataClone, gMapTop.mapData, 0x1000); + MemCopy(gMapTop.unkData3, gMapTop.mapDataClone, 0x1000); + MemCopy(gMapTop.mapData + 0x800, gMapTop.unkData3, 0x1000); + MemCopy(gMapTop.mapDataClone + 0x800, gMapTop.mapData + 0x800, 0x1000); + MemCopy(gMapTop.unkData3, gMapTop.mapDataClone + 0x800, 0x1000); + } + if (!tmp) { + sub_0807BBE4(); + } else { + sub_0807C69C(gMapBottom.collisionData, roomControls->width >> 4, roomControls->height >> 4); + sub_0807C69C(gMapTop.collisionData, roomControls->width >> 4, roomControls->height >> 4); + sub_0807C460(); + } + sub_0807BC84(); + sub_08080B60(&gMapBottom); + sub_08080B60(&gMapTop); + if (!tmp) { + sub_0801AB08((u16*)&gMapDataBottomSpecial, &gMapBottom); + sub_0801AB08((u16*)&gMapDataTopSpecial, &gMapTop); + } else { + MemCopy(&gMapDataBottomSpecial, &gMapDataBottomSpecial[0x2000], 0x4000); // TODO + sub_0807C5F4((u16*)&gMapDataBottomSpecial, &gMapDataBottomSpecial[0x2000]); + MemClear(&gMapDataBottomSpecial[0x2000], 0x4000); + MemCopy(&gMapDataTopSpecial, &gMapDataTopSpecial[0x2000], 0x4000); + sub_0807C5F4((u16*)&gMapDataTopSpecial, (u16*)&gMapDataTopSpecial[0x2000]); + MemClear(&gMapDataTopSpecial[0x2000], 0x4000); + } + if (tmp || roomControls->area == 0x71) { + roomControls->scroll_flags |= 1; + } + + switch (roomControls->area) { + case 0x20: + case 0x2d: + if (gMapBottom.bgSettings != NULL) { + gMapBottom.bgSettings->control |= 0x80; + } + gScreen.lcd.displayControl &= 0xfdff; + break; + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x27: + case 0x28: + case 0x30: + case 0x38: + if (gMapTop.bgSettings != NULL) { + gMapTop.bgSettings->control = gUnk_080B77C0[2]; + } + sub_0807C5B0(); + break; + default: + if (gMapBottom.bgSettings != NULL) { + gMapBottom.bgSettings->control = gUnk_080B77C0[0]; + } + if (gMapTop.bgSettings != NULL) { + gMapTop.bgSettings->control = gUnk_080B77C0[1]; + } + + gScreen.lcd.displayControl = (gScreen.lcd.displayControl & 0x800) | DISPCNT_OBJ_ON | DISPCNT_BG2_ON | + DISPCNT_BG1_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP; + + if (gArea.lightType != 0) { + gScreen.lcd.displayControl |= DISPCNT_OBJWIN_ON | DISPCNT_WIN0_ON; + } + break; + } +} void sub_0807C460(void) { u32 x; @@ -2692,24 +2868,48 @@ void sub_0807C460(void) { ASM_FUNC("asm/non_matching/playerUtils/sub_0807C4F8.inc", void sub_0807C4F8()) -ASM_FUNC("asm/non_matching/playerUtils/sub_0807C5B0.inc", void sub_0807C5B0()) +void sub_0807C5B0(void) { + u8 colTop; + u8 colBot; + u8* puVar2; + u8* collisionTop = gMapTop.collisionData; + u32 thousand = 0x1000; + u32 index = 0; + RoomControls* roomControls = &gRoomControls; + u8* collisionBottom = gMapBottom.collisionData; + while (index < thousand) { + colTop = collisionTop[index]; + if (colTop != 0) { + if (colTop < 0x10) { + colBot = collisionBottom[index]; + if (colBot < 0x10) { + collisionBottom[index] = colTop | colBot; + } + } else { + collisionBottom[index] = collisionTop[index]; + } + } + index++; + } + roomControls->scroll_flags |= 2; +} -ASM_FUNC("asm/non_matching/playerUtils/sub_0807C5F4.inc", void sub_0807C5F4()) +ASM_FUNC("asm/non_matching/playerUtils/sub_0807C5F4.inc", void sub_0807C5F4(u16* a, u16* b)) -ASM_FUNC("asm/non_matching/playerUtils/sub_0807C69C.inc", void sub_0807C69C()) +ASM_FUNC("asm/non_matching/playerUtils/sub_0807C69C.inc", void sub_0807C69C(u8* a, u32 b, u32 c)) ASM_FUNC("asm/non_matching/playerUtils/sub_0807C740.inc", void InitializeCamera()) void sub_0807C810(void) { - struct_03004030* ptr; + DiggingCaveEntranceTransition* ptr; Entity* player; RoomControls* ctrls; sub_0807BFD0(); - ptr = &gUnk_03004030; + ptr = &gDiggingCaveEntranceTransition; player = &gPlayerEntity; ctrls = &gRoomControls; - player->x.HALF.HI = ((ptr->unk_00)->unk_06 & 0x3f) * 0x10 + ctrls->origin_x + ptr->unk_04; - player->y.HALF.HI = (((ptr->unk_00)->unk_06 & 0xfc0) >> 2) + ctrls->origin_y + ptr->unk_06; + player->x.HALF.HI = ((ptr->entrance)->targetTilePosition & 0x3f) * 0x10 + ctrls->origin_x + ptr->offsetX; + player->y.HALF.HI = (((ptr->entrance)->targetTilePosition & 0xfc0) >> 2) + ctrls->origin_y + ptr->offsetY; sub_080809D4(); gUpdateVisibleTiles = 0; } @@ -2729,7 +2929,7 @@ void sub_0807C898(void) { gRoomTransition.field_0x2c[0] = 0; } -ASM_FUNC("asm/non_matching/playerUtils/sub_0807C8B0.inc", void sub_0807C8B0()) +ASM_FUNC("asm/non_matching/playerUtils/sub_0807C8B0.inc", void sub_0807C8B0(u16* a, u32 b, u32 c)) void LoadCompressedMapData(void* dest, u32 offset) { void* src; diff --git a/src/projectile/removableDust.c b/src/projectile/removableDust.c index 86fa2908..aa4054ec 100644 --- a/src/projectile/removableDust.c +++ b/src/projectile/removableDust.c @@ -3,6 +3,7 @@ #include "physics.h" #include "functions.h" #include "object.h" +#include "room.h" extern u32 sub_080B1AE0(u16, u8); diff --git a/src/room.c b/src/room.c index f4ef24c7..02a61d78 100644 --- a/src/room.c +++ b/src/room.c @@ -1,16 +1,16 @@ -#include "global.h" #include "area.h" -#include "room.h" +#include "common.h" #include "flags.h" #include "functions.h" -#include "common.h" -#include "object.h" #include "game.h" +#include "global.h" +#include "manager/bombableWallManager.h" +#include "object.h" +#include "room.h" static void sub_0804B058(EntityData* dat); extern void sub_0801AC98(void); extern u32 sub_08049D1C(u32); -extern Entity* LoadRoomEntity(const EntityData*); extern void* GetRoomProperty(u32, u32, u32); extern void** gCurrentRoomProperties; @@ -65,7 +65,7 @@ NONMATCH("asm/non_matching/LoadRoomEntity.inc", Entity* LoadRoomEntity(const Ent if ((dat->flags & 0xF0) != 16) { v5->type2 = dat->type2; v5->timer = (dat->type2 & 0xFF00) >> 8; - if (kind == 9) + if (kind == MANAGER) return v5; sub_0804AF0C(v5, dat); if (v5->next == NULL) @@ -327,10 +327,10 @@ static void LoadSmallChestTile(TileEntity* tile) { } static void LoadBombableWallTile(TileEntity* tile) { - Manager24* mgr = (Manager24*)GetEmptyManager(); + BombableWallManager* mgr = (BombableWallManager*)GetEmptyManager(); if (mgr != NULL) { - mgr->manager.type = 9; - mgr->manager.subtype = 0x24; + mgr->base.kind = MANAGER; + mgr->base.id = BOMBABLE_WALL_MANAGER; mgr->x = tile->tilePos; mgr->y = *(u16*)&tile->_6; mgr->field_0x35 = tile->_2; @@ -351,8 +351,8 @@ static void LoadDestructibleTile(TileEntity* tile) { gRoomVars.filler_0x1 = 1; mgr = GetEmptyManager(); if (mgr != NULL) { - mgr->type = 9; - mgr->subtype = 0x2a; + mgr->kind = MANAGER; + mgr->id = DESTRUCTIBLE_TILE_OBSERVE_MANAGER; AppendEntityToList((Entity*)mgr, 6); } } diff --git a/src/roomInit.c b/src/roomInit.c index 8578ebd6..756c5404 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -2516,7 +2516,7 @@ extern EntityData gUnk_additional_a_CaveOfFlamesBoss_Main; void sub_StateChange_CaveOfFlamesBoss_Main(void) { if (CheckGlobalFlag(LV2_CLEAR)) { - gMapTop.bgControlPtr = 0; + gMapTop.bgSettings = 0; gScreen.lcd.displayControl &= ~DISPCNT_BG1_ON; sub_0807AABC(&gPlayerEntity); LoadRoomEntityList(&gUnk_additional_a_CaveOfFlamesBoss_Main); @@ -3161,7 +3161,7 @@ extern EntityData gUnk_080E72C4; extern EntityData gUnk_additional_8_PalaceOfWinds_GyorgTornado; void sub_StateChange_PalaceOfWinds_GyorgTornado(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); if (CheckGlobalFlag(LV5_CLEAR)) { LoadRoomEntityList(&gUnk_additional_9_PalaceOfWinds_GyorgTornado); } @@ -3183,7 +3183,7 @@ u32 sub_unk3_PalaceOfWinds_BossKey(void) { } void sub_StateChange_PalaceOfWinds_BossKey(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_BeforeBallAndChainSoldiers(void) { @@ -3191,7 +3191,7 @@ u32 sub_unk3_PalaceOfWinds_BeforeBallAndChainSoldiers(void) { } void sub_StateChange_PalaceOfWinds_BeforeBallAndChainSoldiers(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_GyorgBossDoor(void) { @@ -3199,7 +3199,7 @@ u32 sub_unk3_PalaceOfWinds_GyorgBossDoor(void) { } void sub_StateChange_PalaceOfWinds_GyorgBossDoor(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_EastChestFromGyorgBossDoor(void) { @@ -3207,7 +3207,7 @@ u32 sub_unk3_PalaceOfWinds_EastChestFromGyorgBossDoor(void) { } void sub_StateChange_PalaceOfWinds_EastChestFromGyorgBossDoor(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_MoblinAndWizzrobeFight(void) { @@ -3215,7 +3215,7 @@ u32 sub_unk3_PalaceOfWinds_MoblinAndWizzrobeFight(void) { } void sub_StateChange_PalaceOfWinds_MoblinAndWizzrobeFight(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_FourButtonStalfos(void) { @@ -3223,7 +3223,7 @@ u32 sub_unk3_PalaceOfWinds_FourButtonStalfos(void) { } void sub_StateChange_PalaceOfWinds_FourButtonStalfos(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_FanAndKeyToBossKey(void) { @@ -3231,7 +3231,7 @@ u32 sub_unk3_PalaceOfWinds_FanAndKeyToBossKey(void) { } void sub_StateChange_PalaceOfWinds_FanAndKeyToBossKey(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_BallAndChainSoldiers(void) { @@ -3239,7 +3239,7 @@ u32 sub_unk3_PalaceOfWinds_BallAndChainSoldiers(void) { } void sub_StateChange_PalaceOfWinds_BallAndChainSoldiers(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_BombarossaPath(void) { @@ -3247,7 +3247,7 @@ u32 sub_unk3_PalaceOfWinds_BombarossaPath(void) { } void sub_StateChange_PalaceOfWinds_BombarossaPath(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_HoleToDarknut(void) { @@ -3255,7 +3255,7 @@ u32 sub_unk3_PalaceOfWinds_HoleToDarknut(void) { } void sub_StateChange_PalaceOfWinds_HoleToDarknut(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_ToBombarossaPath(void) { @@ -3263,7 +3263,7 @@ u32 sub_unk3_PalaceOfWinds_ToBombarossaPath(void) { } void sub_StateChange_PalaceOfWinds_ToBombarossaPath(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_DarknutMiniboss(void) { @@ -3271,7 +3271,7 @@ u32 sub_unk3_PalaceOfWinds_DarknutMiniboss(void) { } void sub_StateChange_PalaceOfWinds_DarknutMiniboss(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_BombWallInside(void) { @@ -3279,7 +3279,7 @@ u32 sub_unk3_PalaceOfWinds_BombWallInside(void) { } void sub_StateChange_PalaceOfWinds_BombWallInside(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_BombWallOutside(void) { @@ -3287,7 +3287,7 @@ u32 sub_unk3_PalaceOfWinds_BombWallOutside(void) { } void sub_StateChange_PalaceOfWinds_BombWallOutside(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_CloudJumps(void) { @@ -3295,7 +3295,7 @@ u32 sub_unk3_PalaceOfWinds_CloudJumps(void) { } void sub_StateChange_PalaceOfWinds_CloudJumps(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_BlockMazeToBossDoor(void) { @@ -3303,7 +3303,7 @@ u32 sub_unk3_PalaceOfWinds_BlockMazeToBossDoor(void) { } void sub_StateChange_PalaceOfWinds_BlockMazeToBossDoor(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_CrackedFloorLakitu(void) { @@ -3311,7 +3311,7 @@ u32 sub_unk3_PalaceOfWinds_CrackedFloorLakitu(void) { } void sub_StateChange_PalaceOfWinds_CrackedFloorLakitu(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_HeartPieceBridge(void) { @@ -3319,7 +3319,7 @@ u32 sub_unk3_PalaceOfWinds_HeartPieceBridge(void) { } void sub_StateChange_PalaceOfWinds_HeartPieceBridge(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_FanBridge(void) { @@ -3327,7 +3327,7 @@ u32 sub_unk3_PalaceOfWinds_FanBridge(void) { } void sub_StateChange_PalaceOfWinds_FanBridge(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_ToFanBridge(void) { @@ -3335,7 +3335,7 @@ u32 sub_unk3_PalaceOfWinds_ToFanBridge(void) { } void sub_StateChange_PalaceOfWinds_ToFanBridge(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_RedWarpHall(void) { @@ -3350,7 +3350,7 @@ u32 sub_unk3_PalaceOfWinds_PlatformCloneRide(void) { } void sub_StateChange_PalaceOfWinds_PlatformCloneRide(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_PitCornerAfterKey(void) { @@ -3358,7 +3358,7 @@ u32 sub_unk3_PalaceOfWinds_PitCornerAfterKey(void) { } void sub_StateChange_PalaceOfWinds_PitCornerAfterKey(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_CrowRide(void) { @@ -3366,7 +3366,7 @@ u32 sub_unk3_PalaceOfWinds_CrowRide(void) { } void sub_StateChange_PalaceOfWinds_CrowRide(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_GratePlatformRide(void) { @@ -3374,7 +3374,7 @@ u32 sub_unk3_PalaceOfWinds_GratePlatformRide(void) { } void sub_StateChange_PalaceOfWinds_GratePlatformRide(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_PotPush(void) { @@ -3382,7 +3382,7 @@ u32 sub_unk3_PalaceOfWinds_PotPush(void) { } void sub_StateChange_PalaceOfWinds_PotPush(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_FloormasterLever(void) { @@ -3432,7 +3432,7 @@ u32 sub_unk3_PalaceOfWinds_GratesTo3F(void) { } void sub_StateChange_PalaceOfWinds_GratesTo3F(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_SpinyFight(void) { @@ -3440,7 +3440,7 @@ u32 sub_unk3_PalaceOfWinds_SpinyFight(void) { } void sub_StateChange_PalaceOfWinds_SpinyFight(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_PeahatSwitch(void) { @@ -3448,7 +3448,7 @@ u32 sub_unk3_PalaceOfWinds_PeahatSwitch(void) { } void sub_StateChange_PalaceOfWinds_PeahatSwitch(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_WhirlwindBombarossa(void) { @@ -3456,7 +3456,7 @@ u32 sub_unk3_PalaceOfWinds_WhirlwindBombarossa(void) { } void sub_StateChange_PalaceOfWinds_WhirlwindBombarossa(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_DoorToStalfosFirebar(void) { @@ -3506,7 +3506,7 @@ u32 sub_unk3_PalaceOfWinds_SpikeBarSmallKey(void) { } void sub_StateChange_PalaceOfWinds_SpikeBarSmallKey(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_RocCape(void) { @@ -3516,7 +3516,7 @@ u32 sub_unk3_PalaceOfWinds_RocCape(void) { extern EntityData gUnk_080EA09C; void sub_StateChange_PalaceOfWinds_RocCape(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); if (!CheckLocalFlag(0x70)) { LoadRoomEntityList(&gUnk_080EA09C); } @@ -3527,7 +3527,7 @@ u32 sub_unk3_PalaceOfWinds_FireBarGrates(void) { } void sub_StateChange_PalaceOfWinds_FireBarGrates(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_PlatformRideBombarossas(void) { @@ -3535,7 +3535,7 @@ u32 sub_unk3_PalaceOfWinds_PlatformRideBombarossas(void) { } void sub_StateChange_PalaceOfWinds_PlatformRideBombarossas(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_BridgeAfterDarknut(void) { @@ -3543,7 +3543,7 @@ u32 sub_unk3_PalaceOfWinds_BridgeAfterDarknut(void) { } void sub_StateChange_PalaceOfWinds_BridgeAfterDarknut(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_BridgeSwitchesCloneBlock(void) { @@ -3551,7 +3551,7 @@ u32 sub_unk3_PalaceOfWinds_BridgeSwitchesCloneBlock(void) { } void sub_StateChange_PalaceOfWinds_BridgeSwitchesCloneBlock(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_EntranceRoom(void) { @@ -3559,7 +3559,7 @@ u32 sub_unk3_PalaceOfWinds_EntranceRoom(void) { } void sub_StateChange_PalaceOfWinds_EntranceRoom(void) { - Manager19_Main(NULL); + PowBackgroundManager_Main(NULL); } u32 sub_unk3_PalaceOfWinds_DarkCompassHall(void) { @@ -3590,7 +3590,7 @@ u32 sub_unk3_Vaati3_Main(void) { } void sub_StateChange_Vaati3_Main(void) { - Manager2F_Main(NULL); + Vaati3BackgroundManager_Main(NULL); if ((gRoomTransition.field_0x38 & 1) && gRoomTransition.field_0x39) { if (gRoomTransition.field_0x3c == 1) { @@ -5630,7 +5630,7 @@ u32 sub_unk3_HyruleField_WesternWoodSouth(void) { } void sub_StateChange_HyruleField_WesternWoodSouth(void) { - Manager18_Main(0); + CloudOverlayManager_Main(0); } u32 sub_unk3_HyruleField_SouthHyruleField(void) { @@ -5646,7 +5646,7 @@ extern EntityData gUnk_080F70D8; extern EntityData gUnk_080F7088; void sub_StateChange_HyruleField_SouthHyruleField(void) { - Manager18_Main(NULL); + CloudOverlayManager_Main(NULL); if (!CheckLocalFlag(SOUGEN_01_ZELDA)) { LoadRoomEntityList(&gUnk_080F70A8); ClearGlobalFlag(ZELDA_CHASE); @@ -5673,7 +5673,7 @@ u32 sub_unk3_HyruleField_EasternHillsSouth(void) { } void sub_StateChange_HyruleField_EasternHillsSouth(void) { - Manager18_Main(NULL); + CloudOverlayManager_Main(NULL); } u32 sub_unk3_HyruleField_EasternHillsCenter(void) { @@ -5681,7 +5681,7 @@ u32 sub_unk3_HyruleField_EasternHillsCenter(void) { } void sub_StateChange_HyruleField_EasternHillsCenter(void) { - Manager18_Main(NULL); + CloudOverlayManager_Main(NULL); } extern u32 gUnk_080F7680; @@ -5697,7 +5697,7 @@ extern EntityData gUnk_080F7500; extern EntityData gUnk_080F7550; void sub_StateChange_HyruleField_EasternHillsNorth(void) { - Manager18_Main(NULL); + CloudOverlayManager_Main(NULL); if (gSave.global_progress > 3) { LoadRoomEntityList(&gUnk_080F7500); } @@ -5722,7 +5722,7 @@ extern EntityData gUnk_080F78A0; void sub_StateChange_HyruleField_LonLonRanch(void) { - Manager18_Main(0); + CloudOverlayManager_Main(0); if (CheckLocalFlagByBank(FLAG_BANK_2, 0x8f)) { if (!CheckGlobalFlag(INLOCK)) { LoadRoomEntityList(&gUnk_080F77C0); @@ -5767,7 +5767,7 @@ u32 sub_unk3_HyruleField_OutsideCastle(void) { } void sub_0804F4E4(void) { - Manager18_Main(NULL); + CloudOverlayManager_Main(NULL); sub_0804F578(); } @@ -5947,7 +5947,7 @@ u32 sub_unk3_HyruleField_TrilbyHighlands(void) { extern EntityData gUnk_080F806C; void sub_StateChange_HyruleField_TrilbyHighlands(void) { - Manager18_Main(NULL); + CloudOverlayManager_Main(NULL); if ((gSave.global_progress > 3) && CheckGlobalFlag(TINGLE_TALK1ST)) { LoadRoomEntityList(&gUnk_080F806C); } @@ -5960,7 +5960,7 @@ u32 sub_unk3_HyruleField_WesternWoodsNorth(void) { extern EntityData gUnk_080F82E0; void sub_StateChange_HyruleField_WesternWoodsNorth(void) { - Manager18_Main(NULL); + CloudOverlayManager_Main(NULL); if (CheckGlobalFlag(LV2_CLEAR) && GetInventoryValue(ITEM_RED_SWORD) && !CheckLocalFlag(SOUGEN_08_TORITSUKI)) { LoadRoomEntityList(&gUnk_080F82E0); } @@ -5973,7 +5973,7 @@ u32 sub_unk3_HyruleField_WesternWoodsCenter(void) { extern EntityData gUnk_080F8430; void sub_StateChange_HyruleField_WesternWoodsCenter(void) { - Manager18_Main(NULL); + CloudOverlayManager_Main(NULL); if (CheckKinstoneFused(KINSTONE_21) && !CheckLocalFlagByBank(FLAG_BANK_2, 0x42)) { LoadRoomEntityList(&gUnk_080F8430); } diff --git a/src/scroll.c b/src/scroll.c index f28acaaa..4a3c4742 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -1,3 +1,4 @@ +#include "scroll.h" #include "global.h" #include "entity.h" #include "structures.h" @@ -8,6 +9,7 @@ #include "common.h" #include "fileselect.h" #include "screen.h" +#include "manager/diggingCaveEntranceManager.h" extern void sub_08080BC4(void); extern void sub_080197D4(const void*); @@ -45,7 +47,6 @@ void sub_08080040(RoomControls*); void sub_08080108(RoomControls*); void sub_08080198(RoomControls*); void sub_080801BC(RoomControls*); -void UpdateIsDiggingCave(void); u32 sub_080803D0(); u32 sub_08080278(); void sub_08080C80(u32*); @@ -200,7 +201,7 @@ void sub_0807FF6C(RoomControls* controls) { gScreen.controls.window1VerticalDimensions = 0xf0; ResetPlayerItem(); ResetPlayerAnimationAndAction(); - if (gUnk_03004030.isDiggingCave) { + if (gDiggingCaveEntranceTransition.isDiggingCave) { gPlayerEntity.animationState = 4; } else { gPlayerEntity.animationState = 0; @@ -212,7 +213,7 @@ void sub_0807FFE4(RoomControls* controls) { controls->unk4 = 2; controls->filler2[0] = sub_080803D0() + 6; gUnk_0200B640 = sub_08080278(); - sub_080197D4(*gUnk_08109194[gUnk_03004030.unk_00->unk_03]); + sub_080197D4(*gUnk_08109194[gDiggingCaveEntranceTransition.entrance->type]); sub_0807C8B0(gMapDataTop, controls->width >> 4, controls->height >> 4); sub_0801AB08(gMapDataTopSpecial, gMapDataTop - 4); } @@ -253,7 +254,7 @@ void sub_08080040(RoomControls* controls) { controls->unk4 = 3; DeleteSleepingEntities(); sub_0807C810(); - sub_08080C80(*(gUnk_08109194[gUnk_03004030.unk_00->unk_03] + 1)); + sub_08080C80(*(gUnk_08109194[gDiggingCaveEntranceTransition.entrance->type] + 1)); } else { gUpdateVisibleTiles = 4; } @@ -344,18 +345,18 @@ void UpdateIsDiggingCave(void) { case AREA_VEIL_FALLS_DIG_CAVE: case AREA_CASTOR_WILDS_DIG_CAVE: case AREA_HYLIA_DIG_CAVES: - gUnk_03004030.isDiggingCave = 1; + gDiggingCaveEntranceTransition.isDiggingCave = 1; return; } - gUnk_03004030.isDiggingCave = 0; + gDiggingCaveEntranceTransition.isDiggingCave = 0; } void ClearTilemaps(void) { // Is gRoomControls 4 bytes bigger? MemClear(&gRoomControls, 0x38); - MemClear(&gUnk_03004030, sizeof(gUnk_03004030)); + MemClear(&gDiggingCaveEntranceTransition, sizeof(gDiggingCaveEntranceTransition)); gRoomControls.filler3 = 0xffff; - gUnk_03004030.unk_0a = 0xff; + gDiggingCaveEntranceTransition.previousArea = 0xff; gUnk_02034480.unk_00 = 0; MemClear(&gMapDataBottomSpecial, 0x8000); MemClear(&gMapDataTopSpecial, 0x8000); @@ -522,7 +523,7 @@ void sub_0808091C(const ScreenTransitionData* param_1, u32 param_2) { gRoomTransition.type = param_2; } -void sub_08080930(void) { +void sub_08080930(u32 unused) { gRoomControls.unk3 = 5; gRoomControls.unk4 = 0; gRoomControls.reload_flags = 2; diff --git a/src/subtask.c b/src/subtask.c index 6ee32e04..3126c4b8 100644 --- a/src/subtask.c +++ b/src/subtask.c @@ -1,18 +1,19 @@ -#include "global.h" -#include "menu.h" +#include "asm.h" +#include "common.h" +#include "effects.h" #include "fade.h" #include "flags.h" -#include "sound.h" -#include "room.h" #include "functions.h" -#include "effects.h" -#include "asm.h" -#include "save.h" +#include "global.h" #include "kinstone.h" -#include "screen.h" -#include "common.h" -#include "object.h" +#include "manager/bombableWallManager.h" +#include "menu.h" #include "message.h" +#include "object.h" +#include "room.h" +#include "save.h" +#include "screen.h" +#include "sound.h" extern void (*const gUnk_080FEEB8[])(void); @@ -212,10 +213,10 @@ void sub_08054E9C(void) { } void sub_08054EB8(Entity* this, ScriptExecutionContext* context) { - Manager24* manager = (Manager24*)GetEmptyManager(); + BombableWallManager* manager = (BombableWallManager*)GetEmptyManager(); if (manager != NULL) { - (manager->manager).type = 9; - (manager->manager).subtype = 0x24; + manager->base.kind = MANAGER; + manager->base.id = BOMBABLE_WALL_MANAGER; manager->x = this->x.HALF.HI - gRoomControls.origin_x; manager->y = (this->y.HALF.HI - gRoomControls.origin_y) - 0x10; manager->field_0x35 = 1; diff --git a/src/subtask2.c b/src/subtask2.c index b390c56b..9e430801 100644 --- a/src/subtask2.c +++ b/src/subtask2.c @@ -1244,7 +1244,7 @@ void sub_080A67C4(u32 param_1) { LoadGfxGroup(iVar4); ptr = &gUnk_08128E94[param_1]; - puVar2 = &gUnk_02017AA0[gUnk_03003DE4 * 0x500]; + puVar2 = &gUnk_02017AA0[gUnk_03003DE4[0] * 0x500]; for (i = 0; i <= 7; puVar2++, i++) { *puVar2 = 0x1e0a; @@ -1258,7 +1258,7 @@ void sub_080A67C4(u32 param_1) { *puVar2 = 0x1e0a; } - sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4 * 0x500], REG_ADDR_BG3CNT, 0xa2600001); + sub_0805622C((struct BgAffineDstData*)&gUnk_02017AA0[gUnk_03003DE4[0] * 0x500], REG_ADDR_BG3CNT, 0xa2600001); gMenu.field_0xa = ptr->unk2 >> 1; MemClear(&gMapDataBottomSpecial, 0x400); } @@ -1791,8 +1791,8 @@ void Subtask_FadeIn(void) { gUI.unk_d = gRoomTransition.field_0x2c[2]; gUI.controlMode = gPlayerState.controlMode; gUI.currentRoomProperties = gCurrentRoomProperties; - gUI.mapBottomBgControlPtr = gMapBottom.bgControlPtr; - gUI.mapTopBgControlPtr = gMapTop.bgControlPtr; + gUI.mapBottomBgSettings = gMapBottom.bgSettings; + gUI.mapTopBgSettings = gMapTop.bgSettings; gUI.nextToLoad = 1; } } @@ -1821,8 +1821,8 @@ void Subtask_FadeOut(void) { sub_0805E974(); gCurrentRoomProperties = gUI.currentRoomProperties; gPlayerState.controlMode = gUI.controlMode; - gMapBottom.bgControlPtr = gUI.mapBottomBgControlPtr; - gMapTop.bgControlPtr = gUI.mapTopBgControlPtr; + gMapBottom.bgSettings = gUI.mapBottomBgSettings; + gMapTop.bgSettings = gUI.mapTopBgSettings; MemCopy(&gUI.activeScriptInfo, &gActiveScriptInfo, sizeof(ActiveScriptInfo)); MemCopy(gUI.unk_2a8, gUnk_03000420, sizeof(gUI.unk_2a8)); MemCopy(gUI.palettes, gPaletteList, sizeof(gUI.palettes));