From fb9f59fbbbd1ec2db3a3e757a3dab9a0e563520c Mon Sep 17 00:00:00 2001 From: theo3 Date: Sat, 30 Dec 2023 17:13:42 -0800 Subject: [PATCH 01/10] label BounceUpdate asm --- asm/macros/map.inc | 15 ++++ asm/src/code_080043E8.s | 46 ++++++------ asm/src/intr.s | 75 ++++++++++--------- asm/src/script.s | 2 +- asm/src/veneer.s | 64 ++++++++-------- include/asm.h | 14 +++- include/common.h | 4 +- include/enemy.h | 2 +- include/functions.h | 2 +- include/message.h | 10 +-- linker.ld | 2 +- src/collision.c | 8 +- src/common.c | 12 +-- src/debug.c | 2 +- src/enemy/acroBandits.c | 2 +- src/enemy/beetle.c | 2 +- src/enemy/bobomb.c | 2 +- src/enemy/bombPeahat.c | 4 +- src/enemy/chuchu.c | 2 +- src/enemy/cloudPiranha.c | 2 +- src/enemy/cuccoAggr.c | 2 +- src/enemy/fallingBoulder.c | 2 +- src/enemy/helmasaur.c | 2 +- src/enemy/peahat.c | 2 +- src/enemy/rollobite.c | 6 +- src/enemy/rope.c | 2 +- src/enemy/spikedBeetle.c | 6 +- src/enemy/tektite.c | 4 +- src/enemy/tektiteGolden.c | 4 +- src/enemy/vaatiTransfigured.c | 4 +- src/fileselect.c | 2 +- src/manager/enemyInteractionManager.c | 4 +- src/menu/figurineMenu.c | 4 +- src/menu/kinstoneMenu.c | 2 +- src/menu/pauseMenu.c | 4 +- src/message.c | 2 +- src/npc/phonograph.c | 8 +- src/npcUtils.c | 2 +- src/object/bird.c | 2 +- src/object/book.c | 2 +- src/object/crenelBeanSprout.c | 2 +- src/object/cutsceneMiscObject.c | 4 +- src/object/figurineDevice.c | 6 +- src/object/graveyardKey.c | 2 +- src/object/itemOnGround.c | 2 +- src/object/keyStealingTakkuri.c | 2 +- src/object/lilypadLarge.c | 4 +- src/object/mask.c | 2 +- src/object/minecart.c | 4 +- src/object/objectA2.c | 8 +- src/object/objectOnPillar.c | 2 +- src/object/playerClone.c | 2 +- src/object/pot.c | 20 ++--- src/object/rupee.c | 2 +- src/player.c | 6 +- src/playerItem/playerItemHeldObject.c | 2 +- .../playerItemPacciCaneProjectile.c | 2 +- src/playerUtils.c | 2 +- src/projectile/boneProjectile.c | 2 +- src/projectile/dekuSeedProjectile.c | 6 +- src/projectile/dirtBallProjectile.c | 2 +- src/projectile/rockProjectile.c | 6 +- 62 files changed, 230 insertions(+), 198 deletions(-) diff --git a/asm/macros/map.inc b/asm/macros/map.inc index c731112d..0a2ac5c5 100755 --- a/asm/macros/map.inc +++ b/asm/macros/map.inc @@ -1,6 +1,21 @@ .ifndef GUARD_ASM_MACROS_MAP_INC .set GUARD_ASM_MACROS_MAP_INC, 1 + .set TOP_TILEDATA, gMapTop+0x4 + .set TOP_COLLISIONDATA, gMapTop+0x2004 + .set TOP_TILEDATACLONE, gMapTop+0x3004 + .set TOP_METATILETYPES, gMapTop+0x5004 + .set TOP_UNKDATA2, gMapTop+0x6004 + .set TOP_METATILES, gMapTop+0x7004 + .set TOP_UNKDATA3, gMapTop+0xb004 + .set BOTTOM_TILEDATA, gMapBottom+0x4 + .set BOTTOM_COLLISIONDATA, gMapBottom+0x2004 + .set BOTTOM_TILEDATACLONE, gMapBottom+0x3004 + .set BOTTOM_METATILETYPES, gMapBottom+0x5004 + .set BOTTOM_UNKDATA2, gMapBottom+0x6004 + .set BOTTOM_METATILES, gMapBottom+0x7004 + .set BOTTOM_UNKDATA3, gMapBottom+0xb004 + .macro room_header map_x, map_y, pixel_width, pixel_height, tileset_id .2byte (\map_x) << 4 .2byte (\map_y) << 4 diff --git a/asm/src/code_080043E8.s b/asm/src/code_080043E8.s index 0216f977..98048228 100644 --- a/asm/src/code_080043E8.s +++ b/asm/src/code_080043E8.s @@ -67,7 +67,7 @@ sub_0800445C: @ 0x0800445C ldr r5, _080044D8 @ =gPlayerEntity adds r0, r4, #0 adds r1, r5, #0 - bl sub_08004484 + bl CalcCollisionStaticEntity cmp r0, #0 beq _08004482 ldrb r0, [r5, #0xc] @@ -80,8 +80,8 @@ _08004480: _08004482: pop {r4, r5, pc} - thumb_func_start sub_08004484 -sub_08004484: @ 0x08004484 + thumb_func_start CalcCollisionStaticEntity +CalcCollisionStaticEntity: @ 0x08004484 ldr r2, _080044DC @ =ram_sub_080B227C bx r2 @@ -138,30 +138,34 @@ _080044E0: .4byte gUnk_02024048 _080044E4: .4byte gUnk_02021F20 _080044E8: .4byte gPlayerEntity - thumb_func_start sub_080044EC -sub_080044EC: @ 0x080044EC + // BounceUpdate + // assumes initial velocity is set + // r0: entity* + // r1: acceleration + thumb_func_start BounceUpdate +BounceUpdate: @ 0x080044EC ldr r2, [r0, #0x34] ldr r3, [r0, #0x20] - subs r2, r2, r3 - bpl _080044FE - str r2, [r0, #0x34] - subs r3, r3, r1 - str r3, [r0, #0x20] - movs r0, #2 + subs r2, r3 + bpl grounded // if z is positive, entity is grounded + str r2, [r0, #0x34] // entity.z = entity.z - entity.zVelocity + subs r3, r1 + str r3, [r0, #0x20] // entity.zVelocity = entity.zVelocity - acceleration + movs r0, #2 // return 2 bx lr -_080044FE: +grounded: movs r2, #1 - str r2, [r0, #0x34] - subs r3, r3, r1 - rsbs r3, r3, #0 - lsrs r3, r3, #1 + str r2, [r0, #0x34] // entity.z = 1 (note: player cant do certain actions at z!=0) + subs r3, r1 + negs r3, r3 + lsrs r3, #1 lsrs r1, r3, #2 - adds r3, r3, r1 + adds r3, r1 // calc next bounce velocity lsrs r1, r3, #0xc cmp r1, #0xc - bhs _08004516 - movs r2, #0 - movs r3, #0 + bhs _08004516 // return 1 if bouncing + movs r2, #0 // return 0 if not bouncing + movs r3, #0 // set velocity to 0 _08004516: str r3, [r0, #0x20] adds r0, r2, #0 @@ -170,7 +174,7 @@ _08004516: thumb_func_start sub_0800451C sub_0800451C: @ 0x0800451C push {r0, lr} - bl GetTileUnderEntity + bl GetActTile adds r1, r0, #0 pop {r0, r3} mov lr, r3 diff --git a/asm/src/intr.s b/asm/src/intr.s index 4d59c9d7..4f65fa09 100644 --- a/asm/src/intr.s +++ b/asm/src/intr.s @@ -86,7 +86,7 @@ arm_sub_080B1A0C: @ 0x080B1A0C ldrb r2, [r0, #0x38] mov r0, r3 b arm_GetTileTypeByPos -arm_GetTileTypeByEntity: +arm_GetTileTypeByEntity: // GetCell ldrb r2, [r0, #0x38] ldrh r1, [r0, #0x32] ldrh r0, [r0, #0x2e] @@ -129,7 +129,7 @@ arm_GetRelativeCollisionTile: @ 0x080B1A8C ldrb r2, [r0, #0x38] mov r0, r3 b arm_sub_080B1AB4 -arm_GetTileUnderEntity: +arm_GetActTile: // GetCellAct ldrb r2, [r0, #0x38] ldrh r1, [r0, #0x32] ldrh r0, [r0, #0x2e] @@ -148,42 +148,46 @@ arm_sub_080B1AD8: add r0, r0, r1, lsl #6 mov r1, r2 arm_sub_080B1AE0: - ldr r2, _080B1C24 @ =gUnk_08000278 + ldr r2, _080B1C24 @ =gUnkDataPtrs ldr r2, [r2, r1, lsl #2] ldrb r0, [r2, r0] bx lr arm_func_start arm_sub_080B1AF0 arm_sub_080B1AF0: @ 0x080B1AF0 - ldrh r3, [r0, #0x2e] + @ r0 = entity* + @ r1 = x + @ r2 = y + + ldrh r3, [r0, #0x2e] @ ent.x + x add r3, r3, r1 - ldrh r1, [r0, #0x32] + ldrh r1, [r0, #0x32] @ ent.y + y add r1, r1, r2 - ldrb r2, [r0, #0x38] + ldrb r2, [r0, #0x38] @ ent.layer mov r0, r3 b arm_sub_080B1B18 -arm_sub_080B1B0C: - ldrb r2, [r0, #0x38] - ldrh r1, [r0, #0x32] - ldrh r0, [r0, #0x2e] +arm_sub_080B1B0C: // GetCellAtt + ldrb r2, [r0, #0x38] @ ent.layer + ldrh r1, [r0, #0x32] @ ent.y + ldrh r0, [r0, #0x2e] @ ent.x arm_sub_080B1B18: ldr ip, _080B1C28 @ =gRoomControls ldrh r3, [ip, #6] - sub r0, r0, r3 + sub r0, r0, r3 @ ent.x - gRoomControls.origin_x ldrh r3, [ip, #8] - sub r1, r1, r3 + sub r1, r1, r3 @ ent.y - gRoomControls.origin_y arm_sub_080B1B2C: lsl r0, r0, #0x16 - lsr r0, r0, #0x1a + lsr r0, r0, #0x1a @ /= 16 lsl r1, r1, #0x16 - lsr r1, r1, #0x1a + lsr r1, r1, #0x1a @ /= 16 arm_sub_080B1B3C: - add r0, r0, r1, lsl #6 + add r0, r0, r1, lsl #6 @ convert coords to tile index mov r1, r2 arm_sub_080B1B44: ldr r2, _080B1C2C @ =gUnk_08000248 ldr r1, [r2, r1, lsl #2] - ldrb r0, [r1, r0] + ldrb r0, [r1, r0] @ load collision tile at my location bx lr arm_func_start arm_sub_080B1B54 @@ -242,7 +246,7 @@ sub_080B1BCC: @ 0x080B1BCC and r1, r1, #0x3f0 and r2, r2, #0x3f0 add r1, r1, r2, lsl #6 - ldr r2, _080B1C50 @ =gUnk_08000278 + ldr r2, _080B1C50 @ =gUnkDataPtrs ldrb r3, [r0, #0x38] ldr r2, [r2, r3, lsl #2] ldrb r0, [r2, r1, lsr #4] @@ -253,7 +257,7 @@ _080B1C14: .4byte gUnk_08000258 _080B1C18: .4byte gRoomControls _080B1C1C: .4byte gUnk_08000228 _080B1C20: .4byte gRoomControls -_080B1C24: .4byte gUnk_08000278 +_080B1C24: .4byte gUnkDataPtrs _080B1C28: .4byte gRoomControls _080B1C2C: .4byte gUnk_08000248 _080B1C30: .4byte gUnk_080B37A0 @@ -264,7 +268,7 @@ _080B1C40: .4byte gUnk_080B7A3E _080B1C44: .4byte gUnk_08000360 _080B1C48: .4byte gUnk_080B7A3E _080B1C4C: .4byte gRoomControls -_080B1C50: .4byte gUnk_08000278 +_080B1C50: .4byte gUnkDataPtrs arm_func_start UpdateCollision UpdateCollision: @ 0x080B1C54 @@ -424,15 +428,15 @@ _080B1E74: mov ip, #0 bl arm_CalcCollisionDirection mov r6, r0 - ldrb r1, [r5, #0x3f] + ldrb r1, [r5, #0x3f] // hitType mov r0, #0x22 mul r1, r0, r1 - ldrb r0, [r4, #0x40] + ldrb r0, [r4, #0x40] // hurtType add r0, r0, r1 mov r1, #0xc mul r2, r0, r1 ldr r1, _080B2014 @ =gCollisionMtx - add r3, r2, r1 + add r3, r2, r1 // gCollisionMtx + 12 * (34 * hurtType + hurtType) mov r1, #0 ldrb r0, [r3] cmp r0, #0xff @@ -742,29 +746,30 @@ _080B2270: .4byte gUpdateContext _080B2274: .4byte gUnk_080026A4 _080B2278: .4byte gUpdateContext + // calculating knockback? arm_func_start arm_sub_080B227C arm_sub_080B227C: @ 0x080B227C - push {r4, r5, r6, r7, r8, lr} - ldr r2, [r0, #0x48] + push {r4-r8, lr} + ldr r2, [r0, #0x48] // tgt.hitbox cmp r2, #0 - beq _080B236C - ldr r3, [r1, #0x48] + beq ret_false + ldr r3, [r1, #0x48] // org.hitbox cmp r3, #0 - beq _080B236C + beq ret_false ldrh r4, [r1, #0x2e] ldrsb r5, [r3] add r4, r4, r5 ldrh r5, [r0, #0x2e] sub r4, r4, r5 ldrsb r5, [r2] - sub r4, r4, r5 + sub r4, r4, r5 // temp = (tgt.x + tgt.hitbox.x) - (org.x + org.hitbox.x) ldrb r5, [r2, #6] ldrb r6, [r3, #6] add r5, r5, r6 - add r6, r4, r5 + add r6, r4, r5 // temp = temp + (tgt.hitbox.width + org.hitbox.width) lsl r7, r5, #1 cmp r7, r6 - blo _080B236C + blo ret_false // not colliding cmp r4, #0 movpl ip, #8 movmi ip, #0x18 @@ -783,7 +788,7 @@ arm_sub_080B227C: @ 0x080B227C add r5, r4, r3 lsl r6, r3, #1 cmp r6, r5 - blo _080B236C + blo ret_false cmp r4, #0 movpl r2, #0x10 movmi r2, #0 @@ -793,7 +798,7 @@ arm_sub_080B227C: @ 0x080B227C movhs r7, r8 movhs r2, ip cmp r7, #0 - beq _080B236C + beq ret_false cmp r7, #5 movhs r7, #4 mov r0, r1 @@ -802,11 +807,11 @@ arm_sub_080B227C: @ 0x080B227C mov lr, pc bx r3 _080B2360: - pop {r4, r5, r6, r7, r8, lr} + pop {r4-r8, lr} mov r0, #1 bx lr -_080B236C: - pop {r4, r5, r6, r7, r8, lr} +ret_false: + pop {r4-r8, lr} mov r0, #0 bx lr .align 2, 0 diff --git a/asm/src/script.s b/asm/src/script.s index 4a607068..f1fc3cfd 100644 --- a/asm/src/script.s +++ b/asm/src/script.s @@ -106,7 +106,7 @@ _08016A64: sub_08016A6C: @ 0x08016A6C push {r4, r5, lr} adds r4, r0, #0 - bl GetTileUnderEntity + bl GetActTile add r1, pc, #0x38 _08016A76: adds r1, #4 diff --git a/asm/src/veneer.s b/asm/src/veneer.s index c3fc5da8..2d484627 100644 --- a/asm/src/veneer.s +++ b/asm/src/veneer.s @@ -107,7 +107,7 @@ _080001CC: .4byte gMapBottom+0x6004 thumb_func_start sub_080001D0 sub_080001D0: @ 0x080001D0 lsls r2, r2, #2 - ldr r3, _08000220 @ =gUnk_08000278 + ldr r3, _08000220 @ =gUnkDataPtrs ldr r3, [r3, r2] strb r0, [r3, r1] bx lr @@ -135,37 +135,37 @@ _08000210: .4byte gUnk_080B7910 _08000214: .4byte gUnk_080B79A7 _08000218: .4byte gUnk_080B37A0 _0800021C: .4byte gUnk_080B3E80 -_08000220: .4byte gUnk_08000278 +_08000220: .4byte gUnkDataPtrs _08000224: .4byte gUnk_08000228 gUnk_08000228:: - .4byte gMapBottom+0x0004 + .4byte BOTTOM_TILEDATA gUnk_0800022C:: - .4byte gMapBottom+0x5004 - .4byte gMapBottom+0x0004 - .4byte gMapBottom+0x5004 - .4byte gMapTop+0x0004 - .4byte gMapTop+0x5004 - .4byte gMapBottom+0x0004 - .4byte gMapBottom+0x5004 + .4byte BOTTOM_METATILETYPES + .4byte BOTTOM_TILEDATA + .4byte BOTTOM_METATILETYPES + .4byte TOP_TILEDATA + .4byte TOP_METATILETYPES + .4byte BOTTOM_TILEDATA + .4byte BOTTOM_METATILETYPES gUnk_08000248:: - .4byte gMapBottom+0x2004 - .4byte gMapBottom+0x2004 - .4byte gMapTop+0x2004 - .4byte gMapBottom+0x2004 + .4byte BOTTOM_COLLISIONDATA + .4byte BOTTOM_COLLISIONDATA + .4byte TOP_COLLISIONDATA + .4byte BOTTOM_COLLISIONDATA gUnk_08000258:: - .4byte gMapBottom+0x3004 - .4byte gMapBottom+0x5004 - .4byte gMapBottom+0x3004 - .4byte gMapBottom+0x5004 - .4byte gMapTop+0x3004 - .4byte gMapTop+0x5004 - .4byte gMapBottom+0x3004 - .4byte gMapBottom+0x5004 -gUnk_08000278:: - .4byte gMapBottom+0xb004 - .4byte gMapBottom+0xb004 - .4byte gMapTop+0xb004 - .4byte gMapBottom+0xb004 + .4byte BOTTOM_TILEDATACLONE + .4byte BOTTOM_METATILETYPES + .4byte BOTTOM_TILEDATACLONE + .4byte BOTTOM_METATILETYPES + .4byte TOP_TILEDATACLONE + .4byte TOP_METATILETYPES + .4byte BOTTOM_TILEDATACLONE + .4byte BOTTOM_METATILETYPES +gUnkDataPtrs:: + .4byte BOTTOM_UNKDATA3 + .4byte BOTTOM_UNKDATA3 + .4byte TOP_UNKDATA3 + .4byte BOTTOM_UNKDATA3 @ call 0x80B19CC @ ======== @@ -277,9 +277,9 @@ GetRelativeCollisionTile: @ 0x080002B4 @ return: @ ======== @ Called every frame a pot is thrown, every frame the screen is sliding in a transition, and once when entering stairs. - thumb_func_start GetTileUnderEntity -GetTileUnderEntity: @ 0x080002B8 - ldr r3, _08000324 @ =ram_GetTileUnderEntity + thumb_func_start GetActTile +GetActTile: @ 0x080002B8 + ldr r3, _08000324 @ =ram_GetActTile bx r3 @ call 0x080B1AB4 @@ -362,8 +362,6 @@ sub_080B1B3C: @ 0x080002DC bx r3 @ call 0x080B1B44 -@ ======== -@ Unused? Doesn't seem to be called by anything in Ghidra. thumb_func_start sub_080B1B44 sub_080B1B44: @ 0x080002E0 ldr r3, _0800034C @ =ram_sub_080B1B44 @@ -413,7 +411,7 @@ _08000314: .4byte ram_sub_080B1A48 _08000318: .4byte ram_sub_080B1A58 _0800031C: .4byte ram_GetTileType _08000320: .4byte ram_GetRelativeCollisionTile -_08000324: .4byte ram_GetTileUnderEntity +_08000324: .4byte ram_GetActTile _08000328: .4byte ram_sub_080B1AB4 _0800032C: .4byte ram_sub_080B1AC8 _08000330: .4byte ram_sub_080B1AD8 diff --git a/include/asm.h b/include/asm.h index 391ba768..bb768be3 100644 --- a/include/asm.h +++ b/include/asm.h @@ -20,11 +20,21 @@ extern void GenericKnockback(struct Entity_*); extern u32 GetFuserId(struct Entity_*); extern u32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY); extern u32 GravityUpdate(struct Entity_* entity, u32 gravity); +enum { + BOUNCE_DONE_ALL, + BOUNCE_INIT_NEXT, + BOUNCE_AIRBORNE, +}; +u32 BounceUpdate(struct Entity_*, u32 acceleration); extern u32 CheckOnScreen(struct Entity_*); extern bool32 EntityInRectRadius(struct Entity_*, struct Entity_*, u32, u32); extern void UpdateAnimationVariableFrames(struct Entity_*, u32); extern u32 sub_080043E8(struct Entity_*); -extern void sub_08004484(struct Entity_*, struct Entity_*); +/** + * Basic collision, only used between player and dazed enemies. + * (Probablity leftover from Four Swords) + */ +extern void CalcCollisionStaticEntity(struct Entity_*, struct Entity_*); extern void ResetCollisionLayer(struct Entity_*); extern void sub_08004596(struct Entity_*, u32); extern u32 sub_080045B4(struct Entity_*, u32, u32); @@ -41,7 +51,7 @@ extern u32 sub_080B1B44(u32, u32); extern u32 sub_080B1A48(u32, u32, u32); extern u32 sub_080B1B18(s32, s32, u32); extern u32 sub_080B1AE0(u16, u8); -extern u32 GetTileUnderEntity(struct Entity_*); +extern u32 GetActTile(struct Entity_*); extern u32 sub_0800445C(struct Entity_*); extern u32 sub_080B1AF0(struct Entity_*, s32, s32); extern u32 GetRelativeCollisionTile(struct Entity_*, u32, u32); diff --git a/include/common.h b/include/common.h index 871e5f05..c9200c98 100644 --- a/include/common.h +++ b/include/common.h @@ -11,9 +11,9 @@ struct Entity_; typedef struct { u16 heldKeys; /**< Keys held since last frame. */ u16 newKeys; /** Keys newly pressed this frame. */ - u16 unk4; + u16 menuScrollKeys; u8 unk6; - u8 unk7; + u8 menuScrollTimer; } Input; extern Input gInput; /**< Input instance. */ diff --git a/include/enemy.h b/include/enemy.h index ba1b828b..1f13a8d0 100644 --- a/include/enemy.h +++ b/include/enemy.h @@ -43,7 +43,7 @@ bool32 sub_08049F84(Entity*, s32); Entity* sub_08049DF4(u32); u32 sub_0804A044(Entity*, Entity*, u32); s32 sub_080012DC(Entity*); -u32 sub_080044EC(Entity*, u32); + void sub_0804AA1C(Entity*); bool32 sub_08049F1C(Entity*, Entity*, s32); bool32 PlayerInRange(Entity*, u32, s32); diff --git a/include/functions.h b/include/functions.h index 49fb3f31..1caeb76d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -69,7 +69,7 @@ extern void sub_080042D0(Entity*, u32, u16); extern void sub_080043A8(Entity*); extern u32 sub_0800445C(Entity*); extern void sub_080044AE(Entity*, u32, u32); -extern u32 sub_080044EC(Entity*, u32); +extern u32 BounceUpdate(Entity*, u32); extern void sub_0800451C(Entity*); extern void sub_08004542(Entity*); extern void sub_080085B0(Entity*); diff --git a/include/message.h b/include/message.h index 32f9f582..ae739791 100644 --- a/include/message.h +++ b/include/message.h @@ -18,11 +18,11 @@ typedef struct { u8 textWindowPosY; u16 textIndex; u16 unk2; // HI? - u32 field_0xc; - u32 rupees; - u32 field_0x14; - u32 field_0x18; - u32 field_0x1c; + u32 flags; + u32 rupees; // item price, shells, minigame timer + u32 field_0x14; // number of cuccos + u32 field_0x18; // unused + u32 field_0x1c; // unused } Message; extern Message gMessage; diff --git a/linker.ld b/linker.ld index 18f9d27d..1774c36d 100644 --- a/linker.ld +++ b/linker.ld @@ -170,7 +170,7 @@ SECTIONS { . = 0x000057CC; ram_sub_080B1A58 = .; . = 0x000057D4; ram_GetTileType = .; . = 0x00005800; ram_GetRelativeCollisionTile = .; - . = 0x0000581C; ram_GetTileUnderEntity = .; + . = 0x0000581C; ram_GetActTile = .; . = 0x00005828; ram_sub_080B1AB4 = .; . = 0x0000583C; ram_sub_080B1AC8 = .; . = 0x0000584C; ram_sub_080B1AD8 = .; diff --git a/src/collision.c b/src/collision.c index 7fb08ca4..5fe00c99 100644 --- a/src/collision.c +++ b/src/collision.c @@ -580,7 +580,7 @@ CollisionResult sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSetting org->health = 0; } } else if (tgt->kind == ENEMY && org == &gPlayerEntity) { - sub_08004484(tgt, org); + CalcCollisionStaticEntity(tgt, org); } return RESULT_NO_COLLISION; } @@ -670,14 +670,14 @@ CollisionResult sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSetting org->health = 0; } } else if ((tgt->kind == ENEMY) && (org == &gPlayerEntity)) { - sub_08004484(tgt, &gPlayerEntity); + CalcCollisionStaticEntity(tgt, &gPlayerEntity); } return RESULT_NO_COLLISION; } CollisionResult sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { if (org == &gPlayerEntity && PlayerCanBeMoved()) - sub_08004484(tgt, org); + CalcCollisionStaticEntity(tgt, org); return RESULT_NO_COLLISION; } @@ -716,7 +716,7 @@ CollisionResult sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSetting CollisionResult CollisionDefault(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { u32 confused = 0; if (tgt->confusedTime && tgt->kind == ENEMY && org == &gPlayerEntity) { - sub_08004484(tgt, org); + CalcCollisionStaticEntity(tgt, org); confused = 1; } if ((org->kind == PLAYER_ITEM && org->id == PL_ITEM_SHIELD) && diff --git a/src/common.c b/src/common.c index 10e200c0..83d194ca 100644 --- a/src/common.c +++ b/src/common.c @@ -216,15 +216,15 @@ static void StoreKeyInput(Input* input, u32 keyInput) { u32 difference = keyInput & ~heldKeys; input->newKeys = difference; if (keyInput == heldKeys) { - if (--input->unk7 == 0) { - input->unk7 = 4; - input->unk4 = keyInput; + if (--input->menuScrollTimer == 0) { + input->menuScrollTimer = 4; + input->menuScrollKeys = keyInput; } else { - input->unk4 = 0; + input->menuScrollKeys = 0; } } else { - input->unk7 = 20; - input->unk4 = difference; + input->menuScrollTimer = 20; + input->menuScrollKeys = difference; } input->heldKeys = keyInput; } diff --git a/src/debug.c b/src/debug.c index 399dcf71..6edbf3ee 100644 --- a/src/debug.c +++ b/src/debug.c @@ -73,7 +73,7 @@ void sub_0805FA98(void) { MessageInitialize(); break; default: - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { case DPAD_LEFT: iVar1 = -1; break; diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 58457d1d..e80b7eb3 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -509,7 +509,7 @@ void AcroBandit_Type1Action6(Entity* this) { void AcroBandit_Type1Action7(Entity* this) { ProcessMovement2(this); - if (sub_080044EC(this, 0x2000) == 0) + if (BounceUpdate(this, Q_8_8(32.0)) == BOUNCE_DONE_ALL) this->action = 8; } diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index 451d9aea..3fd4457b 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -114,7 +114,7 @@ void sub_080218CC(Entity* this) { GetNextFrame(this); if (this->frame & 1) { ProcessMovement2(this); - if (sub_080044EC(this, 0x1c00) == 0) + if (BounceUpdate(this, Q_8_8(28.0)) == BOUNCE_DONE_ALL) this->frameDuration = 1; } diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index ad7ceff0..234b032e 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -242,7 +242,7 @@ void sub_0802CAF8(Entity* this) { if (--this->timer == 0) { sub_0802CBC4(this); } else { - if (this->field_0x80.HALF.HI && sub_080044EC(this, 0x2800) == 1) { + if (this->field_0x80.HALF.HI && BounceUpdate(this, Q_8_8(40.0)) == BOUNCE_INIT_NEXT) { EnqueueSFX(SFX_PLACE_OBJ); } sub_0802CC18(this); diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index ab856221..79a83a7f 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -462,7 +462,7 @@ void sub_0802AEBC(Entity* this) { void sub_0802AED4(Entity* this) { GetNextFrame(this); if (this->field_0x80.HALF.HI < 2) { - if (sub_080044EC(this, 0x2800) == 1) { + if (BounceUpdate(this, Q_8_8(40.0)) == BOUNCE_INIT_NEXT) { this->field_0x80.HALF.HI++; } } else { @@ -661,7 +661,7 @@ void sub_0802B1BC(Entity* this) { #endif void sub_0802B204(Entity* this) { - if (sub_080044EC(this, 0x2800) == 1) { + if (BounceUpdate(this, Q_8_8(40.0)) == BOUNCE_INIT_NEXT) { Entity* ent = CreateEnemy(BOBOMB, 1); if (ent != NULL) { CopyPosition(this, ent); diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 82de5555..c2c62822 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -704,7 +704,7 @@ void sub_0801FB68(Entity* this) { } u32 sub_0801FBD0(Entity* this) { - if (GetTileUnderEntity(this) == 0x10) { + if (GetActTile(this) == 0x10) { return 1; } else { return 0; diff --git a/src/enemy/cloudPiranha.c b/src/enemy/cloudPiranha.c index d9ae589f..6e059ed7 100644 --- a/src/enemy/cloudPiranha.c +++ b/src/enemy/cloudPiranha.c @@ -178,7 +178,7 @@ void CloudPiranha_Action3(CloudPiranhaEntity* this) { void CloudPiranha_Action4(CloudPiranhaEntity* this) { Entity* effect; sub_080387F0(this); - if (sub_080044EC(super, 0x1800) == 1) { + if (BounceUpdate(super, Q_8_8(24.0)) == BOUNCE_INIT_NEXT) { super->action = 1; super->hitType = 0x72; super->timer = 1; diff --git a/src/enemy/cuccoAggr.c b/src/enemy/cuccoAggr.c index c14a4464..5bd8cae2 100644 --- a/src/enemy/cuccoAggr.c +++ b/src/enemy/cuccoAggr.c @@ -171,7 +171,7 @@ void sub_08038F44(CuccoAggrEntity* this) { super->direction = GetFacingDirection(&gPlayerEntity, super); sub_080390F8(this); ProcessMovement0(super); - sub_080044EC(super, 0x1800); + BounceUpdate(super, Q_8_8(24.0)); GetNextFrame(super); sub_08039298(this); if (--this->unk_78 == 0) { diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index 5f9f5ce2..40666e63 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -81,7 +81,7 @@ void sub_0802C334(Entity* this) { } GetNextFrame(this); this->field_0x7c.HALF.HI = COORD_TO_TILE(this); - if (sub_080044EC(this, *(u32*)&this->cutsceneBeh) == 1) { + if (BounceUpdate(this, *(u32*)&this->cutsceneBeh) == BOUNCE_INIT_NEXT) { EnqueueSFX(0x14c); COLLISION_ON(this); this->field_0x7a.HWORD = 0xc; diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 122ac212..01eb1fab 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -218,7 +218,7 @@ void sub_0802BEBC(Entity* this) { this->direction ^= DirectionSouth; ProcessMovement2(this); this->direction ^= DirectionSouth; - if (!sub_080044EC(this, Q_16_16(0.125))) { + if (BounceUpdate(this, Q_16_16(0.125)) == BOUNCE_DONE_ALL) { sub_0802C1C0(this); } } diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index a6ba87da..18634e49 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -232,7 +232,7 @@ void Peahat_ChargeEnd(Entity* this) { void Peahat_Stunned(Entity* this) { switch (this->animationState) { default: - if (sub_080044EC(this, 0x1800) == 0) { + if (BounceUpdate(this, Q_8_8(24.0)) == BOUNCE_DONE_ALL) { this->action = 6; this->timer = 240; this->subtimer = 10; diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index e064cfeb..c33b7aa4 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -181,16 +181,16 @@ void Rollobite_RolledUp(Entity* this) { if ((this->frame & ANIM_DONE) == 0) GetNextFrame(this); - unk = sub_080044EC(this, 0x2800); + unk = BounceUpdate(this, Q_8_8(40.0)); - if (unk == 0) { + if (unk == BOUNCE_DONE_ALL) { if (--this->timer == 0) { this->action = 5; InitializeAnimation(this, this->animationState + 12); } RegisterCarryEntity(this); } else { - if (unk == 1) + if (unk == BOUNCE_INIT_NEXT) EnqueueSFX(SFX_PLACE_OBJ); if (!(this->direction & DIR_NOT_MOVING_CHECK)) diff --git a/src/enemy/rope.c b/src/enemy/rope.c index 098d4b89..590e0f5f 100644 --- a/src/enemy/rope.c +++ b/src/enemy/rope.c @@ -196,7 +196,7 @@ void sub_08031600(Entity* this) { u32 sub_0803163C(Entity* this) { u32 h; - if (GetTileUnderEntity(this) == 0x13) { + if (GetActTile(this) == 0x13) { h = this->field_0x7a.HWORD / 2; } else { h = this->field_0x7a.HWORD; diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index 6cb42502..1508beab 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -153,12 +153,12 @@ void sub_0802B880(Entity* this) { void sub_0802B8B0(Entity* this) { ProcessMovement2(this); - switch (sub_080044EC(this, 0x1800)) { - case 0: + switch (BounceUpdate(this, Q_8_8(24.0))) { + case BOUNCE_DONE_ALL: this->action = 7; this->timer = 150; /* fallthrough */ - case 1: + case BOUNCE_INIT_NEXT: EnqueueSFX(SFX_12B); break; } diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index 02a1c4ba..3d4d077c 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -141,7 +141,7 @@ void sub_0802F300(Entity* this) { temp = this->z.HALF.HI; rand = Random() & 0xf; - if (sub_080044EC(this, this->field_0x80.HWORD) == 1) { + if (BounceUpdate(this, this->field_0x80.HWORD) == BOUNCE_INIT_NEXT) { this->action = 3; this->subAction = 0; if (this->type != 0) { @@ -158,7 +158,7 @@ void sub_0802F300(Entity* this) { return; } else if (this->collisions != COL_NONE) { sub_0800417E(this, this->collisions); - } else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) { + } else if ((GetActTile(this) & 0xf0) == 0x50) { this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); } diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index fa967d18..86c9f155 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -127,7 +127,7 @@ void sub_08038048(Entity* this) { temp = this->z.HALF.HI; rand = Random() & 0xf; - if (sub_080044EC(this, 0x3000) == 1) { + if (BounceUpdate(this, Q_8_8(48.0)) == BOUNCE_INIT_NEXT) { this->action = 3; this->subAction = 0; this->timer = 20; @@ -135,7 +135,7 @@ void sub_08038048(Entity* this) { return; } else if (this->collisions != COL_NONE) { sub_0800417E(this, this->collisions); - } else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) { + } else if ((GetActTile(this) & 0xf0) == 0x50) { this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); } diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 57b830d6..7e351588 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -265,8 +265,8 @@ void VaatiTransfiguredType0Action3(Entity* this) { switch (this->field_0x80.HALF.LO) { case 0: - uVar4 = sub_080044EC(this, 0x2800); - if (uVar4 != 1) + uVar4 = BounceUpdate(this, Q_8_8(40.0)); + if (uVar4 != BOUNCE_INIT_NEXT) break; this->field_0x80.HALF.LO = 1; this->timer = 192; diff --git a/src/fileselect.c b/src/fileselect.c index 7e4d9108..cf275fe1 100644 --- a/src/fileselect.c +++ b/src/fileselect.c @@ -1145,7 +1145,7 @@ void sub_080610B8(void) { default: uVar6 = 0; tmp4 = 0; - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { case DPAD_UP: tmp4 = -1; break; diff --git a/src/manager/enemyInteractionManager.c b/src/manager/enemyInteractionManager.c index 0c8428d7..cd393b31 100644 --- a/src/manager/enemyInteractionManager.c +++ b/src/manager/enemyInteractionManager.c @@ -66,14 +66,14 @@ void EnemyInteractionManager_Action1(EnemyInteractionManager* this) { for (i = 0; i < n; i++) { tmp = this->d.enemies[i]; for (j = i + 1; j < super->timer; j++) { - sub_08004484(tmp, this->d.enemies[j]); + CalcCollisionStaticEntity(tmp, this->d.enemies[j]); } } } else { for (i = 0; i < n; i++) { tmp = this->d.enemies[i]; for (j = i + 1; j < super->timer; j++) { - sub_08004484(this->d.enemies[j], tmp); + CalcCollisionStaticEntity(this->d.enemies[j], tmp); } } } diff --git a/src/menu/figurineMenu.c b/src/menu/figurineMenu.c index f8732c15..f76389fd 100644 --- a/src/menu/figurineMenu.c +++ b/src/menu/figurineMenu.c @@ -180,7 +180,7 @@ void FigurineMenu0_ViewFigurineAfterDrawing(void) { s32 t; infoY = gFigurineMenu.unk1f; - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { case B_BUTTON: case START_BUTTON: FigurineMenu_ExitMenu(); @@ -219,7 +219,7 @@ void FigurineMenu1_ViewAllFigurines(void) { infoY = gFigurineMenu.unk1f; figurineIndex = gFigurineMenu.figure_idx; - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { case B_BUTTON: case START_BUTTON: SetMenuType(3); diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index cfc0473a..446cd71c 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -194,7 +194,7 @@ void KinstoneMenu_Type1(void) { return; } tmp3 = menu->unk28; - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { case DPAD_LEFT: case DPAD_UP: tmp3--; diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index 6b1d0cef..ab90f23b 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -404,7 +404,7 @@ void PauseMenu_ItemMenu_Update(void) { } break; default: - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { case DPAD_UP: menuSlot = entry->up; break; @@ -710,7 +710,7 @@ void sub_080A56A0(void) { gMenu.field_0xc = gUnk_08128C00; ptr = &gUnk_08128C14[gMenu.field_0x3]; uVar2 = 0xff; - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { case DPAD_UP: uVar2 = ptr->unk0; break; diff --git a/src/message.c b/src/message.c index 87d6e461..08bad90c 100644 --- a/src/message.c +++ b/src/message.c @@ -408,7 +408,7 @@ u16 RunTextCommand(TextRender* this) { gMessage.unk = this->curToken.param; break; case 6: - ptr = &gMessage.field_0xc; + ptr = &gMessage.flags; tmp3 = this->curToken.param; tmp3 &= 0x1f; WriteBit(ptr, tmp3); diff --git a/src/npc/phonograph.c b/src/npc/phonograph.c index 469dddb5..dc1061d8 100644 --- a/src/npc/phonograph.c +++ b/src/npc/phonograph.c @@ -62,10 +62,10 @@ void sub_0806E964(PhonographEntity* this, ScriptExecutionContext* context) { sub_0806EABC(this); } - if (gInput.unk4 & (DPAD_UP | DPAD_DOWN)) { + if (gInput.menuScrollKeys & (DPAD_UP | DPAD_DOWN)) { s32 val2, val3; s32 val = this->unk_68; - if (gInput.unk4 & DPAD_UP) { + if (gInput.menuScrollKeys & DPAD_UP) { val++; } else { val--; @@ -148,8 +148,8 @@ void sub_0806E964(PhonographEntity* this, ScriptExecutionContext* context) { if (val > val2) { val = 1; } - } else if (gInput.unk4 & (DPAD_UP | DPAD_DOWN)) { - if (gInput.unk4 & DPAD_UP) { + } else if (gInput.menuScrollKeys & (DPAD_UP | DPAD_DOWN)) { + if (gInput.menuScrollKeys & DPAD_UP) { val++; } else { val--; diff --git a/src/npcUtils.c b/src/npcUtils.c index b0c111fe..79d572a4 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -321,7 +321,7 @@ void CollideFollowers(void) { continue; if ((nextEnt->followerFlag & 1) == 0) continue; - sub_08004484(currentEntity, nextEnt); + CalcCollisionStaticEntity(currentEntity, nextEnt); } } } diff --git a/src/object/bird.c b/src/object/bird.c index 485c0695..95761443 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -132,7 +132,7 @@ void Bird_Type1_Action1_Subaction0(BirdEntity* this) { void Bird_Type1_Action1_Subaction1(BirdEntity* this) { Entity* fx; - if (sub_080044EC(super, 0x1800) < 2) { + if (BounceUpdate(super, Q_8_8(24.0)) < BOUNCE_AIRBORNE) { super->type = 2; super->action = 1; super->z.WORD = 0; diff --git a/src/object/book.c b/src/object/book.c index 4ebd3f7d..5ab73149 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -139,7 +139,7 @@ void Book_Action2(BookEntity* this) { void Book_Action3(BookEntity* this) { Entity* fx; - if (sub_080044EC(super, 0x2800) != 1) { + if (BounceUpdate(super, Q_8_8(40.0)) != BOUNCE_INIT_NEXT) { return; } diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index 7480ba07..31946da4 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -175,7 +175,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { gUnk_0200AF00.rActionPlayerState = R_ACTION_NONE; } PositionRelative(&gPlayerEntity, super, 0, 0x10000); - if (GetTileUnderEntity(super) == 0x19) { + if (GetActTile(super) == 0x19) { RestorePrevTileEntity(0xdc, super->collisionLayer); sub_08096A78(this); } diff --git a/src/object/cutsceneMiscObject.c b/src/object/cutsceneMiscObject.c index 44fc603f..0cc769f1 100644 --- a/src/object/cutsceneMiscObject.c +++ b/src/object/cutsceneMiscObject.c @@ -332,7 +332,7 @@ void CutsceneMiscObject_Type5(CutsceneMiscObjectEntity* this) { super->zVelocity = 0; SetEntityPriority(super, PRIO_PLAYER_EVENT); InitializeAnimation(super, 0); - if (GetTileUnderEntity(super) == 13) { + if (GetActTile(super) == 13) { super->action = 3; } break; @@ -551,7 +551,7 @@ void CutsceneMiscObject_Type11(CutsceneMiscObjectEntity* this) { InitAnimationForceUpdate(super, 0); } if (super->subAction != 0) { - if ((u32)sub_080044EC(super, 0x1800) <= 1) { + if ((u32)BounceUpdate(super, Q_8_8(24.0)) <= BOUNCE_INIT_NEXT) { super->subAction = 0; SetAffineInfo(super, 0x100, 0x100, 0xC000); } else { diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c index 86c09f1d..d0e918ac 100644 --- a/src/object/figurineDevice.c +++ b/src/object/figurineDevice.c @@ -260,9 +260,9 @@ void FigurineDevice_Action4(FigurineDeviceEntity* this) { tmp = 1; } #ifdef JP - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { #else - switch (gInput.unk4 & 0xfffffeff) { + switch (gInput.menuScrollKeys & ~R_BUTTON) { #endif case DPAD_UP: FigurineDevice_ChangeShellAmount(this, tmp); @@ -275,7 +275,7 @@ void FigurineDevice_Action4(FigurineDeviceEntity* this) { sub_080882A8(this); } #else - switch (gInput.unk4) { + switch (gInput.menuScrollKeys) { case DPAD_UP: FigurineDevice_ChangeShellAmount(this, 1); break; diff --git a/src/object/graveyardKey.c b/src/object/graveyardKey.c index bef307ed..e9c217ba 100644 --- a/src/object/graveyardKey.c +++ b/src/object/graveyardKey.c @@ -125,7 +125,7 @@ void GraveyardKey_Action2(Entity* this, const struct_gUnk_08123FB0* param_2) { u8 type; LinearMoveUpdate(this); - if (sub_080044EC(this, param_2->unk14) < 2) { + if (BounceUpdate(this, param_2->unk14) < BOUNCE_AIRBORNE) { if (this->timer) { this->timer--; this->zVelocity = param_2->unk14 << 3; diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index 5c46e2dd..2d2c1fe9 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -437,7 +437,7 @@ u32 sub_080814C0(ItemOnGroundEntity* this) { void sub_08081500(ItemOnGroundEntity* this) { if (this->unk_68 == 0) { - u32 var0 = sub_080044EC(super, 0x2800); + u32 var0 = BounceUpdate(super, Q_8_8(40.0)); if (var0 == 0) { this->unk_68 = 1; } else { diff --git a/src/object/keyStealingTakkuri.c b/src/object/keyStealingTakkuri.c index 8a5a40b1..7a6e7653 100644 --- a/src/object/keyStealingTakkuri.c +++ b/src/object/keyStealingTakkuri.c @@ -164,7 +164,7 @@ void KeyStealingTakkuri_Type5_Init(KeyStealingTakkuriEntity* this) { void KeyStealingTakkuri_Type5_Action1(KeyStealingTakkuriEntity* this) { LinearMoveUpdate(super); - if (sub_080044EC(super, 0x2000) < 2) { + if (BounceUpdate(super, Q_8_8(32.0)) < BOUNCE_AIRBORNE) { if (super->timer != 0) { super->timer--; super->zVelocity = Q_16_16(1.0); diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index 5571ca47..5d6a6fc5 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -387,7 +387,7 @@ void sub_08085B40(LilypadLargeEntity* this) { } } else { ResetCollisionLayer(super); - if (GetTileUnderEntity(super) == 0xd) { + if (GetActTile(super) == 0xd) { ResetCollisionLayer(&gPlayerEntity); LilypadLarge_Action4(this); super->direction = GetFacingDirection(&gPlayerEntity, super); @@ -409,7 +409,7 @@ void sub_08085B40(LilypadLargeEntity* this) { super->timer |= 0x80; this->unk_70 = 0; this->unk_6c = 0; - if (GetTileUnderEntity(super) == 0xd) { + if (GetActTile(super) == 0xd) { super->action = 4; } } diff --git a/src/object/mask.c b/src/object/mask.c index e6934e5a..26539e87 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -130,7 +130,7 @@ void Mask_Action2(MaskEntity* this) { CreateRandomItemDrop(super, 3); } else { - sub_080044EC(super, this->unk_78); + BounceUpdate(super, this->unk_78); if (super->z.HALF.HI == 0) { super->timer++; diff --git a/src/object/minecart.c b/src/object/minecart.c index 73cf2e51..fb53ac7d 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -200,7 +200,7 @@ void Minecart_Action3(MinecartEntity* this) { case 0x6d: case 0x6e: case 0x6f: - if (uVar3 == GetTileUnderEntity(super)) { + if (uVar3 == GetActTile(super)) { Minecart_Action4(this); gPlayerEntity.animationState = super->animationState << 1; return; @@ -222,7 +222,7 @@ void Minecart_Action3(MinecartEntity* this) { void Minecart_Action4(MinecartEntity* this) { sub_08004168(super); CopyPosition(super, &gPlayerEntity); - switch (GetTileUnderEntity(super)) { + switch (GetActTile(super)) { case 0x67: if (super->direction == DirectionWest) { super->direction = DirectionNorth; diff --git a/src/object/objectA2.c b/src/object/objectA2.c index 4f9c55cb..08f90505 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -52,7 +52,7 @@ void ObjectA2_Action1(Entity* this) { LinearMoveUpdate(this); #ifndef EU if (gSaveHeader->language < 2) { - if (sub_080044EC(this, 0x2000) < 2) { + if (BounceUpdate(this, Q_8_8(32.0)) < BOUNCE_AIRBORNE) { this->z.WORD = 0; this->action = 2; InitializeAnimation(this, 1); @@ -62,15 +62,15 @@ void ObjectA2_Action1(Entity* this) { } } else { #endif - switch (sub_080044EC(this, 0x2000)) { + switch (BounceUpdate(this, Q_8_8(32.0))) { default: this->timer++; break; - case 0: + case BOUNCE_DONE_ALL: this->action = 2; InitializeAnimation(this, 1); // fall through - case 1: + case BOUNCE_INIT_NEXT: this->timer = 0; sub_0809F448(this); SoundReq(SFX_186); diff --git a/src/object/objectOnPillar.c b/src/object/objectOnPillar.c index 6f3381dc..773ab378 100644 --- a/src/object/objectOnPillar.c +++ b/src/object/objectOnPillar.c @@ -209,7 +209,7 @@ void sub_080970F4(ObjectOnPillarEntity* this) { bool32 sub_08097144(ObjectOnPillarEntity* this) { LinearMoveUpdate(super); sub_0800445C(super); - if (GetTileUnderEntity(super) == 0x19) { + if (GetActTile(super) == 0x19) { super->spriteOffsetY = 2; } if ((--this->unk_76 == 0) && sub_08097194(this) == FALSE) { diff --git a/src/object/playerClone.c b/src/object/playerClone.c index 56a3c8bf..21bb818b 100644 --- a/src/object/playerClone.c +++ b/src/object/playerClone.c @@ -110,7 +110,7 @@ void PlayerClone_Action2(PlayerCloneEntity* this) { if (gPlayerEntity.iframes >= 1) { gPlayerState.chargeState.action = 1; } else { - GetTileUnderEntity(super); + GetActTile(super); sub_08084B1C(this); super->x.HALF.HI = gPlayerEntity.x.HALF.HI + this->unk78; super->y.HALF.HI = gPlayerEntity.y.HALF.HI + this->unk7a; diff --git a/src/object/pot.c b/src/object/pot.c index 93bc1995..255b3e36 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -26,7 +26,7 @@ typedef struct { } PotEntity; void Pot_Action5(PotEntity*); -static void sub_08082850(PotEntity*, Entity*); +static void BreakPot(PotEntity*, Entity*); void sub_08082608(PotEntity* this); void Pot_Init(PotEntity* this); void Pot_Action1(PotEntity* this); @@ -129,13 +129,13 @@ void Pot_Action1(PotEntity* this) { DeleteThisEntity(); break; default: - if (GetTileUnderEntity(super) == 13) { + if (GetActTile(super) == 13) { CreateFx(super, FX_FALL_DOWN, 0); } else if (tileType == 0x4005) { gPlayerState.lastSwordMove = SWORD_MOVE_BREAK_POT; SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); } - sub_08082850(this, NULL); + BreakPot(this, NULL); break; } } else { @@ -182,7 +182,7 @@ void sub_0808259C(PotEntity* this) { CreateFx(super, FX_LAVA_SPLASH, 0); break; default: - sub_08082850(this, &gPlayerEntity); + BreakPot(this, &gPlayerEntity); return; } @@ -228,7 +228,7 @@ void Pot_Action4(PotEntity* this) { switch (tileType) { case 0x71: case 0x72: - sub_08082850(this, NULL); + BreakPot(this, NULL); break; default: SetTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); @@ -269,7 +269,7 @@ void sub_08082778(PotEntity* this) { } if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { - sub_08082850(this, NULL); + BreakPot(this, NULL); } else { sub_0806F3E4(super); } @@ -277,7 +277,7 @@ void sub_08082778(PotEntity* this) { void sub_080827F8(PotEntity* this) { if (gPlayerState.field_0x1c == 0) { - sub_08082850(this, NULL); + BreakPot(this, NULL); } } @@ -285,7 +285,7 @@ void nullsub_512(PotEntity* this) { } void sub_08082818(PotEntity* this) { - sub_08082850(this, NULL); + BreakPot(this, NULL); } void Pot_Action5(PotEntity* this) { @@ -294,11 +294,11 @@ void Pot_Action5(PotEntity* this) { } if (GravityUpdate(super, Q_8_8(32.0)) == 0) { - sub_08082850(this, NULL); + BreakPot(this, NULL); } } -static void sub_08082850(PotEntity* this, Entity* parent) { +static void BreakPot(PotEntity* this, Entity* parent) { u32 parameter = sub_0808288C(super, super->type, this->unk_7d, super->type2); Entity* fxEntity = CreateFx(super, FX_POT_SHATTER, parameter); if (fxEntity) { diff --git a/src/object/rupee.c b/src/object/rupee.c index fe38b3ad..edf3799b 100644 --- a/src/object/rupee.c +++ b/src/object/rupee.c @@ -46,7 +46,7 @@ void Rupee_Action_1(Entity* this) { if (this->child->next == NULL) { this->action = 2; } else { - if (sub_080044EC(this, 10240) == 0) { + if (BounceUpdate(this, Q_8_8(40.0)) == BOUNCE_DONE_ALL) { this->action = 2; } ProcessMovement0(this); diff --git a/src/player.c b/src/player.c index c50cfcf2..414a675d 100644 --- a/src/player.c +++ b/src/player.c @@ -1974,7 +1974,7 @@ static void PlayerRoomTransition(Entity* this) { static void sub_080724DC(Entity* this) { this->knockbackDuration = 0; DeleteClones(); - if (GetTileUnderEntity(this) != 0x29) { + if (GetActTile(this) != 0x29) { if ((gPlayerState.remainingDiveTime == 0) && (gPlayerState.swim_state != 0)) { PlayerUpdateSwimming(this); } @@ -2618,7 +2618,7 @@ static void PlayerUseStairs(Entity* this) { static void sub_080732D0(Entity* this) { UpdateAnimationSingleFrame(this); - if (GetTileUnderEntity(this) != 40) { + if (GetActTile(this) != 40) { this->direction = DirectionNorth; LinearMoveUpdate(this); } else { @@ -4105,7 +4105,7 @@ void sub_0807529C(Entity* this) { void sub_080752AC(Entity* this, ScriptExecutionContext* ctx) { LinearMoveUpdate(this); if (!ctx->unk_18) { - if (GetTileUnderEntity(this) != 41) { + if (GetActTile(this) != 41) { ctx->unk_18 = 1; ctx->unk_19 = 6; } diff --git a/src/playerItem/playerItemHeldObject.c b/src/playerItem/playerItemHeldObject.c index 5f454d37..ddecc171 100644 --- a/src/playerItem/playerItemHeldObject.c +++ b/src/playerItem/playerItemHeldObject.c @@ -137,7 +137,7 @@ void PlayerItemHeldObject_SubAction2(PlayerItemHeldObjectEntity* this) { (child->base).x = super->x; (child->base).y = super->y; (child->base).z = super->z; - tile = GetTileUnderEntity(super); + tile = GetActTile(super); switch (tile) { case 0xd: case 0x10: diff --git a/src/playerItem/playerItemPacciCaneProjectile.c b/src/playerItem/playerItemPacciCaneProjectile.c index 0aec528a..0a42549f 100644 --- a/src/playerItem/playerItemPacciCaneProjectile.c +++ b/src/playerItem/playerItemPacciCaneProjectile.c @@ -128,7 +128,7 @@ void PlayerItemPacciCaneProjectile_Action1(PlayerItemPacciCaneProjectileEntity* } if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0) { if (sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI) == 0) { - if (GetTileUnderEntity(super) == 0x19) { + if (GetActTile(super) == 0x19) { super->action = 4; COLLISION_OFF(super); super->x.HALF.HI = (super->x.HALF.HI & 0xfff0) | 8; diff --git a/src/playerUtils.c b/src/playerUtils.c index 412d7142..27374038 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -2349,7 +2349,7 @@ bool32 sub_08079D48(void) { return TRUE; } else { if (!PlayerCheckNEastTile()) { - if (!sub_08007DD6((u16)GetTileUnderEntity(&gPlayerEntity), gUnk_0811C268)) { + if (!sub_08007DD6((u16)GetActTile(&gPlayerEntity), gUnk_0811C268)) { return TRUE; } } diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index 5593b602..3b8382ca 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -71,7 +71,7 @@ void BoneProjectile_Action3(Entity* this) { this->spriteSettings.draw ^= 1; LinearMoveUpdate(this); GetNextFrame(this); - if (sub_080044EC(this, 0x1800) == 0) { + if (BounceUpdate(this, Q_8_8(24.0)) == BOUNCE_DONE_ALL) { DeleteEntity(this); } } diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c index 59189ac3..3ab18bd0 100644 --- a/src/projectile/dekuSeedProjectile.c +++ b/src/projectile/dekuSeedProjectile.c @@ -116,11 +116,11 @@ void DekuSeedProjectile_Action3(Entity* this) { void DekuSeedProjectile_Action4(Entity* this) { GetNextFrame(this); ProcessMovement3(this); - switch (sub_080044EC(this, 0x2800)) { - case 0: + switch (BounceUpdate(this, Q_8_8(40.0))) { + case BOUNCE_DONE_ALL: DeleteThisEntity(); return; - case 1: + case BOUNCE_INIT_NEXT: COLLISION_OFF(this); this->speed = 0x120; diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index d1205188..7afb43f8 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -133,7 +133,7 @@ void DirtBallProjectile_Action2(Entity* this) { FreeCarryEntity(entity); CopyPosition(this, entity); } - if (sub_080044EC(this, 0x2800) != 1) { + if (BounceUpdate(this, Q_8_8(40.0)) != BOUNCE_INIT_NEXT) { return; } diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c index 786fe69a..e82a8fce 100644 --- a/src/projectile/rockProjectile.c +++ b/src/projectile/rockProjectile.c @@ -67,11 +67,11 @@ void RockProjectile_Action2(Entity* this) { void RockProjectile_Action3(Entity* this) { GetNextFrame(this); ProcessMovement3(this); - switch (sub_080044EC(this, 0x2800)) { - case 0: + switch (BounceUpdate(this, Q_8_8(40.0))) { + case BOUNCE_DONE_ALL: DeleteEntity(this); return; - case 1: + case BOUNCE_INIT_NEXT: COLLISION_OFF(this); this->speed = 0x120; if (sub_0800442E(this) != 0) { From 2c7c9ae509d3a9909623c917c082a1ed45b76f46 Mon Sep 17 00:00:00 2001 From: theo3 Date: Sat, 30 Dec 2023 17:26:46 -0800 Subject: [PATCH 02/10] fmt --- include/message.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/message.h b/include/message.h index ae739791..b25e9df5 100644 --- a/include/message.h +++ b/include/message.h @@ -19,7 +19,7 @@ typedef struct { u16 textIndex; u16 unk2; // HI? u32 flags; - u32 rupees; // item price, shells, minigame timer + u32 rupees; // item price, shells, minigame timer u32 field_0x14; // number of cuccos u32 field_0x18; // unused u32 field_0x1c; // unused From 201955ea052a5188f2e59bdcdbf6c52ff158ee66 Mon Sep 17 00:00:00 2001 From: theo3 Date: Sat, 30 Dec 2023 20:05:32 -0800 Subject: [PATCH 03/10] create enemy struct and enemy flags --- asm/src/code_08003FC4.s | 14 +-- asm/src/enemy.s | 2 +- include/enemy.h | 46 ++++++-- include/functions.h | 4 +- include/room.h | 4 +- linker.ld | 3 +- src/code_08049CD4.c | 29 ++--- src/code_08049DF4.c | 20 ---- src/collision.c | 2 +- src/createEnemy.c | 23 ---- src/enemy/acroBandits.c | 4 +- src/enemy/armos.c | 4 +- src/enemy/ballChainSoldier.c | 4 +- src/enemy/beetle.c | 2 +- src/enemy/bowMoblin.c | 6 +- src/enemy/businessScrub.c | 10 +- src/enemy/businessScrubPrologue.c | 6 +- src/enemy/chuchu.c | 24 ++--- src/enemy/chuchuBoss.c | 4 +- src/enemy/cloudPiranha.c | 4 +- src/enemy/cuccoAggr.c | 4 +- src/enemy/darkNut.c | 20 ++-- src/enemy/doorMimic.c | 2 +- src/enemy/enemy4D.c | 4 +- src/enemy/enemy50.c | 4 +- src/enemy/ghini.c | 4 +- src/enemy/gibdo.c | 6 +- src/enemy/gleerok.c | 8 +- src/enemy/helmasaur.c | 4 +- src/enemy/keaton.c | 6 +- src/enemy/lakitu.c | 8 +- src/enemy/leever.c | 6 +- src/enemy/likeLike.c | 4 +- src/enemy/miniSlime.c | 4 +- src/enemy/mulldozer.c | 4 +- src/enemy/octorok.c | 8 +- src/enemy/octorokBoss.c | 12 +-- src/enemy/octorokGolden.c | 8 +- src/enemy/peahat.c | 12 +-- src/enemy/pesto.c | 6 +- src/enemy/puffstool.c | 10 +- src/enemy/rockChuchu.c | 2 +- src/enemy/rope.c | 4 +- src/enemy/ropeGolden.c | 6 +- src/enemy/rupeeLike.c | 6 +- src/enemy/scissorsBeetle.c | 4 +- src/enemy/slime.c | 6 +- src/enemy/sluggula.c | 8 +- src/enemy/spearMoblin.c | 4 +- src/enemy/spikedBeetle.c | 4 +- src/enemy/spinyBeetle.c | 4 +- src/enemy/spinyChuchu.c | 8 +- src/enemy/stalfos.c | 14 +-- src/enemy/tektite.c | 4 +- src/enemy/tektiteGolden.c | 6 +- src/enemy/torchTrap.c | 2 +- src/enemy/treeItem.c | 4 +- src/enemy/vaatiArm.c | 10 +- src/enemy/vaatiBall.c | 4 +- src/enemy/vaatiEyesMacro.c | 4 +- src/enemy/vaatiRebornEnemy.c | 4 +- src/enemy/vaatiTransfigured.c | 10 +- src/enemy/wallMaster.c | 4 +- src/enemy/wallMaster2.c | 4 +- src/enemy/wizzrobeFire.c | 8 +- src/enemy/wizzrobeIce.c | 8 +- src/enemy/wizzrobeWind.c | 10 +- src/enemyUtils.c | 142 ++++++++++++++++--------- src/entity.c | 4 +- src/manager/fightManager.c | 3 +- src/manager/templeOfDropletsManager.c | 2 +- src/menu/kinstoneMenu.c | 2 +- src/object/bush.c | 2 +- src/object/crackingGround.c | 2 +- src/object/crenelBeanSprout.c | 2 +- src/object/flame.c | 2 +- src/object/minecart.c | 4 +- src/object/mulldozerSpawnPoint.c | 3 +- src/object/object53.c | 2 +- src/object/object70.c | 2 +- src/object/pushableStatue.c | 8 +- src/object/smallIceBlock.c | 2 +- src/player.c | 4 +- src/playerUtils.c | 4 +- src/projectile/gleerokProjectile.c | 2 +- src/projectile/octorokBossProjectile.c | 2 +- src/projectile/v2Projectile.c | 2 +- src/room.c | 13 +-- 88 files changed, 375 insertions(+), 345 deletions(-) delete mode 100644 src/createEnemy.c diff --git a/asm/src/code_08003FC4.s b/asm/src/code_08003FC4.s index 25bfc6ec..362f7d8d 100644 --- a/asm/src/code_08003FC4.s +++ b/asm/src/code_08003FC4.s @@ -258,17 +258,17 @@ _08004162: ands r2, r4 pop {r4, pc} - thumb_func_start sub_08004168 -sub_08004168: @ 0x08004168 + thumb_func_start SnapToTile +SnapToTile: @ 0x08004168 ldr r3, _08004384 @ =0x000FFFFF ldr r1, _08004388 @ =0x00080000 - ldr r2, [r0, #0x2c] - bics r2, r3 - adds r2, r2, r1 + ldr r2, [r0, #0x2c] // x + bics r2, r3 // align to grid + adds r2, r1 // add half of a tile str r2, [r0, #0x2c] - ldr r2, [r0, #0x30] + ldr r2, [r0, #0x30] // y bics r2, r3 - adds r2, r2, r1 + adds r2, r1 str r2, [r0, #0x30] bx lr diff --git a/asm/src/enemy.s b/asm/src/enemy.s index a19f232f..52aacf91 100644 --- a/asm/src/enemy.s +++ b/asm/src/enemy.s @@ -105,7 +105,7 @@ GenericConfused: @ 0x08001242 cmp r2, #0x1c bne _08001282 push {r0} - bl sub_0804AA1C + bl EnemyDetachFX pop {r0} _08001282: ldr r1, _08001364 @ =0x00001800 diff --git a/include/enemy.h b/include/enemy.h index d9bc0a76..28a236ab 100644 --- a/include/enemy.h +++ b/include/enemy.h @@ -12,7 +12,35 @@ #include "entity.h" #include "projectile.h" -bool32 EnemyInit(Entity* this); +#define EM_FLAG_BOSS (1 << 0) +#define EM_FLAG_BOSS_KILLED (1 << 1) +#define EM_FLAG_HAS_HOME (1 << 2) +#define EM_FLAG_NO_DEATH_FX (1 << 3) +#define EM_FLAG_SUPPORT (1 << 4) +#define EM_FLAG_CAPTAIN (1 << 5) +#define EM_FLAG_MONITORED (1 << 6) + +typedef struct { + Entity base; + Entity* child; + u8 idx; + u8 enemyFlags; + u8 rangeX; + u8 rangeY; + s16 homeX; + s16 homeY; + /*0x74*/ union SplitHWord field_0x74; + /*0x76*/ union SplitHWord field_0x76; + /*0x78*/ union SplitHWord field_0x78; + /*0x7a*/ union SplitHWord field_0x7a; + /*0x7c*/ union SplitWord field_0x7c; + /*0x80*/ union SplitHWord field_0x80; + /*0x82*/ union SplitHWord field_0x82; + /*0x84*/ union SplitHWord cutsceneBeh; + /*0x86*/ union SplitHWord field_0x86; +} Enemy; + +bool32 EnemyInit(Enemy* this); /** * 0: _OnTick * 1: _OnCollision @@ -25,13 +53,13 @@ u32 GetNextFunction(Entity*); void EnemyFunctionHandler(Entity*, EntityActionArray); void EnemyFunctionHandlerAfterCollision(Entity*, void (*const[])()); void GenericKnockback(Entity*); -Entity* CreateDeathFx(Entity*, u32, u32); +void EnemyCreateDeathFX(Enemy*, u32, u32); void sub_0804A720(Entity*); bool32 sub_08049FDC(Entity*, u32); -Entity* Create0x68FX(Entity*, u32); -void SetChildOffset(Entity*, s32, s32, s32); -Entity* CreateProjectileWithParent(Entity*, u8, u8); +Entity* EnemyCreateFX(Entity*, u32); +void EnemySetFXOffset(Entity*, s32, s32, s32); +Entity* EnemyCreateProjectile(Entity*, u32, u32); void GenericDeath(Entity*); void sub_08002724(void*, u8*); @@ -44,13 +72,13 @@ Entity* sub_08049DF4(u32); u32 sub_0804A044(Entity*, Entity*, u32); s32 sub_080012DC(Entity*); -void sub_0804AA1C(Entity*); +void EnemyDetachFX(Entity*); bool32 sub_08049F1C(Entity*, Entity*, s32); bool32 PlayerInRange(Entity*, u32, s32); -void sub_0804A4E4(Entity*, Entity*); +void EnemyCopyParams(Entity*, Entity*); void GenericKnockback2(Entity*); -typedef enum { +enum { /*0x00*/ OCTOROK, /*0x01*/ CHUCHU, /*0x02*/ LEEVER, @@ -154,7 +182,7 @@ typedef enum { /*0x64*/ ENEMY_64, /*0x65*/ TREE_ITEM, /*0x66*/ ENEMY_66 -} Enemy; +}; void Octorok(); void Chuchu(); diff --git a/include/functions.h b/include/functions.h index 1caeb76d..2d843967 100644 --- a/include/functions.h +++ b/include/functions.h @@ -61,7 +61,7 @@ extern void sub_080027EA(Entity*, u32, u32); extern void sub_080028E0(Entity*); extern u32 sub_080040A2(Entity*); extern u32 sub_080040D8(Entity*, u8*, s32, s32); -extern void sub_08004168(Entity*); +extern void SnapToTile(Entity*); extern u32 sub_0800419C(Entity*, Entity*, u32, u32); extern u32 sub_080041DC(Entity*, u32, u32); extern void sub_080042BA(Entity*, u32); @@ -81,7 +81,7 @@ extern void UpdateUIElements(void); extern void sub_0801E104(void); extern void sub_08030118(u32); extern void sub_0803C0AC(Entity*); -extern void sub_08049CF4(Entity*); +extern void EnemyDisableRespawn(Entity*); extern u32 sub_0804A024(Entity*, u32, u32); extern u32 IsMinishItem(u32); extern void DisableRandomDrops(); diff --git a/include/room.h b/include/room.h index 3b0ff0d2..f9201826 100644 --- a/include/room.h +++ b/include/room.h @@ -88,10 +88,10 @@ typedef struct { u8 area; u8 room; u16 unk_02; - u32 unk_04; + u32 enemyBits; } RoomMemory; -extern RoomMemory* gUnk_020354B0; +extern RoomMemory* gCurrentRoomMemory; extern RoomMemory gRoomMemory[]; // Packets used to store which entities to load in a room diff --git a/linker.ld b/linker.ld index 1774c36d..7099a9ab 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,7 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x000354B0; gUnk_020354B0 = .; + . = 0x000354B0; gCurrentRoomMemory = .; . = 0x000354B4; gManagerCount = .; . = 0x000354C0; gUnk_020354C0 = .; . = 0x00035540; gzHeap = .; @@ -386,7 +386,6 @@ SECTIONS { src/code_08049CD4.o(.text); /* enemyUtils.c */ src/code_08049DF4.o(.text); src/enemyUtils.o(.text); - src/createEnemy.o(.text); src/enterPortalSubtask.o(.text); src/room.o(.text); src/roomInit.o(.text); diff --git a/src/code_08049CD4.c b/src/code_08049CD4.c index 3755f9d6..4dddb214 100644 --- a/src/code_08049CD4.c +++ b/src/code_08049CD4.c @@ -1,5 +1,6 @@ #include "global.h" #include "room.h" +#include "enemy.h" extern void MemFill32(u32, void*, u32); @@ -8,35 +9,35 @@ RoomMemory* sub_08049D88(void); void ClearRoomMemory(void) { MemFill32(0xFFFFFFFF, gRoomMemory, 0x40); - gUnk_020354B0 = gRoomMemory; + gCurrentRoomMemory = gRoomMemory; } -void sub_08049CF4(GenericEntity* ent) { - u8 field_0x6c = ent->field_0x6c.HALF.LO; - if (field_0x6c & 0x80) { - gUnk_020354B0->unk_04 |= 1 << (field_0x6c & 0x1f); +void EnemyDisableRespawn(Enemy* ent) { + u8 idx = ent->idx; + if (idx & 0x80) { + gCurrentRoomMemory->enemyBits |= 1 << (idx & 0x1f); } } -u32 sub_08049D1C(u32 arg0) { - u32 bitmask = gUnk_020354B0->unk_04 >> arg0; +u32 EnemyEnableRespawn(u32 arg0) { + u32 bitmask = gCurrentRoomMemory->enemyBits >> arg0; u32 output = 1; output &= ~bitmask; return output; } void UpdateRoomTracker(void) { - gUnk_020354B0 = gRoomMemory; + gCurrentRoomMemory = gRoomMemory; do { - if (gUnk_020354B0->area == gRoomControls.area && gUnk_020354B0->room == gRoomControls.room) { - sub_08049DCC(gUnk_020354B0); + if (gCurrentRoomMemory->area == gRoomControls.area && gCurrentRoomMemory->room == gRoomControls.room) { + sub_08049DCC(gCurrentRoomMemory); return; } - gUnk_020354B0++; + gCurrentRoomMemory++; - } while (gUnk_020354B0 < gRoomMemory + 8); - gUnk_020354B0 = sub_08049D88(); + } while (gCurrentRoomMemory < gRoomMemory + 8); + gCurrentRoomMemory = sub_08049D88(); } RoomMemory* sub_08049D88(void) { @@ -54,7 +55,7 @@ RoomMemory* sub_08049D88(void) { rm->room = gRoomControls.room; rm->unk_02 = 0xFFFF; - rm->unk_04 = 0; + rm->enemyBits = 0; sub_08049DCC(rm); diff --git a/src/code_08049DF4.c b/src/code_08049DF4.c index e9794e59..ebfd458c 100644 --- a/src/code_08049DF4.c +++ b/src/code_08049DF4.c @@ -10,8 +10,6 @@ extern Entity* gUnk_020000B0; extern Entity* (*const gUnk_080D3BE8[])(void); -extern void ReplaceMonitoredEntity(Entity*, Entity*); - Entity* sub_08049DF4(u32 arg0) { if (gUnk_020000B0 != NULL) { return gUnk_020000B0; @@ -311,21 +309,3 @@ bool32 sub_0804A4BC(u8* arg0, u8* arg1, s32 arg2, u32 arg3) { return TRUE; } - -void sub_0804A4E4(Entity* entA, Entity* entB) { - GenericEntity* r5 = (GenericEntity*)entA; - GenericEntity* r6 = (GenericEntity*)entB; - - r6->field_0x6c.HALF.HI = (r5->field_0x6c.HALF.HI & 0x40) | 4; - r6->field_0x6c.HALF.LO = r5->field_0x6c.HALF.LO; - r6->field_0x70.HALF.LO = r5->field_0x70.HALF.LO; - r6->field_0x70.HALF.HI = r5->field_0x70.HALF.HI; - r6->field_0x6e.HALF.LO = r5->field_0x6e.HALF.LO; - r6->field_0x6e.HALF.HI = r5->field_0x6e.HALF.HI; - - CopyPositionAndSpriteOffset(&r5->base, &r6->base); - - if (r5->field_0x6c.HALF.HI & 0x40) { - ReplaceMonitoredEntity(&r5->base, &r6->base); - } -} diff --git a/src/collision.c b/src/collision.c index 6ec7f5f3..d1408375 100644 --- a/src/collision.c +++ b/src/collision.c @@ -247,7 +247,7 @@ s32 CalculateDamage(Entity* org, Entity* tgt) { } health = org->health - damage; if (org->kind == ENEMY) { - if ((((GenericEntity*)org)->field_0x6c.HALF.HI & 1) != 0) + if (((Enemy*)org)->enemyFlags & EM_FLAG_BOSS) SoundReqClipped(org, SFX_BOSS_HIT); else SoundReqClipped(org, SFX_HIT); diff --git a/src/createEnemy.c b/src/createEnemy.c deleted file mode 100644 index 6c97985c..00000000 --- a/src/createEnemy.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "enemy.h" - -/** Unsets bitfield 0x80 before calling GetNextFunction, so that the enemyFunction 1 is not called. */ -void EnemyFunctionHandlerAfterCollision(Entity* entity, void (*const fntable[])()) { - u32 idx; - entity->contactFlags &= ~0x80; - idx = GetNextFunction(entity); - entity->contactFlags |= 0x80; - fntable[idx](entity); -} - -Entity* CreateEnemy(u32 subtype, u32 form) { - Entity* enemy; - - enemy = GetEmptyEntity(); - if (enemy != NULL) { - enemy->kind = ENEMY; - enemy->id = subtype; - enemy->type = form; - AppendEntityToList(enemy, 4); - } - return enemy; -} diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 84963d1f..ac12c313 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -81,7 +81,7 @@ void AcroBandit(AcroBanditEntity* this) { gUnk_080012C8[index](super); } else { AcroBandit_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } } @@ -150,7 +150,7 @@ void AcroBandit_OnCollision(AcroBanditEntity* this) { } if (super->confusedTime) - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); EnemyFunctionHandlerAfterCollision(super, AcroBandit_Functions); } diff --git a/src/enemy/armos.c b/src/enemy/armos.c index b0a28dbb..2824b950 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -83,7 +83,7 @@ void sub_08030150(ArmosEntity* this) { void Armos(ArmosEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)&gUnk_080CE124); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); sub_08030150(this); } @@ -101,7 +101,7 @@ void sub_080301D4(ArmosEntity* this) { sub_080309E8(this); } if (super->confusedTime != 0) { - Create0x68FX(super, 0x1c); + EnemyCreateFX(super, 0x1c); } this->unk_81 = super->health; EnemyFunctionHandlerAfterCollision(super, gUnk_080CE124); diff --git a/src/enemy/ballChainSoldier.c b/src/enemy/ballChainSoldier.c index b2a34518..bc6ff6d2 100644 --- a/src/enemy/ballChainSoldier.c +++ b/src/enemy/ballChainSoldier.c @@ -55,7 +55,7 @@ void BallChainSoldier_OnKnockback(BallChainSoldierEntity* this) { } void BallChainSoldier_OnDeath(BallChainSoldierEntity* this) { - CreateDeathFx(super, 0xff, 0x57); + EnemyCreateDeathFX((Enemy*)super, 0xff, 0x57); } void BallChainSoldier_OnGrabbed(BallChainSoldierEntity* this) { @@ -64,7 +64,7 @@ void BallChainSoldier_OnGrabbed(BallChainSoldierEntity* this) { void BallChainSoldier_Init(BallChainSoldierEntity* this) { Entity* entity; sub_0804A720(super); - entity = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0); + entity = EnemyCreateProjectile(super, BALL_AND_CHAIN, 0); if (entity == NULL) return; diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index d6b4d9f8..10263a30 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -70,7 +70,7 @@ void Beetle_OnDeath(BeetleEntity* this) { entity->subtimer--; super->parent = NULL; } - CreateDeathFx(super, 0xf0, 0); + EnemyCreateDeathFX((Enemy*)super, 0xf0, 0); } } diff --git a/src/enemy/bowMoblin.c b/src/enemy/bowMoblin.c index 93358b37..3a86b016 100644 --- a/src/enemy/bowMoblin.c +++ b/src/enemy/bowMoblin.c @@ -42,7 +42,7 @@ const s8 gUnk_080CFFC4[8]; void BowMoblin(Entity* this) { EnemyFunctionHandler(this, BowMoblin_Functions); - SetChildOffset(this, 0, 1, -0x18); + EnemySetFXOffset(this, 0, 1, -0x18); } void BowMoblin_OnTick(BowMoblinEntity* this) { @@ -53,7 +53,7 @@ void BowMoblin_OnCollision(BowMoblinEntity* this) { Entity* pEVar1; if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)BowMoblin_Functions); if ((super->contactFlags & 0x80) != 0) { @@ -213,7 +213,7 @@ void sub_0803C400(BowMoblinEntity* this) { switch (++super->timer) { case 1: super->direction = super->animationState << 2; - projectile = CreateProjectileWithParent(super, ARROW_PROJECTILE, super->animationState >> 1); + projectile = EnemyCreateProjectile(super, ARROW_PROJECTILE, super->animationState >> 1); if (projectile) { super->child = projectile; projectile->direction = (super->direction + 4) & 0x18; diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index dde81993..a770f1d9 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -153,7 +153,7 @@ void BusinessScrub_Action2(BusinessScrubEntity* this) { unk = 1; sub_080290FC(this); if (super->frame & 1) { - Entity* entity = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0); + Entity* entity = EnemyCreateProjectile(super, DEKU_SEED_PROJECTILE, 0); if (entity != NULL) { entity->parent = super; entity->direction = super->direction; @@ -220,7 +220,7 @@ void BusinessScrub_Action3(BusinessScrubEntity* this) { super->timer = 30; super->subtimer = 5; sub_080290E0(this, 0); - iVar1 = Create0x68FX(super, FX_STARS); + iVar1 = EnemyCreateFX(super, FX_STARS); if (iVar1 != NULL) { iVar1->spritePriority.b0 = 3; iVar1->z.HALF.HI -= 12; @@ -236,7 +236,7 @@ void BusinessScrub_Action3(BusinessScrubEntity* this) { sub_0800445C(super); } -extern void sub_0804AA1C(Entity*); +extern void EnemyDetachFX(Entity*); void sub_08028F0C(BusinessScrubEntity*); void BusinessScrub_Action4(BusinessScrubEntity* this) { @@ -244,7 +244,7 @@ void BusinessScrub_Action4(BusinessScrubEntity* this) { super->timer = 48; if (super->subtimer) { if (--super->subtimer == 0) { - sub_0804AA1C(super); + EnemyDetachFX(super); } } else if (sub_08028FDC(this) || this->unk_80) { this->unk_80 = 0; @@ -380,7 +380,7 @@ void sub_08028F0C(BusinessScrubEntity* this) { const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c; super->interactType = INTERACTION_NONE; - sub_0804AA1C(super); + EnemyDetachFX(super); super->direction = (GetAnimationState(super) << 3); sub_080290E0(this, 3); this->unk_80 = 1; diff --git a/src/enemy/businessScrubPrologue.c b/src/enemy/businessScrubPrologue.c index b7b7bc16..0f84737b 100644 --- a/src/enemy/businessScrubPrologue.c +++ b/src/enemy/businessScrubPrologue.c @@ -127,7 +127,7 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) { r6 = 1; sub_0804604C(this); if (super->frame & 1) { - entity = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0); + entity = EnemyCreateProjectile(super, DEKU_SEED_PROJECTILE, 0); if (entity != NULL) { entity->parent = super; entity->direction = super->direction; @@ -190,7 +190,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) { super->action = 5; super->subAction = 0; sub_08046030(this, 0); - entity = Create0x68FX(super, FX_STARS); + entity = EnemyCreateFX(super, FX_STARS); if (entity != NULL) { entity->spritePriority.b0 = 3; entity->z.HALF.HI -= 0xc; @@ -329,7 +329,7 @@ void sub_08046078(BusinessScrubPrologueEntity* this) { super->child->action = 0xff; } - sub_0804AA1C(super); + EnemyDetachFX(super); } void (*const BusinessScrubPrologue_Functions[])(Entity*) = { diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 8e72398d..41ac71c4 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -81,7 +81,7 @@ void Chuchu(ChuchuEntity* this) { this->unk_81 = index; Chuchu_Functions[GetNextFunction(super)](this); if (this->unk_68->type == 0x1c) { - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } else if (super->type == 2) { sub_0801FB34(this); } @@ -117,14 +117,14 @@ void Chuchu_OnCollision(ChuchuEntity* this) { if (health) { if (super->contactFlags == 0x94) { sub_0801FB68(this); - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); InitializeAnimation(super, 6); } else if (this->unk_80 != health) { sub_0801FB68(this); InitializeAnimation(super, 6); } } else { - sub_0804AA1C(super); + EnemyDetachFX(super); super->zVelocity = 0; InitializeAnimation(super, 9); } @@ -134,7 +134,7 @@ void Chuchu_OnCollision(ChuchuEntity* this) { void Chuchu_OnGrabbed(ChuchuEntity* this) { if (!sub_0806F520(super) && super->confusedTime) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); InitializeAnimation(super, 6); } else { if (super->animIndex != 8) { @@ -158,9 +158,9 @@ void Chuchu_OnDeath(ChuchuEntity* this) { if (super->type == 0) { GenericDeath(super); } else if (super->type == 1) { - CreateDeathFx(super, 0xf2, 0); + EnemyCreateDeathFX((Enemy*)super, 0xf2, 0); } else { - CreateDeathFx(super, 0xf1, 0); + EnemyCreateDeathFX((Enemy*)super, 0xf1, 0); } } @@ -289,7 +289,7 @@ void sub_0801F2F8(ChuchuEntity* this) { GetNextFrame(super); if (super->frame & ANIM_DONE) { sub_0801F340(this); - sub_0804AA1C(super); + EnemyDetachFX(super); } } @@ -488,7 +488,7 @@ void sub_0801F6F8(ChuchuEntity* this) { if (super->frame & ANIM_DONE) { super->action = 4; super->speed = 0x20; - sub_0804AA1C(super); + EnemyDetachFX(super); InitializeAnimation(super, 2); } } @@ -561,7 +561,7 @@ void sub_0801F884(ChuchuEntity* this) { if (super->subtimer) { super->subtimer--; } else { - Entity* entity = Create0x68FX(super, FX_LIGHTNING_STRIKE); + Entity* entity = EnemyCreateFX(super, FX_LIGHTNING_STRIKE); if (entity != NULL) { entity->type2 = 64; super->action = 4; @@ -653,7 +653,7 @@ void sub_0801FA78(ChuchuEntity* this) { super->action = 1; super->spriteSettings.draw = 0; InitializeAnimation(super, 4); - sub_0804AA1C(super); + EnemyDetachFX(super); } } @@ -663,7 +663,7 @@ void sub_0801FAAC(ChuchuEntity* this) { if (super->frame & ANIM_DONE) { sub_0801FB14(this); super->speed = 0x20; - sub_0804AA1C(super); + EnemyDetachFX(super); } } @@ -707,7 +707,7 @@ void sub_0801FB68(ChuchuEntity* this) { case 2: super->action = 10; super->hitType = 92; - sub_0804AA1C(super); + EnemyDetachFX(super); break; } diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index 00488c3c..ca490003 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -283,9 +283,9 @@ void ChuchuBoss_OnDeath(ChuchuBossEntity* this) { break; case 1: if (this->unk_7d-- == 0) { - ((GenericEntity*)super->child)->field_0x6c.HALF.HI |= 2; + ((Enemy*)super->child)->enemyFlags |= EM_FLAG_BOSS_KILLED; this->unk_68->unk_6d.unk1 = 1; - ((GenericEntity*)super->parent)->field_0x6c.HALF.HI |= 2; + ((Enemy*)super->parent)->enemyFlags |= EM_FLAG_BOSS_KILLED; parent = super->child; child = super->parent; this->unk_68->base.health = 0; diff --git a/src/enemy/cloudPiranha.c b/src/enemy/cloudPiranha.c index dbe78f28..14296cd6 100644 --- a/src/enemy/cloudPiranha.c +++ b/src/enemy/cloudPiranha.c @@ -41,7 +41,7 @@ void (*const gUnk_080CF4F0[])(CloudPiranhaEntity*) = { void CloudPiranha(CloudPiranhaEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)&gUnk_080CF4F0); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void CloudPiranha_OnTick(CloudPiranhaEntity* this) { @@ -55,7 +55,7 @@ void CloudPiranha_OnTick(CloudPiranhaEntity* this) { void CloudPiranha_OnCollision(CloudPiranhaEntity* this) { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, gUnk_080CF4F0); if ((super->contactFlags & 0x80) != 0) { diff --git a/src/enemy/cuccoAggr.c b/src/enemy/cuccoAggr.c index 45c7f863..bf749082 100644 --- a/src/enemy/cuccoAggr.c +++ b/src/enemy/cuccoAggr.c @@ -50,7 +50,7 @@ void CuccoAggr(Entity* this) { gUnk_080012C8[index](this); } else { CuccoAggr_Functions[GetNextFunction(this)](this); - SetChildOffset(this, 0, 1, -0x10); + EnemySetFXOffset(this, 0, 1, -0x10); sub_080391B4((CuccoAggrEntity*)this); } } @@ -74,7 +74,7 @@ void CuccoAggr_OnCollision(CuccoAggrEntity* this) { } if (super->confusedTime) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, CuccoAggr_Functions); diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index 9192857d..f5d0919e 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -67,7 +67,7 @@ extern void (*const gUnk_080CAB58[])(DarkNutEntity*); void DarkNut(DarkNutEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)DarkNut_Functions); - SetChildOffset(super, 0, 1, -22); + EnemySetFXOffset(super, 0, 1, -22); } void DarkNut_OnTick(DarkNutEntity* this) { @@ -82,7 +82,7 @@ void DarkNut_OnCollision(DarkNutEntity* this) { super->hitType = 81; sub_08021218(this, 8, DirectionToAnimationState(super->knockbackDirection ^ 0x10)); sub_08021588(this); - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); break; case 0x16: super->action = 11; @@ -90,7 +90,7 @@ void DarkNut_OnCollision(DarkNutEntity* this) { super->hitType = 81; sub_08021218(this, 8, DirectionToAnimationState(super->knockbackDirection ^ 0x10)); sub_08021588(this); - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); break; case 0x4b: if (super->action == 13 || super->action == 15 || super->action == 19 || super->action == 18) @@ -128,7 +128,7 @@ void DarkNut_OnCollision(DarkNutEntity* this) { if (super->health != this->unk_78) { sub_08021588(this); sub_08021390(this); - sub_0804AA1C(super); + EnemyDetachFX(super); } break; } @@ -240,7 +240,7 @@ void sub_08020F48(DarkNutEntity* this) { super->action = 14; sub_08021218(this, 13, uVar2 >> 3); - pEVar3 = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 1); + pEVar3 = EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 1); if (pEVar3) { pEVar3->parent = super; super->child = pEVar3; @@ -272,7 +272,7 @@ void sub_08020FE4(DarkNutEntity* this) { if (--super->timer == 0) { super->action = 12; sub_08021218(this, 9, super->animationState); - sub_0804AA1C(super); + EnemyDetachFX(super); } } @@ -286,7 +286,7 @@ void sub_08021010(DarkNutEntity* this) { void sub_08021038(DarkNutEntity* this) { if (super->child == NULL && super->frame) { - Entity* pEVar2 = (Entity*)CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 0); + Entity* pEVar2 = (Entity*)EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 0); if (pEVar2) { pEVar2->parent = super; super->child = pEVar2; @@ -325,7 +325,7 @@ void sub_080210E4(DarkNutEntity* this) { Entity* entity; super->frame &= ~1; - entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 2); + entity = EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 2); if (entity != NULL) { entity->parent = super; super->child = entity; @@ -594,7 +594,7 @@ void sub_0802159C(DarkNutEntity* this) { super->frame = 0; super->hitType = 0x51; - entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 3); + entity = EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 3); if (entity != NULL) { entity->parent = super; super->child = entity; @@ -615,7 +615,7 @@ void sub_08021600(DarkNutEntity* this) { super->frame = 0; super->hitType = 0x51; - entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 4); + entity = EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 4); if (entity != NULL) { entity->parent = super; super->child = entity; diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index 5885ef40..344e284b 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -50,7 +50,7 @@ void DoorMimic_OnCollision(DoorMimicEntity* this) { void DoorMimic_OnDeath(DoorMimicEntity* this) { SetTile(this->unk_7c, this->unk_7e, super->collisionLayer); CreateFx(super, FX_POT_SHATTER, 0); - sub_08049CF4(super); + EnemyDisableRespawn(super); DeleteThisEntity(); } diff --git a/src/enemy/enemy4D.c b/src/enemy/enemy4D.c index f333f9cb..4fe0acfa 100644 --- a/src/enemy/enemy4D.c +++ b/src/enemy/enemy4D.c @@ -90,7 +90,7 @@ void Enemy4D_OnKnockback(Enemy4DEntity* this) { } void Enemy4D_OnDeath(Enemy4DEntity* this) { - CreateDeathFx(super, 0xff, 0x57); + EnemyCreateDeathFX((Enemy*)super, 0xff, 0x57); } void Enemy4D_OnGrabbed(Enemy4DEntity* this) { @@ -100,7 +100,7 @@ void Enemy4D_Init(Enemy4DEntity* this) { Entity* projectile; sub_0804A720(super); - projectile = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0); + projectile = EnemyCreateProjectile(super, BALL_AND_CHAIN, 0); if (projectile != NULL) { projectile->parent = super; super->child = projectile; diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index bb18b5bd..3839aabf 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -65,7 +65,7 @@ void Enemy50(Enemy50Entity* this) { DeleteThisEntity(); } Enemy50_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void Enemy50_OnTick(Enemy50Entity* this) { @@ -93,7 +93,7 @@ void Enemy50_OnCollision(Enemy50Entity* this) { if (super->confusedTime != 0) { super->animationState = super->knockbackDirection >> 4; InitializeAnimation(super, super->animationState + 7); - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } if (super->health != this->unk_7a) { if (super->type == 0) { diff --git a/src/enemy/ghini.c b/src/enemy/ghini.c index 5b408126..e49b8293 100644 --- a/src/enemy/ghini.c +++ b/src/enemy/ghini.c @@ -44,7 +44,7 @@ void sub_0803F528(GhiniEntity*); void Ghini(GhiniEntity* this) { Ghini_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void Ghini_OnTick(GhiniEntity* this) { @@ -69,7 +69,7 @@ void Ghini_OnCollision(GhiniEntity* this) { if (super->confusedTime != 0) { super->animationState = super->knockbackDirection >> 4; InitializeAnimation(super, super->animationState + 7); - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } if (super->health != this->unk_7a) { this->unk_7a = super->health; diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index 0732a282..5da67ddf 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -44,7 +44,7 @@ extern Entity* gUnk_020000B0; void Gibdo(Entity* this) { EnemyFunctionHandler(this, Gibdo_Functions); - SetChildOffset(this, 0, 1, -0x15); + EnemySetFXOffset(this, 0, 1, -0x15); } void Gibdo_OnTick(GibdoEntity* this) { @@ -83,7 +83,7 @@ void Gibdo_OnCollision(GibdoEntity* this) { } } if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Gibdo_Functions); } @@ -192,7 +192,7 @@ void sub_0803775C(GibdoEntity* this) { if (--super->timer == 0) { stalfos = CreateEnemy(STALFOS, 0); if (stalfos != NULL) { - sub_0804A4E4(super, stalfos); + EnemyCopyParams(super, stalfos); Gibdo_MoveObjectsToStalfos(this, stalfos); } DeleteEntity(super); diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index 19399037..dfbbd62c 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -300,7 +300,7 @@ void sub_0802D33C(GleerokEntity* this) { } unk_84->entities[i]->health = 0; - ((GenericEntity*)unk_84->entities[i])->field_0x6c.HALF.HI |= 1; + ((Enemy*)(unk_84->entities[i]))->enemyFlags |= EM_FLAG_BOSS; unk_84->ent2->health = 0; unk_84->ent2->type2 = 0; unk_84->ent2->spriteSettings.draw &= ~1; @@ -815,7 +815,7 @@ void sub_0802DCE0(GleerokEntity* this) { } } else { if (this->unk_84->ent2->subtimer == 0) { - super->child = CreateProjectileWithParent(super, GLEEROK_PROJECTILE, 0); + super->child = EnemyCreateProjectile(super, GLEEROK_PROJECTILE, 0); if (super->child != NULL) { super->child->direction = this->unk_84->filler[5].unk0.HALF.HI; @@ -883,7 +883,7 @@ void sub_0802DDD8(GleerokEntity* this) { } if (this->unk_84->ent2->subtimer == 1) { - super->child = CreateProjectileWithParent(super, GLEEROK_PROJECTILE, r2); + super->child = EnemyCreateProjectile(super, GLEEROK_PROJECTILE, r2); if (super->child != NULL) { super->child->direction = this->unk_84->filler[5].unk0.HALF.HI; super->child->type2 = this->unk_84->ent2->frame & 0xf; @@ -1160,7 +1160,7 @@ void sub_0802E300(GleerokEntity* this) { heap->ent2->timer = 24; } else { if ((gRoomTransition.frameCount & 0xf) == 0) { - CreateProjectileWithParent(super, GLEEROK_PROJECTILE, 0x3); + EnemyCreateProjectile(super, GLEEROK_PROJECTILE, 0x3); } } diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index e1cb2a51..4a43753e 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -39,7 +39,7 @@ extern const s8 gUnk_080CD464[]; void Helmasaur(HelmasaurEntity* this) { if (super->type == 0) { EnemyFunctionHandler(super, (EntityActionArray)Helmasaur_Functions); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } else { gUnk_080CD3FC[super->action](this); } @@ -63,7 +63,7 @@ void Helmasaur_OnCollision(HelmasaurEntity* this) { } } if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Helmasaur_Functions); diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index c92b2ade..d499adad 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -51,7 +51,7 @@ void sub_080327E0(KeatonEntity* this); void Keaton(KeatonEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)Keaton_Functions); - SetChildOffset(super, 0, 1, -18); + EnemySetFXOffset(super, 0, 1, -18); } void Keaton_OnTick(KeatonEntity* this) { @@ -75,7 +75,7 @@ void Keaton_OnCollision(KeatonEntity* this) { } } if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Keaton_Functions); } @@ -262,7 +262,7 @@ void sub_08032794(KeatonEntity* this) { void sub_080327C8(KeatonEntity* this) { Entity* child; - child = CreateProjectileWithParent(super, KEATON_DAGGER, 0); + child = EnemyCreateProjectile(super, KEATON_DAGGER, 0); if (child != NULL) { child->parent = super; super->child = child; diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 107afd16..740ceb54 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -54,7 +54,7 @@ extern const OffsetCoords gUnk_080D0154[]; void Lakitu(LakituEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)Lakitu_Functions); - SetChildOffset(super, 0, 1, -16); + EnemySetFXOffset(super, 0, 1, -16); } void Lakitu_OnTick(LakituEntity* this) { @@ -96,7 +96,7 @@ void Lakitu_OnCollision(LakituEntity* this) { } if (super->confusedTime) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Lakitu_Functions); @@ -128,7 +128,7 @@ void sub_0803C86C(LakituEntity* this) { } void Lakitu_Initialize(LakituEntity* this) { - Entity* cloud = CreateProjectileWithParent(super, 17, 0); + Entity* cloud = EnemyCreateProjectile(super, 17, 0); if (cloud == NULL) { return; } @@ -313,7 +313,7 @@ void Lakitu_SpawnLightning(LakituEntity* this) { Entity* lightning; const OffsetCoords* offset; - lightning = CreateProjectileWithParent(super, LAKITU_LIGHTNING, 0); + lightning = EnemyCreateProjectile(super, LAKITU_LIGHTNING, 0); if (lightning == NULL) { return; diff --git a/src/enemy/leever.c b/src/enemy/leever.c index 647c9a86..3f8937b3 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -39,7 +39,7 @@ enum { void Leever(LeeverEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)Leever_Functions); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void Leever_OnTick(LeeverEntity* this) { @@ -53,7 +53,7 @@ void Leever_OnCollision(LeeverEntity* this) { } } else { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } } EnemyFunctionHandlerAfterCollision(super, Leever_Functions); @@ -63,7 +63,7 @@ void Leever_OnDeath(LeeverEntity* this) { if (super->type == LeeverForm_Red) { GenericDeath(super); } else { - CreateDeathFx(super, 0xf1, 0); + EnemyCreateDeathFX((Enemy*)super, 0xf1, 0); } } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index fef316b6..85919220 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -31,7 +31,7 @@ extern void (*const gUnk_080CC714[])(LikeLikeEntity*); void LikeLike(Entity* this) { EnemyFunctionHandler(this, LikeLike_Functions); - SetChildOffset(this, 0, 1, -0x10); + EnemySetFXOffset(this, 0, 1, -0x10); } void LikeLike_OnTick(LikeLikeEntity* this) { @@ -63,7 +63,7 @@ void LikeLike_OnCollision(LikeLikeEntity* this) { } if (super->confusedTime) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, LikeLike_Functions); diff --git a/src/enemy/miniSlime.c b/src/enemy/miniSlime.c index bef76f86..856651e6 100644 --- a/src/enemy/miniSlime.c +++ b/src/enemy/miniSlime.c @@ -36,7 +36,7 @@ static void (*const MiniSlime_Functions[])(MiniSlimeEntity*) = { void MiniSlime(MiniSlimeEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)MiniSlime_Functions); - SetChildOffset(super, 0, 1, -8); + EnemySetFXOffset(super, 0, 1, -8); } void MiniSlime_OnTick(MiniSlimeEntity* this) { @@ -51,7 +51,7 @@ void MiniSlime_OnTick(MiniSlimeEntity* this) { void MiniSlime_OnCollision(MiniSlimeEntity* this) { if (super->confusedTime) - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); EnemyFunctionHandlerAfterCollision(super, MiniSlime_Functions); } diff --git a/src/enemy/mulldozer.c b/src/enemy/mulldozer.c index fbc3f09c..b9911272 100644 --- a/src/enemy/mulldozer.c +++ b/src/enemy/mulldozer.c @@ -43,7 +43,7 @@ void sub_080332E8(MulldozerEntity*, s32); void Mulldozer(MulldozerEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)Mulldozer_Functions); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void Mulldozer_OnInit(MulldozerEntity* this) { @@ -52,7 +52,7 @@ void Mulldozer_OnInit(MulldozerEntity* this) { void Mulldozer_OnCollision(MulldozerEntity* this) { if (super->confusedTime != 0) { - Create0x68FX(super, 0x1c); + EnemyCreateFX(super, 0x1c); } EnemyFunctionHandlerAfterCollision(super, Mulldozer_Functions); if ((super->contactFlags & 0x80) != 0) { diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c index d33a9a54..bdf9c73f 100644 --- a/src/enemy/octorok.c +++ b/src/enemy/octorok.c @@ -24,7 +24,7 @@ extern const s8 gUnk_080CA17E[2]; // Main void Octorok(Entity* this) { EnemyFunctionHandler(this, Octorok_Functions); - SetChildOffset(this, 0, 1, -16); + EnemySetFXOffset(this, 0, 1, -16); } // Idle @@ -35,7 +35,7 @@ void Octorok_OnTick(Entity* this) { // Touch player void Octorok_OnCollision(Entity* this) { if (this->confusedTime != 0) { - Create0x68FX(this, FX_STARS); + EnemyCreateFX(this, FX_STARS); } EnemyFunctionHandlerAfterCollision(this, Octorok_Functions); } @@ -45,7 +45,7 @@ void Octorok_OnDeath(Entity* this) { if (this->type == 0) { GenericDeath(this); } else { - CreateDeathFx(this, 241, 0); + EnemyCreateDeathFX((Enemy*)this, 241, 0); } } @@ -127,7 +127,7 @@ void Octorok_Move(Entity* this) { void Octorok_ShootNut(Entity* this) { GetNextFrame(this); if (this->frame & 1) { - Entity* entity = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0); + Entity* entity = EnemyCreateProjectile(this, ROCK_PROJECTILE, 0); if (entity != NULL) { const s8* off; entity->direction = this->direction; diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index 4b3531f8..762ba7e2 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -342,7 +342,7 @@ void OctorokBoss_Init(OctorokBossEntity* this) { (this->heap)->field_0x2 = 0; (this->heap)->tailCount = 5; super->spriteRendering.b0 = 3; - this->field_0x6c.HALF.HI |= 1; + ((Enemy*)this)->enemyFlags |= EM_FLAG_BOSS; this->unk_76 = 0xa0; this->unk_74 = 0xa0; this->angle.HWORD = 0; @@ -556,7 +556,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) { case LEG_FR: case LEG_FL: case LEG_BL: - if ((((OctorokBossEntity*)super->parent)->field_0x6c.HALF.HI & 2) != 0) { + if (((Enemy*)super->parent)->enemyFlags & EM_FLAG_BOSS_KILLED) { DeleteThisEntity(); } if (this->heap->mouthObject->base.health == 1) { @@ -676,7 +676,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) { this->heap->fallingStonesTimer--; if ((gRoomTransition.frameCount & 3) == 0) { // Falling stones - CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 3); + EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 3); } } OctorokBoss_Action1_SubActions[super->subAction](this); @@ -883,7 +883,7 @@ void OctorokBoss_Action1_Attack_Type2_3(OctorokBossEntity* this) { } void OctorokBoss_ExecuteAttackSpitRock(OctorokBossEntity* this) { - super->child = CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 0); + super->child = EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 0); if (super->child != NULL) { super->child->parent = super; super->child->direction = ((u8) - this->angle.HALF.HI ^ 0x80); @@ -1002,7 +1002,7 @@ void OctorokBoss_ExecuteAttackFreeze(OctorokBossEntity* this) { } else { this->timer--; if ((gRoomTransition.frameCount & 3) == 0) { - super->child = CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 2); + super->child = EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 2); if (super->child != NULL) { super->child->parent = super; super->child->direction = (u8) - this->angle.HALF.HI ^ 0x80; @@ -1022,7 +1022,7 @@ void OctorokBoss_Burning(OctorokBossEntity* this) { this->heap->fallingStonesTimer--; if ((gRoomTransition.frameCount & 7) == 0) { // Falling stones - CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 3); + EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 3); } } SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD); diff --git a/src/enemy/octorokGolden.c b/src/enemy/octorokGolden.c index 80342aa7..82bb3c8f 100644 --- a/src/enemy/octorokGolden.c +++ b/src/enemy/octorokGolden.c @@ -26,7 +26,7 @@ void OctorokGolden(Entity* this) { gUnk_080012C8[index](this); } else { OctorokGolden_Functions[GetNextFunction(this)](this); - SetChildOffset(this, 0, 1, -0x10); + EnemySetFXOffset(this, 0, 1, -0x10); } } @@ -36,7 +36,7 @@ void OctorokGolden_OnTick(Entity* this) { void OctorokGolden_OnCollision(Entity* this) { if (this->confusedTime != 0) { - Create0x68FX(this, FX_STARS); + EnemyCreateFX(this, FX_STARS); } EnemyFunctionHandlerAfterCollision(this, OctorokGolden_Functions); @@ -47,7 +47,7 @@ void OctorokGolden_OnDeath(Entity* this) { SetGlobalFlag(this->type2); } - CreateDeathFx(this, 0xff, ITEM_RUPEE100); + EnemyCreateDeathFX((Enemy*)this, 0xff, ITEM_RUPEE100); } void sub_08037CE4(Entity* this) { @@ -83,7 +83,7 @@ static void sub_08037D54(Entity* this) { this->frame ^= 2; if (this->frame & 0x2) { - Entity* proj = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0); + Entity* proj = EnemyCreateProjectile(this, ROCK_PROJECTILE, 0); if (proj) { const s8* ptr; s32 dir; diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index eeae83f8..d4c0e3d8 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -47,7 +47,7 @@ enum { void Peahat(PeahatEntity* this) { if (super->type == PeahatForm_Torso) { EnemyFunctionHandler(super, (EntityActionArray)Peahat_Functions); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } else { gPeahatPropellerFunctions[super->action](this); } @@ -94,7 +94,7 @@ void Peahat_OnCollision(PeahatEntity* this) { } if (super->confusedTime) - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); EnemyFunctionHandlerAfterCollision(super, Peahat_Functions); } @@ -267,14 +267,14 @@ void Peahat_Stunned(PeahatEntity* this) { void Peahat_RepairPropeller(PeahatEntity* this) { if ((super->subtimer != 0) && (--super->subtimer == 0)) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } if (sub_0800442E(super) || (--super->timer == 0)) { super->action = 9; super->zVelocity = Q_16_16(1.5); super->direction = Random() & 0x1f; - sub_0804AA1C(super); + EnemyDetachFX(super); super->animationState = PeahatAnimation_RepairPropeller; InitializeAnimation(super, super->animationState); } @@ -282,14 +282,14 @@ void Peahat_RepairPropeller(PeahatEntity* this) { void Peahat_Recover(PeahatEntity* this) { if ((super->subtimer != 0) && (--super->subtimer == 0)) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } if (sub_0800442E(super) || (--super->timer == 0)) { super->action = 8; super->timer = 240; super->direction = Random() & 0x1f; - sub_0804AA1C(super); + EnemyDetachFX(super); } } diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 037bd7db..b3f6cfdc 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -185,7 +185,7 @@ void sub_080240B8(PestoEntity* this) { Entity* entity; this->unk_83 = 0; - entity = CreateProjectileWithParent(super, DIRT_BALL_PROJECTILE, this->unk_83); + entity = EnemyCreateProjectile(super, DIRT_BALL_PROJECTILE, this->unk_83); if (entity != NULL) { super->child = entity; entity->parent = super; @@ -428,7 +428,7 @@ void sub_080244E8(PestoEntity* this) { super->z.HALF.HI -= 0xe; this->unk_78 -= 0xe; - entity = CreateProjectileWithParent(super, DIRT_BALL_PROJECTILE, this->unk_83); + entity = EnemyCreateProjectile(super, DIRT_BALL_PROJECTILE, this->unk_83); if (entity != NULL) { entity->parent = super; entity->z.HALF.HI += 0xe; @@ -451,7 +451,7 @@ void sub_080244E8(PestoEntity* this) { super->z.HALF.HI -= 0xe; this->unk_78 -= 0xe; - entity = CreateProjectileWithParent(super, DIRT_BALL_PROJECTILE, this->unk_83); + entity = EnemyCreateProjectile(super, DIRT_BALL_PROJECTILE, this->unk_83); if (entity != NULL) { entity->parent = super; entity->z.HALF.HI += 0xe; diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index dca8086a..7018c562 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -56,7 +56,7 @@ extern const s8 gUnk_080CC0C2[]; void Puffstool(PuffstoolEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)Puffstool_Functions); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void Puffstool_OnTick(PuffstoolEntity* this) { @@ -71,7 +71,7 @@ void Puffstool_OnCollide(PuffstoolEntity* this) { /* ... */ break; case 0x1b: - sub_0804AA1C(super); + EnemyDetachFX(super); tmp = gUnk_080CBFE8[(*(Entity**)&super->contactedEntity)->type]; if (tmp < this->unk_82) { @@ -132,7 +132,7 @@ void sub_08025180(PuffstoolEntity* this) { super->timer = Random(); super->animationState = (((*(Entity**)&super->contactedEntity)->direction ^ 0x10) >> 3); InitializeAnimation(super, super->animationState + 4); - sub_0804AA1C(super); + EnemyDetachFX(super); } void sub_080251AC(PuffstoolEntity* this) { @@ -291,7 +291,7 @@ void sub_080254B4(PuffstoolEntity* this) { sub_080256B4(this); } else { super->action = 0xc; - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } InitializeAnimation(super, 0); } @@ -375,7 +375,7 @@ void sub_0802563C(PuffstoolEntity* this) { super->hitType = 0x82; this->unk_82 = 240; sub_080256B4(this); - sub_0804AA1C(super); + EnemyDetachFX(super); } else if (this->unk_84 < 120) { u32 tmp3 = gUnk_080CBFF8[this->unk_84 >> 4]; if ((this->unk_84 & tmp3) == 0) { diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index dc3af233..f6eba66d 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -49,7 +49,7 @@ void RockChuchu_OnCollision(Entity* this) { #ifndef EU entity->iframes = -8; #endif - sub_0804A4E4(this, entity); + EnemyCopyParams(this, entity); this->action = 2; COLLISION_OFF(this); this->spriteSettings.draw = 0; diff --git a/src/enemy/rope.c b/src/enemy/rope.c index 79fa291b..51e71250 100644 --- a/src/enemy/rope.c +++ b/src/enemy/rope.c @@ -42,7 +42,7 @@ u32 sub_0803163C(RopeEntity* this); void Rope(RopeEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)Rope_Functions); - SetChildOffset(super, 0, 1, -16); + EnemySetFXOffset(super, 0, 1, -16); } void Rope_OnTick(RopeEntity* this) { @@ -62,7 +62,7 @@ void Rope_OnCollision(RopeEntity* this) { sub_08031600(this); } if (super->confusedTime) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Rope_Functions); } diff --git a/src/enemy/ropeGolden.c b/src/enemy/ropeGolden.c index fd83dc53..0e653b80 100644 --- a/src/enemy/ropeGolden.c +++ b/src/enemy/ropeGolden.c @@ -45,7 +45,7 @@ void RopeGolden(RopeGoldenEntity* this) { gUnk_080012C8[x](super); } else { RopeGolden_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } } @@ -61,7 +61,7 @@ void RopeGolden_OnTick(RopeGoldenEntity* this) { void RopeGolden_OnCollision(RopeGoldenEntity* this) { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, RopeGolden_Functions); } @@ -70,7 +70,7 @@ void RopeGolden_OnDeath(RopeGoldenEntity* this) { if ((super->gustJarState & 2) == 0) { SetGlobalFlag(super->type2); } - CreateDeathFx(super, 0xff, ITEM_RUPEE100); + EnemyCreateDeathFX((Enemy*)super, 0xff, ITEM_RUPEE100); } void sub_08038258(RopeGoldenEntity* this) { diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index b749e900..4831bf3b 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -48,7 +48,7 @@ void RupeeLike(RupeeLikeEntity* this) { sub_08001290(super, uVar1); } else { RupeeLike_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } } else { sub_080293DC(this); @@ -80,7 +80,7 @@ void RupeeLike_OnCollision(RupeeLikeEntity* this) { EnqueueSFX(SFX_PLACE_OBJ); } else { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } } } @@ -88,7 +88,7 @@ void RupeeLike_OnCollision(RupeeLikeEntity* this) { } void RupeeLike_OnDeath(RupeeLikeEntity* this) { - CreateDeathFx(super, 0xff, gUnk_080CCC34[this->unk_84 * 3 + super->type]); + EnemyCreateDeathFX((Enemy*)super, 0xff, gUnk_080CCC34[this->unk_84 * 3 + super->type]); } void RupeeLike_OnGrabbed(RupeeLikeEntity* this) { diff --git a/src/enemy/scissorsBeetle.c b/src/enemy/scissorsBeetle.c index 7b76a9fd..34aca2b2 100644 --- a/src/enemy/scissorsBeetle.c +++ b/src/enemy/scissorsBeetle.c @@ -30,7 +30,7 @@ void sub_08038B90(ScissorsBeetleEntity*); void ScissorsBeetle(Entity* this) { EnemyFunctionHandler(this, ScissorsBeetle_Functions); - SetChildOffset(this, 0, 1, -0x10); + EnemySetFXOffset(this, 0, 1, -0x10); } void ScissorsBeetle_OnTick(ScissorsBeetleEntity* this) { @@ -40,7 +40,7 @@ void ScissorsBeetle_OnTick(ScissorsBeetleEntity* this) { void ScissorsBeetle_OnCollision(ScissorsBeetleEntity* this) { Entity* child; if (super->confusedTime) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, ScissorsBeetle_Functions); diff --git a/src/enemy/slime.c b/src/enemy/slime.c index 81565493..813a6026 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -40,7 +40,7 @@ static void (*const Slime_Functions[])(SlimeEntity*) = { void Slime(SlimeEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)Slime_Functions); - SetChildOffset(super, 0, 1, -12); + EnemySetFXOffset(super, 0, 1, -12); } void Slime_OnTick(SlimeEntity* this) { @@ -58,7 +58,7 @@ void Slime_OnCollision(SlimeEntity* this) { } if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } } @@ -149,7 +149,7 @@ void sub_08045178(SlimeEntity* this, Entity* child, int h, int v) { if (child == NULL) return; - sub_0804A4E4(super, child); + EnemyCopyParams(super, child); if (sub_080B1AF0(child, h, v)) return; diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c index 2397c3aa..cd371ec4 100644 --- a/src/enemy/sluggula.c +++ b/src/enemy/sluggula.c @@ -23,7 +23,7 @@ void Sluggula(Entity* this) { if (this->type == 1) { EnemyFunctionHandler(this, Sluggula_Functions); - SetChildOffset(this, 0, 1, -0x10); + EnemySetFXOffset(this, 0, 1, -0x10); } else if (this->type == 0) { if (this->z.HALF.HI == 0) { u32 idx = sub_080012DC(this); @@ -34,7 +34,7 @@ void Sluggula(Entity* this) { } gUnk_080CBDD4[GetNextFunction(this)](this); - SetChildOffset(this, 0, 1, -0x10); + EnemySetFXOffset(this, 0, 1, -0x10); } else { sub_08023E10(this); } @@ -46,7 +46,7 @@ void Sluggula_OnTick(Entity* this) { void Sluggula_OnCollision(Entity* this) { if (this->confusedTime) - Create0x68FX(this, FX_STARS); + EnemyCreateFX(this, FX_STARS); if (this->type == 1) { EnemyFunctionHandlerAfterCollision(this, Sluggula_Functions); @@ -130,7 +130,7 @@ void sub_08023CE0(Entity* this) { if (this->frame & ANIM_DONE) { Entity* entity = CreateEnemy(SLUGGULA, 1); if (entity != NULL) { - sub_0804A4E4(this, entity); + EnemyCopyParams(this, entity); DeleteThisEntity(); } } else { diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index 089f0ba8..ac61f57e 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -42,7 +42,7 @@ extern const Hitbox* const gUnk_080CC944[]; void SpearMoblin(SpearMoblinEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)SpearMoblin_Functions); - SetChildOffset(super, 0, 1, -0x20); + EnemySetFXOffset(super, 0, 1, -0x20); if (super->child && super->child->next) { CopyPosition(super, super->child); } @@ -54,7 +54,7 @@ void SpearMoblin_OnTick(SpearMoblinEntity* this) { void SpearMoblin_OnCollision(SpearMoblinEntity* this) { if (super->confusedTime != 0) - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); EnemyFunctionHandlerAfterCollision(super, SpearMoblin_Functions); if (super->contactFlags & 0x80) { diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index 3a282359..4dcd1ec3 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -22,7 +22,7 @@ extern const s8 gUnk_080CD318[]; void SpikedBeetle(Entity* this) { EnemyFunctionHandler(this, SpikedBeetle_Functions); - SetChildOffset(this, 0, 1, -0x10); + EnemySetFXOffset(this, 0, 1, -0x10); } void SpikedBeetle_OnTick(Entity* this) { @@ -63,7 +63,7 @@ void SpikedBeetle_OnCollision(Entity* this) { } } if (this->confusedTime) { - Create0x68FX(this, FX_STARS); + EnemyCreateFX(this, FX_STARS); } EnemyFunctionHandlerAfterCollision(this, SpikedBeetle_Functions); } diff --git a/src/enemy/spinyBeetle.c b/src/enemy/spinyBeetle.c index 67cb1ebd..ebaa6322 100644 --- a/src/enemy/spinyBeetle.c +++ b/src/enemy/spinyBeetle.c @@ -36,7 +36,7 @@ extern u32 sub_0804A024(Entity*, u32, u32); void SpinyBeetle(Entity* this) { EnemyFunctionHandler(this, SpinyBeetle_Functions); - SetChildOffset(this, 0, 1, -0x10); + EnemySetFXOffset(this, 0, 1, -0x10); } void SpinyBeetle_OnTick(SpinyBeetleEntity* this) { @@ -45,7 +45,7 @@ void SpinyBeetle_OnTick(SpinyBeetleEntity* this) { void SpinyBeetle_OnCollision(SpinyBeetleEntity* this) { if (super->confusedTime) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, SpinyBeetle_Functions); diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index 03b7f09c..0028054f 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -27,7 +27,7 @@ extern Entity* gUnk_020000B0; void SpinyChuchu(SpinyChuchuEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)SpinyChuchu_Functions); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void SpinyChuchu_OnTick(SpinyChuchuEntity* this) { @@ -55,13 +55,13 @@ void SpinyChuchu_OnCollision(SpinyChuchuEntity* this) { case 0x18: case 0x19: case 0x1a: - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); super->action = 5; super->hitType = 0x5c; InitializeAnimation(super, 1); } } else if (super->contactFlags == 0x94) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); super->action = 5; InitializeAnimation(super, 1); } @@ -216,7 +216,7 @@ void sub_0802281C(SpinyChuchuEntity* this) { super->action = 2; super->speed = 0x20; InitializeAnimation(super, 0); - sub_0804AA1C(super); + EnemyDetachFX(super); } } diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index 98e75b9c..6c86aa18 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -48,7 +48,7 @@ u32 sub_08039B28(StalfosEntity*); void Stalfos(StalfosEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)&Stalfos_Functions); - SetChildOffset(super, 0, 1, -0x12); + EnemySetFXOffset(super, 0, 1, -0x12); } void Stalfos_OnTick(StalfosEntity* this) { @@ -92,7 +92,7 @@ void Stalfos_OnCollision(StalfosEntity* this) { r1 = super->child; if (r1 == NULL) { if (super->action < 9) { - r1 = CreateProjectileWithParent(super, STALFOS_PROJECTILE, 1); + r1 = EnemyCreateProjectile(super, STALFOS_PROJECTILE, 1); if (r1 != NULL) { r1->frameIndex = super->animationState << 1; r1->type2 = 2; @@ -112,14 +112,14 @@ void Stalfos_OnCollision(StalfosEntity* this) { super->flags2 &= 0xfb; } if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Stalfos_Functions); } void Stalfos_OnDeath(StalfosEntity* this) { if (super->type == 0) { - CreateDeathFx(super, 0xf3, 0); + EnemyCreateDeathFX((Enemy*)super, 0xf3, 0); } else { GenericDeath(super); } @@ -143,7 +143,7 @@ void Stalfos_SubAction1(StalfosEntity* this) { void Stalfos_SubAction2(StalfosEntity* this) { Entity* projectile = super->child; if (projectile == NULL) { - projectile = CreateProjectileWithParent(super, STALFOS_PROJECTILE, 1); + projectile = EnemyCreateProjectile(super, STALFOS_PROJECTILE, 1); if (projectile != NULL) { projectile->frameIndex = super->animationState << 1; projectile->type2 = 1; @@ -396,7 +396,7 @@ void sub_08039A00(StalfosEntity* this, u32 param_2) { } void sub_08039A20(StalfosEntity* this) { - Entity* projectile = CreateProjectileWithParent(super, BONE_PROJECTILE, 0); + Entity* projectile = EnemyCreateProjectile(super, BONE_PROJECTILE, 0); if (projectile != NULL) { projectile->direction = super->direction; this->unk_7c = 0x3c; @@ -431,7 +431,7 @@ void sub_08039A70(StalfosEntity* this) { void sub_08039AD4(StalfosEntity* this) { u32 position = sub_08039B28(this); if (position != 0xffff) { - Entity* projectile = CreateProjectileWithParent(super, STALFOS_PROJECTILE, super->type2); + Entity* projectile = EnemyCreateProjectile(super, STALFOS_PROJECTILE, super->type2); if (projectile != NULL) { projectile->parent = super; super->action = 0xb; diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index 7423bc40..803ebd47 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -38,7 +38,7 @@ static void (*const Tektite_Functions[])(TektiteEntity*) = { void Tektite(TektiteEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)Tektite_Functions); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void Tektite_OnTick(TektiteEntity* this) { @@ -60,7 +60,7 @@ static const u8 gUnk_080CDEF8[] = { void Tektite_OnCollision(TektiteEntity* this) { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Tektite_Functions); if ((super->contactFlags & 0x80) != 0) { diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index 140658b7..22184e0d 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -33,7 +33,7 @@ static void (*const TektiteGolden_Functions[])(TektiteGoldenEntity*) = { void TektiteGolden(TektiteGoldenEntity* this) { EnemyFunctionHandler(super, (EntityActionArray)TektiteGolden_Functions); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void TektiteGolden_OnTick(TektiteGoldenEntity* this) { @@ -48,7 +48,7 @@ void TektiteGolden_OnTick(TektiteGoldenEntity* this) { void TektiteGolden_OnCollision(TektiteGoldenEntity* this) { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, TektiteGolden_Functions); if (super->contactFlags == 0x94) { @@ -78,7 +78,7 @@ void TektiteGolden_OnDeath(TektiteGoldenEntity* this) { } else { uVar1 = ITEM_RUPEE100; } - CreateDeathFx(super, 0xff, uVar1); + EnemyCreateDeathFX((Enemy*)super, 0xff, uVar1); } void TektiteGolden_OnConfused(TektiteGoldenEntity* this) { diff --git a/src/enemy/torchTrap.c b/src/enemy/torchTrap.c index de2e12eb..f0604697 100644 --- a/src/enemy/torchTrap.c +++ b/src/enemy/torchTrap.c @@ -122,7 +122,7 @@ void TorchTrap_Reset(TorchTrapEntity* this) { } void TorchTrap_CreateProjectile(TorchTrapEntity* this) { - Entity* proj = CreateProjectileWithParent(super, TORCH_TRAP_PROJECTILE, 0); + Entity* proj = EnemyCreateProjectile(super, TORCH_TRAP_PROJECTILE, 0); if (proj) { u16 speed = super->speed; if (super->speed) { diff --git a/src/enemy/treeItem.c b/src/enemy/treeItem.c index 7ce1dc35..0d8dd476 100644 --- a/src/enemy/treeItem.c +++ b/src/enemy/treeItem.c @@ -15,7 +15,7 @@ typedef struct { static bool32 ShouldSpawnTreeItem(TreeItemEntity*); -extern void sub_08049CF4(Entity*); +extern void EnemyDisableRespawn(Entity*); const u8 gTreeItemDropTables[][16] = { { 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, @@ -74,7 +74,7 @@ void TreeItem(TreeItemEntity* this) { break; } - sub_08049CF4(super); + EnemyDisableRespawn(super); DeleteThisEntity(); } diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index 476730df..65ace01e 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -43,7 +43,7 @@ typedef struct VaatiArm_HeapStruct { VaatiArm_HeapStruct1 s1[5]; } VaatiArm_HeapStruct; -extern void sub_0804AA1C(Entity*); +extern void EnemyDetachFX(Entity*); static u32 sub_080437DC(VaatiArmEntity*); static bool32 sub_08043C98(VaatiArmEntity*); @@ -835,7 +835,7 @@ static void sub_08043130(VaatiArmEntity* this) { if (super->spriteSettings.draw == 0) { super->subAction = 9; super->timer = 60; - sub_0804AA1C(super); + EnemyDetachFX(super); } } } @@ -913,7 +913,7 @@ void sub_080432A8(VaatiArmEntity* this) { super->subAction = 1; super->timer = 0x1e; ((VaatiArm_HeapStruct*)super->myHeap)->s1[0].unk04.HWORD = 0x4000; - sub_0804AA1C(&((VaatiArm_HeapStruct*)super->myHeap)->entities[4]->base); + EnemyDetachFX(&((VaatiArm_HeapStruct*)super->myHeap)->entities[4]->base); } } @@ -1066,7 +1066,7 @@ static void sub_08043580(VaatiArmEntity* this) { entity->collisionFlags = entity->collisionFlags | 0x10; entity->hitType = 0x39; entity->hitbox = (Hitbox*)&gUnk_080FD538; - sub_0804AA1C(super); + EnemyDetachFX(super); } } @@ -1443,7 +1443,7 @@ static void sub_08043D08(VaatiArmEntity* this) { entity->flags &= ~ENT_COLLIDE; entity->spriteSettings.draw = 0; InitializeAnimation(entity, 0x13); - sub_0804AA1C(entity); + EnemyDetachFX(entity); fx = CreateFx(entity, FX_GIANT_EXPLOSION4, 0); if (fx != NULL) { fx->x.HALF.HI += gUnk_080D13E9[super->type2]; diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 7e0d04a6..485749b5 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -213,7 +213,7 @@ void sub_08044868(VaatiBallEntity* this) { if (vaati->unk_86 > 1) { u8 draw = super->spriteSettings.draw; if (draw == 1 && this->unk_84 == 0) { - vaati = (VaatiBallEntity*)CreateProjectileWithParent(super, V1_DARK_MAGIC_PROJECTILE, 0); + vaati = (VaatiBallEntity*)EnemyCreateProjectile(super, V1_DARK_MAGIC_PROJECTILE, 0); if (vaati) { vaati->base.type2 = 1; vaati->base.parent = super; @@ -303,7 +303,7 @@ void sub_080449F8(VaatiBallEntity* this) { this->unk_74++; draw = super->spriteSettings.draw; if (draw) { - vaati = (VaatiBallEntity*)CreateProjectileWithParent(super, V1_EYE_LASER, 0); + vaati = (VaatiBallEntity*)EnemyCreateProjectile(super, V1_EYE_LASER, 0); if (vaati) { vaati->base.y.HALF.HI += 4; vaati->base.parent = super; diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c index 714e7ec9..92cf62c5 100644 --- a/src/enemy/vaatiEyesMacro.c +++ b/src/enemy/vaatiEyesMacro.c @@ -62,7 +62,7 @@ const u16 gUnk_080CDE98[] = { 0xc0, 0x100, 0x140, 0x180 }; void VaatiEyesMacro(VaatiEyesMacroEntity* this) { VaatiEyesMacro_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void VaatiEyesMacro_OnTick(VaatiEyesMacroEntity* this) { @@ -98,7 +98,7 @@ void VaatiEyesMacro_OnCollision(VaatiEyesMacroEntity* this) { } } if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)VaatiEyesMacro_Functions); } diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index 7ff9174e..83fcbc65 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -369,7 +369,7 @@ void VaatiRebornEnemyType0Action4(VaatiRebornEnemyEntity* this) { super->subtimer = 0; } if ((super->subtimer < 0x10) && - (entity = CreateProjectileWithParent(super, V1_FIRE_PROJECTILE, this->unk_84), entity != NULL)) { + (entity = EnemyCreateProjectile(super, V1_FIRE_PROJECTILE, this->unk_84), entity != NULL)) { entity->subtimer = super->subtimer; entity->parent = super; entity->z.HALF.HI = super->z.HALF.HI; @@ -456,7 +456,7 @@ void VaatiRebornEnemyType0Action6(VaatiRebornEnemyEntity* this) { if (--super->timer == 0) { this->unk_74++; SoundReq(SFX_150); - target = CreateProjectileWithParent(super, V1_DARK_MAGIC_PROJECTILE, 0); + target = EnemyCreateProjectile(super, V1_DARK_MAGIC_PROJECTILE, 0); if (target != NULL) { PositionRelative(super, target, 0, Q_16_16(-16.0)); target->parent = super; diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 56ca8a39..e04bd547 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -436,7 +436,7 @@ void VaatiTransfiguredType0Action4(VaatiTransfiguredEntity* this) { super->timer = gUnk_080D0ABF[((u32)super->animationState << 1 | 1)]; } else { if ((super->timer & 7) == 0) { - CreateProjectileWithParent(super, V2_PROJECTILE, super->subtimer); + EnemyCreateProjectile(super, V2_PROJECTILE, super->subtimer); } if (((super->subtimer != 0) && (1 < super->animationState)) && (super->timer < 6)) { super->timer = 128; @@ -482,7 +482,7 @@ void VaatiTransfiguredType0Action5(VaatiTransfiguredEntity* this) { } else { if (super->subtimer) { if ((super->timer & 7) == 0) { - CreateProjectileWithParent(super, V2_PROJECTILE, super->subtimer); + EnemyCreateProjectile(super, V2_PROJECTILE, super->subtimer); } if (super->timer < 6) { super->timer = 64; @@ -490,7 +490,7 @@ void VaatiTransfiguredType0Action5(VaatiTransfiguredEntity* this) { } } else { if ((super->timer & 0xf) == 0) { - entity = CreateProjectileWithParent(super, V2_PROJECTILE, 2); + entity = EnemyCreateProjectile(super, V2_PROJECTILE, 2); if (entity != NULL) { entity->type2 = 0; if (this->unk_81 != 0) { @@ -534,7 +534,7 @@ void VaatiTransfiguredType0Action6(VaatiTransfiguredEntity* this) { } else { if (super->subtimer) { if ((super->timer & 7) == 0) { - CreateProjectileWithParent(super, V2_PROJECTILE, super->subtimer); + EnemyCreateProjectile(super, V2_PROJECTILE, super->subtimer); } if (super->timer < 6) { super->timer = 128; @@ -542,7 +542,7 @@ void VaatiTransfiguredType0Action6(VaatiTransfiguredEntity* this) { } } else { if ((super->timer & 0x1f) == 0) { - pEVar2 = CreateProjectileWithParent(super, V2_PROJECTILE, 2); + pEVar2 = EnemyCreateProjectile(super, V2_PROJECTILE, 2); if (pEVar2 != NULL) { pEVar2->type2 = 1; pEVar2->y.HALF.HI += -0x20; diff --git a/src/enemy/wallMaster.c b/src/enemy/wallMaster.c index 8f37a64f..e48becaa 100644 --- a/src/enemy/wallMaster.c +++ b/src/enemy/wallMaster.c @@ -30,7 +30,7 @@ extern const s8 gUnk_080CD0B0[]; void WallMaster(WallMasterEntity* this) { WallMaster_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void WallMaster_OnTick(WallMasterEntity* this) { @@ -55,7 +55,7 @@ void WallMaster_OnCollision(WallMasterEntity* this) { super->knockbackDuration -= 4; if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)WallMaster_Functions); diff --git a/src/enemy/wallMaster2.c b/src/enemy/wallMaster2.c index e5a20d2c..63f14826 100644 --- a/src/enemy/wallMaster2.c +++ b/src/enemy/wallMaster2.c @@ -34,7 +34,7 @@ extern const s8 gUnk_080CD740[]; void WallMaster2(WallMaster2Entity* this) { WallMaster2_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void WallMaster2_OnTick(WallMaster2Entity* this) { @@ -53,7 +53,7 @@ void WallMaster2_OnCollision(WallMaster2Entity* this) { break; } if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)WallMaster2_Functions); } diff --git a/src/enemy/wizzrobeFire.c b/src/enemy/wizzrobeFire.c index 356a8b1b..0253a142 100644 --- a/src/enemy/wizzrobeFire.c +++ b/src/enemy/wizzrobeFire.c @@ -13,7 +13,7 @@ extern void (*const WizzrobeFire_Actions[])(WizzrobeEntity*); void WizzrobeFire(WizzrobeEntity* this) { WizzrobeFire_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void WizzrobeFire_OnTick(WizzrobeEntity* this) { @@ -22,7 +22,7 @@ void WizzrobeFire_OnTick(WizzrobeEntity* this) { void WizzrobeFire_OnCollision(WizzrobeEntity* this) { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, WizzrobeFire_Functions); if (super->health == 0) { @@ -40,7 +40,7 @@ void WizzrobeFire_Init(WizzrobeEntity* this) { super->timer = 40; super->subtimer = 96; sub_0802F888(this); - projectile = CreateProjectileWithParent(super, FIRE_PROJECTILE, 0); + projectile = EnemyCreateProjectile(super, FIRE_PROJECTILE, 0); if (projectile != NULL) { super->child = projectile; projectile->parent = super; @@ -96,7 +96,7 @@ void WizzrobeFire_Action2(WizzrobeEntity* this) { break; case 6: if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) { - Entity* projectile = CreateProjectileWithParent(super, FIRE_PROJECTILE, 1); + Entity* projectile = EnemyCreateProjectile(super, FIRE_PROJECTILE, 1); if (projectile != NULL) { projectile->direction = super->direction & 0x18; } diff --git a/src/enemy/wizzrobeIce.c b/src/enemy/wizzrobeIce.c index 4df8891c..84fe790e 100644 --- a/src/enemy/wizzrobeIce.c +++ b/src/enemy/wizzrobeIce.c @@ -14,7 +14,7 @@ extern void (*const WizzrobeIce_Actions[])(WizzrobeEntity*); void WizzrobeIce(WizzrobeEntity* this) { WizzrobeIce_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void WizzrobeIce_OnTick(WizzrobeEntity* this) { @@ -23,7 +23,7 @@ void WizzrobeIce_OnTick(WizzrobeEntity* this) { void WizzrobeIce_OnCollision(WizzrobeEntity* this) { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, WizzrobeIce_Functions); if (super->contactFlags == 0x87) { @@ -49,7 +49,7 @@ void WizzrobeIce_Init(WizzrobeEntity* this) { super->timer = 40; super->subtimer = 96; sub_0802F888(this); - projectile = CreateProjectileWithParent(super, ICE_PROJECTILE, 0); + projectile = EnemyCreateProjectile(super, ICE_PROJECTILE, 0); if (projectile != NULL) { super->child = projectile; projectile->parent = super; @@ -103,7 +103,7 @@ void WizzrobeIce_Action2(WizzrobeEntity* this) { break; case 0xa: if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) { - Entity* projectile = CreateProjectileWithParent(super, ICE_PROJECTILE, 1); + Entity* projectile = EnemyCreateProjectile(super, ICE_PROJECTILE, 1); if (projectile != NULL) { projectile->direction = super->direction & 0x18; } diff --git a/src/enemy/wizzrobeWind.c b/src/enemy/wizzrobeWind.c index ac1c3396..8f23e3da 100644 --- a/src/enemy/wizzrobeWind.c +++ b/src/enemy/wizzrobeWind.c @@ -21,7 +21,7 @@ void sub_0802F8E4(WizzrobeEntity*); void WizzrobeWind(WizzrobeEntity* this) { WizzrobeWind_Functions[GetNextFunction(super)](this); - SetChildOffset(super, 0, 1, -0x10); + EnemySetFXOffset(super, 0, 1, -0x10); } void WizzrobeWind_OnTick(WizzrobeEntity* this) { @@ -30,7 +30,7 @@ void WizzrobeWind_OnTick(WizzrobeEntity* this) { void WizzrobeWind_OnCollision(WizzrobeEntity* this) { if (super->confusedTime != 0) { - Create0x68FX(super, FX_STARS); + EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, WizzrobeWind_Functions); if (super->contactFlags == 0x87) { @@ -66,7 +66,7 @@ void WizzrobeWind_Init(WizzrobeEntity* this) { super->subtimer = 96; sub_0802F888(this); } - projectile = CreateProjectileWithParent(super, WIND_PROJECTILE, 0); + projectile = EnemyCreateProjectile(super, WIND_PROJECTILE, 0); if (projectile != NULL) { super->parent = projectile; projectile->parent = super; @@ -119,7 +119,7 @@ void WizzrobeWind_Action2(WizzrobeEntity* this) { break; case 8: if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) { - Entity* projectile = CreateProjectileWithParent(super, WIND_PROJECTILE, 1); + Entity* projectile = EnemyCreateProjectile(super, WIND_PROJECTILE, 1); if (projectile != NULL) { projectile->direction = super->direction & 0x18; } @@ -190,7 +190,7 @@ void WizzrobeWind_Action3(WizzrobeEntity* this) { parent->spriteSettings.draw = 0; InitializeAnimation(super, super->animationState >> 1); } else if (super->timer == 8) { - parent = CreateProjectileWithParent(super, WIND_PROJECTILE, 1); + parent = EnemyCreateProjectile(super, WIND_PROJECTILE, 1); if (parent != NULL) { parent->direction = super->direction & 0x18; } diff --git a/src/enemyUtils.c b/src/enemyUtils.c index fa6b4bc0..04281240 100644 --- a/src/enemyUtils.c +++ b/src/enemyUtils.c @@ -1,5 +1,5 @@ #include "enemyUtils.h" - +#include "enemy.h" #include "definitions.h" #include "entity.h" #include "functions.h" @@ -8,7 +8,8 @@ #include "projectile.h" #include "save.h" -extern void sub_08049CF4(Entity*); +extern void EnemyDisableRespawn(Entity*); +extern void ReplaceMonitoredEntity(Entity*, Entity*); extern EnemyDefinition gEnemyDefinitions[]; @@ -33,6 +34,24 @@ const struct_080D3D94 gUnk_080D3D94[] = { const u16 gUnk_080D3E74[] = { 2373, 1105, 2324, 21568, 4177, 16656, 1365, 21760, 8209, 0, 20480, 5, 0, 0 }; +void EnemyCopyParams(Entity* src, Entity* dest) { + Enemy* em_src = (Enemy*)src; + Enemy* em_dest = (Enemy*)dest; + + em_dest->enemyFlags = (em_src->enemyFlags & EM_FLAG_MONITORED) | EM_FLAG_HAS_HOME; + em_dest->idx = em_src->idx; + em_dest->homeX = em_src->homeX; + em_dest->homeY = em_src->homeY; + em_dest->rangeX = em_src->rangeX; + em_dest->rangeY = em_src->rangeY; + + CopyPositionAndSpriteOffset(&em_src->base, &em_dest->base); + + if (em_src->enemyFlags & EM_FLAG_MONITORED) { + ReplaceMonitoredEntity(&em_src->base, &em_dest->base); + } +} + const EnemyDefinition* GetEnemyDefinition(Entity* entity) { const EnemyDefinition* definition = &gEnemyDefinitions[entity->id]; if (definition->gfx == 0xffff) { @@ -41,7 +60,7 @@ const EnemyDefinition* GetEnemyDefinition(Entity* entity) { return definition; } -bool32 EnemyInit(GenericEntity* this) { +bool32 EnemyInit(Enemy* this) { if ((super->flags & ENT_DID_INIT) == 0) { const EnemyDefinition* definition = GetEnemyDefinition(super); if (LoadEnemySprite(super, definition) == FALSE) { @@ -68,19 +87,19 @@ bool32 EnemyInit(GenericEntity* this) { super->hurtType = 0x41; } UpdateSpriteForCollisionLayer(super); - if ((this->field_0x6c.HALF.HI & 0x20) != 0) { + if (this->enemyFlags & EM_FLAG_CAPTAIN) { u32 uVar4 = gUnk_080D3E74[super->id >> 3] >> ((super->id & 7) << 1) & 3; if (uVar4 != 0) { - Entity* object = CreateObject(MULLDOZER_SPAWN_POINT, uVar4 - 1, 0); - if (object != NULL) { - object->timer = super->flags; - object->subtimer = super->spriteSettings.draw; - object->spritePriority.b0 = 3; - object->parent = super; - CopyPosition(super, object); - super->flags &= ~ENT_COLLIDE; + Entity* spawn_pt = CreateObject(MULLDOZER_SPAWN_POINT, uVar4 - 1, 0); + if (spawn_pt != NULL) { + spawn_pt->timer = super->flags; + spawn_pt->subtimer = super->spriteSettings.draw; + spawn_pt->spritePriority.b0 = 3; + spawn_pt->parent = super; + CopyPosition(super, spawn_pt); + COLLISION_OFF(super); super->spriteSettings.draw = 0; - this->field_0x6c.HALF.HI |= 0x10; + this->enemyFlags |= EM_FLAG_SUPPORT; } } } @@ -111,65 +130,66 @@ bool32 LoadEnemySprite(Entity* entity, const EnemyDefinition* definition) { return TRUE; } -void sub_0804A720(GenericEntity* this) { +void sub_0804A720(Entity* parent) { int iVar2; const struct_080D3D94* pbVar3; GenericEntityData* ptr; + Enemy* this = (Enemy*)parent; - if ((this->field_0x6c.HALF.HI & 4) != 0) { + if (this->enemyFlags & EM_FLAG_HAS_HOME) { return; } pbVar3 = &gUnk_080D3D94[super->id]; - ptr = (GenericEntityData*)&this->field_0x68; + ptr = (GenericEntityData*)&this->child; if (ptr->field_0x7c.BYTES.byte2 == 0) { - this->field_0x6e.HALF.LO = pbVar3->unk_0; + this->rangeX = pbVar3->unk_0; } else { - this->field_0x6e.HALF.LO = ptr->field_0x7c.BYTES.byte2; + this->rangeX = ptr->field_0x7c.BYTES.byte2; } if (ptr->field_0x7c.BYTES.byte3 == 0) { - this->field_0x6e.HALF.HI = pbVar3->unk_1; + this->rangeY = pbVar3->unk_1; } else { - this->field_0x6e.HALF.HI = ptr->field_0x7c.BYTES.byte3; + this->rangeY = ptr->field_0x7c.BYTES.byte3; } if (ptr->cutsceneBeh.HWORD != 0) { - this->field_0x70.HALF.LO = ptr->cutsceneBeh.HWORD + gRoomControls.origin_x; + this->homeX = ptr->cutsceneBeh.HWORD + gRoomControls.origin_x; } else { - iVar2 = this->field_0x6e.HALF.LO * 4; + iVar2 = this->rangeX * 4; if (super->x.HALF.HI >= iVar2) { - this->field_0x70.HALF.LO = super->x.HALF_U.HI - 4 * this->field_0x6e.HALF.LO; + this->homeX = super->x.HALF_U.HI - 4 * this->rangeX; } else { - this->field_0x70.HALF.LO = 0; + this->homeX = 0; } } if (ptr->field_0x86.HWORD != 0) { - this->field_0x70.HALF.HI = ptr->field_0x86.HWORD + gRoomControls.origin_y; + this->homeY = ptr->field_0x86.HWORD + gRoomControls.origin_y; } else { - iVar2 = this->field_0x6e.HALF.HI * 4; + iVar2 = this->rangeY * 4; if (super->y.HALF.HI >= iVar2) { - this->field_0x70.HALF.HI = super->y.HALF.HI - iVar2; + this->homeY = super->y.HALF.HI - iVar2; } else { - this->field_0x70.HALF.HI = 0; + this->homeY = 0; } } - this->field_0x6c.HALF.HI |= 4; + this->enemyFlags |= EM_FLAG_HAS_HOME; } -void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem); +void EnemyCreateDeathFX(Enemy* parent, u32 parentId, u32 fixedItem); void GenericDeath(Entity* this) { - CreateDeathFx((GenericEntity*)this, this->id, 0); + EnemyCreateDeathFX((Enemy*)this, this->id, 0); } -void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) { +void EnemyCreateDeathFX(Enemy* parent, u32 parentId, u32 fixedItem) { DeathFxObject* deathFx; DeathFxObject* deathFx2; u8 bVar3; - if ((parent->field_0x6c.HALF.HI & 1) != 0) { - if ((parent->field_0x6c.HALF.HI & 2) != 0) { + if (parent->enemyFlags & EM_FLAG_BOSS) { + if (parent->enemyFlags & EM_FLAG_BOSS_KILLED) { return; } deathFx = (DeathFxObject*)CreateObject(DEATH_FX, parent->base.id, 0); @@ -179,7 +199,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) { deathFx->unk6c = 1; PositionRelative(&(parent->base), &(deathFx->base), 0, 1); deathFx->base.parent = &(parent->base); - parent->field_0x6c.HALF.HI |= 2; + parent->enemyFlags |= EM_FLAG_BOSS_KILLED; if ((parent->base.id == 0x37) && (gRoomTransition.field_0x39 != 0)) { DeleteThisEntity(); } @@ -190,7 +210,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) { } else { int tmp = parent->base.gustJarState & 2; if (tmp == 0) { - sub_08049CF4(&(parent->base)); + EnemyDisableRespawn(&(parent->base)); gSave.enemies_killed++; parent->base.gustJarState |= 2; parent->base.timer = 255; @@ -204,7 +224,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) { deathFx2->base.child = &(parent->base); CopyPosition(&(parent->base), &(deathFx2->base)); } - if ((parent->field_0x6c.HALF.HI & 8) != 0) { + if (parent->enemyFlags & EM_FLAG_NO_DEATH_FX) { deathFx2->unk6c |= 8; DeleteEntity(&(parent->base)); return; @@ -245,7 +265,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) { } } -Entity* CreateProjectileWithParent(Entity* parent, u32 projectileId, u32 projectileType) { +Entity* EnemyCreateProjectile(Entity* parent, u32 projectileId, u32 projectileType) { Entity* projectile; projectile = CreateProjectile(projectileId); @@ -256,11 +276,11 @@ Entity* CreateProjectileWithParent(Entity* parent, u32 projectileId, u32 project return projectile; } -void SetChildOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) { +void EnemySetFXOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) { Entity* other; - GenericEntity* this = (GenericEntity*)entity; + Enemy* this = (Enemy*)entity; - other = *(Entity**)&this->field_0x68; + other = this->child; if (other != NULL) { other->spriteRendering.b3 = super->spriteRendering.b3; other->spriteOrientation.flipY = super->spriteOrientation.flipY; @@ -271,22 +291,44 @@ void SetChildOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) { } } -Entity* Create0x68FX(Entity* parent, u32 fxType) { +Entity* EnemyCreateFX(Entity* parent, u32 fxType) { Entity* fx; - GenericEntity* this = (GenericEntity*)parent; + Enemy* this = (Enemy*)parent; - if ((*(Entity**)&this->field_0x68 == NULL) && (fx = CreateFx(super, fxType, 0), fx != NULL)) { - *(Entity**)&this->field_0x68 = fx; + if (this->child == NULL && (fx = CreateFx(super, fxType, 0), fx != NULL)) { + this->child = fx; } else { fx = NULL; } return fx; } -void sub_0804AA1C(Entity* entity) { - GenericEntity* this = (GenericEntity*)entity; - if (*(Entity**)&this->field_0x68 != NULL) { - (*(Entity**)&this->field_0x68)->parent = NULL; - *(Entity**)&this->field_0x68 = NULL; +void EnemyDetachFX(Entity* entity) { + Enemy* this = (Enemy*)entity; + if (this->child != NULL) { + this->child->parent = NULL; + this->child = NULL; } } + +/** Unsets bitfield 0x80 before calling GetNextFunction, so that the enemyFunction 1 is not called. */ +void EnemyFunctionHandlerAfterCollision(Entity* entity, void (*const fntable[])()) { + u32 idx; + entity->contactFlags &= ~0x80; + idx = GetNextFunction(entity); + entity->contactFlags |= 0x80; + fntable[idx](entity); +} + +Entity* CreateEnemy(u32 subtype, u32 form) { + Entity* enemy; + + enemy = GetEmptyEntity(); + if (enemy != NULL) { + enemy->kind = ENEMY; + enemy->id = subtype; + enemy->type = form; + AppendEntityToList(enemy, 4); + } + return enemy; +} diff --git a/src/entity.c b/src/entity.c index 260ee5fa..7297982a 100644 --- a/src/entity.c +++ b/src/entity.c @@ -21,7 +21,7 @@ void DeleteAllEntities(void); void sub_0805E98C(void); extern void UnloadOBJPalette2(Entity*); extern void sub_08017744(Entity*); -extern void sub_0804AA1C(Entity*); +extern void EnemyDetachFX(Entity*); void ClearDeletedEntity(Entity*); extern void ram_ClearAndUpdateEntities(void); @@ -369,7 +369,7 @@ void DeleteEntity(Entity* ent) { zFree(ent->myHeap); ent->myHeap = NULL; if (ent->kind == ENEMY) { - sub_0804AA1C(ent); + EnemyDetachFX(ent); } COLLISION_OFF(ent); ent->spriteSettings.draw = 0; diff --git a/src/manager/fightManager.c b/src/manager/fightManager.c index 9d743f07..477d2112 100644 --- a/src/manager/fightManager.c +++ b/src/manager/fightManager.c @@ -16,6 +16,7 @@ #include "message.h" #include "room.h" #include "sound.h" +#include "enemy.h" enum FightManager_State { Init, WaitForFlag, WaitForDone }; @@ -112,7 +113,7 @@ void FightManager_LoadFight(FightManager* this) { while (prop->kind != 0xFF) { ent = LoadRoomEntity(prop++); if ((ent != NULL) && (ent->kind == ENEMY)) { - ((GenericEntity*)ent)->field_0x6c.HALF.HI |= 0x40; + ((Enemy*)ent)->enemyFlags |= EM_FLAG_MONITORED; FightManagerHelper_Monitor(monitor, ent, counter++); } if (counter >= 7) { diff --git a/src/manager/templeOfDropletsManager.c b/src/manager/templeOfDropletsManager.c index bdec6a4a..4082f884 100644 --- a/src/manager/templeOfDropletsManager.c +++ b/src/manager/templeOfDropletsManager.c @@ -340,7 +340,7 @@ void TempleOfDropletsManager_Type6_Action2(TempleOfDropletsManager* this) { case PL_STATE_WALK: if (sub_0805A73C(this)) { super->action++; - sub_08004168(&gPlayerEntity.base); + SnapToTile(&gPlayerEntity.base); gPlayerEntity.base.animationState = 4; RequestPriorityDuration((Entity*)this, 600); SetPlayerControl(0xFF); diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index 446cd71c..1040a8b1 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -681,7 +681,7 @@ void KinstoneMenu_080A4528(void) { entity->subtimer = entity->id; entity->id = 0x56; } else { - EnemyInit(entity); + EnemyInit((Enemy*)entity); entity->subtimer = entity->id; entity->id = 0x66; } diff --git a/src/object/bush.c b/src/object/bush.c index 6e7a08af..38371e1e 100644 --- a/src/object/bush.c +++ b/src/object/bush.c @@ -50,7 +50,7 @@ void Bush_Init(BushEntity* this) { if (super->type == 3) { Bush_Action2SubAction5(this); } - sub_08004168(super); + SnapToTile(super); if (super->type == 4) { Bush_Action2SubAction5(this); } diff --git a/src/object/crackingGround.c b/src/object/crackingGround.c index 3c8c9e85..fe8488c0 100644 --- a/src/object/crackingGround.c +++ b/src/object/crackingGround.c @@ -11,7 +11,7 @@ void CrackingGround(Entity* this) { if (this->action == 0) { this->action = 1; this->timer = 20; - sub_08004168(this); + SnapToTile(this); } else { if (this->timer-- == 0) { sub_0807B7D8(0x35, COORD_TO_TILE(this), this->collisionLayer); diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index 3621f300..cdadc583 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -326,7 +326,7 @@ void sub_080969A4(CrenelBeanSproutEntity* this) { void sub_08096A78(CrenelBeanSproutEntity* this) { SetGlobalFlag(WATERBEAN_PUT); InitAnimationForceUpdate(super, (super->type >> 1) + 8); - sub_08004168(super); + SnapToTile(super); super->y.HALF.HI += 4; super->action = 3; SetTile(0x403b, COORD_TO_TILE(super), super->collisionLayer); diff --git a/src/object/flame.c b/src/object/flame.c index 34013762..5b1b48a7 100644 --- a/src/object/flame.c +++ b/src/object/flame.c @@ -37,7 +37,7 @@ void Flame_Init(FlameEntity* this) { break; case 2: super->timer = 15; - sub_08004168(super); + SnapToTile(super); break; case 3: CopyPosition(super->parent, super); diff --git a/src/object/minecart.c b/src/object/minecart.c index ee523716..64fb239d 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -186,7 +186,7 @@ void Minecart_Action3(MinecartEntity* this) { gPlayerEntity.base.animationState = super->animationState << 1; gPlayerEntity.base.direction = super->direction; gPlayerEntity.base.flags |= PL_MINISH; - sub_08004168(super); + SnapToTile(super); InitAnimationForceUpdate(super, super->animationState + 0xc); SoundReq(SFX_PLY_VO4); SoundReq(SFX_139); @@ -219,7 +219,7 @@ void Minecart_Action3(MinecartEntity* this) { } void Minecart_Action4(MinecartEntity* this) { - sub_08004168(super); + SnapToTile(super); CopyPosition(super, &gPlayerEntity.base); switch (GetActTile(super)) { case 0x67: diff --git a/src/object/mulldozerSpawnPoint.c b/src/object/mulldozerSpawnPoint.c index 8ba4d3b0..611f77dd 100644 --- a/src/object/mulldozerSpawnPoint.c +++ b/src/object/mulldozerSpawnPoint.c @@ -6,6 +6,7 @@ */ #include "entity.h" #include "sound.h" +#include "enemy.h" void MulldozerSpawnPoint_Init(Entity*); void MulldozerSpawnPoint_Action1(Entity*); @@ -37,6 +38,6 @@ void MulldozerSpawnPoint_Action1(Entity* this) { parent = this->parent; parent->flags = this->timer; parent->spriteSettings.draw = this->subtimer; - ((GenericEntity*)parent)->field_0x6c.HALF.HI &= 0xef; + ((Enemy*)parent)->enemyFlags &= ~EM_FLAG_SUPPORT; } } diff --git a/src/object/object53.c b/src/object/object53.c index e00e9ef2..737c8967 100644 --- a/src/object/object53.c +++ b/src/object/object53.c @@ -41,7 +41,7 @@ void Object53_Init(Entity* this) { this->spriteRendering.b3 = 2; this->zVelocity = Q_16_16(2.625); InitializeAnimation(this, gUnk_08122288[this->type].animationState); - sub_08004168(this); + SnapToTile(this); } void Object53_Action1(Entity* this) { diff --git a/src/object/object70.c b/src/object/object70.c index f9017446..605e074b 100644 --- a/src/object/object70.c +++ b/src/object/object70.c @@ -23,7 +23,7 @@ void Object70_Init(Entity* this) { this->spriteSettings.draw = 1; this->frameIndex = this->type + 0xb; if (this->type != 0) { - sub_08004168(this); + SnapToTile(this); gPlayerEntity.base.spriteOrientation.flipY = 3; if ((gPlayerEntity.base.spritePriority.b0) != 7) { this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 + 1; diff --git a/src/object/pushableStatue.c b/src/object/pushableStatue.c index 90ba2fc2..1755dc5b 100644 --- a/src/object/pushableStatue.c +++ b/src/object/pushableStatue.c @@ -106,13 +106,13 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) { this->unk_83 = 1; index = gPlayerEntity.base.animationState; ptr = &gUnk_08120CB4[index]; - PositionRelative(super, &gPlayerEntity.base, *(ptr) << 0x10, *(ptr + 1) << 0x10); + PositionRelative(super, &gPlayerEntity.base, Q_16_16(ptr[0]), Q_16_16(ptr[1])); } tileType = GetTileType(this->unk_84, super->collisionLayer); if (tileType != 0x400b) { switch (sub_0808968C(tileType)) { case 1: - super->direction = (((tileType - 0xc) & 3) << 3); + super->direction = DirectionFromAnimationState((tileType - 0xc) & 3); sub_08089538(this); break; case 0: @@ -133,7 +133,7 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) { gPlayerState.flags |= PL_BUSY; gPlayerEntity.base.x.HALF.LO = 0; gPlayerEntity.base.y.HALF.LO = 0; - super->direction = (gPlayerEntity.base.animationState ^ 4) << 2; + super->direction = Direction8FromAnimationState(AnimationStateFlip180(gPlayerEntity.base.animationState)); sub_08089538(this); } } @@ -181,7 +181,7 @@ void sub_080894C8(PushableStatueEntity* this) { void sub_080894FC(PushableStatueEntity* this) { u32 index; - for (index = 0; index <= 7; index++) { + for (index = 0; index < 8; index++) { if (super == gRoomVars.puzzleEntities[index]) { gRoomVars.puzzleEntities[index] = NULL; break; diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c index ed2cdea1..e5a6c3f1 100644 --- a/src/object/smallIceBlock.c +++ b/src/object/smallIceBlock.c @@ -168,7 +168,7 @@ void SmallIceBlock_Action4(SmallIceBlockEntity* this) { x = ((rand >> 0x10) % 9) - 4; y = rand & 0xf; obj->spritePriority.b0 = 3; - PositionRelative(super, obj, x * 0x10000, -y * 0x10000); + PositionRelative(super, obj, Q_16_16(x), Q_16_16(-y)); } } } diff --git a/src/player.c b/src/player.c index 1c41684c..a67e1022 100644 --- a/src/player.c +++ b/src/player.c @@ -588,7 +588,7 @@ static void PlayerFall(PlayerEntity* this) { } static void PlayerFallInit(PlayerEntity* this) { - sub_08004168(super); + SnapToTile(super); gPlayerState.flags |= PL_BUSY | PL_DROWNING; gPlayerState.flags &= ~PL_BURNING; @@ -962,7 +962,7 @@ static void PlayerDrownInit(PlayerEntity* this) { SoundReq(SFX_WATER_SPLASH); } else { if (!(gPlayerState.flags & PL_FLAGS10000)) - sub_08004168(super); + SnapToTile(super); CreateFx(super, FX_WATER_SPLASH, 0); diff --git a/src/playerUtils.c b/src/playerUtils.c index 833d8acf..7820a1e5 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -2559,7 +2559,7 @@ bool32 HasSwordEquipped(void) { u32 sub_0807A180(Entity* param_1, Entity* param_2, u32 param_3, u32 param_4) { GenericEntity stackEntity; - PositionRelative(param_1, &stackEntity.base, 0, -0x40000); + PositionRelative(param_1, &stackEntity.base, 0, Q_16_16(-4.0)); stackEntity.base.animationState = param_1->animationState; return sub_08003FDE(&stackEntity.base, param_2, param_3, param_4); } @@ -2933,7 +2933,7 @@ void sub_0807AB44(Entity* this, s32 xOffset, s32 yOffset) { object = CreateObject(FLAME, 1, 0); if (object != NULL) { PositionRelative(this, object, xOffset << 0x10, yOffset << 0x10); - sub_08004168(object); + SnapToTile(object); sub_0807B7D8(ptr[3], COORD_TO_TILE(object), object->collisionLayer); } } else { diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index ed957966..2b4af4f2 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -86,7 +86,7 @@ void GleerokProjectile_Init(GleerokProjectileEntity* this) { super->x.HALF.HI += gUnk_08129980[Random() & 7]; super->y.HALF.HI += gUnk_08129988[Random() & 0xf]; } - sub_08004168(super); + SnapToTile(super); InitializeAnimation(super, 0); break; } diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 3786d872..789e3a41 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -150,7 +150,7 @@ void OctorokBossProjectile_Action1(OctorokBossProjectileEntity* this) { return; } for (index = 0; index < 3; ++index) { - super->child = CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 1); + super->child = EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 1); if (super->child != NULL) { super->child->parent = super->parent; super->child->direction = super->direction + gUnk_08129ADC[index]; diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index cb59c16a..e602c6f4 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -157,7 +157,7 @@ void sub_080ABE04(Entity* this) { } this->x.HALF.HI = newX + ((0xe0 & rand) >> 1); this->y.HALF.HI += ((0xf & rand) << 4); - sub_08004168(this); + SnapToTile(this); InitializeAnimation(this, 0); SoundReq(SFX_12D); } diff --git a/src/room.c b/src/room.c index 1e321869..5a3a1129 100644 --- a/src/room.c +++ b/src/room.c @@ -1,3 +1,5 @@ +// TODO: original name is probably floor.c + #include "area.h" #include "common.h" #include "flags.h" @@ -7,10 +9,11 @@ #include "manager/bombableWallManager.h" #include "object.h" #include "room.h" +#include "enemy.h" static void sub_0804B058(EntityData* dat); extern void sub_0801AC98(void); -extern u32 sub_08049D1C(u32); +extern u32 EnemyEnableRespawn(u32); extern void** gCurrentRoomProperties; extern void*** gAreaTable[]; @@ -122,9 +125,7 @@ void sub_0804AF0C(Entity* ent, const EntityData* dat) { ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y; break; case 0x20: - // TODO: for enemies, I think this is for delayed spawn - // see mulldozerSpawnPoint.c - ((GenericEntity*)ent)->field_0x6c.HALF.HI |= 0x20; + ((Enemy*)ent)->enemyFlags |= EM_FLAG_CAPTAIN; ent->x.HALF.HI = dat->xPos + gRoomControls.origin_x; ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y; break; @@ -196,10 +197,10 @@ static void sub_0804B058(EntityData* dat) { uVar2 = 0; do { if ((uVar2 < 0x20) && ((dat->kind & 0xF) == 3)) { - if (sub_08049D1C(uVar2) != 0) { + if (EnemyEnableRespawn(uVar2) != 0) { ent = LoadRoomEntity(dat); if ((ent != NULL) && (ent->kind == ENEMY)) { - ((GenericEntity*)ent)->field_0x6c.HALF.LO = uVar2 | 0x80; + ((Enemy*)ent)->idx = uVar2 | 0x80; } } } else { From 5049daabc59d113152143d123aea2798d9487a0c Mon Sep 17 00:00:00 2001 From: theo3 Date: Sat, 30 Dec 2023 21:07:06 -0800 Subject: [PATCH 04/10] label contact flags --- include/collision.h | 10 ++++++++++ include/entity.h | 2 ++ src/collision.c | 4 ++-- src/enemy/acroBandits.c | 2 +- src/enemy/armos.c | 2 +- src/enemy/beetle.c | 4 ++-- src/enemy/bobomb.c | 2 +- src/enemy/bowMoblin.c | 2 +- src/enemy/chaser.c | 2 +- src/enemy/chuchuBoss.c | 4 ++-- src/enemy/cloudPiranha.c | 2 +- src/enemy/crow.c | 2 +- src/enemy/darkNut.c | 3 ++- src/enemy/enemy50.c | 8 ++++---- src/enemy/eyegore.c | 6 +++--- src/enemy/flyingPot.c | 2 +- src/enemy/flyingSkull.c | 2 +- src/enemy/ghini.c | 4 ++-- src/enemy/gibdo.c | 4 ++-- src/enemy/gleerok.c | 4 ++-- src/enemy/hangingSeed.c | 2 +- src/enemy/keaton.c | 2 +- src/enemy/leever.c | 2 +- src/enemy/likeLike.c | 4 ++-- src/enemy/madderpillar.c | 4 ++-- src/enemy/mazaalBracelet.c | 4 ++-- src/enemy/moldworm.c | 6 +++--- src/enemy/mulldozer.c | 2 +- src/enemy/peahat.c | 6 +++--- src/enemy/pesto.c | 2 +- src/enemy/rockChuchu.c | 2 +- src/enemy/rollobite.c | 4 ++-- src/enemy/scissorsBeetle.c | 2 +- src/enemy/spark.c | 2 +- src/enemy/spearMoblin.c | 4 ++-- src/enemy/spinyBeetle.c | 2 +- src/enemy/spinyChuchu.c | 2 +- src/enemy/takkuri.c | 2 +- src/enemy/tektite.c | 2 +- src/enemy/tektiteGolden.c | 2 +- src/enemy/vaatiArm.c | 6 +++--- src/enemy/vaatiBall.c | 2 +- src/enemy/vaatiProjectile.c | 2 +- src/enemy/vaatiRebornEnemy.c | 4 ++-- src/enemy/vaatiTransfigured.c | 4 ++-- src/enemy/vaatiTransfiguredEye.c | 2 +- src/enemy/vaatiWrath.c | 2 +- src/enemy/wisp.c | 2 +- src/enemy/wizzrobeIce.c | 2 +- src/enemy/wizzrobeWind.c | 2 +- src/enemyUtils.c | 4 ++-- src/interrupts.c | 4 ++-- src/npc/npc5.c | 2 +- src/object.c | 2 +- src/object/barrelSpiderweb.c | 6 +++--- src/object/dirtParticle.c | 4 ++-- src/object/eyeSwitch.c | 2 +- src/object/fairy.c | 2 +- src/object/hittableLever.c | 2 +- src/object/itemOnGround.c | 2 +- src/object/jarPortal.c | 2 +- src/object/lavaPlatform.c | 4 ++-- src/object/lightableSwitch.c | 4 ++-- src/object/objectA8.c | 2 +- src/object/objectOnSpinyBeetle.c | 2 +- src/object/sanctuaryStoneTablet.c | 2 +- src/object/smallIceBlock.c | 2 +- src/object/unusedSkull.c | 2 +- src/physics.c | 2 +- src/player.c | 3 ++- src/playerItem.c | 2 +- src/playerItem/playerItemBoomerang.c | 2 +- src/playerItem/playerItemGustBig.c | 2 +- src/playerItem/playerItemHeldObject.c | 2 +- src/playerItem/playerItemShield.c | 2 +- src/playerItem/playerItemSword.c | 2 +- src/projectile/arrowProjectile.c | 2 +- src/projectile/boneProjectile.c | 2 +- src/projectile/darkNutSwordSlash.c | 2 +- src/projectile/dekuSeedProjectile.c | 4 ++-- src/projectile/dirtBallProjectile.c | 2 +- src/projectile/gleerokProjectile.c | 2 +- src/projectile/guardLineOfSight.c | 4 ++-- src/projectile/keatonDagger.c | 2 +- src/projectile/lakituLightning.c | 2 +- src/projectile/mandiblesProjectile.c | 2 +- src/projectile/moblinSpear.c | 2 +- src/projectile/octorokBossProjectile.c | 4 ++-- src/projectile/projectile5.c | 2 +- src/projectile/removableDust.c | 2 +- src/projectile/rockProjectile.c | 2 +- src/projectile/spiderWeb.c | 2 +- src/projectile/stalfosProjectile.c | 2 +- src/projectile/v1DarkMagicProjectile.c | 2 +- src/projectile/v1FireProjectile.c | 2 +- src/projectile/v2Projectile.c | 2 +- 96 files changed, 142 insertions(+), 128 deletions(-) diff --git a/include/collision.h b/include/collision.h index af8ba984..465d3e9f 100644 --- a/include/collision.h +++ b/include/collision.h @@ -6,6 +6,16 @@ /** Collisions. */ +enum { + COL_LANTERN = 0x7, + COL_SMALL_GUST = 0x13, + COL_BOOMERANG = 0x14, + COL_ARROW = 0x15, + COL_BIG_GUST = 0x1b, + COL_PACCI = 0x1d, + COL_SWORD_BEAM = 0x21, +}; + typedef enum { COL_NONE = 0x0, COL_NORTH_WEST = 0x2, diff --git a/include/entity.h b/include/entity.h index 315e94db..8a66283c 100644 --- a/include/entity.h +++ b/include/entity.h @@ -79,6 +79,8 @@ typedef enum { DirectionNorthWest = 0x1c, /**< North West. */ } Direction; +#define CONTACT_TAKE_DAMAGE 0x80 + typedef struct { void* entity1; void* entity2; diff --git a/src/collision.c b/src/collision.c index d1408375..6dda05c3 100644 --- a/src/collision.c +++ b/src/collision.c @@ -371,7 +371,7 @@ CollisionResult CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettin // target: item CollisionResult CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { COLLISION_OFF(tgt); - tgt->contactFlags = org->hurtType | 0x80; + tgt->contactFlags = org->hurtType | CONTACT_TAKE_DAMAGE; if ((tgt->type == 0x5F || tgt->type == 0x60) && sub_08081420(tgt)) tgt->health = 0; return RESULT_COLLISION_WITHOUT_SET; @@ -503,7 +503,7 @@ CollisionResult sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSetting sub_08079D84(); org->iframes = 90; } else { - gPlayerEntity.base.contactFlags = tgt->hurtType | 0x80; + gPlayerEntity.base.contactFlags = tgt->hurtType | CONTACT_TAKE_DAMAGE; gPlayerEntity.base.iframes = 12; gPlayerEntity.base.knockbackDuration = 16; gPlayerEntity.base.knockbackDirection = DirectionTurnAround(direction); diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index ac12c313..73911ecf 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -96,7 +96,7 @@ void AcroBandit_OnTick(AcroBanditEntity* this) { void AcroBandit_OnCollision(AcroBanditEntity* this) { Entity* brother; - if (super->contactFlags != 0x80 && super->contactFlags != 0x81) { + if (super->contactFlags != CONTACT_TAKE_DAMAGE && super->contactFlags != (CONTACT_TAKE_DAMAGE | 0x1)) { if (super->type == 1) { if (super->action < 7 && super->knockbackDuration != 0) { brother = super->child; diff --git a/src/enemy/armos.c b/src/enemy/armos.c index 2824b950..bd164871 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -337,7 +337,7 @@ bool32 sub_080305BC(ArmosEntity* this) { bool32 sub_08030650(ArmosEntity* this) { if (super->type == 0) { - if (super->contactFlags == 0x80) { + if (super->contactFlags == CONTACT_TAKE_DAMAGE) { return 1; } } else if (this->unk_80 != 2) { diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index 10263a30..75924746 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -35,7 +35,7 @@ void Beetle_OnTick(BeetleEntity* this) { void Beetle_OnCollision(BeetleEntity* this) { switch (super->contactFlags) { - case 0x80: + case CONTACT_TAKE_DAMAGE: if (gPlayerState.framestate == PL_STATE_CLIMB) { Beetle_OnTick(this); } else { @@ -50,7 +50,7 @@ void Beetle_OnCollision(BeetleEntity* this) { InitializeAnimation(super, 6); } break; - case 0x93: + case CONTACT_TAKE_DAMAGE | 0x13: Beetle_OnTick(this); break; } diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index f007f779..7dfae72e 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -38,7 +38,7 @@ void Bobomb_OnTick(BobombEntity* this) { } void Bobomb_OnCollision(BobombEntity* this) { - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { switch (super->contactFlags & 0x7f) { case 0: case 1: diff --git a/src/enemy/bowMoblin.c b/src/enemy/bowMoblin.c index 3a86b016..6a1176ee 100644 --- a/src/enemy/bowMoblin.c +++ b/src/enemy/bowMoblin.c @@ -56,7 +56,7 @@ void BowMoblin_OnCollision(BowMoblinEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)BowMoblin_Functions); - if ((super->contactFlags & 0x80) != 0) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { sub_0803C5F0(this); pEVar1 = super->child; if (pEVar1 != NULL) { diff --git a/src/enemy/chaser.c b/src/enemy/chaser.c index 9255b1f1..3c374cd4 100644 --- a/src/enemy/chaser.c +++ b/src/enemy/chaser.c @@ -43,7 +43,7 @@ void sub_0802B540(Entity* this) { void sub_0802B56C(Entity* this) { GetNextFrame(this); - if (this->contactFlags & 0x80) { + if (this->contactFlags & CONTACT_TAKE_DAMAGE) { this->speed = 0x40; } diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index ca490003..0f054bdd 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -1346,7 +1346,7 @@ void sub_080272D4(ChuchuBossEntity* this) { super->hitbox->height = (u32)((0x10000 / this->unk_74.HALF_U.HI) * 5) >> 6; if (*(char*)&this->unk_84 == 0) break; - if ((super->contactFlags & 0x80) != 0) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { if (super->iframes != 0) { ((ChuchuBossEntity*)super->child)->unk_68->base.iframes = super->iframes; super->child->parent->iframes = super->iframes; @@ -1697,7 +1697,7 @@ bool32 sub_08027AA4(ChuchuBossEntity* this) { s32 iVar4; Helper* pHelper; - if ((super->contactFlags & 0x80) == 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) { return FALSE; } switch (super->contactFlags & 0x7f) { diff --git a/src/enemy/cloudPiranha.c b/src/enemy/cloudPiranha.c index 14296cd6..64bf98cc 100644 --- a/src/enemy/cloudPiranha.c +++ b/src/enemy/cloudPiranha.c @@ -58,7 +58,7 @@ void CloudPiranha_OnCollision(CloudPiranhaEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, gUnk_080CF4F0); - if ((super->contactFlags & 0x80) != 0) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { if (super->hitType == 0x5a) { switch (super->contactFlags & 0x3f) { case 0x14: diff --git a/src/enemy/crow.c b/src/enemy/crow.c index 4f0c587b..c540e4ae 100644 --- a/src/enemy/crow.c +++ b/src/enemy/crow.c @@ -44,7 +44,7 @@ void Crow_OnTick(CrowEntity* this) { } void Crow_OnCollision(CrowEntity* this) { - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { if ((super->contactFlags & 0x3f) == 0) { COLLISION_OFF(super); super->subtimer = 16; diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index f5d0919e..39820a64 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -335,7 +335,8 @@ void sub_080210E4(DarkNutEntity* this) { } sub_08021644(this); - if ((super->frame & 0x10) && (!ProcessMovement0(super) || (super->child && (super->child->contactFlags & 0x80)))) { + if ((super->frame & 0x10) && + (!ProcessMovement0(super) || (super->child && (super->child->contactFlags & CONTACT_TAKE_DAMAGE)))) { sub_080213D0(this, 0); } else { if (--this->unk_76 == 0) diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index 3839aabf..9987ee88 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -79,15 +79,15 @@ void Enemy50_OnCollision(Enemy50Entity* this) { sub_08041134(this); sub_0803F6EC(this); } - if (super->hitType == 0x25 && super->contactFlags == 0x80) { + if (super->hitType == 0x25 && super->contactFlags == CONTACT_TAKE_DAMAGE) { super->action = 8; InitializeAnimation(super, 3); } else { - if (super->contactFlags == 0x80) { + if (super->contactFlags == CONTACT_TAKE_DAMAGE) { this->unk_7c = 0x78; sub_08041128(this); } - if (super->contactFlags == 0x9d) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { super->zVelocity = Q_16_16(1.5); } if (super->confusedTime != 0) { @@ -422,7 +422,7 @@ void sub_0804122C(Enemy50Entity* this) { #ifndef EU bool32 sub_08041300(Enemy50Entity* this) { - if ((super->hitType == 0x25) && (super->contactFlags == 0x80)) { + if ((super->hitType == 0x25) && (super->contactFlags == CONTACT_TAKE_DAMAGE)) { return TRUE; } else { return super->action == 8 || super->action == 9; diff --git a/src/enemy/eyegore.c b/src/enemy/eyegore.c index 9c8eb9e1..b023469c 100644 --- a/src/enemy/eyegore.c +++ b/src/enemy/eyegore.c @@ -82,14 +82,14 @@ void Eyegore_OnTick(EyegoreEntity* this) { void Eyegore_OnCollision(EyegoreEntity* this) { u32 tmp; - if ((super->contactFlags == 0x95) || (super->contactFlags == 0x8e)) { + if ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15)) || (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe))) { Entity* entity = super->contactedEntity; tmp = (((entity->direction + 4) & 0x18) ^ 0x10) >> 3; if (tmp == super->animationState) { if ((tmp & 1) != 0) { if (0x10 < ((entity->y.HALF.HI + entity->z.HALF.HI) - (super->y.HALF.HI + super->z.HALF.HI)) + 0x14U) { } else { - if (super->contactFlags == 0x8e) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe)) { super->health = 0; } else { super->health--; @@ -105,7 +105,7 @@ void Eyegore_OnCollision(EyegoreEntity* this) { EnqueueSFX(SFX_BUTTON_PRESS); sub_08031344(this); } else { - if (super->contactFlags == 0x8e) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe)) { super->health = 0; } else { super->health--; diff --git a/src/enemy/flyingPot.c b/src/enemy/flyingPot.c index 8c4159d4..74f0a3b5 100644 --- a/src/enemy/flyingPot.c +++ b/src/enemy/flyingPot.c @@ -93,7 +93,7 @@ void FlyingPot_OnTick(FlyingPotEntity* this) { void FlyingPot_OnCollision(FlyingPotEntity* this) { sub_08037418(this); - if (super->contactFlags == 0x9D) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { super->action = FLYING_POT_ACTION_6; COLLISION_OFF(super); super->zVelocity = Q_16_16(2.625); diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 17c46040..7318f358 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -45,7 +45,7 @@ void FlyingSkull_OnTick(FlyingSkullEntity* this) { void FlyingSkull_OnCollision(FlyingSkullEntity* this) { sub_0803A100(this); - if (super->contactFlags == 0x9d) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { super->action = 7; COLLISION_OFF(super); super->zVelocity = Q_16_16(2.625); diff --git a/src/enemy/ghini.c b/src/enemy/ghini.c index e49b8293..87a9c402 100644 --- a/src/enemy/ghini.c +++ b/src/enemy/ghini.c @@ -59,11 +59,11 @@ void Ghini_OnCollision(GhiniEntity* this) { sub_0803F630(this); sub_0803F6EC(this); } - if ((super->hitType == 0x25) && (super->contactFlags == 0x80)) { + if ((super->hitType == 0x25) && (super->contactFlags == CONTACT_TAKE_DAMAGE)) { super->action = 8; InitializeAnimation(super, 3); } else { - if (super->contactFlags == 0x9d) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { super->zVelocity = 0x18000; } if (super->confusedTime != 0) { diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index 5da67ddf..0f521e14 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -52,7 +52,7 @@ void Gibdo_OnTick(GibdoEntity* this) { } void Gibdo_OnCollision(GibdoEntity* this) { - if (super->contactFlags == 0x87) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { if (super->action == 0x6) { sub_08037ACC(this); } @@ -62,7 +62,7 @@ void Gibdo_OnCollision(GibdoEntity* this) { Gibdo_CreateObjects(this); } else { if (super->action != 0x6) { - if (super->hitType == 0x27 && super->contactFlags == 0x80) { + if (super->hitType == 0x27 && super->contactFlags == CONTACT_TAKE_DAMAGE) { sub_08037A14(this); } else { if ((u8)(super->action - 1) < 2) { diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index dfbbd62c..9eb430b9 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -659,7 +659,7 @@ void sub_0802D86C(GleerokEntity* this) { } } - if ((super->contactFlags & 0x80) && this->unk_74 == 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) && this->unk_74 == 0) { if ((super->contactFlags & 0x7f) == 0x1d) { super->zVelocity = Q_16_16(3.0); super->parent->subAction = 4; @@ -1039,7 +1039,7 @@ void sub_0802E0B8(GleerokEntity* this) { super->type2 = 4; InitializeAnimation(super, 0x4e); } else { - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { if (super->iframes > 0) { SoundReq(SFX_BOSS_HIT); } diff --git a/src/enemy/hangingSeed.c b/src/enemy/hangingSeed.c index 1a383efb..dfdcae96 100644 --- a/src/enemy/hangingSeed.c +++ b/src/enemy/hangingSeed.c @@ -20,7 +20,7 @@ void HangingSeed_OnTick(Entity* this) { } void HangingSeed_OnCollision(Entity* this) { - if (this->contactFlags & 0x80) { + if (this->contactFlags & CONTACT_TAKE_DAMAGE) { CreateFx(this, FX_BUSH, 0x80); DeleteThisEntity(); } diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index d499adad..348d7e25 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -143,7 +143,7 @@ void Keaton_Action3(KeatonEntity* this) { } void Keaton_Action4(KeatonEntity* this) { - if (super->child && (super->child->contactFlags & 0x80)) { + if (super->child && (super->child->contactFlags & CONTACT_TAKE_DAMAGE)) { sub_0803275C(this); return; } diff --git a/src/enemy/leever.c b/src/enemy/leever.c index 3f8937b3..4bdc4253 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -47,7 +47,7 @@ void Leever_OnTick(LeeverEntity* this) { } void Leever_OnCollision(LeeverEntity* this) { - if (super->contactFlags == 0x80) { + if (super->contactFlags == CONTACT_TAKE_DAMAGE) { if (super->action == 3) { this->unk_74 = 1; } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 85919220..373953f6 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -46,8 +46,8 @@ void LikeLike_OnCollision(LikeLikeEntity* this) { } else { if (super->action == 7) { LikeLike_ReleasePlayer(this); - } else if (super->contactFlags & 0x80) { - u8 tmp = super->contactFlags & ~0x80; + } else if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + u8 tmp = super->contactFlags & ~CONTACT_TAKE_DAMAGE; if (tmp == 0) { super->action = 7; super->timer = 95; diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index 4dda2643..39d929c9 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -518,7 +518,7 @@ void sub_0802A098(MadderpillarEntity* this) { void sub_0802A0F8(MadderpillarEntity* this) { if (super->health != 0) { - if ((super->contactFlags & 0x80) && super->iframes != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) && super->iframes != 0) { Entity* entity = super; u32 i; for (i = 0; i < 6; i++) { @@ -549,7 +549,7 @@ void sub_0802A16C(MadderpillarEntity* this) { } void sub_0802A18C(MadderpillarEntity* this) { - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { switch (super->contactFlags & 0x7f) { case 0: case 1: diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index c2afcae9..65e917a2 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -167,7 +167,7 @@ void MazaalBracelet_OnCollision(MazaalBraceletEntity* this) { if (super->type < 2) { if (super->action != 0x2b) { - if ((0 < super->iframes) && ((super->contactFlags == 0x95 || (super->contactFlags == 0x8e)))) { + if ((0 < super->iframes) && ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15) || (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe))))) { super->action = 0x28; COLLISION_OFF(super); entity = (MazaalBraceletEntity*)super->parent; @@ -1299,7 +1299,7 @@ u32 sub_0803B870(MazaalBraceletEntity* this) { Entity* entity; entity = super->child; - if ((entity->contactFlags & 0x80) != 0 && (gPlayerState.flags & PL_CAPTURED)) { + if ((entity->contactFlags & CONTACT_TAKE_DAMAGE) != 0 && (gPlayerState.flags & PL_CAPTURED)) { super->action = 0x18; super->timer = 68; super->spriteSettings.draw = 0; diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index acb85509..ef1650f7 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -101,7 +101,7 @@ void Moldworm_OnCollision(MoldwormEntity* this) { super->iframes = -8; this->unk_7f = 0; this->unk_7b = 0; - if (super->contactFlags == 0x80 || super->contactFlags == 0x9e) { + if (super->contactFlags == CONTACT_TAKE_DAMAGE || super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1e)) { super->type2 = 0; this->unk_80 = 0x14; } else { @@ -441,7 +441,7 @@ void sub_08023894(MoldwormEntity* this) { } void sub_0802390C(MoldwormEntity* this) { - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { Entity* ent = super->child; do { ent->iframes = super->iframes; @@ -449,7 +449,7 @@ void sub_0802390C(MoldwormEntity* this) { } else { Entity* ent = super->child; do { - if (ent->contactFlags & 0x80) { + if (ent->contactFlags & CONTACT_TAKE_DAMAGE) { u8 bVar2 = 0xff - ent->health; if (bVar2 != 0) { u32 tmp; diff --git a/src/enemy/mulldozer.c b/src/enemy/mulldozer.c index b9911272..8af9198a 100644 --- a/src/enemy/mulldozer.c +++ b/src/enemy/mulldozer.c @@ -55,7 +55,7 @@ void Mulldozer_OnCollision(MulldozerEntity* this) { EnemyCreateFX(super, 0x1c); } EnemyFunctionHandlerAfterCollision(super, Mulldozer_Functions); - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { switch (super->contactFlags & 0x3f) { case 2: case 3: diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index d4c0e3d8..c3250c60 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -61,7 +61,7 @@ void Peahat_OnTick(PeahatEntity* this) { void Peahat_OnCollision(PeahatEntity* this) { if (this->unk_82) { - if (super->contactFlags == 0x94) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x14)) { Entity* entity = CreateEnemy(PEAHAT, PeahatForm_Propeller); if (entity != NULL) { CopyPosition(super, entity); @@ -74,14 +74,14 @@ void Peahat_OnCollision(PeahatEntity* this) { super->iframes = -30; this->unk_81 = 0; InitializeAnimation(super, super->animationState); - } else if (super->contactFlags == 0x9b) { + } else if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1b)) { super->animationState = PeahatAnimation_BrokenPropeller; super->action = 5; super->speed = 0x80; super->iframes = -30; this->unk_81 = 0; InitializeAnimation(super, super->animationState); - } else if (super->contactFlags == 0x80) { + } else if (super->contactFlags == CONTACT_TAKE_DAMAGE) { if (super->animationState == PeahatAnimation_Flying) { super->action = 1; super->timer = 30; diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index b3f6cfdc..f0bdb5a2 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -65,7 +65,7 @@ void Pesto_OnTick(PestoEntity* this) { void Pesto_OnCollision(PestoEntity* this) { if (super->hitType != 0x6e) { - if (super->contactFlags == 0x80) { + if (super->contactFlags == CONTACT_TAKE_DAMAGE) { this->unk_86 = 0x30; if ((this->unk_83 & 0xf) == 3 && super->action == 6) { diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index f6eba66d..4b760d66 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -100,7 +100,7 @@ void sub_080223E4(Entity* this) { entity = this->child; if (entity != NULL) { - entity->contactFlags = 0x94; + entity->contactFlags = (CONTACT_TAKE_DAMAGE | 0x14); entity->iframes = 0x10; #ifndef EU entity->knockbackDuration = 0xc; diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index 7d297f8d..6031dd12 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -51,7 +51,7 @@ void Rollobite_OnCollision(RollobiteEntity* this) { InitializeAnimation(super, super->animationState + 8); } - if (super->contactFlags != 0x80) { + if (super->contactFlags != CONTACT_TAKE_DAMAGE) { if (super->action == 4 || super->action == 5) { super->action = 4; super->timer = 180; @@ -60,7 +60,7 @@ void Rollobite_OnCollision(RollobiteEntity* this) { } } - if (super->contactFlags == 0x93) + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x13)) Rollobite_OnTick(this); } diff --git a/src/enemy/scissorsBeetle.c b/src/enemy/scissorsBeetle.c index 34aca2b2..bbd7f223 100644 --- a/src/enemy/scissorsBeetle.c +++ b/src/enemy/scissorsBeetle.c @@ -44,7 +44,7 @@ void ScissorsBeetle_OnCollision(ScissorsBeetleEntity* this) { } EnemyFunctionHandlerAfterCollision(super, ScissorsBeetle_Functions); - if ((super->contactFlags & 0x80) && super->action != 4) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) && super->action != 4) { u32 knockbackDir; child = super->child; child->iframes = super->iframes; diff --git a/src/enemy/spark.c b/src/enemy/spark.c index e135424b..7006c8b9 100644 --- a/src/enemy/spark.c +++ b/src/enemy/spark.c @@ -22,7 +22,7 @@ void Spark_OnTick(Entity* this) { void Spark_OnCollision(Entity* this) { Entity* entity; - if (this->contactFlags & 0x80) { + if (this->contactFlags & CONTACT_TAKE_DAMAGE) { if ((this->contactFlags & 0x7f) == 0x14) { COLLISION_OFF(this); this->iframes = 0; diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index ac61f57e..97d5850b 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -57,7 +57,7 @@ void SpearMoblin_OnCollision(SpearMoblinEntity* this) { EnemyCreateFX(super, FX_STARS); EnemyFunctionHandlerAfterCollision(super, SpearMoblin_Functions); - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { if (super->action != 4) { sub_08028754(this); } else { @@ -398,7 +398,7 @@ bool32 sub_080288A4(SpearMoblinEntity* this) { void sub_080288C0(SpearMoblinEntity* this) { Entity* entity = super->child; - if ((entity != NULL) && (entity->contactFlags & 0x80)) { + if ((entity != NULL) && (entity->contactFlags & CONTACT_TAKE_DAMAGE)) { super->knockbackDirection = entity->knockbackDirection; super->iframes = -entity->iframes; super->knockbackSpeed = entity->knockbackSpeed; diff --git a/src/enemy/spinyBeetle.c b/src/enemy/spinyBeetle.c index ebaa6322..d729bc52 100644 --- a/src/enemy/spinyBeetle.c +++ b/src/enemy/spinyBeetle.c @@ -49,7 +49,7 @@ void SpinyBeetle_OnCollision(SpinyBeetleEntity* this) { } EnemyFunctionHandlerAfterCollision(super, SpinyBeetle_Functions); - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { if (super->iframes > 0 && super->child) { sub_08033E1C(this); } diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index 0028054f..d736b8e0 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -60,7 +60,7 @@ void SpinyChuchu_OnCollision(SpinyChuchuEntity* this) { super->hitType = 0x5c; InitializeAnimation(super, 1); } - } else if (super->contactFlags == 0x94) { + } else if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x14)) { EnemyCreateFX(super, FX_STARS); super->action = 5; InitializeAnimation(super, 1); diff --git a/src/enemy/takkuri.c b/src/enemy/takkuri.c index 20dd168a..38aa602f 100644 --- a/src/enemy/takkuri.c +++ b/src/enemy/takkuri.c @@ -46,7 +46,7 @@ void Takkuri_OnTick(TakkuriEntity* this) { } void Takkuri_OnCollision(TakkuriEntity* this) { - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { if ((super->contactFlags & 0x7f) == 0) { u32 direction; sub_0803C0AC(super); diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index 803ebd47..0cc625b3 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -63,7 +63,7 @@ void Tektite_OnCollision(TektiteEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Tektite_Functions); - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { switch (super->contactFlags & 0x3f) { case 0x14: super->action = 1; diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index 22184e0d..c6af233a 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -51,7 +51,7 @@ void TektiteGolden_OnCollision(TektiteGoldenEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, TektiteGolden_Functions); - if (super->contactFlags == 0x94) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x14)) { super->action = 1; super->subAction = 0; super->timer = 20; diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index 65ace01e..b94db4e5 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -1401,7 +1401,7 @@ static void sub_08043C40(VaatiArmEntity* this, VaatiArm_HeapStruct1* heapStruct) static bool32 sub_08043C98(VaatiArmEntity* this) { #if defined EU || defined JP Entity* e1 = &((VaatiArm_HeapStruct*)super->myHeap)->entities[3]->base; - if ((e1->contactFlags == 0x9d)) { + if ((e1->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d))) { sub_08043D08(this); return TRUE; } else { @@ -1410,7 +1410,7 @@ static bool32 sub_08043C98(VaatiArmEntity* this) { #else Entity* e1 = &((VaatiArm_HeapStruct*)super->myHeap)->entities[2]->base; Entity* e2 = &((VaatiArm_HeapStruct*)super->myHeap)->entities[3]->base; - if ((e1->contactFlags == 0x9d) || (e2->contactFlags == 0x9d)) { + if ((e1->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) || (e2->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d))) { sub_08043D08(this); gRoomTransition.field_0x38 |= 2; return TRUE; @@ -1423,7 +1423,7 @@ static bool32 sub_08043C98(VaatiArmEntity* this) { static void sub_08043CD4(VaatiArmEntity* this) { u32 i; for (i = 0; i < 5; i++) { - if (((VaatiArm_HeapStruct*)super->myHeap)->entities[i]->base.contactFlags == 0x9d) { + if (((VaatiArm_HeapStruct*)super->myHeap)->entities[i]->base.contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { this->unk_7c = 0x78; this->unk_7d = i; return; diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 485749b5..a32eb624 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -58,7 +58,7 @@ void VaatiBall(VaatiBallEntity* this) { super->health = -1; } - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { if ((super->contactFlags & 0x3f) == 0 && super->action == 6) { ModHealth(-2); } diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index a202f9a3..a7efe411 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -66,7 +66,7 @@ void VaatiProjectile_OnTick(VaatiProjectileEntity* this) { void VaatiProjectile_OnCollision(VaatiProjectileEntity* this) { Entity* entity; - if (super->contactFlags == 0x80) { + if (super->contactFlags == CONTACT_TAKE_DAMAGE) { #ifndef EU if (super->health != 0) { #endif diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index 83fcbc65..28586549 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -539,7 +539,7 @@ void VaatiRebornEnemyType1Action1(VaatiRebornEnemyEntity* this) { super->hitType = 0x2f; InitAnimationForceUpdate(super, this->unk_74); } else { - if (((super->contactFlags & 0x80) != 0) && (0 < super->iframes)) { + if (((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (0 < super->iframes)) { parent->iframes = super->iframes; parent->contactFlags = super->contactFlags; } @@ -665,7 +665,7 @@ void VaatiRebornEnemyType1PreAction(VaatiRebornEnemyEntity* this) { } parent = super->parent; this->unk_77 = 0; - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { if (gUnk_080D04D0[((VaatiRebornEnemyEntity*)parent)->unk_86] > super->health) { if (2 < ++((VaatiRebornEnemyEntity*)parent)->unk_86) { COLLISION_OFF(super); diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index e04bd547..9d8f7158 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -1097,11 +1097,11 @@ void sub_080409B0(VaatiTransfiguredEntity* this) { Knockback1(super); } } else { - if (((super->contactFlags & 0x80) != 0) && (0 < super->iframes)) { + if (((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (0 < super->iframes)) { InitScreenShake(12, 1); SoundReq(SFX_BOSS_HIT); } - if ((super->contactFlags == 0x8a) && (gPlayerState.chargeState.action == 5)) { + if ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xa)) && (gPlayerState.chargeState.action == 5)) { super->health = 0xc0; } } diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c index e417c2fd..74e0a522 100644 --- a/src/enemy/vaatiTransfiguredEye.c +++ b/src/enemy/vaatiTransfiguredEye.c @@ -72,7 +72,7 @@ void VaatiTransfiguredEye_OnCollision(VaatiTransfiguredEyeEntity* this) { if (super->type != 0) { pEVar4 = super->parent->parent; - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { bVar1 = super->contactFlags & 0x3f; if ((bVar1 == 0xe) || (bVar1 == 0x15)) { diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index b8bd9b20..cac6435c 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -101,7 +101,7 @@ const s8 gUnk_080D0EB0[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x0 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd }; void VaatiWrath(VaatiWrathEntity* this) { - if (((super->type == 0) && ((super->contactFlags & 0x80) != 0)) && (super->health == 0)) { + if (((super->type == 0) && ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) && (super->health == 0)) { COLLISION_ON(super); super->health = 0xff; if (--this->unk_84 == 0) { diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 1ed368b6..88125bcf 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -57,7 +57,7 @@ void Wisp_OnCollision(WispEntity* this) { Entity* entity; bits = super->contactFlags; - if ((bits & 0x80) == 0) { + if ((bits & CONTACT_TAKE_DAMAGE) == 0) { return; } diff --git a/src/enemy/wizzrobeIce.c b/src/enemy/wizzrobeIce.c index 84fe790e..def00092 100644 --- a/src/enemy/wizzrobeIce.c +++ b/src/enemy/wizzrobeIce.c @@ -26,7 +26,7 @@ void WizzrobeIce_OnCollision(WizzrobeEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, WizzrobeIce_Functions); - if (super->contactFlags == 0x87) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { Entity* obj = CreateObject(FLAME, 3, 0); if (obj != NULL) { obj->spritePriority.b0 = 3; diff --git a/src/enemy/wizzrobeWind.c b/src/enemy/wizzrobeWind.c index 8f23e3da..b4aeca23 100644 --- a/src/enemy/wizzrobeWind.c +++ b/src/enemy/wizzrobeWind.c @@ -33,7 +33,7 @@ void WizzrobeWind_OnCollision(WizzrobeEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, WizzrobeWind_Functions); - if (super->contactFlags == 0x87) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { Entity* obj = CreateObject(FLAME, 3, 0); if (obj != NULL) { obj->spritePriority.b0 = 3; diff --git a/src/enemyUtils.c b/src/enemyUtils.c index 04281240..ed13377f 100644 --- a/src/enemyUtils.c +++ b/src/enemyUtils.c @@ -314,9 +314,9 @@ void EnemyDetachFX(Entity* entity) { /** Unsets bitfield 0x80 before calling GetNextFunction, so that the enemyFunction 1 is not called. */ void EnemyFunctionHandlerAfterCollision(Entity* entity, void (*const fntable[])()) { u32 idx; - entity->contactFlags &= ~0x80; + entity->contactFlags &= ~CONTACT_TAKE_DAMAGE; idx = GetNextFunction(entity); - entity->contactFlags |= 0x80; + entity->contactFlags |= CONTACT_TAKE_DAMAGE; fntable[idx](entity); } diff --git a/src/interrupts.c b/src/interrupts.c index b27a43a7..5ea8bc64 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -236,7 +236,7 @@ static void HandlePlayerLife(Entity* this) { gUnk_0200AF00.rActionInteractTile = R_ACTION_NONE; gUnk_0200AF00.rActionGrabbing = R_ACTION_NONE; - if ((gPlayerEntity.base.contactFlags & 0x80) && (gPlayerEntity.base.iframes > 0)) + if ((gPlayerEntity.base.contactFlags & CONTACT_TAKE_DAMAGE) && (gPlayerEntity.base.iframes > 0)) SoundReq(SFX_86); gPlayerState.flags &= ~(PL_FALLING | PL_CONVEYOR_PUSHED); @@ -323,7 +323,7 @@ static void sub_080171F0(void) { if (gPlayerEntity.unk_7a != 0) gPlayerEntity.unk_7a--; - gPlayerEntity.base.contactFlags &= ~0x80; + gPlayerEntity.base.contactFlags &= ~CONTACT_TAKE_DAMAGE; if (gPlayerEntity.base.action != PLAYER_DROWN) COPY_FLAG_FROM_TO(gPlayerState.flags, 0x2, 0x10000); diff --git a/src/npc/npc5.c b/src/npc/npc5.c index d4a78753..dc301ae8 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -525,7 +525,7 @@ u32 sub_080611D4(Entity* this) { u32 sub_08061230(NPC5Entity* this) { if ((((UnkHeap*)super->myHeap)->unk_0 & 1) == 0) { - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { switch (super->contactFlags & 0x7f) { case 0: case 1: diff --git a/src/object.c b/src/object.c index 8f23887e..31bbdd63 100644 --- a/src/object.c +++ b/src/object.c @@ -207,7 +207,7 @@ void ObjectUpdate(Entity* this) { this->iframes++; if (!EntityDisabled(this)) { gObjectFunctions[this->id](this); - this->contactFlags &= ~0x80; + this->contactFlags &= ~CONTACT_TAKE_DAMAGE; } DrawEntity(this); } diff --git a/src/object/barrelSpiderweb.c b/src/object/barrelSpiderweb.c index 386f2c74..d4d821dd 100644 --- a/src/object/barrelSpiderweb.c +++ b/src/object/barrelSpiderweb.c @@ -64,7 +64,7 @@ void sub_0808BBE0(Entity* this) { ptr = &gUnk_0812144C[diff * 2]; SetAffineInfo(this, ptr[0], ptr[1], 0); } else { - this->contactFlags &= ~0x80; + this->contactFlags &= ~CONTACT_TAKE_DAMAGE; } } @@ -74,7 +74,7 @@ void BarrelSpiderweb_Action1(Entity* this) { tmp = -0x170; this->y.HALF.HI = gRoomControls.origin_y - ((this->parent)->zVelocity + tmp); sub_0808BBE0(this); - if (this->contactFlags == 0x93) { + if (this->contactFlags == (CONTACT_TAKE_DAMAGE | 0x13)) { this->timer--; this->spriteSettings.draw = 1; if (this->timer == 0) { @@ -114,7 +114,7 @@ void BarrelSpiderweb_Action2(Entity* this) { this->subtimer -= 8; SetAffineInfo(this, 0x200 - this->subtimer, 0x200 - this->subtimer, 0); } - if (this->contactFlags == 0x93) { + if (this->contactFlags == (CONTACT_TAKE_DAMAGE | 0x13)) { this->direction = GetFacingDirection(this, &gPlayerEntity.base); LinearMoveUpdate(this); if (EntityWithinDistance(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI - 6, 0x1c)) { diff --git a/src/object/dirtParticle.c b/src/object/dirtParticle.c index 827456c2..ac7e848e 100644 --- a/src/object/dirtParticle.c +++ b/src/object/dirtParticle.c @@ -101,7 +101,7 @@ void DirtParticle_Init(DirtParticleEntity* this) { void DirtParticle_Action1(DirtParticleEntity* this) { DirtParticleEntity* entity; - if ((super->contactFlags & 0x80) == 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) { return; } switch (super->contactFlags & 0x7f) { @@ -128,7 +128,7 @@ void DirtParticle_Action3(DirtParticleEntity* this) { sub_08087B9C, sub_08087B9C, }; - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { gUnk_08120A80[super->subAction](this); } else { super->action = 1; diff --git a/src/object/eyeSwitch.c b/src/object/eyeSwitch.c index 152d511a..60310e5c 100644 --- a/src/object/eyeSwitch.c +++ b/src/object/eyeSwitch.c @@ -50,7 +50,7 @@ void EyeSwitch_Init(EyeSwitchEntity* this) { } void EyeSwitch_Action1(EyeSwitchEntity* this) { - if ((super->contactFlags == 0x95 || super->contactFlags == 0x8e) && + if ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15) || super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe)) && (DirectionRoundUp(super->contactedEntity->direction) >> 3 == (super->animationState & 3))) { super->action = 2; COLLISION_OFF(super); diff --git a/src/object/fairy.c b/src/object/fairy.c index 871da3dd..38026906 100644 --- a/src/object/fairy.c +++ b/src/object/fairy.c @@ -40,7 +40,7 @@ void Fairy(FairyEntity* this) { Fairy_Init, Fairy_Action1, Fairy_Action2, Fairy_Action3, Fairy_Action4, }; - if (((super->contactFlags & 0x80) != 0)) { + if (((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) { switch (super->contactFlags & 0x7f) { case 0x14: super->action = 3; diff --git a/src/object/hittableLever.c b/src/object/hittableLever.c index 8e6b63be..0bf530ac 100644 --- a/src/object/hittableLever.c +++ b/src/object/hittableLever.c @@ -47,7 +47,7 @@ void HittableLever_Init(HittableLeverEntity* this) { } void HittableLever_Idle(HittableLeverEntity* this) { - if (((super->contactFlags & 0x80) != 0) && (this->wasHit == 0)) { + if (((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (this->wasHit == 0)) { this->wasHit = 1; super->type ^= 1; super->iframes = -0x18; diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index dc9d0975..b3f6f045 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -63,7 +63,7 @@ void ItemOnGround(ItemOnGroundEntity* this) { static void (*const ItemOnGround_Actions[])(ItemOnGroundEntity*) = { ItemOnGround_Init, ItemOnGround_Action1, ItemOnGround_Action2, ItemOnGround_Action3, ItemOnGround_Action4, }; - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { switch (super->contactFlags & 0x7F) { case 20: super->action = 3; diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index aa94b26f..f2e4f852 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -170,7 +170,7 @@ void JarPortal_Action4(JarPortalEntity* this) { } u32 sub_0808C128(JarPortalEntity* this) { - return super->contactFlags == 157; + return super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d); } void sub_0808C13C(JarPortalEntity* this) { diff --git a/src/object/lavaPlatform.c b/src/object/lavaPlatform.c index 5db1f0b9..619bc685 100644 --- a/src/object/lavaPlatform.c +++ b/src/object/lavaPlatform.c @@ -131,7 +131,7 @@ void LavaPlatform_Type1Action1(LavaPlatformEntity* this) { } void LavaPlatform_Type1Action2(LavaPlatformEntity* this) { - if (super->contactFlags == 0x9d) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { sub_08092620(this); } else { if (LavaPlatform_IsPlayerOnPlatform(this)) { @@ -223,7 +223,7 @@ void LavaPlatform_Type1Action6(LavaPlatformEntity* this) { } void LavaPlatform_Type1Action7(LavaPlatformEntity* this) { - if (super->contactFlags == 0x9d) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { sub_08092620(this); } } diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index 927a4c9d..8c68f708 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -67,7 +67,7 @@ void LightableSwitch_Type0_Init(LightableSwitchEntity* this) { void LightableSwitch_Type0_Action1(LightableSwitchEntity* this) { - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { if (CheckFlags(this->unk_86) != 0) { ClearFlag(this->unk_86); } else { @@ -147,7 +147,7 @@ void LightableSwitch_Type1_Init(LightableSwitchEntity* this) { } void LightableSwitch_Type1_Action1(LightableSwitchEntity* this) { - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { super->action = 2; super->timer = 16; super->frameIndex = 2; diff --git a/src/object/objectA8.c b/src/object/objectA8.c index 4de9ccae..6f47de25 100644 --- a/src/object/objectA8.c +++ b/src/object/objectA8.c @@ -39,7 +39,7 @@ void ObjectA8(ObjectA8Entity* this) { ObjectA8_Init, ObjectA8_Action1, ObjectA8_Action2, ObjectA8_Action3, ObjectA8_Action4, ObjectA8_Action5, ObjectA8_Action6, }; - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { switch (super->contactFlags & 0x7f) { case 0: case 1: diff --git a/src/object/objectOnSpinyBeetle.c b/src/object/objectOnSpinyBeetle.c index 17597f8f..aa28ae96 100644 --- a/src/object/objectOnSpinyBeetle.c +++ b/src/object/objectOnSpinyBeetle.c @@ -72,7 +72,7 @@ void ObjectOnSpinyBeetle_Action1(ObjectOnSpinyBeetleEntity* this) { sub_080989C0(this); return; } - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { switch (super->contactFlags & 0x3f) { case 0x13: super->action = 3; diff --git a/src/object/sanctuaryStoneTablet.c b/src/object/sanctuaryStoneTablet.c index 31201381..b612f487 100644 --- a/src/object/sanctuaryStoneTablet.c +++ b/src/object/sanctuaryStoneTablet.c @@ -44,7 +44,7 @@ void SanctuaryStoneTablet_Init(SanctuaryStoneTabletEntity* this) { void SanctuaryStoneTablet_Action1(SanctuaryStoneTabletEntity* this) { Entity* fxEnt; - if (super->contactFlags == 0xa1) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x21)) { fxEnt = CreateFx(super, FX_MAGIC_STORM, 0); if (fxEnt != NULL) { fxEnt->spritePriority.b0 = 3; diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c index e5a6c3f1..836dc648 100644 --- a/src/object/smallIceBlock.c +++ b/src/object/smallIceBlock.c @@ -281,7 +281,7 @@ bool32 sub_0809963C(SmallIceBlockEntity* this) { } } } - if (super->contactFlags == 0x87) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { return TRUE; } return FALSE; diff --git a/src/object/unusedSkull.c b/src/object/unusedSkull.c index 204fc9b6..40303016 100644 --- a/src/object/unusedSkull.c +++ b/src/object/unusedSkull.c @@ -49,7 +49,7 @@ void UnusedSkull_Init(UnusedSkullEntity* this) { } void UnusedSkull_Action1(UnusedSkullEntity* this) { - if (super->contactFlags == 0x9c) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1c)) { super->action = 2; super->flags &= ~0x80; CreateFx(super, FX_ICE, 0); diff --git a/src/physics.c b/src/physics.c index 206b33c3..ac34b999 100644 --- a/src/physics.c +++ b/src/physics.c @@ -114,7 +114,7 @@ void sub_0806F4E8(Entity* ent) { } bool32 sub_0806F520(Entity* ent) { - if (ent->contactFlags == 0x93) + if (ent->contactFlags == (CONTACT_TAKE_DAMAGE | 0x13)) return 1; ent->gustJarState &= ~4; ent->spriteOffsetY = 0; diff --git a/src/player.c b/src/player.c index a67e1022..4f0dec35 100644 --- a/src/player.c +++ b/src/player.c @@ -2067,7 +2067,8 @@ static void PlayerRollInit(PlayerEntity* this) { static void PlayerRollUpdate(PlayerEntity* this) { if (((gPlayerState.flags & (PL_ROLLING | PL_MOLDWORM_CAPTURED)) != PL_ROLLING) || - (!(gPlayerState.flags & PL_MOLDWORM_RELEASED) && (super->iframes != 0) && (super->contactFlags & 0x80))) { + (!(gPlayerState.flags & PL_MOLDWORM_RELEASED) && (super->iframes != 0) && + (super->contactFlags & CONTACT_TAKE_DAMAGE))) { gPlayerState.flags &= ~PL_ROLLING; if (CheckQueuedAction()) return; diff --git a/src/playerItem.c b/src/playerItem.c index dcf2532b..46fbd023 100644 --- a/src/playerItem.c +++ b/src/playerItem.c @@ -74,7 +74,7 @@ void ItemUpdate(Entity* this) { if (!EntityDisabled(this)) { gPlayerItemFunctions[this->id](this); - this->contactFlags &= ~0x80; + this->contactFlags &= ~CONTACT_TAKE_DAMAGE; if (this->iframes != 0) { if (this->iframes > 0) this->iframes--; diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c index 0f7a8662..ca380e3e 100644 --- a/src/playerItem/playerItemBoomerang.c +++ b/src/playerItem/playerItemBoomerang.c @@ -184,7 +184,7 @@ void PlayerItemBoomerang_Action2(PlayerItemBoomerangEntity* this) { if (super->timer == 0) { uVar6 = TRUE; } - if (super->contactFlags & 0x80) { + if (super->contactFlags & CONTACT_TAKE_DAMAGE) { uVar6 = TRUE; } if (!uVar6) { diff --git a/src/playerItem/playerItemGustBig.c b/src/playerItem/playerItemGustBig.c index 15e95c2d..e0adbfcb 100644 --- a/src/playerItem/playerItemGustBig.c +++ b/src/playerItem/playerItemGustBig.c @@ -141,7 +141,7 @@ void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this) { if ((super->child->gustJarState & 4) == 0) { DeleteThisEntity(); } - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { PlayerItemGustBig_Action3(this); return; } diff --git a/src/playerItem/playerItemHeldObject.c b/src/playerItem/playerItemHeldObject.c index 7d1eebd6..dee58c8b 100644 --- a/src/playerItem/playerItemHeldObject.c +++ b/src/playerItem/playerItemHeldObject.c @@ -112,7 +112,7 @@ void PlayerItemHeldObject_SubAction2(PlayerItemHeldObjectEntity* this) { if ((child->base).action != 2) { DeleteThisEntity(); } - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { super->z.WORD = 0; } if (super->speed != 0) { diff --git a/src/playerItem/playerItemShield.c b/src/playerItem/playerItemShield.c index bb592f74..35bd8586 100644 --- a/src/playerItem/playerItemShield.c +++ b/src/playerItem/playerItemShield.c @@ -102,7 +102,7 @@ void PlayerItemShield_Action1(PlayerItemShieldEntity* this) { gPlayerState.shield_status &= ~0x80; sub_080176E4(super); } else { - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { if ((((super->contactFlags & 0x7f) == 0x42) && this->unk_68 == 0xe) && ((gPlayerState.shield_status & 0x40) == 0)) { playerItem = CreatePlayerItem(PLAYER_ITEM_FIRE_ROD_PROJECTILE, 0, 0, this->unk_68); diff --git a/src/playerItem/playerItemSword.c b/src/playerItem/playerItemSword.c index 6df61709..e9e45087 100644 --- a/src/playerItem/playerItemSword.c +++ b/src/playerItem/playerItemSword.c @@ -285,7 +285,7 @@ void sub_080A78B8(PlayerItemSwordEntity* this, Entity* param_2) { } super->spriteSettings.flipX = flipX; } - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { if ((param_2->iframes == 0) || ((u8)param_2->iframes == 0x81)) { param_2->iframes = super->iframes; param_2->knockbackDirection = super->knockbackDirection; diff --git a/src/projectile/arrowProjectile.c b/src/projectile/arrowProjectile.c index 0eda80eb..7acc8003 100644 --- a/src/projectile/arrowProjectile.c +++ b/src/projectile/arrowProjectile.c @@ -34,7 +34,7 @@ void ArrowProjectile_OnTick(Entity* this) { } void ArrowProjectile_OnCollision(Entity* this) { - if ((this->contactFlags & 0x80) != 0) { + if ((this->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { if ((this->contactFlags & 0x3f) != 0) { ModHealth(-2); sub_080A9488(this); diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index 164ec13b..82c2156c 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -23,7 +23,7 @@ void BoneProjectile_OnTick(Entity* this) { } void BoneProjectile_OnCollision(Entity* this) { - if (this->contactFlags == 0x80) { + if (this->contactFlags == CONTACT_TAKE_DAMAGE) { DeleteEntity(this); } else { sub_080A82D8(this); diff --git a/src/projectile/darkNutSwordSlash.c b/src/projectile/darkNutSwordSlash.c index e95ab908..838435e5 100644 --- a/src/projectile/darkNutSwordSlash.c +++ b/src/projectile/darkNutSwordSlash.c @@ -30,7 +30,7 @@ void DarkNutSwordSlash(Entity* this) { if ((this->parent == NULL) || (this->parent->health == 0)) { DeleteThisEntity(); } - if (((this->contactFlags & 0x80) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { + if (((this->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { this->iframes = -0x2d; } this->contactFlags = 0; diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c index 132bf708..302615fe 100644 --- a/src/projectile/dekuSeedProjectile.c +++ b/src/projectile/dekuSeedProjectile.c @@ -24,7 +24,7 @@ void DekuSeedProjectile_OnTick(Entity* this) { } void DekuSeedProjectile_OnCollision(Entity* this) { - if (this->contactFlags == 0x80) { + if (this->contactFlags == CONTACT_TAKE_DAMAGE) { if (this->hitType == 0x68) { EnqueueSFX(SFX_86); } @@ -75,7 +75,7 @@ void DekuSeedProjectile_Action1(Entity* this) { if ((parent->next != NULL) && (IsColliding(this, parent) != 0)) { this->iframes = 0x10; this->knockbackDirection = -this->direction; - this->contactFlags = 0x80; + this->contactFlags = CONTACT_TAKE_DAMAGE; this->knockbackDuration = 0xc; this->knockbackSpeed = 0; parent->iframes = 0x10; diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index 12f9beae..3da1926c 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -41,7 +41,7 @@ void DirtBallProjectile_OnCollision(Entity* this) { this->knockbackSpeed = 0; if (this->type == 0) { this->parent->child = NULL; - if (this->contactFlags == 0x80) { + if (this->contactFlags == CONTACT_TAKE_DAMAGE) { gPlayerState.hurtBlinkSpeed = 0xf0; ModHealth(-2); } diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index 2b4af4f2..cac30dd3 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -28,7 +28,7 @@ void GleerokProjectile(GleerokProjectileEntity* this) { } void GleerokProjectile_OnTick(GleerokProjectileEntity* this) { - if (((super->type != 3) && ((super->contactFlags & 0x80) != 0)) && ((super->contactFlags & 0x7f) != 0x1e)) { + if (((super->type != 3) && ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) && ((super->contactFlags & 0x7f) != 0x1e)) { super->action = 3; COLLISION_OFF(super); InitializeAnimation(super, 0x53); diff --git a/src/projectile/guardLineOfSight.c b/src/projectile/guardLineOfSight.c index f76f4360..dfb59237 100644 --- a/src/projectile/guardLineOfSight.c +++ b/src/projectile/guardLineOfSight.c @@ -26,7 +26,7 @@ void GuardLineOfSight(Entity* this) { this->timer = Random(); this->spriteSettings.draw = 0; } - if (this->contactFlags == 0x80) { + if (this->contactFlags == CONTACT_TAKE_DAMAGE) { if (this->parent != NULL) { this->parent->type = 0xff; } @@ -58,7 +58,7 @@ void GuardLineOfSight(Entity* this) { this->hitbox = (Hitbox*)&gUnk_080FD1E4; InitializeAnimation(this, 0); } - if (this->contactFlags == 0x80) { + if (this->contactFlags == CONTACT_TAKE_DAMAGE) { if (this->parent != NULL) { this->parent->type = 0xff; } diff --git a/src/projectile/keatonDagger.c b/src/projectile/keatonDagger.c index 4f5b95af..6a4b66c3 100644 --- a/src/projectile/keatonDagger.c +++ b/src/projectile/keatonDagger.c @@ -20,7 +20,7 @@ void KeatonDagger(Entity* this) { } parent = this->parent; if (((parent == NULL) || (parent->health == 0)) || (parent->next == NULL)) { - if (((this->contactFlags & 0x80) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { + if (((this->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { sub_0803C0AC(this); } DeleteEntity(this); diff --git a/src/projectile/lakituLightning.c b/src/projectile/lakituLightning.c index 866c5b20..47d300a7 100644 --- a/src/projectile/lakituLightning.c +++ b/src/projectile/lakituLightning.c @@ -23,7 +23,7 @@ void LakituLightning_OnTick(Entity* this) { } void LakituLightning_OnCollision(Entity* this) { - if ((this->health == 0) || (this->contactFlags == 0x80)) { + if ((this->health == 0) || (this->contactFlags == CONTACT_TAKE_DAMAGE)) { DeleteThisEntity(); } LakituLightning_OnTick(this); diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index 6e797140..0062d622 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -55,7 +55,7 @@ void MandiblesProjectile_OnTick(MandiblesProjectileEntity* this) { void MandiblesProjectile_OnCollision(MandiblesProjectileEntity* this) { Entity* parent; - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { switch (super->action) { case 4: super->subtimer = 0; diff --git a/src/projectile/moblinSpear.c b/src/projectile/moblinSpear.c index ea1ac374..076477b0 100644 --- a/src/projectile/moblinSpear.c +++ b/src/projectile/moblinSpear.c @@ -38,7 +38,7 @@ void MoblinSpear_OnTick(Entity* this) { void MoblinSpear_OnCollision(Entity* this) { u8 tmp; - if (this->contactFlags == 0x80) { + if (this->contactFlags == CONTACT_TAKE_DAMAGE) { this->iframes = 0x10; this->knockbackDuration = 0xc; this->knockbackSpeed = 0x180; diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 789e3a41..43982f37 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -99,7 +99,7 @@ void OctorokBossProjectile_Action1(OctorokBossProjectileEntity* this) { if (super->parent->action == 2) { DeleteThisEntity(); } - if ((super->type2 == 0) && ((super->contactFlags & 0x80) != 0)) { + if ((super->type2 == 0) && ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) { if ((super->contactFlags & 0x7f) == 0) { OctorokBossProjectile_Action2(this); } @@ -182,7 +182,7 @@ void OctorokBossProjectile_Action1(OctorokBossProjectileEntity* this) { if (--*(u32*)&this->unk_78 == -1) { OctorokBossProjectile_Action2(this); } - if ((super->contactFlags & 0x80) == 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) { return; } OctorokBossProjectile_Action2(this); diff --git a/src/projectile/projectile5.c b/src/projectile/projectile5.c index 31471e10..379dd97d 100644 --- a/src/projectile/projectile5.c +++ b/src/projectile/projectile5.c @@ -41,7 +41,7 @@ void Projectile5_OnCollision(Entity* this) { if ((((Projectile5Entity*)this->parent)->unk_83 & 0x3f) == 3) { if (gPlayerState.hurtBlinkSpeed != 0) { if (sub_080B1B44(TILE(this->x.HALF.HI, this->y.HALF.HI), gPlayerEntity.base.collisionLayer) == 0) { - if (this->contactFlags == 0x80) { + if (this->contactFlags == CONTACT_TAKE_DAMAGE) { *pbVar2 = *pbVar2 & 0x7f; DeleteThisEntity(); } diff --git a/src/projectile/removableDust.c b/src/projectile/removableDust.c index c3138d16..40ef0640 100644 --- a/src/projectile/removableDust.c +++ b/src/projectile/removableDust.c @@ -51,7 +51,7 @@ void RemovableDust_OnTick(RemovableDustEntity* this) { } void RemovableDust_OnCollision(RemovableDustEntity* this) { - if (super->contactFlags == 0x96) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x16)) { RemovableDust_OnGrabbed(this); } } diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c index 70957e97..e8ebe565 100644 --- a/src/projectile/rockProjectile.c +++ b/src/projectile/rockProjectile.c @@ -22,7 +22,7 @@ void RockProjectile_OnTick(Entity* this) { } void RockProjectile_OnCollision(Entity* this) { - if (this->contactFlags == 0x80) { + if (this->contactFlags == CONTACT_TAKE_DAMAGE) { DeleteEntity(this); } else { this->direction = this->knockbackDirection; diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c index dca0bc9a..b2e97623 100644 --- a/src/projectile/spiderWeb.c +++ b/src/projectile/spiderWeb.c @@ -64,7 +64,7 @@ void SpiderWeb_OnCollision(SpiderWebEntity* this) { }; Entity* object; - if (super->contactFlags == 0x87) { + if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { super->action = 3; super->timer = 90; COLLISION_OFF(super); diff --git a/src/projectile/stalfosProjectile.c b/src/projectile/stalfosProjectile.c index ff776f2e..660b8f5c 100644 --- a/src/projectile/stalfosProjectile.c +++ b/src/projectile/stalfosProjectile.c @@ -35,7 +35,7 @@ void StalfosProjectile_OnTick(Entity* this) { } void StalfosProjectile_OnCollision(Entity* this) { - if (this->contactFlags == 0x9d) { + if (this->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { this->action = 3; COLLISION_OFF(this); this->zVelocity = Q_16_16(2.625); diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index 248612e4..eb5f73cc 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -43,7 +43,7 @@ void V1DarkMagicProjectile_OnTick(V1DarkMagicProjectileEntity* this) { } void V1DarkMagicProjectile_OnCollision(V1DarkMagicProjectileEntity* this) { - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { if (super->type2 == 0) { if ((super->contactFlags & 0x3f) == 0) { super->action = 2; diff --git a/src/projectile/v1FireProjectile.c b/src/projectile/v1FireProjectile.c index a0f89b5b..661547ba 100644 --- a/src/projectile/v1FireProjectile.c +++ b/src/projectile/v1FireProjectile.c @@ -31,7 +31,7 @@ void V1FireProjectile_OnTick(V1FireProjectileEntity* this) { } void V1FireProjectile_OnCollision(V1FireProjectileEntity* this) { - if ((super->contactFlags & 0x80) != 0) { + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { super->action = 3; COLLISION_OFF(super); InitializeAnimation(super, 0x53); diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index e602c6f4..8f7531c4 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -43,7 +43,7 @@ void V2Projectile_OnTick(V2ProjectileEntity* this) { } void V2Projectile_OnCollision(V2ProjectileEntity* this) { - if ((super->contactFlags & 0x80) == 0) + if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) return; switch (super->type) { From b199773a123742a0cf58d94174464534940e83d2 Mon Sep 17 00:00:00 2001 From: Elmyr de Hory <85423474+Elmyr-de-Hory@users.noreply.github.com> Date: Sun, 31 Dec 2023 00:55:02 -0800 Subject: [PATCH 05/10] True match sub_0806252C Co-authored-by: KEKW555 <152369890+KEKW555@users.noreply.github.com> --- src/npc/kid.c | 121 +++++++++++++++----------------------------------- 1 file changed, 37 insertions(+), 84 deletions(-) diff --git a/src/npc/kid.c b/src/npc/kid.c index aa4bcbea..9f65aad8 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -199,13 +199,13 @@ const FrameStruct gUnk_0810C0A0[] = { void sub_080621AC(KidEntity* this); void sub_080622F4(KidEntity* this); -void sub_0806265C(Entity* this, ScriptExecutionContext* context); -void sub_0806252C(Entity* this); +void sub_0806265C(KidEntity* this, ScriptExecutionContext* context); +void sub_0806252C(KidEntity* this); typedef union { struct { - s16 x; - s16 y; + u16 x; + u16 y; s16 z; u8 framestate; u8 animationState : 6; @@ -306,7 +306,7 @@ void sub_080621AC(KidEntity* this) { return; } } - sub_0806265C(super, this->context); + sub_0806265C(this, this->context); tmp = super->animIndex; } this->unk_6b = super->animIndex; @@ -375,7 +375,7 @@ void sub_080622F4(KidEntity* this) { return; } - sub_0806252C(super); + sub_0806252C(this); } animIndex = 0; @@ -440,88 +440,41 @@ void sub_08062500(KidEntity* this) { this->unk_68 = 1; RemoveInteractableObject(super); super->hitbox = NULL; - sub_0806252C(super); + sub_0806252C(this); } } -void sub_0806252C(Entity* this) { - s16 sVar1; - s16 sVar2; - u16 uVar3; - u8 uVar4; - s16 sVar5; - s16 sVar6; - u8 bVar7; - KidHeapItem* item; - s32 loopVar; - FORCE_REGISTER(u32 r5, r5); - FORCE_REGISTER(u32 r6, r6); - FORCE_REGISTER(u32 r0, r0); - FORCE_REGISTER(u32 r1, r1); - FORCE_REGISTER(u32 r2, r2); - u32 r3; - FORCE_REGISTER(s32 r8, r8); - s32 y; - s32 r10; - FORCE_REGISTER(s32 x, r12); +void sub_0806252C(KidEntity* this) { + s32 dx, dy; + s32 i; - r1 = gPlayerEntity.base.x.HALF_U.HI; - r3 = 0xffff0000; - r0 = r3; - r0 &= r5; - r0 |= r1; + KidHeapItem *heapPtr, item; - r1 = gPlayerEntity.base.y.HALF_U.HI; - r1 <<= 0x10; - r2 = 0x0000ffff; - r0 &= r2; - r0 |= r1; - r5 = r0; + // Copy from the player's position/state. + item.FIELDS.x = gPlayerEntity.base.x.HALF_U.HI; + item.FIELDS.y = gPlayerEntity.base.y.HALF_U.HI; + item.FIELDS.z = gPlayerEntity.base.z.HALF_U.HI; + item.FIELDS.framestate = gPlayerState.framestate; + item.FIELDS.animationState = gPlayerEntity.base.animationState; + item.FIELDS.collisionLayer = gPlayerEntity.base.collisionLayer; - r0 = gPlayerEntity.base.z.HALF_U.HI; - r3 &= r6; - r3 |= r0; + // Compute the distance between the kid and the player. + dx = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI; + dy = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI; - r0 = gPlayerState.framestate; - r0 <<= 0x10; - r2 = 0xff00ffff; - r2 &= r3; - r2 |= r0; + // Divide it into KID_HEAP_COUNT increments. + dx = FixedDiv(dx, KID_HEAP_COUNT); + dy = FixedDiv(dy, KID_HEAP_COUNT); - r1 = gPlayerEntity.base.animationState; - r0 = 0x3f; - r1 &= r0; - r1 <<= 0x18; - r0 = 0xc0ffffff; - r0 &= r2; - r0 |= r1; - - r1 = gPlayerEntity.base.collisionLayer; - r1 <<= 0x1e; - r2 = 0x3fffffff; - r0 &= r2; - r0 |= r1; - r6 = r0; - - r10 = r0 = gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI; - r8 = r0 = gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI; - - r10 = FixedDiv(r10, KID_HEAP_COUNT); - r8 = FixedDiv(r8, KID_HEAP_COUNT); - item = (KidHeapItem*)this->myHeap; - y = 0; - x = 0; - - for (loopVar = KID_HEAP_COUNT - 1; loopVar >= 0; loopVar--) { - item->FIELDS.x = r5 - (x >> 8); - item->FIELDS.y = (r5 >> 0x10) - (y >> 8); - item->FIELDS.z = r6; - item->FIELDS.framestate = r6 >> 0x10; - item->FIELDS.animationState = this->animationState & 0x3f; - item->FIELDS.collisionLayer = this->collisionLayer; - item++; - y = y + r8; - x = x + r10; + heapPtr = KID_HEAP; + for (i = 0; i < KID_HEAP_COUNT; i++) { + heapPtr->FIELDS.x = item.FIELDS.x - ((i * dx) >> 8); + heapPtr->FIELDS.y = item.FIELDS.y - ((i * dy) >> 8); + heapPtr->FIELDS.z = item.FIELDS.z; + heapPtr->FIELDS.framestate = item.FIELDS.framestate; + heapPtr->FIELDS.animationState = super->animationState; + heapPtr->FIELDS.collisionLayer = super->collisionLayer; + heapPtr++; } } @@ -531,13 +484,13 @@ void sub_08062634(Entity* this) { MessageNoOverlap(gUnk_0810BDE8[a][b], this); } -void sub_0806265C(Entity* this, ScriptExecutionContext* context) { +void sub_0806265C(KidEntity* this, ScriptExecutionContext* context) { if (gSave.global_progress == 0) { - MessageNoOverlap(0, this); + MessageNoOverlap(0, super); } else { - const Dialog* pDialog = &gUnk_0810BE10[this->type * 9 - 1]; + const Dialog* pDialog = &gUnk_0810BE10[super->type * 9 - 1]; pDialog += gSave.global_progress; - ShowNPCDialogue(this, pDialog); + ShowNPCDialogue(super, pDialog); } } From 72c27b5393372081f558a4c610bab7d5c88d3e89 Mon Sep 17 00:00:00 2001 From: KEKW555 <152369890+KEKW555@users.noreply.github.com> Date: Mon, 1 Jan 2024 04:43:39 +0530 Subject: [PATCH 06/10] True match sub_08068578 (#683) --- src/npc/zeldaFollower.c | 157 +++++++++------------------------------- 1 file changed, 34 insertions(+), 123 deletions(-) diff --git a/src/npc/zeldaFollower.c b/src/npc/zeldaFollower.c index 1fe5f067..3e372423 100644 --- a/src/npc/zeldaFollower.c +++ b/src/npc/zeldaFollower.c @@ -15,7 +15,7 @@ typedef union { struct { u16 x; u16 y; - u16 z; + s16 z; u8 framestate; u8 animationState : 6; u8 collisionLayer : 2; @@ -41,7 +41,7 @@ typedef union { void sub_08068318(ZeldaFollowerEntity*); void sub_0806854C(ZeldaFollowerEntity*, u32*); -void sub_08068578(Entity* this); +void sub_08068578(ZeldaFollowerEntity* this); void ZeldaFollower(ZeldaFollowerEntity* this) { if (super->action == 0) { @@ -63,7 +63,6 @@ void ZeldaFollower(ZeldaFollowerEntity* this) { void sub_08068318(ZeldaFollowerEntity* this) { s32 dist; - s16 z; u32 animIndex; u32 animIndexTmp; @@ -85,7 +84,7 @@ void sub_08068318(ZeldaFollowerEntity* this) { super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI; super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI; super->spriteSettings.draw = 1; - sub_08068578(super); + sub_08068578(this); } animIndex = 0; @@ -100,9 +99,8 @@ void sub_08068318(ZeldaFollowerEntity* this) { } } else { heapPtr += ZELDA_FOLLOWER_HEAP_LEN - 1; - z = heapPtr->FIELDS.z; - if (z < 0) { + if (heapPtr->FIELDS.z < 0) { ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(super, heapPtr); animIndex = 0x4; } else { @@ -154,128 +152,41 @@ void sub_0806854C(ZeldaFollowerEntity* this, u32* none) { this->unk_68 = 1; RemoveInteractableObject(super); super->hitbox = NULL; - sub_08068578(super); + sub_08068578(this); } } -void sub_08068578(Entity* this) { - ZeldaFollowerItem* item; - s32 index; -#ifdef REWRITE_CODE - u32 r0; - u32 r1; - u32 r2; - u32 r3; - u32 r5; - u32 r6; - u32 r8; - s32 y; - u32 r10; - s32 x; -#else - register u32 r5 asm("r5"); - register u32 r6 asm("r6"); - register u32 r0 asm("r0"); - register u32 r1 asm("r1"); - register u32 r2 asm("r2"); - register u32 r3 asm("r3"); - register s32 r8 asm("r8"); - register s32 y asm("r9"); - register s32 r10 asm("r10"); - register s32 x asm("r12"); -#endif +void sub_08068578(ZeldaFollowerEntity* this) { + s32 dx, dy; + s32 i; - // first u32 (r5) -#ifdef REWRITE_CODE - r0 = gPlayerEntity.base.x.HALF_U.HI | (r5 & 0xffff0000); - r5 = (gPlayerEntity.base.y.HALF_U.HI << 0x10) | (r0 & 0x0000ffff); -#else - r1 = gPlayerEntity.base.x.HALF_U.HI; + ZeldaFollowerItem *heapPtr, item; - r3 = 0xffff0000; - r0 = r3; - r0 &= r5; - r0 |= r1; + // Copy from the player's position/state. + item.FIELDS.x = gPlayerEntity.base.x.HALF_U.HI; + item.FIELDS.y = gPlayerEntity.base.y.HALF_U.HI; + item.FIELDS.z = gPlayerEntity.base.z.HALF_U.HI; + item.FIELDS.framestate = gPlayerState.framestate; + item.FIELDS.animationState = gPlayerEntity.base.animationState; + item.FIELDS.collisionLayer = gPlayerEntity.base.collisionLayer; - r1 = gPlayerEntity.base.y.HALF_U.HI; - r1 <<= 0x10; - r2 = 0xffff; - r0 &= r2; - r0 |= r1; - r5 = r0; -#endif + // Compute the distance between zelda and the player. + dx = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI; + dy = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI; - // second u32 (r6) -#ifdef REWRITE_CODE - r3 = gPlayerEntity.base.z.HALF_U.HI | (r6 & 0xffff0000); - r2 = (gPlayerState.framestate << 0x10) | (r3 & 0xff00ffff); - r0 = ((gPlayerEntity.base.animationState & 0x3f) << 0x18) | (r2 & 0xc0ffffff); - r6 = (gPlayerEntity.base.collisionLayer << 0x1e) | (r0 & 0x3fffffff); -#else - r0 = gPlayerEntity.base.z.HALF_U.HI; - r3 &= r6; - r3 |= r0; + // Divide it into ZELDA_FOLLOWER_HEAP_LEN increments. + dx = FixedDiv(dx, ZELDA_FOLLOWER_HEAP_LEN); + dy = FixedDiv(dy, ZELDA_FOLLOWER_HEAP_LEN); - r0 = gPlayerState.framestate; - r0 <<= 0x10; - r2 = 0xff00ffff; - r2 &= r3; - r2 |= r0; - - r1 = gPlayerEntity.base.animationState; - r0 = 0x3f; - r1 &= r0; - r1 <<= 0x18; - r0 = 0xc0ffffff; - r0 &= r2; - r0 |= r1; - - // gPlayerEntity.base.is now at r1 - r1 = gPlayerEntity.base.collisionLayer; - r1 <<= 0x1e; - r2 = 0x3fffffff; - r0 &= r2; - r0 |= r1; - r6 = r0; -#endif - -#ifdef REWRITE_CODE - r10 = gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI; -#else - r1 = gPlayerEntity.base.x.HALF.HI; - r0 = this->x.HALF.HI; - r0 = r1 - r0; - r10 = r0; -#endif - -#ifdef REWRITE_CODE - r8 = gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI; -#else - r1 = gPlayerEntity.base.y.HALF.HI; - r0 = this->y.HALF.HI; - r0 = r1 - r0; - r8 = r0; -#endif - - r10 = FixedDiv(r10, 0x14); - r8 = FixedDiv(r8, 0x14); - - item = this->myHeap; - y = 0; - x = 0; - - // Down here the u32 are suddendly accessed correctly as u16 and bitfields? - // How are the results of above u32 calculations used? - for (index = 0x13; index >= 0; index--) { - item->FIELDS.x = r5 - (x >> 8); - item->FIELDS.y = (r5 >> 0x10) - (y >> 8); - item->FIELDS.z = r6; - item->FIELDS.framestate = r6 >> 0x10; - item->FIELDS.animationState = this->animationState & 0x3f; - item->FIELDS.collisionLayer = this->collisionLayer; - item++; - y = y + r8; - x = x + r10; + heapPtr = ZELDA_FOLLOWER_HEAP; + for (i = 0; i < ZELDA_FOLLOWER_HEAP_LEN; i++) { + heapPtr->FIELDS.x = item.FIELDS.x - ((i * dx) >> 8); + heapPtr->FIELDS.y = item.FIELDS.y - ((i * dy) >> 8); + heapPtr->FIELDS.z = item.FIELDS.z; + heapPtr->FIELDS.framestate = item.FIELDS.framestate; + heapPtr->FIELDS.animationState = super->animationState; + heapPtr->FIELDS.collisionLayer = super->collisionLayer; + heapPtr++; } } @@ -288,11 +199,11 @@ void ZeldaFollower_Show(Entity* zelda, ZeldaFollowerEntity* follower) { follower->unk_68 = 1; follower->base.spriteSettings.draw = 1; follower->base.animationState = zelda->animationState; - sub_08068578(&follower->base); + sub_08068578(follower); InitAnimationForceUpdate(&follower->base, follower->base.animationState / 2); } -void sub_080686C4(Entity* zelda, Entity* follower) { - follower->y.HALF.HI -= 0x10; +void sub_080686C4(Entity* zelda, ZeldaFollowerEntity* follower) { + follower->base.y.HALF.HI -= 0x10; sub_08068578(follower); } From 37ac9cb0fb2d9ccb64286bab2cdf648e6f2541c5 Mon Sep 17 00:00:00 2001 From: theo3 Date: Sun, 31 Dec 2023 17:29:08 -0800 Subject: [PATCH 07/10] document tile asm functions --- asm/src/code_08001A7C.s | 22 +-- asm/src/code_08003FC4.s | 40 ++--- asm/src/code_080043E8.s | 65 ++++--- asm/src/code_08007CAC.s | 14 +- asm/src/enemy.s | 14 +- asm/src/intr.s | 4 +- asm/src/player.s | 164 +++++++++--------- asm/src/script.s | 102 ++++++----- asm/src/veneer.s | 22 +-- include/asm.h | 8 +- include/enemy.h | 1 - include/functions.h | 14 +- include/map.h | 16 +- include/player.h | 2 +- include/tiles.h | 17 ++ linker.ld | 2 +- src/beanstalkSubtask.c | 46 ++--- src/code_08049DF4.c | 2 +- src/enemy/armos.c | 8 +- src/enemy/businessScrub.c | 4 +- src/enemy/chuchu.c | 24 +-- src/enemy/chuchuBoss.c | 2 +- src/enemy/doorMimic.c | 4 +- src/enemy/enemy64.c | 16 +- src/enemy/eyegore.c | 20 +-- src/enemy/flyingPot.c | 12 +- src/enemy/flyingSkull.c | 16 +- src/enemy/gyorgFemale.c | 2 +- src/enemy/helmasaur.c | 4 +- src/enemy/mazaalBracelet.c | 3 +- src/enemy/mazaalMacro.c | 2 +- src/enemy/octorokGolden.c | 2 +- src/enemy/pesto.c | 3 +- src/enemy/rollobite.c | 2 +- src/enemy/rupeeLike.c | 2 +- src/enemy/spinyBeetle.c | 4 +- src/enemy/stalfos.c | 2 +- src/enemy/vaatiProjectile.c | 2 +- src/enemy/wizzrobeFire.c | 4 +- src/enemy/wizzrobeIce.c | 4 +- src/enemy/wizzrobeWind.c | 6 +- src/interrupts.c | 4 +- src/item/itemMoleMitts.c | 4 +- src/item/itemTryPickupObject.c | 4 +- src/manager/diggingCaveEntranceManager.c | 6 +- src/manager/flameManager.c | 4 +- src/manager/manager29.c | 2 +- src/manager/tileChangeObserveManager.c | 2 +- src/manager/waterfallBottomManager.c | 2 +- src/movement.c | 2 +- src/npc/castorWildsStatue.c | 16 +- src/npc/clothesRack.c | 12 +- src/npc/dog.c | 2 +- src/npc/kid.c | 12 +- src/npc/npc5.c | 6 +- src/object/angryStatue.c | 2 +- src/object/bakerOven.c | 16 +- src/object/beanstalk.c | 10 +- src/object/bigIceBlock.c | 50 +++--- src/object/bigPushableLever.c | 14 +- src/object/board.c | 2 +- src/object/bollard.c | 4 +- src/object/bossDoor.c | 24 +-- src/object/bush.c | 2 +- src/object/button.c | 8 +- src/object/cabinFurniture.c | 40 ++--- src/object/carlovObject.c | 6 +- src/object/crenelBeanSprout.c | 8 +- src/object/doubleBookshelf.c | 40 ++--- src/object/figurineDevice.c | 6 +- src/object/fireplace.c | 4 +- src/object/frozenWaterElement.c | 54 +++--- src/object/furniture.c | 56 +++--- src/object/gentariCurtain.c | 8 +- src/object/giantBookLadder.c | 24 +-- src/object/giantLeaf.c | 2 +- src/object/giantRock2.c | 8 +- src/object/giantTwig.c | 92 +++++----- src/object/jarPortal.c | 8 +- src/object/ladderUp.c | 10 +- src/object/lightDoor.c | 18 +- src/object/lightableSwitch.c | 2 +- src/object/lilypadLarge.c | 8 +- src/object/linkEmptyingBottle.c | 4 +- src/object/lockedDoor.c | 6 +- src/object/macroAcorn.c | 56 +++--- src/object/macroBook.c | 2 +- src/object/macroDecorations.c | 2 +- src/object/macroShoe.c | 6 +- src/object/mask.c | 4 +- src/object/metalDoor.c | 12 +- src/object/minecart.c | 10 +- src/object/minecartDoor.c | 4 +- src/object/minishVillageObject.c | 6 +- src/object/object30.c | 2 +- src/object/object37.c | 2 +- src/object/objectBlockingStairs.c | 18 +- src/object/objectOnPillar.c | 6 +- src/object/objectOnSpinyBeetle.c | 2 +- src/object/palaceArchway.c | 2 +- src/object/paper.c | 6 +- src/object/playerClone.c | 4 +- src/object/pot.c | 24 +-- src/object/pullableMushroom.c | 2 +- src/object/pushableFurniture.c | 26 +-- src/object/pushableGrave.c | 10 +- src/object/pushableLever.c | 8 +- src/object/pushableRock.c | 6 +- src/object/pushableStatue.c | 10 +- src/object/railtrack.c | 14 +- src/object/smallIceBlock.c | 8 +- src/object/smokeParticle.c | 6 +- src/object/treeThorns.c | 4 +- src/object/unusedSkull.c | 2 +- src/object/well.c | 2 +- src/physics.c | 6 +- src/player.c | 20 +-- src/playerItem/playerItemBomb.c | 2 +- src/playerItem/playerItemBoomerang.c | 4 +- src/playerItem/playerItemBottle.c | 2 +- src/playerItem/playerItemBow.c | 4 +- src/playerItem/playerItemDashSword.c | 4 +- src/playerItem/playerItemFireRodProjectile.c | 2 +- src/playerItem/playerItemGust.c | 4 +- src/playerItem/playerItemGustBig.c | 8 +- src/playerItem/playerItemHeldObject.c | 4 +- .../playerItemPacciCaneProjectile.c | 8 +- src/playerItem/playerItemSword.c | 8 +- src/playerItem/playerItemSwordBeam.c | 2 +- src/playerUtils.c | 98 +++++------ src/projectile/boneProjectile.c | 2 +- src/projectile/cannonballProjectile.c | 8 +- src/projectile/dekuSeedProjectile.c | 6 +- src/projectile/dirtBallProjectile.c | 2 +- src/projectile/fireProjectile.c | 2 +- src/projectile/gleerokProjectile.c | 5 +- src/projectile/iceProjectile.c | 2 +- src/projectile/mandiblesProjectile.c | 2 +- src/projectile/removableDust.c | 2 +- src/projectile/rockProjectile.c | 4 +- src/projectile/spiderWeb.c | 2 +- src/projectile/windProjectile.c | 2 +- src/projectile/winder.c | 2 +- src/roomInit.c | 54 +++--- src/scroll.c | 14 +- src/text.c | 34 ++-- src/worldEvent/worldEvent17.c | 2 +- 147 files changed, 973 insertions(+), 931 deletions(-) diff --git a/asm/src/code_08001A7C.s b/asm/src/code_08001A7C.s index dfaa3ad4..4568bf6c 100644 --- a/asm/src/code_08001A7C.s +++ b/asm/src/code_08001A7C.s @@ -931,8 +931,8 @@ _0800271A: bne _0800270A pop {r4, r5, r6, pc} - thumb_func_start sub_08002724 -sub_08002724: @ 0x08002724 + thumb_func_start UnpackTextNibbles +UnpackTextNibbles: @ 0x08002724 push {r4, r5, lr} movs r2, #0x10 movs r3, #0xf @@ -1019,24 +1019,25 @@ _080027E6: movs r0, #4 bx lr + // almost identical to LinearMoveDirection // r0 = Entity* // r1 = speed // r2 = direction - non_word_aligned_thumb_func_start sub_080027EA -sub_080027EA: @ 0x080027EA + non_word_aligned_thumb_func_start LinearMoveDirectionOLD +LinearMoveDirectionOLD: @ 0x080027EA push {r4, r5, r6, r7, lr} movs r3, #0x80 tst r2, r3 bne _08002860 movs r4, #0x2a - ldrh r3, [r0, r4] + ldrh r3, [r0, r4] // collisions movs r4, #7 tst r2, r4 bne _08002812 push {r0, r1, r2, r3} adds r0, r2, #0 adds r1, r3, #0 - bl sub_08002864 + bl CalcCollisionDirectionOLD adds r4, r0, #0 pop {r0, r1, r2, r3} cmp r2, r4 @@ -1063,7 +1064,7 @@ _08002812: _08002834: adds r4, r0, #0 pop {r0, r1, r2, r3} - ldr r5, [r0, #0x2c] + ldr r5, [r0, #0x2c] // x adds r5, r5, r4 str r5, [r0, #0x2c] _0800283E: @@ -1081,15 +1082,16 @@ _0800283E: _08002856: adds r4, r0, #0 pop {r0, r1, r2, r3} - ldr r5, [r0, #0x30] + ldr r5, [r0, #0x30] // y subs r5, r5, r4 str r5, [r0, #0x30] _08002860: adds r1, r6, #0 pop {r4, r5, r6, r7, pc} - thumb_func_start sub_08002864 -sub_08002864: @ 0x08002864 + // collision related, probably leftover from FS + thumb_func_start CalcCollisionDirectionOLD +CalcCollisionDirectionOLD: @ 0x08002864 adds r2, r0, #0 lsrs r2, r2, #3 cmp r2, #0 diff --git a/asm/src/code_08003FC4.s b/asm/src/code_08003FC4.s index 362f7d8d..ff872eb4 100644 --- a/asm/src/code_08003FC4.s +++ b/asm/src/code_08003FC4.s @@ -621,26 +621,26 @@ _0800439C: .4byte gSpritePtrs _080043A0: .4byte gSpritePtrs _080043A4: .4byte gGFXSlots+4 - thumb_func_start sub_080043A8 -sub_080043A8: @ 0x080043A8 - movs r1, #0xb - b _080043B6 + thumb_func_start CreateDrownFX +CreateDrownFX: @ 0x080043A8 + movs r1, #0xb // FX_WATER_SPLASH + b create_fx - thumb_func_start CreateChestSpawner -CreateChestSpawner: @ 0x080043AC - movs r1, #0xc - b _080043B6 + thumb_func_start CreateLavaDrownFX +CreateLavaDrownFX: @ 0x080043AC + movs r1, #0xc // FX_LAVA_SPLASH + b create_fx - thumb_func_start sub_080043B0 -sub_080043B0: @ 0x080043AC - movs r1, #0x52 - b _080043B6 + thumb_func_start CreateSwampDrownFX +CreateSwampDrownFX: @ 0x080043AC + movs r1, #0x52 // FX_GREEN_SPLASH + b create_fx - thumb_func_start CreateItemOnGround -CreateItemOnGround: @ 0x080043B4 - movs r1, #0 + thumb_func_start CreatePitFallFX +CreatePitFallFX: @ 0x080043B4 + movs r1, #0 // FX_FALL_DOWN -_080043B6: +create_fx: push {r4, lr} adds r4, r0, #0 movs r0, #0xf @@ -648,10 +648,10 @@ _080043B6: bl CreateObject cmp r0, #0 - beq _080043E0 @ Branch if entity could not be created + beq _080043E0 movs r1, #0x48 - ldr r1, [r4, r1] @ Unused? + ldr r1, [r4, r1] // load hitbox (unused) ldrh r3, [r4, #0x2e] strh r3, [r0, #0x2e] @@ -664,11 +664,11 @@ _080043B6: ldrb r3, [r4, #8] - cmp r3, #3 @ Is the spawner an enemy? + cmp r3, #3 // is parent entity an enemy? bne _080043E0 movs r1, #1 - strb r1, [r0, #0xb] @ Set base parameter + strb r1, [r0, #0xb] // copy entity.type2 _080043E0: adds r0, r4, #0 diff --git a/asm/src/code_080043E8.s b/asm/src/code_080043E8.s index 98048228..3d723136 100644 --- a/asm/src/code_080043E8.s +++ b/asm/src/code_080043E8.s @@ -5,57 +5,67 @@ .text - thumb_func_start sub_080043E8 -sub_080043E8: @ 0x080043E8 + .macro hazard_tile tile:req, hazard_type:req + .short \tile + .short \hazard_type + .endm + + thumb_func_start GetTileHazardType +GetTileHazardType: @ 0x080043E8 push {r4, lr} ldrb r1, [r0, #0xc] cmp r1, #0 - beq _08004414 + beq no_hazard // action == 0 adds r4, r0, #0 - bl sub_08016AD2 + bl UpdateCollisionLayer movs r3, #0x36 ldrsh r2, [r4, r3] cmp r2, #0 - bmi _08004414 - cmp r0, #0 - beq _08004414 - add r3, pc, #0x10 -_08004404: + bmi no_hazard // collisionLayer is negative + cmp r0, #0 // are we on a tile? + beq no_hazard + adr r3, hazard_list-4 +loop: adds r3, #4 ldrh r1, [r3] cmp r1, #0 - beq _08004414 + beq no_hazard cmp r0, r1 - bne _08004404 + bne loop ldrh r0, [r3, #2] pop {r4, pc} -_08004414: +no_hazard: movs r0, #0 pop {r4, pc} -_08004418: - .byte 0x0D, 0x00, 0x01, 0x00, 0x10, 0x00, 0x02, 0x00 - .byte 0x11, 0x00, 0x02, 0x00, 0x5A, 0x00, 0x03, 0x00, 0x13, 0x00, 0x04, 0x00, 0x00, 0x00 + +hazard_list: + hazard_tile 0xD, 0x1 + hazard_tile 0x10, 0x2 + hazard_tile 0x11, 0x2 + hazard_tile 0x5A, 0x3 + hazard_tile 0x13, 0x4 + .short 0x0000 non_word_aligned_thumb_func_start sub_0800442E sub_0800442E: @ 0x0800442E push {r0, lr} - bl sub_080043E8 + bl GetTileHazardType cmp r0, #0 - beq _08004448 - lsls r0, r0, #2 - add r1, pc, #0xC + beq not_hazard + lsls r0, #2 + adr r1, _0800444C - 4 ldr r1, [r1, r0] pop {r0} bl _call_via_r1 movs r0, #1 pop {pc} -_08004448: +not_hazard: movs r0, #0 pop {r1, pc} -_0800444C: .4byte CreateItemOnGround -_08004450: .4byte sub_080043A8 -_08004454: .4byte CreateChestSpawner -_08004458: .4byte sub_080043B0 +_0800444C: .4byte CreatePitFallFX +_08004450: .4byte CreateDrownFX +_08004454: .4byte CreateLavaDrownFX +_08004458: .4byte CreateSwampDrownFX thumb_func_start sub_0800445C sub_0800445C: @ 0x0800445C @@ -171,6 +181,7 @@ _08004516: adds r0, r2, #0 bx lr + // r0 = Entity* thumb_func_start sub_0800451C sub_0800451C: @ 0x0800451C push {r0, lr} @@ -196,17 +207,17 @@ sub_0800451C: @ 0x0800451C sub_08004542: @ 0x08004542 movs r1, #0x38 movs r2, #2 - strb r2, [r0, r1] + strb r2, [r0, r1] // entity->collisionLayer = 2 movs r2, #0xc0 ldrb r1, [r0, #0x1b] bics r1, r2 adds r1, #0x40 - strb r1, [r0, #0x1b] + strb r1, [r0, #0x1b] // update spriteOrientation movs r2, #0xc0 ldrb r1, [r0, #0x19] bics r1, r2 adds r1, #0x40 - strb r1, [r0, #0x19] + strb r1, [r0, #0x19] // update spriteRendering bx lr non_word_aligned_thumb_func_start ResetCollisionLayer diff --git a/asm/src/code_08007CAC.s b/asm/src/code_08007CAC.s index c457c0a2..146e4ac7 100644 --- a/asm/src/code_08007CAC.s +++ b/asm/src/code_08007CAC.s @@ -29,22 +29,22 @@ gUnk_08007CAC:: @ 08007CAC .endif .endif - non_word_aligned_thumb_func_start sub_08007DD6 -sub_08007DD6: @ 0x08007DD6 + non_word_aligned_thumb_func_start ActTileToTile +ActTileToTile: @ 0x08007DD6 push {lr} - bl sub_08007DE0 + bl ActTileConv adds r0, r3, #0 pop {pc} - thumb_func_start sub_08007DE0 -sub_08007DE0: @ 0x08007DE0 + thumb_func_start ActTileConv +ActTileConv: @ 0x08007DE0 subs r1, #4 _08007DE2: adds r1, #4 ldrh r3, [r1] - cmp r3, #0 + cmp r3, #0 // reached end beq _08007DF2 - cmp r0, r3 + cmp r0, r3 // equal bne _08007DE2 ldrh r3, [r1, #2] movs r2, #1 diff --git a/asm/src/enemy.s b/asm/src/enemy.s index 52aacf91..d2dcd5ff 100644 --- a/asm/src/enemy.s +++ b/asm/src/enemy.s @@ -71,7 +71,7 @@ _08001230: ldr r3, _0800135C @ =UpdateAnimationVariableFrames bx r3 _0800123E: - ldr r3, _08001360 @ =CreateItemOnGround + ldr r3, _08001360 @ =CreatePitFallFX bx r3 non_word_aligned_thumb_func_start GenericConfused @@ -155,19 +155,19 @@ _080012BA: gUnk_080012C8:: .4byte 0x00000000 _080012CC: .4byte sub_08001214 -_080012D0: .4byte sub_080043A8 -_080012D4: .4byte CreateChestSpawner -_080012D8: .4byte sub_080043B0 +_080012D0: .4byte CreateDrownFX +_080012D4: .4byte CreateLavaDrownFX +_080012D8: .4byte CreateSwampDrownFX thumb_func_start sub_080012DC sub_080012DC: @ 0x080012DC push {r4, r5, lr} adds r4, r0, #0 movs r5, #0x3a - ldrb r1, [r4, r5] + ldrb r1, [r4, r5] // gust jar state lsrs r1, r1, #3 bhs _08001302 - bl sub_080043E8 + bl GetTileHazardType cmp r0, #4 beq _08001302 cmp r0, #0 @@ -241,7 +241,7 @@ _08001352: .align 2, 0 _08001358: .4byte gEnemyFunctions _0800135C: .4byte UpdateAnimationVariableFrames -_08001360: .4byte CreateItemOnGround +_08001360: .4byte CreatePitFallFX _08001364: .4byte 0x00001800 _08001368: .4byte gUnk_080012C8 _0800136C: .4byte gUnk_080012C8 diff --git a/asm/src/intr.s b/asm/src/intr.s index 4f65fa09..c2dab21d 100644 --- a/asm/src/intr.s +++ b/asm/src/intr.s @@ -120,8 +120,8 @@ _080B1A64: ldrh r0, [r1, r0] bx lr - arm_func_start arm_GetRelativeCollisionTile -arm_GetRelativeCollisionTile: @ 0x080B1A8C + arm_func_start arm_GetActTileRelative +arm_GetActTileRelative: @ 0x080B1A8C ldrh r3, [r0, #0x2e] add r3, r3, r1 ldrh r1, [r0, #0x32] diff --git a/asm/src/player.s b/asm/src/player.s index 05f6ed35..fefcf695 100644 --- a/asm/src/player.s +++ b/asm/src/player.s @@ -26,7 +26,7 @@ sub_0800857C: @ 0x0800857C _0800859C: ldrh r1, [r0, #0x24] ldrb r2, [r0, #0x15] - bl sub_080027EA + bl LinearMoveDirectionOLD pop {r4 - r7} mov r8, r4 @@ -57,11 +57,11 @@ sub_080085CC: @ 0x080085CC ldr r2, _0800888C @ =gPlayerState ldr r1, _08008890 @ =gUnk_080083FC movs r3, #0x26 - ldrb r3, [r2, r3] + ldrb r3, [r2, r3] // swim_state orrs r3, r3 beq _080085E6 ldr r2, [r2, #0x30] - movs r3, #0x80 + movs r3, #0x80 // flags & PL_MINISH ands r2, r3 beq _0800861A ldr r1, _08008894 @ =gUnk_0800839C @@ -70,12 +70,12 @@ _080085E6: ldr r1, _08008898 @ =gUnk_0800845C ldrb r3, [r2, #2] orrs r3, r3 - bne _0800861A - ldr r2, [r2, #0x30] + bne _0800861A // jump_status != 0 + ldr r2, [r2, #0x30] // flags & PL_PARACHUTE ldr r3, _0800889C @ =0x01000000 tst r2, r3 bne _0800861A - movs r3, #0x80 + movs r3, #0x80 // // flags & PL_MINISH ldr r1, _080088A0 @ =gUnk_0800833C ands r2, r3 bne _0800861A @@ -83,15 +83,15 @@ _080085E6: ldr r3, _080088A8 @ =gPlayerState ldrb r2, [r3, #0x1c] orrs r2, r2 - bne _0800861A + bne _0800861A // field_0x1c != 0 ldrb r2, [r3, #5] orrs r2, r2 - bne _0800861A + bne _0800861A // heldObject != 0 ldr r1, _080088AC @ =gUnk_0800851C movs r2, #0xaa ldrb r2, [r3, r2] orrs r2, r2 - bne _0800861A + bne _0800861A // attachedBeetleCount != 0 ldr r1, _080088B0 @ =gUnk_080082DC _0800861A: mov r11, r1 @@ -169,7 +169,7 @@ _08008684: _080086AC: mov r0, r8 movs r2, #0x2a - strh r7, [r0, r2] + strh r7, [r0, r2] // collisions pop {pc} thumb_func_start sub_080086B4 @@ -265,17 +265,17 @@ _08008754: ands r2, r3 pop {pc} - non_word_aligned_thumb_func_start sub_0800875A -sub_0800875A: @ 0x0800875A + non_word_aligned_thumb_func_start DoItemTileInteraction +DoItemTileInteraction: @ 0x0800875A push {r2, r4, lr} - ldrb r3, [r0, #0x14] + ldrb r3, [r0, #0x14] // item.animationState movs r2, #6 ands r3, r2 ldr r4, _080088D0 @ =gUnk_08007DF4 ldrsb r2, [r4, r3] adds r3, #1 ldrsb r3, [r4, r3] - bl sub_08008782 + bl DoTileInteractionOffset pop {r2, r4} cmp r0, #0 beq _08008780 @@ -288,21 +288,21 @@ sub_0800875A: @ 0x0800875A _08008780: pop {pc} - non_word_aligned_thumb_func_start sub_08008782 -sub_08008782: @ 0x08008782 + non_word_aligned_thumb_func_start DoTileInteractionOffset +DoTileInteractionOffset: @ 0x08008782 push {r4} ldrh r4, [r0, #0x2e] adds r2, r2, r4 ldrh r4, [r0, #0x32] adds r3, r3, r4 pop {r4} - b sub_08008796 + b DoTileInteraction - thumb_func_start sub_08008790 -sub_08008790: @ 0x08008790 + thumb_func_start DoTileInteractionHere +DoTileInteractionHere: @ 0x08008790 ldrh r2, [r0, #0x2e] ldrh r3, [r0, #0x32] - b sub_08008796 + b DoTileInteraction // r0: Entity* // r1: tile filter? @@ -310,8 +310,8 @@ sub_08008790: @ 0x08008790 // r3: y // Somehow involved in trampling tiles, digging with claws, picking up tiles.. - non_word_aligned_thumb_func_start sub_08008796 -sub_08008796: @ 0x08008796 + non_word_aligned_thumb_func_start DoTileInteraction +DoTileInteraction: @ 0x08008796 push {r4, r5, r6, r7, lr} push {r2, r3} ldr r2, _080088D4 @ =gRoomControls @@ -319,17 +319,17 @@ sub_08008796: @ 0x08008796 movs r2, #1 cmp r2, r3 pop {r2, r3} - beq _080087CE + beq _080087CE_return0 push {r0, r1, r2, r3} pop {r4, r5, r6, r7} adds r0, r6, #0 adds r1, r7, #0 movs r2, #0x38 - ldrb r2, [r4, r2] + ldrb r2, [r4, r2] // collision layer bl GetTileTypeByPos ldr r1, _080088D8 @ =gUnk_080046A4 - bl sub_08007DE0 - beq _080087CE + bl ActTileConv + beq _080087CE_return0 lsls r1, r3, #3 adds r3, r5, #0 ldr r0, _080088DC @ =gUnk_080047F6 @@ -338,51 +338,51 @@ sub_08008796: @ 0x08008796 lsrs r0, r3 lsrs r0, r0, #1 bhs _080087D2 -_080087CE: +_080087CE_return0: movs r0, #0 pop {r4, r5, r6, r7, pc} _080087D2: - ldrb r0, [r5, #2] - ldrb r1, [r5, #3] + ldrb r0, [r5, #2] // object id + ldrb r1, [r5, #3] // object type cmp r0, #0xff - beq _0800883A + beq after_create_obj cmp r3, #6 - beq _0800883A + beq after_create_obj cmp r3, #0xe - beq _0800883A + beq after_create_obj cmp r3, #0xa - beq _0800883A + beq after_create_obj cmp r3, #0xb - beq _0800883A + beq after_create_obj cmp r3, #0xd bne _080087F6 - cmp r0, #0xf - bne _0800883A - cmp r1, #0x17 - bne _0800883A + cmp r0, #0xf // SPECIAL_FX + bne after_create_obj + cmp r1, #0x17 // FX_GRASS_CUT + bne after_create_obj _080087F6: movs r2, #0 - cmp r0, #0xf + cmp r0, #0xf // SPECIAL_FX bne _080087FE movs r2, #0x80 _080087FE: - bl CreateObject + bl CreateObject // r0 = id, r1 = type, r2 = type2 cmp r0, #0 - beq _0800883A - ldrb r1, [r5, #2] + beq after_create_obj + ldrb r1, [r5, #2] // object id cmp r1, #0 - beq _08008820 + beq no_offset movs r2, #0xf adds r1, r6, #0 bics r1, r2 adds r1, #8 - strh r1, [r0, #0x2e] + strh r1, [r0, #0x2e] // x adds r1, r7, #0 bics r1, r2 adds r1, #8 - strh r1, [r0, #0x32] + strh r1, [r0, #0x32] // y b _0800882C -_08008820: +no_offset: ldrh r1, [r4, #0x2e] strh r1, [r0, #0x2e] ldrh r1, [r4, #0x32] @@ -391,12 +391,12 @@ _08008820: strh r1, [r1, #0x36] _0800882C: movs r3, #0x50 - str r4, [r1, r3] + str r4, [r1, r3] // set parent to r4 movs r3, #0x38 - ldrb r1, [r4, r3] + ldrb r1, [r4, r3] // copy collision layer from parent strb r1, [r0, r3] bl UpdateSpriteForCollisionLayer -_0800883A: +after_create_obj: ldr r1, _080088E0 @ =gRoomControls ldrh r0, [r1, #6] subs r2, r6, r0 @@ -417,7 +417,7 @@ _0800883A: beq _08008876 push {r0, r1} adds r0, r2, #0 - bl GetLayerByIndex + bl GetTileBuffer adds r3, r0, #4 pop {r0, r1} lsls r1, r1, #1 @@ -461,22 +461,22 @@ _080088DC: .4byte gUnk_080047F6 _080088E0: .4byte gRoomControls _080088E4: .4byte 0x00004000 _080088E8: .4byte 0x0000FFFF -_080088EC: +velocities1: .byte 0, -3, 3, -3 .byte 3, 0, 3, 3 .byte 0, 3, -3, 3 .byte -3, 0, -3, -3 -_080088FC: +ice_velocities: .byte 0, -10, 10, -10 .byte 10, 0, 10, 10 .byte 0, 10, -10, 10 .byte -10, 0, -10, -10 -_0800890C: +velocities3: .byte 0, 6, -6, 0 .byte 0, -6, 6, 0 .byte 19, 18, 18, 16 .byte 16, 17, 17, 19 -_0800891C: +reset_vel: push {r0} bl ResetPlayerVelocity pop {r0} @@ -497,7 +497,7 @@ UpdateIcePlayerVelocity: @ 0x0800892E _UpdateIcePlayerVelocity: push {lr} - ldrb r2, [r0, #0x14] + ldrb r2, [r0, #0x14] // animationState lsrs r2, r2, #1 lsls r2, r2, #3 ldr r1, _08008A68 @ =gPlayerState @@ -522,20 +522,20 @@ _08008956: movs r3, #0x80 tst r2, r3 bne _080089C0 -_08008960: - ldrb r3, [r1, #5] +_08008960: // r1 = gPlayerState + ldrb r3, [r1, #5] // heldObject cmp r3, #2 - beq _0800891C + beq reset_vel cmp r3, #1 - beq _0800891C - ldr r4, _08008A74 @ =_080088FC + beq reset_vel + ldr r4, _08008A74 @ =ice_velocities ldrb r3, [r1, #2] adds r1, r2, #0 - orrs r3, r3 + orrs r3, r3 // jump_status != 0 beq _08008992 push {r2} movs r3, #0x14 - ldrb r1, [r0, r3] + ldrb r1, [r0, r3] // field_0x14 lsrs r1, r1, #1 lsls r1, r1, #1 lsrs r2, r2, #2 @@ -544,7 +544,7 @@ _08008960: adds r2, #2 movs r4, #7 ands r2, r4 - ldr r4, _08008A78 @ =_080088EC + ldr r4, _08008A78 @ =velocities1 cmp r2, #4 beq _08008992 bhs _080089A8 @@ -557,25 +557,25 @@ _08008992: ldrsb r2, [r4, r3] adds r3, #1 ldrsb r3, [r4, r3] - bl sub_08008A46 + bl AddPlayerVelocity b _080089C0 _080089A8: movs r3, #0x14 ldrb r3, [r0, r3] lsrs r3, r3, #1 lsls r3, r3, #1 - ldr r4, _08008A7C @ =_0800890C + ldr r4, _08008A7C @ =velocities3 adds r4, r4, r3 movs r3, #0 ldrsb r2, [r4, r3] adds r3, #1 ldrsb r3, [r4, r3] - bl sub_08008A46 + bl AddPlayerVelocity _080089C0: ldr r1, _08008A80 @ =gPlayerState movs r4, #0x8c movs r2, #8 - ldrsh r3, [r1, r4] + ldrsh r3, [r1, r4] // vel_x orrs r3, r3 beq _080089E4 bpl _080089D2 @@ -585,7 +585,7 @@ _080089D2: push {r0, r1} adds r1, r3, #0 push {r2} - bl sub_080027EA + bl LinearMoveDirectionOLD pop {r0} bl sub_0807A5B8 pop {r0, r1} @@ -602,7 +602,7 @@ _080089F4: push {r0, r1} adds r1, r3, #0 push {r2} - bl sub_080027EA + bl LinearMoveDirectionOLD pop {r0} bl sub_0807A5B8 pop {r0, r1} @@ -646,18 +646,18 @@ _08008A3E: beq _08008A3A b _08008A38 - non_word_aligned_thumb_func_start sub_08008A46 -sub_08008A46: @ 0x08008A46 + non_word_aligned_thumb_func_start AddPlayerVelocity +AddPlayerVelocity: @ 0x08008A46 push {lr} ldr r1, _08008A84 @ =gPlayerState movs r4, #0x8c - ldrsh r5, [r1, r4] + ldrsh r5, [r1, r4] // vel_x adds r5, r5, r2 - bl sub_08008A88 - movs r4, #0x8e + bl ClampPlayerVelocity + movs r4, #0x8e // vel_y ldrsh r5, [r1, r4] adds r5, r5, r3 - bl sub_08008A88 + bl ClampPlayerVelocity pop {pc} _08008A60: eors r3, r3 @@ -667,14 +667,14 @@ _08008A60: _08008A68: .4byte gPlayerState _08008A6C: .4byte gPlayerState _08008A70: .4byte gPlayerState -_08008A74: .4byte _080088FC -_08008A78: .4byte _080088EC -_08008A7C: .4byte _0800890C +_08008A74: .4byte ice_velocities +_08008A78: .4byte velocities1 +_08008A7C: .4byte velocities3 _08008A80: .4byte gPlayerState _08008A84: .4byte gPlayerState - thumb_func_start sub_08008A88 -sub_08008A88: @ 0x08008A88 + thumb_func_start ClampPlayerVelocity +ClampPlayerVelocity: @ 0x08008A88 orrs r5, r5 bmi _08008A94 ldr r6, _08008B38 @ =0x00000180 @@ -758,13 +758,13 @@ CheckNEastTile: @ 0x08008B02 push {r0, r1, lr} movs r1, #0 movs r2, #0 - bl GetRelativeCollisionTile + bl GetActTileRelative // check if north east collision? ldr r1, =0x4000 tst r0, r1 bne _08008B1E ldr r1, =gUnk_08007CAC - bl sub_08007DE0 + bl ActTileConv movs r2, #1 cmp r3, #1 beq _08008B20 diff --git a/asm/src/script.s b/asm/src/script.s index f1fc3cfd..fd37d8f8 100644 --- a/asm/src/script.s +++ b/asm/src/script.s @@ -4,32 +4,33 @@ .syntax unified .text + .thumb + + .macro transition_tile tile:req, src_layer:req dest_layer:req + .short \tile + .byte \src_layer, \dest_layer + .endm + gUnk_08016984:: @ 08016984 .incbin "code_08016984/gUnk_08016984.bin" - .text - - non_word_aligned_thumb_func_start GetNextScriptCommandHalfword -GetNextScriptCommandHalfword: @ 0x08016986 +GetNextScriptCommandHalfword:: ldrh r0, [r0] bx lr - non_word_aligned_thumb_func_start GetNextScriptCommandHalfwordAfterCommandMetadata -GetNextScriptCommandHalfwordAfterCommandMetadata: @ 0x0801698A +GetNextScriptCommandHalfwordAfterCommandMetadata:: ldrh r0, [r0, #2] bx lr - non_word_aligned_thumb_func_start GetNextScriptCommandWord -GetNextScriptCommandWord: @ 0x0801698E +GetNextScriptCommandWord:: ldrh r1, [r0] ldrh r0, [r0, #2] lsls r0, r0, #0x10 orrs r0, r1 bx lr - thumb_func_start GetNextScriptCommandWordAfterCommandMetadata -GetNextScriptCommandWordAfterCommandMetadata: @ 0x08016998 +GetNextScriptCommandWordAfterCommandMetadata:: ldrh r1, [r0, #2] ldrh r0, [r0, #4] lsls r0, r0, #0x10 @@ -37,17 +38,15 @@ GetNextScriptCommandWordAfterCommandMetadata: @ 0x08016998 bx lr .align 2, 0 -gUnk_080169A4:: - .byte 0x01, 0xFF, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x01, 0x00 - .byte 0xFF, 0x01, 0x00, 0x00, 0x02, 0xFF, 0x01, 0xFE, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x01, 0xFF, 0x02 - .byte 0x00, 0x00, 0x01, 0x01, 0x02, 0xFF, 0x02, 0xFE, 0xFE, 0x02, 0xFF, 0x03, 0xFD, 0xFF, 0xFE, 0x01 - .byte 0x01, 0xFD, 0xFF, 0xFF, 0x03, 0xFE, 0x02, 0x00, 0x00, 0xFF, 0xFE, 0x03, 0xFD, 0x02, 0xFF, 0x00 - .byte 0x00, 0xFD, 0x02, 0x00, 0x00, 0xFF, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02 - .byte 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00 - .byte 0x00, 0x00, 0x01, 0x00 +gShakeOffsets:: + .byte 1, -1, 0, 1, 1, 0, 0, 1, -1, -1, 1, 0, -1, 1, 0, 0 + .byte 2, -1, 1, -2, 0, -1, -1, 0, -1, 1, -1, 2, 0, 0, 1, 1 + .byte 2, -1, 2, -2, -2, 2, -1, 3, -3, -1, -2, 1, 1, -3, -1, -1 + .byte 3, -2, 2, 0, 0, -1, -2, 3, -3, 2, -1, 0, 0, -3, 2, 0 + .byte 0, -1, 0, -2, 0, -1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1 + .byte 2, 0, 1, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, 0, 1, 0 - thumb_func_start UpdateSpriteForCollisionLayer -UpdateSpriteForCollisionLayer: @ 0x08016A04 +UpdateSpriteForCollisionLayer:: movs r1, #0x38 ldrb r1, [r0, r1] lsls r1, r1, #1 @@ -69,8 +68,7 @@ UpdateSpriteForCollisionLayer: @ 0x08016A04 _08016A28: .byte 0x80, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x40 - thumb_func_start ResolveCollisionLayer -ResolveCollisionLayer: @ 0x08016A30 +ResolveCollisionLayer:: push {r4, r5, lr} adds r4, r0, #0 movs r5, #0x38 @@ -102,41 +100,51 @@ _08016A64: bl UpdateSpriteForCollisionLayer pop {r4, r5, pc} - thumb_func_start sub_08016A6C -sub_08016A6C: @ 0x08016A6C +CheckOnLayerTransition:: push {r4, r5, lr} adds r4, r0, #0 - bl GetActTile - add r1, pc, #0x38 -_08016A76: - adds r1, #4 - ldrh r2, [r1] + bl GetActTile // tile under me + adr r1, gTransitionTiles-4 +loop: + adds r1, #4 // p += 4 + ldrh r2, [r1] // *(u16*)(p) cmp r2, #0 - beq _08016A90 + beq not_found cmp r2, r0 - bne _08016A76 + bne loop // found the tile under me? movs r2, #0x38 - ldrb r3, [r4, r2] - ldrb r5, [r1, #2] - cmp r3, r5 - beq _08016A90 - ldrb r5, [r1, #3] - strb r5, [r4, r2] -_08016A90: + ldrb r3, [r4, r2] // collision layer + ldrb r5, [r1, #2] // *(u8*)(p + 2) + cmp r3, r5 // am i on the right later? + beq not_found + ldrb r5, [r1, #3] // *(u8*)(p + 3) + strb r5, [r4, r2] // move to a new layer +not_found: pop {r4, r5, pc} .align 2, 0 -_08016A94: - .byte 0x2A, 0x00, 0x03, 0x03, 0x2D, 0x00, 0x03, 0x03, 0x2B, 0x00, 0x03, 0x03 - .byte 0x2C, 0x00, 0x03, 0x03, 0x4C, 0x00, 0x03, 0x03, 0x4E, 0x00, 0x03, 0x03, 0x4D, 0x00, 0x03, 0x03 - .byte 0x4F, 0x00, 0x03, 0x03, 0x0A, 0x00, 0x02, 0x01, 0x09, 0x00, 0x02, 0x01, 0x0C, 0x00, 0x01, 0x02 - .byte 0x0B, 0x00, 0x01, 0x02, 0x52, 0x00, 0x03, 0x03, 0x27, 0x00, 0x03, 0x03, 0x26, 0x00, 0x03, 0x03 - .byte 0x00, 0x00 - non_word_aligned_thumb_func_start sub_08016AD2 -sub_08016AD2: @ 0x08016AD2 + transition_tile 0x2A, 3, 3 + transition_tile 0x2D, 3, 3 + transition_tile 0x2B, 3, 3 + transition_tile 0x2C, 3, 3 + transition_tile 0x4C, 3, 3 + transition_tile 0x4E, 3, 3 + transition_tile 0x4D, 3, 3 + transition_tile 0x4F, 3, 3 +gTransitionTiles: + transition_tile 0x0A, 2, 1 + transition_tile 0x09, 2, 1 + transition_tile 0x0C, 1, 2 + transition_tile 0x0B, 1, 2 + transition_tile 0x52, 3, 3 + transition_tile 0x27, 3, 3 + transition_tile 0x26, 3, 3 + .short 0x0000 + +UpdateCollisionLayer:: push {r4, lr} adds r4, r0, #0 - bl sub_08016A6C + bl CheckOnLayerTransition push {r0} adds r0, r4, #0 bl UpdateSpriteForCollisionLayer diff --git a/asm/src/veneer.s b/asm/src/veneer.s index 2d484627..45ffb90a 100644 --- a/asm/src/veneer.s +++ b/asm/src/veneer.s @@ -54,8 +54,8 @@ CloneTile: @ 0x08000152 ldrh r0, [r3, r0] lsrs r2, r2, #2 - non_word_aligned_thumb_func_start SetTile -SetTile: @ r0 = tile type, r1, = tile position, r2 = layer + non_word_aligned_thumb_func_start SetBottomTile +SetBottomTile: @ r0 = tile type, r1, = tile position, r2 = layer push {r4-r7, lr} lsls r3, r2, #3 ldr r4, _08000208 @ =gUnk_08000228 @@ -65,7 +65,7 @@ SetTile: @ r0 = tile type, r1, = tile position, r2 = layer strh r0, [r5, r6] ldr r6, _0800020C @ =0x00004000 cmp r0, r6 - blo _0800019A + blo tile_wrong_type push {r1, r2} subs r4, r0, r6 ldr r3, _08000210 @ =gUnk_080B7910 @@ -77,12 +77,12 @@ SetTile: @ r0 = tile type, r1, = tile position, r2 = layer bl sub_08000148 pop {r0, r1} @ tilepos, layer push {r0, r1} - bl DeleteLoadedTileEntity + bl UnregisterInteractTile adds r0, r7, #0 pop {r1, r2} - bl sub_0801AF48 + bl RegisterInteractTile pop {r4, r5, r6, r7, pc} -_0800019A: +tile_wrong_type: adds r3, #4 ldr r4, [r4, r3] lsls r0, r0, #1 @@ -96,7 +96,7 @@ _0800019A: lsrs r2, r2, #2 bl sub_08000148 pop {r0, r1} - bl DeleteLoadedTileEntity + bl UnregisterInteractTile pop {r4, r5, r6, r7, pc} .align 2, 0 _080001C0: .4byte gMapBottom+0x6004 @@ -265,9 +265,9 @@ GetTileType: @ 0x080002B0 @ r0: Entity* @ r1: u32 @ r2: u32 - thumb_func_start GetRelativeCollisionTile -GetRelativeCollisionTile: @ 0x080002B4 - ldr r3, _08000320 @ =ram_GetRelativeCollisionTile + thumb_func_start GetActTileRelative +GetActTileRelative: @ 0x080002B4 + ldr r3, _08000320 @ =ram_GetActTileRelative bx r3 @ call 0x080B1AA8 @@ -410,7 +410,7 @@ _08000310: .4byte ram_GetTileTypeByPos _08000314: .4byte ram_sub_080B1A48 _08000318: .4byte ram_sub_080B1A58 _0800031C: .4byte ram_GetTileType -_08000320: .4byte ram_GetRelativeCollisionTile +_08000320: .4byte ram_GetActTileRelative _08000324: .4byte ram_GetActTile _08000328: .4byte ram_sub_080B1AB4 _0800032C: .4byte ram_sub_080B1AC8 diff --git a/include/asm.h b/include/asm.h index bb768be3..a6c7db62 100644 --- a/include/asm.h +++ b/include/asm.h @@ -9,7 +9,7 @@ extern void CloneTile(u32, u32, u32); extern u32 GetTileTypeByEntity(struct Entity_*); extern u32 GetTileTypeByPos(s32 x, s32 y, u32 layer); extern u32 GetTileType(u32 position, u32 layer); -extern void SetTile(u32 index, u32 position, u32 layer); +extern void SetBottomTile(u32 index, u32 position, u32 layer); extern void UpdateScrollVram(void); extern u32 sub_080B1B0C(struct Entity_*); extern u32 sub_080B1BA4(u32, u32, u32); @@ -29,7 +29,7 @@ u32 BounceUpdate(struct Entity_*, u32 acceleration); extern u32 CheckOnScreen(struct Entity_*); extern bool32 EntityInRectRadius(struct Entity_*, struct Entity_*, u32, u32); extern void UpdateAnimationVariableFrames(struct Entity_*, u32); -extern u32 sub_080043E8(struct Entity_*); +extern u32 GetTileHazardType(struct Entity_*); /** * Basic collision, only used between player and dazed enemies. * (Probablity leftover from Four Swords) @@ -44,7 +44,7 @@ extern u32 sub_080086B4(u32, u32, const u8*); extern u32 ResolveCollisionLayer(struct Entity_*); extern void sub_0800417E(struct Entity_*, u32); extern u32 sub_0800442E(struct Entity_*); -extern u32 sub_08007DD6(u32, const u16*); +extern u32 ActTileToTile(u32, const u16*); extern void SoundReqClipped(struct Entity_*, u32); extern u32 sub_0800132C(struct Entity_*, struct Entity_*); extern u32 sub_080B1B44(u32, u32); @@ -54,7 +54,7 @@ extern u32 sub_080B1AE0(u16, u8); extern u32 GetActTile(struct Entity_*); extern u32 sub_0800445C(struct Entity_*); extern u32 sub_080B1AF0(struct Entity_*, s32, s32); -extern u32 GetRelativeCollisionTile(struct Entity_*, u32, u32); +extern u32 GetActTileRelative(struct Entity_*, u32, u32); extern bool32 sub_080B1B54(u32); extern u32 CheckRectOnScreen(s32, s32, u32, u32); diff --git a/include/enemy.h b/include/enemy.h index 28a236ab..c799f058 100644 --- a/include/enemy.h +++ b/include/enemy.h @@ -62,7 +62,6 @@ void EnemySetFXOffset(Entity*, s32, s32, s32); Entity* EnemyCreateProjectile(Entity*, u32, u32); void GenericDeath(Entity*); -void sub_08002724(void*, u8*); void sub_080026C4(u8*, u8*, u8*, u32); void sub_080026F2(u8*, void*, u8*, u32); bool32 sub_08049FA0(Entity*); diff --git a/include/functions.h b/include/functions.h index 2d843967..5d4b01fe 100644 --- a/include/functions.h +++ b/include/functions.h @@ -14,10 +14,10 @@ // Identified - to be sorted into header files extern u32 CheckRegionOnScreen(u32, u32, u32, u32); extern void CopyOAM(void); -extern void CreateChestSpawner(Entity*); +extern void CreateLavaDrownFX(Entity*); extern Entity* CreateGroundItem(Entity*, u32, u32); extern Entity* CreateGroundItemWithFlags(Entity*, u32, u32, u32); -extern void CreateItemOnGround(Entity*); +extern void CreatePitFallFX(Entity*); extern void CreateMagicSparkles(u32, u32, u32); extern void CreateMinishEntrance(u32 tile); extern u32 CreateRandomItemDrop(Entity*, u32); @@ -25,7 +25,7 @@ extern void DrawDirect(u32 spriteIndex, u32 frameIndex); extern void DrawEntities(void); extern bool32 EntityWithinDistance(Entity*, s32, s32, s32); extern void FlushSprites(void); -extern LayerStruct* GetLayerByIndex(u32); +extern LayerStruct* GetTileBuffer(u32); extern u32 GetTileIndex(u32 tilePos, u32 layer); extern u32 GiveItem(u32, u32); extern bool32 LoadFixedGFX(Entity*, u32); @@ -57,7 +57,7 @@ extern u32 sub_080B1B18(s32, s32, u32); extern u32 sub_080B1B44(u32, u32); extern s32 sub_080012DC(Entity*); extern void sub_08001318(Entity*); -extern void sub_080027EA(Entity*, u32, u32); +extern void LinearMoveDirectionOLD(Entity*, u32, u32); extern void sub_080028E0(Entity*); extern u32 sub_080040A2(Entity*); extern u32 sub_080040D8(Entity*, u8*, s32, s32); @@ -66,15 +66,15 @@ extern u32 sub_0800419C(Entity*, Entity*, u32, u32); extern u32 sub_080041DC(Entity*, u32, u32); extern void sub_080042BA(Entity*, u32); extern void sub_080042D0(Entity*, u32, u16); -extern void sub_080043A8(Entity*); +extern void CreateDrownFX(Entity*); extern u32 sub_0800445C(Entity*); extern void sub_080044AE(Entity*, u32, u32); extern u32 BounceUpdate(Entity*, u32); extern void sub_0800451C(Entity*); extern void sub_08004542(Entity*); extern void sub_080085B0(Entity*); -extern u16* sub_08008796(Entity*, u32, u32, u32); -extern void sub_08016AD2(Entity*); +extern u16* DoTileInteraction(Entity*, u32, u32, u32); +extern void UpdateCollisionLayer(Entity*); extern u32 sub_0801766C(Entity*); extern void sub_0801AFE4(void); extern void UpdateUIElements(void); diff --git a/include/map.h b/include/map.h index b943ca2e..9859fa39 100644 --- a/include/map.h +++ b/include/map.h @@ -6,18 +6,18 @@ typedef struct { /*0x0000*/ BgSettings* bgSettings; - /*0x0004*/ u16 mapData[0x1000]; // tilemap data? <-- gMapDataTop / gMapDataBottom - /*0x2004*/ u8 collisionData[0x1000]; // more tilemap data? <-- gUnk_0200D654 / gUnk_02027EB4 - /*0x3004*/ u16 mapDataClone[0x1000]; // more tilemap data? <-- gUnk_0200E654 / gUnk_02028EB4 - /*0x5004*/ u16 metatileTypes[0x800]; // gMetatileTypesTop, gMetatileTypesBottom - /*0x6004*/ u16 unkData2[0x800]; // gUnk_02011654,gUnk_0202BEB4 - /*0x7004*/ u16 metatiles[0x2000]; // gMetatilesTop, gMetatilesBottom - /*0xb004*/ u8 unkData3[0x1000]; // gUnk_02016654, gUnk_02030EB4 + /*0x0004*/ u16 mapData[0x1000]; // tilemap data? <-- gMapDataTop / gMapDataBottom + /*0x2004*/ u8 collisionData[0x1000]; // more tilemap data? <-- gUnk_0200D654 / gUnk_02027EB4 + /*0x3004*/ u16 mapDataOriginal[0x1000]; // more tilemap data? <-- gUnk_0200E654 / gUnk_02028EB4 + /*0x5004*/ u16 metatileTypes[0x800]; // gMetatileTypesTop, gMetatileTypesBottom + /*0x6004*/ u16 unkData2[0x800]; // gUnk_02011654,gUnk_0202BEB4 + /*0x7004*/ u16 metatiles[0x2000]; // gMetatilesTop, gMetatilesBottom + /*0xb004*/ u8 unkData3[0x1000]; // gUnk_02016654, gUnk_02030EB4 } LayerStruct; extern LayerStruct gMapTop; extern LayerStruct gMapBottom; -LayerStruct* GetLayerByIndex(u32); +LayerStruct* GetTileBuffer(u32); #endif // MAP_H diff --git a/include/player.h b/include/player.h index d22b8968..0f0aa027 100644 --- a/include/player.h +++ b/include/player.h @@ -762,7 +762,7 @@ void PlayerShrinkByRay(void); // player.s extern u32 PlayerCheckNEastTile(); -extern u32* sub_08008790(Entity*, u32); +extern u32* DoTileInteractionHere(Entity*, u32); extern void UpdateIcePlayerVelocity(Entity*); extern void sub_08008AC6(Entity*); extern void sub_08008926(Entity*); diff --git a/include/tiles.h b/include/tiles.h index 1d3cac90..2dd6783a 100644 --- a/include/tiles.h +++ b/include/tiles.h @@ -1,6 +1,23 @@ #ifndef TILES_H #define TILES_H +typedef enum { + TILE_ACT_CUT = 0x0, + TILE_ACT_ROCKBREAKER = 0x1, + TILE_ACT_BOOMERANG = 0x2, + TILE_ACT_BOMB = 0x3, + TILE_ACT_ARROW = 0x4, + TILE_ACT_GUST = 0x5, + TILE_ACT_LIFT = 0x6, + TILE_ACT_FIRE = 0x7, + TILE_ACT_PLAYER_WALK = 0x8, + TILE_ACT_ENEMY_WALK = 0x9, + TILE_ACT_PACCI = 0xA, + TILE_ACT_SWORDBEAM = 0xC, + TILE_ACT_DIG = 0xD, + TILE_ACT_MINIGUST = 0xE, +} TileInteraction; + typedef enum { CUT_BUSH = 0x1C, CUT_GRASS = 0x1D, diff --git a/linker.ld b/linker.ld index 7099a9ab..eb2a4578 100644 --- a/linker.ld +++ b/linker.ld @@ -169,7 +169,7 @@ SECTIONS { . = 0x000057BC; ram_sub_080B1A48 = .; . = 0x000057CC; ram_sub_080B1A58 = .; . = 0x000057D4; ram_GetTileType = .; - . = 0x00005800; ram_GetRelativeCollisionTile = .; + . = 0x00005800; ram_GetActTileRelative = .; . = 0x0000581C; ram_GetActTile = .; . = 0x00005828; ram_sub_080B1AB4 = .; . = 0x0000583C; ram_sub_080B1AC8 = .; diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 3b26138a..beacfffc 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -217,7 +217,7 @@ u32 UpdatePlayerCollision(void) { } } } - layer = GetLayerByIndex(gPlayerEntity.base.collisionLayer); + layer = GetTileBuffer(gPlayerEntity.base.collisionLayer); ptr1 = &gUnk_080B4468[gPlayerEntity.base.animationState & 6]; position = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr1[0], -ptr1[1]); tileType = GetTileType(position, gPlayerEntity.base.collisionLayer); @@ -509,13 +509,13 @@ u32 UpdatePlayerCollision(void) { if (gPlayerState.field_0x35 != 0) { return 0; } - SetTile(0x4054, position, gPlayerEntity.base.collisionLayer); + SetBottomTile(0x4054, position, gPlayerEntity.base.collisionLayer); return 4; case 0x4053: if (gPlayerState.field_0x35 != 6) { return 0; } - SetTile(0x4054, position, gPlayerEntity.base.collisionLayer); + SetBottomTile(0x4054, position, gPlayerEntity.base.collisionLayer); return 4; case 0x4055: position--; @@ -529,7 +529,7 @@ u32 UpdatePlayerCollision(void) { } for (index = 0; index < 3; index++) { if (sub_0801A8D0(gPlayerClones[index], 0) == position) { - SetTile(0x4059, position, gPlayerEntity.base.collisionLayer); + SetBottomTile(0x4059, position, gPlayerEntity.base.collisionLayer); return 4; } } @@ -546,7 +546,7 @@ u32 UpdatePlayerCollision(void) { } for (index = 0; index < 3; index++) { if (sub_0801A8D0(gPlayerClones[index], 6) == position) { - SetTile(0x4059, position, gPlayerEntity.base.collisionLayer); + SetBottomTile(0x4059, position, gPlayerEntity.base.collisionLayer); return 4; } } @@ -563,7 +563,7 @@ u32 UpdatePlayerCollision(void) { if ((gPlayerEntity.base.frame & 1) == 0) { return 0; } - SetTile(0x4074, position, gPlayerEntity.base.collisionLayer); + SetBottomTile(0x4074, position, gPlayerEntity.base.collisionLayer); gPlayerState.pushedObject = 0xa0; gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.flags |= PL_BUSY; @@ -582,7 +582,7 @@ u32 UpdatePlayerCollision(void) { if ((gPlayerEntity.base.frame & 1) == 0) { return 0; } - SetTile(0x4074, position, gPlayerEntity.base.collisionLayer); + SetBottomTile(0x4074, position, gPlayerEntity.base.collisionLayer); sub_080001D0(0xd, position, gPlayerEntity.base.collisionLayer); return 1; default: @@ -638,7 +638,7 @@ bool32 sub_0801A370(LayerStruct* layer, u32 position) { if (!sub_0801A4F8()) { return FALSE; } - topLayer = GetLayerByIndex(2); + topLayer = GetTileBuffer(2); offset = gUnk_080B4488[gPlayerEntity.base.animationState >> 1]; pos = position + offset; tileType = GetTileType(pos, gPlayerEntity.base.collisionLayer); @@ -748,7 +748,7 @@ u32 sub_0801A570(Entity* this, u32 param_2) { if (this == NULL) { return 0xffff; } - layer = GetLayerByIndex(this->collisionLayer); + layer = GetTileBuffer(this->collisionLayer); metatileTypes = layer->metatileTypes; index1 = 4; index2 = 2; @@ -904,7 +904,7 @@ u32 sub_0801A8D0(Entity* this, u32 param_2) { if (this == NULL) return 0xffff; - mapData = GetLayerByIndex(this->collisionLayer)->mapData; + mapData = GetTileBuffer(this->collisionLayer)->mapData; if (param_2 == 0) { position = COORD_TO_TILE_OFFSET(this, 0, 8); tile = mapData[position]; @@ -930,7 +930,7 @@ u32 sub_0801A8D0(Entity* this, u32 param_2) { bool32 sub_0801A980(void) { u16 tileType; const s16* ptr; - GetLayerByIndex(gPlayerEntity.base.collisionLayer); + GetTileBuffer(gPlayerEntity.base.collisionLayer); ptr = &gUnk_080B44A8[gPlayerEntity.base.animationState & 6]; tileType = GetTileType(COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr[0], -ptr[1]), gPlayerEntity.base.collisionLayer); @@ -982,7 +982,7 @@ bool32 sub_0801AA58(Entity* this, u32 param_2, u32 param_3) { Entity* object; u32 temp; - layer = GetLayerByIndex(this->collisionLayer); + layer = GetTileBuffer(this->collisionLayer); if (((layer->collisionData[param_2 + gUnk_080B4488[param_3 >> 3]] == 0) || ((u8)(layer->collisionData[param_2 + gUnk_080B4488[param_3 >> 3]] - 0x20) < 0x20))) { @@ -1007,7 +1007,7 @@ bool32 sub_0801AA58(Entity* this, u32 param_2, u32 param_3) { void sub_0801AB08(u16* specialData, LayerStruct* layer) { u16* metatiles; u16* mapData; - u16* mapDataClone; + u16* mapDataOriginal; u16 index; u16 innerIndex; u32 tmp2; @@ -1020,7 +1020,7 @@ void sub_0801AB08(u16* specialData, LayerStruct* layer) { tmp3 = 2; } tmp2 = tmp3 << 0xc; - mapDataClone = layer->mapDataClone; + mapDataOriginal = layer->mapDataOriginal; mapData = layer->mapData; for (index = 0; index < 0x40; index++) { @@ -1028,7 +1028,7 @@ void sub_0801AB08(u16* specialData, LayerStruct* layer) { if (mapData[0] < 0x4000) { tmp1 = mapData[0] << 2; } else { - tmp1 = sub_0801AC68(tmp2, mapDataClone[0]); + tmp1 = sub_0801AC68(tmp2, mapDataOriginal[0]); } metatiles = layer->metatiles + tmp1; specialData[0] = metatiles[0]; @@ -1039,7 +1039,7 @@ void sub_0801AB08(u16* specialData, LayerStruct* layer) { if (mapData[1] < 0x4000) { tmp1 = mapData[1] << 2; } else { - tmp1 = sub_0801AC68(tmp2 + 1, mapDataClone[1]); + tmp1 = sub_0801AC68(tmp2 + 1, mapDataOriginal[1]); } metatiles = layer->metatiles + tmp1; specialData[0] = metatiles[0]; @@ -1050,7 +1050,7 @@ void sub_0801AB08(u16* specialData, LayerStruct* layer) { if (mapData[2] < 0x4000) { tmp1 = mapData[2] << 2; } else { - tmp1 = sub_0801AC68(tmp2 + 2, mapDataClone[2]); + tmp1 = sub_0801AC68(tmp2 + 2, mapDataOriginal[2]); } metatiles = layer->metatiles + tmp1; specialData[0] = metatiles[0]; @@ -1061,7 +1061,7 @@ void sub_0801AB08(u16* specialData, LayerStruct* layer) { if (mapData[3] < 0x4000) { tmp1 = mapData[3] << 2; } else { - tmp1 = sub_0801AC68(tmp2 + 3, mapDataClone[3]); + tmp1 = sub_0801AC68(tmp2 + 3, mapDataOriginal[3]); } metatiles = layer->metatiles + tmp1; specialData[0] = metatiles[0]; @@ -1071,7 +1071,7 @@ void sub_0801AB08(u16* specialData, LayerStruct* layer) { specialData += 2; mapData += 4; - mapDataClone += 4; + mapDataOriginal += 4; tmp2 = (u16)(tmp2 + 4); } specialData = specialData + 0x80; @@ -1215,13 +1215,13 @@ void sub_0801AE44(bool32 loadGfx) { void SetMultipleTiles(const TileData* tileData, u32 basePosition, u32 layer) { while (tileData->tile != -1) { - SetTile((u16)tileData->tile, basePosition + tileData->position, layer); + SetBottomTile((u16)tileData->tile, basePosition + tileData->position, layer); tileData++; } } // Add a new entry at the end of gUnk_0200B240 -void sub_0801AF48(u32 data, u32 position, u32 layer) { +void RegisterInteractTile(u32 data, u32 position, u32 layer) { u32 index; if ((data < 0x4000) && (gRoomTransition.field30 == 0)) { index = gRoomVars.tileEntityCount; @@ -1233,7 +1233,7 @@ void sub_0801AF48(u32 data, u32 position, u32 layer) { } } -void DeleteLoadedTileEntity(u32 position, s32 layer) { +void UnregisterInteractTile(u32 position, s32 layer) { u32 count; struct_0200B240* ptr; u32 positionLayer; @@ -1289,7 +1289,7 @@ void sub_0801AFE4(void) { for (x = 0; x < width; x++) { for (ptr = gUnk_080B44D0; ptr->collision != 0; ptr++) { if (ptr->collision == *collisionData) { - SetTile(ptr->tileIndex, y * 0x40 + x, 1); + SetBottomTile(ptr->tileIndex, y * 0x40 + x, 1); break; } } diff --git a/src/code_08049DF4.c b/src/code_08049DF4.c index ebfd458c..89cf6216 100644 --- a/src/code_08049DF4.c +++ b/src/code_08049DF4.c @@ -167,7 +167,7 @@ u32 sub_0804A044(Entity* entA, Entity* entB, u32 arg2) { //! @bug flags & 5 can never equal 0xA if (flags && ((flags & 5) != 0xA)) { - layer = GetLayerByIndex(entA->collisionLayer); + layer = GetTileBuffer(entA->collisionLayer); if (xDiff < 0) { xDiff = -xDiff; } diff --git a/src/enemy/armos.c b/src/enemy/armos.c index bd164871..db597408 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -403,11 +403,11 @@ void sub_080307D4(ArmosEntity* this) { void sub_080307EC(ArmosEntity* this) { u32 position = COORD_TO_TILE(super); this->unk_78 = GetTileIndex(position, super->collisionLayer); - SetTile(0x4022, position, (u32)super->collisionLayer); + SetBottomTile(0x4022, position, (u32)super->collisionLayer); } void sub_08030834(ArmosEntity* this) { - SetTile(this->unk_78, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(this->unk_78, COORD_TO_TILE(super), super->collisionLayer); } bool32 sub_0803086C(ArmosEntity* this) { @@ -435,11 +435,11 @@ bool32 sub_0803086C(ArmosEntity* this) { return TRUE; } } else { - SetTile(0x4022, pos, super->collisionLayer); + SetBottomTile(0x4022, pos, super->collisionLayer); } } else { if (CheckPlayerInRegion(centerX, centerY + 6, 2, 5) != 0) { - SetTile(0x4049, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4049, COORD_TO_TILE(super), super->collisionLayer); } } } diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index a770f1d9..5a2f0d9b 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -442,7 +442,7 @@ void sub_08028FFC(BusinessScrubEntity* this) { super->x.HALF.HI = this->unk_78; super->y.HALF.HI = this->unk_7a; InitializeAnimation(super, 0); - SetTile(0x4022, this->unk_76, super->collisionLayer); + SetBottomTile(0x4022, this->unk_76, super->collisionLayer); } void sub_08029078(BusinessScrubEntity* this) { @@ -456,7 +456,7 @@ void sub_08029078(BusinessScrubEntity* this) { super->spriteIndex = 0xd0; sub_08028FDC(this); sub_080290E0(this, 1); - SetTile(this->unk_74, this->unk_76, super->collisionLayer); + SetBottomTile(this->unk_74, this->unk_76, super->collisionLayer); } } diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 41ac71c4..95a08744 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -34,7 +34,7 @@ void sub_0801FAF8(ChuchuEntity* this); void sub_0801FB14(ChuchuEntity* this); void sub_0801FB34(ChuchuEntity* this); void sub_0801FB68(ChuchuEntity* this); -u32 sub_0801FBD0(ChuchuEntity* this); +u32 CheckWaterTile(ChuchuEntity* this); void Chuchu_JumpAtPlayer(ChuchuEntity* this); extern void (*const Chuchu_Functions[])(ChuchuEntity*); @@ -72,7 +72,7 @@ void Chuchu(ChuchuEntity* this) { /* ... */ break; case 2: - sub_080043A8(super); + CreateDrownFX(super); return; } } @@ -196,7 +196,7 @@ void sub_0801F0C8(ChuchuEntity* this) { } void sub_0801F12C(ChuchuEntity* this) { - if (sub_0801FBD0(this)) { + if (CheckWaterTile(this)) { sub_0801F328(this); } else { if ((super->subtimer++ & 7) == 0) { @@ -232,7 +232,7 @@ void sub_0801F1B0(ChuchuEntity* this) { } if (super->frame & ANIM_DONE) { - if (sub_0801FBD0(this)) { + if (CheckWaterTile(this)) { sub_0801F328(this); } else { sub_0801F340(this); @@ -261,7 +261,7 @@ void sub_0801F270(ChuchuEntity* this) { ProcessMovement5(super); GetNextFrame(super); - if (sub_0801FBD0(this)) + if (CheckWaterTile(this)) return; if (--super->timer != 0) @@ -390,7 +390,7 @@ void sub_0801F4EC(ChuchuEntity* this) { } void sub_0801F508(ChuchuEntity* this) { - if (sub_0801FBD0(this)) { + if (CheckWaterTile(this)) { this->unk_83 = 0; sub_0801F730(this); } else { @@ -429,7 +429,7 @@ void sub_0801F584(ChuchuEntity* this) { } if (super->frame & ANIM_DONE) { - if (sub_0801FBD0(this)) { + if (CheckWaterTile(this)) { this->unk_83 = 0; sub_0801F730(this); } else { @@ -464,7 +464,7 @@ void sub_0801F688(ChuchuEntity* this) { if (this->unk_83) this->unk_83--; - if (sub_0801FBD0(this) || this->unk_83) { + if (CheckWaterTile(this) || this->unk_83) { super->direction = sub_08049F84(super, 1); ProcessMovement5(super); GetNextFrame(super); @@ -572,7 +572,7 @@ void sub_0801F884(ChuchuEntity* this) { } void sub_0801F8C0(ChuchuEntity* this) { - if (sub_0801FBD0(this)) { + if (CheckWaterTile(this)) { sub_0801FAE0(this); } else if (sub_08049FDC(super, 1) == 0) { sub_0801F730(this); @@ -605,7 +605,7 @@ void sub_0801F940(ChuchuEntity* this) { } if (super->frame & ANIM_DONE) { - if (sub_0801FBD0(this)) { + if (CheckWaterTile(this)) { sub_0801FAE0(this); } else { super->action = 6; @@ -635,7 +635,7 @@ void sub_0801F9E0(ChuchuEntity* this) { } void sub_0801FA30(ChuchuEntity* this) { - if (sub_0801FBD0(this)) { + if (CheckWaterTile(this)) { super->direction = sub_08049F84(super, 1); ProcessMovement5(super); GetNextFrame(super); @@ -714,7 +714,7 @@ void sub_0801FB68(ChuchuEntity* this) { super->zVelocity = 0; } -u32 sub_0801FBD0(ChuchuEntity* this) { +u32 CheckWaterTile(ChuchuEntity* this) { if (GetActTile(super) == 0x10) { return 1; } else { diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index 0f054bdd..c9ee902c 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -561,7 +561,7 @@ void sub_080262A8(ChuchuBossEntity* this) { gPlayerEntity.base.animationState = 0; gRoomControls.camera_target = super; gRoomControls.scrollSpeed = 1; - SetTile(0x4022, 0x2c8, 1); + SetBottomTile(0x4022, 0x2c8, 1); } } diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index 344e284b..b7c57037 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -48,7 +48,7 @@ void DoorMimic_OnCollision(DoorMimicEntity* this) { } void DoorMimic_OnDeath(DoorMimicEntity* this) { - SetTile(this->unk_7c, this->unk_7e, super->collisionLayer); + SetBottomTile(this->unk_7c, this->unk_7e, super->collisionLayer); CreateFx(super, FX_POT_SHATTER, 0); EnemyDisableRespawn(super); DeleteThisEntity(); @@ -125,7 +125,7 @@ void sub_080221C0(DoorMimicEntity* this) { u32 tile = COORD_TO_TILE(super) + gUnk_080B4488[super->type2]; this->unk_7e = tile; this->unk_7c = GetTileIndex(tile, super->collisionLayer); - SetTile(gUnk_080CB79C[super->type2], tile, super->collisionLayer); + SetBottomTile(gUnk_080CB79C[super->type2], tile, super->collisionLayer); } // clang-format off diff --git a/src/enemy/enemy64.c b/src/enemy/enemy64.c index 62bd707b..be47abc9 100644 --- a/src/enemy/enemy64.c +++ b/src/enemy/enemy64.c @@ -85,10 +85,10 @@ void Enemy64_Init(Enemy64Entity* this) { Entity* tail; if (CheckFlags(0x7c)) { - SetTile(0x4081, 10, 2); - SetTile(0x4081, 0x4a, 2); - SetTile(0x4081, 0x8a, 2); - SetTile(0x4081, 0xca, 2); + SetBottomTile(0x4081, 10, 2); + SetBottomTile(0x4081, 0x4a, 2); + SetBottomTile(0x4081, 0x8a, 2); + SetBottomTile(0x4081, 0xca, 2); DeleteThisEntity(); } else { sub_0807B7D8(0x323, 10, 1); @@ -440,19 +440,19 @@ void Enemy64_Action4_SubAction7(Enemy64Entity* this) { DeleteThisEntity(); } else if (super->timer == 16) { sub_0807B7D8(0x36, 0xca, 1); - SetTile(0x4081, 0xca, 2); + SetBottomTile(0x4081, 0xca, 2); SoundReq(SFX_HEART_GET); } else if (super->timer == 24) { sub_0807B7D8(0x36, 0x8a, 1); - SetTile(0x4081, 0x8a, 2); + SetBottomTile(0x4081, 0x8a, 2); SoundReq(SFX_HEART_GET); } else if (super->timer == 32) { sub_0807B7D8(0x36, 0x4a, 1); - SetTile(0x4081, 0x4a, 2); + SetBottomTile(0x4081, 0x4a, 2); SoundReq(SFX_HEART_GET); } else if (super->timer == 40) { sub_0807B7D8(0x36, 10, 1); - SetTile(0x4081, 10, 2); + SetBottomTile(0x4081, 10, 2); SoundReq(SFX_HEART_GET); } } diff --git a/src/enemy/eyegore.c b/src/enemy/eyegore.c index b023469c..3b4ee58c 100644 --- a/src/enemy/eyegore.c +++ b/src/enemy/eyegore.c @@ -335,18 +335,18 @@ void sub_08030F00(EyegoreEntity* this) { this->unk_84 = tileIndex; tileIndex = GetTileIndex(position + 0x41, super->collisionLayer); this->unk_86 = tileIndex; - SetTile(0x4022, position, super->collisionLayer); - SetTile(0x4022, position + 1, super->collisionLayer); - SetTile(0x4022, position + 0x40, super->collisionLayer); - SetTile(0x4022, position + 0x41, super->collisionLayer); + SetBottomTile(0x4022, position, super->collisionLayer); + SetBottomTile(0x4022, position + 1, super->collisionLayer); + SetBottomTile(0x4022, position + 0x40, super->collisionLayer); + SetBottomTile(0x4022, position + 0x41, super->collisionLayer); } void sub_08030FB4(EyegoreEntity* this) { u32 position = COORD_TO_TILE_OFFSET(super, 8, 0x14); - SetTile(this->unk_80, position, super->collisionLayer); - SetTile(this->unk_82, position + 1, super->collisionLayer); - SetTile(this->unk_84, position + 0x40, super->collisionLayer); - SetTile(this->unk_86, position + 0x41, super->collisionLayer); + SetBottomTile(this->unk_80, position, super->collisionLayer); + SetBottomTile(this->unk_82, position + 1, super->collisionLayer); + SetBottomTile(this->unk_84, position + 0x40, super->collisionLayer); + SetBottomTile(this->unk_86, position + 0x41, super->collisionLayer); } void sub_08031024(EyegoreEntity* this) { @@ -439,8 +439,8 @@ void sub_08031024(EyegoreEntity* this) { void sub_08031250(EyegoreEntity* this) { u32 tmp2; u32 tmp = (u32)super->animationState * 4; - sub_08008796(super, 9, super->x.HALF.HI + gUnk_080CE2C0[tmp], super->y.HALF.HI + gUnk_080CE2C0[tmp + 1]); - sub_08008796(super, 9, super->x.HALF.HI + gUnk_080CE2C0[tmp + 2], super->y.HALF.HI + gUnk_080CE2C0[tmp + 3]); + DoTileInteraction(super, 9, super->x.HALF.HI + gUnk_080CE2C0[tmp], super->y.HALF.HI + gUnk_080CE2C0[tmp + 1]); + DoTileInteraction(super, 9, super->x.HALF.HI + gUnk_080CE2C0[tmp + 2], super->y.HALF.HI + gUnk_080CE2C0[tmp + 3]); if (this->unk_79 != 0) { tmp2 = 0; if ((super->x.HALF.HI - (u32)this->unk_74) + 2 < 5) { diff --git a/src/enemy/flyingPot.c b/src/enemy/flyingPot.c index 74f0a3b5..cc868bc0 100644 --- a/src/enemy/flyingPot.c +++ b/src/enemy/flyingPot.c @@ -99,7 +99,7 @@ void FlyingPot_OnCollision(FlyingPotEntity* this) { super->zVelocity = Q_16_16(2.625); super->spritePriority.b1 = 1; - SetTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetBottomTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); } else if (super->z.HALF.HI != 0) { sub_08037408(this); } @@ -145,7 +145,7 @@ void FlyingPot_SubAction2(FlyingPotEntity* this) { COLLISION_OFF(super); super->spriteOffsetX = 0; - SetTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetBottomTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); } if (sub_0806F520(super)) { @@ -177,7 +177,7 @@ void FlyingPot_Init(FlyingPotEntity* this) { tile = TILE(super->x.HALF.HI, super->y.HALF.HI); this->tileIndex = GetTileIndex(tile, super->collisionLayer); - SetTile(0x4000, tile, super->collisionLayer); + SetBottomTile(0x4000, tile, super->collisionLayer); InitializeAnimation(super, 5); } @@ -185,7 +185,7 @@ void FlyingPot_Action1(FlyingPotEntity* this) { sub_08037418(this); if (GetTileTypeByEntity(super) != 0x4000) { - SetTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetBottomTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); sub_08037408(this); } @@ -210,7 +210,7 @@ void FlyingPot_Action2(FlyingPotEntity* this) { super->flags2 = 0xF; super->hitbox = &gUnk_080FD34C; - SetTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetBottomTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); } } @@ -257,7 +257,7 @@ void sub_08037418(FlyingPotEntity* this) { u32 tile = COORD_TO_TILE(super); if (GetTileIndex(tile, super->collisionLayer) == 0x4067) { - SetTile(this->tileIndex, tile, super->collisionLayer); + SetBottomTile(this->tileIndex, tile, super->collisionLayer); DeleteThisEntity(); } } diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 7318f358..23ba5c87 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -50,7 +50,7 @@ void FlyingSkull_OnCollision(FlyingSkullEntity* this) { COLLISION_OFF(super); super->zVelocity = Q_16_16(2.625); super->spritePriority.b1 = 1; - SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); } else if (super->z.HALF.HI) { sub_0803A0E0(this); } @@ -89,7 +89,7 @@ void sub_08039CE0(FlyingSkullEntity* this) { super->timer = 1; super->z.HALF.HI = -1; super->spriteOffsetX = 0; - SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); } if (sub_0806F520(super)) { @@ -121,7 +121,7 @@ void sub_08039D74(FlyingSkullEntity* this) { tmp = COORD_TO_TILE(super); this->unk_0x74 = GetTileIndex(tmp, super->collisionLayer); - SetTile(0x4060, tmp, super->collisionLayer); + SetBottomTile(0x4060, tmp, super->collisionLayer); InitializeAnimation(super, 0); } @@ -130,7 +130,7 @@ void sub_08039DD8(FlyingSkullEntity* this) { if (super->type == 0) { if (GetTileTypeByEntity(super) == 0x4073) { - SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); sub_0803A0E0(this); } @@ -147,7 +147,7 @@ void sub_08039DD8(FlyingSkullEntity* this) { if (player != NULL) { player->type2 = 1; CopyPosition(super, player); - SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); DeleteEntity(super); } } @@ -167,7 +167,7 @@ void sub_08039EE4(FlyingSkullEntity* this) { super->hitbox = (Hitbox*)&gUnk_080FD340; gPlayerEntity.base.animationState; this->unk_0x76 = gPlayerEntity.base.animationState; - SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); } void sub_08039F4C(FlyingSkullEntity* this) { @@ -200,7 +200,7 @@ void sub_08039FAC(FlyingSkullEntity* this) { super->hitType = 0xa0; super->flags2 = 0xf; super->hitbox = (Hitbox*)&gUnk_080FD34C; - SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); } } @@ -249,7 +249,7 @@ void sub_0803A0E0(FlyingSkullEntity* this) { void sub_0803A100(FlyingSkullEntity* this) { u32 tile = COORD_TO_TILE(super); if (GetTileIndex(tile, super->collisionLayer) == 0x4067) { - SetTile(this->unk_0x74, tile, super->collisionLayer); + SetBottomTile(this->unk_0x74, tile, super->collisionLayer); DeleteThisEntity(); } } diff --git a/src/enemy/gyorgFemale.c b/src/enemy/gyorgFemale.c index fbc0a222..baa1105b 100644 --- a/src/enemy/gyorgFemale.c +++ b/src/enemy/gyorgFemale.c @@ -250,7 +250,7 @@ void sub_080464C0(GyorgFemaleEntity* this) { void sub_08046518(void) { u16* ptr = gMapTop.metatileTypes; u16* sl = &gMapTop.mapData[sub_08046518_offset]; - u16* stack1 = &gMapTop.mapDataClone[sub_08046518_offset]; + u16* stack1 = &gMapTop.mapDataOriginal[sub_08046518_offset]; u8* stack2 = &gMapTop.unkData3[sub_08046518_offset]; u8* r6 = &gMapTop.collisionData[sub_08046518_offset]; u32 i; diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 4a43753e..ab1437cc 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -373,8 +373,8 @@ void sub_0802C1C0(HelmasaurEntity* this) { void sub_0802C1CC(HelmasaurEntity* this) { const s8* ptr = &gUnk_080CD464[super->animationState << 2]; - sub_08008796(super, 9, super->x.HALF.HI + ptr[0], super->y.HALF.HI + ptr[1]); - sub_08008796(super, 9, super->x.HALF.HI + ptr[2], super->y.HALF.HI + ptr[3]); + DoTileInteraction(super, 9, super->x.HALF.HI + ptr[0], super->y.HALF.HI + ptr[1]); + DoTileInteraction(super, 9, super->x.HALF.HI + ptr[2], super->y.HALF.HI + ptr[3]); } void sub_0802C218(HelmasaurEntity* this) { diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index 65e917a2..15e84846 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -167,7 +167,8 @@ void MazaalBracelet_OnCollision(MazaalBraceletEntity* this) { if (super->type < 2) { if (super->action != 0x2b) { - if ((0 < super->iframes) && ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15) || (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe))))) { + if ((0 < super->iframes) && ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15) || + (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe))))) { super->action = 0x28; COLLISION_OFF(super); entity = (MazaalBraceletEntity*)super->parent; diff --git a/src/enemy/mazaalMacro.c b/src/enemy/mazaalMacro.c index a404cbdc..ef417421 100644 --- a/src/enemy/mazaalMacro.c +++ b/src/enemy/mazaalMacro.c @@ -96,7 +96,7 @@ void sub_08034CC4(MazaalMacroEntity* this) { this->unk_78 = 0x4b0; sub_08034F70(this); InitializeAnimation(super, super->type); - SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); entity = CreateEnemy(MAZAAL_MACRO, 2); if (entity != NULL) { super->child = entity; diff --git a/src/enemy/octorokGolden.c b/src/enemy/octorokGolden.c index 82bb3c8f..0d6e6ddf 100644 --- a/src/enemy/octorokGolden.c +++ b/src/enemy/octorokGolden.c @@ -117,7 +117,7 @@ void sub_08037E14(Entity* this) { s32 x, y; this->timer = 8; dir = (GetFacingDirection(this, &gPlayerEntity.base) + 4) & 0x18; - layer = (u8*)GetLayerByIndex(this->collisionLayer)->collisionData; + layer = (u8*)GetTileBuffer(this->collisionLayer)->collisionData; ptr = gUnk_080CF498 + (dir >> 2); x = this->x.HALF.HI + *ptr; y = this->y.HALF.HI + *(ptr + 1); diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index f0bdb5a2..e386d4b6 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -446,7 +446,8 @@ void sub_080244E8(PestoEntity* this) { super->timer = 12; this->unk_83 &= ~0x80; entity = super->child; - SetTile(((PestoEntity*)entity)->unk_70, COORD_TO_TILE(entity), entity->collisionLayer); + SetBottomTile(((PestoEntity*)entity)->unk_70, COORD_TO_TILE(entity), + entity->collisionLayer); DeleteEntity(entity); super->z.HALF.HI -= 0xe; this->unk_78 -= 0xe; diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index 6031dd12..db6233e1 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -276,7 +276,7 @@ bool32 Rollobite_TryToHoleUp(RollobiteEntity* this) { super->y.HALF.HI += 13; super->zVelocity = Q_16_16(2.0); InitializeAnimation(super, super->animationState + 0x14); - SetTile(0x4034, tile, super->collisionLayer); + SetBottomTile(0x4034, tile, super->collisionLayer); return TRUE; } } diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 4831bf3b..7ebff811 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -40,7 +40,7 @@ void RupeeLike(RupeeLikeEntity* this) { u32 uVar1; if (super->type2 == 0) { - uVar1 = (u8)sub_080043E8(super); + uVar1 = (u8)GetTileHazardType(super); if (uVar1 != 0) { if (super->action == 4) { sub_080296D8(this); diff --git a/src/enemy/spinyBeetle.c b/src/enemy/spinyBeetle.c index d729bc52..297b3b51 100644 --- a/src/enemy/spinyBeetle.c +++ b/src/enemy/spinyBeetle.c @@ -94,7 +94,7 @@ void SpinyBeetle_Init(SpinyBeetleEntity* this) { this->unk_7b = 0; this->tile = COORD_TO_TILE(super); this->tileIndex = GetTileIndex(this->tile, super->collisionLayer); - SetTile(0x4022, this->tile, super->collisionLayer); + SetBottomTile(0x4022, this->tile, super->collisionLayer); obj = CreateObject(OBJECT_ON_BEETLE, super->type, 0); if (obj == NULL) { @@ -259,7 +259,7 @@ void sub_08033B44(SpinyBeetleEntity* this) { } } - SetTile(0x4022, this->tile, super->collisionLayer); + SetBottomTile(0x4022, this->tile, super->collisionLayer); InitializeAnimation(super, 0); } diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index 6c86aa18..b4a26dfb 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -437,7 +437,7 @@ void sub_08039AD4(StalfosEntity* this) { super->action = 0xb; super->child = projectile; InitAnimationForceUpdate(super, super->animationState + 0x18); - SetTile(0x4067, position, super->collisionLayer); + SetBottomTile(0x4067, position, super->collisionLayer); return; } } diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index a7efe411..3df5abe6 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -285,6 +285,6 @@ void sub_0803E4D8(VaatiProjectileEntity* this) { tile = TILE(super->x.HALF.HI, super->y.HALF.HI + 8); if (sub_080B1B44(tile, gPlayerEntity.base.collisionLayer) != 0xff) { - SetTile(0x4074, tile, gPlayerEntity.base.collisionLayer); + SetBottomTile(0x4074, tile, gPlayerEntity.base.collisionLayer); } } diff --git a/src/enemy/wizzrobeFire.c b/src/enemy/wizzrobeFire.c index 0253a142..b4c6656c 100644 --- a/src/enemy/wizzrobeFire.c +++ b/src/enemy/wizzrobeFire.c @@ -26,7 +26,7 @@ void WizzrobeFire_OnCollision(WizzrobeEntity* this) { } EnemyFunctionHandlerAfterCollision(super, WizzrobeFire_Functions); if (super->health == 0) { - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); } } @@ -111,7 +111,7 @@ void WizzrobeFire_Action2(WizzrobeEntity* this) { super->timer = 40; super->subtimer = 0; super->flags &= ~0x80; - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); EnqueueSFX(SFX_156); InitializeAnimation(super, super->direction >> 3); } diff --git a/src/enemy/wizzrobeIce.c b/src/enemy/wizzrobeIce.c index def00092..ae2dbcfe 100644 --- a/src/enemy/wizzrobeIce.c +++ b/src/enemy/wizzrobeIce.c @@ -35,7 +35,7 @@ void WizzrobeIce_OnCollision(WizzrobeEntity* this) { } } if (super->health == 0) { - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); } } @@ -118,7 +118,7 @@ void WizzrobeIce_Action2(WizzrobeEntity* this) { super->timer = 40; super->subtimer = 0; super->flags &= ~0x80; - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); EnqueueSFX(SFX_156); InitializeAnimation(super, super->direction >> 3); } diff --git a/src/enemy/wizzrobeWind.c b/src/enemy/wizzrobeWind.c index b4aeca23..18ee7116 100644 --- a/src/enemy/wizzrobeWind.c +++ b/src/enemy/wizzrobeWind.c @@ -42,7 +42,7 @@ void WizzrobeWind_OnCollision(WizzrobeEntity* this) { } } if (super->health == 0) { - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); } } @@ -135,7 +135,7 @@ void WizzrobeWind_Action2(WizzrobeEntity* this) { super->subtimer = 0; super->flags &= ~0x80; EnqueueSFX(SFX_156); - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); InitializeAnimation(super, super->direction >> 3); } break; @@ -208,7 +208,7 @@ void sub_0802F888(WizzrobeEntity* this) { super->direction = (sub_08049F84(super, 3) + 4) & 0x18; this->tilePosition = COORD_TO_TILE(super); this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer); - SetTile(0x4071, this->tilePosition, super->collisionLayer); + SetBottomTile(0x4071, this->tilePosition, super->collisionLayer); } void sub_0802F8E4(WizzrobeEntity* this) { diff --git a/src/interrupts.c b/src/interrupts.c index 5ea8bc64..f52a8da3 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -219,8 +219,8 @@ void PlayerUpdate(PlayerEntity* this) { } HandlePlayerLife(super); DoPlayerAction(this); - if ((super->z.WORD == 0) && (super->action == 1 || super->action == 9)) - sub_08008790(super, 8); + if ((super->z.WORD == 0) && (super->action == PLAYER_NORMAL || super->action == PLAYER_MINISH)) + DoTileInteractionHere(super, 8); sub_080171F0(); } sub_08078FB0(super); diff --git a/src/item/itemMoleMitts.c b/src/item/itemMoleMitts.c index 7dfc8d27..6940a95b 100644 --- a/src/item/itemMoleMitts.c +++ b/src/item/itemMoleMitts.c @@ -6,7 +6,7 @@ #include "object.h" s32 sub_080774A0(void); -extern s32 sub_0800875A(Entity*, u32, ItemBehavior*); +extern s32 DoItemTileInteraction(Entity*, u32, ItemBehavior*); extern void UpdatePlayerMovement(void); extern bool32 sub_0807B5B0(Entity*); void sub_08077130(ItemBehavior*, u32); @@ -70,7 +70,7 @@ void sub_080771C8(ItemBehavior* this, u32 index) { CreateObjectWithParent(&gPlayerEntity.base, MOLE_MITTS_PARTICLE, this->playerFrame, 1); } if ((this->playerFrame & 0x10) != 0) { - if (sub_0800875A(&gPlayerEntity.base, 0xd, this) == 0) { + if (DoItemTileInteraction(&gPlayerEntity.base, 0xd, this) == 0) { SetItemAnim(this, ANIM_MOLEMITTS_MISS); this->stateID = 3; SoundReq(SFX_ITEM_GLOVES_AIR); diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index e721bb51..c908f04f 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -14,7 +14,7 @@ void sub_08076518(ItemBehavior*, u32); void sub_080765E0(ItemBehavior*, u32); void sub_0807660C(ItemBehavior*, u32); -extern s32 sub_0800875A(Entity*, u32, ItemBehavior*); +extern s32 DoItemTileInteraction(Entity*, u32, ItemBehavior*); extern const u16 gUnk_0811BE38[]; extern const u16 gUnk_0811BE40[]; @@ -168,7 +168,7 @@ void sub_080762D8(ItemBehavior* this, u32 index) { if (!gPlayerState.jump_status) { - if (gPlayerState.heldObject == 1 && sub_0800875A(&gPlayerEntity.base, 6, this) != 0) { + if (gPlayerState.heldObject == 1 && DoItemTileInteraction(&gPlayerEntity.base, 6, this) != 0) { sub_08076088(this, NULL, index); return; } else if (gUnk_0811BE38[gPlayerEntity.base.animationState >> 1] & gPlayerState.playerInput.heldInput) { diff --git a/src/manager/diggingCaveEntranceManager.c b/src/manager/diggingCaveEntranceManager.c index 7491eea4..8698db9e 100644 --- a/src/manager/diggingCaveEntranceManager.c +++ b/src/manager/diggingCaveEntranceManager.c @@ -53,9 +53,9 @@ void DiggingCaveEntranceManager_Init(DiggingCaveEntranceManager* this) { tile = 0x81 << 7; // 0x4080 for (entrance = GetDiggingCaveEntranceForRoom(entrance, room); entrance != 0; entrance = GetDiggingCaveEntranceForRoom(entrance, room)) { - SetTile(tile, entrance->sourceTilePosition + TILE_POS(-1, 1), 1); - SetTile(tile, entrance->sourceTilePosition + TILE_POS(0, 1), 1); - SetTile(tile, entrance->sourceTilePosition + TILE_POS(1, 1), 1); + SetBottomTile(tile, entrance->sourceTilePosition + TILE_POS(-1, 1), 1); + SetBottomTile(tile, entrance->sourceTilePosition + TILE_POS(0, 1), 1); + SetBottomTile(tile, entrance->sourceTilePosition + TILE_POS(1, 1), 1); entrance++; } } diff --git a/src/manager/flameManager.c b/src/manager/flameManager.c index 880324fd..46d2ad32 100644 --- a/src/manager/flameManager.c +++ b/src/manager/flameManager.c @@ -16,7 +16,7 @@ void FlameManager_Main(FlameManager* this) { this->field_0x38 = TILE(this->field_0x38, this->field_0x3a); if (GetTileType(this->field_0x38, 2) == 0x75) { super->action = 1; - SetTile(0x406a, this->field_0x38, 1); + SetBottomTile(0x406a, this->field_0x38, 1); } else { DeleteThisEntity(); } @@ -26,7 +26,7 @@ void FlameManager_Main(FlameManager* this) { DeleteThisEntity(); } if (GetTileType(this->field_0x38, 2) == 0x76) { - SetTile(0x406b, this->field_0x38, 1); + SetBottomTile(0x406b, this->field_0x38, 1); DeleteThisEntity(); } } diff --git a/src/manager/manager29.c b/src/manager/manager29.c index 02ed52ba..55a5548f 100644 --- a/src/manager/manager29.c +++ b/src/manager/manager29.c @@ -33,7 +33,7 @@ void sub_0805CBD0(Manager29* this) { this->unk_38 = (this->unk_38 >> 4 & 0x3fU) | (((this->unk_3a << 0x10) >> 0x14 & 0x3fU) << 6); this->unk_3a = (this->unk_3c >> 4 & 0x3f) | (((this->unk_36 + this->unk_37 * 0x100) >> 4 & 0x3fU) << 6); this->unk_3c = GetTileType(this->unk_38, this->unk_34); - layer = GetLayerByIndex(this->unk_34); + layer = GetTileBuffer(this->unk_34); this->unk_28 = (u16*)layer->metatileTypes; this->unk_2c = &layer->mapData[(s16)this->unk_3a]; } diff --git a/src/manager/tileChangeObserveManager.c b/src/manager/tileChangeObserveManager.c index f2ada610..77c24677 100644 --- a/src/manager/tileChangeObserveManager.c +++ b/src/manager/tileChangeObserveManager.c @@ -31,7 +31,7 @@ void TileChangeObserveManager_Init(TileChangeObserveManager* this) { DeleteThisEntity(); } else { super->action = 1; - tile = &GetLayerByIndex(this->field_0x3a)->mapData[this->tilePosition]; + tile = &GetTileBuffer(this->field_0x3a)->mapData[this->tilePosition]; this->observedTile = tile; this->initialTile = tile[0]; } diff --git a/src/manager/waterfallBottomManager.c b/src/manager/waterfallBottomManager.c index a8e3f4c4..11b93c99 100644 --- a/src/manager/waterfallBottomManager.c +++ b/src/manager/waterfallBottomManager.c @@ -10,7 +10,7 @@ #include "functions.h" void WaterfallBottomManager_Main(WaterfallBottomManager* this) { - SetTile(0x4014, 0x5c3, 1); + SetBottomTile(0x4014, 0x5c3, 1); if ((gRoomControls.origin_y + 200 < gPlayerEntity.base.y.HALF.HI) && ((u32)(gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x) - 0x30 < 0x11)) { gPlayerEntity.base.collisionLayer = 3; diff --git a/src/movement.c b/src/movement.c index 51e95932..f166c5b0 100644 --- a/src/movement.c +++ b/src/movement.c @@ -1612,7 +1612,7 @@ void CalculateEntityTileCollisions(Entity* this, u32 direction, u32 collisionTyp u32 hitboxUnkX; u32 hitboxUnkY; - layer = GetLayerByIndex(this->collisionLayer)->collisionData; + layer = GetTileBuffer(this->collisionLayer)->collisionData; hb = this->hitbox; xMin = this->x.HALF.HI + hb->offset_x; yMin = this->y.HALF.HI + hb->offset_y; diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c index 86365860..1d0c6b07 100644 --- a/src/npc/castorWildsStatue.c +++ b/src/npc/castorWildsStatue.c @@ -78,20 +78,20 @@ void sub_08067418(CastorWildsStatueEntity* this) { this->tilePos = COORD_TO_TILE(super); if (super->type == 0) { super->hitbox = (Hitbox*)&gUnk_08110E94; - SetTile(0x4022, this->tilePos - 1, super->collisionLayer); - SetTile(0x4022, this->tilePos, super->collisionLayer); - SetTile(0x4022, this->tilePos + 0x3f, super->collisionLayer); - SetTile(0x4022, this->tilePos + 0x40, super->collisionLayer); + SetBottomTile(0x4022, this->tilePos - 1, super->collisionLayer); + SetBottomTile(0x4022, this->tilePos, super->collisionLayer); + SetBottomTile(0x4022, this->tilePos + 0x3f, super->collisionLayer); + SetBottomTile(0x4022, this->tilePos + 0x40, super->collisionLayer); } else { super->collisionLayer = 3; super->spriteOrientation.flipY = 1; super->spriteRendering.b3 = 1; super->spritePriority.b0 = 2; if (CheckLocalFlag(HIKYOU_00_SEKIZOU) == 0) { - SetTile(0x4022, 0xe81, 1); - SetTile(0x4022, 0xe82, 1); - SetTile(0x4022, 0xe83, 1); - SetTile(0x4022, 0xec3, 1); + SetBottomTile(0x4022, 0xe81, 1); + SetBottomTile(0x4022, 0xe82, 1); + SetBottomTile(0x4022, 0xe83, 1); + SetBottomTile(0x4022, 0xec3, 1); } } InitScriptForNPC(super); diff --git a/src/npc/clothesRack.c b/src/npc/clothesRack.c index 28de3bed..aa6ae533 100644 --- a/src/npc/clothesRack.c +++ b/src/npc/clothesRack.c @@ -36,12 +36,12 @@ void sub_0806DD90(Entity* this) { InitializeAnimation(this, animIndex); x = this->x.HALF.HI; y = this->y.HALF.HI; - SetTile(0x4072, TILE(x - 0x18, y - 0x10), this->collisionLayer); - SetTile(0x4072, TILE(x - 0x18, y), this->collisionLayer); - SetTile(0x4072, TILE(x - 0x18, y + 0x10), this->collisionLayer); - SetTile(0x4072, TILE(x + 0x18, y - 0x10), this->collisionLayer); - SetTile(0x4072, TILE(x + 0x18, y), this->collisionLayer); - SetTile(0x4072, TILE(x + 0x18, y + 0x10), this->collisionLayer); + SetBottomTile(0x4072, TILE(x - 0x18, y - 0x10), this->collisionLayer); + SetBottomTile(0x4072, TILE(x - 0x18, y), this->collisionLayer); + SetBottomTile(0x4072, TILE(x - 0x18, y + 0x10), this->collisionLayer); + SetBottomTile(0x4072, TILE(x + 0x18, y - 0x10), this->collisionLayer); + SetBottomTile(0x4072, TILE(x + 0x18, y), this->collisionLayer); + SetBottomTile(0x4072, TILE(x + 0x18, y + 0x10), this->collisionLayer); } void sub_0806DEC8(Entity* this) { diff --git a/src/npc/dog.c b/src/npc/dog.c index 3ca53e97..a6c7c0fe 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -235,7 +235,7 @@ void sub_08069B44(DogEntity* this) { super->action = 4; } if ((super->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) { - SetTile(0x4072, TILE(super->x.HALF.HI, super->y.HALF.HI - 8), super->collisionLayer); + SetBottomTile(0x4072, TILE(super->x.HALF.HI, super->y.HALF.HI - 8), super->collisionLayer); } } } diff --git a/src/npc/kid.c b/src/npc/kid.c index aa4bcbea..c6a57463 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -586,12 +586,12 @@ void sub_080626E0(Entity* this, ScriptExecutionContext* context) { } void sub_08062788(Entity* this, ScriptExecutionContext* context) { - SetTile(0x4072, 0x60b, 1); - SetTile(0x4072, 0x60c, 1); - SetTile(0x4072, 0x60d, 1); - SetTile(0x4072, 0x64b, 1); - SetTile(0x4072, 0x64c, 1); - SetTile(0x4072, 0x64d, 1); + SetBottomTile(0x4072, 0x60b, 1); + SetBottomTile(0x4072, 0x60c, 1); + SetBottomTile(0x4072, 0x60d, 1); + SetBottomTile(0x4072, 0x64b, 1); + SetBottomTile(0x4072, 0x64c, 1); + SetBottomTile(0x4072, 0x64d, 1); } void sub_080627E8(Entity* this, ScriptExecutionContext* context) { diff --git a/src/npc/npc5.c b/src/npc/npc5.c index dc301ae8..1b60767d 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -68,7 +68,7 @@ u32 PointInsideRadius(s32, s32, s32); u32 sub_080611D4(Entity*); extern u32 sub_08079FD4(Entity*, u32); -extern void sub_08016AD2(Entity*); +extern void UpdateCollisionLayer(Entity*); bool32 sub_08061630(NPC5Entity*, s32, s32, s32); bool32 sub_08061720(NPC5Entity*, s32, s32, s32); @@ -471,7 +471,7 @@ bool32 sub_08061170(NPC5Entity* this) { } return FALSE; } else { - sub_08016AD2(super); + UpdateCollisionLayer(super); return TRUE; } } @@ -501,7 +501,7 @@ u32 sub_080611D4(Entity* this) { ptr = (s8*)gUnk_0810AC4C; a = ptr[x]; b = ptr[x + 1]; - uVar2 = GetRelativeCollisionTile(this, a, b); + uVar2 = GetActTileRelative(this, a, b); ptr2 = gUnk_0810AC54; do { diff --git a/src/object/angryStatue.c b/src/object/angryStatue.c index 0204c90e..687d32d9 100644 --- a/src/object/angryStatue.c +++ b/src/object/angryStatue.c @@ -29,7 +29,7 @@ void AngryStatue(Entity* this) { void AngryStatue_Init(Entity* this) { this->action = 1; this->hitbox = (Hitbox*)&gUnk_080FD178; - SetTile(0x4022, COORD_TO_TILE(this), this->collisionLayer); + SetBottomTile(0x4022, COORD_TO_TILE(this), this->collisionLayer); InitializeAnimation(this, this->type); } diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index 22b5fbbb..9a593e32 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -107,12 +107,12 @@ void sub_0809CDF0(BakerOvenEntity* this) { (((super->y.HALF.HI - gRoomControls.origin_y) >> 4 & 0x3f) << 6); y = this->unk_80; - SetTile(0x402e, y - 0x01, super->collisionLayer); - SetTile(0x4022, y - 0x00, super->collisionLayer); - SetTile(0x4022, y + 0x01, super->collisionLayer); - SetTile(0x4026, y - 0x41, super->collisionLayer); - SetTile(0x4026, y - 0x40, super->collisionLayer); - SetTile(0x4024, y - 0x3f, super->collisionLayer); - SetTile(0x4026, y - 0x81, super->collisionLayer); - SetTile(0x4026, y - 0x80, super->collisionLayer); + SetBottomTile(0x402e, y - 0x01, super->collisionLayer); + SetBottomTile(0x4022, y - 0x00, super->collisionLayer); + SetBottomTile(0x4022, y + 0x01, super->collisionLayer); + SetBottomTile(0x4026, y - 0x41, super->collisionLayer); + SetBottomTile(0x4026, y - 0x40, super->collisionLayer); + SetBottomTile(0x4024, y - 0x3f, super->collisionLayer); + SetBottomTile(0x4026, y - 0x81, super->collisionLayer); + SetBottomTile(0x4026, y - 0x80, super->collisionLayer); } diff --git a/src/object/beanstalk.c b/src/object/beanstalk.c index fb6abf4e..db00d5d0 100644 --- a/src/object/beanstalk.c +++ b/src/object/beanstalk.c @@ -257,8 +257,8 @@ void Beanstalk_Action1Type7(BeanstalkEntity* this) { this->unk_70 = TILE(super->x.HALF.HI, this->unk_6c); while (TRUE) { this->unk_70 = TILE(super->x.HALF.HI, this->unk_6c); - SetTile(0x4017, this->unk_70, 2); - SetTile(0x4017, this->unk_70, 1); + SetBottomTile(0x4017, this->unk_70, 2); + SetBottomTile(0x4017, this->unk_70, 1); this->unk_6c += 0x10; if (this->unk_6c >= gRoomControls.origin_y + gRoomControls.height) break; @@ -307,7 +307,7 @@ void Beanstalk_Action1Type8SubAction0(BeanstalkEntity* this) { super->spriteOrientation.flipY = 2; this->unk_70 = COORD_TO_TILE(super); - SetTile(0x4017, this->unk_70, 1); + SetBottomTile(0x4017, this->unk_70, 1); super->subAction = 1; obj = CreateObjectWithParent(super, CHUCHU_BOSS_PARTICLE, 0, 0); if (obj != NULL) { @@ -339,12 +339,12 @@ void Beanstalk_Action1Type9(BeanstalkEntity* this) { if (gPlayerState.floor_type == SURFACE_LADDER) { super->spritePriority.b0 = 0; if (sub_080B1A0C(super, 0, -0x18) != 0x4014) { - SetTile(0x4014, COORD_TO_TILE_OFFSET(super, 0, 0x18), 1); + SetBottomTile(0x4014, COORD_TO_TILE_OFFSET(super, 0, 0x18), 1); } } else { super->spritePriority.b0 = 5; if (this->unk_72 != sub_080B1A0C(super, 0, -0x18)) { - SetTile(this->unk_72, COORD_TO_TILE_OFFSET(super, 0, 0x18), 1); + SetBottomTile(this->unk_72, COORD_TO_TILE_OFFSET(super, 0, 0x18), 1); } } } diff --git a/src/object/bigIceBlock.c b/src/object/bigIceBlock.c index e52d4323..126b0600 100644 --- a/src/object/bigIceBlock.c +++ b/src/object/bigIceBlock.c @@ -137,10 +137,10 @@ void sub_08099910(BigIceBlockEntity* this) { switch (uVar2) { default: - SetTile(0x4022, position - 0x41, super->collisionLayer); - SetTile(0x4022, position - 0x40, super->collisionLayer); - SetTile(0x4022, position - 1, super->collisionLayer); - SetTile(0x4022, position, super->collisionLayer); + SetBottomTile(0x4022, position - 0x41, super->collisionLayer); + SetBottomTile(0x4022, position - 0x40, super->collisionLayer); + SetBottomTile(0x4022, position - 1, super->collisionLayer); + SetBottomTile(0x4022, position, super->collisionLayer); break; case 1: iVar1 = sub_080B1AE0(position - 0x41, super->collisionLayer); @@ -148,27 +148,27 @@ void sub_08099910(BigIceBlockEntity* this) { if (iVar1 == 0x12) { uVar3 = 0x4079; } - SetTile(uVar3, position - 0x41, super->collisionLayer); - SetTile(0x4022, position - 0x40, super->collisionLayer); + SetBottomTile(uVar3, position - 0x41, super->collisionLayer); + SetBottomTile(0x4022, position - 0x40, super->collisionLayer); iVar1 = sub_080B1AE0(position - 0x3f, super->collisionLayer); uVar3 = 0x4025; if (iVar1 == 0x12) { uVar3 = 0x407b; } - SetTile(uVar3, position - 0x3f, super->collisionLayer); + SetBottomTile(uVar3, position - 0x3f, super->collisionLayer); iVar1 = sub_080B1AE0(position - 1, super->collisionLayer); uVar3 = 0x4024; if (iVar1 == 0x12) { uVar3 = 0x4079; } - SetTile(uVar3, position - 1, super->collisionLayer); - SetTile(0x4022, position, super->collisionLayer); + SetBottomTile(uVar3, position - 1, super->collisionLayer); + SetBottomTile(0x4022, position, super->collisionLayer); iVar1 = sub_080B1AE0(position + 1, super->collisionLayer); uVar3 = 0x4025; if (iVar1 == 0x12) { uVar3 = 0x407b; } - SetTile(uVar3, position + 1, super->collisionLayer); + SetBottomTile(uVar3, position + 1, super->collisionLayer); return; break; case 2: @@ -177,27 +177,27 @@ void sub_08099910(BigIceBlockEntity* this) { if (iVar1 == 0x12) { uVar3 = 0x4077; } - SetTile(uVar3, position - 0x41, super->collisionLayer); + SetBottomTile(uVar3, position - 0x41, super->collisionLayer); iVar1 = sub_080B1AE0(position - 0x40, super->collisionLayer); uVar3 = 0x4023; if (iVar1 == 0x12) { uVar3 = 0x4077; } - SetTile(uVar3, position - 0x40, super->collisionLayer); - SetTile(0x4022, position - 1, super->collisionLayer); - SetTile(0x4022, position, super->collisionLayer); + SetBottomTile(uVar3, position - 0x40, super->collisionLayer); + SetBottomTile(0x4022, position - 1, super->collisionLayer); + SetBottomTile(0x4022, position, super->collisionLayer); iVar1 = sub_080B1AE0(position + 0x3f, super->collisionLayer); uVar3 = 0x4026; if (iVar1 == 0x12) { uVar3 = 0x407c; } - SetTile(uVar3, position + 0x3f, super->collisionLayer); + SetBottomTile(uVar3, position + 0x3f, super->collisionLayer); iVar1 = sub_080B1AE0(position + 0x40, super->collisionLayer); uVar3 = 0x4026; if (iVar1 == 0x12) { uVar3 = 0x407c; } - SetTile(uVar3, position + 0x40, super->collisionLayer); + SetBottomTile(uVar3, position + 0x40, super->collisionLayer); break; case 3: iVar1 = sub_080B1AE0(position - 0x41, super->collisionLayer); @@ -205,50 +205,50 @@ void sub_08099910(BigIceBlockEntity* this) { if (iVar1 == 0x12) { uVar3 = 0x4075; } - SetTile(uVar3, position - 0x41, super->collisionLayer); + SetBottomTile(uVar3, position - 0x41, super->collisionLayer); iVar1 = sub_080B1AE0(position - 0x40, super->collisionLayer); uVar3 = 0x4023; if (iVar1 == 0x12) { uVar3 = 0x4077; } - SetTile(uVar3, position - 0x40, super->collisionLayer); + SetBottomTile(uVar3, position - 0x40, super->collisionLayer); iVar1 = sub_080B1AE0(position - 0x3f, super->collisionLayer); uVar3 = 0x4028; if (iVar1 == 0x12) { uVar3 = 0x4076; } - SetTile(uVar3, position - 0x3f, super->collisionLayer); + SetBottomTile(uVar3, position - 0x3f, super->collisionLayer); iVar1 = sub_080B1AE0(position - 1, super->collisionLayer); uVar3 = 0x4024; if (iVar1 == 0x12) { uVar3 = 0x4079; } - SetTile(uVar3, position - 1, super->collisionLayer); - SetTile(0x4022, position, super->collisionLayer); + SetBottomTile(uVar3, position - 1, super->collisionLayer); + SetBottomTile(0x4022, position, super->collisionLayer); iVar1 = sub_080B1AE0(position + 1, super->collisionLayer); uVar3 = 0x4025; if (iVar1 == 0x12) { uVar3 = 0x407b; } - SetTile(uVar3, position + 1, super->collisionLayer); + SetBottomTile(uVar3, position + 1, super->collisionLayer); iVar1 = sub_080B1AE0(position + 0x3f, super->collisionLayer); uVar3 = 0x4029; if (iVar1 == 0x12) { uVar3 = 0x4078; } - SetTile(uVar3, position + 0x3f, super->collisionLayer); + SetBottomTile(uVar3, position + 0x3f, super->collisionLayer); iVar1 = sub_080B1AE0(position + 0x40, super->collisionLayer); uVar3 = 0x4026; if (iVar1 == 0x12) { uVar3 = 0x407c; } - SetTile(uVar3, position + 0x40, super->collisionLayer); + SetBottomTile(uVar3, position + 0x40, super->collisionLayer); iVar1 = sub_080B1AE0(position + 0x41, super->collisionLayer); uVar3 = 0x402a; if (iVar1 == 0x12) { uVar3 = 0x407a; } - SetTile(uVar3, position + 0x41, super->collisionLayer); + SetBottomTile(uVar3, position + 0x41, super->collisionLayer); break; } } diff --git a/src/object/bigPushableLever.c b/src/object/bigPushableLever.c index e4110703..10dc9367 100644 --- a/src/object/bigPushableLever.c +++ b/src/object/bigPushableLever.c @@ -50,8 +50,8 @@ void BigPushableLever_Init(BigPushableLeverEntity* this) { void BigPushableLever_Idle(BigPushableLeverEntity* this) { if (BigPushableLever_ShouldStartPushing(this)) { super->action = PUSHING; - SetTile(this->tileIndexUpper, this->tilePositionUpper, super->collisionLayer); - SetTile(this->tileIndexLower, this->tilePositionLower, super->collisionLayer); + SetBottomTile(this->tileIndexUpper, this->tilePositionUpper, super->collisionLayer); + SetBottomTile(this->tileIndexLower, this->tilePositionLower, super->collisionLayer); EnqueueSFX(SFX_132); RequestPriorityDuration(super, 30); if (PlayerCanBeMoved()) { @@ -90,8 +90,8 @@ void BigPushableLever_SetTiles(BigPushableLeverEntity* this) { this->tilePositionLower = this->tilePositionUpper - 0x40; this->tileIndexUpper = GetTileIndex(this->tilePositionUpper, super->collisionLayer); this->tileIndexLower = GetTileIndex(this->tilePositionLower, super->collisionLayer); - SetTile(0x4057, this->tilePositionUpper, super->collisionLayer); - SetTile(0x4058, this->tilePositionLower, super->collisionLayer); + SetBottomTile(0x4057, this->tilePositionUpper, super->collisionLayer); + SetBottomTile(0x4058, this->tilePositionLower, super->collisionLayer); InitializeAnimation(super, 1); } else { super->type2 = 1; @@ -99,8 +99,8 @@ void BigPushableLever_SetTiles(BigPushableLeverEntity* this) { this->tilePositionLower = this->tilePositionUpper - 1; this->tileIndexUpper = GetTileIndex(this->tilePositionUpper, super->collisionLayer); this->tileIndexLower = GetTileIndex(this->tilePositionLower, super->collisionLayer); - SetTile(0x4055, this->tilePositionUpper, super->collisionLayer); - SetTile(0x4056, this->tilePositionLower, super->collisionLayer); + SetBottomTile(0x4055, this->tilePositionUpper, super->collisionLayer); + SetBottomTile(0x4056, this->tilePositionLower, super->collisionLayer); InitializeAnimation(super, 0); } } @@ -111,7 +111,7 @@ bool32 BigPushableLever_ShouldStartPushing(BigPushableLeverEntity* this) { return TRUE; } BigPushableLever_CalculateSpriteOffsets(this); - SetTile(gUnk_081236E8[super->type2], this->tilePositionLower, super->collisionLayer); + SetBottomTile(gUnk_081236E8[super->type2], this->tilePositionLower, super->collisionLayer); } else { this->timer = 60; super->spriteOffsetX = 0; diff --git a/src/object/board.c b/src/object/board.c index dbdcabea..be77640a 100644 --- a/src/object/board.c +++ b/src/object/board.c @@ -53,7 +53,7 @@ void Board_Init(BoardEntity* this) { UpdateSpriteForCollisionLayer(super); super->spritePriority.b0 = 6; if (super->type == 0) { - SetTile(0x4074, this->tile - 0x40, super->collisionLayer); + SetBottomTile(0x4074, this->tile - 0x40, super->collisionLayer); } sub_08098BE8(this); } diff --git a/src/object/bollard.c b/src/object/bollard.c index 6a5d45cc..b21636c5 100644 --- a/src/object/bollard.c +++ b/src/object/bollard.c @@ -58,7 +58,7 @@ void Bollard_Action1(BollardEntity* this) { } super->action = 2; InitializeAnimation(super, 3); - SetTile(this->tileIndex, this->tile, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tile, super->collisionLayer); EnqueueSFX(SFX_1A5); } @@ -95,7 +95,7 @@ void sub_0808B3AC(BollardEntity* this) { this->tile = COORD_TO_TILE(super); this->tileIndex = GetTileIndex(this->tile, super->collisionLayer); this->unk74 = sub_080B1B44(this->tile, super->collisionLayer); - SetTile(0x400b, this->tile, super->collisionLayer); + SetBottomTile(0x400b, this->tile, super->collisionLayer); } void sub_0808B41C(BollardEntity* this) { diff --git a/src/object/bossDoor.c b/src/object/bossDoor.c index 8502dd14..0a408f4e 100644 --- a/src/object/bossDoor.c +++ b/src/object/bossDoor.c @@ -177,28 +177,28 @@ void sub_0808C500(BossDoorEntity* this) { this->unk_78 = GetTileIndex(this->unk_74 - 1, super->collisionLayer); this->unk_7a = GetTileIndex(this->unk_74, super->collisionLayer); this->unk_7c = GetTileIndex(this->unk_74 + 1, super->collisionLayer); - SetTile(0x4022, this->unk_74 - 1, super->collisionLayer); - SetTile(0x4022, this->unk_74, super->collisionLayer); - SetTile(0x4022, this->unk_74 + 1, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74 - 1, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74 + 1, super->collisionLayer); } else { this->unk_78 = GetTileIndex(this->unk_74 - 0x40, super->collisionLayer); this->unk_7a = GetTileIndex(this->unk_74, super->collisionLayer); this->unk_7c = GetTileIndex(this->unk_74 + 0x40, super->collisionLayer); - SetTile(0x4022, this->unk_74 - 0x40, super->collisionLayer); - SetTile(0x4022, this->unk_74, super->collisionLayer); - SetTile(0x4022, this->unk_74 + 0x40, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74 - 0x40, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74 + 0x40, super->collisionLayer); } } void sub_0808C5D0(BossDoorEntity* this) { if ((this->unk_76 == 0) || (this->unk_76 == 2)) { - SetTile(this->unk_78, this->unk_74 - 1, super->collisionLayer); - SetTile(this->unk_7a, this->unk_74, super->collisionLayer); - SetTile(this->unk_7c, this->unk_74 + 1, super->collisionLayer); + SetBottomTile(this->unk_78, this->unk_74 - 1, super->collisionLayer); + SetBottomTile(this->unk_7a, this->unk_74, super->collisionLayer); + SetBottomTile(this->unk_7c, this->unk_74 + 1, super->collisionLayer); } else { - SetTile(this->unk_78, this->unk_74 - 0x40, super->collisionLayer); - SetTile(this->unk_7a, this->unk_74, super->collisionLayer); - SetTile(this->unk_7c, this->unk_74 + 0x40, super->collisionLayer); + SetBottomTile(this->unk_78, this->unk_74 - 0x40, super->collisionLayer); + SetBottomTile(this->unk_7a, this->unk_74, super->collisionLayer); + SetBottomTile(this->unk_7c, this->unk_74 + 0x40, super->collisionLayer); } } diff --git a/src/object/bush.c b/src/object/bush.c index 38371e1e..4e086347 100644 --- a/src/object/bush.c +++ b/src/object/bush.c @@ -68,7 +68,7 @@ void Bush_Init(BushEntity* this) { super->hitbox = (Hitbox*)&gUnk_081205B4; this->unk_72 = 0; this->unk_70 = GetTileIndex(COORD_TO_TILE(super), super->collisionLayer); - SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); InitializeAnimation(super, gUnk_08120588[super->type].unk_0); } diff --git a/src/object/button.c b/src/object/button.c index ad621bc7..f0192ac7 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -105,7 +105,7 @@ void Button_Action4(ButtonEntity* this) { super->timer--; if (super->subtimer != 0) { super->subtimer = 0; - SetTile(0x4035, this->unk_74, super->collisionLayer); + SetBottomTile(0x4035, this->unk_74, super->collisionLayer); } if (sub_08081CB0(this)) { super->action = 3; @@ -230,7 +230,7 @@ void sub_08081E6C(ButtonEntity* this) { if (tile < 0x4000) return; - r1 = GetLayerByIndex(r5); + r1 = GetTileBuffer(r5); r4 = (super->type == 0 ? 0x7a : 0x78); tmp = r1->metatiles; tmp = tmp + (r1->unkData2[r4] << 2); @@ -239,7 +239,7 @@ void sub_08081E6C(ButtonEntity* this) { if (sub_08081F00((u32*)tmp2, (u32*)tmp)) return; SetTileType(r4, r6, r5); - SetTile(tile, r6, r5); + SetBottomTile(tile, r6, r5); } u32 sub_08081F00(u32* unk1, u32* unk2) { @@ -279,7 +279,7 @@ bool32 sub_08081F7C(ButtonEntity* this, u32 r7) { sub_08081F24(super); SoundReq(SFX_BUTTON_PRESS); if (this->unk_70 != 0xFFFF) - SetTile(this->unk_70, this->unk_74, super->collisionLayer); + SetBottomTile(this->unk_70, this->unk_74, super->collisionLayer); return FALSE; } } diff --git a/src/object/cabinFurniture.c b/src/object/cabinFurniture.c index e23df88c..2a9979ab 100644 --- a/src/object/cabinFurniture.c +++ b/src/object/cabinFurniture.c @@ -43,38 +43,38 @@ void CabinFurniture_Init(CabinFurnitureEntity* this) { super->spritePriority.b0 = 6; uVar7 = this->tile; uVar6 = uVar7 - 1; - SetTile(0x4022, uVar6, uVar1); - SetTile(0x4022, uVar7, uVar1); - SetTile(0x4022, uVar7 + 1, uVar1); - SetTile(0x4022, uVar7 + 0x3f, uVar1); - SetTile(0x4022, uVar7 + 0x40, uVar1); - SetTile(0x4022, uVar7 + 0x41, uVar1); - SetTile(0x403d, uVar7 - 0x41, uVar1); - SetTile(0x403d, uVar7 - 0x40, uVar1); - SetTile(0x4026, uVar7 - 0x3f, uVar1); - SetTile(0x4026, uVar7 - 0x81, uVar1); - SetTile(0x4026, uVar7 - 0x80, uVar1); + SetBottomTile(0x4022, uVar6, uVar1); + SetBottomTile(0x4022, uVar7, uVar1); + SetBottomTile(0x4022, uVar7 + 1, uVar1); + SetBottomTile(0x4022, uVar7 + 0x3f, uVar1); + SetBottomTile(0x4022, uVar7 + 0x40, uVar1); + SetBottomTile(0x4022, uVar7 + 0x41, uVar1); + SetBottomTile(0x403d, uVar7 - 0x41, uVar1); + SetBottomTile(0x403d, uVar7 - 0x40, uVar1); + SetBottomTile(0x4026, uVar7 - 0x3f, uVar1); + SetBottomTile(0x4026, uVar7 - 0x81, uVar1); + SetBottomTile(0x4026, uVar7 - 0x80, uVar1); break; case 1: super->action = 1; uVar6 = this->tile; - SetTile(0x4022, uVar6, uVar1); - SetTile(0x4022, uVar6 + 0x40, uVar1); - SetTile(0x4025, uVar6 + 0x41, uVar1); + SetBottomTile(0x4022, uVar6, uVar1); + SetBottomTile(0x4022, uVar6 + 0x40, uVar1); + SetBottomTile(0x4025, uVar6 + 0x41, uVar1); if (CheckLocalFlag(0x4f) == 0) { - SetTile(0x402f, uVar6 + 1, uVar1); + SetBottomTile(0x402f, uVar6 + 1, uVar1); } else { - SetTile(0x402d, uVar6 + 1, uVar1); + SetBottomTile(0x402d, uVar6 + 1, uVar1); } break; case 2: super->action = 1; uVar7 = this->tile; uVar6 = uVar7 - 0x41; - SetTile(0x4022, uVar6, uVar1); - SetTile(0x4022, uVar7 - 0x40, uVar1); - SetTile(0x4022, uVar7 - 1, uVar1); - SetTile(0x4022, uVar7, uVar1); + SetBottomTile(0x4022, uVar6, uVar1); + SetBottomTile(0x4022, uVar7 - 0x40, uVar1); + SetBottomTile(0x4022, uVar7 - 1, uVar1); + SetBottomTile(0x4022, uVar7, uVar1); break; } } diff --git a/src/object/carlovObject.c b/src/object/carlovObject.c index 2a093491..ea7d30a6 100644 --- a/src/object/carlovObject.c +++ b/src/object/carlovObject.c @@ -97,7 +97,7 @@ void CarlovObject_Type1Init(CarlovObjectEntity* this) { if (super->timer == 0) { super->action = 1; super->subtimer = 120; - SetTile(0x4022, this->unk_76, super->collisionLayer); + SetBottomTile(0x4022, this->unk_76, super->collisionLayer); } else { super->action = 3; super->spriteSettings.draw = 0; @@ -111,7 +111,7 @@ void CarlovObject_Type1Action1(CarlovObjectEntity* this) { super->action = 2; super->timer = 7; super->direction = 0; - SetTile(this->unk_74, this->unk_76, super->collisionLayer); + SetBottomTile(this->unk_74, this->unk_76, super->collisionLayer); EnqueueSFX(SFX_10B); } } @@ -140,7 +140,7 @@ void CarlovObject_Type1Action4(CarlovObjectEntity* this) { super->action = 5; sub_08083814(super, 2); EnqueueSFX(SFX_10B); - SetTile(0x4022, this->unk_76, super->collisionLayer); + SetBottomTile(0x4022, this->unk_76, super->collisionLayer); } } diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index cdadc583..b6512f06 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -54,13 +54,13 @@ void CrenelBeanSprout_Init(CrenelBeanSproutEntity* this) { if (CheckGlobalFlag(WATERBEAN_OUT)) { if (CheckGlobalFlag(WATERBEAN_PUT) == 0) { PositionRelative(&gPlayerEntity.base, super, 0, 0x10000); - SetTile(0x4022, 0xdc, super->collisionLayer); + SetBottomTile(0x4022, 0xdc, super->collisionLayer); } else { if (CheckLocalFlag(super->type2) == 0) { InitializeAnimation(super, 10); super->y.HALF.HI += 4; super->action = 4; - SetTile(0x403b, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x403b, COORD_TO_TILE(super), super->collisionLayer); return; } super->type2 = 0; @@ -107,7 +107,7 @@ void CrenelBeanSprout_Init(CrenelBeanSproutEntity* this) { InitializeAnimation(super, 0xb); super->y.HALF.HI += 4; super->action = 4; - SetTile(0x4032, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4032, COORD_TO_TILE(super), super->collisionLayer); return; } else { super->type2 = 0; @@ -329,5 +329,5 @@ void sub_08096A78(CrenelBeanSproutEntity* this) { SnapToTile(super); super->y.HALF.HI += 4; super->action = 3; - SetTile(0x403b, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x403b, COORD_TO_TILE(super), super->collisionLayer); } diff --git a/src/object/doubleBookshelf.c b/src/object/doubleBookshelf.c index cbc27c93..d1b0c1fe 100644 --- a/src/object/doubleBookshelf.c +++ b/src/object/doubleBookshelf.c @@ -98,39 +98,39 @@ void sub_0809B0B0(DoubleBookshelfEntity* this) { case 0: this->unk_84 = 0; this->unk_82 = position + 2; - SetTile(0x4082, position - 1, layer); - SetTile(0x4022, position, layer); - SetTile(0x4022, position + 1, layer); - SetTile(0x4022, position + 2, layer); + SetBottomTile(0x4082, position - 1, layer); + SetBottomTile(0x4022, position, layer); + SetBottomTile(0x4022, position + 1, layer); + SetBottomTile(0x4022, position + 2, layer); break; case 1: this->unk_84 = 1; this->unk_82 = position; - SetTile(0x405f, position, layer); - SetTile(0x4022, position + 1, layer); - SetTile(0x4022, position + 2, layer); - SetTile(0x4082, position + 3, layer); + SetBottomTile(0x405f, position, layer); + SetBottomTile(0x4022, position + 1, layer); + SetBottomTile(0x4022, position + 2, layer); + SetBottomTile(0x4082, position + 3, layer); break; case 2: this->unk_84 = 1; this->unk_82 = position; - SetTile(0x4082, position + 3, layer); - SetTile(0x4022, position + 2, layer); - SetTile(0x405f, position, layer); + SetBottomTile(0x4082, position + 3, layer); + SetBottomTile(0x4022, position + 2, layer); + SetBottomTile(0x405f, position, layer); SetFlag(((DoubleBookshelfEntity*)super->parent)->unk_86); break; case 3: this->unk_84 = 0; this->unk_82 = position + 2; - SetTile(0x4082, position - 1, layer); - SetTile(0x4022, position, layer); - SetTile(0x405f, position + 2, layer); + SetBottomTile(0x4082, position - 1, layer); + SetBottomTile(0x4022, position, layer); + SetBottomTile(0x405f, position + 2, layer); ClearFlag(((DoubleBookshelfEntity*)super->parent)->unk_86); break; case 4: - SetTile(0x4022, position, layer); - SetTile(0x4022, position + 1, layer); - SetTile(0x4022, position + 2, layer); + SetBottomTile(0x4022, position, layer); + SetBottomTile(0x4022, position + 1, layer); + SetBottomTile(0x4022, position + 2, layer); break; } } @@ -157,7 +157,7 @@ void sub_0809B274(DoubleBookshelfEntity* this) { case 1: if (player->x.HALF.HI + 0x1c > super->x.HALF.HI) { this->unk_84 = 2; - SetTile(0x4022, this->unk_80 + 2, 1); + SetBottomTile(0x4022, this->unk_80 + 2, 1); sub_0809B358((DoubleBookshelfEntity*)super->child); return; } @@ -182,7 +182,7 @@ void sub_0809B334(DoubleBookshelfEntity* this) { s32 index; u32 position = this->unk_80 - 0x81; for (index = 2; index >= 0; index--, position++) { - SetTile(0x4026, position, 1); + SetBottomTile(0x4026, position, 1); } } @@ -194,7 +194,7 @@ void sub_0809B358(DoubleBookshelfEntity* this) { const u16* array = &gUnk_08123D68[this->unk_84]; u32 position = this->unk_80 - 0x82; for (index = 4; index >= 0;) { - SetTile(*array, position, 1); + SetBottomTile(*array, position, 1); index--; position++; array += 2; diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c index d975556a..d21c51cd 100644 --- a/src/object/figurineDevice.c +++ b/src/object/figurineDevice.c @@ -305,9 +305,9 @@ void sub_08087F58(FigurineDeviceEntity* this) { switch (super->type) { case 0: case 1: - SetTile(0x4022, this->unk_78 - 1, 1); - SetTile(0x4022, this->unk_78, 1); - SetTile(0x4022, this->unk_78 + 1, 1); + SetBottomTile(0x4022, this->unk_78 - 1, 1); + SetBottomTile(0x4022, this->unk_78, 1); + SetBottomTile(0x4022, this->unk_78 + 1, 1); break; } } diff --git a/src/object/fireplace.c b/src/object/fireplace.c index 98cfa2a6..4e463979 100644 --- a/src/object/fireplace.c +++ b/src/object/fireplace.c @@ -35,7 +35,7 @@ void Fireplace_Init(FireplaceEntity* this) { DeleteThisEntity(); } else { sub_0807B7D8(0x30b, TILE(super->x.HALF.HI, super->y.HALF.HI), 2); - SetTile(0x4061, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetBottomTile(0x4061, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); } Fireplace_Action1(this); } @@ -57,6 +57,6 @@ void sub_0809B7C0(FireplaceEntity* this) { void sub_0809B7DC(FireplaceEntity* this) { sub_0807B7D8(0xc3 << 2, TILE(super->x.HALF.HI, super->y.HALF.HI), 2); - SetTile(0x4062, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetBottomTile(0x4062, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); super->timer = 1; } diff --git a/src/object/frozenWaterElement.c b/src/object/frozenWaterElement.c index dd40d3ab..e9588e4e 100644 --- a/src/object/frozenWaterElement.c +++ b/src/object/frozenWaterElement.c @@ -113,33 +113,33 @@ void FrozenWaterElement_Action2(FrozenWaterElementEntity* this) { void sub_0809C0A8(FrozenWaterElementEntity* this) { u32 position = COORD_TO_TILE(super); - SetTile(0x4022, position - 0x41, super->collisionLayer); - SetTile(0x4022, position - 0x40, super->collisionLayer); - SetTile(0x4022, position - 0x3f, super->collisionLayer); - SetTile(0x4022, position - 2, super->collisionLayer); - SetTile(0x4022, position - 1, super->collisionLayer); - SetTile(0x4022, position, super->collisionLayer); - SetTile(0x4022, position + 1, super->collisionLayer); - SetTile(0x4022, position + 2, super->collisionLayer); - SetTile(0x4022, position + 0x3e, super->collisionLayer); - SetTile(0x4022, position + 0x3f, super->collisionLayer); - SetTile(0x4022, position + 0x40, super->collisionLayer); - SetTile(0x4022, position + 0x41, super->collisionLayer); - SetTile(0x4022, position + 0x42, super->collisionLayer); - SetTile(0x4022, position + 0x7f, super->collisionLayer); - SetTile(0x4022, position + 0x80, super->collisionLayer); - SetTile(0x4022, position + 0x81, super->collisionLayer); - SetTile(0x4022, position + 0x13f, super->collisionLayer); - SetTile(0x4022, position + 0x140, super->collisionLayer); - SetTile(0x4022, position + 0x141, super->collisionLayer); - SetTile(0x4022, position + 0x17f, super->collisionLayer); - SetTile(0x4022, position + 0x181, super->collisionLayer); - SetTile(0x4022, position + 0x1bd, super->collisionLayer); - SetTile(0x4022, position + 0x1be, super->collisionLayer); - SetTile(0x4022, position + 0x1bf, super->collisionLayer); - SetTile(0x4022, position + 0x1c1, super->collisionLayer); - SetTile(0x4022, position + 0x1c2, super->collisionLayer); - SetTile(0x4022, position + 0x1c3, super->collisionLayer); + SetBottomTile(0x4022, position - 0x41, super->collisionLayer); + SetBottomTile(0x4022, position - 0x40, super->collisionLayer); + SetBottomTile(0x4022, position - 0x3f, super->collisionLayer); + SetBottomTile(0x4022, position - 2, super->collisionLayer); + SetBottomTile(0x4022, position - 1, super->collisionLayer); + SetBottomTile(0x4022, position, super->collisionLayer); + SetBottomTile(0x4022, position + 1, super->collisionLayer); + SetBottomTile(0x4022, position + 2, super->collisionLayer); + SetBottomTile(0x4022, position + 0x3e, super->collisionLayer); + SetBottomTile(0x4022, position + 0x3f, super->collisionLayer); + SetBottomTile(0x4022, position + 0x40, super->collisionLayer); + SetBottomTile(0x4022, position + 0x41, super->collisionLayer); + SetBottomTile(0x4022, position + 0x42, super->collisionLayer); + SetBottomTile(0x4022, position + 0x7f, super->collisionLayer); + SetBottomTile(0x4022, position + 0x80, super->collisionLayer); + SetBottomTile(0x4022, position + 0x81, super->collisionLayer); + SetBottomTile(0x4022, position + 0x13f, super->collisionLayer); + SetBottomTile(0x4022, position + 0x140, super->collisionLayer); + SetBottomTile(0x4022, position + 0x141, super->collisionLayer); + SetBottomTile(0x4022, position + 0x17f, super->collisionLayer); + SetBottomTile(0x4022, position + 0x181, super->collisionLayer); + SetBottomTile(0x4022, position + 0x1bd, super->collisionLayer); + SetBottomTile(0x4022, position + 0x1be, super->collisionLayer); + SetBottomTile(0x4022, position + 0x1bf, super->collisionLayer); + SetBottomTile(0x4022, position + 0x1c1, super->collisionLayer); + SetBottomTile(0x4022, position + 0x1c2, super->collisionLayer); + SetBottomTile(0x4022, position + 0x1c3, super->collisionLayer); } void sub_0809C23C(FrozenWaterElementEntity* this) { diff --git a/src/object/furniture.c b/src/object/furniture.c index 31d06f14..7a185287 100644 --- a/src/object/furniture.c +++ b/src/object/furniture.c @@ -217,14 +217,14 @@ static void FurnitureInit(FurnitureEntity* this) { break; case 0x40: super->y.HALF.HI = (super->y.HALF.HI & ~0xF) | 4; - SetTile(0x4017, this->tile - 128, 1); - SetTile(0x4017, this->tile - 64, 1); + SetBottomTile(0x4017, this->tile - 128, 1); + SetBottomTile(0x4017, this->tile - 64, 1); break; case 0x80: super->frameIndex = 0; super->y.HALF.HI = (super->y.HALF.HI & ~0xF) | 6; this->tile = COORD_TO_TILE(super); - SetTile(0x4026, this->tile, super->collisionLayer); + SetBottomTile(0x4026, this->tile, super->collisionLayer); break; case 0x200: break; @@ -260,8 +260,8 @@ static void FurnitureInit(FurnitureEntity* this) { tile = this->tile - 129; cnt = super->type != 26 ? 3 : 2; for (i = 0; i < cnt; ++i, ++tile) { - SetTile(0x4026, tile, 2); - SetTile(0x4026, tile, 1); + SetBottomTile(0x4026, tile, 2); + SetBottomTile(0x4026, tile, 1); sub_080001D0(0, tile + 64, 1); } break; @@ -287,22 +287,22 @@ static void FurnitureInit(FurnitureEntity* this) { case STAIRCASE: super->collisionLayer = 1; super->spriteOrientation.flipY = 2; - SetTile(0x4074, this->tile - 64, super->collisionLayer); + SetBottomTile(0x4074, this->tile - 64, super->collisionLayer); sub_080001D0(63, this->tile - 64, super->collisionLayer); - SetTile(0x4017, this->tile, super->collisionLayer); - SetTile(0x4017, this->tile + 64, super->collisionLayer); + SetBottomTile(0x4017, this->tile, super->collisionLayer); + SetBottomTile(0x4017, this->tile + 64, super->collisionLayer); break; case MINISH_CHEESE: if (super->type2 != 0) super->spriteOffsetX = -4; break; case WOODEN_TABLE: - SetTile(0x4023, this->tile - 65, super->collisionLayer); - SetTile(0x4023, this->tile - 64, super->collisionLayer); - SetTile(0x4023, this->tile - 63, super->collisionLayer); + SetBottomTile(0x4023, this->tile - 65, super->collisionLayer); + SetBottomTile(0x4023, this->tile - 64, super->collisionLayer); + SetBottomTile(0x4023, this->tile - 63, super->collisionLayer); break; case LOW_BOOKSHELF: - SetTile(0x4022, this->tile + 65, super->collisionLayer); + SetBottomTile(0x4022, this->tile + 65, super->collisionLayer); } } @@ -340,9 +340,9 @@ static void FurnitureUpdate(FurnitureEntity* this) { case 0x80: if (gPlayerEntity.base.y.HALF.HI < super->y.HALF.HI + 8) { if (gPlayerState.floor_type != SURFACE_LADDER && GetTileTypeByEntity(super) == 0x4017) { - SetTile(0x4026, this->tile, super->collisionLayer); - SetTile(0x403D, this->tile - 64, super->collisionLayer); - SetTile(0x403D, this->tile - 128, super->collisionLayer); + SetBottomTile(0x4026, this->tile, super->collisionLayer); + SetBottomTile(0x403D, this->tile - 64, super->collisionLayer); + SetBottomTile(0x403D, this->tile - 128, super->collisionLayer); } } else { if (gPlayerEntity.base.collisionLayer & 2) { @@ -350,9 +350,9 @@ static void FurnitureUpdate(FurnitureEntity* this) { UpdateSpriteForCollisionLayer(&gPlayerEntity.base); } if (GetTileTypeByEntity(super) != 0x4017) { - SetTile(0x4017, this->tile, super->collisionLayer); - SetTile(0x4017, this->tile - 64, super->collisionLayer); - SetTile(0x4014, this->tile - 128, super->collisionLayer); + SetBottomTile(0x4017, this->tile, super->collisionLayer); + SetBottomTile(0x4017, this->tile - 64, super->collisionLayer); + SetBottomTile(0x4014, this->tile - 128, super->collisionLayer); } } break; @@ -377,28 +377,28 @@ static void sub_08090B6C(FurnitureEntity* this) { num = 2; } for (i = -num; i <= num; ++i) { - SetTile(0x4022, tile + i, cl); + SetBottomTile(0x4022, tile + i, cl); } if (px & 8) { sub_08090CDC(0x4024, tile - i, cl); sub_08090CDC(0x4025, tile + i, cl); } else { - SetTile(0x4022, tile - i, cl); + SetBottomTile(0x4022, tile - i, cl); } break; case 1: num = w2 / 8; for (i = -num; i <= num; i++) { - SetTile(0x4022, tile + i, cl); + SetBottomTile(0x4022, tile + i, cl); } if (px & 8) { sub_08090CDC(0x4024, tile - i, cl); if (i != 0) { - SetTile(0x4022, tile + i, cl); + SetBottomTile(0x4022, tile + i, cl); } } else { if (i != 0) { - SetTile(0x4022, tile - i, cl); + SetBottomTile(0x4022, tile - i, cl); } sub_08090CDC(0x4025, tile + i, cl); } @@ -406,10 +406,10 @@ static void sub_08090B6C(FurnitureEntity* this) { case 2: num = w2 / 4; for (i = -num; i < num; ++i) { - SetTile(0x4022, tile + i, cl); + SetBottomTile(0x4022, tile + i, cl); } if (px & 8) { - SetTile(0x4022, tile + i, cl); + SetBottomTile(0x4022, tile + i, cl); } else { sub_08090CDC(0x4024, tile - i - 1, cl); sub_08090CDC(0x4025, tile + i, cl); @@ -418,7 +418,7 @@ static void sub_08090B6C(FurnitureEntity* this) { case 3: num = w2 / 4; for (i = -num; i <= num; ++i) { - SetTile(0x4022, tile + i, cl); + SetBottomTile(0x4022, tile + i, cl); } if (px & 8) { sub_08090CDC(0x4025, tile + i, cl); @@ -436,7 +436,7 @@ static void sub_08090CDC(u32 id, u32 pos, u32 layer) { u32 id2; if ((cur & 0x4000) == 0) { - SetTile(id, pos, layer); + SetBottomTile(id, pos, layer); } else { switch (cur) { case 0x4025: @@ -474,7 +474,7 @@ static void sub_08090CDC(u32 id, u32 pos, u32 layer) { default: return; } - SetTile(next, pos, layer); + SetBottomTile(next, pos, layer); } } diff --git a/src/object/gentariCurtain.c b/src/object/gentariCurtain.c index d980d400..a4c5e2a6 100644 --- a/src/object/gentariCurtain.c +++ b/src/object/gentariCurtain.c @@ -59,8 +59,8 @@ void GentariCurtain_Init(GentariCurtainEntity* this) { this->tile2 = COORD_TO_TILE_OFFSET(super, 0, -8); this->tileIndex = GetTileIndex(this->tile, 1); this->tileIndex2 = GetTileIndex(this->tile2, 1); - SetTile(0x4022, this->tile, 1); - SetTile(0x4022, this->tile2, 1); + SetBottomTile(0x4022, this->tile, 1); + SetBottomTile(0x4022, this->tile2, 1); InitAnimationForceUpdate(super, 0); } else { super->action = 1; @@ -80,8 +80,8 @@ void GentariCurtain_Action2(GentariCurtainEntity* this) { UpdateAnimationSingleFrame(super); if ((super->frame & ANIM_DONE) != 0) { super->action = 3; - SetTile(this->tileIndex, this->tile, 1); - SetTile(this->tileIndex2, this->tile2, 1); + SetBottomTile(this->tileIndex, this->tile, 1); + SetBottomTile(this->tileIndex2, this->tile2, 1); sub_08092214(this); sub_0809223C(this); InitAnimationForceUpdate(super, 1); diff --git a/src/object/giantBookLadder.c b/src/object/giantBookLadder.c index 1553723b..fb808a1b 100644 --- a/src/object/giantBookLadder.c +++ b/src/object/giantBookLadder.c @@ -50,33 +50,33 @@ void sub_0808E55C(GiantBookLadderEntity* this) { case 2: position = this->unk74; unaff_r9 = position - 0x101; - SetTile(0x408f, unaff_r9, super->collisionLayer); - SetTile(0x408f, position - 0x100, super->collisionLayer); - SetTile(0x406c, position - 0x102, super->collisionLayer); - SetTile(0x406d, position - 0xff, super->collisionLayer); + SetBottomTile(0x408f, unaff_r9, super->collisionLayer); + SetBottomTile(0x408f, position - 0x100, super->collisionLayer); + SetBottomTile(0x406c, position - 0x102, super->collisionLayer); + SetBottomTile(0x406d, position - 0xff, super->collisionLayer); type = super->type; uVar5 = 6; if (type != 0) { uVar5 = 4; - SetTile(0x4072, position + 0x3f, super->collisionLayer); - SetTile(0x4072, position + 0x40, super->collisionLayer); - SetTile(0x4072, position + 0x7f, super->collisionLayer); - SetTile(0x4072, position + 0x80, super->collisionLayer); + SetBottomTile(0x4072, position + 0x3f, super->collisionLayer); + SetBottomTile(0x4072, position + 0x40, super->collisionLayer); + SetBottomTile(0x4072, position + 0x7f, super->collisionLayer); + SetBottomTile(0x4072, position + 0x80, super->collisionLayer); } break; case 1: position = this->unk74; unaff_r9 = position - 1; - SetTile(0x408e, unaff_r9, super->collisionLayer); - SetTile(0x408e, position, super->collisionLayer); + SetBottomTile(0x408e, unaff_r9, super->collisionLayer); + SetBottomTile(0x408e, position, super->collisionLayer); uVar5 = 2; break; } for (uVar4 = 0; uVar4 < uVar5; uVar4++) { unaff_r9 += 0x40; - SetTile(0x408e, unaff_r9, super->collisionLayer); - SetTile(0x408e, unaff_r9 + 1, super->collisionLayer); + SetBottomTile(0x408e, unaff_r9, super->collisionLayer); + SetBottomTile(0x408e, unaff_r9 + 1, super->collisionLayer); } } diff --git a/src/object/giantLeaf.c b/src/object/giantLeaf.c index 5c6b1d3c..3ef82f75 100644 --- a/src/object/giantLeaf.c +++ b/src/object/giantLeaf.c @@ -35,6 +35,6 @@ void sub_0808D618(Entity* this) { ((((this->y.HALF.HI - gRoomControls.origin_y) >> 4) & 0x3F) * 64); for (i = 0; i < 13; i++) { - SetTile(16500, tilePos + arr[i], 1); + SetBottomTile(16500, tilePos + arr[i], 1); } } diff --git a/src/object/giantRock2.c b/src/object/giantRock2.c index 2f5765da..4370663b 100644 --- a/src/object/giantRock2.c +++ b/src/object/giantRock2.c @@ -38,10 +38,10 @@ void GiantRock2_Init(GiantRock2Entity* this) { position = (this->tile - 0x80); tileIndex = 0x4022; for (index = 4; index > -1; index--) { - SetTile(tileIndex, position - 2, collisionLayer); - SetTile(tileIndex, position - 1, collisionLayer); - SetTile(tileIndex, position, collisionLayer); - SetTile(tileIndex, position + 1, collisionLayer); + SetBottomTile(tileIndex, position - 2, collisionLayer); + SetBottomTile(tileIndex, position - 1, collisionLayer); + SetBottomTile(tileIndex, position, collisionLayer); + SetBottomTile(tileIndex, position + 1, collisionLayer); position += 0x40; } } diff --git a/src/object/giantTwig.c b/src/object/giantTwig.c index 62deab7a..a308adf0 100644 --- a/src/object/giantTwig.c +++ b/src/object/giantTwig.c @@ -155,7 +155,7 @@ void sub_08093984(GiantTwigEntity* this) { } for (index = 0; index < 0x13; index++) { - SetTile(0x4074, array[index] + this->tilePosition, 1); + SetBottomTile(0x4074, array[index] + this->tilePosition, 1); } } @@ -174,47 +174,47 @@ void GiantTwig_Type3Idle(GiantTwigEntity* this) { void sub_08093A1C(GiantTwigEntity* this) { switch (super->type) { case 0: - SetTile(0x4024, this->tilePosition + 0x3c, super->collisionLayer); - SetTile(0x4022, this->tilePosition + 0x3d, super->collisionLayer); - SetTile(0x4022, this->tilePosition + 0x3e, super->collisionLayer); - SetTile(0x4029, this->tilePosition + 0x7c, super->collisionLayer); - SetTile(0x4026, this->tilePosition + 0x7d, super->collisionLayer); - SetTile(0x4026, this->tilePosition + 0x7e, super->collisionLayer); - SetTile(0x403d, this->tilePosition + 0x40, super->collisionLayer); - SetTile(0x403d, this->tilePosition + 0x80, super->collisionLayer); - SetTile(0x4027, this->tilePosition + 0x41, super->collisionLayer); - SetTile(0x4023, this->tilePosition + 0x42, super->collisionLayer); - SetTile(0x406d, this->tilePosition + 0x43, super->collisionLayer); - SetTile(0x4029, this->tilePosition + 0x81, super->collisionLayer); - SetTile(0x4026, this->tilePosition + 0x82, super->collisionLayer); - SetTile(0x4026, this->tilePosition + 0x83, super->collisionLayer); + SetBottomTile(0x4024, this->tilePosition + 0x3c, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition + 0x3d, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition + 0x3e, super->collisionLayer); + SetBottomTile(0x4029, this->tilePosition + 0x7c, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition + 0x7d, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition + 0x7e, super->collisionLayer); + SetBottomTile(0x403d, this->tilePosition + 0x40, super->collisionLayer); + SetBottomTile(0x403d, this->tilePosition + 0x80, super->collisionLayer); + SetBottomTile(0x4027, this->tilePosition + 0x41, super->collisionLayer); + SetBottomTile(0x4023, this->tilePosition + 0x42, super->collisionLayer); + SetBottomTile(0x406d, this->tilePosition + 0x43, super->collisionLayer); + SetBottomTile(0x4029, this->tilePosition + 0x81, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition + 0x82, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition + 0x83, super->collisionLayer); break; case 1: if ((super->type2 & 1) != 0) { - SetTile(0x406d, this->tilePosition - 0x81, super->collisionLayer); - SetTile(0x4022, this->tilePosition - 0x41, super->collisionLayer); - SetTile(0x4029, this->tilePosition - 2, super->collisionLayer); - SetTile(0x4026, this->tilePosition - 1, super->collisionLayer); - SetTile(0x4022, this->tilePosition, super->collisionLayer); - SetTile(0x406d, this->tilePosition + 1, super->collisionLayer); - SetTile(0x406e, this->tilePosition + 0x40, super->collisionLayer); - SetTile(0x4022, this->tilePosition + 0x41, super->collisionLayer); - SetTile(0x406d, this->tilePosition + 0x42, super->collisionLayer); + SetBottomTile(0x406d, this->tilePosition - 0x81, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition - 0x41, super->collisionLayer); + SetBottomTile(0x4029, this->tilePosition - 2, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition - 1, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition, super->collisionLayer); + SetBottomTile(0x406d, this->tilePosition + 1, super->collisionLayer); + SetBottomTile(0x406e, this->tilePosition + 0x40, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition + 0x41, super->collisionLayer); + SetBottomTile(0x406d, this->tilePosition + 0x42, super->collisionLayer); } else { - SetTile(0x406c, this->tilePosition - 0x7f, super->collisionLayer); - SetTile(0x4022, this->tilePosition - 0x3f, super->collisionLayer); - SetTile(0x406c, this->tilePosition - 1, super->collisionLayer); - SetTile(0x4022, this->tilePosition, super->collisionLayer); - SetTile(0x4026, this->tilePosition + 1, super->collisionLayer); - SetTile(0x402a, this->tilePosition + 2, super->collisionLayer); - SetTile(0x406c, this->tilePosition + 0x3e, super->collisionLayer); - SetTile(0x4022, this->tilePosition + 0x3f, super->collisionLayer); - SetTile(0x406f, this->tilePosition + 0x40, super->collisionLayer); + SetBottomTile(0x406c, this->tilePosition - 0x7f, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition - 0x3f, super->collisionLayer); + SetBottomTile(0x406c, this->tilePosition - 1, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition + 1, super->collisionLayer); + SetBottomTile(0x402a, this->tilePosition + 2, super->collisionLayer); + SetBottomTile(0x406c, this->tilePosition + 0x3e, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition + 0x3f, super->collisionLayer); + SetBottomTile(0x406f, this->tilePosition + 0x40, super->collisionLayer); return; } break; case 3: - SetTile(0x4022, this->tilePosition, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition, super->collisionLayer); break; } } @@ -223,12 +223,12 @@ void sub_08093C70(GiantTwigEntity* this) { if (this->unk_78 != 0) { if (gPlayerState.heldObject != 0) { this->unk_78 = 0; - SetTile(0x4022, this->tilePosition + 0x3f, super->collisionLayer); - SetTile(0x4022, this->tilePosition + 0x40, super->collisionLayer); - SetTile(0x4022, this->tilePosition + 0x41, super->collisionLayer); - SetTile(0x4026, this->tilePosition + 0x7f, super->collisionLayer); - SetTile(0x4026, this->tilePosition + 0x80, super->collisionLayer); - SetTile(0x4026, this->tilePosition + 0x81, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition + 0x3f, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition + 0x40, super->collisionLayer); + SetBottomTile(0x4022, this->tilePosition + 0x41, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition + 0x7f, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition + 0x80, super->collisionLayer); + SetBottomTile(0x4026, this->tilePosition + 0x81, super->collisionLayer); } } else { @@ -236,12 +236,12 @@ void sub_08093C70(GiantTwigEntity* this) { if (--this->unk_7a == 0) { this->unk_78++; this->unk_7a = 0x3c; - SetTile(0x403d, this->tilePosition + 0x3f, super->collisionLayer); - SetTile(0x403d, this->tilePosition + 0x40, super->collisionLayer); - SetTile(0x4027, this->tilePosition + 0x41, super->collisionLayer); - SetTile(0x403d, this->tilePosition + 0x7f, super->collisionLayer); - SetTile(0x403d, this->tilePosition + 0x80, super->collisionLayer); - SetTile(0x4029, this->tilePosition + 0x81, super->collisionLayer); + SetBottomTile(0x403d, this->tilePosition + 0x3f, super->collisionLayer); + SetBottomTile(0x403d, this->tilePosition + 0x40, super->collisionLayer); + SetBottomTile(0x4027, this->tilePosition + 0x41, super->collisionLayer); + SetBottomTile(0x403d, this->tilePosition + 0x7f, super->collisionLayer); + SetBottomTile(0x403d, this->tilePosition + 0x80, super->collisionLayer); + SetBottomTile(0x4029, this->tilePosition + 0x81, super->collisionLayer); } } } diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index f2e4f852..cd77b956 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -183,10 +183,10 @@ void sub_0808C148(JarPortalEntity* this, u32 a2) { pos = COORD_TO_TILE(super); if (!a2) { - SetTile(16530, pos - 1, super->collisionLayer); - SetTile(16531, pos, super->collisionLayer); - SetTile(16532, pos + 63, super->collisionLayer); - SetTile(16533, pos + 64, super->collisionLayer); + SetBottomTile(16530, pos - 1, super->collisionLayer); + SetBottomTile(16531, pos, super->collisionLayer); + SetBottomTile(16532, pos + 63, super->collisionLayer); + SetBottomTile(16533, pos + 64, super->collisionLayer); } else { RestorePrevTileEntity(pos - 1, super->collisionLayer); RestorePrevTileEntity(pos, super->collisionLayer); diff --git a/src/object/ladderUp.c b/src/object/ladderUp.c index cfdadfb9..7bd66824 100644 --- a/src/object/ladderUp.c +++ b/src/object/ladderUp.c @@ -37,7 +37,7 @@ void LadderUp(Entity* this) { return; } this->y.HALF.HI = (this->y.HALF.HI & 0xfff0) + 0xc; - SetTile(0x4023, COORD_TO_TILE(this), this->collisionLayer); + SetBottomTile(0x4023, COORD_TO_TILE(this), this->collisionLayer); break; case 1: if (GravityUpdate(this, Q_8_8(16.0)) == 0) { @@ -66,16 +66,16 @@ void LadderUp(Entity* this) { if (this->type2 == 0) { if (gPlayerEntity.base.y.HALF.HI < this->y.HALF.HI) { if (gPlayerState.floor_type != SURFACE_LADDER && (GetTileTypeByEntity(this) == 0x4017)) { - SetTile(0x4023, COORD_TO_TILE(this), this->collisionLayer); + SetBottomTile(0x4023, COORD_TO_TILE(this), this->collisionLayer); RestorePrevTileEntity(COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer); } } else { if (GetTileTypeByEntity(this) != 0x4017) { - SetTile(0x4017, COORD_TO_TILE(this), this->collisionLayer); + SetBottomTile(0x4017, COORD_TO_TILE(this), this->collisionLayer); if (this->type == 0) { - SetTile(0x4017, COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer); + SetBottomTile(0x4017, COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer); } else { - SetTile(0x4014, COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer); + SetBottomTile(0x4014, COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer); } } } diff --git a/src/object/lightDoor.c b/src/object/lightDoor.c index e128c65c..5062c26f 100644 --- a/src/object/lightDoor.c +++ b/src/object/lightDoor.c @@ -87,13 +87,13 @@ void LightDoor_Action4(LightDoorEntity* this) { void sub_080850FC(LightDoorEntity* this) { u32 position = COORD_TO_TILE(super); u32 layer = super->collisionLayer; - SetTile(0x403d, position - 0x41, layer); - SetTile(0x403d, position - 0x40, layer); - SetTile(0x403d, position - 0x3f, layer); - SetTile(0x403d, position - 1, layer); - SetTile(0x403d, position, layer); - SetTile(0x403d, position + 1, layer); - SetTile(0x403d, position + 0x3f, layer); - SetTile(0x403d, position + 0x40, layer); - SetTile(0x403d, position + 0x41, layer); + SetBottomTile(0x403d, position - 0x41, layer); + SetBottomTile(0x403d, position - 0x40, layer); + SetBottomTile(0x403d, position - 0x3f, layer); + SetBottomTile(0x403d, position - 1, layer); + SetBottomTile(0x403d, position, layer); + SetBottomTile(0x403d, position + 1, layer); + SetBottomTile(0x403d, position + 0x3f, layer); + SetBottomTile(0x403d, position + 0x40, layer); + SetBottomTile(0x403d, position + 0x41, layer); } diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index 8c68f708..06bb3244 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -99,7 +99,7 @@ static void sub_0809EAD8(LightableSwitchEntity* this) { UpdateRailMovement(super, (u16**)&super->child, &this->unk_74); } else { - SetTile(0x4050, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4050, COORD_TO_TILE(super), super->collisionLayer); } } diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index 9bc15399..b4bd9c60 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -329,10 +329,10 @@ void LilypadLarge_Action2(LilypadLargeEntity* this) { void sub_08085A44(LilypadLargeEntity* this) { super->speed = 0x200; - if (GetRelativeCollisionTile(super, 0x10, 0x18) != 0x11) { + if (GetActTileRelative(super, 0x10, 0x18) != 0x11) { super->direction = 0x18; } else { - if (GetRelativeCollisionTile(super, -0x10, 0x18) != 0x11) { + if (GetActTileRelative(super, -0x10, 0x18) != 0x11) { super->direction = 8; } else { super->direction = 0x10; @@ -353,7 +353,7 @@ void sub_08085A98(LilypadLargeEntity* this) { this->unk_78.WORD -= 0x20000; SetAffineInfo(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); } - if (GetRelativeCollisionTile(super, 0, 0x18) != 0x11) { + if (GetActTileRelative(super, 0, 0x18) != 0x11) { super->subAction = 2; if (gArea.locationIndex == 0x1b) { super->y.HALF.HI += 0xd0; @@ -456,7 +456,7 @@ void LilypadLarge_Action5(LilypadLargeEntity* this) { void sub_08085D28(LilypadLargeEntity* this) { if (((gPlayerState.framestate != PL_STATE_TALKEZLO) && ((gPlayerState.flags & PL_FLAGS2) != 0)) && - (GetRelativeCollisionTile(super, 0, 0x18) == 0x11)) { + (GetActTileRelative(super, 0, 0x18) == 0x11)) { super->action = 2; super->subAction = 0; PausePlayer(); diff --git a/src/object/linkEmptyingBottle.c b/src/object/linkEmptyingBottle.c index e3b77637..0c47f3a8 100644 --- a/src/object/linkEmptyingBottle.c +++ b/src/object/linkEmptyingBottle.c @@ -118,8 +118,8 @@ void sub_08094980(LinkEmptyingBottleEntity* this, u32 searchTileIndex, u32 repla xOffset = gUnk_08122A28[index]; yOffset = gUnk_08122A28[index + 1]; if (searchTileIndex == sub_080B1A0C(super, xOffset, yOffset)) { - SetTile(replaceTileIndex, TILE(super->x.HALF.HI + xOffset, super->y.HALF.HI + yOffset), - super->collisionLayer); + SetBottomTile(replaceTileIndex, TILE(super->x.HALF.HI + xOffset, super->y.HALF.HI + yOffset), + super->collisionLayer); } index += 2; } diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index d7f089a2..8f4bcbc3 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -162,7 +162,7 @@ void LockedDoor_Action1(LockedDoorEntity* this) { if (--super->timer == 0) { super->action = 2; super->timer = 7; - SetTile(this->unk_74, this->unk_76, super->collisionLayer); + SetBottomTile(this->unk_74, this->unk_76, super->collisionLayer); EnqueueSFX(SFX_10B); } } @@ -262,12 +262,12 @@ void sub_080836A0(LockedDoorEntity* this) { super->spriteSettings.draw = 1; super->x.HALF.HI = this->unk_70; super->y.HALF.HI = this->unk_72; - SetTile(0x4022, this->unk_76, super->collisionLayer); + SetBottomTile(0x4022, this->unk_76, super->collisionLayer); } void sub_080836DC(Entity* this, u32 unk_0, u32 unk_1) { const struct_0811F680* tmp; - SetTile(0x4022, unk_1, this->collisionLayer); + SetBottomTile(0x4022, unk_1, this->collisionLayer); this->timer = 7; this->spriteSettings.draw = 1; this->direction = (unk_0 << 3) ^ DirectionSouth; diff --git a/src/object/macroAcorn.c b/src/object/macroAcorn.c index a7f32871..4997cb1f 100644 --- a/src/object/macroAcorn.c +++ b/src/object/macroAcorn.c @@ -74,38 +74,38 @@ void sub_0809E5F0(MacroAcornEntity* this) { this->unk_80 = position; switch (super->type) { case 2: - SetTile(0x4022, position - 0x3d, 1); - SetTile(0x406d, position - 0x3c, 1); + SetBottomTile(0x4022, position - 0x3d, 1); + SetBottomTile(0x406d, position - 0x3c, 1); case 0: - SetTile(0x406c, position - 0x42, 1); - SetTile(0x4022, position - 0x41, 1); - SetTile(0x4022, position - 0x40, 1); - SetTile(0x4022, position - 0x3f, 1); - SetTile(0x4022, position - 2, 1); - SetTile(0x4022, position - 1, 1); - SetTile(0x4022, position, 1); - SetTile(0x4022, position + 1, 1); - SetTile(0x406e, position + 0x3e, 1); - SetTile(0x4022, position + 0x3f, 1); - SetTile(0x4022, position + 0x40, 1); - SetTile(0x406f, position + 0x41, 1); + SetBottomTile(0x406c, position - 0x42, 1); + SetBottomTile(0x4022, position - 0x41, 1); + SetBottomTile(0x4022, position - 0x40, 1); + SetBottomTile(0x4022, position - 0x3f, 1); + SetBottomTile(0x4022, position - 2, 1); + SetBottomTile(0x4022, position - 1, 1); + SetBottomTile(0x4022, position, 1); + SetBottomTile(0x4022, position + 1, 1); + SetBottomTile(0x406e, position + 0x3e, 1); + SetBottomTile(0x4022, position + 0x3f, 1); + SetBottomTile(0x4022, position + 0x40, 1); + SetBottomTile(0x406f, position + 0x41, 1); break; case 3: - SetTile(0x4022, position - 0x44, 1); - SetTile(0x406c, position - 0x45, 1); + SetBottomTile(0x4022, position - 0x44, 1); + SetBottomTile(0x406c, position - 0x45, 1); case 1: - SetTile(0x4022, position - 0x42, 1); - SetTile(0x4022, position - 0x41, 1); - SetTile(0x4022, position - 0x40, 1); - SetTile(0x406d, position - 0x3f, 1); - SetTile(0x4022, position - 2, 1); - SetTile(0x4022, position - 1, 1); - SetTile(0x4022, position, 1); - SetTile(0x4022, position + 1, 1); - SetTile(0x406e, position + 0x3e, 1); - SetTile(0x4022, position + 0x3f, 1); - SetTile(0x4022, position + 0x40, 1); - SetTile(0x406f, position + 0x41, 1); + SetBottomTile(0x4022, position - 0x42, 1); + SetBottomTile(0x4022, position - 0x41, 1); + SetBottomTile(0x4022, position - 0x40, 1); + SetBottomTile(0x406d, position - 0x3f, 1); + SetBottomTile(0x4022, position - 2, 1); + SetBottomTile(0x4022, position - 1, 1); + SetBottomTile(0x4022, position, 1); + SetBottomTile(0x4022, position + 1, 1); + SetBottomTile(0x406e, position + 0x3e, 1); + SetBottomTile(0x4022, position + 0x3f, 1); + SetBottomTile(0x4022, position + 0x40, 1); + SetBottomTile(0x406f, position + 0x41, 1); break; } } diff --git a/src/object/macroBook.c b/src/object/macroBook.c index c0cb253e..0fe65615 100644 --- a/src/object/macroBook.c +++ b/src/object/macroBook.c @@ -150,7 +150,7 @@ void sub_0809A958(MacroBookEntity* this) { for (index = 0; index < 5; index++, tilePos += 0x40) { for (index2 = 0; index2 < 4; index2++, tileIndexPtr++) { if ((*tileIndexPtr & 0x4000) != 0) { - SetTile(*tileIndexPtr, tilePos + index2, 1); + SetBottomTile(*tileIndexPtr, tilePos + index2, 1); } } } diff --git a/src/object/macroDecorations.c b/src/object/macroDecorations.c index 4e886ae0..c6142185 100644 --- a/src/object/macroDecorations.c +++ b/src/object/macroDecorations.c @@ -87,7 +87,7 @@ void sub_08097EB8(MacroDecorationEntity* this) { const s16* tilePosPtr; u16 tile = COORD_TO_TILE(super); for (tilePosPtr = tilePosArray; *tilePosPtr != 0x7fff; tilePosPtr += 2) { - SetTile((u16)tilePosPtr[1], tile + tilePosPtr[0], 1); + SetBottomTile((u16)tilePosPtr[1], tile + tilePosPtr[0], 1); } } diff --git a/src/object/macroShoe.c b/src/object/macroShoe.c index 2d4b5ac2..574fcf20 100644 --- a/src/object/macroShoe.c +++ b/src/object/macroShoe.c @@ -39,9 +39,9 @@ void MacroShoe_Init(Entity* this) { this->action = 1; this->hitbox = (Hitbox*)MacroShoe_TypeHitboxes[this->type]; if (this->type2 == 1) { - SetTile(0x4024, 0x410, 1); - SetTile(0x4026, 0x411, 1); - SetTile(0x4025, 0x412, 1); + SetBottomTile(0x4024, 0x410, 1); + SetBottomTile(0x4026, 0x411, 1); + SetBottomTile(0x4025, 0x412, 1); } } diff --git a/src/object/mask.c b/src/object/mask.c index 46cfdb9e..e517a8bb 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -74,7 +74,7 @@ void Mask_Init(MaskEntity* this) { this->unk_7a = sub_080B1B44(this->unk_7e, 1); - SetTile(0x4022, this->unk_7e, 1); + SetBottomTile(0x4022, this->unk_7e, 1); } // Probably related to knocking it down @@ -99,7 +99,7 @@ void Mask_Action1(MaskEntity* this) { } // Presumably, make the mask fall - SetTile(this->unk_7c, this->unk_7e, 1); + SetBottomTile(this->unk_7c, this->unk_7e, 1); sub_08000148(this->unk_7a, this->unk_7e, 1); diff --git a/src/object/metalDoor.c b/src/object/metalDoor.c index 0c7fbfd0..c0bbc874 100644 --- a/src/object/metalDoor.c +++ b/src/object/metalDoor.c @@ -118,13 +118,13 @@ void sub_080A080C(MetalDoorEntity* this) { this->unk_76 = GetTileIndex(this->unk_74 - 1, super->collisionLayer); this->unk_78 = GetTileIndex(this->unk_74, super->collisionLayer); this->unk_7a = GetTileIndex(this->unk_74 + 1, super->collisionLayer); - SetTile(0x4022, this->unk_74 - 1, super->collisionLayer); - SetTile(0x4022, this->unk_74, super->collisionLayer); - SetTile(0x4022, this->unk_74 + 1, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74 - 1, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74, super->collisionLayer); + SetBottomTile(0x4022, this->unk_74 + 1, super->collisionLayer); } void sub_080A0870(MetalDoorEntity* this) { - SetTile(this->unk_76, this->unk_74 - 1, super->collisionLayer); - SetTile(this->unk_78, this->unk_74, super->collisionLayer); - SetTile(this->unk_7a, this->unk_74 + 1, super->collisionLayer); + SetBottomTile(this->unk_76, this->unk_74 - 1, super->collisionLayer); + SetBottomTile(this->unk_78, this->unk_74, super->collisionLayer); + SetBottomTile(this->unk_7a, this->unk_74 + 1, super->collisionLayer); } diff --git a/src/object/minecart.c b/src/object/minecart.c index 64fb239d..b13f2c7e 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -59,7 +59,7 @@ void Minecart_Init(MinecartEntity* this) { super->speed = 0x700; super->spritePriority.b1 = 3; InitAnimationForceUpdate(super, super->type2 + 4 + super->animationState); - SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); } void Minecart_Action1(MinecartEntity* this) { @@ -163,9 +163,9 @@ void Minecart_Action3(MinecartEntity* this) { super->subtimer = 60; } - uVar3 = GetRelativeCollisionTile(super, gUnk_081223C8[super->animationState * 2], - gUnk_081223C8[super->animationState * 2 + 1]); - iVar2 = sub_08007DD6(uVar3, gUnk_081223D8[super->animationState]); + uVar3 = GetActTileRelative(super, gUnk_081223C8[super->animationState * 2], + gUnk_081223C8[super->animationState * 2 + 1]); + iVar2 = ActTileToTile(uVar3, gUnk_081223D8[super->animationState]); if (iVar2 == 0) { super->direction = DirectionTurnAround(super->direction); super->animationState = AnimationStateFlip90(super->animationState); @@ -290,7 +290,7 @@ void Minecart_Action6(MinecartEntity* this) { minecartData->room = gRoomControls.room; minecartData->animationState = super->animationState; InitAnimationForceUpdate(super, super->animationState + 0x10); - SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); } else { UpdateAnimationSingleFrame(super); gPlayerEntity.base.spritePriority.b0 = super->spritePriority.b0 - 1; diff --git a/src/object/minecartDoor.c b/src/object/minecartDoor.c index 6c70abd8..c74e1109 100644 --- a/src/object/minecartDoor.c +++ b/src/object/minecartDoor.c @@ -63,7 +63,7 @@ void MinecartDoor_Init(MinecartDoorEntity* this) { } else { super->action = 1; super->spriteSettings.draw = 1; - SetTile(0x4022, this->unk_76, super->collisionLayer); + SetBottomTile(0x4022, this->unk_76, super->collisionLayer); } } } @@ -73,7 +73,7 @@ void MinecartDoor_Action1(MinecartDoorEntity* this) { super->action = 2; super->timer = 7; super->direction = super->type << 3; - SetTile(this->unk_74, this->unk_76, super->collisionLayer); + SetBottomTile(this->unk_74, this->unk_76, super->collisionLayer); EnqueueSFX(SFX_10B); } } diff --git a/src/object/minishVillageObject.c b/src/object/minishVillageObject.c index ef5c9780..a4a3e48c 100644 --- a/src/object/minishVillageObject.c +++ b/src/object/minishVillageObject.c @@ -83,7 +83,7 @@ void MinishVillageObject_Type1(Entity* this) { this->subtimer = 0; this->frameIndex = 0; this->spritePriority.b0 = 7; - SetTile(0x4069, COORD_TO_TILE(this) - 0x40, 1); + SetBottomTile(0x4069, COORD_TO_TILE(this) - 0x40, 1); break; case 2: if ((gRoomTransition.frameCount & 3U) == 0) { @@ -217,7 +217,7 @@ void MinishVillageObject_Type8_Init(Entity* this) { if (this->type2 != 0) { tilePosition -= 0x40; } - SetTile(0x4069, tilePosition, this->collisionLayer); + SetBottomTile(0x4069, tilePosition, this->collisionLayer); } } @@ -230,7 +230,7 @@ void MinishVillageObject_Type8_Action1(Entity* this) { this->timer = 8; this->spriteRendering.alphaBlend = 0; gScreen.controls.layerFXControl = 0; - SetTile(0x4069, COORD_TO_TILE(this), this->collisionLayer); + SetBottomTile(0x4069, COORD_TO_TILE(this), this->collisionLayer); } } } diff --git a/src/object/object30.c b/src/object/object30.c index 61b3448f..7d2acb49 100644 --- a/src/object/object30.c +++ b/src/object/object30.c @@ -40,7 +40,7 @@ void Object30_Init(Object30Entity* this) { const u16* ptr; switch (super->type) { case 0: - data = GetLayerByIndex(super->collisionLayer); + data = GetTileBuffer(super->collisionLayer); ptr = &data->mapData[sub_0806F798(super)]; this->unk_6c = (u16*)ptr; this->unk_68 = ptr[0]; diff --git a/src/object/object37.c b/src/object/object37.c index 35f32e93..e0b08edc 100644 --- a/src/object/object37.c +++ b/src/object/object37.c @@ -34,7 +34,7 @@ void Object37(Entity* this) { void Object37_Init(Object37Entity* this) { u16* puVar1; - puVar1 = GetLayerByIndex(super->collisionLayer)->mapData + sub_0806F798(super); + puVar1 = GetTileBuffer(super->collisionLayer)->mapData + sub_0806F798(super); this->unk78 = puVar1; this->unk70 = *puVar1; super->action = 1; diff --git a/src/object/objectBlockingStairs.c b/src/object/objectBlockingStairs.c index b35f6777..83c6e976 100644 --- a/src/object/objectBlockingStairs.c +++ b/src/object/objectBlockingStairs.c @@ -133,23 +133,23 @@ void ObjectBlockingStairs_Action1(ObjectBlockingStairsEntity* this) { if (this->unk7b & 0x80) { this->unk7b &= ~0x80; if ((this->unk7b & 0x40) != 0) { - SetTile(0x402c, this->tilePos - 1, super->collisionLayer); - SetTile(0x403d, this->tilePos + 1, super->collisionLayer); + SetBottomTile(0x402c, this->tilePos - 1, super->collisionLayer); + SetBottomTile(0x403d, this->tilePos + 1, super->collisionLayer); } else { - SetTile(0x403d, this->tilePos - 1, super->collisionLayer); - SetTile(0x402d, this->tilePos + 1, super->collisionLayer); + SetBottomTile(0x403d, this->tilePos - 1, super->collisionLayer); + SetBottomTile(0x402d, this->tilePos + 1, super->collisionLayer); } } else if (this->unk7b & 0x40) { if (xDist >= 5) { this->unk7b &= ~(0x40 | 0x80); - SetTile(0x403d, this->tilePos - 1, super->collisionLayer); - SetTile(0x402d, this->tilePos + 1, super->collisionLayer); + SetBottomTile(0x403d, this->tilePos - 1, super->collisionLayer); + SetBottomTile(0x402d, this->tilePos + 1, super->collisionLayer); } } else { if (-xDist > 4) { this->unk7b |= 0x40; - SetTile(0x402c, this->tilePos - 1, super->collisionLayer); - SetTile(0x403d, this->tilePos + 1, super->collisionLayer); + SetBottomTile(0x402c, this->tilePos - 1, super->collisionLayer); + SetBottomTile(0x403d, this->tilePos + 1, super->collisionLayer); } } } @@ -223,7 +223,7 @@ void sub_080931A4(ObjectBlockingStairsEntity* this, u32 param_2) { for (index = 0, iVar5 = 0; index < 9; index++) { u32 pos = tilePos + iVar5 + index - 1; - SetTile(pTileTypes[index], pos, collisionLayer); + SetBottomTile(pTileTypes[index], pos, collisionLayer); switch (index) { case 2: iVar5 = 0x3d; diff --git a/src/object/objectOnPillar.c b/src/object/objectOnPillar.c index 98501c8e..f0525f1d 100644 --- a/src/object/objectOnPillar.c +++ b/src/object/objectOnPillar.c @@ -192,7 +192,7 @@ void sub_08097098(ObjectOnPillarEntity* this) { u16 tileType; this->unk_76 = 0x20; EnqueueSFX(SFX_10F); - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); tileType = GetTileType(gUnk_080B4488[super->direction >> 3] + this->tilePosition, super->collisionLayer); if ((tileType == 0x79) || tileType == 0x77) { super->spriteOffsetY = 2; @@ -202,7 +202,7 @@ void sub_08097098(ObjectOnPillarEntity* this) { void sub_080970F4(ObjectOnPillarEntity* this) { this->tilePosition = COORD_TO_TILE(super); this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer); - SetTile(0x4036, this->tilePosition, super->collisionLayer); + SetBottomTile(0x4036, this->tilePosition, super->collisionLayer); } bool32 sub_08097144(ObjectOnPillarEntity* this) { @@ -255,7 +255,7 @@ void sub_080971E0(ObjectOnPillarEntity* this) { super->action = 4; super->frameIndex = 1; super->spritePriority.b0 = 7; - SetTile(0, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0, COORD_TO_TILE(super), super->collisionLayer); DeleteThisEntity(); break; case 1: diff --git a/src/object/objectOnSpinyBeetle.c b/src/object/objectOnSpinyBeetle.c index aa28ae96..aafecc5b 100644 --- a/src/object/objectOnSpinyBeetle.c +++ b/src/object/objectOnSpinyBeetle.c @@ -152,7 +152,7 @@ void ObjectOnSpinyBeetle_Action2Subaction2(ObjectOnSpinyBeetleEntity* this) { } void ObjectOnSpinyBeetle_Action2Subaction3(ObjectOnSpinyBeetleEntity* this) { - switch (sub_080043E8(super)) { + switch (GetTileHazardType(super)) { case 2: CreateFx(super, FX_WATER_SPLASH, 0); break; diff --git a/src/object/palaceArchway.c b/src/object/palaceArchway.c index 4f545bef..77ca2a74 100644 --- a/src/object/palaceArchway.c +++ b/src/object/palaceArchway.c @@ -22,7 +22,7 @@ void PalaceArchway_Init(Entity* this) { this->frameIndex = this->type2; this->spriteRendering.b3 = 3; this->spritePriority.b0 = 7; - SetTile(0x4069, COORD_TO_TILE(this), this->collisionLayer); + SetBottomTile(0x4069, COORD_TO_TILE(this), this->collisionLayer); } void PalaceArchway_Action1(Entity* this) { diff --git a/src/object/paper.c b/src/object/paper.c index 62e49ff7..541d86a5 100644 --- a/src/object/paper.c +++ b/src/object/paper.c @@ -40,7 +40,7 @@ void Paper_Type0(Entity* this) { } this->spriteSettings.draw = 0; } - SetTile(0x4051, COORD_TO_TILE(this), 1); + SetBottomTile(0x4051, COORD_TO_TILE(this), 1); } void Paper_Type1(Entity* this) { @@ -60,8 +60,8 @@ void Paper_Type2(Entity* this) { this->action = 1; this->y.HALF.HI++; this->spriteOffsetY = -1; - SetTile(0x4051, COORD_TO_TILE(this) - 1, 1); - SetTile(0x4051, COORD_TO_TILE(this), 1); + SetBottomTile(0x4051, COORD_TO_TILE(this) - 1, 1); + SetBottomTile(0x4051, COORD_TO_TILE(this), 1); } void Paper_Action1(Entity* this) { diff --git a/src/object/playerClone.c b/src/object/playerClone.c index a5e8bed4..c6e65188 100644 --- a/src/object/playerClone.c +++ b/src/object/playerClone.c @@ -51,7 +51,7 @@ void PlayerClone_Init(PlayerCloneEntity* this) { super->y.HALF.HI = (super->y.HALF.HI & 0xfff0) | 8; this->tilePos = COORD_TO_TILE(super); InitializeAnimation(super, 8); - SetTile(0x4016, this->tilePos, super->collisionLayer); + SetBottomTile(0x4016, this->tilePos, super->collisionLayer); SoundReq(SFX_112); } @@ -109,7 +109,7 @@ void PlayerClone_Action2(PlayerCloneEntity* this) { if (gPlayerEntity.base.iframes >= 1) { gPlayerState.chargeState.action = 1; } else { - GetActTile(super); + GetActTile(super); // leftover from debugging? sub_08084B1C(this); super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI + this->unk78; super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI + this->unk7a; diff --git a/src/object/pot.c b/src/object/pot.c index 0575dc87..3901820e 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -48,7 +48,7 @@ void sub_0808270C(PotEntity* this); void sub_080826FC(PotEntity* this); extern void RegisterCarryEntity(Entity*); -extern void sub_08016A6C(Entity*); +extern void CheckOnLayerTransition(Entity*); void Pot(PotEntity* this) { static void (*const Pot_Actions[])(PotEntity*) = { @@ -83,7 +83,7 @@ void Pot_Init(PotEntity* this) { DeleteThisEntity(); } - SetTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); InitializeAnimation(super, 5); } @@ -96,7 +96,7 @@ void Pot_Action1(PotEntity* this) { super->subAction = 0; break; case 0x1D: - SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); super->action = 5; super->zVelocity = Q_16_16(2.625); super->spriteOffsetY = 0; @@ -120,11 +120,11 @@ void Pot_Action1(PotEntity* this) { super->speed >>= 1; super->timer = 64; } - SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); EnqueueSFX(SFX_10F); break; case 0x4067: - SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); DeleteThisEntity(); break; default: @@ -132,7 +132,7 @@ void Pot_Action1(PotEntity* this) { CreateFx(super, FX_FALL_DOWN, 0); } else if (tileType == 0x4005) { gPlayerState.lastSwordMove = SWORD_MOVE_BREAK_POT; - SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); } BreakPot(this, NULL); break; @@ -158,7 +158,7 @@ void sub_08082510(PotEntity* this) { super->hitType = 1; super->flags2 = gPlayerEntity.base.flags2; super->spriteOffsetY = 0; - SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); super->subAction++; } @@ -170,7 +170,7 @@ void sub_08082588(PotEntity* this) { } void sub_0808259C(PotEntity* this) { - switch (sub_080043E8(super)) { + switch (GetTileHazardType(super)) { case 2: CreateFx(super, FX_WATER_SPLASH, 0); break; @@ -209,7 +209,7 @@ void Pot_Action4(PotEntity* this) { sub_0800445C(super); if (super->timer-- != 0) { LinearMoveUpdate(super); - sub_08016A6C(super); + CheckOnLayerTransition(super); return; } @@ -230,7 +230,7 @@ void Pot_Action4(PotEntity* this) { BreakPot(this, NULL); break; default: - SetTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); RegisterCarryEntity(super); break; } @@ -253,7 +253,7 @@ void sub_0808270C(PotEntity* this) { if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { super->spriteOffsetX = 0; super->action = 1; - SetTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); } else { sub_0806F4E8(super); } @@ -264,7 +264,7 @@ void sub_08082778(PotEntity* this) { super->timer = 1; super->spriteOffsetX = 0; super->spriteOffsetY = -2; - SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); } if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c index 63fcdfbb..b8f6eabc 100644 --- a/src/object/pullableMushroom.c +++ b/src/object/pullableMushroom.c @@ -59,7 +59,7 @@ void PullableMushroom_Init(PullableMushroomEntity* this) { super->spritePriority.b0 = 4; super->hitbox = (Hitbox*)&gUnk_080FD224; super->carryFlags = 1; - SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); super->health = 1; super->collisionFlags = 7; super->hitType = 0x6e; diff --git a/src/object/pushableFurniture.c b/src/object/pushableFurniture.c index 327dfbe6..ec391f0c 100644 --- a/src/object/pushableFurniture.c +++ b/src/object/pushableFurniture.c @@ -295,12 +295,12 @@ void sub_0808FDE8(PushableFurnitureEntity* this) { iVar2 = GetTileIndex(uVar3, 1); if (iVar2 == 0x402e) { if ((((uVar1 & 0xf0) != 0) && ((uVar1 & 0xf0) != 0x50)) || ((uVar1 & 5) == 0)) { - SetTile(0x402c, uVar3, 1); + SetBottomTile(0x402c, uVar3, 1); } } else { iVar2 = sub_080B1B44(uVar3, 1); if ((iVar2 == 5) && ((((uVar1 & 0xf0) == 0 || ((uVar1 & 0xf0) == 0x50)) && ((uVar1 & 5) != 0)))) { - SetTile(0x402e, uVar3, 1); + SetBottomTile(0x402e, uVar3, 1); } } uVar3 = (u32)this->unk_72; @@ -308,12 +308,12 @@ void sub_0808FDE8(PushableFurnitureEntity* this) { iVar2 = GetTileIndex(uVar3, 1); if (iVar2 == 0x402f) { if ((((uVar1 & 0xf0) != 0) && ((uVar1 & 0xf0) != 0x50)) || ((uVar1 & 10) == 0)) { - SetTile(0x402d, uVar3, 1); + SetBottomTile(0x402d, uVar3, 1); } } else { iVar2 = sub_080B1B44(uVar3, 1); if (((iVar2 == 10) && (((uVar1 & 0xf0) == 0 || ((uVar1 & 0xf0) == 0x50)))) && ((uVar1 & 10) != 0)) { - SetTile(0x402f, uVar3, 1); + SetBottomTile(0x402f, uVar3, 1); } } } @@ -361,13 +361,13 @@ void sub_0808FF50(PushableFurnitureEntity* this) { case 0: this->unk_70 = tmp; this->unk_74 = GetTileIndex(this->unk_70, 1); - SetTile(0x404a, tmp, 1); + SetBottomTile(0x404a, tmp, 1); break; case 1: if ((tmp2 & 8) != 0) { this->unk_70 = this->unk_7c; this->unk_74 = GetTileIndex(this->unk_70, 1); - SetTile(gUnk_08121EE4[this->unk_81], position, 1); + SetBottomTile(gUnk_08121EE4[this->unk_81], position, 1); this->unk_72 = tmp + 1; this->unk_76 = GetTileIndex(this->unk_72, 1); sub_08090094(this, gUnk_08121EE4[this->unk_81 + 4], this->unk_72); @@ -375,7 +375,7 @@ void sub_0808FF50(PushableFurnitureEntity* this) { } else { this->unk_72 = this->unk_7c; this->unk_76 = GetTileIndex(this->unk_72, 1); - SetTile(gUnk_08121EE4[this->unk_81], position, 1); + SetBottomTile(gUnk_08121EE4[this->unk_81], position, 1); this->unk_70 = tmp - 1; this->unk_74 = GetTileIndex(this->unk_70, 1); sub_08090094(this, gUnk_08121EE4[this->unk_81 + 2], this->unk_70); @@ -400,14 +400,14 @@ void sub_08090094(PushableFurnitureEntity* this, u32 param_2, u32 tilePos) { if (tmp1 == 5) { index = 0x4022; } - SetTile(index, tilePos, 1); + SetBottomTile(index, tilePos, 1); return; case 0x402d: case 0x402f: if (tmp1 == 5) { index = 0x4022; } - SetTile(index, tilePos, 1); + SetBottomTile(index, tilePos, 1); return; case 0x4024: case 0x402c: @@ -415,10 +415,10 @@ void sub_08090094(PushableFurnitureEntity* this, u32 param_2, u32 tilePos) { if (tmp1 == 10) { index = 0x4022; } - SetTile(index, tilePos, 1); + SetBottomTile(index, tilePos, 1); return; default: - SetTile(index, tilePos, 1); + SetBottomTile(index, tilePos, 1); return; } } @@ -470,7 +470,7 @@ void sub_08090094(PushableFurnitureEntity* this, u32 param_2, u32 tilePos) { break; } - SetTile(index, tilePos, 1); + SetBottomTile(index, tilePos, 1); } void sub_08090254(PushableFurnitureEntity* this) { @@ -572,7 +572,7 @@ void sub_0809028C(PushableFurnitureEntity* this, u32 param_2) { } void sub_08090480(u32 param_1, u32 param_2) { - SetTile(gUnk_08121EF0[param_1], param_2, 1); + SetBottomTile(gUnk_08121EF0[param_1], param_2, 1); } void sub_08090498(PushableFurnitureEntity* this) { diff --git a/src/object/pushableGrave.c b/src/object/pushableGrave.c index eb343f09..75fe9463 100644 --- a/src/object/pushableGrave.c +++ b/src/object/pushableGrave.c @@ -68,12 +68,12 @@ void PushableGrave_Init(PushableGraveEntity* this) { tileIndex = PushableGrave_Tiles[super->type2]; if (super->type == 0) { super->hitbox = (Hitbox*)&gUnk_080FD578; - SetTile(tileIndex, tilePosition - 1, super->collisionLayer); - SetTile(tileIndex, tilePosition, super->collisionLayer); + SetBottomTile(tileIndex, tilePosition - 1, super->collisionLayer); + SetBottomTile(tileIndex, tilePosition, super->collisionLayer); super->y.HALF.HI += 2; } else { super->hitbox = (Hitbox*)&gUnk_080FD570; - SetTile(tileIndex, tilePosition, super->collisionLayer); + SetBottomTile(tileIndex, tilePosition, super->collisionLayer); if (super->type2 == 2) { SetMultipleTiles((TileData*)gUnk_081232C0, tilePosition, super->collisionLayer); } @@ -133,9 +133,9 @@ void sub_080977F4(PushableGraveEntity* this) { super->action = 4; super->spriteOffsetY = 0; tilePosition = COORD_TO_TILE(super); - SetTile(0x4022, tilePosition, super->collisionLayer); + SetBottomTile(0x4022, tilePosition, super->collisionLayer); if (super->type == 0) { - SetTile(0x4022, tilePosition - 1, super->collisionLayer); + SetBottomTile(0x4022, tilePosition - 1, super->collisionLayer); } if (this->pushedFlag != 0) { SetFlag(this->pushedFlag); diff --git a/src/object/pushableLever.c b/src/object/pushableLever.c index bfdc1a46..f7633eae 100644 --- a/src/object/pushableLever.c +++ b/src/object/pushableLever.c @@ -50,7 +50,7 @@ void PushableLever_Idle(PushableLeverEntity* this) { super->action = PUSHING; super->spriteOffsetX = 0; super->spriteOffsetY = 0; - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); EnqueueSFX(SFX_16A); RequestPriorityDuration(super, 30); if (PlayerCanBeMoved()) { @@ -87,13 +87,13 @@ void PushableLever_SetTiles(PushableLeverEntity* this) { super->type2 = 0; this->tilePosition = COORD_TO_TILE_OFFSET(super, 0, 0x10); this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer); - SetTile(TILE_INITIAL, this->tilePosition, super->collisionLayer); + SetBottomTile(TILE_INITIAL, this->tilePosition, super->collisionLayer); InitializeAnimation(super, 1); } else { super->type2 = 1; this->tilePosition = COORD_TO_TILE_OFFSET(super, 0x10, 0); this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer); - SetTile(TILE_PUSHED, this->tilePosition, super->collisionLayer); + SetBottomTile(TILE_PUSHED, this->tilePosition, super->collisionLayer); InitializeAnimation(super, 0); } } @@ -104,7 +104,7 @@ bool32 PushableLever_ShouldStartPushing(PushableLeverEntity* this) { return TRUE; } PushableLever_CalculateSpriteOffsets(this); - SetTile(PushableLever_Tiles[super->type2], this->tilePosition, super->collisionLayer); + SetBottomTile(PushableLever_Tiles[super->type2], this->tilePosition, super->collisionLayer); } else { this->timer = 60; super->spriteOffsetX = 0; diff --git a/src/object/pushableRock.c b/src/object/pushableRock.c index 00d8739a..f008712b 100644 --- a/src/object/pushableRock.c +++ b/src/object/pushableRock.c @@ -54,7 +54,7 @@ void PushableRock_Action1(PushableRockEntity* this) { } else { super->spriteSettings.flipX = 0; } - SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + SetBottomTile(this->tileIndex, this->tilePosition, super->collisionLayer); super->action = 2; InitializeAnimation(super, (super->animationState >> 1) + 1); EnqueueSFX(SFX_10F); @@ -92,7 +92,7 @@ void sub_0808A644(PushableRockEntity* this) { this->unk_72 = sub_080B1B44(this->tilePosition, super->collisionLayer); tmp = sub_080B1AE0(this->tilePosition, super->collisionLayer); if ((tmp == 0x19) || (tmp == 0xf0)) { - SetTile(0x4015, this->tilePosition, super->collisionLayer); + SetBottomTile(0x4015, this->tilePosition, super->collisionLayer); super->action = 3; if (!CheckFlags(this->pushedFlag)) { SetFlag(this->pushedFlag); @@ -102,7 +102,7 @@ void sub_0808A644(PushableRockEntity* this) { InitializeAnimation(super, 6); } } else { - SetTile(0x401b, this->tilePosition, super->collisionLayer); + SetBottomTile(0x401b, this->tilePosition, super->collisionLayer); } } diff --git a/src/object/pushableStatue.c b/src/object/pushableStatue.c index 1755dc5b..5da8d0e8 100644 --- a/src/object/pushableStatue.c +++ b/src/object/pushableStatue.c @@ -155,7 +155,7 @@ void PushableStatue_Action4(PushableStatueEntity* this) { } else { super->spriteSettings.draw = 1; super->action = 1; - SetTile(0x400b, this->unk_84, super->collisionLayer); + SetBottomTile(0x400b, this->unk_84, super->collisionLayer); sub_080894C8(this); } } @@ -163,9 +163,9 @@ void PushableStatue_Action4(PushableStatueEntity* this) { void sub_08089454(PushableStatueEntity* this) { this->unk_84 = COORD_TO_TILE(super); this->unk_80 = GetTileIndex(this->unk_84, super->collisionLayer); - SetTile(0x400b, this->unk_84, super->collisionLayer); + SetBottomTile(0x400b, this->unk_84, super->collisionLayer); if (super->collisionLayer == 2 && GetTileType(this->unk_84, 1) == 0x310) { - SetTile(0x400b, this->unk_84, 1); + SetBottomTile(0x400b, this->unk_84, 1); } } @@ -194,7 +194,7 @@ void sub_08089538(PushableStatueEntity* this) { u16 tileType; this->unk_86 = 0x20; EnqueueSFX(SFX_10F); - SetTile(this->unk_80, this->unk_84, super->collisionLayer); + SetBottomTile(this->unk_80, this->unk_84, super->collisionLayer); if ((super->collisionLayer == 2) && (GetTileType(this->unk_84, 1) == 0x400b)) { CloneTile(0x310, this->unk_84, 1); } @@ -264,7 +264,7 @@ bool32 sub_080896B0(void) { uVar4 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr[0], -ptr[1]) - uVar1; val = sub_080B1AE0(uVar4, gPlayerEntity.base.collisionLayer); if ((val - 0x26 > 1) && (val != 0x29)) { - layer = GetLayerByIndex(gPlayerEntity.base.collisionLayer); + layer = GetTileBuffer(gPlayerEntity.base.collisionLayer); iVar2 = (uVar4 * 0x10000) >> 0x10; tmp1 = layer->collisionData[iVar2]; tmp2 = layer->collisionData[(iVar2 - uVar1)]; diff --git a/src/object/railtrack.c b/src/object/railtrack.c index 5582202f..63172e5a 100644 --- a/src/object/railtrack.c +++ b/src/object/railtrack.c @@ -65,7 +65,7 @@ void Railtrack_Init(RailtrackEntity* this) { } } InitializeAnimation(super, super->animationState); - this->unk_70 = &GetLayerByIndex(super->collisionLayer)->mapData[COORD_TO_TILE(super)]; + this->unk_70 = &GetTileBuffer(super->collisionLayer)->mapData[COORD_TO_TILE(super)]; sub_08085394(this); } @@ -140,13 +140,13 @@ void sub_08085394(RailtrackEntity* this) { tile = COORD_TO_TILE(super); this->unk_74 = *(layerData - offset); - SetTile(uVar1, tile - offset, super->collisionLayer); + SetBottomTile(uVar1, tile - offset, super->collisionLayer); this->unk_76 = layerData[0x0]; - SetTile(uVar1, tile - 0x0, super->collisionLayer); + SetBottomTile(uVar1, tile - 0x0, super->collisionLayer); this->unk_78 = layerData[offset]; - SetTile(uVar1, tile + offset, super->collisionLayer); + SetBottomTile(uVar1, tile + offset, super->collisionLayer); } void sub_0808543C(RailtrackEntity* this) { @@ -156,9 +156,9 @@ void sub_0808543C(RailtrackEntity* this) { temp = gUnk_080B4488[super->animationState / 2][0]; uVar2 = COORD_TO_TILE(super); - SetTile(this->unk_74, uVar2 - temp, super->collisionLayer); - SetTile(this->unk_76, uVar2, super->collisionLayer); - SetTile(this->unk_78, uVar2 + temp, super->collisionLayer); + SetBottomTile(this->unk_74, uVar2 - temp, super->collisionLayer); + SetBottomTile(this->unk_76, uVar2, super->collisionLayer); + SetBottomTile(this->unk_78, uVar2 + temp, super->collisionLayer); } u32 sub_080854A8(RailtrackEntity* this) { diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c index 836dc648..e7931190 100644 --- a/src/object/smallIceBlock.c +++ b/src/object/smallIceBlock.c @@ -99,7 +99,7 @@ void SmallIceBlock_Action1(SmallIceBlockEntity* this) { if (obj != NULL) { CopyPosition(super, obj); } - SetTile(this->unk_6c, this->unk_70, super->collisionLayer); + SetBottomTile(this->unk_6c, this->unk_70, super->collisionLayer); DeleteEntity(super); break; @@ -158,7 +158,7 @@ void SmallIceBlock_Action4(SmallIceBlockEntity* this) { DeleteThisEntity(); } else { if (super->timer == 0x30) { - SetTile(this->unk_6c, this->unk_70, super->collisionLayer); + SetBottomTile(this->unk_6c, this->unk_70, super->collisionLayer); } SetAffineInfo(super, 0x100, (0x3c - super->timer) * 0x20 + 0x100, 0); if ((super->timer & 1) != 0) { @@ -177,14 +177,14 @@ void SmallIceBlock_Action4(SmallIceBlockEntity* this) { void sub_08099468(SmallIceBlockEntity* this) { this->unk_70 = COORD_TO_TILE(super); this->unk_6c = GetTileIndex(this->unk_70, super->collisionLayer); - SetTile(0x405a, this->unk_70, super->collisionLayer); + SetBottomTile(0x405a, this->unk_70, super->collisionLayer); } void sub_080994B8(SmallIceBlockEntity* this) { u16 tileType; EnqueueSFX(SFX_ICE_BLOCK_SLIDE); - SetTile(this->unk_6c, this->unk_70, super->collisionLayer); + SetBottomTile(this->unk_6c, this->unk_70, super->collisionLayer); if ((super->collisionLayer == 2) && (GetTileType(this->unk_70, 1) == 0x405a)) { CloneTile(0x310, this->unk_70, 1); } diff --git a/src/object/smokeParticle.c b/src/object/smokeParticle.c index ab50e2b8..4c24717a 100644 --- a/src/object/smokeParticle.c +++ b/src/object/smokeParticle.c @@ -74,14 +74,14 @@ void sub_080878CC(Entity* this) { switch (GetTileType(pos, layer)) { case 0x368: case 0x367: - sub_08008796(this, 3, x + itX, y + itY); + DoTileInteraction(this, 3, x + itX, y + itY); break; default: - SetTile(0x4022, pos, layer); + SetBottomTile(0x4022, pos, layer); break; } } else { - sub_08008796(this, 3, x + itX, y + itY); + DoTileInteraction(this, 3, x + itX, y + itY); } } } diff --git a/src/object/treeThorns.c b/src/object/treeThorns.c index a51bf700..66f26cc6 100644 --- a/src/object/treeThorns.c +++ b/src/object/treeThorns.c @@ -29,8 +29,8 @@ void TreeThorns(Entity* this) { this->flags2 = 1; this->hitbox = (Hitbox*)&gHitbox_1; tilePos = COORD_TO_TILE(this); - SetTile(0x4066, tilePos - 1, *layer); - SetTile(0x4065, tilePos, *layer); + SetBottomTile(0x4066, tilePos - 1, *layer); + SetBottomTile(0x4065, tilePos, *layer); UpdateSpriteForCollisionLayer(this); ent = CreateObject(TREE_THORNS, 1, 0); if (ent != NULL) { diff --git a/src/object/unusedSkull.c b/src/object/unusedSkull.c index 40303016..d594d5c1 100644 --- a/src/object/unusedSkull.c +++ b/src/object/unusedSkull.c @@ -38,7 +38,7 @@ void UnusedSkull_Init(UnusedSkullEntity* this) { super->hurtType = 0x47; super->flags2 = 2; super->hitbox = (Hitbox*)&gHitbox_4; - SetTile(0x4050, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4050, COORD_TO_TILE(super), super->collisionLayer); if (super->type == 1 || CheckFlags(this->unk_86)) { super->action = 3; SetFlag(this->unk_86); diff --git a/src/object/well.c b/src/object/well.c index c48948b1..fbf85d13 100644 --- a/src/object/well.c +++ b/src/object/well.c @@ -33,7 +33,7 @@ void Well_Init(WellEntity* this) { super->action = 1; tilePos = COORD_TO_TILE(super); this->unk_80 = tilePos; - SetTile(16509, this->unk_80, 1); + SetBottomTile(16509, this->unk_80, 1); } void Well_Action1(WellEntity* this) { diff --git a/src/physics.c b/src/physics.c index ac34b999..04eae6c1 100644 --- a/src/physics.c +++ b/src/physics.c @@ -45,7 +45,7 @@ u32 sub_0806F39C(Entity* ent) { } if (dist > 64) { - sub_080027EA(&gPlayerEntity.base, ent->speed, ent->direction); + LinearMoveDirectionOLD(&gPlayerEntity.base, ent->speed, ent->direction); return 1; } return 0; @@ -402,7 +402,7 @@ bool32 CheckPlayerProximity(u32 x, u32 y, u32 distX, u32 DistY) { } bool32 sub_0806FC24(u32 param_1, u32 param_2) { - u32 val = sub_08007DD6(param_1, gUnk_080046A4); + u32 val = ActTileToTile(param_1, gUnk_080046A4); if (!val) return 0; @@ -411,7 +411,7 @@ bool32 sub_0806FC24(u32 param_1, u32 param_2) { const u16* sub_0806FC50(u32 param_1, u32 param_2) { const u16* rv; - u32 val = sub_08007DD6(param_1, gUnk_080046A4); + u32 val = ActTileToTile(param_1, gUnk_080046A4); if (!val || ((gUnk_080047F6[val << 2] >> param_2) & 0x1) == 0) { rv = 0; } else { diff --git a/src/player.c b/src/player.c index 4f0dec35..064b47ec 100644 --- a/src/player.c +++ b/src/player.c @@ -894,7 +894,7 @@ static void sub_08071130(PlayerEntity* this) { if (this->unk_74 != NULL) ResetCollisionLayer(this->unk_74); - sub_08008790(super, 7); + DoTileInteractionHere(super, 7); if (gPlayerState.field_0x14) return; @@ -2195,7 +2195,7 @@ static void PlayerInHoleInit(PlayerEntity* this) { super->timer = 1; } } - SetTile(0x4070, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4070, COORD_TO_TILE(super), super->collisionLayer); ResetActiveItems(); PlayerInHoleUpdate(this); SoundReq(SFX_81); @@ -2252,7 +2252,7 @@ static void sub_08072B5C(PlayerEntity* this) { return; } - SetTile(0x4021, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4021, COORD_TO_TILE(super), super->collisionLayer); super->direction = Direction8FromAnimationState(super->animationState); temp = sub_0807A2F8(1); if (!temp) { @@ -2288,7 +2288,7 @@ static void sub_08072C48(PlayerEntity* this) { if (GravityUpdate(super, GRAVITY_RATE)) return; - sub_08008790(super, 7); + DoTileInteractionHere(super, 7); if (gPlayerState.field_0x14) { if (PlayerCheckNEastTile()) { gPlayerState.surfacePositionSameTimer = 7; @@ -2364,13 +2364,13 @@ static void sub_08072D54(PlayerEntity* this) { uVar2 = GetTileType(sub_0806F730(super), super->collisionLayer); switch (super->subtimer) { case 0: - if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { + if (ActTileToTile(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { super->timer = 1; super->subtimer = 1; } break; case 1: - if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { + if (ActTileToTile(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { super->timer = 1; } else { super->subtimer = 2; @@ -2378,7 +2378,7 @@ static void sub_08072D54(PlayerEntity* this) { break; case 2: super->animationState ^= 4; - if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1]) != 0) { + if (ActTileToTile(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1]) != 0) { super->timer = 1; super->subtimer = 3; } @@ -2386,7 +2386,7 @@ static void sub_08072D54(PlayerEntity* this) { break; case 3: super->animationState ^= 4; - if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { + if (ActTileToTile(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { super->timer = 1; } else { super->subtimer = 4; @@ -2410,7 +2410,7 @@ static void sub_08072D54(PlayerEntity* this) { } else { sub_08004542(super); } - sub_08008790(super, 7); + DoTileInteractionHere(super, 7); if (gPlayerState.field_0x14 != 0) { if (PlayerCheckNEastTile()) { gPlayerState.surfacePositionSameTimer = 7; @@ -3504,7 +3504,7 @@ void SurfaceAction_16(PlayerEntity* this) { (super->x.HALF.HI & 0xFFF0) | 8, (super->y.HALF.HI & 0xFFF0) | 8, super->x.HALF.HI, super->y.HALF.HI); } if ((gPlayerState.flags & PL_MINISH) == 0) - sub_08008790(super, 7); + DoTileInteractionHere(super, 7); } } diff --git a/src/playerItem/playerItemBomb.c b/src/playerItem/playerItemBomb.c index 5535277f..0a08c55d 100644 --- a/src/playerItem/playerItemBomb.c +++ b/src/playerItem/playerItemBomb.c @@ -195,7 +195,7 @@ void sub_0801B418(Entity* this) { x = 0x10; iVar3 = y - 0x10; while (x >= -0x10) { - sub_08008796(this, 3, this->x.HALF.HI + x, this->y.HALF.HI + y); + DoTileInteraction(this, 3, this->x.HALF.HI + x, this->y.HALF.HI + y); x -= 0x10; } y = iVar3; diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c index ca380e3e..46bc2ca4 100644 --- a/src/playerItem/playerItemBoomerang.c +++ b/src/playerItem/playerItemBoomerang.c @@ -28,7 +28,7 @@ void PlayerItemBoomerang_Init(PlayerItemBoomerangEntity* this); void PlayerItemBoomerang_Action2(PlayerItemBoomerangEntity* this); void PlayerItemBoomerang_Action3(PlayerItemBoomerangEntity* this); -extern Entity* sub_08008782(Entity*, u32, s32, s32); +extern Entity* DoTileInteractionOffset(Entity*, u32, s32, s32); extern bool32 sub_080040E2(Entity*, u8*); extern Hitbox gUnk_081271CC; extern u8 gUnk_08003E44; @@ -257,5 +257,5 @@ Entity* sub_0801B864(Entity* this) { sub_0800451C(this); } iVar1 = (this->direction >> 2) * 2; - return sub_08008782(this, 2, gUnk_080B782E[iVar1], gUnk_080B782E[iVar1 + 1]); + return DoTileInteractionOffset(this, 2, gUnk_080B782E[iVar1], gUnk_080B782E[iVar1 + 1]); } diff --git a/src/playerItem/playerItemBottle.c b/src/playerItem/playerItemBottle.c index 8196ba8b..962f8d7a 100644 --- a/src/playerItem/playerItemBottle.c +++ b/src/playerItem/playerItemBottle.c @@ -279,7 +279,7 @@ void PlayerItemBottle_UseEmptyBottle(Entity* this) { if (this->spriteSettings.flipX != 0) { iVar2 = -iVar2; } - if (GetRelativeCollisionTile(this, iVar2, (s8)ptr2[1]) == 0x10) { + if (GetActTileRelative(this, iVar2, (s8)ptr2[1]) == 0x10) { this->type2 = ITEM_BOTTLE_WATER; } } diff --git a/src/playerItem/playerItemBow.c b/src/playerItem/playerItemBow.c index ecedd873..4495475b 100644 --- a/src/playerItem/playerItemBow.c +++ b/src/playerItem/playerItemBow.c @@ -37,7 +37,7 @@ typedef struct { extern u8 gUnk_08003E44; -extern Entity* sub_08008782(Entity*, u32, s32, s32); +extern Entity* DoTileInteractionOffset(Entity*, u32, s32, s32); extern void sub_08017744(Entity*); extern void ModArrows(s32); @@ -146,7 +146,7 @@ void PlayerItemBow_Action1(PlayerItemBowEntity* this) { super->spriteSettings.draw ^= 1; } LinearMoveUpdate(super); - if (sub_08008782(super, (super->hurtType == 0x0e) ? 1 : 4, this->unk_6c, this->unk_70) != NULL) { + if (DoTileInteractionOffset(super, (super->hurtType == 0x0e) ? 1 : 4, this->unk_6c, this->unk_70) != NULL) { if (super->hurtType != 0x0e) { DeleteThisEntity(); } diff --git a/src/playerItem/playerItemDashSword.c b/src/playerItem/playerItemDashSword.c index ef127535..126d17bb 100644 --- a/src/playerItem/playerItemDashSword.c +++ b/src/playerItem/playerItemDashSword.c @@ -8,7 +8,7 @@ #include "functions.h" #include "player.h" -extern Entity* sub_08008782(Entity*, u32, s32, s32); +extern Entity* DoTileInteractionOffset(Entity*, u32, s32, s32); void PlayerItemDashSword_Action1(Entity* this); void PlayerItemDashSword_Init(Entity* this); @@ -81,7 +81,7 @@ void sub_0801B938(Entity* this) { this->hitbox = (Hitbox*)&gUnk_080B7850[this->animationState >> 1]; ptr = &gUnk_080B7848[(this->animationState >> 1) * 2]; - sub_08008782(this, -(gPlayerState.skills & SKILL_ROCK_BREAKER) != 0, ptr[0], ptr[1]); + DoTileInteractionOffset(this, -(gPlayerState.skills & SKILL_ROCK_BREAKER) != 0, ptr[0], ptr[1]); sub_08078E84(this, &gPlayerEntity.base); } diff --git a/src/playerItem/playerItemFireRodProjectile.c b/src/playerItem/playerItemFireRodProjectile.c index eb5c4005..c80c7894 100644 --- a/src/playerItem/playerItemFireRodProjectile.c +++ b/src/playerItem/playerItemFireRodProjectile.c @@ -79,7 +79,7 @@ void PlayerItemFireRodProjectile_Action1(PlayerItemFireRodProjectileEntity* this CreateFx(super, FX_SWORD_MAGIC, 0); DeleteThisEntity(); } - if (sub_08008790(super, 0xc)) { + if (DoTileInteractionHere(super, 0xc)) { DeleteThisEntity(); } super->child = CreatePlayerItem(PLAYER_ITEM_FIRE_ROD_PROJECTILE, 1, 0, this->unk_68); diff --git a/src/playerItem/playerItemGust.c b/src/playerItem/playerItemGust.c index 40e2a1be..d77d1747 100644 --- a/src/playerItem/playerItemGust.c +++ b/src/playerItem/playerItemGust.c @@ -42,7 +42,7 @@ typedef struct { u16 tileID; } Obj11; -Obj11* sub_08008782(Entity*, u32, u32, u32); +Obj11* DoTileInteractionOffset(Entity*, u32, u32, u32); extern const s8* const sOffsets[]; extern const s8 gUnk_0812AABC[]; @@ -101,7 +101,7 @@ static void sub_080ACC78(PlayerItemGustEntity* this) { if (child_offsets[this->offset_iter] == 0) { this->offset_iter = 0; } - o = sub_08008782(super, 0xe, child_offsets[this->offset_iter], child_offsets[this->offset_iter + 1]); + o = DoTileInteractionOffset(super, 0xe, child_offsets[this->offset_iter], child_offsets[this->offset_iter + 1]); if (o != NULL) { child = CreateObject(BUSH, o->type, o->type2); if (child != NULL) { diff --git a/src/playerItem/playerItemGustBig.c b/src/playerItem/playerItemGustBig.c index e0adbfcb..a2e18c99 100644 --- a/src/playerItem/playerItemGustBig.c +++ b/src/playerItem/playerItemGustBig.c @@ -25,7 +25,7 @@ extern void PlayerItemGustBig_Action1(PlayerItemGustBigEntity* this); extern void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this); extern void PlayerItemGustBig_Action3(PlayerItemGustBigEntity* this); -extern u32 sub_08007DD6(u32, const u16*); +extern u32 ActTileToTile(u32, const u16*); extern const u8 gUnk_08003E44[]; @@ -136,7 +136,7 @@ void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this) { s32 x; if (super->child == NULL) { GetNextFrame(super); - sub_08008790(super, 5); + DoTileInteractionHere(super, 5); } else { if ((super->child->gustJarState & 4) == 0) { DeleteThisEntity(); @@ -174,10 +174,10 @@ void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this) { if (super->type2 == 0) { sub_0800451C(super); } - if (sub_08007DD6(sub_080B1A0C(super, x, y), gUnk_080B3DF4) != 0) { + if (ActTileToTile(sub_080B1A0C(super, x, y), gUnk_080B3DF4) != 0) { return; } - if (GetRelativeCollisionTile(super, x, y) == 0x74) { + if (GetActTileRelative(super, x, y) == 0x74) { return; } if (sub_080040D8(super, (u8*)gUnk_08003E44, super->x.HALF.HI + x, super->y.HALF.HI + y) == 0) { diff --git a/src/playerItem/playerItemHeldObject.c b/src/playerItem/playerItemHeldObject.c index dee58c8b..669c77ca 100644 --- a/src/playerItem/playerItemHeldObject.c +++ b/src/playerItem/playerItemHeldObject.c @@ -121,8 +121,8 @@ void PlayerItemHeldObject_SubAction2(PlayerItemHeldObjectEntity* this) { super->direction = super->knockbackDirection; super->knockbackDuration = 0; } - if (GetRelativeCollisionTile(super, gUnk_081320C4[super->direction >> 2], - gUnk_081320C4[(super->direction >> 2) + 1]) == 0x74) { + if (GetActTileRelative(super, gUnk_081320C4[super->direction >> 2], + gUnk_081320C4[(super->direction >> 2) + 1]) == 0x74) { LinearMoveUpdate(super); } else { tile = sub_080B1B0C(super); diff --git a/src/playerItem/playerItemPacciCaneProjectile.c b/src/playerItem/playerItemPacciCaneProjectile.c index a5725d17..4c4bc005 100644 --- a/src/playerItem/playerItemPacciCaneProjectile.c +++ b/src/playerItem/playerItemPacciCaneProjectile.c @@ -30,7 +30,7 @@ void PlayerItemPacciCaneProjectile_Action4(PlayerItemPacciCaneProjectileEntity* void sub_08070458(PlayerItemPacciCaneProjectileEntity* this); extern void sub_08017744(Entity*); -extern u8* sub_08008782(Entity*, u32, u32, u32); +extern u8* DoTileInteractionOffset(Entity*, u32, u32, u32); void PlayerItemPacciCaneProjectile(PlayerItemPacciCaneProjectileEntity* this) { static void (*const PlayerItemPacciCaneProjectile_Actions[])(PlayerItemPacciCaneProjectileEntity*) = { @@ -104,7 +104,7 @@ void PlayerItemPacciCaneProjectile_Action1(PlayerItemPacciCaneProjectileEntity* cVar1 = gUnk_0811B9C8[super->animationState]; cVar2 = gUnk_0811B9C8[super->animationState + 1]; - iVar3 = sub_08008782(super, 10, cVar1, cVar2); + iVar3 = DoTileInteractionOffset(super, 10, cVar1, cVar2); if (iVar3) { pEVar4 = CreateObject(OBJECT_53, iVar3[5], iVar3[2]); if (pEVar4) { @@ -135,7 +135,7 @@ void PlayerItemPacciCaneProjectile_Action1(PlayerItemPacciCaneProjectileEntity* super->spritePriority.b0 = 7; this->unk_7c = GetTileIndex(COORD_TO_TILE(super), super->collisionLayer); InitializeAnimation(super, 0x14); - SetTile(0x4020, COORD_TO_TILE(super), super->collisionLayer); + SetBottomTile(0x4020, COORD_TO_TILE(super), super->collisionLayer); return; } } else { @@ -197,7 +197,7 @@ void sub_08070458(PlayerItemPacciCaneProjectileEntity* this) { COLLISION_OFF(super); super->speed = 0; if (this->unk_7c != 0) { - SetTile(this->unk_7c, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetBottomTile(this->unk_7c, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); } InitializeAnimation(super, 0x13); sub_08017744(super); diff --git a/src/playerItem/playerItemSword.c b/src/playerItem/playerItemSword.c index e9e45087..bed81f9f 100644 --- a/src/playerItem/playerItemSword.c +++ b/src/playerItem/playerItemSword.c @@ -361,7 +361,7 @@ void sub_080A7A84(PlayerItemSwordEntity* this) { uVar3 = -uVar3; } if (super->type != 0) { - sub_08008796(super, 0, super->x.HALF.HI + uVar3, super->y.HALF.HI + r5); + DoTileInteraction(super, 0, super->x.HALF.HI + uVar3, super->y.HALF.HI + r5); } else if (super->z.WORD == 0) { if (gPlayerState.skills & SKILL_ROCK_BREAKER) { tmp2 = 1; @@ -369,11 +369,11 @@ void sub_080A7A84(PlayerItemSwordEntity* this) { tmp2 = 0; } new_var = uVar3; - if (((sub_08008796(super, tmp2, super->x.HALF.HI + new_var, super->y.HALF.HI + r5) == NULL) && + if (((DoTileInteraction(super, tmp2, super->x.HALF.HI + new_var, super->y.HALF.HI + r5) == NULL) && (gPlayerState.sword_state != 0)) && ((gPlayerState.sword_state & 0xc0) == 0)) { new_var2 = super; - if (GetRelativeCollisionTile(new_var2, new_var, r5) == 0x2e) { + if (GetActTileRelative(new_var2, new_var, r5) == 0x2e) { SoundReqClipped(&gPlayerEntity.base, SFX_ITEM_GLOVES_KNOCKBACK); } else { SoundReqClipped(&gPlayerEntity.base, SFX_METAL_CLINK); @@ -406,7 +406,7 @@ void sub_080A7B98(PlayerItemSwordEntity* this) { for (i = 0; i < 3; i++) { xOffset = -0x10; for (j = 0; j < 3; j++) { - sub_08008796(super, uVar2, super->x.HALF.HI + xOffset, super->y.HALF.HI + yOffset); + DoTileInteraction(super, uVar2, super->x.HALF.HI + xOffset, super->y.HALF.HI + yOffset); xOffset += 0x10; } yOffset += 0x10; diff --git a/src/playerItem/playerItemSwordBeam.c b/src/playerItem/playerItemSwordBeam.c index 0d572c09..4b110c43 100644 --- a/src/playerItem/playerItemSwordBeam.c +++ b/src/playerItem/playerItemSwordBeam.c @@ -97,7 +97,7 @@ void PlayerItemSwordBeam_Action1(PlayerItemSwordBeamEntity* this) { CreateFx(super, FX_SWORD_MAGIC, 0); DeleteThisEntity(); } - if (sub_08008790(super, 0xc) != NULL) { + if (DoTileInteractionHere(super, 0xc) != NULL) { DeleteThisEntity(); } } else { diff --git a/src/playerUtils.c b/src/playerUtils.c index 7820a1e5..8ff5a7f9 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -59,7 +59,7 @@ extern ItemDefinition gItemDefinitions[]; extern ItemBehavior* (*const gCreateItemsFuncs[])(Item); -extern void DeleteLoadedTileEntity(u32, u32); +extern void UnregisterInteractTile(u32, u32); extern const u8 gUnk_080B3E80[]; // collisionData for tileType? @@ -1910,7 +1910,7 @@ void sub_080792D8(void) { gPlayerState.animation = ANIM_BOUNCE_NOCAP; } } - sub_080027EA(playerEntity, 0x280, playerEntity->knockbackDirection); + LinearMoveDirectionOLD(playerEntity, 0x280, playerEntity->knockbackDirection); sub_0807A5B8(playerEntity->knockbackDirection); } } @@ -2003,10 +2003,10 @@ bool32 sub_08079550(void) { } uVar3 = sub_080B1AE0(tilePos1, gPlayerEntity.base.collisionLayer); - uVar3 = sub_08007DD6(uVar3, gUnk_0811C1E8[gPlayerEntity.base.animationState >> 1]); + uVar3 = ActTileToTile(uVar3, gUnk_0811C1E8[gPlayerEntity.base.animationState >> 1]); if (uVar3 != 0) { uVar3 = sub_080B1AE0(tilePos2, gPlayerEntity.base.collisionLayer); - uVar3 = sub_08007DD6(uVar3, gUnk_0811C1E8[gPlayerEntity.base.animationState >> 1]); + uVar3 = ActTileToTile(uVar3, gUnk_0811C1E8[gPlayerEntity.base.animationState >> 1]); if (uVar3 != 0) { gPlayerState.pushedObject |= 0x80; if (gPlayerState.dash_state == 0 && (++gPlayerEntity.base.subtimer <= 5)) { @@ -2332,13 +2332,13 @@ bool32 sub_08079C30(Entity* param_1) { return TRUE; } - if (gPlayerState.floor_type != sub_08007DD6(GetRelativeCollisionTile(param_1, 0, -1), (u16*)gUnk_08007CAC)) + if (gPlayerState.floor_type != ActTileToTile(GetActTileRelative(param_1, 0, -1), (u16*)gUnk_08007CAC)) return FALSE; - if (gPlayerState.floor_type != sub_08007DD6(GetRelativeCollisionTile(param_1, 2, 0), (u16*)gUnk_08007CAC)) + if (gPlayerState.floor_type != ActTileToTile(GetActTileRelative(param_1, 2, 0), (u16*)gUnk_08007CAC)) return FALSE; - if (gPlayerState.floor_type == sub_08007DD6(GetRelativeCollisionTile(param_1, -2, 0), (u16*)gUnk_08007CAC)) { + if (gPlayerState.floor_type == ActTileToTile(GetActTileRelative(param_1, -2, 0), (u16*)gUnk_08007CAC)) { return TRUE; } } @@ -2350,7 +2350,7 @@ bool32 sub_08079D48(void) { return TRUE; } else { if (!PlayerCheckNEastTile()) { - if (!sub_08007DD6((u16)GetActTile(&gPlayerEntity.base), gUnk_0811C268)) { + if (!ActTileToTile((u16)GetActTile(&gPlayerEntity.base), gUnk_0811C268)) { return TRUE; } } @@ -2397,7 +2397,7 @@ void sub_08079E58(s32 speed, u32 direction) { sub_08079E90(direction); } sub_080085B0(&gPlayerEntity.base); - sub_080027EA(&gPlayerEntity.base, (s16)speed, (u8)direction); + LinearMoveDirectionOLD(&gPlayerEntity.base, (s16)speed, (u8)direction); sub_0807A5B8(direction); } @@ -2588,8 +2588,8 @@ SurfaceType GetSurfaceCalcType(Entity* param_1, s32 x, s32 y) { gPlayerState.surfaceTimer++; } gPlayerState.floor_type_last = gPlayerState.floor_type; - tileType = GetRelativeCollisionTile(param_1, x, y); - return sub_08007DD6(tileType, (u16*)gUnk_08007CAC); + tileType = GetActTileRelative(param_1, x, y); + return ActTileToTile(tileType, (u16*)gUnk_08007CAC); } void EnablePlayerDraw(Entity* this) { @@ -2633,8 +2633,8 @@ u32 sub_0807A2F8(u32 param_1) { iVar4 = 0; uVar2 = sub_08004202(&gPlayerEntity.base, auStack36, uVar2); if (sub_080B1B44(uVar2 >> 1, 1)) { - if (!sub_08007DD6((u16)sub_080B1AE0((u16)(uVar2 >> 1), gPlayerEntity.base.collisionLayer), - gUnk_0811C1D8[gPlayerEntity.base.animationState >> 1])) { + if (!ActTileToTile((u16)sub_080B1AE0((u16)(uVar2 >> 1), gPlayerEntity.base.collisionLayer), + gUnk_0811C1D8[gPlayerEntity.base.animationState >> 1])) { break; } } else { @@ -2643,8 +2643,8 @@ u32 sub_0807A2F8(u32 param_1) { uVar1 = sub_08004202(&gPlayerEntity.base, auStack36, uVar1); if (sub_080B1B44(uVar1 >> 1, 1)) { - if (!sub_08007DD6((u16)sub_080B1AE0((uVar1 >> 1), gPlayerEntity.base.collisionLayer), - gUnk_0811C1D8[gPlayerEntity.base.animationState >> 1])) { + if (!ActTileToTile((u16)sub_080B1AE0((uVar1 >> 1), gPlayerEntity.base.collisionLayer), + gUnk_0811C1D8[gPlayerEntity.base.animationState >> 1])) { break; } } else { @@ -2857,7 +2857,7 @@ u32 GetCollisionTileInFront(Entity* this) { x = 0; break; } - return GetRelativeCollisionTile(this, x, y); + return GetActTileRelative(this, x, y); } void nullsub_505(void) { @@ -2941,7 +2941,7 @@ void sub_0807AB44(Entity* this, s32 xOffset, s32 yOffset) { if (object != NULL) { PositionRelative(this, object, xOffset << 0x10, yOffset << 0x10); object->child = (Entity*)ptr; - SetTile(0x404f, COORD_TO_TILE(object), object->collisionLayer); + SetBottomTile(0x404f, COORD_TO_TILE(object), object->collisionLayer); } } } @@ -3263,8 +3263,8 @@ void SetTileType(u32 tileType, u32 position, u32 layer) { u16* dest; if (tileType < 0x800) { - DeleteLoadedTileEntity(position, layer); - data = GetLayerByIndex(layer); + UnregisterInteractTile(position, layer); + data = GetTileBuffer(layer); metatile = data->unkData2[tileType]; data->mapData[position] = metatile; collisionData = gUnk_080B3E80[tileType]; @@ -3290,7 +3290,7 @@ void SetTileType(u32 tileType, u32 position, u32 layer) { } } } else if (tileType >= 0x4000) { // The tile type actually directly is a tileIndex - SetTile(tileType, position, layer); + SetBottomTile(tileType, position, layer); } else { RestorePrevTileEntity(position, layer); } @@ -3426,16 +3426,16 @@ void sub_0807B778(u32 position, u32 layer) { } } -void sub_0807B7D8(u32 param_1, u32 param_2, u32 param_3) { - if (param_1 == 53) { - CloneTile(53, param_2, param_3); - sub_0807B778(param_2, param_3); - sub_0807B778(param_2 + 1, param_3); - sub_0807B778(param_2 - 1, param_3); - sub_0807B778(param_2 + 64, param_3); - sub_0807B778(param_2 - 64, param_3); +void sub_0807B7D8(u32 type, u32 pos, u32 layer) { + if (type == 53) { + CloneTile(53, pos, layer); + sub_0807B778(pos, layer); + sub_0807B778(pos + 1, layer); + sub_0807B778(pos - 1, layer); + sub_0807B778(pos + 64, layer); + sub_0807B778(pos - 64, layer); } else { - SetTileType(param_1, param_2, param_3); + SetTileType(type, pos, layer); } } @@ -3481,8 +3481,8 @@ void sub_0807B9B8(u32 tileIndex, u32 position, u32 layer) { u16* dest; u16 tileType; - DeleteLoadedTileEntity(position, layer); - data = GetLayerByIndex(layer); + UnregisterInteractTile(position, layer); + data = GetTileBuffer(layer); data->mapData[position] = tileIndex; tileType = data->metatileTypes[tileIndex]; data->collisionData[position] = gUnk_080B3E80[tileType]; @@ -3512,9 +3512,9 @@ void RestorePrevTileEntity(u32 position, u32 layer) { u16* dest; u16* src; - DeleteLoadedTileEntity(position, layer); - data = GetLayerByIndex(layer); - data->mapData[position] = tileIndex = data->mapDataClone[position]; + UnregisterInteractTile(position, layer); + data = GetTileBuffer(layer); + data->mapData[position] = tileIndex = data->mapDataOriginal[position]; tileType = data->metatileTypes[tileIndex]; data->collisionData[position] = gUnk_080B3E80[tileType]; data->unkData3[position] = gUnk_080B37A0[tileType]; @@ -3548,7 +3548,7 @@ void sub_0807BB98(s32 basePosition, u32 layer, u32 width, u32 height) { u32 x; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - SetTile(0x4072, basePosition + x, layer); + SetBottomTile(0x4072, basePosition + x, layer); } basePosition += 0x40; } @@ -3853,21 +3853,21 @@ void LoadRoomGfx(void) { tmp = TRUE; } if (gRoomTransition.field2d == 0) { - MemCopy(gMapBottom.mapData, gMapBottom.mapDataClone, sizeof(gMapBottom.mapData)); - MemCopy(gMapTop.mapData, gMapTop.mapDataClone, sizeof(gMapBottom.mapData)); + MemCopy(gMapBottom.mapData, gMapBottom.mapDataOriginal, sizeof(gMapBottom.mapData)); + MemCopy(gMapTop.mapData, gMapTop.mapDataOriginal, sizeof(gMapBottom.mapData)); } else if (gRoomTransition.field2d == 2) { MemCopy(gMapBottom.mapData, gMapBottom.unkData3, 0x1000); - MemCopy(gMapBottom.mapDataClone, gMapBottom.mapData, 0x1000); - MemCopy(gMapBottom.unkData3, gMapBottom.mapDataClone, 0x1000); + MemCopy(gMapBottom.mapDataOriginal, gMapBottom.mapData, 0x1000); + MemCopy(gMapBottom.unkData3, gMapBottom.mapDataOriginal, 0x1000); MemCopy(gMapBottom.mapData + 0x800, gMapBottom.unkData3, 0x1000); - MemCopy(gMapBottom.mapDataClone + 0x800, gMapBottom.mapData + 0x800, 0x1000); - MemCopy(gMapBottom.unkData3, gMapBottom.mapDataClone + 0x800, 0x1000); + MemCopy(gMapBottom.mapDataOriginal + 0x800, gMapBottom.mapData + 0x800, 0x1000); + MemCopy(gMapBottom.unkData3, gMapBottom.mapDataOriginal + 0x800, 0x1000); MemCopy(gMapTop.mapData, gMapTop.unkData3, 0x1000); - MemCopy(gMapTop.mapDataClone, gMapTop.mapData, 0x1000); - MemCopy(gMapTop.unkData3, gMapTop.mapDataClone, 0x1000); + MemCopy(gMapTop.mapDataOriginal, gMapTop.mapData, 0x1000); + MemCopy(gMapTop.unkData3, gMapTop.mapDataOriginal, 0x1000); MemCopy(gMapTop.mapData + 0x800, gMapTop.unkData3, 0x1000); - MemCopy(gMapTop.mapDataClone + 0x800, gMapTop.mapData + 0x800, 0x1000); - MemCopy(gMapTop.unkData3, gMapTop.mapDataClone + 0x800, 0x1000); + MemCopy(gMapTop.mapDataOriginal + 0x800, gMapTop.mapData + 0x800, 0x1000); + MemCopy(gMapTop.unkData3, gMapTop.mapDataOriginal + 0x800, 0x1000); } if (!tmp) { sub_0807BBE4(); @@ -3946,10 +3946,10 @@ void sub_0807C460(void) { for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if (*mapBottom > 0x3fff) { - SetTile(*mapBottom, position, 1); + SetBottomTile(*mapBottom, position, 1); } if (*mapTop > 0x3fff) { - SetTile(*mapTop, position, 2); + SetBottomTile(*mapTop, position, 2); } mapBottom++; mapTop++; @@ -4188,8 +4188,8 @@ void sub_0807C810(void) { */ void CloneMapData(void) { gRoomTransition.field2d = 1; - MemCopy(&gMapBottom.mapData, &gMapBottom.mapDataClone, 0x2000); - MemCopy(&gMapTop.mapData, &gMapTop.mapDataClone, 0x2000); + MemCopy(&gMapBottom.mapData, &gMapBottom.mapDataOriginal, 0x2000); + MemCopy(&gMapTop.mapData, &gMapTop.mapDataOriginal, 0x2000); } void sub_0807C898(void) { diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index 82c2156c..d1052df8 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -44,7 +44,7 @@ void BoneProjectile_Action1(Entity* this) { if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { - sub_08016AD2(this); + UpdateCollisionLayer(this); if (--this->timer == 0) { this->action = 2; this->speed = 0x120; diff --git a/src/projectile/cannonballProjectile.c b/src/projectile/cannonballProjectile.c index 5f2e7e04..c5b4244f 100644 --- a/src/projectile/cannonballProjectile.c +++ b/src/projectile/cannonballProjectile.c @@ -63,15 +63,15 @@ void CannonballProjectile_Action2(Entity* this) { } bool32 sub_080AB5F4(Entity* this) { - switch (sub_080043E8(this)) { + switch (GetTileHazardType(this)) { case 1: - CreateItemOnGround(this); + CreatePitFallFX(this); return TRUE; case 2: - sub_080043A8(this); + CreateDrownFX(this); return TRUE; case 3: - CreateChestSpawner(this); + CreateLavaDrownFX(this); return TRUE; } return FALSE; diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c index 302615fe..c086f251 100644 --- a/src/projectile/dekuSeedProjectile.c +++ b/src/projectile/dekuSeedProjectile.c @@ -60,13 +60,13 @@ void DekuSeedProjectile_Action1(Entity* this) { if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } - sub_08016AD2(this); + UpdateCollisionLayer(this); if (--this->timer == 0) { this->action = 4; } } else { sub_0800417E(this, this->collisions); - sub_08016AD2(this); + UpdateCollisionLayer(this); InitializeAnimation(this, 0x19); sub_080A86A0(this); } @@ -99,7 +99,7 @@ void DekuSeedProjectile_Action2(Entity* this) { } } else { sub_0800417E(this, this->collisions); - sub_08016AD2(this); + UpdateCollisionLayer(this); InitializeAnimation(this, 0x19); sub_080A86A0(this); } diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index 3da1926c..2ef3867e 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -136,7 +136,7 @@ void DirtBallProjectile_Action2(Entity* this) { return; } - tmp = sub_080043E8(this); + tmp = GetTileHazardType(this); if (tmp != 0) { switch (tmp) { case 2: diff --git a/src/projectile/fireProjectile.c b/src/projectile/fireProjectile.c index fa5e2d5c..cd81f3d3 100644 --- a/src/projectile/fireProjectile.c +++ b/src/projectile/fireProjectile.c @@ -57,7 +57,7 @@ void FireProjectile_Action2(Entity* this) { if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { - sub_08016AD2(this); + UpdateCollisionLayer(this); } } else { this->action = 3; diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index cac30dd3..d40d2a92 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -28,7 +28,8 @@ void GleerokProjectile(GleerokProjectileEntity* this) { } void GleerokProjectile_OnTick(GleerokProjectileEntity* this) { - if (((super->type != 3) && ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) && ((super->contactFlags & 0x7f) != 0x1e)) { + if (((super->type != 3) && ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) && + ((super->contactFlags & 0x7f) != 0x1e)) { super->action = 3; COLLISION_OFF(super); InitializeAnimation(super, 0x53); @@ -95,7 +96,7 @@ void GleerokProjectile_Init(GleerokProjectileEntity* this) { void GleerokProjectile_Action1(GleerokProjectileEntity* this) { if (super->type == 3) { if (GravityUpdate(super, Q_8_8(24.0)) == 0) { - sub_08008790(super, 7); + DoTileInteractionHere(super, 7); CreateFx(super, FX_ROCK, 0); DeleteThisEntity(); } diff --git a/src/projectile/iceProjectile.c b/src/projectile/iceProjectile.c index 1fa2ea7a..7a430b38 100644 --- a/src/projectile/iceProjectile.c +++ b/src/projectile/iceProjectile.c @@ -59,7 +59,7 @@ void IceProjectile_Action2(Entity* this) { if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { - sub_08016AD2(this); + UpdateCollisionLayer(this); } } else { this->action = 3; diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index 0062d622..64142a9c 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -118,7 +118,7 @@ void MandiblesProjectile_Action2(MandiblesProjectileEntity* this) { } this->unk_78 = TILE(super->x.HALF.HI, super->y.HALF.HI); if (GetTileType(this->unk_78, super->collisionLayer) == 0x4000) { - SetTile(0x4005, this->unk_78, super->collisionLayer); + SetBottomTile(0x4005, this->unk_78, super->collisionLayer); } } diff --git a/src/projectile/removableDust.c b/src/projectile/removableDust.c index 40ef0640..e89cd3b4 100644 --- a/src/projectile/removableDust.c +++ b/src/projectile/removableDust.c @@ -91,7 +91,7 @@ void sub_080AA494(RemovableDustEntity* this) { } super->type2 = index; super->spritePriority.b0 = 7; - SetTile(0x4068, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); + SetBottomTile(0x4068, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); } void sub_080AA534(Entity* this) { diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c index e8ebe565..7dc35d0c 100644 --- a/src/projectile/rockProjectile.c +++ b/src/projectile/rockProjectile.c @@ -43,7 +43,7 @@ void RockProjectile_Action1(Entity* this) { if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { - sub_08016AD2(this); + UpdateCollisionLayer(this); if (--this->timer == 0) { this->action = 3; } @@ -51,7 +51,7 @@ void RockProjectile_Action1(Entity* this) { } else { sub_0800417E(this, this->collisions); sub_080A8178(this); - sub_08016AD2(this); + UpdateCollisionLayer(this); } } diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c index b2e97623..c1cb7adc 100644 --- a/src/projectile/spiderWeb.c +++ b/src/projectile/spiderWeb.c @@ -246,7 +246,7 @@ void sub_080AA9E0(Entity* this) { void sub_080AAA68(Entity* this) { static const u16 typeTiles[] = { 16419, 16421, 16422, 16420 }; - SetTile(typeTiles[this->type], TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); + SetBottomTile(typeTiles[this->type], TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); } void sub_080AAAA8(SpiderWebEntity* this) { diff --git a/src/projectile/windProjectile.c b/src/projectile/windProjectile.c index 499409f2..2682b104 100644 --- a/src/projectile/windProjectile.c +++ b/src/projectile/windProjectile.c @@ -64,7 +64,7 @@ void WindProjectile_Action2(Entity* this) { if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { - sub_08016AD2(this); + UpdateCollisionLayer(this); } } else { this->action = 3; diff --git a/src/projectile/winder.c b/src/projectile/winder.c index 5cbea569..b8caaefb 100644 --- a/src/projectile/winder.c +++ b/src/projectile/winder.c @@ -119,7 +119,7 @@ void Winder_SetPositions(WinderEntity* this) { bool32 Winder_CheckForRailings(WinderEntity* this, u32 dir) { u32 tile; u32 val; - LayerStruct* layer = GetLayerByIndex(super->collisionLayer); + LayerStruct* layer = GetTileBuffer(super->collisionLayer); u32 collisionData; tile = TILE(super->x.HALF.HI, super->y.HALF.HI); diff --git a/src/roomInit.c b/src/roomInit.c index 2f832223..8c1b6899 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -807,10 +807,10 @@ extern EntityData gUnk_080D7D34; void sub_StateChange_GreatFairies_Exit(void) { if (GetInventoryValue(ITEM_FOURSWORD)) { - SetTile(0x4072, 0x14d, 1); - SetTile(0x4072, 0x10c, 1); - SetTile(0x4090, 0x14c, 1); - SetTile(0x4090, 0x18c, 1); + SetBottomTile(0x4072, 0x14d, 1); + SetBottomTile(0x4072, 0x10c, 1); + SetBottomTile(0x4090, 0x14c, 1); + SetBottomTile(0x4090, 0x18c, 1); LoadRoomEntityList(&gUnk_080D7D34); } } @@ -1051,8 +1051,8 @@ void sub_StateChange_RoyalValley_Main(void) { EnableRandomDrops(); sub_08059278(); - SetTile(0x4072, 0xa47, 1); - SetTile(0x4072, 0xc47, 1); + SetBottomTile(0x4072, 0xa47, 1); + SetBottomTile(0x4072, 0xc47, 1); if (CheckGlobalFlag(MAZE_CLEAR)) if (gRoomTransition.player_status.start_pos_x == 0x78 && gRoomTransition.player_status.start_pos_y == 0x278) @@ -4446,7 +4446,7 @@ void sub_0804E150(void) { uVar3 = 1 << gSave.global_progress; for (; pTileData[1] != 0; pTileData += 3) { if ((pTileData[0] & uVar3) != 0) { - SetTile(pTileData[2], pTileData[1], 1); + SetBottomTile(pTileData[2], pTileData[1], 1); } } if (CheckLocalFlag(SHOP05_OPEN) == 0) { @@ -4454,7 +4454,7 @@ void sub_0804E150(void) { uVar3 = 1 << gSave.global_progress; for (; pTileData[0] != 0; pTileData += 3) { if ((pTileData[0] & uVar3) != 0) { - SetTile(pTileData[2], pTileData[1], 1); + SetBottomTile(pTileData[2], pTileData[1], 1); } } } @@ -4463,7 +4463,7 @@ void sub_0804E150(void) { uVar3 = 1 << gSave.global_progress; for (; pTileData[0] != 0; pTileData += 3) { if ((pTileData[0] & uVar3) != 0) { - SetTile(pTileData[2], pTileData[1], 1); + SetBottomTile(pTileData[2], pTileData[1], 1); } } } @@ -5043,22 +5043,22 @@ void sub_StateChange_LakeHylia_Main(void) { if ((gSave.global_progress > 3) && CheckGlobalFlag(TINGLE_TALK1ST)) { LoadRoomEntityList(&gUnk_080F3C44); } - SetTile(0x4091, 0x590, 1); - SetTile(0x4091, 0x591, 1); - SetTile(0x4091, 0x592, 1); - SetTile(0x4091, 0x593, 1); - SetTile(0x4091, 0x594, 1); - SetTile(0x4091, 0x5d0, 1); - SetTile(0x4091, 0x610, 1); - SetTile(0x4091, 0x650, 1); - SetTile(0x4091, 0x5d4, 1); - SetTile(0x4091, 0x614, 1); - SetTile(0x4091, 0x654, 1); - SetTile(0x4091, 0x690, 1); - SetTile(0x4091, 0x691, 1); - SetTile(0x4091, 0x692, 1); - SetTile(0x4091, 0x693, 1); - SetTile(0x4091, 0x694, 1); + SetBottomTile(0x4091, 0x590, 1); + SetBottomTile(0x4091, 0x591, 1); + SetBottomTile(0x4091, 0x592, 1); + SetBottomTile(0x4091, 0x593, 1); + SetBottomTile(0x4091, 0x594, 1); + SetBottomTile(0x4091, 0x5d0, 1); + SetBottomTile(0x4091, 0x610, 1); + SetBottomTile(0x4091, 0x650, 1); + SetBottomTile(0x4091, 0x5d4, 1); + SetBottomTile(0x4091, 0x614, 1); + SetBottomTile(0x4091, 0x654, 1); + SetBottomTile(0x4091, 0x690, 1); + SetBottomTile(0x4091, 0x691, 1); + SetBottomTile(0x4091, 0x692, 1); + SetBottomTile(0x4091, 0x693, 1); + SetBottomTile(0x4091, 0x694, 1); } u32 sub_unk3_LakeHylia_Beanstalk(void) { @@ -5733,8 +5733,8 @@ void sub_StateChange_HyruleField_LonLonRanch(void) { } if (!CheckKinstoneFused(KINSTONE_29)) { LoadRoomEntityList(&gUnk_080F7860); - SetTile(0x4072, 0xd88, 1); - SetTile(0x4096, 0xdc8, 1); + SetBottomTile(0x4072, 0xd88, 1); + SetBottomTile(0x4096, 0xdc8, 1); } if ((gSave.global_progress > 3) && CheckGlobalFlag(TINGLE_TALK1ST)) { LoadRoomEntityList(&gUnk_080F78A0); diff --git a/src/scroll.c b/src/scroll.c index 7c30e701..3baf20fb 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -64,7 +64,7 @@ void sub_08080910(s32); extern u8 gMapDataTopSpecial[]; -extern const s8 gUnk_080169A4[]; +extern const s8 gShakeOffsets[]; void UpdateScroll(void) { static void (*const gUnk_0811E768[])(RoomControls*) = { @@ -350,8 +350,8 @@ void sub_08080040(RoomControls* controls) { void sub_08080108(RoomControls* controls) { controls->scrollSubAction = 4; - MemCopy(gMapBottom.mapData, gMapBottom.mapDataClone, sizeof(gMapBottom.mapData)); - MemCopy(gMapTop.mapData, gMapTop.mapDataClone, sizeof(gMapTop.mapData)); + MemCopy(gMapBottom.mapData, gMapBottom.mapDataOriginal, sizeof(gMapBottom.mapData)); + MemCopy(gMapTop.mapData, gMapTop.mapDataOriginal, sizeof(gMapTop.mapData)); sub_08080368(); gUnk_02034480.unk_00 = gUnk_0200B640; MemCopy(gUnk_02022830, gUnk_020246B0, 0x1800); @@ -422,8 +422,8 @@ u32 sub_08080278(void) { u16* ptr1 = (u16*)gUnk_02022830; u16* mapBottomData = gMapBottom.mapData; u16* mapTopData = gMapTop.mapData; - u16* mapBottomDataClone = gMapBottom.mapDataClone; - u16* mapTopDataClone = gMapTop.mapDataClone; + u16* mapBottomDataClone = gMapBottom.mapDataOriginal; + u16* mapTopDataClone = gMapTop.mapDataOriginal; u32 width = gRoomControls.width >> 4; u32 height = (gRoomControls.height >> 4) << 6; @@ -761,7 +761,7 @@ void sub_08080930(u32 unused) { SetInitializationPriority(); } -LayerStruct* GetLayerByIndex(u32 param_1) { +LayerStruct* GetTileBuffer(u32 param_1) { if (param_1 == 2) { return &gMapTop; } else { @@ -904,7 +904,7 @@ void sub_08080BC4(void) { tmpY = ((gRoomControls.scroll_y - gRoomControls.origin_y) & 0xf) + 8; if (gRoomControls.shake_duration != 0) { gRoomControls.shake_duration--; - ptr = &gUnk_080169A4[gRoomControls.shake_magnitude * 0x10 + (gRoomControls.shake_duration & 0xe)]; + ptr = &gShakeOffsets[gRoomControls.shake_magnitude * 0x10 + (gRoomControls.shake_duration & 0xe)]; if (gMapBottom.bgSettings != NULL) { gMapBottom.bgSettings->xOffset = ptr[0] + tmpX; gMapBottom.bgSettings->yOffset = ptr[1] + tmpY; diff --git a/src/text.c b/src/text.c index 6cadf99c..b8ee3169 100644 --- a/src/text.c +++ b/src/text.c @@ -7,6 +7,8 @@ #include "message.h" #include "fileselect.h" +extern void UnpackTextNibbles(void*, u8*); + extern u8 gUnk_02036AD8; extern u8 gUnk_02036A58; @@ -609,19 +611,19 @@ u32 sub_0805F76C(u32 textIdOrPtr, WStruct* param_2) { } static u32 sub_0805F7A0(u32 param_1) { - u32 uVar1; - u32 uVar2; - u32 uVar3; + u32 mask; + u32 i; + u32 j; - uVar1 = 0xf; - for (uVar2 = 0; uVar2 < 8; uVar2++) { - if (uVar1 != (param_1 & uVar1)) + mask = 0xf; + for (i = 0; i < 8; i++) { + if (mask != (param_1 & mask)) break; - uVar1 <<= 4; + mask <<= 4; } - for (uVar3 = uVar2; (uVar2 < 8 && (uVar1 != (param_1 & uVar1))); uVar1 <<= 4, uVar2++) {} - uVar2 -= uVar3; - return (uVar2 << 8) | uVar3; + for (j = i; (i < 8 && (mask != (param_1 & mask))); mask <<= 4, i++) {} + i -= j; + return (i << 8) | j; } u32 sub_0805F7DC(u32 r0, WStruct* r1) { @@ -656,12 +658,12 @@ void sub_0805F820(WStruct* r0, u32* r1) { u32 uVar7; u8* puVar8; u8* temp; - void* temp2; + void* buffer_loc; VStruct* temp3; u32 temp4; if (r0->unk4 - r0->unk6 > 0) { - sub_08002724(r1, &gUnk_02036A58); + UnpackTextNibbles(r1, &gUnk_02036A58); if (r0->unk1 == 0) { u32 tmp = sub_0805F7A0(*r1); uVar6 = tmp & 0xf; @@ -680,7 +682,7 @@ void sub_0805F820(WStruct* r0, u32* r1) { } puVar8 = &gUnk_02036A58 + uVar6; - temp2 = r0->unk8; + buffer_loc = r0->unk8; temp = gUnk_0810942E[r0->bgColor].filler0[r0->charColor * 2]; uVar7 = r0->unk6; r0->unk6 += uVar3; @@ -688,13 +690,13 @@ void sub_0805F820(WStruct* r0, u32* r1) { temp4 = r0->unk04; if (temp4 != 1) { while (uVar3-- > 0) { - sub_080026C4(puVar8, temp2, temp, uVar7); + sub_080026C4(puVar8, buffer_loc, temp, uVar7); puVar8++; uVar7++; } } else { while (uVar3-- > 0) { - sub_080026F2(puVar8, temp2, temp, uVar7); + sub_080026F2(puVar8, buffer_loc, temp, uVar7); puVar8++; uVar7++; } @@ -730,7 +732,7 @@ void sub_0805F918(u32 idx, u32 idx2, void* dest) { idx3 = 0; for (i = 0; i < 3; i++) { puVar2 = &gUnk_02036A58; - sub_08002724(puVar1, &gUnk_02036A58); + UnpackTextNibbles(puVar1, &gUnk_02036A58); puVar1 += 0x40; for (j = 0; j < 8; j++) { diff --git a/src/worldEvent/worldEvent17.c b/src/worldEvent/worldEvent17.c index 9b96ecb4..3541626d 100644 --- a/src/worldEvent/worldEvent17.c +++ b/src/worldEvent/worldEvent17.c @@ -34,7 +34,7 @@ void sub_08054EB8(Entity* this, ScriptExecutionContext* context) { void sub_08054EFC(Entity* this, ScriptExecutionContext* context) { Entity* effect; u32 tmp = COORD_TO_TILE(this) - 0x40; - SetTile(0x4074, tmp, 1); + SetBottomTile(0x4074, tmp, 1); this->collisionLayer = 2; UpdateSpriteForCollisionLayer(this); effect = CreateFx(this, FX_BIG_EXPLOSION, 0); From dcc596ed8763efd9f71ce9a669cb67a1849d7c2b Mon Sep 17 00:00:00 2001 From: theo3 Date: Sun, 31 Dec 2023 21:24:07 -0800 Subject: [PATCH 08/10] define collisions --- asm/src/intr.s | 248 ++++++++++-------- include/definitions.h | 4 +- include/entity.h | 40 ++- include/player.h | 2 +- src/code_08049DF4.c | 8 +- src/collision.c | 4 +- src/enemy/acroBandits.c | 2 +- src/enemy/armos.c | 6 +- src/enemy/beetle.c | 4 +- src/enemy/bobomb.c | 2 +- src/enemy/bowMoblin.c | 2 +- src/enemy/chaser.c | 2 +- src/enemy/chuchuBoss.c | 8 +- src/enemy/cloudPiranha.c | 2 +- src/enemy/crow.c | 2 +- src/enemy/darkNut.c | 2 +- src/enemy/enemy50.c | 8 +- src/enemy/eyegore.c | 6 +- src/enemy/flyingPot.c | 4 +- src/enemy/flyingSkull.c | 4 +- src/enemy/ghini.c | 4 +- src/enemy/gibdo.c | 8 +- src/enemy/gleerok.c | 8 +- src/enemy/hangingSeed.c | 2 +- src/enemy/helmasaur.c | 2 +- src/enemy/keaton.c | 2 +- src/enemy/lakitu.c | 2 +- src/enemy/leever.c | 2 +- src/enemy/likeLike.c | 10 +- src/enemy/madderpillar.c | 4 +- src/enemy/mazaalBracelet.c | 6 +- src/enemy/moldworm.c | 6 +- src/enemy/mulldozer.c | 2 +- src/enemy/peahat.c | 6 +- src/enemy/pesto.c | 6 +- src/enemy/rockChuchu.c | 2 +- src/enemy/rollobite.c | 4 +- src/enemy/rupeeLike.c | 4 +- src/enemy/scissorsBeetle.c | 2 +- src/enemy/spark.c | 2 +- src/enemy/spearMoblin.c | 4 +- src/enemy/spinyBeetle.c | 2 +- src/enemy/spinyChuchu.c | 2 +- src/enemy/stalfos.c | 6 +- src/enemy/takkuri.c | 2 +- src/enemy/tektite.c | 2 +- src/enemy/tektiteGolden.c | 2 +- src/enemy/vaatiArm.c | 6 +- src/enemy/vaatiBall.c | 2 +- src/enemy/vaatiProjectile.c | 4 +- src/enemy/vaatiRebornEnemy.c | 4 +- src/enemy/vaatiTransfigured.c | 4 +- src/enemy/vaatiTransfiguredEye.c | 2 +- src/enemy/vaatiWrath.c | 2 +- src/enemy/wisp.c | 2 +- src/enemy/wizzrobeIce.c | 2 +- src/enemy/wizzrobeWind.c | 2 +- src/enemyUtils.c | 6 +- src/interrupts.c | 5 +- src/npc/cat.c | 2 +- src/npc/npc5.c | 6 +- src/object.c | 2 +- src/object/barrelSpiderweb.c | 8 +- src/object/bigIceBlock.c | 2 +- src/object/bush.c | 2 +- src/object/dirtParticle.c | 6 +- src/object/evilSpirit.c | 2 +- src/object/eyeSwitch.c | 4 +- src/object/fairy.c | 6 +- src/object/gleerokParticle.c | 2 +- src/object/hittableLever.c | 4 +- src/object/itemOnGround.c | 8 +- src/object/jarPortal.c | 4 +- src/object/lavaPlatform.c | 6 +- src/object/lightableSwitch.c | 8 +- src/object/lilypadLarge.c | 2 +- src/object/minecart.c | 6 +- src/object/mineralWaterSource.c | 2 +- src/object/objectA8.c | 4 +- src/object/objectOnSpinyBeetle.c | 6 +- src/object/playerClone.c | 2 +- src/object/pot.c | 4 +- src/object/pullableMushroom.c | 4 +- src/object/sanctuaryStoneTablet.c | 4 +- src/object/smallIceBlock.c | 4 +- src/object/smokeParticle.c | 2 +- src/object/treeThorns.c | 2 +- src/object/unusedSkull.c | 4 +- src/object/whirlwind.c | 4 +- src/physics.c | 2 +- src/player.c | 8 +- src/playerItem.c | 2 +- src/playerItem/playerItemBoomerang.c | 4 +- src/playerItem/playerItemBottle.c | 2 +- src/playerItem/playerItemBow.c | 2 +- src/playerItem/playerItemDashSword.c | 2 +- src/playerItem/playerItemGust.c | 2 +- src/playerItem/playerItemGustBig.c | 4 +- src/playerItem/playerItemHeldObject.c | 2 +- src/playerItem/playerItemLantern.c | 2 +- .../playerItemPacciCaneProjectile.c | 2 +- src/playerItem/playerItemShield.c | 2 +- src/playerItem/playerItemSword.c | 4 +- src/playerUtils.c | 8 +- src/projectile/arrowProjectile.c | 2 +- src/projectile/boneProjectile.c | 2 +- src/projectile/darkNutSwordSlash.c | 2 +- src/projectile/dekuSeedProjectile.c | 4 +- src/projectile/dirtBallProjectile.c | 2 +- src/projectile/gleerokProjectile.c | 3 +- src/projectile/guardLineOfSight.c | 4 +- src/projectile/keatonDagger.c | 2 +- src/projectile/lakituLightning.c | 2 +- src/projectile/mandiblesProjectile.c | 2 +- src/projectile/moblinSpear.c | 2 +- src/projectile/octorokBossProjectile.c | 4 +- src/projectile/projectile5.c | 2 +- src/projectile/removableDust.c | 2 +- src/projectile/rockProjectile.c | 2 +- src/projectile/spiderWeb.c | 2 +- src/projectile/stalfosProjectile.c | 2 +- src/projectile/v1DarkMagicProjectile.c | 2 +- src/projectile/v1FireProjectile.c | 2 +- src/projectile/v2Projectile.c | 2 +- src/projectileUtils.c | 2 +- 125 files changed, 388 insertions(+), 336 deletions(-) diff --git a/asm/src/intr.s b/asm/src/intr.s index c2dab21d..86ec0618 100644 --- a/asm/src/intr.s +++ b/asm/src/intr.s @@ -286,77 +286,80 @@ UpdateCollision: @ 0x080B1C54 arm_func_start arm_CollideAll arm_CollideAll: @ 0x080B1C7C + THIS .req r4 + OTHER .req r5 + push {r4, r5, r6, r7, r8, sb, sl, lr} add r0, pc, #0x104 @ =_080B1D8C ldm r0, {r8, sb, sl} ldrb sl, [sl] cmp sl, #0 beq _080B1D84 - ldr r8, [r8] + ldr r8, [r8] // load entity mov r7, r8 -_080B1C9C: - ldr r4, [r8, #8] - ldrb r0, [r4, #0x10] - ands r0, r0, #0x80 - beq _080B1D78 - ldrb r0, [r4, #0x3c] - and r0, r0, #7 +next_this: + ldr THIS, [r8, #8] + ldrb r0, [THIS, #0x10] + ands r0, r0, #0x80 // disable collision flag + beq end_check_this + ldrb r0, [THIS, #0x3c] // collisionFlags + and r0, r0, #7 // first 3 bits mov r1, #1 - lsl r6, r1, r0 - ldrb r3, [r4, #0x3c] - ldrb r2, [r4, #0x3d] + lsl r6, r1, r0 // 1 << (collisionFlags & 7) + ldrb r3, [THIS, #0x3c] + ldrb r2, [THIS, #0x3d] // iframes mov ip, sl -_080B1CC8: +next_other: // r4 = this, r5 = other subs ip, ip, #1 - bmi _080B1D78 - ldr r5, [sb, ip, lsl #2] - cmp r4, r5 - beq _080B1CC8 - ldr r0, [r5, #0x3b] - ands r0, r0, r6 - beq _080B1CC8 - ldrb r0, [r5, #0x10] + bmi end_check_this + ldr OTHER, [sb, ip, lsl #2] + cmp THIS, OTHER + beq next_other + ldr r0, [OTHER, #0x3b] // collisionMask + ands r0, r0, r6 // other.collisionMask & (1 << m) + beq next_other + ldrb r0, [OTHER, #0x10] // disable collision flag ands r0, r0, #0x80 - beq _080B1CC8 - ldrb r0, [r4, #0x38] - ldrb r1, [r5, #0x38] + beq next_other + ldrb r0, [THIS, #0x38] // collisionLayer + ldrb r1, [OTHER, #0x38] ands r0, r0, r1 - beq _080B1CC8 - ldrb r0, [r5, #0x3c] + beq next_other + ldrb r0, [OTHER, #0x3c] // collisionFlags orr r0, r0, r3 - lsrs r0, r0, #7 + lsrs r0, r0, #7 // top bhs _080B1D20 - ldrb r0, [r5, #0x3d] + ldrb r0, [OTHER, #0x3d] // iframes orrs r0, r0, r2 - bne _080B1CC8 + bne next_other _080B1D20: bl arm_CalcCollision cmp r0, #0 - beq _080B1CC8 - ldrb r3, [r4, #0x3c] - ldrb r0, [r4, #0x3d] - ldrb r1, [r4, #0x43] + beq next_other + ldrb r3, [THIS, #0x3c] + ldrb r0, [THIS, #0x3d] // iframes + ldrb r1, [THIS, #0x43] // hitType orr r2, r0, r1 - ldrb r0, [r5, #0x41] + ldrb r0, [OTHER, #0x41] // OTHER processing a collision already? ands r0, r0, #0x80 - bne _080B1D58 - str r4, [r5, #0x4c] - ldrb r0, [r4, #0x40] + bne _080B1D58 // branch if set + str THIS, [OTHER, #0x4c] // contactedEntity + ldrb r0, [THIS, #0x40] orr r0, r0, #0x80 - strb r0, [r5, #0x41] + strb r0, [OTHER, #0x41] // contactFlags |= 0x80 _080B1D58: - ldrb r0, [r4, #0x41] + ldrb r0, [THIS, #0x41] // THIS processing a collision already? ands r0, r0, #0x80 - bne _080B1CC8 - str r5, [r4, #0x4c] - ldrb r0, [r5, #0x40] + bne next_other + str OTHER, [THIS, #0x4c] + ldrb r0, [OTHER, #0x40] orr r0, r0, #0x80 - strb r0, [r4, #0x41] - b _080B1CC8 -_080B1D78: + strb r0, [THIS, #0x41] + b next_other +end_check_this: ldr r8, [r8, #4] cmp r8, r7 - bne _080B1C9C + bne next_this _080B1D84: pop {r4, r5, r6, r7, r8, sb, sl, lr} bx lr @@ -366,56 +369,59 @@ _080B1D94: .4byte gCollidableCount arm_func_start arm_CalcCollision arm_CalcCollision: @ 0x080B1D98 - @ r6 = this, r7 = other + THIS .req r4 + OTHER .req r5 + BB_THIS .req r6 + BB_OTHER .req r7 push {r2, r3, r6, r7, r8, sb, ip, lr} - ldr r6, [r4, #0x48] - ldr r7, [r5, #0x48] - ldrh r0, [r4, #0x2e] - ldrh r1, [r5, #0x2e] + ldr BB_THIS, [THIS, #0x48] + ldr BB_OTHER, [OTHER, #0x48] + ldrh r0, [THIS, #0x2e] + ldrh r1, [OTHER, #0x2e] sub r0, r0, r1 - ldrsb r1, [r6] + ldrsb r1, [BB_THIS] add r0, r0, r1 - ldrsb r1, [r7] + ldrsb r1, [BB_OTHER] sub r0, r0, r1 - ldrb r1, [r6, #6] - ldrb r2, [r7, #6] + ldrb r1, [BB_THIS, #6] + ldrb r2, [BB_OTHER, #6] add r1, r1, r2 add r2, r0, r1 cmp r2, r1, lsl #1 - bhi _080B1F28 - ldrh r1, [r4, #0x32] - ldrh r2, [r5, #0x32] + bhi not_overlapping + ldrh r1, [THIS, #0x32] + ldrh r2, [OTHER, #0x32] sub r1, r1, r2 - ldrsb r2, [r6, #1] + ldrsb r2, [BB_THIS, #1] add r1, r1, r2 - ldrsb r2, [r7, #1] + ldrsb r2, [BB_OTHER, #1] sub r1, r1, r2 - ldrb r2, [r6, #7] - ldrb r3, [r7, #7] + ldrb r2, [BB_THIS, #7] + ldrb r3, [BB_OTHER, #7] add r2, r2, r3 add r3, r1, r2 cmp r3, r2, lsl #1 - bhi _080B1F28 + bhi not_overlapping mov r2, #5 mov r3, #5 - ldr r8, [r4, #0x3c] + ldr r8, [THIS, #0x3c] // collisionFlags & 0x10 ands r8, r8, #0x10 - ldrbne r2, [r6, #8] - ldr r8, [r5, #0x3c] + ldrbne r2, [BB_THIS, #8] // 3d hitbox + ldr r8, [OTHER, #0x3c] ands r8, r8, #0x10 - ldrbne r3, [r7, #8] + ldrbne r3, [BB_OTHER, #8] add r2, r2, r3 - ldrsh r8, [r4, #0x36] - ldrsh sb, [r5, #0x36] + ldrsh r8, [THIS, #0x36] // Z + ldrsh sb, [OTHER, #0x36] sub r8, r8, sb add r8, r2, r8 cmp r8, r2, lsl #1 - bhi _080B1F28 - ldrb r2, [r4, #0x3c] + bhi not_overlapping + ldrb r2, [THIS, #0x3c] // collisionFlags & BBOX_SOLID and r2, r2, #0x20 lsr r2, r2, #3 - ldrb r3, [r5, #0x3c] + ldrb r3, [OTHER, #0x3c] and r3, r3, #0x20 adds r2, r2, r3, lsr #2 beq _080B1E74 @@ -428,10 +434,10 @@ _080B1E74: mov ip, #0 bl arm_CalcCollisionDirection mov r6, r0 - ldrb r1, [r5, #0x3f] // hitType + ldrb r1, [OTHER, #0x3f] // hitType mov r0, #0x22 mul r1, r0, r1 - ldrb r0, [r4, #0x40] // hurtType + ldrb r0, [THIS, #0x40] // hurtType add r0, r0, r1 mov r1, #0xc mul r2, r0, r1 @@ -449,106 +455,120 @@ _080B1E74: mov lr, pc bx r7 _080B1ED4: - cmp r0, #0 - beq _080B1F20 - cmp r0, #2 - beq _080B1F1C - ldrb r0, [r4, #0x3c] + cmp r0, #0 // RESULT_NO_COLLISION + beq no_col + cmp r0, #2 // RESULT_COLLISION_WITHOUT_SET + beq col_no_set + // RESULT_COLLISION + ldrb r0, [THIS, #0x3c] // collisionFlags and r0, r0, #0x80 lsr r0, r0, #5 - ldrb r1, [r5, #0x3c] + ldrb r1, [OTHER, #0x3c] // collisionFlags and r1, r1, #0x80 lsr r1, r1, #4 add r0, r0, r1 add r1, pc, #0xF4 @ =_080B1FFC ldr r0, [r1, r0] mov lr, pc - bx r0 + bx r0 // jumptable 0 1 2 _080B1F10: - strb r6, [r5, #0x3e] + strb r6, [OTHER, #0x3e] eor r6, r6, #0x10 - strb r6, [r4, #0x3e] -_080B1F1C: + strb r6, [THIS, #0x3e] +col_no_set: mov r0, #1 -_080B1F20: +no_col: pop {r2, r3, r6, r7, r8, sb, ip, lr} bx lr -_080B1F28: +not_overlapping: mov r0, #0 - b _080B1F20 + b no_col + // BBOX_SOLID THIS arm_func_start arm_sub_080B1F30 arm_sub_080B1F30: @ 0x080B1F30 - ldrh r0, [r4, #0x2e] - ldrh r1, [r5, #0x2e] + ldrh r0, [THIS, #0x2e] + ldrh r1, [OTHER, #0x2e] sub r0, r0, r1 - ldrsb r1, [r7] + ldrsb r1, [BB_OTHER] sub r0, r0, r1 - ldrh r1, [r4, #0x32] - ldrh r2, [r5, #0x32] + ldrh r1, [THIS, #0x32] + ldrh r2, [OTHER, #0x32] sub r1, r1, r2 - ldrsb r2, [r7, #1] + ldrsb r2, [BB_OTHER, #1] sub r1, r1, r2 bx lr + // BBOX_SOLID OTHER arm_func_start arm_sub_080B1F5C arm_sub_080B1F5C: @ 0x080B1F5C - ldrh r0, [r4, #0x2e] - ldrh r1, [r5, #0x2e] + ldrh r0, [THIS, #0x2e] + ldrh r1, [OTHER, #0x2e] sub r0, r0, r1 - ldrsb r1, [r6] + ldrsb r1, [BB_THIS] add r0, r0, r1 - ldrh r1, [r4, #0x32] - ldrh r2, [r5, #0x32] + ldrh r1, [THIS, #0x32] + ldrh r2, [OTHER, #0x32] sub r1, r1, r2 - ldrsb r2, [r6, #1] + ldrsb r2, [BB_THIS, #1] add r1, r1, r2 bx lr + // BBOX_SOLID BOTH arm_func_start arm_sub_080B1F88 arm_sub_080B1F88: @ 0x080B1F88 - ldrh r0, [r4, #0x2e] - ldrh r1, [r5, #0x2e] + ldrh r0, [THIS, #0x2e] + ldrh r1, [OTHER, #0x2e] sub r0, r0, r1 - ldrh r1, [r4, #0x32] - ldrh r2, [r5, #0x32] + ldrh r1, [THIS, #0x32] + ldrh r2, [OTHER, #0x32] sub r1, r1, r2 bx lr + // BBOX_REFLECT OTHER arm_func_start arm_sub_080B1FA4 arm_sub_080B1FA4: @ 0x080B1FA4 - ldrb r0, [r5, #0x15] + ldrb r0, [r5, #0x15] // invert direction eor r0, r0, #0x10 b _080B1FB4 + + // BBOX_REFLECT THIS _080B1FB0: - ldrb r0, [r4, #0x15] + ldrb r0, [THIS, #0x15] // direction _080B1FB4: - sub r1, r0, #8 - and r1, r1, #0x1f - sub r1, r6, r1 - and r1, r1, #0x1f + sub r1, r0, #8 // turn counterclockwise + and r1, r1, #0x1f // normalize + sub r1, r6, r1 // sub calcDir + and r1, r1, #0x1f // normalize cmp r1, #0x11 - bxlo lr - sub r0, r6, r0 - sub r0, r0, #8 - and r0, r0, #0x1f - sub r6, r6, r0, lsl #1 + bxlo lr // branch if facing to the right + sub r0, r6, r0 // sub calcDir + sub r0, r0, #8 // turn counterclockwise + and r0, r0, #0x1f // normalize + sub r6, r6, r0, lsl #1 // calcDir -= 2 * temp and r6, r6, #0x1f bx lr + // BBOX_REFLECT BOTH arm_func_start arm_sub_080B1FE4 arm_sub_080B1FE4: @ 0x080B1FE4 - ldrb r6, [r4, #0x15] + ldrb r6, [THIS, #0x15] // direction + + // BBOX_REFLECT NONE, BBOX_SOLID NONE _080B1FE8: bx lr + + _080B1FEC: .4byte ram_sub_080B1FE8 _080B1FF0: .4byte ram_sub_080B1F30 _080B1FF4: .4byte ram_sub_080B1F5C _080B1FF8: .4byte ram_sub_080B1F88 + _080B1FFC: .4byte ram_sub_080B1FE8 _080B2000: .4byte ram_sub_080B1FB0 _080B2004: .4byte ram_sub_080B1FA4 _080B2008: .4byte ram_sub_080B1FE4 + _080B200C: .4byte gCollidableList _080B2010: .4byte gCollidableCount _080B2014: .4byte gCollisionMtx diff --git a/include/definitions.h b/include/definitions.h index 7764f76f..088635db 100644 --- a/include/definitions.h +++ b/include/definitions.h @@ -22,7 +22,7 @@ typedef struct EnemyDefinition { u8 health; s16 speed; u8 damageType; - u8 flags2; + u8 collisionMask; } EnemyDefinition; typedef struct ProjectileDefinition { @@ -43,7 +43,7 @@ typedef struct ProjectileDefinition { u8 field0x40; s16 speed; u8 damageType; - u8 flags2; + u8 collisionMask; } ProjectileDefinition; // Sprite data definition for objects and npcs diff --git a/include/entity.h b/include/entity.h index 8a66283c..455761c0 100644 --- a/include/entity.h +++ b/include/entity.h @@ -79,7 +79,39 @@ typedef enum { DirectionNorthWest = 0x1c, /**< North West. */ } Direction; -#define CONTACT_TAKE_DAMAGE 0x80 +/** Collision layer flags. */ +typedef enum { + COL_LAYER_NONE = 0x0, + COL_LAYER_BOTTOM = 0x1, + COL_LAYER_TOP = 0x2, + COL_LAYER_BOTH = 0x3 +} CollisionLayer; + +/** + * Collision class flags. + * An Entity's collision class is determined by the first 3 bits of #Entity::collisionFlags. + * What classes an Entity collides with is determined by the bitfield #Entity::collisionMask. +*/ +typedef enum { + COL_CLASS_NONE = 0x0, + COL_CLASS_PLAYER = 0x1, + COL_CLASS_ITEM = 0x2, + COL_CLASS_FLAMMABLE = 0x3, + COL_CLASS_4 = 0x4, + COL_CLASS_5 = 0x5, + COL_CLASS_6 = 0x6, + COL_CLASS_PACCI_OBJ = 0x7, +} CollisionClass; + +/** Collision flags. */ +typedef enum { + COL_FLAG_3D = 0x10, + COL_FLAG_SOLID = 0x20, + COL_FLAG_REFLECT = 0x80, +} CollisionFlags; + +#define COLLISION_MASK(layer) (1 << (layer)) +#define CONTACT_NOW 0x80 typedef struct { void* entity1; @@ -194,11 +226,11 @@ typedef struct Entity_ { /*0x2c*/ union SplitWord x; /**< X position, fixed point Q16.16. */ /*0x30*/ union SplitWord y; /**< Y position, fixed point Q16.16. */ /*0x34*/ union SplitWord z; /**< Z position, fixed point Q16.16. */ - /*0x38*/ u8 collisionLayer; /**< Collision layer. */ + /*0x38*/ u8 collisionLayer; /**< @see CollisionLayer. */ /*0x39*/ s8 interactType; /*0x3a*/ u8 gustJarState; /**< 4: grabbed by GustJar */ - /*0x3b*/ u8 flags2; /**< Debug visualization related? */ - /*0x3c*/ u8 collisionFlags; /**< Controls collision modes. */ + /*0x3b*/ u8 collisionMask; /**< Bitfield. @see CollisionClass */ + /*0x3c*/ u8 collisionFlags; /**< @see CollisionFlags, @see CollisionClass */ /*0x3d*/ s8 iframes; /**< Invulnerability frames. */ /*0x3e*/ u8 knockbackDirection; /**< Direction of knockback. */ /*0x3f*/ u8 hitType; /**< Behavior as a collision sender. */ diff --git a/include/player.h b/include/player.h index 0f0aa027..e344d0af 100644 --- a/include/player.h +++ b/include/player.h @@ -511,7 +511,7 @@ typedef struct { /*0x39*/ u8 field_0x39; /*0x3a*/ u8 field_0x3a; /*0x3b*/ u8 field_0x3b; - /*0x3c*/ u8 field_0x3c; + /*0x3c*/ u8 killed; /**< Non-zero if player is dead */ /*0x3d*/ u8 moleMittsState; /*0x3e*/ u8 swordDamage : 2; /* */ u8 filler14 : 6; diff --git a/src/code_08049DF4.c b/src/code_08049DF4.c index 89cf6216..c72da0d8 100644 --- a/src/code_08049DF4.c +++ b/src/code_08049DF4.c @@ -18,7 +18,7 @@ Entity* sub_08049DF4(u32 arg0) { } Entity* sub_08049E18(void) { - if ((gPlayerState.field_0x3c == 0) && + if ((gPlayerState.killed == 0) && !(gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_DISABLE_ITEMS | PL_FALLING | PL_FROZEN | PL_IN_MINECART | PL_PIT_IS_EXIT | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_CONVEYOR_PUSHED | PL_CLIMBING))) { @@ -29,7 +29,7 @@ Entity* sub_08049E18(void) { } Entity* sub_08049E4C(void) { - if ((gPlayerState.field_0x3c == 0) && + if ((gPlayerState.killed == 0) && !(gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_MINISH | PL_DISABLE_ITEMS | PL_FALLING | PL_FROZEN | PL_IN_MINECART | PL_PIT_IS_EXIT | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_CONVEYOR_PUSHED | PL_CLIMBING))) { @@ -40,7 +40,7 @@ Entity* sub_08049E4C(void) { } Entity* sub_08049E80(void) { - if ((gPlayerState.field_0x3c != 0) || !(gPlayerState.flags & PL_MINISH)) { + if ((gPlayerState.killed != 0) || !(gPlayerState.flags & PL_MINISH)) { return NULL; } gUnk_020000B0 = &gPlayerEntity.base; @@ -48,7 +48,7 @@ Entity* sub_08049E80(void) { } Entity* sub_08049EB0(void) { - if ((gPlayerState.field_0x3c == 0) && + if ((gPlayerState.killed == 0) && !(gPlayerState.flags & (PL_MOLDWORM_CAPTURED | PL_DISABLE_ITEMS | PL_MINISH | PL_CAPTURED))) { gUnk_020000B0 = &gPlayerEntity.base; return &gPlayerEntity.base; diff --git a/src/collision.c b/src/collision.c index 6dda05c3..95595906 100644 --- a/src/collision.c +++ b/src/collision.c @@ -371,7 +371,7 @@ CollisionResult CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettin // target: item CollisionResult CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { COLLISION_OFF(tgt); - tgt->contactFlags = org->hurtType | CONTACT_TAKE_DAMAGE; + tgt->contactFlags = org->hurtType | CONTACT_NOW; if ((tgt->type == 0x5F || tgt->type == 0x60) && sub_08081420(tgt)) tgt->health = 0; return RESULT_COLLISION_WITHOUT_SET; @@ -503,7 +503,7 @@ CollisionResult sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSetting sub_08079D84(); org->iframes = 90; } else { - gPlayerEntity.base.contactFlags = tgt->hurtType | CONTACT_TAKE_DAMAGE; + gPlayerEntity.base.contactFlags = tgt->hurtType | CONTACT_NOW; gPlayerEntity.base.iframes = 12; gPlayerEntity.base.knockbackDuration = 16; gPlayerEntity.base.knockbackDirection = DirectionTurnAround(direction); diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 73911ecf..f2e7c201 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -96,7 +96,7 @@ void AcroBandit_OnTick(AcroBanditEntity* this) { void AcroBandit_OnCollision(AcroBanditEntity* this) { Entity* brother; - if (super->contactFlags != CONTACT_TAKE_DAMAGE && super->contactFlags != (CONTACT_TAKE_DAMAGE | 0x1)) { + if (super->contactFlags != CONTACT_NOW && super->contactFlags != (CONTACT_NOW | 0x1)) { if (super->type == 1) { if (super->action < 7 && super->knockbackDuration != 0) { brother = super->child; diff --git a/src/enemy/armos.c b/src/enemy/armos.c index db597408..99fe9517 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -176,7 +176,7 @@ void sub_08030338(ArmosEntity* this) { if (super->frame == 2) { super->frame = 0; if (this->unk_80 != 2) { - super->flags2 = 0xb; + super->collisionMask = 0xb; super->hitType = 8; super->hitbox = (Hitbox*)&gUnk_080FD2F0; } @@ -281,7 +281,7 @@ void sub_08030580(ArmosEntity* this) { void sub_08030590(ArmosEntity* this) { super->action = 5; - super->flags2 = 1; + super->collisionMask = 1; super->hitType = 1; super->hitbox = (Hitbox*)&gHitbox_15; sub_080309C8(this, 5); @@ -337,7 +337,7 @@ bool32 sub_080305BC(ArmosEntity* this) { bool32 sub_08030650(ArmosEntity* this) { if (super->type == 0) { - if (super->contactFlags == CONTACT_TAKE_DAMAGE) { + if (super->contactFlags == CONTACT_NOW) { return 1; } } else if (this->unk_80 != 2) { diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index 75924746..19603462 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -35,7 +35,7 @@ void Beetle_OnTick(BeetleEntity* this) { void Beetle_OnCollision(BeetleEntity* this) { switch (super->contactFlags) { - case CONTACT_TAKE_DAMAGE: + case CONTACT_NOW: if (gPlayerState.framestate == PL_STATE_CLIMB) { Beetle_OnTick(this); } else { @@ -50,7 +50,7 @@ void Beetle_OnCollision(BeetleEntity* this) { InitializeAnimation(super, 6); } break; - case CONTACT_TAKE_DAMAGE | 0x13: + case CONTACT_NOW | 0x13: Beetle_OnTick(this); break; } diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index 7dfae72e..f1ae158b 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -38,7 +38,7 @@ void Bobomb_OnTick(BobombEntity* this) { } void Bobomb_OnCollision(BobombEntity* this) { - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { switch (super->contactFlags & 0x7f) { case 0: case 1: diff --git a/src/enemy/bowMoblin.c b/src/enemy/bowMoblin.c index 6a1176ee..b071ced4 100644 --- a/src/enemy/bowMoblin.c +++ b/src/enemy/bowMoblin.c @@ -56,7 +56,7 @@ void BowMoblin_OnCollision(BowMoblinEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)BowMoblin_Functions); - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { sub_0803C5F0(this); pEVar1 = super->child; if (pEVar1 != NULL) { diff --git a/src/enemy/chaser.c b/src/enemy/chaser.c index 3c374cd4..a17f4c96 100644 --- a/src/enemy/chaser.c +++ b/src/enemy/chaser.c @@ -43,7 +43,7 @@ void sub_0802B540(Entity* this) { void sub_0802B56C(Entity* this) { GetNextFrame(this); - if (this->contactFlags & CONTACT_TAKE_DAMAGE) { + if (this->contactFlags & CONTACT_NOW) { this->speed = 0x40; } diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index c9ee902c..d5502a80 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -978,13 +978,13 @@ void sub_08026BE8(ChuchuBossEntity* this) { Entity* child; child = super->child; - child->flags2 &= ~1; + child->collisionMask &= ~1; if (this->unk_7c == 0) { super->subAction = 7; this->unk_84->unk_03 = 0; this->unk_7d = 0x2d; child->flags &= ~0x80; - child->flags2 |= 1; + child->collisionMask |= 1; SoundReq(SFX_155); } else { this->unk_7c--; @@ -1346,7 +1346,7 @@ void sub_080272D4(ChuchuBossEntity* this) { super->hitbox->height = (u32)((0x10000 / this->unk_74.HALF_U.HI) * 5) >> 6; if (*(char*)&this->unk_84 == 0) break; - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { if (super->iframes != 0) { ((ChuchuBossEntity*)super->child)->unk_68->base.iframes = super->iframes; super->child->parent->iframes = super->iframes; @@ -1697,7 +1697,7 @@ bool32 sub_08027AA4(ChuchuBossEntity* this) { s32 iVar4; Helper* pHelper; - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) { + if ((super->contactFlags & CONTACT_NOW) == 0) { return FALSE; } switch (super->contactFlags & 0x7f) { diff --git a/src/enemy/cloudPiranha.c b/src/enemy/cloudPiranha.c index 64bf98cc..74f4be6b 100644 --- a/src/enemy/cloudPiranha.c +++ b/src/enemy/cloudPiranha.c @@ -58,7 +58,7 @@ void CloudPiranha_OnCollision(CloudPiranhaEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, gUnk_080CF4F0); - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { if (super->hitType == 0x5a) { switch (super->contactFlags & 0x3f) { case 0x14: diff --git a/src/enemy/crow.c b/src/enemy/crow.c index c540e4ae..5c882480 100644 --- a/src/enemy/crow.c +++ b/src/enemy/crow.c @@ -44,7 +44,7 @@ void Crow_OnTick(CrowEntity* this) { } void Crow_OnCollision(CrowEntity* this) { - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { if ((super->contactFlags & 0x3f) == 0) { COLLISION_OFF(super); super->subtimer = 16; diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index 39820a64..6a7a17db 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -336,7 +336,7 @@ void sub_080210E4(DarkNutEntity* this) { sub_08021644(this); if ((super->frame & 0x10) && - (!ProcessMovement0(super) || (super->child && (super->child->contactFlags & CONTACT_TAKE_DAMAGE)))) { + (!ProcessMovement0(super) || (super->child && (super->child->contactFlags & CONTACT_NOW)))) { sub_080213D0(this, 0); } else { if (--this->unk_76 == 0) diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index 9987ee88..36156ce7 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -79,15 +79,15 @@ void Enemy50_OnCollision(Enemy50Entity* this) { sub_08041134(this); sub_0803F6EC(this); } - if (super->hitType == 0x25 && super->contactFlags == CONTACT_TAKE_DAMAGE) { + if (super->hitType == 0x25 && super->contactFlags == CONTACT_NOW) { super->action = 8; InitializeAnimation(super, 3); } else { - if (super->contactFlags == CONTACT_TAKE_DAMAGE) { + if (super->contactFlags == CONTACT_NOW) { this->unk_7c = 0x78; sub_08041128(this); } - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { + if (super->contactFlags == (CONTACT_NOW | 0x1d)) { super->zVelocity = Q_16_16(1.5); } if (super->confusedTime != 0) { @@ -422,7 +422,7 @@ void sub_0804122C(Enemy50Entity* this) { #ifndef EU bool32 sub_08041300(Enemy50Entity* this) { - if ((super->hitType == 0x25) && (super->contactFlags == CONTACT_TAKE_DAMAGE)) { + if ((super->hitType == 0x25) && (super->contactFlags == CONTACT_NOW)) { return TRUE; } else { return super->action == 8 || super->action == 9; diff --git a/src/enemy/eyegore.c b/src/enemy/eyegore.c index 3b4ee58c..1ccf4e78 100644 --- a/src/enemy/eyegore.c +++ b/src/enemy/eyegore.c @@ -82,14 +82,14 @@ void Eyegore_OnTick(EyegoreEntity* this) { void Eyegore_OnCollision(EyegoreEntity* this) { u32 tmp; - if ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15)) || (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe))) { + if ((super->contactFlags == (CONTACT_NOW | 0x15)) || (super->contactFlags == (CONTACT_NOW | 0xe))) { Entity* entity = super->contactedEntity; tmp = (((entity->direction + 4) & 0x18) ^ 0x10) >> 3; if (tmp == super->animationState) { if ((tmp & 1) != 0) { if (0x10 < ((entity->y.HALF.HI + entity->z.HALF.HI) - (super->y.HALF.HI + super->z.HALF.HI)) + 0x14U) { } else { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe)) { + if (super->contactFlags == (CONTACT_NOW | 0xe)) { super->health = 0; } else { super->health--; @@ -105,7 +105,7 @@ void Eyegore_OnCollision(EyegoreEntity* this) { EnqueueSFX(SFX_BUTTON_PRESS); sub_08031344(this); } else { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe)) { + if (super->contactFlags == (CONTACT_NOW | 0xe)) { super->health = 0; } else { super->health--; diff --git a/src/enemy/flyingPot.c b/src/enemy/flyingPot.c index cc868bc0..0402aac5 100644 --- a/src/enemy/flyingPot.c +++ b/src/enemy/flyingPot.c @@ -93,7 +93,7 @@ void FlyingPot_OnTick(FlyingPotEntity* this) { void FlyingPot_OnCollision(FlyingPotEntity* this) { sub_08037418(this); - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { + if (super->contactFlags == (CONTACT_NOW | 0x1d)) { super->action = FLYING_POT_ACTION_6; COLLISION_OFF(super); super->zVelocity = Q_16_16(2.625); @@ -207,7 +207,7 @@ void FlyingPot_Action2(FlyingPotEntity* this) { super->spritePriority.b1 = 1; super->spriteOffsetX = 0; super->hitType = 0xA0; - super->flags2 = 0xF; + super->collisionMask = 0xF; super->hitbox = &gUnk_080FD34C; SetBottomTile(this->tileIndex, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer); diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 23ba5c87..4e5acb0e 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -45,7 +45,7 @@ void FlyingSkull_OnTick(FlyingSkullEntity* this) { void FlyingSkull_OnCollision(FlyingSkullEntity* this) { sub_0803A100(this); - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { + if (super->contactFlags == (CONTACT_NOW | 0x1d)) { super->action = 7; COLLISION_OFF(super); super->zVelocity = Q_16_16(2.625); @@ -198,7 +198,7 @@ void sub_08039FAC(FlyingSkullEntity* this) { super->spritePriority.b1 = 1; super->spriteOffsetX = 0; super->hitType = 0xa0; - super->flags2 = 0xf; + super->collisionMask = 0xf; super->hitbox = (Hitbox*)&gUnk_080FD34C; SetBottomTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); } diff --git a/src/enemy/ghini.c b/src/enemy/ghini.c index 87a9c402..f835ec1f 100644 --- a/src/enemy/ghini.c +++ b/src/enemy/ghini.c @@ -59,11 +59,11 @@ void Ghini_OnCollision(GhiniEntity* this) { sub_0803F630(this); sub_0803F6EC(this); } - if ((super->hitType == 0x25) && (super->contactFlags == CONTACT_TAKE_DAMAGE)) { + if ((super->hitType == 0x25) && (super->contactFlags == CONTACT_NOW)) { super->action = 8; InitializeAnimation(super, 3); } else { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { + if (super->contactFlags == (CONTACT_NOW | 0x1d)) { super->zVelocity = 0x18000; } if (super->confusedTime != 0) { diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index 0f521e14..e0813e6d 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -52,7 +52,7 @@ void Gibdo_OnTick(GibdoEntity* this) { } void Gibdo_OnCollision(GibdoEntity* this) { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { + if (super->contactFlags == (CONTACT_NOW | 0x7)) { if (super->action == 0x6) { sub_08037ACC(this); } @@ -62,7 +62,7 @@ void Gibdo_OnCollision(GibdoEntity* this) { Gibdo_CreateObjects(this); } else { if (super->action != 0x6) { - if (super->hitType == 0x27 && super->contactFlags == CONTACT_TAKE_DAMAGE) { + if (super->hitType == 0x27 && super->contactFlags == CONTACT_NOW) { sub_08037A14(this); } else { if ((u8)(super->action - 1) < 2) { @@ -326,7 +326,7 @@ void sub_08037A14(GibdoEntity* this) { super->timer = 24; super->spritePriority.b0 &= super->timer - 32; super->spritePriority.b0 |= 3; - super->flags2 &= 0xfe; + super->collisionMask &= 0xfe; this->field_0x7c = 5; CopyPosition(super, super->contactedEntity); InitAnimationForceUpdate(super, super->animationState + 0xc); @@ -341,7 +341,7 @@ void sub_08037A58(GibdoEntity* this) { super->iframes = 0xec; } super->hitType = 0x26; - super->flags2 |= 1; + super->collisionMask |= 1; super->iframes = 0xf4; super->knockbackDirection = DirectionFromAnimationState(super->animationState) ^ 0x10; super->knockbackDuration = 8; diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index 9eb430b9..e88550f1 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -383,7 +383,7 @@ void sub_0802D3B8(GleerokEntity* this) { case 1: if (super->type2 == 1) { COLLISION_ON(super); - super->flags2 |= 0x80; + super->collisionMask |= 0x80; } super->spritePriority.b0 = gUnk_080CD7C4[super->type2].unk0.HALF.HI; @@ -399,7 +399,7 @@ void sub_0802D3B8(GleerokEntity* this) { this->unk_74 = gUnk_080CD884[0]; this->unk_75 = 0; super->spritePriority.b0 = 6; - super->flags2 |= 0x80; + super->collisionMask |= 0x80; CopyPosition(super->parent, super); InitializeAnimation(super, 0x4f); break; @@ -659,7 +659,7 @@ void sub_0802D86C(GleerokEntity* this) { } } - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) && this->unk_74 == 0) { + if ((super->contactFlags & CONTACT_NOW) && this->unk_74 == 0) { if ((super->contactFlags & 0x7f) == 0x1d) { super->zVelocity = Q_16_16(3.0); super->parent->subAction = 4; @@ -1039,7 +1039,7 @@ void sub_0802E0B8(GleerokEntity* this) { super->type2 = 4; InitializeAnimation(super, 0x4e); } else { - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { if (super->iframes > 0) { SoundReq(SFX_BOSS_HIT); } diff --git a/src/enemy/hangingSeed.c b/src/enemy/hangingSeed.c index dfdcae96..2f52e0ab 100644 --- a/src/enemy/hangingSeed.c +++ b/src/enemy/hangingSeed.c @@ -20,7 +20,7 @@ void HangingSeed_OnTick(Entity* this) { } void HangingSeed_OnCollision(Entity* this) { - if (this->contactFlags & CONTACT_TAKE_DAMAGE) { + if (this->contactFlags & CONTACT_NOW) { CreateFx(this, FX_BUSH, 0x80); DeleteThisEntity(); } diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index ab1437cc..6a929ab6 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -261,7 +261,7 @@ void sub_0802BF3C(HelmasaurEntity* this) { void sub_0802BF78(HelmasaurEntity* this) { super->action = 1; - super->flags2 = 4; + super->collisionMask = 4; super->gustJarFlags = 1; super->direction = super->animationState << 3; InitializeAnimation(super, super->animationState + 8); diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index 348d7e25..40688bfe 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -143,7 +143,7 @@ void Keaton_Action3(KeatonEntity* this) { } void Keaton_Action4(KeatonEntity* this) { - if (super->child && (super->child->contactFlags & CONTACT_TAKE_DAMAGE)) { + if (super->child && (super->child->contactFlags & CONTACT_NOW)) { sub_0803275C(this); return; } diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 740ceb54..c0dba3db 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -342,7 +342,7 @@ void sub_0803CBAC(LakituEntity* this) { super->spritePriority.b1 = 1; - super->flags2 &= 0x7b; + super->collisionMask &= 0x7b; super->hitType = 0x42; diff --git a/src/enemy/leever.c b/src/enemy/leever.c index 4bdc4253..17745ecb 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -47,7 +47,7 @@ void Leever_OnTick(LeeverEntity* this) { } void Leever_OnCollision(LeeverEntity* this) { - if (super->contactFlags == CONTACT_TAKE_DAMAGE) { + if (super->contactFlags == CONTACT_NOW) { if (super->action == 3) { this->unk_74 = 1; } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 373953f6..0a124fe5 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -46,13 +46,13 @@ void LikeLike_OnCollision(LikeLikeEntity* this) { } else { if (super->action == 7) { LikeLike_ReleasePlayer(this); - } else if (super->contactFlags & CONTACT_TAKE_DAMAGE) { - u8 tmp = super->contactFlags & ~CONTACT_TAKE_DAMAGE; + } else if (super->contactFlags & CONTACT_NOW) { + u8 tmp = super->contactFlags & ~CONTACT_NOW; if (tmp == 0) { super->action = 7; super->timer = 95; super->subtimer = tmp; - super->flags2 &= 0xfc; + super->collisionMask &= 0xfc; this->prevSpritePriority = gPlayerEntity.base.spritePriority.b1; } } @@ -153,7 +153,7 @@ void sub_08027FB4(LikeLikeEntity* this) { if (--super->timer == 0) { super->action = 1; super->timer = 1; - super->flags2 |= 1; + super->collisionMask |= 1; } GetNextFrame(super); } @@ -236,7 +236,7 @@ void LikeLike_ReleasePlayer(LikeLikeEntity* this) { super->action = 4; super->timer = 80; super->subtimer = tmp; - super->flags2 |= 2; + super->collisionMask |= 2; if (super->iframes == 0) { super->iframes = -18; } diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index 39d929c9..387740b9 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -518,7 +518,7 @@ void sub_0802A098(MadderpillarEntity* this) { void sub_0802A0F8(MadderpillarEntity* this) { if (super->health != 0) { - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) && super->iframes != 0) { + if ((super->contactFlags & CONTACT_NOW) && super->iframes != 0) { Entity* entity = super; u32 i; for (i = 0; i < 6; i++) { @@ -549,7 +549,7 @@ void sub_0802A16C(MadderpillarEntity* this) { } void sub_0802A18C(MadderpillarEntity* this) { - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { switch (super->contactFlags & 0x7f) { case 0: case 1: diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index 15e84846..a4ec8dd8 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -167,8 +167,8 @@ void MazaalBracelet_OnCollision(MazaalBraceletEntity* this) { if (super->type < 2) { if (super->action != 0x2b) { - if ((0 < super->iframes) && ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15) || - (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe))))) { + if ((0 < super->iframes) && + ((super->contactFlags == (CONTACT_NOW | 0x15) || (super->contactFlags == (CONTACT_NOW | 0xe))))) { super->action = 0x28; COLLISION_OFF(super); entity = (MazaalBraceletEntity*)super->parent; @@ -1300,7 +1300,7 @@ u32 sub_0803B870(MazaalBraceletEntity* this) { Entity* entity; entity = super->child; - if ((entity->contactFlags & CONTACT_TAKE_DAMAGE) != 0 && (gPlayerState.flags & PL_CAPTURED)) { + if ((entity->contactFlags & CONTACT_NOW) != 0 && (gPlayerState.flags & PL_CAPTURED)) { super->action = 0x18; super->timer = 68; super->spriteSettings.draw = 0; diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index ef1650f7..a09275f1 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -101,7 +101,7 @@ void Moldworm_OnCollision(MoldwormEntity* this) { super->iframes = -8; this->unk_7f = 0; this->unk_7b = 0; - if (super->contactFlags == CONTACT_TAKE_DAMAGE || super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1e)) { + if (super->contactFlags == CONTACT_NOW || super->contactFlags == (CONTACT_NOW | 0x1e)) { super->type2 = 0; this->unk_80 = 0x14; } else { @@ -441,7 +441,7 @@ void sub_08023894(MoldwormEntity* this) { } void sub_0802390C(MoldwormEntity* this) { - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { Entity* ent = super->child; do { ent->iframes = super->iframes; @@ -449,7 +449,7 @@ void sub_0802390C(MoldwormEntity* this) { } else { Entity* ent = super->child; do { - if (ent->contactFlags & CONTACT_TAKE_DAMAGE) { + if (ent->contactFlags & CONTACT_NOW) { u8 bVar2 = 0xff - ent->health; if (bVar2 != 0) { u32 tmp; diff --git a/src/enemy/mulldozer.c b/src/enemy/mulldozer.c index 8af9198a..9afd925a 100644 --- a/src/enemy/mulldozer.c +++ b/src/enemy/mulldozer.c @@ -55,7 +55,7 @@ void Mulldozer_OnCollision(MulldozerEntity* this) { EnemyCreateFX(super, 0x1c); } EnemyFunctionHandlerAfterCollision(super, Mulldozer_Functions); - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { switch (super->contactFlags & 0x3f) { case 2: case 3: diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index c3250c60..a8404af9 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -61,7 +61,7 @@ void Peahat_OnTick(PeahatEntity* this) { void Peahat_OnCollision(PeahatEntity* this) { if (this->unk_82) { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x14)) { + if (super->contactFlags == (CONTACT_NOW | 0x14)) { Entity* entity = CreateEnemy(PEAHAT, PeahatForm_Propeller); if (entity != NULL) { CopyPosition(super, entity); @@ -74,14 +74,14 @@ void Peahat_OnCollision(PeahatEntity* this) { super->iframes = -30; this->unk_81 = 0; InitializeAnimation(super, super->animationState); - } else if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1b)) { + } else if (super->contactFlags == (CONTACT_NOW | 0x1b)) { super->animationState = PeahatAnimation_BrokenPropeller; super->action = 5; super->speed = 0x80; super->iframes = -30; this->unk_81 = 0; InitializeAnimation(super, super->animationState); - } else if (super->contactFlags == CONTACT_TAKE_DAMAGE) { + } else if (super->contactFlags == CONTACT_NOW) { if (super->animationState == PeahatAnimation_Flying) { super->action = 1; super->timer = 30; diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index e386d4b6..05e38286 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -65,7 +65,7 @@ void Pesto_OnTick(PestoEntity* this) { void Pesto_OnCollision(PestoEntity* this) { if (super->hitType != 0x6e) { - if (super->contactFlags == CONTACT_TAKE_DAMAGE) { + if (super->contactFlags == CONTACT_NOW) { this->unk_86 = 0x30; if ((this->unk_83 & 0xf) == 3 && super->action == 6) { @@ -406,7 +406,7 @@ void sub_080244E8(PestoEntity* this) { super->direction = DirectionSouth; super->speed = tmp; this->unk_84 = 0; - super->flags2 &= 0xfc; + super->collisionMask &= 0xfc; sub_080249DC(this); this->unk_85 = gPlayerEntity.base.spritePriority.b1; gPlayerEntity.base.flags &= ~ENT_COLLIDE; @@ -878,7 +878,7 @@ void sub_08024F50(PestoEntity* this) { gPlayerEntity.base.spritePriority.b1 = this->unk_85; gPlayerEntity.base.z.HALF.HI = gPlayerEntity.base.spriteOffsetY; gPlayerEntity.base.spriteOffsetY = 0; - super->flags2 |= 3; + super->collisionMask |= 3; this->unk_83 = 0xc0; this->unk_80 += 2; this->unk_84 = 0; diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index 4b760d66..72e18f8d 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -100,7 +100,7 @@ void sub_080223E4(Entity* this) { entity = this->child; if (entity != NULL) { - entity->contactFlags = (CONTACT_TAKE_DAMAGE | 0x14); + entity->contactFlags = (CONTACT_NOW | 0x14); entity->iframes = 0x10; #ifndef EU entity->knockbackDuration = 0xc; diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index db6233e1..deb60f26 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -51,7 +51,7 @@ void Rollobite_OnCollision(RollobiteEntity* this) { InitializeAnimation(super, super->animationState + 8); } - if (super->contactFlags != CONTACT_TAKE_DAMAGE) { + if (super->contactFlags != CONTACT_NOW) { if (super->action == 4 || super->action == 5) { super->action = 4; super->timer = 180; @@ -60,7 +60,7 @@ void Rollobite_OnCollision(RollobiteEntity* this) { } } - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x13)) + if (super->contactFlags == (CONTACT_NOW | 0x13)) Rollobite_OnTick(this); } diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 7ebff811..ada5434e 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -75,7 +75,7 @@ void RupeeLike_OnCollision(RupeeLikeEntity* this) { super->timer = 60; super->subtimer = 0; this->unk_83 = 0x41; - super->flags2 &= 0xfc; + super->collisionMask &= 0xfc; this->unk_80 = gPlayerEntity.base.spritePriority.b1; EnqueueSFX(SFX_PLACE_OBJ); } else { @@ -255,7 +255,7 @@ void sub_080296D8(RupeeLikeEntity* this) { gPlayerEntity.base.speed = 0x140; super->action = 5; super->subtimer = 60; - super->flags2 |= 3; + super->collisionMask |= 3; if ((s8)super->iframes == 0) { super->iframes = 0xf4; } diff --git a/src/enemy/scissorsBeetle.c b/src/enemy/scissorsBeetle.c index bbd7f223..72bb2f8a 100644 --- a/src/enemy/scissorsBeetle.c +++ b/src/enemy/scissorsBeetle.c @@ -44,7 +44,7 @@ void ScissorsBeetle_OnCollision(ScissorsBeetleEntity* this) { } EnemyFunctionHandlerAfterCollision(super, ScissorsBeetle_Functions); - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) && super->action != 4) { + if ((super->contactFlags & CONTACT_NOW) && super->action != 4) { u32 knockbackDir; child = super->child; child->iframes = super->iframes; diff --git a/src/enemy/spark.c b/src/enemy/spark.c index 7006c8b9..79a65afe 100644 --- a/src/enemy/spark.c +++ b/src/enemy/spark.c @@ -22,7 +22,7 @@ void Spark_OnTick(Entity* this) { void Spark_OnCollision(Entity* this) { Entity* entity; - if (this->contactFlags & CONTACT_TAKE_DAMAGE) { + if (this->contactFlags & CONTACT_NOW) { if ((this->contactFlags & 0x7f) == 0x14) { COLLISION_OFF(this); this->iframes = 0; diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index 97d5850b..271a4c23 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -57,7 +57,7 @@ void SpearMoblin_OnCollision(SpearMoblinEntity* this) { EnemyCreateFX(super, FX_STARS); EnemyFunctionHandlerAfterCollision(super, SpearMoblin_Functions); - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { if (super->action != 4) { sub_08028754(this); } else { @@ -398,7 +398,7 @@ bool32 sub_080288A4(SpearMoblinEntity* this) { void sub_080288C0(SpearMoblinEntity* this) { Entity* entity = super->child; - if ((entity != NULL) && (entity->contactFlags & CONTACT_TAKE_DAMAGE)) { + if ((entity != NULL) && (entity->contactFlags & CONTACT_NOW)) { super->knockbackDirection = entity->knockbackDirection; super->iframes = -entity->iframes; super->knockbackSpeed = entity->knockbackSpeed; diff --git a/src/enemy/spinyBeetle.c b/src/enemy/spinyBeetle.c index 297b3b51..3bd9b0da 100644 --- a/src/enemy/spinyBeetle.c +++ b/src/enemy/spinyBeetle.c @@ -49,7 +49,7 @@ void SpinyBeetle_OnCollision(SpinyBeetleEntity* this) { } EnemyFunctionHandlerAfterCollision(super, SpinyBeetle_Functions); - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { if (super->iframes > 0 && super->child) { sub_08033E1C(this); } diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index d736b8e0..72329b9f 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -60,7 +60,7 @@ void SpinyChuchu_OnCollision(SpinyChuchuEntity* this) { super->hitType = 0x5c; InitializeAnimation(super, 1); } - } else if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x14)) { + } else if (super->contactFlags == (CONTACT_NOW | 0x14)) { EnemyCreateFX(super, FX_STARS); super->action = 5; InitializeAnimation(super, 1); diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index b4a26dfb..4bb4b5c1 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -109,7 +109,7 @@ void Stalfos_OnCollision(StalfosEntity* this) { sub_08039A48(this); this->unk_78 += 0x5a; } - super->flags2 &= 0xfb; + super->collisionMask &= 0xfb; } if (super->confusedTime != 0) { EnemyCreateFX(super, FX_STARS); @@ -153,7 +153,7 @@ void Stalfos_SubAction2(StalfosEntity* this) { } super->child = NULL; super->gustJarState &= 0xfb; - super->flags2 &= 0xfb; + super->collisionMask &= 0xfb; sub_08039A48(this); this->unk_78 += 0x5a; } @@ -279,7 +279,7 @@ void Stalfos_Action12(StalfosEntity* this) { } else { sub_08039A48(this); } - super->flags2 |= 4; + super->collisionMask |= 4; this->unk_78 += 0x3c; } } diff --git a/src/enemy/takkuri.c b/src/enemy/takkuri.c index 38aa602f..fc5c90bd 100644 --- a/src/enemy/takkuri.c +++ b/src/enemy/takkuri.c @@ -46,7 +46,7 @@ void Takkuri_OnTick(TakkuriEntity* this) { } void Takkuri_OnCollision(TakkuriEntity* this) { - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { if ((super->contactFlags & 0x7f) == 0) { u32 direction; sub_0803C0AC(super); diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index 0cc625b3..be3e79e4 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -63,7 +63,7 @@ void Tektite_OnCollision(TektiteEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, Tektite_Functions); - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { switch (super->contactFlags & 0x3f) { case 0x14: super->action = 1; diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index c6af233a..61737644 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -51,7 +51,7 @@ void TektiteGolden_OnCollision(TektiteGoldenEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, TektiteGolden_Functions); - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x14)) { + if (super->contactFlags == (CONTACT_NOW | 0x14)) { super->action = 1; super->subAction = 0; super->timer = 20; diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index b94db4e5..facc5527 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -1401,7 +1401,7 @@ static void sub_08043C40(VaatiArmEntity* this, VaatiArm_HeapStruct1* heapStruct) static bool32 sub_08043C98(VaatiArmEntity* this) { #if defined EU || defined JP Entity* e1 = &((VaatiArm_HeapStruct*)super->myHeap)->entities[3]->base; - if ((e1->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d))) { + if ((e1->contactFlags == (CONTACT_NOW | 0x1d))) { sub_08043D08(this); return TRUE; } else { @@ -1410,7 +1410,7 @@ static bool32 sub_08043C98(VaatiArmEntity* this) { #else Entity* e1 = &((VaatiArm_HeapStruct*)super->myHeap)->entities[2]->base; Entity* e2 = &((VaatiArm_HeapStruct*)super->myHeap)->entities[3]->base; - if ((e1->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) || (e2->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d))) { + if ((e1->contactFlags == (CONTACT_NOW | 0x1d)) || (e2->contactFlags == (CONTACT_NOW | 0x1d))) { sub_08043D08(this); gRoomTransition.field_0x38 |= 2; return TRUE; @@ -1423,7 +1423,7 @@ static bool32 sub_08043C98(VaatiArmEntity* this) { static void sub_08043CD4(VaatiArmEntity* this) { u32 i; for (i = 0; i < 5; i++) { - if (((VaatiArm_HeapStruct*)super->myHeap)->entities[i]->base.contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { + if (((VaatiArm_HeapStruct*)super->myHeap)->entities[i]->base.contactFlags == (CONTACT_NOW | 0x1d)) { this->unk_7c = 0x78; this->unk_7d = i; return; diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index a32eb624..94e040be 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -58,7 +58,7 @@ void VaatiBall(VaatiBallEntity* this) { super->health = -1; } - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { if ((super->contactFlags & 0x3f) == 0 && super->action == 6) { ModHealth(-2); } diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index 3df5abe6..7a27a6eb 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -66,7 +66,7 @@ void VaatiProjectile_OnTick(VaatiProjectileEntity* this) { void VaatiProjectile_OnCollision(VaatiProjectileEntity* this) { Entity* entity; - if (super->contactFlags == CONTACT_TAKE_DAMAGE) { + if (super->contactFlags == CONTACT_NOW) { #ifndef EU if (super->health != 0) { #endif @@ -118,7 +118,7 @@ void VaatiProjectileFunction0Action0(VaatiProjectileEntity* this) { } else { super->action = 9; super->z.HALF.HI = -0x80; - super->flags2 = 1; + super->collisionMask = 1; } InitializeAnimation(super, 0); } diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index 28586549..5463b4f0 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -539,7 +539,7 @@ void VaatiRebornEnemyType1Action1(VaatiRebornEnemyEntity* this) { super->hitType = 0x2f; InitAnimationForceUpdate(super, this->unk_74); } else { - if (((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (0 < super->iframes)) { + if (((super->contactFlags & CONTACT_NOW) != 0) && (0 < super->iframes)) { parent->iframes = super->iframes; parent->contactFlags = super->contactFlags; } @@ -665,7 +665,7 @@ void VaatiRebornEnemyType1PreAction(VaatiRebornEnemyEntity* this) { } parent = super->parent; this->unk_77 = 0; - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { if (gUnk_080D04D0[((VaatiRebornEnemyEntity*)parent)->unk_86] > super->health) { if (2 < ++((VaatiRebornEnemyEntity*)parent)->unk_86) { COLLISION_OFF(super); diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 9d8f7158..663133fe 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -1097,11 +1097,11 @@ void sub_080409B0(VaatiTransfiguredEntity* this) { Knockback1(super); } } else { - if (((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (0 < super->iframes)) { + if (((super->contactFlags & CONTACT_NOW) != 0) && (0 < super->iframes)) { InitScreenShake(12, 1); SoundReq(SFX_BOSS_HIT); } - if ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xa)) && (gPlayerState.chargeState.action == 5)) { + if ((super->contactFlags == (CONTACT_NOW | 0xa)) && (gPlayerState.chargeState.action == 5)) { super->health = 0xc0; } } diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c index 74e0a522..c3e33442 100644 --- a/src/enemy/vaatiTransfiguredEye.c +++ b/src/enemy/vaatiTransfiguredEye.c @@ -72,7 +72,7 @@ void VaatiTransfiguredEye_OnCollision(VaatiTransfiguredEyeEntity* this) { if (super->type != 0) { pEVar4 = super->parent->parent; - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { bVar1 = super->contactFlags & 0x3f; if ((bVar1 == 0xe) || (bVar1 == 0x15)) { diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index cac6435c..21f5c506 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -101,7 +101,7 @@ const s8 gUnk_080D0EB0[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x0 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd }; void VaatiWrath(VaatiWrathEntity* this) { - if (((super->type == 0) && ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) && (super->health == 0)) { + if (((super->type == 0) && ((super->contactFlags & CONTACT_NOW) != 0)) && (super->health == 0)) { COLLISION_ON(super); super->health = 0xff; if (--this->unk_84 == 0) { diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 88125bcf..e5c4c5e5 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -57,7 +57,7 @@ void Wisp_OnCollision(WispEntity* this) { Entity* entity; bits = super->contactFlags; - if ((bits & CONTACT_TAKE_DAMAGE) == 0) { + if ((bits & CONTACT_NOW) == 0) { return; } diff --git a/src/enemy/wizzrobeIce.c b/src/enemy/wizzrobeIce.c index ae2dbcfe..364d56bd 100644 --- a/src/enemy/wizzrobeIce.c +++ b/src/enemy/wizzrobeIce.c @@ -26,7 +26,7 @@ void WizzrobeIce_OnCollision(WizzrobeEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, WizzrobeIce_Functions); - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { + if (super->contactFlags == (CONTACT_NOW | 0x7)) { Entity* obj = CreateObject(FLAME, 3, 0); if (obj != NULL) { obj->spritePriority.b0 = 3; diff --git a/src/enemy/wizzrobeWind.c b/src/enemy/wizzrobeWind.c index 18ee7116..92afac49 100644 --- a/src/enemy/wizzrobeWind.c +++ b/src/enemy/wizzrobeWind.c @@ -33,7 +33,7 @@ void WizzrobeWind_OnCollision(WizzrobeEntity* this) { EnemyCreateFX(super, FX_STARS); } EnemyFunctionHandlerAfterCollision(super, WizzrobeWind_Functions); - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { + if (super->contactFlags == (CONTACT_NOW | 0x7)) { Entity* obj = CreateObject(FLAME, 3, 0); if (obj != NULL) { obj->spritePriority.b0 = 3; diff --git a/src/enemyUtils.c b/src/enemyUtils.c index ed13377f..35ff738d 100644 --- a/src/enemyUtils.c +++ b/src/enemyUtils.c @@ -79,7 +79,7 @@ bool32 EnemyInit(Enemy* this) { if (super->speed == 0) { super->speed = definition->speed; } - super->flags2 = definition->flags2; + super->collisionMask = definition->collisionMask; super->hitType = definition->damageType; super->hitbox = (Hitbox*)definition->ptr.hitbox; super->health = definition->health; @@ -314,9 +314,9 @@ void EnemyDetachFX(Entity* entity) { /** Unsets bitfield 0x80 before calling GetNextFunction, so that the enemyFunction 1 is not called. */ void EnemyFunctionHandlerAfterCollision(Entity* entity, void (*const fntable[])()) { u32 idx; - entity->contactFlags &= ~CONTACT_TAKE_DAMAGE; + entity->contactFlags &= ~CONTACT_NOW; idx = GetNextFunction(entity); - entity->contactFlags |= CONTACT_TAKE_DAMAGE; + entity->contactFlags |= CONTACT_NOW; fntable[idx](entity); } diff --git a/src/interrupts.c b/src/interrupts.c index f52a8da3..828a6537 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -10,6 +10,7 @@ #include "sound.h" #include "structures.h" #include "ui.h" +#include "collision.h" extern u8 gUnk_03003DE0; extern u8 gUnk_03000C30; @@ -236,7 +237,7 @@ static void HandlePlayerLife(Entity* this) { gUnk_0200AF00.rActionInteractTile = R_ACTION_NONE; gUnk_0200AF00.rActionGrabbing = R_ACTION_NONE; - if ((gPlayerEntity.base.contactFlags & CONTACT_TAKE_DAMAGE) && (gPlayerEntity.base.iframes > 0)) + if ((gPlayerEntity.base.contactFlags & CONTACT_NOW) && (gPlayerEntity.base.iframes > 0)) SoundReq(SFX_86); gPlayerState.flags &= ~(PL_FALLING | PL_CONVEYOR_PUSHED); @@ -323,7 +324,7 @@ static void sub_080171F0(void) { if (gPlayerEntity.unk_7a != 0) gPlayerEntity.unk_7a--; - gPlayerEntity.base.contactFlags &= ~CONTACT_TAKE_DAMAGE; + gPlayerEntity.base.contactFlags &= ~CONTACT_NOW; if (gPlayerEntity.base.action != PLAYER_DROWN) COPY_FLAG_FROM_TO(gPlayerState.flags, 0x2, 0x10000); diff --git a/src/npc/cat.c b/src/npc/cat.c index a3228998..9adf40f1 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -140,7 +140,7 @@ void sub_080677EC(CatEntity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = -0x58; - super->flags2 = 1; + super->collisionMask = 1; this->unk_69 = 0xff; if (super->x.HALF.HI < gPlayerEntity.base.x.HALF.HI) { super->spriteSettings.flipX = 1; diff --git a/src/npc/npc5.c b/src/npc/npc5.c index 1b60767d..b6b17ca6 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -2,7 +2,7 @@ * @file npc5.c * @ingroup NPCs * - * @brief NPC 5 + * @brief Unused Zelda follower NPC. */ #include "collision.h" #include "functions.h" @@ -166,7 +166,7 @@ void sub_08060AE0(NPC5Entity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = 0x49; - super->flags2 = 3; + super->collisionMask = 3; super->hitbox = (Hitbox*)&gHitbox_0; super->followerFlag &= 0xfe; this->unk_6c = 0xff; @@ -525,7 +525,7 @@ u32 sub_080611D4(Entity* this) { u32 sub_08061230(NPC5Entity* this) { if ((((UnkHeap*)super->myHeap)->unk_0 & 1) == 0) { - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { switch (super->contactFlags & 0x7f) { case 0: case 1: diff --git a/src/object.c b/src/object.c index 31bbdd63..4f61cd10 100644 --- a/src/object.c +++ b/src/object.c @@ -207,7 +207,7 @@ void ObjectUpdate(Entity* this) { this->iframes++; if (!EntityDisabled(this)) { gObjectFunctions[this->id](this); - this->contactFlags &= ~CONTACT_TAKE_DAMAGE; + this->contactFlags &= ~CONTACT_NOW; } DrawEntity(this); } diff --git a/src/object/barrelSpiderweb.c b/src/object/barrelSpiderweb.c index d4d821dd..69a1ea77 100644 --- a/src/object/barrelSpiderweb.c +++ b/src/object/barrelSpiderweb.c @@ -40,7 +40,7 @@ void BarrelSpiderweb_Init(Entity* this) { this->hitType = 1; this->collisionFlags = 7; this->hurtType = 0x48; - this->flags2 = 4; + this->collisionMask = 4; this->hitbox = (Hitbox*)&gHitbox_0; this->frameIndex = 2; this->collisionLayer = gPlayerEntity.base.collisionLayer; @@ -64,7 +64,7 @@ void sub_0808BBE0(Entity* this) { ptr = &gUnk_0812144C[diff * 2]; SetAffineInfo(this, ptr[0], ptr[1], 0); } else { - this->contactFlags &= ~CONTACT_TAKE_DAMAGE; + this->contactFlags &= ~CONTACT_NOW; } } @@ -74,7 +74,7 @@ void BarrelSpiderweb_Action1(Entity* this) { tmp = -0x170; this->y.HALF.HI = gRoomControls.origin_y - ((this->parent)->zVelocity + tmp); sub_0808BBE0(this); - if (this->contactFlags == (CONTACT_TAKE_DAMAGE | 0x13)) { + if (this->contactFlags == (CONTACT_NOW | 0x13)) { this->timer--; this->spriteSettings.draw = 1; if (this->timer == 0) { @@ -114,7 +114,7 @@ void BarrelSpiderweb_Action2(Entity* this) { this->subtimer -= 8; SetAffineInfo(this, 0x200 - this->subtimer, 0x200 - this->subtimer, 0); } - if (this->contactFlags == (CONTACT_TAKE_DAMAGE | 0x13)) { + if (this->contactFlags == (CONTACT_NOW | 0x13)) { this->direction = GetFacingDirection(this, &gPlayerEntity.base); LinearMoveUpdate(this); if (EntityWithinDistance(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI - 6, 0x1c)) { diff --git a/src/object/bigIceBlock.c b/src/object/bigIceBlock.c index 126b0600..0cc856b9 100644 --- a/src/object/bigIceBlock.c +++ b/src/object/bigIceBlock.c @@ -48,7 +48,7 @@ void BigIceBlock_Init(BigIceBlockEntity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = 1; - super->flags2 = 0x80; + super->collisionMask = 0x80; super->hitbox = (Hitbox*)&gUnk_080FD190; sub_08099910(this); InitializeAnimation(super, super->type); diff --git a/src/object/bush.c b/src/object/bush.c index 4e086347..d0fbc49e 100644 --- a/src/object/bush.c +++ b/src/object/bush.c @@ -64,7 +64,7 @@ void Bush_Init(BushEntity* this) { super->health = 1; super->collisionFlags = 7; super->hitType = 0x6e; - super->flags2 = 4; + super->collisionMask = 4; super->hitbox = (Hitbox*)&gUnk_081205B4; this->unk_72 = 0; this->unk_70 = GetTileIndex(COORD_TO_TILE(super), super->collisionLayer); diff --git a/src/object/dirtParticle.c b/src/object/dirtParticle.c index ac7e848e..cfd0295a 100644 --- a/src/object/dirtParticle.c +++ b/src/object/dirtParticle.c @@ -78,7 +78,7 @@ void DirtParticle_Init(DirtParticleEntity* this) { super->health = 1; super->collisionFlags = 7; super->hitType = 0xaa; - super->flags2 = 0x0e; + super->collisionMask = 0x0e; super->hitbox = (Hitbox*)&gUnk_08120A8C; super->gustJarFlags = 0; case 2: @@ -101,7 +101,7 @@ void DirtParticle_Init(DirtParticleEntity* this) { void DirtParticle_Action1(DirtParticleEntity* this) { DirtParticleEntity* entity; - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) { + if ((super->contactFlags & CONTACT_NOW) == 0) { return; } switch (super->contactFlags & 0x7f) { @@ -128,7 +128,7 @@ void DirtParticle_Action3(DirtParticleEntity* this) { sub_08087B9C, sub_08087B9C, }; - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { gUnk_08120A80[super->subAction](this); } else { super->action = 1; diff --git a/src/object/evilSpirit.c b/src/object/evilSpirit.c index a09392a4..43dc00ab 100644 --- a/src/object/evilSpirit.c +++ b/src/object/evilSpirit.c @@ -55,7 +55,7 @@ void EvilSpirit_Init(EvilSpiritEntity* this) { COLLISION_ON(super); super->collisionFlags = 7; super->hitType = 1; - super->flags2 = 4; + super->collisionMask = 4; for (index = 0; index < 4; index++) { evilSpiritEnt = CreateObjectWithParent(super, EVIL_SPIRIT, index + 1, 0); super->child = evilSpiritEnt; diff --git a/src/object/eyeSwitch.c b/src/object/eyeSwitch.c index 60310e5c..0e401a64 100644 --- a/src/object/eyeSwitch.c +++ b/src/object/eyeSwitch.c @@ -37,7 +37,7 @@ void EyeSwitch_Init(EyeSwitchEntity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = 1; - super->flags2 = 2; + super->collisionMask = 2; super->hitbox = (Hitbox*)&gHitbox_1; if (CheckFlags(this->eyeSwitchFlags)) { super->action = 3; @@ -50,7 +50,7 @@ void EyeSwitch_Init(EyeSwitchEntity* this) { } void EyeSwitch_Action1(EyeSwitchEntity* this) { - if ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15) || super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe)) && + if ((super->contactFlags == (CONTACT_NOW | 0x15) || super->contactFlags == (CONTACT_NOW | 0xe)) && (DirectionRoundUp(super->contactedEntity->direction) >> 3 == (super->animationState & 3))) { super->action = 2; COLLISION_OFF(super); diff --git a/src/object/fairy.c b/src/object/fairy.c index 38026906..0f2eb209 100644 --- a/src/object/fairy.c +++ b/src/object/fairy.c @@ -40,7 +40,7 @@ void Fairy(FairyEntity* this) { Fairy_Init, Fairy_Action1, Fairy_Action2, Fairy_Action3, Fairy_Action4, }; - if (((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) { + if (((super->contactFlags & CONTACT_NOW) != 0)) { switch (super->contactFlags & 0x7f) { case 0x14: super->action = 3; @@ -103,7 +103,7 @@ void Fairy_Init(FairyEntity* this) { super->collisionFlags = 0x17; super->hurtType = 0x49; super->hitType = 7; - super->flags2 = 0x17; + super->collisionMask = 0x17; super->health = 0xff; super->hitbox = (Hitbox*)&gUnk_080FD1A8; super->gustJarFlags = 1; @@ -253,6 +253,6 @@ void sub_0808DB2C(FairyEntity* this) { super->action = 2; super->subAction = 0; super->flags |= ENT_COLLIDE; - super->flags2 = 1; + super->collisionMask = 1; CopyPosition(&gPlayerEntity.base, super); } diff --git a/src/object/gleerokParticle.c b/src/object/gleerokParticle.c index 23bd5d17..7af41d2f 100644 --- a/src/object/gleerokParticle.c +++ b/src/object/gleerokParticle.c @@ -152,7 +152,7 @@ void GleerokParticle_Init(GleerokParticleEntity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = 0x7a; - super->flags2 = 1; + super->collisionMask = 1; } break; case 0x80: diff --git a/src/object/hittableLever.c b/src/object/hittableLever.c index 0bf530ac..a2d97301 100644 --- a/src/object/hittableLever.c +++ b/src/object/hittableLever.c @@ -32,7 +32,7 @@ void HittableLever_Init(HittableLeverEntity* this) { super->flags |= ENT_COLLIDE; super->collisionFlags = 7; super->hitType = 0x8f; - super->flags2 = 0xa; + super->collisionMask = 0xa; super->hitbox = (Hitbox*)&HittableLever_Hitbox; if (super->type == 0) { if (CheckFlags(this->hitFlag)) { @@ -47,7 +47,7 @@ void HittableLever_Init(HittableLeverEntity* this) { } void HittableLever_Idle(HittableLeverEntity* this) { - if (((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (this->wasHit == 0)) { + if (((super->contactFlags & CONTACT_NOW) != 0) && (this->wasHit == 0)) { this->wasHit = 1; super->type ^= 1; super->iframes = -0x18; diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index b3f6f045..8080b14c 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -63,7 +63,7 @@ void ItemOnGround(ItemOnGroundEntity* this) { static void (*const ItemOnGround_Actions[])(ItemOnGroundEntity*) = { ItemOnGround_Init, ItemOnGround_Action1, ItemOnGround_Action2, ItemOnGround_Action3, ItemOnGround_Action4, }; - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { switch (super->contactFlags & 0x7F) { case 20: super->action = 3; @@ -130,10 +130,10 @@ void ItemOnGround_Init(ItemOnGroundEntity* this) { case ITEM_BOMBS5: case ITEM_ARROWS5: case ITEM_HEART: - super->flags2 = 0x17; + super->collisionMask = 0x17; break; default: - super->flags2 = 0x11; + super->collisionMask = 0x11; break; } @@ -186,7 +186,7 @@ void sub_080810FC(ItemOnGroundEntity* this) { super->action = 2; super->subAction = 0; COLLISION_ON(super); - super->flags2 = 0x11; + super->collisionMask = 0x11; CopyPosition(&gPlayerEntity.base, super); } } diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index cd77b956..83c47a0d 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -39,7 +39,7 @@ void JarPortal_Init(JarPortalEntity* this) { super->hitType = 1; super->collisionFlags = 0x47; super->hurtType = 0x44; - super->flags2 = 0x80; + super->collisionMask = 0x80; this->unk_68 = 0; if (CheckLocalFlag(super->type)) { if (this->unk_7c != 0) { @@ -170,7 +170,7 @@ void JarPortal_Action4(JarPortalEntity* this) { } u32 sub_0808C128(JarPortalEntity* this) { - return super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d); + return super->contactFlags == (CONTACT_NOW | 0x1d); } void sub_0808C13C(JarPortalEntity* this) { diff --git a/src/object/lavaPlatform.c b/src/object/lavaPlatform.c index 619bc685..5e806494 100644 --- a/src/object/lavaPlatform.c +++ b/src/object/lavaPlatform.c @@ -112,7 +112,7 @@ void LavaPlatform_Type1Init(LavaPlatformEntity* this) { super->spritePriority.b0 = 7; super->hurtType = 0x48; super->collisionFlags = 7; - super->flags2 = 0x81; + super->collisionMask = 0x81; super->hitbox = (Hitbox*)&gUnk_080FD280; sub_0809264C(this); } @@ -131,7 +131,7 @@ void LavaPlatform_Type1Action1(LavaPlatformEntity* this) { } void LavaPlatform_Type1Action2(LavaPlatformEntity* this) { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { + if (super->contactFlags == (CONTACT_NOW | 0x1d)) { sub_08092620(this); } else { if (LavaPlatform_IsPlayerOnPlatform(this)) { @@ -223,7 +223,7 @@ void LavaPlatform_Type1Action6(LavaPlatformEntity* this) { } void LavaPlatform_Type1Action7(LavaPlatformEntity* this) { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { + if (super->contactFlags == (CONTACT_NOW | 0x1d)) { sub_08092620(this); } } diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index 06bb3244..a6f0427f 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -58,7 +58,7 @@ void LightableSwitch_Type0_Init(LightableSwitchEntity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = 0x28; - super->flags2 = 10; + super->collisionMask = 10; super->hitbox = (Hitbox*)&gHitbox_0; sub_0809EAD8(this); UpdateSpriteForCollisionLayer(super); @@ -67,7 +67,7 @@ void LightableSwitch_Type0_Init(LightableSwitchEntity* this) { void LightableSwitch_Type0_Action1(LightableSwitchEntity* this) { - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { if (CheckFlags(this->unk_86) != 0) { ClearFlag(this->unk_86); } else { @@ -136,7 +136,7 @@ void LightableSwitch_Type1_Init(LightableSwitchEntity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = 0x28; - super->flags2 = 10; + super->collisionMask = 10; super->hitbox = (Hitbox*)&gHitbox_0; sub_0809EAD8(this); UpdateSpriteForCollisionLayer(super); @@ -147,7 +147,7 @@ void LightableSwitch_Type1_Init(LightableSwitchEntity* this) { } void LightableSwitch_Type1_Action1(LightableSwitchEntity* this) { - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { super->action = 2; super->timer = 16; super->frameIndex = 2; diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index b4bd9c60..d90c1610 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -76,7 +76,7 @@ void LilypadLarge_Init(LilypadLargeEntity* this) { super->flags |= ENT_COLLIDE; super->collisionFlags = 7; super->hitType = 1; - super->flags2 = 4; + super->collisionMask = 4; this->unk_78.WORD = 0x1000000; this->unk_7c.HALF_U.HI = 0x1000; this->unk_85 = 0; diff --git a/src/object/minecart.c b/src/object/minecart.c index b13f2c7e..30594d6d 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -54,7 +54,7 @@ void Minecart_Init(MinecartEntity* this) { super->hitType = 1; super->collisionFlags = 0x47; super->hurtType = 0x44; - super->flags2 = 0x80; + super->collisionMask = 0x80; super->direction = DirectionFromAnimationState(super->animationState); super->speed = 0x700; super->spritePriority.b1 = 3; @@ -112,7 +112,7 @@ void Minecart_Action2(MinecartEntity* this) { super->flags |= ENT_PERSIST; super->hitType = 0x97; super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x20; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; super->hurtType = 0x18; super->damage = 8; sub_0801766C(super); @@ -176,7 +176,7 @@ void Minecart_Action3(MinecartEntity* this) { super->hitType = 1; super->collisionFlags = 0x47; super->hurtType = 0x44; - super->flags2 = 0x80; + super->collisionMask = 0x80; super->action = 6; sub_08017744(super); gPlayerState.jump_status = 0x41; diff --git a/src/object/mineralWaterSource.c b/src/object/mineralWaterSource.c index e60006d8..3692821b 100644 --- a/src/object/mineralWaterSource.c +++ b/src/object/mineralWaterSource.c @@ -46,7 +46,7 @@ void MineralWaterSource_Init(Entity* this) { this->collisionFlags = 7; this->hitType = 145; - this->flags2 = 2; + this->collisionMask = 2; this->action = 1; } diff --git a/src/object/objectA8.c b/src/object/objectA8.c index 6f47de25..4f602fd0 100644 --- a/src/object/objectA8.c +++ b/src/object/objectA8.c @@ -39,7 +39,7 @@ void ObjectA8(ObjectA8Entity* this) { ObjectA8_Init, ObjectA8_Action1, ObjectA8_Action2, ObjectA8_Action3, ObjectA8_Action4, ObjectA8_Action5, ObjectA8_Action6, }; - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { switch (super->contactFlags & 0x7f) { case 0: case 1: @@ -77,7 +77,7 @@ void ObjectA8_Init(ObjectA8Entity* this) { super->collisionFlags = 0x17; super->hurtType = 0x48; super->hitType = 7; - super->flags2 = 0x17; + super->collisionMask = 0x17; super->hitbox = (Hitbox*)&gUnk_080FD1A8; super->gustJarFlags = 1; this->unk_74 = super->x.HALF.HI; diff --git a/src/object/objectOnSpinyBeetle.c b/src/object/objectOnSpinyBeetle.c index aafecc5b..fda7b417 100644 --- a/src/object/objectOnSpinyBeetle.c +++ b/src/object/objectOnSpinyBeetle.c @@ -54,7 +54,7 @@ void ObjectOnSpinyBeetle_Init(ObjectOnSpinyBeetleEntity* this) { super->spriteRendering.b3 = 2; super->subtimer = 0; super->hitType = 0x6e; - super->flags2 = 0x86; + super->collisionMask = 0x86; super->carryFlags = 0; if (super->type != 0) { super->gustJarFlags = 2; @@ -72,7 +72,7 @@ void ObjectOnSpinyBeetle_Action1(ObjectOnSpinyBeetleEntity* this) { sub_080989C0(this); return; } - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { switch (super->contactFlags & 0x3f) { case 0x13: super->action = 3; @@ -138,7 +138,7 @@ void ObjectOnSpinyBeetle_Action2Subaction0(ObjectOnSpinyBeetleEntity* this) { super->flags |= ENT_COLLIDE; super->collisionFlags = 7; super->hitType = 1; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; super->spriteOffsetY = 0; (super->parent)->child = NULL; super->subAction++; diff --git a/src/object/playerClone.c b/src/object/playerClone.c index c6e65188..f6767e07 100644 --- a/src/object/playerClone.c +++ b/src/object/playerClone.c @@ -163,7 +163,7 @@ void sub_08084B1C(PlayerCloneEntity* this) { super->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0; super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; super->collisionLayer = gPlayerEntity.base.collisionLayer; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; super->hitType = gPlayerEntity.base.hitType; super->collisionFlags = gPlayerEntity.base.collisionFlags; super->hurtType = gPlayerEntity.base.hurtType; diff --git a/src/object/pot.c b/src/object/pot.c index 3901820e..444c14bb 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -72,7 +72,7 @@ void Pot_Init(PotEntity* this) { super->health = 1; super->collisionFlags = 7; super->hitType = 0x6E; - super->flags2 = 0x84; + super->collisionMask = 0x84; super->gustJarFlags = 0x12; if (super->collisionLayer == 0) { ResolveCollisionLayer(super); @@ -156,7 +156,7 @@ void sub_08082510(PotEntity* this) { super->hitbox = (Hitbox*)&gUnk_080FD340; super->collisionFlags = 7; super->hitType = 1; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; super->spriteOffsetY = 0; SetBottomTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); super->subAction++; diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c index b8f6eabc..de90f11d 100644 --- a/src/object/pullableMushroom.c +++ b/src/object/pullableMushroom.c @@ -63,7 +63,7 @@ void PullableMushroom_Init(PullableMushroomEntity* this) { super->health = 1; super->collisionFlags = 7; super->hitType = 0x6e; - super->flags2 = 0x0e; + super->collisionMask = 0x0e; super->gustJarFlags = 1; super->flags |= 0x80; super->spriteOffsetY = 4; @@ -76,7 +76,7 @@ void PullableMushroom_Init(PullableMushroomEntity* this) { super->health = 1; super->collisionFlags = 7; super->hitType = 0x6e; - super->flags2 = 4; + super->collisionMask = 4; super->gustJarFlags = 1; super->action = 3; } diff --git a/src/object/sanctuaryStoneTablet.c b/src/object/sanctuaryStoneTablet.c index b612f487..9d943927 100644 --- a/src/object/sanctuaryStoneTablet.c +++ b/src/object/sanctuaryStoneTablet.c @@ -37,14 +37,14 @@ void SanctuaryStoneTablet_Init(SanctuaryStoneTabletEntity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = 1; - super->flags2 = 2; + super->collisionMask = 2; super->hitbox = (Hitbox*)&gHitbox_0; } void SanctuaryStoneTablet_Action1(SanctuaryStoneTabletEntity* this) { Entity* fxEnt; - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x21)) { + if (super->contactFlags == (CONTACT_NOW | 0x21)) { fxEnt = CreateFx(super, FX_MAGIC_STORM, 0); if (fxEnt != NULL) { fxEnt->spritePriority.b0 = 3; diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c index e7931190..f6e6e7b3 100644 --- a/src/object/smallIceBlock.c +++ b/src/object/smallIceBlock.c @@ -60,7 +60,7 @@ void SmallIceBlock_Init(SmallIceBlockEntity* this) { super->collisionFlags = 7; super->hurtType = 0x48; super->hitType = 1; - super->flags2 = 0x80; + super->collisionMask = 0x80; super->hitbox = (Hitbox*)&gUnk_080FD408; sub_08099468(this); InitializeAnimation(super, super->type); @@ -281,7 +281,7 @@ bool32 sub_0809963C(SmallIceBlockEntity* this) { } } } - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { + if (super->contactFlags == (CONTACT_NOW | 0x7)) { return TRUE; } return FALSE; diff --git a/src/object/smokeParticle.c b/src/object/smokeParticle.c index 4c24717a..b6b2305d 100644 --- a/src/object/smokeParticle.c +++ b/src/object/smokeParticle.c @@ -36,7 +36,7 @@ void SmokeParticle_Init(Entity* this) { this->hitType = 0xa9; this->hurtType = 0x16; this->hitbox = (Hitbox*)gUnk_08120A54[0]; - this->flags2 = 0x8b; + this->collisionMask = 0x8b; sub_080878CC(this); InitializeAnimation(this, 1); sub_0801766C(this); diff --git a/src/object/treeThorns.c b/src/object/treeThorns.c index 66f26cc6..1af83621 100644 --- a/src/object/treeThorns.c +++ b/src/object/treeThorns.c @@ -26,7 +26,7 @@ void TreeThorns(Entity* this) { this->collisionFlags = 7; this->hurtType = 0x48; this->hitType = 0x7a; - this->flags2 = 1; + this->collisionMask = 1; this->hitbox = (Hitbox*)&gHitbox_1; tilePos = COORD_TO_TILE(this); SetBottomTile(0x4066, tilePos - 1, *layer); diff --git a/src/object/unusedSkull.c b/src/object/unusedSkull.c index d594d5c1..038472d2 100644 --- a/src/object/unusedSkull.c +++ b/src/object/unusedSkull.c @@ -36,7 +36,7 @@ void UnusedSkull_Init(UnusedSkullEntity* this) { super->collisionFlags = 7; super->hitType = 1; super->hurtType = 0x47; - super->flags2 = 2; + super->collisionMask = 2; super->hitbox = (Hitbox*)&gHitbox_4; SetBottomTile(0x4050, COORD_TO_TILE(super), super->collisionLayer); if (super->type == 1 || CheckFlags(this->unk_86)) { @@ -49,7 +49,7 @@ void UnusedSkull_Init(UnusedSkullEntity* this) { } void UnusedSkull_Action1(UnusedSkullEntity* this) { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1c)) { + if (super->contactFlags == (CONTACT_NOW | 0x1c)) { super->action = 2; super->flags &= ~0x80; CreateFx(super, FX_ICE, 0); diff --git a/src/object/whirlwind.c b/src/object/whirlwind.c index 979a62a3..add24319 100644 --- a/src/object/whirlwind.c +++ b/src/object/whirlwind.c @@ -33,7 +33,7 @@ void Whirlwind_Init(Entity* this) { this->hitType = 1; this->collisionFlags = 0x47; this->hurtType = 0x44; - this->flags2 = 0x80; + this->collisionMask = 0x80; this->spriteOrientation.flipY = 1; this->spriteRendering.b3 = 1; this->animationState = this->type; @@ -58,7 +58,7 @@ void Whirlwind_Action1(Entity* this) { } if (this->spriteSettings.draw != 0) { GetNextFrame(this); - if ((((((gPlayerState.flags & PL_MINISH) == 0)) && (gPlayerState.field_0x3c == 0)) && + if ((((((gPlayerState.flags & PL_MINISH) == 0)) && (gPlayerState.killed == 0)) && ((gPlayerEntity.base.action == PLAYER_JUMP || ((gPlayerEntity.base.flags & ENT_COLLIDE) != 0)))) && ((gPlayerEntity.base.action != PLAYER_BOUNCE && (sub_0800419C(this, &gPlayerEntity.base, 0xc, 0xc) != 0)))) { diff --git a/src/physics.c b/src/physics.c index 04eae6c1..421c2474 100644 --- a/src/physics.c +++ b/src/physics.c @@ -114,7 +114,7 @@ void sub_0806F4E8(Entity* ent) { } bool32 sub_0806F520(Entity* ent) { - if (ent->contactFlags == (CONTACT_TAKE_DAMAGE | 0x13)) + if (ent->contactFlags == (CONTACT_NOW | 0x13)) return 1; ent->gustJarState &= ~4; ent->spriteOffsetY = 0; diff --git a/src/player.c b/src/player.c index 064b47ec..ffb4ca6c 100644 --- a/src/player.c +++ b/src/player.c @@ -349,7 +349,7 @@ static void PlayerInit(PlayerEntity* this) { super->spritePriority.b1 = 1; super->spriteSettings.shadow = 1; super->carryFlags = 0x20; - super->flags2 = 8; + super->collisionMask = 8; super->hitType = 0x79; super->hitbox = (Hitbox*)&gPlayerHitbox; super->spriteIndex = 1; @@ -1561,7 +1561,7 @@ static void sub_08071D04(PlayerEntity* this) { if (deltaHealth != 0) { ModHealth(deltaHealth); super->subAction = 3; - gPlayerState.field_0x3c = 0; + gPlayerState.killed = 0; super->direction = DIR_NONE; super->speed = 0; super->zVelocity = Q_16_16(1.5); @@ -2068,7 +2068,7 @@ static void PlayerRollInit(PlayerEntity* this) { static void PlayerRollUpdate(PlayerEntity* this) { if (((gPlayerState.flags & (PL_ROLLING | PL_MOLDWORM_CAPTURED)) != PL_ROLLING) || (!(gPlayerState.flags & PL_MOLDWORM_RELEASED) && (super->iframes != 0) && - (super->contactFlags & CONTACT_TAKE_DAMAGE))) { + (super->contactFlags & CONTACT_NOW))) { gPlayerState.flags &= ~PL_ROLLING; if (CheckQueuedAction()) return; @@ -2753,7 +2753,7 @@ static void sub_08073504(PlayerEntity* this) { static void sub_08073584(PlayerEntity* this) { u32 state, dir, idx; - if ((gPlayerState.playerInput.newInput & INPUT_ACTION) || super->iframes > 0 || gPlayerState.field_0x3c || + if ((gPlayerState.playerInput.newInput & INPUT_ACTION) || super->iframes > 0 || gPlayerState.killed || (gPlayerState.flags & PL_PARACHUTE) == 0) { gPlayerState.jump_status |= 0x40; PlayerSetNormalAndCollide(); diff --git a/src/playerItem.c b/src/playerItem.c index 46fbd023..266d12d0 100644 --- a/src/playerItem.c +++ b/src/playerItem.c @@ -74,7 +74,7 @@ void ItemUpdate(Entity* this) { if (!EntityDisabled(this)) { gPlayerItemFunctions[this->id](this); - this->contactFlags &= ~CONTACT_TAKE_DAMAGE; + this->contactFlags &= ~CONTACT_NOW; if (this->iframes != 0) { if (this->iframes > 0) this->iframes--; diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c index 46bc2ca4..bcc151a8 100644 --- a/src/playerItem/playerItemBoomerang.c +++ b/src/playerItem/playerItemBoomerang.c @@ -128,7 +128,7 @@ void PlayerItemBoomerang_Action1(PlayerItemBoomerangEntity* this) { super->spriteVramOffset = 0xd5; COLLISION_ON(super); super->collisionFlags |= 1; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; super->spriteIndex = 0xa6; super->spriteSettings.flipX = 0; super->spriteSettings.draw = 1; @@ -184,7 +184,7 @@ void PlayerItemBoomerang_Action2(PlayerItemBoomerangEntity* this) { if (super->timer == 0) { uVar6 = TRUE; } - if (super->contactFlags & CONTACT_TAKE_DAMAGE) { + if (super->contactFlags & CONTACT_NOW) { uVar6 = TRUE; } if (!uVar6) { diff --git a/src/playerItem/playerItemBottle.c b/src/playerItem/playerItemBottle.c index 962f8d7a..c8cb3ad7 100644 --- a/src/playerItem/playerItemBottle.c +++ b/src/playerItem/playerItemBottle.c @@ -48,7 +48,7 @@ void PlayerItemBottle_Init(PlayerItemBottleEntity* this) { } COLLISION_ON(super); super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x20; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; super->hurtType = 0x1f; super->type = 1; super->type2 = ITEM_BOTTLE_EMPTY; diff --git a/src/playerItem/playerItemBow.c b/src/playerItem/playerItemBow.c index 4495475b..0c3932a8 100644 --- a/src/playerItem/playerItemBow.c +++ b/src/playerItem/playerItemBow.c @@ -87,7 +87,7 @@ void PlayerItemBow_Init(PlayerItemBowEntity* this) { } super->direction = super->animationState << 2; super->collisionFlags = gPlayerEntity.base.collisionFlags + 1; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; if (super->collisionLayer == 2) { super->type2 = 1; } else { diff --git a/src/playerItem/playerItemDashSword.c b/src/playerItem/playerItemDashSword.c index 126d17bb..0256561c 100644 --- a/src/playerItem/playerItemDashSword.c +++ b/src/playerItem/playerItemDashSword.c @@ -29,7 +29,7 @@ void PlayerItemDashSword_Init(Entity* this) { gPlayerState.item = this; this->flags |= ENT_PERSIST; this->action = 1; - this->flags2 = 8; + this->collisionMask = 8; LoadSwapGFX(this, 1, 3); sub_08079BD8(this); sub_0801766C(this); diff --git a/src/playerItem/playerItemGust.c b/src/playerItem/playerItemGust.c index d77d1747..94fd1bdb 100644 --- a/src/playerItem/playerItemGust.c +++ b/src/playerItem/playerItemGust.c @@ -70,7 +70,7 @@ void PlayerItemGust(Entity* this) { static void PlayerItemGust_Init(PlayerItemGustEntity* this) { super->action = GUST_UPDATE; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; super->direction = super->animationState << 2; super->speed = 0x200; super->flags |= ENT_COLLIDE | ENT_PERSIST; diff --git a/src/playerItem/playerItemGustBig.c b/src/playerItem/playerItemGustBig.c index a2e18c99..228ca1a3 100644 --- a/src/playerItem/playerItemGustBig.c +++ b/src/playerItem/playerItemGustBig.c @@ -73,7 +73,7 @@ void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this) { super->speed = 0x400; super->hitType = 0x96; super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x80; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; pEVar3 = super->child; if (pEVar3 != NULL) { super->action = 1; @@ -141,7 +141,7 @@ void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this) { if ((super->child->gustJarState & 4) == 0) { DeleteThisEntity(); } - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { PlayerItemGustBig_Action3(this); return; } diff --git a/src/playerItem/playerItemHeldObject.c b/src/playerItem/playerItemHeldObject.c index 669c77ca..520d8359 100644 --- a/src/playerItem/playerItemHeldObject.c +++ b/src/playerItem/playerItemHeldObject.c @@ -112,7 +112,7 @@ void PlayerItemHeldObject_SubAction2(PlayerItemHeldObjectEntity* this) { if ((child->base).action != 2) { DeleteThisEntity(); } - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { super->z.WORD = 0; } if (super->speed != 0) { diff --git a/src/playerItem/playerItemLantern.c b/src/playerItem/playerItemLantern.c index 04664464..7c16acbc 100644 --- a/src/playerItem/playerItemLantern.c +++ b/src/playerItem/playerItemLantern.c @@ -29,7 +29,7 @@ void PlayerItemLantern_Init(Entity* this) { this->frameIndex = -1; this->updatePriority = 6; this->collisionFlags = 7; - this->flags2 = -0x80; + this->collisionMask = -0x80; this->animationState = gPlayerEntity.base.animationState & 0xe; if (AllocMutableHitbox(this) == NULL) { DeleteThisEntity(); diff --git a/src/playerItem/playerItemPacciCaneProjectile.c b/src/playerItem/playerItemPacciCaneProjectile.c index 4c4bc005..cb6cdfb5 100644 --- a/src/playerItem/playerItemPacciCaneProjectile.c +++ b/src/playerItem/playerItemPacciCaneProjectile.c @@ -74,7 +74,7 @@ void PlayerItemPacciCaneProjectile_Init(PlayerItemPacciCaneProjectileEntity* thi super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI + gUnk_0811B9A0[super->animationState]; super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI + gUnk_0811B9A0[super->animationState + 1]; super->collisionFlags = 7; - super->flags2 = 0x8a; + super->collisionMask = 0x8a; super->hitbox = (Hitbox*)&gUnk_0811B9D0; if (super->collisionLayer == 2) { super->type = 1; diff --git a/src/playerItem/playerItemShield.c b/src/playerItem/playerItemShield.c index 35bd8586..7df31ebd 100644 --- a/src/playerItem/playerItemShield.c +++ b/src/playerItem/playerItemShield.c @@ -102,7 +102,7 @@ void PlayerItemShield_Action1(PlayerItemShieldEntity* this) { gPlayerState.shield_status &= ~0x80; sub_080176E4(super); } else { - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { if ((((super->contactFlags & 0x7f) == 0x42) && this->unk_68 == 0xe) && ((gPlayerState.shield_status & 0x40) == 0)) { playerItem = CreatePlayerItem(PLAYER_ITEM_FIRE_ROD_PROJECTILE, 0, 0, this->unk_68); diff --git a/src/playerItem/playerItemSword.c b/src/playerItem/playerItemSword.c index bed81f9f..13d96c42 100644 --- a/src/playerItem/playerItemSword.c +++ b/src/playerItem/playerItemSword.c @@ -59,7 +59,7 @@ void PlayerItemSword_Init(PlayerItemSwordEntity* this) { } LoadSwapGFX(super, 1, 3); super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x20; - super->flags2 = gPlayerEntity.base.flags2; + super->collisionMask = gPlayerEntity.base.collisionMask; super->updatePriority = 6; super->contactFlags = 0; super->iframes = 0; @@ -285,7 +285,7 @@ void sub_080A78B8(PlayerItemSwordEntity* this, Entity* param_2) { } super->spriteSettings.flipX = flipX; } - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { if ((param_2->iframes == 0) || ((u8)param_2->iframes == 0x81)) { param_2->iframes = super->iframes; param_2->knockbackDirection = super->knockbackDirection; diff --git a/src/playerUtils.c b/src/playerUtils.c index 8ff5a7f9..85656344 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -1564,7 +1564,7 @@ void ClearPlayerState(void) { gPlayerState.field_0x39 = 0; gPlayerState.field_0x3a = 0; gPlayerState.spriteOffsetY = 0; - gPlayerState.field_0x3c = 0; + gPlayerState.killed = 0; MemFill32(0xffffffff, gPlayerState.path_memory, 0x40); MemClear(&gPossibleInteraction, sizeof(gPossibleInteraction)); } @@ -2029,9 +2029,9 @@ bool32 sub_08079550(void) { void sub_08079708(Entity* this) { gPlayerState.framestate = PL_STATE_DIE; - gPlayerState.field_0x3c = 0xff; + gPlayerState.killed = 0xff; this->flags &= ~ENT_COLLIDE; - this->action = 0xa; + this->action = PLAYER_MINISHDIE; this->subAction = 0; sub_080085B0(this); if (!(gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS))) { @@ -2450,7 +2450,7 @@ bool32 PlayerCanBeMoved(void) { if ((gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_FROZEN | PL_FALLING | PL_DISABLE_ITEMS | PL_PIT_IS_EXIT | PL_IN_MINECART | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_CONVEYOR_PUSHED | PL_CLIMBING)) != 0 || - gPlayerState.field_0x3c != 0 || gPlayerEntity.base.action == PLAYER_FALL || + gPlayerState.killed != 0 || gPlayerEntity.base.action == PLAYER_FALL || gPlayerEntity.base.action == PLAYER_08071DB8) { return FALSE; } else { diff --git a/src/projectile/arrowProjectile.c b/src/projectile/arrowProjectile.c index 7acc8003..c47f0414 100644 --- a/src/projectile/arrowProjectile.c +++ b/src/projectile/arrowProjectile.c @@ -34,7 +34,7 @@ void ArrowProjectile_OnTick(Entity* this) { } void ArrowProjectile_OnCollision(Entity* this) { - if ((this->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((this->contactFlags & CONTACT_NOW) != 0) { if ((this->contactFlags & 0x3f) != 0) { ModHealth(-2); sub_080A9488(this); diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index d1052df8..336920a2 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -23,7 +23,7 @@ void BoneProjectile_OnTick(Entity* this) { } void BoneProjectile_OnCollision(Entity* this) { - if (this->contactFlags == CONTACT_TAKE_DAMAGE) { + if (this->contactFlags == CONTACT_NOW) { DeleteEntity(this); } else { sub_080A82D8(this); diff --git a/src/projectile/darkNutSwordSlash.c b/src/projectile/darkNutSwordSlash.c index 838435e5..1b09cf4b 100644 --- a/src/projectile/darkNutSwordSlash.c +++ b/src/projectile/darkNutSwordSlash.c @@ -30,7 +30,7 @@ void DarkNutSwordSlash(Entity* this) { if ((this->parent == NULL) || (this->parent->health == 0)) { DeleteThisEntity(); } - if (((this->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { + if (((this->contactFlags & CONTACT_NOW) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { this->iframes = -0x2d; } this->contactFlags = 0; diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c index c086f251..f3b2f5e7 100644 --- a/src/projectile/dekuSeedProjectile.c +++ b/src/projectile/dekuSeedProjectile.c @@ -24,7 +24,7 @@ void DekuSeedProjectile_OnTick(Entity* this) { } void DekuSeedProjectile_OnCollision(Entity* this) { - if (this->contactFlags == CONTACT_TAKE_DAMAGE) { + if (this->contactFlags == CONTACT_NOW) { if (this->hitType == 0x68) { EnqueueSFX(SFX_86); } @@ -75,7 +75,7 @@ void DekuSeedProjectile_Action1(Entity* this) { if ((parent->next != NULL) && (IsColliding(this, parent) != 0)) { this->iframes = 0x10; this->knockbackDirection = -this->direction; - this->contactFlags = CONTACT_TAKE_DAMAGE; + this->contactFlags = CONTACT_NOW; this->knockbackDuration = 0xc; this->knockbackSpeed = 0; parent->iframes = 0x10; diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index 2ef3867e..a03009de 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -41,7 +41,7 @@ void DirtBallProjectile_OnCollision(Entity* this) { this->knockbackSpeed = 0; if (this->type == 0) { this->parent->child = NULL; - if (this->contactFlags == CONTACT_TAKE_DAMAGE) { + if (this->contactFlags == CONTACT_NOW) { gPlayerState.hurtBlinkSpeed = 0xf0; ModHealth(-2); } diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index d40d2a92..2b01180f 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -28,8 +28,7 @@ void GleerokProjectile(GleerokProjectileEntity* this) { } void GleerokProjectile_OnTick(GleerokProjectileEntity* this) { - if (((super->type != 3) && ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) && - ((super->contactFlags & 0x7f) != 0x1e)) { + if (((super->type != 3) && ((super->contactFlags & CONTACT_NOW) != 0)) && ((super->contactFlags & 0x7f) != 0x1e)) { super->action = 3; COLLISION_OFF(super); InitializeAnimation(super, 0x53); diff --git a/src/projectile/guardLineOfSight.c b/src/projectile/guardLineOfSight.c index dfb59237..d117507c 100644 --- a/src/projectile/guardLineOfSight.c +++ b/src/projectile/guardLineOfSight.c @@ -26,7 +26,7 @@ void GuardLineOfSight(Entity* this) { this->timer = Random(); this->spriteSettings.draw = 0; } - if (this->contactFlags == CONTACT_TAKE_DAMAGE) { + if (this->contactFlags == CONTACT_NOW) { if (this->parent != NULL) { this->parent->type = 0xff; } @@ -58,7 +58,7 @@ void GuardLineOfSight(Entity* this) { this->hitbox = (Hitbox*)&gUnk_080FD1E4; InitializeAnimation(this, 0); } - if (this->contactFlags == CONTACT_TAKE_DAMAGE) { + if (this->contactFlags == CONTACT_NOW) { if (this->parent != NULL) { this->parent->type = 0xff; } diff --git a/src/projectile/keatonDagger.c b/src/projectile/keatonDagger.c index 6a4b66c3..cf1fa109 100644 --- a/src/projectile/keatonDagger.c +++ b/src/projectile/keatonDagger.c @@ -20,7 +20,7 @@ void KeatonDagger(Entity* this) { } parent = this->parent; if (((parent == NULL) || (parent->health == 0)) || (parent->next == NULL)) { - if (((this->contactFlags & CONTACT_TAKE_DAMAGE) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { + if (((this->contactFlags & CONTACT_NOW) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { sub_0803C0AC(this); } DeleteEntity(this); diff --git a/src/projectile/lakituLightning.c b/src/projectile/lakituLightning.c index 47d300a7..279ef9e9 100644 --- a/src/projectile/lakituLightning.c +++ b/src/projectile/lakituLightning.c @@ -23,7 +23,7 @@ void LakituLightning_OnTick(Entity* this) { } void LakituLightning_OnCollision(Entity* this) { - if ((this->health == 0) || (this->contactFlags == CONTACT_TAKE_DAMAGE)) { + if ((this->health == 0) || (this->contactFlags == CONTACT_NOW)) { DeleteThisEntity(); } LakituLightning_OnTick(this); diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index 64142a9c..2b6f67a3 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -55,7 +55,7 @@ void MandiblesProjectile_OnTick(MandiblesProjectileEntity* this) { void MandiblesProjectile_OnCollision(MandiblesProjectileEntity* this) { Entity* parent; - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { switch (super->action) { case 4: super->subtimer = 0; diff --git a/src/projectile/moblinSpear.c b/src/projectile/moblinSpear.c index 076477b0..2e58a091 100644 --- a/src/projectile/moblinSpear.c +++ b/src/projectile/moblinSpear.c @@ -38,7 +38,7 @@ void MoblinSpear_OnTick(Entity* this) { void MoblinSpear_OnCollision(Entity* this) { u8 tmp; - if (this->contactFlags == CONTACT_TAKE_DAMAGE) { + if (this->contactFlags == CONTACT_NOW) { this->iframes = 0x10; this->knockbackDuration = 0xc; this->knockbackSpeed = 0x180; diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 43982f37..8ca0d67d 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -99,7 +99,7 @@ void OctorokBossProjectile_Action1(OctorokBossProjectileEntity* this) { if (super->parent->action == 2) { DeleteThisEntity(); } - if ((super->type2 == 0) && ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0)) { + if ((super->type2 == 0) && ((super->contactFlags & CONTACT_NOW) != 0)) { if ((super->contactFlags & 0x7f) == 0) { OctorokBossProjectile_Action2(this); } @@ -182,7 +182,7 @@ void OctorokBossProjectile_Action1(OctorokBossProjectileEntity* this) { if (--*(u32*)&this->unk_78 == -1) { OctorokBossProjectile_Action2(this); } - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) { + if ((super->contactFlags & CONTACT_NOW) == 0) { return; } OctorokBossProjectile_Action2(this); diff --git a/src/projectile/projectile5.c b/src/projectile/projectile5.c index 379dd97d..4fa9a3d8 100644 --- a/src/projectile/projectile5.c +++ b/src/projectile/projectile5.c @@ -41,7 +41,7 @@ void Projectile5_OnCollision(Entity* this) { if ((((Projectile5Entity*)this->parent)->unk_83 & 0x3f) == 3) { if (gPlayerState.hurtBlinkSpeed != 0) { if (sub_080B1B44(TILE(this->x.HALF.HI, this->y.HALF.HI), gPlayerEntity.base.collisionLayer) == 0) { - if (this->contactFlags == CONTACT_TAKE_DAMAGE) { + if (this->contactFlags == CONTACT_NOW) { *pbVar2 = *pbVar2 & 0x7f; DeleteThisEntity(); } diff --git a/src/projectile/removableDust.c b/src/projectile/removableDust.c index e89cd3b4..49da5582 100644 --- a/src/projectile/removableDust.c +++ b/src/projectile/removableDust.c @@ -51,7 +51,7 @@ void RemovableDust_OnTick(RemovableDustEntity* this) { } void RemovableDust_OnCollision(RemovableDustEntity* this) { - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x16)) { + if (super->contactFlags == (CONTACT_NOW | 0x16)) { RemovableDust_OnGrabbed(this); } } diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c index 7dc35d0c..a2e75f11 100644 --- a/src/projectile/rockProjectile.c +++ b/src/projectile/rockProjectile.c @@ -22,7 +22,7 @@ void RockProjectile_OnTick(Entity* this) { } void RockProjectile_OnCollision(Entity* this) { - if (this->contactFlags == CONTACT_TAKE_DAMAGE) { + if (this->contactFlags == CONTACT_NOW) { DeleteEntity(this); } else { this->direction = this->knockbackDirection; diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c index c1cb7adc..b749caf4 100644 --- a/src/projectile/spiderWeb.c +++ b/src/projectile/spiderWeb.c @@ -64,7 +64,7 @@ void SpiderWeb_OnCollision(SpiderWebEntity* this) { }; Entity* object; - if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) { + if (super->contactFlags == (CONTACT_NOW | 0x7)) { super->action = 3; super->timer = 90; COLLISION_OFF(super); diff --git a/src/projectile/stalfosProjectile.c b/src/projectile/stalfosProjectile.c index 660b8f5c..bbe7b728 100644 --- a/src/projectile/stalfosProjectile.c +++ b/src/projectile/stalfosProjectile.c @@ -35,7 +35,7 @@ void StalfosProjectile_OnTick(Entity* this) { } void StalfosProjectile_OnCollision(Entity* this) { - if (this->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) { + if (this->contactFlags == (CONTACT_NOW | 0x1d)) { this->action = 3; COLLISION_OFF(this); this->zVelocity = Q_16_16(2.625); diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index eb5f73cc..dd3d1d0b 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -43,7 +43,7 @@ void V1DarkMagicProjectile_OnTick(V1DarkMagicProjectileEntity* this) { } void V1DarkMagicProjectile_OnCollision(V1DarkMagicProjectileEntity* this) { - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { if (super->type2 == 0) { if ((super->contactFlags & 0x3f) == 0) { super->action = 2; diff --git a/src/projectile/v1FireProjectile.c b/src/projectile/v1FireProjectile.c index 661547ba..9fa0260f 100644 --- a/src/projectile/v1FireProjectile.c +++ b/src/projectile/v1FireProjectile.c @@ -31,7 +31,7 @@ void V1FireProjectile_OnTick(V1FireProjectileEntity* this) { } void V1FireProjectile_OnCollision(V1FireProjectileEntity* this) { - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) { + if ((super->contactFlags & CONTACT_NOW) != 0) { super->action = 3; COLLISION_OFF(super); InitializeAnimation(super, 0x53); diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index 8f7531c4..68759c91 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -43,7 +43,7 @@ void V2Projectile_OnTick(V2ProjectileEntity* this) { } void V2Projectile_OnCollision(V2ProjectileEntity* this) { - if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) + if ((super->contactFlags & CONTACT_NOW) == 0) return; switch (super->type) { diff --git a/src/projectileUtils.c b/src/projectileUtils.c index 56dc2a66..e11be579 100644 --- a/src/projectileUtils.c +++ b/src/projectileUtils.c @@ -35,7 +35,7 @@ bool32 ProjectileInit(Entity* this) { this->speed = definition->speed; } this->collisionFlags = (definition->field0x3c << 4) | 7; - this->flags2 = definition->flags2; + this->collisionMask = definition->collisionMask; this->hitType = definition->damageType; this->hurtType = definition->field0x40; this->health = 0xff; From 5324928f44a85e9867b960ca9a0a68931f5f3bbd Mon Sep 17 00:00:00 2001 From: theo3 Date: Mon, 1 Jan 2024 12:12:05 -0800 Subject: [PATCH 09/10] npc5 document --- asm/src/code_08003FC4.s | 4 +- asm/src/code_080043E8.s | 4 +- data/animations/npc/npc5.s | 2 +- include/asm.h | 2 +- src/enemy/enemy64.c | 6 +- src/enemy/gyorgMale.c | 24 +- src/enemy/octorokBoss.c | 14 +- src/npc/ezlo.c | 2 +- src/npc/gorman.c | 4 +- src/npc/kid.c | 2 +- src/npc/npc5.c | 800 +++++++++++++++++--------------- src/object/cutsceneMiscObject.c | 2 +- src/object/evilSpirit.c | 6 +- src/object/fileScreenObjects.c | 6 +- src/object/keyStealingTakkuri.c | 2 +- src/object/objectA2.c | 2 +- src/object/octorokBossObject.c | 4 +- src/object/specialFx.c | 2 +- src/player.c | 147 +++--- src/script.c | 4 +- 20 files changed, 539 insertions(+), 500 deletions(-) diff --git a/asm/src/code_08003FC4.s b/asm/src/code_08003FC4.s index ff872eb4..cf5a3f86 100644 --- a/asm/src/code_08003FC4.s +++ b/asm/src/code_08003FC4.s @@ -348,8 +348,8 @@ sub_080041E8: @ 0x080041E8 subs r0, r0, r2 subs r1, r1, r3 - thumb_func_start sub_080041EC -sub_080041EC: @ 0x080041EC + thumb_func_start CalcDistance +CalcDistance: @ 0x080041EC adds r2, r0, #0 muls r0, r2, r0 adds r3, r1, #0 diff --git a/asm/src/code_080043E8.s b/asm/src/code_080043E8.s index 3d723136..fa2ddead 100644 --- a/asm/src/code_080043E8.s +++ b/asm/src/code_080043E8.s @@ -301,8 +301,8 @@ CalculateDirectionTo: @ 0x080045D4 ldr r3, _08004694 @ =ram_CalcCollisionDirection bx r3 - non_word_aligned_thumb_func_start sub_080045DA -sub_080045DA: @ 0x080045DA + non_word_aligned_thumb_func_start CalcOffsetAngle +CalcOffsetAngle: @ 0x080045DA push {r0, r1, r4, r5, r6, lr} movs r6, #0x40 cmp r0, #0 diff --git a/data/animations/npc/npc5.s b/data/animations/npc/npc5.s index 7bd4a442..fab530f9 100644 --- a/data/animations/npc/npc5.s +++ b/data/animations/npc/npc5.s @@ -339,7 +339,7 @@ gUnk_0810B65C:: @ 0810B65C gUnk_0810B65E:: @ 0810B65E .incbin "npc5/gUnk_0810B65E.bin" -gUnk_0810B660:: @ 0810B660 +gZeldaFollowerText:: @ 0810B660 .4byte gUnk_0810B650 .4byte gUnk_0810B652 .4byte gUnk_0810B654 diff --git a/include/asm.h b/include/asm.h index a6c7db62..d42458ee 100644 --- a/include/asm.h +++ b/include/asm.h @@ -39,7 +39,7 @@ extern void ResetCollisionLayer(struct Entity_*); extern void sub_08004596(struct Entity_*, u32); extern u32 sub_080045B4(struct Entity_*, u32, u32); extern u32 CalculateDirectionTo(u32, u32, u32, u32); -extern u32 sub_080045DA(s32, s32); +extern u32 CalcOffsetAngle(s32, s32); extern u32 sub_080086B4(u32, u32, const u8*); extern u32 ResolveCollisionLayer(struct Entity_*); extern void sub_0800417E(struct Entity_*, u32); diff --git a/src/enemy/enemy64.c b/src/enemy/enemy64.c index be47abc9..c929ae8d 100644 --- a/src/enemy/enemy64.c +++ b/src/enemy/enemy64.c @@ -189,7 +189,7 @@ void Enemy64_Action2_SubAction0(Enemy64Entity* this) { } void Enemy64_Action2_SubAction1(Enemy64Entity* this) { - u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); if (4 < (((super->direction - tmp) + 2) & 0xff)) { if (((tmp - super->direction) & 0x80) != 0) { super->direction--; @@ -290,7 +290,7 @@ void Enemy64_Action3(Enemy64Entity* this) { } void Enemy64_Action3_SubAction0(Enemy64Entity* this) { - u32 tmp = sub_080045DA(gRoomControls.origin_x + 0xa8 - super->x.HALF.HI, + u32 tmp = CalcOffsetAngle(gRoomControls.origin_x + 0xa8 - super->x.HALF.HI, gRoomControls.origin_y + 0x80 - super->y.HALF.HI); if (tmp != super->direction) { if (((tmp - super->direction) & 0x80) != 0) { @@ -490,7 +490,7 @@ void sub_080499F0(Enemy64Entity* this) { ((this->unk_7c & 1) == 0)) { if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24) && ((this->unk_7c & 2) == 0)) { - tmp = sub_080045DA((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, + tmp = CalcOffsetAngle((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, (s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); gPlayerEntity.base.x.WORD = super->x.WORD + gSineTable[tmp] * 0x2400; gPlayerEntity.base.y.WORD = super->y.WORD + gSineTable[tmp + 0x40] * -0x2400; diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index 40c43de4..30a4273f 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -260,7 +260,7 @@ void sub_08046AE8(GyorgMaleEntity* this) { } void sub_08046B18(GyorgMaleEntity* this) { - u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); if (tmp != super->direction) { if (((tmp - super->direction) & 0xFF) > 0x80) { this->unk_76 -= 0x100; @@ -283,13 +283,13 @@ void sub_08046B8C(GyorgMaleEntity* this) { this->unk_82 = gRoomControls.origin_y + 0x210; sub_08047D88(this); } else { - super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8); } } void sub_08046C04(GyorgMaleEntity* this) { - u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); if (tmp != super->direction) { if (((tmp - super->direction) & 0xFF) > 0x80) { this->unk_76 -= 0x100; @@ -311,7 +311,7 @@ void sub_08046C88(GyorgMaleEntity* this) { sub_08048178(this, sub_08048158(this->unk_70)); sub_08047D88(this); } else { - super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8); } } @@ -348,7 +348,7 @@ void sub_08046D44(GyorgMaleEntity* this) { } void sub_08046D98(GyorgMaleEntity* this) { - u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); if (tmp != super->direction) { if (((tmp - super->direction) & 0xFF) > 0x80) { this->unk_76 -= 0x100; @@ -369,7 +369,7 @@ void sub_08046E0C(GyorgMaleEntity* this) { this->unk_76 = super->direction << 8; sub_08047D88(this); } else { - super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); sub_08047DF0(this, ((0x100 - super->direction) & 0xFF) << 8); } } @@ -456,7 +456,7 @@ void sub_08046FE8(GyorgMaleEntity* this) { } void sub_0804702C(GyorgMaleEntity* this) { - u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); if (((super->direction - tmp + 2) & 0xFF) > 4) { if ((tmp - super->direction) & 0x80) { super->direction--; @@ -607,7 +607,7 @@ void sub_080473B8(GyorgMaleEntity* this) { } void sub_080473F0(GyorgMaleEntity* this) { - u32 tmp = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + u32 tmp = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); if (((super->direction - tmp + 2) & 0xFF) > 4) { s32 tmp2 = tmp - super->direction; if (tmp2 & 0x80) { @@ -791,7 +791,7 @@ void sub_080477F0(GyorgMaleEntity* this) { if (super->speed < 0x300) { super->speed += 8; } - super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); sub_08047E48(this); if (!EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x80)) { super->action = 2; @@ -896,7 +896,7 @@ void sub_08047978(GyorgMaleEntity* this) { void sub_08047B08(GyorgMaleEntity* this) { sub_08047D88(this); - super->direction = sub_080045DA(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); + super->direction = CalcOffsetAngle(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI); super->speed = 0x200; sub_08047E58(this); if (!EntityWithinDistance(super, this->unk_80, this->unk_82, 4)) @@ -1066,7 +1066,7 @@ void sub_08047EA4(GyorgMaleEntity* this, u32 unk1) { return; if (this->unk_7c & 1) { tmp2 = sub_08047F68(this) << 8; - dir = sub_080045DA(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, + dir = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); tmp = dir - (tmp / 256); tmp &= 0xFF; @@ -1149,7 +1149,7 @@ void sub_08048004(GyorgMaleEntity* this) { if (b != 3) { if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24)) { if (!(this->unk_7c & 2)) { - u32 tmp = sub_080045DA(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, + u32 tmp = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); gPlayerEntity.base.x.WORD = super->x.WORD + (gSineTable[tmp] * 9216); gPlayerEntity.base.y.WORD = super->y.WORD - (gSineTable[tmp + 0x40] * 9216); diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index 762ba7e2..1279f133 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -167,11 +167,11 @@ void OctorokBoss_Hit_SubAction1(OctorokBossEntity* this) { if (diffX > 8 || diffY > 8) { this->heap->field_0x2 = 1; #if defined(JP) || defined(DEMO_JP) || defined(EU) - super->direction = ((s32)sub_080045DA((((gRoomControls.origin_x + 0x108) << 0x10) - super->x.WORD), + super->direction = ((s32)CalcOffsetAngle((((gRoomControls.origin_x + 0x108) << 0x10) - super->x.WORD), (((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >> 3; #else - super->direction = ((s32)sub_080045DA(gRoomControls.origin_x + 0x108 - super->x.HALF.HI, + super->direction = ((s32)CalcOffsetAngle(gRoomControls.origin_x + 0x108 - super->x.HALF.HI, gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >> 3; #endif @@ -689,7 +689,7 @@ void OctorokBoss_Action1_AimTowardsPlayer(OctorokBossEntity* this) { s32 tmp1; s32 tmp2; - tmp1 = (u8)(sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) - + tmp1 = (u8)(CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) - (((u8)(-this->angle.HALF.HI) ^ 0x80))); if (IS_FROZEN(this) == FALSE) { tmp2 = 8; @@ -898,7 +898,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) { if (this->unk_80 == 0) { super->direction = - sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD); + CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD); tmp = ((u8) - (this->angle.HALF.HI + 0x80)) - super->direction; if (tmp < 0) { tmp = -tmp; @@ -912,7 +912,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) { this->unk_80 = 1; this->timer = 2; this->heap->targetAngle = - sub_080045DA((gRoomControls.origin_x + 0x108) * 0x10000 - super->x.WORD, + CalcOffsetAngle((gRoomControls.origin_x + 0x108) * 0x10000 - super->x.WORD, (gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD); this->heap->targetAngle = (u8) - (this->heap->targetAngle + 0x80); SoundReq(SFX_ED); @@ -956,7 +956,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) { } else { this->timer--; if ((gPlayerState.flags == PL_FROZEN) && (this->timer == 0x3c)) { - tmp = sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD); + tmp = CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD); if ((u8)((tmp - ((u8) - this->angle.HALF.HI ^ 0x80))) > 0x80) { this->heap->targetAngle = this->angle.HALF.HI + 0x30; } else { @@ -1178,7 +1178,7 @@ void sub_08036AF0(OctorokBossEntity* this, s32 radius, s32 angleSpeed) { continue; } else { heap->tailObjects[index - 1]->angle.HALF.HI = - sub_080045DA(heap->tailObjects[index - 1]->base.x.WORD - heap->tailObjects[index]->base.x.WORD, + CalcOffsetAngle(heap->tailObjects[index - 1]->base.x.WORD - heap->tailObjects[index]->base.x.WORD, heap->tailObjects[index - 1]->base.y.WORD - heap->tailObjects[index]->base.y.WORD); tmp = FixedMul(gSineTable[heap->tailObjects[index - 1]->angle.HALF.HI], radius << 4); tmp = FixedDiv(tmp, 0x100); diff --git a/src/npc/ezlo.c b/src/npc/ezlo.c index b80078cb..26de89ef 100644 --- a/src/npc/ezlo.c +++ b/src/npc/ezlo.c @@ -38,7 +38,7 @@ void sub_0806D8A0(Entity* this, ScriptExecutionContext* context) { context->y.HALF.HI = yOffset; xOffset -= this->x.HALF.HI; - this->direction = sub_080045DA(xOffset, yOffset - this->y.HALF.HI); + this->direction = CalcOffsetAngle(xOffset, yOffset - this->y.HALF.HI); this->animationState = (this->animationState & 0x80) | gUnk_08114134[this->direction >> 4]; } diff --git a/src/npc/gorman.c b/src/npc/gorman.c index d4a8683a..bb679c80 100644 --- a/src/npc/gorman.c +++ b/src/npc/gorman.c @@ -154,7 +154,7 @@ void sub_0806991C(GormanEntity* this, ScriptExecutionContext* context) { context->unk_19 = 8; context->postScriptActions |= 2; context->condition = 0; - tmp = sub_080045DA(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI); + tmp = CalcOffsetAngle(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI); super->direction = tmp; super->animationState = (super->animationState & 0x80) | gUnk_08111C74[(tmp << 0x18) >> 0x1c]; gActiveScriptInfo.flags |= 1; @@ -170,7 +170,7 @@ void sub_080699AC(GormanEntity* this, ScriptExecutionContext* context) { context->unk_19 = 8; context->postScriptActions |= 2; context->condition = 0; - tmp = sub_080045DA(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI); + tmp = CalcOffsetAngle(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI); super->direction = tmp; super->animationState = (super->animationState & 0x80) | gUnk_08111C8C[(tmp << 0x18) >> 0x1c]; gActiveScriptInfo.flags |= 1; diff --git a/src/npc/kid.c b/src/npc/kid.c index 0faaac1b..fd51fd2f 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -524,7 +524,7 @@ void sub_080626E0(Entity* this, ScriptExecutionContext* context) { } if (--context->unk_19 == 0) { context->unk_19 = 10; - uVar4 = sub_080045DA(context->x.HALF.HI - this->x.HALF.HI, context->y.HALF.HI - this->y.HALF.HI); + uVar4 = CalcOffsetAngle(context->x.HALF.HI - this->x.HALF.HI, context->y.HALF.HI - this->y.HALF.HI); this->direction = (u8)uVar4; uVar4 = Random(); this->direction = (this->direction + uVar4 % 0xb) - 5; diff --git a/src/npc/npc5.c b/src/npc/npc5.c index b6b17ca6..d266d96c 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -10,86 +10,112 @@ #include "message.h" #include "npc.h" +#define kFollowDistance 32 // distance to follow player +#define kPoiDistance 4 // point of interest distance +#define kGravity Q_8_8(32.0) + +#define kCloseDistance 48 // distance to player to walk slowly +#define kFarDistance 80 // distance to player to walk fast +#define kCloseSpeed 0x120 // speed when close to player +#define kMidSpeed 0x160 // speed when mid distance from player +#define kFarSpeed 0x220 // speed when far from player +#define kNavigateSpeed 0x1e0 // speed when navigating + +#define FLAG_FLINCHING 0x1 +#define FLAG_GOTO_PLAYER 0x2 +#define FLAG_GOTO_JUMPED 0x4 +#define FLAG_NAVIGATE 0x8 + +typedef enum { + ZELDA_STATE_INIT, + ZELDA_STATE_IDLE, + ZELDA_STATE_FOLLOW, + ZELDA_STATE_LOST, + ZELDA_STATE_ANIM_SCRIPTED, + ZELDA_STATE_WALK_PRE_JUMP, + ZELDA_STATE_JUMP, + ZELDA_STATE_LAND, +} ZeldaState; + +#define HEAP ((ZeldaData*)super->myHeap) + typedef struct { /*0x00*/ Entity base; - /*0x68*/ u16* unk_68; - /*0x6c*/ u8 unk_6c; + /*0x68*/ u16* messageData; + /*0x6c*/ u8 baseAnimation; /*0x6d*/ u8 unused1; - /*0x6e*/ u16 unk_6e; + /*0x6e*/ u16 linear_move_dist; /*0x70*/ u8 unused2[4]; - /*0x74*/ u16 unk_74; + /*0x74*/ u16 currentRoom; /*0x76*/ u8 unused3[2]; - /*0x78*/ Entity* unk_78; + /*0x78*/ Entity* interactEntity; } NPC5Entity; typedef struct { - u8 unk_0; // u8 - u8 unk_0b; // u8 - u16 unk_1; // u16 - u16 unk_2; // u16 - u16 unk_3; - u16 unk_4; - u16 unk_5; // u16 - u16 unk_6; // u16 - u16 unk_7; // u16 - u16 unk_8; // u16 -} UnkHeap; + u8 flags; // u8 + u8 followDistance; // u8 + u16 playerX; // u16 + u16 playerY; // u16 + u16 destX; + u16 destY; + u16 playerJumpedX; // u16 + u16 playerJumpedY; // u16 + u16 navX; // u16 + u16 navY; // u16 +} ZeldaData; -void sub_08060E70(NPC5Entity*, u32); +void ZeldaSetAnim(NPC5Entity*, u32); -u32 sub_08061230(NPC5Entity*); -u32 sub_08060F80(Entity*); -void sub_08060EDC(NPC5Entity*); -void sub_08061090(NPC5Entity*, u32, u32); +u32 CheckIsFlinching(NPC5Entity*); +u32 ZeldaAtDestination(Entity*); +void ZeldaUpdateIdleAnim(NPC5Entity*); +void ZeldaCalcWalkSpeed(NPC5Entity*, u32, u32); -bool32 sub_08060FD0(Entity*, u32, u32); -void sub_08061464(NPC5Entity*, u32, u32); -void sub_08061120(NPC5Entity*, u32, u32, u32); -bool32 sub_08061170(NPC5Entity*); +bool32 CheckDirectPathUnblocked(Entity*, u32, u32); +void ZeldaInitNavigate(NPC5Entity*, u32, u32); +void ZeldaCalcWalkAnim(NPC5Entity*, u32, u32, u32); +bool32 ZeldaProcessMovement(NPC5Entity*); -void sub_08061358(NPC5Entity*); -void sub_08060E94(Entity*); -void sub_08060A00(NPC5Entity*); -void sub_08061AA0(NPC5Entity*); -void sub_08061AA8(NPC5Entity*); -void sub_08061B58(NPC5Entity*); -void sub_08060AE0(NPC5Entity*); -void sub_08060B5C(NPC5Entity*); -void sub_08060BA0(NPC5Entity*); -void sub_08060D78(NPC5Entity*); -void sub_08060DD0(NPC5Entity*); -void sub_08060DF4(NPC5Entity*); -void sub_08060DFC(NPC5Entity*); -void sub_08060E34(NPC5Entity*); +void ZeldaDoLostAnim(NPC5Entity*); +void ZeldaUpdateAnim(Entity*); +void ZeldaType0Init(NPC5Entity*); +void ZeldaType1Init(NPC5Entity*); +void ZeldaType2Init(NPC5Entity*); +void ZeldaType3Init(NPC5Entity*); +void ZeldaInitAction(NPC5Entity*); +void ZeldaIdleAction(NPC5Entity*); +void ZeldaFollowAction(NPC5Entity*); +void ZeldaLostAction(NPC5Entity*); +void ZeldaAnimScripted(NPC5Entity*); +void ZeldaWalkPreJump(NPC5Entity*); +void ZeldaJumpAction(NPC5Entity*); +void ZeldaLandAction(NPC5Entity*); void sub_08061ACC(NPC5Entity*); void sub_08061B18(NPC5Entity*); u32 PointInsideRadius(s32, s32, s32); -u32 sub_080611D4(Entity*); +u32 CalcJumpDirection(Entity*); extern u32 sub_08079FD4(Entity*, u32); extern void UpdateCollisionLayer(Entity*); -bool32 sub_08061630(NPC5Entity*, s32, s32, s32); -bool32 sub_08061720(NPC5Entity*, s32, s32, s32); -bool32 sub_080616A8(NPC5Entity*, s32, s32, s32); -bool32 sub_08061798(NPC5Entity*, s32, s32, s32); -bool32 sub_08061888(NPC5Entity*, s32, s32, s32); -bool32 sub_08061978(NPC5Entity*, s32, s32, s32); -bool32 sub_08061810(NPC5Entity*, s32, s32, s32); -bool32 sub_08061900(NPC5Entity*, s32, s32, s32); +bool32 TryNavRightFromAbove(NPC5Entity*, s32, s32, s32); +bool32 TryNavUpFromRight(NPC5Entity*, s32, s32, s32); +bool32 TryNavLeftFromAbove(NPC5Entity*, s32, s32, s32); +bool32 TryNavBelowFromRight(NPC5Entity*, s32, s32, s32); +bool32 TryNavLeftFromBelow(NPC5Entity*, s32, s32, s32); +bool32 TryNavBelowFromLeft(NPC5Entity*, s32, s32, s32); +bool32 TryNavRightFromBelow(NPC5Entity*, s32, s32, s32); +bool32 TryNavUpFromLeft(NPC5Entity*, s32, s32, s32); -bool32 sub_08061A74(u8*, s32, s32, s32); - -bool32 sub_08061A1C(u8*, s32, s32, s32); - -bool32 sub_080619F0(u8*, s32, s32, s32); - -bool32 sub_08061A48(u8*, s32, s32, s32); +bool32 CheckPathRight(u8*, s32, s32, s32); +bool32 CheckPathLeft(u8*, s32, s32, s32); +bool32 CheckPathUp(u8*, s32, s32, s32); +bool32 CheckPathBelow(u8*, s32, s32, s32); void sub_08061AFC(NPC5Entity*); -extern u16* gUnk_0810B660[8]; +extern u16* gZeldaFollowerText[8]; void CreateZeldaFollower(void) { Entity* npc; @@ -106,61 +132,62 @@ void CreateZeldaFollower(void) { // UNUSED zelda follower, probably because it was too resource heavy void NPC5(NPC5Entity* this) { static void (*const gUnk_0810AC1C[])(NPC5Entity*) = { - sub_08060A00, - sub_08061AA0, - sub_08061AA8, - sub_08061B58, + ZeldaType0Init, + ZeldaType1Init, + ZeldaType2Init, + ZeldaType3Init, }; gUnk_0810AC1C[super->type](this); } -void sub_08060A00(NPC5Entity* this) { +void ZeldaType0Init(NPC5Entity* this) { static void (*const Npc5_Actions[])(NPC5Entity*) = { - sub_08060AE0, sub_08060B5C, sub_08060BA0, sub_08060D78, sub_08060DD0, sub_08060DF4, sub_08060DFC, sub_08060E34, + ZeldaInitAction, ZeldaIdleAction, ZeldaFollowAction, ZeldaLostAction, + ZeldaAnimScripted, ZeldaWalkPreJump, ZeldaJumpAction, ZeldaLandAction, }; u32 tmp; - if ((gPlayerState.jump_status & 0x80) != 0) { - if (super->action != 0) { - if (((((UnkHeap*)super->myHeap)->unk_0) & 4) == 0) { - ((UnkHeap*)super->myHeap)->unk_0 |= 4; - ((UnkHeap*)super->myHeap)->unk_5 = (gPlayerEntity.base.x.HALF.HI & 0xfff0) + 8; - ((UnkHeap*)super->myHeap)->unk_6 = (gPlayerEntity.base.y.HALF.HI & 0xfff0) + 8; + if (gPlayerState.jump_status & 0x80) { + if (super->action != ZELDA_STATE_INIT) { + if ((HEAP->flags & FLAG_GOTO_JUMPED) == 0) { + HEAP->flags |= FLAG_GOTO_JUMPED; + HEAP->playerJumpedX = (gPlayerEntity.base.x.HALF.HI & 0xfff0) + 8; + HEAP->playerJumpedY = (gPlayerEntity.base.y.HALF.HI & 0xfff0) + 8; } } } - if ((super->action == 0) || (super->spriteSettings.draw != 0)) { + if ((super->action == ZELDA_STATE_INIT) || (super->spriteSettings.draw != 0)) { Npc5_Actions[super->action](this); } - if (super->action != 0) { - ((UnkHeap*)super->myHeap)->unk_1 = gPlayerEntity.base.x.HALF.HI; - ((UnkHeap*)super->myHeap)->unk_2 = gPlayerEntity.base.y.HALF.HI; + if (super->action != ZELDA_STATE_INIT) { + HEAP->playerX = gPlayerEntity.base.x.HALF.HI; + HEAP->playerY = gPlayerEntity.base.y.HALF.HI; } - if (this->unk_74 != gRoomControls.room) { - this->unk_74 = gRoomControls.room; + if (this->currentRoom != gRoomControls.room) { + this->currentRoom = gRoomControls.room; CopyPosition(&gPlayerEntity.base, super); - super->action = 1; + super->action = ZELDA_STATE_IDLE; super->spriteSettings.draw = 1; - super->speed = 0x120; + super->speed = kCloseSpeed; tmp = gRoomControls.scroll_direction; super->animationState = tmp * 2; InitAnimationForceUpdate(super, tmp << 0x19 >> 0x19); // TODO some conversion between u8 and u32? super->frameDuration = (Random() & 0x7f) + 0x80; - ((UnkHeap*)super->myHeap)->unk_0 &= 0xfb; + HEAP->flags &= ~FLAG_GOTO_JUMPED; } } -void sub_08060AE0(NPC5Entity* this) { - UnkHeap* heapObj; +void ZeldaInitAction(NPC5Entity* this) { + ZeldaData* heapObj; Entity* otherNpc; - heapObj = (UnkHeap*)zMalloc(0x14); // TODO UnkHeap struct should have size 0x14? + heapObj = (ZeldaData*)zMalloc(sizeof(ZeldaData)); if (heapObj != NULL) { super->myHeap = (u32*)heapObj; - heapObj->unk_0b = 0x20; - super->action = 1; + heapObj->followDistance = kFollowDistance; + super->action = ZELDA_STATE_IDLE; COLLISION_ON(super); super->animationState &= 3; super->collisionFlags = 7; @@ -168,167 +195,172 @@ void sub_08060AE0(NPC5Entity* this) { super->hitType = 0x49; super->collisionMask = 3; super->hitbox = (Hitbox*)&gHitbox_0; - super->followerFlag &= 0xfe; - this->unk_6c = 0xff; - sub_08060E70(this, super->animationState); + super->followerFlag &= ~1; + this->baseAnimation = 0xff; + ZeldaSetAnim(this, super->animationState); otherNpc = CreateNPC(NPC_UNK_5, 2, 0); if (otherNpc != NULL) { otherNpc->parent = super; - this->unk_78 = otherNpc; + this->interactEntity = otherNpc; } } } -void sub_08060B5C(NPC5Entity* this) { - if (sub_08061230(this) == 0) { - if ((sub_08060F80(super) == 0) && - (((GetFacingDirection(super, &gPlayerEntity.base) + (super->animationState * -4) + 4) & 0x1f)) < 9) { - super->action = 2; - super->subtimer = 0; - return; - } - sub_08060EDC(this); +void ZeldaIdleAction(NPC5Entity* this) { + if (CheckIsFlinching(this)) { + return; } + + if (!ZeldaAtDestination(super) && + DirectionNormalize(GetFacingDirection(super, &gPlayerEntity.base) + (super->animationState * -4) + 4) < 9) { + super->action = ZELDA_STATE_FOLLOW; + super->subtimer = 0; + return; + } + ZeldaUpdateIdleAnim(this); } -void sub_08060BA0(NPC5Entity* this) { +void ZeldaFollowAction(NPC5Entity* this) { Entity* r5; //! @bug: r5 is uninitialized - if (sub_08061230(this) != 0) { + if (CheckIsFlinching(this)) { return; } - if ((((UnkHeap*)super->myHeap)->unk_0 & 4) != 0) { - if ((((UnkHeap*)super->myHeap)->unk_0 & 8) != 0) { - super->speed = 0x1e0; - sub_08061120(this, ((UnkHeap*)super->myHeap)->unk_7, ((UnkHeap*)super->myHeap)->unk_8, 0xc); - sub_08061170(this); - if (EntityWithinDistance(super, ((UnkHeap*)super->myHeap)->unk_7, ((UnkHeap*)super->myHeap)->unk_8, 4) != - 0) { - ((UnkHeap*)super->myHeap)->unk_0 &= 0xf7; - } - } else { - if (sub_08060FD0(super, ((UnkHeap*)super->myHeap)->unk_5, ((UnkHeap*)super->myHeap)->unk_6) != 0) { - if (EntityWithinDistance(super, ((UnkHeap*)super->myHeap)->unk_5, ((UnkHeap*)super->myHeap)->unk_6, - 4) != 0) { - ((UnkHeap*)super->myHeap)->unk_0 &= 0xfb; - super->action = 5; - super->direction = r5->direction; - super->speed = 0x160; - sub_08060E70(this, 8); - } else { - super->speed = 0x1e0; - sub_08061120(this, r5->x.HALF.HI, r5->y.HALF.HI, 0xc); - sub_08061170(this); - } - } else { - sub_08061464(this, r5->x.HALF.HI, r5->y.HALF.HI); - } - } - } else { - if (sub_08060FD0(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI) != 0) { - sub_08061090(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); - sub_08061170(this); - ((UnkHeap*)super->myHeap)->unk_0 &= 0xf5; - } else { - ((UnkHeap*)super->myHeap) = (UnkHeap*)super->myHeap; - if ((((UnkHeap*)super->myHeap)->unk_0 & 8) != 0) { - super->speed = 0x1e0; - sub_08061120(this, ((UnkHeap*)super->myHeap)->unk_7, ((UnkHeap*)super->myHeap)->unk_8, 0xc); - sub_08061170(this); - if (EntityWithinDistance(super, ((UnkHeap*)super->myHeap)->unk_7, ((UnkHeap*)super->myHeap)->unk_8, - 4) != 0) { - ((UnkHeap*)super->myHeap)->unk_0 &= 0xf7; - } - } else { - if ((((UnkHeap*)super->myHeap)->unk_0 & 2) == 0) { - ((UnkHeap*)super->myHeap)->unk_0 |= 2; - ((UnkHeap*)super->myHeap)->unk_3 = ((UnkHeap*)super->myHeap)->unk_1; - ((UnkHeap*)super->myHeap)->unk_4 = ((UnkHeap*)super->myHeap)->unk_2; - } - if (sub_08060FD0(super, ((UnkHeap*)super->myHeap)->unk_3, ((UnkHeap*)super->myHeap)->unk_4) != 0) { - super->speed = 0x1e0; - sub_08061120(this, ((UnkHeap*)super->myHeap)->unk_3, ((UnkHeap*)super->myHeap)->unk_4, 0xc); - sub_08061170(this); - if (EntityWithinDistance(super, ((UnkHeap*)super->myHeap)->unk_3, ((UnkHeap*)super->myHeap)->unk_4, - 4) != 0) { - ((UnkHeap*)super->myHeap)->unk_0 &= 0xfd; - } - } else { - ((UnkHeap*)super->myHeap)->unk_0 &= 0xfd; - sub_08061464(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); - } + if (HEAP->flags & FLAG_GOTO_JUMPED) { + // goto position where player jumped + if (HEAP->flags & FLAG_NAVIGATE) { + // navigate to jump position + super->speed = kNavigateSpeed; + ZeldaCalcWalkAnim(this, HEAP->navX, HEAP->navY, 0xc); + ZeldaProcessMovement(this); + if (EntityWithinDistance(super, HEAP->navX, HEAP->navY, kPoiDistance)) { + // reached navigation position + HEAP->flags &= ~FLAG_NAVIGATE; } + } else if (CheckDirectPathUnblocked(super, HEAP->playerJumpedX, HEAP->playerJumpedY)) { + // At jump location, begin jumping + if (EntityWithinDistance(super, HEAP->playerJumpedX, HEAP->playerJumpedY, kPoiDistance)) { + HEAP->flags &= ~FLAG_GOTO_JUMPED; + super->action = ZELDA_STATE_WALK_PRE_JUMP; + super->direction = r5->direction; + super->speed = kMidSpeed; + ZeldaSetAnim(this, 8); + } else { + // walk to jump location + super->speed = kNavigateSpeed; + ZeldaCalcWalkAnim(this, r5->x.HALF.HI, r5->y.HALF.HI, 0xc); + ZeldaProcessMovement(this); + } + } else { + // navigate to jump location (bugged) + ZeldaInitNavigate(this, r5->x.HALF.HI, r5->y.HALF.HI); + } + } else if (CheckDirectPathUnblocked(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI)) { + // walk directly to player + ZeldaCalcWalkSpeed(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); + ZeldaProcessMovement(this); + HEAP->flags &= ~(FLAG_NAVIGATE | FLAG_GOTO_PLAYER); + } else if (HEAP->flags & FLAG_NAVIGATE) { + // navigating to a position + super->speed = kNavigateSpeed; + ZeldaCalcWalkAnim(this, HEAP->navX, HEAP->navY, 0xc); + ZeldaProcessMovement(this); + if (EntityWithinDistance(super, HEAP->navX, HEAP->navY, kPoiDistance)) { + // reached navigation position + HEAP->flags &= ~FLAG_NAVIGATE; + } + } else { // player not found and no position set to navigate to + if ((HEAP->flags & FLAG_GOTO_PLAYER) == 0) { + // get player position + HEAP->flags |= FLAG_GOTO_PLAYER; + HEAP->destX = HEAP->playerX; + HEAP->destY = HEAP->playerY; + } + if (CheckDirectPathUnblocked(super, HEAP->destX, HEAP->destY)) { + // can walk directly to player + super->speed = kNavigateSpeed; + ZeldaCalcWalkAnim(this, HEAP->destX, HEAP->destY, 0xc); + ZeldaProcessMovement(this); + if (EntityWithinDistance(super, HEAP->destX, HEAP->destY, kPoiDistance)) { + // reached player position + HEAP->flags &= ~FLAG_GOTO_PLAYER; + } + } else { // try to navigate to player + HEAP->flags &= ~FLAG_GOTO_PLAYER; + ZeldaInitNavigate(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); } } - if (sub_08060F80(super) != 0) { - super->action = 1; - ((UnkHeap*)super->myHeap)->unk_0 &= 0xfb; - sub_08060E70(this, 0); + + if (ZeldaAtDestination(super)) { + super->action = ZELDA_STATE_IDLE; + HEAP->flags &= ~FLAG_GOTO_JUMPED; + ZeldaSetAnim(this, 0); } } -void sub_08060D78(NPC5Entity* this) { - sub_08061358(this); - if (sub_08060F80(super) != 0) { - if ((u32)super->animIndex - 0x20 < 0x10) { - if ((super->frame & 7) != 0) { - super->frameDuration = 1; - UpdateAnimationSingleFrame(super); - } - super->animationState = super->frame & 0x18; - this->unk_6c = 0xff; - } - super->action = 1; - sub_08060E70(this, 0); +void ZeldaLostAction(NPC5Entity* this) { + ZeldaDoLostAnim(this); + + // wait to be found + if (!ZeldaAtDestination(super)) { + return; } + + if ((u32)super->animIndex - 0x20 < 0x10) { + if ((super->frame & 7) != 0) { + super->frameDuration = 1; + UpdateAnimationSingleFrame(super); + } + super->animationState = super->frame & 0x18; + this->baseAnimation = 0xff; + } + super->action = ZELDA_STATE_IDLE; + ZeldaSetAnim(this, 0); } -void sub_08060DD0(NPC5Entity* this) { +void ZeldaAnimScripted(NPC5Entity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & ANIM_DONE) != 0) { - super->action = 1; - sub_08060E70(this, 0); + if (super->frame & ANIM_DONE) { + super->action = ZELDA_STATE_IDLE; + ZeldaSetAnim(this, 0); } } -void sub_08060DF4(NPC5Entity* this) { - sub_08061170(this); +void ZeldaWalkPreJump(NPC5Entity* this) { + ZeldaProcessMovement(this); } -void sub_08060DFC(NPC5Entity* this) { - u32 uVar1; - +void ZeldaJumpAction(NPC5Entity* this) { LinearMoveUpdate(super); - sub_08060E94(super); - uVar1 = GravityUpdate(super, Q_8_8(32.0)); - if (uVar1 == 0) { - super->action = 7; + ZeldaUpdateAnim(super); + if (GravityUpdate(super, kGravity) == 0) { + super->action = ZELDA_STATE_LAND; super->collisionLayer = 1; UpdateSpriteForCollisionLayer(super); - sub_08060E70(this, 0x1c); + ZeldaSetAnim(this, 0x1c); } } -void sub_08060E34(NPC5Entity* this) { +void ZeldaLandAction(NPC5Entity* this) { UpdateAnimationSingleFrame(super); - if ((super->frame & ANIM_DONE) != 0) { - super->action = 2; + if (super->frame & ANIM_DONE) { + super->action = ZELDA_STATE_FOLLOW; super->animationState = DirectionToAnimationState(GetFacingDirection(super, &gPlayerEntity.base)) * 2; - sub_08060E70(this, 8); + ZeldaSetAnim(this, 8); } } -void sub_08060E70(NPC5Entity* this, u32 param) { +void ZeldaSetAnim(NPC5Entity* this, u32 param) { u32 tmp = param + super->animationState / 2; if (tmp != super->animIndex) { - this->unk_6c = param; + this->baseAnimation = param; InitAnimationForceUpdate(super, tmp); } } -void sub_08060E94(Entity* this) { +void ZeldaUpdateAnim(Entity* this) { if (((*(u32*)&this->animIndex & 0x80ff00) == 0x800100) && (this->animIndex < 4)) { InitAnimationForceUpdate(this, (this->animationState >> 1)); this->frameDuration = (Random() & 0x7f) + 0x80; @@ -337,80 +369,88 @@ void sub_08060E94(Entity* this) { } } -void sub_08060EDC(NPC5Entity* this) { +void ZeldaUpdateIdleAnim(NPC5Entity* this) { s32 tmp; if (((u32)super->animIndex - 0x20 < 0x10) && ((super->frame & ANIM_DONE) == 0)) { UpdateAnimationSingleFrame(super); - } else { - tmp = GetFacingDirection(super, &gPlayerEntity.base) + super->animationState * -4; - if (((tmp + 3) & 0x1f) >= 7) { - if ((tmp & 0x1f) < 0x10) { - InitAnimationForceUpdate(super, super->animationState + 0x20); - super->animationState = (super->animationState + 1) & 7; - } else { - InitAnimationForceUpdate(super, super->animationState + 0x28); - super->animationState = (super->animationState - 1) & 7; - } + return; + } + + tmp = GetFacingDirection(super, &gPlayerEntity.base) + super->animationState * -4; + if (((tmp + 3) & 0x1f) > 6) { + if ((tmp & 0x1f) < 0x10) { + InitAnimationForceUpdate(super, super->animationState + 0x20); + super->animationState = (super->animationState + 1) & 7; } else { - if ((super->animationState & 1) == 0) { - if (((super->frame & ANIM_DONE) != 0) && (0xf >= (u32)super->animIndex - 0x20)) { - sub_08060E70(this, 0); - } else { - sub_08060E94(super); - } - } + InitAnimationForceUpdate(super, super->animationState + 0x28); + super->animationState = (super->animationState - 1) & 7; + } + return; + } + + if ((super->animationState & 1) == 0) { + if ((super->frame & ANIM_DONE) && (0xf >= (u32)super->animIndex - 0x20)) { + ZeldaSetAnim(this, 0); + } else { + ZeldaUpdateAnim(super); } } } -u32 sub_08060F80(Entity* this) { - if (sub_08060FD0(this, (s32)gPlayerEntity.base.x.HALF.HI, (s32)gPlayerEntity.base.y.HALF.HI) == 0) { + +u32 ZeldaAtDestination(Entity* this) { + if (CheckDirectPathUnblocked(this, (s32)gPlayerEntity.base.x.HALF.HI, (s32)gPlayerEntity.base.y.HALF.HI) == 0) { return 0; } - ((UnkHeap*)this->myHeap)->unk_0 &= 0xfb; + ((ZeldaData*)this->myHeap)->flags &= ~FLAG_GOTO_JUMPED; if (PointInsideRadius(gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI, - gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI, ((UnkHeap*)this->myHeap)->unk_0b) != 0) { + gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI, ((ZeldaData*)this->myHeap)->followDistance)) { return 1; } return 0; } -bool32 sub_08060FD0(Entity* this, u32 a, u32 b) { - s32 sVar1; - s32 sVar2; - int iVar3; +bool32 CheckDirectPathUnblocked(Entity* this, u32 target_x, u32 target_y) { + s32 dx; + s32 dy; + int angle; int x; int y; - u8* puVar8; + u8* layer; + + const int col_check_length = 6; x = this->x.HALF.HI; y = this->y.HALF.HI; - iVar3 = sub_080045DA(a - x, b - y); + angle = CalcOffsetAngle(target_x - x, target_y - y); x <<= 8; y <<= 8; - sVar1 = gSineTable[iVar3] * 6; - sVar2 = gSineTable[(iVar3 + 0x40)] * 6; + + // get vector to target + dx = gSineTable[angle] * col_check_length; + dy = gSineTable[(angle + 0x40)] * col_check_length; if (this->collisionLayer != 2) { - puVar8 = gMapBottom.collisionData; + layer = gMapBottom.collisionData; } else { - puVar8 = gMapTop.collisionData; + layer = gMapTop.collisionData; } while (1) { - if (IsTileCollision(puVar8, x / 0x100, y / 0x100, 6)) { + if (IsTileCollision(layer, x / 0x100, y / 0x100, col_check_length)) { return 0; } - if (((a - (x / 0x100)) + 6 >= 0xd) || ((b - (y / 0x100)) + 6 >= 0xd)) { - x += sVar1; - y -= sVar2; + if (((target_x - (x / 0x100)) + col_check_length > col_check_length * 2) || + ((target_y - (y / 0x100)) + col_check_length > col_check_length * 2)) { + x += dx; + y -= dy; continue; } return 1; } } -void sub_08061090(NPC5Entity* this, u32 a, u32 b) { +void ZeldaCalcWalkSpeed(NPC5Entity* this, u32 a, u32 b) { s32 xDist; s32 yDist; s32 sqrDist; @@ -419,42 +459,42 @@ void sub_08061090(NPC5Entity* this, u32 a, u32 b) { xDist = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI; yDist = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI; sqrDist = (xDist * xDist) + (yDist * yDist); - if (sqrDist < 0x900) { - super->speed = 0x120; + if (sqrDist < kCloseDistance * kCloseDistance) { + super->speed = kCloseSpeed; } else { - if (sqrDist < 0x1900) { - super->speed = ((sqrDist - 0x900) >> 4) + 0x120; + if (sqrDist < kFarDistance * kFarDistance) { + super->speed = ((sqrDist - (kCloseDistance * kCloseDistance)) >> 4) + kCloseSpeed; } else { - super->speed = 0x220; + super->speed = kFarSpeed; } } - if (super->speed == 0x120) { + if (super->speed == kCloseSpeed) { tmp = 4; - } else if (super->speed < 0x160) { + } else if (super->speed < kMidSpeed) { tmp = 8; } else { tmp = 0xc; } - sub_08061120(this, a, b, tmp); + ZeldaCalcWalkAnim(this, a, b, tmp); } -void sub_08061120(NPC5Entity* this, u32 param_a, u32 param_b, u32 param_c) { - super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, param_a, param_b); - if ((param_c != this->unk_6c) || (10 < ((super->direction + super->animationState * -4 + 5) & 0x1f))) { - super->animationState = DirectionRoundUp(super->direction) >> 2; - sub_08060E70(this, param_c); +void ZeldaCalcWalkAnim(NPC5Entity* this, u32 target_x, u32 target_y, u32 anim) { + super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, target_x, target_y); + if ((anim != this->baseAnimation) || (10 < ((super->direction + super->animationState * -4 + 5) & 0x1f))) { + super->animationState = Direction8ToAnimationState(DirectionRoundUp(super->direction)); + ZeldaSetAnim(this, anim); } } -bool32 sub_08061170(NPC5Entity* this) { +bool32 ZeldaProcessMovement(NPC5Entity* this) { u32 direction; u32 tmp; UpdateAnimationSingleFrame(super); if (ProcessMovement6(super) == 0) { - direction = sub_080611D4(super); + direction = CalcJumpDirection(super); if (direction != 0xff) { - super->action = 6; + super->action = ZELDA_STATE_JUMP; tmp = (sub_08079FD4(super, 1)); tmp <<= 4; tmp -= 4; @@ -464,9 +504,9 @@ bool32 sub_08061170(NPC5Entity* this) { super->direction = direction; super->animationState = direction >> 2; if (tmp >> 0x10 != 0) { - sub_08060E70(this, 0x14); + ZeldaSetAnim(this, 0x14); } else { - sub_08060E70(this, 0x18); + ZeldaSetAnim(this, 0x18); } } return FALSE; @@ -476,36 +516,37 @@ bool32 sub_08061170(NPC5Entity* this) { } } -u32 sub_080611D4(Entity* this) { +// TODO: this relies on tiles 0x2a - 0x2d, do these exist in the game? +u32 CalcJumpDirection(Entity* this) { static const struct { s8 unk_0; s8 unk_1; - } PACKED gUnk_0810AC4C[] = { + } PACKED sOffsets[] = { { 0, -8 }, { 8, 0 }, { 0, 3 }, { -8, 0 }, }; - static const u8 gUnk_0810AC54[] = { - 0x2b, 0x10, 0x2a, 0x0, 0x2d, 0x8, 0x2c, 0x18, 0x0, + static const u8 sTable[] = { + 0x2b, DirectionSouth, 0x2a, DirectionNorth, 0x2d, DirectionEast, 0x2c, DirectionWest, 0x0, }; - u32 uVar2; + u32 tile; u32 x; - s32 a; - s32 b; + s32 x_offset; + s32 y_offset; s8* ptr; const u8* ptr2; - x = this->animationState & 6; - ptr = (s8*)gUnk_0810AC4C; - a = ptr[x]; - b = ptr[x + 1]; - uVar2 = GetActTileRelative(this, a, b); - ptr2 = gUnk_0810AC54; + x = AnimationStateIdle(this->animationState); + ptr = (s8*)sOffsets; + x_offset = ptr[x]; + y_offset = ptr[x + 1]; + tile = GetActTileRelative(this, x_offset, y_offset); + ptr2 = sTable; do { - if (*ptr2 != uVar2 || this->animationState != (ptr2[1] >> 2)) { + if (*ptr2 != tile || this->animationState != (ptr2[1] >> 2)) { continue; } @@ -523,9 +564,9 @@ u32 sub_080611D4(Entity* this) { return 0xff; } -u32 sub_08061230(NPC5Entity* this) { - if ((((UnkHeap*)super->myHeap)->unk_0 & 1) == 0) { - if ((super->contactFlags & CONTACT_NOW) != 0) { +u32 CheckIsFlinching(NPC5Entity* this) { + if ((HEAP->flags & FLAG_FLINCHING) == 0) { + if (super->contactFlags & CONTACT_NOW) { switch (super->contactFlags & 0x7f) { case 0: case 1: @@ -538,7 +579,7 @@ u32 sub_08061230(NPC5Entity* this) { case 0x1f: break; default: - ((UnkHeap*)super->myHeap)->unk_0 = ((UnkHeap*)super->myHeap)->unk_0 | 1; + HEAP->flags |= FLAG_FLINCHING; InitAnimationForceUpdate(super, (super->animationState >> 1) + 0x40); return 1; } @@ -548,17 +589,17 @@ u32 sub_08061230(NPC5Entity* this) { if ((super->frame & ANIM_DONE) == 0) { return 1; } - ((UnkHeap*)super->myHeap)->unk_0 &= 0xfe; - InitAnimationForceUpdate(super, this->unk_6c + (super->animationState >> 1)); + HEAP->flags &= ~FLAG_FLINCHING; + InitAnimationForceUpdate(super, this->baseAnimation + (super->animationState >> 1)); } - super->contactFlags = super->contactFlags & 0x7f; + super->contactFlags &= 0x7f; if (super->iframes != 0) { super->iframes++; } return 0; } -void sub_08061358(NPC5Entity* this) { +void ZeldaDoLostAnim(NPC5Entity* this) { static const u8 gUnk_0810AC5D[] = { 0x30, 0x31, 0x38, 0x39, 0x32, 0x33, 0x3a, 0x3b, 0x34, 0x35, 0x3c, 0x3d, 0x36, 0x37, 0x3e, 0x3f, 0x0, 0x0, 0x0, }; @@ -573,7 +614,7 @@ void sub_08061358(NPC5Entity* this) { } super->subAction = 1; super->timer = 15; - sub_08060E70(this, 0); + ZeldaSetAnim(this, 0); break; case 1: super->timer--; @@ -585,7 +626,7 @@ void sub_08061358(NPC5Entity* this) { if ((uVar2 & 1) == 0) { super->subAction = 3; super->timer = (bVar4 & 0x18) + 30; - sub_08060E70(this, 4); + ZeldaSetAnim(this, 4); return; } super->subAction = 2; @@ -600,14 +641,14 @@ void sub_08061358(NPC5Entity* this) { if ((Random() & 1)) { super->subAction = 3; super->timer = (bVar4 & 0x18) + 30; - sub_08060E70(this, 4); + ZeldaSetAnim(this, 4); return; } super->subAction = 0; - sub_08060E70(this, 0x10); + ZeldaSetAnim(this, 0x10); break; case 3: - if (sub_08061170(this) == 0) { + if (ZeldaProcessMovement(this) == 0) { super->subAction = 2; //! @bug bVar4 (r6) is uninitialized. @@ -618,96 +659,95 @@ void sub_08061358(NPC5Entity* this) { return; } super->subAction = 0; - sub_08060E70(this, 0x10); + ZeldaSetAnim(this, 0x10); break; } } -void sub_08061464(NPC5Entity* this, u32 param_a, u32 param_b) { - s32 iVar10; - s32 iVar9; - u32 bVar1; +void ZeldaInitNavigate(NPC5Entity* this, u32 tgt_x, u32 tgt_y) { + s32 x; + s32 y; - iVar10 = super->x.HALF.HI; - iVar9 = super->y.HALF.HI; + x = super->x.HALF.HI; + y = super->y.HALF.HI; - switch (((CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, param_a, param_b) + 2) & 0x1c) >> 2) { + switch (((CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, tgt_x, tgt_y) + 2) & 0x1c) >> 2) { case 0: - this->unk_6e = param_b; - if (super->x.HALF.HI > (s32)param_a) { - sub_08061630(this, iVar10, iVar9 + -8, param_a); + this->linear_move_dist = tgt_y; + if (super->x.HALF.HI > (s32)tgt_x) { + TryNavRightFromAbove(this, x, y + -8, tgt_x); break; } - sub_080616A8(this, iVar10, iVar9 + -8, param_a); + TryNavLeftFromAbove(this, x, y + -8, tgt_x); break; case 1: - this->unk_6e = param_a; - if (sub_08061720(this, iVar10 + 8, iVar9, param_b) != 0) + this->linear_move_dist = tgt_x; + if (TryNavUpFromRight(this, x + 8, y, tgt_y) != 0) break; - this->unk_6e = param_b; - sub_080616A8(this, iVar10, iVar9 + -8, param_a); + this->linear_move_dist = tgt_y; + TryNavLeftFromAbove(this, x, y + -8, tgt_x); break; case 2: - this->unk_6e = param_a; - if (super->y.HALF.HI > (s32)param_b) { - sub_08061720(this, iVar10 + 8, iVar9, param_b); + this->linear_move_dist = tgt_x; + if (super->y.HALF.HI > (s32)tgt_y) { + TryNavUpFromRight(this, x + 8, y, tgt_y); } else { - sub_08061798(this, iVar10 + 8, iVar9, param_b); + TryNavBelowFromRight(this, x + 8, y, tgt_y); } break; case 3: - this->unk_6e = param_a; - if (sub_08061798(this, iVar10 + 8, iVar9, param_b) != 0) + this->linear_move_dist = tgt_x; + if (TryNavBelowFromRight(this, x + 8, y, tgt_y) != 0) break; - this->unk_6e = param_b; - sub_08061888(this, iVar10, iVar9 + 8, param_a); + this->linear_move_dist = tgt_y; + TryNavLeftFromBelow(this, x, y + 8, tgt_x); break; case 4: - this->unk_6e = param_b; - if (super->x.HALF.HI > (s32)param_a) { - sub_08061810(this, iVar10, iVar9 + 8, param_a); + this->linear_move_dist = tgt_y; + if (super->x.HALF.HI > (s32)tgt_x) { + TryNavRightFromBelow(this, x, y + 8, tgt_x); break; } - sub_08061888(this, iVar10, iVar9 + 8, param_a); + TryNavLeftFromBelow(this, x, y + 8, tgt_x); break; case 5: - this->unk_6e = param_a; - if (sub_08061978(this, iVar10 + -8, iVar9, param_b) != 0) + this->linear_move_dist = tgt_x; + if (TryNavBelowFromLeft(this, x + -8, y, tgt_y) != 0) break; - this->unk_6e = param_b; - sub_08061810(this, iVar10, iVar9 + 8, param_a); + this->linear_move_dist = tgt_y; + TryNavRightFromBelow(this, x, y + 8, tgt_x); break; case 6: - this->unk_6e = param_a; - if (super->y.HALF.HI > (s32)param_b) { - sub_08061900(this, iVar10 + -8, iVar9, param_b); + this->linear_move_dist = tgt_x; + if (super->y.HALF.HI > (s32)tgt_y) { + TryNavUpFromLeft(this, x + -8, y, tgt_y); } else { - sub_08061978(this, iVar10 + -8, iVar9, param_b); + TryNavBelowFromLeft(this, x + -8, y, tgt_y); } break; case 7: - this->unk_6e = param_a; - if (sub_08061900(this, iVar10 + -8, iVar9, param_b) == 0) { - this->unk_6e = param_b; - sub_08061630(this, iVar10, iVar9 + -8, param_a); + this->linear_move_dist = tgt_x; + if (TryNavUpFromLeft(this, x + -8, y, tgt_y) == 0) { + this->linear_move_dist = tgt_y; + TryNavRightFromAbove(this, x, y + -8, tgt_x); } } - bVar1 = ((UnkHeap*)super->myHeap)->unk_0 & 8; - if (bVar1 == 0) { - super->action = 3; - super->subAction = bVar1; + + if ((HEAP->flags & FLAG_NAVIGATE) == 0) { + super->action = ZELDA_STATE_LOST; + super->subAction = 0; } } -bool32 sub_08061630(NPC5Entity* this, s32 x, s32 y, s32 param) { +bool32 TryNavRightFromAbove(NPC5Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; u8* layer = (super->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { - if (sub_08061A74(layer, x, y, param)) { - ((UnkHeap*)super->myHeap)->unk_7 = x; - ((UnkHeap*)super->myHeap)->unk_8 = param_y; - ((UnkHeap*)super->myHeap)->unk_0 |= 8; - if (this->unk_6e >= y) { + if (CheckPathRight(layer, x, y, param)) { + HEAP->navX = x; + HEAP->navY = param_y; + HEAP->flags |= FLAG_NAVIGATE; + if (this->linear_move_dist >= y) { return TRUE; } } @@ -716,15 +756,15 @@ bool32 sub_08061630(NPC5Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_080616A8(NPC5Entity* this, s32 x, s32 y, s32 param) { +bool32 TryNavLeftFromAbove(NPC5Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; u8* layer = (super->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { - if (sub_08061A1C(layer, x, y, param)) { - ((UnkHeap*)super->myHeap)->unk_7 = x; - ((UnkHeap*)super->myHeap)->unk_8 = param_y; - ((UnkHeap*)super->myHeap)->unk_0 |= 8; - if (this->unk_6e >= y) { + if (CheckPathLeft(layer, x, y, param)) { + HEAP->navX = x; + HEAP->navY = param_y; + HEAP->flags |= FLAG_NAVIGATE; + if (this->linear_move_dist >= y) { return TRUE; } } @@ -733,15 +773,15 @@ bool32 sub_080616A8(NPC5Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_08061720(NPC5Entity* this, s32 x, s32 y, s32 param) { +bool32 TryNavUpFromRight(NPC5Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; u8* layer = (super->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { - if (sub_080619F0(layer, x, y, param)) { - ((UnkHeap*)super->myHeap)->unk_7 = param_x; - ((UnkHeap*)super->myHeap)->unk_8 = y; - ((UnkHeap*)super->myHeap)->unk_0 |= 8; - if (this->unk_6e <= x) { + if (CheckPathUp(layer, x, y, param)) { + HEAP->navX = param_x; + HEAP->navY = y; + HEAP->flags |= FLAG_NAVIGATE; + if (this->linear_move_dist <= x) { return TRUE; } } @@ -750,15 +790,15 @@ bool32 sub_08061720(NPC5Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_08061798(NPC5Entity* this, s32 x, s32 y, s32 param) { +bool32 TryNavBelowFromRight(NPC5Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; u8* layer = (super->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { - if (sub_08061A48(layer, x, y, param)) { - ((UnkHeap*)super->myHeap)->unk_7 = param_x; - ((UnkHeap*)super->myHeap)->unk_8 = y; - ((UnkHeap*)super->myHeap)->unk_0 |= 8; - if (this->unk_6e <= x) { + if (CheckPathBelow(layer, x, y, param)) { + HEAP->navX = param_x; + HEAP->navY = y; + HEAP->flags |= FLAG_NAVIGATE; + if (this->linear_move_dist <= x) { return TRUE; } } @@ -767,15 +807,15 @@ bool32 sub_08061798(NPC5Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_08061810(NPC5Entity* this, s32 x, s32 y, s32 param) { +bool32 TryNavRightFromBelow(NPC5Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; u8* layer = (super->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { - if (sub_08061A74(layer, x, y, param)) { - ((UnkHeap*)super->myHeap)->unk_7 = x; - ((UnkHeap*)super->myHeap)->unk_8 = param_y; - ((UnkHeap*)super->myHeap)->unk_0 |= 8; - if (this->unk_6e <= y) { + if (CheckPathRight(layer, x, y, param)) { + HEAP->navX = x; + HEAP->navY = param_y; + HEAP->flags |= FLAG_NAVIGATE; + if (this->linear_move_dist <= y) { return TRUE; } } @@ -784,15 +824,15 @@ bool32 sub_08061810(NPC5Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_08061888(NPC5Entity* this, s32 x, s32 y, s32 param) { +bool32 TryNavLeftFromBelow(NPC5Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; u8* layer = (super->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { - if (sub_08061A1C(layer, x, y, param)) { - ((UnkHeap*)super->myHeap)->unk_7 = x; - ((UnkHeap*)super->myHeap)->unk_8 = param_y; - ((UnkHeap*)super->myHeap)->unk_0 |= 8; - if (this->unk_6e <= y) { + if (CheckPathLeft(layer, x, y, param)) { + HEAP->navX = x; + HEAP->navY = param_y; + HEAP->flags |= FLAG_NAVIGATE; + if (this->linear_move_dist <= y) { return TRUE; } } @@ -801,15 +841,15 @@ bool32 sub_08061888(NPC5Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_08061900(NPC5Entity* this, s32 x, s32 y, s32 param) { +bool32 TryNavUpFromLeft(NPC5Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; u8* layer = (super->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { - if (sub_080619F0(layer, x, y, param)) { - ((UnkHeap*)super->myHeap)->unk_7 = param_x; - ((UnkHeap*)super->myHeap)->unk_8 = y; - ((UnkHeap*)super->myHeap)->unk_0 |= 8; - if (this->unk_6e >= x) { + if (CheckPathUp(layer, x, y, param)) { + HEAP->navX = param_x; + HEAP->navY = y; + HEAP->flags |= FLAG_NAVIGATE; + if (this->linear_move_dist >= x) { return TRUE; } } @@ -818,15 +858,15 @@ bool32 sub_08061900(NPC5Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_08061978(NPC5Entity* this, s32 x, s32 y, s32 param) { +bool32 TryNavBelowFromLeft(NPC5Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; u8* layer = (super->collisionLayer == 2) ? gMapTop.collisionData : gMapBottom.collisionData; while (!IsTileCollision(layer, x, y, 6)) { - if (sub_08061A48(layer, x, y, param)) { - ((UnkHeap*)super->myHeap)->unk_7 = param_x; - ((UnkHeap*)super->myHeap)->unk_8 = y; - ((UnkHeap*)super->myHeap)->unk_0 |= 8; - if (this->unk_6e >= x) { + if (CheckPathBelow(layer, x, y, param)) { + HEAP->navX = param_x; + HEAP->navY = y; + HEAP->flags |= FLAG_NAVIGATE; + if (this->linear_move_dist >= x) { return TRUE; } } @@ -835,7 +875,7 @@ bool32 sub_08061978(NPC5Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_080619F0(u8* layer, s32 x, s32 y, s32 param) { +bool32 CheckPathUp(u8* layer, s32 x, s32 y, s32 param) { while (param <= y) { if (IsTileCollision(layer, x, y, 6) != 0) { return FALSE; @@ -845,7 +885,7 @@ bool32 sub_080619F0(u8* layer, s32 x, s32 y, s32 param) { return TRUE; } -bool32 sub_08061A1C(u8* layer, s32 x, s32 y, s32 param) { +bool32 CheckPathLeft(u8* layer, s32 x, s32 y, s32 param) { while (param >= x) { if (IsTileCollision(layer, x, y, 6) != 0) { return FALSE; @@ -855,7 +895,7 @@ bool32 sub_08061A1C(u8* layer, s32 x, s32 y, s32 param) { return TRUE; } -bool32 sub_08061A48(u8* layer, s32 x, s32 y, s32 param) { +bool32 CheckPathBelow(u8* layer, s32 x, s32 y, s32 param) { while (param >= y) { if (IsTileCollision(layer, x, y, 6) != 0) { return FALSE; @@ -865,7 +905,7 @@ bool32 sub_08061A48(u8* layer, s32 x, s32 y, s32 param) { return TRUE; } -bool32 sub_08061A74(u8* layer, s32 x, s32 y, s32 param) { +bool32 CheckPathRight(u8* layer, s32 x, s32 y, s32 param) { while (param <= x) { if (IsTileCollision(layer, x, y, 6) != 0) { return FALSE; @@ -875,11 +915,11 @@ bool32 sub_08061A74(u8* layer, s32 x, s32 y, s32 param) { return TRUE; } -void sub_08061AA0(NPC5Entity* this) { +void ZeldaType1Init(NPC5Entity* this) { DeleteThisEntity(); } -void sub_08061AA8(NPC5Entity* this) { +void ZeldaType2Init(NPC5Entity* this) { static void (*const gUnk_0810AC70[])(NPC5Entity*) = { sub_08061ACC, sub_08061B18, @@ -889,11 +929,11 @@ void sub_08061AA8(NPC5Entity* this) { } void sub_08061ACC(NPC5Entity* this) { - super->flags = super->flags | ENT_PERSIST; + super->flags |= ENT_PERSIST; super->action = 1; super->subAction = 0xff; super->timer = 0; - super->followerFlag = super->followerFlag & 0xfe; + super->followerFlag = super->followerFlag & ~1; AddInteractableWhenBigObject(super); sub_08061AFC(this); } @@ -902,7 +942,7 @@ void sub_08061AFC(NPC5Entity* this) { u32 tmp = 0; if (super->subAction != 0) { super->subAction = tmp; - this->unk_68 = gUnk_0810B660[0]; + this->messageData = gZeldaFollowerText[0]; super->timer = 0; } } @@ -916,7 +956,7 @@ void sub_08061B18(NPC5Entity* this) { case INTERACTION_TALK: super->interactType = INTERACTION_NONE; sub_08061AFC(this); - puVar2 = this->unk_68; + puVar2 = this->messageData; puVar2 += (super->timer++); if (puVar2[1] == 0) { super->timer = 0; @@ -926,7 +966,7 @@ void sub_08061B18(NPC5Entity* this) { } } -void sub_08061B58(NPC5Entity* this) { +void ZeldaType3Init(NPC5Entity* this) { if (super->action == 0) { super->action = 1; InitAnimationForceUpdate(super, 2); diff --git a/src/object/cutsceneMiscObject.c b/src/object/cutsceneMiscObject.c index c2320d91..fa787b35 100644 --- a/src/object/cutsceneMiscObject.c +++ b/src/object/cutsceneMiscObject.c @@ -710,7 +710,7 @@ void sub_0809567C(CutsceneMiscObjectEntity* this) { super->action = 3; super->subAction = 1; super->speed = 0x400; - super->direction = sub_080045DA(super->x.WORD - ((s16)this->px << 16), super->y.WORD - ((s16)this->py << 16)); + super->direction = CalcOffsetAngle(super->x.WORD - ((s16)this->px << 16), super->y.WORD - ((s16)this->py << 16)); } void CutsceneMiscObject_Type15(CutsceneMiscObjectEntity* this) { diff --git a/src/object/evilSpirit.c b/src/object/evilSpirit.c index 43dc00ab..a2943a52 100644 --- a/src/object/evilSpirit.c +++ b/src/object/evilSpirit.c @@ -83,10 +83,10 @@ void EvilSpirit_Action1(EvilSpiritEntity* this) { this->unk7a = this->unk7c; super->speed = 0x300; super->direction = - sub_080045DA(super->parent->x.WORD - super->x.WORD, super->parent->y.WORD - super->y.WORD) ^ 0x80; + CalcOffsetAngle(super->parent->x.WORD - super->x.WORD, super->parent->y.WORD - super->y.WORD) ^ 0x80; } else { super->speed = 0x600; - dir = sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^ + dir = CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^ 0x80; if (dir != super->direction) { if ((u8)(dir - super->direction) > 0x80) { @@ -178,7 +178,7 @@ void EvilSpirit_Action3(EvilSpiritEntity* this) { short iVar4; int iVar6; - super->direction = sub_080045DA(this->x - super->x.WORD, this->y - super->y.WORD); + super->direction = CalcOffsetAngle(this->x - super->x.WORD, this->y - super->y.WORD); if ((super->contactFlags & 0x7f) == 0x13) { super->speed = 0x100; super->gustJarTolerance--; diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c index b474fdd6..19842f23 100644 --- a/src/object/fileScreenObjects.c +++ b/src/object/fileScreenObjects.c @@ -20,7 +20,7 @@ typedef struct { /*0x70*/ u8 unk_70; } FileScreenObjectsEntity; -extern u32 sub_080041EC(s32, s32); +extern u32 CalcDistance(s32, s32); static bool32 sub_0808E950(void); static void sub_0808EABC(FileScreenObjectsEntity*); @@ -550,14 +550,14 @@ static u32 sub_0808EF6C(FileScreenObjectsEntity* this) { return 0; } - var4 = var7 = sub_080041EC(var0, var2); + var4 = var7 = CalcDistance(var0, var2); var4 += 128; var7 = var4 + var7 * 16; if (this->unk_6c < var7) { var7 = this->unk_6c; } super->speed = var7; - super->direction = sub_080045DA(var0, var2) >> 3; + super->direction = CalcOffsetAngle(var0, var2) >> 3; LinearMoveUpdate(super); return 1; } diff --git a/src/object/keyStealingTakkuri.c b/src/object/keyStealingTakkuri.c index 2f67e69f..2fceaa87 100644 --- a/src/object/keyStealingTakkuri.c +++ b/src/object/keyStealingTakkuri.c @@ -433,7 +433,7 @@ void sub_0809E0D4(KeyStealingTakkuriEntity* this, ScriptExecutionContext* contex varY2 = varY; if (--context->unk_19 == 0) { context->unk_19 = 8; - super->direction = sub_080045DA(varX2 - super->x.HALF.HI, varY2 - super->y.HALF.HI); + super->direction = CalcOffsetAngle(varX2 - super->x.HALF.HI, varY2 - super->y.HALF.HI); } varX3 = super->x.HALF.HI - varX2; varY3 = super->y.HALF.HI - varY2; diff --git a/src/object/objectA2.c b/src/object/objectA2.c index 0617ce3e..9e82aeb3 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -117,5 +117,5 @@ void sub_0809F448(Entity* this) { break; } this->speed = (tmp > 0 ? tmp : -tmp) / (tmp2->unk_1 << 8); - this->direction = sub_080045DA(tmp, 0) >> 3; + this->direction = CalcOffsetAngle(tmp, 0) >> 3; } diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index ddab7bce..bc77267c 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -181,7 +181,7 @@ void OctorokBossObject_Action1(OctorokBossObjectEntity* this) { return; } case 1: - super->direction = sub_080045DA(this->helper->tailObjects[super->timer]->x.WORD - super->x.WORD, + super->direction = CalcOffsetAngle(this->helper->tailObjects[super->timer]->x.WORD - super->x.WORD, this->helper->tailObjects[super->timer]->y.WORD - super->y.WORD); LinearMoveAngle(super, super->speed, super->direction); if (EntityInRectRadius(super, this->helper->tailObjects[super->timer], 2, 2) == 0) { @@ -207,7 +207,7 @@ void OctorokBossObject_Action1(OctorokBossObjectEntity* this) { case 2: if (super->parent->type2 == 3) { Entity* object = ((OctorokBossObjectEntity*)super->parent)->helper->mouthObject; - super->direction = sub_080045DA(object->x.WORD - super->x.WORD, object->y.WORD - super->y.WORD); + super->direction = CalcOffsetAngle(object->x.WORD - super->x.WORD, object->y.WORD - super->y.WORD); LinearMoveAngle(super, 0x280, super->direction); if (sub_0806FC80(super, super->parent, 0x48) == 0) { return; diff --git a/src/object/specialFx.c b/src/object/specialFx.c index bfe1a5e5..622aa059 100644 --- a/src/object/specialFx.c +++ b/src/object/specialFx.c @@ -199,7 +199,7 @@ void sub_080845DC(SpecialFxObject* this) { void sub_080845F8(SpecialFxObject* this) { if (((8 - (super->x.HALF.HI & 0xF)) | (8 - (super->y.HALF.HI & 0xF))) != 0) { - super->direction = sub_080045DA((8 - (super->x.HALF.HI & 0xF)), (8 - (super->y.HALF.HI & 0xF))) >> 3; + super->direction = CalcOffsetAngle((8 - (super->x.HALF.HI & 0xF)), (8 - (super->y.HALF.HI & 0xF))) >> 3; LinearMoveUpdate(super); } sub_08084630(this); diff --git a/src/player.c b/src/player.c index ffb4ca6c..303bc8ff 100644 --- a/src/player.c +++ b/src/player.c @@ -25,28 +25,27 @@ #include "screenTransitions.h" #include "sound.h" -#define GRAVITY_RATE Q_8_8(32) -#define SLOPE_SPEED_MODIFIER 0x50 +#define kGravityRate Q_8_8(32) +#define kWalkSpeedSlopeSubtractor Q_8_8(0.3125) +#define kWalkSpeed Q_8_8(1.25) +#define kWalkSpeedRolling Q_8_8(2.0) +#define kWalkSpeedGustJar Q_8_8(0.5) +#define kWalkSpeedShield Q_8_8(0.75) +#define kWalkSpeedSwordCharge Q_8_8(0.875) +#define kWalkSpeedBurning Q_8_8(3) -#define WALK_SPEED Q_8_8(1.25) -#define ROLL_SPEED Q_8_8(2.0) -#define GUST_JAR_SPEED Q_8_8(0.5) -#define SHIELDING_SPEED Q_8_8(0.75) -#define SWORD_CHARGE_SPEED Q_8_8(0.875) -#define BURNING_SPEED Q_8_8(3) - -#define JUMP_SPEED_FWD Q_8_8(1) +#define kJumpSpeedForward Q_8_8(1) /* Jumping out of a hole */ -#define JUMP_SPEED_HOLE_FWD Q_8_8(0.46875) -#define JUMP_SPEED_HOLE_Z Q_16_16(1.625) +#define kJumpSpeedHoleForward Q_8_8(0.46875) +#define kJumpSpeedHoleZ Q_16_16(1.625) /* Bouncing off a wall */ -#define BOUNCE_SPEED_FWD Q_8_8(1.0) -#define BOUNCE_SPEED_Z Q_16_16(2.0) +#define kBounceSpeedForward Q_8_8(1.0) +#define kBounceSpeedZ Q_16_16(2.0) -#define PULL_SPEED Q_8_8(0.5) -#define PUSH_SPEED Q_8_8(0.5) +#define kPullSpeed Q_8_8(0.5) +#define kPushSpeed Q_8_8(0.5) -#define FALL_DAMAGE 2 +#define kFallDamage 2 typedef void(PlayerEntityAction)(PlayerEntity*); @@ -392,7 +391,7 @@ static void PlayerNormal(PlayerEntity* this) { if (gPlayerState.flags & PL_CAPTURED) { super->spritePriority.b1 = 0; super->knockbackDuration = 0; - super->speed = WALK_SPEED; + super->speed = kWalkSpeed; gPlayerState.pushedObject = 0x80; gPlayerState.framestate = PL_STATE_TRAPPED; if ((super->animationState >> 1) + 92 == super->animIndex && (u16)super->spriteIndex == 2) @@ -421,14 +420,14 @@ static void PlayerNormal(PlayerEntity* this) { } if (!gPlayerState.swim_state && (gPlayerState.jump_status & 0xC0) == 0) { if (gPlayerState.shield_status || gPlayerState.bow_state) { - super->speed = SHIELDING_SPEED; + super->speed = kWalkSpeedShield; } else { if (gPlayerState.sword_state) { - super->speed = SWORD_CHARGE_SPEED; + super->speed = kWalkSpeedSwordCharge; } else if (gPlayerState.field_0x1c) { - super->speed = GUST_JAR_SPEED; + super->speed = kWalkSpeedGustJar; } else { - super->speed = WALK_SPEED; + super->speed = kWalkSpeed; } } } @@ -536,7 +535,7 @@ static void PlayerNormal(PlayerEntity* this) { if ((gPlayerState.sword_state & 0x10) == 0) { super->direction = gPlayerState.direction; if (gPlayerState.flags & PL_BURNING) { - super->speed = BURNING_SPEED; + super->speed = kWalkSpeedBurning; if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) super->direction = 4 * (super->animationState & 0xE); DeleteClones(); @@ -624,7 +623,7 @@ static void PlayerFallUpdate(PlayerEntity* this) { RespawnPlayer(); gPlayerState.field_0xa = 0; super->iframes = 32; - ModHealth(-FALL_DAMAGE); + ModHealth(-kFallDamage); } } } @@ -641,19 +640,19 @@ static void PlayerBounce(PlayerEntity* this) { static void PlayerBounceInit(PlayerEntity* this) { COLLISION_OFF(super); super->direction = DirectionTurnAround(Direction8FromAnimationState(AnimationStateWalk(super->animationState))); - super->speed = BOUNCE_SPEED_FWD; + super->speed = kBounceSpeedForward; super->knockbackDuration = 0; super->subAction++; super->timer = gPlayerState.field_0x38; super->spriteIndex = 1; if (!(gPlayerState.flags & PL_MINISH)) { - super->zVelocity = BOUNCE_SPEED_Z; + super->zVelocity = kBounceSpeedZ; gPlayerState.animation = ANIM_BOUNCE; InitScreenShake(16, 0); } else { gPlayerState.animation = ANIM_BOUNCE_MINISH; - super->zVelocity = (BOUNCE_SPEED_Z * 3) / 4; + super->zVelocity = (kBounceSpeedZ * 3) / 4; } gPlayerState.jump_status = 0x80; @@ -668,7 +667,7 @@ static void PlayerBounceUpdate(PlayerEntity* this) { UpdatePlayerMovement(); UpdateFloorType(); - if (CheckQueuedAction() || GravityUpdate(super, GRAVITY_RATE)) + if (CheckQueuedAction() || GravityUpdate(super, kGravityRate)) return; gPlayerState.jump_status = 0; @@ -866,7 +865,7 @@ static void PlayerJumpInit(PlayerEntity* this) { temp <<= 12; super->zVelocity = temp; - super->speed = JUMP_SPEED_FWD; + super->speed = kJumpSpeedForward; DeleteClones(); SoundReq(SFX_PLY_JUMP); SoundReq(SFX_PLY_VO4); @@ -885,7 +884,7 @@ static void sub_08071130(PlayerEntity* this) { LinearMoveUpdate(super); - if (GravityUpdate(super, GRAVITY_RATE)) + if (GravityUpdate(super, kGravityRate)) return; gPlayerState.jump_status = 0; @@ -1041,7 +1040,7 @@ static void PortalJumpOnUpdate(PlayerEntity* this) { if ((super->x.HALF.HI != x) || (super->y.HALF.HI != y)) { super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gArea.portal_x, gArea.portal_y); - super->speed = JUMP_SPEED_FWD; + super->speed = kJumpSpeedForward; UpdatePlayerMovement(); } @@ -1081,7 +1080,7 @@ static void PortalStandUpdate(PlayerEntity* this) { super->direction = gPlayerState.direction; super->animationState = Direction8ToAnimationState(super->direction); super->zVelocity = Q_16_16(2.0); - super->speed = JUMP_SPEED_FWD; + super->speed = kJumpSpeedForward; super->action = PLAYER_MINISH; super->subAction = 7; super->subtimer = 0; @@ -1216,7 +1215,7 @@ static void PortalShrinkUpdate(PlayerEntity* this) { static void PortalEnterUpdate(PlayerEntity* this) { if (super->timer == 0) { - if (GravityUpdate(super, GRAVITY_RATE)) + if (GravityUpdate(super, kGravityRate)) return; super->spriteSettings.draw = FALSE; @@ -1311,7 +1310,7 @@ static void PlayerTalkEzlo_Init(PlayerEntity* this) { return; } - if (!GravityUpdate(super, GRAVITY_RATE)) { + if (!GravityUpdate(super, kGravityRate)) { gPlayerState.jump_status = 0; } } @@ -1406,7 +1405,7 @@ static void PlayerPushInit(PlayerEntity* this) { super->timer = 0; super->subtimer = 1; } else { - super->speed = (gPlayerState.flags & PL_MINISH) ? PUSH_SPEED / 2 : PUSH_SPEED; + super->speed = (gPlayerState.flags & PL_MINISH) ? kPushSpeed / 2 : kPushSpeed; } PlayerPushUpdate(this); } @@ -1419,19 +1418,19 @@ static void PlayerPushUpdate(PlayerEntity* this) { static const PushFrame sPushFrames[] = { { 5, 0 }, - { 1, PUSH_SPEED * 2 }, + { 1, kPushSpeed * 2 }, { 5, 0 }, - { 1, PUSH_SPEED * 2 }, + { 1, kPushSpeed * 2 }, { 2, 0 }, - { 1, PUSH_SPEED * 2 }, + { 1, kPushSpeed * 2 }, { 2, 0 }, - { 1, PUSH_SPEED * 2 }, + { 1, kPushSpeed * 2 }, { 3, 0 }, - { 1, PUSH_SPEED * 2 }, - { 8, PUSH_SPEED * 3 / 4 }, - { 8, PUSH_SPEED * 3 / 4 }, - { 8, PUSH_SPEED * 3 / 4 }, - { 8, PUSH_SPEED / 2 }, + { 1, kPushSpeed * 2 }, + { 8, kPushSpeed * 3 / 4 }, + { 8, kPushSpeed * 3 / 4 }, + { 8, kPushSpeed * 3 / 4 }, + { 8, kPushSpeed / 2 }, { 0xFF, 0 }, }; @@ -1491,7 +1490,7 @@ static void PlayerMinishDieInit(PlayerEntity* this) { if (gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS)) return; - if (GravityUpdate(super, GRAVITY_RATE)) { + if (GravityUpdate(super, kGravityRate)) { if (gPlayerState.flags & PL_NO_CAP) gPlayerState.animation = ANIM_JUMP_NOCAP; else @@ -1637,7 +1636,7 @@ static void sub_08071E04(PlayerEntity* this) { static void sub_08071E74(PlayerEntity* this) { u32 temp; - GravityUpdate(super, GRAVITY_RATE); + GravityUpdate(super, kGravityRate); UpdatePlayerMovement(); temp = super->timer--; if (temp == 0) @@ -1703,7 +1702,7 @@ static void PlayerFrozenInit(PlayerEntity* this) { } static void PlayerFrozenUpdate(PlayerEntity* this) { - if (GravityUpdate(super, GRAVITY_RATE) == 0) { + if (GravityUpdate(super, kGravityRate) == 0) { UpdateSpriteForCollisionLayer(super); gPlayerState.jump_status = 0; if (gPlayerState.field_0x14 == 0) { @@ -1807,7 +1806,7 @@ static void sub_08072168(PlayerEntity* this) { u32 i; UpdateAnimationSingleFrame(super); - i = (u16)sub_0806F854(super, 0, -12) ? GRAVITY_RATE * 2 : GRAVITY_RATE; + i = (u16)sub_0806F854(super, 0, -12) ? kGravityRate * 2 : kGravityRate; GravityUpdate(super, i); if (gPlayerState.field_0x3a) { LinearMoveUpdate(super); @@ -1837,7 +1836,7 @@ static void PlayerPull(PlayerEntity* this) { static void sub_08072214(PlayerEntity* this) { super->subAction = 1; - super->speed = PULL_SPEED; + super->speed = kPullSpeed; super->timer = gPlayerState.field_0x38; super->direction = Direction8FromAnimationState(AnimationStateFlip180(super->animationState)); if ((gPlayerState.flags & PL_NO_CAP) == 0) { @@ -1904,7 +1903,7 @@ static void sub_08072354(PlayerEntity* this) { sub_0806F854(super, 0, -12); UpdateAnimationSingleFrame(super); sub_08079744(super); - if (GravityUpdate(super, GRAVITY_RATE)) + if (GravityUpdate(super, kGravityRate)) return; super->spritePriority.b1 = 0; @@ -2112,14 +2111,14 @@ static void PlayerRollUpdate(PlayerEntity* this) { switch (super->frame & 0xf) { case 0: if ((super->frame & 0xf) == 0) { - super->speed = ROLL_SPEED; + super->speed = kWalkSpeedRolling; } break; case 1: - super->speed += ROLL_SPEED / 16; + super->speed += kWalkSpeedRolling / 16; break; case 2: - super->speed = (ROLL_SPEED * 3 / 2); + super->speed = (kWalkSpeedRolling * 3 / 2); break; case 3: super->speed = 0; @@ -2229,8 +2228,8 @@ static void sub_08072ACC(PlayerEntity* this) { } else if (super->subtimer > 7) { COLLISION_ON(super); super->direction = gPlayerState.direction; - super->zVelocity = JUMP_SPEED_HOLE_Z; - super->speed = JUMP_SPEED_HOLE_FWD; + super->zVelocity = kJumpSpeedHoleZ; + super->speed = kJumpSpeedHoleForward; super->spritePriority.b0 = 4; super->spritePriority.b1 = 1; gPlayerState.jump_status = 0x41; @@ -2277,7 +2276,7 @@ static void sub_08072B5C(PlayerEntity* this) { temp <<= 12; super->zVelocity = temp; - super->speed = JUMP_SPEED_FWD; + super->speed = kJumpSpeedForward; gPlayerState.animation = ANIM_JUMP; SoundReq(SFX_PLY_JUMP); } @@ -2285,7 +2284,7 @@ static void sub_08072B5C(PlayerEntity* this) { static void sub_08072C48(PlayerEntity* this) { UpdateAnimationSingleFrame(super); LinearMoveUpdate(super); - if (GravityUpdate(super, GRAVITY_RATE)) + if (GravityUpdate(super, kGravityRate)) return; DoTileInteractionHere(super, 7); @@ -2403,7 +2402,7 @@ static void sub_08072D54(PlayerEntity* this) { super->timer = 0; } - if (!GravityUpdate(super, GRAVITY_RATE)) { + if (!GravityUpdate(super, kGravityRate)) { COLLISION_ON(super); if (super->collisionLayer == 1) { ResetCollisionLayer(super); @@ -2724,7 +2723,7 @@ static void sub_08073468(PlayerEntity* this) { } static void sub_080734D4(PlayerEntity* this) { - GravityUpdate(super, -(GRAVITY_RATE / 2)); + GravityUpdate(super, -(kGravityRate / 2)); if (super->zVelocity > 0 || gPlayerState.field_0x38 == 1) { super->zVelocity = Q_16_16(4.5625); super->subAction++; @@ -2732,7 +2731,7 @@ static void sub_080734D4(PlayerEntity* this) { } static void sub_08073504(PlayerEntity* this) { - GravityUpdate(super, super->zVelocity < 0 ? GRAVITY_RATE / 4 : GRAVITY_RATE * 2); + GravityUpdate(super, super->zVelocity < 0 ? kGravityRate / 4 : kGravityRate * 2); if (super->zVelocity < 0 && super->z.HALF.HI > -32) { super->subAction++; this->unk_80.WORD = super->direction << 8; @@ -2908,7 +2907,7 @@ static void sub_0807380C(PlayerEntity* this) { } gPlayerState.animation = sAnims[super->animationState >> 1]; if (super->z.HALF.HI < -16) { - GravityUpdate(super, GRAVITY_RATE / 16); + GravityUpdate(super, kGravityRate / 16); } else { if (--super->timer == 0) { super->subAction = 7; @@ -2939,7 +2938,7 @@ void sub_08073884(PlayerEntity* this) { else InitParachuteRoom(); } - GravityUpdate(super, -((GRAVITY_RATE * 3) / 4)); + GravityUpdate(super, -((kGravityRate * 3) / 4)); UpdateAnimationSingleFrame(super); } @@ -2993,13 +2992,13 @@ static void sub_080739EC(PlayerEntity* this) { gPlayerState.direction = super->direction; if (gPlayerState.jump_status & 0x80) super->collisions = COL_NONE; - v = GRAVITY_RATE; + v = kGravityRate; } else { if ((u16)sub_0806F854(super, 0, -12)) { gPlayerState.jump_status |= 8; - v = GRAVITY_RATE * 2; + v = kGravityRate * 2; } else { - v = GRAVITY_RATE; + v = kGravityRate; if (gPlayerState.jump_status & 0x10) v /= 2; } @@ -3079,7 +3078,7 @@ void sub_08073B8C(PlayerEntity* this) { --super->timer; return; } - GravityUpdate(super, GRAVITY_RATE * 2); + GravityUpdate(super, kGravityRate * 2); if (super->z.HALF.HI >= -8) { if (!gPlayerState.field_0x14 && (sub_0807A2B8() || !sub_08079D48())) { COLLISION_ON(super); @@ -3173,7 +3172,7 @@ static void sub_08073D20(PlayerEntity* this) { } if (!UpdatePlayerCollision()) { UpdateActiveItems(super); - if (!GravityUpdate(super, GRAVITY_RATE)) + if (!GravityUpdate(super, kGravityRate)) gPlayerState.jump_status = 0; if ((gPlayerState.field_0x7 & 0x80) == 0 && !gPlayerState.field_0xa) { if (super->iframes <= 8) { @@ -3251,7 +3250,7 @@ static void sub_08073FD0(PlayerEntity* this) { SoundReq(SFX_PLY_JUMP); } } - GravityUpdate(super, GRAVITY_RATE); + GravityUpdate(super, kGravityRate); if (super->zVelocity == 0) { super->subAction++; SoundReq(SFX_PLY_GROW); @@ -3270,7 +3269,7 @@ static void sub_08074018(PlayerEntity* this) { } static void sub_08074060(PlayerEntity* this) { - if (!GravityUpdate(super, GRAVITY_RATE)) { + if (!GravityUpdate(super, kGravityRate)) { super->hitbox = (Hitbox*)&gPlayerHitbox; super->direction = DirectionSouth; super->animationState = IdleSouth; @@ -3320,7 +3319,7 @@ void sub_080740D8(PlayerEntity* this) { LinearMoveUpdate(super); else super->subtimer = 1; - if (!GravityUpdate(super, GRAVITY_RATE)) + if (!GravityUpdate(super, kGravityRate)) PlayerSetNormalAndCollide(); } @@ -3367,7 +3366,7 @@ static void sub_08074244(PlayerEntity* this, u32 a1, u32 a2) { tmp = 4 * super->animationState; } if (a1 != tmp || a2 != tmp) { - gPlayerState.speed_modifier -= SLOPE_SPEED_MODIFIER; + gPlayerState.speed_modifier -= kWalkSpeedSlopeSubtractor; } } } @@ -3788,7 +3787,7 @@ void SurfaceAction_ConveyerEast(PlayerEntity* this) { static void conveyer_push(PlayerEntity* this) { ResetActiveItems(); super->spritePriority.b1 = 0; - super->speed = WALK_SPEED; + super->speed = kWalkSpeed; gPlayerState.flags |= PL_CONVEYOR_PUSHED; gPlayerState.field_0xa |= 0x80; gPlayerState.mobility |= 0x80; @@ -3839,7 +3838,7 @@ static void sub_08074CF8(PlayerEntity* this) { sub_08074D34(this, *(ScriptExecutionContext**)&this->unk_84.WORD); if ((this->unk_80.HALF.HI & 1) != 0) super->animationState = v3; - GravityUpdate(super, GRAVITY_RATE); + GravityUpdate(super, kGravityRate); UpdateAnimationSingleFrame(super); } @@ -3995,7 +3994,7 @@ void sub_0807501C(PlayerEntity* this) { void sub_0807508C(PlayerEntity* this) { UpdateAnimationSingleFrame(super); - if (GravityUpdate(super, GRAVITY_RATE)) { + if (GravityUpdate(super, kGravityRate)) { LinearMoveUpdate(super); } else { if (!gPlayerState.field_0x39) { diff --git a/src/script.c b/src/script.c index 6a10ec96..3a826a34 100644 --- a/src/script.c +++ b/src/script.c @@ -436,7 +436,7 @@ void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 x, u32 y) context->y.HALF.HI = y; xOffset = context->x.HALF.HI - entity->x.HALF.HI; yOffset = context->y.HALF.HI - entity->y.HALF.HI; - direction = sub_080045DA(xOffset, yOffset); + direction = CalcOffsetAngle(xOffset, yOffset); entity->direction = direction; entity->animationState = (entity->animationState & 0x80) | sDirectionTable[(u8)direction >> 4]; } @@ -1394,7 +1394,7 @@ void ScriptCommand_0807EE30(Entity* entity, ScriptExecutionContext* context) { if (!--context->unk_19) { context->unk_19 = 8; entity->direction = - sub_080045DA(context->x.HALF.HI - entity->x.HALF.HI, context->y.HALF.HI - entity->y.HALF.HI); + CalcOffsetAngle(context->x.HALF.HI - entity->x.HALF.HI, context->y.HALF.HI - entity->y.HALF.HI); } tmp = entity->x.HALF.HI - context->x.HALF.HI; tmp2 = entity->y.HALF.HI - context->y.HALF.HI; From f5c6178ed4830769f65fbc74b18e3403eda05f86 Mon Sep 17 00:00:00 2001 From: theo3 Date: Mon, 1 Jan 2024 13:02:57 -0800 Subject: [PATCH 10/10] gustjar player fields --- asm/src/player.s | 2 +- include/player.h | 26 ++++++++++-- src/beanstalkSubtask.c | 2 +- src/collision.c | 2 +- src/enemy/bombPeahat.c | 4 +- src/enemy/dust.c | 2 +- src/enemy/enemy64.c | 4 +- src/enemy/flyingPot.c | 2 +- src/enemy/flyingSkull.c | 2 +- src/enemy/gyorgMale.c | 4 +- src/enemy/octorokBoss.c | 8 ++-- src/item/itemGustJar.c | 60 +++++++++++++-------------- src/item/itemPegasusBoots.c | 2 +- src/item/itemRocsCape.c | 2 +- src/item/itemTryPickupObject.c | 2 +- src/object/bush.c | 4 +- src/object/chuchuBossStartParticle.c | 2 +- src/object/evilSpirit.c | 5 ++- src/object/gustJarParticle.c | 2 +- src/object/itemForSale.c | 6 +-- src/object/lilypadLarge.c | 6 +-- src/object/minecart.c | 2 +- src/object/objectA8.c | 4 +- src/object/objectOnSpinyBeetle.c | 6 +-- src/object/octorokBossObject.c | 2 +- src/object/pot.c | 6 +-- src/object/pullableMushroom.c | 11 ++--- src/physics.c | 18 ++++---- src/player.c | 8 ++-- src/playerItem/playerItemGust.c | 2 +- src/playerItem/playerItemGustBig.c | 21 ++++------ src/playerItem/playerItemGustJar.c | 18 ++++---- src/playerItem/playerItemHeldObject.c | 2 +- src/playerUtils.c | 25 +++++------ 34 files changed, 146 insertions(+), 128 deletions(-) diff --git a/asm/src/player.s b/asm/src/player.s index fefcf695..488fdbaa 100644 --- a/asm/src/player.s +++ b/asm/src/player.s @@ -83,7 +83,7 @@ _080085E6: ldr r3, _080088A8 @ =gPlayerState ldrb r2, [r3, #0x1c] orrs r2, r2 - bne _0800861A // field_0x1c != 0 + bne _0800861A // gustJarState != 0 ldrb r2, [r3, #5] orrs r2, r2 bne _0800861A // heldObject != 0 diff --git a/include/player.h b/include/player.h index e344d0af..dbd1f923 100644 --- a/include/player.h +++ b/include/player.h @@ -11,8 +11,8 @@ typedef struct { /*0x6d*/ u8 unk_6d; /*0x6e*/ u8 unk_6e; /*0x6f*/ u8 unk_6f; - /*0x70*/ Entity* unk_70; - /*0x74*/ Entity* unk_74; + /*0x70*/ Entity* pulledJarEntity; + /*0x74*/ Entity* carriedEntity; /*0x78*/ u8 unk_78; /*0x79*/ u8 unk_79; /*0x7a*/ u16 unk_7a; @@ -298,6 +298,24 @@ typedef enum { SWORD_MOVE_LOW_BEAM, } SwordMove; +typedef enum { + PL_JAR_NONE = 0x0, + PL_JAR_SUCK = 0x1, + PL_JAR_2 = 0x2, + PL_JAR_3 = 0x3, + PL_JAR_BLAST_INIT = 0x4, + PL_JAR_BLAST_UPDATE = 0x5, + PL_JAR_BLAST_DONE = 0x6, + PL_JAR_ENT_ATTACHED = 0x7, +} GustJarState; + +typedef enum { + JAR_CHARGE_NONE = 0, + JAR_CHARGE_SMALL = 1, + JAR_CHARGE_MID = 2, + JAR_CHARGE_BIG = 3, +} GustJarCharge; + typedef enum { ANIM_DEFAULT = 0x100, ANIM_WALK = 0x104, @@ -492,8 +510,8 @@ typedef struct { /*0x18*/ u16 startPosY; /*0x1a*/ u8 mobility; /*0x1b*/ u8 sword_state; - /*0x1c*/ u8 field_0x1c; - /*0x1d*/ u8 gustJarSpeed; + /*0x1c*/ u8 gustJarState; + /*0x1d*/ u8 gustJarCharge; /*0x1e*/ u8 dash_state; /*0x1f*/ u8 field_0x1f[2]; /*0x21*/ u8 bow_state; diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index beacfffc..2eb16f89 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -208,7 +208,7 @@ u32 UpdatePlayerCollision(void) { ((gPlayerState.sword_state & 0x10) != 0)) || ((sub_080806BC(gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x, gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y, index, 5) == 0 && - (((gPlayerState.heldObject != 0 || ((gPlayerState.field_0x1c & 0xf) != 0)) || + (((gPlayerState.heldObject != 0 || ((gPlayerState.gustJarState & 0xf) != 0)) || (sub_0807BD14(&gPlayerEntity.base, index) == 0)))))) { return 3; } diff --git a/src/collision.c b/src/collision.c index 95595906..b8c0bbd3 100644 --- a/src/collision.c +++ b/src/collision.c @@ -391,7 +391,7 @@ CollisionResult sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSetting CollisionResult sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { if ((tgt->gustJarState & 4) != 0) { if (tgt->gustJarTolerance) { - tgt->gustJarTolerance = tgt->gustJarTolerance - gPlayerState.gustJarSpeed; + tgt->gustJarTolerance = tgt->gustJarTolerance - gPlayerState.gustJarCharge; if ((s8)tgt->gustJarTolerance <= 0) { tgt->gustJarTolerance = 0; tgt->subAction = 2; diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 44ea5007..64bff4f2 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -96,8 +96,8 @@ void sub_0802A8F4(BombPeahatEntity* this) { } void sub_0802A8FC(BombPeahatEntity* this) { - if ((gPlayerState.field_0x1c & 0xf) == 0) { - super->health = gPlayerState.field_0x1c & 0xf; + if ((gPlayerState.gustJarState & 0xf) == 0) { + super->health = gPlayerState.gustJarState & 0xf; } } diff --git a/src/enemy/dust.c b/src/enemy/dust.c index e6d3ca7a..7fd8c6d0 100644 --- a/src/enemy/dust.c +++ b/src/enemy/dust.c @@ -303,7 +303,7 @@ void sub_08044550(DustEntity* this) { u8 uVar1; const s8* ptr; - if ((gPlayerState.field_0x1c & 0xf) == 1) { + if ((gPlayerState.gustJarState & 0xf) == 1) { if (super->speed < 0x100) { super->speed += 0x10; } diff --git a/src/enemy/enemy64.c b/src/enemy/enemy64.c index c929ae8d..41566f7b 100644 --- a/src/enemy/enemy64.c +++ b/src/enemy/enemy64.c @@ -291,7 +291,7 @@ void Enemy64_Action3(Enemy64Entity* this) { void Enemy64_Action3_SubAction0(Enemy64Entity* this) { u32 tmp = CalcOffsetAngle(gRoomControls.origin_x + 0xa8 - super->x.HALF.HI, - gRoomControls.origin_y + 0x80 - super->y.HALF.HI); + gRoomControls.origin_y + 0x80 - super->y.HALF.HI); if (tmp != super->direction) { if (((tmp - super->direction) & 0x80) != 0) { super->direction--; @@ -491,7 +491,7 @@ void sub_080499F0(Enemy64Entity* this) { if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24) && ((this->unk_7c & 2) == 0)) { tmp = CalcOffsetAngle((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, - (s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); + (s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); gPlayerEntity.base.x.WORD = super->x.WORD + gSineTable[tmp] * 0x2400; gPlayerEntity.base.y.WORD = super->y.WORD + gSineTable[tmp + 0x40] * -0x2400; } diff --git a/src/enemy/flyingPot.c b/src/enemy/flyingPot.c index 0402aac5..46490d61 100644 --- a/src/enemy/flyingPot.c +++ b/src/enemy/flyingPot.c @@ -156,7 +156,7 @@ void FlyingPot_SubAction2(FlyingPotEntity* this) { } void FlyingPot_SubAction3(FlyingPotEntity* this) { - if (!(gPlayerState.field_0x1c & 0xF)) { + if (!(gPlayerState.gustJarState & 0xF)) { sub_08037408(this); } } diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 4e5acb0e..4af30c9f 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -100,7 +100,7 @@ void sub_08039CE0(FlyingSkullEntity* this) { } void sub_08039D4C(FlyingSkullEntity* this) { - if ((gPlayerState.field_0x1c & 0xf) == 0) { + if ((gPlayerState.gustJarState & 0xf) == 0) { sub_0803A0E0(this); } } diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index 30a4273f..70598f81 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -1067,7 +1067,7 @@ void sub_08047EA4(GyorgMaleEntity* this, u32 unk1) { if (this->unk_7c & 1) { tmp2 = sub_08047F68(this) << 8; dir = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, - gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); + gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); tmp = dir - (tmp / 256); tmp &= 0xFF; gPlayerEntity.base.x.WORD += (gSineTable[tmp] - gSineTable[dir]) * tmp2; @@ -1150,7 +1150,7 @@ void sub_08048004(GyorgMaleEntity* this) { if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24)) { if (!(this->unk_7c & 2)) { u32 tmp = CalcOffsetAngle(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI, - gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); + gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI); gPlayerEntity.base.x.WORD = super->x.WORD + (gSineTable[tmp] * 9216); gPlayerEntity.base.y.WORD = super->y.WORD - (gSineTable[tmp + 0x40] * 9216); } diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index 1279f133..1e0f70c7 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -168,11 +168,11 @@ void OctorokBoss_Hit_SubAction1(OctorokBossEntity* this) { this->heap->field_0x2 = 1; #if defined(JP) || defined(DEMO_JP) || defined(EU) super->direction = ((s32)CalcOffsetAngle((((gRoomControls.origin_x + 0x108) << 0x10) - super->x.WORD), - (((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >> + (((gRoomControls.origin_y + 0x88) << 0x10) - super->y.WORD))) >> 3; #else super->direction = ((s32)CalcOffsetAngle(gRoomControls.origin_x + 0x108 - super->x.HALF.HI, - gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >> + gRoomControls.origin_y + 0x88 - super->y.HALF.HI)) >> 3; #endif super->speed = 0x100; @@ -913,7 +913,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) { this->timer = 2; this->heap->targetAngle = CalcOffsetAngle((gRoomControls.origin_x + 0x108) * 0x10000 - super->x.WORD, - (gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD); + (gRoomControls.origin_y + 0x88) * 0x10000 - super->y.WORD); this->heap->targetAngle = (u8) - (this->heap->targetAngle + 0x80); SoundReq(SFX_ED); } @@ -1179,7 +1179,7 @@ void sub_08036AF0(OctorokBossEntity* this, s32 radius, s32 angleSpeed) { } else { heap->tailObjects[index - 1]->angle.HALF.HI = CalcOffsetAngle(heap->tailObjects[index - 1]->base.x.WORD - heap->tailObjects[index]->base.x.WORD, - heap->tailObjects[index - 1]->base.y.WORD - heap->tailObjects[index]->base.y.WORD); + heap->tailObjects[index - 1]->base.y.WORD - heap->tailObjects[index]->base.y.WORD); tmp = FixedMul(gSineTable[heap->tailObjects[index - 1]->angle.HALF.HI], radius << 4); tmp = FixedDiv(tmp, 0x100); heap->tailObjects[index - 1]->base.x.WORD = heap->tailObjects[index]->base.x.WORD + ((s32)tmp << 8); diff --git a/src/item/itemGustJar.c b/src/item/itemGustJar.c index a1c8b4f0..ea2da874 100644 --- a/src/item/itemGustJar.c +++ b/src/item/itemGustJar.c @@ -18,9 +18,9 @@ void sub_08076DF4(ItemBehavior* this, u32 index) { this->playerAnimationState = gPlayerEntity.base.animationState; this->priority |= 0x80; this->priority++; - gPlayerState.gustJarSpeed = 1; - gPlayerEntity.unk_74 = NULL; - gPlayerState.field_0x1c = 1; + gPlayerState.gustJarCharge = JAR_CHARGE_SMALL; + gPlayerEntity.carriedEntity = NULL; + gPlayerState.gustJarState = PL_JAR_SUCK; sub_08077BB8(this); } else { DeleteItemBehavior(this, index); @@ -30,7 +30,7 @@ void sub_08076DF4(ItemBehavior* this, u32 index) { void sub_08076E60(ItemBehavior* this, u32 index) { Entity* playerItem; - if ((gPlayerState.field_0x1c & 0xf) == 0) { + if ((gPlayerState.gustJarState & 0xf) == 0) { DeleteItemBehavior(this, index); } if ((this->playerFrame & 0x80) != 0) { @@ -47,7 +47,7 @@ void sub_08076E60(ItemBehavior* this, u32 index) { } void sub_08076EC8(ItemBehavior* this, u32 index) { - if ((gPlayerState.field_0x1c & 0xf) == 0) { + if ((gPlayerState.gustJarState & 0xf) == PL_JAR_NONE) { DeleteItemBehavior(this, index); return; } @@ -55,11 +55,11 @@ void sub_08076EC8(ItemBehavior* this, u32 index) { if (IsItemActive(this)) { u32 animIndex; if (this->timer > 0xef) { - gPlayerState.gustJarSpeed = 3; + gPlayerState.gustJarCharge = JAR_CHARGE_BIG; } else if (++this->timer > 0x77) { - gPlayerState.gustJarSpeed = 2; + gPlayerState.gustJarCharge = JAR_CHARGE_MID; } else { - gPlayerState.gustJarSpeed = 1; + gPlayerState.gustJarCharge = JAR_CHARGE_SMALL; } if (gPlayerEntity.base.subAction == 0x1b) { @@ -87,16 +87,16 @@ void sub_08076EC8(ItemBehavior* this, u32 index) { void sub_08076F64(ItemBehavior* this, u32 index) { Entity* item; PlayerEntity* player; - switch (gPlayerState.field_0x1c & 0xf) { - case 5: + switch (gPlayerState.gustJarState & 0xf) { + case PL_JAR_BLAST_UPDATE: if (this->playerFrame & 0x80) { if (this->subtimer) { this->subtimer = 0; this->timer = 0; - gPlayerState.gustJarSpeed = 1; + gPlayerState.gustJarCharge = JAR_CHARGE_SMALL; player = &gPlayerEntity; - player->unk_74 = NULL; - gPlayerState.field_0x1c = 1; + player->carriedEntity = NULL; + gPlayerState.gustJarState = PL_JAR_SUCK; gPlayerState.field_0xa &= ~(8 >> index); this->stateID = 2; SetItemAnim(this, ANIM_GUSTJAR_SUCK); @@ -106,7 +106,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) { } return; } else { - gPlayerState.field_0x1c = 6; + gPlayerState.gustJarState = PL_JAR_BLAST_DONE; SetItemAnim(this, ANIM_GUSTJAR_END); return; } @@ -126,18 +126,18 @@ void sub_08076F64(ItemBehavior* this, u32 index) { return; } return; - case 3: - gPlayerState.field_0x1c = 4; - case 4: + case PL_JAR_3: + gPlayerState.gustJarState = PL_JAR_BLAST_INIT; + case PL_JAR_BLAST_INIT: if (IsItemActive(this)) { this->subtimer = 1; } UpdateItemAnim(this); if (this->playerFrame & 1) { - gPlayerState.field_0x1c = 5; - gPlayerEntity.unk_70 = NULL; - if (gPlayerState.gustJarSpeed) { + gPlayerState.gustJarState = PL_JAR_BLAST_UPDATE; + gPlayerEntity.pulledJarEntity = NULL; + if (gPlayerState.gustJarCharge) { CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0); } } @@ -149,27 +149,27 @@ void sub_08076F64(ItemBehavior* this, u32 index) { gPlayerEntity.base.speed = 0x80; UpdatePlayerMovement(); return; - case 6: + case PL_JAR_BLAST_DONE: UpdateItemAnim(this); if ((this->playerFrame & 0x80) == 0) return; break; - case 7: + case PL_JAR_ENT_ATTACHED: SetItemAnim(this, ANIM_GUSTJAR_BLOW); - gPlayerState.field_0x1c = 3; - gPlayerState.gustJarSpeed = 0; + gPlayerState.gustJarState = PL_JAR_3; + gPlayerState.gustJarCharge = JAR_CHARGE_NONE; return; - case 1: - case 2: + case PL_JAR_SUCK: + case PL_JAR_2: default: - gPlayerState.field_0x1c = 3; + gPlayerState.gustJarState = PL_JAR_3; SetItemAnim(this, ANIM_GUSTJAR_BLOW); return; - case 0: + case PL_JAR_NONE: break; } - gPlayerState.field_0x1c = 0; - gPlayerEntity.unk_70 = NULL; + gPlayerState.gustJarState = PL_JAR_NONE; + gPlayerEntity.pulledJarEntity = NULL; DeleteItemBehavior(this, index); } diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index a79c4788..fca72541 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -62,7 +62,7 @@ void sub_080768F8(ItemBehavior* this, u32 index) { u32 bVar1; u32 bVar2; - bVar1 = gPlayerState.field_0x1c | gPlayerState.attack_status | gPlayerState.heldObject | gPlayerState.jump_status; + bVar1 = gPlayerState.gustJarState | gPlayerState.attack_status | gPlayerState.heldObject | gPlayerState.jump_status; bVar2 = (gPlayerState.flags & PL_IN_MINECART); bVar1 |= bVar2; if (bVar1 == 0) { diff --git a/src/item/itemRocsCape.c b/src/item/itemRocsCape.c index ed7f6526..60d290c1 100644 --- a/src/item/itemRocsCape.c +++ b/src/item/itemRocsCape.c @@ -35,7 +35,7 @@ void ItemRocsCape(ItemBehavior* this, u32 index) { } } else { if (((u8)(gPlayerState.sword_state | gPlayerState.field_0xa | gPlayerState.attack_status | - gPlayerState.heldObject | gPlayerState.field_0x1c | gPlayerState.moleMittsState) == 0) && + gPlayerState.heldObject | gPlayerState.gustJarState | gPlayerState.moleMittsState) == 0) && ((((gPlayerState.floor_type != SURFACE_DOOR && gPlayerState.floor_type != SURFACE_DOOR_13 && gPlayerState.floor_type != SURFACE_PIT) || (gPlayerEntity.base.z.WORD != 0)) || diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index c908f04f..c6122f1f 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -56,7 +56,7 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) { PlayerCancelHoldItem(this, param_3); } else { PlayerEntity* playerEnt = &gPlayerEntity; - playerEnt->unk_74 = param_2; + playerEnt->carriedEntity = param_2; playerEnt->base.subtimer = 0; param_2->child = this->field_0x18; param_2->carryFlags = playerEnt->base.carryFlags; diff --git a/src/object/bush.c b/src/object/bush.c index d0fbc49e..895e6747 100644 --- a/src/object/bush.c +++ b/src/object/bush.c @@ -73,7 +73,7 @@ void Bush_Init(BushEntity* this) { } void Bush_Action1(BushEntity* this) { - if (((gPlayerState.field_0x1c & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) { + if (((gPlayerState.gustJarState & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) { RestorePrevTileEntity(COORD_TO_TILE(super), super->collisionLayer); DeleteThisEntity(); } @@ -108,7 +108,7 @@ void Bush_Action2SubAction2(BushEntity* this) { super->spriteOffsetX = 0; sub_0807B9B8(this->unk_70, COORD_TO_TILE(super), super->collisionLayer); } - if (((gPlayerState.field_0x1c & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) { + if (((gPlayerState.gustJarState & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) { Bush_Action2SubAction5(this); } if (sub_0806F3E4(super) && ((super->gustJarFlags & 0xf) == 1)) { diff --git a/src/object/chuchuBossStartParticle.c b/src/object/chuchuBossStartParticle.c index ddd7032a..286c414c 100644 --- a/src/object/chuchuBossStartParticle.c +++ b/src/object/chuchuBossStartParticle.c @@ -264,7 +264,7 @@ void ChuchuBossStartParticle_Type9(ChuchuBossStartParticleEntity* this) { DeleteThisEntity(); } - if (gPlayerState.field_0x1c != 1) { + if (gPlayerState.gustJarState != 1) { DeleteThisEntity(); } } else { diff --git a/src/object/evilSpirit.c b/src/object/evilSpirit.c index a2943a52..2ab38f90 100644 --- a/src/object/evilSpirit.c +++ b/src/object/evilSpirit.c @@ -86,8 +86,9 @@ void EvilSpirit_Action1(EvilSpiritEntity* this) { CalcOffsetAngle(super->parent->x.WORD - super->x.WORD, super->parent->y.WORD - super->y.WORD) ^ 0x80; } else { super->speed = 0x600; - dir = CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^ - 0x80; + dir = + CalcOffsetAngle(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^ + 0x80; if (dir != super->direction) { if ((u8)(dir - super->direction) > 0x80) { super->direction += 3; diff --git a/src/object/gustJarParticle.c b/src/object/gustJarParticle.c index afbc0aa1..0da0d398 100644 --- a/src/object/gustJarParticle.c +++ b/src/object/gustJarParticle.c @@ -44,7 +44,7 @@ void GustJarParticle_Action1(Entity* this) { if (sub_0806F3E4(this)) { DeleteThisEntity(); - } else if ((gPlayerState.field_0x1c & 0xf) != 1) { + } else if ((gPlayerState.gustJarState & 0xf) != 1) { DeleteThisEntity(); } } diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index 0b99381d..60cfe8f2 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -91,7 +91,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) { PausePlayer(); ResetActiveItems(); gPlayerState.heldObject = 4; - gPlayerEntity.unk_74 = super; + gPlayerEntity.carriedEntity = super; gUnk_0200AF00.rActionPlayerState = R_ACTION_DROP; MessageClose(); } @@ -104,7 +104,7 @@ void ItemForSale_Action2(ItemForSaleEntity* this) { gUnk_0200AF00.rActionPlayerState = R_ACTION_DROP; super->spriteSettings.draw = gPlayerEntity.base.spriteSettings.draw; - if ((gPlayerState.heldObject == 0) || (super != gPlayerEntity.unk_74)) { + if ((gPlayerState.heldObject == 0) || (super != gPlayerEntity.carriedEntity)) { sub_080819B4(this); } else { ptr = sub_080784E4(); @@ -129,7 +129,7 @@ void sub_080819B4(ItemForSaleEntity* this) { DeleteThisEntity(); } gPlayerState.heldObject = 0; - gPlayerEntity.unk_74 = 0; + gPlayerEntity.carriedEntity = 0; ptr = &gUnk_0200AF00; gRoomVars.shopItemType = 0; ptr->rActionInteractObject = R_ACTION_NONE; diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index d90c1610..b34360a2 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -125,8 +125,8 @@ void LilypadLarge_Action1(LilypadLargeEntity* this) { this->unk_70 = 0; this->unk_6c = 0; } - if (gPlayerState.field_0x1c == 3) { - tmp = gUnk_08120620[gPlayerState.gustJarSpeed - 1]; + if (gPlayerState.gustJarState == PL_JAR_3) { + tmp = gUnk_08120620[gPlayerState.gustJarCharge - 1]; switch (gPlayerEntity.base.animationState & 6) { case 4: this->unk_70 -= tmp; @@ -154,7 +154,7 @@ void LilypadLarge_Action1(LilypadLargeEntity* this) { uVar4 = gPlayerEntity.base.y.HALF.HI + gUnk_08126EE4[gPlayerEntity.base.animationState | 1]; super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, sVar10, uVar4); - switch (gPlayerState.gustJarSpeed) { + switch (gPlayerState.gustJarCharge) { case 3: tmp = 0x400; break; diff --git a/src/object/minecart.c b/src/object/minecart.c index 30594d6d..58138b3b 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -70,7 +70,7 @@ void Minecart_Action1(MinecartEntity* this) { SoundReq(SFX_13B); } else { if (sub_0800445C(super) != 0) { - if (!((gPlayerState.flags & (PL_MINISH | PL_ROLLING)) || gPlayerState.field_0x1c || + if (!((gPlayerState.flags & (PL_MINISH | PL_ROLLING)) || gPlayerState.gustJarState || gPlayerState.heldObject || gPlayerState.jump_status)) { super->timer++; } else { diff --git a/src/object/objectA8.c b/src/object/objectA8.c index 4f602fd0..c5e95687 100644 --- a/src/object/objectA8.c +++ b/src/object/objectA8.c @@ -116,7 +116,7 @@ void ObjectA8_Action2Subaction0(ObjectA8Entity* this) { } void ObjectA8_Action2Subaction1(ObjectA8Entity* this) { - if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) { + if ((gPlayerState.gustJarState & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) { super->action = 3; } else { sub_0806F4E8(super); @@ -124,7 +124,7 @@ void ObjectA8_Action2Subaction1(ObjectA8Entity* this) { } void ObjectA8_Action2Subaction2(ObjectA8Entity* this) { - if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) { + if ((gPlayerState.gustJarState & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) { super->action = 3; } else { if (sub_0806F3E4(super)) { diff --git a/src/object/objectOnSpinyBeetle.c b/src/object/objectOnSpinyBeetle.c index fda7b417..52c575ca 100644 --- a/src/object/objectOnSpinyBeetle.c +++ b/src/object/objectOnSpinyBeetle.c @@ -204,7 +204,7 @@ void ObjectOnSpinyBeetle_Action3Subaction0(ObjectOnSpinyBeetleEntity* this) { } void ObjectOnSpinyBeetle_Action3Subaction1(ObjectOnSpinyBeetleEntity* this) { - if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) { + if ((gPlayerState.gustJarState & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) { super->spriteOffsetX = 0; super->action = 1; } else { @@ -219,7 +219,7 @@ void ObjectOnSpinyBeetle_Action3Subaction2(ObjectOnSpinyBeetleEntity* this) { super->spriteOffsetY = -2; (super->parent)->child = NULL; } - if ((gPlayerState.field_0x1c & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) { + if ((gPlayerState.gustJarState & 0xf) != 1 || (super->contactFlags & 0x7f) != 0x13) { sub_080989C0(this); } else { if ((sub_0806F3E4(super) != 0) && (super->type == 0)) { @@ -229,7 +229,7 @@ void ObjectOnSpinyBeetle_Action3Subaction2(ObjectOnSpinyBeetleEntity* this) { } void ObjectOnSpinyBeetle_Action3Subaction3(ObjectOnSpinyBeetleEntity* this) { - if (gPlayerState.field_0x1c == 0) { + if (gPlayerState.gustJarState == 0) { sub_080989C0(this); } else { (this->base).flags &= ~ENT_COLLIDE; diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index bc77267c..075c858f 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -182,7 +182,7 @@ void OctorokBossObject_Action1(OctorokBossObjectEntity* this) { } case 1: super->direction = CalcOffsetAngle(this->helper->tailObjects[super->timer]->x.WORD - super->x.WORD, - this->helper->tailObjects[super->timer]->y.WORD - super->y.WORD); + this->helper->tailObjects[super->timer]->y.WORD - super->y.WORD); LinearMoveAngle(super, super->speed, super->direction); if (EntityInRectRadius(super, this->helper->tailObjects[super->timer], 2, 2) == 0) { return; diff --git a/src/object/pot.c b/src/object/pot.c index 444c14bb..150705f2 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -250,7 +250,7 @@ void sub_080826FC(PotEntity* this) { } void sub_0808270C(PotEntity* this) { - if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { + if ((gPlayerState.gustJarState & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { super->spriteOffsetX = 0; super->action = 1; SetBottomTile(0x4000, COORD_TO_TILE(super), super->collisionLayer); @@ -267,7 +267,7 @@ void sub_08082778(PotEntity* this) { SetBottomTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); } - if ((gPlayerState.field_0x1c & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { + if ((gPlayerState.gustJarState & 0xF) != 0x1 || (super->contactFlags & 0x7F) != 0x13) { BreakPot(this, NULL); } else { sub_0806F3E4(super); @@ -275,7 +275,7 @@ void sub_08082778(PotEntity* this) { } void sub_080827F8(PotEntity* this) { - if (gPlayerState.field_0x1c == 0) { + if (gPlayerState.gustJarState == 0) { BreakPot(this, NULL); } } diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c index de90f11d..17333ae3 100644 --- a/src/object/pullableMushroom.c +++ b/src/object/pullableMushroom.c @@ -65,7 +65,7 @@ void PullableMushroom_Init(PullableMushroomEntity* this) { super->hitType = 0x6e; super->collisionMask = 0x0e; super->gustJarFlags = 1; - super->flags |= 0x80; + COLLISION_ON(super); super->spriteOffsetY = 4; break; case 1: @@ -116,13 +116,14 @@ void PullableMushroom_Action1_Type0(PullableMushroomEntity* this) { } void PullableMushroom_Action1_Type1(PullableMushroomEntity* this) { - if (*(u16*)&super->parent->action == 0x201) { + if (super->parent->action == 1 && super->parent->subAction == 2) { super->parent->child = NULL; DeleteThisEntity(); } else if (super->parent->action == 2) { sub_0808B168(this, 0); } } + void sub_0808ABC4(PullableMushroomEntity* this) { static const s8 gUnk_081211CC[] = { 0, -128, 0, -6, 0, 0, 5, -4, 0, 0, 0, 0, 0, -128, -5, -4 }; u32 tmp; @@ -292,7 +293,7 @@ void sub_0808AEB0(PullableMushroomEntity* this) { this->unk_7c = 1; super->animationState = AnimationStateFlip90(gPlayerEntity.base.animationState >> 1); super->direction = (super->animationState << 3); - super->flags &= ~0x80; + COLLISION_OFF(super); super->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; InitializeAnimation(super, super->animationState + 5); if (sub_0808B21C(this, 0)) { @@ -320,7 +321,7 @@ void PullableMushroom_Action3(PullableMushroomEntity* this) { }; funcs[super->subAction](this); - if ((((gPlayerState.field_0x1c & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) && (super->type == 1)) { + if ((((gPlayerState.gustJarState & 0xf) != 1) || ((super->contactFlags & 0x7f) != 0x13)) && (super->type == 1)) { (super->parent)->action = 1; (super->parent)->subAction = 1; super->direction = DirectionTurnAround(super->parent->direction); @@ -336,7 +337,7 @@ void sub_0808B05C(PullableMushroomEntity* this) { super->animationState = AnimationStateFlip90(gPlayerEntity.base.animationState >> 1); super->direction = super->animationState << 3; super->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; - super->flags &= ~0x80; + COLLISION_OFF(super); InitializeAnimation(super, super->animationState + 5); if (sub_0808B21C(this, 1)) { sub_0808B168((PullableMushroomEntity*)super->child, 1); diff --git a/src/physics.c b/src/physics.c index 421c2474..7daea2e3 100644 --- a/src/physics.c +++ b/src/physics.c @@ -55,16 +55,16 @@ bool32 sub_0806F3E4(Entity* ent) { GenericEntity tmp_ent; s8* p; - if ((gPlayerState.field_0x1c & 0x7F) != 1) + if ((gPlayerState.gustJarState & 0x7F) != PL_JAR_SUCK) return 0; - switch (gPlayerState.gustJarSpeed) { - case 1: + switch (gPlayerState.gustJarCharge) { + case JAR_CHARGE_SMALL: ent->knockbackSpeed += 64; break; - case 2: + case JAR_CHARGE_MID: ent->knockbackSpeed += 128; break; - case 3: + case JAR_CHARGE_BIG: ent->knockbackSpeed += 192; break; } @@ -76,18 +76,18 @@ bool32 sub_0806F3E4(Entity* ent) { LinearMoveDirection(ent, ent->knockbackSpeed, GetFacingDirection(ent, &tmp_ent.base)); if (sub_0800419C(&tmp_ent.base, ent, 4, 4)) { u32 state = ent->gustJarFlags & 0xF; - if (state == 2) { + if (state == PL_JAR_2) { Entity* item; ent->subAction = 3; - gPlayerEntity.unk_70 = ent; - gPlayerState.field_0x1c = 7; + gPlayerEntity.pulledJarEntity = ent; + gPlayerState.gustJarState = PL_JAR_ENT_ATTACHED; item = CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0); if (item != NULL) { item->child = ent; ent->parent = item; } SoundReq(SFX_ED); - } else if (state == 1) { + } else if (state == PL_JAR_SUCK) { gPlayerState.item->type = 1; SoundReq(SFX_EF); } diff --git a/src/player.c b/src/player.c index 303bc8ff..2ffa311e 100644 --- a/src/player.c +++ b/src/player.c @@ -424,7 +424,7 @@ static void PlayerNormal(PlayerEntity* this) { } else { if (gPlayerState.sword_state) { super->speed = kWalkSpeedSwordCharge; - } else if (gPlayerState.field_0x1c) { + } else if (gPlayerState.gustJarState != PL_JAR_NONE) { super->speed = kWalkSpeedGustJar; } else { super->speed = kWalkSpeed; @@ -890,8 +890,8 @@ static void sub_08071130(PlayerEntity* this) { gPlayerState.jump_status = 0; ResetCollisionLayer(super); - if (this->unk_74 != NULL) - ResetCollisionLayer(this->unk_74); + if (this->carriedEntity != NULL) + ResetCollisionLayer(this->carriedEntity); DoTileInteractionHere(super, 7); @@ -1982,7 +1982,7 @@ static void sub_080724DC(PlayerEntity* this) { if (gRoomControls.reload_flags == 0) { super->updatePriority = super->updatePriorityPrev; PlayerWaitForScroll(this); - } else if (gPlayerState.field_0x1c == 0) { + } else if (gPlayerState.gustJarState == PL_JAR_NONE) { UpdateAnimationSingleFrame(super); } } else { diff --git a/src/playerItem/playerItemGust.c b/src/playerItem/playerItemGust.c index 94fd1bdb..286c06f3 100644 --- a/src/playerItem/playerItemGust.c +++ b/src/playerItem/playerItemGust.c @@ -61,7 +61,7 @@ void PlayerItemGust(Entity* this) { PlayerItemGust_Update, }; - if ((gPlayerState.field_0x1c & 0x7f) != 1) { + if ((gPlayerState.gustJarState & 0x7f) != 1) { DeleteThisEntity(); } PlayerItemGust_Actions[this->action]((PlayerItemGustEntity*)this); diff --git a/src/playerItem/playerItemGustBig.c b/src/playerItem/playerItemGustBig.c index 228ca1a3..566ef948 100644 --- a/src/playerItem/playerItemGustBig.c +++ b/src/playerItem/playerItemGustBig.c @@ -85,7 +85,7 @@ void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this) { super->child->spriteOffsetX = 0; super->child->spriteSettings.draw = 0; } else { - if (gPlayerState.field_0x1c == 0) { + if (gPlayerState.gustJarState == PL_JAR_NONE) { DeleteThisEntity(); } super->action = 2; @@ -93,14 +93,14 @@ void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this) { super->spriteIndex = 0xa6; super->palette.raw = 0x33; super->spriteVramOffset = 0; - super->type = gPlayerState.gustJarSpeed - 1; + super->type = gPlayerState.gustJarCharge - 1; super->timer = gUnk_080B3DE0[super->type * 2]; super->damage = gUnk_080B3DE0[super->type * 2 + 1]; super->hurtType = 0x1b; super->hitbox = (Hitbox*)gUnk_080B3DE8[super->type]; - gPlayerEntity.unk_70 = super; + gPlayerEntity.pulledJarEntity = super; sub_08078CD0(&gPlayerEntity.base); - gPlayerEntity.unk_70 = pEVar3; + gPlayerEntity.pulledJarEntity = pEVar3; InitializeAnimation(super, super->type + 10); sub_08018FA0(super); } @@ -108,18 +108,15 @@ void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this) { } void PlayerItemGustBig_Action1(PlayerItemGustBigEntity* this) { - u8 bVar1; - - bVar1 = super->child->gustJarState & 4; - if (bVar1 == 0) { - gPlayerState.field_0x1c = bVar1; + if ((super->child->gustJarState & 4) == 0) { + gPlayerState.gustJarState = PL_JAR_NONE; DeleteThisEntity(); } - switch (gPlayerState.field_0x1c) { - case 0: + switch (gPlayerState.gustJarState) { + case PL_JAR_NONE: PlayerItemGustBig_Action3(this); break; - case 5: + case PL_JAR_BLAST_UPDATE: super->child->subAction = 4; COLLISION_ON(super); super->action = 2; diff --git a/src/playerItem/playerItemGustJar.c b/src/playerItem/playerItemGustJar.c index b3ebcb29..10cbca1b 100644 --- a/src/playerItem/playerItemGustJar.c +++ b/src/playerItem/playerItemGustJar.c @@ -29,7 +29,7 @@ void PlayerItemGustJar(Entity* this) { PlayerItemGustJar_Action3, PlayerItemGustJar_Action4, }; - if (((Entity*)gPlayerState.item != this) || (gPlayerState.field_0x1c == 0)) { + if (((Entity*)gPlayerState.item != this) || (gPlayerState.gustJarState == PL_JAR_NONE)) { DeleteThisEntity(); } PlayerItemGustJar_Actions[this->action](this); @@ -63,10 +63,10 @@ void PlayerItemGustJar_Action2(Entity* this) { u32 in_r2; int windSound; - if (gPlayerState.field_0x1c == 3) { + if (gPlayerState.gustJarState == PL_JAR_3) { this->action++; InitAnimationForceUpdate(this, (gPlayerEntity.base.animationState >> 1) + 8); - } else if (gPlayerState.field_0x1c == 6) { + } else if (gPlayerState.gustJarState == PL_JAR_BLAST_DONE) { this->action = 4; InitAnimationForceUpdate(this, (gPlayerEntity.base.animationState >> 1) + 4); } else { @@ -84,11 +84,11 @@ void PlayerItemGustJar_Action2(Entity* this) { } } } else { - if ((gPlayerState.field_0x1c & 0xf) == 7) { + if ((gPlayerState.gustJarState & 0xf) == PL_JAR_ENT_ATTACHED) { this->frameDuration = 0x7f; } - switch (gPlayerState.gustJarSpeed) { + switch (gPlayerState.gustJarCharge) { case 3: sub_080ADCDC(this, 3); this->palette.b.b0 = 0; @@ -109,7 +109,7 @@ void PlayerItemGustJar_Action2(Entity* this) { break; } - if ((gPlayerState.field_0x1c & 0xf) == 7) { + if ((gPlayerState.gustJarState & 0xf) == PL_JAR_ENT_ATTACHED) { windSound = SFX_EE; in_r2 = 1; } @@ -126,12 +126,12 @@ void PlayerItemGustJar_Action2(Entity* this) { } void PlayerItemGustJar_Action3(Entity* this) { - switch (gPlayerState.field_0x1c & 0xf) { - case 6: + switch (gPlayerState.gustJarState & 0xf) { + case PL_JAR_BLAST_DONE: this->action++; InitAnimationForceUpdate(this, (gPlayerEntity.base.animationState >> 1) + 4); break; - case 1: + case PL_JAR_SUCK: sub_080ADCA0(this, 0); this->action = 2; break; diff --git a/src/playerItem/playerItemHeldObject.c b/src/playerItem/playerItemHeldObject.c index 520d8359..f20236d4 100644 --- a/src/playerItem/playerItemHeldObject.c +++ b/src/playerItem/playerItemHeldObject.c @@ -235,7 +235,7 @@ void sub_080AD27C(PlayerItemHeldObjectEntity* this) { static const u32 gUnk_081320D4[] = { Q_16_16(0), Q_16_16(0.5), Q_16_16(1.25), Q_16_16(1.25) }; u32 tmp; PlayerItemHeldObjectEntity* child = (PlayerItemHeldObjectEntity*)super->child; - gPlayerEntity.unk_74 = NULL; + gPlayerEntity.carriedEntity = NULL; if ((this->unk_6c == (u16)(child->base).kind) && (this->unk_6e == (u16)(child->base).id)) { if (child != this) { (child->base).subAction = 2; diff --git a/src/playerUtils.c b/src/playerUtils.c index 85656344..ba020870 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -229,7 +229,7 @@ bool32 IsPreventedFromUsingItem(void) { } return FALSE; default: - if ((((gUnk_0200AF00.rActionInteractObject == R_ACTION_ROLL) && (gPlayerState.field_0x1c == 0)) && + if ((((gUnk_0200AF00.rActionInteractObject == R_ACTION_ROLL) && (gPlayerState.gustJarState == 0)) && (gPlayerState.floor_type != SURFACE_SWAMP)) && ((((gPlayerState.playerInput.heldInput & INPUT_ANY_DIRECTION) != 0 && ((gPlayerState.flags & (PL_BURNING | PL_ROLLING)) == 0)) && @@ -339,7 +339,7 @@ ItemBehavior* CreateItem3(Item itemId) { gItemDefinitions[itemId].priority >= gActiveItems[ACTIVE_ITEM_0].priority) { DeleteItemBehavior(&gActiveItems[ACTIVE_ITEM_0], 0); gPlayerState.grab_status = 0; - gPlayerState.field_0x1c = 0; + gPlayerState.gustJarState = 0; gPlayerState.sword_state = 0; return &gActiveItems[ACTIVE_ITEM_0]; } @@ -395,7 +395,7 @@ void ResetActiveItems() { } gPlayerState.moleMittsState = 0; - gPlayerState.field_0x1c = 0; + gPlayerState.gustJarState = PL_JAR_NONE; gPlayerState.bow_state = 0; gPlayerState.grab_status = 0; gPlayerState.itemAnimPriority = 0; @@ -405,7 +405,7 @@ void ResetActiveItems() { gPlayerState.heldObject = 0; gPlayerState.flags &= ~(PL_ROLLING | PL_SWORD_THRUST); - gPlayerEntity.unk_70 = NULL; + gPlayerEntity.pulledJarEntity = NULL; if ((gPlayerState.jump_status & 0xc0) == 0) { gPlayerState.jump_status = 0; @@ -1104,7 +1104,8 @@ bool32 sub_080782C0(void) { if (gPlayerState.heldObject != 4) { return FALSE; } - if ((gPlayerEntity.unk_74)->child->kind != OBJECT || (gPlayerEntity.unk_74)->child->id != SHOP_ITEM) { + if ((gPlayerEntity.carriedEntity)->child->kind != OBJECT || + (gPlayerEntity.carriedEntity)->child->id != SHOP_ITEM) { return FALSE; } } @@ -1580,7 +1581,7 @@ void sub_08078CD0(PlayerEntity* this) { u32 tmp; const s8* ptr; - entity = this->unk_70; + entity = this->pulledJarEntity; entity->z.HALF.HI = super->z.HALF.HI - 1; entity->spriteOrientation.flipY = super->spriteOrientation.flipY; entity->collisionLayer = super->collisionLayer; @@ -1605,7 +1606,7 @@ void sub_08078D60(void) { Entity* player; player = &gPlayerEntity.base; - iVar4 = (*(Entity**)&((GenericEntity*)player)->field_0x74)->child; + iVar4 = ((PlayerEntity*)player)->carriedEntity->child; if (iVar4->action != 2) return; @@ -1815,7 +1816,7 @@ void sub_080790E4(Entity* this) { void PlayerDropHeldObject(void) { gPlayerState.heldObject = 0; gPlayerState.grab_status = 0; - gPlayerEntity.unk_74 = NULL; + gPlayerEntity.carriedEntity = NULL; } void PlayerResetStateFromFusion(void) { @@ -2109,7 +2110,7 @@ void sub_080797EC(void) { animation = ANIM_BOW_WALK; } } else { - if (gPlayerState.field_0x1c) { + if (gPlayerState.gustJarState) { return; } else if (gPlayerState.heldObject) { animation = ANIM_CARRY; @@ -2166,7 +2167,7 @@ void ResolvePlayerAnimation(void) { if (gPlayerState.heldObject) { anim = ANIM_CARRY_STAND_NOCAP; } else { - if (gPlayerState.field_0x1c | gPlayerState.moleMittsState) { + if (gPlayerState.gustJarState | gPlayerState.moleMittsState) { return; } if (gPlayerState.flags & PL_CONVEYOR_PUSHED) { @@ -2209,7 +2210,7 @@ void ResolvePlayerAnimation(void) { if (gPlayerState.heldObject) { anim = ANIM_CARRY_STAND; } else { - if (gPlayerState.field_0x1c | gPlayerState.moleMittsState) { + if (gPlayerState.gustJarState | gPlayerState.moleMittsState) { return; } if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) { @@ -2722,7 +2723,7 @@ void sub_0807A5B8(u32 direction) { pbVar4 = gUnk_0800833C; } else if (((gPlayerState.flags & PL_PARACHUTE) != 0) || gPlayerState.jump_status != 0) { pbVar4 = gUnk_0800845C; - } else if (gPlayerState.heldObject != 0 || gPlayerState.field_0x1c != 0) { + } else if (gPlayerState.heldObject != 0 || gPlayerState.gustJarState != 0) { pbVar4 = gUnk_080084BC; } else if (gPlayerState.attachedBeetleCount != 0) { pbVar4 = gUnk_0800851C;