From 313cc336f21fcf81e3e336b4fe45ca5053771f93 Mon Sep 17 00:00:00 2001 From: theo3 Date: Wed, 10 Nov 2021 00:35:06 -0800 Subject: [PATCH] thumb interwork finished --- Makefile | 3 +- asm/code_080011C4.s | 2 +- asm/code_08016B30.s | 226 --- asm/code_08016DF8.s | 1730 ----------------- asm/code_0806EC20.s | 4 +- asm/code_0807F0D8.s | 2 +- asm/code_080A3BD0.s | 2 +- ...ateBackgroundRegisters.s => dispCtrlSet.s} | 9 +- asm/fileScreen.s | 4 +- asm/intr.s | 22 +- asm/jarPortal.s | 8 - asm/non_matching/arm_proxy/NPCUpdate.inc | 4 +- asm/non_matching/collision/sub_08017CBC.inc | 57 + asm/non_matching/collision/sub_0801802C.inc | 75 + asm/object11.s | 2 +- asm/object1E.s | 2 +- asm/sub_08016AE4.s | 2 +- asm/sub_080A2838.s | 4 +- data/data_080B2A70.s | 26 +- data/data_080B3740.s | 6 +- data/data_080B7B74.s | 2 +- include/entity.h | 36 +- include/main.h | 2 +- include/player.h | 6 +- include/structures.h | 2 +- linker.ld | 7 +- src/collision.c | 714 +++++++ src/enemy/acroBandits.c | 14 +- src/enemy/beetle.c | 8 +- src/enemy/bobomb.c | 22 +- src/enemy/bombPeahat.c | 6 +- src/enemy/businessScrub.c | 10 +- src/enemy/chuchu.c | 36 +- src/enemy/darkNut.c | 14 +- src/enemy/doorMimic.c | 4 +- src/enemy/enemy4D.c | 2 +- src/enemy/fallingBoulder.c | 6 +- src/enemy/gibdo.c | 12 +- src/enemy/gyorgMale.c | 4 +- src/enemy/helmasaur.c | 16 +- src/enemy/keaton.c | 2 +- src/enemy/lakitu.c | 14 +- src/enemy/lakituCloud.c | 4 +- src/enemy/leever.c | 4 +- src/enemy/likeLike.c | 16 +- src/enemy/madderpillar.c | 16 +- src/enemy/mazaalBracelet.c | 40 +- src/enemy/mazaalHead.c | 2 +- src/enemy/mazaalMacro.c | 2 +- src/enemy/moldorm.c | 4 +- src/enemy/moldworm.c | 20 +- src/enemy/octorok.c | 6 +- src/enemy/peahat.c | 14 +- src/enemy/pesto.c | 12 +- src/enemy/puffstool.c | 10 +- src/enemy/rockChuchu.c | 4 +- src/enemy/rollobite.c | 20 +- src/enemy/rupeeLike.c | 14 +- src/enemy/smallPesto.c | 2 +- src/enemy/spark.c | 2 +- src/enemy/spikedBeetle.c | 4 +- src/enemy/spinyChuchu.c | 18 +- src/enemy/vaatiArm.c | 38 +- src/enemy/vaatiBall.c | 24 +- src/enemy/vaatiEyesMacro.c | 2 +- src/enemy/vaatiProjectile.c | 6 +- src/enemy/vaatiRebornEnemy.c | 14 +- src/enemy/vaatiTransfigured.c | 14 +- src/enemy/vaatiTransfiguredEye.c | 10 +- src/enemy/vaatiWrath.c | 12 +- src/enemy/vaatiWrathEye.c | 6 +- src/enemy/wallMaster.c | 12 +- src/enemy/wallMaster2.c | 2 +- src/enemy/waterDrop.c | 6 +- src/enemy/wisp.c | 6 +- src/entity.c | 34 +- src/game.c | 2 +- src/{arm_proxy.c => interrupts.c} | 323 ++- src/item/itemSword.c | 4 +- src/main.c | 2 +- src/npc/cat.c | 8 +- src/npc/npc5.c | 6 +- src/object/button.c | 8 +- src/object/heartContainer.c | 2 +- src/object/itemOnGround.c | 38 +- src/object/jarPortal.c | 6 +- src/object/lightableSwitch.c | 12 +- src/object/minecart.c | 24 +- src/object/mineralWaterSource.c | 6 +- src/object/object49.c | 6 +- src/object/object9E.c | 6 +- src/object/pot.c | 10 +- src/object/warpPoint.c | 2 +- src/player.c | 64 +- src/playerItem/playerItem10.c | 2 +- src/playerItem/playerItem11.c | 14 +- src/playerItem/playerItem12.c | 2 +- src/playerItem/playerItemBow.c | 2 +- src/playerItem/playerItemC.c | 2 +- src/playerItem/playerItemLantern.c | 2 +- src/projectile/arrowProjectile.c | 8 +- src/projectile/boneProjectile.c | 4 +- src/projectile/darkNutSwordSlash.c | 6 +- src/projectile/dekuSeedProjectile.c | 18 +- src/projectile/fireProjectile.c | 2 +- src/projectile/gleerokProjectile.c | 6 +- src/projectile/gyorgMaleEnergyProjectile.c | 4 +- src/projectile/gyorgTail.c | 10 +- src/projectile/iceProjectile.c | 2 +- src/projectile/lakituCloudProjectile.c | 2 +- src/projectile/mandiblesProjectile.c | 12 +- src/projectile/mazaalEnergyBeam.c | 2 +- src/projectile/moblinSpear.c | 8 +- src/projectile/octorokBossProjectile.c | 2 +- src/projectile/rockProjectile.c | 6 +- src/projectile/spiderWeb.c | 2 +- src/projectile/stalfosProjectile.c | 6 +- src/projectile/v1DarkMagicProjectile.c | 14 +- src/projectile/v1EyeLaser.c | 2 +- src/projectile/v1FireProjectile.c | 4 +- src/projectile/windProjectile.c | 2 +- src/script.c | 6 +- 122 files changed, 1514 insertions(+), 2696 deletions(-) delete mode 100644 asm/code_08016B30.s delete mode 100644 asm/code_08016DF8.s rename asm/{updateBackgroundRegisters.s => dispCtrlSet.s} (94%) delete mode 100644 asm/jarPortal.s create mode 100644 asm/non_matching/collision/sub_08017CBC.inc create mode 100644 asm/non_matching/collision/sub_0801802C.inc create mode 100644 src/collision.c rename src/{arm_proxy.c => interrupts.c} (61%) diff --git a/Makefile b/Makefile index d8c37941..c2f9fd4f 100644 --- a/Makefile +++ b/Makefile @@ -111,7 +111,8 @@ NODEP := 1 endif #$(C_BUILDDIR)/need_interworking_file_name.o: CFLAGS += -mthumb-interwork -$(C_BUILDDIR)/arm_proxy.o: CFLAGS += -mthumb-interwork +$(C_BUILDDIR)/interrupts.o: CFLAGS += -mthumb-interwork +$(C_BUILDDIR)/collision.o: CFLAGS += -mthumb-interwork $(C_BUILDDIR)/gba/m4a.o: CFLAGS = -O2 -mthumb-interwork -Wimplicit -Wparentheses -Werror -Wno-multichar $(C_BUILDDIR)/eeprom.o: CFLAGS = -O1 -mthumb-interwork -Wimplicit -Wparentheses -Werror -Wno-multichar diff --git a/asm/code_080011C4.s b/asm/code_080011C4.s index b3ef8bab..37c2b33c 100644 --- a/asm/code_080011C4.s +++ b/asm/code_080011C4.s @@ -18,7 +18,7 @@ EnemyUpdate: @ 0x080011C4 bne _080011EA bl DeleteThisEntity _080011DC: - bl sub_0805E3B0 + bl CheckDontUpdate cmp r0, #0 bne _0800120A adds r0, r4, #0 diff --git a/asm/code_08016B30.s b/asm/code_08016B30.s deleted file mode 100644 index 6726c90a..00000000 --- a/asm/code_08016B30.s +++ /dev/null @@ -1,226 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_08016B30 -sub_08016B30: @ 0x08016B30 - bx lr - .align 2, 0 - - thumb_func_start sub_08016B34 -sub_08016B34: @ 0x08016B34 - ldr r1, _08016B54 @ =0x03007FFC - ldr r0, _08016B58 @ =gIntrMain - str r0, [r1] - ldr r1, _08016B5C @ =0x04000004 - ldr r2, _08016B60 @ =0x00005028 - adds r0, r2, #0 - strh r0, [r1] - ldr r1, _08016B64 @ =0x04000200 - ldr r2, _08016B68 @ =0x00002005 - adds r0, r2, #0 - strh r0, [r1] - adds r1, #8 - movs r0, #1 - strh r0, [r1] - bx lr - .align 2, 0 -_08016B54: .4byte 0x03007FFC -_08016B58: .4byte gIntrMain -_08016B5C: .4byte 0x04000004 -_08016B60: .4byte 0x00005028 -_08016B64: .4byte 0x04000200 -_08016B68: .4byte 0x00002005 - - thumb_func_start sub_08016B6C -sub_08016B6C: @ 0x08016B6C - push {r4, r5, lr} - ldr r4, _08016BBC @ =0x040000B0 - ldrh r1, [r4, #0xa] - ldr r0, _08016BC0 @ =0x0000C5FF - ands r0, r1 - strh r0, [r4, #0xa] - ldrh r1, [r4, #0xa] - ldr r0, _08016BC4 @ =0x00007FFF - ands r0, r1 - strh r0, [r4, #0xa] - ldrh r0, [r4, #0xa] - bl m4aSoundVSync - ldr r5, _08016BC8 @ =gMain - ldrb r0, [r5] - cmp r0, #0 - bne _08016BA6 - bl DispCtrlSet - ldr r0, _08016BCC @ =gUnk_03000FBC - str r0, [r4] - ldr r0, _08016BD0 @ =gUnk_02022730 - str r0, [r4, #4] - ldr r0, _08016BD4 @ =0x84000004 - str r0, [r4, #8] - ldr r0, [r4, #8] - ldrb r0, [r5] - movs r0, #1 - strb r0, [r5] -_08016BA6: - bl sub_08016BF8 - ldr r0, _08016BD8 @ =0x03007FF8 - ldrh r1, [r0] - movs r2, #1 - orrs r1, r2 - strh r1, [r0] - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_08016BBC: .4byte 0x040000B0 -_08016BC0: .4byte 0x0000C5FF -_08016BC4: .4byte 0x00007FFF -_08016BC8: .4byte gMain -_08016BCC: .4byte gUnk_03000FBC -_08016BD0: .4byte gUnk_02022730 -_08016BD4: .4byte 0x84000004 -_08016BD8: .4byte 0x03007FF8 - - thumb_func_start HBlankIntr -HBlankIntr: @ 0x08016BDC - push {lr} - ldr r1, _08016BF0 @ =0x04000004 - ldr r2, _08016BF4 @ =0x00005028 - adds r0, r2, #0 - strh r0, [r1] - bl m4aSoundMain - pop {r0} - bx r0 - .align 2, 0 -_08016BF0: .4byte 0x04000004 -_08016BF4: .4byte 0x00005028 - - thumb_func_start sub_08016BF8 -sub_08016BF8: @ 0x08016BF8 - push {lr} - ldr r1, _08016C30 @ =gUnk_02022730 - ldrb r0, [r1] - cmp r0, #0 - beq _08016C2C - ldr r3, [r1, #4] - ldr r2, [r1, #8] - ldr r1, [r1, #0xc] - ldr r0, _08016C34 @ =0x040000B0 - str r3, [r0] - str r2, [r0, #4] - str r1, [r0, #8] - ldr r0, [r0, #8] - ldr r0, _08016C38 @ =0x00003FFF - ands r1, r0 - cmp r1, #0 - bne _08016C1E - movs r1, #0x80 - lsls r1, r1, #7 -_08016C1E: - ldrh r0, [r3] - strh r0, [r2] - adds r3, #2 - adds r2, #2 - subs r1, #1 - cmp r1, #0 - bgt _08016C1E -_08016C2C: - pop {r0} - bx r0 - .align 2, 0 -_08016C30: .4byte gUnk_02022730 -_08016C34: .4byte 0x040000B0 -_08016C38: .4byte 0x00003FFF - - thumb_func_start UpdateDisplayControls -UpdateDisplayControls: @ 0x08016C3C - push {r4, lr} - ldr r2, _08016C94 @ =gUnk_03000000 - ldrb r0, [r2] - cmp r0, #0 - beq _08016C6C - ldr r0, _08016C98 @ =gScreen - ldrh r1, [r0] - movs r0, #0x80 - lsls r0, r0, #5 - ands r0, r1 - cmp r0, #0 - beq _08016C6C - movs r0, #0 - strb r0, [r2] - ldr r1, _08016C9C @ =0x040000D4 - adds r0, r2, #0 - adds r0, #0x20 - str r0, [r1] - movs r0, #0xe0 - lsls r0, r0, #0x13 - str r0, [r1, #4] - ldr r0, _08016CA0 @ =0x84000100 - str r0, [r1, #8] - ldr r0, [r1, #8] -_08016C6C: - ldr r4, _08016CA4 @ =gBG0Settings - adds r0, r4, #0 - bl sub_08016CA8 - adds r0, r4, #0 - adds r0, #0xc - bl sub_08016CA8 - adds r0, r4, #0 - adds r0, #0x18 - bl sub_08016CA8 - adds r4, #0x24 - adds r0, r4, #0 - bl sub_08016CA8 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08016C94: .4byte gUnk_03000000 -_08016C98: .4byte gScreen -_08016C9C: .4byte 0x040000D4 -_08016CA0: .4byte 0x84000100 -_08016CA4: .4byte gBG0Settings - - thumb_func_start sub_08016CA8 -sub_08016CA8: @ 0x08016CA8 - push {lr} - adds r1, r0, #0 - ldrh r0, [r1, #6] - cmp r0, #0 - beq _08016CE8 - ldr r2, [r1, #8] - cmp r2, #0 - beq _08016CE8 - movs r0, #0 - strh r0, [r1, #6] - ldrh r1, [r1] - ldr r3, _08016CEC @ =0x040000D4 - str r2, [r3] - lsls r0, r1, #3 - movs r2, #0xf8 - lsls r2, r2, #8 - ands r0, r2 - movs r2, #0xc0 - lsls r2, r2, #0x13 - adds r0, r0, r2 - str r0, [r3, #4] - ldr r0, _08016CF0 @ =gUnk_080B2CD8 - lsrs r1, r1, #0xe - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - lsrs r0, r0, #2 - movs r1, #0x84 - lsls r1, r1, #0x18 - orrs r0, r1 - str r0, [r3, #8] - ldr r0, [r3, #8] -_08016CE8: - pop {r0} - bx r0 - .align 2, 0 -_08016CEC: .4byte 0x040000D4 -_08016CF0: .4byte gUnk_080B2CD8 diff --git a/asm/code_08016DF8.s b/asm/code_08016DF8.s deleted file mode 100644 index b1bbea94..00000000 --- a/asm/code_08016DF8.s +++ /dev/null @@ -1,1730 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_08017874 -sub_08017874: @ 0x08017874 - push {r4, r5, lr} - adds r4, r0, #0 - adds r2, r1, #0 - ldrb r0, [r4, #8] - cmp r0, #1 - bne _080178C6 - adds r0, r2, #0 - adds r0, #0x44 - ldrb r1, [r0] - ldr r0, _08017898 @ =gSave - adds r0, #0xb2 - ldrb r0, [r0] - cmp r0, #0x2f - beq _0801789C - cmp r0, #0x30 - beq _080178A8 - b _080178AE - .align 2, 0 -_08017898: .4byte gSave -_0801789C: - adds r0, r1, #0 - cmp r1, #0 - bge _080178A4 - adds r0, r1, #3 -_080178A4: - asrs r1, r0, #2 - b _080178AE -_080178A8: - lsrs r0, r1, #0x1f - adds r0, r1, r0 - asrs r1, r0, #1 -_080178AE: - cmp r1, #0 - bgt _080178B4 - movs r1, #1 -_080178B4: - rsbs r0, r1, #0 - bl ModHealth - adds r5, r0, #0 - adds r0, r4, #0 - movs r1, #0x7a - bl sub_0800449C - b _08017928 -_080178C6: - adds r0, r2, #0 - adds r0, #0x44 - ldrb r1, [r0] - ldrb r0, [r2, #8] - cmp r0, #8 - bne _080178F6 - ldr r0, _080178E4 @ =gSave - adds r0, #0xb2 - ldrb r0, [r0] - cmp r0, #0x30 - beq _080178E8 - cmp r0, #0x31 - beq _080178F4 - b _080178F6 - .align 2, 0 -_080178E4: .4byte gSave -_080178E8: - lsls r0, r1, #1 - adds r0, r0, r1 - lsrs r1, r0, #0x1f - adds r0, r0, r1 - asrs r1, r0, #1 - b _080178F6 -_080178F4: - lsls r1, r1, #1 -_080178F6: - adds r0, r4, #0 - adds r0, #0x45 - ldrb r0, [r0] - subs r5, r0, r1 - ldrb r0, [r4, #8] - cmp r0, #3 - bne _08017928 - adds r0, r4, #0 - adds r0, #0x6d - ldrb r1, [r0] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _08017920 - ldr r1, _0801791C @ =0x00000127 - adds r0, r4, #0 - bl sub_0800449C - b _08017928 - .align 2, 0 -_0801791C: .4byte 0x00000127 -_08017920: - adds r0, r4, #0 - movs r1, #0xfe - bl sub_0800449C -_08017928: - cmp r5, #0 - ble _08017930 - adds r0, r5, #0 - b _0801793A -_08017930: - ldrb r1, [r4, #0x10] - movs r0, #0x7f - ands r0, r1 - strb r0, [r4, #0x10] - movs r0, #0 -_0801793A: - pop {r4, r5} - pop {r1} - bx r1 - - thumb_func_start sub_08017940 -sub_08017940: @ 0x08017940 - push {r4, r5, lr} - adds r5, r0, #0 - adds r4, r1, #0 - adds r0, r4, #0 - movs r1, #0x2c - movs r2, #0 - bl CreateFx - adds r2, r0, #0 - cmp r2, #0 - beq _080179CC - adds r3, r2, #0 - adds r3, #0x29 - ldrb r1, [r3] - movs r0, #8 - rsbs r0, r0, #0 - ands r0, r1 - movs r1, #2 - orrs r0, r1 - strb r0, [r3] - movs r1, #0x2e - ldrsh r0, [r5, r1] - ldr r1, [r5, #0x48] - ldrb r1, [r1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - adds r0, r0, r1 - movs r3, #0x2e - ldrsh r1, [r4, r3] - adds r0, r0, r1 - ldr r1, [r4, #0x48] - ldrb r1, [r1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - adds r0, r0, r1 - asrs r0, r0, #1 - strh r0, [r2, #0x2e] - movs r1, #0x32 - ldrsh r0, [r5, r1] - ldr r1, [r5, #0x48] - ldrb r1, [r1, #1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - adds r0, r0, r1 - movs r3, #0x32 - ldrsh r1, [r4, r3] - adds r0, r0, r1 - ldr r1, [r4, #0x48] - ldrb r1, [r1, #1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - adds r0, r0, r1 - asrs r0, r0, #1 - strh r0, [r2, #0x32] - movs r1, #0x36 - ldrsh r0, [r5, r1] - movs r3, #0x36 - ldrsh r1, [r4, r3] - adds r0, r0, r1 - asrs r0, r0, #1 - strh r0, [r2, #0x36] - adds r0, r5, #0 - adds r0, #0x38 - ldrb r1, [r0] - adds r0, r2, #0 - adds r0, #0x38 - strb r1, [r0] - adds r0, r2, #0 - bl UpdateSpriteForCollisionLayer -_080179CC: - movs r1, #0 - ldr r0, _080179E8 @ =gPlayerEntity - cmp r5, r0 - beq _080179DA - cmp r4, r0 - bne _080179E0 - adds r0, r4, #0 -_080179DA: - adds r0, #0x42 - ldrb r0, [r0] - lsrs r1, r0, #3 -_080179E0: - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_080179E8: .4byte gPlayerEntity - - thumb_func_start sub_080179EC -sub_080179EC: @ 0x080179EC - push {r4, r5, r6, lr} - adds r6, r0, #0 - adds r5, r1, #0 - ldr r4, _08017A8C @ =gUnk_080B3740 - bl Random - movs r1, #3 - ands r1, r0 - adds r1, r1, r4 - ldrb r1, [r1] - adds r0, r5, #0 - movs r2, #0 - bl CreateFx - adds r4, r0, #0 - cmp r4, #0 - beq _08017A84 - ldr r0, [r5, #0x48] - movs r2, #0 - ldrsb r2, [r0, r2] - lsls r2, r2, #0x10 - movs r3, #1 - ldrsb r3, [r0, r3] - lsls r3, r3, #0x10 - adds r0, r5, #0 - adds r1, r4, #0 - bl PositionRelative - adds r2, r4, #0 - adds r2, #0x29 - ldrb r1, [r2] - movs r0, #8 - rsbs r0, r0, #0 - ands r0, r1 - movs r1, #2 - orrs r0, r1 - strb r0, [r2] - movs r1, #0x2e - ldrsh r0, [r6, r1] - ldr r1, [r6, #0x48] - ldrb r1, [r1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - adds r0, r0, r1 - movs r2, #0x2e - ldrsh r1, [r5, r2] - ldr r2, [r5, #0x48] - ldrb r2, [r2] - lsls r2, r2, #0x18 - asrs r2, r2, #0x18 - adds r1, r1, r2 - subs r0, r0, r1 - asrs r0, r0, #1 - adds r1, r4, #0 - adds r1, #0x62 - strb r0, [r1] - movs r1, #0x32 - ldrsh r0, [r6, r1] - ldr r1, [r6, #0x48] - ldrb r1, [r1, #1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - adds r0, r0, r1 - movs r2, #0x32 - ldrsh r1, [r5, r2] - ldr r2, [r5, #0x48] - ldrb r2, [r2, #1] - lsls r2, r2, #0x18 - asrs r2, r2, #0x18 - adds r1, r1, r2 - subs r0, r0, r1 - asrs r0, r0, #1 - adds r1, r4, #0 - adds r1, #0x63 - strb r0, [r1] - str r5, [r4, #0x54] -_08017A84: - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_08017A8C: .4byte gUnk_080B3740 - - thumb_func_start sub_08017A90 -sub_08017A90: @ 0x08017A90 - push {r4, r5, lr} - adds r4, r0, #0 - adds r5, r1, #0 - movs r0, #0x99 - movs r1, #0 - movs r2, #0 - bl CreateObject - adds r2, r0, #0 - cmp r2, #0 - bne _08017AAA - movs r0, #0 - b _08017AD0 -_08017AAA: - ldrb r0, [r4, #0x15] - lsrs r0, r0, #3 - movs r1, #3 - ands r0, r1 - strb r0, [r2, #0x14] - ldrh r0, [r4, #0x2e] - ldrh r1, [r5, #0x2e] - subs r0, r0, r1 - adds r1, r2, #0 - adds r1, #0x62 - strb r0, [r1] - ldrh r0, [r4, #0x32] - ldrh r1, [r5, #0x32] - subs r0, r0, r1 - adds r1, r2, #0 - adds r1, #0x63 - strb r0, [r1] - str r5, [r2, #0x50] - adds r0, r2, #0 -_08017AD0: - pop {r4, r5} - pop {r1} - bx r1 - .align 2, 0 - - thumb_func_start sub_08017AD8 -sub_08017AD8: @ 0x08017AD8 - movs r0, #0 - bx lr - - thumb_func_start sub_08017ADC -sub_08017ADC: @ 0x08017ADC - push {r4, lr} - adds r4, r1, #0 - ldrb r2, [r4, #0x10] - movs r1, #0x7f - ands r1, r2 - strb r1, [r4, #0x10] - adds r0, #0x40 - ldrb r1, [r0] - movs r0, #0x80 - adds r2, r4, #0 - adds r2, #0x41 - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r4, #0xa] - subs r0, #0x5f - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #1 - bhi _08017B14 - adds r0, r4, #0 - bl sub_08081420 - cmp r0, #0 - beq _08017B14 - adds r1, r4, #0 - adds r1, #0x45 - movs r0, #0 - strb r0, [r1] -_08017B14: - movs r0, #2 - pop {r4} - pop {r1} - bx r1 - - thumb_func_start sub_08017B1C -sub_08017B1C: @ 0x08017B1C - push {lr} - adds r2, r0, #0 - adds r3, r1, #0 - ldr r0, _08017B38 @ =gPlayerState - ldrb r1, [r0, #0x1e] - movs r0, #0x60 - ands r0, r1 - cmp r0, #0 - beq _08017B3C - ldrb r1, [r3, #0x10] - movs r0, #0x7f - ands r0, r1 - strb r0, [r3, #0x10] - b _08017B52 - .align 2, 0 -_08017B38: .4byte gPlayerState -_08017B3C: - adds r1, r2, #0 - adds r1, #0x42 - movs r0, #0x10 - strb r0, [r1] - subs r1, #5 - movs r0, #0xec - strb r0, [r1] - adds r1, #9 - movs r0, #0xa0 - lsls r0, r0, #2 - strh r0, [r1] -_08017B52: - movs r0, #1 - pop {r1} - bx r1 - - thumb_func_start sub_08017B58 -sub_08017B58: @ 0x08017B58 - push {lr} - adds r2, r1, #0 - adds r3, r2, #0 - adds r3, #0x3a - ldrb r1, [r3] - movs r0, #4 - ands r0, r1 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #0 - beq _08017B98 - ldrb r1, [r2, #0x1d] - cmp r1, #0 - beq _08017BA2 - ldr r0, _08017B94 @ =gPlayerState - ldrb r0, [r0, #0x1d] - subs r0, r1, r0 - movs r1, #0 - strb r0, [r2, #0x1d] - lsls r0, r0, #0x18 - cmp r0, #0 - bgt _08017BA2 - strb r1, [r2, #0x1d] - movs r0, #2 - strb r0, [r2, #0xd] - adds r0, r2, #0 - adds r0, #0x46 - strh r1, [r0] - b _08017BA2 - .align 2, 0 -_08017B94: .4byte gPlayerState -_08017B98: - strb r0, [r2, #0xd] - ldrb r0, [r3] - movs r1, #4 - orrs r0, r1 - strb r0, [r3] -_08017BA2: - adds r1, r2, #0 - adds r1, #0x3d - ldrb r2, [r1] - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #0 - bne _08017BB4 - movs r0, #0xff - strb r0, [r1] -_08017BB4: - movs r0, #1 - pop {r1} - bx r1 - .align 2, 0 - - thumb_func_start sub_08017BBC -sub_08017BBC: @ 0x08017BBC - push {r4, r5, r6, r7, lr} - adds r4, r0, #0 - adds r6, r1, #0 - adds r7, r2, #0 - ldr r5, _08017C38 @ =gPlayerState - ldr r0, [r5, #0x30] - ldr r1, _08017C3C @ =0x00001481 - ands r0, r1 - cmp r0, #0 - bne _08017BF2 - movs r0, #0x42 - movs r1, #1 - movs r2, #0 - bl CreateObject - cmp r0, #0 - beq _08017BF2 - str r4, [r0, #0x54] - ldr r0, [r5, #0x30] - movs r1, #0x80 - lsls r1, r1, #3 - orrs r0, r1 - str r0, [r5, #0x30] - movs r0, #0x10 - eors r0, r7 - lsrs r0, r0, #2 - strb r0, [r4, #0x14] -_08017BF2: - adds r1, r6, #0 - adds r1, #0x44 - movs r0, #4 - strb r0, [r1] - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_08017874 - adds r1, r4, #0 - adds r1, #0x45 - strb r0, [r1] - subs r1, #3 - movs r0, #0xc - strb r0, [r1] - subs r1, #5 - movs r0, #0x1e - strb r0, [r1] - adds r1, #9 - movs r0, #0xc0 - lsls r0, r0, #1 - strh r0, [r1] - adds r1, r6, #0 - adds r1, #0x3d - ldrb r2, [r1] - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #0 - bne _08017C2E - movs r0, #0xff - strb r0, [r1] -_08017C2E: - movs r0, #1 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 - .align 2, 0 -_08017C38: .4byte gPlayerState -_08017C3C: .4byte 0x00001481 - - thumb_func_start sub_08017C40 -sub_08017C40: @ 0x08017C40 - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r5, r1, #0 - ldr r6, _08017CB4 @ =gPlayerState - ldr r0, [r6, #0x30] - ldr r1, _08017CB8 @ =0x00001881 - ands r0, r1 - cmp r0, #0 - bne _08017C82 - ldrb r0, [r6, #0xc] - cmp r0, #0 - bne _08017C82 - ldrb r0, [r4, #0xc] - cmp r0, #1 - beq _08017C62 - cmp r0, #0x18 - bne _08017C82 -_08017C62: - adds r1, r5, #0 - adds r1, #0x44 - movs r0, #4 - strb r0, [r1] - adds r0, r4, #0 - adds r1, r5, #0 - bl sub_08017874 - adds r1, r4, #0 - adds r1, #0x45 - strb r0, [r1] - movs r0, #0x80 - lsls r0, r0, #4 - str r0, [r6, #0x30] - movs r0, #0xd - strb r0, [r6, #0xc] -_08017C82: - adds r1, r4, #0 - adds r1, #0x42 - movs r0, #0xc - strb r0, [r1] - subs r1, #5 - movs r0, #0x10 - strb r0, [r1] - adds r1, #9 - movs r0, #0xa0 - lsls r0, r0, #2 - strh r0, [r1] - adds r1, r5, #0 - adds r1, #0x3d - ldrb r2, [r1] - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #0 - bne _08017CAA - movs r0, #0xff - strb r0, [r1] -_08017CAA: - movs r0, #1 - pop {r4, r5, r6} - pop {r1} - bx r1 - .align 2, 0 -_08017CB4: .4byte gPlayerState -_08017CB8: .4byte 0x00001881 - - thumb_func_start sub_08017CBC -sub_08017CBC: @ 0x08017CBC - push {r4, r5, lr} - adds r4, r0, #0 - adds r3, r1, #0 - movs r5, #0x10 - eors r2, r5 - adds r0, r2, #0 - subs r0, #0xc - movs r2, #0x1f - ands r0, r2 - ldrb r1, [r3, #0x15] - subs r1, r1, r0 - ands r1, r2 - cmp r1, #0x18 - bhi _08017CF0 - adds r1, r4, #0 - adds r1, #0x3d - movs r0, #0xf4 - strb r0, [r1] - adds r1, r3, #0 - adds r1, #0x3d - strb r0, [r1] - adds r0, r4, #0 - adds r1, r3, #0 - bl sub_08017940 - b _08017D1E -_08017CF0: - adds r1, r3, #0 - adds r1, #0x42 - movs r0, #0xc - strb r0, [r1] - adds r0, r3, #0 - adds r0, #0x3d - strb r5, [r0] - adds r1, #1 - movs r0, #0xf0 - strb r0, [r1] - adds r1, #3 - movs r0, #0xc0 - lsls r0, r0, #2 - strh r0, [r1] - adds r1, r4, #0 - adds r1, #0x3d - ldrb r2, [r1] - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #0 - bne _08017D1E - movs r0, #0xff - strb r0, [r1] -_08017D1E: - movs r0, #1 - pop {r4, r5} - pop {r1} - bx r1 - .align 2, 0 - - thumb_func_start sub_08017D28 -sub_08017D28: @ 0x08017D28 - push {lr} - adds r3, r0, #0 - ldr r2, _08017D68 @ =gPlayerState - movs r0, #1 - strb r0, [r2, #0x1a] - adds r2, r3, #0 - adds r2, #0x7a - movs r0, #0x96 - lsls r0, r0, #2 - strh r0, [r2] - subs r2, #0x38 - movs r0, #0xc - strb r0, [r2] - subs r2, #5 - movs r0, #0x10 - strb r0, [r2] - adds r2, #9 - movs r0, #0xa0 - lsls r0, r0, #2 - strh r0, [r2] - adds r1, #0x3d - ldrb r2, [r1] - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #0 - bne _08017D60 - movs r0, #0xff - strb r0, [r1] -_08017D60: - movs r0, #1 - pop {r1} - bx r1 - .align 2, 0 -_08017D68: .4byte gPlayerState - - thumb_func_start sub_08017D6C -sub_08017D6C: @ 0x08017D6C - push {r4, r5, r6, lr} - adds r5, r0, #0 - adds r4, r1, #0 - adds r6, r2, #0 - movs r0, #0x10 - eors r0, r6 - subs r0, #5 - movs r2, #0x1f - ands r0, r2 - ldrb r1, [r4, #0x14] - lsls r1, r1, #3 - subs r1, r1, r0 - ands r1, r2 - cmp r1, #0xa - bls _08017D98 - adds r0, r5, #0 - adds r0, #0x40 - ldrb r0, [r0] - ldr r1, _08017D94 @ =0x00000AC2 - b _08017DB0 - .align 2, 0 -_08017D94: .4byte 0x00000AC2 -_08017D98: - adds r1, r4, #0 - adds r1, #0x41 - movs r0, #0xcb - strb r0, [r1] - adds r1, r5, #0 - adds r1, #0x40 - ldrb r0, [r1] - adds r2, r4, #0 - adds r2, #0x79 - strb r0, [r2] - ldrb r0, [r1] - ldr r1, _08017DCC @ =0x00000AE4 -_08017DB0: - adds r0, r0, r1 - lsls r3, r0, #1 - adds r3, r3, r0 - lsls r3, r3, #2 - ldr r0, _08017DD0 @ =gUnk_080B7B74 - adds r3, r3, r0 - adds r0, r5, #0 - adds r1, r4, #0 - adds r2, r6, #0 - bl sub_08018308 - pop {r4, r5, r6} - pop {r1} - bx r1 - .align 2, 0 -_08017DCC: .4byte 0x00000AE4 -_08017DD0: .4byte gUnk_080B7B74 - - thumb_func_start sub_08017DD4 -sub_08017DD4: @ 0x08017DD4 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - mov r8, r0 - adds r5, r1, #0 - adds r7, r2, #0 - mov r1, r8 - adds r1, #0x41 - movs r0, #0 - strb r0, [r1] - adds r1, r5, #0 - adds r1, #0x44 - ldrb r2, [r1] - movs r0, #0x80 - ands r0, r2 - cmp r0, #0 - beq _08017DFC - movs r0, #0x7f - ands r0, r2 - b _08017DFE -_08017DFC: - movs r0, #4 -_08017DFE: - strb r0, [r1] - ldr r4, _08017E34 @ =gPlayerEntity - adds r0, r4, #0 - adds r1, r5, #0 - bl sub_08017874 - adds r1, r4, #0 - adds r1, #0x45 - strb r0, [r1] - adds r2, r5, #0 - adds r2, #0x3d - movs r0, #0xf4 - strb r0, [r2] - ldr r0, _08017E38 @ =gPlayerState - ldr r0, [r0, #0x30] - movs r1, #0x80 - ands r0, r1 - adds r6, r2, #0 - cmp r0, #0 - bne _08017E3C - bl sub_08079D84 - mov r1, r8 - adds r1, #0x3d - movs r0, #0x5a - strb r0, [r1] - b _08017E6E - .align 2, 0 -_08017E34: .4byte gPlayerEntity -_08017E38: .4byte gPlayerState -_08017E3C: - adds r0, r5, #0 - adds r0, #0x40 - ldrb r0, [r0] - movs r1, #0x80 - orrs r0, r1 - adds r1, r4, #0 - adds r1, #0x41 - strb r0, [r1] - subs r1, #4 - movs r0, #0xc - strb r0, [r1] - adds r2, r4, #0 - adds r2, #0x42 - movs r1, #0x10 - movs r0, #0x10 - strb r0, [r2] - eors r7, r1 - adds r0, r4, #0 - adds r0, #0x3e - strb r7, [r0] - adds r1, r4, #0 - adds r1, #0x46 - movs r0, #0xa0 - lsls r0, r0, #2 - strh r0, [r1] -_08017E6E: - ldrb r1, [r6] - movs r0, #0 - ldrsb r0, [r6, r0] - cmp r0, #0 - bne _08017E7C - movs r0, #0xff - strb r0, [r6] -_08017E7C: - movs r0, #1 - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 - - thumb_func_start sub_08017E88 -sub_08017E88: @ 0x08017E88 - push {lr} - adds r3, r0, #0 - adds r3, #0x42 - movs r2, #2 - strb r2, [r3] - adds r0, #0x46 - movs r2, #0xa0 - lsls r2, r2, #2 - strh r2, [r0] - adds r1, #0x3d - ldrb r2, [r1] - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #0 - bne _08017EAA - movs r0, #0xff - strb r0, [r1] -_08017EAA: - movs r0, #1 - pop {r1} - bx r1 - - thumb_func_start sub_08017EB0 -sub_08017EB0: @ 0x08017EB0 - push {r4, r5, r6, r7, lr} - adds r2, r0, #0 - adds r7, r1, #0 - adds r5, r7, #0 - adds r5, #0x44 - ldrb r0, [r5] - cmp r0, #0 - bne _08017EC4 - movs r0, #0 - b _08017F36 -_08017EC4: - ldr r6, _08017EF8 @ =gPlayerEntity - cmp r2, r6 - bne _08017EFC - ldrb r4, [r5] - movs r0, #8 - strb r0, [r5] - adds r0, r6, #0 - adds r1, r7, #0 - bl sub_08017874 - adds r1, r6, #0 - adds r1, #0x45 - strb r0, [r1] - strb r4, [r5] - subs r1, #3 - movs r0, #0xc - strb r0, [r1] - subs r1, #5 - movs r0, #0x10 - strb r0, [r1] - adds r1, #9 - movs r0, #0xc0 - lsls r0, r0, #1 - strh r0, [r1] - b _08017F22 - .align 2, 0 -_08017EF8: .4byte gPlayerEntity -_08017EFC: - ldrh r1, [r2, #8] - movs r0, #0xa1 - lsls r0, r0, #3 - cmp r1, r0 - bne _08017F22 - adds r1, r2, #0 - adds r1, #0x42 - movs r0, #8 - strb r0, [r1] - subs r1, #5 - movs r0, #0xfa - strb r0, [r1] - adds r1, #9 - adds r0, #0x86 - strh r0, [r1] - adds r1, r6, #0 - adds r1, #0x3d - movs r0, #0x80 - strb r0, [r1] -_08017F22: - adds r1, r7, #0 - adds r1, #0x3d - ldrb r2, [r1] - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #0 - bne _08017F34 - movs r0, #0xff - strb r0, [r1] -_08017F34: - movs r0, #1 -_08017F36: - pop {r4, r5, r6, r7} - pop {r1} - bx r1 - - thumb_func_start sub_08017F3C -sub_08017F3C: @ 0x08017F3C - movs r0, #1 - bx lr - - thumb_func_start sub_08017F40 -sub_08017F40: @ 0x08017F40 - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r5, r1, #0 - adds r0, r5, #0 - adds r0, #0x43 - ldrb r6, [r0] - cmp r6, #0 - bne _0801800A - ldr r0, _08017FAC @ =gPlayerEntity - cmp r4, r0 - bne _08018002 - bl sub_08079F8C - cmp r0, #0 - beq _0801801E - ldr r2, _08017FB0 @ =gPlayerState - ldr r3, [r2, #0x30] -.ifdef EU - movs r0, #0x81 -.else - movs r0, #0x80 -.endif - ands r0, r3 - cmp r0, #0 - bne _0801801E - adds r0, r2, #0 - adds r0, #0x26 - ldrb r0, [r0] - cmp r0, #0 - bne _0801801E - ldrb r1, [r2, #0x1a] - movs r0, #0x80 - orrs r1, r0 - strb r1, [r2, #0x1a] - ldrb r1, [r2, #0xa] - orrs r0, r1 - strb r0, [r2, #0xa] - movs r0, #0x10 - orrs r3, r0 - str r3, [r2, #0x30] - strb r6, [r2, #2] - ldrb r0, [r5, #8] - cmp r0, #3 - bne _08017FB4 - ldrb r0, [r5, #9] - cmp r0, #0x4e - beq _08017F9A - cmp r0, #0x50 - bne _08017FB4 -_08017F9A: - strh r6, [r4, #0x36] - movs r3, #0x80 - lsls r3, r3, #9 - adds r0, r4, #0 - adds r1, r5, #0 - movs r2, #0 - bl PositionRelative - b _08017FC2 - .align 2, 0 -_08017FAC: .4byte gPlayerEntity -_08017FB0: .4byte gPlayerState -_08017FB4: - movs r3, #0x80 - lsls r3, r3, #9 - adds r0, r5, #0 - adds r1, r4, #0 - movs r2, #0 - bl PositionRelative -_08017FC2: - ldrb r1, [r4, #0x10] - movs r0, #0x7f - ands r0, r1 - strb r0, [r4, #0x10] - ldrb r2, [r5, #0x19] - lsrs r2, r2, #6 - lsls r2, r2, #6 - ldrb r3, [r4, #0x19] - movs r1, #0x3f - adds r0, r1, #0 - ands r0, r3 - orrs r0, r2 - strb r0, [r4, #0x19] - ldrb r0, [r5, #0x1b] - lsrs r0, r0, #6 - lsls r0, r0, #6 - ldrb r2, [r4, #0x1b] - ands r1, r2 - orrs r1, r0 - strb r1, [r4, #0x1b] - adds r1, r4, #0 - adds r1, #0x3d - movs r0, #0xff - strb r0, [r1] - adds r1, r5, #0 - adds r1, #0x3d - movs r0, #0xf8 - strb r0, [r1] - bl ResetPlayer - movs r0, #1 - b _08018020 -_08018002: - adds r0, r4, #0 - adds r0, #0x45 - strb r6, [r0] - b _0801801E -_0801800A: - ldrb r0, [r5, #8] - cmp r0, #3 - bne _0801801E - ldr r0, _08018028 @ =gPlayerEntity - cmp r4, r0 - bne _0801801E - adds r0, r5, #0 - adds r1, r4, #0 - bl sub_08004484 -_0801801E: - movs r0, #0 -_08018020: - pop {r4, r5, r6} - pop {r1} - bx r1 - .align 2, 0 -_08018028: .4byte gPlayerEntity - - thumb_func_start sub_0801802C -sub_0801802C: @ 0x0801802C - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r5, r1, #0 - adds r6, r2, #0 - ldrb r0, [r4, #8] - cmp r0, #1 - bne _08018058 - bl sub_08079F8C - cmp r0, #0 - beq _08018090 - movs r0, #0x10 - eors r0, r6 - ldrb r1, [r5, #0x14] - lsls r1, r1, #2 - subs r0, r0, r1 - adds r0, #5 - movs r1, #0x1f - ands r0, r1 - cmp r0, #0xa - bhi _08018090 - b _0801807A -_08018058: - cmp r0, #8 - bne _08018086 - ldrb r0, [r4, #0x15] - movs r1, #0x10 - eors r1, r0 - ldrb r0, [r5, #0x14] - lsls r0, r0, #2 - subs r1, r1, r0 - adds r1, #5 - movs r0, #0x1f - ands r1, r0 - cmp r1, #0xa - bgt _08018090 - adds r1, r4, #0 - adds r1, #0x45 - movs r0, #0 - strb r0, [r1] -_0801807A: - adds r0, r4, #0 - adds r1, r5, #0 - bl sub_080180BC - movs r0, #1 - b _080180AE -_08018086: - adds r1, r4, #0 - adds r1, #0x45 - movs r0, #0 - strb r0, [r1] - b _080180AE -_08018090: - adds r0, r4, #0 - adds r0, #0x40 - ldrb r0, [r0] - ldr r1, _080180B4 @ =0x000011AA - adds r0, r0, r1 - lsls r3, r0, #1 - adds r3, r3, r0 - lsls r3, r3, #2 - ldr r0, _080180B8 @ =gUnk_080B7B74 - adds r3, r3, r0 - adds r0, r4, #0 - adds r1, r5, #0 - adds r2, r6, #0 - bl sub_08018308 -_080180AE: - pop {r4, r5, r6} - pop {r1} - bx r1 - .align 2, 0 -_080180B4: .4byte 0x000011AA -_080180B8: .4byte gUnk_080B7B74 - - thumb_func_start sub_080180BC -sub_080180BC: @ 0x080180BC - push {lr} - adds r2, r0, #0 - adds r2, #0x3d - movs r0, #0 - ldrsb r0, [r2, r0] - cmp r0, #0 - bne _080180CE - movs r0, #0xe2 - strb r0, [r2] -_080180CE: - adds r2, r1, #0 - adds r2, #0x3d - ldrb r3, [r2] - movs r0, #0 - ldrsb r0, [r2, r0] - cmp r0, #0 - bne _080180E0 - movs r0, #0xff - strb r0, [r2] -_080180E0: - movs r0, #0xff - strb r0, [r1, #0xd] - pop {r0} - bx r0 - - thumb_func_start sub_080180E8 -sub_080180E8: @ 0x080180E8 - push {r4, lr} - mov ip, r0 - adds r4, r1, #0 - movs r0, #0x10 - eors r0, r2 - adds r2, r0, #0 - subs r2, #0xc - movs r1, #0x1f - ands r2, r1 - ldrb r0, [r4, #0x15] - subs r0, r0, r2 - ands r0, r1 - cmp r0, #0x18 - bls _0801812C - mov r0, ip - adds r0, #0x40 - ldrb r0, [r0] - ldr r1, _08018124 @ =0x00000352 - adds r0, r0, r1 - lsls r3, r0, #1 - adds r3, r3, r0 - lsls r3, r3, #2 - ldr r0, _08018128 @ =gUnk_080B7B74 - adds r3, r3, r0 - mov r0, ip - adds r1, r4, #0 - bl sub_08018308 - b _08018162 - .align 2, 0 -_08018124: .4byte 0x00000352 -_08018128: .4byte gUnk_080B7B74 -_0801812C: - mov r0, ip - adds r0, #0x42 - movs r2, #0xc - strb r2, [r0] - subs r0, #5 - movs r1, #0xf0 - strb r1, [r0] - mov r3, ip - adds r3, #0x46 - movs r0, #0xa0 - lsls r0, r0, #2 - strh r0, [r3] - adds r0, r4, #0 - adds r0, #0x42 - strb r2, [r0] - subs r0, #5 - strb r1, [r0] - adds r1, r4, #0 - adds r1, #0x46 - movs r0, #0xc0 - lsls r0, r0, #2 - strh r0, [r1] - mov r0, ip - adds r1, r4, #0 - bl sub_08017940 - movs r0, #1 -_08018162: - pop {r4} - pop {r1} - bx r1 - - thumb_func_start sub_08018168 -sub_08018168: @ 0x08018168 - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r6, r1, #0 - adds r0, r6, #0 - adds r0, #0x43 - ldrb r5, [r0] - cmp r5, #0 - bne _08018208 - ldr r0, _080181F4 @ =gPlayerEntity - cmp r4, r0 - bne _08018200 - bl sub_08079F8C - cmp r0, #0 - beq _0801821C - ldr r2, _080181F8 @ =gPlayerState - ldr r3, [r2, #0x30] -.ifdef EU - movs r0, #0x81 -.else - ldr r0, _080181FC @ =0x00040080 -.endif - ands r0, r3 - cmp r0, #0 - bne _0801821C - adds r0, r2, #0 - adds r0, #0x26 - ldrb r0, [r0] - cmp r0, #0 - bne _0801821C - ldrb r1, [r2, #0x1a] - movs r0, #0x80 - orrs r1, r0 - strb r1, [r2, #0x1a] - ldrb r1, [r2, #0xa] - orrs r0, r1 - strb r0, [r2, #0xa] - movs r0, #0x80 - lsls r0, r0, #1 - orrs r3, r0 - str r3, [r2, #0x30] - strb r5, [r2, #2] - ldrb r1, [r4, #0x10] - movs r0, #0x7f - ands r0, r1 - strb r0, [r4, #0x10] - ldrb r2, [r6, #0x19] - lsrs r2, r2, #6 - lsls r2, r2, #6 - ldrb r3, [r4, #0x19] - movs r1, #0x3f - adds r0, r1, #0 - ands r0, r3 - orrs r0, r2 - strb r0, [r4, #0x19] - ldrb r0, [r6, #0x1b] - lsrs r0, r0, #6 - lsls r0, r0, #6 - ldrb r2, [r4, #0x1b] - ands r1, r2 - orrs r1, r0 - strb r1, [r4, #0x1b] - adds r1, r4, #0 - adds r1, #0x3d - movs r0, #0xff - strb r0, [r1] - adds r1, r6, #0 - adds r1, #0x3d - movs r0, #0xf8 - strb r0, [r1] - bl sub_08077B20 - movs r0, #1 - b _0801821E - .align 2, 0 -_080181F4: .4byte gPlayerEntity -_080181F8: .4byte gPlayerState -.ifndef EU -_080181FC: .4byte 0x00040080 -.endif -_08018200: - adds r0, r4, #0 - adds r0, #0x45 - strb r5, [r0] - b _0801821C -_08018208: - ldrb r0, [r6, #8] - cmp r0, #3 - bne _0801821C - ldr r0, _08018224 @ =gPlayerEntity - cmp r4, r0 - bne _0801821C - adds r0, r6, #0 - adds r1, r4, #0 - bl sub_08004484 -_0801821C: - movs r0, #0 -_0801821E: - pop {r4, r5, r6} - pop {r1} - bx r1 - .align 2, 0 -_08018224: .4byte gPlayerEntity - - thumb_func_start sub_08018228 -sub_08018228: @ 0x08018228 - push {r4, r5, lr} - adds r4, r0, #0 - adds r5, r1, #0 - ldr r0, _0801824C @ =gPlayerEntity - cmp r4, r0 - bne _08018244 - bl sub_08079F8C - cmp r0, #0 - beq _08018244 - adds r0, r5, #0 - adds r1, r4, #0 - bl sub_08004484 -_08018244: - movs r0, #0 - pop {r4, r5} - pop {r1} - bx r1 - .align 2, 0 -_0801824C: .4byte gPlayerEntity - - thumb_func_start sub_08018250 -sub_08018250: @ 0x08018250 - push {r4, lr} - adds r3, r0, #0 - adds r2, r3, #0 - adds r2, #0x3d - movs r0, #1 - rsbs r0, r0, #0 - adds r4, r0, #0 - movs r0, #0xff - strb r0, [r2] - ldrb r0, [r3, #0x15] - cmp r0, #0 - bne _08018278 - adds r2, r1, #0 - adds r2, #0x3d - movs r0, #0x10 - strb r0, [r2] - adds r0, r3, #0 - bl sub_08017A90 - b _08018280 -_08018278: - adds r1, #0x3d - ldrb r0, [r1] - orrs r0, r4 - strb r0, [r1] -_08018280: - movs r0, #1 - pop {r4} - pop {r1} - bx r1 - - thumb_func_start sub_08018288 -sub_08018288: @ 0x08018288 - push {lr} - adds r1, r0, #0 - ldr r0, _08018298 @ =gPlayerEntity - cmp r1, r0 - bne _0801829C - bl sub_0807AFE8 - b _080182A2 - .align 2, 0 -_08018298: .4byte gPlayerEntity -_0801829C: - adds r1, #0x45 - movs r0, #0 - strb r0, [r1] -_080182A2: - movs r0, #1 - pop {r1} - bx r1 - - thumb_func_start sub_080182A8 -sub_080182A8: @ 0x080182A8 - push {r4, lr} - adds r4, r0, #0 - adds r0, r1, #0 - adds r0, #0x43 - ldrb r0, [r0] - cmp r0, #0 - bne _080182DA - adds r2, r4, #0 - adds r2, #0x3d - ldrb r3, [r2] - movs r0, #0 - ldrsb r0, [r2, r0] - cmp r0, #0 - bne _080182C8 - movs r0, #0xff - strb r0, [r2] -_080182C8: - adds r1, #0x3d - ldrb r2, [r1] - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #0 - bne _08018300 - movs r0, #0xff - strb r0, [r1] - b _08018300 -_080182DA: - adds r0, r4, #0 - adds r0, #0x40 - ldrb r0, [r0] - ldr r3, _080182F8 @ =0x0000092A - adds r0, r0, r3 - lsls r3, r0, #1 - adds r3, r3, r0 - lsls r3, r3, #2 - ldr r0, _080182FC @ =gUnk_080B7B74 - adds r3, r3, r0 - adds r0, r4, #0 - bl sub_08018308 - b _08018302 - .align 2, 0 -_080182F8: .4byte 0x0000092A -_080182FC: .4byte gUnk_080B7B74 -_08018300: - movs r0, #1 -_08018302: - pop {r4} - pop {r1} - bx r1 - - thumb_func_start sub_08018308 -sub_08018308: @ 0x08018308 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - adds r6, r0, #0 - adds r4, r1, #0 - mov r8, r2 - adds r5, r3, #0 - movs r3, #0 - adds r0, r4, #0 - adds r0, #0x43 - ldrb r0, [r0] - cmp r0, #0 - beq _08018338 - ldrb r0, [r4, #8] - cmp r0, #3 - bne _08018338 - ldr r0, _0801835C @ =gPlayerEntity - cmp r6, r0 - bne _08018338 - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_08004484 - movs r3, #1 -_08018338: - ldrh r1, [r6, #8] - movs r0, #0xa1 - lsls r0, r0, #3 - cmp r1, r0 - bne _08018360 - ldr r0, _0801835C @ =gPlayerEntity - ldrb r2, [r0, #0x14] - mov r0, r8 - adds r0, #4 - movs r1, #0x18 - ands r0, r1 - lsrs r0, r0, #2 - movs r1, #4 - eors r0, r1 - cmp r2, r0 - bne _08018360 - movs r0, #0 - b _080184F0 - .align 2, 0 -_0801835C: .4byte gPlayerEntity -_08018360: - cmp r3, #0 - bne _08018408 - ldrb r0, [r5] - lsls r0, r0, #4 - adds r1, r6, #0 - adds r1, #0x46 - strh r0, [r1] - ldrb r1, [r5, #1] - adds r2, r6, #0 - adds r2, #0x3d - strb r1, [r2] - lsls r0, r1, #0x18 - cmp r0, #0 - bne _08018382 - movs r0, #0xff - orrs r0, r1 - strb r0, [r2] -_08018382: - ldrb r0, [r5, #2] - adds r1, r6, #0 - adds r1, #0x42 - strb r0, [r1] - ldrb r1, [r5, #3] - adds r0, r4, #0 - adds r0, #0x44 - strb r1, [r0] - movs r7, #0xff - ldrb r0, [r5, #3] - cmp r0, #0 - beq _080183A8 - adds r0, r6, #0 - adds r1, r4, #0 - bl sub_08017874 - adds r1, r6, #0 - adds r1, #0x45 - strb r0, [r1] -_080183A8: - adds r1, r6, #0 - adds r1, #0x43 - ldrb r0, [r5, #4] - ldrb r2, [r1] - cmp r0, r2 - bls _080183B6 - strb r0, [r1] -_080183B6: - ldrb r0, [r5, #5] - lsls r0, r0, #4 - adds r1, r4, #0 - adds r1, #0x46 - strh r0, [r1] - ldrb r1, [r5, #6] - adds r2, r4, #0 - adds r2, #0x3d - strb r1, [r2] - movs r0, #6 - ldrsb r0, [r5, r0] - cmp r0, #0 - bne _080183D6 - movs r0, #0xff - orrs r0, r1 - strb r0, [r2] -_080183D6: - ldrb r0, [r5, #7] - adds r1, r4, #0 - adds r1, #0x42 - strb r0, [r1] - ldrb r1, [r5, #8] - adds r0, r6, #0 - adds r0, #0x44 - strb r1, [r0] - ands r7, r1 - cmp r7, #0 - beq _080183FA - adds r0, r4, #0 - adds r1, r6, #0 - bl sub_08017874 - adds r1, r4, #0 - adds r1, #0x45 - strb r0, [r1] -_080183FA: - adds r1, r4, #0 - adds r1, #0x43 - ldrb r0, [r5, #9] - ldrb r2, [r1] - cmp r0, r2 - bls _08018408 - strb r0, [r1] -_08018408: - ldrb r1, [r5, #0xa] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _0801841A - adds r0, r6, #0 - adds r1, r4, #0 - bl sub_08017940 -_0801841A: - ldrb r2, [r5, #0xa] - movs r0, #2 - ands r0, r2 - cmp r0, #0 - beq _0801842C - adds r1, r6, #0 - adds r1, #0x41 - movs r0, #0xca - strb r0, [r1] -_0801842C: - movs r0, #4 - ands r0, r2 - cmp r0, #0 - beq _0801847E - ldr r2, [r4, #0x50] - cmp r2, #0 - beq _0801847E - adds r1, r2, #0 - adds r1, #0x41 - movs r0, #0xcc - strb r0, [r1] - adds r0, r4, #0 - adds r0, #0x3d - ldrb r0, [r0] - subs r1, #4 - strb r0, [r1] - adds r0, r2, #0 - adds r0, #0x3e - mov r1, r8 - strb r1, [r0] - adds r0, r4, #0 - adds r0, #0x42 - ldrb r0, [r0] - adds r1, r2, #0 - adds r1, #0x42 - strb r0, [r1] - adds r1, #1 - ldrb r0, [r1] - cmp r0, #0 - bne _08018470 - adds r0, r4, #0 - adds r0, #0x43 - ldrb r0, [r0] - strb r0, [r1] -_08018470: - adds r0, r4, #0 - adds r0, #0x46 - ldrh r0, [r0] - adds r1, r2, #0 - adds r1, #0x46 - strh r0, [r1] - str r6, [r2, #0x4c] -_0801847E: - ldrb r1, [r6, #8] - cmp r1, #8 - bne _080184DA - ldrb r0, [r6, #9] - cmp r0, #1 - bne _0801849A - ldrb r0, [r5, #8] - cmp r0, #0 - beq _080184DA - adds r0, r6, #0 - adds r1, r4, #0 - bl sub_080179EC - b _080184DA -_0801849A: - cmp r0, #4 - bne _080184BA - adds r0, r6, #0 - adds r0, #0x44 - ldrb r0, [r0] - cmp r0, #0 - bne _080184B0 - ldrb r0, [r5, #0xa] - ands r1, r0 - cmp r1, #0 - beq _080184DA -_080184B0: - adds r0, r6, #0 - adds r1, r4, #0 - bl sub_08017A90 - b _080184DA -_080184BA: - cmp r0, #3 - bne _080184CE - ldrb r0, [r5, #9] - cmp r0, #0 - beq _080184DA - adds r0, r4, #0 - movs r1, #0xfe - bl sub_0800449C - b _080184DA -_080184CE: - cmp r0, #5 - bne _080184DA - ldr r0, _080184FC @ =gPlayerEntity - adds r0, #0x3d - movs r1, #0x80 - strb r1, [r0] -_080184DA: - ldrb r0, [r4, #8] - cmp r0, #8 - bne _080184EE - ldrb r0, [r6, #9] - cmp r0, #5 - bne _080184EE - ldr r0, _080184FC @ =gPlayerEntity - adds r0, #0x3d - movs r1, #0x80 - strb r1, [r0] -_080184EE: - movs r0, #1 -_080184F0: - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 - .align 2, 0 -_080184FC: .4byte gPlayerEntity diff --git a/asm/code_0806EC20.s b/asm/code_0806EC20.s index ff7f71a1..447e31be 100644 --- a/asm/code_0806EC20.s +++ b/asm/code_0806EC20.s @@ -58,8 +58,8 @@ _0806EC6E: .align 2, 0 _0806EC74: .4byte gUnk_08114AE4 - thumb_func_start sub_0806EC78 -sub_0806EC78: @ 0x0806EC78 + thumb_func_start InitNPC +InitNPC: @ 0x0806EC78 push {r4, r5, lr} adds r4, r0, #0 ldrb r1, [r4, #0x10] diff --git a/asm/code_0807F0D8.s b/asm/code_0807F0D8.s index df197ed3..6eaef89b 100644 --- a/asm/code_0807F0D8.s +++ b/asm/code_0807F0D8.s @@ -625,7 +625,7 @@ _080800C6: bne _080800FC movs r0, #3 strb r0, [r5, #3] - bl sub_0805E9F4 + bl DeleteSleepingEntities bl sub_0807C810 ldr r1, _080800F4 @ =gUnk_08109194 ldr r0, _080800F8 @ =gUnk_03004030 diff --git a/asm/code_080A3BD0.s b/asm/code_080A3BD0.s index 47338cc4..ac544ed9 100644 --- a/asm/code_080A3BD0.s +++ b/asm/code_080A3BD0.s @@ -1263,7 +1263,7 @@ _080A4550: cmp r0, #7 bne _080A456A adds r0, r4, #0 - bl sub_0806EC78 + bl InitNPC ldrb r0, [r4, #9] strb r0, [r4, #0xf] movs r0, #0x56 diff --git a/asm/updateBackgroundRegisters.s b/asm/dispCtrlSet.s similarity index 94% rename from asm/updateBackgroundRegisters.s rename to asm/dispCtrlSet.s index 94c37ab2..7f170352 100644 --- a/asm/updateBackgroundRegisters.s +++ b/asm/dispCtrlSet.s @@ -1,12 +1,4 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - .syntax unified - - .text - - thumb_func_start DispCtrlSet -DispCtrlSet: @ 0x08016CF4 ldr r3, _08016DF0 @ =gScreen ldrh r1, [r3] ldrh r0, [r3, #6] @@ -136,3 +128,4 @@ DispCtrlSet: @ 0x08016CF4 .align 2, 0 _08016DF0: .4byte gScreen _08016DF4: .4byte 0x04000020 + .syntax divided \ No newline at end of file diff --git a/asm/fileScreen.s b/asm/fileScreen.s index ba9cbbfd..0b431a67 100755 --- a/asm/fileScreen.s +++ b/asm/fileScreen.s @@ -242,7 +242,7 @@ _0805173E: adds r0, r2, #0 bl SoundReq _08051796: - bl sub_0805E9F4 + bl DeleteSleepingEntities bl sub_0805BC04 adds r4, r0, #0 cmp r4, #0 @@ -324,7 +324,7 @@ _08051B02: adds r0, r2, #0 bl SoundReq _08051B5A: - bl sub_0805E9F4 + bl DeleteSleepingEntities bl sub_0805BC04 adds r4, r0, #0 cmp r4, #0 diff --git a/asm/intr.s b/asm/intr.s index fc981eb3..735f7115 100644 --- a/asm/intr.s +++ b/asm/intr.s @@ -268,8 +268,8 @@ UpdateCollision: @ 0x080B1C54 strb r1, [r3] bx lr - arm_func_start sub_080B1C7C -sub_080B1C7C: @ 0x080B1C7C + arm_func_start CollideAll +CollideAll: @ 0x080B1C7C push {r4, r5, r6, r7, r8, sb, sl, lr} add r0, pc, #0x104 @ =_080B1D8C ldm r0, {r8, sb, sl} @@ -314,7 +314,7 @@ _080B1CC8: orrs r0, r0, r2 bne _080B1CC8 _080B1D20: - bl sub_080B1D98 + bl CalcCollision cmp r0, #0 beq _080B1CC8 ldrb r3, [r4, #0x3c] @@ -348,8 +348,10 @@ _080B1D8C: .4byte gUnk_02018EA0 _080B1D90: .4byte gCollidableList _080B1D94: .4byte gCollidableCount - arm_func_start sub_080B1D98 -sub_080B1D98: @ 0x080B1D98 + arm_func_start CalcCollision +CalcCollision: @ 0x080B1D98 + @ r6 = this, r7 = other + push {r2, r3, r6, r7, r8, sb, ip, lr} ldr r6, [r4, #0x48] ldr r7, [r5, #0x48] @@ -408,7 +410,7 @@ sub_080B1D98: @ 0x080B1D98 _080B1E74: mov r2, #0 mov ip, #0 - bl sub_080B237C + bl CalcCollisionDirection mov r6, r0 ldrb r1, [r5, #0x3f] mov r0, #0x22 @@ -417,7 +419,7 @@ _080B1E74: add r0, r0, r1 mov r1, #0xc mul r2, r0, r1 - ldr r1, _080B2014 @ =gUnk_080B7B74 + ldr r1, _080B2014 @ =gCollisionMtx add r3, r2, r1 mov r1, #0 ldrb r0, [r3] @@ -532,7 +534,7 @@ _080B2004: .4byte gUnk_03005D18 _080B2008: .4byte gUnk_03005D58 _080B200C: .4byte gCollidableList _080B2010: .4byte gCollidableCount -_080B2014: .4byte gUnk_080B7B74 +_080B2014: .4byte gCollisionMtx _080B2018: .4byte gUnk_080B3744 arm_func_start IntrMain @@ -796,8 +798,8 @@ _080B236C: .align 2, 0 _080B2378: .4byte sub_080044AE - arm_func_start sub_080B237C -sub_080B237C: @ 0x080B237C + arm_func_start CalcCollisionDirection +CalcCollisionDirection: @ 0x080B237C subs r2, r2, r0 movpl r0, #0 movmi r0, #0x20 diff --git a/asm/jarPortal.s b/asm/jarPortal.s deleted file mode 100644 index a42aa8ad..00000000 --- a/asm/jarPortal.s +++ /dev/null @@ -1,8 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - diff --git a/asm/non_matching/arm_proxy/NPCUpdate.inc b/asm/non_matching/arm_proxy/NPCUpdate.inc index 278daa48..bb62b469 100644 --- a/asm/non_matching/arm_proxy/NPCUpdate.inc +++ b/asm/non_matching/arm_proxy/NPCUpdate.inc @@ -23,10 +23,10 @@ _08017550: cmp r0, #0 bne _08017566 adds r0, r4, #0 - bl sub_0806EC78 + bl InitNPC _08017566: adds r0, r4, #0 - bl sub_0805E3B0 + bl CheckDontUpdate cmp r0, #0 bne _08017584 ldr r2, _080175DC @ =gNPCFunctions diff --git a/asm/non_matching/collision/sub_08017CBC.inc b/asm/non_matching/collision/sub_08017CBC.inc new file mode 100644 index 00000000..470a013e --- /dev/null +++ b/asm/non_matching/collision/sub_08017CBC.inc @@ -0,0 +1,57 @@ + .syntax unified + push {r4, r5, lr} + adds r4, r0, #0 + adds r3, r1, #0 + movs r5, #0x10 + eors r2, r5 + adds r0, r2, #0 + subs r0, #0xc + movs r2, #0x1f + ands r0, r2 + ldrb r1, [r3, #0x15] + subs r1, r1, r0 + ands r1, r2 + cmp r1, #0x18 + bhi _08017CF0 + adds r1, r4, #0 + adds r1, #0x3d + movs r0, #0xf4 + strb r0, [r1] + adds r1, r3, #0 + adds r1, #0x3d + strb r0, [r1] + adds r0, r4, #0 + adds r1, r3, #0 + bl sub_08017940 + b _08017D1E +_08017CF0: + adds r1, r3, #0 + adds r1, #0x42 + movs r0, #0xc + strb r0, [r1] + adds r0, r3, #0 + adds r0, #0x3d + strb r5, [r0] + adds r1, #1 + movs r0, #0xf0 + strb r0, [r1] + adds r1, #3 + movs r0, #0xc0 + lsls r0, r0, #2 + strh r0, [r1] + adds r1, r4, #0 + adds r1, #0x3d + ldrb r2, [r1] + movs r0, #0 + ldrsb r0, [r1, r0] + cmp r0, #0 + bne _08017D1E + movs r0, #0xff + strb r0, [r1] +_08017D1E: + movs r0, #1 + pop {r4, r5} + pop {r1} + bx r1 + .align 2, 0 + .syntax divided diff --git a/asm/non_matching/collision/sub_0801802C.inc b/asm/non_matching/collision/sub_0801802C.inc new file mode 100644 index 00000000..66be3cf4 --- /dev/null +++ b/asm/non_matching/collision/sub_0801802C.inc @@ -0,0 +1,75 @@ + .syntax unified + push {r4, r5, r6, lr} + adds r4, r0, #0 + adds r5, r1, #0 + adds r6, r2, #0 + ldrb r0, [r4, #8] + cmp r0, #1 + bne _08018058 + bl sub_08079F8C + cmp r0, #0 + beq _08018090 + movs r0, #0x10 + eors r0, r6 + ldrb r1, [r5, #0x14] + lsls r1, r1, #2 + subs r0, r0, r1 + adds r0, #5 + movs r1, #0x1f + ands r0, r1 + cmp r0, #0xa + bhi _08018090 + b _0801807A +_08018058: + cmp r0, #8 + bne _08018086 + ldrb r0, [r4, #0x15] + movs r1, #0x10 + eors r1, r0 + ldrb r0, [r5, #0x14] + lsls r0, r0, #2 + subs r1, r1, r0 + adds r1, #5 + movs r0, #0x1f + ands r1, r0 + cmp r1, #0xa + bgt _08018090 + adds r1, r4, #0 + adds r1, #0x45 + movs r0, #0 + strb r0, [r1] +_0801807A: + adds r0, r4, #0 + adds r1, r5, #0 + bl sub_080180BC + movs r0, #1 + b _080180AE +_08018086: + adds r1, r4, #0 + adds r1, #0x45 + movs r0, #0 + strb r0, [r1] + b _080180AE +_08018090: + adds r0, r4, #0 + adds r0, #0x40 + ldrb r0, [r0] + ldr r1, _080180B4 @ =0x000011AA + adds r0, r0, r1 + lsls r3, r0, #1 + adds r3, r3, r0 + lsls r3, r3, #2 + ldr r0, _080180B8 @ =gCollisionMtx + adds r3, r3, r0 + adds r0, r4, #0 + adds r1, r5, #0 + adds r2, r6, #0 + bl sub_08018308 +_080180AE: + pop {r4, r5, r6} + pop {r1} + bx r1 + .align 2, 0 +_080180B4: .4byte 0x000011AA +_080180B8: .4byte gCollisionMtx + .syntax divided \ No newline at end of file diff --git a/asm/object11.s b/asm/object11.s index 165dd5ab..2c8211d8 100644 --- a/asm/object11.s +++ b/asm/object11.s @@ -11,7 +11,7 @@ Object11: @ 0x08084D34 push {r4, lr} adds r4, r0, #0 - bl sub_0805E3B0 + bl CheckDontUpdate cmp r0, #0 bne _08084D50 ldr r0, _08084D54 @ =gUnk_0812057C diff --git a/asm/object1E.s b/asm/object1E.s index e3168e6a..5191f789 100644 --- a/asm/object1E.s +++ b/asm/object1E.s @@ -11,7 +11,7 @@ Object1E: @ 0x08087504 push {r4, lr} adds r4, r0, #0 - bl sub_0805E3B0 + bl CheckDontUpdate cmp r0, #0 bne _08087520 ldr r0, _08087524 @ =gUnk_081208B8 diff --git a/asm/sub_08016AE4.s b/asm/sub_08016AE4.s index c5b75bef..5de15a92 100644 --- a/asm/sub_08016AE4.s +++ b/asm/sub_08016AE4.s @@ -18,7 +18,7 @@ ProjectileUpdate: @ 0x08016AE4 bne _08016B0A bl DeleteThisEntity _08016AFC: - bl sub_0805E3B0 + bl CheckDontUpdate cmp r0, #0 bne _08016B22 adds r0, r4, #0 diff --git a/asm/sub_080A2838.s b/asm/sub_080A2838.s index 57383f72..643d1ae1 100644 --- a/asm/sub_080A2838.s +++ b/asm/sub_080A2838.s @@ -6,8 +6,8 @@ .text - thumb_func_start sub_080A2838 -sub_080A2838: @ 0x080A2838 + thumb_func_start InitObject +InitObject: @ 0x080A2838 push {r4, lr} adds r4, r0, #0 ldrb r2, [r4, #9] diff --git a/data/data_080B2A70.s b/data/data_080B2A70.s index 80681df3..f25effdf 100644 --- a/data/data_080B2A70.s +++ b/data/data_080B2A70.s @@ -5,20 +5,20 @@ .align 2 gUnk_080B2A70:: @ 080B2A70 - .4byte sub_08016B30 - .4byte sub_08016B30 - .4byte sub_08016B30 + .4byte DummyIntr + .4byte DummyIntr + .4byte DummyIntr .4byte HBlankIntr - .4byte sub_08016B6C - .4byte sub_08016B30 - .4byte sub_08016B30 - .4byte sub_08016B30 - .4byte sub_08016B30 - .4byte sub_08016B30 - .4byte sub_08016B30 - .4byte sub_08016B30 - .4byte sub_08016B30 - .4byte sub_08016B30 + .4byte VBlankIntr + .4byte DummyIntr + .4byte DummyIntr + .4byte DummyIntr + .4byte DummyIntr + .4byte DummyIntr + .4byte DummyIntr + .4byte DummyIntr + .4byte DummyIntr + .4byte DummyIntr @ TODO contains some pointers to iwram diff --git a/data/data_080B3740.s b/data/data_080B3740.s index 393f1e17..7eadfad5 100644 --- a/data/data_080B3740.s +++ b/data/data_080B3740.s @@ -9,9 +9,9 @@ gUnk_080B3740:: @ 080B3740 gUnk_080B3744:: @ 080B3744 .4byte sub_08018308 - .4byte sub_08017AD8 - .4byte sub_08017AD8 - .4byte sub_08017ADC + .4byte CollisionNoOp + .4byte CollisionNoOp + .4byte CollisionGroundItem .4byte sub_08017B58 .4byte sub_08017EB0 .4byte sub_08017F3C diff --git a/data/data_080B7B74.s b/data/data_080B7B74.s index 32ea1744..9f7e39d3 100644 --- a/data/data_080B7B74.s +++ b/data/data_080B7B74.s @@ -4,7 +4,7 @@ .section .rodata .align 2 -gUnk_080B7B74:: @ 080B7B74 +gCollisionMtx:: @ 080B7B74 .incbin "baserom.gba", 0x0B7B74, 0x00004BA gUnk_080B802E:: @ 080B802E diff --git a/include/entity.h b/include/entity.h index 1873138f..b6793df1 100644 --- a/include/entity.h +++ b/include/entity.h @@ -42,17 +42,17 @@ typedef struct { typedef struct Entity { /*0x00*/ struct Entity* prev; /*0x04*/ struct Entity* next; - /*0x08*/ u8 kind; // was: type - /*0x09*/ u8 id; // was: subtype - /*0x0a*/ u8 type; // was: form - /*0x0b*/ u8 type2; // was: parameter + /*0x08*/ u8 kind; + /*0x09*/ u8 id; + /*0x0a*/ u8 type; + /*0x0b*/ u8 type2; /*0x0c*/ u8 action; /*0x0d*/ u8 subAction; /*0x0e*/ u8 actionDelay; /*0x0f*/ u8 field_0xf; /*0x10*/ u8 flags; - /*0x11*/ u8 scriptedScene : 4; - /* */ u8 scriptedScene2 : 4; + /*0x11*/ u8 updateConditions : 4; // should we update this sprite during pause + /* */ u8 updateConditions2 : 4; /*0x12*/ s16 spriteIndex; /*0x14*/ u8 animationState; /*0x15*/ u8 direction; @@ -110,12 +110,12 @@ typedef struct Entity { /*0x3c*/ u8 field_0x3c; /*0x3d*/ s8 iframes; /*0x3e*/ u8 knockbackDirection; - /*0x3f*/ u8 damageType; - /*0x40*/ u8 field_0x40; + /*0x3f*/ u8 hitType; // behavior as a collision sender + /*0x40*/ u8 hurtType; // behavior as a collision reciever /*0x41*/ u8 bitfield; /*0x42*/ u8 knockbackDuration; /*0x43*/ u8 field_0x43; - /*0x44*/ u8 field_0x44; + /*0x44*/ u8 damage; /*0x45*/ u8 currentHealth; /*0x46*/ u16 field_0x46; /*0x48*/ Hitbox* hitbox; @@ -165,9 +165,20 @@ extern LinkedList gUnk_03003D90; extern LinkedList gUnk_03003DA0; +enum { + ENT_DID_INIT = 0x1, + ENT_SCRIPTED = 0x2, + ENT_ASLEEP = 0x10, + ENT_20 = 0x20, + ENT_COLLIDE = 0x80, +}; + +#define COLLISION_OFF(entity) ((entity)->flags &= ~ENT_COLLIDE) +#define COLLISION_ON(entity) ((entity)->flags |= ENT_COLLIDE) + #define TILE(x, y) \ - (((((x) - gRoomControls.roomOriginX) >> 4) & 0x3fU) | \ - ((((y) - gRoomControls.roomOriginY) >> 4) & 0x3fU) << 6) + (((((x) - gRoomControls.roomOriginX) >> 4) & 0x3F) | \ + ((((y) - gRoomControls.roomOriginY) >> 4) & 0x3F) << 6) #define COORD_TO_TILE(entity) \ TILE((entity)->x.HALF.HI, (entity)->y.HALF.HI) @@ -186,9 +197,10 @@ enum { #define DirectionRoundUp(expr) DirectionRound((expr) + 4) #define DirectionIsHorizontal(expr) ((expr) & 0x08) #define DirectionIsVertical(expr) ((expr) & 0x10) -#define DirectionTurnAround(expr) (DirectionRoundUp(expr) ^ 0x10) +#define DirectionTurnAround(expr) ((expr) ^ 0x10) #define DirectionToAnimationState(expr) (DirectionRoundUp(expr) >> 3) #define DirectionFromAnimationState(expr) ((expr) << 3) +#define DirectionNormalize(expr) ((expr) & 0x1f) #define Direction8Round(expr) ((expr) & 0x1c) #define Direction8RoundUp(expr) Direction8Round((expr) + 2) diff --git a/include/main.h b/include/main.h index b358ba49..99007163 100644 --- a/include/main.h +++ b/include/main.h @@ -96,7 +96,7 @@ extern void sub_0804FF84(u32); extern u16 gPaletteBuffer[]; extern void VBlankInterruptWait(void); extern void DisableInterruptsAndDMA(void); -extern void sub_08016B34(void); +extern void EnableVBlankIntr(void); static void sub_08055F70(void); static bool32 SoftResetKeysPressed(void); diff --git a/include/player.h b/include/player.h index 11d91234..b33a2b8f 100644 --- a/include/player.h +++ b/include/player.h @@ -92,7 +92,7 @@ typedef struct { /* */ u8 swordBlueParticle : 1; /* */ u8 filler14 : 6; /*0x3f*/ u8 field_0x3f; - /*0x40*/ u8 field_0x40[64]; + /*0x40*/ u8 hurtType[64]; /*0x80*/ u16 field_0x80; /*0x82*/ u8 field_0x82[9]; /*0x8b*/ u8 field_0x8b; @@ -161,6 +161,10 @@ extern Entity gPlayerEntity; extern u32 GetInventoryValue(u32); extern s32 ModHealth(s32); extern void ModRupees(s32); + +#define COPY_FLAG_FROM_TO(base, src, dest) (base) = ((base) & ~(dest)) | (((dest) * ((base) & (src))) / src) + + #endif // clang-format on diff --git a/include/structures.h b/include/structures.h index 9f3f1276..bc5f13ea 100644 --- a/include/structures.h +++ b/include/structures.h @@ -61,7 +61,7 @@ typedef struct { u8 field_0x3c; u8 field_0x3d; u16 field_0x3e; - u16 field_0x40; + u16 hurtType; u16 field_0x42; u16 field_0x44; u16 field_0x46; diff --git a/linker.ld b/linker.ld index a14b7752..284ad05c 100644 --- a/linker.ld +++ b/linker.ld @@ -331,10 +331,8 @@ SECTIONS { /* C source compiled with interworking */ - asm/code_08016B30.o(.text); - asm/updateBackgroundRegisters.o(.text); - src/arm_proxy.o(.text); - asm/code_08016DF8.o(.text); + src/interrupts.o(.text); + src/collision.o(.text); /* C source compiled without interworking */ asm/code_08018500.o(.text); src/code_08018C58.o(.text); @@ -757,7 +755,6 @@ SECTIONS { asm/object36.o(.text); asm/object37.o(.text); src/object/jarPortal.o(.text); - asm/jarPortal.o(.text); asm/bossDoor.o(.text); asm/object3A.o(.text); asm/macroMushroomStalks.o(.text); diff --git a/src/collision.c b/src/collision.c new file mode 100644 index 00000000..9c0309c7 --- /dev/null +++ b/src/collision.c @@ -0,0 +1,714 @@ +#include "global.h" +#include "entity.h" +#include "player.h" +#include "save.h" +#include "random.h" +#include "utils.h" +#include "functions.h" +#include "enemy.h" +#include "effects.h" + +extern u8 gCollidableCount; +extern u8 gUnk_080B3740[]; + +typedef struct { + u8 _0; + u8 _1; + u8 _2; + u8 _3; + u8 _4; + u8 _5; + s8 _6; + u8 _7; + u8 _8; + u8 _9; + u8 _a; + u8 _b; +} ColSettings; + +extern ColSettings gCollisionMtx[173 * 34]; + +extern void gDoCollision(void); +u32 sub_08081420(Entity*); +extern void sub_0800449C(Entity*, u32); +s32 sub_08018308(Entity*, Entity*, u32, ColSettings*); +void sub_08079D84(void); +void sub_080180BC(Entity*, Entity*); +void sub_0807AFE8(void); + +typedef struct { + void* last; + void* first; + void* node; + u8 flags; +} LinkedList2; + +extern LinkedList2 gUnk_03003C70[16]; +extern LinkedList2* gUnk_02018EA0; + +void ClearHitboxList(void) { + gCollidableCount = 0; +} + +void CollisionMain(void) { + void (*doCollision)(void); + u32 temp; + + temp = gUnk_03003DC0.unk0; + if (gUnk_03003DC0.unk0 <= gUnk_03003DC0.unk1) + temp = gUnk_03003DC0.unk1; + if (temp != 0) + return; + + doCollision = &gDoCollision; + // Check to see if we should disable collision this frame + if (gPlayerState.field_0x8b != 0) { + u32 flags = gPlayerEntity.flags; + COLLISION_OFF(&gPlayerEntity); + doCollision(); + gPlayerEntity.flags = flags; // reset collision to before + } else { + doCollision(); + } +} + +void RegisterPlayerHitbox(void) { + MemClear(&gUnk_03003C70, sizeof(gUnk_03003C70)); + gUnk_02018EA0 = (LinkedList2*)&gUnk_03003C70[0].last; + gUnk_03003C70[0].last = &gUnk_03003C70[0].last; + gUnk_03003C70[0].first = &gUnk_03003C70[0].last; + gUnk_03003C70[0].node = &gPlayerEntity; +} + +// Loop declaration seems wrong +NONMATCH("asm/non_matching/arm_proxy/sub_0801766C.inc", u32 sub_0801766C(Entity* this)) { + u32 uVar1; + LinkedList2* puVar3; + LinkedList2* puVar2; + LinkedList2* pLVar2; + LinkedList2* i; + u8* pbVar4; + + if (this->spritePriority.b2 != 0) { + return 1; + } else { + for (i = &gUnk_03003C70[0]; i < &gUnk_03003C70[16]; ++i) { + if (i->node == NULL) { + i->node = this; + i->flags = 0; + this->spritePriority.b2 = 1; + pLVar2 = gUnk_02018EA0; + if (gUnk_02018EA0->flags != 0) { + do { + pLVar2 = pLVar2->first; + } while (pLVar2->flags != 0); + i->first = pLVar2; + puVar3 = pLVar2->last; + i->last = puVar3; + puVar3->first = i; + pLVar2->last = i; + } else { + i->first = gUnk_02018EA0; + puVar2 = gUnk_02018EA0->last; + i->last = puVar2; + puVar2->first = i; + gUnk_02018EA0->last = i; + gUnk_02018EA0 = i; + } + return 1; + } + } + return 0; + } +} +END_NONMATCH + +// same loop issue +NONMATCH("asm/non_matching/arm_proxy/sub_080176E4.inc", u32 sub_080176E4(Entity* this)) { + u32 uVar1; + LinkedList2* j; + LinkedList2* i; + u8* pbVar4; + + if (this->spritePriority.b2 != 0) { + return 1; + } else { + for (i = &gUnk_03003C70[0]; i < &gUnk_03003C70[16]; ++i) { + if (i->node == NULL) { + i->node = this; + i->flags = 1; + this->spritePriority.b2 = 1; + i->first = gUnk_02018EA0; + j = gUnk_02018EA0->last; + i->last = j; + j->first = i; + gUnk_02018EA0->last = i; + gUnk_02018EA0 = i; + return 1; + } + } + return 0; + } +} +END_NONMATCH + +// you guessed it +NONMATCH("asm/non_matching/arm_proxy/sub_08017744.inc", void sub_08017744(Entity* this)) { + LinkedList2* i; + for (i = &gUnk_03003C70[0]; i < &gUnk_03003C70[16]; ++i) { + if (i->node == this) { + if (this->spritePriority.b2 != 0) { + this->spritePriority.b2 = 0; + i->node = NULL; + ((LinkedList2*)i->last)->first = i->first; + ((LinkedList2*)i->first)->last = i->last; + if (i != gUnk_02018EA0) + return; + gUnk_02018EA0 = i->first; + } + } + } +} +END_NONMATCH + +// regalloc +NONMATCH("asm/non_matching/arm_proxy/sub_080177A0.inc", bool32 sub_080177A0(Entity* this, Entity* that)) { + u32 this_d; + u32 depth; + + if ((that->collisionLayer & this->collisionLayer) != 0) { + Hitbox* bb_this = this->hitbox; + Hitbox* bb_that = that->hitbox; + u32 this_w = bb_this->width; + u32 that_w = bb_that->width; + if ((((this->x.HALF.HI - that->x.HALF.HI) + bb_this->offset_x) - bb_that->offset_x) + this_w + that_w <= + (this_w + that_w) * 2) { + u32 this_h = bb_this->height; + u32 that_h = bb_that->height; + if ((((this->y.HALF.HI - that->y.HALF.HI) + bb_this->offset_y) - bb_that->offset_y) + this_h + that_h <= + (this_h + that_h) * 2) { + if ((this->field_0x3c & 0x10) != 0) + this_d = ((Hitbox3D*)bb_this)->depth; + else + this_d = 5; + if ((that->field_0x3c & 0x10) != 0) + depth = this_d + ((Hitbox3D*)bb_that)->depth; + else + depth = this_d + 5; + if ((this->height.HALF.HI - that->height.HALF.HI) + depth <= depth * 2) + return TRUE; + } + } + } + return FALSE; +} +END_NONMATCH + +bool32 sub_08017850(Entity* this) { + if (sub_08079F8C()) + return sub_080177A0(this, &gPlayerEntity); + return FALSE; +} + +s32 sub_08017874(Entity* a, Entity* b) { + s32 newDmg; + s32 v5; + s32 v6; + + asm("" ::: "r1"); + if (a->kind == 1) { + newDmg = b->damage; + switch (gSave.stats.charm) { + case 47: + newDmg /= 4; + break; + case 48: + newDmg /= 2; + break; + } + if (newDmg <= 0) + newDmg = 1; + v5 = ModHealth(-newDmg); + sub_0800449C(a, 122); + } else { + v6 = b->damage; + if (b->kind == 8) { + switch (gSave.stats.charm) { + case 48: + v6 = 3 * v6 / 2; + break; + case 49: + v6 *= 2; + break; + } + } + v5 = a->currentHealth - v6; + if (a->kind == 3) { + if ((a->field_0x6c.HALF.HI & 1) != 0) + sub_0800449C(a, 295); + else + sub_0800449C(a, 254); + } + } + if (v5 <= 0) { + COLLISION_OFF(a); + return 0; + } + return v5; +} + +void sub_08017940(Entity* org, Entity* tgt) { + Entity* e; + u32 r1; + + e = CreateFx(tgt, FX_REFECT3, 0); + if (e != NULL) { + e->spritePriority.b0 = 2; + e->x.HALF.HI = (org->x.HALF.HI + org->hitbox->offset_x + tgt->x.HALF.HI + tgt->hitbox->offset_x) >> 1; + e->y.HALF.HI = (org->y.HALF.HI + org->hitbox->offset_y + tgt->y.HALF.HI + tgt->hitbox->offset_y) >> 1; + e->height.HALF.HI = (org->height.HALF.HI + tgt->height.HALF.HI) >> 1; + e->collisionLayer = org->collisionLayer; + UpdateSpriteForCollisionLayer(e); + } + + r1 = 0; + + r1 = (u32)(org == &gPlayerEntity ? gPlayerEntity.knockbackDuration + : (tgt == &gPlayerEntity ? tgt->knockbackDuration : 0)) >> + 3; + + // Anything requiring the evaluation of r1 could be written here. + // The compiler is not smart enough to know that r1 has no side effects, + // so the above code will still generate. + r1 = !r1 ? !!r1 : !!!r1; +} + +void sub_080179EC(Entity* a1, Entity* a2) { + u8* p = gUnk_080B3740; + u32 rand = Random(); + Entity* e = CreateFx(a2, p[rand & 3], 0); + if (e != NULL) { + PositionRelative(a2, e, a2->hitbox->offset_x << 16, a2->hitbox->offset_y << 16); + e->spritePriority.b0 = 2; + e->spriteOffsetX = (a1->x.HALF.HI + a1->hitbox->offset_x - (a2->x.HALF.HI + a2->hitbox->offset_x)) >> 1; + e->spriteOffsetY = (a1->y.HALF.HI + a1->hitbox->offset_y - (a2->y.HALF.HI + a2->hitbox->offset_y)) >> 1; + e->attachedEntity = a2; + } +} + +Entity* sub_08017A90(Entity* a1, Entity* parent) { + Entity* e; + + e = (Entity*)CreateObject(153, 0, 0); + if (e != NULL) { + e->animationState = (a1->direction >> 3) & 3; + e->spriteOffsetX = a1->x.HALF.HI - parent->x.HALF.HI; + e->spriteOffsetY = a1->y.HALF.HI - parent->y.HALF.HI; + e->parent = parent; + return e; + } + return NULL; +} + +u32 CollisionNoOp(Entity* org, Entity* tgt, u32 direction) { + return 0; +} + +// origin: player or sword +// target: item +s32 CollisionGroundItem(Entity* org, Entity* tgt, u32 direction) { + COLLISION_OFF(tgt); + tgt->bitfield = org->hurtType | 0x80; + if ((tgt->type == 0x5F || tgt->type == 0x60) && sub_08081420(tgt)) + tgt->currentHealth = 0; + return 2; +} + +s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction) { + if ((gPlayerState.field_0x1d[1] & 0x60) != 0) { + COLLISION_OFF(tgt); + } else { + org->knockbackDuration = 0x10; + org->iframes = -20; + org->field_0x46 = 640; + } + return 1; +} + +s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction) { + if ((tgt->field_0x3a & 4) != 0) { + if (tgt->field_0x1d) { + s32 x = tgt->field_0x1d = tgt->field_0x1d - gPlayerState.field_0x1d[0]; + if (x << 24 <= 0) { + tgt->field_0x1d = 0; + tgt->subAction = 2; + tgt->field_0x46 = 0; + } + } + } else { + tgt->subAction = 0; + tgt->field_0x3a |= 4u; + } + if (tgt->iframes == 0) + tgt->iframes = -1; + return 1; +} + +s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction) { + if ((gPlayerState.flags & (0x1 | 0x80 | 0x400 | 0x1000)) == 0) { + Entity* e = CreateObject(66, 1, 0); + if (e != NULL) { + e->attachedEntity = org; + gPlayerState.flags |= 0x400; + org->animationState = (direction ^ 0x10) >> 2; + } + } + tgt->damage = 4; + org->currentHealth = sub_08017874(org, tgt); + org->knockbackDuration = 12; + org->iframes = 30; + org->field_0x46 = 384; + if (tgt->iframes == 0) + tgt->iframes = -1; + return 1; +} + +s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction) { + if ((gPlayerState.flags & (0x1 | 0x80 | 0x800 | 0x1000)) == 0 && gPlayerState.playerAction == 0) { + if (org->action == 1 || org->action == 24) { + tgt->damage = 4; + org->currentHealth = sub_08017874(org, tgt); + gPlayerState.flags = 0x800; + gPlayerState.playerAction = 13; + } + } + org->knockbackDuration = 12; + org->iframes = 16; + org->field_0x46 = 640; + if (tgt->iframes == 0) + tgt->iframes = -1; + return 1; +} + +NONMATCH("asm/non_matching/collision/sub_08017CBC.inc", s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction)) { + if (((-(((direction ^ 0x10) - 0xc) & 0x1f) + tgt->direction) & 0x1f) < 0x19) { + org->iframes = -12; + tgt->iframes = -12; + sub_08017940(org, tgt); + } else { + tgt->knockbackDuration = 12; + tgt->iframes = 16; + tgt->field_0x43 = -16; + tgt->field_0x46 = 768; + if (org->iframes == 0) + org->iframes = -1; + } + return 1; +} +END_NONMATCH + +s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction) { + gPlayerState.field_0x1a[0] = 1; + org->field_0x7a.HWORD = 600; + org->knockbackDuration = 12; + org->iframes = 16; + org->field_0x46 = 640; + if (tgt->iframes == 0) + tgt->iframes = -1; + return 1; +} + +s32 sub_08017D6C(Entity* org, Entity* tgt, u32 direction) { + u32 x; + u32 y; + ColSettings* p; + + if (((-(((direction ^ 0x10) - 5) & 0x1f) + (tgt->animationState << 3)) & 0x1f) >= 0xb) { + x = org->hurtType; + y = 0xac2; + } else { + tgt->bitfield = 0xcb; + tgt->field_0x78.HALF.HI = org->hurtType; + x = org->hurtType; + y = 0xae4; + } + p = &gCollisionMtx[x + y]; + return sub_08018308(org, tgt, direction, p); +} + +int sub_08017DD4(Entity* org, Entity* tgt, u32 direction) { + org->bitfield = 0; + if (tgt->damage & 0x80) + tgt->damage &= ~0x80; + else + tgt->damage = 4; + gPlayerEntity.currentHealth = sub_08017874(&gPlayerEntity, tgt); + tgt->iframes = -12; + if ((gPlayerState.flags & 0x80) == 0) { + sub_08079D84(); + org->iframes = 90; + } else { + gPlayerEntity.bitfield = tgt->hurtType | 0x80; + gPlayerEntity.iframes = 12; + gPlayerEntity.knockbackDuration = 16; + gPlayerEntity.knockbackDirection = DirectionTurnAround(direction); + gPlayerEntity.field_0x46 = 640; + } + if (tgt->iframes == 0) + tgt->iframes = -1; + return 1; +} + +s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction) { + org->knockbackDuration = 2; + org->field_0x46 = 640; + if (tgt->iframes == 0) + tgt->iframes = -1; + return 1; +} + +s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction) { + if (tgt->damage == 0) + return 0; + if (org == &gPlayerEntity) { + u32 temp = tgt->damage; + tgt->damage = 8; + gPlayerEntity.currentHealth = sub_08017874(&gPlayerEntity, tgt); + tgt->damage = temp; + gPlayerEntity.knockbackDuration = 12; + gPlayerEntity.iframes = 16; + gPlayerEntity.field_0x46 = 384; + } else if (org->kind == 8 && org->id == 5) { + org->knockbackDuration = 8; + org->iframes = -6; + org->field_0x46 = 384; + gPlayerEntity.iframes = 0x80; + } + if (tgt->iframes == 0) + tgt->iframes = -1; + return 1; +} + +s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction) { + return 1; +} + +s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction) { + if (tgt->field_0x43 == 0) { + if (org == &gPlayerEntity) { + if (sub_08079F8C() && (gPlayerState.flags & 0x80) == 0 && !gPlayerState.swimState) { + gPlayerState.field_0x1a[0] |= 0x80u; + gPlayerState.field_0xa |= 0x80u; + gPlayerState.flags |= 0x10u; + gPlayerState.jumpStatus = 0; + if (tgt->kind == ENEMY && (tgt->id == GHINI || tgt->id == ENEMY_50)) { + org->height.HALF.HI = 0; + PositionRelative(org, tgt, 0, 0x10000); + } else { + PositionRelative(tgt, org, 0, 0x10000); + } + COLLISION_OFF(org); + org->spriteRendering.b3 = tgt->spriteRendering.b3; + org->spriteOrientation.flipY = tgt->spriteOrientation.flipY; + org->iframes = -1; + tgt->iframes = -8; + ResetPlayer(); + return 1; + } + } else { + org->currentHealth = 0; + } + } else if (tgt->kind == 3 && org == &gPlayerEntity) { + sub_08004484(tgt, org); + } + return 0; +} + +// inverted branch +NONMATCH("asm/non_matching/collision/sub_0801802C.inc", s32 sub_0801802C(Entity* org, Entity* tgt, u32 direction)) { + int kind; + ColSettings* p; + u32 x; + + kind = org->kind; + if (kind == 1) { + if (sub_08079F8C() && (((direction ^ 0x10) - 4 * tgt->animationState + 5) & 0x1Fu) <= 0xA) + goto _0801807A; + } else if (kind == 8) { + if ((((org->direction ^ 0x10) - 4 * tgt->animationState + 5) & 0x1Fu) <= 0xA) { + org->currentHealth = 0; + _0801807A: + sub_080180BC(org, tgt); + return 1; + } + } else { + org->currentHealth = 0; + return 0; + } + x = 0x11aa; + return sub_08018308(org, tgt, direction, &gCollisionMtx[x + org->hurtType]); +} +END_NONMATCH + +void sub_080180BC(Entity* org, Entity* tgt) { + if (org->iframes == 0) + org->iframes = -30; + if (tgt->iframes == 0) + tgt->iframes = -1; + tgt->subAction = -1; +} + +s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction) { + u32 v3; + u32 x; + + v3 = DirectionNormalize(DirectionTurnAround(direction) - 0xc); + if (DirectionNormalize(tgt->direction - v3) <= 0x18) { + org->knockbackDuration = 12; + org->iframes = -16; + org->field_0x46 = 640; + tgt->knockbackDuration = 12; + tgt->iframes = -16; + tgt->field_0x46 = 768; + sub_08017940(org, tgt); + return 1; + } + x = 0x352; + return sub_08018308(org, tgt, v3, &gCollisionMtx[org->hurtType + x]); +} + +s32 sub_08018168(Entity* org, Entity* tgt, u32 direction) { + if (tgt->field_0x43 == 0) { + if (org == &gPlayerEntity) { + if (((sub_08079F8C() != 0) && ((gPlayerState.flags & 0x40080) == 0)) && (gPlayerState.swimState == 0)) { + gPlayerState.field_0x1a[0] |= 0x80; + gPlayerState.field_0xa |= 0x80; + gPlayerState.flags |= 0x100; + gPlayerState.jumpStatus = 0; + gPlayerEntity.flags &= ~0x80; + gPlayerEntity.spriteRendering.b3 = tgt->spriteRendering.b3; + gPlayerEntity.spriteOrientation.flipY = tgt->spriteOrientation.flipY; + gPlayerEntity.iframes = 0xff; + tgt->iframes = -8; + sub_08077B20(); + return 1; + } + } else { + org->currentHealth = 0; + } + } else if ((tgt->kind == 3) && (org == &gPlayerEntity)) { + sub_08004484(tgt, &gPlayerEntity); + } + return 0; +} + +s32 sub_08018228(Entity* org, Entity* tgt, u32 direction) { + if (org == &gPlayerEntity && sub_08079F8C()) + sub_08004484(tgt, org); + return 0; +} + +s32 sub_08018250(Entity* org, Entity* tgt, u32 direction) { + org->iframes = -1; + if (org->direction == 0) { + tgt->iframes = 16; + sub_08017A90(org, tgt); + } else { + tgt->iframes = -1; + } + return 1; +} + +s32 sub_08018288(Entity* org, Entity* tgt, u32 direction) { + if (org == &gPlayerEntity) + sub_0807AFE8(); + else + org->currentHealth = 0; + return 1; +} + +s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction) { + if (tgt->field_0x43 == 0) { + if (org->iframes == 0) + org->iframes = -1; + if (tgt->iframes == 0) + tgt->iframes = -1; + } else { + u32 x = 0x92a; + return sub_08018308(org, tgt, direction, &gCollisionMtx[org->hurtType + x]); + } + return 1; +} + +s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { + u32 temp = 0; + if (tgt->field_0x43 && tgt->kind == 3 && org == &gPlayerEntity) { + sub_08004484(tgt, org); + temp = 1; + } + if ((org->kind == 8 && org->id == 0x5) && gPlayerEntity.animationState == ((((direction + 4) & 0x18) >> 2) ^ 4)) { + return 0; + } + if (!temp) { + u32 tmp2; + org->field_0x46 = 16 * settings->_0; + org->iframes = settings->_1; + if (org->iframes == 0) + org->iframes = -1; + org->knockbackDuration = settings->_2; + tgt->damage = settings->_3; + tmp2 = 0xFF; + if (settings->_3 != 0) + org->currentHealth = sub_08017874(org, tgt); + if (settings->_4 > org->field_0x43) + org->field_0x43 = settings->_4; + tgt->field_0x46 = 16 * settings->_5; + tgt->iframes = settings->_6; + if (settings->_6 == 0) + tgt->iframes = -1; + tgt->knockbackDuration = settings->_7; + tmp2 &= org->damage = settings->_8; + if (tmp2 != 0) + tgt->currentHealth = sub_08017874(tgt, org); + if (settings->_9 > tgt->field_0x43) + tgt->field_0x43 = settings->_9; + } + if (settings->_a & 1) + sub_08017940(org, tgt); + if (settings->_a & 2) + org->bitfield = 0xca; + if (settings->_a & 4) { + Entity* parent = tgt->parent; + if (parent != NULL) { + parent->bitfield = 0xcc; + parent->iframes = tgt->iframes; + parent->knockbackDirection = direction; + parent->knockbackDuration = tgt->knockbackDuration; + if (parent->field_0x43 == 0) + parent->field_0x43 = tgt->field_0x43; + parent->field_0x46 = tgt->field_0x46; + parent->field_0x4c = org; + } + } + if (org->kind == 8) { + if (org->id == 1) { + if (settings->_8) { + sub_080179EC(org, tgt); + } + } else if (org->id == 4) { + if (org->damage || (settings->_a & 8)) { + sub_08017A90(org, tgt); + } + } else if (org->id == 3) { + if (settings->_9) { + sub_0800449C(tgt, 254); + } + } else if (org->id == 5) { + gPlayerEntity.iframes = 0x80; + } + } + if (tgt->kind == 8 && org->id == 5) { + gPlayerEntity.iframes = 0x80; + } + return 1; +} diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 4644e620..dc8fdf95 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -160,7 +160,7 @@ void sub_08031B48(Entity* this) { GetNextFrame(this); if (this->frames.b.f0) { this->frames.all = 0; - this->flags |= 0x80; + COLLISION_ON(this); } else { if (this->frames.b.f3) { this->action = 0x3; @@ -188,7 +188,7 @@ void sub_08031B98(Entity* this) { GetNextFrame(this); if (this->actionDelay == 0) { this->action = 4; - this->flags &= 0x7f; + COLLISION_OFF(this); InitializeAnimation(this, 2); } } @@ -255,7 +255,7 @@ void sub_08031C58(Entity* this) { } else { if (this->frames.b.f0) { this->frames.all = 0; - this->flags &= 0x7f; + COLLISION_OFF(this); } } } @@ -264,7 +264,7 @@ void sub_08031D70(Entity* this) { GetNextFrame(this); if (--this->actionDelay == '\0') { this->action = 7; - this->flags &= 0x7f; + COLLISION_OFF(this); this->actionDelay = 5; this->spriteSettings.b.draw = 0; } @@ -289,7 +289,7 @@ void sub_08031DC4(Entity* this) { } else { GetNextFrame(this); if ((this->frames.all & 0xf) == 2) { - this->flags &= 0x7f; + COLLISION_OFF(this); } } } @@ -349,7 +349,7 @@ void sub_08031EE8(Entity* this) { if (this->hVelocity < 1) { this->action = 2; - this->flags |= 0x80; + COLLISION_ON(this); InitializeAnimation(this, 5); } } @@ -494,7 +494,7 @@ void sub_08032248(Entity* this) { GetNextFrame(this); if ((this->frames.all & 0xf) == 2) - this->flags &= 0x7f; + COLLISION_OFF(this); } } } diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index 15535172..4b1d8429 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -34,7 +34,7 @@ void sub_08021780(Entity* this) { this->action = 5; this->actionDelay = 0xb4; this->field_0xf = 0; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spritePriority.b0 = 3; CopyPositionAndSpriteOffset(&gPlayerEntity, this); this->height.HALF.HI = -1; @@ -119,7 +119,7 @@ void sub_080218CC(Entity* this) { this->action = 2; this->actionDelay = (Random() & 0x38) + 8; this->field_0xf = 1; - this->flags |= 0x80; + COLLISION_ON(this); this->speed = 0x180; InitializeAnimation(this, 0); } @@ -128,7 +128,7 @@ void sub_080218CC(Entity* this) { void sub_08021984(Entity* this) { if (this->subAction == 0) { this->subAction = 1; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = 3; this->height.HALF.HI = -0x80; this->spriteRendering.b3 = 1; @@ -270,7 +270,7 @@ void sub_08021C58(Entity* this) { this->action = 2; this->actionDelay = 60; this->field_0xf = 1; - this->flags |= 0x80; + COLLISION_ON(this); this->spritePriority.b0 = 4; ((u8*)&this->field_0x86)[0] = 60; InitializeAnimation(this, 0); diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index 67bb138b..579a5c4c 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -52,7 +52,7 @@ void sub_0802C688(Entity* this) { break; case 2: this->action = 3; - this->damageType = 0x6e; + this->hitType = 0x6e; this->field_0xf = 1; this->hVelocity = 0x18000; this->speed = 0; @@ -112,15 +112,15 @@ void sub_0802C83C(Entity* this) { sub_0802CBC4(this); } else { sub_0802CC18(this); - this->flags &= ~0x80; - this->damageType = 0x6e; + COLLISION_OFF(this); + this->hitType = 0x6e; } } else { this->field_0x82.HALF.LO = 2; this->actionDelay = 120; InitializeAnimation(this, (this->direction >> 4) | 6); - this->flags &= ~0x80; - this->damageType = 0x6e; + COLLISION_OFF(this); + this->hitType = 0x6e; } } @@ -187,7 +187,7 @@ void sub_0802C9B8(Entity* this) { void sub_0802C9D0(Entity* this) { this->subAction = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spritePriority.b1 = 0; this->field_0x82.HALF.HI = 1; sub_0802CC18(this); @@ -222,7 +222,7 @@ void sub_0802CA6C(Entity* this) { void sub_0802CA94(Entity* this) { this->action = 3; - this->flags &= ~0x80; + COLLISION_OFF(this); this->field_0xf = 1; this->spritePriority.b1 = 1; this->hVelocity = 0x18000; @@ -244,8 +244,8 @@ void sub_0802CAF8(Entity* this) { sub_08078930(this); if (this->field_0xf && this->height.HALF.HI == 0) { this->field_0xf = 0; - this->flags = this->flags | 0x80; - this->damageType = 0x6e; + COLLISION_ON(this); + this->hitType = 0x6e; } GetNextFrame(this); } @@ -260,7 +260,7 @@ void sub_0802CB68(Entity* this) { this->subAction = 0; this->direction = Random() & 0x18; this->direction |= 4; - this->flags |= 0x80; + COLLISION_ON(this); if (this->field_0x82.HALF.LO) { this->actionDelay = 200; this->speed = 0x200; @@ -277,7 +277,7 @@ void sub_0802CBC4(Entity* this) { this->action = 4; this->spriteSettings.b.draw = 0; - this->flags &= ~0x80; + COLLISION_OFF(this); this->currentHealth = 0; if (this->field_0x82.HALF.HI) { sub_08079184(); diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index d5220c6d..9b2b5547 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -507,9 +507,9 @@ void sub_0802B048(Entity* this) { if (this->field_0x7a.HALF.HI) { if (gRoomControls.roomOriginY > this->y.HALF.HI || (gRoomControls.roomOriginY + gRoomControls.height + 0x20) < this->y.HALF.HI) { - this->flags &= ~0x80; + COLLISION_OFF(this); } else { - this->flags |= 0x80; + COLLISION_ON(this); } } @@ -540,7 +540,7 @@ void sub_0802B048(Entity* this) { this->hitbox = (Hitbox*)&gUnk_080CD17C; this->actionDelay = 0xf; this->spriteSettings.b.draw = 0; - this->flags |= 0x80; + COLLISION_ON(this); this->field_0x7a.HALF.HI = 0; sub_08078954(this); if (this->parent->next) { diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 989c6bea..275b1775 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -55,11 +55,11 @@ void sub_0802891C(Entity* this) { void sub_08028934(Entity* this) { Entity* pEVar1; - if (this->damageType == 1 && (this->bitfield & 0x7f) == 0x42) { + if (this->hitType == 1 && (this->bitfield & 0x7f) == 0x42) { this->action = 3; this->subAction = 0; this->actionDelay = 0x28; - this->flags &= ~0x80; + COLLISION_OFF(this); sub_080290E0(this, 4); pEVar1 = CreateFx(this, FX_BUSH, 0); if (pEVar1 != NULL) { @@ -90,7 +90,7 @@ void sub_08028994(Entity* this) { this->actionDelay = 0; this->field_0x76.HWORD = COORD_TO_TILE(this); this->field_0x74.HWORD = sub_080001DA(this->field_0x76.HWORD, this->collisionLayer); - this->field_0x40 = 0x41; + this->hurtType = 0x41; sub_08028FFC(this); } } @@ -417,7 +417,7 @@ bool32 sub_08028FDC(Entity* this) { void sub_08028FFC(Entity* this) { this->action = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spritePriority.b1 = 0; sub_080AE068(this); UnloadOBJPalette(this); @@ -433,7 +433,7 @@ void sub_08028FFC(Entity* this) { void sub_08029078(Entity* this) { this->action = 2; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->spritePriority.b1 = 1; if (LoadFixedGFX(this, 0x72) == 0) { DeleteEntity(this); diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 56e23b75..32f1a1b1 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -52,11 +52,11 @@ void Chuchu(Entity* this) { if (index != this->field_0x80.HALF.HI) { switch (this->type) { case 0: - if (this->flags & 0x80) { + if (this->flags & ENT_COLLIDE) { this->action = 6; - this->flags &= ~0x80; + COLLISION_OFF(this); this->speed = 0x20; - this->damageType = 0x5c; + this->hitType = 0x5c; InitializeAnimation(this, 5); } break; @@ -100,7 +100,7 @@ void sub_0801EF40(Entity* this) { if (this->type == 2) { if (this->bitfield == 0x8e || this->bitfield == 0x95) { - this->flags &= ~0x80; + COLLISION_OFF(this); this->currentHealth = 0; } } @@ -180,7 +180,7 @@ void sub_0801F0C8(Entity* this) { this->actionDelay = (Random() & 3) + 0xc; this->field_0xf = Random(); this->direction = sub_08049F84(this, 1); - this->flags |= 0x80; + COLLISION_ON(this); this->spritePriority.b0 = 4; this->spritePriority.b1 = 3; InitializeAnimation(this, 2); @@ -213,7 +213,7 @@ void sub_0801F1B0(Entity* this) { if (this->frames.all & 0x10) { if (this->frames.all & 1) { this->frames.all ^= 1; - this->damageType = 90; + this->hitType = 90; EnqueueSFX(299); } sub_080AEFE0(this); @@ -287,7 +287,7 @@ void sub_0801F2F8(Entity* this) { void sub_0801F328(Entity* this) { this->action = 6; - this->flags &= ~0x80; + COLLISION_OFF(this); InitializeAnimation(this, 5); } @@ -295,7 +295,7 @@ void sub_0801F340(Entity* this) { this->action = 5; this->actionDelay = 60; this->speed = 0x20; - this->damageType = 92; + this->hitType = 92; InitializeAnimation(this, 2); } @@ -346,7 +346,7 @@ void sub_0801F428(Entity* this) { this->action = 3; this->field_0xf = 30; - this->flags |= 0x80; + COLLISION_ON(this); this->spritePriority.b1 = 3; this->spriteSettings.b.draw = 1; InitializeAnimation(this, 2); @@ -363,7 +363,7 @@ void sub_0801F494(Entity* this) { this->action = 3; this->field_0xf = 30; this->direction = sub_08049F84(this, 1); - this->flags |= 0x80; + COLLISION_ON(this); this->spritePriority.b0 = 4; this->spritePriority.b1 = 3; InitializeAnimation(this, 2); @@ -404,7 +404,7 @@ void sub_0801F584(Entity* this) { if (this->frames.all & 0x10) { if (this->frames.all & 0x1) { this->frames.all ^= 1; - this->damageType = 91; + this->hitType = 91; EnqueueSFX(299); } sub_080AEFE0(this); @@ -423,7 +423,7 @@ void sub_0801F584(Entity* this) { this->action = 6; this->field_0xf = 60; this->speed = 0x20; - this->damageType = 92; + this->hitType = 92; InitializeAnimation(this, 2); } } @@ -482,7 +482,7 @@ void sub_0801F6F8(Entity* this) { void sub_0801F730(Entity* this) { this->action = 7; - this->flags &= ~0x80; + COLLISION_OFF(this); InitializeAnimation(this, 5); } @@ -537,7 +537,7 @@ void sub_0801F840(Entity* this) { GetNextFrame(this); if (this->frames.all & 0x80) { sub_0801FB14(this); - this->flags |= 0x80; + COLLISION_ON(this); this->spritePriority.b0 = 4; this->spritePriority.b1 = 3; } @@ -552,7 +552,7 @@ void sub_0801F884(Entity* this) { if (ent) { ent->type2 = 64; this->action = 4; - this->damageType = 165; + this->hitType = 165; EnqueueSFX(0x193); } } @@ -656,7 +656,7 @@ void sub_0801FAAC(Entity* this) { void sub_0801FAE0(Entity* this) { this->action = 7; - this->flags &= ~0x80; + COLLISION_OFF(this); InitializeAnimation(this, 5); } @@ -687,13 +687,13 @@ void sub_0801FB68(Entity* this) { break; case 1: this->action = 10; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = 1; this->spritePriority.b1 = 3; break; case 2: this->action = 10; - this->damageType = 92; + this->hitType = 92; sub_0804AA1C(this); break; } diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index d28e3b15..09648a8f 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -63,7 +63,7 @@ void sub_08020BB8(Entity* this) { case 0x1c: this->action = 11; this->actionDelay = gUnk_080CAB0C[this->type]; - this->damageType = 81; + this->hitType = 81; sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10)); sub_08021588(this); sub_0804A9FC(this, 0x1c); @@ -71,7 +71,7 @@ void sub_08020BB8(Entity* this) { case 0x16: this->action = 11; this->actionDelay = gUnk_080CAB10[this->type]; - this->damageType = 81; + this->hitType = 81; sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10)); sub_08021588(this); sub_0804A9FC(this, 0x1c); @@ -263,7 +263,7 @@ void sub_08020FE4(Entity* this) { void sub_08021010(Entity* this) { UpdateAnimationSingleFrame(this); if (this->frames.all & 0x80) { - this->damageType = 0x56; + this->hitType = 0x56; sub_080213F0(this); } } @@ -288,7 +288,7 @@ void sub_08021038(Entity* this) { } else { UpdateAnimationSingleFrame(this); if (this->frames.all == 4) - this->damageType = 81; + this->hitType = 81; } } @@ -445,7 +445,7 @@ void sub_08021380(Entity* this) { void sub_08021390(Entity* this) { this->action = 7; this->speed = 0x200; - this->damageType = 0x56; + this->hitType = 0x56; sub_08021218(this, 6, this->animationState); } @@ -568,7 +568,7 @@ void sub_0802159C(Entity* this) { Entity* ent; this->frames.all = 0; - this->damageType = 0x51; + this->hitType = 0x51; ent = CreateProjectileWithParent(this, 0, 3); if (ent) { ent->parent = this; @@ -589,7 +589,7 @@ void sub_08021600(Entity* this) { Entity* ent; this->frames.all = 0; - this->damageType = 0x51; + this->hitType = 0x51; ent = CreateProjectileWithParent(this, 0, 4); if (ent) { ent->parent = this; diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index c3fd44ee..301efced 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -77,7 +77,7 @@ void sub_080220F0(Entity* this) { this->action = 4; this->actionDelay = 0x78; - this->field_0x44 = 0; + this->damage = 0; off = gUnk_080CB76C[this->type2]; for (i = 0; i < 6; i++, off++) { Entity* fx = CreateFx(this, FX_DASH, 0); @@ -88,7 +88,7 @@ void sub_080220F0(Entity* this) { } EnqueueSFX(260); } else if (this->frames.all & 1) { - this->field_0x44 = 4; + this->damage = 4; } } diff --git a/src/enemy/enemy4D.c b/src/enemy/enemy4D.c index 0049a853..f1b16cc7 100644 --- a/src/enemy/enemy4D.c +++ b/src/enemy/enemy4D.c @@ -40,7 +40,7 @@ void sub_0803EB44(Entity* this) { if (pEVar1 != NULL) { pEVar1->parent = this; this->attachedEntity = pEVar1; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = TRUE; this->animationState = 2; *((u8*)&this->field_0x7a + 1) = 0; diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index 29446667..039c817f 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -76,7 +76,7 @@ NONMATCH("asm/non_matching/fallingBoulder/sub_0802C334.inc", void sub_0802C334(E this->field_0x7c.HALF.HI = COORD_TO_TILE(this); if (sub_080044EC(this, *(u32*)&this->cutsceneBeh) == 1) { EnqueueSFX(0x14c); - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->field_0x7a.HWORD = 0xc; sub_0802C4B0(this); } else { @@ -86,7 +86,7 @@ NONMATCH("asm/non_matching/fallingBoulder/sub_0802C334.inc", void sub_0802C334(E u16 tmp = --this->field_0x7a.HWORD; switch (tmp) { case 0: - this->flags &= ~0x80; + COLLISION_OFF(this); break; case 8: if (this->type2 != 0 && !sub_08049FA0(this)) { @@ -211,7 +211,7 @@ void sub_0802C62C(Entity* this) { this->y.HALF.HI = this->field_0x82.HWORD; this->x.HALF.HI = this->field_0x80.HWORD; this->spriteSettings.b.draw = 0; - this->flags &= ~0x80; + COLLISION_OFF(this); this->field_0x7c.HALF.LO = 0; } diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index d1773a7d..6fc3a27f 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -47,18 +47,18 @@ NONMATCH("asm/non_matching/gibdo/sub_080374A4.inc", void sub_080374A4(Entity* th } this->action = 0x8; this->actionDelay = 0x3c; - this->flags &= 0x7F; + COLLISION_OFF(this); sub_08037B48(this); } else { if (this->action != 0x6) { - if (this->damageType == 0x27) { + if (this->hitType == 0x27) { if (this->bitfield == 0x80) { sub_08037A14(this); } } else { if ((u8)(this->action - 1) < 2) { this->action = 1; - x = DirectionTurnAround(this->knockbackDirection); + x = DirectionTurnAround(DirectionRoundUp(this->knockbackDirection)); this->direction = x; this->animationState = x >> 3; InitAnimationForceUpdate(this, this->animationState); @@ -153,7 +153,7 @@ void sub_08037690(Entity* this) { sub_08037794(this); } else { if ((this->frames.all & 1) != 0) { - this->damageType = 0x27; + this->hitType = 0x27; ProcessMovement(this); } } @@ -202,7 +202,7 @@ void sub_0803775C(Entity* this) { void sub_08037794(Entity* this) { this->action = 1; this->field_0x74.HWORD = 0x1e; - this->damageType = 0x26; + this->hitType = 0x26; InitAnimationForceUpdate(this, this->animationState); } @@ -339,7 +339,7 @@ void sub_08037A58(Entity* this) { if (this->iframes == 0) { this->iframes = 0xec; } - this->damageType = 0x26; + this->hitType = 0x26; this->flags2 |= 1; this->iframes = 0xf4; this->knockbackDirection = DirectionFromAnimationState(this->animationState) ^ 0x10; diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index 7aaa2153..6c0fb567 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -1113,7 +1113,7 @@ void sub_08048004(Entity* this) { if (this->action == 0) return; if (this->animIndex == 0) { - this->flags &= ~0x80; + COLLISION_OFF(this); if (gPlayerEntity.height.HALF.HI != 0) return; if (!sub_08079F8C()) @@ -1151,7 +1151,7 @@ void sub_08048004(Entity* this) { this->field_0x7c.BYTES.byte0 = 0; } } else { - this->flags |= 0x80; + COLLISION_ON(this); } } diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 41f0ed85..870831bc 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -42,7 +42,7 @@ void sub_0802BBAC(Entity* this) { } void sub_0802BBC4(Entity* this) { - if (this->damageType != 0x19) { + if (this->hitType != 0x19) { switch (this->bitfield & 0x7f) { case 0: case 2: @@ -62,7 +62,7 @@ void sub_0802BBC4(Entity* this) { } void sub_0802BC20(Entity* this) { - if (this->damageType != 0x19) { + if (this->hitType != 0x19) { if (sub_0806F520(this)) { gUnk_080CD42C[this->subAction](this); } @@ -84,13 +84,13 @@ void sub_0802BCA0(Entity* this) { } void sub_0802BCA8(Entity* this) { - if (this->damageType != 0x19) { + if (this->hitType != 0x19) { Entity* ent; this->action = 7; this->actionDelay = 0x5a; this->hVelocity = 0x18000; - this->damageType = 0x19; + this->hitType = 0x19; this->field_0x3a = this->field_0x3a & 0xfb; this->field_0x1c = 0x12; ent = CreateEnemy(HELMASAUR, 1); @@ -112,7 +112,7 @@ void sub_0802BD08(Entity* this) { } void sub_0802BD10(Entity* this) { - this->flags &= ~0x80; + COLLISION_OFF(this); UpdateAnimationVariableFrames(this, 2); } @@ -121,8 +121,8 @@ void nullsub_145(Entity* this) { } void sub_0802BD28(Entity* this) { - if (this->flags & 0x80) { - this->flags |= 0x80; + if (this->flags & ENT_COLLIDE) { + COLLISION_ON(this); this->field_0x3a &= ~0x4; } else { this->currentHealth = 0; @@ -265,7 +265,7 @@ void sub_0802BF98(Entity* this) { } else { this->action = 2; this->actionDelay = 30; - this->flags &= ~0x80; + COLLISION_OFF(this); } } diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index 1b4f20c0..d1a41424 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -40,7 +40,7 @@ void sub_080323F4(Entity* this) { if (this->action != 3 && this->action != 4) { this->action = 3; this->actionDelay = 0xC; - this->direction = DirectionTurnAround(this->knockbackDirection); + this->direction = DirectionTurnAround(DirectionRoundUp(this->knockbackDirection)); InitAnimationForceUpdate(this, this->direction >> 3); } else if (this->bitfield == 0xCC) { if (this->field_0x43 == 0) { diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 1353d489..91798d2e 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -61,7 +61,7 @@ void sub_0803C784(Entity* this) { sub_0803CBAC(this); } else { - if (this->damageType == 0x43) { + if (this->hitType == 0x43) { Entity* fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { @@ -154,7 +154,7 @@ void Lakitu_EndHide(Entity* this) { this->action = IDLE; this->actionDelay = 0x3c; - this->damageType = 0x42; + this->hitType = 0x42; InitAnimationForceUpdate(this, this->animationState + 4); } @@ -168,7 +168,7 @@ void Lakitu_Idle(Entity* this) { if (!sub_0803CA4C(this)) { this->action = BEGIN_HIDE; - this->damageType = 0x43; + this->hitType = 0x43; InitAnimationForceUpdate(this, this->animationState + 0xc); } else { sub_0803CA84(this, 4); @@ -196,7 +196,7 @@ void Lakitu_Lightning(Entity* this) { Lakitu_SpawnLightning(this); this->action = LIGHTNING_DELAY; - this->damageType = 0x42; + this->hitType = 0x42; if ((Random() & 1) && !this->field_0x78.HALF.HI) { this->actionDelay = 0xf; @@ -293,7 +293,7 @@ bool32 sub_0803CB04(Entity* this) { void sub_0803CB34(Entity* this) { this->action = LIGHTNING_THROW; - this->damageType = 0xa6; + this->hitType = 0xa6; this->field_0x78.HALF.LO = GetFacingDirection(this, &gPlayerEntity); @@ -325,7 +325,7 @@ void sub_0803CBAC(Entity* this) { cloud = this->attachedEntity; if (cloud != NULL) { cloud->flags |= 0x80; - cloud->damageType = 0x43; + cloud->hitType = 0x43; } this->action = CLOUDLESS; @@ -335,7 +335,7 @@ void sub_0803CBAC(Entity* this) { this->flags2 &= 0x7b; - this->damageType = 0x42; + this->hitType = 0x42; InitAnimationForceUpdate(this, this->animationState + 16); } diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index b7301df7..4ace44e2 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -105,7 +105,7 @@ void sub_0803CDD8(Entity* this) { if (this->actionDelay == 0) { this->action = 1; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = one; } @@ -132,7 +132,7 @@ void sub_0803CE3C(Entity* this) { this->action = 2; this->actionDelay = 60; - this->flags &= 0x7f; + COLLISION_OFF(this); this->field_0x3a &= 0xfb; diff --git a/src/enemy/leever.c b/src/enemy/leever.c index d92e1d26..4bdb53c8 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -92,7 +92,7 @@ void Leever_DigUp(Entity* this) { InitializeAnimation(this, LeeverAnimation_Attack); } else if (this->frames.b.f0 != 0) { this->frames.all &= 0xfe; - this->flags |= 0x80; + COLLISION_ON(this); } } @@ -102,7 +102,7 @@ void Leever_Attack(Entity* this) { if (--this->field_0x74.HWORD == 0) { this->action = 4; - this->flags &= 0x7f; + COLLISION_OFF(this); InitializeAnimation(this, LeeverAnimation_DigDown); } } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 70f5ea3f..54d0852f 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -26,10 +26,10 @@ void sub_08027D8C(Entity* this) { } void sub_08027DA4(Entity* this) { - if (this->damageType == 1) { + if (this->hitType == 1) { this->action = 3; - this->flags &= ~0x80; - this->damageType = 0x8c; + COLLISION_OFF(this); + this->hitType = 0x8c; } else { if (this->action == 7) { sub_0802810C(this); @@ -75,7 +75,7 @@ void sub_08027E70(Entity* this) { case 0: this->action = 3; this->spriteSettings.b.draw = 0; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); this->actionDelay = 0; break; case 1: @@ -88,7 +88,7 @@ void sub_08027E70(Entity* this) { this->action = 1; this->spriteSettings.b.draw = 0; this->actionDelay = 0; - this->damageType = 1; + this->hitType = 1; InitializeAnimation(this, 0); break; } @@ -101,7 +101,7 @@ void sub_08027E70(Entity* this) { } void sub_08027EFC(Entity* this) { - if (this->damageType == 1) + if (this->hitType == 1) return; if (sub_08049FDC(this, 1)) { @@ -120,7 +120,7 @@ void sub_08027EFC(Entity* this) { GetNextFrame(this); } else { this->action = 6; - this->flags &= ~0x80; + COLLISION_OFF(this); InitializeAnimation(this, 2); } } @@ -151,7 +151,7 @@ void sub_08027FE0(Entity* this) { GetNextFrame(this); if (this->frames.all & 1) { this->action = 1; - this->flags |= 0x80; + COLLISION_ON(this); this->direction = sub_08049F84(this, 1); this->actionDelay = 8; this->spritePriority.b1 = 1; diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index 513848d9..314b28fc 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -55,7 +55,7 @@ void sub_080298A4(Entity* this) { default: this->action = 2; this->actionDelay = 0; - this->damageType = 0x6b; + this->hitType = 0x6b; this->field_0x76.HALF.HI = 0; sub_0801D2B4(this, 0x7f); EnqueueSFX(0xfe); @@ -115,7 +115,7 @@ void sub_0802999C(Entity* this) { ent5->attachedEntity = ent6; this->action = 1; - this->flags |= 0x80; + COLLISION_ON(this); this->direction = DirectionRound(Random()); this->speed = 0xa0; this->animationState = 0xff; @@ -138,7 +138,7 @@ void sub_08029AA4(Entity* this) { if (this->field_0x76.HALF.HI != 0) { this->action = 3; this->speed = 0x108; - this->damageType = 0x6a; + this->hitType = 0x6a; this->field_0x7a.HWORD = 0x168; this->field_0x74.HALF.HI = 4; sub_08029EEC(this); @@ -168,7 +168,7 @@ void sub_08029B2C(Entity* this) { DeleteEntity(this); } } else { - this->flags &= ~0x80; + COLLISION_OFF(this); this->actionDelay = -(this->type * 15 - 90); this->field_0x86.HALF.LO = 1; } @@ -210,7 +210,7 @@ void sub_08029BC4(Entity* this) { void sub_08029C08(Entity* this) { this->action = 3; this->actionDelay = gUnk_080CCDA0[this->type]; - this->damageType = 0x6b; + this->hitType = 0x6b; this->attachedEntity->action = 2; } @@ -225,7 +225,7 @@ void sub_08029C2C(Entity* this) { void sub_08029C50(Entity* this) { if (this->parent->field_0x76.HALF.HI != 0) { this->action = 5; - this->damageType = 0x6a; + this->hitType = 0x6a; } } @@ -279,7 +279,7 @@ void sub_08029D14(Entity* this) { if (this->frames.all & 0x80) { this->action = 4; this->actionDelay = 0x78; - this->damageType = 0x6c; + this->hitType = 0x6c; this->hitbox = &gUnk_080FD298; EnqueueSFX(0x6b); } @@ -290,7 +290,7 @@ void sub_08029D78(Entity* this) { sub_0802A0F8(this); if (--this->actionDelay == 0) { this->action = 5; - this->damageType = 0x6a; + this->hitType = 0x6a; this->hitbox = (Hitbox*)&gUnk_080FD2A0; InitializeAnimation(this, this->animationState + 0x10); } diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index 96ded54d..0437d6f2 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -143,7 +143,7 @@ NONMATCH("asm/non_matching/mazaal/sub_0803A188.inc", void sub_0803A188(Entity* t if (this->action != 0x2b) { if ((0 < this->iframes) && ((this->bitfield == 0x95 || (this->bitfield == 0x8e)))) { this->action = 0x28; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); pEVar3 = this->parent; pEVar3->field_0x7c.BYTES.byte1 = pEVar3->field_0x7c.BYTES.byte1 | (this->type == 0 ? 1 : 2); pEVar3->field_0x80.HALF.LO = (this->type == 0 ? 1 : 2) | pEVar3->field_0x80.HALF.LO; @@ -203,7 +203,7 @@ void sub_0803A274(Entity* this) { } if (gScreenTransition.field_0x38 != 0) { this->action = 3; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = 1; this->attachedEntity->spriteSettings.b.draw = 1; InitializeAnimation(this, 0x10); @@ -312,7 +312,7 @@ void sub_0803A364(Entity* this) { default: this->actionDelay--; if (this->actionDelay == 0) { - this->flags = this->flags | 0x80; + COLLISION_ON(this); sub_0803B4D4(this); } break; @@ -352,7 +352,7 @@ void sub_0803A5D0(Entity* this) { s8* ptr; this->action = 5; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); ptr = gUnk_080CED6C; index = ((this->parent->field_0xf >> 4) + 3); this->height.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; @@ -500,7 +500,7 @@ void sub_0803A86C(Entity* this) { this->height.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; GetNextFrame(this); if ((this->frames.all & 0x80) != 0) { - this->flags = this->flags | 0x80; + COLLISION_ON(this); sub_0803B59C(this); } } @@ -558,7 +558,7 @@ void sub_0803A978(Entity* this) { if (this->direction == 0x10) { this->action = 0x12; this->actionDelay = 3; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); *(u8*)(*(int*)&this->field_0x74 + 0x10) &= 0x7f; InitializeAnimation(this, 8); InitAnimationForceUpdate(this->attachedEntity, 3); @@ -605,7 +605,7 @@ NONMATCH("asm/non_matching/mazaal/sub_0803AA98.inc", void sub_0803AA98(Entity* t InitializeAnimation(this, 10); (*(Entity**)&this->field_0x74)->flags |= 0x80; temp = this->attachedEntity; - temp->damageType = 0x13; + temp->hitType = 0x13; InitAnimationForceUpdate(temp, 5); SoundReq(SFX_16E); } @@ -654,7 +654,7 @@ void sub_0803ABB4(Entity* this) { sub_0803B55C(this); if ((this->attachedEntity->frames.all & 0x80) != 0) { this->action = 0x17; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->speed = 0x180; InitializeAnimation(this, 0x10); InitAnimationForceUpdate(this->attachedEntity, 0); @@ -807,14 +807,14 @@ void sub_0803AEC4(Entity* this) { UpdateAnimationSingleFrame(this); GetNextFrame(this); if ((this->frames.all & 0x80) != 0) { - this->flags |= 0x80; + COLLISION_ON(this); sub_0803B59C(this); } } void sub_0803AF18(Entity* this) { this->action = 0x1f; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); InitializeAnimation(this, 5); this->height.HALF.HI = gUnk_080CED6C[(this->parent->field_0xf >> 4) & 7] + 4; } @@ -907,7 +907,7 @@ void sub_0803B0D4(Entity* this) { UpdateAnimationSingleFrame(this); GetNextFrame(this); if ((this->frames.all & 0x80) != 0) { - this->flags |= 0x80; + COLLISION_ON(this); sub_0803B59C(this); } } @@ -943,8 +943,8 @@ void sub_0803B17C(Entity* this) { GetNextFrame(this); if ((this->frames.all & 0x80) != 0) { this->action = 0x2b; - this->flags |= 0x80; - this->damageType = 0x18; + COLLISION_ON(this); + this->hitType = 0x18; this->currentHealth = 0xff; this->field_0x7c.HALF.HI = 600; } @@ -962,7 +962,7 @@ void sub_0803B1B8(Entity* this) { this->action = 0x32; this->field_0x7c.HALF.HI = 0x5dc; this->spriteSettings.b.draw = 0; - this->damageType = 0x14; + this->hitType = 0x14; temp = CreateFx(this, FX_GIANT_EXPLOSION4, 0); if (temp != (Entity*)0x0) { temp->x.HALF.HI += this->hitbox->offset_x; @@ -1068,7 +1068,7 @@ void sub_0803B3F4(Entity* this) { this->height.HALF.HI = ptr[(index + (u32)this->type * 2) & 7] + 4; GetNextFrame(this); if ((this->frames.all & 0x80) != 0) { - this->damageType = 0x17; + this->hitType = 0x17; if (this->type == 0) { this->hitbox = (Hitbox*)&gUnk_080FD35C; } else { @@ -1185,7 +1185,7 @@ void sub_0803B6A4(Entity* this) { Entity* temp; this->action = 0x2c; - this->damageType = 0x14; + this->hitType = 0x14; temp = this->parent; temp->field_0x80.HALF.LO |= (this->type == 0) ? 0x10 : 0x20; temp->field_0x80.HALF.LO &= (this->type == 0) ? -5 : -9; @@ -1264,12 +1264,12 @@ u32 sub_0803B870(Entity* this) { gPlayerEntity.flags = gPlayerEntity.flags & 0x7f; gPlayerEntity.iframes = -0x10; sub_0803B824(this); - entity->damageType = 0x13; + entity->hitType = 0x13; InitAnimationForceUpdate(entity, 7); SoundReq(SFX_16E); return 1; } else { - entity->damageType = 0x15; + entity->hitType = 0x15; return 0; } } @@ -1277,9 +1277,9 @@ u32 sub_0803B870(Entity* this) { void sub_0803B8E8(Entity* this, u32 unk) { Entity* entity; entity = this->attachedEntity; - entity->damageType = unk; + entity->hitType = unk; entity = (*(Entity**)&this->field_0x74); - entity->damageType = unk; + entity->hitType = unk; } void sub_0803B8F8(Entity* this) { diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index a4b000e8..55199ec2 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -144,7 +144,7 @@ void sub_08033F3C(Entity* this) { this->action = 0xd; this->subAction = 0; this->actionDelay = 0xfc; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); } else { pEVar2 = CreateEnemy(MAZAAL_BRACELET, 0); pEVar2->parent = this; diff --git a/src/enemy/mazaalMacro.c b/src/enemy/mazaalMacro.c index e9cf7191..2edf3d96 100644 --- a/src/enemy/mazaalMacro.c +++ b/src/enemy/mazaalMacro.c @@ -229,7 +229,7 @@ void sub_08034FA0(Entity* this) { void sub_08035050(Entity* this) { Entity* entity; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); this->currentHealth = 0; entity = CreateEnemy(VAATI_PROJECTILE, 0); if (entity != NULL) { diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c index 1ee92567..909f3792 100644 --- a/src/enemy/moldorm.c +++ b/src/enemy/moldorm.c @@ -50,7 +50,7 @@ void sub_08022BEC(Entity* this) { void sub_08022C58(Entity* this) { Entity *tail0, *tail1, *tail2; - this->flags &= ~0x80; + COLLISION_OFF(this); if (gEntCount >= 0x45) return; @@ -77,7 +77,7 @@ void sub_08022C58(Entity* this) { this->action = 1; this->actionDelay = 1; this->field_0xf = 1; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->parent = this; this->attachedEntity = tail0; *(Entity**)&this->field_0x7c = tail1; diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index 88ad48bf..9b53911f 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -67,7 +67,7 @@ void sub_080230E4(Entity* this) { this->action = 7; this->actionDelay = 1; this->subAction = 0; - this->damageType = 0x85; + this->hitType = 0x85; this->iframes = -8; this->field_0x7c.BYTES.byte3 = 0; this->field_0x7a.HALF.HI = 0; @@ -170,7 +170,7 @@ void sub_08023330(Entity* this) { if (this->frames.all & 0x80) { this->action = 4; this->actionDelay = 0x19; - this->flags |= 0x80; + COLLISION_ON(this); this->field_0x78.HWORD = 600; this->direction = Random() & 0x1c; this->animationState = this->direction >> 2; @@ -196,8 +196,8 @@ void sub_08023398(Entity* this) { if (sub_08023A38(GetTileTypeByEntity(this))) { this->action = 5; this->field_0x7c.BYTES.byte3 = 0; - this->flags = this->flags & 0x7f; - this->damageType = 0x85; + COLLISION_OFF(this); + this->hitType = 0x85; this->attachedEntity->actionDelay = 1; sub_08023A68(this); CreateFx(this, FX_ROCK, 0); @@ -299,7 +299,7 @@ void sub_08023604(Entity* this) { if (((u8*)&this->field_0x78)[this->parent->field_0x7c.BYTES.byte0 & 0xf] != 0x88) { this->action = 2; this->actionDelay = 0; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = 1; sub_08023644(this); } @@ -311,7 +311,7 @@ void sub_08023644(Entity* this) { if (parent->animIndex == 0x17 && this->actionDelay != 0 && this->x.HALF.HI == parent->x.HALF.HI && this->y.HALF.HI == parent->y.HALF.HI) { this->action = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spriteSettings.b.draw = 0; this->attachedEntity->actionDelay = 1; sub_080239F0(this); @@ -364,7 +364,7 @@ void sub_0802376C(Entity* this) { if (((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf] != 0x88) { this->action = 2; this->actionDelay = 0; - this->flags |= 0x80; + COLLISION_ON(this); this->parent->field_0x7c.BYTES.byte3 = 1; sub_08023A88(this, 20); sub_080237D8(this); @@ -377,7 +377,7 @@ void sub_080237D8(Entity* this) { if (parent->animIndex == 0x17 && this->actionDelay != 0 && this->x.HALF.HI == parent->x.HALF.HI && this->y.HALF.HI == parent->y.HALF.HI) { this->action = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spriteSettings.b.draw = 0; parent->field_0x7c.BYTES.byte3 = 1; sub_080239F0(this); @@ -499,7 +499,7 @@ void sub_08023AB0(Entity* this) { if (this->field_0x7c.BYTES.byte2) { this->field_0x7c.BYTES.byte2--; } else if (!sub_08023B38(this) || 0x1d >= this->field_0x78.HWORD) { - this->damageType = 0x85; + this->hitType = 0x85; this->field_0x7a.HALF.HI = 0; this->field_0x7c.BYTES.byte2 = 30; InitializeAnimation(this, this->animationState); @@ -507,7 +507,7 @@ void sub_08023AB0(Entity* this) { } else if (this->field_0x7c.BYTES.byte2) { this->field_0x7c.BYTES.byte2--; } else if (this->field_0x78.HWORD >= 90 && sub_08023B38(this)) { - this->damageType = 0x87; + this->hitType = 0x87; this->field_0x7a.HALF.HI = 8; this->field_0x7c.BYTES.byte2 = 10; InitializeAnimation(this, this->animationState + 8); diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c index 525ad1bf..53794388 100644 --- a/src/enemy/octorok.c +++ b/src/enemy/octorok.c @@ -71,7 +71,7 @@ void sub_0801EB7C(Entity* this) { } void sub_0801EB84(Entity* this) { - this->flags &= 0x7f; + COLLISION_OFF(this); UpdateAnimationVariableFrames(this, 2); } @@ -80,8 +80,8 @@ void nullsub_3(Entity* this) { } void sub_0801EB9C(Entity* this) { - if (this->flags & 0x80) { - this->flags |= 0x80; + if (this->flags & ENT_COLLIDE) { + COLLISION_ON(this); this->field_0x3a &= 0xfb; } else { this->currentHealth = 0; diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 9a96a72d..6ac631b5 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -101,7 +101,7 @@ void sub_080200B4(Entity* this) { if (this->animationState == PeahatAnimation_Flying) { this->animationState = PeahatAnimation_BrokenPropeller; this->action = 5; - this->damageType = 0x71; + this->hitType = 0x71; this->field_0x80.HALF.HI = 0; InitializeAnimation(this, this->animationState); } @@ -116,15 +116,15 @@ void sub_080200EC(Entity* this) { } void sub_080200F4(Entity* this) { - this->flags &= ~0x80; + COLLISION_OFF(this); } void nullsub_5(Entity* this) { } void sub_08020104(Entity* this) { - if (this->flags & 0x80) { - this->flags |= 0x80; + if (this->flags & ENT_COLLIDE) { + COLLISION_ON(this); this->field_0x3a &= 0xfb; } else { this->currentHealth = 0; @@ -230,7 +230,7 @@ void Peahat_Stunned(Entity* this) { this->action = 6; this->actionDelay = 240; this->field_0xf = 10; - this->damageType = 0x71; + this->hitType = 0x71; } if (this->direction == 0xff) @@ -245,7 +245,7 @@ void Peahat_Stunned(Entity* this) { this->action = 7; this->actionDelay = 150; this->field_0xf = 10; - this->damageType = 0x71; + this->hitType = 0x71; } break; }; @@ -310,7 +310,7 @@ void Peahat_Takeoff(Entity* this) { GetNextFrame(this); if (this->frames.all & 0x80) { this->action = 1; - this->damageType = 0x70; + this->hitType = 0x70; this->field_0x82.HALF.LO = 1; this->field_0x80.HALF.HI = 1; this->animationState = PeahatAnimation_Flying; diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index b8247e34..6ee4a4da 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -49,7 +49,7 @@ void sub_08023F44(Entity* this) { } void sub_08023F5C(Entity* this) { - if (this->damageType != 0x6e) { + if (this->hitType != 0x6e) { if (this->bitfield == 0x80) { this->field_0x86.HALF.LO = 0x30; @@ -83,8 +83,8 @@ void sub_08023FF0(Entity* this) { if (this->subAction < 3 && !sub_0806F520(this)) { this->action = 1; this->subAction = 0; - this->flags |= 0x80; - this->damageType = 0x77; + COLLISION_ON(this); + this->hitType = 0x77; this->actionDelay = 1; this->speed = 0x40; } else { @@ -108,9 +108,9 @@ void sub_08024058(Entity* this) { } void sub_08024060(Entity* this) { - if (this->damageType != 0x6e) { - this->flags = this->flags & 0x7f; - this->damageType = 0x6e; + if (this->hitType != 0x6e) { + COLLISION_OFF(this); + this->hitType = 0x6e; this->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; } diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 4225a61f..4688d174 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -66,7 +66,7 @@ void sub_08025020(Entity* this) { this->field_0x82.HALF.LO -= gUnk_080CBFE8[(*(Entity**)&this->field_0x4c)->type]; } else { this->cutsceneBeh.HWORD = 0x294; - this->damageType = 0x83; + this->hitType = 0x83; this->field_0x82.HALF.LO = 0; sub_0801D2B4(this, 0x7c); } @@ -85,7 +85,7 @@ void sub_08025020(Entity* this) { } break; default: - if (this->damageType == 0x82 && this->iframes < 0) { + if (this->hitType == 0x82 && this->iframes < 0) { Entity* ent = CreateObject(OBJECT_21, 2, 0); if (ent != NULL) { ent->spritePriority.b0 = 3; @@ -131,7 +131,7 @@ void sub_080251AC(Entity* this) { } } else { this->cutsceneBeh.HWORD = 0x294; - this->damageType = 0x83; + this->hitType = 0x83; this->field_0x82.HALF.LO = 0; sub_0801D2B4(this, 0x7c); } @@ -275,7 +275,7 @@ void sub_080254B4(Entity* this) { if (this->frames.all & 0x80) { if (this->height.HALF.HI == 0) { if (this->cutsceneBeh.HWORD == 0) { - this->damageType = 0x82; + this->hitType = 0x82; this->field_0x82.HALF.LO = -0x10; sub_080256B4(this); } else { @@ -361,7 +361,7 @@ void sub_0802563C(Entity* this) { if (--this->cutsceneBeh.HWORD == 0) { sub_0801D2B4(this, 0x28); - this->damageType = 0x82; + this->hitType = 0x82; this->field_0x82.HALF.LO = 240; sub_080256B4(this); sub_0804AA1C(this); diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index e4f2bf30..3248714f 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -50,14 +50,14 @@ void sub_08022254(Entity* this) { #endif sub_0804A4E4(this, ent); this->action = 2; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spriteSettings.b.draw = 0; this->direction = this->knockbackDirection; this->attachedEntity = ent; } } } else { - if (this->damageType != 0x94) + if (this->hitType != 0x94) InitializeAnimation(this, 2); } diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index cafa618d..3316e6e5 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -30,12 +30,12 @@ void Rollobite_OnTick(Entity* this) { } void sub_08020668(Entity* this) { - if (this->damageType == 34 && this->currentHealth != 0xff) { + if (this->hitType == 34 && this->currentHealth != 0xff) { this->action = 4; this->hVelocity = 0x20000; this->direction = 0xff; this->currentHealth = 0xff; - this->damageType = 35; + this->hitType = 35; InitializeAnimation(this, this->animationState + 8); } @@ -67,7 +67,7 @@ void sub_080206E0(Entity* this) { void sub_08020734(Entity* this) { if (this->subAction < 3 && !sub_0806F520(this)) { this->action = 4; - this->flags |= 0x80; + COLLISION_ON(this); this->direction = 0xff; InitializeAnimation(this, this->animationState + 0x10); } else { @@ -89,7 +89,7 @@ void sub_08020790(Entity* this) { } void sub_08020798(Entity* this) { - this->flags &= ~0x80; + COLLISION_OFF(this); } void nullsub_6(Entity* this) { @@ -98,7 +98,7 @@ void nullsub_6(Entity* this) { void sub_080207A8(Entity* this) { this->action = 4; - this->flags |= 0x80; + COLLISION_ON(this); this->spritePriority.b0 = 4; this->field_0x3a &= 0xfb; this->direction ^= 0x10; @@ -139,7 +139,7 @@ void sub_08020874(Entity* this) { void sub_0802088C(Entity* this) { this->subAction = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); this->cutsceneBeh.HALF.HI = gPlayerEntity.animationState; this->spritePriority.b1 = 0; } @@ -159,7 +159,7 @@ void sub_080208F0(Entity* this) { void sub_08020904(Entity* this) { this->action = 4; - this->flags |= 0x80; + COLLISION_ON(this); this->direction = -1; InitializeAnimation(this, this->animationState + 0x10); } @@ -195,9 +195,9 @@ void Rollobite_RolledUp(Entity* this) { void Rollobite_Unroll(Entity* this) { GetNextFrame(this); if (this->frames.all & 0x80) { - this->flags |= 0x80; + COLLISION_ON(this); this->speed = 0x100; - this->damageType = 34; + this->hitType = 34; sub_08020A30(this); this->direction = DirectionFromAnimationState(this->animationState); InitializeAnimation(this, this->animationState); @@ -257,7 +257,7 @@ bool32 Rollobite_TryToHoleUp(Entity* this) { int iVar1 = GetTileType(tile, this->collisionLayer); if ((iVar1 * 0x10000 - 0x710000U) >> 0x10 < 2) { this->action = 6; - this->flags &= ~0x80; + COLLISION_OFF(this); this->x.HALF.HI &= 0xfff0; this->x.HALF.HI += 8; this->y.HALF.HI &= 0xfff0; diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index fd72c272..04c87bba 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -47,7 +47,7 @@ void sub_08029300(Entity* this) { } void sub_08029318(Entity* this) { - if (this->damageType == 0x8e) { + if (this->hitType == 0x8e) { sub_08029770(this); } else { if (this->action == 4) { @@ -126,7 +126,7 @@ void sub_08029474(Entity* this) { } else { if (this->frames.all == 1) { this->frames.all = 0; - this->flags |= 0x80; + COLLISION_ON(this); } } } @@ -142,7 +142,7 @@ void sub_080294D4(Entity* this) { sub_080296C8(this); } else { this->action = 6; - this->flags &= 0x7f; + COLLISION_OFF(this); InitializeAnimation(this, 3); InitializeAnimation(this->attachedEntity, 7); } @@ -252,12 +252,12 @@ void sub_08029770(Entity* this) { u32 temp; if (LoadFixedGFX(this, 0x73) != 0) { this->action = 2; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); this->spriteIndex = 0xd1; this->spritePriority.b1 = 3; temp = this->field_0x82.HALF.LO; this->palette.b.b0 = temp; - this->damageType = 0x8d; + this->hitType = 0x8d; this->hitbox = &gUnk_080FD260; InitializeAnimation(this, 2); this->attachedEntity->spriteSettings.b.draw = TRUE; @@ -270,9 +270,9 @@ void sub_080297F0(Entity* this) { u32 temp; this->action = 1; this->actionDelay = 0x78; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = TRUE; - this->damageType = 0x8e; + this->hitType = 0x8e; sub_080AE068(this); #ifdef EU this->spriteIndex = 0x142; diff --git a/src/enemy/smallPesto.c b/src/enemy/smallPesto.c index 1d09e3c1..660a3110 100644 --- a/src/enemy/smallPesto.c +++ b/src/enemy/smallPesto.c @@ -36,7 +36,7 @@ void sub_0803169C(Entity* this) { if (iVar1 == 0) { this->action = 1; this->subAction = 0; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->speed = 0x40; this->field_0xf = 1; } else { diff --git a/src/enemy/spark.c b/src/enemy/spark.c index 71e913c5..811bea88 100644 --- a/src/enemy/spark.c +++ b/src/enemy/spark.c @@ -20,7 +20,7 @@ void sub_0802B2E0(Entity* this) { if (this->bitfield & 0x80) { if ((this->bitfield & 0x7f) == 0x14) { - this->flags &= ~0x80; + COLLISION_OFF(this); this->iframes = 0; this->spriteSettings.b.draw = 0; this->action = 2; diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index 4884f873..9f3aa75f 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -54,7 +54,7 @@ void sub_0802B628(Entity* this) { this->direction = this->knockbackDirection; this->knockbackDuration = 0; this->iframes = -8; - this->damageType = 100; + this->hitType = 100; InitializeAnimation(this, 9); } } @@ -168,7 +168,7 @@ void sub_0802B8E0(Entity* this) { this->action = 8; this->hVelocity = 0x10000; this->speed = 0x60; - this->damageType = 99; + this->hitType = 99; InitializeAnimation(this, this->animationState); EnqueueSFX(299); } diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index 5f928636..56872a16 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -33,13 +33,13 @@ void sub_08022434(Entity* this) { void sub_0802244C(Entity* this) { if (this->currentHealth) { - if (this->damageType == 0x65) { + if (this->hitType == 0x65) { switch (this->bitfield & 0x7f) { case 2: case 3: this->action = 2; this->field_0xf = 0x3c; - this->damageType = 0x5c; + this->hitType = 0x5c; this->hitbox = &gUnk_080FD468; InitializeAnimation(this, 0); break; @@ -54,7 +54,7 @@ void sub_0802244C(Entity* this) { case 0x1a: sub_0804A9FC(this, 0x1c); this->action = 5; - this->damageType = 0x5c; + this->hitType = 0x5c; InitializeAnimation(this, 1); } } else if (this->bitfield == 0x94) { @@ -65,7 +65,7 @@ void sub_0802244C(Entity* this) { if (this->field_0x80.HALF.LO != this->currentHealth) { this->action = 5; - this->damageType = 0x5c; + this->hitType = 0x5c; InitializeAnimation(this, 1); } else { if (this->action == 3) { @@ -141,7 +141,7 @@ void sub_08022654(Entity* this) { GetNextFrame(this); if (--this->actionDelay == 0) { this->action = 3; - this->damageType = 0x65; + this->hitType = 0x65; InitializeAnimation(this, 2); } break; @@ -152,7 +152,7 @@ void sub_080226EC(Entity* this) { if (sub_08049FDC(this, 1)) { if (sub_080228CC(this)) { this->action = 3; - this->damageType = 0x65; + this->hitType = 0x65; InitializeAnimation(this, 2); return; } @@ -162,7 +162,7 @@ void sub_080226EC(Entity* this) { this->hVelocity = 0x12000; this->speed = 0x140; this->direction = GetFacingDirection(this, gUnk_020000B0); - this->damageType = 0x5a; + this->hitType = 0x5a; InitializeAnimation(this, 4); return; } @@ -196,7 +196,7 @@ void sub_080227AC(Entity* this) { if (this->frames.all & 2) { this->frames.all &= ~2; - this->damageType = 0x5c; + this->hitType = 0x5c; } if (this->frames.all & 0x80) { @@ -223,7 +223,7 @@ void sub_08022854(Entity* this) { sub_080AEFE0(this); if (sub_08003FC4(this, 0x1800) == 0) { this->action = 7; - this->damageType = 0x5c; + this->hitType = 0x5c; InitializeAnimation(this, 5); EnqueueSFX(0x7d); } diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index bd5d18f8..d001699a 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -355,7 +355,7 @@ void sub_080428FC(Entity* this) { SoundReq(SFX_153); uVar2 = 0; do { - ((VaatiArm_HeapStruct*)this->myHeap)->entities[uVar2]->damageType = 0x3b; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[uVar2]->hitType = 0x3b; uVar2 = uVar2 + 1; } while (uVar2 < 5); } @@ -387,7 +387,7 @@ void sub_08042970(Entity* this) { this->actionDelay = 0x3c; uVar2 = 0; do { - ((VaatiArm_HeapStruct*)this->myHeap)->entities[uVar2]->damageType = 0x39; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[uVar2]->hitType = 0x39; uVar2 = uVar2 + 1; } while (uVar2 < 5); } @@ -460,9 +460,9 @@ void sub_08042AEC(Entity* this) { if (--this->actionDelay == 0) { this->subAction = 3; this->actionDelay = 4; - this->damageType = 0x3d; + this->hitType = 0x3d; InitAnimationForceUpdate(this, 0xe); - ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->damageType = 0x3d; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->hitType = 0x3d; } } @@ -508,8 +508,8 @@ void sub_08042B20(Entity* this) { this->action = 5; this->subAction = 0; this->actionDelay = 0x1e; - this->damageType = 0x39; - ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->damageType = 0x39; + this->hitType = 0x39; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->hitType = 0x39; } } } @@ -565,7 +565,7 @@ void sub_08042C34(Entity* this) { entity->x.HALF.HI = x; entity->y.HALF.HI = y; entity->height.HALF.HI = 0x32; - entity->damageType = 0x39; + entity->hitType = 0x39; ptr = &((VaatiArm_HeapStruct*)this->myHeap)->s1[i]; ptr->unk00.HWORD = 0x80; ptr->unk04.HWORD = 0; @@ -582,8 +582,8 @@ void sub_08042D24(Entity* this) { if (--this->actionDelay == 0) { this->subAction = 2; - this->damageType = 0x3d; - ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->damageType = 0x3d; + this->hitType = 0x3d; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->hitType = 0x3d; entity = CreateObject(OBJECT_AF, 1, 0); if (entity != NULL) { entity->parent = ((VaatiArm_HeapStruct*)this->myHeap)->entities[3]; @@ -618,10 +618,10 @@ void sub_08042D6C(Entity* this) { ((VaatiArm_HeapStruct*)this->myHeap)->s1[0].unk0a = 0xc0; this->subAction = 3; this->actionDelay = 0x1e; - this->damageType = 0x39; + this->hitType = 0x39; this->field_0x7c.BYTES.byte3 = 0x2d; InitAnimationForceUpdate(this, 0); - ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->damageType = 0x39; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]->hitType = 0x39; } else { entity->height.HALF.HI -= 2; } @@ -742,7 +742,7 @@ void sub_08043048(Entity* this) { ptr[0].unk04.HWORD += 0x200; if (0x4f < ptr[0].unk04.HALF.HI) { for (i = 0; i < 5; i++) { - ((VaatiArm_HeapStruct*)this->myHeap)->entities[i]->damageType = 0x3b; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[i]->hitType = 0x3b; } SoundReq(SFX_153); } @@ -751,7 +751,7 @@ void sub_08043048(Entity* this) { if (--this->actionDelay == 0) { this->subAction = 7; for (i = 0; i < 5; i++) { - ((VaatiArm_HeapStruct*)this->myHeap)->entities[i]->damageType = 0x39; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[i]->hitType = 0x39; } } } @@ -962,7 +962,7 @@ NONMATCH("asm/non_matching/vaati/sub_08043490.inc", void sub_08043490(Entity* th entity->flags = entity->flags | 0x80; entity->spriteSettings.b.draw = 1; entity->field_0x3c = entity->field_0x3c & 0xef; - entity->damageType = 0x3a; + entity->hitType = 0x3a; entity->hitbox = (Hitbox*)&gUnk_080FD450; entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[2]; entity->flags = entity->flags | 0x80; @@ -1011,7 +1011,7 @@ void sub_08043580(Entity* this) { this->actionDelay = 0x3c; entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4]; entity->field_0x3c = entity->field_0x3c | 0x10; - entity->damageType = 0x39; + entity->hitType = 0x39; entity->hitbox = (Hitbox*)&gUnk_080FD538; sub_0804AA1C(this); } @@ -1341,7 +1341,7 @@ void sub_08043D08(Entity* this) { CopyPosition(((VaatiArm_HeapStruct*)this->myHeap)->entities[3], entity); entity->height.HALF.HI += ((VaatiArm_HeapStruct*)this->myHeap)->s1[3].unk0c; for (i = 0; i < 5; i++) { - ((VaatiArm_HeapStruct*)this->myHeap)->entities[i]->damageType = 0x39; + ((VaatiArm_HeapStruct*)this->myHeap)->entities[i]->hitType = 0x39; } EnqueueSFX(SFX_HIT); } @@ -1364,7 +1364,7 @@ void sub_08043DB0(Entity* this) { gScreenTransition.field_0x3d = 0x1e - (cVar1 / 0x3c); gScreenTransition.field_0x3c = this->type2; pEVar2 = ((VaatiArm_HeapStruct*)this->myHeap)->parent; - gScreenTransition.field_0x40 = pEVar2->x.HALF.HI; + gScreenTransition.hurtType = pEVar2->x.HALF.HI; gScreenTransition.field_0x42 = pEVar2->y.HALF.HI; pEVar4 = ((VaatiArm_HeapStruct*)pEVar2->myHeap)->parent; if (pEVar4 != NULL) { @@ -1391,7 +1391,7 @@ void sub_08043EB8(Entity* this) { Entity* pEVar4; VaatiArm_HeapStruct1* ptr; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->spritePriority.b0 = 4; InitAnimationForceUpdate(this, 0xd); pEVar4 = ((VaatiArm_HeapStruct*)this->myHeap)->entities[1]; @@ -1412,7 +1412,7 @@ void sub_08043EB8(Entity* this) { pEVar4->y.HALF.HI = (this->type2 == 0) ? gScreenTransition.field_0x46 : gScreenTransition.field_0x4a; pEVar4->height.HALF.HI = 0; pEVar4->field_0x3c = pEVar4->field_0x3c & 0xef; - pEVar4->damageType = 0x3a; + pEVar4->hitType = 0x3a; pEVar4->hitbox = (Hitbox*)&gUnk_080FD450; pEVar4 = CreateObject(OBJECT_AF, 0, 0); if (pEVar4 != NULL) { diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 00c3f24c..dca843d9 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -40,7 +40,7 @@ void VaatiBall(Entity* this) { if (this->currentHealth < 0xfd) { #endif this->spriteSettings.b.draw = 0; - this->flags &= 0x7f; + COLLISION_OFF(this); this->currentHealth = -1; parent->field_0x80.HALF.LO--; CreateDust(this); @@ -99,7 +99,7 @@ void sub_0804474C(Entity* this) { case 2: this->action = 2; this->field_0x74.HALF.LO = 0; - this->damageType = 0; + this->hitType = 0; break; } @@ -121,14 +121,14 @@ void sub_080447E0(Entity* this) { if (vaati->action == 1) { this->action = 1; - this->damageType = 43; + this->hitType = 43; sub_08044E74(this, 0); - if (this->flags & 0x80) + if (this->flags & ENT_COLLIDE) this->spriteSettings.b.draw = 1; } else { this->field_0x76.HALF.HI++; this->field_0x76.HALF.HI &= 7; - if (this->flags & 0x80) { + if (this->flags & ENT_COLLIDE) { if (this->field_0x76.HALF.HI & 1) { this->spriteSettings.b.draw = 1; } else { @@ -190,7 +190,7 @@ void sub_08044868(Entity* this) { vaati->type2 = 1; vaati->parent = this; this->cutsceneBeh.HALF.LO = 1; - this->damageType = 0; + this->hitType = 0; } } } @@ -207,9 +207,9 @@ void sub_08044868(Entity* this) { sub_08044E74(this, 1); draw = this->spriteSettings.b.draw; if (draw == 1) { - this->flags |= 0x80; + COLLISION_ON(this); } else { - this->flags &= 0x7f; + COLLISION_OFF(this); } break; } @@ -390,7 +390,7 @@ void sub_08044B04(Entity* this) { case 3: this->field_0x74.HALF.LO = 1; this->actionDelay = 80; - this->flags &= 0x7f; + COLLISION_OFF(this); PositionRelative(vaati, this, 0, -0x100000); if (this->field_0xf) this->spriteSettings.b.draw = 0; @@ -429,9 +429,9 @@ void sub_08044B04(Entity* this) { sub_08044E74(this, 1); draw = this->spriteSettings.b.draw; if (draw == 1) { - this->flags |= 0x80; + COLLISION_ON(this); } else { - this->flags &= 0x7f; + COLLISION_OFF(this); } vaati->actionDelay++; break; @@ -452,7 +452,7 @@ void sub_08044DEC(Entity* this) { } else { this->spriteSettings.b.draw = 0; } - this->flags &= 0x7f; + COLLISION_OFF(this); this->field_0x78.HALF.LO = 0; this->speed = 0x300; off = this->parent->field_0x80.HALF.LO - 1; diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c index f2d3041d..86b5a739 100644 --- a/src/enemy/vaatiEyesMacro.c +++ b/src/enemy/vaatiEyesMacro.c @@ -146,7 +146,7 @@ void VaatiEyesMacroFunction0Type1Action0(Entity* this) { void VaatiEyesMacroFunction0Type1Action1(Entity* this) { if (this->parent->next == NULL) { - this->flags &= 0x7f; + COLLISION_OFF(this); this->currentHealth = 0; } else { sub_0802F04C(this); diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index a74de388..f86fb5ab 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -42,7 +42,7 @@ void (*const vaatiProjectileFunction0Actions[])(Entity*) = { void VaatiProjectile(Entity* this) { if (sub_0803E4A0(this)) { - this->flags &= 0x7f; + COLLISION_OFF(this); this->currentHealth = 0; this->parent = NULL; } @@ -61,7 +61,7 @@ void VaatiProjectileFunction1(Entity* this) { if (this->currentHealth != 0) { #endif this->action = 5; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); this->spritePriority.b1 = 0; gPlayerEntity.flags &= 0x7f; gPlayerEntity.spriteOrientation.flipY = this->spriteOrientation.flipY; @@ -114,7 +114,7 @@ void VaatiProjectileFunction0Action0(Entity* this) { } } else { this->action = 8; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); this->spriteOffsetY = 1; this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY; this->spriteRendering.b3 = this->parent->spriteRendering.b3; diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index f96527e9..85c39122 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -514,13 +514,13 @@ void VaatiRebornEnemyType1Action1(Entity* this) { if (this->field_0x74.HALF.LO == 0) { if (parent->field_0x80.HALF.LO == 0) { this->field_0x74.HALF.LO = 1; - this->damageType = 0x30; + this->hitType = 0x30; InitAnimationForceUpdate(this, this->field_0x74.HALF.LO); } } else { if (parent->field_0x80.HALF.LO != 0) { this->field_0x74.HALF.LO = 0; - this->damageType = 0x2f; + this->hitType = 0x2f; InitAnimationForceUpdate(this, this->field_0x74.HALF.LO); } else { if (((this->bitfield & 0x80) != 0) && (0 < this->iframes)) { @@ -536,12 +536,12 @@ void VaatiRebornEnemyType1Action1(Entity* this) { if (this->field_0x74.HALF.HI == 0) { if (parent->action != 2) { this->field_0x74.HALF.HI = 1; - this->flags |= 0x80; + COLLISION_ON(this); } } else { if (parent->action == 2) { this->field_0x74.HALF.HI = 0; - this->flags &= 0x7f; + COLLISION_OFF(this); } } this->spriteSettings.b.draw = parent->spriteSettings.b.draw; @@ -644,7 +644,7 @@ void sub_0803DC0C(Entity* this) { void VaatiRebornEnemyType1PreAction(Entity* this) { Entity* parent; - if (this->damageType != 0x30) { + if (this->hitType != 0x30) { return; } parent = this->parent; @@ -652,7 +652,7 @@ void VaatiRebornEnemyType1PreAction(Entity* this) { if ((this->bitfield & 0x80) != 0) { if (gUnk_080D04D0[parent->field_0x86.HALF.LO] > this->currentHealth) { if (2 < ++parent->field_0x86.HALF.LO) { - this->flags &= 0x7f; + COLLISION_OFF(this); parent->action = 7; parent->flags &= 0x7f; parent->actionDelay = 0x80; @@ -675,7 +675,7 @@ void VaatiRebornEnemyType1PreAction(Entity* this) { } if (this->actionDelay != 0) { if (--this->actionDelay == 0) { - this->damageType = 0x2f; + this->hitType = 0x2f; this->field_0x74.HALF.LO = 1; if (this->field_0x76.HALF.HI == 0) { parent->field_0x74.HALF.LO = 0xf0; diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 757d6544..0933b1eb 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -269,14 +269,14 @@ void VaatiTransfiguredType0Action3(Entity* this) { break; this->field_0x80.HALF.LO = 1; this->actionDelay = 0xc0; - this->flags |= 0x80; + COLLISION_ON(this); SoundReq(SFX_14C); sub_08080964(0x14, 4); break; case 1: if (--this->actionDelay == 0) { this->field_0x80.HALF.LO = 2; - this->damageType = 0x35; + this->hitType = 0x35; this->spriteOffsetX = 0; } if (this->currentHealth < gUnk_080D0ABC[this->animationState]) { @@ -287,7 +287,7 @@ void VaatiTransfiguredType0Action3(Entity* this) { } if (tmp) { this->field_0x80.HALF.LO = 2; - this->damageType = 0x35; + this->hitType = 0x35; this->spriteOffsetX = 0; this->animationState++; if (this->animationState > 2) { @@ -312,7 +312,7 @@ void VaatiTransfiguredType0Action3(Entity* this) { case 3: if (this->actionDelay != 0) { if (--this->actionDelay == 0) { - this->flags &= 0x7f; + COLLISION_OFF(this); this->hVelocity = 0x38000; this->field_0xf = 0x10; } @@ -321,7 +321,7 @@ void VaatiTransfiguredType0Action3(Entity* this) { if (sub_08003FC4(this, 0x2800) == 0) { this->field_0x80.HALF.LO = 5; this->actionDelay = 0x10; - this->flags |= 0x80; + COLLISION_ON(this); this->currentHealth = 0xff; this->field_0x86.HALF.LO = 0; sub_080408EC(this); @@ -1059,8 +1059,8 @@ void sub_080409B0(Entity* this) { this->action = 3; this->field_0x80.HALF.LO = 0; this->field_0x80.HALF.HI = 3; - this->flags &= 0x7f; - this->damageType = 0x36; + COLLISION_OFF(this); + this->hitType = 0x36; this->hVelocity = 0x18000; SoundReq(SFX_164); } diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c index a4cf8999..a6777666 100644 --- a/src/enemy/vaatiTransfiguredEye.c +++ b/src/enemy/vaatiTransfiguredEye.c @@ -125,7 +125,7 @@ void VaatiTransfiguredEyeFunction0Action1(Entity* this) { if (this->field_0x82.HALF.LO == 0) { if ((this->frames.all & 0x80) != 0) { if (this->type != 0) { - this->flags |= 0x80; + COLLISION_ON(this); } this->action = 2; InitializeAnimation(this, this->type << 3); @@ -149,7 +149,7 @@ void VaatiTransfiguredEyeFunction0Action2(Entity* this) { this->action = 4; this->field_0xf = 0; if (this->type != 0) { - this->flags &= 0x7f; + COLLISION_OFF(this); if (this->actionDelay != 0) { InitializeAnimation(this, this->type << 3 | 5); InitializeAnimation(this->parent, this->parent->type << 3 | 5); @@ -167,10 +167,10 @@ void VaatiTransfiguredEyeFunction0Action3(Entity* this) { this->action = 2; if (this->type != 0) { if (this->actionDelay == 0) { - this->damageType = 0x32; + this->hitType = 0x32; } else { this->parent->parent->field_0x76.HALF.LO |= (1 << this->type2); - this->damageType = 0x31; + this->hitType = 0x31; } } } @@ -195,7 +195,7 @@ void VaatiTransfiguredEyeFunction0Action4(Entity* this) { this->field_0x80.HALF.HI = 0; this->cutsceneBeh.HALF.HI = 0; if (this->type != 0) { - this->damageType = 0x33; + this->hitType = 0x33; } if ((parent->field_0x74.HALF.HI >> this->type2 & 1U) != 0) { this->actionDelay = 1; diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 08b5cb85..23063fc3 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -104,7 +104,7 @@ const s8 gUnk_080D0EB0[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x0 void VaatiWrath(Entity* this) { if (((this->type == 0) && ((this->bitfield & 0x80) != 0)) && (this->currentHealth == 0)) { - this->flags |= 0x80; + COLLISION_ON(this); this->currentHealth = 0xff; if (--this->cutsceneBeh.HALF.LO == 0) { this->action = 0xd; @@ -138,7 +138,7 @@ void VaatiWrathType0Action0(Entity* this) { this->action = 2; this->actionDelay = 0x3c; } - this->x.HALF.HI = gScreenTransition.field_0x40; + this->x.HALF.HI = gScreenTransition.hurtType; this->y.HALF.HI = gScreenTransition.field_0x42; sub_08042004(this); } else { @@ -480,7 +480,7 @@ void VaatiWrathType0ActionB(Entity* this) { this->subAction = 1; this->actionDelay = 0xf0; this->currentHealth = 8; - this->damageType = 0x38; + this->hitType = 0x38; sub_08080964(0x14, 0); InitAnimationForceUpdate(this, 6); InitializeAnimation(((VaatiWrathHeapStruct*)this->myHeap)->type2, 0x16); @@ -492,7 +492,7 @@ void VaatiWrathType0ActionB(Entity* this) { if (--this->actionDelay == 0) { this->subAction = 2; this->actionDelay = 0x3c; - this->damageType = 0x39; + this->hitType = 0x39; this->currentHealth = 0xff; } break; @@ -567,7 +567,7 @@ void sub_08041BE8(Entity* this) { if (sub_08079F8C() != 0) { this->subAction = 1; this->actionDelay = 120; - this->scriptedScene = 3; + this->updateConditions = 3; InitAnimationForceUpdate(this, 10); entity = ((VaatiWrathHeapStruct*)this->myHeap)->type1; @@ -576,7 +576,7 @@ void sub_08041BE8(Entity* this) { ((VaatiWrathHeapStruct*)this->myHeap)->type1 = NULL; entity = ((VaatiWrathHeapStruct*)this->myHeap)->type2; - entity->scriptedScene = 3; + entity->updateConditions = 3; sub_080AE068(entity); LoadFixedGFX(entity, 0x1f5); sub_0801D2B4(entity, 0x16b); diff --git a/src/enemy/vaatiWrathEye.c b/src/enemy/vaatiWrathEye.c index 2fd855f5..f33e4009 100644 --- a/src/enemy/vaatiWrathEye.c +++ b/src/enemy/vaatiWrathEye.c @@ -62,7 +62,7 @@ void VaatiWrathEyeAction2(Entity* this) { sub_080485D8(this); if ((gScreenTransition.field_0x39 & 3) == 0) { this->action = 3; - this->flags |= 0x80; + COLLISION_ON(this); this->speed = 0x80; } } @@ -157,7 +157,7 @@ void VaatiWrathEyeAction7(Entity* this) { if (this->field_0xf != 0) { this->action = 8; this->actionDelay = 0x3c; - this->flags &= 0x7f; + COLLISION_OFF(this); this->spriteSettings.b.draw = 0; CreateFx(this, FX_REFLECT2, 0x40); this->parent->field_0x7a.HALF.HI |= 0x10 << this->type; @@ -177,7 +177,7 @@ void VaatiWrathEyeAction8(Entity* this) { } else { if (--this->actionDelay == 0) { this->action = 9; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = 1; InitializeAnimation(this, 0); sub_080485FC(this); diff --git a/src/enemy/wallMaster.c b/src/enemy/wallMaster.c index 9a3ae8d2..7107cf9c 100644 --- a/src/enemy/wallMaster.c +++ b/src/enemy/wallMaster.c @@ -26,9 +26,9 @@ void sub_0802A434(Entity* this) { } void sub_0802A454(Entity* this) { - if (this->damageType != 0x75 && ((this->bitfield & 0x7f) == 0 || (this->bitfield & 0x7f) == 0x1e)) { + if (this->hitType != 0x75 && ((this->bitfield & 0x7f) == 0 || (this->bitfield & 0x7f) == 0x1e)) { this->action = 5; - this->flags &= ~0x80; + COLLISION_OFF(this); this->field_0x7c.HALF.HI = gPlayerEntity.x.HALF.HI; this->field_0x80.HWORD = gPlayerEntity.y.HALF.HI; this->field_0x82.HWORD = gPlayerEntity.height.HALF.HI; @@ -72,7 +72,7 @@ void sub_0802A534(Entity* this) { if (ent != NULL) { this->action = 2; this->actionDelay = 0x5a; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteSettings.b.draw = 3; this->x.HALF.HI = ent->x.HALF.HI; this->y.HALF.HI = ent->y.HALF.HI; @@ -115,7 +115,7 @@ void sub_0802A610(Entity* this) { this->actionDelay = 0x1e; } else if (this->frames.all & 1) { this->frames.all = flags; - this->damageType = 0x75; + this->hitType = 0x75; } } @@ -124,9 +124,9 @@ void sub_0802A650(Entity* this) { this->height.HALF.HI -= 2; if (-0xa0 > this->height.HALF.HI) { this->action = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spriteSettings.b.draw = 0; - this->damageType = 0x74; + this->hitType = 0x74; this->field_0x78.HWORD = this->field_0x7c.BYTES.byte0 * 0x3c; } } diff --git a/src/enemy/wallMaster2.c b/src/enemy/wallMaster2.c index 26074c7d..d21ca8a2 100644 --- a/src/enemy/wallMaster2.c +++ b/src/enemy/wallMaster2.c @@ -33,7 +33,7 @@ void sub_0802CC80(Entity* this) { case 0 ... 1: case 0x1e: this->action = 3; - this->flags &= ~0x80; + COLLISION_OFF(this); InitializeAnimation(this, 1); gPlayerEntity.flags &= ~0x80; break; diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c index 73fc59eb..0625569c 100644 --- a/src/enemy/waterDrop.c +++ b/src/enemy/waterDrop.c @@ -55,7 +55,7 @@ void sub_0802A2FC(Entity* this) { if (this->frames.all & 0x80) { DeleteEntity(this); } else if (this->frames.all & 1) { - this->flags &= ~0x80; + COLLISION_OFF(this); } else { sub_0802A39C(this); } @@ -76,9 +76,9 @@ void sub_0802A39C(Entity* this) { u32 x = (gPlayerEntity.x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1xOffset) >> 3; u32 y = (gPlayerEntity.y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg1yOffset - 10) >> 3; if (gBG3Buffer[(x & 0x1fU) + (y & 0x1fU) * 0x20 + 0x400]) { - this->flags &= ~0x80; + COLLISION_OFF(this); } else { - this->flags |= 0x80; + COLLISION_ON(this); } } diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 05fdc4e0..734b47df 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -35,7 +35,7 @@ void sub_08033564(Entity* this) { case 0: this->action = 2; this->spriteSettings.b.draw = FALSE; - this->flags &= 0x7f; + COLLISION_OFF(this); this->field_0x7c.HALF.LO = 0x27c; gPlayerState.flags |= 0x4000; gSave.stats.effect = this->type + 1; @@ -50,7 +50,7 @@ void sub_08033564(Entity* this) { this->currentHealth = 0; break; case 0x14: - this->flags &= 0x7f; + COLLISION_OFF(this); this->iframes = 0; this->spriteSettings.b.draw = FALSE; ent = CreateFx(this, FX_DEATH, 0); @@ -119,7 +119,7 @@ void sub_080336DC(Entity* this) { break; case 0x0: this->action = 1; - this->flags |= 0x80; + COLLISION_ON(this); sub_08033744(this); break; } diff --git a/src/entity.c b/src/entity.c index e05c64d1..ba3aa31b 100644 --- a/src/entity.c +++ b/src/entity.c @@ -66,14 +66,14 @@ void sub_0805E374(Entity* param_1) { void sub_0805E3A0(void* ent, u32 param) { Entity* e = (Entity*)ent; - e->scriptedScene2 = param; - e->scriptedScene = param; + e->updateConditions2 = param; + e->updateConditions = param; } -bool32 sub_0805E3B0(Entity* this) { +bool32 CheckDontUpdate(Entity* this) { u32 value; - if (this->flags & 0x10) + if (this->flags & ENT_ASLEEP) return TRUE; if (this->action == 0) return FALSE; @@ -85,7 +85,7 @@ bool32 sub_0805E3B0(Entity* this) { if (gMessage.doTextBox & 0x7F) value = value < 2 ? 2 : value; - return value > this->scriptedScene; + return value > this->updateConditions; } bool32 sub_0805E40C(void) { @@ -124,16 +124,16 @@ void sub_0805E470(void) { } void sub_0805E47C(Entity* this) { - this->scriptedScene2 = this->scriptedScene; - this->scriptedScene = 2; + this->updateConditions2 = this->updateConditions; + this->updateConditions = 2; if (sub_0805E450(2)) gUnk_03003DC0.unk4 = this; } void sub_0805E4A0(Entity* this) { sub_08078A90(1); - this->scriptedScene2 = this->scriptedScene; - this->scriptedScene = 3; + this->updateConditions2 = this->updateConditions; + this->updateConditions = 3; if (sub_0805E450(1)) gUnk_03003DC0.unk4 = this; } @@ -145,8 +145,8 @@ void sub_0805E4CC(Entity* this) { void sub_0805E4E0(Entity* a1, u32 a2) { if (a1 != NULL) { - a1->scriptedScene2 = a1->scriptedScene; - a1->scriptedScene = 3; + a1->updateConditions2 = a1->updateConditions; + a1->updateConditions = 3; } if (sub_0805E450(1u)) gUnk_03003DC0.unk4 = a1; @@ -167,16 +167,16 @@ void sub_0805E524(void) { void sub_0805E544(void) { gUnk_03003DC0.unk0 = 6; - gPlayerEntity.scriptedScene = 6; + gPlayerEntity.updateConditions = 6; } void UnfreezeTime() { gUnk_03003DC0.unk0 = 0; - gPlayerEntity.scriptedScene = 1; + gPlayerEntity.updateConditions = 1; } void sub_0805E584(Entity* e) { - e->scriptedScene = e->scriptedScene2; + e->updateConditions = e->updateConditions2; sub_0805E470(); } @@ -317,7 +317,7 @@ void DeleteEntity(Entity* ent) { if (ent->kind == ENEMY) { sub_0804AA1C(ent); } - ent->flags = ent->flags & 0x7f; + COLLISION_OFF(ent); ent->spriteSettings.b.draw = 0; ent->field_0x3c = 0; ent->bitfield = 0; @@ -440,7 +440,7 @@ void sub_0805E9A8(void) { } while (++list < &gEntityLists[9]); } -void sub_0805E9F4(void) { +void DeleteSleepingEntities(void) { Entity* ent; Entity* next; LinkedList* list; @@ -449,7 +449,7 @@ void sub_0805E9F4(void) { do { for (ent = list->first; (u32)ent != (u32)list; ent = next) { next = ent->next; - if (ent->flags & 0x10) + if (ent->flags & ENT_ASLEEP) DeleteEntityAny(ent); } } while (++list < &gEntityLists[9]); diff --git a/src/game.c b/src/game.c index 408f3e73..0d33c6ca 100644 --- a/src/game.c +++ b/src/game.c @@ -259,7 +259,7 @@ void InitializePlayer(void) { MemClear((void*)&gUnk_03000B80, sizeof(gUnk_03000B80)); MemClear((void*)&gPlayerState, 0xb0); - MemFill32(0xffffffff, &gPlayerState.field_0x40, 0x40); + MemFill32(0xffffffff, &gPlayerState.hurtType, 0x40); pl = &gPlayerEntity; MemClear((void*)pl, 0x88); gRoomControls.cameraTarget = pl; diff --git a/src/arm_proxy.c b/src/interrupts.c similarity index 61% rename from src/arm_proxy.c rename to src/interrupts.c index 62d49afb..da810ec6 100644 --- a/src/arm_proxy.c +++ b/src/interrupts.c @@ -11,6 +11,7 @@ #include "utils.h" #include "npc.h" #include "effects.h" +#include "screen.h" extern u8 gUnk_03003DE0; extern u8 gUnk_03000C30; @@ -22,15 +23,13 @@ extern u8 gUnk_03003DF0[]; extern u8 gUnk_03003BE0; extern Entity* gUnk_03004040[3]; extern u8 gUnk_020342F8; -extern u8 gCollidableCount; -extern void gDoCollision(void); extern void sub_080ADD70(); extern void sub_0801C25C(); extern void UpdateDisplayControls(); extern void LoadResources(); extern void FadeMain(); -extern u32 sub_0805E3B0(); +extern u32 CheckDontUpdate(); extern void HandlePlayerLife(); extern void DoPlayerAction(); extern void sub_080171F0(); @@ -46,9 +45,11 @@ extern void sub_0807B0C8(void); extern void sub_0807A8D8(Entity*); extern void sub_08077FEC(u32); extern void ItemInit(Entity*); -extern void sub_080A2838(Entity*); +extern void InitObject(Entity*); extern u32 ReadBit(void*, u32); -extern void sub_0806EC78(Entity*); +extern void InitNPC(Entity*); +extern void m4aSoundMain(); +extern void m4aSoundVSync(); typedef struct { u8 unk0; @@ -70,15 +71,108 @@ typedef struct { } NPCStruct; extern NPCStruct gUnk_02031EC0[100]; +// todo: merge with screen.h typedef struct { - void* last; - void* first; - void* node; - u8 flags; -} LinkedList2; + u16 dest; + u16 _2; + u16 _4; + u16 _6; + u8* src; +} DmaSettings; -extern LinkedList2 gUnk_03003C70[16]; -extern LinkedList2* gUnk_02018EA0; +extern u16 gDmaPresets[]; + +struct { + u8 update; + u8 _0[0x1c]; + struct OamData oam[0x80]; +} extern gUnk_03000000; + +struct { + u8 ready; + u16* src; + u16* dest; + u32 size; +} extern gUnk_02022730; + +void sub_08016CA8(DmaSettings* s); +void sub_08016BF8(void); +void DispCtrlSet(void); + +extern u16 gUnk_080B2CD8[]; + +extern u32 gUnk_03000FBC; + +void gIntrMain(void); + +typedef void (*fp)(void); + +void DummyIntr(void) { + /* .. */ +} + +void EnableVBlankIntr(void) { + INTR_VECTOR = gIntrMain; + REG_DISPSTAT = 0x5028; + REG_IE = 0x2005; + REG_IME = 1; +} + +void VBlankIntr(void) { + DmaStop(0); + m4aSoundVSync(); + if (gMain.interruptFlag == 0) { + DispCtrlSet(); + DmaCopy32(0, &gUnk_03000FBC, &gUnk_02022730, 16); + gMain.interruptFlag = 1; + } + sub_08016BF8(); + INTR_CHECK |= 1; +} + +void HBlankIntr(void) { + REG_DISPSTAT = 0x5028; + m4aSoundMain(); +} + +void sub_08016BF8(void) { + if (gUnk_02022730.ready) { + const u16* src = gUnk_02022730.src; + u16* dest = gUnk_02022730.dest; + s32 size, i = size = gUnk_02022730.size; + DmaSet(0, src, dest, size); + + i = size & 0x3fff; + if (i == 0) { + i = 0x4000; + } + do { + *dest++ = *src++; + } while (--i > 0); + } +} + +void UpdateDisplayControls(void) { + if (gUnk_03000000.update && ((gScreen.lcd.displayControl & 0x1000) != 0)) { + gUnk_03000000.update = 0; + DmaCopy32(3, &gUnk_03000000.oam, 0x07000000, 0x400); + } + sub_08016CA8((DmaSettings*)&gScreen.bg.bg0Control); + sub_08016CA8((DmaSettings*)&gScreen.bg.bg1Control); + sub_08016CA8((DmaSettings*)&gScreen.affine.bg2Control); + sub_08016CA8((DmaSettings*)&gScreen.affine.bg3Control); +} + +void sub_08016CA8(DmaSettings* s) { + if (s->_6 && s->src != 0) { + u32 dest; + s->_6 = 0; + dest = s->dest; + DmaCopy32(3, s->src, ((dest << 3) & 0xF800) + 0x06000000, gUnk_080B2CD8[dest >> 14]); + } +} + +ASM_FUNC("asm/dispCtrlSet.s", void DispCtrlSet(void)); // Load any resources that were requested with LoadResourceAsync void LoadResources(void) { @@ -133,16 +227,16 @@ void PlayerUpdate(Entity* this) { else gPlayerState.flags &= ~0x4000; - if (sub_0805E3B0(this) == 0) { + if (CheckDontUpdate(this) == 0) { if ((gPlayerState.flags & 0x80000) != 0) { sub_08077B20(); if ((gPlayerState.flags & 0x200000) != 0) { gPlayerState.playerAction = 0x18; gPlayerState.flags &= ~0x80000; gPlayerState.hurtBlinkSpeed = 0xf0; - this->flags |= 0x80; + COLLISION_ON(this); } else { - this->flags &= ~0x80; + COLLISION_OFF(this); gPlayerState.field_0xa8 = 0xf; } } @@ -185,8 +279,8 @@ void HandlePlayerLife(Entity* this) { gPlayerState.field_0xa9 = gPlayerState.field_0xa8; gPlayerState.field_0xa8 = 0; - if (gPlayerState.field_0x40[0x4a] != 0) { - gPlayerState.field_0x40[0x4a]--; + if (gPlayerState.hurtType[0x4a] != 0) { + gPlayerState.hurtType[0x4a]--; return; } @@ -243,7 +337,7 @@ void sub_080171F0(void) { gPlayerEntity.bitfield &= ~0x80; if (gPlayerEntity.action != 0x14) - gPlayerState.flags = (gPlayerState.flags & ~0x10000) | (0x10000 * (gPlayerState.flags & 2) / 2); + COPY_FLAG_FROM_TO(gPlayerState.flags, 0x2, 0x10000); gPlayerState.flags &= ~2; sub_080028E0(&gPlayerEntity); @@ -281,10 +375,10 @@ void sub_080171F0(void) { } void ItemUpdate(Entity* this) { - if ((this->flags & 1) == 0 && this->action == 0 && this->subAction == 0) + if ((this->flags & ENT_DID_INIT) == 0 && this->action == 0 && this->subAction == 0) ItemInit(this); - if (!sub_0805E3B0(this)) { + if (!CheckDontUpdate(this)) { gPlayerItemFunctions[this->id](this); this->bitfield &= ~0x80; if (this->iframes != 0) { @@ -309,9 +403,9 @@ NONMATCH("asm/non_matching/arm_proxy/ItemInit.inc", void ItemInit(Entity* this)) } this->palette.raw = ((entry->unk0 & 0xf) << 4) | entry->unk0; - this->field_0x44 = entry->unk1; - this->field_0x40 = entry->unk3; - this->damageType = entry->unk4; + this->damage = entry->unk1; + this->hurtType = entry->unk3; + this->hitType = entry->unk4; this->spriteIndex = entry->unk5; if (entry->unk6 == 0) this->spriteVramOffset = gPlayerEntity.spriteVramOffset; @@ -326,18 +420,16 @@ NONMATCH("asm/non_matching/arm_proxy/ItemInit.inc", void ItemInit(Entity* this)) this->spritePriority.b0 = gPlayerEntity.spritePriority.b0; this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; this->currentHealth = 1; - this->flags |= 1; + this->flags |= ENT_DID_INIT; } END_NONMATCH void ObjectUpdate(Entity* this) { - int iVar1; - - if (((this->flags & 1) == 0) && (this->action == 0)) - sub_080A2838(this); + if ((this->flags & ENT_DID_INIT) == 0 && this->action == 0) + InitObject(this); if (this->iframes != 0) this->iframes++; - if (!sub_0805E3B0(this)) { + if (!CheckDontUpdate(this)) { gObjectFunctions[this->id](this); this->bitfield &= ~0x80; } @@ -345,7 +437,7 @@ void ObjectUpdate(Entity* this) { } void ManagerUpdate(Entity* this) { - if (!sub_0805E3B0(this)) + if (!CheckDontUpdate(this)) gManagerFunctions[this->id](this); } @@ -353,9 +445,9 @@ void ManagerUpdate(Entity* this) { NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) { if ((this->currentHealth & 0x7f) && !ReadBit(&gUnk_020342F8, this->currentHealth - 1)) DeleteThisEntity(); - if ((this->action == 0) && ((this->flags & 1) == 0)) - sub_0806EC78(this); - if (!sub_0805E3B0(this)) + if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0) + InitNPC(this); + if (!CheckDontUpdate(this)) gNPCFunctions[this->id][0](this); if (this->next != NULL) { if (gNPCFunctions[this->id][1] != NULL) @@ -369,168 +461,3 @@ NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this } } END_NONMATCH - -void ClearHitboxList(void) { - gCollidableCount = 0; -} - -void CollisionMain(void) { - void (*doCollision)(void); - u32 flags; - u32 temp; - - temp = gUnk_03003DC0.unk0; - if (gUnk_03003DC0.unk0 <= gUnk_03003DC0.unk1) - temp = gUnk_03003DC0.unk1; - if (temp != 0) - return; - - doCollision = &gDoCollision; - // Check to see if we should disable collision this frame - if (gPlayerState.field_0x8b != 0) { - u32 temp = gPlayerEntity.flags; - gPlayerEntity.flags &= ~0x80; - doCollision(); - gPlayerEntity.flags = temp; // reset collision to before - } else { - doCollision(); - } -} - -void RegisterPlayerHitbox(void) { - MemClear(&gUnk_03003C70, sizeof(gUnk_03003C70)); - gUnk_02018EA0 = (LinkedList2*)&gUnk_03003C70[0].last; - gUnk_03003C70[0].last = &gUnk_03003C70[0].last; - gUnk_03003C70[0].first = &gUnk_03003C70[0].last; - gUnk_03003C70[0].node = &gPlayerEntity; -} - -// Loop declaration seems wrong -NONMATCH("asm/non_matching/arm_proxy/sub_0801766C.inc", u32 sub_0801766C(Entity* this)) { - u32 uVar1; - LinkedList2* puVar3; - LinkedList2* puVar2; - LinkedList2* pLVar2; - LinkedList2* i; - u8* pbVar4; - - if (this->spritePriority.b2 != 0) { - return 1; - } else { - for (i = &gUnk_03003C70[0]; i < &gUnk_03003C70[16]; ++i) { - if (i->node == NULL) { - i->node = this; - i->flags = 0; - this->spritePriority.b2 = 1; - pLVar2 = gUnk_02018EA0; - if (gUnk_02018EA0->flags != 0) { - do { - pLVar2 = pLVar2->first; - } while (pLVar2->flags != 0); - i->first = pLVar2; - puVar3 = pLVar2->last; - i->last = puVar3; - puVar3->first = i; - pLVar2->last = i; - } else { - i->first = gUnk_02018EA0; - puVar2 = gUnk_02018EA0->last; - i->last = puVar2; - puVar2->first = i; - gUnk_02018EA0->last = i; - gUnk_02018EA0 = i; - } - return 1; - } - } - return 0; - } -} -END_NONMATCH - -// same loop issue -NONMATCH("asm/non_matching/arm_proxy/sub_080176E4.inc", u32 sub_080176E4(Entity* this)) { - u32 uVar1; - LinkedList2* j; - LinkedList2* i; - u8* pbVar4; - - if (this->spritePriority.b2 != 0) { - return 1; - } else { - for (i = &gUnk_03003C70[0]; i < &gUnk_03003C70[16]; ++i) { - if (i->node == NULL) { - i->node = this; - i->flags = 1; - this->spritePriority.b2 = 1; - i->first = gUnk_02018EA0; - j = gUnk_02018EA0->last; - i->last = j; - j->first = i; - gUnk_02018EA0->last = i; - gUnk_02018EA0 = i; - return 1; - } - } - return 0; - } -} -END_NONMATCH - -// you guessed it -NONMATCH("asm/non_matching/arm_proxy/sub_08017744.inc", void sub_08017744(Entity* this)) { - LinkedList2* i; - for (i = &gUnk_03003C70[0]; i < &gUnk_03003C70[16]; ++i) { - if (i->node == this) { - if (this->spritePriority.b2 != 0) { - this->spritePriority.b2 = 0; - i->node = NULL; - ((LinkedList2*)i->last)->first = i->first; - ((LinkedList2*)i->first)->last = i->last; - if (i != gUnk_02018EA0) - return; - gUnk_02018EA0 = i->first; - } - } - } -} -END_NONMATCH - -// regalloc -NONMATCH("asm/non_matching/arm_proxy/sub_080177A0.inc", bool32 sub_080177A0(Entity* this, Entity* that)) { - u32 this_d; - u32 depth; - - if ((that->collisionLayer & this->collisionLayer) != 0) { - Hitbox* bb_this = this->hitbox; - Hitbox* bb_that = that->hitbox; - u32 this_w = bb_this->width; - u32 that_w = bb_that->width; - if ((((this->x.HALF.HI - that->x.HALF.HI) + bb_this->offset_x) - bb_that->offset_x) + this_w + that_w <= - (this_w + that_w) * 2) { - u32 this_h = bb_this->height; - u32 that_h = bb_that->height; - if ((((this->y.HALF.HI - that->y.HALF.HI) + bb_this->offset_y) - bb_that->offset_y) + this_h + that_h <= - (this_h + that_h) * 2) { - if ((this->field_0x3c & 0x10) != 0) - this_d = ((Hitbox3D*)bb_this)->depth; - else - this_d = 5; - if ((that->field_0x3c & 0x10) != 0) - depth = this_d + ((Hitbox3D*)bb_that)->depth; - else - depth = this_d + 5; - if ((this->height.HALF.HI - that->height.HALF.HI) + depth <= depth * 2) - return TRUE; - } - } - } - return FALSE; -} -END_NONMATCH - -bool32 sub_08017850(Entity* this) { - if (sub_08079F8C()) - return sub_080177A0(this, &gPlayerEntity); - return FALSE; -} diff --git a/src/item/itemSword.c b/src/item/itemSword.c index c18178f2..7835fcc0 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -83,7 +83,7 @@ void sub_08075694(ItemBehavior* this, u32 arg1) { gPlayerState.field_0xa = (8 >> arg1) | gPlayerState.field_0xa; this->stateID = 4; this->field_0xf = 6; - gPlayerEntity.field_0x40 = 0x1e; + gPlayerEntity.hurtType = 0x1e; gPlayerState.field_0x1a[1] |= 0x40; gPlayerState.field_0x1a[1] &= 0xdf; if ((gPlayerState.field_0xa0[0] == 0x04) && ((gPlayerState.flags & 0x400000) == 0)) { @@ -122,7 +122,7 @@ ASM_FUNC("asm/non_matching/itemSword/sub_08075900.inc", void sub_08075900(ItemBe void sub_080759B8(ItemBehavior* this, u32 arg1) { if ((gPlayerState.flags & 0x80) == 0) { - gPlayerEntity.field_0x40 = 0; + gPlayerEntity.hurtType = 0; } gPlayerState.flags &= 0xf7ffffff; gPlayerState.field_0x1a[1] = 0; diff --git a/src/main.c b/src/main.c index bff9997b..c69d07fa 100644 --- a/src/main.c +++ b/src/main.c @@ -118,7 +118,7 @@ static void sub_08055F70(void) { } DispReset(0); - sub_08016B34(); + EnableVBlankIntr(); } #define SOFT_RESET_KEYS (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON) diff --git a/src/npc/cat.c b/src/npc/cat.c index 30160f98..7a49b5ce 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -66,8 +66,8 @@ void sub_080677EC(Entity* this) { this->direction = 8; this->speed = 0x80; this->field_0x3c = 7; - this->field_0x40 = 0x48; - this->damageType = -0x58; + this->hurtType = 0x48; + this->hitType = -0x58; this->flags2 = 1; this->field_0x68.HALF.HI = 0xff; if (this->x.HALF.HI < gPlayerEntity.x.HALF.HI) { @@ -183,7 +183,7 @@ void sub_08067A0C(Entity* this) { } else { tmp = (this->frames.all & 7); if (tmp != 0) { - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->hitbox = gUnk_08111154[tmp - 1 + ((this->spriteSettings.b.flipX << 2))]; } else { sub_08067DDC(this); @@ -381,7 +381,7 @@ void sub_08067DCC(Entity* this, u32 param) { } void sub_08067DDC(Entity* this) { - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); this->bitfield = 0; this->iframes = 0; this->hitbox = &gUnk_08110EF0; diff --git a/src/npc/npc5.c b/src/npc/npc5.c index f90e709b..8cffdf49 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -134,11 +134,11 @@ void sub_08060AE0(Entity* this) { this->myHeap = (u32*)heapObj; heapObj->unk_0b = 0x20; this->action = 1; - this->flags |= 0x80; + COLLISION_ON(this); this->animationState &= 3; this->field_0x3c = 7; - this->field_0x40 = 0x48; - this->damageType = 0x49; + this->hurtType = 0x48; + this->hitType = 0x49; this->flags2 = 3; this->hitbox = &gUnk_080FD150; this->field_0x17 &= 0xfe; diff --git a/src/object/button.c b/src/object/button.c index 8bbd7bca..0a1c7fbb 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -15,8 +15,8 @@ void Button(Entity* this) { extern u32 sub_08081E3C(Entity*); void sub_08081AE0(Entity* this) { - this->flags &= 0x7F; - this->scriptedScene = 3; + COLLISION_OFF(this); + this->updateConditions = 3; this->y.HALF.HI++; if (this->cutsceneBeh.HWORD != 0) { this->collisionLayer = this->cutsceneBeh.HWORD; @@ -234,13 +234,13 @@ u32 sub_08081F00(u32* unk1, u32* unk2) { void sub_08081F24(Entity* this) { Entity* fx = CreateFx(this, FX_DASH, 0x40); if (fx) { - fx->scriptedScene = 3; + fx->updateConditions = 3; fx->x.HALF.HI += 7; fx->y.HALF.HI += 5; } fx = CreateFx(this, FX_DASH, 0x40); if (fx) { - fx->scriptedScene = 3; + fx->updateConditions = 3; fx->x.HALF.HI -= 7; fx->y.HALF.HI += 5; } diff --git a/src/object/heartContainer.c b/src/object/heartContainer.c index 1821a27b..71d109f4 100644 --- a/src/object/heartContainer.c +++ b/src/object/heartContainer.c @@ -31,7 +31,7 @@ static void sub_0808E6A0(Entity* this) { this->spriteSettings.b.draw = 0; this->hitbox = &gUnk_08121C58; this->collisionLayer = 3; - this->scriptedScene = 3; + this->updateConditions = 3; } static void sub_0808E6E4(Entity* this) { diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index 2e4f555a..f9ac58f6 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -50,7 +50,7 @@ void ItemOnGround(Entity* this) { switch (this->bitfield & 0x7F) { case 20: this->action = 3; - this->flags &= 0x7F; + COLLISION_OFF(this); this->spriteSettings.b.draw = 1; this->field_0x3c |= 0x10; this->attachedEntity = this->field_0x4c; @@ -93,22 +93,22 @@ void sub_08080F20(Entity* this) { this->spriteSettings.b.draw = 1; this->spritePriority.b1 = 3; this->spriteSettings.b.shadow = 0; - this->damageType = 7; + this->hitType = 7; this->field_0x3c = 0x47; - this->field_0x40 = 0x44; + this->hurtType = 0x44; this->currentHealth = 0xFF; this->hitbox = &gUnk_080FD1A8; - switch (this->type - 0x3F) { - case 0: - case 21: - case 22: - case 23: - case 24: - case 25: - case 29: - case 30: - case 31: - case 32: + switch (this->type) { + case 0x3f: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + case 0x58: + case 0x5c: + case 0x5d: + case 0x5e: + case 0x5f: this->flags2 = 0x17; break; default: @@ -165,7 +165,7 @@ void sub_080810FC(Entity* this) { } else { this->action = 2; this->subAction = 0; - this->flags |= 0x80; + COLLISION_ON(this); this->flags2 = 0x11; CopyPosition(&gPlayerEntity, this); } @@ -179,7 +179,7 @@ void sub_08081134(Entity* this) { void sub_08081150(Entity* this) { this->action = 2; - this->flags |= 0x80; + COLLISION_ON(this); this->height.HALF.HI = -0x80; this->spriteOrientation.flipY = 1; this->spriteRendering.b3 = 1; @@ -188,7 +188,7 @@ void sub_08081150(Entity* this) { void sub_08081188(Entity* this) { this->action = 2; - this->flags |= 0x80; + COLLISION_ON(this); if (this->collisionLayer == 2) { sub_08016A30(this); } @@ -220,7 +220,7 @@ void sub_080811EC(Entity* this) { sub_08003FC4(this, 0x2800); if (this->hVelocity <= 0) { this->action = 2; - this->flags |= 0x80; + COLLISION_ON(this); sub_080814A4(this); } } @@ -430,7 +430,7 @@ void sub_08081598(Entity* this) { sub_08081404(this, 1); } - this->flags &= 0x7F; + COLLISION_OFF(this); this->action = 4; this->actionDelay = 14; this->hVelocity = 0x20000; diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index a3f2541d..8262fa0a 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -20,10 +20,10 @@ void JarPortal(Entity* this) { } void sub_0808BE9C(Entity* this) { - this->flags |= 0x80; - this->damageType = 1; + COLLISION_ON(this); + this->hitType = 1; this->field_0x3c = 0x47; - this->field_0x40 = 0x44; + this->hurtType = 0x44; this->flags2 = 0x80; this->field_0x68.HALF.LO = 0; if (CheckLocalFlag(this->type)) { diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index cbeafdd7..1b8d651a 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -26,11 +26,11 @@ void sub_0809EA1C(Entity* this) { void sub_0809EA34(Entity* this) { this->action = 1; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->frameIndex = 0; this->field_0x3c = 7; - this->field_0x40 = 0x48; - this->damageType = 0x28; + this->hurtType = 0x48; + this->hitType = 0x28; this->flags2 = 10; this->hitbox = &gUnk_080FD150; sub_0809EAD8(this); @@ -98,11 +98,11 @@ void sub_0809EB68(Entity* this) { void sub_0809EB80(Entity* this) { this->action = 1; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->frameIndex = 3; this->field_0x3c = 7; - this->field_0x40 = 0x48; - this->damageType = 0x28; + this->hurtType = 0x48; + this->hitType = 0x28; this->flags2 = 10; this->hitbox = &gUnk_080FD150; sub_0809EAD8(this); diff --git a/src/object/minecart.c b/src/object/minecart.c index 01d7d1ac..a1c79b41 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -45,10 +45,10 @@ void sub_080916EC(Entity* this) { this->type2 = unk->field_0x6; this->action = 1; this->hitbox = &gUnk_080FD310; - this->flags |= 0x80; - this->damageType = 1; + COLLISION_ON(this); + this->hitType = 1; this->field_0x3c = 0x47; - this->field_0x40 = 0x44; + this->hurtType = 0x44; this->flags2 = 0x80; this->direction = DirectionFromAnimationState(this->animationState); this->speed = 0x700; @@ -105,12 +105,12 @@ void sub_080918A4(Entity* this) { gPlayerState.flags = (gPlayerState.flags ^ 0x4000000) | 0x1000; this->action++; this->field_0xf = 1; - this->flags |= 0x20; - this->damageType = 0x97; + this->flags |= ENT_20; + this->hitType = 0x97; this->field_0x3c = (gPlayerEntity.field_0x3c + 1) | 0x20; this->flags2 = gPlayerEntity.flags2; - this->field_0x40 = 0x18; - this->field_0x44 = 8; + this->hurtType = 0x18; + this->damage = 8; sub_0801766C(this); sub_0807BA8C(COORD_TO_TILE(this), this->collisionLayer); SoundReq(SFX_137); @@ -134,7 +134,7 @@ void sub_080919AC(Entity* this) { } if ((gPlayerEntity.frames.all & 0xf) == 0) { - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); CopyPosition(this, &gPlayerEntity); if ((gPlayerEntity.frames.all & 0xf0) == 0x10) { this->spriteOffsetY = 1; @@ -142,7 +142,7 @@ void sub_080919AC(Entity* this) { this->spriteOffsetY = 0; } } else { - this->flags = this->flags | 0x80; + COLLISION_ON(this); gPlayerEntity.speed = 0; sub_0806F69C(this); CopyPosition(this, &gPlayerEntity); @@ -166,10 +166,10 @@ void sub_080919AC(Entity* this) { } else { switch (uVar3) { case 0x64: - this->flags = this->flags & 0xdf; - this->damageType = 1; + this->flags &= ~ENT_20; + this->hitType = 1; this->field_0x3c = 0x47; - this->field_0x40 = 0x44; + this->hurtType = 0x44; this->flags2 = 0x80; this->action = 6; sub_08017744(this); diff --git a/src/object/mineralWaterSource.c b/src/object/mineralWaterSource.c index 50212f44..1ffcd585 100644 --- a/src/object/mineralWaterSource.c +++ b/src/object/mineralWaterSource.c @@ -28,15 +28,15 @@ void MineralWaterSource_Init(Entity* this) { unknownParameters = &MineralWaterSourceParameters[this->type]; this->type2 = unknownParameters->field_0x00; - this->field_0x40 = unknownParameters->field_0x03; + this->hurtType = unknownParameters->field_0x03; this->hitbox->width = unknownParameters->field_0x01; this->hitbox->height = unknownParameters->field_0x02; - this->flags |= 0x80; + COLLISION_ON(this); this->field_0x3c = 7; - this->damageType = 145; + this->hitType = 145; this->flags2 = 2; this->action = 1; diff --git a/src/object/object49.c b/src/object/object49.c index 0be4c477..02aac844 100644 --- a/src/object/object49.c +++ b/src/object/object49.c @@ -188,14 +188,14 @@ void sub_0808F3DC(Entity* this) { return; } } else { - this->damageType = this->attachedEntity->damageType; - this->attachedEntity->damageType = 0x7E; + this->hitType = this->attachedEntity->hitType; + this->attachedEntity->hitType = 0x7E; } ResolveEntityOnTop(this->attachedEntity, this); } else { if (*(u32*)&this->parent->field_0x74 == 0) { if (this->type == 8) { - this->attachedEntity->damageType = this->damageType; + this->attachedEntity->hitType = this->hitType; } DeleteThisEntity(); } diff --git a/src/object/object9E.c b/src/object/object9E.c index 771f7e80..ea6b1787 100644 --- a/src/object/object9E.c +++ b/src/object/object9E.c @@ -16,13 +16,13 @@ void Object9E(Entity* this) { this->action = 1; this->spritePriority.b0 = 6; if (this->type == 0) { - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->frameIndex = 1; layer = &this->collisionLayer; *layer = 1; this->field_0x3c = 7; - this->field_0x40 = 0x48; - this->damageType = 0x7a; + this->hurtType = 0x48; + this->hitType = 0x7a; this->flags2 = 1; this->hitbox = &gUnk_080FD168; tilePos = COORD_TO_TILE(this); diff --git a/src/object/pot.c b/src/object/pot.c index 79d0a38f..ce0fa0bf 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -37,10 +37,10 @@ void sub_0808222C(Entity* this) { this->speed = 0x80; this->y.HALF.HI += 3; this->field_0x16 = 0; - this->flags |= 0x80; + COLLISION_ON(this); this->currentHealth = 1; this->field_0x3c = 7; - this->damageType = 0x6E; + this->hitType = 0x6E; this->flags2 = 0x84; this->field_0x1c = 0x12; if (this->collisionLayer == 0) { @@ -71,7 +71,7 @@ void sub_08082310(Entity* this) { this->spriteOffsetY = 0; this->spriteSettings.b.shadow = 1; this->spritePriority.b1 = 3; - this->flags &= 0x7F; + COLLISION_OFF(this); sub_08082824(this); break; default: @@ -118,10 +118,10 @@ void sub_080824F8(Entity* this) { } void sub_08082510(Entity* this) { - this->flags |= 0x80; + COLLISION_ON(this); this->hitbox = &gUnk_080FD340; this->field_0x3c = 7; - this->damageType = 1; + this->hitType = 1; this->flags2 = gPlayerEntity.flags2; this->spriteOffsetY = 0; SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); diff --git a/src/object/warpPoint.c b/src/object/warpPoint.c index 69ed1fdc..fc6239d1 100644 --- a/src/object/warpPoint.c +++ b/src/object/warpPoint.c @@ -41,7 +41,7 @@ void sub_0808B474(Entity* this) { this->palette.b.b0 = tmp; this->spritePriority.b0 = 6; this->hitbox = &gUnk_080FD168; - this->scriptedScene = 3; + this->updateConditions = 3; InitializeAnimation(this, 0); if (CheckFlags(this->field_0x86.HWORD)) { sub_0808B830(this); diff --git a/src/player.c b/src/player.c index 0f68f9e3..ad3107fe 100644 --- a/src/player.c +++ b/src/player.c @@ -90,13 +90,13 @@ void PlayerInit(Entity* this) { gPlayerState.field_0x0[0] = 0xff; gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; - this->flags |= 0x80; + COLLISION_ON(this); this->spritePriority.b0 = 0xc; this->spritePriority.b1 = 1; this->spriteSettings.b.shadow = 1; this->field_0x16 = 0x20; this->flags2 = 8; - this->damageType = 0x79; + this->hitType = 0x79; this->hitbox = &gUnk_08114F88; this->spriteIndex = 1; #ifndef EU @@ -168,7 +168,7 @@ void sub_08070C3C(Entity* this) { gPlayerState.field_0x8 = 0x1b8; this->subAction++; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spritePriority.b1 = 0; ResetPlayer(); sub_0807A108(); @@ -197,7 +197,7 @@ void PlayerBounce(Entity* this) { } void sub_08070D38(Entity* this) { - this->flags &= ~0x80; + COLLISION_OFF(this); this->direction = ((this->animationState & 0xe) << 2) ^ 0x10; this->speed = 0x100; this->knockbackDuration = 0; @@ -246,7 +246,7 @@ NONMATCH("asm/non_matching/player/sub_08070DC4.inc", void sub_08070DC4(Entity* t return; } - this->flags |= 0x80; + COLLISION_ON(this); if ((gPlayerState.field_0x14 == 0) && sub_08008B22()) { gPlayerState.field_0x10[1] = 7; @@ -285,7 +285,7 @@ void sub_08070E9C(Entity* this) { } void sub_08070EDC(Entity* this) { - this->scriptedScene = 2; + this->updateConditions = 2; if ((gMessage.doTextBox & 0x7f) != 0) this->subAction = 1; @@ -299,7 +299,7 @@ void sub_08070EDC(Entity* this) { void sub_08070f24(Entity* this) { UpdateAnimationSingleFrame(this); if ((gMessage.doTextBox & 0x7f) == 0) { - this->scriptedScene = this->scriptedScene2; + this->updateConditions = this->updateConditions2; sub_080791D0(); } } @@ -309,7 +309,7 @@ void PlayerItemGet(Entity* this) { u8* temp; // todo: retype gPlayerState.field_0xa8 = 0x15; - this->flags &= ~(0x80); + COLLISION_OFF(this); gUnk_0811BA7C[this->subAction](this); child = this->attachedEntity; @@ -486,7 +486,7 @@ void sub_08071208(Entity* this) { void PlayerDrown(Entity* this) { gPlayerState.field_0xa8 = 0x16; gPlayerState.flags |= 4; - this->flags &= ~0x80; + COLLISION_OFF(this); gUnk_0811BA94[this->subAction](this); } @@ -568,7 +568,7 @@ void PortalJumpOnUpdate(Entity* this) { u16 x; u16 y; - this->flags &= ~0x80; + COLLISION_OFF(this); this->knockbackDuration = 0; x = gArea.curPortalX; @@ -735,7 +735,7 @@ void PlayerTalkEzlo(Entity* this) { sub_08071A6C(); } else { gPlayerState.field_0xa8 = 0x13; - this->flags &= ~0x80; + COLLISION_OFF(this); gUnk_0811BAD4[this->subAction](this); } } @@ -745,7 +745,7 @@ void sub_080718A0(Entity* this) { gUnk_03000B80.filler[0x63] = 0; this->iframes = 0; gUnk_03003DC0.unk0 = 6; - this->scriptedScene = 6; + this->updateConditions = 6; if (gPlayerState.flags & 0x80) { this->subAction = 2; @@ -838,7 +838,7 @@ void sub_08071A4C(Entity* this) { void sub_08071A6C(void) { gUnk_03003DC0.unk0 = 0; - gPlayerEntity.scriptedScene = gPlayerEntity.scriptedScene2; + gPlayerEntity.updateConditions = gPlayerEntity.updateConditions2; } void PlayerPush(Entity* this) { @@ -901,7 +901,7 @@ void sub_08071B60(Entity* this) { extern void (*const gUnk_0811BB2C[])(Entity*); void PlayerMinishDie(Entity* this) { - this->flags &= ~0x80; + COLLISION_OFF(this); gUnk_0811BB2C[this->subAction](this); gPlayerState.field_0xa8 = 0x12; } @@ -1101,7 +1101,7 @@ void PlayerFrozen(Entity* this) { } void sub_08071F50(Entity* this) { - this->flags &= ~0x80; + COLLISION_OFF(this); this->actionDelay = 0x78; this->subAction++; gPlayerState.field_0x8 = 0x294; @@ -1141,7 +1141,7 @@ void sub_08071F80(Entity* this) { void sub_08072008(Entity* this) { this->iframes = 160; this->knockbackDuration = 0; - this->flags |= 0x80; + COLLISION_ON(this); this->spriteOffsetX = 0; gPlayerState.flags &= ~(0x800 | 0x1); CreateFx(this, FX_ICE, 0); @@ -1156,7 +1156,7 @@ void sub_0807204C(Entity* this) { void sub_08072064(Entity* this) { this->subAction = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); this->actionDelay = gPlayerState.field_0x3a; gPlayerState.field_0x8 = gPlayerState.field_0x38 | (gPlayerState.field_0x39 << 8); ResetPlayer(); @@ -1173,7 +1173,7 @@ void sub_08072098(Entity* this) { return; if (this->currentHealth != 0) - this->flags |= 0x80; + COLLISION_ON(this); sub_080791BC(); } @@ -1190,7 +1190,7 @@ void sub_08072100(Entity* this) { this->hitbox = &gUnk_08114F88; this->actionDelay = gPlayerState.field_0x38; this->subAction = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); if (gPlayerState.field_0x39) this->direction = 0xff; @@ -1218,7 +1218,7 @@ void sub_08072168(Entity* this) { sub_08019840(); if (--this->actionDelay == 0xff) { this->knockbackDuration = 0; - this->flags |= 0x80; + COLLISION_ON(this); UpdateSpriteForCollisionLayer(this); sub_080791BC(); } @@ -1272,7 +1272,7 @@ void PlayerLava(Entity* this) { void sub_080722DC(Entity* this) { Entity* ent; - this->flags &= ~0x80; + COLLISION_OFF(this); if (!(gPlayerState.flags & 0x80)) { this->subAction = 1; this->hVelocity = 0x28000; @@ -1368,7 +1368,7 @@ void sub_080724DC(Entity* this) { sub_0807AE20(this); } if (gRoomControls.unk2 == 0) { - this->scriptedScene = this->scriptedScene2; + this->updateConditions = this->updateConditions2; sub_080728AC(this); } else if (gPlayerState.field_0x1c == 0) { UpdateAnimationSingleFrame(this); @@ -1394,7 +1394,7 @@ void sub_0807258C(Entity* this) { if (sub_080797C4() != 0) { gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; - this->scriptedScene = this->scriptedScene2; + this->updateConditions = this->updateConditions2; sub_080728AC(this); } else { UpdateAnimationSingleFrame(this); @@ -1402,7 +1402,7 @@ void sub_0807258C(Entity* this) { } else { gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; - this->scriptedScene = this->scriptedScene2; + this->updateConditions = this->updateConditions2; sub_080728AC(this); } } @@ -1433,7 +1433,7 @@ void sub_08072650(Entity* this) { this->spritePriority.b1 = 0; gPlayerState.field_0x8 = 0xc08; } else { - *(u8*)&this->field_0x40 = 0x1e; + *(u8*)&this->hurtType = 0x1e; if (temp & 8) { gPlayerState.field_0x8 = 0x438; } else { @@ -1509,7 +1509,7 @@ void sub_080726F4(Entity* this) { sub_08079E08(); } if (((this->frames.all & 0x10) == 0) && ((gPlayerState.flags & 0x80) == 0)) { - *(u8*)&this->field_0x40 = 0; + *(u8*)&this->hurtType = 0; } if ((this->frames.all & 0x40) != 0) { sub_08077698(this); @@ -1539,7 +1539,7 @@ void sub_080728AC(Entity* this) { if (!(gRoomControls.unk6 & 4)) { if ((gPlayerState.flags & 0x40)) - this->flags |= 0x80; + COLLISION_ON(this); sub_080791D0(); } if (!(gPlayerState.flags & 2)) { @@ -1559,7 +1559,7 @@ void sub_08072970(Entity* this) { this->subAction = 1; this->x.HALF.HI = (this->x.HALF.HI & ~0xF) | 8; this->y.HALF.HI = (this->y.HALF.HI & ~0XF) | 10; - this->flags &= ~0x80; + COLLISION_OFF(this); this->spritePriority.b0 = 7; this->spritePriority.b1 = 0; this->actionDelay = 0; @@ -1604,7 +1604,7 @@ void sub_08072ACC(Entity* this) { if (gPlayerState.field_0xd == 0xff) { this->field_0xf = 0; } else if (this->field_0xf > 7) { - this->flags |= 0x80; + COLLISION_ON(this); this->direction = gPlayerState.field_0xd; this->hVelocity = 0x1a000; this->speed = 0x78; @@ -1633,7 +1633,7 @@ void sub_08072B5C(Entity* this) { this->direction = this->animationState << 2; temp = sub_0807A2F8(1); if (!temp) { - this->flags |= 0x80; + COLLISION_ON(this); this->spritePriority.b0 = 4; this->speed = 0x40; this->hVelocity = 0x39000; @@ -1685,7 +1685,7 @@ void sub_08072C9C(Entity* this) { void sub_08072CC0(Entity* this) { this->subAction = 1; - this->flags &= ~0x80; + COLLISION_OFF(this); this->field_0xf = (gPlayerState.field_0x3a >> 2) + 1; this->direction = gPlayerState.field_0x39; this->speed = 0x400; @@ -1773,7 +1773,7 @@ NONMATCH("asm/non_matching/player/sub_08072D54.inc", void sub_08072D54(Entity* t this->actionDelay = bVar1; if (!sub_08003FC4(this, 0x2000)) { - this->flags |= 0x80; + COLLISION_ON(this); if (this->collisionLayer == 1) { sub_0800455E(this); } else { diff --git a/src/playerItem/playerItem10.c b/src/playerItem/playerItem10.c index 9ffc8e2c..bb4e5202 100644 --- a/src/playerItem/playerItem10.c +++ b/src/playerItem/playerItem10.c @@ -86,7 +86,7 @@ void sub_080ACC04(Entity* this) { this->flags2 = gPlayerEntity.flags2; this->direction = this->animationState << 2; this->speed = 0x200; - this->flags |= 0xa0; + this->flags |= ENT_COLLIDE | ENT_20; this->field_0x3c = 2; this->hitbox = (Hitbox*)gUnk_0812AAD8[this->type]; this->field_0x70.WORD = 0x10; diff --git a/src/playerItem/playerItem11.c b/src/playerItem/playerItem11.c index a2512e11..046a5ab0 100644 --- a/src/playerItem/playerItem11.c +++ b/src/playerItem/playerItem11.c @@ -33,16 +33,16 @@ void sub_08018CBC(Entity* this) { uVar2 = this->animationState = gPlayerEntity.animationState & 0xe; this->direction = (u8)(uVar2 << 2); this->speed = 0x400; - this->damageType = 0x96; + this->hitType = 0x96; this->field_0x3c = (gPlayerEntity.field_0x3c + 1) | 0x80; this->flags2 = gPlayerEntity.flags2; pEVar3 = this->attachedEntity; if (pEVar3 != NULL) { this->action = 1; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); this->actionDelay = 0x56; - this->field_0x40 = 0x1c; - this->field_0x44 = 6; + this->hurtType = 0x1c; + this->damage = 6; this->hitbox = &gUnk_080B3E18; this->attachedEntity->spriteOffsetX = 0; this->attachedEntity->spriteSettings.b.draw = 0; @@ -57,8 +57,8 @@ void sub_08018CBC(Entity* this) { this->spriteVramOffset = 0; this->type = gPlayerState.field_0x1d[0] - 1; this->actionDelay = gUnk_080B3DE0[this->type * 2]; - this->field_0x44 = gUnk_080B3DE0[this->type * 2 + 1]; - this->field_0x40 = 0x1b; + this->damage = gUnk_080B3DE0[this->type * 2 + 1]; + this->hurtType = 0x1b; this->hitbox = gUnk_080B3DE8[this->type]; (u32*)gPlayerEntity.field_0x70.WORD = this; sub_08078CD0(&gPlayerEntity); @@ -83,7 +83,7 @@ void sub_08018DE8(Entity* this) { break; case 5: this->attachedEntity->subAction = 4; - this->flags = this->flags | 0x80; + COLLISION_ON(this); this->action = 2; this->spritePriority.b0 = 2; this->attachedEntity->spriteSettings.b.draw = 1; diff --git a/src/playerItem/playerItem12.c b/src/playerItem/playerItem12.c index f75a8e4a..f29eb37c 100644 --- a/src/playerItem/playerItem12.c +++ b/src/playerItem/playerItem12.c @@ -33,7 +33,7 @@ ASM_FUNC("asm/non_matching/playerItem12/sub_080703BC.inc", void sub_080703BC(Ent void sub_08070458(Entity* this) { this->action = 2; - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = 0; if (this->field_0x7c.WORD != 0) { SetTile(this->field_0x7c.WORD, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); diff --git a/src/playerItem/playerItemBow.c b/src/playerItem/playerItemBow.c index 7f6aaf22..6c2b8206 100644 --- a/src/playerItem/playerItemBow.c +++ b/src/playerItem/playerItemBow.c @@ -33,7 +33,7 @@ void sub_08019444(Entity* this) { } void sub_08019468(Entity* this) { - if (this->field_0x40 == 0x0e) { + if (this->hurtType == 0x0e) { CreateFx(this, FX_REFLECT5, 0); } } diff --git a/src/playerItem/playerItemC.c b/src/playerItem/playerItemC.c index 8298a66a..2c2ed212 100644 --- a/src/playerItem/playerItemC.c +++ b/src/playerItem/playerItemC.c @@ -55,6 +55,6 @@ END_NONMATCH ASM_FUNC("asm/non_matching/playerItemC/sub_0801B938.inc", void sub_0801B938(Entity* this)) void sub_0801B9F0(Entity* this) { - this->flags &= 0x7f; + COLLISION_OFF(this); sub_08017744(this); } diff --git a/src/playerItem/playerItemLantern.c b/src/playerItem/playerItemLantern.c index e2f0587f..6741823f 100644 --- a/src/playerItem/playerItemLantern.c +++ b/src/playerItem/playerItemLantern.c @@ -18,7 +18,7 @@ NONMATCH("asm/non_matching/playerItemLantern/sub_08054A60.inc", void sub_08054A6 this->actionDelay = 0x04; this->frameIndex = -1; // TODO regalloc and mov 6 too early - this->scriptedScene = (this->scriptedScene & 0xf0) | 6; + this->updateConditions = (this->updateConditions & 0xf0) | 6; this->field_0x3c = 7; this->flags2 = -0x80; this->animationState = gPlayerEntity.animationState & 0xe; diff --git a/src/projectile/arrowProjectile.c b/src/projectile/arrowProjectile.c index fc6d3305..eb9296a4 100644 --- a/src/projectile/arrowProjectile.c +++ b/src/projectile/arrowProjectile.c @@ -45,7 +45,7 @@ void sub_080A9334(Entity* this) { void ArrowProjectile_Init(Entity* this) { this->action = 1; this->spriteSettings.b.draw = 1; - this->flags &= 0x7f; + COLLISION_OFF(this); this->actionDelay = 0x6a; this->field_0xf = 0; this->hVelocity = 0xa00; @@ -62,7 +62,7 @@ void ArrowProjectile_Action1(Entity* this) { } if (parent->field_0xf != 0) { this->action = 2; - this->flags = this->flags | 0x80; + COLLISION_ON(this); parent->attachedEntity = NULL; SoundReq(SFX_FC); } @@ -71,7 +71,7 @@ void ArrowProjectile_Action1(Entity* this) { void ArrowProjectile_Action2(Entity* this) { if (this->collisions != 0) { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); this->actionDelay = 0x20; InitializeAnimation(this, this->animIndex + 2); EnqueueSFX(0x18a); @@ -104,7 +104,7 @@ void ArrowProjectile_Action4(Entity* this) { void sub_080A9488(Entity* this) { this->action = 4; - this->flags &= 0x7f; + COLLISION_OFF(this); this->actionDelay = 2; this->hVelocity = 0x18000; this->animationState = (this->knockbackDirection & 0x18) >> 3; diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index cfa5f3ed..29361923 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -57,7 +57,7 @@ void BoneProjectile_Action2(Entity* this) { sub_080AF090(this); if (sub_08003FC4(this, 0x1800) == 0) { this->action = 3; - this->flags = this->flags & 0x7f; + COLLISION_OFF(this); this->speed = 0xe0; this->hVelocity = 0xe000; } @@ -82,7 +82,7 @@ void BoneProjectile_Action4(Entity* this) { void sub_080A82D8(Entity* this) { this->action = 4; - this->flags &= 0x7f; + COLLISION_OFF(this); this->hVelocity = 0x10000; this->direction ^= 0x10; this->speed = 0x80; diff --git a/src/projectile/darkNutSwordSlash.c b/src/projectile/darkNutSwordSlash.c index 51123fc7..5875a9d6 100644 --- a/src/projectile/darkNutSwordSlash.c +++ b/src/projectile/darkNutSwordSlash.c @@ -2,7 +2,7 @@ #include "player.h" #include "coord.h" -extern const u8 DarkNutSwordSlash_DamageTypes[]; +extern const u8 DarkNutSwordSlash_hitTypes[]; extern void (*const DarkNutSwordSlash_UpdatesForType[])(Entity*); extern Hitbox const* const* const gUnk_081293E0[]; extern const Hitbox* const gUnk_081293F0[]; @@ -37,7 +37,7 @@ void DarkNutSwordSlash(Entity* this) { } void DarkNutSwordSlash_Init(Entity* this) { - this->damageType = DarkNutSwordSlash_DamageTypes[this->parent->type + this->type * 4]; + this->hitType = DarkNutSwordSlash_hitTypes[this->parent->type + this->type * 4]; } void DarkNutSwordSlash_OnTick(Entity* this) { @@ -67,7 +67,7 @@ void DarkNutSwordSlash_UpdateType1(Entity* this) { this->hitbox = (Hitbox*)gUnk_08129420[parent->animationState]; } -const u8 DarkNutSwordSlash_DamageTypes[] = { +const u8 DarkNutSwordSlash_hitTypes[] = { 76, 76, 78, 77, 83, 83, 83, 83, 79, 79, 76, 80, 84, 84, 84, 85, 79, 79, 76, 80, }; void (*const DarkNutSwordSlash_UpdatesForType[])(Entity*) = { diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c index 40c51e69..63716065 100644 --- a/src/projectile/dekuSeedProjectile.c +++ b/src/projectile/dekuSeedProjectile.c @@ -25,7 +25,7 @@ void DekuSeedProjectile_OnTick(Entity* this) { void sub_080A8470(Entity* this) { if (this->bitfield == 0x80) { - if (this->damageType == 0x68) { + if (this->hitType == 0x68) { EnqueueSFX(SFX_86); } DeleteEntity(this); @@ -46,7 +46,7 @@ void DekuSeedProjectile_Init(Entity* this) { this->field_0xf = 0; this->height.HALF.HI -= 4; if (CheckGlobalFlag(TABIDACHI) == 0) { - this->damageType = 0x68; + this->hitType = 0x68; } EnqueueSFX(SFX_18D); InitializeAnimation(this, 0x18); @@ -75,12 +75,12 @@ void DekuSeedProjectile_Action1(Entity* this) { if ((parent->next != NULL) && (sub_080177A0(this, parent) != 0)) { this->iframes = 0x10; this->knockbackDirection = -this->direction; - this->bitfield = -0x80; + this->bitfield = 0x80; this->knockbackDuration = 0xc; this->field_0x46 = 0; parent->iframes = 0x10; parent->knockbackDirection = this->direction; - parent->bitfield = -0x3e; + parent->bitfield = 0xc2; parent->knockbackDuration = 0xc; parent->field_0x46 = 0; } @@ -95,7 +95,7 @@ void DekuSeedProjectile_Action2(Entity* this) { } if (--this->actionDelay == 0) { this->action = 1; - this->flags |= 0x80; + COLLISION_ON(this); } } else { sub_0800417E(this, (u32)this->collisions); @@ -120,19 +120,19 @@ void DekuSeedProjectile_Action4(Entity* this) { DeleteThisEntity(); return; case 1: - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = 0x120; break; } - if ((this->flags & 0x80) == 0) { + if ((this->flags & ENT_COLLIDE) == 0) { this->spriteSettings.b.draw ^= 1; } } void sub_080A8680(Entity* this) { this->action = 2; - this->flags &= 0x7f; + COLLISION_OFF(this); this->actionDelay = 3; this->field_0xf = 1; EnqueueSFX(SFX_ITEM_SHIELD_BOUNCE); @@ -140,7 +140,7 @@ void sub_080A8680(Entity* this) { void sub_080A86A0(Entity* this) { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = 0; EnqueueSFX(SFX_18E); } diff --git a/src/projectile/fireProjectile.c b/src/projectile/fireProjectile.c index 0e32bede..4419b527 100644 --- a/src/projectile/fireProjectile.c +++ b/src/projectile/fireProjectile.c @@ -61,7 +61,7 @@ void FireProjectile_Action2(Entity* this) { } } else { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = 0; } } diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index d48820b0..957667ea 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -25,7 +25,7 @@ void GleerokProjectile(Entity* this) { void GleerokProjectile_OnTick(Entity* this) { if (((this->type != 3) && ((this->bitfield & 0x80) != 0)) && ((this->bitfield & 0x7f) != 0x1e)) { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); InitializeAnimation(this, 0x53); } GleerokProjectile_Actions[this->action](this); @@ -118,7 +118,7 @@ void GleerokProjectile_Action2(Entity* this) { GetNextFrame(this); if (this->type == 2) { if (--this->actionDelay == 0xff) { - this->flags &= 0x7f; + COLLISION_OFF(this); this->action = 3; InitializeAnimation(this, 0x55); } else { @@ -128,7 +128,7 @@ void GleerokProjectile_Action2(Entity* this) { } else { if ((this->frames.all & 0x80) != 0) { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); InitializeAnimation(this, 0x53); } } diff --git a/src/projectile/gyorgMaleEnergyProjectile.c b/src/projectile/gyorgMaleEnergyProjectile.c index 56ff4307..33b34439 100644 --- a/src/projectile/gyorgMaleEnergyProjectile.c +++ b/src/projectile/gyorgMaleEnergyProjectile.c @@ -43,7 +43,7 @@ void GyorgMaleEnergyProjectile_Action1(Entity* this) { GetNextFrame(this); if (--this->actionDelay == 0) { this->action = 2; - this->flags |= 0x80; + COLLISION_ON(this); this->direction = GetFacingDirection(this, &gPlayerEntity); SoundReq(SFX_12E); } @@ -57,7 +57,7 @@ void GyorgMaleEnergyProjectile_Action2(Entity* this) { } if (--this->actionDelay == 0) { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = this->speed >> 1; InitializeAnimation(this, 1); } diff --git a/src/projectile/gyorgTail.c b/src/projectile/gyorgTail.c index d75a8123..acf81cc7 100644 --- a/src/projectile/gyorgTail.c +++ b/src/projectile/gyorgTail.c @@ -40,9 +40,9 @@ void GyorgTail(Entity* this) { this->spritePriority.b0 = parent->spritePriority.b0 - 2; if ((parent->spriteRendering.b3 == 3) && (parent->field_0x7c.BYTES.byte0 == 0)) { - this->flags &= 0x7f; + COLLISION_OFF(this); } else { - this->flags |= 0x80; + COLLISION_ON(this); } } } @@ -68,17 +68,17 @@ void sub_080AC480(Entity* this) { if (this->actionDelay != 0) { if (this->parent->currentHealth == 0) { this->action = 1; - this->damageType = 0x1d; + this->hitType = 0x1d; } else { if (--this->actionDelay == 0) { - this->damageType = 0x1c; + this->hitType = 0x1c; SoundReq(SFX_116); } } } else { if (--this->field_0xf == 0) { this->action = 1; - this->damageType = 0x1d; + this->hitType = 0x1d; } this->field_0x7c.HALF_U.LO += ((s16)this->field_0x7a.HWORD >= 1) ? 0x300 : -0x300; this->direction = this->field_0x7c.HALF.LO >> 8; diff --git a/src/projectile/iceProjectile.c b/src/projectile/iceProjectile.c index 0cd93e21..96e83a42 100644 --- a/src/projectile/iceProjectile.c +++ b/src/projectile/iceProjectile.c @@ -63,7 +63,7 @@ void IceProjectile_Action2(Entity* this) { } } else { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = 0; } } diff --git a/src/projectile/lakituCloudProjectile.c b/src/projectile/lakituCloudProjectile.c index 25599826..1971177d 100644 --- a/src/projectile/lakituCloudProjectile.c +++ b/src/projectile/lakituCloudProjectile.c @@ -42,7 +42,7 @@ void LakituCloudProjectile_SubAction1(Entity* this) { void LakituCloudProjectile_SubAction2(Entity* this) { if (sub_0806F3E4(this) != 0) { - if (this->damageType == 0xa6) { + if (this->hitType == 0xa6) { ModHealth(-2); sub_0800449C(&gPlayerEntity, 0x7a); sub_08079D84(); diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index 1bcfd7cf..1095b9a4 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -31,8 +31,8 @@ void MandiblesProjectile(Entity* this) { if (entity == NULL) { entity = this->parent; } - if ((entity->field_0x43 == 0) && ((this->flags & 0x80) == 0)) { - this->flags |= 0x80; + if ((entity->field_0x43 == 0) && ((this->flags & ENT_COLLIDE) == 0)) { + COLLISION_ON(this); } MandiblesProjectile_Functions[GetNextFunction(this)](this); } @@ -223,12 +223,12 @@ void sub_080AA1D8(Entity* this) { PositionRelative(parent, this, tmp[0] << 0x10, tmp[1] << 0x10); } if (parent->field_0x43 != 0) { - if ((this->flags & 0x80) != 0) { - this->flags &= 0x7f; + if ((this->flags & ENT_COLLIDE) != 0) { + COLLISION_OFF(this); } } else { - if ((this->flags & 0x80) == 0) { - this->flags |= 0x80; + if ((this->flags & ENT_COLLIDE) == 0) { + COLLISION_ON(this); } } } diff --git a/src/projectile/mazaalEnergyBeam.c b/src/projectile/mazaalEnergyBeam.c index 4fe557b0..20b73213 100644 --- a/src/projectile/mazaalEnergyBeam.c +++ b/src/projectile/mazaalEnergyBeam.c @@ -22,7 +22,7 @@ void MazaalEnergyBeam_Action1(Entity* this) { if (--this->actionDelay == 0) { this->action = 2; - this->flags &= 0x7f; + COLLISION_OFF(this); this->spritePriority.b0 = 7; this->y.HALF.HI += 6; InitializeAnimation(this, 1); diff --git a/src/projectile/moblinSpear.c b/src/projectile/moblinSpear.c index c24e3480..e4870a1f 100644 --- a/src/projectile/moblinSpear.c +++ b/src/projectile/moblinSpear.c @@ -73,12 +73,12 @@ NONMATCH("asm/non_matching/moblinSpear/MoblinSpear_Action1.inc", void MoblinSpea this->hitbox->width = a->width; this->hitbox->height = a->height; if (parent->field_0x43 != 0) { - if ((this->flags & 0x80) != 0) { - this->flags &= 0x7f; + if ((this->flags & ENT_COLLIDE) != 0) { + COLLISION_OFF(this); } } else { - if ((this->flags & 0x80) == 0) { - this->flags |= 0x80; + if ((this->flags & ENT_COLLIDE) == 0) { + COLLISION_ON(this); } } } diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 5b1f8e44..63bd13ae 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -89,7 +89,7 @@ void OctorokBossProjectile_Action1(Entity* this) { this->speed = 0x400; this->type2 = 1; this->actionDelay = 0; - this->flags &= 0x7f; + COLLISION_OFF(this); } if (sub_0806FC80(this, this->parent, 0x40) != 0) { if (this->type2 == 0) { diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c index 72d34a73..0f02c6fe 100644 --- a/src/projectile/rockProjectile.c +++ b/src/projectile/rockProjectile.c @@ -69,7 +69,7 @@ void RockProjectile_Action3(Entity* this) { DeleteEntity(this); return; case 1: - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = 0x120; if (sub_0800442E(this) != 0) { return; @@ -77,14 +77,14 @@ void RockProjectile_Action3(Entity* this) { break; } - if ((this->flags & 0x80) == 0) { + if ((this->flags & ENT_COLLIDE) == 0) { this->spriteSettings.b.draw ^= 1; } } void sub_080A8178(Entity* this) { this->action = 2; - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = 0x40; this->hVelocity = 0x14000; } diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c index 68d6e868..d3ec343a 100644 --- a/src/projectile/spiderWeb.c +++ b/src/projectile/spiderWeb.c @@ -37,7 +37,7 @@ void sub_080AA6C0(Entity* this) { if (this->bitfield == 0x87) { this->action = 3; this->actionDelay = 0x5a; - this->flags &= 0x7f; + COLLISION_OFF(this); InitAnimationForceUpdate(this, this->type + 0x10); object = CreateObject(OBJECT_2A, 3, 0); if (object != NULL) { diff --git a/src/projectile/stalfosProjectile.c b/src/projectile/stalfosProjectile.c index fb75691e..39c58075 100644 --- a/src/projectile/stalfosProjectile.c +++ b/src/projectile/stalfosProjectile.c @@ -32,7 +32,7 @@ void StalfosProjectile_OnTick(Entity* this) { void sub_080A9A34(Entity* this) { if (this->bitfield == 0x9d) { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); this->hVelocity = 0x2a000; this->spritePriority.b1 = 1; } @@ -59,7 +59,7 @@ void StalfosProjectile_SubAction2(Entity* this) { } void StalfosProjectile_SubAction3(Entity* this) { - this->flags &= 0x7f; + COLLISION_OFF(this); } void StalfosProjectile_SubAction4(Entity* this) { @@ -73,7 +73,7 @@ void StalfosProjectile_Init(Entity* this) { switch (this->type2) { case 1: this->action = 2; - this->flags |= 0x80; + COLLISION_ON(this); break; case 2: this->action = 3; diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index dc9c97c3..4568d0bc 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -31,7 +31,7 @@ void sub_080AAC44(Entity* this) { if (this->type2 == 0) { if ((this->bitfield & 0x3f) == 0) { this->action = 2; - this->flags &= 0x7f; + COLLISION_OFF(this); if (this->type == 0) { ResolveEntityOnTop(&gPlayerEntity, this); } else { @@ -83,7 +83,7 @@ void V1DarkMagicProjectile_Init(Entity* this) { this->action = 1; } else { this->action = 3; - this->damageType = 0x2c; + this->hitType = 0x2c; ResolveEntityOnTop(this->parent, this); } if (this->type == 0) { @@ -107,7 +107,7 @@ void V1DarkMagicProjectile_Init(Entity* this) { } } else { ResolveEntityOnTop(this->parent, this); - this->flags &= 0x7f; + COLLISION_OFF(this); CopyPosition(this->parent, this); } InitializeAnimation(this, this->type); @@ -154,12 +154,12 @@ void V1DarkMagicProjectile_Action3(Entity* this) { } #ifndef EU if (this->parent->action == 2) { - if ((this->flags & 0x80) != 0) { - this->flags &= 0x7f; + if ((this->flags & ENT_COLLIDE) != 0) { + COLLISION_OFF(this); } } else { - if ((this->flags & 0x80) == 0) { - this->flags |= 0x80; + if ((this->flags & ENT_COLLIDE) == 0) { + COLLISION_ON(this); } } #endif diff --git a/src/projectile/v1EyeLaser.c b/src/projectile/v1EyeLaser.c index 2af3ae08..38be21bc 100644 --- a/src/projectile/v1EyeLaser.c +++ b/src/projectile/v1EyeLaser.c @@ -20,7 +20,7 @@ void V1EyeLaser_Init(Entity* this) { *(u32*)&this->field_0x74 = this->parent->x.WORD; if (this->type == 0) { this->action = 1; - this->flags &= 0x7f; + COLLISION_OFF(this); this->hitbox = (Hitbox*)&gUnk_0812A614; InitializeAnimation(this, 0); } else { diff --git a/src/projectile/v1FireProjectile.c b/src/projectile/v1FireProjectile.c index 00dff22b..c627ee36 100644 --- a/src/projectile/v1FireProjectile.c +++ b/src/projectile/v1FireProjectile.c @@ -26,7 +26,7 @@ void V1FireProjectile_OnTick(Entity* this) { void sub_080AB2DC(Entity* this) { if ((this->bitfield & 0x80) != 0) { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); InitializeAnimation(this, 0x53); if ((this->bitfield & 0x7f) == 0) { ModHealth(-4); @@ -92,7 +92,7 @@ void V1FireProjectile_Action2(Entity* this) { GetNextFrame(this); if ((this->frames.all & 0x80) != 0) { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); InitializeAnimation(this, 0x53); } } diff --git a/src/projectile/windProjectile.c b/src/projectile/windProjectile.c index 92308f75..d607486a 100644 --- a/src/projectile/windProjectile.c +++ b/src/projectile/windProjectile.c @@ -67,7 +67,7 @@ void WindProjectile_Action2(Entity* this) { } } else { this->action = 3; - this->flags &= 0x7f; + COLLISION_OFF(this); this->speed = 0; } } diff --git a/src/script.c b/src/script.c index e38dee61..c38343ae 100644 --- a/src/script.c +++ b/src/script.c @@ -347,14 +347,14 @@ ScriptExecutionContext* StartCutscene(Entity* entity, u16* script) { } void InitScriptForEntity(Entity* entity, ScriptExecutionContext* context, u16* script) { - entity->flags = entity->flags | 2; + entity->flags |= ENT_SCRIPTED; *(ScriptExecutionContext**)&entity->cutsceneBeh = context; InitScriptExecutionContext(context, script); } void UnloadCutsceneData(Entity* entity) { - if ((entity->flags & 2)) { - entity->flags = entity->flags & 0xfd; + if (entity->flags & ENT_SCRIPTED) { + entity->flags &= ~ENT_SCRIPTED; DestroyScriptExecutionContext(*(ScriptExecutionContext**)&entity->cutsceneBeh); *(ScriptExecutionContext**)&entity->cutsceneBeh = NULL; }