diff --git a/asm/beanstalkSubtask.s b/asm/beanstalkSubtask.s index 7690074a..f58e52af 100644 --- a/asm/beanstalkSubtask.s +++ b/asm/beanstalkSubtask.s @@ -154,23 +154,23 @@ sub_080197A0: @ 0x080197A0 thumb_func_start SetBGDefaults SetBGDefaults: @ 0x080197AC - ldr r0, _080197C4 @ =gUnk_02025EB0 + ldr r0, _080197C4 @ =gMapBottom ldr r1, _080197C8 @ =gBGAffSettings str r1, [r0] ldr r2, _080197CC @ =gUnk_080B77C0 ldrh r0, [r2] strh r0, [r1] - ldr r0, _080197D0 @ =gUnk_0200B650 + ldr r0, _080197D0 @ =gMapTop subs r1, #0xc str r1, [r0] ldrh r0, [r2, #2] strh r0, [r1] bx lr .align 2, 0 -_080197C4: .4byte gUnk_02025EB0 +_080197C4: .4byte gMapBottom _080197C8: .4byte gScreen + 0x20 _080197CC: .4byte gUnk_080B77C0 -_080197D0: .4byte gUnk_0200B650 +_080197D0: .4byte gMapTop thumb_func_start sub_080197D4 sub_080197D4: @ 0x080197D4 @@ -1061,7 +1061,7 @@ _08019E54: lsls r1, r7, #1 cmp r0, #3 bne _08019E84 - ldr r0, _08019E7C @ =gUnk_0200B650 + ldr r0, _08019E7C @ =gMapTop adds r0, #4 adds r2, r1, r0 ldrh r0, [r2] @@ -1075,7 +1075,7 @@ _08019E54: mov sb, r5 b _08019E98 .align 2, 0 -_08019E7C: .4byte gUnk_0200B650 +_08019E7C: .4byte gMapTop _08019E80: .4byte 0x0000400C _08019E84: mov r0, r8 @@ -1705,7 +1705,7 @@ _0801A32C: asrs r2, r2, #0x10 adds r0, r3, #0 adds r3, r6, #0 - bl sub_080AE4CC + bl IsTileCollision cmp r0, #0 bne _0801A36C movs r0, #1 @@ -1901,7 +1901,7 @@ _0801A4B0: adds r2, r2, r0 adds r0, r3, #0 mov r3, r8 - bl sub_080AE4CC + bl IsTileCollision cmp r0, #0 bne _0801A4F0 ldrb r0, [r5] @@ -2741,7 +2741,7 @@ sub_0801AB08: @ 0x0801AB08 sub sp, #8 adds r5, r0, #0 mov r8, r1 - ldr r0, _0801AB4C @ =gUnk_02025EB0 + ldr r0, _0801AB4C @ =gMapBottom movs r1, #2 cmp r8, r0 bne _0801AB22 @@ -2770,7 +2770,7 @@ _0801AB40: lsls r0, r0, #2 b _0801AB64 .align 2, 0 -_0801AB4C: .4byte gUnk_02025EB0 +_0801AB4C: .4byte gMapBottom _0801AB50: .4byte 0x00003004 _0801AB54: .4byte 0x00003FFF _0801AB58: @@ -3228,14 +3228,14 @@ _0801AEB6: ands r0, r1 cmp r0, #0 bne _0801AF0C - ldr r1, _0801AEFC @ =gUnk_02025EB0 + ldr r1, _0801AEFC @ =gMapBottom ldr r0, [r1] cmp r0, #0 beq _0801AED0 ldr r0, _0801AF00 @ =gUnk_02019EE0 bl sub_0801AB08 _0801AED0: - ldr r1, _0801AF04 @ =gUnk_0200B650 + ldr r1, _0801AF04 @ =gMapTop ldr r0, [r1] cmp r0, #0 beq _0801AF10 @@ -3250,9 +3250,9 @@ _0801AEEC: .4byte 0x0600F000 _0801AEF0: .4byte gUnk_03004030 _0801AEF4: .4byte 0x0000088C _0801AEF8: .4byte 0x00000888 -_0801AEFC: .4byte gUnk_02025EB0 +_0801AEFC: .4byte gMapBottom _0801AF00: .4byte gUnk_02019EE0 -_0801AF04: .4byte gUnk_0200B650 +_0801AF04: .4byte gMapTop _0801AF08: .4byte gMapDataTopSpecial _0801AF0C: bl sub_0807C4F8 diff --git a/asm/code_080043E8.s b/asm/code_080043E8.s index ab9b0456..61b1d53c 100644 --- a/asm/code_080043E8.s +++ b/asm/code_080043E8.s @@ -119,10 +119,10 @@ sub_080044AE: @ 0x080044AE push {r0, r1, r2} adds r1, r2, #0 movs r2, #2 - bl sub_080AE58C + bl CalculateEntityTileCollisions pop {r0, r1, r2} movs r3, #2 - bl sub_080AE7E8 + bl ProcessMovementInternal _080044C8: pop {r3} bx r3 diff --git a/asm/code_080526F8.s b/asm/code_080526F8.s index 664372c4..9a00adcf 100644 --- a/asm/code_080526F8.s +++ b/asm/code_080526F8.s @@ -261,9 +261,9 @@ sub_08053758: @ 0x08053758 strb r4, [r1, #0x10] ldr r0, _080537E0 @ =gUnk_02032EC0 strb r3, [r0, #6] - ldr r0, _080537E4 @ =gUnk_02025EB0 + ldr r0, _080537E4 @ =gMapBottom str r2, [r0] - ldr r0, _080537E8 @ =gUnk_0200B650 + ldr r0, _080537E8 @ =gMapTop str r2, [r0] ldr r0, _080537EC @ =gRoomControls str r2, [r0, #0x30] @@ -311,8 +311,8 @@ sub_08053758: @ 0x08053758 .align 2, 0 _080537DC: .4byte gMenu _080537E0: .4byte gUnk_02032EC0 -_080537E4: .4byte gUnk_02025EB0 -_080537E8: .4byte gUnk_0200B650 +_080537E4: .4byte gMapBottom +_080537E8: .4byte gMapTop _080537EC: .4byte gRoomControls _080537F0: .4byte gScreen _080537F4: .4byte 0x00002244 diff --git a/asm/code_08078778.s b/asm/code_08078778.s index b5c2c7e6..dfdd37f6 100644 --- a/asm/code_08078778.s +++ b/asm/code_08078778.s @@ -5741,7 +5741,7 @@ SetTileType: @ 0x0807B314 ands r0, r1 cmp r0, #0 beq _0807B36C - ldr r0, _0807B3B4 @ =gUnk_02025EB0 + ldr r0, _0807B3B4 @ =gMapBottom ldr r1, _0807B3AC @ =0x00002004 adds r0, r0, r1 adds r0, r4, r0 @@ -5778,7 +5778,7 @@ _0807B3A4: .4byte 0x00006004 _0807B3A8: .4byte gUnk_080B3E80 _0807B3AC: .4byte 0x00002004 _0807B3B0: .4byte gRoomControls -_0807B3B4: .4byte gUnk_02025EB0 +_0807B3B4: .4byte gMapBottom _0807B3B8: .4byte 0x0000B004 _0807B3BC: .4byte gUnk_080B37A0 _0807B3C0: .4byte gUnk_02019EE0 diff --git a/asm/code_0807B9B8.s b/asm/code_0807B9B8.s index 33b19f0b..0326f133 100644 --- a/asm/code_0807B9B8.s +++ b/asm/code_0807B9B8.s @@ -967,7 +967,7 @@ LoadRoomGfx: @ 0x0807C0DC ldr r0, [r0] ldr r0, [r0, #0xc] bl sub_080197D4 - ldr r2, _0807C170 @ =gUnk_02025EB0 + ldr r2, _0807C170 @ =gMapBottom ldrh r1, [r2, #4] ldr r0, _0807C174 @ =0x0000FFFF cmp r1, r0 @@ -994,7 +994,7 @@ _0807C160: .4byte gUnk_02019EE0 _0807C164: .4byte gMapDataTopSpecial _0807C168: .4byte gArea _0807C16C: .4byte 0x0000085C -_0807C170: .4byte gUnk_02025EB0 +_0807C170: .4byte gMapBottom _0807C174: .4byte 0x0000FFFF _0807C178: adds r0, r2, #4 @@ -1129,10 +1129,10 @@ _0807C280: bl sub_0807C460 _0807C2A0: bl sub_0807BC84 - ldr r4, _0807C2D4 @ =gUnk_02025EB0 + ldr r4, _0807C2D4 @ =gMapBottom adds r0, r4, #0 bl sub_08080B60 - ldr r5, _0807C2D8 @ =gUnk_0200B650 + ldr r5, _0807C2D8 @ =gMapTop adds r0, r5, #0 bl sub_08080B60 mov r3, sb @@ -1148,8 +1148,8 @@ _0807C2A0: .align 2, 0 _0807C2CC: .4byte gUnk_02027EB4 _0807C2D0: .4byte gUnk_0200D654 -_0807C2D4: .4byte gUnk_02025EB0 -_0807C2D8: .4byte gUnk_0200B650 +_0807C2D4: .4byte gMapBottom +_0807C2D8: .4byte gMapTop _0807C2DC: .4byte gUnk_02019EE0 _0807C2E0: .4byte gMapDataTopSpecial _0807C2E4: @@ -1233,7 +1233,7 @@ _0807C358: @ jump table .4byte _0807C400 @ case 23 .4byte _0807C3E4 @ case 24 _0807C3BC: - ldr r0, _0807C3D8 @ =gUnk_02025EB0 + ldr r0, _0807C3D8 @ =gMapBottom ldr r2, [r0] cmp r2, #0 beq _0807C3CC @@ -1249,11 +1249,11 @@ _0807C3CC: strh r0, [r2] b _0807C444 .align 2, 0 -_0807C3D8: .4byte gUnk_02025EB0 +_0807C3D8: .4byte gMapBottom _0807C3DC: .4byte gScreen _0807C3E0: .4byte 0x0000FDFF _0807C3E4: - ldr r0, _0807C3F8 @ =gUnk_0200B650 + ldr r0, _0807C3F8 @ =gMapTop ldr r1, [r0] cmp r1, #0 beq _0807C3F2 @@ -1264,10 +1264,10 @@ _0807C3F2: bl sub_0807C5B0 b _0807C444 .align 2, 0 -_0807C3F8: .4byte gUnk_0200B650 +_0807C3F8: .4byte gMapTop _0807C3FC: .4byte gUnk_080B77C0 _0807C400: - ldr r0, _0807C44C @ =gUnk_02025EB0 + ldr r0, _0807C44C @ =gMapBottom ldr r1, [r0] cmp r1, #0 beq _0807C40E @@ -1275,7 +1275,7 @@ _0807C400: ldrh r0, [r0] strh r0, [r1] _0807C40E: - ldr r0, _0807C454 @ =gUnk_0200B650 + ldr r0, _0807C454 @ =gMapTop ldr r1, [r0] cmp r1, #0 beq _0807C41C @@ -1309,9 +1309,9 @@ _0807C444: mov sb, r4 pop {r4, r5, r6, r7, pc} .align 2, 0 -_0807C44C: .4byte gUnk_02025EB0 +_0807C44C: .4byte gMapBottom _0807C450: .4byte gUnk_080B77C0 -_0807C454: .4byte gUnk_0200B650 +_0807C454: .4byte gMapTop _0807C458: .4byte gScreen _0807C45C: .4byte gArea diff --git a/asm/code_0808091C.s b/asm/code_0808091C.s index 5ab71ebf..db7a753c 100755 --- a/asm/code_0808091C.s +++ b/asm/code_0808091C.s @@ -206,7 +206,7 @@ sub_08080BC4: @ 0x08080BC4 adds r0, r0, r2 ldr r1, _08080C44 @ =gUnk_080169A4 adds r2, r0, r1 - ldr r4, _08080C48 @ =gUnk_02025EB0 + ldr r4, _08080C48 @ =gMapBottom ldr r1, [r4] cmp r1, #0 beq _08080C16 @@ -220,7 +220,7 @@ sub_08080BC4: @ 0x08080BC4 adds r0, r0, r6 strh r0, [r1, #4] _08080C16: - ldr r4, _08080C4C @ =gUnk_0200B650 + ldr r4, _08080C4C @ =gMapTop ldr r1, [r4] cmp r1, #0 beq _08080C30 @@ -245,10 +245,10 @@ _08080C30: .align 2, 0 _08080C40: .4byte gRoomControls _08080C44: .4byte gUnk_080169A4 -_08080C48: .4byte gUnk_02025EB0 -_08080C4C: .4byte gUnk_0200B650 +_08080C48: .4byte gMapBottom +_08080C4C: .4byte gMapTop _08080C50: - ldr r0, _08080C78 @ =gUnk_02025EB0 + ldr r0, _08080C78 @ =gMapBottom ldr r1, [r0] cmp r1, #0 beq _08080C5E @@ -256,7 +256,7 @@ _08080C50: ldr r0, [r0] strh r6, [r0, #4] _08080C5E: - ldr r0, _08080C7C @ =gUnk_0200B650 + ldr r0, _08080C7C @ =gMapTop ldr r1, [r0] cmp r1, #0 beq _08080C6C @@ -272,8 +272,8 @@ _08080C6C: _08080C76: pop {r4, r5, r6, pc} .align 2, 0 -_08080C78: .4byte gUnk_02025EB0 -_08080C7C: .4byte gUnk_0200B650 +_08080C78: .4byte gMapBottom +_08080C7C: .4byte gMapTop thumb_func_start sub_08080C80 sub_08080C80: @ 0x08080C80 diff --git a/asm/enemy.s b/asm/enemy.s index 25f67759..4bada3c6 100644 --- a/asm/enemy.s +++ b/asm/enemy.s @@ -74,8 +74,8 @@ _0800123E: ldr r3, _08001360 @ =CreateItemOnGround bx r3 - non_word_aligned_thumb_func_start sub_08001242 -sub_08001242: @ 0x08001242 + non_word_aligned_thumb_func_start GenericConfused +GenericConfused: @ 0x08001242 push {lr} movs r1, #0x43 ldrb r2, [r0, r1] @@ -199,18 +199,18 @@ sub_08001318: @ 0x08001318 movs r1, #0x36 ldrsh r1, [r0, r1] cmp r1, #0 - bpl sub_08001324 + bpl GenericKnockback movs r2, #0xff strb r2, [r0, #0x15] - thumb_func_start sub_08001324 -sub_08001324: @ 0x08001324 - ldr r3, _08001370 @ =sub_080AF18C + thumb_func_start GenericKnockback +GenericKnockback: @ 0x08001324 + ldr r3, _08001370 @ =Knockback1 bx r3 - thumb_func_start sub_08001328 -sub_08001328: @ 0x08001328 - ldr r3, _08001374 @ =sub_080AF1BC + thumb_func_start GenericKnockback2 +GenericKnockback2: @ 0x08001328 + ldr r3, _08001374 @ =Knockback2 bx r3 thumb_func_start sub_0800132C @@ -245,6 +245,6 @@ _08001360: .4byte CreateItemOnGround _08001364: .4byte 0x00001800 _08001368: .4byte gUnk_080012C8 _0800136C: .4byte gUnk_080012C8 -_08001370: .4byte sub_080AF18C -_08001374: .4byte sub_080AF1BC +_08001370: .4byte Knockback1 +_08001374: .4byte Knockback2 _08001378: .4byte GetFacingDirection diff --git a/asm/enemy/chuchuBoss.s b/asm/enemy/chuchuBoss.s index 3d5bfb57..c14282fe 100644 --- a/asm/enemy/chuchuBoss.s +++ b/asm/enemy/chuchuBoss.s @@ -6,8 +6,8 @@ .text - thumb_func_start sub_08025CD4 -sub_08025CD4: @ 0x08025CD4 + thumb_func_start ChuchuBoss_OnDeath +ChuchuBoss_OnDeath: @ 0x08025CD4 push {r4, r5, lr} adds r4, r0, #0 bl sub_08078B48 @@ -90,7 +90,7 @@ _08025D28: lsls r0, r0, #1 bl SoundReq adds r0, r4, #0 - bl sub_0804A7D4 + bl GenericDeath b _08025D9C .align 2, 0 _08025D80: .4byte gUnk_02034490 @@ -127,8 +127,8 @@ _08025DBC: pop {r4, r5, pc} .align 2, 0 - thumb_func_start sub_08025DC0 -sub_08025DC0: @ 0x08025DC0 + thumb_func_start ChuchuBoss_OnTick +ChuchuBoss_OnTick: @ 0x08025DC0 push {lr} ldr r2, _08025DD4 @ =gUnk_080CC1B0 ldrb r1, [r0, #0xc] @@ -246,7 +246,7 @@ _08025E86: bne _08025EAA _08025EA2: adds r0, r5, #0 - bl sub_0804A7D4 + bl GenericDeath b _0802605E _08025EAA: ldr r0, [r4] @@ -1374,7 +1374,7 @@ _0802670A: bl SoundReq _08026726: adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 _0802672C: adds r0, r4, #0 adds r0, #0x76 @@ -1556,7 +1556,7 @@ sub_0802686C: @ 0x0802686C cmp r5, #0 beq _08026888 adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 b _080268BE _08026888: movs r0, #0x10 @@ -2929,7 +2929,7 @@ _080270D4: ldrb r0, [r0, #0xc] strb r0, [r5, #0x15] adds r0, r5, #0 - bl ProcessMovement + bl ProcessMovement0 _080270E0: adds r0, r6, #0 adds r0, #0x85 @@ -2989,7 +2989,7 @@ _08027110: b _080271FE _0802714A: adds r0, r5, #0 - bl ProcessMovement + bl ProcessMovement0 b _080271FE _08027152: adds r0, r6, #0 diff --git a/asm/enemy/cloudPiranha.s b/asm/enemy/cloudPiranha.s index a8ea962d..b3d9f0d2 100644 --- a/asm/enemy/cloudPiranha.s +++ b/asm/enemy/cloudPiranha.s @@ -46,11 +46,11 @@ sub_08038468: @ 0x08038468 beq _0803847C adds r0, r4, #0 movs r1, #0x1c - bl sub_0804A9FC + bl Create0x68FX _0803847C: ldr r1, _080384B0 @ =gUnk_080CF4F0 adds r0, r4, #0 - bl sub_0804AA30 + bl EnemyFunctionHandlerAfterCollision adds r0, r4, #0 adds r0, #0x41 ldrb r1, [r0] @@ -601,7 +601,7 @@ _08038890: cmp r0, #0 bne _080388A8 adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 b _080388B2 _080388A8: subs r0, #1 diff --git a/asm/enemy/dust.s b/asm/enemy/dust.s index 03c757ba..b91ea514 100644 --- a/asm/enemy/dust.s +++ b/asm/enemy/dust.s @@ -39,7 +39,7 @@ _08044148: .4byte gUnk_080D15A0 sub_0804414C: @ 0x0804414C push {lr} ldr r1, _08044158 @ =gUnk_080D1588 - bl sub_0804AA30 + bl EnemyFunctionHandlerAfterCollision pop {pc} .align 2, 0 _08044158: .4byte gUnk_080D1588 @@ -113,7 +113,7 @@ sub_080441CC: @ 0x080441CC cmp r0, #0 beq _080441DE adds r0, r4, #0 - bl sub_0804A7D4 + bl GenericDeath _080441DE: pop {r4, pc} diff --git a/asm/enemy/enemy4D.s b/asm/enemy/enemy4D.s index dd15a65f..233850b2 100644 --- a/asm/enemy/enemy4D.s +++ b/asm/enemy/enemy4D.s @@ -172,7 +172,7 @@ _0803ECD8: movs r1, #0x10 bl sub_0803E94C adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 _0803ED02: pop {r4, r5, r6, pc} diff --git a/asm/enemy/flyingPot.s b/asm/enemy/flyingPot.s index ef57afcb..5650403a 100644 --- a/asm/enemy/flyingPot.s +++ b/asm/enemy/flyingPot.s @@ -115,7 +115,7 @@ _08037110: _0803711E: ldr r1, _08037128 @ =gUnk_080CF244 adds r0, r5, #0 - bl sub_0804AA30 + bl EnemyFunctionHandlerAfterCollision pop {r4, r5, r6, pc} .align 2, 0 _08037128: .4byte gUnk_080CF244 @@ -476,7 +476,7 @@ _080373C4: sub_080373C8: @ 0x080373C8 push {r4, lr} adds r4, r0, #0 - bl sub_080AEFE0 + bl ProcessMovement2 ldrh r0, [r4, #0x2a] cmp r0, #0 beq _080373DC diff --git a/asm/movement.s b/asm/movement.s deleted file mode 100644 index 6adfcac0..00000000 --- a/asm/movement.s +++ /dev/null @@ -1,2059 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_080AE3E4 -sub_080AE3E4: @ 0x080AE3E4 - movs r0, #0 - bx lr - - thumb_func_start sub_080AE3E8 -sub_080AE3E8: @ 0x080AE3E8 - movs r0, #1 - bx lr - - thumb_func_start sub_080AE3EC -sub_080AE3EC: @ 0x080AE3EC - adds r2, r0, #0 - ldr r0, _080AE404 @ =gUnk_08133918 - movs r3, #0xf - ands r1, r3 - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - ands r2, r3 - asrs r0, r2 - movs r1, #1 - ands r0, r1 - bx lr - .align 2, 0 -_080AE404: .4byte gUnk_08133918 - - thumb_func_start sub_080AE408 -sub_080AE408: @ 0x080AE408 - adds r2, r0, #0 - ldr r0, _080AE420 @ =gUnk_08133938 - movs r3, #0xf - ands r1, r3 - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - ands r2, r3 - asrs r0, r2 - movs r1, #1 - ands r0, r1 - bx lr - .align 2, 0 -_080AE420: .4byte gUnk_08133938 - - thumb_func_start sub_080AE424 -sub_080AE424: @ 0x080AE424 - adds r2, r0, #0 - ldr r0, _080AE43C @ =gUnk_08133958 - movs r3, #0xf - ands r1, r3 - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - ands r2, r3 - asrs r0, r2 - movs r1, #1 - ands r0, r1 - bx lr - .align 2, 0 -_080AE43C: .4byte gUnk_08133958 - - thumb_func_start sub_080AE440 -sub_080AE440: @ 0x080AE440 - adds r2, r0, #0 - ldr r0, _080AE458 @ =gUnk_08133978 - movs r3, #0xf - ands r1, r3 - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - ands r2, r3 - asrs r0, r2 - movs r1, #1 - ands r0, r1 - bx lr - .align 2, 0 -_080AE458: .4byte gUnk_08133978 - - thumb_func_start sub_080AE45C -sub_080AE45C: @ 0x080AE45C - adds r2, r0, #0 - ldr r0, _080AE474 @ =gUnk_08133998 - movs r3, #0xf - ands r1, r3 - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - ands r2, r3 - asrs r0, r2 - movs r1, #1 - ands r0, r1 - bx lr - .align 2, 0 -_080AE474: .4byte gUnk_08133998 - - thumb_func_start sub_080AE478 -sub_080AE478: @ 0x080AE478 - adds r2, r0, #0 - ldr r0, _080AE490 @ =gUnk_081339B8 - movs r3, #0xf - ands r1, r3 - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - ands r2, r3 - asrs r0, r2 - movs r1, #1 - ands r0, r1 - bx lr - .align 2, 0 -_080AE490: .4byte gUnk_081339B8 - - thumb_func_start sub_080AE494 -sub_080AE494: @ 0x080AE494 - adds r2, r0, #0 - ldr r0, _080AE4AC @ =gUnk_081339D8 - movs r3, #0xf - ands r1, r3 - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - ands r2, r3 - asrs r0, r2 - movs r1, #1 - ands r0, r1 - bx lr - .align 2, 0 -_080AE4AC: .4byte gUnk_081339D8 - - thumb_func_start sub_080AE4B0 -sub_080AE4B0: @ 0x080AE4B0 - adds r2, r0, #0 - ldr r0, _080AE4C8 @ =gUnk_081339F8 - movs r3, #0xf - ands r1, r3 - lsls r1, r1, #1 - adds r1, r1, r0 - ldrh r0, [r1] - ands r2, r3 - asrs r0, r2 - movs r1, #1 - ands r0, r1 - bx lr - .align 2, 0 -_080AE4C8: .4byte gUnk_081339F8 - - thumb_func_start sub_080AE4CC -sub_080AE4CC: @ 0x080AE4CC - push {r4, r5, r6, lr} - adds r6, r1, #0 - adds r5, r2, #0 - adds r4, r3, #0 - ldr r1, _080AE4FC @ =gRoomControls - ldrh r2, [r1, #6] - subs r2, r6, r2 - asrs r2, r2, #4 - movs r3, #0x3f - ands r2, r3 - ldrh r1, [r1, #8] - subs r1, r5, r1 - asrs r1, r1, #4 - ands r1, r3 - lsls r1, r1, #6 - orrs r2, r1 - adds r0, r0, r2 - ldrb r3, [r0] - cmp r3, #0 - bne _080AE500 - cmp r4, #4 - beq _080AE588 - b _080AE516 - .align 2, 0 -_080AE4FC: .4byte gRoomControls -_080AE500: - cmp r3, #0xf - bhi _080AE53E - ldr r2, _080AE51C @ =gUnk_08133A40 - lsls r1, r4, #1 - adds r0, r3, #1 - lsrs r0, r0, #4 - adds r1, r1, r0 - adds r1, r1, r2 - ldrb r0, [r1] - cmp r0, #0 - bne _080AE520 -_080AE516: - movs r0, #0 - b _080AE58A - .align 2, 0 -_080AE51C: .4byte gUnk_08133A40 -_080AE520: - cmp r0, #1 - beq _080AE588 - movs r0, #8 - ands r5, r0 - cmp r5, #0 - bne _080AE52E - lsrs r3, r3, #2 -_080AE52E: - ands r6, r0 - cmp r6, #0 - bne _080AE536 - lsrs r3, r3, #1 -_080AE536: - movs r0, #1 - ands r3, r0 - adds r0, r3, #0 - b _080AE58A -_080AE53E: - cmp r3, #0xff - bne _080AE558 - ldr r1, _080AE550 @ =gUnk_08133A18 - ldr r0, _080AE554 @ =gUnk_08133A5A - adds r0, r4, r0 - ldrb r0, [r0] - lsls r0, r0, #2 - adds r0, r0, r1 - b _080AE572 - .align 2, 0 -_080AE550: .4byte gUnk_08133A18 -_080AE554: .4byte gUnk_08133A5A -_080AE558: - cmp r3, #0x6f - bhi _080AE588 - ldr r2, _080AE580 @ =gUnk_08133A18 - ldr r1, _080AE584 @ =gUnk_08133A67 - lsls r0, r4, #1 - adds r0, r0, r4 - lsls r0, r0, #5 - adds r0, r0, r3 - subs r0, #0x10 - adds r0, r0, r1 - ldrb r0, [r0] - lsls r0, r0, #2 - adds r0, r0, r2 -_080AE572: - ldr r2, [r0] - adds r0, r6, #0 - adds r1, r5, #0 - bl _call_via_r2 - b _080AE58A - .align 2, 0 -_080AE580: .4byte gUnk_08133A18 -_080AE584: .4byte gUnk_08133A67 -_080AE588: - movs r0, #1 -_080AE58A: - pop {r4, r5, r6, pc} - - thumb_func_start sub_080AE58C -sub_080AE58C: @ 0x080AE58C - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x18 - str r0, [sp] - str r1, [sp, #4] - adds r4, r2, #0 - adds r0, #0x38 - ldrb r0, [r0] - bl GetLayerByIndex - ldr r1, _080AE624 @ =0x00002004 - adds r5, r0, r1 - ldr r2, [sp] - ldr r2, [r2, #0x48] - str r2, [sp, #8] - ldr r0, [sp] - movs r2, #0x2e - ldrsh r1, [r0, r2] - ldr r2, [sp, #8] - movs r0, #0 - ldrsb r0, [r2, r0] - adds r1, r1, r0 - str r1, [sp, #0xc] - ldr r0, [sp] - movs r2, #0x32 - ldrsh r1, [r0, r2] - ldr r2, [sp, #8] - movs r0, #1 - ldrsb r0, [r2, r0] - adds r1, r1, r0 - mov sl, r1 - ldrb r0, [r2, #2] - mov sb, r0 - ldrb r1, [r2, #3] - mov r8, r1 - movs r0, #0xf - ldr r2, [sp, #4] - ands r0, r2 - cmp r0, #0 - beq _080AE65C - cmp r2, #0xf - bhi _080AE628 - ldr r7, [sp, #0xc] - add r7, sb - adds r0, r5, #0 - adds r1, r7, #0 - mov r2, sl - adds r3, r4, #0 - bl sub_080AE4CC - adds r6, r0, #0 - lsls r6, r6, #1 - mov r2, sl - add r2, r8 - adds r0, r5, #0 - adds r1, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - mov r0, sl - mov r1, r8 - subs r2, r0, r1 - adds r0, r5, #0 - adds r1, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #6 - b _080AE6D2 - .align 2, 0 -_080AE624: .4byte 0x00002004 -_080AE628: - ldr r2, [sp, #0xc] - mov r0, sb - subs r7, r2, r0 - adds r0, r5, #0 - adds r1, r7, #0 - mov r2, sl - adds r3, r4, #0 - bl sub_080AE4CC - adds r6, r0, #0 - lsls r6, r6, #1 - mov r2, sl - add r2, r8 - adds r0, r5, #0 - adds r1, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - mov r1, sl - mov r0, r8 - subs r2, r1, r0 - adds r0, r5, #0 - adds r1, r7, #0 - b _080AE6C8 -_080AE65C: - ldr r7, [sp, #0xc] - add r7, sb - adds r0, r5, #0 - adds r1, r7, #0 - mov r2, sl - adds r3, r4, #0 - bl sub_080AE4CC - adds r6, r0, #0 - lsls r6, r6, #1 - mov r1, sl - add r1, r8 - str r1, [sp, #0x10] - adds r0, r5, #0 - adds r1, r7, #0 - ldr r2, [sp, #0x10] - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - mov r2, sl - mov r0, r8 - subs r2, r2, r0 - mov r8, r2 - adds r0, r5, #0 - adds r1, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #2 - ldr r1, [sp, #0xc] - mov r2, sb - subs r7, r1, r2 - adds r0, r5, #0 - adds r1, r7, #0 - mov r2, sl - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - adds r0, r5, #0 - adds r1, r7, #0 - ldr r2, [sp, #0x10] - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - adds r0, r5, #0 - adds r1, r7, #0 - mov r2, r8 -_080AE6C8: - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #2 -_080AE6D2: - ldr r0, [sp, #8] - ldrb r0, [r0, #4] - mov sb, r0 - ldr r1, [sp, #8] - ldrb r1, [r1, #5] - mov r8, r1 - ldr r2, [sp, #4] - subs r2, #8 - str r2, [sp, #4] - movs r0, #0xf - ands r0, r2 - cmp r0, #0 - beq _080AE760 - cmp r2, #0xf - bhi _080AE72C - mov r7, sl - add r7, r8 - adds r0, r5, #0 - ldr r1, [sp, #0xc] - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - ldr r1, [sp, #0xc] - add r1, sb - adds r0, r5, #0 - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - ldr r0, [sp, #0xc] - mov r2, sb - subs r1, r0, r2 - adds r0, r5, #0 - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #5 - b _080AE7D6 -_080AE72C: - mov r0, sl - mov r1, r8 - subs r7, r0, r1 - lsls r6, r6, #4 - adds r0, r5, #0 - ldr r1, [sp, #0xc] - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - ldr r1, [sp, #0xc] - add r1, sb - adds r0, r5, #0 - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - ldr r2, [sp, #0xc] - mov r0, sb - subs r1, r2, r0 - adds r0, r5, #0 - b _080AE7CA -_080AE760: - mov r7, sl - add r7, r8 - adds r0, r5, #0 - ldr r1, [sp, #0xc] - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - ldr r1, [sp, #0xc] - add r1, sb - str r1, [sp, #0x14] - adds r0, r5, #0 - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - ldr r2, [sp, #0xc] - mov r0, sb - subs r2, r2, r0 - mov sb, r2 - adds r0, r5, #0 - mov r1, sb - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #2 - mov r1, sl - mov r2, r8 - subs r7, r1, r2 - adds r0, r5, #0 - ldr r1, [sp, #0xc] - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - adds r0, r5, #0 - ldr r1, [sp, #0x14] - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 - adds r0, r5, #0 - mov r1, sb -_080AE7CA: - adds r2, r7, #0 - adds r3, r4, #0 - bl sub_080AE4CC - orrs r6, r0 - lsls r6, r6, #1 -_080AE7D6: - ldr r0, [sp] - strh r6, [r0, #0x2a] - add sp, #0x18 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - - thumb_func_start sub_080AE7E8 -sub_080AE7E8: @ 0x080AE7E8 - push {r4, r5, lr} - ldr r5, _080AE7FC @ =gUnk_08133F48 - lsls r4, r2, #2 - adds r4, r4, r5 - lsls r2, r2, #3 - ldr r4, [r4] - bl _call_via_r4 - pop {r4, r5, pc} - .align 2, 0 -_080AE7FC: .4byte gUnk_08133F48 - - thumb_func_start sub_080AE800 -sub_080AE800: @ 0x080AE800 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - adds r4, r0, #0 - adds r5, r1, #0 - adds r2, r3, #0 - movs r6, #0 - mov r8, r6 - ldrh r1, [r4, #0x2a] - movs r7, #0xe - adds r0, r7, #0 - ands r0, r1 - cmp r0, #0 - beq _080AE89C - cmp r0, #2 - bne _080AE85C - movs r0, #0xe0 - lsls r0, r0, #8 - ands r0, r1 - cmp r0, #0 - bne _080AE8AE - lsls r6, r5, #8 - ldr r0, [r4, #0x2c] - adds r0, r0, r6 - str r0, [r4, #0x2c] - adds r0, r4, #0 - movs r1, #4 - bl sub_080AE58C - ldrh r1, [r4, #0x2a] - adds r0, r7, #0 - ands r0, r1 - cmp r0, #0 - bne _080AE8AE - ldr r0, _080AE858 @ =gSineTable - adds r0, #0x80 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r1, r0, #0 - muls r1, r5, r1 - mov r8, r1 - ldr r0, [r4, #0x30] - subs r0, r0, r1 - b _080AE8AC - .align 2, 0 -_080AE858: .4byte gSineTable -_080AE85C: - cmp r0, #4 - bne _080AE8AE - movs r0, #0xe0 - lsls r0, r0, #4 - ands r0, r1 - cmp r0, #0 - bne _080AE8AE - lsls r6, r5, #8 - ldr r0, [r4, #0x2c] - subs r0, r0, r6 - str r0, [r4, #0x2c] - adds r0, r4, #0 - movs r1, #0x1c - bl sub_080AE58C - ldrh r1, [r4, #0x2a] - adds r0, r7, #0 - ands r0, r1 - cmp r0, #0 - bne _080AE8AE - ldr r0, _080AE898 @ =gSineTable - adds r0, #0x80 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r1, r0, #0 - muls r1, r5, r1 - mov r8, r1 - ldr r0, [r4, #0x30] - subs r0, r0, r1 - b _080AE8AC - .align 2, 0 -_080AE898: .4byte gSineTable -_080AE89C: - ldr r0, _080AE8C4 @ =gSineTable - adds r0, #0x80 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x30] - subs r0, r0, r6 -_080AE8AC: - str r0, [r4, #0x30] -_080AE8AE: - ldr r1, _080AE8C8 @ =0x00003333 - adds r0, r6, r1 - ldr r1, _080AE8CC @ =0x00006665 - cmp r0, r1 - bhi _080AE8D0 - ldr r0, _080AE8C8 @ =0x00003333 - add r0, r8 - cmp r0, r1 - bhi _080AE8D0 - movs r0, #0 - b _080AE8D2 - .align 2, 0 -_080AE8C4: .4byte gSineTable -_080AE8C8: .4byte 0x00003333 -_080AE8CC: .4byte 0x00006665 -_080AE8D0: - movs r0, #1 -_080AE8D2: - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7, pc} - - thumb_func_start sub_080AE8D8 -sub_080AE8D8: @ 0x080AE8D8 - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r4, r0, #0 - adds r5, r1, #0 - mov r8, r2 - mov sb, r3 - movs r7, #0 - movs r6, #0 - ldrh r0, [r4, #0x2a] - movs r1, #0xe - ands r1, r0 - mov ip, r1 - movs r2, #0xe0 - lsls r2, r2, #8 - ands r2, r0 - adds r3, r2, #0 - cmp r1, #0 - beq _080AE904 - cmp r2, #0 - bne _080AE99E -_080AE904: - orrs r1, r2 - cmp r1, #0 - bne _080AE928 - ldr r1, _080AE924 @ =gSineTable - mov r0, r8 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r2, #0 - ldrsh r0, [r0, r2] - adds r7, r0, #0 - muls r7, r5, r7 - ldr r0, [r4, #0x30] - subs r0, r0, r7 - str r0, [r4, #0x30] - b _080AE98A - .align 2, 0 -_080AE924: .4byte gSineTable -_080AE928: - mov r2, ip - cmp r2, #2 - bne _080AE942 - lsls r7, r5, #8 - ldr r0, [r4, #0x2c] - adds r0, r0, r7 - str r0, [r4, #0x2c] - adds r0, r4, #0 - movs r1, #4 - mov r2, sb - bl sub_080AE58C - b _080AE95C -_080AE942: - movs r0, #0x80 - lsls r0, r0, #7 - cmp r3, r0 - bne _080AE95C - lsls r7, r5, #8 - ldr r0, [r4, #0x30] - subs r0, r0, r7 - str r0, [r4, #0x30] - adds r0, r4, #0 - movs r1, #4 - mov r2, sb - bl sub_080AE58C -_080AE95C: - ldrh r2, [r4, #0x2a] - movs r0, #0xe - ands r0, r2 - cmp r0, #0 - bne _080AE97E - ldr r1, _080AE9B4 @ =gSineTable - mov r0, r8 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x30] - subs r0, r0, r6 - str r0, [r4, #0x30] -_080AE97E: - movs r0, #0xe0 - lsls r0, r0, #8 - ands r0, r2 - cmp r0, #0 - bne _080AE99E - ldr r1, _080AE9B4 @ =gSineTable -_080AE98A: - mov r2, r8 - lsls r0, r2, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x2c] - adds r0, r0, r6 - str r0, [r4, #0x2c] -_080AE99E: - ldr r2, _080AE9B8 @ =0x00003333 - adds r0, r7, r2 - ldr r1, _080AE9BC @ =0x00006665 - cmp r0, r1 - bhi _080AE9C0 - ldr r2, _080AE9B8 @ =0x00003333 - adds r0, r6, r2 - cmp r0, r1 - bhi _080AE9C0 - movs r0, #0 - b _080AE9C2 - .align 2, 0 -_080AE9B4: .4byte gSineTable -_080AE9B8: .4byte 0x00003333 -_080AE9BC: .4byte 0x00006665 -_080AE9C0: - movs r0, #1 -_080AE9C2: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - - thumb_func_start sub_080AE9CC -sub_080AE9CC: @ 0x080AE9CC - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r4, r0, #0 - adds r5, r1, #0 - adds r7, r2, #0 - movs r6, #0 - mov sb, r6 - ldrh r2, [r4, #0x2a] - movs r0, #0xe0 - lsls r0, r0, #8 - mov r8, r0 - mov r1, r8 - ands r1, r2 - cmp r1, #0 - beq _080AEA7C - movs r0, #0x80 - lsls r0, r0, #6 - cmp r1, r0 - bne _080AEA34 - movs r0, #0xe0 - ands r0, r2 - cmp r0, #0 - bne _080AEA90 - lsls r6, r5, #8 - ldr r0, [r4, #0x30] - adds r0, r0, r6 - str r0, [r4, #0x30] - adds r0, r4, #0 - movs r1, #0xc - adds r2, r3, #0 - bl sub_080AE58C - ldrh r1, [r4, #0x2a] - mov r0, r8 - ands r0, r1 - cmp r0, #0 - bne _080AEA90 - ldr r1, _080AEA30 @ =gSineTable - lsls r0, r7, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r1, r0, #0 - muls r1, r5, r1 - mov sb, r1 - ldr r0, [r4, #0x2c] - add r0, sb - b _080AEA8E - .align 2, 0 -_080AEA30: .4byte gSineTable -_080AEA34: - movs r0, #0x80 - lsls r0, r0, #7 - cmp r1, r0 - bne _080AEA90 - movs r0, #0xe - ands r0, r2 - cmp r0, #0 - bne _080AEA90 - lsls r6, r5, #8 - ldr r0, [r4, #0x30] - subs r0, r0, r6 - str r0, [r4, #0x30] - adds r0, r4, #0 - movs r1, #4 - adds r2, r3, #0 - bl sub_080AE58C - ldrh r1, [r4, #0x2a] - mov r0, r8 - ands r0, r1 - cmp r0, #0 - bne _080AEA90 - ldr r1, _080AEA78 @ =gSineTable - lsls r0, r7, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r1, r0, #0 - muls r1, r5, r1 - mov sb, r1 - ldr r0, [r4, #0x2c] - add r0, sb - b _080AEA8E - .align 2, 0 -_080AEA78: .4byte gSineTable -_080AEA7C: - ldr r1, _080AEAA8 @ =gSineTable - lsls r0, r7, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x2c] - adds r0, r0, r6 -_080AEA8E: - str r0, [r4, #0x2c] -_080AEA90: - ldr r1, _080AEAAC @ =0x00003333 - adds r0, r6, r1 - ldr r1, _080AEAB0 @ =0x00006665 - cmp r0, r1 - bhi _080AEAB4 - ldr r0, _080AEAAC @ =0x00003333 - add r0, sb - cmp r0, r1 - bhi _080AEAB4 - movs r0, #0 - b _080AEAB6 - .align 2, 0 -_080AEAA8: .4byte gSineTable -_080AEAAC: .4byte 0x00003333 -_080AEAB0: .4byte 0x00006665 -_080AEAB4: - movs r0, #1 -_080AEAB6: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - - thumb_func_start sub_080AEAC0 -sub_080AEAC0: @ 0x080AEAC0 - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r4, r0, #0 - adds r5, r1, #0 - mov r8, r2 - mov sb, r3 - movs r7, #0 - movs r6, #0 - ldrh r0, [r4, #0x2a] - movs r1, #0xe0 - ands r1, r0 - mov ip, r1 - movs r2, #0xe0 - lsls r2, r2, #8 - ands r2, r0 - adds r3, r2, #0 - cmp r1, #0 - beq _080AEAEC - cmp r2, #0 - bne _080AEB86 -_080AEAEC: - orrs r1, r2 - cmp r1, #0 - bne _080AEB10 - ldr r1, _080AEB0C @ =gSineTable - mov r0, r8 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r2, #0 - ldrsh r0, [r0, r2] - adds r7, r0, #0 - muls r7, r5, r7 - ldr r0, [r4, #0x30] - subs r0, r0, r7 - str r0, [r4, #0x30] - b _080AEB72 - .align 2, 0 -_080AEB0C: .4byte gSineTable -_080AEB10: - mov r2, ip - cmp r2, #0x20 - bne _080AEB2A - lsls r7, r5, #8 - ldr r0, [r4, #0x2c] - adds r0, r0, r7 - str r0, [r4, #0x2c] - adds r0, r4, #0 - movs r1, #0xc - mov r2, sb - bl sub_080AE58C - b _080AEB44 -_080AEB2A: - movs r0, #0x80 - lsls r0, r0, #6 - cmp r3, r0 - bne _080AEB44 - lsls r7, r5, #8 - ldr r0, [r4, #0x30] - adds r0, r0, r7 - str r0, [r4, #0x30] - adds r0, r4, #0 - movs r1, #0xc - mov r2, sb - bl sub_080AE58C -_080AEB44: - ldrh r2, [r4, #0x2a] - movs r0, #0xe0 - ands r0, r2 - cmp r0, #0 - bne _080AEB66 - ldr r1, _080AEB9C @ =gSineTable - mov r0, r8 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x30] - subs r0, r0, r6 - str r0, [r4, #0x30] -_080AEB66: - movs r0, #0xe0 - lsls r0, r0, #8 - ands r0, r2 - cmp r0, #0 - bne _080AEB86 - ldr r1, _080AEB9C @ =gSineTable -_080AEB72: - mov r2, r8 - lsls r0, r2, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x2c] - adds r0, r0, r6 - str r0, [r4, #0x2c] -_080AEB86: - ldr r2, _080AEBA0 @ =0x00003333 - adds r0, r7, r2 - ldr r1, _080AEBA4 @ =0x00006665 - cmp r0, r1 - bhi _080AEBA8 - ldr r2, _080AEBA0 @ =0x00003333 - adds r0, r6, r2 - cmp r0, r1 - bhi _080AEBA8 - movs r0, #0 - b _080AEBAA - .align 2, 0 -_080AEB9C: .4byte gSineTable -_080AEBA0: .4byte 0x00003333 -_080AEBA4: .4byte 0x00006665 -_080AEBA8: - movs r0, #1 -_080AEBAA: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - - thumb_func_start sub_080AEBB4 -sub_080AEBB4: @ 0x080AEBB4 - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r4, r0, #0 - adds r5, r1, #0 - adds r7, r2, #0 - adds r2, r3, #0 - movs r6, #0 - mov sb, r6 - ldrh r1, [r4, #0x2a] - movs r0, #0xe0 - mov r8, r0 - ands r0, r1 - cmp r0, #0 - beq _080AEC64 - cmp r0, #0x20 - bne _080AEC1C - movs r0, #0xe0 - lsls r0, r0, #8 - ands r0, r1 - cmp r0, #0 - bne _080AEC7C - lsls r6, r5, #8 - ldr r0, [r4, #0x2c] - adds r0, r0, r6 - str r0, [r4, #0x2c] - adds r0, r4, #0 - movs r1, #0xc - bl sub_080AE58C - ldrh r1, [r4, #0x2a] - mov r0, r8 - ands r0, r1 - cmp r0, #0 - bne _080AEC7C - ldr r1, _080AEC18 @ =gSineTable - adds r0, r7, #0 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r1, r0, #0 - muls r1, r5, r1 - mov sb, r1 - ldr r0, [r4, #0x30] - subs r0, r0, r1 - b _080AEC7A - .align 2, 0 -_080AEC18: .4byte gSineTable -_080AEC1C: - cmp r0, #0x40 - bne _080AEC7C - movs r0, #0xe0 - lsls r0, r0, #4 - ands r0, r1 - cmp r0, #0 - bne _080AEC7C - lsls r6, r5, #8 - ldr r0, [r4, #0x2c] - subs r0, r0, r6 - str r0, [r4, #0x2c] - adds r0, r4, #0 - movs r1, #0x14 - bl sub_080AE58C - ldrh r1, [r4, #0x2a] - mov r0, r8 - ands r0, r1 - cmp r0, #0 - bne _080AEC7C - ldr r1, _080AEC60 @ =gSineTable - adds r0, r7, #0 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r1, r0, #0 - muls r1, r5, r1 - mov sb, r1 - ldr r0, [r4, #0x30] - subs r0, r0, r1 - b _080AEC7A - .align 2, 0 -_080AEC60: .4byte gSineTable -_080AEC64: - ldr r1, _080AEC94 @ =gSineTable - adds r0, r7, #0 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x30] - subs r0, r0, r6 -_080AEC7A: - str r0, [r4, #0x30] -_080AEC7C: - ldr r1, _080AEC98 @ =0x00003333 - adds r0, r6, r1 - ldr r1, _080AEC9C @ =0x00006665 - cmp r0, r1 - bhi _080AECA0 - ldr r0, _080AEC98 @ =0x00003333 - add r0, sb - cmp r0, r1 - bhi _080AECA0 - movs r0, #0 - b _080AECA2 - .align 2, 0 -_080AEC94: .4byte gSineTable -_080AEC98: .4byte 0x00003333 -_080AEC9C: .4byte 0x00006665 -_080AECA0: - movs r0, #1 -_080AECA2: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - - thumb_func_start sub_080AECAC -sub_080AECAC: @ 0x080AECAC - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r4, r0, #0 - adds r5, r1, #0 - mov r8, r2 - mov sb, r3 - movs r7, #0 - movs r6, #0 - ldrh r0, [r4, #0x2a] - movs r1, #0xe0 - ands r1, r0 - mov ip, r1 - movs r2, #0xe0 - lsls r2, r2, #4 - ands r2, r0 - adds r3, r2, #0 - cmp r1, #0 - beq _080AECD8 - cmp r2, #0 - bne _080AED72 -_080AECD8: - orrs r1, r2 - cmp r1, #0 - bne _080AECFC - ldr r1, _080AECF8 @ =gSineTable - mov r0, r8 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r2, #0 - ldrsh r0, [r0, r2] - adds r7, r0, #0 - muls r7, r5, r7 - ldr r0, [r4, #0x30] - subs r0, r0, r7 - str r0, [r4, #0x30] - b _080AED5E - .align 2, 0 -_080AECF8: .4byte gSineTable -_080AECFC: - mov r2, ip - cmp r2, #0x40 - bne _080AED16 - lsls r7, r5, #8 - ldr r0, [r4, #0x2c] - subs r0, r0, r7 - str r0, [r4, #0x2c] - adds r0, r4, #0 - movs r1, #0x14 - mov r2, sb - bl sub_080AE58C - b _080AED30 -_080AED16: - movs r0, #0x80 - lsls r0, r0, #2 - cmp r3, r0 - bne _080AED30 - lsls r7, r5, #8 - ldr r0, [r4, #0x30] - adds r0, r0, r7 - str r0, [r4, #0x30] - adds r0, r4, #0 - movs r1, #0x14 - mov r2, sb - bl sub_080AE58C -_080AED30: - ldrh r2, [r4, #0x2a] - movs r0, #0xe0 - ands r0, r2 - cmp r0, #0 - bne _080AED52 - ldr r1, _080AED88 @ =gSineTable - mov r0, r8 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x30] - subs r0, r0, r6 - str r0, [r4, #0x30] -_080AED52: - movs r0, #0xe0 - lsls r0, r0, #4 - ands r0, r2 - cmp r0, #0 - bne _080AED72 - ldr r1, _080AED88 @ =gSineTable -_080AED5E: - mov r2, r8 - lsls r0, r2, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x2c] - adds r0, r0, r6 - str r0, [r4, #0x2c] -_080AED72: - ldr r2, _080AED8C @ =0x00003333 - adds r0, r7, r2 - ldr r1, _080AED90 @ =0x00006665 - cmp r0, r1 - bhi _080AED94 - ldr r2, _080AED8C @ =0x00003333 - adds r0, r6, r2 - cmp r0, r1 - bhi _080AED94 - movs r0, #0 - b _080AED96 - .align 2, 0 -_080AED88: .4byte gSineTable -_080AED8C: .4byte 0x00003333 -_080AED90: .4byte 0x00006665 -_080AED94: - movs r0, #1 -_080AED96: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - - thumb_func_start sub_080AEDA0 -sub_080AEDA0: @ 0x080AEDA0 - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r4, r0, #0 - adds r5, r1, #0 - adds r7, r2, #0 - movs r6, #0 - mov sb, r6 - ldrh r2, [r4, #0x2a] - movs r0, #0xe0 - lsls r0, r0, #4 - mov r8, r0 - mov r1, r8 - ands r1, r2 - cmp r1, #0 - beq _080AEE50 - movs r0, #0x80 - lsls r0, r0, #2 - cmp r1, r0 - bne _080AEE08 - movs r0, #0xe0 - ands r0, r2 - cmp r0, #0 - bne _080AEE64 - lsls r6, r5, #8 - ldr r0, [r4, #0x30] - adds r0, r0, r6 - str r0, [r4, #0x30] - adds r0, r4, #0 - movs r1, #0x1c - adds r2, r3, #0 - bl sub_080AE58C - ldrh r1, [r4, #0x2a] - mov r0, r8 - ands r0, r1 - cmp r0, #0 - bne _080AEE64 - ldr r1, _080AEE04 @ =gSineTable - lsls r0, r7, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r1, r0, #0 - muls r1, r5, r1 - mov sb, r1 - ldr r0, [r4, #0x2c] - add r0, sb - b _080AEE62 - .align 2, 0 -_080AEE04: .4byte gSineTable -_080AEE08: - movs r0, #0x80 - lsls r0, r0, #3 - cmp r1, r0 - bne _080AEE64 - movs r0, #0xe - ands r0, r2 - cmp r0, #0 - bne _080AEE64 - lsls r6, r5, #8 - ldr r0, [r4, #0x30] - subs r0, r0, r6 - str r0, [r4, #0x30] - adds r0, r4, #0 - movs r1, #0x1c - adds r2, r3, #0 - bl sub_080AE58C - ldrh r1, [r4, #0x2a] - mov r0, r8 - ands r0, r1 - cmp r0, #0 - bne _080AEE64 - ldr r1, _080AEE4C @ =gSineTable - lsls r0, r7, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r1, r0, #0 - muls r1, r5, r1 - mov sb, r1 - ldr r0, [r4, #0x2c] - add r0, sb - b _080AEE62 - .align 2, 0 -_080AEE4C: .4byte gSineTable -_080AEE50: - ldr r1, _080AEE7C @ =gSineTable - lsls r0, r7, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x2c] - adds r0, r0, r6 -_080AEE62: - str r0, [r4, #0x2c] -_080AEE64: - ldr r1, _080AEE80 @ =0x00003333 - adds r0, r6, r1 - ldr r1, _080AEE84 @ =0x00006665 - cmp r0, r1 - bhi _080AEE88 - ldr r0, _080AEE80 @ =0x00003333 - add r0, sb - cmp r0, r1 - bhi _080AEE88 - movs r0, #0 - b _080AEE8A - .align 2, 0 -_080AEE7C: .4byte gSineTable -_080AEE80: .4byte 0x00003333 -_080AEE84: .4byte 0x00006665 -_080AEE88: - movs r0, #1 -_080AEE8A: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - - thumb_func_start sub_080AEE94 -sub_080AEE94: @ 0x080AEE94 - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r4, r0, #0 - adds r5, r1, #0 - mov r8, r2 - mov sb, r3 - movs r7, #0 - movs r6, #0 - ldrh r0, [r4, #0x2a] - movs r1, #0xe - ands r1, r0 - mov ip, r1 - movs r2, #0xe0 - lsls r2, r2, #4 - ands r2, r0 - adds r3, r2, #0 - cmp r1, #0 - beq _080AEEC0 - cmp r2, #0 - bne _080AEF5A -_080AEEC0: - orrs r1, r2 - cmp r1, #0 - bne _080AEEE4 - ldr r1, _080AEEE0 @ =gSineTable - mov r0, r8 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r2, #0 - ldrsh r0, [r0, r2] - adds r7, r0, #0 - muls r7, r5, r7 - ldr r0, [r4, #0x30] - subs r0, r0, r7 - str r0, [r4, #0x30] - b _080AEF46 - .align 2, 0 -_080AEEE0: .4byte gSineTable -_080AEEE4: - mov r2, ip - cmp r2, #4 - bne _080AEEFE - lsls r7, r5, #8 - ldr r0, [r4, #0x2c] - subs r0, r0, r7 - str r0, [r4, #0x2c] - adds r0, r4, #0 - movs r1, #0x1c - mov r2, sb - bl sub_080AE58C - b _080AEF18 -_080AEEFE: - movs r0, #0x80 - lsls r0, r0, #3 - cmp r3, r0 - bne _080AEF18 - lsls r7, r5, #8 - ldr r0, [r4, #0x30] - subs r0, r0, r7 - str r0, [r4, #0x30] - adds r0, r4, #0 - movs r1, #0x1c - mov r2, sb - bl sub_080AE58C -_080AEF18: - ldrh r2, [r4, #0x2a] - movs r0, #0xe - ands r0, r2 - cmp r0, #0 - bne _080AEF3A - ldr r1, _080AEF70 @ =gSineTable - mov r0, r8 - adds r0, #0x40 - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x30] - subs r0, r0, r6 - str r0, [r4, #0x30] -_080AEF3A: - movs r0, #0xe0 - lsls r0, r0, #4 - ands r0, r2 - cmp r0, #0 - bne _080AEF5A - ldr r1, _080AEF70 @ =gSineTable -_080AEF46: - mov r2, r8 - lsls r0, r2, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - adds r6, r0, #0 - muls r6, r5, r6 - ldr r0, [r4, #0x2c] - adds r0, r0, r6 - str r0, [r4, #0x2c] -_080AEF5A: - ldr r2, _080AEF74 @ =0x00003333 - adds r0, r7, r2 - ldr r1, _080AEF78 @ =0x00006665 - cmp r0, r1 - bhi _080AEF7C - ldr r2, _080AEF74 @ =0x00003333 - adds r0, r6, r2 - cmp r0, r1 - bhi _080AEF7C - movs r0, #0 - b _080AEF7E - .align 2, 0 -_080AEF70: .4byte gSineTable -_080AEF74: .4byte 0x00003333 -_080AEF78: .4byte 0x00006665 -_080AEF7C: - movs r0, #1 -_080AEF7E: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7, pc} - .align 2, 0 - - thumb_func_start ProcessMovement -ProcessMovement: @ 0x080AEF88 - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AEFB0 - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #0 - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #0 - bl sub_080AE7E8 - b _080AEFB2 -_080AEFB0: - movs r0, #0 -_080AEFB2: - pop {r4, pc} - - thumb_func_start sub_080AEFB4 -sub_080AEFB4: @ 0x080AEFB4 - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AEFDC - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #1 - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #1 - bl sub_080AE7E8 - b _080AEFDE -_080AEFDC: - movs r0, #0 -_080AEFDE: - pop {r4, pc} - - thumb_func_start sub_080AEFE0 -sub_080AEFE0: @ 0x080AEFE0 - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AF008 - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #2 - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #2 - bl sub_080AE7E8 - b _080AF00A -_080AF008: - movs r0, #0 -_080AF00A: - pop {r4, pc} - - thumb_func_start sub_080AF00C -sub_080AF00C: @ 0x080AF00C - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AF034 - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #0xa - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #0xa - bl sub_080AE7E8 - b _080AF036 -_080AF034: - movs r0, #0 -_080AF036: - pop {r4, pc} - - thumb_func_start sub_080AF038 -sub_080AF038: @ 0x080AF038 - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AF060 - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #0xc - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #0xc - bl sub_080AE7E8 - b _080AF062 -_080AF060: - movs r0, #0 -_080AF062: - pop {r4, pc} - - thumb_func_start sub_080AF064 -sub_080AF064: @ 0x080AF064 - push {r4, r5, r6, lr} - adds r5, r0, #0 - adds r4, r1, #0 - adds r6, r2, #0 - movs r0, #0x80 - ands r0, r4 - cmp r0, #0 - bne _080AF08A - adds r0, r5, #0 - movs r2, #0 - bl sub_080AE58C - adds r0, r5, #0 - adds r1, r6, #0 - adds r2, r4, #0 - movs r3, #0 - bl sub_080AE7E8 - b _080AF08C -_080AF08A: - movs r0, #0 -_080AF08C: - pop {r4, r5, r6, pc} - .align 2, 0 - - thumb_func_start sub_080AF090 -sub_080AF090: @ 0x080AF090 - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AF0C2 - adds r0, r4, #0 - bl sub_080AF0C8 - cmp r0, #0 - bne _080AF0C2 - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #3 - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #3 - bl sub_080AE7E8 - b _080AF0C4 -_080AF0C2: - movs r0, #0 -_080AF0C4: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_080AF0C8 -sub_080AF0C8: @ 0x080AF0C8 - push {r4, lr} - adds r4, r0, #0 - bl GetTileTypeByEntity - cmp r0, #0x88 - beq _080AF10A - cmp r0, #0x88 - bhi _080AF0DE - cmp r0, #0x87 - beq _080AF0E8 - b _080AF130 -_080AF0DE: - cmp r0, #0x89 - beq _080AF11A - cmp r0, #0x8a - beq _080AF0F8 - b _080AF130 -_080AF0E8: - ldrb r0, [r4, #0x15] - adds r0, #7 - movs r1, #0x1f - ands r0, r1 - cmp r0, #0xf - bgt _080AF130 - movs r0, #0xe - b _080AF12A -_080AF0F8: - ldrb r0, [r4, #0x15] - subs r0, #1 - movs r1, #0x1f - ands r0, r1 - cmp r0, #0xf - bgt _080AF130 - movs r0, #0xe0 - lsls r0, r0, #8 - b _080AF12A -_080AF10A: - ldrb r0, [r4, #0x15] - subs r0, #9 - movs r1, #0x1f - ands r0, r1 - cmp r0, #0xf - bgt _080AF130 - movs r0, #0xe0 - b _080AF12A -_080AF11A: - ldrb r0, [r4, #0x15] - subs r0, #0x11 - movs r1, #0x1f - ands r0, r1 - cmp r0, #0xf - bgt _080AF130 - movs r0, #0xe0 - lsls r0, r0, #4 -_080AF12A: - strh r0, [r4, #0x2a] - movs r0, #1 - b _080AF132 -_080AF130: - movs r0, #0 -_080AF132: - pop {r4, pc} - - thumb_func_start sub_080AF134 -sub_080AF134: @ 0x080AF134 - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AF15C - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #4 - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #4 - bl sub_080AE7E8 - b _080AF15E -_080AF15C: - movs r0, #0 -_080AF15E: - pop {r4, pc} - - thumb_func_start sub_080AF160 -sub_080AF160: @ 0x080AF160 - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AF188 - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #5 - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #5 - bl sub_080AE7E8 - b _080AF18A -_080AF188: - movs r0, #0 -_080AF18A: - pop {r4, pc} - - thumb_func_start sub_080AF18C -sub_080AF18C: @ 0x080AF18C - push {r4, r5, lr} - adds r4, r0, #0 - adds r1, r4, #0 - adds r1, #0x42 - ldrb r0, [r1] - subs r0, #1 - strb r0, [r1] - adds r5, r4, #0 - adds r5, #0x3e - ldrb r1, [r5] - adds r0, r4, #0 - movs r2, #2 - bl sub_080AE58C - adds r0, r4, #0 - adds r0, #0x46 - ldrh r1, [r0] - ldrb r2, [r5] - adds r0, r4, #0 - movs r3, #2 - bl sub_080AE7E8 - pop {r4, r5, pc} - .align 2, 0 - - thumb_func_start sub_080AF1BC -sub_080AF1BC: @ 0x080AF1BC - push {r4, r5, lr} - adds r4, r0, #0 - adds r1, r4, #0 - adds r1, #0x42 - ldrb r0, [r1] - subs r0, #1 - strb r0, [r1] - adds r5, r4, #0 - adds r5, #0x3e - ldrb r1, [r5] - adds r0, r4, #0 - movs r2, #1 - bl sub_080AE58C - adds r0, r4, #0 - adds r0, #0x46 - ldrh r1, [r0] - ldrb r2, [r5] - adds r0, r4, #0 - movs r3, #1 - bl sub_080AE7E8 - pop {r4, r5, pc} - .align 2, 0 - - thumb_func_start sub_080AF1EC -sub_080AF1EC: @ 0x080AF1EC - push {r4, lr} - adds r4, r0, #0 - ldrb r1, [r4, #0x15] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080AF214 - ldrb r1, [r4, #0x15] - adds r0, r4, #0 - movs r2, #6 - bl sub_080AE58C - movs r0, #0x24 - ldrsh r1, [r4, r0] - ldrb r2, [r4, #0x15] - adds r0, r4, #0 - movs r3, #6 - bl sub_080AE7E8 - b _080AF216 -_080AF214: - movs r0, #0 -_080AF216: - pop {r4, pc} - - thumb_func_start sub_080AF218 -sub_080AF218: @ 0x080AF218 - push {r4, r5, r6, lr} - adds r5, r0, #0 - adds r4, r1, #0 - adds r6, r2, #0 - movs r0, #0x80 - ands r0, r4 - cmp r0, #0 - bne _080AF23E - adds r0, r5, #0 - movs r2, #6 - bl sub_080AE58C - adds r0, r5, #0 - adds r1, r6, #0 - adds r2, r4, #0 - movs r3, #6 - bl sub_080AE7E8 - b _080AF240 -_080AF23E: - movs r0, #0 -_080AF240: - pop {r4, r5, r6, pc} - .align 2, 0 - - thumb_func_start sub_080AF244 -sub_080AF244: @ 0x080AF244 - push {lr} - movs r3, #2 - bl sub_080AE7E8 - pop {pc} - .align 2, 0 - - thumb_func_start sub_080AF250 -sub_080AF250: @ 0x080AF250 - push {r4, lr} - adds r4, r0, #0 - bl GetCurrentRoomInfo - adds r1, r0, #0 - ldr r0, _080AF26C @ =gArea - ldr r2, _080AF270 @ =0x0000085C - adds r0, r0, r2 - str r1, [r0] - cmp r4, #0 - beq _080AF278 - ldr r0, _080AF274 @ =gUnk_08135190 - b _080AF27A - .align 2, 0 -_080AF26C: .4byte gArea -_080AF270: .4byte 0x0000085C -_080AF274: .4byte gUnk_08135190 -_080AF278: - ldr r0, _080AF280 @ =gExitList_RoyalValley_ForestMaze -_080AF27A: - str r0, [r1, #0x18] - pop {r4, pc} - .align 2, 0 -_080AF280: .4byte gExitList_RoyalValley_ForestMaze - - thumb_func_start sub_080AF284 -sub_080AF284: @ 0x080AF284 - push {lr} - ldr r0, _080AF2AC @ =gRoomControls - ldrh r1, [r0, #0x20] - subs r1, #0x50 - movs r0, #0x78 - movs r2, #0x78 - movs r3, #0x50 - bl CheckPlayerInRegion - cmp r0, #0 - beq _080AF2BC - bl GetCurrentRoomInfo - ldr r1, _080AF2B0 @ =gArea - ldr r2, _080AF2B4 @ =0x0000085C - adds r1, r1, r2 - str r0, [r1] - ldr r1, _080AF2B8 @ =gUnk_08135048 - b _080AF2D4 - .align 2, 0 -_080AF2AC: .4byte gRoomControls -_080AF2B0: .4byte gArea -_080AF2B4: .4byte 0x0000085C -_080AF2B8: .4byte gUnk_08135048 -_080AF2BC: - movs r0, #6 - bl GetInventoryValue - cmp r0, #0 - beq _080AF2D6 - bl GetCurrentRoomInfo - ldr r1, _080AF2D8 @ =gArea - ldr r2, _080AF2DC @ =0x0000085C - adds r1, r1, r2 - str r0, [r1] - ldr r1, _080AF2E0 @ =gUnk_08134FBC -_080AF2D4: - str r1, [r0, #0x18] -_080AF2D6: - pop {pc} - .align 2, 0 -_080AF2D8: .4byte gArea -_080AF2DC: .4byte 0x0000085C -_080AF2E0: .4byte gUnk_08134FBC - - thumb_func_start sub_080AF2E4 -sub_080AF2E4: @ 0x080AF2E4 - push {lr} - movs r0, #6 - bl GetInventoryValue - cmp r0, #0 - beq _080AF300 - bl GetCurrentRoomInfo - ldr r1, _080AF304 @ =gArea - ldr r2, _080AF308 @ =0x0000085C - adds r1, r1, r2 - str r0, [r1] - ldr r1, _080AF30C @ =gUnk_0813A76C - str r1, [r0, #0x18] -_080AF300: - pop {pc} - .align 2, 0 -_080AF304: .4byte gArea -_080AF308: .4byte 0x0000085C -_080AF30C: .4byte gUnk_0813A76C diff --git a/asm/non_matching/armos/sub_080305BC.inc b/asm/non_matching/armos/sub_080305BC.inc index 1267ed9d..f1259e5b 100644 --- a/asm/non_matching/armos/sub_080305BC.inc +++ b/asm/non_matching/armos/sub_080305BC.inc @@ -32,7 +32,7 @@ _080305E4: cmp r0, #0 bne _08030608 adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 cmp r0, #0 bne _0803064A ldrb r0, [r4, #0x15] @@ -59,7 +59,7 @@ _0803061E: cmp r3, #0 bne _08030638 adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 cmp r0, #0 bne _0803064A ldrb r0, [r4, #0x15] diff --git a/asm/non_matching/armos/sub_080306C4.inc b/asm/non_matching/armos/sub_080306C4.inc index a57b4080..f5a094d8 100644 --- a/asm/non_matching/armos/sub_080306C4.inc +++ b/asm/non_matching/armos/sub_080306C4.inc @@ -93,7 +93,7 @@ _08030758: adds r2, r2, r0 mov r0, ip movs r3, #0 - bl sub_080AE4CC + bl IsTileCollision cmp r0, #0 beq _0803079E movs r0, #4 diff --git a/asm/non_matching/fallingBoulder/sub_0802C334.inc b/asm/non_matching/fallingBoulder/sub_0802C334.inc index 50161c05..3c67cf6b 100644 --- a/asm/non_matching/fallingBoulder/sub_0802C334.inc +++ b/asm/non_matching/fallingBoulder/sub_0802C334.inc @@ -148,7 +148,7 @@ _0802C442: cmp r5, #4 ble _0802C460 adds r0, r4, #0 - bl sub_080AEFB4 + bl ProcessMovement1 b _0802C48C .align 2, 0 _0802C45C: .4byte gRoomControls diff --git a/asm/non_matching/gleerok/sub_0802D3B8.inc b/asm/non_matching/gleerok/sub_0802D3B8.inc index ccc08049..1cc4e2e9 100644 --- a/asm/non_matching/gleerok/sub_0802D3B8.inc +++ b/asm/non_matching/gleerok/sub_0802D3B8.inc @@ -76,7 +76,7 @@ _0802D420: cmp r5, #0 bne _0802D470 adds r0, r4, #0 - bl sub_0804A7D4 + bl GenericDeath bl DeleteThisEntity _0802D470: ldr r0, [r7] diff --git a/asm/non_matching/guardWithSpear/sub_0806407C.inc b/asm/non_matching/guardWithSpear/sub_0806407C.inc index 21843fdf..97ecad24 100644 --- a/asm/non_matching/guardWithSpear/sub_0806407C.inc +++ b/asm/non_matching/guardWithSpear/sub_0806407C.inc @@ -75,7 +75,7 @@ _080640E8: bl InitializeAnimation _0806410A: adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 movs r0, #0x2e ldrsh r1, [r4, r0] adds r2, r4, #0 diff --git a/asm/non_matching/guardWithSpear/sub_08064198.inc b/asm/non_matching/guardWithSpear/sub_08064198.inc index 89fc6a7f..62c0c2e0 100644 --- a/asm/non_matching/guardWithSpear/sub_08064198.inc +++ b/asm/non_matching/guardWithSpear/sub_08064198.inc @@ -49,7 +49,7 @@ _080641E6: movs r0, #0x32 ldrsh r4, [r5, r0] adds r0, r5, #0 - bl ProcessMovement + bl ProcessMovement0 movs r1, #0x32 ldrsh r0, [r5, r1] adds r6, r5, #0 diff --git a/asm/non_matching/guardWithSpear/sub_080642B8.inc b/asm/non_matching/guardWithSpear/sub_080642B8.inc index cf29a63e..3d4a9531 100644 --- a/asm/non_matching/guardWithSpear/sub_080642B8.inc +++ b/asm/non_matching/guardWithSpear/sub_080642B8.inc @@ -49,7 +49,7 @@ _08064306: movs r0, #0x2e ldrsh r4, [r5, r0] adds r0, r5, #0 - bl ProcessMovement + bl ProcessMovement0 movs r1, #0x2e ldrsh r0, [r5, r1] adds r6, r5, #0 diff --git a/asm/non_matching/kid/sub_08062948.inc b/asm/non_matching/kid/sub_08062948.inc index 6e77f2ee..e751a7c0 100644 --- a/asm/non_matching/kid/sub_08062948.inc +++ b/asm/non_matching/kid/sub_08062948.inc @@ -75,7 +75,7 @@ _080629B4: strh r1, [r0] _080629D2: adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 movs r3, #0x2e ldrsh r1, [r4, r3] adds r2, r4, #0 diff --git a/asm/non_matching/lilypadLarge/sub_080855E8.inc b/asm/non_matching/lilypadLarge/sub_080855E8.inc index 99680726..36a3e7e8 100644 --- a/asm/non_matching/lilypadLarge/sub_080855E8.inc +++ b/asm/non_matching/lilypadLarge/sub_080855E8.inc @@ -389,7 +389,7 @@ _080858E0: adds r0, r7, #0 bl sub_08085EFC adds r0, r7, #0 - bl sub_080AF134 + bl ProcessMovement4 ldr r1, [r7, #0x54] ldr r0, [r7, #0x2c] cmp r1, r0 diff --git a/asm/non_matching/moldworm/Moldworm.inc b/asm/non_matching/moldworm/Moldworm.inc index 8f9c5c64..55289bb4 100644 --- a/asm/non_matching/moldworm/Moldworm.inc +++ b/asm/non_matching/moldworm/Moldworm.inc @@ -23,12 +23,12 @@ _08023052: adds r1, r4, #0 adds r1, #0x7d strb r0, [r1] - ldr r1, _08023068 @ =gUnk_080CBC38 + ldr r1, _08023068 @ =Moldworm_Functions adds r0, r4, #0 bl EnemyFunctionHandler b _08023090 .align 2, 0 -_08023068: .4byte gUnk_080CBC38 +_08023068: .4byte Moldworm_Functions _0802306C: ldr r0, [r4, #0x50] ldr r0, [r0, #4] diff --git a/asm/non_matching/movement/CalculateEntityTileCollisions.inc b/asm/non_matching/movement/CalculateEntityTileCollisions.inc new file mode 100644 index 00000000..4c7223d6 --- /dev/null +++ b/asm/non_matching/movement/CalculateEntityTileCollisions.inc @@ -0,0 +1,288 @@ + .syntax unified + push {r4, r5, r6, r7, lr} + mov r7, sl + mov r6, sb + mov r5, r8 + push {r5, r6, r7} + sub sp, #0x18 + str r0, [sp] + str r1, [sp, #4] + adds r4, r2, #0 + adds r0, #0x38 + ldrb r0, [r0] + bl GetLayerByIndex + ldr r1, _080AE624 @ =0x00002004 + adds r5, r0, r1 + ldr r2, [sp] + ldr r2, [r2, #0x48] + str r2, [sp, #8] + ldr r0, [sp] + movs r2, #0x2e + ldrsh r1, [r0, r2] + ldr r2, [sp, #8] + movs r0, #0 + ldrsb r0, [r2, r0] + adds r1, r1, r0 + str r1, [sp, #0xc] + ldr r0, [sp] + movs r2, #0x32 + ldrsh r1, [r0, r2] + ldr r2, [sp, #8] + movs r0, #1 + ldrsb r0, [r2, r0] + adds r1, r1, r0 + mov sl, r1 + ldrb r0, [r2, #2] + mov sb, r0 + ldrb r1, [r2, #3] + mov r8, r1 + movs r0, #0xf + ldr r2, [sp, #4] + ands r0, r2 + cmp r0, #0 + beq _080AE65C + cmp r2, #0xf + bhi _080AE628 + ldr r7, [sp, #0xc] + add r7, sb + adds r0, r5, #0 + adds r1, r7, #0 + mov r2, sl + adds r3, r4, #0 + bl IsTileCollision + adds r6, r0, #0 + lsls r6, r6, #1 + mov r2, sl + add r2, r8 + adds r0, r5, #0 + adds r1, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + mov r0, sl + mov r1, r8 + subs r2, r0, r1 + adds r0, r5, #0 + adds r1, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #6 + b _080AE6D2 + .align 2, 0 +_080AE624: .4byte 0x00002004 +_080AE628: + ldr r2, [sp, #0xc] + mov r0, sb + subs r7, r2, r0 + adds r0, r5, #0 + adds r1, r7, #0 + mov r2, sl + adds r3, r4, #0 + bl IsTileCollision + adds r6, r0, #0 + lsls r6, r6, #1 + mov r2, sl + add r2, r8 + adds r0, r5, #0 + adds r1, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + mov r1, sl + mov r0, r8 + subs r2, r1, r0 + adds r0, r5, #0 + adds r1, r7, #0 + b _080AE6C8 +_080AE65C: + ldr r7, [sp, #0xc] + add r7, sb + adds r0, r5, #0 + adds r1, r7, #0 + mov r2, sl + adds r3, r4, #0 + bl IsTileCollision + adds r6, r0, #0 + lsls r6, r6, #1 + mov r1, sl + add r1, r8 + str r1, [sp, #0x10] + adds r0, r5, #0 + adds r1, r7, #0 + ldr r2, [sp, #0x10] + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + mov r2, sl + mov r0, r8 + subs r2, r2, r0 + mov r8, r2 + adds r0, r5, #0 + adds r1, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #2 + ldr r1, [sp, #0xc] + mov r2, sb + subs r7, r1, r2 + adds r0, r5, #0 + adds r1, r7, #0 + mov r2, sl + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + adds r0, r5, #0 + adds r1, r7, #0 + ldr r2, [sp, #0x10] + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + adds r0, r5, #0 + adds r1, r7, #0 + mov r2, r8 +_080AE6C8: + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #2 +_080AE6D2: + ldr r0, [sp, #8] + ldrb r0, [r0, #4] + mov sb, r0 + ldr r1, [sp, #8] + ldrb r1, [r1, #5] + mov r8, r1 + ldr r2, [sp, #4] + subs r2, #8 + str r2, [sp, #4] + movs r0, #0xf + ands r0, r2 + cmp r0, #0 + beq _080AE760 + cmp r2, #0xf + bhi _080AE72C + mov r7, sl + add r7, r8 + adds r0, r5, #0 + ldr r1, [sp, #0xc] + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + ldr r1, [sp, #0xc] + add r1, sb + adds r0, r5, #0 + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + ldr r0, [sp, #0xc] + mov r2, sb + subs r1, r0, r2 + adds r0, r5, #0 + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #5 + b _080AE7D6 +_080AE72C: + mov r0, sl + mov r1, r8 + subs r7, r0, r1 + lsls r6, r6, #4 + adds r0, r5, #0 + ldr r1, [sp, #0xc] + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + ldr r1, [sp, #0xc] + add r1, sb + adds r0, r5, #0 + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + ldr r2, [sp, #0xc] + mov r0, sb + subs r1, r2, r0 + adds r0, r5, #0 + b _080AE7CA +_080AE760: + mov r7, sl + add r7, r8 + adds r0, r5, #0 + ldr r1, [sp, #0xc] + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + ldr r1, [sp, #0xc] + add r1, sb + str r1, [sp, #0x14] + adds r0, r5, #0 + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + ldr r2, [sp, #0xc] + mov r0, sb + subs r2, r2, r0 + mov sb, r2 + adds r0, r5, #0 + mov r1, sb + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #2 + mov r1, sl + mov r2, r8 + subs r7, r1, r2 + adds r0, r5, #0 + ldr r1, [sp, #0xc] + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + adds r0, r5, #0 + ldr r1, [sp, #0x14] + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 + adds r0, r5, #0 + mov r1, sb +_080AE7CA: + adds r2, r7, #0 + adds r3, r4, #0 + bl IsTileCollision + orrs r6, r0 + lsls r6, r6, #1 +_080AE7D6: + ldr r0, [sp] + strh r6, [r0, #0x2a] + add sp, #0x18 + pop {r3, r4, r5} + mov r8, r3 + mov sb, r4 + mov sl, r5 + pop {r4, r5, r6, r7, pc} + .align 2, 0 + .syntax divided diff --git a/asm/non_matching/movement/MoveNorthEast.inc b/asm/non_matching/movement/MoveNorthEast.inc new file mode 100644 index 00000000..65a3ffcc --- /dev/null +++ b/asm/non_matching/movement/MoveNorthEast.inc @@ -0,0 +1,129 @@ + .syntax unified + push {r4, r5, r6, r7, lr} + mov r7, sb + mov r6, r8 + push {r6, r7} + adds r4, r0, #0 + adds r5, r1, #0 + mov r8, r2 + mov sb, r3 + movs r7, #0 + movs r6, #0 + ldrh r0, [r4, #0x2a] + movs r1, #0xe + ands r1, r0 + mov ip, r1 + movs r2, #0xe0 + lsls r2, r2, #8 + ands r2, r0 + adds r3, r2, #0 + cmp r1, #0 + beq _080AE904 + cmp r2, #0 + bne _080AE99E +_080AE904: + orrs r1, r2 + cmp r1, #0 + bne _080AE928 + ldr r1, _080AE924 @ =gSineTable + mov r0, r8 + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r1 + movs r2, #0 + ldrsh r0, [r0, r2] + adds r7, r0, #0 + muls r7, r5, r7 + ldr r0, [r4, #0x30] + subs r0, r0, r7 + str r0, [r4, #0x30] + b _080AE98A + .align 2, 0 +_080AE924: .4byte gSineTable +_080AE928: + mov r2, ip + cmp r2, #2 + bne _080AE942 + lsls r7, r5, #8 + ldr r0, [r4, #0x2c] + adds r0, r0, r7 + str r0, [r4, #0x2c] + adds r0, r4, #0 + movs r1, #4 + mov r2, sb + bl CalculateEntityTileCollisions + b _080AE95C +_080AE942: + movs r0, #0x80 + lsls r0, r0, #7 + cmp r3, r0 + bne _080AE95C + lsls r7, r5, #8 + ldr r0, [r4, #0x30] + subs r0, r0, r7 + str r0, [r4, #0x30] + adds r0, r4, #0 + movs r1, #4 + mov r2, sb + bl CalculateEntityTileCollisions +_080AE95C: + ldrh r2, [r4, #0x2a] + movs r0, #0xe + ands r0, r2 + cmp r0, #0 + bne _080AE97E + ldr r1, _080AE9B4 @ =gSineTable + mov r0, r8 + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r1 + movs r1, #0 + ldrsh r0, [r0, r1] + adds r6, r0, #0 + muls r6, r5, r6 + ldr r0, [r4, #0x30] + subs r0, r0, r6 + str r0, [r4, #0x30] +_080AE97E: + movs r0, #0xe0 + lsls r0, r0, #8 + ands r0, r2 + cmp r0, #0 + bne _080AE99E + ldr r1, _080AE9B4 @ =gSineTable +_080AE98A: + mov r2, r8 + lsls r0, r2, #1 + adds r0, r0, r1 + movs r1, #0 + ldrsh r0, [r0, r1] + adds r6, r0, #0 + muls r6, r5, r6 + ldr r0, [r4, #0x2c] + adds r0, r0, r6 + str r0, [r4, #0x2c] +_080AE99E: + ldr r2, _080AE9B8 @ =0x00003333 + adds r0, r7, r2 + ldr r1, _080AE9BC @ =0x00006665 + cmp r0, r1 + bhi _080AE9C0 + ldr r2, _080AE9B8 @ =0x00003333 + adds r0, r6, r2 + cmp r0, r1 + bhi _080AE9C0 + movs r0, #0 + b _080AE9C2 + .align 2, 0 +_080AE9B4: .4byte gSineTable +_080AE9B8: .4byte 0x00003333 +_080AE9BC: .4byte 0x00006665 +_080AE9C0: + movs r0, #1 +_080AE9C2: + pop {r3, r4} + mov r8, r3 + mov sb, r4 + pop {r4, r5, r6, r7, pc} + .align 2, 0 + .syntax divided diff --git a/asm/non_matching/movement/MoveNorthWest.inc b/asm/non_matching/movement/MoveNorthWest.inc new file mode 100644 index 00000000..b6ab895b --- /dev/null +++ b/asm/non_matching/movement/MoveNorthWest.inc @@ -0,0 +1,129 @@ + .syntax unified + push {r4, r5, r6, r7, lr} + mov r7, sb + mov r6, r8 + push {r6, r7} + adds r4, r0, #0 + adds r5, r1, #0 + mov r8, r2 + mov sb, r3 + movs r7, #0 + movs r6, #0 + ldrh r0, [r4, #0x2a] + movs r1, #0xe + ands r1, r0 + mov ip, r1 + movs r2, #0xe0 + lsls r2, r2, #4 + ands r2, r0 + adds r3, r2, #0 + cmp r1, #0 + beq _080AEEC0 + cmp r2, #0 + bne _080AEF5A +_080AEEC0: + orrs r1, r2 + cmp r1, #0 + bne _080AEEE4 + ldr r1, _080AEEE0 @ =gSineTable + mov r0, r8 + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r1 + movs r2, #0 + ldrsh r0, [r0, r2] + adds r7, r0, #0 + muls r7, r5, r7 + ldr r0, [r4, #0x30] + subs r0, r0, r7 + str r0, [r4, #0x30] + b _080AEF46 + .align 2, 0 +_080AEEE0: .4byte gSineTable +_080AEEE4: + mov r2, ip + cmp r2, #4 + bne _080AEEFE + lsls r7, r5, #8 + ldr r0, [r4, #0x2c] + subs r0, r0, r7 + str r0, [r4, #0x2c] + adds r0, r4, #0 + movs r1, #0x1c + mov r2, sb + bl CalculateEntityTileCollisions + b _080AEF18 +_080AEEFE: + movs r0, #0x80 + lsls r0, r0, #3 + cmp r3, r0 + bne _080AEF18 + lsls r7, r5, #8 + ldr r0, [r4, #0x30] + subs r0, r0, r7 + str r0, [r4, #0x30] + adds r0, r4, #0 + movs r1, #0x1c + mov r2, sb + bl CalculateEntityTileCollisions +_080AEF18: + ldrh r2, [r4, #0x2a] + movs r0, #0xe + ands r0, r2 + cmp r0, #0 + bne _080AEF3A + ldr r1, _080AEF70 @ =gSineTable + mov r0, r8 + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r1 + movs r1, #0 + ldrsh r0, [r0, r1] + adds r6, r0, #0 + muls r6, r5, r6 + ldr r0, [r4, #0x30] + subs r0, r0, r6 + str r0, [r4, #0x30] +_080AEF3A: + movs r0, #0xe0 + lsls r0, r0, #4 + ands r0, r2 + cmp r0, #0 + bne _080AEF5A + ldr r1, _080AEF70 @ =gSineTable +_080AEF46: + mov r2, r8 + lsls r0, r2, #1 + adds r0, r0, r1 + movs r1, #0 + ldrsh r0, [r0, r1] + adds r6, r0, #0 + muls r6, r5, r6 + ldr r0, [r4, #0x2c] + adds r0, r0, r6 + str r0, [r4, #0x2c] +_080AEF5A: + ldr r2, _080AEF74 @ =0x00003333 + adds r0, r7, r2 + ldr r1, _080AEF78 @ =0x00006665 + cmp r0, r1 + bhi _080AEF7C + ldr r2, _080AEF74 @ =0x00003333 + adds r0, r6, r2 + cmp r0, r1 + bhi _080AEF7C + movs r0, #0 + b _080AEF7E + .align 2, 0 +_080AEF70: .4byte gSineTable +_080AEF74: .4byte 0x00003333 +_080AEF78: .4byte 0x00006665 +_080AEF7C: + movs r0, #1 +_080AEF7E: + pop {r3, r4} + mov r8, r3 + mov sb, r4 + pop {r4, r5, r6, r7, pc} + .align 2, 0 + .syntax divided diff --git a/asm/non_matching/movement/MoveSouthEast.inc b/asm/non_matching/movement/MoveSouthEast.inc new file mode 100644 index 00000000..d497d4e9 --- /dev/null +++ b/asm/non_matching/movement/MoveSouthEast.inc @@ -0,0 +1,129 @@ + .syntax unified + push {r4, r5, r6, r7, lr} + mov r7, sb + mov r6, r8 + push {r6, r7} + adds r4, r0, #0 + adds r5, r1, #0 + mov r8, r2 + mov sb, r3 + movs r7, #0 + movs r6, #0 + ldrh r0, [r4, #0x2a] + movs r1, #0xe0 + ands r1, r0 + mov ip, r1 + movs r2, #0xe0 + lsls r2, r2, #8 + ands r2, r0 + adds r3, r2, #0 + cmp r1, #0 + beq _080AEAEC + cmp r2, #0 + bne _080AEB86 +_080AEAEC: + orrs r1, r2 + cmp r1, #0 + bne _080AEB10 + ldr r1, _080AEB0C @ =gSineTable + mov r0, r8 + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r1 + movs r2, #0 + ldrsh r0, [r0, r2] + adds r7, r0, #0 + muls r7, r5, r7 + ldr r0, [r4, #0x30] + subs r0, r0, r7 + str r0, [r4, #0x30] + b _080AEB72 + .align 2, 0 +_080AEB0C: .4byte gSineTable +_080AEB10: + mov r2, ip + cmp r2, #0x20 + bne _080AEB2A + lsls r7, r5, #8 + ldr r0, [r4, #0x2c] + adds r0, r0, r7 + str r0, [r4, #0x2c] + adds r0, r4, #0 + movs r1, #0xc + mov r2, sb + bl CalculateEntityTileCollisions + b _080AEB44 +_080AEB2A: + movs r0, #0x80 + lsls r0, r0, #6 + cmp r3, r0 + bne _080AEB44 + lsls r7, r5, #8 + ldr r0, [r4, #0x30] + adds r0, r0, r7 + str r0, [r4, #0x30] + adds r0, r4, #0 + movs r1, #0xc + mov r2, sb + bl CalculateEntityTileCollisions +_080AEB44: + ldrh r2, [r4, #0x2a] + movs r0, #0xe0 + ands r0, r2 + cmp r0, #0 + bne _080AEB66 + ldr r1, _080AEB9C @ =gSineTable + mov r0, r8 + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r1 + movs r1, #0 + ldrsh r0, [r0, r1] + adds r6, r0, #0 + muls r6, r5, r6 + ldr r0, [r4, #0x30] + subs r0, r0, r6 + str r0, [r4, #0x30] +_080AEB66: + movs r0, #0xe0 + lsls r0, r0, #8 + ands r0, r2 + cmp r0, #0 + bne _080AEB86 + ldr r1, _080AEB9C @ =gSineTable +_080AEB72: + mov r2, r8 + lsls r0, r2, #1 + adds r0, r0, r1 + movs r1, #0 + ldrsh r0, [r0, r1] + adds r6, r0, #0 + muls r6, r5, r6 + ldr r0, [r4, #0x2c] + adds r0, r0, r6 + str r0, [r4, #0x2c] +_080AEB86: + ldr r2, _080AEBA0 @ =0x00003333 + adds r0, r7, r2 + ldr r1, _080AEBA4 @ =0x00006665 + cmp r0, r1 + bhi _080AEBA8 + ldr r2, _080AEBA0 @ =0x00003333 + adds r0, r6, r2 + cmp r0, r1 + bhi _080AEBA8 + movs r0, #0 + b _080AEBAA + .align 2, 0 +_080AEB9C: .4byte gSineTable +_080AEBA0: .4byte 0x00003333 +_080AEBA4: .4byte 0x00006665 +_080AEBA8: + movs r0, #1 +_080AEBAA: + pop {r3, r4} + mov r8, r3 + mov sb, r4 + pop {r4, r5, r6, r7, pc} + .align 2, 0 + .syntax divided diff --git a/asm/non_matching/movement/MoveSouthWest.inc b/asm/non_matching/movement/MoveSouthWest.inc new file mode 100644 index 00000000..563fe38c --- /dev/null +++ b/asm/non_matching/movement/MoveSouthWest.inc @@ -0,0 +1,129 @@ + .syntax unified + push {r4, r5, r6, r7, lr} + mov r7, sb + mov r6, r8 + push {r6, r7} + adds r4, r0, #0 + adds r5, r1, #0 + mov r8, r2 + mov sb, r3 + movs r7, #0 + movs r6, #0 + ldrh r0, [r4, #0x2a] + movs r1, #0xe0 + ands r1, r0 + mov ip, r1 + movs r2, #0xe0 + lsls r2, r2, #4 + ands r2, r0 + adds r3, r2, #0 + cmp r1, #0 + beq _080AECD8 + cmp r2, #0 + bne _080AED72 +_080AECD8: + orrs r1, r2 + cmp r1, #0 + bne _080AECFC + ldr r1, _080AECF8 @ =gSineTable + mov r0, r8 + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r1 + movs r2, #0 + ldrsh r0, [r0, r2] + adds r7, r0, #0 + muls r7, r5, r7 + ldr r0, [r4, #0x30] + subs r0, r0, r7 + str r0, [r4, #0x30] + b _080AED5E + .align 2, 0 +_080AECF8: .4byte gSineTable +_080AECFC: + mov r2, ip + cmp r2, #0x40 + bne _080AED16 + lsls r7, r5, #8 + ldr r0, [r4, #0x2c] + subs r0, r0, r7 + str r0, [r4, #0x2c] + adds r0, r4, #0 + movs r1, #0x14 + mov r2, sb + bl CalculateEntityTileCollisions + b _080AED30 +_080AED16: + movs r0, #0x80 + lsls r0, r0, #2 + cmp r3, r0 + bne _080AED30 + lsls r7, r5, #8 + ldr r0, [r4, #0x30] + adds r0, r0, r7 + str r0, [r4, #0x30] + adds r0, r4, #0 + movs r1, #0x14 + mov r2, sb + bl CalculateEntityTileCollisions +_080AED30: + ldrh r2, [r4, #0x2a] + movs r0, #0xe0 + ands r0, r2 + cmp r0, #0 + bne _080AED52 + ldr r1, _080AED88 @ =gSineTable + mov r0, r8 + adds r0, #0x40 + lsls r0, r0, #1 + adds r0, r0, r1 + movs r1, #0 + ldrsh r0, [r0, r1] + adds r6, r0, #0 + muls r6, r5, r6 + ldr r0, [r4, #0x30] + subs r0, r0, r6 + str r0, [r4, #0x30] +_080AED52: + movs r0, #0xe0 + lsls r0, r0, #4 + ands r0, r2 + cmp r0, #0 + bne _080AED72 + ldr r1, _080AED88 @ =gSineTable +_080AED5E: + mov r2, r8 + lsls r0, r2, #1 + adds r0, r0, r1 + movs r1, #0 + ldrsh r0, [r0, r1] + adds r6, r0, #0 + muls r6, r5, r6 + ldr r0, [r4, #0x2c] + adds r0, r0, r6 + str r0, [r4, #0x2c] +_080AED72: + ldr r2, _080AED8C @ =0x00003333 + adds r0, r7, r2 + ldr r1, _080AED90 @ =0x00006665 + cmp r0, r1 + bhi _080AED94 + ldr r2, _080AED8C @ =0x00003333 + adds r0, r6, r2 + cmp r0, r1 + bhi _080AED94 + movs r0, #0 + b _080AED96 + .align 2, 0 +_080AED88: .4byte gSineTable +_080AED8C: .4byte 0x00003333 +_080AED90: .4byte 0x00006665 +_080AED94: + movs r0, #1 +_080AED96: + pop {r3, r4} + mov r8, r3 + mov sb, r4 + pop {r4, r5, r6, r7, pc} + .align 2, 0 + .syntax divided diff --git a/asm/non_matching/npc5/sub_08060FD0.inc b/asm/non_matching/npc5/sub_08060FD0.inc index 4e81f326..a86ce611 100644 --- a/asm/non_matching/npc5/sub_08060FD0.inc +++ b/asm/non_matching/npc5/sub_08060FD0.inc @@ -64,7 +64,7 @@ _08061040: adds r1, r5, #0 adds r2, r4, #0 movs r3, #6 - bl sub_080AE4CC + bl IsTileCollision cmp r0, #0 beq _08061064 movs r0, #0 diff --git a/asm/non_matching/npc5/sub_08061170.inc b/asm/non_matching/npc5/sub_08061170.inc index fe9d7f84..566b0b23 100644 --- a/asm/non_matching/npc5/sub_08061170.inc +++ b/asm/non_matching/npc5/sub_08061170.inc @@ -5,7 +5,7 @@ adds r4, r0, #0 bl UpdateAnimationSingleFrame adds r0, r4, #0 - bl sub_080AF1EC + bl ProcessMovement6 cmp r0, #0 bne _080611CA adds r0, r4, #0 diff --git a/asm/non_matching/octorokBoss/OctorokBoss_Init.inc b/asm/non_matching/octorokBoss/OctorokBoss_Init.inc index f9d23b7e..80d45b33 100644 --- a/asm/non_matching/octorokBoss/OctorokBoss_Init.inc +++ b/asm/non_matching/octorokBoss/OctorokBoss_Init.inc @@ -56,7 +56,7 @@ _08035764: cmp r2, #0 bne _0803579E adds r0, r4, #0 - bl sub_0804A7D4 + bl GenericDeath b _080359A6 _0803579E: str r2, [r4, #0x64] diff --git a/asm/non_matching/playerItem10/sub_080ACDB0.inc b/asm/non_matching/playerItem10/sub_080ACDB0.inc index 663ffea1..cf9b7271 100644 --- a/asm/non_matching/playerItem10/sub_080ACDB0.inc +++ b/asm/non_matching/playerItem10/sub_080ACDB0.inc @@ -127,7 +127,7 @@ _080ACE90: strh r1, [r4, #0x24] _080ACEA4: adds r0, r4, #0 - bl sub_080AEFB4 + bl ProcessMovement1 b _080ACEB6 .align 2, 0 _080ACEAC: .4byte gUnk_0812AAE8 diff --git a/asm/non_matching/playerItem13/sub_080AD040.inc b/asm/non_matching/playerItem13/sub_080AD040.inc index 21e62945..9a53727b 100644 --- a/asm/non_matching/playerItem13/sub_080AD040.inc +++ b/asm/non_matching/playerItem13/sub_080AD040.inc @@ -66,7 +66,7 @@ _080AD0B4: cmp r0, #0x26 beq _080AD0C8 adds r0, r4, #0 - bl sub_080AF00C + bl ProcessMovement10 _080AD0C8: movs r1, #0x80 lsls r1, r1, #6 diff --git a/asm/non_matching/ropeGolden/sub_08038304.inc b/asm/non_matching/ropeGolden/sub_08038304.inc index 46f0703e..c0743c49 100644 --- a/asm/non_matching/ropeGolden/sub_08038304.inc +++ b/asm/non_matching/ropeGolden/sub_08038304.inc @@ -9,7 +9,7 @@ movs r1, #2 bl UpdateAnimationVariableFrames adds r0, r4, #0 - bl ProcessMovement + bl ProcessMovement0 cmp r0, #0 bne _08038334 adds r0, r4, #0 diff --git a/asm/non_matching/stalfos/sub_0803933C.inc b/asm/non_matching/stalfos/sub_0803933C.inc index 875ca86a..b92cc3bb 100644 --- a/asm/non_matching/stalfos/sub_0803933C.inc +++ b/asm/non_matching/stalfos/sub_0803933C.inc @@ -100,11 +100,11 @@ _080393F8: beq _0803940A adds r0, r5, #0 movs r1, #0x1c - bl sub_0804A9FC + bl Create0x68FX _0803940A: ldr r1, _08039414 @ =Stalfos_Functions adds r0, r5, #0 - bl sub_0804AA30 + bl EnemyFunctionHandlerAfterCollision pop {r4, r5, pc} .align 2, 0 _08039414: .4byte Stalfos_Functions diff --git a/asm/object/fairy.s b/asm/object/fairy.s index c5ddf035..9ef7cce9 100644 --- a/asm/object/fairy.s +++ b/asm/object/fairy.s @@ -334,7 +334,7 @@ _0808D8EE: strb r0, [r4, #0x18] _0808D910: adds r0, r4, #0 - bl sub_080AEFB4 + bl ProcessMovement1 bl AnyPrioritySet cmp r0, #0 bne _0808D954 diff --git a/asm/object/fan.s b/asm/object/fan.s index 42657bff..83e95e44 100644 --- a/asm/object/fan.s +++ b/asm/object/fan.s @@ -212,7 +212,7 @@ _0809EFE6: adds r1, r6, #0 adds r2, r5, #0 movs r3, #9 - bl sub_080AE4CC + bl IsTileCollision cmp r0, #0 beq _0809EFE6 subs r0, r7, #1 diff --git a/asm/object/object1F.s b/asm/object/object1F.s index 9f65249f..6147f3bb 100644 --- a/asm/object/object1F.s +++ b/asm/object/object1F.s @@ -135,7 +135,7 @@ sub_0808776C: @ 0x0808776C _08087784: .4byte gPlayerState _08087788: adds r0, r4, #0 - bl sub_080AEFE0 + bl ProcessMovement2 movs r1, #0xa0 lsls r1, r1, #6 adds r0, r4, #0 diff --git a/asm/object/objectA8.s b/asm/object/objectA8.s index 2ccbef65..69bbbe08 100644 --- a/asm/object/objectA8.s +++ b/asm/object/objectA8.s @@ -276,7 +276,7 @@ _0809FC8A: strb r0, [r4, #0x18] _0809FCAC: adds r0, r4, #0 - bl sub_080AEFB4 + bl ProcessMovement1 bl AnyPrioritySet cmp r0, #0 bne _0809FCF8 diff --git a/asm/subtask2.s b/asm/subtask2.s index 84c29c41..e3f93a6f 100644 --- a/asm/subtask2.s +++ b/asm/subtask2.s @@ -4893,10 +4893,10 @@ Subtask_FadeIn: @ 0x080A7250 ldr r0, _080A731C @ =gCurrentRoomProperties ldr r0, [r0] str r0, [r1, #0x10] - ldr r0, _080A7320 @ =gUnk_02025EB0 + ldr r0, _080A7320 @ =gMapBottom ldr r0, [r0] str r0, [r1, #0x14] - ldr r0, _080A7324 @ =gUnk_0200B650 + ldr r0, _080A7324 @ =gMapTop ldr r0, [r0] str r0, [r1, #0x18] movs r0, #1 @@ -4918,8 +4918,8 @@ _080A7310: .4byte gActiveScriptInfo _080A7314: .4byte gRoomTransition _080A7318: .4byte gPlayerState _080A731C: .4byte gCurrentRoomProperties -_080A7320: .4byte gUnk_02025EB0 -_080A7324: .4byte gUnk_0200B650 +_080A7320: .4byte gMapBottom +_080A7324: .4byte gMapTop thumb_func_start Subtask_Init Subtask_Init: @ 0x080A7328 @@ -4991,10 +4991,10 @@ _080A73B4: ldrb r1, [r5, #0xc] adds r0, #0x8b strb r1, [r0] - ldr r1, _080A7478 @ =gUnk_02025EB0 + ldr r1, _080A7478 @ =gMapBottom ldr r0, [r5, #0x14] str r0, [r1] - ldr r1, _080A747C @ =gUnk_0200B650 + ldr r1, _080A747C @ =gMapTop ldr r0, [r5, #0x18] str r0, [r1] movs r1, #0xea @@ -5061,8 +5061,8 @@ _080A7468: .4byte gFadeControl _080A746C: .4byte gCurrentRoomProperties _080A7470: .4byte gUnk_02032EC0 _080A7474: .4byte gPlayerState -_080A7478: .4byte gUnk_02025EB0 -_080A747C: .4byte gUnk_0200B650 +_080A7478: .4byte gMapBottom +_080A747C: .4byte gMapTop _080A7480: .4byte gActiveScriptInfo _080A7484: .4byte gUnk_03000420 _080A7488: .4byte gPaletteList diff --git a/asm/veneer.s b/asm/veneer.s index 80f63869..0854ae5e 100644 --- a/asm/veneer.s +++ b/asm/veneer.s @@ -88,7 +88,7 @@ UpdateScrollVram: @ 0x08000108 beq _08000136 add r4, pc, #0x20 ldr r4, [r4, r1] - ldr r0, _080001EC @ =gUnk_02025EB0 + ldr r0, _080001EC @ =gMapBottom ldr r0, [r0] cmp r0, #0 beq _08000126 @@ -96,7 +96,7 @@ UpdateScrollVram: @ 0x08000108 ldr r1, _080001F4 @ =gUnk_02021F70 bl _call_via_r4 _08000126: - ldr r0, _080001F8 @ =gUnk_0200B650 + ldr r0, _080001F8 @ =gMapTop ldr r0, [r0] cmp r0, #0 beq _08000136 @@ -196,10 +196,10 @@ GetTileIndex: @ 0x080001DA bx lr .align 2, 0 _080001E8: .4byte gUpdateVisibleTiles -_080001EC: .4byte gUnk_02025EB0 +_080001EC: .4byte gMapBottom _080001F0: .4byte gUnk_02019EE0 _080001F4: .4byte gUnk_02021F70 -_080001F8: .4byte gUnk_0200B650 +_080001F8: .4byte gMapTop _080001FC: .4byte gMapDataTopSpecial _08000200: .4byte gUnk_020344F0 _08000204: .4byte gUnk_08000248 diff --git a/data/const/enemy/acroBandits.s b/data/const/enemy/acroBandits.s index 1274dbcc..cdda3e2d 100644 --- a/data/const/enemy/acroBandits.s +++ b/data/const/enemy/acroBandits.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080CE56C:: @ 080CE56C - .4byte sub_080318C4 - .4byte sub_080318DC - .4byte sub_08031A60 - .4byte sub_0804A7D4 - .4byte sub_08001242 - .4byte nullsub_154 +AcroBandit_Functions:: @ 080CE56C + .4byte AcroBandit_OnTick + .4byte AcroBandit_OnCollision + .4byte AcroBandit_OnKnockback + .4byte GenericDeath + .4byte GenericConfused + .4byte AcroBandit_OnGrabbed gUnk_080CE584:: @ 080CE584 .4byte sub_08031A88 diff --git a/data/const/enemy/cloudPiranha.s b/data/const/enemy/cloudPiranha.s index 3878d908..e4156069 100644 --- a/data/const/enemy/cloudPiranha.s +++ b/data/const/enemy/cloudPiranha.s @@ -7,9 +7,9 @@ gUnk_080CF4F0:: @ 080CF4F0 .4byte sub_08038450 .4byte sub_08038468 - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused .4byte nullsub_163 gUnk_080CF508:: @ 080CF508 diff --git a/data/const/enemy/dust.s b/data/const/enemy/dust.s index e89eb6f0..e8f1e1cb 100644 --- a/data/const/enemy/dust.s +++ b/data/const/enemy/dust.s @@ -7,9 +7,9 @@ gUnk_080D1588:: @ 080D1588 .4byte sub_08044134 .4byte sub_0804414C - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused .4byte sub_0804415C gUnk_080D15A0:: @ 080D15A0 diff --git a/data/const/enemy/enemy4D.s b/data/const/enemy/enemy4D.s index 71415f71..8780a68d 100644 --- a/data/const/enemy/enemy4D.s +++ b/data/const/enemy/enemy4D.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080D0880:: @ 080D0880 - .4byte sub_0803EAFC - .4byte sub_0803EB14 - .4byte sub_0803EB24 - .4byte sub_0803EB34 - .4byte sub_08001242 - .4byte nullsub_21 +Enemy4D_Functions:: @ 080D0880 + .4byte Enemy4D_OnTick + .4byte Enemy4D_OnCollision + .4byte Enemy4D_OnKnockback + .4byte Enemy4D_OnDeath + .4byte GenericConfused + .4byte Enemy4D_OnGrabbed gUnk_080D0898:: @ 080D0898 .4byte sub_0803EB44 diff --git a/data/const/enemy/fireballGuy.s b/data/const/enemy/fireballGuy.s index 771a6b82..7f761fe4 100644 --- a/data/const/enemy/fireballGuy.s +++ b/data/const/enemy/fireballGuy.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080D17E8:: @ 080D17E8 - .4byte sub_080453A4 - .4byte sub_080453BC - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 - .4byte nullsub_172 +FireballGuy_Functions:: @ 080D17E8 + .4byte FireballGuy_OnTick + .4byte FireballGuy_OnCollision + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused + .4byte FireballGuy_OnGrabbed gUnk_080D1800:: @ 080D1800 .4byte sub_080453E8 diff --git a/data/const/enemy/flyingPot.s b/data/const/enemy/flyingPot.s index d068c955..f02b1ecc 100644 --- a/data/const/enemy/flyingPot.s +++ b/data/const/enemy/flyingPot.s @@ -8,9 +8,9 @@ gUnk_080CF244:: @ 080CF244 .4byte sub_0803708C .4byte sub_080370A4 - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused .4byte sub_0803712C gUnk_080CF25C:: @ 080CF25C diff --git a/data/const/enemy/gleerok.s b/data/const/enemy/gleerok.s index 51e32030..15de7dca 100644 --- a/data/const/enemy/gleerok.s +++ b/data/const/enemy/gleerok.s @@ -5,12 +5,12 @@ .align 2 -gUnk_080CD748:: @ 080CD748 - .4byte sub_0802D394 - .4byte sub_0802D394 - .4byte sub_08001324 - .4byte sub_0802D034 - .4byte sub_08001242 +Gleerok_Functions:: @ 080CD748 + .4byte Gleerok_OnTick + .4byte Gleerok_OnTick + .4byte GenericKnockback + .4byte Gleerok_OnDeath + .4byte GenericConfused gUnk_080CD75C:: @ 080CD75C .4byte sub_0802D158 diff --git a/data/const/enemy/keaton.s b/data/const/enemy/keaton.s index 64e84906..0fba5fb0 100644 --- a/data/const/enemy/keaton.s +++ b/data/const/enemy/keaton.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080CE7B0:: @ 080CE7B0 - .4byte sub_080323DC - .4byte sub_080323F4 - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 - .4byte nullsub_155 +Keaton_Functions:: @ 080CE7B0 + .4byte Keaton_OnTick + .4byte Keaton_OnCollision + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused + .4byte Keaton_OnGrabbed gUnk_080CE7C8:: @ 080CE7C8 .4byte sub_08032468 diff --git a/data/const/enemy/miniFireballGuy.s b/data/const/enemy/miniFireballGuy.s index 6a70de35..2acc1d34 100644 --- a/data/const/enemy/miniFireballGuy.s +++ b/data/const/enemy/miniFireballGuy.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080D1868:: @ 080D1868 - .4byte sub_080455BC - .4byte sub_080455D4 - .4byte sub_08001324 - .4byte sub_080455E4 - .4byte sub_08001242 - .4byte nullsub_23 +MiniFireballGuy_Functions:: @ 080D1868 + .4byte MiniFireballGuy_OnTick + .4byte MiniFireballGuy_OnCollision + .4byte GenericKnockback + .4byte MiniFireballGuy_OnDeath + .4byte GenericConfused + .4byte MiniFireballGuy_OnGrabbed gUnk_080D1880:: @ 080D1880 .4byte sub_08045618 diff --git a/data/const/enemy/miniSlime.s b/data/const/enemy/miniSlime.s index 6d3a549f..a11e40e9 100644 --- a/data/const/enemy/miniSlime.s +++ b/data/const/enemy/miniSlime.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080D17C0:: @ 080D17C0 - .4byte sub_08045220 - .4byte sub_08045238 - .4byte sub_08001324 - .4byte sub_0804525C - .4byte sub_08001242 - .4byte nullsub_22 +MiniSlime_Functions:: @ 080D17C0 + .4byte MiniSlime_OnTick + .4byte MiniSlime_OnCollision + .4byte GenericKnockback + .4byte MiniSlime_OnDeath + .4byte GenericConfused + .4byte MiniSlime_OnGrabbed gUnk_080D17D8:: @ 080D17D8 .4byte sub_080452A4 diff --git a/data/const/enemy/rope.s b/data/const/enemy/rope.s index b7b3b1d2..92d12e93 100644 --- a/data/const/enemy/rope.s +++ b/data/const/enemy/rope.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gRope:: @ 080CE448 +Rope_Functions:: @ 080CE448 .4byte Rope_OnTick+1 - .4byte sub_080313AC - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 - .4byte sub_080313E8 + .4byte Rope_OnCollision + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused + .4byte Rope_OnGrabbed gUnk_080CE460:: @ 080CE460 .4byte sub_08031434 diff --git a/data/const/enemy/ropeGolden.s b/data/const/enemy/ropeGolden.s index 69d94b9d..65413cf8 100644 --- a/data/const/enemy/ropeGolden.s +++ b/data/const/enemy/ropeGolden.s @@ -4,12 +4,12 @@ .section .rodata .align 2 -gUnk_080CF4C8:: @ 080CF4C8 +RopeGolden_Functions:: @ 080CF4C8 .4byte RopeGolden_OnTick+1 - .4byte sub_08038210 - .4byte sub_08001324 - .4byte sub_08038234 - .4byte sub_08001242 + .4byte RopeGolden_OnCollision + .4byte GenericKnockback + .4byte RopeGolden_OnDeath + .4byte GenericConfused .4byte RopeGolden_OnTick+1 gUnk_080CF4E0:: @ 080CF4E0 diff --git a/data/const/enemy/slime.s b/data/const/enemy/slime.s index feb5de4b..b08debdd 100644 --- a/data/const/enemy/slime.s +++ b/data/const/enemy/slime.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080D16A4:: @ 080D16A4 - .4byte sub_08044F70 - .4byte sub_08044F88 - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 - .4byte nullsub_171 +Slime_Functions:: @ 080D16A4 + .4byte Slime_OnTick + .4byte Slime_OnCollision + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused + .4byte Slime_OnGrabbed gUnk_080D16BC:: @ 080D16BC .4byte sub_08044FC8 diff --git a/data/const/enemy/smallPesto.s b/data/const/enemy/smallPesto.s index 0faa02ba..98cb42c6 100644 --- a/data/const/enemy/smallPesto.s +++ b/data/const/enemy/smallPesto.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080CE530:: @ 080CE530 - .4byte sub_08031680 - .4byte nullsub_152 - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 - .4byte sub_0803169C +SmallPesto_Functions:: @ 080CE530 + .4byte SmallPesto_OnTick + .4byte SmallPesto_OnCollision + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused + .4byte SmallPesto_OnGrabbed gUnk_080CE548:: @ 080CE548 .4byte sub_08031704 diff --git a/data/const/enemy/tektite.s b/data/const/enemy/tektite.s index cb4646b9..94e67dc7 100644 --- a/data/const/enemy/tektite.s +++ b/data/const/enemy/tektite.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080CDED0:: @ 080CDED0 - .4byte sub_0802F138 - .4byte sub_0802F150 - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_0802F1F0 - .4byte nullsub_16 +Tektite_Functions:: @ 080CDED0 + .4byte Tektite_OnTick + .4byte Tektite_OnCollision + .4byte GenericKnockback + .4byte GenericDeath + .4byte Tektite_OnConfused + .4byte Tektite_OnGrabbed gUnk_080CDEE8:: @ 080CDEE8 .4byte sub_0802F210 diff --git a/data/const/enemy/tektiteGolden.s b/data/const/enemy/tektiteGolden.s index 46928122..453c46bb 100644 --- a/data/const/enemy/tektiteGolden.s +++ b/data/const/enemy/tektiteGolden.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080CF4A0:: @ 080CF4A0 - .4byte sub_08037EE8 - .4byte sub_08037F00 - .4byte sub_08001324 - .4byte sub_08037F58 - .4byte sub_08037F84 - .4byte sub_08037EE8 +TektiteGolden_Functions:: @ 080CF4A0 + .4byte TektiteGolden_OnTick + .4byte TektiteGolden_OnCollision + .4byte GenericKnockback + .4byte TektiteGolden_OnDeath + .4byte TektiteGolden_OnConfused + .4byte TektiteGolden_OnTick gUnk_080CF4B8:: @ 080CF4B8 .4byte sub_08037FA0 diff --git a/data/const/enemy/wisp.s b/data/const/enemy/wisp.s index 09f90f97..2c66267a 100644 --- a/data/const/enemy/wisp.s +++ b/data/const/enemy/wisp.s @@ -4,13 +4,13 @@ .section .rodata .align 2 -gUnk_080CEB74:: @ 080CEB74 - .4byte sub_0803354C - .4byte sub_08033564 - .4byte sub_08001324 - .4byte sub_0804A7D4 - .4byte sub_08001242 - .4byte sub_0803362C +Wisp_Functions:: @ 080CEB74 + .4byte Wisp_OnTick + .4byte Wisp_OnCollision + .4byte GenericKnockback + .4byte GenericDeath + .4byte GenericConfused + .4byte Wisp_OnGrabbed gUnk_080CEB8C:: @ 080CEB8C .4byte sub_08033674 diff --git a/data/const/movement.s b/data/const/movement.s new file mode 100644 index 00000000..e85c3236 --- /dev/null +++ b/data/const/movement.s @@ -0,0 +1,14 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + .align 2 + + +gUnk_08133368:: @ 08133368 +.ifdef EU + @ TODO only small differences + .incbin "data_08132B30/gUnk_08133368_EU.bin" +.else + .incbin "data_08132B30/gUnk_08133368_1_USA-JP-DEMO_USA-DEMO_JP.bin" +.endif diff --git a/data/data_08132B30.s b/data/data_08132B30.s deleted file mode 100644 index 837ad6a0..00000000 --- a/data/data_08132B30.s +++ /dev/null @@ -1,93 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - - -gUnk_08133368:: @ 08133368 -.ifdef EU - @ TODO only small differences - .incbin "data_08132B30/gUnk_08133368_EU.bin" -.else - .incbin "data_08132B30/gUnk_08133368_1_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_08133918:: @ 08133918 - .incbin "data_08132B30/gUnk_08133918.bin" - -gUnk_08133938:: @ 08133938 - .incbin "data_08132B30/gUnk_08133938.bin" - -gUnk_08133958:: @ 08133958 - .incbin "data_08132B30/gUnk_08133958.bin" - -gUnk_08133978:: @ 08133978 - .incbin "data_08132B30/gUnk_08133978.bin" - -gUnk_08133998:: @ 08133998 - .incbin "data_08132B30/gUnk_08133998.bin" - -gUnk_081339B8:: @ 081339B8 - .incbin "data_08132B30/gUnk_081339B8.bin" - -gUnk_081339D8:: @ 081339D8 - .incbin "data_08132B30/gUnk_081339D8.bin" - -gUnk_081339F8:: @ 081339F8 - .incbin "data_08132B30/gUnk_081339F8.bin" - -gUnk_08133A18:: @ 08133A18 - .4byte sub_080AE3E4 - .4byte sub_080AE3E8 - .4byte sub_080AE3EC - .4byte sub_080AE408 - .4byte sub_080AE424 - .4byte sub_080AE440 - .4byte sub_080AE45C - .4byte sub_080AE478 - .4byte sub_080AE494 - .4byte sub_080AE4B0 - -gUnk_08133A40:: @ 08133A40 - .incbin "data_08132B30/gUnk_08133A40.bin" - -gUnk_08133A5A:: @ 08133A5A - .incbin "data_08132B30/gUnk_08133A5A.bin" - -gUnk_08133A67:: @ 08133A67 - .incbin "data_08132B30/gUnk_08133A67.bin" - -gUnk_08133F48:: @ 08133F48 - .4byte sub_080AE800 - .4byte sub_080AE8D8 - .4byte sub_080AE8D8 - .4byte sub_080AE8D8 - .4byte sub_080AE8D8 - .4byte sub_080AE8D8 - .4byte sub_080AE8D8 - .4byte sub_080AE8D8 - .4byte sub_080AE9CC - .4byte sub_080AEAC0 - .4byte sub_080AEAC0 - .4byte sub_080AEAC0 - .4byte sub_080AEAC0 - .4byte sub_080AEAC0 - .4byte sub_080AEAC0 - .4byte sub_080AEAC0 - .4byte sub_080AEBB4 - .4byte sub_080AECAC - .4byte sub_080AECAC - .4byte sub_080AECAC - .4byte sub_080AECAC - .4byte sub_080AECAC - .4byte sub_080AECAC - .4byte sub_080AECAC - .4byte sub_080AEDA0 - .4byte sub_080AEE94 - .4byte sub_080AEE94 - .4byte sub_080AEE94 - .4byte sub_080AEE94 - .4byte sub_080AEE94 - .4byte sub_080AEE94 - .4byte sub_080AEE94 diff --git a/include/asm.h b/include/asm.h index ef1511d2..c0aaa344 100644 --- a/include/asm.h +++ b/include/asm.h @@ -13,9 +13,9 @@ extern void UpdateScrollVram(void); extern u32 sub_080002D0(struct Entity_*); extern u32 sub_080002F0(u32, u32, u32); extern void LoadResourceAsync(const void*, u32, u32); -extern void sub_08001242(struct Entity_*); +extern void GenericConfused(struct Entity_*); extern void sub_08001290(struct Entity_*, u32); -extern void sub_08001324(struct Entity_*); +extern void GenericKnockback(struct Entity_*); extern u32 sub_08002632(struct Entity_*); extern u32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY); extern u32 GravityUpdate(struct Entity_*, u32); diff --git a/include/enemy.h b/include/enemy.h index b07aceb8..4b9fc37b 100644 --- a/include/enemy.h +++ b/include/enemy.h @@ -15,14 +15,14 @@ bool32 EnemyInit(Entity* this); extern u32 GetNextFunction(Entity*); extern void EnemyFunctionHandler(Entity*, EntityActionArray); -extern void sub_08001324(Entity*); +extern void GenericKnockback(Entity*); extern Entity* CreateDeathFx(Entity*, u32, u32); -extern Entity* sub_0804A9FC(Entity*, u32); +extern Entity* Create0x68FX(Entity*, u32); extern void SetChildOffset(Entity*, s32, s32, s32); extern Entity* CreateProjectileWithParent(Entity*, u8, u8); -extern void sub_0804A7D4(Entity*); +extern void GenericDeath(Entity*); extern void sub_08002724(void*, u8*); extern void sub_080026C4(u8*, u8*, u8*, u32); extern void sub_080026F2(u8*, void*, u8*, u32); diff --git a/include/entity.h b/include/entity.h index 3bbc7d5b..2428d972 100644 --- a/include/entity.h +++ b/include/entity.h @@ -66,9 +66,13 @@ typedef enum { /** Direction. */ typedef enum { DirectionNorth = 0x00, /**< North. */ + DirectionNorthEast = 0x04, /**< North East. */ DirectionEast = 0x08, /**< East. */ + DirectionSouthEast = 0x0c, /**< South East. */ DirectionSouth = 0x10, /**< South. */ + DirectionSouthWest = 0x14, /**< South West. */ DirectionWest = 0x18, /**< West. */ + DirectionNorthWest = 0x1c, /**< North West. */ } Direction; typedef struct { @@ -170,7 +174,7 @@ typedef struct Entity_ { /*0x34*/ union SplitWord z; /**< Z position, fixed point Q16.16. */ /*0x38*/ u8 collisionLayer; /**< Collision layer. */ /*0x39*/ s8 interactType; - /*0x3a*/ u8 field_0x3a; + /*0x3a*/ u8 field_0x3a; /**< 4: grabbed by GustJar */ /*0x3b*/ u8 flags2; /*0x3c*/ u8 field_0x3c; /*0x3d*/ s8 iframes; /**< Invulnerability frames. */ @@ -179,10 +183,10 @@ typedef struct Entity_ { /*0x40*/ u8 hurtType; /**< behavior as a collision receiver. */ /*0x41*/ u8 bitfield; /*0x42*/ u8 knockbackDuration; /**< Duration of knockback. */ - /*0x43*/ u8 field_0x43; + /*0x43*/ u8 confusedTime; /**< Frames that this Entity is confused. */ /*0x44*/ u8 damage; /**< Damage this Entity inflicts. */ /*0x45*/ u8 health; /**< Health of this Entity. */ - /*0x46*/ u16 field_0x46; + /*0x46*/ u16 knockbackSpeed; /**< How fast this Entity is knocked back. */ /*0x48*/ Hitbox* hitbox; /**< Hitbox associated with this Entity. */ /*0x4c*/ struct Entity_* field_0x4c; /*0x50*/ struct Entity_* parent; /**< Parent Entity. Sometimes points to associated data. */ @@ -271,7 +275,7 @@ u8* GetSpriteSubEntryOffsetDataPointer(u32, u32); */ u32 GetFacingDirection(Entity* origin, Entity* target); -u32 ProcessMovement(Entity*); +bool32 ProcessMovement0(Entity*); /// @{ /** diff --git a/include/functions.h b/include/functions.h index b6b9770d..44b14c4d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -10,170 +10,204 @@ #include "room.h" #include "structures.h" #include "script.h" +#include "map.h" // Identified - to be sorted into header files -extern void SetDirtTile(u32); -extern bool32 LoadFixedGFX(Entity*, u32); -extern void MenuFadeIn(u32, u32); -extern void TryLoadPrologueHyruleTown(void); +extern void CalculateEntityTileCollisions(Entity*, u32, u32); +extern void CopyOAM(void); +extern void CreateChestSpawner(Entity*); +extern void CreateItemOnGround(Entity*); +extern void CreateRandomItemDrop(Entity*, s32); +extern void DrawDirect(u32, u32); // trampoline to sub_080B27F4 +extern void DrawEntities(void); +extern void DrawOAMCmd(void); +extern void EnemyFunctionHandlerAfterCollision(Entity*, void (*const[])()); +extern u32 EntityWithinDistance(Entity*, s32, s32, s32); extern void FlushSprites(void); +extern void GenericKnockback2(Entity*); +extern LayerStruct* GetLayerByIndex(u32); +extern u32 GetTileIndex(u32, u32); +extern u32 IsColliding(Entity*, Entity*); +extern u32 IsColliding(Entity*, Entity*); +extern u32 IsCollidingPlayer(Entity*); +extern bool32 IsProjectileOffScreen(Entity*); +extern bool32 IsTileCollision(u8*, s32, s32, u32); +extern void LinearMoveAngle(Entity*, u32, u32); +extern void LinearMoveDirection(Entity*, u32, u32); +extern bool32 LoadFixedGFX(Entity*, u32); +extern bool32 LoadSwapGFX(Entity*, u16, u32); +extern void MenuFadeIn(u32, u32); +extern u32 PlayerInRange(Entity*, u32, u32); +extern u32 PlayerInRange(Entity*, u32, u32); +extern bool32 ProcessMovement1(Entity*); +extern bool32 ProcessMovement12(Entity*); +extern bool32 ProcessMovement2(Entity*); +extern bool32 ProcessMovement3(Entity*); +extern bool32 ProcessMovement4(Entity*); +extern bool32 ProcessMovement5(Entity*); +extern bool32 ProcessMovement6(Entity*); +extern bool32 ProcessMovementInternal(Entity*, s32, s32, u32); +extern void SetDirtTile(u32); +extern void SoundReqClipped(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); +extern void SoundReqClipped(Entity*, u32); +extern void TryLoadPrologueHyruleTown(void); +extern void UnloadOBJPalette(Entity*); +extern void UpdateItemAnim(ItemBehavior*); // Unidentified -extern void sub_0805EC9C(Entity*, u32, u32, u32); -extern void sub_0805EC60(Entity*); -extern void sub_0806D0B0(Entity*); -extern void sub_0806D02C(Entity*); -extern void sub_0806FD3C(Entity*); -extern void sub_0805ED14(u32*); -extern void sub_080A7C18(u32, u32, u32); -extern void sub_0804AA30(Entity*, void (*const[])()); -extern void sub_0804A720(Entity*); -extern u32 sub_080AEFE0(Entity*); +extern void sub_08000148(u32, u32, u32); +extern u32 sub_080002A8(u32, u32, u32); +extern u32 sub_080002B4(Entity*, u32, u32); +extern u32 sub_080002B8(Entity*); +extern u32 sub_080002C8(u16, u8); +extern u32 sub_080002CC(Entity*, s32, s32); +extern u32 sub_080002D4(s32, s32, u32); +extern u32 sub_080002E0(u32, u32); +extern s32 sub_080012DC(Entity*); +extern u32 sub_0800132C(Entity*, Entity*); +extern u32 sub_080040A2(Entity*); +extern u32 sub_080040D8(Entity*, u8*, s32, s32); +extern void sub_08004168(Entity*); +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 u32 sub_0800445C(Entity*); +extern void sub_080044AE(Entity*, u32, u32); +extern u32 sub_080044EC(Entity*, u32); +extern void sub_0800451C(Entity*); +extern void sub_08004542(Entity*); +extern void sub_080085B0(Entity*); +extern void sub_08008796(Entity*, u32, u32, u32); +extern void sub_08016AD2(Entity*); +extern u32 sub_0801766C(Entity*); +extern void sub_0801AF18(u8*, u32, u32); +extern void sub_0801AFE4(void); +extern void sub_0801C1D4(void); +extern void sub_0801E104(void); +extern void sub_08030118(u32); +extern u32 sub_08031E04(Entity*); +extern void sub_08031E48(Entity*, Entity*); +extern void sub_08032290(Entity*); +extern u32 sub_080322A4(Entity*); +extern void sub_080322E8(Entity*); +extern void sub_08032338(Entity*); +extern void sub_0803C0AC(Entity*); +extern Entity* sub_08049DF4(u32); +extern u32 sub_08049EE4(Entity*); +extern u32 sub_08049F1C(Entity*, Entity*, u32); +extern u32 sub_08049F84(Entity*, u32); extern u32 sub_08049FA0(Entity*); extern u32 sub_08049FDC(Entity*, u32); -extern u32 sub_08049EE4(Entity*); -extern void sub_08077E54(ItemBehavior*); -extern void sub_080042BA(Entity*, u32); -extern bool32 sub_08077F24(ItemBehavior*, u32); -extern void sub_08079184(); -extern void sub_08077F50(ItemBehavior* beh, u32 arg1); -extern void sub_0807AA80(Entity*); -extern s32 sub_0807887C(Entity*, u32, u32); -extern s32 sub_08078904(); -extern void DrawEntities(void); -extern void CopyOAM(void); -extern void sub_0801E104(void); -extern void sub_080A57F4(void); -extern void sub_08030118(u32); +extern u32 sub_0804A044(Entity*, Entity*, u32); +extern void sub_0804A720(Entity*); +extern void sub_0804AA1C(Entity*); +extern void sub_0804C128(); +extern u32 sub_080542AC(u32); +extern void sub_08054564(); +extern void sub_08054570(void); +extern s32 sub_08056338(void); extern void sub_080575C8(u32); extern void sub_08057688(void); extern void sub_080580B0(u32); -extern void sub_080751E8(u32, u32, void*); -extern void sub_0808091C(const ScreenTransitionData*, u32); -extern void sub_0805BC4C(void); -extern void sub_0807BB68(u32*, u32, u32); -extern void sub_08054570(void); -extern void sub_08059278(void); -extern void sub_0804C128(); extern void sub_08058324(u32); -extern void sub_0801AFE4(void); -extern void sub_0807AABC(Entity*); +extern void sub_08059278(void); extern void sub_0805B4D0(u32); -extern void sub_0807BA8C(u32, u32); -extern void sub_080AF284(void); -extern void sub_080A71C4(u32, u32, u32, u32); -extern void sub_08054564(); -extern void DrawDirect(u32, u32); // trampoline to sub_080B27F4 -extern void sub_0801C1D4(void); -extern void DrawOAMCmd(void); -extern u32 sub_0807953C(void); -extern void sub_080AE068(Entity*); -extern u32 sub_0800445C(Entity*); -extern u32 sub_0801766C(Entity*); -extern void sub_08004168(Entity*); -extern u32 sub_0806F520(); -extern void sub_0806F4E8(Entity*); -extern void sub_080784C8(); -extern u32 sub_0808288C(Entity*, u32, u32, u32); -extern bool32 sub_0806FDA0(Entity*); -extern bool32 LoadSwapGFX(Entity*, u16, u32); -extern void sub_0807921C(); -extern void sub_0807ACCC(Entity*); -extern u32 sub_08079F8C(void); -extern void sub_080787CC(Entity*); -extern u32 sub_080044EC(Entity*, u32); -extern u32 sub_080002B8(Entity*); -extern u32 sub_08049F84(Entity*, u32); -extern u32 sub_0800419C(Entity*, Entity*, u32, u32); -extern void sub_08004542(Entity*); -extern u32 IsCollidingPlayer(Entity*); -extern void sub_080809D4(void); -extern void sub_08080CB4(Entity*); -extern void sub_0807B7D8(u32, u32, u32); -extern void sub_0800451C(Entity*); -extern u32 sub_080040D8(Entity*, u8*, s32, s32); -extern u32 sub_0805F8F8(u32); -extern u32 sub_0805F7A0(u32); +extern void sub_0805BC4C(void); +extern void sub_0805EC60(Entity*); +extern void sub_0805EC9C(Entity*, u32, u32, u32); +extern void sub_0805ED14(u32*); extern u32* sub_0805F25C(u32); -u32 EntityWithinDistance(Entity*, s32, s32, s32); -extern void LinearMoveAngle(Entity*, u32, u32); -extern void sub_080A1ED0(u32, u32, u32); -extern u32 sub_0806F5B0(u32); -extern void sub_08078790(Entity*, u32); -extern void sub_080788E0(Entity*); -extern void sub_08078B48(void); -extern void sub_0807919C(); -extern void sub_0807CAA0(u32, u32); -extern void sub_080085B0(Entity*); -extern u32 sub_08079D48(); -extern u32 sub_080542AC(u32); -extern u32 sub_08079FC4(u32); +extern u32 sub_0805F7A0(u32); extern void sub_0805F8E4(u32 r0, WStruct* r1); -extern Entity* sub_08077C94(ItemBehavior*, u32); -extern Entity* sub_08077C0C(ItemBehavior*, u32); -extern void sub_08077D38(ItemBehavior*, u32); -extern void sub_08077E78(ItemBehavior*, u32); -extern void UpdateItemAnim(ItemBehavior*); -extern u32 sub_0806F948(Entity*); -extern void sub_08077DF4(ItemBehavior*, u32); -extern void sub_08077BB8(ItemBehavior*); -extern bool32 sub_08077EFC(ItemBehavior*); -extern void sub_08078E84(Entity*, Entity*); -extern void sub_080042D0(Entity*, u32, u16); -extern u32 sub_080002A8(u32, u32, u32); -extern bool32 sub_080806BC(u32, u32, u32, u32); -extern bool32 sub_0806FC80(Entity*, Entity*, s32); -extern u32 sub_080002B4(Entity*, u32, u32); -extern u32 sub_080AF134(Entity*); -extern void LinearMoveDirection(Entity*, u32, u32); -extern void sub_080A2AF4(Entity*, u32, u32); -extern u32 sub_080002CC(Entity*, s32, s32); -extern bool32 sub_0807BD14(Entity*, u32); -extern void sub_0807A5B8(u32); -extern Entity* sub_080A2AD4(Entity*); -extern u32 sub_080040A2(Entity*); - -extern Entity* sub_08049DF4(u32); -extern s32 sub_080012DC(Entity*); -extern s32 sub_08056338(void); -extern s32 sub_080AF090(Entity*); -extern u32 PlayerInRange(Entity*, u32, u32); -extern u32 sub_080002C8(u16, u8); -extern u32 sub_080002D4(s32, s32, u32); -extern u32 sub_080002E0(u32, u32); -extern u32 sub_08031E04(Entity*); -extern u32 sub_080322A4(Entity*); -extern u32 sub_08049F1C(Entity*, Entity*, u32); -extern u32 sub_08049F1C(Entity*, Entity*, u32); -extern void SoundReqClipped(Entity*, u32); -extern void SoundReqClipped(Entity*, u32); -extern void sub_08001328(Entity*); -extern void sub_08031E48(Entity*, Entity*); -extern void sub_08032290(Entity*); -extern void sub_08032338(Entity*); -extern void sub_0803C0AC(Entity*); -extern void sub_0804AA1C(Entity*); +extern u32 sub_0805F8F8(u32); +extern void sub_0806D02C(Entity*); +extern void sub_0806D0B0(Entity*); +extern void sub_0806F4E8(Entity*); +extern u32 sub_0806F520(); +extern u32 sub_0806F5B0(u32); extern u32 sub_0806F824(Entity*, Entity*, s32, s32); +extern u32 sub_0806F948(Entity*); +extern void sub_0806FBB4(Entity*); +extern bool32 sub_0806FC80(Entity*, Entity*, s32); +extern void sub_0806FCF4(Entity*, s32, s32, s32); +extern void sub_0806FD3C(Entity*); +extern bool32 sub_0806FDA0(Entity*); +extern void sub_080751E8(u32, u32, void*); +extern void sub_08077BB8(ItemBehavior*); +extern Entity* sub_08077C0C(ItemBehavior*, u32); +extern Entity* sub_08077C94(ItemBehavior*, u32); +extern void sub_08077D38(ItemBehavior*, u32); +extern void sub_08077DF4(ItemBehavior*, u32); +extern void sub_08077E54(ItemBehavior*); +extern void sub_08077E78(ItemBehavior*, u32); +extern bool32 sub_08077EFC(ItemBehavior*); +extern bool32 sub_08077F24(ItemBehavior*, u32); +extern void sub_08077F50(ItemBehavior* beh, u32 arg1); +extern void sub_080784C8(); +extern void sub_08078790(Entity*, u32); +extern void sub_080787CC(Entity*); +extern s32 sub_0807887C(Entity*, u32, u32); +extern void sub_080788E0(Entity*); +extern s32 sub_08078904(); +extern void sub_08078930(Entity*); extern void sub_08078930(Entity*); extern void sub_08078954(Entity*); +extern void sub_08078B48(void); +extern void sub_08078E84(Entity*, Entity*); +extern void sub_08079184(); +extern void sub_0807919C(); +extern void sub_0807921C(); +extern u32 sub_0807953C(void); extern void sub_08079BD8(Entity*); -extern void sub_080AEFB4(Entity*); -extern void UnloadOBJPalette(Entity*); -void sub_080322E8(Entity*); -extern u32 GetTileIndex(u32, u32); -extern void sub_0806FBB4(Entity*); -extern u32 sub_080002D4(s32, s32, u32); -extern void sub_08078930(Entity*); -extern void sub_080044AE(Entity*, u32, u32); -extern void sub_0801AF18(u8*, u32, u32); +extern u32 sub_08079D48(); +extern void sub_08079D84(void); +extern u32 sub_08079F8C(void); +extern u32 sub_08079FC4(u32); +extern void sub_0807A5B8(u32); +extern void sub_0807AA80(Entity*); +extern void sub_0807AABC(Entity*); +extern void sub_0807ACCC(Entity*); +extern void sub_0807B7D8(u32, u32, u32); extern void sub_0807B9B8(s32, s32, s32); -extern void sub_08000148(u32, u32, u32); -extern void CreateRandomItemDrop(Entity*, s32); +extern void sub_0807BA8C(u32, u32); +extern void sub_0807BB68(u32*, u32, u32); +extern bool32 sub_0807BD14(Entity*, u32); +extern void sub_0807CAA0(u32, u32); +extern bool32 sub_080806BC(u32, u32, u32, u32); +extern void sub_0808091C(const ScreenTransitionData*, u32); +extern void sub_080809D4(void); +extern void sub_08080CB4(Entity*); +extern u32 sub_0808288C(Entity*, u32, u32, u32); +extern void sub_080A1ED0(u32, u32, u32); extern Entity* sub_080A2A3C(Entity*, u32, u32, u32); -extern void sub_0806FCF4(Entity*, s32, s32, s32); -extern u32 sub_080041DC(Entity*, u32, u32); -extern void sub_080AE58C(Entity*, u32, u32); -extern u32 sub_0800132C(Entity*, Entity*); -extern bool32 sub_080AE4CC(Entity*, u32, u32, u32); -extern void sub_08008796(Entity*, u32, u32, u32); +extern Entity* sub_080A2AD4(Entity*); +extern void sub_080A2AF4(Entity*, u32, u32); +extern void sub_080A57F4(void); +extern void sub_080A71C4(u32, u32, u32, u32); +extern void sub_080A7C18(u32, u32, u32); +extern void sub_080AE068(Entity*); +extern void sub_080AF284(void); +extern void sub_08078930(Entity*); +extern void sub_08078954(Entity*); +extern void sub_0809EB30(Entity*); +extern void sub_0809EAD8(Entity*); +extern void sub_0809EABC(Entity*); +extern void sub_08079D84(void); +extern void sub_080A2CC0(Entity*, Entity**, u16*); +// extern void sub_080A2CC0(Entity*, void*, void*); +extern void sub_08095C48(Entity*); +extern s32 sub_080012DC(Entity*); +extern u32 sub_0804A024(Entity*, u32, u32); +extern s32 sub_080012DC(Entity*); +extern void sub_08001318(Entity*); +extern void sub_080043A8(Entity*); +extern u32 sub_08049F1C(Entity*, Entity*, u32); +extern void sub_0804AA1C(Entity*); +extern void sub_08027870(Entity*); +extern u32 sub_0804A044(Entity*, Entity*, u32); +extern void sub_0804AA1C(Entity*); +extern void sub_08049CF4(Entity*); #endif diff --git a/include/map.h b/include/map.h new file mode 100644 index 00000000..7c800a5a --- /dev/null +++ b/include/map.h @@ -0,0 +1,20 @@ +#ifndef MAP_H +#define MAP_H + +#include "global.h" + +typedef struct { + u16* bgControlPtr; // Points to the BgSettings.control field for the bg belonging to this layer? + u16 _4[0x1000]; // tilemap data? <-- gMapDataTop / gMapDataBottom + u8 _2004[0x1000]; // more tilemap data? <-- gUnk_0200D654 / gUnk_02027EB4 + u8 _3004[0x1000]; // more tilemap data? <-- gUnk_0200E654 / gUnk_02028EB4 + u8 _4004[0x1000]; // gMetatileTypesTop, gMetatileTypesBottom + s16 _5004[0x500]; // gUnk_02011654,gUnk_0202BEB4 + // Maybe even include here gMetatilesTop, gUnk_02016654 ? + // gMetatilesBottom, gUnk_02030EB4 +} LayerStruct; + +extern LayerStruct gMapTop; +extern LayerStruct gMapBottom; + +#endif // MAP_H \ No newline at end of file diff --git a/linker.ld b/linker.ld index c12a0e0d..59ac6429 100644 --- a/linker.ld +++ b/linker.ld @@ -48,7 +48,7 @@ SECTIONS { . = 0x0000B240; gUnk_0200B240 = .; . = 0x0000B640; gUnk_0200B640 = .; . = 0x0000B644; gUsedPalettes = .; - . = 0x0000B650; gUnk_0200B650 = .; + . = 0x0000B650; gMapTop = .; . = 0x0000B654; gMapDataTop = .; . = 0x0000D654; gUnk_0200D654 = .; . = 0x0000E654; gUnk_0200E654 = .; @@ -96,7 +96,7 @@ SECTIONS { . = 0x00024490; gGFXSlots = .; . = 0x00024494; gUnk_02024494 = .; . = 0x000246B0; gUnk_020246B0 = .; - . = 0x00025EB0; gUnk_02025EB0 = .; + . = 0x00025EB0; gMapBottom = .; . = 0x00025EB4; gMapDataBottom = .; . = 0x00027EB4; gUnk_02027EB4 = .; . = 0x00028EB4; gUnk_02028EB4 = .; @@ -904,7 +904,7 @@ SECTIONS { src/affine.o(.text); src/playerItem/playerItemGustJar.o(.text); asm/vram.o(.text); - asm/movement.o(.text); + src/movement.o(.text); /* library functions */ asm/lib/m4a_asm.o(.text); src/gba/m4a.o(.text); @@ -1680,7 +1680,8 @@ SECTIONS { src/projectile.o(.rodata); data/const/playerItem/playerItemGustJar.o(.rodata); data/gfx/fixed_type_gfx.o(.rodata); - data/data_08132B30.o(.rodata); + data/const/movement.o(.rodata); + src/movement.o(.rodata); data/map/exit_lists.o(.rodata); data/gfx_0813AA54.o(.rodata); data/gfx/sprite_gfx.o(.rodata); diff --git a/src/collision.c b/src/collision.c index 4af9296e..649055cf 100644 --- a/src/collision.c +++ b/src/collision.c @@ -13,18 +13,18 @@ extern u8 gCollidableCount; extern u8 gUnk_080B3740[]; typedef struct { - u8 _0; - u8 _1; - u8 _2; - u8 _3; - u8 _4; - u8 _5; - s8 _6; - u8 _7; - u8 _8; - u8 _9; - u8 _a; - u8 _b; + /*0x00*/ u8 orgKnockbackSpeed; + /*0x01*/ u8 orgIframes; + /*0x02*/ u8 orgKnockbackDuration; + /*0x03*/ u8 tgtDamage; + /*0x04*/ u8 orgConfusedTime; + /*0x05*/ u8 tgtKnockbackSpeed; + /*0x06*/ s8 tgtIframes; + /*0x07*/ u8 tgtKnockbackDuration; + /*0x08*/ u8 orgDamage; + /*0x09*/ u8 tgtConfusedTime; + /*0x0a*/ u8 _a; + /*0x0b*/ u8 _b; } ColSettings; extern ColSettings gCollisionMtx[173 * 34]; @@ -362,7 +362,7 @@ s32 sub_08017B1C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } else { org->knockbackDuration = 0x10; org->iframes = -20; - org->field_0x46 = 640; + org->knockbackSpeed = 640; } return 1; } @@ -374,7 +374,7 @@ s32 sub_08017B58(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) if (x << 24 <= 0) { tgt->field_0x1d = 0; tgt->subAction = 2; - tgt->field_0x46 = 0; + tgt->knockbackSpeed = 0; } } } else { @@ -399,7 +399,7 @@ s32 sub_08017BBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) org->health = sub_08017874(org, tgt); org->knockbackDuration = 12; org->iframes = 30; - org->field_0x46 = 384; + org->knockbackSpeed = 384; if (tgt->iframes == 0) tgt->iframes = -1; return 1; @@ -416,7 +416,7 @@ s32 sub_08017C40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } org->knockbackDuration = 12; org->iframes = 16; - org->field_0x46 = 640; + org->knockbackSpeed = 640; if (tgt->iframes == 0) tgt->iframes = -1; return 1; @@ -431,8 +431,8 @@ s32 sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } else { tgt->knockbackDuration = 12; tgt->iframes = 16; - tgt->field_0x43 = -16; - tgt->field_0x46 = 768; + tgt->confusedTime = -16; + tgt->knockbackSpeed = 768; if (org->iframes == 0) org->iframes = -1; } @@ -444,7 +444,7 @@ s32 sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) org->field_0x7a.HWORD = 600; org->knockbackDuration = 12; org->iframes = 16; - org->field_0x46 = 640; + org->knockbackSpeed = 640; if (tgt->iframes == 0) tgt->iframes = -1; return 1; @@ -484,7 +484,7 @@ int sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) gPlayerEntity.iframes = 12; gPlayerEntity.knockbackDuration = 16; gPlayerEntity.knockbackDirection = DirectionTurnAround(direction); - gPlayerEntity.field_0x46 = 640; + gPlayerEntity.knockbackSpeed = 640; } if (tgt->iframes == 0) tgt->iframes = -1; @@ -493,7 +493,7 @@ int sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) s32 sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { org->knockbackDuration = 2; - org->field_0x46 = 640; + org->knockbackSpeed = 640; if (tgt->iframes == 0) tgt->iframes = -1; return 1; @@ -509,11 +509,11 @@ s32 sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) tgt->damage = temp; gPlayerEntity.knockbackDuration = 12; gPlayerEntity.iframes = 16; - gPlayerEntity.field_0x46 = 384; + gPlayerEntity.knockbackSpeed = 384; } else if (org->kind == PLAYER_ITEM && org->id == 5) { org->knockbackDuration = 8; org->iframes = -6; - org->field_0x46 = 384; + org->knockbackSpeed = 384; gPlayerEntity.iframes = 0x80; } if (tgt->iframes == 0) @@ -526,7 +526,7 @@ s32 sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { - if (tgt->field_0x43 == 0) { + if (tgt->confusedTime == 0) { if (org == &gPlayerEntity) { if (sub_08079F8C() && #ifdef EU @@ -608,10 +608,10 @@ s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) if (DirectionNormalize(tgt->direction - v3) <= 0x18) { org->knockbackDuration = 12; org->iframes = -16; - org->field_0x46 = 640; + org->knockbackSpeed = 640; tgt->knockbackDuration = 12; tgt->iframes = -16; - tgt->field_0x46 = 768; + tgt->knockbackSpeed = 768; sub_08017940(org, tgt); return 1; } @@ -620,7 +620,7 @@ s32 sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } s32 sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { - if (tgt->field_0x43 == 0) { + if (tgt->confusedTime == 0) { if (org == &gPlayerEntity) { if (sub_08079F8C() && #ifdef EU @@ -676,7 +676,7 @@ s32 sub_08018288(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { - if (tgt->field_0x43 == 0) { + if (tgt->confusedTime == 0) { if (org->iframes == 0) org->iframes = -1; if (tgt->iframes == 0) @@ -690,7 +690,7 @@ s32 sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) { u32 temp = 0; - if (tgt->field_0x43 && tgt->kind == ENEMY && org == &gPlayerEntity) { + if (tgt->confusedTime && tgt->kind == ENEMY && org == &gPlayerEntity) { sub_08004484(tgt, org); temp = 1; } @@ -700,27 +700,27 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) } if (!temp) { u32 tmp2; - org->field_0x46 = 16 * settings->_0; - org->iframes = settings->_1; + org->knockbackSpeed = 16 * settings->orgKnockbackSpeed; + org->iframes = settings->orgIframes; if (org->iframes == 0) org->iframes = -1; - org->knockbackDuration = settings->_2; - tgt->damage = settings->_3; + org->knockbackDuration = settings->orgKnockbackDuration; + tgt->damage = settings->tgtDamage; tmp2 = 0xFF; - if (settings->_3 != 0) + if (settings->tgtDamage != 0) org->health = sub_08017874(org, tgt); - if (settings->_4 > org->field_0x43) - org->field_0x43 = settings->_4; - tgt->field_0x46 = 16 * settings->_5; - tgt->iframes = settings->_6; - if (settings->_6 == 0) + if (settings->orgConfusedTime > org->confusedTime) + org->confusedTime = settings->orgConfusedTime; + tgt->knockbackSpeed = 16 * settings->tgtKnockbackSpeed; + tgt->iframes = settings->tgtIframes; + if (settings->tgtIframes == 0) tgt->iframes = -1; - tgt->knockbackDuration = settings->_7; - tmp2 &= org->damage = settings->_8; + tgt->knockbackDuration = settings->tgtKnockbackDuration; + tmp2 &= org->damage = settings->orgDamage; if (tmp2 != 0) tgt->health = sub_08017874(tgt, org); - if (settings->_9 > tgt->field_0x43) - tgt->field_0x43 = settings->_9; + if (settings->tgtConfusedTime > tgt->confusedTime) + tgt->confusedTime = settings->tgtConfusedTime; } if (settings->_a & 1) sub_08017940(org, tgt); @@ -733,15 +733,15 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) parent->iframes = tgt->iframes; parent->knockbackDirection = direction; parent->knockbackDuration = tgt->knockbackDuration; - if (parent->field_0x43 == 0) - parent->field_0x43 = tgt->field_0x43; - parent->field_0x46 = tgt->field_0x46; + if (parent->confusedTime == 0) + parent->confusedTime = tgt->confusedTime; + parent->knockbackSpeed = tgt->knockbackSpeed; parent->field_0x4c = org; } } if (org->kind == PLAYER_ITEM) { if (org->id == 1) { - if (settings->_8) { + if (settings->orgDamage) { sub_080179EC(org, tgt); } } else if (org->id == 4) { @@ -749,7 +749,7 @@ s32 sub_08018308(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) sub_08017A90(org, tgt); } } else if (org->id == 3) { - if (settings->_9) { + if (settings->tgtConfusedTime) { SoundReqClipped(tgt, SFX_HIT); } } else if (org->id == 5) { diff --git a/src/coord.c b/src/coord.c index 92c97f46..43f86a67 100644 --- a/src/coord.c +++ b/src/coord.c @@ -35,13 +35,6 @@ static_assert(sizeof(struct_gUnk_020000C0) == 0x40); extern struct_gUnk_020000C0 gUnk_020000C0[0x30]; extern u32 gSpritePtrs[]; -typedef struct { - u32 _0; - u16 _4[0x1000]; - u8 _2004[0x2000]; -} struct_02025EB0; -extern struct_02025EB0 gUnk_02025EB0; - extern u16 gExtraFrameOffsets[]; extern s8 gUnk_08126EE4[]; extern const u16 gUnk_080046A4[]; @@ -93,21 +86,21 @@ u32 sub_0806F3E4(Entity* ent) { return 0; switch (gPlayerState.field_0x1d) { case 1: - ent->field_0x46 += 64; + ent->knockbackSpeed += 64; break; case 2: - ent->field_0x46 += 128; + ent->knockbackSpeed += 128; break; case 3: - ent->field_0x46 += 192; + ent->knockbackSpeed += 192; break; } - if (ent->field_0x46 > 0x500) - ent->field_0x46 = 0x500; + if (ent->knockbackSpeed > 0x500) + ent->knockbackSpeed = 0x500; p = &gUnk_08126EE4[gPlayerEntity.animationState & 0xE]; tmp_ent.x.HALF.HI = p[0] + gPlayerEntity.x.HALF.HI; tmp_ent.y.HALF.HI = p[1] + gPlayerEntity.y.HALF.HI; - LinearMoveDirection(ent, ent->field_0x46, GetFacingDirection(ent, &tmp_ent)); + LinearMoveDirection(ent, ent->knockbackSpeed, GetFacingDirection(ent, &tmp_ent)); if (sub_0800419C(&tmp_ent, ent, 4, 4)) { u32 state = ent->field_0x1c & 0xF; if (state == 2) { @@ -233,16 +226,16 @@ u32 sub_0806F798(Entity* ent) { } u32 sub_0806F7D0(Entity* ent) { - return gUnk_02025EB0._2004[sub_0806F730(ent)]; + return gMapBottom._2004[sub_0806F730(ent)]; } u32 sub_0806F7EC(Entity* ent) { - return gUnk_02025EB0._4[sub_0806F730(ent)]; + return gMapBottom._4[sub_0806F730(ent)]; } u32 sub_0806F804(u32 x, u32 y) { u32 idx = ((x >> 4) & 0x3F) + 4 * (y & 0x3F0); - return gUnk_02025EB0._4[idx]; + return gMapBottom._4[idx]; } u32 sub_0806F824(Entity* a, Entity* b, s32 x, s32 y) { diff --git a/src/createEnemy.c b/src/createEnemy.c index 4550f3ad..ed4da368 100644 --- a/src/createEnemy.c +++ b/src/createEnemy.c @@ -1,6 +1,7 @@ #include "enemy.h" -void sub_0804AA30(Entity* entity, void (*fntable[])()) { +/** Unsets bitfield 0x80 before calling GetNextFunction, so that the enemyFunction 1 is not called. */ +void EnemyFunctionHandlerAfterCollision(Entity* entity, void (*fntable[])()) { u32 idx; entity->bitfield &= ~0x80; idx = GetNextFunction(entity); diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 1df406b1..7b92aec0 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -10,7 +10,7 @@ extern Entity* gUnk_020000B0; extern void (*const gUnk_080012C8[])(Entity*); -extern void (*const gUnk_080CE56C[])(Entity*); +extern void (*const AcroBandit_Functions[])(Entity*); extern void (*const gUnk_080CE584[])(Entity*); extern void (*const gUnk_080CE58C[])(Entity*); extern void (*const gUnk_080CE5C8[])(Entity*); @@ -31,16 +31,16 @@ void AcroBandit(Entity* this) { gUnk_080012C8[index](this); } else { - gUnk_080CE56C[GetNextFunction(this)](this); + AcroBandit_Functions[GetNextFunction(this)](this); SetChildOffset(this, 0, 1, -0x10); } } -void sub_080318C4(Entity* this) { +void AcroBandit_OnTick(Entity* this) { gUnk_080CE584[this->type](this); } -void sub_080318DC(Entity* this) { +void AcroBandit_OnCollision(Entity* this) { Entity* brother; if (this->bitfield != 0x80 && this->bitfield != 0x81) { @@ -96,20 +96,20 @@ void sub_080318DC(Entity* this) { } } - if (this->field_0x43) - sub_0804A9FC(this, 0x1c); + if (this->confusedTime) + Create0x68FX(this, FX_STARS); - sub_0804AA30(this, gUnk_080CE56C); + EnemyFunctionHandlerAfterCollision(this, AcroBandit_Functions); } -void sub_08031A60(Entity* this) { +void AcroBandit_OnKnockback(Entity* this) { if (this->iframes > 0) GravityUpdate(this, Q_8_8(24.0)); - sub_08001324(this); + GenericKnockback(this); } -void nullsub_154(void) { +void AcroBandit_OnGrabbed(void) { /* ... */ } @@ -400,7 +400,7 @@ void sub_08032008(Entity* this) { if (this->direction & 0xf) this->spriteSettings.flipX = (this->direction >> 4 ^ 1); - ProcessMovement(this); + ProcessMovement0(this); } else { if (this->field_0x76.HALF.HI == 0) { if (EntityWithinDistance(this, parent->x.HALF.HI, parent->y.HALF.HI, 1) == 0) { @@ -457,7 +457,7 @@ void sub_08032160(Entity* this) { } void sub_080321E8(Entity* this) { - sub_080AEFE0(this); + ProcessMovement2(this); if (sub_080044EC(this, 0x2000) == 0) this->action = 8; diff --git a/src/enemy/armos.c b/src/enemy/armos.c index c2df4d80..df7a0705 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -68,11 +68,11 @@ void sub_080301D4(ArmosEntity* this) { sub_080309C8(this, 6); sub_080309E8(this); } - if (super->field_0x43 != 0) { - sub_0804A9FC(super, 0x1c); + if (super->confusedTime != 0) { + Create0x68FX(super, 0x1c); } this->unk_81 = super->health; - sub_0804AA30(super, gUnk_080CE124); + EnemyFunctionHandlerAfterCollision(super, gUnk_080CE124); } void sub_08030240(ArmosEntity* this) { @@ -81,7 +81,7 @@ void sub_08030240(ArmosEntity* this) { GetNextFrame(super); } } - sub_08001242(super); + GenericConfused(super); } void nullsub_17(ArmosEntity* this) { @@ -331,7 +331,7 @@ void sub_080309E8(ArmosEntity* this) { } void sub_08030A04(ArmosEntity* this) { - ProcessMovement(super); + ProcessMovement0(super); if ((super->frame & 1) != 0) { super->frame = super->frame & 0xfe; EnqueueSFX(SFX_101); @@ -339,7 +339,7 @@ void sub_08030A04(ArmosEntity* this) { } void (*const gUnk_080CE124[])(ArmosEntity*) = { - sub_080301BC, sub_080301D4, (void (*)(ArmosEntity*))sub_08001324, (void (*)(ArmosEntity*))sub_0804A7D4, + sub_080301BC, sub_080301D4, (void (*)(ArmosEntity*))GenericKnockback, (void (*)(ArmosEntity*))GenericDeath, sub_08030240, nullsub_17, }; void (*const gUnk_080CE13C[])(ArmosEntity*) = { diff --git a/src/enemy/ballChainSoldier.c b/src/enemy/ballChainSoldier.c index dad421f3..f29df68c 100644 --- a/src/enemy/ballChainSoldier.c +++ b/src/enemy/ballChainSoldier.c @@ -17,44 +17,43 @@ typedef struct { extern Entity* gUnk_020000B0; -void (*const gUnk_080D06E0[])(BallChainSoldierEntity*); +void (*const BallChainSoldier_Functions[])(BallChainSoldierEntity*); void (*const gUnk_080D06F8[])(BallChainSoldierEntity*); const u8 gUnk_080D0724[]; const u16 gUnk_080D0728[]; const u16 gUnk_080D0730[]; -extern u32 sub_0804A044(Entity*, Entity*, u32); -extern void sub_0803E86C(BallChainSoldierEntity*); -extern void sub_0803E9A4(BallChainSoldierEntity*); -extern bool32 sub_0803E9D4(BallChainSoldierEntity*); -extern void sub_0803E8CC(BallChainSoldierEntity*); -extern void sub_0803E92C(BallChainSoldierEntity*); -extern bool32 sub_0803EA64(BallChainSoldierEntity*); -extern void sub_0803E94C(BallChainSoldierEntity*, u32); -extern bool32 sub_0803EAD0(BallChainSoldierEntity*, u32); +void sub_0803E86C(BallChainSoldierEntity*); +void sub_0803E9A4(BallChainSoldierEntity*); +bool32 sub_0803E9D4(BallChainSoldierEntity*); +void sub_0803E8CC(BallChainSoldierEntity*); +void sub_0803E92C(BallChainSoldierEntity*); +bool32 sub_0803EA64(BallChainSoldierEntity*); +void sub_0803E94C(BallChainSoldierEntity*, u32); +bool32 sub_0803EAD0(BallChainSoldierEntity*, u32); void BallChainSoldier(Entity* this) { - EnemyFunctionHandler(this, (EntityActionArray)gUnk_080D06E0); + EnemyFunctionHandler(this, (EntityActionArray)BallChainSoldier_Functions); } -void sub_0803E538(BallChainSoldierEntity* this) { +void BallChainSoldier_OnTick(BallChainSoldierEntity* this) { gUnk_080D06F8[super->action](this); } -void sub_0803E550(BallChainSoldierEntity* this) { - sub_0804AA30(super, gUnk_080D06E0); +void BallChainSoldier_OnCollision(BallChainSoldierEntity* this) { + EnemyFunctionHandlerAfterCollision(super, BallChainSoldier_Functions); } -void sub_0803E560(BallChainSoldierEntity* this) { - sub_08001324(super); - sub_0803E538(this); +void BallChainSoldier_OnKnockback(BallChainSoldierEntity* this) { + GenericKnockback(super); + BallChainSoldier_OnTick(this); } -void BallChainSoldier_CreateDeathFx(BallChainSoldierEntity* this) { +void BallChainSoldier_OnDeath(BallChainSoldierEntity* this) { CreateDeathFx(super, 0xff, 0x57); } -void nullsub_20(BallChainSoldierEntity* this) { +void BallChainSoldier_OnGrabbed(BallChainSoldierEntity* this) { } void BallChainSoldier_Init(BallChainSoldierEntity* this) { @@ -92,7 +91,7 @@ void sub_0803E61C(BallChainSoldierEntity* this) { sub_0803E9A4(this); if (sub_0803E9D4(this) == 0) { if (super->knockbackDuration == 0) { - if (ProcessMovement(super) == 0) { + if (ProcessMovement0(super) == 0) { sub_0803E86C(this); return; } @@ -321,13 +320,13 @@ bool32 sub_0803EAD0(BallChainSoldierEntity* this, u32 distance) { return EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI - 4, distance); } -void (*const gUnk_080D06E0[])(BallChainSoldierEntity*) = { - sub_0803E538, - sub_0803E550, - sub_0803E560, - BallChainSoldier_CreateDeathFx, - (void (*const)(BallChainSoldierEntity*))sub_08001242, - nullsub_20, +void (*const BallChainSoldier_Functions[])(BallChainSoldierEntity*) = { + BallChainSoldier_OnTick, + BallChainSoldier_OnCollision, + BallChainSoldier_OnKnockback, + BallChainSoldier_OnDeath, + (void (*const)(BallChainSoldierEntity*))GenericConfused, + BallChainSoldier_OnGrabbed, }; void (*const gUnk_080D06F8[])(BallChainSoldierEntity*) = { diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index 6b5ddbb6..207cf1c7 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -8,12 +8,10 @@ #include "enemy.h" #include "functions.h" -extern u32 PlayerInRange(Entity*, u32, u32); - u32 sub_08021D00(Entity*); void sub_08021D44(Entity* this, u32 direction); -extern void (*const gUnk_080CB590[])(Entity*); +extern void (*const Beetle_Functions[])(Entity*); extern void (*const gUnk_080CB5A8[])(Entity*); extern void (*const gUnk_080CB5C8[])(Entity*); extern void (*const gUnk_080CB5D4[])(Entity*); @@ -22,18 +20,18 @@ extern const s8 gUnk_080CB5DC[]; extern const s8 gUnk_080CB5E4[]; void Beetle(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CB590); + EnemyFunctionHandler(this, Beetle_Functions); } -void sub_08021768(Entity* this) { +void Beetle_OnTick(Entity* this) { gUnk_080CB5A8[this->action](this); } -void sub_08021780(Entity* this) { +void Beetle_OnCollision(Entity* this) { switch (this->bitfield) { case 0x80: if (gPlayerState.framestate == PL_STATE_CLIMB) { - sub_08021768(this); + Beetle_OnTick(this); } else { this->action = 5; this->actionDelay = 0xb4; @@ -47,19 +45,19 @@ void sub_08021780(Entity* this) { } break; case 0x93: - sub_08021768(this); + Beetle_OnTick(this); break; } if (this->health == 0) this->knockbackDuration = 0; - sub_0804AA30(this, gUnk_080CB590); + EnemyFunctionHandlerAfterCollision(this, Beetle_Functions); } -void sub_08021818(Entity* this) { +void Beetle_OnDeath(Entity* this) { if (this->type == 0) { - sub_0804A7D4(this); + GenericDeath(this); } else { Entity* ent = this->parent; if (ent) { @@ -70,7 +68,7 @@ void sub_08021818(Entity* this) { } } -void sub_08021848(Entity* this) { +void Beetle_OnGrabbed(Entity* this) { if (sub_0806F520(this)) { gUnk_080CB5C8[this->subAction](this); } else { @@ -89,7 +87,7 @@ void nullsub_130(Entity* this) { void sub_08021888(Entity* this) { if (sub_0806F3E4(this)) - sub_08021818(this); + Beetle_OnDeath(this); } void Beetle_Initialize(Entity* this) { @@ -114,7 +112,7 @@ void sub_080218CC(Entity* this) { GetNextFrame(this); if (this->frame & 1) { - sub_080AEFE0(this); + ProcessMovement2(this); if (sub_080044EC(this, 0x1c00) == 0) this->frameDuration = 1; } @@ -184,7 +182,7 @@ void sub_08021A64(Entity* this) { } sub_08021D44(this, tmp); } - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); } } @@ -206,7 +204,7 @@ void sub_08021AD8(Entity* this) { this->direction = (u8)tmp; EnqueueSFX(SFX_PLY_JUMP); } - sub_080AEFE0(this); + ProcessMovement2(this); if (!GravityUpdate(this, 0x1800)) this->frameDuration = 1; } @@ -265,7 +263,7 @@ void sub_08021B64(Entity* this) { void sub_08021C58(Entity* this) { GetNextFrame(this); if (this->frame & 1) { - sub_080AEFE0(this); + ProcessMovement2(this); if (GravityUpdate(this, 0x1800) == 0) this->frameDuration = 1; } @@ -322,13 +320,13 @@ void sub_08021D44(Entity* this, u32 direction) { } // clang-format off -void (*const gUnk_080CB590[])(Entity*) = { - sub_08021768, - sub_08021780, - sub_08001324, - sub_08021818, - sub_08001242, - sub_08021848, +void (*const Beetle_Functions[])(Entity*) = { + Beetle_OnTick, + Beetle_OnCollision, + GenericKnockback, + Beetle_OnDeath, + GenericConfused, + Beetle_OnGrabbed, }; void (*const gUnk_080CB5A8[])(Entity*) = { diff --git a/src/enemy/bladeTrap.c b/src/enemy/bladeTrap.c index 3af99a33..f5531def 100644 --- a/src/enemy/bladeTrap.c +++ b/src/enemy/bladeTrap.c @@ -10,13 +10,11 @@ #include "room.h" #include "functions.h" -extern void sub_080A2CC0(Entity*, void*, void*); - void BladeTrap(Entity* this) { if (this->action == 0) { this->action = 1; this->child = GetCurrentRoomProperty(this->type); - sub_080A2CC0(this, &this->child, &this->field_0x74); + sub_080A2CC0(this, &this->child, &this->field_0x74.HWORD); } if (!(this->direction & 0x80)) { LinearMoveUpdate(this); diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index 116febb2..42c3d2b1 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -11,27 +11,24 @@ #include "object.h" #include "functions.h" -extern void sub_08078930(Entity*); -extern void sub_08078954(Entity*); - void sub_0802CB68(Entity*); void sub_0802CBC4(Entity*); void sub_0802CC18(Entity*); -extern void (*const gUnk_080CD5D4[])(Entity*); +extern void (*const Bobomb_Functions[])(Entity*); extern void (*const gUnk_080CD5EC[])(Entity*); extern void (*const gUnk_080CD600[])(Entity*); extern void (*const gUnk_080CD618[])(Entity*); void Bobomb(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CD5D4); + EnemyFunctionHandler(this, Bobomb_Functions); } -void sub_0802C670(Entity* this) { +void Bobomb_OnTick(Entity* this) { gUnk_080CD5EC[this->action](this); } -void sub_0802C688(Entity* this) { +void Bobomb_OnCollision(Entity* this) { if (this->bitfield & 0x80) { switch (this->bitfield & 0x7f) { case 0: @@ -68,10 +65,10 @@ void sub_0802C688(Entity* this) { break; } } - sub_0804AA30(this, gUnk_080CD5D4); + EnemyFunctionHandlerAfterCollision(this, Bobomb_Functions); } -void sub_0802C7AC(Entity* this) { +void Bobomb_OnGrabbed(Entity* this) { if (this->subAction < 3 && !sub_0806F520(this)) { this->subAction = 0; this->field_0xf = 1; @@ -140,8 +137,8 @@ void sub_0802C8B8(Entity* this) { sub_0802CBC4(this); } -void sub_0802C8C4(Entity* this) { - sub_0804A7D4(this); +void Bobomb_OnDeath(Entity* this) { + GenericDeath(this); this->spriteSettings.draw = 0; } @@ -161,7 +158,7 @@ void sub_0802C8D8(Entity* this) { void sub_0802C91C(Entity* this) { GetNextFrame(this); - ProcessMovement(this); + ProcessMovement0(this); if (this->field_0x82.HALF.LO) { if (this->collisions) { sub_0800417E(this, this->collisions); @@ -305,13 +302,13 @@ void sub_0802CC18(Entity* this) { } // clang-format off -void (*const gUnk_080CD5D4[])(Entity*) = { - sub_0802C670, - sub_0802C688, - sub_08001324, - sub_0802C8C4, - sub_08001242, - sub_0802C7AC, +void (*const Bobomb_Functions[])(Entity*) = { + Bobomb_OnTick, + Bobomb_OnCollision, + GenericKnockback, + Bobomb_OnDeath, + GenericConfused, + Bobomb_OnGrabbed, }; void (*const gUnk_080CD5EC[])(Entity*) = { diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 1ceea7db..4602b3a2 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -24,7 +24,7 @@ void sub_0802B264(Entity*); extern void (*const gUnk_080012C8[])(Entity*); -extern void (*const gUnk_080CD0F0[])(Entity*); +extern void (*const BombPeahat_Functions[])(Entity*); extern void (*const gUnk_080CD108[])(Entity*); extern void (*const gUnk_080CD120[])(Entity*); extern void (*const gUnk_080CD134[])(Entity*); @@ -41,11 +41,11 @@ void BombPeahat(Entity* this) { if ((this->type == 2) && (iVar1 = sub_080012DC(this), iVar1)) { gUnk_080012C8[iVar1](this); } else { - gUnk_080CD0F0[GetNextFunction(this)](this); + BombPeahat_Functions[GetNextFunction(this)](this); } } -void sub_0802A84C(Entity* this) { +void BombPeahat_OnTick(Entity* this) { switch (this->type) { default: gUnk_080CD108[this->action](this); @@ -61,14 +61,14 @@ void sub_0802A84C(Entity* this) { } } -void sub_0802A8AC(Entity* this) { +void BombPeahat_OnCollision(Entity* this) { this->field_0x80.HALF.HI = 0; if (this->type < 2) { InitializeAnimation(this, 0); } } -void sub_0802A8C8(Entity* this) { +void BombPeahat_OnGrabbed(Entity* this) { gUnk_080CD140[this->subAction](this); } @@ -705,13 +705,13 @@ void sub_0802B264(Entity* this) { #endif // clang-format off -void (*const gUnk_080CD0F0[])(Entity*) = { - sub_0802A84C, - sub_0802A8AC, - sub_08001324, - sub_0804A7D4, - sub_08001242, - sub_0802A8C8, +void (*const BombPeahat_Functions[])(Entity*) = { + BombPeahat_OnTick, + BombPeahat_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + BombPeahat_OnGrabbed, }; void (*const gUnk_080CD108[])(Entity*) = { diff --git a/src/enemy/bombarossa.c b/src/enemy/bombarossa.c index de59188d..f3455a21 100644 --- a/src/enemy/bombarossa.c +++ b/src/enemy/bombarossa.c @@ -11,18 +11,16 @@ typedef struct { u16 unk_0x76; } BombarossaEntity; -void (*const gUnk_080CEB38[])(Entity*); +void (*const Bombarossa_Functions[])(Entity*); const s8 gUnk_080CEB50[]; -extern void sub_080A2CC0(Entity*, void*, void*); - void sub_0803350C(BombarossaEntity* this); void Bombarossa(Entity* this) { - gUnk_080CEB38[GetNextFunction(this)](this); + Bombarossa_Functions[GetNextFunction(this)](this); } -void sub_080333D4(BombarossaEntity* this) { +void Bombarossa_OnTick(BombarossaEntity* this) { if (super->action == 0) { super->action = 1; super->actionDelay = Random() & 0xf; @@ -41,7 +39,7 @@ void sub_080333D4(BombarossaEntity* this) { } } -void sub_08033448(BombarossaEntity* this) { +void Bombarossa_OnCollision(BombarossaEntity* this) { Entity* ent; switch (super->bitfield & 0x7f) { default: @@ -56,12 +54,12 @@ void sub_08033448(BombarossaEntity* this) { case 27: case 29: case 30: - sub_0804AA30(super, gUnk_080CEB38); + EnemyFunctionHandlerAfterCollision(super, Bombarossa_Functions); break; } } -void nullsub_158() { +void Bombarossa_OnGrabbed() { } void sub_0803350C(BombarossaEntity* this) { @@ -74,8 +72,13 @@ void sub_0803350C(BombarossaEntity* this) { } } -void (*const gUnk_080CEB38[])(Entity*) = { - (EntityActionPtr)sub_080333D4, (EntityActionPtr)sub_08033448, sub_08001324, sub_0804A7D4, sub_08001242, nullsub_158, +void (*const Bombarossa_Functions[])(Entity*) = { + (EntityActionPtr)Bombarossa_OnTick, + (EntityActionPtr)Bombarossa_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + Bombarossa_OnGrabbed, }; const s8 gUnk_080CEB50[] = { diff --git a/src/enemy/bowMoblin.c b/src/enemy/bowMoblin.c index d8737c42..b65f1ea3 100644 --- a/src/enemy/bowMoblin.c +++ b/src/enemy/bowMoblin.c @@ -35,7 +35,7 @@ u32 sub_0803C6F8(BowMoblinEntity*); u32 sub_0803C568(BowMoblinEntity*); void sub_0803C664(BowMoblinEntity*); -void (*const gUnk_080CFF78[])(Entity*); +void (*const BowMoblin_Functions[])(Entity*); void (*const gUnk_080CFF90[])(BowMoblinEntity*); const s8 gUnk_080CFFA4[8]; @@ -44,21 +44,21 @@ const u16 gUnk_080CFFBC[4]; const s8 gUnk_080CFFC4[8]; void BowMoblin(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CFF78); + EnemyFunctionHandler(this, BowMoblin_Functions); SetChildOffset(this, 0, 1, -0x18); } -void sub_0803C180(BowMoblinEntity* this) { +void BowMoblin_OnTick(BowMoblinEntity* this) { gUnk_080CFF90[super->action](this); } -void sub_0803C198(BowMoblinEntity* this) { +void BowMoblin_OnCollision(BowMoblinEntity* this) { Entity* pEVar1; - if (super->field_0x43 != 0) { - sub_0804A9FC(super, 0x1c); + if (super->confusedTime != 0) { + Create0x68FX(super, FX_STARS); } - sub_0804AA30(super, (EntityActionArray)gUnk_080CFF78); + EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)BowMoblin_Functions); if ((super->bitfield & 0x80) != 0) { sub_0803C5F0(this); pEVar1 = super->child; @@ -68,7 +68,7 @@ void sub_0803C198(BowMoblinEntity* this) { } } -void nullsub_168(BowMoblinEntity* this) { +void BowMoblin_OnGrabbed(BowMoblinEntity* this) { } void sub_0803C1E0(BowMoblinEntity* this) { @@ -365,7 +365,7 @@ void sub_0803C6DC(BowMoblinEntity* this) { super->speed = tmp; } - ProcessMovement(super); + ProcessMovement0(super); GetNextFrame(super); } @@ -388,9 +388,13 @@ void sub_0803C714(BowMoblinEntity* this) { PositionRelative(super, child, offsetX, offsetY); } -void (*const gUnk_080CFF78[])(Entity*) = { - (EntityActionPtr)sub_0803C180, (EntityActionPtr)sub_0803C198, sub_08001324, sub_0804A7D4, sub_08001242, - (EntityActionPtr)nullsub_168, +void (*const BowMoblin_Functions[])(Entity*) = { + (EntityActionPtr)BowMoblin_OnTick, + (EntityActionPtr)BowMoblin_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + (EntityActionPtr)BowMoblin_OnGrabbed, }; void (*const gUnk_080CFF90[])(BowMoblinEntity*) = { diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index b30080b8..b473854c 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -14,22 +14,22 @@ #include "game.h" #include "item.h" +void sub_08028E9C(Entity*); +void sub_08028EDC(Entity*); +bool32 sub_08028F98(Entity*, u32); +bool32 sub_08028FDC(Entity*); +void sub_08028FFC(Entity*); +void sub_08029078(Entity*); +void sub_080290E0(Entity*, u32); +void sub_080290FC(Entity*); bool32 sub_0802915C(Entity*); bool32 sub_080291DC(Entity*); void sub_0802922C(Entity*); -void sub_08028E9C(Entity*); -void sub_08028FFC(Entity*); void sub_0802925C(Entity*); -void sub_080290E0(Entity*, u32); -bool32 sub_08028F98(Entity*, u32); -void sub_08029078(Entity*); -bool32 sub_08028FDC(Entity*); -void sub_080290FC(Entity*); -void sub_08028EDC(Entity*); extern const struct SalesOffering gUnk_080CC954[]; extern const u8 gUnk_080CC9C0[]; -extern void (*const gUnk_080CC9C8[])(Entity*); +extern void (*const BusinessScrub_Functions[])(Entity*); extern void (*const gUnk_080CC9E0[])(Entity*); extern const u8 gUnk_080CCA04[]; @@ -45,14 +45,14 @@ struct SalesOffering { }; void BusinessScrub(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CC9C8); + EnemyFunctionHandler(this, BusinessScrub_Functions); } -void sub_0802891C(Entity* this) { +void BusinessScrub_OnTick(Entity* this) { gUnk_080CC9E0[this->action](this); } -void sub_08028934(Entity* this) { +void BusinessScrub_OnCollision(Entity* this) { Entity* pEVar1; if (this->hitType == 1 && (this->bitfield & 0x7f) == 0x42) { @@ -69,7 +69,7 @@ void sub_08028934(Entity* this) { } } -void nullsub_140(Entity* this) { +void BusinessScrub_OnGrabbed(Entity* this) { /* ... */ } @@ -206,7 +206,7 @@ void sub_08028BC4(Entity* this) { this->actionDelay = 0x1e; this->field_0xf = 5; sub_080290E0(this, 0); - iVar1 = sub_0804A9FC(this, 0x1c); + iVar1 = Create0x68FX(this, FX_STARS); if (iVar1 != NULL) { iVar1->spritePriority.b0 = 3; iVar1->z.HALF.HI -= 12; @@ -585,13 +585,13 @@ const u8 gUnk_080CC9C0[] = { }; -void (*const gUnk_080CC9C8[])(Entity*) = { - sub_0802891C, - sub_08028934, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_140, +void (*const BusinessScrub_Functions[])(Entity*) = { + BusinessScrub_OnTick, + BusinessScrub_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + BusinessScrub_OnGrabbed, }; void (*const gUnk_080CC9E0[])(Entity*) = { diff --git a/src/enemy/businessScrubPrologue.c b/src/enemy/businessScrubPrologue.c index 7fe66de5..036c4e19 100644 --- a/src/enemy/businessScrubPrologue.c +++ b/src/enemy/businessScrubPrologue.c @@ -12,17 +12,15 @@ typedef struct { u32 unk_84; } BusinessScrubPrologueEntity; +extern void sub_080954AC(Entity*, u32); extern u16 script_BusinessScrubIntro[]; -void (*const gUnk_080D19FC[])(Entity*); +void (*const BusinessScrubPrologue_Functions[])(Entity*); void (*const gUnk_080D1A14[])(BusinessScrubPrologueEntity*); const u8 gUnk_080D1A38[]; const s8 gUnk_080D1A3E[]; const u16 gUnk_080D1A4E[]; -extern void sub_08095C48(Entity* this); -extern void sub_080954AC(Entity*, u32); - void sub_08046030(BusinessScrubPrologueEntity*, u32); bool32 sub_08045F54(BusinessScrubPrologueEntity*, u32); void sub_08045FF0(BusinessScrubPrologueEntity*); @@ -31,16 +29,16 @@ void sub_0804604C(BusinessScrubPrologueEntity*); void sub_08045FA0(BusinessScrubPrologueEntity*); void BusinessScrubPrologue(Entity* this) { - EnemyFunctionHandler(this, gUnk_080D19FC); + EnemyFunctionHandler(this, BusinessScrubPrologue_Functions); } -void sub_08045B98(BusinessScrubPrologueEntity* this) { +void BusinessScrubPrologue_OnTick(BusinessScrubPrologueEntity* this) { super->spriteSettings.draw = 1; gUnk_080D1A14[super->action](this); sub_0800445C(super); } -void sub_08045BC8(BusinessScrubPrologueEntity* this) { +void BusinessScrubPrologue_OnCollision(BusinessScrubPrologueEntity* this) { Entity* ent; if (super->hitType == 1) { if ((super->bitfield & 0x7f) == 0x42) { @@ -61,7 +59,7 @@ void sub_08045BC8(BusinessScrubPrologueEntity* this) { } } -void nullsub_174(BusinessScrubPrologueEntity* this) { +void BusinessScrubPrologue_OnGrabbed(BusinessScrubPrologueEntity* this) { } void sub_08045C3C(BusinessScrubPrologueEntity* this) { @@ -187,7 +185,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) { super->action = 5; super->subAction = 0; sub_08046030(this, 0); - ent = sub_0804A9FC(super, 0x1c); + ent = Create0x68FX(super, FX_STARS); if (ent) { ent->spritePriority.b0 = 3; ent->z.HALF.HI -= 0xc; @@ -329,9 +327,13 @@ void sub_08046078(BusinessScrubPrologueEntity* this) { sub_0804AA1C(super); } -void (*const gUnk_080D19FC[])(Entity*) = { - (EntityActionPtr)sub_08045B98, (EntityActionPtr)sub_08045BC8, sub_08001324, sub_0804A7D4, sub_08001242, - (EntityActionPtr)nullsub_174, +void (*const BusinessScrubPrologue_Functions[])(Entity*) = { + (EntityActionPtr)BusinessScrubPrologue_OnTick, + (EntityActionPtr)BusinessScrubPrologue_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + (EntityActionPtr)BusinessScrubPrologue_OnGrabbed, }; void (*const gUnk_080D1A14[])(BusinessScrubPrologueEntity*) = { diff --git a/src/enemy/chaser.c b/src/enemy/chaser.c index 2efbe92b..16a61b2a 100644 --- a/src/enemy/chaser.c +++ b/src/enemy/chaser.c @@ -8,13 +8,8 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080012DC(Entity*); -extern u32 sub_0804A024(Entity*, u32, u32); -extern bool32 sub_080AF038(Entity*); - extern void (*const gUnk_080012C8[])(Entity*); - -extern void (*const gUnk_080CD27C[])(Entity*); +extern void (*const Chaser_Functions[])(Entity*); extern void (*const gUnk_080CD298[])(Entity*); void Chaser(Entity* this) { @@ -22,11 +17,11 @@ void Chaser(Entity* this) { if (idx) { gUnk_080012C8[idx](this); } else { - gUnk_080CD27C[GetNextFunction(this)](this); + Chaser_Functions[GetNextFunction(this)](this); } } -void sub_0802B518(Entity* this) { +void Chaser_OnTick(Entity* this) { gUnk_080CD298[this->action](this); } @@ -54,7 +49,7 @@ void sub_0802B56C(Entity* this) { this->speed = 0x40; } - if (sub_080AF038(this)) { + if (ProcessMovement12(this)) { if (this->animIndex != 1) { InitializeAnimation(this, 1); } @@ -77,14 +72,14 @@ void sub_0802B5C8(Entity* this) { } // clang-format off -void (*const gUnk_080CD27C[])(Entity*) = { - sub_0802B518, - sub_0802B518, - sub_08001324, - sub_0804A7D4, - sub_08001242, - sub_0802B518, - sub_0802B518, +void (*const Chaser_Functions[])(Entity*) = { + Chaser_OnTick, + Chaser_OnTick, + GenericKnockback, + GenericDeath, + GenericConfused, + Chaser_OnTick, + Chaser_OnTick, }; void (*const gUnk_080CD298[])(Entity*) = { diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 8a5f90fb..6b01d0a9 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -9,14 +9,6 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080012DC(Entity*); -extern void sub_08001318(Entity*); -extern void sub_080043A8(Entity*); -extern u32 sub_08049F1C(Entity*, Entity*, u32); -extern u32 PlayerInRange(Entity*, u32, u32); -extern void sub_0804AA1C(Entity*); -extern void sub_080AF160(Entity*); - extern Entity* gUnk_020000B0; void sub_0801F328(Entity*); @@ -35,7 +27,7 @@ u32 sub_0801FBD0(Entity*); void Chuchu_JumpAtPlayer(Entity*); extern void (*const gUnk_080012C8[])(Entity*); -extern void (*const gUnk_080CA21C[])(Entity*); +extern void (*const Chuchu_Functions[])(Entity*); extern void (*const gUnk_080CA234[])(Entity*); extern void (*const gUnk_080CA25C[])(Entity*); extern void (*const gUnk_080CA288[])(Entity*); @@ -77,7 +69,7 @@ void Chuchu(Entity* this) { break; } this->field_0x80.HALF.HI = index; - gUnk_080CA21C[GetNextFunction(this)](this); + Chuchu_Functions[GetNextFunction(this)](this); if (*(char*)(*(int*)&this->field_0x68 + 10) == 0x1c) { SetChildOffset(this, 0, 1, -0x10); } else if (this->type == 2) { @@ -101,7 +93,7 @@ void Chuchu_OnTick(Entity* this) { } } -void sub_0801EF40(Entity* this) { +void Chuchu_OnCollision(Entity* this) { u8 health; if (this->type == 2) { @@ -115,7 +107,7 @@ void sub_0801EF40(Entity* this) { if (health) { if (this->bitfield == 0x94) { sub_0801FB68(this); - sub_0804A9FC(this, 0x1c); + Create0x68FX(this, FX_STARS); InitializeAnimation(this, 6); } else if (this->field_0x80.HALF.LO != health) { sub_0801FB68(this); @@ -127,12 +119,12 @@ void sub_0801EF40(Entity* this) { InitializeAnimation(this, 9); } this->field_0x80.HALF.LO = this->health; - sub_0804AA30(this, gUnk_080CA21C); + EnemyFunctionHandlerAfterCollision(this, Chuchu_Functions); } -void sub_0801EFD8(Entity* this) { - if (sub_0806F520(this) == 0 && this->field_0x43) { - sub_0804A9FC(this, 0x1c); +void Chuchu_OnGrabbed(Entity* this) { + if (sub_0806F520(this) == 0 && this->confusedTime) { + Create0x68FX(this, FX_STARS); InitializeAnimation(this, 6); } else { if (this->animIndex != 8) { @@ -144,17 +136,17 @@ void sub_0801EFD8(Entity* this) { } } -void sub_0801F02C(Entity* this) { +void Chuchu_OnKnockback(Entity* this) { if (this->animIndex == 6) GetNextFrame(this); sub_08001318(this); } -void sub_0801F048(Entity* this) { +void Chuchu_OnDeath(Entity* this) { GravityUpdate(this, 0x1800); GetNextFrame(this); if (this->type == 0) { - sub_0804A7D4(this); + GenericDeath(this); } else if (this->type == 1) { CreateDeathFx(this, 0xf2, 0); } else { @@ -162,10 +154,10 @@ void sub_0801F048(Entity* this) { } } -void sub_0801F084(Entity* this) { +void Chuchu_OnConfused(Entity* this) { if ((this->frame & 0x80) == 0) GetNextFrame(this); - sub_08001242(this); + GenericConfused(this); } void sub_0801F0A4(Entity* this) { @@ -200,7 +192,7 @@ void sub_0801F12C(Entity* this) { if ((this->field_0xf++ & 7) == 0) { this->direction = sub_08049F84(this, 1); } - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); if (--this->actionDelay == 0) { if (PlayerInRange(this, 1, 0x38)) { @@ -222,7 +214,7 @@ void sub_0801F1B0(Entity* this) { this->hitType = 90; EnqueueSFX(SFX_12B); } - sub_080AEFE0(this); + ProcessMovement2(this); if (GravityUpdate(this, 0x4000) == 0) GetNextFrame(this); } else { @@ -257,7 +249,7 @@ void sub_0801F270(Entity* this) { this->direction = sub_08049F84(this, 1); } - sub_080AF160(this); + ProcessMovement5(this); GetNextFrame(this); if (sub_0801FBD0(this)) return; @@ -405,7 +397,7 @@ void sub_0801F508(Entity* this) { if (tmp == 4) { this->direction = sub_08049F84(this, 1); } - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); } } @@ -418,7 +410,7 @@ void sub_0801F584(Entity* this) { this->hitType = 91; EnqueueSFX(SFX_12B); } - sub_080AEFE0(this); + ProcessMovement2(this); if (GravityUpdate(this, 0x4000) == 0) GetNextFrame(this); @@ -464,7 +456,7 @@ void sub_0801F688(Entity* this) { if (sub_0801FBD0(this) || this->field_0x82.HALF.HI) { this->direction = sub_08049F84(this, 1); - sub_080AF160(this); + ProcessMovement5(this); GetNextFrame(this); } else { sub_0801F748(this); @@ -559,7 +551,7 @@ void sub_0801F884(Entity* this) { if (this->field_0xf) { this->field_0xf--; } else { - Entity* ent = sub_0804A9FC(this, 0x1b); + Entity* ent = Create0x68FX(this, FX_LIGHTNING_STRIKE); if (ent) { ent->type2 = 64; this->action = 4; @@ -583,7 +575,7 @@ void sub_0801F8C0(Entity* this) { if (tmp == 4) { this->direction = GetFacingDirection(this, gUnk_020000B0); } - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); } } @@ -595,7 +587,7 @@ void sub_0801F940(Entity* this) { this->frame ^= 1; EnqueueSFX(SFX_12B); } - sub_080AEFE0(this); + ProcessMovement2(this); if (GravityUpdate(this, 0x4000) == 0) GetNextFrame(this); } else { @@ -635,7 +627,7 @@ void sub_0801F9E0(Entity* this) { void sub_0801FA30(Entity* this) { if (sub_0801FBD0(this)) { this->direction = sub_08049F84(this, 1); - sub_080AF160(this); + ProcessMovement5(this); GetNextFrame(this); } else if (sub_08049FDC(this, 1) == 0) { this->action = 9; @@ -728,13 +720,13 @@ void Chuchu_JumpAtPlayer(Entity* this) { } // clang-format off -void (*const gUnk_080CA21C[])(Entity*) = { +void (*const Chuchu_Functions[])(Entity*) = { Chuchu_OnTick, - sub_0801EF40, - sub_0801F02C, - sub_0801F048, - sub_0801F084, - sub_0801EFD8, + Chuchu_OnCollision, + Chuchu_OnKnockback, + Chuchu_OnDeath, + Chuchu_OnConfused, + Chuchu_OnGrabbed, }; void (*const gUnk_080CA234[])(Entity*) = { diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index 4204609f..c910f882 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -6,10 +6,9 @@ */ #include "enemy.h" +#include "functions.h" -void sub_08027870(Entity*); - -extern void (*const gUnk_080CC19C[])(Entity*); +extern void (*const ChuchuBoss_Functions[])(Entity*); extern void (*const gUnk_080CC1B0[])(Entity*); extern const u8 gUnk_080CC1B8[]; extern void (*const gUnk_080CC1C8[])(Entity*); @@ -27,18 +26,18 @@ extern const u16 gUnk_080CC2BC[]; extern const s8 gUnk_080CC2DC[]; void ChuchuBoss(Entity* this) { - gUnk_080CC19C[GetNextFunction(this)]((Entity*)this); + ChuchuBoss_Functions[GetNextFunction(this)]((Entity*)this); } -void sub_08025CBC(Entity* this) { - sub_08001324(this); +void ChuchuBoss_OnKnockback(Entity* this) { + GenericKnockback(this); if (this->type == 0) { sub_08027870(this); } } -void sub_08025DC0(Entity*); -void sub_08025CD4(Entity*); +void ChuchuBoss_OnTick(Entity*); +void ChuchuBoss_OnDeath(Entity*); void sub_08025DD8(Entity*); void sub_08026060(Entity*); void sub_08026110(Entity*); @@ -77,12 +76,12 @@ void sub_080269CC(Entity*); void sub_08026BE8(Entity*); // clang-format off -void (*const gUnk_080CC19C[])(Entity*) = { - sub_08025DC0, - sub_08025DC0, - sub_08025CBC, - sub_08025CD4, - sub_08001242, +void (*const ChuchuBoss_Functions[])(Entity*) = { + ChuchuBoss_OnTick, + ChuchuBoss_OnTick, + ChuchuBoss_OnKnockback, + ChuchuBoss_OnDeath, + GenericConfused, }; void (*const gUnk_080CC1B0[])(Entity*) = { diff --git a/src/enemy/crow.c b/src/enemy/crow.c index 4dfdc773..efe2b3e5 100644 --- a/src/enemy/crow.c +++ b/src/enemy/crow.c @@ -15,7 +15,7 @@ typedef struct { u8 unk_84; } CrowEntity; -void (*const gUnk_080CE978[])(Entity*); +void (*const Crow_Functions[])(Entity*); void (*const gUnk_080CE990[])(CrowEntity*); void (*const gUnk_080CE9A4[])(CrowEntity*); extern Entity* gUnk_020000B0; @@ -26,10 +26,10 @@ void sub_08032B38(CrowEntity* this); void sub_08032B10(CrowEntity* this); void Crow(Entity* this) { - gUnk_080CE978[GetNextFunction(this)](this); + Crow_Functions[GetNextFunction(this)](this); } -void sub_08032810(CrowEntity* this) { +void Crow_OnTick(CrowEntity* this) { gUnk_080CE990[super->action](this); if (super->field_0xf) { if (--super->field_0xf == 0) { @@ -38,7 +38,7 @@ void sub_08032810(CrowEntity* this) { } } -void sub_08032844(CrowEntity* this) { +void Crow_OnCollision(CrowEntity* this) { if (super->bitfield & 0x80) { if ((super->bitfield & 0x3f) == 0) { COLLISION_OFF(super); @@ -64,7 +64,7 @@ void sub_08032844(CrowEntity* this) { GetNextFrame(super); } -void sub_080328B8(CrowEntity* this) { +void Crow_OnGrabbed(CrowEntity* this) { gUnk_080CE9A4[super->subAction](this); GetNextFrame(super); @@ -90,7 +90,7 @@ void sub_0803290C(CrowEntity* this) { void sub_08032914(CrowEntity* this) { if (sub_0806F3E4(super)) { - sub_0804A7D4(super); + GenericDeath(super); } } @@ -266,9 +266,9 @@ void sub_08032B38(CrowEntity* this) { GetNextFrame(super); } -void (*const gUnk_080CE978[])(Entity*) = { - (EntityActionPtr)sub_08032810, (EntityActionPtr)sub_08032844, sub_08001324, sub_0804A7D4, sub_08001242, - (EntityActionPtr)sub_080328B8, +void (*const Crow_Functions[])(Entity*) = { + (EntityActionPtr)Crow_OnTick, (EntityActionPtr)Crow_OnCollision, GenericKnockback, GenericDeath, GenericConfused, + (EntityActionPtr)Crow_OnGrabbed, }; void (*const gUnk_080CE990[])(CrowEntity*) = { diff --git a/src/enemy/cuccoAggr.c b/src/enemy/cuccoAggr.c index fa6f8bf8..24c8555a 100644 --- a/src/enemy/cuccoAggr.c +++ b/src/enemy/cuccoAggr.c @@ -18,7 +18,7 @@ typedef struct { u16 y; } PosOffset; -void (*const gUnk_080CF778[])(Entity*); +void (*const CuccoAggr_Functions[])(Entity*); void (*const gUnk_080CF790[])(CuccoAggrEntity*); void (*const gUnk_080CF7AC[])(CuccoAggrEntity*); const u8 gUnk_080CF7BC[]; @@ -30,33 +30,33 @@ const u16 gUnk_080CF828[]; const s8 gCuccoAggrFxHorizontalOffsets[]; const u8 gCuccoAggrFx[]; -extern void sub_080391B4(CuccoAggrEntity* this); -extern void sub_08039218(CuccoAggrEntity* this); -extern void CuccoAggr_CreateFx(CuccoAggrEntity* this); -extern void sub_08039120(CuccoAggrEntity* this); -extern void sub_08039140(CuccoAggrEntity* this); -extern void sub_0803901C(CuccoAggrEntity* this); -extern void sub_08039298(CuccoAggrEntity* this); -extern void sub_080390F8(CuccoAggrEntity* this); -extern void sub_080390C0(CuccoAggrEntity* this); -extern bool32 CuccoAggr_IsOutsideScroll(CuccoAggrEntity* this); +void sub_080391B4(CuccoAggrEntity* this); +void sub_08039218(CuccoAggrEntity* this); +void CuccoAggr_CreateFx(CuccoAggrEntity* this); +void sub_08039120(CuccoAggrEntity* this); +void sub_08039140(CuccoAggrEntity* this); +void sub_0803901C(CuccoAggrEntity* this); +void sub_08039298(CuccoAggrEntity* this); +void sub_080390F8(CuccoAggrEntity* this); +void sub_080390C0(CuccoAggrEntity* this); +bool32 CuccoAggr_IsOutsideScroll(CuccoAggrEntity* this); void CuccoAggr(Entity* this) { u32 index = sub_080012DC(this); if (index) { gUnk_080012C8[index](this); } else { - gUnk_080CF778[GetNextFunction(this)](this); + CuccoAggr_Functions[GetNextFunction(this)](this); SetChildOffset(this, 0, 1, -0x10); sub_080391B4((CuccoAggrEntity*)this); } } -void sub_08038CF8(CuccoAggrEntity* this) { +void CuccoAggr_OnTick(CuccoAggrEntity* this) { gUnk_080CF790[super->action](this); } -void sub_08038D10(CuccoAggrEntity* this) { +void CuccoAggr_OnCollision(CuccoAggrEntity* this) { if (super->type != 2) { if (this->unk_7a == 0 && CheckRoomFlag(1) == 0) { if (super->health <= 0xbf) { @@ -70,14 +70,14 @@ void sub_08038D10(CuccoAggrEntity* this) { CuccoAggr_CreateFx(this); } - if (super->field_0x43) { - sub_0804A9FC(super, 0x1c); + if (super->confusedTime) { + Create0x68FX(super, FX_STARS); } - sub_0804AA30(super, gUnk_080CF778); + EnemyFunctionHandlerAfterCollision(super, CuccoAggr_Functions); } -void nullsub_165(CuccoAggrEntity* this) { +void CuccoAggr_OnGrabbed(CuccoAggrEntity* this) { } void sub_08038D78(CuccoAggrEntity* this) { @@ -122,7 +122,7 @@ void sub_08038E18(CuccoAggrEntity* this) { super->spritePriority.b1 = 1; super->spritePriority.b0 = 4; super->direction = Random() & 0x1f; - ProcessMovement(super); + ProcessMovement0(super); UpdateSpriteForCollisionLayer(super); } } @@ -148,7 +148,7 @@ void sub_08038ED0(CuccoAggrEntity* this) { } void sub_08038EE0(CuccoAggrEntity* this) { - ProcessMovement(super); + ProcessMovement0(super); GetNextFrame(super); sub_08039298(this); if (GravityUpdate(super, 0x1C00) == 0) { @@ -172,7 +172,7 @@ void sub_08038F20(CuccoAggrEntity* this) { void sub_08038F44(CuccoAggrEntity* this) { super->direction = GetFacingDirection(&gPlayerEntity, super); sub_080390F8(this); - ProcessMovement(super); + ProcessMovement0(super); sub_080044EC(super, 0x1800); GetNextFrame(super); sub_08039298(this); @@ -332,9 +332,13 @@ void sub_08039298(CuccoAggrEntity* this) { } } -void (*const gUnk_080CF778[])(Entity*) = { - (EntityActionPtr)sub_08038CF8, (EntityActionPtr)sub_08038D10, sub_08001324, sub_0804A7D4, sub_08001242, - (EntityActionPtr)nullsub_165, +void (*const CuccoAggr_Functions[])(Entity*) = { + (EntityActionPtr)CuccoAggr_OnTick, + (EntityActionPtr)CuccoAggr_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + (EntityActionPtr)CuccoAggr_OnGrabbed, }; void (*const gUnk_080CF790[])(CuccoAggrEntity*) = { diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index 5acaf9d3..2099cd13 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -14,22 +14,22 @@ void sub_08022B0C(Entity*); u32 sub_08022B20(Entity*); void sub_08022B44(Entity*); -extern void (*const gUnk_080CBB64[])(Entity*); +extern void (*const CuccoChickAggr_Functions[])(Entity*); extern void (*const gUnk_080CBB7C[])(Entity*); void CuccoChickAggr(Entity* this) { - gUnk_080CBB64[GetNextFunction(this)](this); + CuccoChickAggr_Functions[GetNextFunction(this)](this); } -void sub_08022934(Entity* this) { +void CuccoChickAggr_OnTick(Entity* this) { gUnk_080CBB7C[this->action](this); } -void sub_0802294C(Entity* this) { - sub_0804AA30(this, gUnk_080CBB64); +void CuccoChickAggr_OnCollision(Entity* this) { + EnemyFunctionHandlerAfterCollision(this, CuccoChickAggr_Functions); } -void nullsub_132(Entity* this) { +void CuccoChickAggr_OnGrabbed(Entity* this) { } void sub_08022960(Entity* this) { @@ -56,7 +56,7 @@ void sub_08022988(Entity* this) { EnqueueSFX(SFX_VO_CHEEP); } - ProcessMovement(this); + ProcessMovement0(this); if (GravityUpdate(this, 0x2000) == 0) { if (--this->actionDelay == 0) { sub_08022A88(this); @@ -92,7 +92,7 @@ void sub_08022A40(Entity* this) { this->frameIndex = 1; } - ProcessMovement(this); + ProcessMovement0(this); if (GravityUpdate(this, 0x2000) == 0) { if (--this->actionDelay == 0) { sub_08022A88(this); @@ -151,13 +151,13 @@ void sub_08022B44(Entity* this) { } // clang-format off -void (*const gUnk_080CBB64[])(Entity*) = { - sub_08022934, - sub_0802294C, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_132, +void (*const CuccoChickAggr_Functions[])(Entity*) = { + CuccoChickAggr_OnTick, + CuccoChickAggr_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + CuccoChickAggr_OnGrabbed, }; void (*const gUnk_080CBB7C[])(Entity*) = { diff --git a/src/enemy/curtain.c b/src/enemy/curtain.c index d52c80b3..af8c22d0 100644 --- a/src/enemy/curtain.c +++ b/src/enemy/curtain.c @@ -1,19 +1,19 @@ #include "enemy.h" #include "entity.h" -void (*const gUnk_080D1CC8[])(Entity*); +void (*const Curtain_Functions[])(Entity*); void (*const gUnk_080D1CE0[])(Entity*); void Curtain(Entity* this) { - EnemyFunctionHandler(this, gUnk_080D1CC8); + EnemyFunctionHandler(this, Curtain_Functions); } -void sub_080481D0(Entity* this) { +void Curtain_OnTick(Entity* this) { gUnk_080D1CE0[this->action](this); } -void sub_080481E8(Entity* this) { - if (this->field_0x46) { +void Curtain_OnCollision(Entity* this) { + if (this->knockbackSpeed != 0) { this->action = 2; this->flags &= ~ENT_COLLIDE; this->spritePriority.b0 = 7; @@ -25,7 +25,7 @@ void sub_080481E8(Entity* this) { InitializeAnimation(this, this->actionDelay); } -void nullsub_26() { +void Curtain_OnGrabbed() { } void sub_08048224(Entity* this) { @@ -68,8 +68,8 @@ void sub_08048294(Entity* this) { void nullsub_27() { } -void (*const gUnk_080D1CC8[])(Entity*) = { - sub_080481D0, sub_080481E8, sub_08001324, sub_0804A7D4, sub_08001242, nullsub_26, +void (*const Curtain_Functions[])(Entity*) = { + Curtain_OnTick, Curtain_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Curtain_OnGrabbed, }; void (*const gUnk_080D1CE0[])(Entity*) = { diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c index 57d2087f..6c1b0238 100644 --- a/src/enemy/darkNut.c +++ b/src/enemy/darkNut.c @@ -14,30 +14,27 @@ typedef struct { } PACKED stuct_080CAB14; void sub_08021218(Entity*, u32, u32); -void sub_08021588(Entity*); -void sub_080213D0(Entity*, u32); +void sub_0802124C(Entity*); +u32 sub_08021274(u32, u32); void sub_08021390(Entity*); -void sub_0802159C(Entity*); -void sub_0804AA1C(Entity*); +void sub_080213B0(Entity*); +void sub_080213D0(Entity*, u32); void sub_080213F0(Entity*); +void sub_08021400(Entity*); +void sub_08021414(Entity*); +void sub_08021424(Entity*); u32 sub_080214FC(Entity*); void sub_08021540(Entity*); +void sub_08021588(Entity*); +void sub_0802159C(Entity*); void sub_08021600(Entity*); -void sub_080213B0(Entity*); -u32 PlayerInRange(Entity*, u32, u32); -u32 sub_0802169C(Entity*, Entity*); -void sub_0802124C(Entity*); void sub_08021644(Entity*); -void sub_08021414(Entity*); -void sub_08021400(Entity*); -u32 sub_08021274(u32, u32); u32 sub_08021664(Entity*, Entity*); -u32 sub_0804A044(Entity*, Entity*, u32); -void sub_08021424(Entity*); +u32 sub_0802169C(Entity*, Entity*); extern Entity* gUnk_020000B0; -extern void (*const gUnk_080CAA98[])(Entity*); +extern void (*const DarkNut_Functions[])(Entity*); extern void (*const gUnk_080CAAB0[])(Entity*); extern const s8 gUnk_080CAB00[]; @@ -55,15 +52,15 @@ extern const u8 gUnk_080CAB68[]; extern void (*const gUnk_080CAB58[])(Entity*); void DarkNut(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CAA98); + EnemyFunctionHandler(this, DarkNut_Functions); SetChildOffset(this, 0, 1, -22); } -void sub_08020BA0(Entity* this) { +void DarkNut_OnTick(Entity* this) { gUnk_080CAAB0[this->action](this); } -void sub_08020BB8(Entity* this) { +void DarkNut_OnCollision(Entity* this) { switch (this->bitfield & 0x7f) { case 0x1c: this->action = 11; @@ -71,7 +68,7 @@ void sub_08020BB8(Entity* this) { this->hitType = 81; sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10)); sub_08021588(this); - sub_0804A9FC(this, 0x1c); + Create0x68FX(this, FX_STARS); break; case 0x16: this->action = 11; @@ -79,7 +76,7 @@ void sub_08020BB8(Entity* this) { this->hitType = 81; sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10)); sub_08021588(this); - sub_0804A9FC(this, 0x1c); + Create0x68FX(this, FX_STARS); break; case 0x4b: if (this->action == 13 || this->action == 15 || this->action == 19 || this->action == 18) @@ -122,10 +119,10 @@ void sub_08020BB8(Entity* this) { break; } this->field_0x78.HALF.LO = this->health; - sub_0804AA30(this, gUnk_080CAA98); + EnemyFunctionHandlerAfterCollision(this, DarkNut_Functions); } -void nullsub_129(Entity* this) { +void DarkNut_OnGrabbed(Entity* this) { } void sub_08020D70(Entity* this) { @@ -157,7 +154,7 @@ void sub_08020DD4(Entity* this) { } else { if (--this->actionDelay == 0) sub_08021540(this); - ProcessMovement(this); + ProcessMovement0(this); UpdateAnimationSingleFrame(this); } } @@ -191,7 +188,7 @@ void sub_08020E98(Entity* this) { sub_08021218(this, 7, this->animationState); } else { this->direction = GetFacingDirection(gUnk_020000B0, this); - if (ProcessMovement(this) == 0) { + if (ProcessMovement0(this) == 0) { this->action = 8; sub_08021218(this, 7, this->animationState); } else { @@ -205,7 +202,7 @@ void sub_08020E98(Entity* this) { sub_08021414(this); } else { this->direction = GetFacingDirection(this, gUnk_020000B0); - ProcessMovement(this); + ProcessMovement0(this); sub_0802124C(this); sub_08021644(this); } @@ -324,7 +321,7 @@ void sub_080210E4(Entity* this) { } sub_08021644(this); - if ((this->frame & 0x10) && (!ProcessMovement(this) || (this->child && (this->child->bitfield & 0x80)))) { + if ((this->frame & 0x10) && (!ProcessMovement0(this) || (this->child && (this->child->bitfield & 0x80)))) { sub_080213D0(this, 0); } else { if (--this->field_0x76.HWORD == 0) @@ -519,7 +516,7 @@ void sub_08021424(Entity* this) { sub_080212B0(this); } else { this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y); - if (!ProcessMovement(this)) { + if (!ProcessMovement0(this)) { sub_080212B0(this); } else { UpdateAnimationSingleFrame(this); @@ -655,13 +652,13 @@ u32 sub_0802169C(Entity* this, Entity* ent) { } // clang-format off -void (*const gUnk_080CAA98[])(Entity*) = { - sub_08020BA0, - sub_08020BB8, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_129, +void (*const DarkNut_Functions[])(Entity*) = { + DarkNut_OnTick, + DarkNut_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + DarkNut_OnGrabbed, }; void (*const gUnk_080CAAB0[])(Entity*) = { sub_08020D70, diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index a5b63e9d..f340affa 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -9,7 +9,6 @@ #include "enemy.h" #include "functions.h" -extern void sub_08049CF4(Entity*); void sub_080221C0(Entity*); typedef struct { @@ -17,7 +16,7 @@ typedef struct { s8 v; } PACKED PosOffset; -extern void (*const gUnk_080CB734[])(Entity*); +extern void (*const DoorMimic_Functions[])(Entity*); extern void (*const gUnk_080CB74C[])(Entity*); extern const s8 gUnk_080CB764[]; @@ -28,19 +27,19 @@ extern const Hitbox* const* const gUnk_080CB8A4[]; extern s16 gUnk_080B4488[]; void DoorMimic(Entity* this) { - gUnk_080CB734[GetNextFunction(this)](this); + DoorMimic_Functions[GetNextFunction(this)](this); this->hitbox = (Hitbox*)gUnk_080CB8A4[this->type2][this->frameIndex]; } -void sub_08021FDC(Entity* this) { +void DoorMimic_OnTick(Entity* this) { gUnk_080CB74C[this->action](this); } -void sub_08021FF4(Entity* this) { - sub_0804AA30(this, gUnk_080CB734); +void DoorMimic_OnCollision(Entity* this) { + EnemyFunctionHandlerAfterCollision(this, DoorMimic_Functions); } -void sub_08022004(Entity* this) { +void DoorMimic_OnDeath(Entity* this) { SetTile((u16)this->field_0x7c.HALF.LO, (u16)this->field_0x7c.HALF.HI, this->collisionLayer); CreateFx(this, FX_POT_SHATTER, 0); sub_08049CF4(this); @@ -122,13 +121,13 @@ void sub_080221C0(Entity* this) { } // clang-format off -void (*const gUnk_080CB734[])(Entity*) = { - sub_08021FDC, - sub_08021FF4, - sub_08001324, - sub_08022004, - sub_08001242, - sub_08021FDC, +void (*const DoorMimic_Functions[])(Entity*) = { + DoorMimic_OnTick, + DoorMimic_OnCollision, + GenericKnockback, + DoorMimic_OnDeath, + GenericConfused, + DoorMimic_OnTick, }; void (*const gUnk_080CB74C[])(Entity*) = { diff --git a/src/enemy/enemy4D.c b/src/enemy/enemy4D.c index d06ec59c..616a52a2 100644 --- a/src/enemy/enemy4D.c +++ b/src/enemy/enemy4D.c @@ -12,31 +12,31 @@ extern void sub_0803EE8C(Entity*); -extern void (*const gUnk_080D0880[])(Entity*); +extern void (*const Enemy4D_Functions[])(Entity*); extern void (*const gUnk_080D0898[])(Entity*); void Enemy4D(Entity* this) { - EnemyFunctionHandler(this, gUnk_080D0880); + EnemyFunctionHandler(this, Enemy4D_Functions); } -void sub_0803EAFC(Entity* this) { +void Enemy4D_OnTick(Entity* this) { gUnk_080D0898[this->action](this); } -void sub_0803EB14(Entity* this) { - sub_0804AA30(this, gUnk_080D0880); +void Enemy4D_OnCollision(Entity* this) { + EnemyFunctionHandlerAfterCollision(this, Enemy4D_Functions); } -void sub_0803EB24(Entity* this) { - sub_08001324(this); - sub_0803EAFC(this); +void Enemy4D_OnKnockback(Entity* this) { + GenericKnockback(this); + Enemy4D_OnTick(this); } -void sub_0803EB34(Entity* this) { +void Enemy4D_OnDeath(Entity* this) { CreateDeathFx(this, 0xff, 0x57); } -void nullsub_21(Entity* this) { +void Enemy4D_OnGrabbed(Entity* this) { } void sub_0803EB44(Entity* this) { diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index a77fdec3..98f80480 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -95,10 +95,10 @@ void sub_08040B9C(Enemy50Entity* this) { if (super->bitfield == 0x9d) { super->zVelocity = 0x18000; } - if (super->field_0x43 != 0) { + if (super->confusedTime != 0) { super->animationState = super->knockbackDirection >> 4; InitializeAnimation(super, super->animationState + 7); - sub_0804A9FC(super, 0x1c); + Create0x68FX(super, 0x1c); } if (super->health != this->unk_7a) { if (super->type == 0) { @@ -116,14 +116,14 @@ void sub_08040B9C(Enemy50Entity* this) { this->unk_7a = super->health; } _08040C9C: - sub_0804AA30(super, Enemy50_Functions); + EnemyFunctionHandlerAfterCollision(super, Enemy50_Functions); } void sub_08040CAC(Enemy50Entity* this) { GetNextFrame(super); - sub_08001328(super); + GenericKnockback2(super); if (super->type == 0) { - if (((super->knockbackDuration == 0) && (super->health != 0)) && (super->field_0x43 == 0)) { + if (((super->knockbackDuration == 0) && (super->health != 0)) && (super->confusedTime == 0)) { super->animationState = 0xff; if (super->animIndex == 7 || super->animIndex == 8) { InitializeAnimation(super, ((super->animIndex - 7) ^ 1) + 1); @@ -141,11 +141,11 @@ void sub_08040D30(Enemy50Entity* this) { if (super->animIndex != 7 && super->animIndex != 8) { InitializeAnimation(super, super->animationState + 7); } - sub_08001242(super); + GenericConfused(super); if (super->z.HALF.HI == 0) { super->z.HALF.HI = 0xffff; } - if (super->field_0x43 == 0) { + if (super->confusedTime == 0) { InitializeAnimation(super, (super->animationState ^ 1) + 1); super->direction = 0xff; super->animationState = 0xff; @@ -181,7 +181,7 @@ void Enemy50_SubAction2(Enemy50Entity* this) { effect->spritePriority.b0 = 3; } if (super->type == 0) { - sub_0804A7D4(super); + GenericDeath(super); } else { DeleteThisEntity(); } @@ -273,7 +273,7 @@ void Enemy50_Action6(Enemy50Entity* this) { sub_08004596(super, GetFacingDirection(super, gUnk_020000B0)); } sub_0803F66C(this); - sub_080AEFB4(super); + ProcessMovement1(super); } else { super->action = 7; super->actionDelay = 0x1e; @@ -316,7 +316,7 @@ void Enemy50_Action9(Enemy50Entity* this) { super->animationState = 0xff; super->iframes = -0xc; super->knockbackDuration = 0x14; - super->field_0x46 = 0x180; + super->knockbackSpeed = 0x180; super->knockbackDirection = gPlayerEntity.animationState << 2 ^ 0x10; sub_08041128(this); sub_0803F6EC(this); @@ -436,7 +436,7 @@ bool32 sub_08041300(Enemy50Entity* this) { #endif void (*const Enemy50_Functions[])(Enemy50Entity*) = { - Enemy50_OnTick, sub_08040B9C, sub_08040CAC, (void (*)(Enemy50Entity*))sub_0804A7D4, sub_08040D30, sub_08040D90, + Enemy50_OnTick, sub_08040B9C, sub_08040CAC, (void (*)(Enemy50Entity*))GenericDeath, sub_08040D30, sub_08040D90, }; void (*const Enemy50_Actions[])(Enemy50Entity*) = { Enemy50_Init, Enemy50_Action1, Enemy50_Action2, Enemy50_Action3, Enemy50_Action4, Enemy50_Action5, diff --git a/src/enemy/enemyE.c b/src/enemy/enemyE.c index d19d110b..f0428d37 100644 --- a/src/enemy/enemyE.c +++ b/src/enemy/enemyE.c @@ -10,18 +10,18 @@ void sub_08023000(Entity*, int); -extern void (*const gUnk_080CBBC8[])(Entity*); +extern void (*const EnemyE_Functions[])(Entity*); extern void (*const gUnk_080CBBDC[])(Entity*); void EnemyE(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CBBC8); + EnemyFunctionHandler(this, EnemyE_Functions); } -void sub_08022FB4(Entity* this) { +void EnemyE_OnTick(Entity* this) { gUnk_080CBBDC[this->action](this); } -void nullsub_133(Entity* this) { +void EnemyE_OnCollision(Entity* this) { } void sub_08022FD0(Entity* this) { @@ -58,12 +58,12 @@ void sub_08023000(Entity* this, int frames) { } // clang-format off -void (*const gUnk_080CBBC8[])(Entity*) = { - sub_08022FB4, - nullsub_133, - sub_08001324, - sub_0804A7D4, - sub_08001242, +void (*const EnemyE_Functions[])(Entity*) = { + EnemyE_OnTick, + EnemyE_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, }; void (*const gUnk_080CBBDC[])(Entity*) = { diff --git a/src/enemy/eyegore.c b/src/enemy/eyegore.c index 23acd17f..5869b6f8 100644 --- a/src/enemy/eyegore.c +++ b/src/enemy/eyegore.c @@ -64,9 +64,9 @@ void Eyegore_Action6(EyegoreEntity*); void (*const Eyegore_Functions[])(EyegoreEntity*) = { Eyegore_OnTick, Eyegore_OnCollision, - (void (*)(EyegoreEntity*))sub_08001324, + (void (*)(EyegoreEntity*))GenericKnockback, Eyegore_OnDeath, - (void (*)(EyegoreEntity*))sub_08001242, + (void (*)(EyegoreEntity*))GenericConfused, Eyegore_OnGrabbed, }; @@ -125,7 +125,7 @@ void Eyegore_OnCollision(EyegoreEntity* this) { super->flags &= ~ENT_COLLIDE; super->iframes = 0x78; } - sub_0804AA30(super, Eyegore_Functions); + EnemyFunctionHandlerAfterCollision(super, Eyegore_Functions); } void Eyegore_OnDeath(EyegoreEntity* this) { @@ -136,7 +136,7 @@ void Eyegore_OnDeath(EyegoreEntity* this) { if ((super->field_0x3a & 2) == 0) { CreateFx(super, FX_GIANT_EXPLOSION4, 0); } - sub_0804A7D4(super); + GenericDeath(super); } } @@ -451,7 +451,7 @@ void sub_08031250(EyegoreEntity* this) { super->y.HALF.HI = this->unk_76; this->unk_79 = tmp2 | this->unk_79; } - if (((this->unk_79 & 0x80) == 0) && (ProcessMovement(super) == 0)) { + if (((this->unk_79 & 0x80) == 0) && (ProcessMovement0(super) == 0)) { if ((this->unk_78 & 0x80) != 0) { this->unk_78 = 0x82; } else { @@ -459,7 +459,7 @@ void sub_08031250(EyegoreEntity* this) { } } } else { - ProcessMovement(super); + ProcessMovement0(super); } } diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index 1bb932af..4928bf84 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -11,27 +11,25 @@ void sub_0802C4B0(Entity*); void sub_0802C62C(Entity*); -extern void (*const gUnk_080CD540[])(Entity*); +extern void (*const FallingBoulder_Functions[])(Entity*); extern void (*const gUnk_080CD558[])(Entity*); extern const u16 gUnk_080CD568[]; extern const u8 gUnk_080CD580[]; extern const s16 gUnk_080CD58C[]; -extern void sub_080AEFB4(Entity*); - void FallingBoulder(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CD540); + EnemyFunctionHandler(this, FallingBoulder_Functions); } -void sub_0802C238(Entity* this) { +void FallingBoulder_OnTick(Entity* this) { gUnk_080CD558[this->action](this); } -void sub_0802C250(Entity* this) { +void FallingBoulder_OnCollision(Entity* this) { /* ... */ } -void sub_0802C254(Entity* this) { +void FallingBoulder_OnGrabbed(Entity* this) { /* ... */ } @@ -115,7 +113,7 @@ NONMATCH("asm/non_matching/fallingBoulder/sub_0802C334.inc", void sub_0802C334(E y = gRoomControls.origin_y + gRoomControls.height - this->y.HALF.HI; if (y >= 5) { - sub_080AEFB4(this); + ProcessMovement1(this); } else { LinearMoveUpdate(this); if (this->z.HALF.HI - y > 0x38) { @@ -219,13 +217,13 @@ void sub_0802C62C(Entity* this) { } // clang-format off -void (*const gUnk_080CD540[])(Entity*) = { - sub_0802C238, - sub_0802C250, - sub_08001324, - sub_0804A7D4, - sub_08001242, - sub_0802C254, +void (*const FallingBoulder_Functions[])(Entity*) = { + FallingBoulder_OnTick, + FallingBoulder_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + FallingBoulder_OnGrabbed, }; void (*const gUnk_080CD558[])(Entity*) = { diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index a0546fb8..43ceb90c 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -15,28 +15,28 @@ typedef struct { extern void sub_08045524(Entity*); void sub_08045178(Entity*, Entity*, int, int); -extern void (*const gUnk_080D17E8[])(Entity*); +extern void (*const FireballGuy_Functions[])(Entity*); extern void (*const gUnk_080D1800[])(Entity*); extern u8 gUnk_080D180C[4]; // Entity count per form extern PosOffset gUnk_080D1810[4]; void FireballGuy(Entity* this) { - EnemyFunctionHandler(this, gUnk_080D17E8); + EnemyFunctionHandler(this, FireballGuy_Functions); } -void sub_080453A4(Entity* this) { +void FireballGuy_OnTick(Entity* this) { gUnk_080D1800[this->action](this); } -void sub_080453BC(Entity* this) { +void FireballGuy_OnCollision(Entity* this) { if (this->health && this->cutsceneBeh.HALF.LO != this->health) { this->action = 2; } else { - sub_0804AA30(this, gUnk_080D17E8); + EnemyFunctionHandlerAfterCollision(this, FireballGuy_Functions); } } -void nullsub_172(void) { +void FireballGuy_OnGrabbed(void) { } void sub_080453E8(Entity* this) { @@ -52,7 +52,7 @@ void sub_080453E8(Entity* this) { } void sub_08045430(Entity* this) { - sub_080AEFE0(this); + ProcessMovement2(this); GetNextFrame(this); if (GravityUpdate(this, 0x1800) == 0) sub_08045524(this); diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 5c0fa3b0..0a76c266 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -14,7 +14,7 @@ extern void (*const gUnk_080012C8[])(Entity*); extern Hitbox gUnk_080FD340; // TODO should be const extern Hitbox gUnk_080FD34C; -void (*const gUnk_080CFB84[])(Entity*); +void (*const FlyingSkull_Functions[])(Entity*); void (*const gUnk_080CFB9C[])(FlyingSkullEntity*); void (*const gUnk_080CFBBC[])(FlyingSkullEntity*); void (*const gUnk_080CFBD4[])(FlyingSkullEntity*); @@ -31,15 +31,15 @@ void FlyingSkull(Entity* this) { if (index) { gUnk_080012C8[index](this); } else { - gUnk_080CFB84[GetNextFunction(this)](this); + FlyingSkull_Functions[GetNextFunction(this)](this); } } -void sub_08039BE0(FlyingSkullEntity* this) { +void FlyingSkull_OnTick(FlyingSkullEntity* this) { gUnk_080CFB9C[super->action](this); } -void sub_08039BF8(FlyingSkullEntity* this) { +void FlyingSkull_OnCollision(FlyingSkullEntity* this) { sub_0803A100(this); if (super->bitfield == 0x9d) { @@ -52,10 +52,10 @@ void sub_08039BF8(FlyingSkullEntity* this) { sub_0803A0E0(this); } - sub_0804AA30(super, gUnk_080CFB84); + EnemyFunctionHandlerAfterCollision(super, FlyingSkull_Functions); } -void sub_08039C80(FlyingSkullEntity* this) { +void FlyingSkull_OnGrabbed(FlyingSkullEntity* this) { gUnk_080CFBBC[super->subAction](this); } @@ -221,7 +221,7 @@ void sub_0803A080(FlyingSkullEntity* this) { void sub_0803A09C(FlyingSkullEntity* this) { GetNextFrame(super); - sub_080AEFE0(super); + ProcessMovement2(super); if (super->collisions) { sub_0803A0E0(this); @@ -251,9 +251,13 @@ void sub_0803A100(FlyingSkullEntity* this) { } } -void (*const gUnk_080CFB84[])(Entity*) = { - (EntityActionPtr)sub_08039BE0, (EntityActionPtr)sub_08039BF8, sub_08001324, sub_0804A7D4, sub_08001242, - (EntityActionPtr)sub_08039C80, +void (*const FlyingSkull_Functions[])(Entity*) = { + (EntityActionPtr)FlyingSkull_OnTick, + (EntityActionPtr)FlyingSkull_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + (EntityActionPtr)FlyingSkull_OnGrabbed, }; void (*const gUnk_080CFB9C[])(FlyingSkullEntity*) = { diff --git a/src/enemy/ghini.c b/src/enemy/ghini.c index caf0e985..a7870e07 100644 --- a/src/enemy/ghini.c +++ b/src/enemy/ghini.c @@ -55,7 +55,7 @@ void Ghini_OnTick(GhiniEntity* this) { sub_0803F694(this); } -void sub_0803F028(GhiniEntity* this) { +void Ghini_OnCollision(GhiniEntity* this) { if (super->action == 8 || super->action == 9) { super->animationState = 0xff; InitializeAnimation(super, (super->knockbackDirection >> 4 ^ 1) + 1); @@ -69,10 +69,10 @@ void sub_0803F028(GhiniEntity* this) { if (super->bitfield == 0x9d) { super->zVelocity = 0x18000; } - if (super->field_0x43 != 0) { + if (super->confusedTime != 0) { super->animationState = super->knockbackDirection >> 4; InitializeAnimation(super, super->animationState + 7); - sub_0804A9FC(super, 0x1c); + Create0x68FX(super, FX_STARS); } if (super->health != this->unk_7a) { this->unk_7a = super->health; @@ -82,13 +82,13 @@ void sub_0803F028(GhiniEntity* this) { InitializeAnimation(super, (super->knockbackDirection >> 4) + 7); } } - sub_0804AA30(super, Ghini_Functions); + EnemyFunctionHandlerAfterCollision(super, Ghini_Functions); } -void sub_0803F0F4(GhiniEntity* this) { +void Ghini_OnKnockback(GhiniEntity* this) { GetNextFrame(super); - sub_08001328(super); - if (((super->knockbackDuration == 0) && (super->health != 0)) && (super->field_0x43 == 0)) { + GenericKnockback2(super); + if (((super->knockbackDuration == 0) && (super->health != 0)) && (super->confusedTime == 0)) { super->animationState = 0xff; if (super->animIndex == 7 || super->animIndex == 8) { InitializeAnimation(super, ((super->animIndex - 7) ^ 1) + 1); @@ -96,15 +96,15 @@ void sub_0803F0F4(GhiniEntity* this) { } } -void sub_0803F148(GhiniEntity* this) { +void Ghini_OnConfused(GhiniEntity* this) { if (super->animIndex != 7 && super->animIndex != 8) { InitializeAnimation(super, super->animationState + 7); } - sub_08001242(super); + GenericConfused(super); if (super->z.HALF.HI == 0) { super->z.HALF.HI = 0xffff; } - if (super->field_0x43 == 0) { + if (super->confusedTime == 0) { InitializeAnimation(super, (super->animationState ^ 1) + 1); super->direction = 0xff; super->animationState = 0xff; @@ -112,7 +112,7 @@ void sub_0803F148(GhiniEntity* this) { } } -void sub_0803F1A8(GhiniEntity* this) { +void Ghini_OnGrabbed(GhiniEntity* this) { if (sub_0806F520()) { Ghini_SubActions[super->subAction](this); } else { @@ -139,7 +139,7 @@ void Ghini_SubAction2(GhiniEntity* this) { if (effect != NULL) { effect->spritePriority.b0 = 3; } - sub_0804A7D4(super); + GenericDeath(super); } } @@ -231,7 +231,7 @@ void Ghini_Action6(GhiniEntity* this) { sub_08004596(super, GetFacingDirection(super, gUnk_020000B0)); } sub_0803F66C(this); - sub_080AEFB4(super); + ProcessMovement1(super); GetNextFrame(super); } else { super->action = 7; @@ -274,7 +274,7 @@ void Ghini_Action9(GhiniEntity* this) { super->animationState = 0xff; super->iframes = -0xc; super->knockbackDuration = 0x14; - super->field_0x46 = 0x180; + super->knockbackSpeed = 0x180; super->knockbackDirection = gPlayerEntity.animationState << 2 ^ 0x10; sub_0803F51C(this); sub_0803F6EC(this); @@ -311,7 +311,7 @@ void sub_0803F58C(GhiniEntity* this) { s32 yBefore; yBefore = super->y.WORD; - sub_080AEFB4(super); + ProcessMovement1(super); yAfter = super->y.WORD; super->y.WORD = yAfter - (yAfter - yBefore) / 2; } @@ -398,7 +398,8 @@ void sub_0803F738(GhiniEntity* this) { } void (*const Ghini_Functions[])(GhiniEntity*) = { - Ghini_OnTick, sub_0803F028, sub_0803F0F4, (void (*)(GhiniEntity*))sub_0804A7D4, sub_0803F148, sub_0803F1A8, + Ghini_OnTick, Ghini_OnCollision, Ghini_OnKnockback, (void (*)(GhiniEntity*))GenericDeath, + Ghini_OnConfused, Ghini_OnGrabbed, }; void (*const Ghini_Actions[])(GhiniEntity*) = { Ghini_Init, Ghini_Action1, Ghini_Action2, Ghini_Action3, Ghini_Action4, diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index c2fe9fd2..9c29dd4e 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -45,12 +45,12 @@ void sub_08037A14(GibdoEntity*); extern void sub_0804A4E4(Entity*, Entity*); u32 sub_0804A044(Entity*, Entity*, u32); -void (*const gGibdo[6])(Entity*); +void (*const Gibdo_Functions[6])(Entity*); void (*const gUnk_080CF2AC[9])(GibdoEntity*); extern Entity* gUnk_020000B0; void Gibdo(Entity* this) { - EnemyFunctionHandler(this, gGibdo); + EnemyFunctionHandler(this, Gibdo_Functions); SetChildOffset(this, 0, 1, -0x15); } @@ -58,7 +58,7 @@ void Gibdo_OnTick(GibdoEntity* this) { gUnk_080CF2AC[super->action](this); } -void sub_080374A4(GibdoEntity* this) { +void Gibdo_OnCollision(GibdoEntity* this) { u8 x; if (super->bitfield == 0x87) { if (super->action == 0x6) { @@ -88,13 +88,13 @@ void sub_080374A4(GibdoEntity* this) { sub_08037A58(this); } } - if (super->field_0x43 != 0) { - sub_0804A9FC(super, 0x1c); + if (super->confusedTime != 0) { + Create0x68FX(super, FX_STARS); } - sub_0804AA30(super, gGibdo); + EnemyFunctionHandlerAfterCollision(super, Gibdo_Functions); } -void nullsub_162(GibdoEntity* this) { +void Gibdo_OnGrabbed(GibdoEntity* this) { } void sub_08037558(GibdoEntity* this) { @@ -120,7 +120,7 @@ void sub_080375A4(GibdoEntity* this) { sub_08037794(this); } else { UpdateAnimationSingleFrame(super); - if (ProcessMovement(super) == 0) { + if (ProcessMovement0(super) == 0) { if (!(--super->field_0xf)) { sub_080379BC(this); } @@ -148,7 +148,7 @@ void sub_08037624(GibdoEntity* this) { } else { UpdateAnimationSingleFrame(super); UpdateAnimationSingleFrame(super); - if (ProcessMovement(super) == 0) { + if (ProcessMovement0(super) == 0) { if (!(--super->field_0xf)) { sub_080379BC(this); } @@ -170,7 +170,7 @@ void sub_08037690(GibdoEntity* this) { } else { if ((super->frame & 1) != 0) { super->hitType = 0x27; - ProcessMovement(super); + ProcessMovement0(super); } } } @@ -359,7 +359,7 @@ void sub_08037A58(GibdoEntity* this) { super->iframes = 0xf4; super->knockbackDirection = DirectionFromAnimationState(super->animationState) ^ 0x10; super->knockbackDuration = 8; - super->field_0x46 = 0x180; + super->knockbackSpeed = 0x180; this->field_0x76 = 0x3c; InitAnimationForceUpdate(super, super->animationState + 0x10); } @@ -370,7 +370,7 @@ void sub_08037ACC(GibdoEntity* this) { gPlayerEntity.iframes = 0x1e; gPlayerEntity.knockbackDirection = DirectionFromAnimationState(super->animationState); gPlayerEntity.knockbackDuration = 4; - gPlayerEntity.field_0x46 = 0x180; + gPlayerEntity.knockbackSpeed = 0x180; } // Damage player maybe? @@ -436,9 +436,13 @@ void Gibdo_MoveObjectsToStalfos(GibdoEntity* this, Entity* that) { } } -void (*const gGibdo[6])(Entity*) = { - (EntityActionPtr)Gibdo_OnTick, (EntityActionPtr)sub_080374A4, sub_08001324, sub_0804A7D4, sub_08001242, - (EntityActionPtr)nullsub_162, +void (*const Gibdo_Functions[6])(Entity*) = { + (EntityActionPtr)Gibdo_OnTick, + (EntityActionPtr)Gibdo_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + (EntityActionPtr)Gibdo_OnGrabbed, }; void (*const gUnk_080CF2AC[9])(GibdoEntity*) = { diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index f7170f8e..bd1584b4 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -34,7 +34,7 @@ typedef struct { Gleerok_HeapStruct* unk_84; } GleerokEntity; -extern void (*const gUnk_080CD748[])(Entity*); +extern void (*const Gleerok_Functions[])(Entity*); extern void (*const gUnk_080CD75C[])(GleerokEntity*); extern void (*const gUnk_080CD7B8[])(GleerokEntity*); extern void (*const gUnk_080CD7E4[])(GleerokEntity*); @@ -69,10 +69,10 @@ extern bool32 sub_0802EA88(Gleerok_HeapStruct* param_1); extern bool32 sub_0802E768(Gleerok_HeapStruct* param_1); void Gleerok(Entity* this) { - gUnk_080CD748[GetNextFunction(this)](this); + Gleerok_Functions[GetNextFunction(this)](this); } -void sub_0802D034(GleerokEntity* this) { +void Gleerok_OnDeath(GleerokEntity* this) { sub_08078B48(); switch (super->type) { @@ -107,7 +107,7 @@ void sub_0802D034(GleerokEntity* this) { break; case 1: SoundReq(SFX_BOSS_DIE); - sub_0804A7D4(super); + GenericDeath(super); break; case 0: gPlayerState.field_0x14 = 1; @@ -237,7 +237,7 @@ NONMATCH("asm/non_matching/gleerok/sub_0802D33C.inc", void sub_0802D33C(GleerokE } END_NONMATCH -void sub_0802D394(GleerokEntity* this) { +void Gleerok_OnTick(GleerokEntity* this) { gUnk_080CD7B8[super->action](this); super->spriteRendering.b3 = 3; } @@ -273,7 +273,7 @@ NONMATCH("asm/non_matching/gleerok/sub_0802D3B8.inc", void sub_0802D3B8(GleerokE heap = this->unk_84; if (heap == NULL) { - sub_0804A7D4(super); + GenericDeath(super); DeleteThisEntity(); } diff --git a/src/enemy/gyorgChild.c b/src/enemy/gyorgChild.c index e260fb25..91b6bf41 100644 --- a/src/enemy/gyorgChild.c +++ b/src/enemy/gyorgChild.c @@ -5,17 +5,17 @@ #include "functions.h" #include "enemy/gyorg.h" -void sub_08048684(GyorgChildEntity*); -void sub_0804869C(GyorgChildEntity*); -void sub_080486AC(GyorgChildEntity*); +void GyorgChild_OnTick(GyorgChildEntity*); +void GyorgChild_OnCollision(GyorgChildEntity*); +void GyorgChild_OnGrabbed(GyorgChildEntity*); -void (*const gUnk_080D1E6C[])(GyorgChildEntity*) = { - sub_08048684, - sub_0804869C, - (void (*)(GyorgChildEntity*))sub_08001324, - (void (*)(GyorgChildEntity*))sub_0804A7D4, - (void (*)(GyorgChildEntity*))sub_08001242, - sub_080486AC, +void (*const GyorgChild_Functions[])(GyorgChildEntity*) = { + GyorgChild_OnTick, + GyorgChild_OnCollision, + (void (*)(GyorgChildEntity*))GenericKnockback, + (void (*)(GyorgChildEntity*))GenericDeath, + (void (*)(GyorgChildEntity*))GenericConfused, + GyorgChild_OnGrabbed, }; void GyorgChild(Entity* this) { @@ -24,7 +24,7 @@ void GyorgChild(Entity* this) { this->health = 0; this->collisionLayer = 2; } - gUnk_080D1E6C[GetNextFunction(this)]((GyorgChildEntity*)this); + GyorgChild_Functions[GetNextFunction(this)]((GyorgChildEntity*)this); } void sub_080486F4(GyorgChildEntity*); @@ -32,7 +32,7 @@ void sub_0804877C(GyorgChildEntity*); void sub_0804882C(GyorgChildEntity*); void sub_08048904(GyorgChildEntity*); -void sub_08048684(GyorgChildEntity* this) { +void GyorgChild_OnTick(GyorgChildEntity* this) { static void (*const gUnk_080D1E84[])(GyorgChildEntity*) = { sub_080486F4, sub_0804877C, @@ -42,15 +42,15 @@ void sub_08048684(GyorgChildEntity* this) { gUnk_080D1E84[super->action](this); } -void sub_0804869C(GyorgChildEntity* this) { - sub_0804AA30(super, gUnk_080D1E6C); +void GyorgChild_OnCollision(GyorgChildEntity* this) { + EnemyFunctionHandlerAfterCollision(super, GyorgChild_Functions); } void sub_080486D0(GyorgChildEntity*); void sub_080486D8(GyorgChildEntity*); void sub_080486E0(GyorgChildEntity*); -void sub_080486AC(GyorgChildEntity* this) { +void GyorgChild_OnGrabbed(GyorgChildEntity* this) { static void (*const gUnk_080D1E94[])(GyorgChildEntity*) = { sub_080486D0, sub_080486D8, @@ -71,7 +71,7 @@ void sub_080486D8(GyorgChildEntity* this) { void sub_080486E0(GyorgChildEntity* this) { if (sub_0806F3E4(super)) { - sub_0804A7D4(super); + GenericDeath(super); } } diff --git a/src/enemy/gyorgFemaleEye.c b/src/enemy/gyorgFemaleEye.c index a653de38..89d8207a 100644 --- a/src/enemy/gyorgFemaleEye.c +++ b/src/enemy/gyorgFemaleEye.c @@ -6,8 +6,8 @@ #include "functions.h" #include "enemy/gyorg.h" -void sub_080489B4(GyorgFemaleEyeEntity*); -void sub_080489CC(GyorgFemaleEyeEntity*); +void GyorgFemaleEye_OnTick(GyorgFemaleEyeEntity*); +void GyorgFemaleEye_OnCollision(GyorgFemaleEyeEntity*); void sub_08048AF0(GyorgFemaleEyeEntity*); void sub_08048B2C(GyorgFemaleEyeEntity*); @@ -18,23 +18,23 @@ void sub_08048CEC(GyorgFemaleEyeEntity*); void sub_08048D20(GyorgFemaleEyeEntity*); u32 sub_08048D70(GyorgFemaleEntity*); -void (*const gUnk_080D1F64[])(GyorgFemaleEyeEntity*) = { - sub_080489B4, - sub_080489CC, - (void (*)(GyorgFemaleEyeEntity*))sub_08001324, - (void (*)(GyorgFemaleEyeEntity*))sub_0804A7D4, - (void (*)(GyorgFemaleEyeEntity*))sub_08001242, - sub_080489B4, +void (*const GyorgFemaleEye_Functions[])(GyorgFemaleEyeEntity*) = { + GyorgFemaleEye_OnTick, + GyorgFemaleEye_OnCollision, + (void (*)(GyorgFemaleEyeEntity*))GenericKnockback, + (void (*)(GyorgFemaleEyeEntity*))GenericDeath, + (void (*)(GyorgFemaleEyeEntity*))GenericConfused, + GyorgFemaleEye_OnTick, }; void GyorgFemaleEye(Entity* this) { if (this->parent->next == NULL) { DeleteThisEntity(); } - gUnk_080D1F64[GetNextFunction(this)]((GyorgFemaleEyeEntity*)this); + GyorgFemaleEye_Functions[GetNextFunction(this)]((GyorgFemaleEyeEntity*)this); } -void sub_080489B4(GyorgFemaleEyeEntity* this) { +void GyorgFemaleEye_OnTick(GyorgFemaleEyeEntity* this) { static void (*const gUnk_080D1F7C[])(GyorgFemaleEyeEntity*) = { sub_08048AF0, sub_08048B2C, sub_08048B84, sub_08048BB0, sub_08048CEC, }; @@ -62,7 +62,7 @@ const u8 gUnk_080D2030[] = { 2, 2, 3, 3, 2, 2, 3, 3, 6, 6, 7, 7, 6, 6, 7, 7, 11, 11, 10, 10, 11, 11, 10, 10, 15, 15, 14, 14, 15, 15, 14, 14, }; -void sub_080489CC(GyorgFemaleEyeEntity* this) { +void GyorgFemaleEye_OnCollision(GyorgFemaleEyeEntity* this) { GyorgFemaleEntity* parent; if (super->health != 0xFF) { parent = (GyorgFemaleEntity*)super->parent; @@ -91,7 +91,7 @@ void sub_080489CC(GyorgFemaleEyeEntity* this) { #endif } super->health = 0xFF; - sub_0804AA30(super, (void (*const*)(Entity*))gUnk_080D1F64); + EnemyFunctionHandlerAfterCollision(super, (void (*const*)(Entity*))GyorgFemaleEye_Functions); } void sub_08048AF0(GyorgFemaleEyeEntity* this) { diff --git a/src/enemy/gyorgMaleEye.c b/src/enemy/gyorgMaleEye.c index 6f87fe4c..a7586c44 100644 --- a/src/enemy/gyorgMaleEye.c +++ b/src/enemy/gyorgMaleEye.c @@ -40,7 +40,7 @@ void GyorgMaleEye_OnTick(GyorgMaleEyeEntity* this) { GyorgMaleEye_Actions[super->action](this); } -void sub_08048E1C(GyorgMaleEyeEntity* this) { +void GyorgMaleEye_OnCollision(GyorgMaleEyeEntity* this) { u32 tmp; Entity* entity; @@ -66,7 +66,7 @@ void sub_08048E1C(GyorgMaleEyeEntity* this) { } super->health = 0xff; } - sub_0804AA30(super, GyorgMaleEye_Functions); + EnemyFunctionHandlerAfterCollision(super, GyorgMaleEye_Functions); } void GyorgMaleEye_Init(GyorgMaleEyeEntity* this) { @@ -114,10 +114,10 @@ void sub_08048F74(GyorgMaleEyeEntity* this) { void (*const GyorgMaleEye_Functions[])(GyorgMaleEyeEntity*) = { GyorgMaleEye_OnTick, - sub_08048E1C, - (void (*)(GyorgMaleEyeEntity*))sub_08001324, - (void (*)(GyorgMaleEyeEntity*))sub_0804A7D4, - (void (*)(GyorgMaleEyeEntity*))sub_08001242, + GyorgMaleEye_OnCollision, + (void (*)(GyorgMaleEyeEntity*))GenericKnockback, + (void (*)(GyorgMaleEyeEntity*))GenericDeath, + (void (*)(GyorgMaleEyeEntity*))GenericConfused, GyorgMaleEye_OnTick, }; void (*const GyorgMaleEye_Actions[])(GyorgMaleEyeEntity*) = { diff --git a/src/enemy/hangingSeed.c b/src/enemy/hangingSeed.c index 4839642f..51b119c7 100644 --- a/src/enemy/hangingSeed.c +++ b/src/enemy/hangingSeed.c @@ -9,25 +9,25 @@ #include "enemy.h" #include "functions.h" -extern void (*const gHangingSeedFunctions[])(Entity*); +extern void (*const HangingSeed_Functions[])(Entity*); extern void (*const gUnk_080CB588[])(Entity*); void HangingSeed(Entity* this) { - EnemyFunctionHandler(this, gHangingSeedFunctions); + EnemyFunctionHandler(this, HangingSeed_Functions); } void HangingSeed_OnTick(Entity* this) { gUnk_080CB588[this->action](this); } -void sub_080216FC(Entity* this) { +void HangingSeed_OnCollision(Entity* this) { if (this->bitfield & 0x80) { CreateFx(this, FX_BUSH, 0x80); DeleteThisEntity(); } } -void nullsub_7(Entity* this) { +void HangingSeed_OnGrabbed(Entity* this) { /* ... */ } @@ -44,13 +44,13 @@ void HangingSeed_Hang(Entity* this) { } // clang-format off -void (*const gHangingSeedFunctions[])(Entity*) = { +void (*const HangingSeed_Functions[])(Entity*) = { HangingSeed_OnTick, - sub_080216FC, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_7, + HangingSeed_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + HangingSeed_OnGrabbed, }; void (*const gUnk_080CB588[])(Entity*) = { diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index fc90c307..2c593691 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -11,8 +11,8 @@ extern u32 sub_0804A024(Entity*, u32, u32); -extern Entity gUnk_0200D654; -extern Entity gUnk_02027EB4; +extern u8 gUnk_0200D654[]; +extern u8 gUnk_02027EB4[]; void sub_0802C18C(Entity*); void sub_0802C218(Entity*); @@ -23,7 +23,7 @@ bool32 sub_0802C06C(Entity*); void sub_0802C1CC(Entity*); bool32 sub_0802C0E8(Entity*); -extern void (*const gUnk_080CD3E4[])(Entity*); +extern void (*const Helmasaur_Functions[])(Entity*); extern void (*const gUnk_080CD3FC[])(Entity*); extern void (*const gUnk_080CD408[])(Entity*); extern void (*const gUnk_080CD42C[])(Entity*); @@ -34,18 +34,18 @@ extern const s8 gUnk_080CD464[]; void Helmasaur(Entity* this) { if (this->type == 0) { - EnemyFunctionHandler(this, gUnk_080CD3E4); + EnemyFunctionHandler(this, Helmasaur_Functions); SetChildOffset(this, 0, 1, -0x10); } else { gUnk_080CD3FC[this->action](this); } } -void sub_0802BBAC(Entity* this) { +void Helmasaur_OnTick(Entity* this) { gUnk_080CD408[this->action](this); } -void sub_0802BBC4(Entity* this) { +void Helmasaur_OnCollision(Entity* this) { if (this->hitType != 0x19) { switch (this->bitfield & 0x7f) { case 0: @@ -58,14 +58,14 @@ void sub_0802BBC4(Entity* this) { break; } } - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CD3E4); + EnemyFunctionHandlerAfterCollision(this, Helmasaur_Functions); } -void sub_0802BC20(Entity* this) { +void Helmasaur_OnGrabbed(Entity* this) { if (this->hitType != 0x19) { if (sub_0806F520(this)) { gUnk_080CD42C[this->subAction](this); @@ -189,7 +189,7 @@ void sub_0802BE18(Entity* this) { } void sub_0802BE48(Entity* this) { - if (!sub_080AEFE0(this)) { + if (!ProcessMovement2(this)) { sub_0802C218(this); InitScreenShake(8, 0); } else { @@ -208,7 +208,7 @@ void sub_0802BE80(Entity* this) { } if (this->speed > 0) { - sub_080AEFE0(this); + ProcessMovement2(this); sub_0802C18C(this); } else { sub_0802C1C0(this); @@ -218,7 +218,7 @@ void sub_0802BE80(Entity* this) { void sub_0802BEBC(Entity* this) { this->direction ^= 0x10; - sub_080AEFE0(this); + ProcessMovement2(this); this->direction ^= 0x10; if (!sub_080044EC(this, Q_16_16(0.125))) { sub_0802C1C0(this); @@ -240,7 +240,7 @@ void sub_0802BEEC(Entity* this) { } void sub_0802BF3C(Entity* this) { - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); if (--this->actionDelay == 0) { u32 sprite; @@ -316,13 +316,13 @@ bool32 sub_0802C06C(Entity* this) { u32 xdiff = gUnk_080CD45C[(this->direction >> 2) + 0]; u32 ydiff = gUnk_080CD45C[(this->direction >> 2) + 1]; - Entity* ent = this->collisionLayer == 2 ? &gUnk_0200D654 : &gUnk_02027EB4; + u8* layer = this->collisionLayer == 2 ? gUnk_0200D654 : gUnk_02027EB4; u32 i; for (i = 0; i < 8; i++) { x += xdiff; y += ydiff; - if (sub_080AE4CC(ent, x, y, 0)) + if (IsTileCollision(layer, x, y, 0)) return FALSE; } @@ -339,10 +339,10 @@ bool32 sub_0802C0E8(Entity* this) { s32 x = this->x.HALF.HI + this->hitbox->offset_x + ptr[0] * 6; s32 y = this->y.HALF.HI + this->hitbox->offset_y + ptr[1] * 6; - Entity* ent = this->collisionLayer == 2 ? &gUnk_0200D654 : &gUnk_02027EB4; + u8* layer = this->collisionLayer == 2 ? gUnk_0200D654 : gUnk_02027EB4; u32 ret = FALSE; if (!sub_0806FC24(TILE(x, y), 9)) { - if (sub_080AE4CC(ent, x, y, 0)) { + if (IsTileCollision(layer, x, y, 0)) { ret = 1; } else { ret = 0; @@ -380,13 +380,13 @@ void sub_0802C218(Entity* this) { } // clang-format off -void (*const gUnk_080CD3E4[])(Entity*) = { - sub_0802BBAC, - sub_0802BBC4, - sub_08001324, - sub_0804A7D4, - sub_08001242, - sub_0802BC20, +void (*const Helmasaur_Functions[])(Entity*) = { + Helmasaur_OnTick, + Helmasaur_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + Helmasaur_OnGrabbed, }; void (*const gUnk_080CD3FC[])(Entity*) = { diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index df262f25..340a9be5 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -10,7 +10,7 @@ extern Entity* gUnk_020000B0; -extern void (*const gUnk_080CE7B0[])(Entity*); +extern void (*const Keaton_Functions[])(Entity*); extern void (*const gUnk_080CE7C8[])(Entity*); extern u8 gUnk_080CE7E0[]; extern u16 gUnk_080CE7F0[]; @@ -29,15 +29,15 @@ void sub_080327C8(Entity* this); void sub_080327E0(Entity* this); void Keaton(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CE7B0); + EnemyFunctionHandler(this, Keaton_Functions); SetChildOffset(this, 0, 1, -18); } -void sub_080323DC(Entity* this) { +void Keaton_OnTick(Entity* this) { gUnk_080CE7C8[this->action](this); } -void sub_080323F4(Entity* this) { +void Keaton_OnCollision(Entity* this) { u32 var; if (this->action != 3 && this->action != 4) { @@ -46,17 +46,17 @@ void sub_080323F4(Entity* this) { this->direction = DirectionTurnAround(DirectionRoundUp(this->knockbackDirection)); InitAnimationForceUpdate(this, this->direction >> 3); } else if (this->bitfield == 0xCC) { - if (this->field_0x43 == 0) { + if (this->confusedTime == 0) { sub_0803275C(this); } } - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1C); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CE7B0); + EnemyFunctionHandlerAfterCollision(this, Keaton_Functions); } -void nullsub_155(Entity* this) { +void Keaton_OnGrabbed(Entity* this) { } void sub_08032468(Entity* this) { @@ -74,7 +74,7 @@ void sub_0803248C(Entity* this) { if (this->actionDelay == 0) { sub_08032650(this); } - if (ProcessMovement(this) == 0) { + if (ProcessMovement0(this) == 0) { this->actionDelay = 1; } UpdateAnimationSingleFrame(this); @@ -126,7 +126,7 @@ void sub_08032574(Entity* this) { return; } - if (--this->field_0x76.HWORD == 0 || !sub_080AEFE0(this)) { + if (--this->field_0x76.HWORD == 0 || !ProcessMovement2(this)) { sub_0803275C(this); return; } diff --git a/src/enemy/keese.c b/src/enemy/keese.c index 1d276078..63b5b78d 100644 --- a/src/enemy/keese.c +++ b/src/enemy/keese.c @@ -8,12 +8,11 @@ #include "enemy.h" #include "functions.h" -extern void sub_08001328(Entity*); +extern void GenericKnockback2(Entity*); extern void Keese_StartFly(Entity*); -extern void sub_080AEFB4(Entity*); extern void sub_08021F24(Entity*); -extern void (*const gKeeseFunctions[])(Entity*); +extern void (*const Keese_Functions[])(Entity*); extern void (*const gKeeseActions[])(Entity*); extern void (*const gUnk_080CB6C4[])(Entity*); @@ -27,18 +26,18 @@ enum { }; void Keese(Entity* this) { - gKeeseFunctions[GetNextFunction(this)](this); + Keese_Functions[GetNextFunction(this)](this); } void Keese_OnTick(Entity* this) { gKeeseActions[this->action](this); } -void sub_08021d98(Entity* this) { - sub_0804AA30(this, gKeeseFunctions); +void Keese_OnCollision(Entity* this) { + EnemyFunctionHandlerAfterCollision(this, Keese_Functions); } -void sub_08021DA8(Entity* this) { +void Keese_OnGrabbed(Entity* this) { if (sub_0806F520(this)) { gUnk_080CB6C4[this->subAction](this); } @@ -54,7 +53,7 @@ void sub_08021DD4(Entity* this) { void sub_08021DDC(Entity* this) { if (sub_0806F3E4(this)) { - sub_0804A7D4(this); + GenericDeath(this); } } @@ -83,7 +82,7 @@ void Keese_Fly(Entity* this) { if (this->frame & 0x80) { sub_08021F24(this); } else { - sub_080AEFB4(this); + ProcessMovement1(this); } this->spriteOffsetY = gKeeseSpriteOffsets[this->frame]; } @@ -131,13 +130,13 @@ void sub_08021F24(Entity* this) { } // clang-format off -void (*const gKeeseFunctions[])(Entity*) = { +void (*const Keese_Functions[])(Entity*) = { Keese_OnTick, - sub_08021d98, - sub_08001328, - sub_0804A7D4, - sub_08001242, - sub_08021DA8, + Keese_OnCollision, + GenericKnockback2, + GenericDeath, + GenericConfused, + Keese_OnGrabbed, }; void (*const gKeeseActions[])(Entity*) = { diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index b9d72989..70145906 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -38,18 +38,18 @@ typedef struct { } PACKED OffsetCoords; // Variables -extern void (*const gUnk_080D0110[])(Entity*); +extern void (*const Lakitu_Functions[])(Entity*); extern void (*const gUnk_080D0128[])(Entity*); extern void (*const gUnk_080D0148[])(Entity*); extern const OffsetCoords gUnk_080D0154[]; void Lakitu(Entity* this) { - EnemyFunctionHandler(this, gUnk_080D0110); + EnemyFunctionHandler(this, Lakitu_Functions); SetChildOffset(this, 0, 1, -16); } -void Lakitu_DoAction(Entity* this) { +void Lakitu_OnTick(Entity* this) { if (this->action != 0 && this->action != 7) { sub_0803CAD0(this); } @@ -57,7 +57,7 @@ void Lakitu_DoAction(Entity* this) { LakituActionFuncs[this->action](this); } -void sub_0803C784(Entity* this) { +void Lakitu_OnCollision(Entity* this) { if ((this->bitfield & 0x7f) == 0x1d) { this->zVelocity = Q_16_16(2.0); @@ -87,14 +87,14 @@ void sub_0803C784(Entity* this) { } } - if (this->field_0x43) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080D0110); + EnemyFunctionHandlerAfterCollision(this, Lakitu_Functions); } -void sub_0803C820(Entity* this) { +void Lakitu_OnGrabbed(Entity* this) { if (sub_0806F520(this)) { gUnk_080D0148[this->subAction](this); } @@ -271,7 +271,7 @@ void sub_0803CAD0(Entity* this) { this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, this->field_0x74.HWORD, this->field_0x76.HWORD); - sub_080AEFE0(this); + ProcessMovement2(this); } } @@ -393,8 +393,8 @@ void sub_0803CC08(Entity* this) { DeleteEntity(cloud); } -void (*const gUnk_080D0110[])(Entity*) = { - Lakitu_DoAction, sub_0803C784, sub_08001324, sub_0804A7D4, sub_08001242, sub_0803C820, +void (*const Lakitu_Functions[])(Entity*) = { + Lakitu_OnTick, Lakitu_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Lakitu_OnGrabbed, }; void (*const LakituActionFuncs[])(Entity*) = { diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index 3cf330c2..dda0a902 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -13,32 +13,27 @@ #include "effects.h" #include "enemy.h" -extern u32 GetNextFunction(Entity*); - -extern void (*const gUnk_080D0418[6])(Entity*); +extern void (*const LakituCloud_Functions[6])(Entity*); extern void (*const gUnk_080D0430[3])(Entity*); extern void (*const gUnk_080D043C[3])(Entity*); -extern void SoundReqClipped(Entity*, u32); -extern void sub_0803CE14(Entity*); -extern void sub_0803CE3C(Entity*); -extern void sub_08079D84(void); -extern void sub_080A2CC0(Entity*, Entity**, u16*); +void sub_0803CE14(Entity*); +void sub_0803CE3C(Entity*); void LakituCloud(Entity* this) { - gUnk_080D0418[GetNextFunction(this)](this); + LakituCloud_Functions[GetNextFunction(this)](this); } -void sub_0803CCD4(Entity* this) { +void LakituCloud_OnTick(Entity* this) { gUnk_080D0430[this->action](this); } -void sub_0803CCEC(Entity* this) { +void LakituCloud_OnKnockback(Entity* this) { this->knockbackDuration = 0; - sub_0803CCD4(this); + LakituCloud_OnTick(this); } -void sub_0803CCFC(Entity* this) { +void LakituCloud_OnGrabbed(Entity* this) { if (sub_0806F520(this) == 0) { if (this->subAction == 2) { sub_0803CE3C(this); @@ -153,8 +148,9 @@ void sub_0803CE3C(Entity* this) { sub_0803CE14(this); } -void (*const gUnk_080D0418[])(Entity*) = { - sub_0803CCD4, sub_0803CCD4, sub_0803CCEC, sub_0804A7D4, sub_08001242, sub_0803CCFC, +void (*const LakituCloud_Functions[])(Entity*) = { + LakituCloud_OnTick, LakituCloud_OnTick, LakituCloud_OnKnockback, + GenericDeath, GenericConfused, LakituCloud_OnGrabbed, }; void (*const gUnk_080D0430[])(Entity*) = { diff --git a/src/enemy/leever.c b/src/enemy/leever.c index df9542f0..776ec72b 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -16,7 +16,7 @@ extern Entity* gUnk_020000B0; bool32 Leever_PlayerInRange(Entity*, s32); void Leever_Move(Entity*); -extern void (*const gLeeverFunctions[])(Entity*); +extern void (*const Leever_Functions[])(Entity*); extern void (*const gLeeverActions[])(Entity*); extern const s8 gLeeverDrift[]; extern const u16 gUnk_080CA4CA[]; @@ -33,7 +33,7 @@ enum { }; void Leever(Entity* this) { - EnemyFunctionHandler(this, gLeeverFunctions); + EnemyFunctionHandler(this, Leever_Functions); SetChildOffset(this, 0, 1, -0x10); } @@ -41,22 +41,22 @@ void Leever_OnTick(Entity* this) { gLeeverActions[this->action](this); } -void sub_0801FC40(Entity* this) { +void Leever_OnCollision(Entity* this) { if (this->bitfield == 0x80) { if (this->action == 3) { this->field_0x74.HWORD = 1; } } else { - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } } - sub_0804AA30(this, gLeeverFunctions); + EnemyFunctionHandlerAfterCollision(this, Leever_Functions); } -void sub_0801FC7C(Entity* this) { +void Leever_OnDeath(Entity* this) { if (this->type == LeeverForm_Red) { - sub_0804A7D4(this); + GenericDeath(this); } else { CreateDeathFx(this, 0xf1, 0); } @@ -180,16 +180,16 @@ void Leever_Move(Entity* this) { } } - ProcessMovement(this); + ProcessMovement0(this); } // clang-format off -void (*const gLeeverFunctions[])(Entity*) = { +void (*const Leever_Functions[])(Entity*) = { Leever_OnTick, - sub_0801FC40, - sub_08001324, - sub_0801FC7C, - sub_08001242, + Leever_OnCollision, + GenericKnockback, + Leever_OnDeath, + GenericConfused, Leever_OnTick, }; diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 8c39b720..4ddac95d 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -19,19 +19,19 @@ void sub_080281A0(Entity*); bool32 sub_080281E0(u32); void sub_08028224(u32); -extern void (*const gUnk_080CC6FC[])(Entity*); +extern void (*const LikeLike_Functions[])(Entity*); extern void (*const gUnk_080CC714[])(Entity*); void LikeLike(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CC6FC); + EnemyFunctionHandler(this, LikeLike_Functions); SetChildOffset(this, 0, 1, -0x10); } -void sub_08027D8C(Entity* this) { +void LikeLike_OnTick(Entity* this) { gUnk_080CC714[this->action](this); } -void sub_08027DA4(Entity* this) { +void LikeLike_OnCollision(Entity* this) { if (this->hitType == 1) { this->action = 3; COLLISION_OFF(this); @@ -55,22 +55,22 @@ void sub_08027DA4(Entity* this) { this->actionDelay = 0x20; } - if (this->field_0x43) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CC6FC); + EnemyFunctionHandlerAfterCollision(this, LikeLike_Functions); } -void sub_08027E40(Entity* this) { +void LikeLike_OnDeath(Entity* this) { if (this->actionDelay == 2 && this->field_0x80.HALF.LO != 0xff) { SetDefaultPriority(this, PRIO_NO_BLOCK); sub_08028224(this->field_0x80.HALF.LO); } - sub_0804A7D4(this); + GenericDeath(this); } -void nullsub_139(Entity* this) { +void LikeLike_OnGrabbed(Entity* this) { /* ... */ } @@ -122,7 +122,7 @@ void sub_08027EFC(Entity* this) { this->field_0x82.HALF.LO = this->direction; this->actionDelay = 8; } - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); } else { this->action = 6; @@ -271,8 +271,8 @@ void sub_08028224(u32 param_1) { MessageFromTarget(0x579); } -void (*const gUnk_080CC6FC[])(Entity*) = { - sub_08027D8C, sub_08027DA4, sub_08001324, sub_08027E40, sub_08001242, nullsub_139, +void (*const LikeLike_Functions[])(Entity*) = { + LikeLike_OnTick, LikeLike_OnCollision, GenericKnockback, LikeLike_OnDeath, GenericConfused, LikeLike_OnGrabbed, }; void (*const gUnk_080CC714[])(Entity*) = { diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index e68df9fd..37708cc4 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -23,7 +23,7 @@ void sub_08029FB4(Entity*, u32, u32); void sub_0802A0F8(Entity*); extern void (*const gUnk_080CCD44[])(Entity*); -extern void (*const gUnk_080CCD60[])(Entity*); +extern void (*const Madderpillar_Functions[])(Entity*); extern void (*const gUnk_080CCD78[])(Entity*); extern void (*const gUnk_080CCD88[])(Entity*); extern const u8 gUnk_080CCDA0[]; @@ -36,14 +36,14 @@ void Madderpillar(Entity* this) { } void sub_08029870(Entity* this) { - gUnk_080CCD60[GetNextFunction(this)](this); + Madderpillar_Functions[GetNextFunction(this)](this); } -void sub_0802988C(Entity* this) { +void Madderpillar_OnTick(Entity* this) { gUnk_080CCD78[this->action](this); } -void sub_080298A4(Entity* this) { +void Madderpillar_OnCollision(Entity* this) { if (this->action == 1) { switch (this->bitfield & 0x7f) { case 0: @@ -67,18 +67,18 @@ void sub_080298A4(Entity* this) { } } - sub_0804AA30(this, gUnk_080CCD60); + EnemyFunctionHandlerAfterCollision(this, Madderpillar_Functions); } -void sub_08029980(Entity* this) { +void Madderpillar_OnDeath(Entity* this) { if (this->field_0xf) { this->field_0xf--; } else { - sub_0804A7D4(this); + GenericDeath(this); } } -void nullsub_14(Entity* this) { +void Madderpillar_OnGrabbed(Entity* this) { /* ... */ } @@ -450,7 +450,7 @@ void sub_0802A098(Entity* this) { } uVar1 = this->x.HALF.HI; uVar2 = this->y.HALF.HI; - ProcessMovement(this); + ProcessMovement0(this); if (sub_08029F48(this)) { sub_08029E0C(this); sub_08029EEC(this); @@ -522,13 +522,13 @@ void (*const gUnk_080CCD44[])(Entity*) = { sub_08029C98, }; -void (*const gUnk_080CCD60[])(Entity*) = { - sub_0802988C, - sub_080298A4, - sub_0802988C, - sub_08029980, - sub_08001242, - nullsub_14, +void (*const Madderpillar_Functions[])(Entity*) = { + Madderpillar_OnTick, + Madderpillar_OnCollision, + Madderpillar_OnTick, + Madderpillar_OnDeath, + GenericConfused, + Madderpillar_OnGrabbed, }; void (*const gUnk_080CCD78[])(Entity*) = { diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index dd687ac0..8f9a317d 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -29,9 +29,9 @@ void sub_0803BA8C(Entity*, u32); void sub_0803B724(Entity*); extern void SoundReqClipped(Entity*, u32); -void sub_0803A170(Entity*); -void sub_0803A188(Entity*); -void nullsub_167(Entity*); +void MazaalBracelet_OnTick(Entity*); +void MazaalBracelet_OnCollision(Entity*); +void MazaalBracelet_OnGrabbed(Entity*); void sub_0803A254(Entity*); void sub_0803B8F8(Entity*); @@ -98,8 +98,9 @@ extern Hitbox gUnk_080FD364; extern Hitbox gUnk_080FD36C; extern Hitbox gUnk_080FD374; -void (*const gUnk_080CFC14[])(Entity*) = { sub_0803A170, sub_0803A188, sub_08001324, - sub_0804A7D4, sub_08001242, nullsub_167 }; +void (*const MazaalBracelet_Functions[])(Entity*) = { MazaalBracelet_OnTick, MazaalBracelet_OnCollision, + GenericKnockback, GenericDeath, + GenericConfused, MazaalBracelet_OnGrabbed }; void (*const gUnk_080CFC2C[])(Entity*) = { sub_0803A254, sub_0803A254, sub_0803B8F8, sub_0803B8F8 }; @@ -130,14 +131,14 @@ const u16 gUnk_080CFD5C[] = { 0xe7, 0xe8 }; extern s8 gUnk_080CED6C[8]; void MazaalBracelet(Entity* this) { - gUnk_080CFC14[GetNextFunction(this)](this); + MazaalBracelet_Functions[GetNextFunction(this)](this); } -void sub_0803A170(Entity* this) { +void MazaalBracelet_OnTick(Entity* this) { gUnk_080CFC2C[this->type](this); } -void sub_0803A188(Entity* this) { +void MazaalBracelet_OnCollision(Entity* this) { Entity* ent; if (this->type < 2) { @@ -164,10 +165,10 @@ void sub_0803A188(Entity* this) { SoundReq(SFX_BOSS_HIT); } } - sub_0804AA30(this, gUnk_080CFC14); + EnemyFunctionHandlerAfterCollision(this, MazaalBracelet_Functions); } -void nullsub_167(Entity* this) { +void MazaalBracelet_OnGrabbed(Entity* this) { } void sub_0803A254(Entity* this) { diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index a2432d0d..add39f8b 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -34,9 +34,9 @@ void sub_0803467C(Entity*); u32 sub_080348A4(Entity*, Entity*, u32); void sub_08034C00(Entity*); -void sub_08033EF0(Entity* this); -void sub_08033F08(Entity* this); -void nullsub_160(Entity* this); +void MazaalHead_OnTick(Entity* this); +void MazaalHead_OnCollision(Entity* this); +void MazaalHead_OnGrabbed(Entity* this); void sub_08033F1C(Entity* this); void sub_08034A84(Entity* this); void sub_08034AC4(Entity* this); @@ -67,8 +67,8 @@ void sub_08034B0C(Entity* this); void sub_08034B38(Entity* this); void sub_08034BA0(Entity* this); -void (*const gUnk_080CEC88[])(Entity*) = { - sub_08033EF0, sub_08033F08, sub_08001324, sub_0804A7D4, sub_08001242, nullsub_160, +void (*const MazaalHead_Functions[])(Entity*) = { + MazaalHead_OnTick, MazaalHead_OnCollision, GenericKnockback, GenericDeath, GenericConfused, MazaalHead_OnGrabbed, }; void (*const gUnk_080CECA0[])(Entity*) = { sub_08033F1C, sub_08034A84, sub_08034AC4, sub_08034AC4, sub_08034BC8, @@ -102,18 +102,18 @@ const ScreenTransitionData gUnk_080CED88 = { 1, { 0, 0, 0, 0 }, 0x88, 0xf8, 0, 0 const ScreenTransitionData gUnk_080CED9C = { 1, { 0, 0, 0, 0 }, 0x88, 0xf8, 0, 0x5a, 0, 1, 0, 0, 0 }; void MazaalHead(Entity* this) { - gUnk_080CEC88[GetNextFunction(this)](this); + MazaalHead_Functions[GetNextFunction(this)](this); } -void sub_08033EF0(Entity* this) { +void MazaalHead_OnTick(Entity* this) { gUnk_080CECA0[this->type](this); } -void sub_08033F08(Entity* this) { - sub_0804AA30(this, gUnk_080CEC88); +void MazaalHead_OnCollision(Entity* this) { + EnemyFunctionHandlerAfterCollision(this, MazaalHead_Functions); } -void nullsub_160(Entity* this) { +void MazaalHead_OnGrabbed(Entity* this) { } void sub_08033F1C(Entity* this) { diff --git a/src/enemy/mazaalMacro.c b/src/enemy/mazaalMacro.c index aa47e78b..31de7ed6 100644 --- a/src/enemy/mazaalMacro.c +++ b/src/enemy/mazaalMacro.c @@ -21,9 +21,9 @@ void sub_08034F70(Entity*); void sub_08035120(Entity*); void sub_08035050(Entity*); -void sub_08034C7C(Entity* this); -void sub_08034CA4(Entity* this); -void sub_08034CBC(Entity* this); +void MazaalMacro_OnTick(Entity* this); +void MazaalMacro_OnCollision(Entity* this); +void MazaalMacro_OnDeath(Entity* this); void sub_08034CC4(Entity* this); void sub_08034D4C(Entity* this); void sub_08034DC8(Entity* this); @@ -34,8 +34,8 @@ void sub_08034ED8(Entity* this); void sub_08034EE4(Entity* this); void sub_08034F58(Entity* this); -void (*const gUnk_080CEE90[])(Entity*) = { - sub_08034C7C, sub_08034CA4, sub_08001324, sub_08034CBC, sub_08001242, +void (*const MazaalMacro_Functions[])(Entity*) = { + MazaalMacro_OnTick, MazaalMacro_OnCollision, GenericKnockback, MazaalMacro_OnDeath, GenericConfused, }; void (*const gUnk_080CEEA4[])(Entity*) = { sub_08034CC4, @@ -54,10 +54,10 @@ const s16 gUnk_080CEED8[] = { -0x82, -0x81, -0x80, -0x7f, -0x7e, -0x42, -0x41, - extern const ScreenTransitionData gUnk_0813ABA8; void MazaalMacro(Entity* this) { - gUnk_080CEE90[GetNextFunction(this)](this); + MazaalMacro_Functions[GetNextFunction(this)](this); } -void sub_08034C7C(Entity* this) { +void MazaalMacro_OnTick(Entity* this) { if (this->type != 2) { gUnk_080CEEA4[this->action](this); } else { @@ -65,13 +65,13 @@ void sub_08034C7C(Entity* this) { } } -void sub_08034CA4(Entity* this) { +void MazaalMacro_OnCollision(Entity* this) { sub_08034FA0(this); - sub_0804AA30(this, gUnk_080CEE90); + EnemyFunctionHandlerAfterCollision(this, MazaalMacro_Functions); } -void sub_08034CBC(Entity* this) { - sub_0804A7D4(this); +void MazaalMacro_OnDeath(Entity* this) { + GenericDeath(this); } void sub_08034CC4(Entity* this) { diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c index fd6f54e2..0f847151 100644 --- a/src/enemy/miniFireballGuy.c +++ b/src/enemy/miniFireballGuy.c @@ -10,31 +10,31 @@ extern void sub_08045678(Entity*); -extern void (*const gUnk_080D1868[])(Entity*); +extern void (*const MiniFireballGuy_Functions[])(Entity*); extern void (*const gUnk_080D1880[])(Entity*); void MiniFireballGuy(Entity* this) { - EnemyFunctionHandler(this, gUnk_080D1868); + EnemyFunctionHandler(this, MiniFireballGuy_Functions); } -void sub_080455BC(Entity* this) { +void MiniFireballGuy_OnTick(Entity* this) { gUnk_080D1880[this->action](this); } -void sub_080455D4(Entity* this) { - sub_0804AA30(this, gUnk_080D1868); +void MiniFireballGuy_OnCollision(Entity* this) { + EnemyFunctionHandlerAfterCollision(this, MiniFireballGuy_Functions); } -void sub_080455E4(Entity* this) { +void MiniFireballGuy_OnDeath(Entity* this) { if ((this != this->parent) && (this->parent != NULL)) { this->field_0x6c.HALF.LO &= 0x7f; this->parent->child = this->child; this->child->parent = this->parent; } - sub_0804A7D4(this); + GenericDeath(this); } -void nullsub_23(Entity* this) { +void MiniFireballGuy_OnGrabbed(Entity* this) { } void sub_08045618(Entity* this) { @@ -48,7 +48,7 @@ void sub_08045618(Entity* this) { } void sub_08045654(Entity* this) { - sub_080AEFE0(this); + ProcessMovement2(this); GetNextFrame(this); if (GravityUpdate(this, 0x1800) == 0) { sub_08045678(this); diff --git a/src/enemy/miniSlime.c b/src/enemy/miniSlime.c index 8de89a28..7c82d1d6 100644 --- a/src/enemy/miniSlime.c +++ b/src/enemy/miniSlime.c @@ -13,26 +13,26 @@ void sub_08045374(Entity*); extern void sub_080452E4(Entity*); extern void ReplaceMonitoredEntity(Entity*, Entity*); -extern void (*const gUnk_080D17C0[])(Entity*); +extern void (*const MiniSlime_Functions[])(Entity*); extern void (*const gUnk_080D17D8[])(Entity*); void MiniSlime(Entity* this) { - EnemyFunctionHandler(this, gUnk_080D17C0); + EnemyFunctionHandler(this, MiniSlime_Functions); SetChildOffset(this, 0, 1, -8); } -void sub_08045220(Entity* this) { +void MiniSlime_OnTick(Entity* this) { gUnk_080D17D8[this->action](this); } -void sub_08045238(Entity* this) { - if (this->field_0x43) - sub_0804A9FC(this, 0x1c); +void MiniSlime_OnCollision(Entity* this) { + if (this->confusedTime) + Create0x68FX(this, FX_STARS); - sub_0804AA30(this, gUnk_080D17C0); + EnemyFunctionHandlerAfterCollision(this, MiniSlime_Functions); } -void sub_0804525C(Entity* this) { +void MiniSlime_OnDeath(Entity* this) { Entity* parent = this->parent; if (this != parent && parent) { this->field_0x6c.HALF.LO &= 0x7f; @@ -41,10 +41,10 @@ void sub_0804525C(Entity* this) { if (this->field_0x6c.HALF.HI & 0x40) ReplaceMonitoredEntity(this, parent); } - sub_0804A7D4(this); + GenericDeath(this); } -void nullsub_22(void) { +void MiniSlime_OnGrabbed(void) { } void sub_080452A4(Entity* this) { @@ -88,7 +88,7 @@ void sub_080452FC(Entity* this) { } void sub_08045374(Entity* this) { - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); if (--this->actionDelay == 0) this->action = 1; diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c index e53f2856..7a5ab69c 100644 --- a/src/enemy/moldorm.c +++ b/src/enemy/moldorm.c @@ -12,7 +12,7 @@ void sub_08022EAC(Entity*); void sub_08022F14(Entity*); extern void (*const gUnk_080CBB90[])(Entity*); -extern void (*const gUnk_080CBBA0[])(Entity*); +extern void (*const Moldorm_Functions[])(Entity*); extern void (*const gUnk_080CBBB4[])(Entity*); extern void (*const gUnk_080CBBBC[])(Entity*); @@ -26,15 +26,15 @@ void sub_08022BA0(Entity* this) { this->field_0x78.HALF.HI++; this->field_0x74.HWORD = this->x.HALF.HI; this->field_0x76.HWORD = this->y.HALF.HI; - EnemyFunctionHandler(this, gUnk_080CBBA0); + EnemyFunctionHandler(this, Moldorm_Functions); sub_08022EAC(this); } -void sub_08022BD4(Entity* this) { +void Moldorm_OnTick(Entity* this) { gUnk_080CBBB4[this->action](this); } -void sub_08022BEC(Entity* this) { +void Moldorm_OnCollision(Entity* this) { if (this->field_0x7a.HALF.LO != this->health) this->field_0x7a.HALF.HI = 30; @@ -48,7 +48,7 @@ void sub_08022BEC(Entity* this) { this->child->iframes = this->iframes; (*(Entity**)&this->field_0x7c)->iframes = this->iframes; (*(Entity**)&this->field_0x80)->iframes = this->iframes; - sub_0804AA30(this, gUnk_080CBBA0); + EnemyFunctionHandlerAfterCollision(this, Moldorm_Functions); } void sub_08022C58(Entity* this) { @@ -101,7 +101,7 @@ void sub_08022D40(Entity* this) { } } else { sub_08022F14(this); - ProcessMovement(this); + ProcessMovement0(this); if (this->collisions) { sub_0800417E(this, this->collisions); @@ -189,12 +189,12 @@ void (*const gUnk_080CBB90[])(Entity*) = { sub_08022D90, }; -void (*const gUnk_080CBBA0[])(Entity*) = { - sub_08022BD4, - sub_08022BEC, - sub_08001324, - sub_0804A7D4, - sub_08001242, +void (*const Moldorm_Functions[])(Entity*) = { + Moldorm_OnTick, + Moldorm_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, }; void (*const gUnk_080CBBB4[])(Entity*) = { diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index 652f0136..b6099372 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -23,7 +23,7 @@ bool32 sub_08023B38(Entity*); extern const u8 gUnk_080B37A0[]; -extern void (*const gUnk_080CBC38[])(Entity*); +extern void (*const Moldworm_Functions[])(Entity*); extern void (*const gUnk_080CBC50[])(Entity*); extern const s8 gUnk_080CBC70[]; extern const s8 gUnk_080CBC90[]; @@ -40,7 +40,7 @@ NONMATCH("asm/non_matching/moldworm/Moldworm.inc", void Moldworm(Entity* this)) sub_0802390C(this); } this->field_0x7c.BYTES.byte1 = this->field_0x7c.BYTES.byte0; - EnemyFunctionHandler(this, gUnk_080CBC38); + EnemyFunctionHandler(this, Moldworm_Functions); } else { if (this->parent->next) { if (this->type != 8) { @@ -61,11 +61,11 @@ NONMATCH("asm/non_matching/moldworm/Moldworm.inc", void Moldworm(Entity* this)) } END_NONMATCH -void sub_080230CC(Entity* this) { +void Moldworm_OnTick(Entity* this) { gUnk_080CBC50[this->action](this); } -void sub_080230E4(Entity* this) { +void Moldworm_OnCollision(Entity* this) { if (this->subAction == 0xff) { this->action = 7; this->actionDelay = 1; @@ -94,15 +94,15 @@ void sub_080230E4(Entity* this) { gPlayerState.flags &= ~PL_MOLDWORM_CAPTURED; } - sub_0804AA30(this, gUnk_080CBC38); + EnemyFunctionHandlerAfterCollision(this, Moldworm_Functions); } -void sub_080231A4(Entity* this) { +void Moldworm_OnKnockback(Entity* this) { this->field_0x7c.BYTES.byte0++; - sub_08001324(this); + GenericKnockback(this); } -void nullsub_135(Entity* this) { +void Moldworm_OnGrabbed(Entity* this) { } void sub_080231BC(Entity* this) { @@ -219,7 +219,7 @@ void sub_08023398(Entity* this) { } else { int prevX = this->x.WORD; int prevY = this->y.WORD; - ProcessMovement(this); + ProcessMovement0(this); if (this->x.WORD == prevX && this->y.WORD == prevY) { this->field_0x7c.BYTES.byte0--; } @@ -520,13 +520,13 @@ void sub_08023AB0(Entity* this) { ASM_FUNC("asm/non_matching/moldworm/sub_08023B38.inc", bool32 sub_08023B38(Entity* this)) // clang-format off -void (*const gUnk_080CBC38[])(Entity*) = { - sub_080230CC, - sub_080230E4, - sub_080231A4, - sub_0804A7D4, - sub_08001242, - nullsub_135, +void (*const Moldworm_Functions[])(Entity*) = { + Moldworm_OnTick, + Moldworm_OnCollision, + Moldworm_OnKnockback, + GenericDeath, + GenericConfused, + Moldworm_OnGrabbed, }; void (*const gUnk_080CBC50[])(Entity*) = { diff --git a/src/enemy/mulldozer.c b/src/enemy/mulldozer.c index 38e3bf88..6a6a79de 100644 --- a/src/enemy/mulldozer.c +++ b/src/enemy/mulldozer.c @@ -54,10 +54,10 @@ void Mulldozer_OnInit(MulldozerEntity* this) { } void sub_08032CAC(MulldozerEntity* this) { - if (super->field_0x43 != 0) { - sub_0804A9FC(super, 0x1c); + if (super->confusedTime != 0) { + Create0x68FX(super, 0x1c); } - sub_0804AA30(super, Mulldozer_Functions); + EnemyFunctionHandlerAfterCollision(super, Mulldozer_Functions); if ((super->bitfield & 0x80) != 0) { switch (super->bitfield & 0x3f) { case 2: @@ -87,7 +87,7 @@ void sub_08032D3C(MulldozerEntity* this) { sub_08032F24(this); sub_080331E8(this); } - sub_08001324(super); + GenericKnockback(super); } void nullsub_157(MulldozerEntity* this) { @@ -159,11 +159,11 @@ void Mulldozer_Action5(MulldozerEntity* this) { sub_080332A8(this); } sub_080331E8(this); - ProcessMovement(super); + ProcessMovement0(super); } void Mulldozer_Action6(MulldozerEntity* this) { - ProcessMovement(super); + ProcessMovement0(super); sub_08032F48(this); if (--super->field_0xf == 0) { super->field_0xf = 2; @@ -206,7 +206,7 @@ void sub_08032F64(MulldozerEntity* this) { sub_08032F24(this); } sub_08032F48(this); - ProcessMovement(super); + ProcessMovement0(super); } void sub_08032F90(MulldozerEntity* this) { @@ -441,8 +441,8 @@ void (*const Mulldozer_Functions[])(MulldozerEntity*) = { Mulldozer_OnInit, sub_08032CAC, sub_08032D3C, - (void (*)(MulldozerEntity*))sub_0804A7D4, - (void (*)(MulldozerEntity*))sub_08001242, + (void (*)(MulldozerEntity*))GenericDeath, + (void (*)(MulldozerEntity*))GenericConfused, nullsub_157, }; void (*const Mulldozer_Actions[])(MulldozerEntity*) = { diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c index 6247a349..5ee3c12a 100644 --- a/src/enemy/octorok.c +++ b/src/enemy/octorok.c @@ -12,7 +12,7 @@ void Octorok_Pause(Entity*); bool32 Octorok_FacesPlayer(Entity*); void Octorok_Turn(Entity*); -extern void (*const gOctorok[6])(Entity*); +extern void (*const Octorok_Functions[6])(Entity*); extern void (*const gOctorokActions[4])(Entity*); extern void (*const gUnk_080CA158[6])(Entity*); @@ -24,7 +24,7 @@ extern const s8 gUnk_080CA17E[2]; // Main void Octorok(Entity* this) { - EnemyFunctionHandler(this, gOctorok); + EnemyFunctionHandler(this, Octorok_Functions); SetChildOffset(this, 0, 1, -16); } @@ -34,23 +34,23 @@ void Octorok_OnTick(Entity* this) { } // Touch player -void sub_0801EAE8(Entity* this) { - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 28); +void Octorok_OnCollision(Entity* this) { + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gOctorok); + EnemyFunctionHandlerAfterCollision(this, Octorok_Functions); } // Death -void sub_0801EB0C(Entity* this) { +void Octorok_OnDeath(Entity* this) { if (this->type == 0) { - sub_0804A7D4(this); + GenericDeath(this); } else { CreateDeathFx(this, 241, 0); } } -void sub_0801EB2C(Entity* this) { +void Octorok_OnGrabbed(Entity* this) { if (this->subAction < 3 && !sub_0806F520(this)) { Octorok_Pause(this); InitializeAnimation(this, this->animationState); @@ -113,7 +113,7 @@ void Octorok_Idle(Entity* this) { } void Octorok_Move(Entity* this) { - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); if (--this->actionDelay == 0) { if (Octorok_FacesPlayer(this) && gOctorokSpitChanceModifier[this->type] <= (Random() & 3)) { @@ -194,13 +194,13 @@ bool32 Octorok_FacesPlayer(Entity* this) { } // clang-format off -void (*const gOctorok[])(Entity*) = { +void (*const Octorok_Functions[])(Entity*) = { Octorok_OnTick, - sub_0801EAE8, - sub_08001324, - sub_0801EB0C, - sub_08001242, - sub_0801EB2C, + Octorok_OnCollision, + GenericKnockback, + Octorok_OnDeath, + GenericConfused, + Octorok_OnGrabbed, }; void (*const gOctorokActions[])(Entity*) = { diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index 4af9d5b8..9198342b 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -151,7 +151,7 @@ void OctorokBoss(Entity* this) { OctorokBoss_Functions[GetNextFunction(this)](this); } -void OctorokBoss_OnHealthZero(Entity* this) { +void OctorokBoss_Death(Entity* this) { if (this->type == WHOLE) { this->action = HIT; this->subAction = 0; @@ -239,7 +239,7 @@ void OctorokBoss_Hit_SubAction1(Entity* this) { 3; #endif this->speed = 0x100; - ProcessMovement(this); + ProcessMovement0(this); } else { // Freeze if (this->type2 == 0) { @@ -356,7 +356,7 @@ void OctorokBoss_Hit_SubAction6(Entity* this) { GET_HELPER(this)->mouthObject->health = 1; SoundReq(SFX_BOSS_DIE); // Kill this boss - sub_0804A7D4(this); + GenericDeath(this); } } else { GET_TIMER(this)--; @@ -389,7 +389,7 @@ ASM_FUNC("asm/non_matching/octorokBoss/OctorokBoss_Init.inc", void OctorokBoss_I GET_HELPER(this) = helper; if (helper == NULL) { // Kill this boss - sub_0804A7D4(this); + GenericDeath(this); return; } this->myHeap = (u32*)helper; @@ -784,7 +784,7 @@ void OctorokBoss_Action1_WaitForTurn(Entity* this) { GET_ATTACK_WAIT_TURNS(this)--; OctorokBoss_ResetToSubAction0(this); } else { - if (ProcessMovement(this) == 0) { + if (ProcessMovement0(this) == 0) { GET_TIMER(this) = 0; } } @@ -802,7 +802,7 @@ void OctorokBoss_Action1_ChargeAttack(Entity* this) { bool32 knockbackCondition; if (GET_TIMER(this) == 0) { - ProcessMovement(this); + ProcessMovement0(this); knockbackCondition = 0; if ((this->direction != 0) && (this->direction != 0x10)) { knockbackCondition = ((u32)this->collisions & 0xee00) != 0; @@ -812,7 +812,7 @@ void OctorokBoss_Action1_ChargeAttack(Entity* this) { } if (knockbackCondition != 0) { this->knockbackDuration = 0x20; - this->field_0x46 = 0x200; + this->knockbackSpeed = 0x200; this->knockbackDirection = this->direction ^ 0x10; GET_HELPER(this)->fallingStonesTimer += 0x3c; OctorokBoss_SetAttackTimer(this); @@ -1068,7 +1068,7 @@ void OctorokBoss_Burning_SubAction0(Entity* this) { } void OctorokBoss_Burning_SubAction1(Entity* this) { - ProcessMovement(this); + ProcessMovement0(this); if (this->collisions != 0) { this->subAction = 2; GET_HELPER(this)->targetAngle = GET_ANGLE_HI(this); @@ -1079,7 +1079,7 @@ void OctorokBoss_Burning_SubAction1(Entity* this) { GET_HELPER(this)->targetAngle = -GET_HELPER(this)->targetAngle ^ 0x80; } this->knockbackDuration = 0x18; - this->field_0x46 = 0x200; + this->knockbackSpeed = 0x200; this->knockbackDirection = this->direction ^ 0x10; GET_HELPER(this)->fallingStonesTimer += 0x1e; InitScreenShake(0x1e, 0); @@ -1099,7 +1099,7 @@ void OctorokBoss_Burning_SubAction2(Entity* this) { this->subAction = 1; this->direction = ((u8)-GET_ANGLE_HI(this) ^ 0x80) >> 3; this->collisions = 0; - ProcessMovement(this); + ProcessMovement0(this); } else { if ((u8)(GET_HELPER(this)->targetAngle - GET_ANGLE_HI(this)) >= 0x81) { GET_ANGLE(this) -= GET_ANGULAR_VEL(this); @@ -1448,7 +1448,7 @@ void sub_08036FE4(Entity* this) { } void (*const OctorokBoss_Functions[])(Entity*) = { - OctorokBoss_OnTick, OctorokBoss_OnTick, sub_08001324, OctorokBoss_OnHealthZero, sub_08001242, + OctorokBoss_OnTick, OctorokBoss_OnTick, GenericKnockback, OctorokBoss_Death, GenericConfused, }; void (*const OctorokBoss_Hit_SubActions[])(Entity*) = { diff --git a/src/enemy/octorokGolden.c b/src/enemy/octorokGolden.c index 60137119..8f72e7a7 100644 --- a/src/enemy/octorokGolden.c +++ b/src/enemy/octorokGolden.c @@ -2,13 +2,12 @@ #include "enemy.h" #include "functions.h" -void (*const gUnk_080CF46C[])(Entity*); +void (*const OctorokGolden_Functions[])(Entity*); void (*const gUnk_080CF484[])(Entity*); extern void (*const gUnk_080012C8[])(Entity*); const s8 gUnk_080CF490[]; const u8 gUnk_080CF498[]; -extern u16* GetLayerByIndex(u32); extern s32 sub_080012DC(Entity*); extern u32 sub_0804A044(Entity*, Entity*, u32); @@ -21,24 +20,24 @@ void OctorokGolden(Entity* this) { //! @bug index (r4) is uninitialized gUnk_080012C8[index](this); } else { - gUnk_080CF46C[GetNextFunction(this)](this); + OctorokGolden_Functions[GetNextFunction(this)](this); SetChildOffset(this, 0, 1, -0x10); } } -void sub_08037C84(Entity* this) { +void OctorokGolden_OnTick(Entity* this) { gUnk_080CF484[this->action](this); } -void sub_08037C9C(Entity* this) { - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); +void OctorokGolden_OnCollision(Entity* this) { + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CF46C); + EnemyFunctionHandlerAfterCollision(this, OctorokGolden_Functions); } -void sub_08037CC0(Entity* this) { +void OctorokGolden_OnDeath(Entity* this) { if ((this->field_0x3a & 0x2) == 0) { SetGlobalFlag(this->type2); } @@ -65,7 +64,7 @@ void sub_08037D0C(Entity* this) { } UpdateAnimationVariableFrames(this, 2); - if (ProcessMovement(this) == 0) { + if (ProcessMovement0(this) == 0) { sub_08037E14(this); } else if (--this->actionDelay == 0) { sub_08037E14(this); @@ -108,16 +107,16 @@ void sub_08037D54(Entity* this) { void sub_08037E14(Entity* this) { u32 dir; - u16* pLayer; + u8* layer; const s8* ptr; s32 x, y; this->actionDelay = 0x8; dir = (GetFacingDirection(this, &gPlayerEntity) + 4) & 0x18; - pLayer = GetLayerByIndex(this->collisionLayer) + 0x1002; + layer = (u8*)GetLayerByIndex(this->collisionLayer)->_2004; ptr = gUnk_080CF498 + (dir >> 2); x = this->x.HALF.HI + *ptr; y = this->y.HALF.HI + *(ptr + 1); - if (sub_080AE4CC((Entity*)pLayer, x, y, 0)) { + if (IsTileCollision(layer, x, y, 0)) { this->direction = Random() & 0x18; } else { this->direction = dir; @@ -144,8 +143,9 @@ bool32 sub_08037E90(Entity* this) { return 0; } -void (*const gUnk_080CF46C[])(Entity*) = { - sub_08037C84, sub_08037C9C, sub_08001324, sub_08037CC0, sub_08001242, sub_08037C84, +void (*const OctorokGolden_Functions[])(Entity*) = { + OctorokGolden_OnTick, OctorokGolden_OnCollision, GenericKnockback, + OctorokGolden_OnDeath, GenericConfused, OctorokGolden_OnTick, }; void (*const gUnk_080CF484[])(Entity*) = { diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 6389b179..3f85d704 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -8,7 +8,7 @@ #include "enemy.h" #include "functions.h" -extern void (*const gPeahatFunctions[])(Entity*); +extern void (*const Peahat_Functions[])(Entity*); extern void (*const gPeahatPropellerFunctions[])(Entity*); extern void (*const gPeahatActions[])(Entity*); extern void (*const gUnk_080CA5BC[])(Entity*); @@ -40,7 +40,7 @@ enum { void Peahat(Entity* this) { if (this->type == PeahatForm_Torso) { - EnemyFunctionHandler(this, gPeahatFunctions); + EnemyFunctionHandler(this, Peahat_Functions); SetChildOffset(this, 0, 1, -0x10); } else { gPeahatPropellerFunctions[this->action](this); @@ -53,7 +53,7 @@ void Peahat_OnTick(Entity* this) { this->z.HALF.HI = gPeahatFlightHeights[(this->field_0xf++ & 0x30) >> 4]; } -void sub_0801FFDC(Entity* this) { +void Peahat_OnCollision(Entity* this) { if (this->field_0x82.HALF.LO) { if (this->bitfield == 0x94) { Entity* ent = CreateEnemy(PEAHAT, PeahatForm_Propeller); @@ -87,13 +87,13 @@ void sub_0801FFDC(Entity* this) { } } - if (this->field_0x43) - sub_0804A9FC(this, 0x1c); + if (this->confusedTime) + Create0x68FX(this, FX_STARS); - sub_0804AA30(this, gPeahatFunctions); + EnemyFunctionHandlerAfterCollision(this, Peahat_Functions); } -void sub_08020088(Entity* this) { +void Peahat_OnGrabbed(Entity* this) { if (2 >= this->subAction && !sub_0806F520(this)) return; @@ -171,7 +171,7 @@ void Peahat_Fly(Entity* this) { } } - sub_080AEFE0(this); + ProcessMovement2(this); GetNextFrame(this); } @@ -205,7 +205,7 @@ void Peahat_ChargeTarget(Entity* this) { if ((gRoomTransition.frameCount & 3) == 0) sub_08004596(this, GetFacingDirection(this, gUnk_020000B0)); } - sub_080AEFE0(this); + ProcessMovement2(this); } else { sub_080205F8(this); } @@ -223,7 +223,7 @@ void Peahat_ChargeEnd(Entity* this) { if (this->actionDelay & 1) this->speed -= 8; - sub_080AEFE0(this); + ProcessMovement2(this); UpdateAnimationVariableFrames(this, 4); } } @@ -241,7 +241,7 @@ void Peahat_Stunned(Entity* this) { if (this->direction == 0xff) this->direction = this->knockbackDirection; - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); break; case PeahatAnimation_SlicedPropeller: @@ -259,7 +259,7 @@ void Peahat_Stunned(Entity* this) { void Peahat_RepairPropeller(Entity* this) { if (this->field_0xf) if (--this->field_0xf == 0) - sub_0804A9FC(this, 0x1c); + Create0x68FX(this, FX_STARS); if (!sub_0800442E(this) && --this->actionDelay) return; @@ -275,7 +275,7 @@ void Peahat_RepairPropeller(Entity* this) { void Peahat_Recover(Entity* this) { if (this->field_0xf) if (--this->field_0xf == 0) - sub_0804A9FC(this, 0x1c); + Create0x68FX(this, FX_STARS); if (!sub_0800442E(this) && --this->actionDelay) return; @@ -307,7 +307,7 @@ void Peahat_Hop(Entity* this) { if (this->frame & 1) { sub_0800442E(this); } else { - ProcessMovement(this); + ProcessMovement0(this); } } @@ -324,7 +324,7 @@ void Peahat_Takeoff(Entity* this) { sub_0800442E(this); } else { GravityUpdate(this, 0x1c00); - ProcessMovement(this); + ProcessMovement0(this); } } @@ -373,13 +373,13 @@ void sub_08020604(Entity* this) { } // clang-format off -void (*const gPeahatFunctions[])(Entity*) = { +void (*const Peahat_Functions[])(Entity*) = { Peahat_OnTick, - sub_0801FFDC, - sub_08001324, - sub_0804A7D4, - sub_08001242, - sub_08020088, + Peahat_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + Peahat_OnGrabbed, }; void (*const gPeahatPropellerFunctions[])(Entity*) = { diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 5611e2d7..9fa20418 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -30,7 +30,7 @@ void sub_08024F50(Entity*); extern Entity* gUnk_020000B0; -extern void (*const gUnk_080CBEC4[])(Entity*); +extern void (*const Pesto_Functions[])(Entity*); extern void (*const gUnk_080CBEDC[])(Entity*); extern void (*const gUnk_080CBEF8[])(Entity*); @@ -39,14 +39,14 @@ extern const u16 gUnk_080CBF18[]; extern const u8 gUnk_080CBF20[]; void Pesto(Entity* this) { - gUnk_080CBEC4[GetNextFunction(this)](this); + Pesto_Functions[GetNextFunction(this)](this); } -void sub_08023F44(Entity* this) { +void Pesto_OnTick(Entity* this) { gUnk_080CBEDC[this->action](this); } -void sub_08023F5C(Entity* this) { +void Pesto_OnCollision(Entity* this) { if (this->hitType != 0x6e) { if (this->bitfield == 0x80) { this->field_0x86.HALF.LO = 0x30; @@ -69,15 +69,15 @@ void sub_08023F5C(Entity* this) { this->health = 0; } - sub_0804AA30(this, gUnk_080CBEC4); + EnemyFunctionHandlerAfterCollision(this, Pesto_Functions); } -void sub_08023FE0(Entity* this) { - sub_08001324(this); +void Pesto_OnKnockback(Entity* this) { + GenericKnockback(this); GetNextFrame(this); } -void sub_08023FF0(Entity* this) { +void Pesto_OnGrabbed(Entity* this) { if (this->subAction < 3 && !sub_0806F520(this)) { this->action = 1; this->subAction = 0; @@ -548,7 +548,7 @@ void sub_08024940(Entity* this) { } } - sub_080AEFB4(this); + ProcessMovement1(this); GetNextFrame(this); } @@ -845,13 +845,13 @@ void sub_08024F50(Entity* this) { } // clang-format off -void (*const gUnk_080CBEC4[])(Entity*) = { - sub_08023F44, - sub_08023F5C, - sub_08023FE0, - sub_0804A7D4, - sub_08001242, - sub_08023FF0, +void (*const Pesto_Functions[])(Entity*) = { + Pesto_OnTick, + Pesto_OnCollision, + Pesto_OnKnockback, + GenericDeath, + GenericConfused, + Pesto_OnGrabbed, }; void (*const gUnk_080CBEDC[])(Entity*) = { diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 3353422f..54e0f92d 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -26,7 +26,7 @@ bool32 sub_0802594C(Entity*, u32); bool32 sub_080257EC(Entity*, u32, u32); bool32 sub_08025AB8(u32, u32); -extern void (*const gUnk_080CBF9C[])(Entity*); +extern void (*const Puffstool_Functions[])(Entity*); extern void (*const gUnk_080CBFB4[])(Entity*); extern const u8 gUnk_080CBFE8[]; extern void (*const gUnk_080CBFEC[])(Entity*); @@ -41,15 +41,15 @@ extern const s8 gUnk_080CC0BA[]; extern const s8 gUnk_080CC0C2[]; void Puffstool(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CBF9C); + EnemyFunctionHandler(this, Puffstool_Functions); SetChildOffset(this, 0, 1, -0x10); } -void sub_08025008(Entity* this) { +void Puffstool_OnTick(Entity* this) { gUnk_080CBFB4[this->action](this); } -void sub_08025020(Entity* this) { +void Puffstool_OnCollide(Entity* this) { u8 tmp; switch (this->bitfield & 0x7f) { @@ -94,17 +94,17 @@ void sub_08025020(Entity* this) { break; } - sub_0804AA30(this, gUnk_080CBF9C); + EnemyFunctionHandlerAfterCollision(this, Puffstool_Functions); } -void sub_0802511C(Entity* this) { +void Puffstool_OnDeath(Entity* this) { if ((this->field_0x3a & 2) && this->actionDelay == 1 && this->field_0x82.HALF.LO) { sub_08025B18(this); } - sub_0804A7D4(this); + GenericDeath(this); } -void sub_0802514C(Entity* this) { +void Puffstool_OnGrabbed(Entity* this) { GravityUpdate(this, 0x2000); if (sub_0806F520(this)) { gUnk_080CBFEC[this->subAction](this); @@ -278,7 +278,7 @@ void sub_080254B4(Entity* this) { sub_080256B4(this); } else { this->action = 0xc; - sub_0804A9FC(this, 0x1c); + Create0x68FX(this, FX_STARS); } InitializeAnimation(this, 0); } @@ -582,7 +582,7 @@ void sub_08025C2C(Entity* this) { bool32 sub_08025C44(Entity* this) { if ((this->frame & 1) == 0) { - return ProcessMovement(this); + return ProcessMovement0(this); } else { return FALSE; } @@ -597,13 +597,13 @@ u32 sub_08025C60(Entity* this) { } // clang-format off -void (*const gUnk_080CBF9C[])(Entity*) = { - sub_08025008, - sub_08025020, - sub_08001324, - sub_0802511C, - sub_08001242, - sub_0802514C, +void (*const Puffstool_Functions[])(Entity*) = { + Puffstool_OnTick, + Puffstool_OnCollide, + GenericKnockback, + Puffstool_OnDeath, + GenericConfused, + Puffstool_OnGrabbed, }; void (*const gUnk_080CBFB4[])(Entity*) = { diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c index 8f86eebb..d8707764 100644 --- a/src/enemy/rockChuchu.c +++ b/src/enemy/rockChuchu.c @@ -10,18 +10,18 @@ extern void sub_0804A4E4(Entity*, Entity*); -extern void (*const gUnk_080CB948[])(Entity*); +extern void (*const RockChuchu_Functions[])(Entity*); extern void (*const gUnk_080CB960[])(Entity*); void RockChuchu(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CB948); + EnemyFunctionHandler(this, RockChuchu_Functions); } -void sub_0802223C(Entity* this) { +void RockChuchu_OnTick(Entity* this) { gUnk_080CB960[this->action](this); } -void sub_08022254(Entity* this) { +void RockChuchu_OnCollision(Entity* this) { Entity* ent; if (this->health) { @@ -65,10 +65,10 @@ void sub_08022254(Entity* this) { InitializeAnimation(this, 2); } - sub_0804AA30(this, gUnk_080CB948); + EnemyFunctionHandlerAfterCollision(this, RockChuchu_Functions); } -void nullsub_131(Entity* this) { +void RockChuchu_OnGrabbed(Entity* this) { } void sub_08022368(Entity* this) { @@ -87,7 +87,7 @@ void sub_08022390(Entity* this) { } if (this->field_0xf == 0) { - ProcessMovement(this); + ProcessMovement0(this); } else { this->field_0xf = this->field_0xf - 1; } @@ -115,13 +115,13 @@ void sub_080223E4(Entity* this) { } // clang-format off -void (*const gUnk_080CB948[])(Entity*) = { - sub_0802223C, - sub_08022254, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_131, +void (*const RockChuchu_Functions[])(Entity*) = { + RockChuchu_OnTick, + RockChuchu_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + RockChuchu_OnGrabbed, }; void (*const gUnk_080CB960[])(Entity*) = { diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index 71ebddee..d0d22bc9 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -8,7 +8,7 @@ #include "enemy.h" #include "functions.h" -extern void (*const gRollobiteFunctions[])(Entity*); +extern void (*const Rollobite_Functions[])(Entity*); extern void (*const gRollobiteActions[])(Entity*); extern void (*const gUnk_080CA6A4[])(Entity*); extern void (*const gUnk_080CA6BC[])(Entity*); @@ -21,11 +21,10 @@ void sub_08020A7C(Entity*); bool32 Rollobite_TryToHoleUp(Entity*); bool32 Rollobite_IsRolledUp(Entity*); -extern void sub_080AE7E8(Entity*, u32, u32, u32); extern void sub_08078930(Entity*); void Rollobite(Entity* this) { - EnemyFunctionHandler(this, gRollobiteFunctions); + EnemyFunctionHandler(this, Rollobite_Functions); } void Rollobite_OnTick(Entity* this) { @@ -33,7 +32,7 @@ void Rollobite_OnTick(Entity* this) { gRollobiteActions[this->action](this); } -void sub_08020668(Entity* this) { +void Rollobite_OnCollision(Entity* this) { if (this->hitType == 34 && this->health != 0xff) { this->action = 4; this->zVelocity = Q_16_16(2.0); @@ -56,19 +55,19 @@ void sub_08020668(Entity* this) { Rollobite_OnTick(this); } -void sub_080206E0(Entity* this) { +void Rollobite_OnKnockback(Entity* this) { if (Rollobite_TryToHoleUp(this)) { this->knockbackDuration = 0; } else if (Rollobite_IsRolledUp(this)) { this->knockbackDuration--; - sub_080AE58C(this, this->knockbackDirection, 10); - sub_080AE7E8(this, this->field_0x46, this->knockbackDirection, 10); + CalculateEntityTileCollisions(this, this->knockbackDirection, 10); + ProcessMovementInternal(this, this->knockbackSpeed, this->knockbackDirection, 10); } else { - sub_08001324(this); + GenericKnockback(this); } } -void sub_08020734(Entity* this) { +void Rollobite_OnGrabbed(Entity* this) { if (this->subAction < 3 && !sub_0806F520(this)) { this->action = 4; COLLISION_ON(this); @@ -124,7 +123,7 @@ void Rollobite_Walk(Entity* this) { GetNextFrame(this); if (this->frame & 0x1) { this->frame &= ~0x1; - if (!ProcessMovement(this)) + if (!ProcessMovement0(this)) this->actionDelay = 1; } @@ -192,7 +191,7 @@ void Rollobite_RolledUp(Entity* this) { EnqueueSFX(SFX_104); if ((this->direction & 0x80) == 0) - sub_080AEFE0(this); + ProcessMovement2(this); } } @@ -285,13 +284,13 @@ bool32 Rollobite_IsRolledUp(Entity* this) { } // clang-format off -void (*const gRollobiteFunctions[])(Entity*) = { +void (*const Rollobite_Functions[])(Entity*) = { Rollobite_OnTick, - sub_08020668, - sub_080206E0, - sub_0804A7D4, - sub_08001242, - sub_08020734, + Rollobite_OnCollision, + Rollobite_OnKnockback, + GenericDeath, + GenericConfused, + Rollobite_OnGrabbed, }; void (*const gRollobiteActions[])(Entity*) = { diff --git a/src/enemy/rope.c b/src/enemy/rope.c index 05e1c85e..a26c1088 100644 --- a/src/enemy/rope.c +++ b/src/enemy/rope.c @@ -8,7 +8,7 @@ #include "enemy.h" #include "functions.h" -extern void (*const gRope[6])(Entity*); +extern void (*const Rope_Functions[6])(Entity*); extern void (*const gUnk_080CE460[4])(Entity*); extern void (*const gUnk_080CE470[3])(Entity*); extern Entity* gUnk_020000B0; @@ -18,7 +18,7 @@ void sub_08031600(Entity*); u32 sub_0803163C(Entity*); void Rope(Entity* this) { - EnemyFunctionHandler(this, gRope); + EnemyFunctionHandler(this, Rope_Functions); SetChildOffset(this, 0, 1, -16); } @@ -26,19 +26,19 @@ void Rope_OnTick(Entity* this) { gUnk_080CE460[this->action](this); } -void sub_080313AC(Entity* this) { +void Rope_OnCollision(Entity* this) { if (this->action == 3) { this->field_0xf = 0x1e; this->field_0x78.HALF.LO = 0x3c; sub_08031600(this); } - if (this->field_0x43) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gRope); + EnemyFunctionHandlerAfterCollision(this, Rope_Functions); } -void sub_080313E8(Entity* this) { +void Rope_OnGrabbed(Entity* this) { if (sub_0806F520()) { gUnk_080CE470[this->subAction](this); } @@ -55,7 +55,7 @@ void sub_08031418(Entity* this) { void sub_08031420(Entity* this) { if (sub_0806F3E4(this)) { - sub_0804A7D4(this); + GenericDeath(this); } } @@ -180,5 +180,5 @@ u32 sub_0803163C(Entity* this) { h = this->field_0x7a.HWORD; } this->speed = h; - return ProcessMovement(this); + return ProcessMovement0(this); } diff --git a/src/enemy/ropeGolden.c b/src/enemy/ropeGolden.c index f31229aa..ca3a57c7 100644 --- a/src/enemy/ropeGolden.c +++ b/src/enemy/ropeGolden.c @@ -11,7 +11,7 @@ #include "enemy.h" extern void (*const gUnk_080012C8[])(Entity*); -extern void (*const gUnk_080CF4C8[6])(Entity*); +extern void (*const RopeGolden_Functions[6])(Entity*); extern void (*const gUnk_080CF4E0[4])(Entity*); extern s32 sub_080012DC(Entity*); @@ -26,7 +26,7 @@ void RopeGolden(Entity* this) { if (x != 0) { gUnk_080012C8[x](this); } else { - gUnk_080CF4C8[GetNextFunction(this)](this); + RopeGolden_Functions[GetNextFunction(this)](this); SetChildOffset(this, 0, 1, -0x10); } } @@ -35,14 +35,14 @@ void RopeGolden_OnTick(Entity* this) { gUnk_080CF4E0[this->action](this); } -void sub_08038210(Entity* this) { - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); +void RopeGolden_OnCollision(Entity* this) { + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CF4C8); + EnemyFunctionHandlerAfterCollision(this, RopeGolden_Functions); } -void sub_08038234(Entity* this) { +void RopeGolden_OnDeath(Entity* this) { if ((this->field_0x3a & 2) == 0) { SetGlobalFlag(this->type2); } @@ -69,7 +69,7 @@ void sub_0803827C(Entity* this) { } } UpdateAnimationVariableFrames(this, 0x2); - if (ProcessMovement(this) == 0) { + if (ProcessMovement0(this) == 0) { sub_080383AC(this); } else { if (!(--this->actionDelay)) { diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 40964971..2ae953e7 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -21,7 +21,7 @@ extern void sub_080297F0(Entity*); extern void sub_080296C8(Entity*); extern void sub_0802969C(Entity*); -extern void (*const gUnk_080CCC00[])(Entity*); +extern void (*const RupeeLike_Functions[])(Entity*); extern void (*const gUnk_080CCC18[])(Entity*); extern void (*const gUnk_080CCC3C[])(Entity*); @@ -41,7 +41,7 @@ void RupeeLike(Entity* this) { } sub_08001290(this, uVar1); } else { - gUnk_080CCC00[GetNextFunction(this)](this); + RupeeLike_Functions[GetNextFunction(this)](this); SetChildOffset(this, 0, 1, -0x10); } } else { @@ -49,11 +49,11 @@ void RupeeLike(Entity* this) { } } -void sub_08029300(Entity* this) { +void RupeeLike_OnTick(Entity* this) { gUnk_080CCC18[this->action](this); } -void sub_08029318(Entity* this) { +void RupeeLike_OnCollision(Entity* this) { if (this->hitType == 0x8e) { sub_08029770(this); } else { @@ -73,19 +73,19 @@ void sub_08029318(Entity* this) { this->field_0x80.HALF.LO = gPlayerEntity.spritePriority.b1; EnqueueSFX(SFX_104); } else { - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } } } - sub_0804AA30(this, gUnk_080CCC00); + EnemyFunctionHandlerAfterCollision(this, RupeeLike_Functions); } -void sub_080293B4(Entity* this) { +void RupeeLike_OnDeath(Entity* this) { CreateDeathFx(this, 0xff, gUnk_080CCC34[this->cutsceneBeh.HALF.LO * 3 + this->type]); } -void nullsub_141(Entity* this) { +void RupeeLike_OnGrabbed(Entity* this) { } void sub_080293DC(Entity* this) { @@ -145,7 +145,7 @@ void sub_080294D4(Entity* this) { sub_08004596(this, GetFacingDirection(this, &gPlayerEntity)); sub_0802969C(this); } - ProcessMovement(this); + ProcessMovement0(this); sub_080296C8(this); } else { this->action = 6; @@ -293,13 +293,13 @@ void sub_080297F0(Entity* this) { } // clang-format off -void (*const gUnk_080CCC00[])(Entity*) = { - sub_08029300, - sub_08029318, - sub_08001324, - sub_080293B4, - sub_08001242, - nullsub_141, +void (*const RupeeLike_Functions[])(Entity*) = { + RupeeLike_OnTick, + RupeeLike_OnCollision, + GenericKnockback, + RupeeLike_OnDeath, + GenericConfused, + RupeeLike_OnGrabbed, }; void (*const gUnk_080CCC18[])(Entity*) = { diff --git a/src/enemy/scissorsBeetle.c b/src/enemy/scissorsBeetle.c index e2de30fe..41f84df0 100644 --- a/src/enemy/scissorsBeetle.c +++ b/src/enemy/scissorsBeetle.c @@ -28,24 +28,24 @@ void ScissorsBeetle(Entity* this) { SetChildOffset(this, 0, 1, -0x10); } -void sub_080388D4(ScissorsBeetleEntity* this) { +void ScissorsBeetle_OnTick(ScissorsBeetleEntity* this) { ScissorsBeetle_Actions[super->action](this); } -void sub_080388EC(ScissorsBeetleEntity* this) { +void ScissorsBeetle_OnCollision(ScissorsBeetleEntity* this) { Entity* child; - if (super->field_0x43) { - sub_0804A9FC(super, 0x1c); + if (super->confusedTime) { + Create0x68FX(super, FX_STARS); } - sub_0804AA30(super, ScissorsBeetle_Functions); + EnemyFunctionHandlerAfterCollision(super, ScissorsBeetle_Functions); if ((super->bitfield & 0x80) && super->action != 4) { u32 knockbackDir; child = super->child; child->iframes = super->iframes; knockbackDir = super->knockbackDirection; child->knockbackDirection = knockbackDir; - if (super->field_0x43) { + if (super->confusedTime) { COLLISION_OFF(child); } else if (super->action == 1) { child->direction = Direction8Round(knockbackDir + 0x12); @@ -58,7 +58,7 @@ void sub_080388EC(ScissorsBeetleEntity* this) { } } -void nullsub_164(ScissorsBeetleEntity* this) { +void ScissorsBeetle_OnGrabbed(ScissorsBeetleEntity* this) { } void ScissorsBeetle_Init(ScissorsBeetleEntity* this) { @@ -155,7 +155,7 @@ void sub_08038B08(ScissorsBeetleEntity* this) { } void sub_08038B64(ScissorsBeetleEntity* this) { - ProcessMovement(super); + ProcessMovement0(super); UpdateAnimationSingleFrame(super); if (--super->field_0xf == 0) { super->field_0xf = 2; @@ -165,7 +165,7 @@ void sub_08038B64(ScissorsBeetleEntity* this) { void sub_08038B90(ScissorsBeetleEntity* this) { UpdateAnimationSingleFrame(super); - ProcessMovement(super); + ProcessMovement0(super); sub_0800445C(super); } @@ -231,8 +231,12 @@ void sub_08038C84(ScissorsBeetleEntity* this, u32 arg2) { } void (*const ScissorsBeetle_Functions[])(Entity*) = { - (EntityActionPtr)sub_080388D4, (EntityActionPtr)sub_080388EC, sub_08001324, sub_0804A7D4, sub_08001242, - (EntityActionPtr)nullsub_164, + (EntityActionPtr)ScissorsBeetle_OnTick, + (EntityActionPtr)ScissorsBeetle_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + (EntityActionPtr)ScissorsBeetle_OnGrabbed, }; void (*const ScissorsBeetle_Actions[])(ScissorsBeetleEntity*) = { diff --git a/src/enemy/sensorBladeTrap.c b/src/enemy/sensorBladeTrap.c index 2c8c4ecf..7ca53a62 100644 --- a/src/enemy/sensorBladeTrap.c +++ b/src/enemy/sensorBladeTrap.c @@ -9,10 +9,9 @@ #include "functions.h" extern u32 sub_0804A024(Entity*, u32, u32); -extern bool32 sub_080AF038(Entity*); -extern Entity gUnk_02027EB4; -extern Entity gUnk_0200D654; +extern u8 gUnk_02027EB4[]; +extern u8 gUnk_0200D654[]; void sub_0802BB10(Entity*); bool32 sub_0802BB2C(Entity*, u32); @@ -61,7 +60,7 @@ void sub_0802BA18(Entity* this) { } void sub_0802BA8C(Entity* this) { - if (!sub_080AF038(this)) { + if (!ProcessMovement12(this)) { sub_0802BB10(this); } else { switch (this->direction >> 3) { @@ -86,7 +85,7 @@ void sub_0802BA8C(Entity* this) { } void sub_0802BAFC(Entity* this) { - if (!sub_080AF038(this)) { + if (!ProcessMovement12(this)) { this->action = 1; } } @@ -99,9 +98,9 @@ void sub_0802BB10(Entity* this) { } bool32 sub_0802BB2C(Entity* this, u32 param_2) { - Entity* ent = this->collisionLayer == 2 ? &gUnk_0200D654 : &gUnk_02027EB4; + u8* layer = this->collisionLayer == 2 ? gUnk_0200D654 : gUnk_02027EB4; const s8* ptr = &gUnk_080CD3DC[param_2 >> 2]; - return sub_080AE4CC(ent, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1], 0); + return IsTileCollision(layer, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1], 0); } // clang-format off diff --git a/src/enemy/slime.c b/src/enemy/slime.c index 0ef493dd..7857c3d6 100644 --- a/src/enemy/slime.c +++ b/src/enemy/slime.c @@ -18,32 +18,32 @@ void sub_08045178(Entity*, Entity*, int, int); extern void sub_0804A4E4(Entity*, Entity*); extern void (*const gUnk_080D16BC[])(Entity*); -extern void (*const gUnk_080D16A4[])(Entity*); +extern void (*const Slime_Functions[])(Entity*); extern u8 gUnk_080D16D0[4]; // Entity count per form extern PosOffset gUnk_080D16D4[4]; void Slime(Entity* this) { - EnemyFunctionHandler(this, gUnk_080D16A4); + EnemyFunctionHandler(this, Slime_Functions); SetChildOffset(this, 0, 1, -12); } -void sub_08044F70(Entity* this) { +void Slime_OnTick(Entity* this) { gUnk_080D16BC[this->action](this); } -void sub_08044F88(Entity* this) { +void Slime_OnCollision(Entity* this) { if ((this->health != 0) && (this->cutsceneBeh.HALF.LO != this->health)) { this->action = 4; } else { - sub_0804AA30(this, gUnk_080D16A4); + EnemyFunctionHandlerAfterCollision(this, Slime_Functions); } - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 28); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } } -void nullsub_171(Entity* this) { +void Slime_OnGrabbed(Entity* this) { } void sub_08044FC8(Entity* this) { @@ -78,7 +78,7 @@ void sub_08045018(Entity* this) { } void sub_08045088(Entity* this) { - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); if (--this->actionDelay == 0) { this->action = 1; diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c index 7d6b68e9..e6b5eb87 100644 --- a/src/enemy/sluggula.c +++ b/src/enemy/sluggula.c @@ -18,7 +18,7 @@ void sub_0804A4E4(Entity*, Entity*); extern void (*const gUnk_080012C8[])(Entity*); -extern void (*const gUnk_080CBDBC[])(Entity*); +extern void (*const Sluggula_Functions[])(Entity*); extern void (*const gUnk_080CBDD4[])(Entity*); extern void (*const gUnk_080CBDEC[])(Entity*); @@ -28,7 +28,7 @@ extern const s8 gUnk_080CBDFF[]; void Sluggula(Entity* this) { if (this->type == 1) { - EnemyFunctionHandler(this, gUnk_080CBDBC); + EnemyFunctionHandler(this, Sluggula_Functions); SetChildOffset(this, 0, 1, -0x10); } else if (this->type == 0) { @@ -47,22 +47,22 @@ void Sluggula(Entity* this) { } } -void sub_08023C08(Entity* this) { +void Sluggula_OnTick(Entity* this) { gUnk_080CBDEC[this->action](this); } -void sub_08023C20(Entity* this) { - if (this->field_0x43) - sub_0804A9FC(this, 0x1c); +void Sluggula_OnCollision(Entity* this) { + if (this->confusedTime) + Create0x68FX(this, FX_STARS); if (this->type == 1) { - sub_0804AA30(this, gUnk_080CBDBC); + EnemyFunctionHandlerAfterCollision(this, Sluggula_Functions); } else { - sub_0804AA30(this, gUnk_080CBDD4); + EnemyFunctionHandlerAfterCollision(this, gUnk_080CBDD4); } } -void nullsub_137(Entity* this) { +void Sluggula_OnGrabbed(Entity* this) { /* ... */ } @@ -76,7 +76,7 @@ void sub_08023C5C(Entity* this) { } void sub_08023C8C(Entity* this) { - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); sub_08023E54(this); if (--this->actionDelay == 0) { @@ -195,22 +195,22 @@ void sub_08023E9C(Entity* this) { } // clang-format off -void (*const gUnk_080CBDBC[])(Entity*) = { - sub_08023C08, - sub_08023C20, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_137, +void (*const Sluggula_Functions[])(Entity*) = { + Sluggula_OnTick, + Sluggula_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + Sluggula_OnGrabbed, }; void (*const gUnk_080CBDD4[])(Entity*) = { sub_08023CE0, - sub_08023C20, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_137, + Sluggula_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + Sluggula_OnGrabbed, }; void (*const gUnk_080CBDEC[])(Entity*) = { diff --git a/src/enemy/smallPesto.c b/src/enemy/smallPesto.c index 6d444f71..69f1e461 100644 --- a/src/enemy/smallPesto.c +++ b/src/enemy/smallPesto.c @@ -10,7 +10,7 @@ extern void sub_080317F8(Entity*); -extern void (*gUnk_080CE530[])(Entity*); +extern void (*SmallPesto_Functions[])(Entity*); extern void (*gUnk_080CE548[])(Entity*); extern void (*gUnk_080CE554[])(Entity*); @@ -21,17 +21,17 @@ void sub_08031840(Entity*); extern Hitbox gUnk_080CE560; void SmallPesto(Entity* this) { - gUnk_080CE530[GetNextFunction(this)](this); + SmallPesto_Functions[GetNextFunction(this)](this); } -void sub_08031680(Entity* this) { +void SmallPesto_OnTick(Entity* this) { gUnk_080CE548[this->action](this); } -void nullsub_152(Entity* this) { +void SmallPesto_OnCollision(Entity* this) { } -void sub_0803169C(Entity* this) { +void SmallPesto_OnGrabbed(Entity* this) { s32 iVar1; GetNextFrame(this); @@ -58,7 +58,7 @@ void sub_080316E8(Entity* this) { void sub_080316F0(Entity* this) { if (sub_0806F3E4(this)) { - sub_0804A7D4(this); + GenericDeath(this); } } diff --git a/src/enemy/spark.c b/src/enemy/spark.c index 30940109..f6f9325d 100644 --- a/src/enemy/spark.c +++ b/src/enemy/spark.c @@ -9,18 +9,18 @@ #include "object.h" #include "functions.h" -extern void (*const gUnk_080CD234[])(Entity*); +extern void (*const Spark_Functions[])(Entity*); extern void (*const gUnk_080CD24C[])(Entity*); void Spark(Entity* this) { - gUnk_080CD234[GetNextFunction(this)](this); + Spark_Functions[GetNextFunction(this)](this); } -void sub_0802B2C8(Entity* this) { +void Spark_OnTick(Entity* this) { gUnk_080CD24C[this->action](this); } -void sub_0802B2E0(Entity* this) { +void Spark_OnCollision(Entity* this) { Entity* ent; if (this->bitfield & 0x80) { @@ -39,7 +39,7 @@ void sub_0802B2E0(Entity* this) { } } -void nullsub_15(Entity* this) { +void Spark_OnGrabbed(Entity* this) { /* ... */ } @@ -55,7 +55,7 @@ void sub_0802B35C(Entity* this) { bool32 is_head; GetNextFrame(this); - ProcessMovement(this); + ProcessMovement0(this); is_head = this->type == 0; if (this->collisions == 0) { if (--this->field_0xf == 0) { @@ -130,13 +130,13 @@ void sub_0802B4A8(Entity* this) { } // clang-format off -void (*const gUnk_080CD234[])(Entity*) = { - sub_0802B2C8, - sub_0802B2E0, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_15, +void (*const Spark_Functions[])(Entity*) = { + Spark_OnTick, + Spark_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + Spark_OnGrabbed, }; void (*const gUnk_080CD24C[])(Entity*) = { diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index 8902e7fc..a402319a 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -20,7 +20,7 @@ void sub_080288C0(Entity*); bool32 sub_08028828(u32, u32); void sub_080287B4(Entity*); -extern void (*const gUnk_080CC790[])(Entity*); +extern void (*const SpearMoblin_Functions[])(Entity*); extern void (*const gUnk_080CC7A8[])(Entity*); extern const u8 gUnk_080CC7BC[]; extern const s8 gUnk_080CC7C0[]; @@ -30,22 +30,22 @@ extern const u16 gUnk_080CC7D8[]; extern const Hitbox* const gUnk_080CC944[]; void SpearMoblin(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CC790); + EnemyFunctionHandler(this, SpearMoblin_Functions); SetChildOffset(this, 0, 1, -0x20); if (this->child && this->child->next) { CopyPosition(this, this->child); } } -void sub_0802826C(Entity* this) { +void SpearMoblin_OnTick(Entity* this) { gUnk_080CC7A8[this->action](this); } -void sub_08028284(Entity* this) { - if (this->field_0x43 != 0) - sub_0804A9FC(this, 0x1c); +void SpearMoblin_OnCollision(Entity* this) { + if (this->confusedTime != 0) + Create0x68FX(this, FX_STARS); - sub_0804AA30(this, gUnk_080CC790); + EnemyFunctionHandlerAfterCollision(this, SpearMoblin_Functions); if (this->bitfield & 0x80) { if (this->action != 4) { sub_08028754(this); @@ -68,7 +68,7 @@ void sub_08028284(Entity* this) { } } -void nullsub_13(Entity* this) { +void SpearMoblin_OnGrabbed(Entity* this) { /* ... */ } @@ -235,7 +235,7 @@ void sub_08028528(Entity* this) { } if (0x20 < this->field_0x7a.HALF.HI) { - ProcessMovement(this); + ProcessMovement0(this); } GetNextFrame(this); @@ -370,7 +370,7 @@ void sub_08028858(Entity* this) { this->speed = 0; } - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); } @@ -383,20 +383,20 @@ void sub_080288C0(Entity* this) { if (ent && (ent->bitfield & 0x80)) { this->knockbackDirection = ent->knockbackDirection; this->iframes = -ent->iframes; - this->field_0x46 = ent->field_0x46; + this->knockbackSpeed = ent->knockbackSpeed; this->knockbackDuration = ent->knockbackDuration; ent->knockbackDuration = 0; } } // clang-format off -void (*const gUnk_080CC790[])(Entity*) = { - sub_0802826C, - sub_08028284, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_13, +void (*const SpearMoblin_Functions[])(Entity*) = { + SpearMoblin_OnTick, + SpearMoblin_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + SpearMoblin_OnGrabbed, }; void (*const gUnk_080CC7A8[])(Entity*) = { diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index fa3d70b4..e0dedef5 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -16,21 +16,21 @@ void sub_0802B9B4(Entity*); void sub_0802B7A4(Entity*); void sub_0802B960(Entity*); -extern void (*const gUnk_080CD2D8[])(Entity*); +extern void (*const SpikedBeetle_Functions[])(Entity*); extern void (*const gUnk_080CD2F0[])(Entity*); extern const u8 gUnk_080CD314[]; extern const s8 gUnk_080CD318[]; void SpikedBeetle(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CD2D8); + EnemyFunctionHandler(this, SpikedBeetle_Functions); SetChildOffset(this, 0, 1, -0x10); } -void sub_0802B610(Entity* this) { +void SpikedBeetle_OnTick(Entity* this) { gUnk_080CD2F0[this->action](this); } -void sub_0802B628(Entity* this) { +void SpikedBeetle_OnCollision(Entity* this) { switch (this->bitfield & 0x7f) { case 0: case 4: @@ -63,13 +63,13 @@ void sub_0802B628(Entity* this) { InitializeAnimation(this, 9); } } - if (this->field_0x43) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CD2D8); + EnemyFunctionHandlerAfterCollision(this, SpikedBeetle_Functions); } -void nullsub_144(Entity* this) { +void SpikedBeetle_OnGrabbed(Entity* this) { /* ... */ } @@ -94,7 +94,7 @@ void sub_0802B744(Entity* this) { this->action = 2; this->actionDelay = 0x1e; } else { - if (!ProcessMovement(this)) { + if (!ProcessMovement0(this)) { this->actionDelay = 1; } } @@ -127,7 +127,7 @@ void sub_0802B7FC(Entity* this) { } void sub_0802B820(Entity* this) { - if (!sub_080AEFE0(this)) { + if (!ProcessMovement2(this)) { this->actionDelay = 1; } GetNextFrame(this); @@ -152,7 +152,7 @@ void sub_0802B880(Entity* this) { } void sub_0802B8B0(Entity* this) { - sub_080AEFE0(this); + ProcessMovement2(this); switch (sub_080044EC(this, 0x1800)) { case 0: this->action = 7; @@ -210,13 +210,13 @@ void sub_0802B9B4(Entity* this) { } // clang-format off -void (*const gUnk_080CD2D8[])(Entity*) = { - sub_0802B610, - sub_0802B628, - sub_08001324, - sub_0804A7D4, - sub_08001242, - nullsub_144, +void (*const SpikedBeetle_Functions[])(Entity*) = { + SpikedBeetle_OnTick, + SpikedBeetle_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + SpikedBeetle_OnGrabbed, }; void (*const gUnk_080CD2F0[])(Entity*) = { diff --git a/src/enemy/spinyBeetle.c b/src/enemy/spinyBeetle.c index 81a45577..1049ffa4 100644 --- a/src/enemy/spinyBeetle.c +++ b/src/enemy/spinyBeetle.c @@ -18,7 +18,7 @@ typedef struct { u16 unk_84; } SpinyBeetleEntity; -void (*const gUnk_080CEBEC[])(Entity*); +void (*const SpinyBeetle_Functions[])(Entity*); void (*const gUnk_080CEC04[])(SpinyBeetleEntity*); const s8 gUnk_080CEC1C[]; @@ -26,25 +26,25 @@ extern void sub_08033E1C(SpinyBeetleEntity*); extern void sub_08033D78(SpinyBeetleEntity*); extern u32 sub_08033DF0(SpinyBeetleEntity*); extern void SpinyBeetle_SetHitType(SpinyBeetleEntity*); -extern void sub_0804AA30(Entity*, EntityActionArray); +extern void EnemyFunctionHandlerAfterCollision(Entity*, EntityActionArray); extern void sub_0807B9B8(s32, s32, s32); extern u32 sub_0804A024(Entity*, u32, u32); void SpinyBeetle(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CEBEC); + EnemyFunctionHandler(this, SpinyBeetle_Functions); SetChildOffset(this, 0, 1, -0x10); } -void sub_080337BC(SpinyBeetleEntity* this) { +void SpinyBeetle_OnTick(SpinyBeetleEntity* this) { gUnk_080CEC04[super->action](this); } -void sub_080337D4(SpinyBeetleEntity* this) { - if (super->field_0x43) { - sub_0804A9FC(super, 0x1c); +void SpinyBeetle_OnCollision(SpinyBeetleEntity* this) { + if (super->confusedTime) { + Create0x68FX(super, FX_STARS); } - sub_0804AA30(super, gUnk_080CEBEC); + EnemyFunctionHandlerAfterCollision(super, SpinyBeetle_Functions); if (super->bitfield & 0x80) { if (super->iframes > 0 && super->child) { sub_08033E1C(this); @@ -62,11 +62,11 @@ void sub_080337D4(SpinyBeetleEntity* this) { } } -void nullsub_159(SpinyBeetleEntity* this) { +void SpinyBeetle_OnGrabbed(SpinyBeetleEntity* this) { } -void sub_08033870(SpinyBeetleEntity* this) { - sub_08001242(super); +void SpinyBeetle_OnConfused(SpinyBeetleEntity* this) { + GenericConfused(super); if (super->action != 5) { if (sub_08033DF0(this)) { @@ -325,7 +325,7 @@ void sub_08033D78(SpinyBeetleEntity* this) { break; default: if (sub_080002E0(tile, super->collisionLayer) - 1 > 0x3e) - ProcessMovement(super); + ProcessMovement0(super); break; } } @@ -382,9 +382,9 @@ const u16 unusedLabel_0CEBDC[] = { 0x3F, 0x1C, 0x50, 0x2A, 0x55, 0x1D, 0x5C, 0x2B, }; -void (*const gUnk_080CEBEC[])(Entity*) = { - (EntityActionPtr)sub_080337BC, (EntityActionPtr)sub_080337D4, sub_08001324, sub_0804A7D4, - (EntityActionPtr)sub_08033870, (EntityActionPtr)nullsub_159, +void (*const SpinyBeetle_Functions[])(Entity*) = { + (EntityActionPtr)SpinyBeetle_OnTick, (EntityActionPtr)SpinyBeetle_OnCollision, GenericKnockback, GenericDeath, + (EntityActionPtr)SpinyBeetle_OnConfused, (EntityActionPtr)SpinyBeetle_OnGrabbed, }; void (*const gUnk_080CEC04[])(SpinyBeetleEntity*) = { diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index 68df4b69..5fad3258 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -16,7 +16,7 @@ extern void sub_0804AA1C(Entity*); u32 sub_080228CC(Entity*); u32 sub_080228F0(Entity*); -extern void (*const gUnk_080CBA28[])(Entity*); +extern void (*const SpinyChuchu_Functions[])(Entity*); extern void (*const gUnk_080CBA40[])(Entity*); extern const u8 gUnk_080CBA60[]; @@ -27,15 +27,15 @@ extern Hitbox gHitbox_32; extern Entity* gUnk_020000B0; void SpinyChuchu(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CBA28); + EnemyFunctionHandler(this, SpinyChuchu_Functions); SetChildOffset(this, 0, 1, -0x10); } -void sub_08022434(Entity* this) { +void SpinyChuchu_OnTick(Entity* this) { gUnk_080CBA40[this->action](this); } -void sub_0802244C(Entity* this) { +void SpinyChuchu_OnCollision(Entity* this) { if (this->health) { if (this->hitType == 0x65) { switch (this->bitfield & 0x7f) { @@ -56,13 +56,13 @@ void sub_0802244C(Entity* this) { case 0x18: case 0x19: case 0x1a: - sub_0804A9FC(this, 0x1c); + Create0x68FX(this, FX_STARS); this->action = 5; this->hitType = 0x5c; InitializeAnimation(this, 1); } } else if (this->bitfield == 0x94) { - sub_0804A9FC(this, 0x1c); + Create0x68FX(this, FX_STARS); this->action = 5; InitializeAnimation(this, 1); } @@ -83,25 +83,25 @@ void sub_0802244C(Entity* this) { } this->field_0x80.HALF.LO = this->health; - sub_0804AA30(this, gUnk_080CBA28); + EnemyFunctionHandlerAfterCollision(this, SpinyChuchu_Functions); } -void sub_080225A0(Entity* this) { +void SpinyChuchu_OnKnockback(Entity* this) { if (this->animIndex == 1) GetNextFrame(this); sub_08001318(this); } -void sub_080225BC(Entity* this) { +void SpinyChuchu_OnDeath(Entity* this) { GravityUpdate(this, Q_8_8(24.0)); if (this->frame & 1) { - sub_0804A7D4(this); + GenericDeath(this); } else { GetNextFrame(this); } } -void nullsub_9(Entity* this) { +void SpinyChuchu_OnGrabbed(Entity* this) { } void sub_080225EC(Entity* this) { @@ -175,7 +175,7 @@ void sub_080226EC(Entity* this) { this->direction = sub_08049F84(this, 1); } - ProcessMovement(this); + ProcessMovement0(this); } GetNextFrame(this); @@ -224,7 +224,7 @@ void sub_0802281C(Entity* this) { void sub_08022854(Entity* this) { GetNextFrame(this); if (this->frame & 1) { - sub_080AEFE0(this); + ProcessMovement2(this); if (GravityUpdate(this, Q_8_8(24.0)) == 0) { this->action = 7; this->hitType = 0x5c; @@ -265,13 +265,13 @@ u32 sub_080228F0(Entity* this) { } // clang-format off -void (*const gUnk_080CBA28[])(Entity*) = { - sub_08022434, - sub_0802244C, - sub_080225A0, - sub_080225BC, - sub_08001242, - nullsub_9, +void (*const SpinyChuchu_Functions[])(Entity*) = { + SpinyChuchu_OnTick, + SpinyChuchu_OnCollision, + SpinyChuchu_OnKnockback, + SpinyChuchu_OnDeath, + GenericConfused, + SpinyChuchu_OnGrabbed, }; void (*const gUnk_080CBA40[])(Entity*) = { diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index 2fea7018..2751cd5b 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -107,10 +107,10 @@ NONMATCH("asm/non_matching/stalfos/sub_0803933C.inc", void sub_0803933C(StalfosE } super->flags2 &= 0xfb; } - if (super->field_0x43 != 0) { - sub_0804A9FC(super, 0x1c); + if (super->confusedTime != 0) { + Create0x68FX(super, 0x1c); } - sub_0804AA30(super, Stalfos_Functions); + EnemyFunctionHandlerAfterCollision(super, Stalfos_Functions); } END_NONMATCH @@ -118,7 +118,7 @@ void sub_08039418(StalfosEntity* this) { if (super->type == 0) { CreateDeathFx(super, 0xf3, 0); } else { - sub_0804A7D4(super); + GenericDeath(super); } } @@ -188,7 +188,7 @@ void Stalfos_Action2(StalfosEntity* this) { void Stalfos_Action3(StalfosEntity* this) { if (sub_08039758(this) == 0) { - if (ProcessMovement(super)) { + if (ProcessMovement0(super)) { UpdateAnimationSingleFrame(super); if (--this->unk_78 == 0) { sub_0803998C(this); @@ -201,7 +201,7 @@ void Stalfos_Action3(StalfosEntity* this) { } void Stalfos_Action4(StalfosEntity* this) { - sub_080AEFE0(super); + ProcessMovement2(super); if (GravityUpdate(super, 0x1800) == 0) { sub_0803998C(this); this->unk_7c = 0x5a; @@ -210,7 +210,7 @@ void Stalfos_Action4(StalfosEntity* this) { } void Stalfos_Action5(StalfosEntity* this) { - sub_080AEFE0(super); + ProcessMovement2(super); GravityUpdate(super, 0x1800); if (super->zVelocity < 0) { super->action = 6; @@ -260,7 +260,7 @@ void Stalfos_Action9(StalfosEntity* this) { } void Stalfos_Action11(StalfosEntity* this) { - sub_080AEFE0(super); + ProcessMovement2(super); UpdateAnimationSingleFrame(super); if (--this->unk_78 == 0) { sub_08039AD4(this); @@ -365,7 +365,7 @@ void sub_0803992C(StalfosEntity* this) { super->speed = 0xe0; super->direction = super->animationState << 3; this->unk_78 = (u16)gUnk_080CF900[Random() & 0xf]; - sub_080AE58C(super, super->direction, 0); + CalculateEntityTileCollisions(super, super->direction, 0); if ((gUnk_080CF910[super->animationState] & super->collisions) != 0) { InitAnimationForceUpdate(super, super->animationState); } else { @@ -451,9 +451,9 @@ ASM_FUNC("asm/non_matching/stalfos/sub_08039B28.inc", u32 sub_08039B28(StalfosEn void (*const Stalfos_Functions[])(StalfosEntity*) = { Stalfos_OnTick, sub_0803933C, - (void (*)(StalfosEntity*))sub_08001324, + (void (*)(StalfosEntity*))GenericKnockback, sub_08039418, - (void (*)(StalfosEntity*))sub_08001242, + (void (*)(StalfosEntity*))GenericConfused, sub_08039438, }; void (*const Stalfos_Actions[])(StalfosEntity*) = { diff --git a/src/enemy/takkuri.c b/src/enemy/takkuri.c index a9a29a9b..dc28b862 100644 --- a/src/enemy/takkuri.c +++ b/src/enemy/takkuri.c @@ -22,7 +22,7 @@ static_assert(sizeof(TakkuriEntity) == 0x88); extern Entity* gUnk_020000B0; -void (*const gUnk_080CFF3C[])(Entity*); +void (*const Takkuri_Functions[])(Entity*); void (*const gUnk_080CFF54[])(TakkuriEntity*); void (*const gUnk_080CFF6C[])(TakkuriEntity*); @@ -33,14 +33,14 @@ void sub_0803BF48(TakkuriEntity* this); void sub_0803C120(TakkuriEntity* this); void Takkuri(Entity* this) { - gUnk_080CFF3C[GetNextFunction(this)](this); + Takkuri_Functions[GetNextFunction(this)](this); } -void sub_0803BB98(TakkuriEntity* this) { +void Takkuri_OnTick(TakkuriEntity* this) { gUnk_080CFF54[super->action](this); } -void sub_0803BBB0(TakkuriEntity* this) { +void Takkuri_OnCollision(TakkuriEntity* this) { if (super->bitfield & 0x80) { if ((super->bitfield & 0x7f) == 0) { u32 direction; @@ -71,7 +71,7 @@ void sub_0803BBB0(TakkuriEntity* this) { GetNextFrame(super); } -void sub_0803BC34(TakkuriEntity* this) { +void Takkuri_OnGrabbed(TakkuriEntity* this) { gUnk_080CFF6C[super->subAction](this); GetNextFrame(super); if (sub_0806F520(super) == 0) { @@ -95,7 +95,7 @@ void sub_0803BC88(TakkuriEntity* this) { void sub_0803BC90(TakkuriEntity* this) { if (sub_0806F3E4(super)) { - sub_0804A7D4(super); + GenericDeath(super); } } @@ -346,9 +346,13 @@ void sub_0803C120(TakkuriEntity* this) { super->spritePriority.b1 = 3; } -void (*const gUnk_080CFF3C[])(Entity*) = { - (EntityActionPtr)sub_0803BB98, (EntityActionPtr)sub_0803BBB0, sub_08001324, sub_0804A7D4, sub_08001242, - (EntityActionPtr)sub_0803BC34, +void (*const Takkuri_Functions[])(Entity*) = { + (EntityActionPtr)Takkuri_OnTick, + (EntityActionPtr)Takkuri_OnCollision, + GenericKnockback, + GenericDeath, + GenericConfused, + (EntityActionPtr)Takkuri_OnGrabbed, }; void (*const gUnk_080CFF54[])(TakkuriEntity*) = { diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index 168f69b6..67fb91a6 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -10,28 +10,28 @@ static void sub_0802F45C(Entity* this); -extern void (*const gUnk_080CDED0[])(Entity*); +extern void (*const Tektite_Functions[])(Entity*); extern void (*const gUnk_080CDEE8[])(Entity*); void Tektite(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CDED0); + EnemyFunctionHandler(this, Tektite_Functions); SetChildOffset(this, 0, 1, -0x10); } -void sub_0802F138(Entity* this) { +void Tektite_OnTick(Entity* this) { gUnk_080CDEE8[this->action](this); } extern u8 gUnk_080CDEF8[]; -void sub_0802F150(Entity* this) { +void Tektite_OnCollision(Entity* this) { u32 bVar1; u32 uVar2; - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CDED0); + EnemyFunctionHandlerAfterCollision(this, Tektite_Functions); if ((this->bitfield & 0x80) != 0) { switch (this->bitfield & 0x3f) { case 0x14: @@ -59,11 +59,11 @@ void sub_0802F150(Entity* this) { } } -void nullsub_16(Entity* this) { +void Tektite_OnGrabbed(Entity* this) { } -void sub_0802F1F0(Entity* this) { - sub_08001242(this); +void Tektite_OnConfused(Entity* this) { + GenericConfused(this); if (this->z.HALF.HI != 0) { GravityUpdate(this, this->field_0x80.HWORD); } @@ -116,7 +116,7 @@ void sub_0802F300(Entity* this) { u32 rand; GetNextFrame(this); - ProcessMovement(this); + ProcessMovement0(this); temp = this->z.HALF.HI; rand = Random() & 0xf; diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index 3841377e..22d7c260 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -10,25 +10,25 @@ extern void sub_08038168(Entity*); -extern void (*const gUnk_080CF4A0)(Entity*); +extern void (*const TektiteGolden_Functions)(Entity*); extern void (*const gUnk_080CF4B8[])(Entity*); void TektiteGolden(Entity* this) { - EnemyFunctionHandler(this, &gUnk_080CF4A0); + EnemyFunctionHandler(this, &TektiteGolden_Functions); SetChildOffset(this, 0, 1, -0x10); } -void sub_08037EE8(Entity* this) { +void TektiteGolden_OnTick(Entity* this) { gUnk_080CF4B8[this->action](this); } -void sub_08037F00(Entity* this) { +void TektiteGolden_OnCollision(Entity* this) { u32 uVar1; - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, &gUnk_080CF4A0); + EnemyFunctionHandlerAfterCollision(this, &TektiteGolden_Functions); if (this->bitfield == 0x94) { this->action = 1; this->subAction = 0; @@ -45,7 +45,7 @@ void sub_08037F00(Entity* this) { } } -void sub_08037F58(Entity* this) { +void TektiteGolden_OnDeath(Entity* this) { u32 uVar1; if ((this->field_0x3a & 2) == 0) { @@ -59,8 +59,8 @@ void sub_08037F58(Entity* this) { CreateDeathFx(this, 0xff, uVar1); } -void sub_08037F84(Entity* this) { - sub_08001242(this); +void TektiteGolden_OnConfused(Entity* this) { + GenericConfused(this); if (this->z.HALF.HI != 0) { GravityUpdate(this, 0x3000); } @@ -104,7 +104,7 @@ void sub_08038048(Entity* this) { u32 rand; UpdateAnimationVariableFrames(this, 2); - ProcessMovement(this); + ProcessMovement0(this); temp = this->z.HALF.HI; rand = Random() & 0xf; diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index 4d43d69c..d58da091 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -30,8 +30,8 @@ typedef struct VaatiArm_HeapStruct { u32 sub_080437DC(Entity*); u32 sub_08043C98(Entity*); -void sub_08042570(Entity*); -void sub_08042588(Entity*); +void VaatiArm_OnTick(Entity*); +void VaatiArm_OnCollision(Entity*); void sub_080425B4(Entity*); void sub_08042818(Entity*); void sub_08042870(Entity*); @@ -40,7 +40,7 @@ void sub_08042C14(Entity*); void sub_0804325C(Entity*); void sub_08043420(Entity*); void sub_08043680(Entity*); -void nullsub_170(Entity*); +void VaatiArm_OnGrabbed(Entity*); void sub_08042654(Entity*); void sub_0804259C(Entity*); void sub_08043A10(Entity*); @@ -94,8 +94,8 @@ void sub_08043700(Entity*); void sub_08043738(Entity*); void sub_08043770(Entity*); -void (*const gUnk_080D1230[])(Entity*) = { - sub_08042570, sub_08042588, sub_08001324, sub_0804A7D4, sub_08001242, nullsub_170, +void (*const VaatiArm_Functions[])(Entity*) = { + VaatiArm_OnTick, VaatiArm_OnCollision, GenericKnockback, GenericDeath, GenericConfused, VaatiArm_OnGrabbed, }; void (*const gUnk_080D1248[])(Entity*) = { sub_0804259C, sub_08044078, sub_08044078, sub_08044078, sub_080440CC, @@ -174,18 +174,18 @@ extern const Hitbox gUnk_080FD450; extern const Hitbox gUnk_080FD538; void VaatiArm(Entity* this) { - gUnk_080D1230[GetNextFunction(this)](this); + VaatiArm_Functions[GetNextFunction(this)](this); } -void sub_08042570(Entity* this) { +void VaatiArm_OnTick(Entity* this) { gUnk_080D1248[this->type](this); } -void sub_08042588(Entity* this) { - sub_0804AA30(this, gUnk_080D1230); +void VaatiArm_OnCollision(Entity* this) { + EnemyFunctionHandlerAfterCollision(this, VaatiArm_Functions); } -void nullsub_170(Entity* this) { +void VaatiArm_OnGrabbed(Entity* this) { } void sub_0804259C(Entity* this) { @@ -698,7 +698,7 @@ void sub_08042EF4(Entity* this) { } entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[3]; entity->direction = this->direction; - ProcessMovement(entity); + ProcessMovement0(entity); } } diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c index e53d51f1..7d84c1a5 100644 --- a/src/enemy/vaatiEyesMacro.c +++ b/src/enemy/vaatiEyesMacro.c @@ -10,8 +10,8 @@ extern s16 gUnk_080B4488[]; -void VaatiEyesMacroFunction0(Entity*); -void VaatiEyesMacroFunction1(Entity*); +void VaatiEyesMacro_OnTick(Entity*); +void VaatiEyesMacro_OnCollision(Entity*); void VaatiEyesMacroFunction0Type0(Entity*); void VaatiEyesMacroFunction0Type1(Entity*); void VaatiEyesMacroFunction0Type2(Entity*); @@ -25,8 +25,9 @@ void sub_0802EFB8(Entity*); void sub_0802EF58(Entity*); void sub_0802F04C(Entity*); -void (*const vaatiEyesMacroFunctions[])(Entity*) = { - VaatiEyesMacroFunction0, VaatiEyesMacroFunction1, sub_08001324, sub_0804A7D4, sub_08001242, VaatiEyesMacroFunction0, +void (*const VaatiEyesMacro_Functions[])(Entity*) = { + VaatiEyesMacro_OnTick, VaatiEyesMacro_OnCollision, GenericKnockback, GenericDeath, + GenericConfused, VaatiEyesMacro_OnTick, }; void (*const vaatiEyesMacroFunction0Types[])(Entity*) = { VaatiEyesMacroFunction0Type0, @@ -50,18 +51,18 @@ const s8 gUnk_080CDE90[] = { -2, -3, -4, -5, -6, -5, -4, -3 }; const u16 gUnk_080CDE98[] = { 0xc0, 0x100, 0x140, 0x180 }; void VaatiEyesMacro(Entity* this) { - vaatiEyesMacroFunctions[GetNextFunction(this)](this); + VaatiEyesMacro_Functions[GetNextFunction(this)](this); SetChildOffset(this, 0, 1, -0x10); } -void VaatiEyesMacroFunction0(Entity* this) { +void VaatiEyesMacro_OnTick(Entity* this) { vaatiEyesMacroFunction0Types[this->type](this); if (this->type < 2) { sub_0802EF90(this); } } -void VaatiEyesMacroFunction1(Entity* this) { +void VaatiEyesMacro_OnCollision(Entity* this) { if (this->type == 0) { if (this->health == 0) { gRoomTransition.field_0x39 &= ~(1 << (gRoomTransition.field_0x3c + 2)); @@ -86,10 +87,10 @@ void VaatiEyesMacroFunction1(Entity* this) { this->health = 0xff; } } - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, vaatiEyesMacroFunctions); + EnemyFunctionHandlerAfterCollision(this, VaatiEyesMacro_Functions); } void VaatiEyesMacroFunction0Type0(Entity* this) { @@ -245,7 +246,7 @@ void sub_0802F04C(Entity* this) { oldX = this->x.HALF.HI; oldY = this->y.HALF.HI; - if (ProcessMovement(this) == 0) { + if (ProcessMovement0(this) == 0) { sub_0802EFB8(this); return; } diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index 440a4287..9cd3c973 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -12,11 +12,11 @@ extern Entity* gUnk_020000B0; extern const ScreenTransitionData gUnk_0813AB94; bool32 sub_0803E4A0(Entity*); -void VaatiProjectileFunction0(Entity*); -void VaatiProjectileFunction1(Entity*); -void sub_08001328(Entity*); -void VaatiProjectileFunction3(Entity*); -void VaatiProjectileNoop(Entity*); +void VaatiProjectile_OnTick(Entity*); +void VaatiProjectile_OnCollision(Entity*); +void GenericKnockback2(Entity*); +void VaatiProjectile_OnDeath(Entity*); +void VaatiProjectile_OnGrabbed(Entity*); void VaatiProjectileFunction0Action0(Entity*); void VaatiProjectileFunction0Action1(Entity*); void VaatiProjectileFunction0Action2(Entity*); @@ -31,9 +31,9 @@ void sub_0803E444(Entity*); void sub_0803E480(Entity*); void sub_0803E4D8(Entity*); -void (*const vaatiProjectileFunctions[])(Entity*) = { - VaatiProjectileFunction0, VaatiProjectileFunction1, sub_08001328, VaatiProjectileFunction3, sub_08001242, - VaatiProjectileNoop, +void (*const VaatiProjectile_Functions[])(Entity*) = { + VaatiProjectile_OnTick, VaatiProjectile_OnCollision, GenericKnockback2, VaatiProjectile_OnDeath, + GenericConfused, VaatiProjectile_OnGrabbed, }; void (*const vaatiProjectileFunction0Actions[])(Entity*) = { VaatiProjectileFunction0Action0, VaatiProjectileFunction0Action1, VaatiProjectileFunction0Action2, @@ -48,14 +48,14 @@ void VaatiProjectile(Entity* this) { this->health = 0; this->parent = NULL; } - vaatiProjectileFunctions[GetNextFunction(this)](this); + VaatiProjectile_Functions[GetNextFunction(this)](this); } -void VaatiProjectileFunction0(Entity* this) { +void VaatiProjectile_OnTick(Entity* this) { vaatiProjectileFunction0Actions[this->action](this); } -void VaatiProjectileFunction1(Entity* this) { +void VaatiProjectile_OnCollision(Entity* this) { Entity* entity; if (this->bitfield == 0x80) { @@ -82,18 +82,18 @@ void VaatiProjectileFunction1(Entity* this) { } #endif } - sub_0804AA30(this, vaatiProjectileFunctions); + EnemyFunctionHandlerAfterCollision(this, VaatiProjectile_Functions); } -void VaatiProjectileFunction3(Entity* this) { +void VaatiProjectile_OnDeath(Entity* this) { if (this->parent != NULL) { this->parent->field_0xf--; this->parent = NULL; } - sub_0804A7D4(this); + GenericDeath(this); } -void VaatiProjectileNoop(Entity* this) { +void VaatiProjectile_OnGrabbed(Entity* this) { } void VaatiProjectileFunction0Action0(Entity* this) { diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index d810aa25..a84dfcbc 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -9,8 +9,6 @@ #include "area.h" #include "functions.h" -extern void sub_080AEFB4(Entity*); - void VaatiRebornEnemyType0PreAction(Entity*); void VaatiRebornEnemyType1PreAction(Entity*); void VaatiRebornEnemyType0Action0(Entity*); @@ -218,7 +216,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) { this->y.HALF.HI--; } } - sub_080AEFB4(this); + ProcessMovement1(this); } } UpdateAnimationSingleFrame(this); @@ -416,7 +414,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) { } if (this->field_0x86.HALF.HI != 0) { - sub_080AEFB4(this); + ProcessMovement1(this); } UpdateAnimationSingleFrame(this); } diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index e3fb790c..6de1a8ae 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -15,7 +15,7 @@ void sub_08040AD4(Entity*); void sub_08040670(Entity*); void sub_080406A0(Entity*); void sub_08040770(Entity*); -void sub_080AF18C(Entity*); +extern void Knockback1(Entity*); u32 sub_08040934(Entity*); void sub_08040648(Entity*, u32, u32); @@ -249,7 +249,7 @@ void VaatiTransfiguredType0Action1(Entity* this) { } } if (this->field_0x80.HALF.LO != 0xff) { - ProcessMovement(this); + ProcessMovement0(this); } UpdateAnimationSingleFrame(this); } @@ -562,7 +562,7 @@ void VaatiTransfiguredType0Action7(Entity* this) { this->spriteSettings.draw = 0; } } else { - sub_0804A7D4(this); + GenericDeath(this); } UpdateAnimationSingleFrame(this); return; @@ -1071,7 +1071,7 @@ void sub_080409B0(Entity* this) { if (this->field_0x80.HALF.HI < 3) { if (this->knockbackDuration != 0) { - sub_080AF18C(this); + Knockback1(this); } } else { if (((this->bitfield & 0x80) != 0) && (0 < this->iframes)) { diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c index e02f2f1b..cd42c7a3 100644 --- a/src/enemy/vaatiTransfiguredEye.c +++ b/src/enemy/vaatiTransfiguredEye.c @@ -14,22 +14,22 @@ void sub_08045A00(Entity*); void sub_08045A28(Entity*); -void VaatiTransfiguredEyeFunction0(Entity*); -void VaatiTransfiguredEyeFunction1(Entity*); -void VaatiTransfiguredEyeNoop(Entity*); +void VaatiTransfiguredEye_OnTick(Entity*); +void VaatiTransfiguredEye_OnCollision(Entity*); +void VaatiTransfiguredEye_OnDragged(Entity*); void VaatiTransfiguredEyeFunction0Action0(Entity*); void VaatiTransfiguredEyeFunction0Action1(Entity*); void VaatiTransfiguredEyeFunction0Action2(Entity*); void VaatiTransfiguredEyeFunction0Action3(Entity*); void VaatiTransfiguredEyeFunction0Action4(Entity*); -void (*const vaatiTransfiguredEyeFunctions[])(Entity*) = { - VaatiTransfiguredEyeFunction0, - VaatiTransfiguredEyeFunction1, - VaatiTransfiguredEyeFunction0, - sub_0804A7D4, - sub_08001242, - VaatiTransfiguredEyeNoop, +void (*const VaatiTransfiguredEye_Functions[])(Entity*) = { + VaatiTransfiguredEye_OnTick, + VaatiTransfiguredEye_OnCollision, + VaatiTransfiguredEye_OnTick, + GenericDeath, + GenericConfused, + VaatiTransfiguredEye_OnDragged, }; void (*const vaatiTransfiguredEyeFunction0Actions[])(Entity*) = { @@ -46,14 +46,14 @@ const struct xy gUnk_080D18B4[] = { { 0xe8, 0xf6 }, { 0xf6, 0xe8 }, { 0x0a, 0xe8 { 0x18, 0x0a }, { 0x0a, 0x18 }, { 0xf6, 0x18 }, { 0xe8, 0x0a } }; void VaatiTransfiguredEye(Entity* this) { - EnemyFunctionHandler(this, vaatiTransfiguredEyeFunctions); + EnemyFunctionHandler(this, VaatiTransfiguredEye_Functions); } -void VaatiTransfiguredEyeFunction0(Entity* this) { +void VaatiTransfiguredEye_OnTick(Entity* this) { vaatiTransfiguredEyeFunction0Actions[this->action](this); } -void VaatiTransfiguredEyeFunction1(Entity* this) { +void VaatiTransfiguredEye_OnCollision(Entity* this) { u8 bVar1; Entity* pEVar4; @@ -89,10 +89,10 @@ void VaatiTransfiguredEyeFunction1(Entity* this) { } } } - sub_0804AA30(this, vaatiTransfiguredEyeFunctions); + EnemyFunctionHandlerAfterCollision(this, VaatiTransfiguredEye_Functions); } -void VaatiTransfiguredEyeNoop(Entity* this) { +void VaatiTransfiguredEye_OnDragged(Entity* this) { } void VaatiTransfiguredEyeFunction0Action0(Entity* this) { diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 5ad9dd16..38115022 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -248,7 +248,7 @@ void VaatiWrathType0Action3(Entity* this) { sub_08042004(this); UpdateAnimationSingleFrame(this); - ProcessMovement(this); + ProcessMovement0(this); roomY = gRoomControls.origin_y; bound = roomY + 0x90; diff --git a/src/enemy/wallMaster.c b/src/enemy/wallMaster.c index 9c91c691..7f08b67e 100644 --- a/src/enemy/wallMaster.c +++ b/src/enemy/wallMaster.c @@ -14,21 +14,21 @@ extern ScreenTransitionData* gUnk_0813AB1C[]; void sub_0802A78C(Entity*); void sub_0802A7D0(Entity*); -extern void (*const gUnk_080CD07C[])(Entity*); +extern void (*const WallMaster_Functions[])(Entity*); extern void (*const gUnk_080CD094[])(Entity*); extern const s8 gUnk_080CD0B0[]; void WallMaster(Entity* this) { - gUnk_080CD07C[GetNextFunction(this)](this); + WallMaster_Functions[GetNextFunction(this)](this); SetChildOffset(this, 0, 1, -0x10); } -void sub_0802A434(Entity* this) { +void WallMaster_OnTick(Entity* this) { sub_0802A78C(this); gUnk_080CD094[this->action](this); } -void sub_0802A454(Entity* this) { +void WallMaster_OnCollision(Entity* this) { if (this->hitType != 0x75 && ((this->bitfield & 0x7f) == 0 || (this->bitfield & 0x7f) == 0x1e)) { this->action = 5; COLLISION_OFF(this); @@ -44,14 +44,14 @@ void sub_0802A454(Entity* this) { if (this->knockbackDuration > 4) this->knockbackDuration -= 4; - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CD07C); + EnemyFunctionHandlerAfterCollision(this, WallMaster_Functions); } -void nullsub_142(Entity* this) { +void WallMaster_OnGrabbed(Entity* this) { /* ... */ } @@ -196,13 +196,13 @@ void sub_0802A7D0(Entity* this) { sub_0805EC9C(this, unk, unk, 0); } // clang-format off -void (*const gUnk_080CD07C[])(Entity*) = { - sub_0802A434, - sub_0802A454, - sub_08001328, - sub_0804A7D4, - sub_08001242, - nullsub_142, +void (*const WallMaster_Functions[])(Entity*) = { + WallMaster_OnTick, + WallMaster_OnCollision, + GenericKnockback2, + GenericDeath, + GenericConfused, + WallMaster_OnGrabbed, }; void (*const gUnk_080CD094[])(Entity*) = { diff --git a/src/enemy/wallMaster2.c b/src/enemy/wallMaster2.c index b2d5ba9f..3ee61f51 100644 --- a/src/enemy/wallMaster2.c +++ b/src/enemy/wallMaster2.c @@ -9,7 +9,7 @@ #include "area.h" #include "functions.h" -extern void sub_08001328(Entity*); +extern void GenericKnockback2(Entity*); extern Entity* gUnk_020000B0; extern ScreenTransitionData* gUnk_0813AB1C[]; @@ -18,22 +18,22 @@ void sub_0802CF64(Entity*); void sub_0802CF8C(Entity*); void sub_0802CFD8(Entity*); -extern void (*const gUnk_080CD6FC[])(Entity*); +extern void (*const WallMaster2_Functions[])(Entity*); extern void (*const gUnk_080CD714[])(Entity*); extern const u16 gUnk_080CD728[]; extern const u16 gUnk_080CD730[]; extern const s8 gUnk_080CD740[]; void WallMaster2(Entity* this) { - gUnk_080CD6FC[GetNextFunction(this)](this); + WallMaster2_Functions[GetNextFunction(this)](this); SetChildOffset(this, 0, 1, -0x10); } -void sub_0802CC68(Entity* this) { +void WallMaster2_OnTick(Entity* this) { gUnk_080CD714[this->action](this); } -void sub_0802CC80(Entity* this) { +void WallMaster2_OnCollision(Entity* this) { u8 bVar1 = this->bitfield & 0x7f; switch (this->bitfield & 0x7f) { case 0 ... 1: @@ -44,13 +44,13 @@ void sub_0802CC80(Entity* this) { gPlayerEntity.flags &= ~ENT_COLLIDE; break; } - if (this->field_0x43 != 0) { - sub_0804A9FC(this, 0x1c); + if (this->confusedTime != 0) { + Create0x68FX(this, FX_STARS); } - sub_0804AA30(this, gUnk_080CD6FC); + EnemyFunctionHandlerAfterCollision(this, WallMaster2_Functions); } -void nullsub_151(Entity* this) { +void WallMaster2_OnGrabbed(Entity* this) { /* ... */ } @@ -173,13 +173,13 @@ void sub_0802CFD8(Entity* this) { } // clang-format off -void (*const gUnk_080CD6FC[])(Entity*) = { - sub_0802CC68, - sub_0802CC80, - sub_08001328, - sub_0804A7D4, - sub_08001242, - nullsub_151, +void (*const WallMaster2_Functions[])(Entity*) = { + WallMaster2_OnTick, + WallMaster2_OnCollision, + GenericKnockback2, + GenericDeath, + GenericConfused, + WallMaster2_OnGrabbed, }; void (*const gUnk_080CD714[])(Entity*) = { diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c index 1d2f7a98..94943d52 100644 --- a/src/enemy/wisp.c +++ b/src/enemy/wisp.c @@ -12,21 +12,21 @@ static void sub_08033744(Entity* this); -extern void (*const gUnk_080CEB74[])(Entity*); +extern void (*const Wisp_Functions[])(Entity*); extern void (*const gUnk_080CEB8C[])(Entity*); extern void (*const gUnk_080CEB98[])(Entity*); extern u8 gUnk_080CEBA4[]; void Wisp(Entity* this) { - EnemyFunctionHandler(this, gUnk_080CEB74); + EnemyFunctionHandler(this, Wisp_Functions); } -void sub_0803354C(Entity* this) { +void Wisp_OnTick(Entity* this) { gUnk_080CEB8C[this->action](this); } -void sub_08033564(Entity* this) { +void Wisp_OnCollision(Entity* this) { u32 bits; Entity* ent; @@ -68,7 +68,7 @@ void sub_08033564(Entity* this) { } } -void sub_0803362C(Entity* this) { +void Wisp_OnGrabbed(Entity* this) { if (sub_0806F520() != 0) { gUnk_080CEB98[this->subAction](this); } @@ -84,7 +84,7 @@ void sub_08033658(Entity* this) { void sub_08033660(Entity* this) { if (sub_0806F3E4(this)) { - sub_0804A7D4(this); + GenericDeath(this); } } @@ -105,7 +105,7 @@ void sub_080336A8(Entity* this) { } else if (this->collisions != 0) { sub_0800417E(this, this->collisions); } - ProcessMovement(this); + ProcessMovement0(this); GetNextFrame(this); } diff --git a/src/enemy/wizzrobeFire.c b/src/enemy/wizzrobeFire.c index 0da0ca09..9cf0272d 100644 --- a/src/enemy/wizzrobeFire.c +++ b/src/enemy/wizzrobeFire.c @@ -23,11 +23,11 @@ void WizzrobeFire_OnTick(WizzrobeEntity* this) { WizzrobeFire_Actions[super->action](this); } -void sub_0802FB74(WizzrobeEntity* this) { - if (super->field_0x43 != 0) { - sub_0804A9FC(super, 0x1c); +void WizzrobeFire_OnCollision(WizzrobeEntity* this) { + if (super->confusedTime != 0) { + Create0x68FX(super, FX_STARS); } - sub_0804AA30(super, WizzrobeFire_Functions); + EnemyFunctionHandlerAfterCollision(super, WizzrobeFire_Functions); if (super->health == 0) { SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); } @@ -144,10 +144,10 @@ void WizzrobeFire_Action2(WizzrobeEntity* this) { void (*const WizzrobeFire_Functions[])(WizzrobeEntity*) = { WizzrobeFire_OnTick, - sub_0802FB74, - (void (*)(WizzrobeEntity*))sub_08001324, - (void (*)(WizzrobeEntity*))sub_0804A7D4, - (void (*)(WizzrobeEntity*))sub_08001242, + WizzrobeFire_OnCollision, + (void (*)(WizzrobeEntity*))GenericKnockback, + (void (*)(WizzrobeEntity*))GenericDeath, + (void (*)(WizzrobeEntity*))GenericConfused, WizzrobeFire_OnTick, }; void (*const WizzrobeFire_Actions[])(WizzrobeEntity*) = { diff --git a/src/enemy/wizzrobeIce.c b/src/enemy/wizzrobeIce.c index 9dbb5377..b053eb71 100644 --- a/src/enemy/wizzrobeIce.c +++ b/src/enemy/wizzrobeIce.c @@ -24,11 +24,11 @@ void WizzrobeIce_OnTick(WizzrobeEntity* this) { WizzrobeIce_Actions[super->action](this); } -void sub_0802FE18(WizzrobeEntity* this) { - if (super->field_0x43 != 0) { - sub_0804A9FC(super, 0x1c); +void WizzrobeIce_OnCollision(WizzrobeEntity* this) { + if (super->confusedTime != 0) { + Create0x68FX(super, FX_STARS); } - sub_0804AA30(super, WizzrobeIce_Functions); + EnemyFunctionHandlerAfterCollision(super, WizzrobeIce_Functions); if (super->bitfield == 0x87) { Entity* obj = CreateObject(OBJECT_2A, 3, 0); if (obj != NULL) { @@ -150,10 +150,10 @@ void WizzrobeIce_Action2(WizzrobeEntity* this) { void (*const WizzrobeIce_Functions[])(WizzrobeEntity*) = { WizzrobeIce_OnTick, - sub_0802FE18, - (void (*)(WizzrobeEntity*))sub_08001324, - (void (*)(WizzrobeEntity*))sub_0804A7D4, - (void (*)(WizzrobeEntity*))sub_08001242, + WizzrobeIce_OnCollision, + (void (*)(WizzrobeEntity*))GenericKnockback, + (void (*)(WizzrobeEntity*))GenericDeath, + (void (*)(WizzrobeEntity*))GenericConfused, WizzrobeIce_OnTick, }; void (*const WizzrobeIce_Actions[])(WizzrobeEntity*) = { diff --git a/src/enemy/wizzrobeWind.c b/src/enemy/wizzrobeWind.c index 8815b5b5..adb291e6 100644 --- a/src/enemy/wizzrobeWind.c +++ b/src/enemy/wizzrobeWind.c @@ -30,11 +30,11 @@ void WizzrobeWind_OnTick(WizzrobeEntity* this) { WizzrobeWind_Actions[super->action](this); } -void sub_0802F4E4(WizzrobeEntity* this) { - if (super->field_0x43 != 0) { - sub_0804A9FC(super, 0x1c); +void WizzrobeWind_OnCollision(WizzrobeEntity* this) { + if (super->confusedTime != 0) { + Create0x68FX(super, FX_STARS); } - sub_0804AA30(super, WizzrobeWind_Functions); + EnemyFunctionHandlerAfterCollision(super, WizzrobeWind_Functions); if (super->bitfield == 0x87) { Entity* obj = CreateObject(OBJECT_2A, 3, 0); if (obj != NULL) { @@ -261,7 +261,7 @@ void sub_0802F9C8(WizzrobeEntity* this) { } } else { if (super->type2 != 0) { - ProcessMovement(super); + ProcessMovement0(super); if (super->collisions != 0) { super->flags &= 0x7f; this->timer1 = 0x28; @@ -315,10 +315,10 @@ bool32 sub_0802FA88(WizzrobeEntity* this) { void (*const WizzrobeWind_Functions[])(WizzrobeEntity*) = { WizzrobeWind_OnTick, - sub_0802F4E4, - (void (*)(WizzrobeEntity*))sub_08001324, - (void (*)(WizzrobeEntity*))sub_0804A7D4, - (void (*)(WizzrobeEntity*))sub_08001242, + WizzrobeWind_OnCollision, + (void (*)(WizzrobeEntity*))GenericKnockback, + (void (*)(WizzrobeEntity*))GenericDeath, + (void (*)(WizzrobeEntity*))GenericConfused, WizzrobeWind_OnTick, }; void (*const WizzrobeWind_Actions[])(WizzrobeEntity*) = { diff --git a/src/enemyUtils.c b/src/enemyUtils.c index d37c33a1..5e60a0d9 100644 --- a/src/enemyUtils.c +++ b/src/enemyUtils.c @@ -96,7 +96,7 @@ bool32 LoadEnemySprite(Entity* entity, const EnemyDefinition* definition) { ASM_FUNC("asm/non_matching/enemyUtils/sub_0804A720.inc", void sub_0804A720(Entity* this)) void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem); -void sub_0804A7D4(Entity* this) { +void GenericDeath(Entity* this) { CreateDeathFx((GenericEntity*)this, this->id, 0); } @@ -209,7 +209,7 @@ void SetChildOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) { } } -Entity* sub_0804A9FC(Entity* parent, u32 fxType) { +Entity* Create0x68FX(Entity* parent, u32 fxType) { Entity* fx; GenericEntity* this = (GenericEntity*)parent; diff --git a/src/interrupts.c b/src/interrupts.c index 8af1982b..bf5f82f3 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -13,8 +13,6 @@ extern u8 gUnk_03003DE0; extern u8 gUnk_03000C30; -extern u16* gUnk_02025EB0; -extern u16* gUnk_0200B650; extern u8 gUpdateVisibleTiles; extern u8 gUnk_03003DF0[]; extern Entity gUnk_03003BE0; @@ -205,11 +203,11 @@ void WaitForNextFrame(void) { if (gUpdateVisibleTiles) { gUpdateVisibleTiles = 0; - if (gUnk_02025EB0 != NULL) + if (gMapBottom.bgControlPtr != NULL) // sizeof(BGBuffer) = 0x800, what are we omitting? - DmaCopy32(3, &gBG1Buffer, VRAM + (*gUnk_02025EB0 & 0x1f00) * 8, 0x5C0); - if (gUnk_0200B650 != NULL) - DmaCopy32(3, &gBG2Buffer, VRAM + (*gUnk_0200B650 & 0x1f00) * 8, 0x5C0); + DmaCopy32(3, &gBG1Buffer, VRAM + (*gMapBottom.bgControlPtr & 0x1f00) * 8, 0x5C0); + if (gMapTop.bgControlPtr != NULL) + DmaCopy32(3, &gBG2Buffer, VRAM + (*gMapTop.bgControlPtr & 0x1f00) * 8, 0x5C0); } FadeVBlank(); } diff --git a/src/manager/manager10.c b/src/manager/manager10.c index f45f2013..58aaf3aa 100644 --- a/src/manager/manager10.c +++ b/src/manager/manager10.c @@ -23,7 +23,6 @@ const u8 gUnk_08108390[6] = { 0x0F, 0x1E, 0x2D, 0x3C, 0x01, 0x01, }; -extern void* gUnk_0200B650; extern u16 gUnk_020176E0[]; extern u8 gUnk_02017700[]; @@ -37,7 +36,7 @@ void Manager10_Main(Manager10* this) { if (sub_0805986C()) { this->unk_20 = 1; this->unk_22 = 2; - gUnk_0200B650 = 0; + gMapTop.bgControlPtr = 0; } else { this->unk_20 = 0x1F; this->unk_22 = 5; @@ -104,7 +103,7 @@ void sub_080596E0(Manager10* this) { this->unk_21 = 1; this->unk_22 = 3; this->manager.unk_0e = gUnk_08108390[3]; - gUnk_0200B650 = 0; + gMapTop.bgControlPtr = 0; } } else { if (this->unk_21 == 0 && this->unk_22 != 5) { @@ -141,7 +140,7 @@ void sub_080596E0(Manager10* this) { LoadResourceAsync(gBG3Buffer, 0x600e800, 0x800); break; case 5: - gUnk_0200B650 = &gScreen.bg1.control; + gMapTop.bgControlPtr = &gScreen.bg1.control; gScreen.lcd.displayControl |= 0x200; break; } diff --git a/src/manager/manager2.c b/src/manager/manager2.c index 828dcbcc..af102652 100644 --- a/src/manager/manager2.c +++ b/src/manager/manager2.c @@ -16,8 +16,6 @@ extern void sub_0805754C(Manager2*); extern u8 gMapDataTopSpecial[]; -extern u32 gUnk_0200B650; - void Manager2_Main(Manager2* this) { if (this->manager.action == 0) { this->manager.action = 1; @@ -52,7 +50,7 @@ void sub_0805754C(Manager2* this) { void sub_080575C8(u32 param) { s32 bgOffset; - gUnk_0200B650 = 0; + gMapTop.bgControlPtr = 0; REG_DISPCNT = 0; LoadGfxGroup(param); gRoomVars.unk_10[0] = param; diff --git a/src/manager/manager29.c b/src/manager/manager29.c index 7a387ee8..fef0953c 100644 --- a/src/manager/manager29.c +++ b/src/manager/manager29.c @@ -24,8 +24,6 @@ bool32 sub_0805CF80(Manager29* this); void sub_0805CBD0(Manager29* this); void sub_0805CC3C(Manager29* this); -extern u16* GetLayerByIndex(u32); - void Manager29_Main(Manager29* this) { if (this->manager.action == 0) { sub_0805CBD0(this); @@ -40,15 +38,15 @@ void Manager29_Main(Manager29* this) { } void sub_0805CBD0(Manager29* this) { - u16* puVar2; + LayerStruct* puVar2; this->manager.action = 1; this->unk_38 = (this->unk_38 >> 4 & 0x3fU) | (((this->unk_3a << 0x10) >> 0x14 & 0x3fU) << 6); this->unk_3a = (this->unk_3c >> 4 & 0x3f) | (((this->unk_36 + this->unk_37 * 0x100) >> 4 & 0x3fU) << 6); this->unk_3c = GetTileType(this->unk_38, this->unk_34); puVar2 = GetLayerByIndex(this->unk_34); - this->unk_28 = puVar2 + 0x2802; - this->unk_2c = puVar2 + 2 + (s16)this->unk_3a; + this->unk_28 = puVar2->_5004; + this->unk_2c = &puVar2->_4[(s16)this->unk_3a]; } void sub_0805CC3C(Manager29* this) { diff --git a/src/manager/manager8.c b/src/manager/manager8.c index 7ec803be..9e8ecc50 100644 --- a/src/manager/manager8.c +++ b/src/manager/manager8.c @@ -102,11 +102,9 @@ void sub_08058084(u16* unk1, u16* unk2) { } } -extern u32 gUnk_0200B650; - void sub_080580B0(u32 unk1) { s32 tmp; - gUnk_0200B650 = 0; + gMapTop.bgControlPtr = 0; REG_DISPCNT = 0; LoadGfxGroup(unk1); gRoomVars.unk_10[0] = unk1; diff --git a/src/manager/manager9.c b/src/manager/manager9.c index c00132df..fd8effea 100644 --- a/src/manager/manager9.c +++ b/src/manager/manager9.c @@ -83,10 +83,8 @@ void sub_080582F8(u8* unk, u8* unk2) { } } -extern u32 gUnk_0200B650; - void sub_08058324(u32 unk) { - gUnk_0200B650 = 0; + gMapTop.bgControlPtr = 0; LoadPaletteGroup(unk + 0x86); LoadGfxGroup(unk + 0x36); sub_080582D0(); diff --git a/src/manager/managerD.c b/src/manager/managerD.c index 376fa94f..621e7c43 100644 --- a/src/manager/managerD.c +++ b/src/manager/managerD.c @@ -34,8 +34,6 @@ typedef struct { extern void (*const gUnk_08108308[])(ManagerD*); -extern u16* GetLayerByIndex(u32); - void ManagerD_Main(ManagerD* this) { gUnk_08108308[this->manager.action](this); } @@ -47,7 +45,7 @@ void sub_08058DE8(ManagerD* this) { DeleteThisEntity(); } else { this->manager.action = 1; - puVar2 = GetLayerByIndex(this->field_0x3a); + puVar2 = (u16*)GetLayerByIndex(this->field_0x3a); puVar3 = (this->field_0x38 + 2) + puVar2; this->field_0x30 = puVar3; this->field_0x28 = *puVar3; diff --git a/src/movement.c b/src/movement.c new file mode 100644 index 00000000..afe81525 --- /dev/null +++ b/src/movement.c @@ -0,0 +1,2296 @@ +#include "global.h" +#include "entity.h" +#include "room.h" +#include "area.h" +#include "game.h" +#include "asm.h" +#include "item.h" +#include "coord.h" +#include "functions.h" + +/** Collisions. */ +typedef enum { + COL_NONE = 0x0, + COL_NORTH_WEST = 0x2, + COL_NORTH_EAST = 0x4, + COL_NORTH_FULL = 0x6, + COL_NORTH_ANY = 0xe, + COL_SOUTH_WEST = 0x20, + COL_SOUTH_EAST = 0x40, + COL_SOUTH_FULL = 0x60, + COL_SOUTH_ANY = 0xe0, + COL_WEST_SOUTH = 0x200, + COL_WEST_NORTH = 0x400, + COL_WEST_FULL = 0x600, + COL_WEST_ANY = 0xe00, + COL_EAST_SOUTH = 0x2000, + COL_EAST_NORTH = 0x4000, + COL_EAST_FULL = 0x6000, + COL_EAST_ANY = 0xe000, +} Collisions; + +extern u8 gExitList_RoyalValley_ForestMaze[]; +extern u8 gUnk_08135190[]; +extern u8 gUnk_08134FBC[]; +extern u8 gUnk_08135048[]; +extern u8 gUnk_0813A76C[]; + +bool32 IsTileCollision(u8*, s32, s32, u32); +void CalculateEntityTileCollisions(Entity*, u32, u32); +bool32 ProcessMovementInternal(Entity*, s32, s32, u32); +bool32 sub_080AF0C8(Entity*); + +/** The type of the movement/collision? that is done. */ +typedef enum { + CollisionType0, // Normal/common? Used by most enemies and NPCs. + CollisionType1, // chaser, enemy50, fallingBoulder, ghini, keese, pesto, sensorBladeTrap, vaatiRebornEnemy, + // playerItem10, playerItem13 + CollisionType2, // acroBandits, beetle, chuchu, fireballGuy, flyingSkull, helmasaur, keaton, lakitu, + // miniFireballGuy, peahat, rollobite, spikedBeetle, spinyChuchu, stalfos, itemOnGround, + // smallIceBlock, flyingPot, object1F + CollisionType3, // arrowProjectile, boneProjectile, cannonballProjectile, deekuSeedProjectile, fireProjectile, + // gyorgMaleEnergyProjectile, iceProjectile, lakituLightning, mandiblesProjectile, rockProjectile, + // spikedRollers, torchTrapProjectile, v2Projectile, v3ElectricProjectile, v3HandProjectile, + // v3TennisBallProjectile, windProjectile + CollisionType4, // lilypadLarge + CollisionType5, // chuchu + CollisionType6, // npc5 + CollisionType7, // not used? + CollisionType8, // not used? + CollisionType9, // not used? + CollisionType10, // playerItem13, rollobite + CollisionType11, // not used? + CollisionType12, // chaser, sensorBladeTrap +} CollisionType; + +/** The collision function that is evaluated for a tile depending on the x/y position of the entity in the tile. */ +typedef enum { + FilledNone = 0, + FilledAll = 1, + FilledNorthWest = 2, + FilledNorthEast = 3, + FilledSouthWest = 4, + FilledSouthEast = 5, + FilledSouth = 6, + FilledNorth = 7, + FilledWest = 8, + FilledEast = 9 +} TileFilled; + +bool32 MoveNorth(Entity*, s32, s32, u32); +bool32 MoveNorthEast(Entity*, s32, s32, u32); +bool32 MoveEast(Entity*, s32, s32, u32); +bool32 MoveSouthEast(Entity*, s32, s32, u32); +bool32 MoveSouth(Entity*, s32, s32, u32); +bool32 MoveSouthWest(Entity*, s32, s32, u32); +bool32 MoveWest(Entity*, s32, s32, u32); +bool32 MoveNorthWest(Entity*, s32, s32, u32); + +/** Empty */ +bool32 TileCollisionFunction0(s32 x, s32 y) { + return FALSE; +} + +/** Fully filled */ +bool32 TileCollisionFunction1(s32 x, s32 y) { + return TRUE; +} + +/** Diagonal North West filled*/ +bool32 TileCollisionFunction2(s32 x, s32 y) { + static const u16 gUnk_08133918[] = { + /* + 0b1000000000000000, + 0b1100000000000000, + 0b1110000000000000, + 0b1111000000000000, + 0b1111100000000000, + 0b1111110000000000, + 0b1111111000000000, + 0b1111111100000000, + 0b1111111110000000, + 0b1111111111000000, + 0b1111111111100000, + 0b1111111111110000, + 0b1111111111111000, + 0b1111111111111100, + 0b1111111111111110, + 0b1111111111111111, + */ + 32768, 49152, 57344, 61440, 63488, 64512, 65024, 65280, 65408, 65472, 65504, 65520, 65528, 65532, 65534, 65535, + }; + + return gUnk_08133918[y & 0xf] >> (x & 0xf) & 1; +} + +/** Diagonal North East filled*/ +bool32 TileCollisionFunction3(s32 x, s32 y) { + static const u16 gUnk_08133938[] = { + /* + 0b1, + 0b11, + 0b111, + 0b1111, + 0b11111, + 0b111111, + 0b1111111, + 0b11111111, + 0b111111111, + 0b1111111111, + 0b11111111111, + 0b111111111111, + 0b1111111111111, + 0b11111111111111, + 0b111111111111111, + 0b1111111111111111, + */ + 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, + }; + return gUnk_08133938[y & 0xf] >> (x & 0xf) & 1; +} + +/** Diagonal South West filled*/ +bool32 TileCollisionFunction4(s32 x, s32 y) { + static const u16 gUnk_08133958[] = { + /* + 0b1111111111111111, + 0b1111111111111110, + 0b1111111111111100, + 0b1111111111111000, + 0b1111111111110000, + 0b1111111111100000, + 0b1111111111000000, + 0b1111111110000000, + 0b1111111100000000, + 0b1111111000000000, + 0b1111110000000000, + 0b1111100000000000, + 0b1111000000000000, + 0b1110000000000000, + 0b1100000000000000, + 0b1000000000000000, + */ + 65535, 65534, 65532, 65528, 65520, 65504, 65472, 65408, 65280, 65024, 64512, 63488, 61440, 57344, 49152, 32768, + }; + return gUnk_08133958[y & 0xf] >> (x & 0xf) & 1; +} + +/** Diagonal South East filled*/ +bool32 TileCollisionFunction5(s32 x, s32 y) { + static const u16 gUnk_08133978[] = { + /* + 0b1111111111111111, + 0b111111111111111, + 0b11111111111111, + 0b1111111111111, + 0b111111111111, + 0b11111111111, + 0b1111111111, + 0b111111111, + 0b11111111, + 0b1111111, + 0b111111, + 0b11111, + 0b1111, + 0b111, + 0b11, + 0b1, + */ + 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, + }; + return gUnk_08133978[y & 0xf] >> (x & 0xf) & 1; +} + +/** 3/8 South filled */ +bool32 TileCollisionFunction6(s32 x, s32 y) { + static const u16 gUnk_08133998[] = { + /* + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b0, + 0b0, + 0b0, + 0b0, + 0b0, + 0b0, + */ + 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 0, 0, 0, 0, 0, 0, + }; + + return gUnk_08133998[y & 0xf] >> (x & 0xf) & 1; +} + +/** 3/8 North filled */ +bool32 TileCollisionFunction7(s32 x, s32 y) { + static const u16 gUnk_081339B8[] = { + /* + 0b0, + 0b0, + 0b0, + 0b0, + 0b0, + 0b0, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + */ + 0, 0, 0, 0, 0, 0, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, + }; + return gUnk_081339B8[y & 0xf] >> (x & 0xf) & 1; +} + +/** 3/8 West filled */ +bool32 TileCollisionFunction8(s32 x, s32 y) { + static const u16 gUnk_081339D8[] = { + /* + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + 0b1111111111000000, + */ + 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, 65472, + }; + return gUnk_081339D8[y & 0xf] >> (x & 0xf) & 1; +} + +/** 3/8 East filled */ +bool32 TileCollisionFunction9(s32 x, s32 y) { + static const u16 gUnk_081339F8[] = { + /* + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + 0b1111111111, + */ + 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, + }; + return gUnk_081339F8[y & 0xf] >> (x & 0xf) & 1; +} + +bool32 IsTileCollision(u8* layer, s32 x, s32 y, u32 collisionType) { + static bool32 (*const tileCollisionFunctions[])(s32, s32) = { + TileCollisionFunction0, TileCollisionFunction1, TileCollisionFunction2, TileCollisionFunction3, + TileCollisionFunction4, TileCollisionFunction5, TileCollisionFunction6, TileCollisionFunction7, + TileCollisionFunction8, TileCollisionFunction9, + }; + + u32 tileType = layer[TILE(x, y)]; + if (tileType == 0) { + if (collisionType == 4) { + return TRUE; + } else { + return FALSE; + } + } else { + if (tileType < 0x10) { + static const u8 collisionLookup[] = { + 0xff, FilledAll, FilledNone, FilledNone, 0xff, FilledAll, FilledNone, FilledAll, FilledAll, + FilledAll, 0xff, FilledAll, 0xff, FilledAll, FilledAll, FilledAll, FilledAll, FilledAll, + FilledNone, FilledAll, 0xff, FilledAll, FilledAll, FilledAll, 0xff, FilledAll, + }; + + if (collisionLookup[collisionType * 2 + ((tileType + 1) >> 4)] == FilledNone) { + return FALSE; + } + if (collisionLookup[collisionType * 2 + ((tileType + 1) >> 4)] == FilledAll) { + return TRUE; + } + // Calculation for 0xff in previous lookup. + if ((y & 8) == 0) { + tileType = layer[TILE(x, y)]; + tileType >>= 2; + } + if ((x & 8) == 0) { + tileType >>= 1; + } + return tileType & 1; + } else { + if (tileType == 0xff) { + static const u8 collisionFunctionLookup[] = { + FilledAll, FilledAll, FilledAll, FilledNone, FilledAll, FilledAll, FilledAll, + FilledAll, FilledAll, FilledAll, FilledAll, FilledAll, FilledAll, + }; + return tileCollisionFunctions[collisionFunctionLookup[collisionType]](x, y); + } else { + static const u8 collisionFunctionLookup[] = { + /* collisionType: 0 */ + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 1 */ + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 2 */ + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 3 */ + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 4 */ + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledNone, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 5 */ + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledNone, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 6 */ + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledSouth, + FilledNorth, + FilledWest, + FilledEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 7 */ + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 8 */ + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 9 */ + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 10 */ + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 11 */ + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /* collisionType: 12 */ + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNorthWest, + FilledNorthEast, + FilledSouthWest, + FilledSouthEast, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledAll, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledNone, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + FilledAll, + /**/ + FilledNone, + }; + if (tileType > 0x6f) { + return TRUE; + } + + return tileCollisionFunctions[collisionFunctionLookup[collisionType * 0x60 + tileType - 0x10]](x, y); + // return tileCollisionFunctions[collisionFunctionLookup[collisionType][tileType - 0x10]](x, y); + } + } + } + return FALSE; +} + +ASM_FUNC("asm/non_matching/movement/CalculateEntityTileCollisions.inc", + void CalculateEntityTileCollisions(Entity* this, u32 direction, u32 collisionType)) +/*NONMATCH("asm/non_matching/movement/CalculateEntityTileCollisions.inc", + void CalculateEntityTileCollisions(Entity* this, u32 direction, u32 collisionType)) { + u8* layer; + + u32 colResult; + + s32 xMin; + s32 xVar1; + s32 xVar2; + + s32 yMin; + s32 yVar1; + s32 yVar2; + + bool32 col1; + bool32 col2; + bool32 col3; + bool32 col4; + bool32 col5; + bool32 col6; + + u32 hitboxUnkX; + u32 hitboxUnkY; + + layer = GetLayerByIndex(this->collisionLayer)->_2004; + xMin = this->x.HALF.HI + this->hitbox->offset_x; + yMin = this->y.HALF.HI + this->hitbox->offset_y; + hitboxUnkX = this->hitbox->unk2[0]; + hitboxUnkY = this->hitbox->unk2[1]; + if ((direction & 0xf) != 0) { + if (0xf >= direction) { + col1 = IsTileCollision(layer, xMin + hitboxUnkX, yMin, collisionType); + col2 = IsTileCollision(layer, xMin + hitboxUnkX, yMin + hitboxUnkY, collisionType); + col3 = IsTileCollision(layer, xMin + hitboxUnkX, yMin - hitboxUnkY, collisionType); + colResult = ((col1 << 1 | col2) << 1 | col3) << 6; + } else { + col1 = IsTileCollision(layer, xMin - hitboxUnkX, yMin, collisionType); + col2 = IsTileCollision(layer, xMin - hitboxUnkX, yMin + hitboxUnkY, collisionType); + colResult = col1 << 1 | col2; + col3 = IsTileCollision(layer, xMin - hitboxUnkX, yMin - hitboxUnkY, collisionType); + colResult = (colResult << 1 | col3) << 2; + } + } else { + col1 = IsTileCollision(layer, xMin + hitboxUnkX, yMin, collisionType); + col2 = IsTileCollision(layer, xMin + hitboxUnkX, yMin + hitboxUnkY, collisionType); + col3 = IsTileCollision(layer, xMin + hitboxUnkX, yMin - hitboxUnkY, collisionType); + col4 = IsTileCollision(layer, xMin - hitboxUnkX, yMin, collisionType); + col5 = IsTileCollision(layer, xMin - hitboxUnkX, yMin + hitboxUnkY, collisionType); + colResult = (((col1 << 1 | col2) << 1 | col3) << 2 | col4) << 1 | col5; + col6 = IsTileCollision(layer, xMin - hitboxUnkX, yMin - hitboxUnkY, collisionType); + colResult = (colResult << 1 | col6) << 2; + } + + hitboxUnkX = this->hitbox->unk2[2]; + hitboxUnkY = this->hitbox->unk2[3]; + + if (((direction - 8) & 0xf) == 0) { + col1 = IsTileCollision(layer, xMin, yMin + hitboxUnkY, collisionType); + col2 = IsTileCollision(layer, xMin + hitboxUnkX, yMin + hitboxUnkY, collisionType); + col3 = IsTileCollision(layer, xMin - hitboxUnkX, yMin + hitboxUnkY, collisionType); + yMin -= hitboxUnkY; + col4 = IsTileCollision(layer, xMin, yMin, collisionType); + col5 = IsTileCollision(layer, xMin + hitboxUnkX, yMin, collisionType); + colResult = ((((colResult | col1) << 1 | col2) << 1 | col3) << 2 | col4) << 1 | col5; + col6 = IsTileCollision(layer, xMin - hitboxUnkX, yMin, collisionType); + this->collisions = ((colResult << 1 | col6) << 1); + } else { + if (direction - 8 < 0x10) { + yMin += hitboxUnkY; + col1 = IsTileCollision(layer, xMin, yMin, collisionType); + col2 = IsTileCollision(layer, xMin + hitboxUnkX, yMin, collisionType); + col3 = IsTileCollision(layer, xMin - hitboxUnkX, yMin, collisionType); + this->collisions = ((((colResult | col1) << 1 | col2) << 1 | col3) << 5); + } else { + yMin -= hitboxUnkY; + col1 = IsTileCollision(layer, xMin, yMin, collisionType); + col2 = IsTileCollision(layer, xMin + hitboxUnkX, yMin, collisionType); + col6 = (colResult << 4 | col1) << 1 | col2; + colResult = IsTileCollision(layer, xMin - hitboxUnkX, yMin, collisionType); + this->collisions = ((col6 << 1 | colResult) << 1); + } + } +} +END_NONMATCH*/ + +bool32 ProcessMovementInternal(Entity* this, s32 radius, s32 direction, u32 collisionType) { + static bool32 (*const gDirectionalMovementFunctions[])(Entity*, s32, s32, u32) = { + MoveNorth, + /**/ + MoveNorthEast, + MoveNorthEast, + MoveNorthEast, + MoveNorthEast, + MoveNorthEast, + MoveNorthEast, + MoveNorthEast, + /**/ + MoveEast, + /**/ + MoveSouthEast, + MoveSouthEast, + MoveSouthEast, + MoveSouthEast, + MoveSouthEast, + MoveSouthEast, + MoveSouthEast, + /**/ + MoveSouth, + /**/ + MoveSouthWest, + MoveSouthWest, + MoveSouthWest, + MoveSouthWest, + MoveSouthWest, + MoveSouthWest, + MoveSouthWest, + /**/ + MoveWest, + /**/ + MoveNorthWest, + MoveNorthWest, + MoveNorthWest, + MoveNorthWest, + MoveNorthWest, + MoveNorthWest, + MoveNorthWest, + }; + return gDirectionalMovementFunctions[direction](this, radius, direction << 3, collisionType); +} + +bool32 MoveNorth(Entity* this, s32 radius, s32 angle, u32 collisionType) { + s32 moveA = 0; + s32 moveB = 0; + if ((this->collisions & COL_NORTH_ANY) != COL_NONE) { + if ((this->collisions & COL_NORTH_ANY) == COL_NORTH_WEST) { + if ((this->collisions & COL_EAST_ANY) == COL_NONE) { + moveA = radius * 0x100; + this->x.WORD += moveA; + CalculateEntityTileCollisions(this, DirectionNorthEast, collisionType); + if ((this->collisions & COL_NORTH_ANY) == COL_NONE) { + moveB = gSineTable[0x40] * radius; + moveA = radius * 0x100; + this->y.WORD -= moveB; + } + } + } else { + if ((this->collisions & COL_NORTH_ANY) == COL_NORTH_EAST) { + if ((this->collisions & COL_WEST_ANY) == COL_NONE) { + moveA = radius * 0x100; + this->x.WORD -= moveA; + CalculateEntityTileCollisions(this, DirectionNorthWest, collisionType); + if ((this->collisions & COL_NORTH_ANY) == COL_NONE) { + moveB = gSineTable[0x40] * radius; + moveA = radius * 0x100; + this->y.WORD -= moveB; + } + } + } + } + } else { + moveA = gSineTable[0x40] * radius; + this->y.WORD -= moveA; + } + if (((moveA >= -0x3333) && (moveA < 0x3333)) && ((moveB >= -0x3333) && (moveB < 0x3333))) { + return FALSE; + } else { + return TRUE; + } +} + +ASM_FUNC("asm/non_matching/movement/MoveNorthEast.inc", + bool32 MoveNorthEast(Entity* this, s32 radius, s32 angle, u32 collisionType)) +/*NONMATCH("asm/non_matching/movement/MoveNorthEast.inc", + bool32 MoveNorthEast(Entity* this, s32 radius, s32 angle, u32 collisionType)) { + s32 moveA = 0; + s32 moveB = 0; + if (((this->collisions & COL_NORTH_ANY) == COL_NONE) || ((this->collisions & COL_EAST_ANY) == COL_NONE)) { + if ((this->collisions & (COL_NORTH_ANY | COL_EAST_ANY)) == COL_NONE) { + moveA = radius * gSineTable[angle + 0x40]; + this->y.WORD -= moveA; + moveB = radius * gSineTable[angle]; + this->x.WORD += moveB; + } else { + if ((this->collisions & COL_NORTH_ANY) == COL_NORTH_WEST) { + moveA = radius * 0x100; + this->x.WORD += moveA; + CalculateEntityTileCollisions(this, DirectionNorthEast, collisionType); + } else { + if ((this->collisions & COL_EAST_ANY) == COL_EAST_NORTH) { + moveA = radius * 0x100; + this->y.WORD -= moveA; + CalculateEntityTileCollisions(this, DirectionNorthEast, collisionType); + } + } + if ((this->collisions & COL_NORTH_ANY) == COL_NONE) { + moveB = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveB; + } + if ((this->collisions & COL_EAST_ANY) == COL_NONE) { + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } + } + } + if (((moveA >= -0x3333) && (moveA < 0x3333)) && ((moveB >= -0x3333) && (moveB < 0x3333))) { + return FALSE; + } else { + return TRUE; + } +} +END_NONMATCH*/ + +bool32 MoveEast(Entity* this, s32 radius, s32 angle, u32 collisionType) { + s32 moveA = 0; + s32 moveB = 0; + if ((this->collisions & COL_EAST_ANY) != COL_NONE) { + if ((this->collisions & COL_EAST_ANY) == COL_EAST_SOUTH) { + if ((this->collisions & COL_SOUTH_ANY) == COL_NONE) { + moveA = radius * 0x100; + this->y.WORD += moveA; + CalculateEntityTileCollisions(this, DirectionSouthEast, collisionType); + if ((this->collisions & COL_EAST_ANY) == COL_NONE) { + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } + } + } else { + if ((this->collisions & COL_EAST_ANY) == COL_EAST_NORTH) { + if ((this->collisions & COL_NORTH_ANY) == COL_NONE) { + moveA = radius * 0x100; + this->y.WORD -= moveA; + CalculateEntityTileCollisions(this, DirectionNorthEast, collisionType); + if ((this->collisions & COL_EAST_ANY) == COL_NONE) { + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } + } + } + } + } else { + moveA = gSineTable[angle] * radius; + this->x.WORD += moveA; + } + if (((moveA >= -0x3333) && (moveA < 0x3333)) && ((moveB >= -0x3333) && (moveB < 0x3333))) { + return FALSE; + } else { + return TRUE; + } +} + +ASM_FUNC("asm/non_matching/movement/MoveSouthEast.inc", + bool32 MoveSouthEast(Entity* this, s32 radius, s32 angle, u32 collisionType)) +/*NONMATCH("asm/non_matching/movement/MoveSouthEast.inc", + bool32 MoveSouthEast(Entity* this, s32 radius, s32 angle, u32 collisionType)) { + s32 moveA = 0; + s32 moveB = 0; + if (((this->collisions & COL_SOUTH_ANY) == COL_NONE) || ((this->collisions & COL_EAST_ANY) == COL_NONE)) { + if ((this->collisions & (COL_SOUTH_ANY | COL_EAST_ANY)) == COL_NONE) { + moveA = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveA; + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } else { + if ((this->collisions & COL_SOUTH_ANY) == COL_SOUTH_WEST) { + moveA = radius * 0x100; + this->x.WORD += moveA; + CalculateEntityTileCollisions(this, DirectionSouthEast, collisionType); + } else if ((this->collisions & COL_EAST_ANY) == COL_EAST_SOUTH) { + moveA = radius * 0x100; + this->y.WORD += moveA; + CalculateEntityTileCollisions(this, DirectionSouthEast, collisionType); + } + if ((this->collisions & COL_SOUTH_ANY) == COL_NONE) { + moveB = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveB; + } + if ((this->collisions & COL_EAST_ANY) == COL_NONE) { + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } + } + } + if (((moveA >= -0x3333) && (moveA < 0x3333)) && ((moveB >= -0x3333) && (moveB < 0x3333))) { + return FALSE; + } else { + return TRUE; + } +} +END_NONMATCH*/ + +bool32 MoveSouth(Entity* this, s32 radius, s32 angle, u32 collisionType) { + s32 moveA = 0; + s32 moveB = 0; + + if ((this->collisions & COL_SOUTH_ANY) != COL_NONE) { + if ((this->collisions & COL_SOUTH_ANY) == COL_SOUTH_WEST) { + if ((this->collisions & COL_EAST_ANY) == COL_NONE) { + moveA = radius * 0x100; + this->x.WORD += moveA; + CalculateEntityTileCollisions(this, DirectionSouthEast, collisionType); + if ((this->collisions & COL_SOUTH_ANY) == COL_NONE) { + moveB = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveB; + } + } + } else { + if ((this->collisions & COL_SOUTH_ANY) == COL_SOUTH_EAST) { + if ((this->collisions & COL_WEST_ANY) == COL_NONE) { + moveA = radius * 0x100; + this->x.WORD -= moveA; + CalculateEntityTileCollisions(this, DirectionSouthWest, collisionType); + if ((this->collisions & COL_SOUTH_ANY) == COL_NONE) { + moveB = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveB; + } + } + } + } + } else { + moveA = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveA; + } + if (((moveA >= -0x3333) && (moveA < 0x3333)) && ((moveB >= -0x3333) && (moveB < 0x3333))) { + return FALSE; + } else { + return TRUE; + } +} + +ASM_FUNC("asm/non_matching/movement/MoveSouthWest.inc", + bool32 MoveSouthWest(Entity* this, s32 radius, s32 angle, u32 collisionType)) +/*NONMATCH("asm/non_matching/movement/MoveSouthWest.inc", + bool32 MoveSouthWest(Entity* this, s32 radius, s32 angle, u32 collisionType)) { + s32 moveA = 0; + s32 moveB = 0; + if (((this->collisions & COL_SOUTH_ANY) == COL_NONE) || ((this->collisions & COL_WEST_ANY) == COL_NONE)) { + if ((this->collisions & (COL_SOUTH_ANY | COL_WEST_ANY)) == COL_NONE) { + moveB = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveB; + moveA = gSineTable[angle] * radius; + this->x.WORD += moveA; + } else { + if ((this->collisions & COL_SOUTH_ANY) == COL_SOUTH_EAST) { + moveB = radius * 0x100; + this->x.WORD -= moveB; + CalculateEntityTileCollisions(this, DirectionSouthWest, collisionType); + } else { + if ((this->collisions & COL_WEST_ANY) == COL_WEST_SOUTH) { + moveB = radius * 0x100; + this->y.WORD += moveB; + CalculateEntityTileCollisions(this, DirectionSouthWest, collisionType); + } + } + if ((this->collisions & COL_SOUTH_ANY) == COL_NONE) { + moveA = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveA; + } + if ((this->collisions & COL_WEST_ANY) == COL_NONE) { + moveA = gSineTable[angle] * radius; + this->x.WORD += moveA; + } + } + } + if (((moveA >= -0x3333) && (moveA < 0x3333)) && ((moveB >= -0x3333) && (moveB < 0x3333))) { + return FALSE; + } else { + return TRUE; + } +} +END_NONMATCH*/ + +bool32 MoveWest(Entity* this, s32 radius, s32 angle, u32 collisionType) { + s32 moveA = 0; + s32 moveB = 0; + + if ((this->collisions & COL_WEST_ANY) != COL_NONE) { + + if ((this->collisions & COL_WEST_ANY) == COL_WEST_SOUTH) { + if ((this->collisions & COL_SOUTH_ANY) == COL_NONE) { + moveA = radius * 0x100; + this->y.WORD += moveA; + CalculateEntityTileCollisions(this, DirectionNorthWest, + collisionType); // @bug? Should this calculate for DirectionSouthWest? + if ((this->collisions & COL_WEST_ANY) == COL_NONE) { + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } + } + } else { + if ((this->collisions & COL_WEST_ANY) == COL_WEST_NORTH) { + if ((this->collisions & COL_NORTH_ANY) == COL_NONE) { + moveA = radius * 0x100; + this->y.WORD -= moveA; + CalculateEntityTileCollisions(this, DirectionNorthWest, collisionType); + if ((this->collisions & COL_WEST_ANY) == COL_NONE) { + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } + } + } + } + } else { + moveA = gSineTable[angle] * radius; + this->x.WORD += moveA; + } + + if (((moveA >= -0x3333) && (moveA < 0x3333)) && ((moveB >= -0x3333) && (moveB < 0x3333))) { + return FALSE; + } else { + return TRUE; + } +} + +ASM_FUNC("asm/non_matching/movement/MoveNorthWest.inc", + bool32 MoveNorthWest(Entity* this, s32 radius, s32 angle, u32 collisionType)) +/*NONMATCH("asm/non_matching/movement/MoveNorthWest.inc", + bool32 MoveNorthWest(Entity* this, s32 radius, s32 angle, u32 collisionType)) { + s32 moveA = 0; + s32 moveB = 0; + u32 colNorthAny = (this->collisions & COL_NORTH_ANY); + u32 colWestAny = (this->collisions & COL_WEST_ANY); + if ((colNorthAny == COL_NONE) || (colWestAny == COL_NONE)) { + if ((colNorthAny | colWestAny) == COL_NONE) { + moveA = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveA; + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } else { + if (colNorthAny == COL_NORTH_EAST) { + moveA = radius * 0x100; + this->x.WORD -= moveA; + CalculateEntityTileCollisions(this, DirectionNorthWest, collisionType); + } else { + if (colWestAny == COL_WEST_NORTH) { + moveA = radius * 0x100; + this->y.WORD -= moveA; + CalculateEntityTileCollisions(this, DirectionNorthWest, collisionType); + } + } + if ((this->collisions & COL_NORTH_ANY) == COL_NONE) { + moveB = gSineTable[angle + 0x40] * radius; + this->y.WORD -= moveB; + } + if ((this->collisions & COL_WEST_ANY) == COL_NONE) { + moveB = gSineTable[angle] * radius; + this->x.WORD += moveB; + } + } + } + if (((moveA >= -0x3333) && (moveA < 0x3333)) && ((moveB >= -0x3333) && (moveB < 0x3333))) { + return FALSE; + } else { + return TRUE; + } +} +END_NONMATCH*/ + +bool32 ProcessMovement0(Entity* this) { + bool32 result; + + if ((this->direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, this->direction, 0); + result = ProcessMovementInternal(this, this->speed, this->direction, 0); + } else { + result = FALSE; + } + return result; +} + +bool32 ProcessMovement1(Entity* this) { + bool32 result; + + if ((this->direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, this->direction, 1); + result = ProcessMovementInternal(this, this->speed, this->direction, 1); + } else { + result = FALSE; + } + return result; +} + +bool32 ProcessMovement2(Entity* this) { + bool32 result; + + if ((this->direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, this->direction, 2); + result = ProcessMovementInternal(this, this->speed, this->direction, 2); + } else { + result = FALSE; + } + return result; +} + +bool32 ProcessMovement10(Entity* this) { + bool32 result; + + if ((this->direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, this->direction, 10); + result = ProcessMovementInternal(this, this->speed, this->direction, 10); + } else { + result = FALSE; + } + return result; +} + +bool32 ProcessMovement12(Entity* this) { + bool32 result; + + if ((this->direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, this->direction, 12); + result = ProcessMovementInternal(this, this->speed, this->direction, 12); + } else { + result = FALSE; + } + return result; +} + +bool32 ProcessMovement0_custom(Entity* this, u32 direction, u32 speed) { + bool32 result; + + if ((direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, direction, 0); + result = ProcessMovementInternal(this, speed, direction, 0); + } else { + result = FALSE; + } + return result; +} + +bool32 ProcessMovement3(Entity* this) { + bool32 result; + + if (((this->direction & 0x80) == 0) && (sub_080AF0C8(this) == 0)) { + CalculateEntityTileCollisions(this, this->direction, 3); + result = ProcessMovementInternal(this, this->speed, this->direction, 3); + } else { + result = FALSE; + } + return result; +} + +bool32 sub_080AF0C8(Entity* this) { + u32 tileType = GetTileTypeByEntity(this); + switch (tileType) { + case 0x87: + if (((this->direction + 7) & 0x1f) < 0x10) { + this->collisions = COL_NORTH_ANY; + return TRUE; + } + break; + case 0x8a: + if (((this->direction - 1) & 0x1f) < 0x10) { + this->collisions = COL_EAST_ANY; + return TRUE; + } + break; + case 0x88: + if (((this->direction - 9) & 0x1f) < 0x10) { + this->collisions = COL_SOUTH_ANY; + return TRUE; + } + break; + case 0x89: + if (((this->direction - 0x11) & 0x1f) < 0x10) { + this->collisions = COL_WEST_ANY; + return TRUE; + } + break; + } + return FALSE; +} + +bool32 ProcessMovement4(Entity* this) { + bool32 result; + + if ((this->direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, this->direction, 4); + result = ProcessMovementInternal(this, this->speed, this->direction, 4); + } else { + result = FALSE; + } + return result; +} + +bool32 ProcessMovement5(Entity* this) { + bool32 result; + + if ((this->direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, this->direction, 5); + result = ProcessMovementInternal(this, this->speed, this->direction, 5); + } else { + result = FALSE; + } + return result; +} + +void Knockback1(Entity* this) { + this->knockbackDuration--; + CalculateEntityTileCollisions(this, this->knockbackDirection, 2); + ProcessMovementInternal(this, this->knockbackSpeed, this->knockbackDirection, 2); +} + +void Knockback2(Entity* this) { + this->knockbackDuration--; + CalculateEntityTileCollisions(this, this->knockbackDirection, 1); + ProcessMovementInternal(this, this->knockbackSpeed, this->knockbackDirection, 1); +} + +bool32 ProcessMovement6(Entity* this) { + bool32 result; + + if ((this->direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, this->direction, 6); + result = ProcessMovementInternal(this, this->speed, this->direction, 6); + } else { + result = FALSE; + } + return result; +} + +bool32 ProcessMovement6_custom(Entity* this, u32 direction, u32 speed) { + bool32 result; + + if ((direction & 0x80) == 0) { + CalculateEntityTileCollisions(this, direction, 6); + result = ProcessMovementInternal(this, speed, direction, 6); + } else { + result = FALSE; + } + return result; +} + +void ProcessMovementInternal2(Entity* this, u32 direction, u32 speed) { + ProcessMovementInternal(this, direction, speed, 2); +} + +void sub_080AF250(s32 param_1) { + gArea.pCurrentRoomInfo = GetCurrentRoomInfo(); + if (param_1 != 0) { + (gArea.pCurrentRoomInfo)->exits = gUnk_08135190; + } else { + (gArea.pCurrentRoomInfo)->exits = gExitList_RoyalValley_ForestMaze; + } +} + +void sub_080AF284(void) { + if (CheckPlayerInRegion(0x78, gRoomControls.height - 0x50, 0x78, 0x50)) { + gArea.pCurrentRoomInfo = GetCurrentRoomInfo(); + (gArea.pCurrentRoomInfo)->exits = gUnk_08135048; + } else { + if (GetInventoryValue(ITEM_FOURSWORD) == 0) { + return; + } + gArea.pCurrentRoomInfo = GetCurrentRoomInfo(); + (gArea.pCurrentRoomInfo)->exits = gUnk_08134FBC; + } +} + +void sub_080AF2E4(void) { + if (GetInventoryValue(ITEM_FOURSWORD)) { + gArea.pCurrentRoomInfo = GetCurrentRoomInfo(); + (gArea.pCurrentRoomInfo)->exits = gUnk_0813A76C; + } +} diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index ab9f4912..cb791a38 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -25,7 +25,6 @@ void sub_0806D138(unk_0806D138param_1* param_1, unk_0806D138param_2* param_2); extern void InitBiggoronTimer(void); -extern u32 gUnk_0200B650; void sub_0806D110(void); void sub_0806D164(Entity* this); @@ -88,7 +87,7 @@ Entity* sub_0806D00C(Entity* this) { ASM_FUNC("asm/non_matching/bigGoron/sub_0806D02C.inc", void sub_0806D02C(Entity* this)) void sub_0806D0B0(Entity* this) { - gUnk_0200B650 = 0; + gMapTop.bgControlPtr = 0; LoadGfxGroup(0x30); sub_0806D110(); MemClear(&gMapDataTopSpecial, 0x2000); diff --git a/src/npc/castleMaid.c b/src/npc/castleMaid.c index 81483829..b846a04a 100644 --- a/src/npc/castleMaid.c +++ b/src/npc/castleMaid.c @@ -155,7 +155,7 @@ void sub_080646A4(Entity* this, ScriptExecutionContext* context) { } context->postScriptActions |= 0x2; - ProcessMovement(this); + ProcessMovement0(this); x = this->x.HALF.HI; diff = x - (s16)this->field_0x6c.HWORD; if (diff > 0x10) { diff --git a/src/npc/cow.c b/src/npc/cow.c index 5f0bcc0a..481877ab 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -87,7 +87,7 @@ void sub_08069068(Entity* ent) { InitAnimationForceUpdate(ent, ent->animationState + 4); } - ProcessMovement(ent); + ProcessMovement0(ent); UpdateAnimationSingleFrame(ent); { diff --git a/src/npc/dog.c b/src/npc/dog.c index 111b27e0..525a0539 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -136,7 +136,7 @@ void sub_08069D54(Entity* this) { this->actionDelay -= 1; if (this->actionDelay != 0) { UpdateAnimationSingleFrame(this); - ProcessMovement(this); + ProcessMovement0(this); collisions = this->collisions; if (this->x.HALF.HI < this->field_0x6e.HWORD) { diff --git a/src/npc/kid.c b/src/npc/kid.c index 011327db..0375b162 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -364,7 +364,7 @@ NONMATCH("asm/non_matching/kid/sub_08062948.inc", void sub_08062948(Entity* this InitializeAnimation(this, uVar3); this->field_0x80.HALF.LO = (u16)this->animIndex; } - ProcessMovement(this); + ProcessMovement0(this); iVar4 = this->x.HALF.HI - this->field_0x6c.HALF.LO; if (0x10 < iVar4) { this->x.HALF.HI = this->field_0x6c.HALF.LO + 0x10; diff --git a/src/npc/npc23.c b/src/npc/npc23.c index 9630e18a..9f64b7bb 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -76,7 +76,7 @@ void sub_080663D4(Entity* this) { InitializeAnimation(this, (this->direction >> 3) + 4); this->subAction = this->subAction + 1; } - ProcessMovement(this); + ProcessMovement0(this); } sub_08078B48(); GetNextFrame(this); diff --git a/src/npc/npc5.c b/src/npc/npc5.c index 3ffa94fb..7a72f32e 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -39,10 +39,9 @@ void sub_08060E94(Entity*); u32 PointInsideRadius(s32, s32, s32); -extern Entity gUnk_0200D654; -extern Entity gUnk_02027EB4; +extern u8 gUnk_0200D654[]; +extern u8 gUnk_02027EB4[]; -extern u32 sub_080AF1EC(Entity*); u32 sub_080611D4(Entity*); extern u32 sub_08079FD4(Entity*, u32); extern void sub_08016AD2(Entity*); @@ -64,13 +63,13 @@ bool32 sub_08061978(Entity*, s32, s32, s32); bool32 sub_08061810(Entity*, s32, s32, s32); bool32 sub_08061900(Entity*, s32, s32, s32); -bool32 sub_08061A74(Entity*, s32, s32, s32); +bool32 sub_08061A74(u8*, s32, s32, s32); -bool32 sub_08061A1C(Entity*, s32, s32, s32); +bool32 sub_08061A1C(u8*, s32, s32, s32); -bool32 sub_080619F0(Entity*, s32, s32, s32); +bool32 sub_080619F0(u8*, s32, s32, s32); -bool32 sub_08061A48(Entity*, s32, s32, s32); +bool32 sub_08061A48(u8*, s32, s32, s32); extern void (*const gUnk_0810AC70[])(Entity*); @@ -395,7 +394,7 @@ NONMATCH("asm/non_matching/npc5/sub_08061170.inc", bool32 sub_08061170(Entity* t u32 tmp; UpdateAnimationSingleFrame(this); - if (sub_080AF1EC(this) == 0) { + if (ProcessMovement6(this) == 0) { direction = sub_080611D4(this); if (direction != 0xff) { this->action = 6; @@ -635,9 +634,9 @@ void sub_08061464(Entity* this, u32 param_a, u32 param_b) { bool32 sub_08061630(Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; - Entity* entity = (this->collisionLayer == 2) ? &gUnk_0200D654 : &gUnk_02027EB4; - while (!sub_080AE4CC(entity, x, y, 6)) { - if (sub_08061A74(entity, x, y, param)) { + u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + while (!IsTileCollision(layer, x, y, 6)) { + if (sub_08061A74(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = x; ((UnkHeap*)this->myHeap)->unk_8 = param_y; ((UnkHeap*)this->myHeap)->unk_0 |= 8; @@ -652,9 +651,9 @@ bool32 sub_08061630(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_080616A8(Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; - Entity* entity = (this->collisionLayer == 2) ? &gUnk_0200D654 : &gUnk_02027EB4; - while (!sub_080AE4CC(entity, x, y, 6)) { - if (sub_08061A1C(entity, x, y, param)) { + u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + while (!IsTileCollision(layer, x, y, 6)) { + if (sub_08061A1C(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = x; ((UnkHeap*)this->myHeap)->unk_8 = param_y; ((UnkHeap*)this->myHeap)->unk_0 |= 8; @@ -669,9 +668,9 @@ bool32 sub_080616A8(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061720(Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; - Entity* entity = (this->collisionLayer == 2) ? &gUnk_0200D654 : &gUnk_02027EB4; - while (!sub_080AE4CC(entity, x, y, 6)) { - if (sub_080619F0(entity, x, y, param)) { + u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + while (!IsTileCollision(layer, x, y, 6)) { + if (sub_080619F0(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = param_x; ((UnkHeap*)this->myHeap)->unk_8 = y; ((UnkHeap*)this->myHeap)->unk_0 |= 8; @@ -686,9 +685,9 @@ bool32 sub_08061720(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061798(Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; - Entity* entity = (this->collisionLayer == 2) ? &gUnk_0200D654 : &gUnk_02027EB4; - while (!sub_080AE4CC(entity, x, y, 6)) { - if (sub_08061A48(entity, x, y, param)) { + u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + while (!IsTileCollision(layer, x, y, 6)) { + if (sub_08061A48(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = param_x; ((UnkHeap*)this->myHeap)->unk_8 = y; ((UnkHeap*)this->myHeap)->unk_0 |= 8; @@ -703,9 +702,9 @@ bool32 sub_08061798(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061810(Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; - Entity* entity = (this->collisionLayer == 2) ? &gUnk_0200D654 : &gUnk_02027EB4; - while (!sub_080AE4CC(entity, x, y, 6)) { - if (sub_08061A74(entity, x, y, param)) { + u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + while (!IsTileCollision(layer, x, y, 6)) { + if (sub_08061A74(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = x; ((UnkHeap*)this->myHeap)->unk_8 = param_y; ((UnkHeap*)this->myHeap)->unk_0 |= 8; @@ -720,9 +719,9 @@ bool32 sub_08061810(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061888(Entity* this, s32 x, s32 y, s32 param) { u32 param_y = y; - Entity* entity = (this->collisionLayer == 2) ? &gUnk_0200D654 : &gUnk_02027EB4; - while (!sub_080AE4CC(entity, x, y, 6)) { - if (sub_08061A1C(entity, x, y, param)) { + u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + while (!IsTileCollision(layer, x, y, 6)) { + if (sub_08061A1C(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = x; ((UnkHeap*)this->myHeap)->unk_8 = param_y; ((UnkHeap*)this->myHeap)->unk_0 |= 8; @@ -737,9 +736,9 @@ bool32 sub_08061888(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061900(Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; - Entity* entity = (this->collisionLayer == 2) ? &gUnk_0200D654 : &gUnk_02027EB4; - while (!sub_080AE4CC(entity, x, y, 6)) { - if (sub_080619F0(entity, x, y, param)) { + u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + while (!IsTileCollision(layer, x, y, 6)) { + if (sub_080619F0(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = param_x; ((UnkHeap*)this->myHeap)->unk_8 = y; ((UnkHeap*)this->myHeap)->unk_0 |= 8; @@ -754,9 +753,9 @@ bool32 sub_08061900(Entity* this, s32 x, s32 y, s32 param) { bool32 sub_08061978(Entity* this, s32 x, s32 y, s32 param) { u32 param_x = x; - Entity* entity = (this->collisionLayer == 2) ? &gUnk_0200D654 : &gUnk_02027EB4; - while (!sub_080AE4CC(entity, x, y, 6)) { - if (sub_08061A48(entity, x, y, param)) { + u8* layer = (this->collisionLayer == 2) ? gUnk_0200D654 : gUnk_02027EB4; + while (!IsTileCollision(layer, x, y, 6)) { + if (sub_08061A48(layer, x, y, param)) { ((UnkHeap*)this->myHeap)->unk_7 = param_x; ((UnkHeap*)this->myHeap)->unk_8 = y; ((UnkHeap*)this->myHeap)->unk_0 |= 8; @@ -769,9 +768,9 @@ bool32 sub_08061978(Entity* this, s32 x, s32 y, s32 param) { return FALSE; } -bool32 sub_080619F0(Entity* this, s32 x, s32 y, s32 param) { +bool32 sub_080619F0(u8* layer, s32 x, s32 y, s32 param) { while (param <= y) { - if (sub_080AE4CC(this, x, y, 6) != 0) { + if (IsTileCollision(layer, x, y, 6) != 0) { return FALSE; } y -= 8; @@ -779,9 +778,9 @@ bool32 sub_080619F0(Entity* this, s32 x, s32 y, s32 param) { return TRUE; } -bool32 sub_08061A1C(Entity* this, s32 x, s32 y, s32 param) { +bool32 sub_08061A1C(u8* layer, s32 x, s32 y, s32 param) { while (param >= x) { - if (sub_080AE4CC(this, x, y, 6) != 0) { + if (IsTileCollision(layer, x, y, 6) != 0) { return FALSE; } x += 8; @@ -789,9 +788,9 @@ bool32 sub_08061A1C(Entity* this, s32 x, s32 y, s32 param) { return TRUE; } -bool32 sub_08061A48(Entity* this, s32 x, s32 y, s32 param) { +bool32 sub_08061A48(u8* layer, s32 x, s32 y, s32 param) { while (param >= y) { - if (sub_080AE4CC(this, x, y, 6) != 0) { + if (IsTileCollision(layer, x, y, 6) != 0) { return FALSE; } y += 8; @@ -799,9 +798,9 @@ bool32 sub_08061A48(Entity* this, s32 x, s32 y, s32 param) { return TRUE; } -bool32 sub_08061A74(Entity* this, s32 x, s32 y, s32 param) { +bool32 sub_08061A74(u8* layer, s32 x, s32 y, s32 param) { while (param <= x) { - if (sub_080AE4CC(this, x, y, 6) != 0) { + if (IsTileCollision(layer, x, y, 6) != 0) { return FALSE; } x -= 8; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 8cfd33c1..f888ea21 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -190,7 +190,7 @@ void sub_08061E90(Entity* this, ScriptExecutionContext* context) { if (animIndex != this->animIndex) { InitializeAnimation(this, animIndex); } - ProcessMovement(this); + ProcessMovement0(this); iVar4 = this->x.HALF.HI - *(s16*)&this->field_0x6a.HWORD; if (0x10 < iVar4) { this->x.HALF.HI = this->field_0x6a.HWORD + 0x10; diff --git a/src/npcUtils.c b/src/npcUtils.c index a430d135..bf609c86 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -130,7 +130,7 @@ void sub_0806EE04(Entity* ent, void* a2, u32 a3) { ent->child = a2; ent->field_0x3c = a3; ent->hitType = 0; - ent->field_0x46 = 0; + ent->knockbackSpeed = 0; ent->field_0x16 = 0; } @@ -141,7 +141,7 @@ u32 sub_0806EE20(Entity* ent) { if (ent->child) return gUnk_08114EFC[ent->field_0x16](ent); } else { - ent->field_0x46 = 8; + ent->knockbackSpeed = 8; v3 = GetFacingDirection(ent, &gPlayerEntity); ent->knockbackDirection = sub_0806F5A4(v3); } @@ -154,8 +154,8 @@ u32 sub_0806EE70(Entity* ent) { u32 result; u16 xy[2]; - if (++ent->field_0x46 > 8) { - ent->field_0x46 = 0; + if (++ent->knockbackSpeed > 8) { + ent->knockbackSpeed = 0; sub_0806EF14(ent); } LinearMoveUpdate(ent); @@ -172,7 +172,7 @@ u32 sub_0806EE70(Entity* ent) { } u32 sub_0806EED0(Entity* ent) { - if (!--ent->field_0x46) + if (!--ent->knockbackSpeed) return sub_0806EF74(ent, 2); return 0; } @@ -214,13 +214,13 @@ u32 sub_0806EFAC(Entity* ent, u16* a2) { u32 sub_0806EFBC(Entity* ent, u16* a2) { ent->field_0x16 = 1; - ent->field_0x46 = 8; + ent->knockbackSpeed = 8; return 0; } u32 sub_0806EFCC(Entity* ent, u16* a2) { ent->field_0x16 = 2; - ent->field_0x46 = a2[1]; + ent->knockbackSpeed = a2[1]; return 0; } diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index cdc65c3a..fd2b80aa 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -65,7 +65,7 @@ void sub_0809CD0C(Entity* this) { gPlayerEntity.iframes = 16; gPlayerEntity.knockbackDirection = 16; gPlayerEntity.knockbackDuration = 12; - gPlayerEntity.field_0x46 = 16; + gPlayerEntity.knockbackSpeed = 16; } } } diff --git a/src/object/button.c b/src/object/button.c index 61f4e704..240fc4e3 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -190,7 +190,6 @@ u32 sub_08081F00(u32*, u32*); extern u16 gMapDataTopSpecial[0x2000]; -extern u16* GetLayerByIndex(u32); extern u16 gUnk_02019EE0[]; NONMATCH("asm/non_matching/button/sub_08081E6C.inc", void sub_08081E6C(Entity* this)) { u32 r4; @@ -201,7 +200,7 @@ NONMATCH("asm/non_matching/button/sub_08081E6C.inc", void sub_08081E6C(Entity* t u32 tile = GetTileType(r6, r5); if (tile < 0x4000) return; - r1 = GetLayerByIndex(r5); + r1 = (u16*)GetLayerByIndex(r5); r4 = (this->type == 0 ? 0x7a : 0x78); tmp = r1 + 0x3802; r1 += 0x3002 + r4; diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index 054f7411..49503916 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -203,7 +203,7 @@ void sub_080811D8(Entity* this) { void sub_080811EC(Entity* this) { if (this->field_0x68.HALF.HI != 6) { - sub_080AEFE0(this); + ProcessMovement2(this); } else { LinearMoveUpdate(this); } @@ -389,7 +389,7 @@ void sub_08081500(Entity* this) { UpdateSpriteForCollisionLayer(this); } - sub_080AEFE0(this); + ProcessMovement2(this); } } } diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index 13dae7bc..aac89cb2 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -6,11 +6,6 @@ #include "flags.h" #include "functions.h" -extern void sub_0809EB30(Entity*); -extern void sub_0809EAD8(Entity*); -extern void sub_0809EABC(Entity*); -extern void sub_080A2CC0(Entity*, Entity**, u16*); - extern void (*const gUnk_081243B4[])(Entity*); extern void (*const gUnk_081243BC[])(Entity*); extern void (*const gUnk_081243C4[])(Entity*); diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index 5f5a426c..6d326946 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -114,7 +114,7 @@ void sub_08085A44(LilypadLargeEntity* this) { } } sub_08085EFC(this); - sub_080AF134(super); + ProcessMovement4(super); sub_08085F1C(this); } diff --git a/src/object/objectB2.c b/src/object/objectB2.c index 1e5f0b58..bd2c58b5 100644 --- a/src/object/objectB2.c +++ b/src/object/objectB2.c @@ -2,27 +2,27 @@ #include "entity.h" #include "functions.h" -extern void* gUnk_02027EB4; -extern void* gUnk_0200D654; +extern u8 gUnk_02027EB4[]; +extern u8 gUnk_0200D654[]; void ObjectB2(Entity* this) { - void* pEVar3; + u8* layer; if (this->action == 0) { this->action = 1; this->actionDelay = 0x10; this->direction = this->type << 3; if (this->collisionLayer == 2) { - pEVar3 = &gUnk_0200D654; + layer = gUnk_0200D654; } else { - pEVar3 = &gUnk_02027EB4; + layer = gUnk_02027EB4; } - this->child = pEVar3; + this->child = (Entity*)layer; InitializeAnimation(this, this->type); } this->speed = this->parent->speed; LinearMoveUpdate(this); - if (sub_080AE4CC(this->child, this->x.HALF.HI, this->y.HALF.HI, 9) != 0) { + if (IsTileCollision((u8*)this->child, this->x.HALF.HI, this->y.HALF.HI, 9) != 0) { DeleteThisEntity(); } if (this->speed < 0x41) { diff --git a/src/object/pushableStatue.c b/src/object/pushableStatue.c index c77436ae..70377802 100644 --- a/src/object/pushableStatue.c +++ b/src/object/pushableStatue.c @@ -20,7 +20,6 @@ typedef struct { /*0x86*/ u16 unk_86; } PushableStatueEntity; -extern u8* GetLayerByIndex(u32); extern const Hitbox gUnk_080FD1F4; extern const s16 gUnk_080B4488[]; extern const s16 gUnk_080B4468[]; diff --git a/src/object/railtrack.c b/src/object/railtrack.c index 303d279d..fbca5d99 100644 --- a/src/object/railtrack.c +++ b/src/object/railtrack.c @@ -6,7 +6,6 @@ #include "flags.h" #include "functions.h" -extern u32* GetLayerByIndex(u32); extern void sub_08085394(Entity*); extern void sub_0808543C(Entity*); extern u32 sub_080854A8(Entity*); diff --git a/src/object/rupee.c b/src/object/rupee.c index f4119600..583cf0f07 100644 --- a/src/object/rupee.c +++ b/src/object/rupee.c @@ -37,7 +37,7 @@ void sub_08086A28(Entity* ent) { if (iVar1 == 0) { ent->action = 2; } - ProcessMovement(ent); + ProcessMovement0(ent); CopyPosition(ent, ent->child); } } diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c index 63542a02..c491a16b 100644 --- a/src/object/smallIceBlock.c +++ b/src/object/smallIceBlock.c @@ -205,7 +205,7 @@ bool32 sub_0809953C(SmallIceBlockEntity* this) { if (uVar3 != 0) { return 0; } - sub_080AEFE0(super); + ProcessMovement2(super); sub_0800445C(super); if (super->actionDelay != 0) { super->speed += 0x10; diff --git a/src/projectile/arrowProjectile.c b/src/projectile/arrowProjectile.c index 7f6079f7..91567d8b 100644 --- a/src/projectile/arrowProjectile.c +++ b/src/projectile/arrowProjectile.c @@ -3,8 +3,6 @@ #include "functions.h" #include "object.h" -extern s32 sub_080AF090(Entity*); - extern void (*const gArrowProjectile[])(Entity*); extern void (*const gArrowProjectileActions[])(Entity*); @@ -78,7 +76,7 @@ void ArrowProjectile_Action2(Entity* this) { } else if (--this->actionDelay == 0) { DeleteThisEntity(); } - sub_080AF090(this); + ProcessMovement3(this); } void ArrowProjectile_Action3(Entity* this) { diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index 33677de2..3f9858a9 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -2,10 +2,6 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); -extern void sub_08016AD2(Entity*); - extern void (*const BoneProjectile_Functions[])(Entity*); extern void (*const BoneProjectile_Actions[])(Entity*); @@ -36,9 +32,9 @@ void BoneProjectile_Init(Entity* this) { void BoneProjectile_Action1(Entity* this) { GetNextFrame(this); - sub_080AF090(this); + ProcessMovement3(this); if (this->collisions == 0) { - if (IsProjectileOffScreen(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { sub_08016AD2(this); @@ -54,7 +50,7 @@ void BoneProjectile_Action1(Entity* this) { void BoneProjectile_Action2(Entity* this) { GetNextFrame(this); - sub_080AF090(this); + ProcessMovement3(this); if (GravityUpdate(this, 0x1800) == 0) { this->action = 3; COLLISION_OFF(this); diff --git a/src/projectile/cannonballProjectile.c b/src/projectile/cannonballProjectile.c index 5e07dfc4..acf5ccd7 100644 --- a/src/projectile/cannonballProjectile.c +++ b/src/projectile/cannonballProjectile.c @@ -1,11 +1,6 @@ #include "entity.h" #include "enemy.h" - -extern void CreateItemOnGround(Entity*); -extern s32 sub_080AF090(Entity*); -extern void sub_080043A8(Entity*); -extern void CreateChestSpawner(Entity*); -extern u32 IsColliding(Entity*, Entity*); +#include "functions.h" extern void (*const CannonballProjectile_Functions[])(Entity*); extern void (*const CannonballProjectile_Actions[])(Entity*); @@ -44,7 +39,7 @@ void CannonballProjectile_Init(Entity* this) { void CannonballProjectile_Action1(Entity* this) { GetNextFrame(this); - if (sub_080AF090(this) == 0) { + if (ProcessMovement3(this) == 0) { CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); } @@ -53,7 +48,7 @@ void CannonballProjectile_Action1(Entity* this) { void CannonballProjectile_Action2(Entity* this) { GetNextFrame(this); - sub_080AF090(this); + ProcessMovement3(this); if ((sub_080AB634(this) == 0) && (this->collisions != 0)) { CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); diff --git a/src/projectile/dekuSeedProjectile.c b/src/projectile/dekuSeedProjectile.c index 3afad118..785504ed 100644 --- a/src/projectile/dekuSeedProjectile.c +++ b/src/projectile/dekuSeedProjectile.c @@ -2,11 +2,6 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); -extern void sub_08016AD2(Entity*); -extern u32 IsColliding(Entity*, Entity*); - extern void (*const DekuSeedProjectile_Functions[])(Entity*); extern void (*const DekuSeedProjectile_Actions[])(Entity*); @@ -54,8 +49,8 @@ void DekuSeedProjectile_Action1(Entity* this) { Entity* parent; GetNextFrame(this); - if (sub_080AF090(this) != 0) { - if (IsProjectileOffScreen(this) != 0) { + if (ProcessMovement3(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } sub_08016AD2(this); @@ -75,20 +70,20 @@ void DekuSeedProjectile_Action1(Entity* this) { this->knockbackDirection = -this->direction; this->bitfield = 0x80; this->knockbackDuration = 0xc; - this->field_0x46 = 0; + this->knockbackSpeed = 0; parent->iframes = 0x10; parent->knockbackDirection = this->direction; parent->bitfield = 0xc2; parent->knockbackDuration = 0xc; - parent->field_0x46 = 0; + parent->knockbackSpeed = 0; } } } void DekuSeedProjectile_Action2(Entity* this) { GetNextFrame(this); - if (sub_080AF090(this) != 0) { - if (IsProjectileOffScreen(this) != 0) { + if (ProcessMovement3(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } if (--this->actionDelay == 0) { @@ -112,7 +107,7 @@ void DekuSeedProjectile_Action3(Entity* this) { void DekuSeedProjectile_Action4(Entity* this) { GetNextFrame(this); - sub_080AF090(this); + ProcessMovement3(this); switch (sub_080044EC(this, 0x2800)) { case 0: DeleteThisEntity(); diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index 03769bb0..bda5e1a2 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -28,7 +28,7 @@ void DirtBallProjectile_OnTick(Entity* this) { } void sub_080A881C(Entity* this) { - this->field_0x46 = 0; + this->knockbackSpeed = 0; if (this->type == 0) { this->parent->child = NULL; if (this->bitfield == 0x80) { diff --git a/src/projectile/fireProjectile.c b/src/projectile/fireProjectile.c index c44a9b89..80fed65b 100644 --- a/src/projectile/fireProjectile.c +++ b/src/projectile/fireProjectile.c @@ -3,10 +3,6 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); -extern void sub_08016AD2(Entity*); - extern void (*const FireProjectile_Actions[])(Entity*); void FireProjectile(Entity* this) { @@ -52,8 +48,8 @@ void FireProjectile_Action1(Entity* this) { void FireProjectile_Action2(Entity* this) { GetNextFrame(this); - if (sub_080AF090(this) != 0) { - if (IsProjectileOffScreen(this) != 0) { + if (ProcessMovement3(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { sub_08016AD2(this); diff --git a/src/projectile/guardLineOfSight.c b/src/projectile/guardLineOfSight.c index 909530b4..1dcdcaaf 100644 --- a/src/projectile/guardLineOfSight.c +++ b/src/projectile/guardLineOfSight.c @@ -5,7 +5,7 @@ #include "projectile.h" extern u32 sub_080644C8(Entity*); -extern Entity gUnk_02027EB4; +extern u8 gUnk_02027EB4[]; extern const Hitbox gUnk_080FD1E4; extern const u8 gUnk_081299C8[]; @@ -62,7 +62,7 @@ void GuardLineOfSight(Entity* this) { DeleteThisEntity(); } LinearMoveUpdate(this); - if (sub_080AE4CC(&gUnk_02027EB4, this->x.HALF.HI, this->y.HALF.HI, 2) != 0) { + if (IsTileCollision(gUnk_02027EB4, this->x.HALF.HI, this->y.HALF.HI, 2)) { DeleteThisEntity(); } } diff --git a/src/projectile/gyorgMaleEnergyProjectile.c b/src/projectile/gyorgMaleEnergyProjectile.c index f654133e..6a98e185 100644 --- a/src/projectile/gyorgMaleEnergyProjectile.c +++ b/src/projectile/gyorgMaleEnergyProjectile.c @@ -2,9 +2,7 @@ #include "enemy.h" #include "coord.h" #include "player.h" - -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); +#include "functions.h" extern void (*const GyorgMaleEnergyProjectile_Functions[])(Entity*); extern void (*const GyorgMaleEnergyProjectile_Actions[])(Entity*); @@ -72,9 +70,9 @@ void GyorgMaleEnergyProjectile_Action1(Entity* this) { } void GyorgMaleEnergyProjectile_Action2(Entity* this) { - sub_080AF090(this); + ProcessMovement3(this); GetNextFrame(this); - if (IsProjectileOffScreen(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } if (--this->actionDelay == 0) { @@ -86,7 +84,7 @@ void GyorgMaleEnergyProjectile_Action2(Entity* this) { } void GyorgMaleEnergyProjectile_Action3(Entity* this) { - sub_080AF090(this); + ProcessMovement3(this); GetNextFrame(this); if ((this->frame & 0x80) != 0) { DeleteThisEntity(); diff --git a/src/projectile/iceProjectile.c b/src/projectile/iceProjectile.c index 52364a53..0f845d8e 100644 --- a/src/projectile/iceProjectile.c +++ b/src/projectile/iceProjectile.c @@ -3,10 +3,6 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); -extern void sub_08016AD2(Entity*); - extern void (*const IceProjectile_Actions[])(Entity*); void IceProjectile(Entity* this) { @@ -54,8 +50,8 @@ void IceProjectile_Action1(Entity* this) { void IceProjectile_Action2(Entity* this) { GetNextFrame(this); - if (sub_080AF090(this) != 0) { - if (IsProjectileOffScreen(this) != 0) { + if (ProcessMovement3(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { sub_08016AD2(this); diff --git a/src/projectile/lakituLightning.c b/src/projectile/lakituLightning.c index e6bb2cef..1f366e0f 100644 --- a/src/projectile/lakituLightning.c +++ b/src/projectile/lakituLightning.c @@ -1,8 +1,6 @@ #include "entity.h" #include "enemy.h" - -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); +#include "functions.h" extern void (*const LakituLightning_Functions[])(Entity*); extern void (*const LakituLightning_Actions[])(Entity*); @@ -33,12 +31,12 @@ void LakituLightning_Init(Entity* this) { void LakituLightning_Action1(Entity* this) { GetNextFrame(this); - sub_080AF090(this); + ProcessMovement3(this); if ((this->collisions != 0) || (--this->actionDelay == 0)) { CreateFx(this, FX_BLUE_EFC, 0); DeleteThisEntity(); } - if (IsProjectileOffScreen(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } } diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index 26e2fe24..3dd794c3 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -25,7 +25,7 @@ void MandiblesProjectile(Entity* this) { if (entity == NULL) { entity = this->parent; } - if ((entity->field_0x43 == 0) && ((this->flags & ENT_COLLIDE) == 0)) { + if ((entity->confusedTime == 0) && ((this->flags & ENT_COLLIDE) == 0)) { COLLISION_ON(this); } MandiblesProjectile_Functions[GetNextFunction(this)](this); @@ -46,11 +46,11 @@ void sub_080A9EBC(Entity* this) { case 4: this->field_0xf = 0; ModHealth(-2); - sub_080AF090(this); + ProcessMovement3(this); UpdateAnimationSingleFrame(this); break; case 3: - if (this->field_0x43 != 0) { + if (this->confusedTime != 0) { this->field_0x82.HALF.LO = 2; this->animationState = 0xff; sub_080AA270(this); @@ -127,7 +127,7 @@ void MandiblesProjectile_Action3(Entity* this) { PositionRelative(entity, this, Q_16_16(tmp[0]), Q_16_16(tmp[1])); } } - if (entity->field_0x43 == 0) { + if (entity->confusedTime == 0) { if (this->field_0xf != 0) { this->field_0xf -= 1; } else { @@ -217,7 +217,7 @@ void sub_080AA1D8(Entity* this) { } else { PositionRelative(parent, this, Q_16_16(tmp[0]), Q_16_16(tmp[1])); } - if (parent->field_0x43 != 0) { + if (parent->confusedTime != 0) { if ((this->flags & ENT_COLLIDE) != 0) { COLLISION_OFF(this); } diff --git a/src/projectile/moblinSpear.c b/src/projectile/moblinSpear.c index 09decdd6..d2816076 100644 --- a/src/projectile/moblinSpear.c +++ b/src/projectile/moblinSpear.c @@ -28,7 +28,7 @@ void sub_080A832C(Entity* this) { if (this->bitfield == 0x80) { this->iframes = 0x10; this->knockbackDuration = 0xc; - this->field_0x46 = 0x180; + this->knockbackSpeed = 0x180; this->parent->bitfield = this->bitfield; } tmp = this->iframes; @@ -38,7 +38,7 @@ void sub_080A832C(Entity* this) { this->parent->iframes = -tmp; } this->parent->knockbackDuration = this->knockbackDuration; - this->parent->field_0x46 = this->field_0x46; + this->parent->knockbackSpeed = this->knockbackSpeed; this->parent->knockbackDirection = this->knockbackDirection; this->knockbackDuration = 0; } @@ -76,7 +76,7 @@ void MoblinSpear_Action1(Entity* this) { this->hitbox->offset_y = *a++; this->hitbox->width = *a++; this->hitbox->height = *a++; - if (parent->field_0x43 != 0) { + if (parent->confusedTime != 0) { if ((this->flags & ENT_COLLIDE) != 0) { COLLISION_OFF(this); } diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 49d4b40f..659f748c 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -103,7 +103,7 @@ void OctorokBossProjectile_Action1(Entity* this) { this->parent->iframes = 0x1e; if (this->parent->field_0x7c.BYTES.byte0 != 0) { this->parent->knockbackDuration = 0x18; - this->parent->field_0x46 = 0x200; + this->parent->knockbackSpeed = 0x200; this->parent->knockbackDirection = this->direction >> 3; } SoundReq(SFX_BOSS_HIT); @@ -113,7 +113,7 @@ void OctorokBossProjectile_Action1(Entity* this) { UpdateAnimationSingleFrame(this); this->field_0x78.HWORD--; LinearMoveAngle(this, this->speed, this->direction); - sub_080AE58C(this, this->direction >> 3, 0); + CalculateEntityTileCollisions(this, this->direction >> 3, 0); if ((this->collisions & 0xee00) != 0) { this->direction = -this->direction; } @@ -150,7 +150,7 @@ void OctorokBossProjectile_Action1(Entity* this) { } GetNextFrame(this); if (GravityUpdate(this, 0x1800) != 0) { - sub_080AE58C(this, this->direction >> 3, 0); + CalculateEntityTileCollisions(this, this->direction >> 3, 0); if (this->collisions == 0) { LinearMoveAngle(this, (s32)this->speed, (u32)this->direction); } else { diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c index 66e8388f..53266767 100644 --- a/src/projectile/rockProjectile.c +++ b/src/projectile/rockProjectile.c @@ -2,10 +2,6 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); -extern void sub_08016AD2(Entity*); - extern void (*const RockProjectile_Functions[])(Entity*); extern void (*const RockProjectile_Actions[])(Entity*); @@ -37,8 +33,8 @@ void RockProjectile_Init(Entity* this) { void RockProjectile_Action1(Entity* this) { GetNextFrame(this); - if (sub_080AF090(this) != 0) { - if (IsProjectileOffScreen(this) != 0) { + if (ProcessMovement3(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { sub_08016AD2(this); @@ -63,7 +59,7 @@ void RockProjectile_Action2(Entity* this) { void RockProjectile_Action3(Entity* this) { GetNextFrame(this); - sub_080AF090(this); + ProcessMovement3(this); switch (sub_080044EC(this, 0x2800)) { case 0: DeleteEntity(this); diff --git a/src/projectile/spikedRollers.c b/src/projectile/spikedRollers.c index 6c68133b..5a9c63bb 100644 --- a/src/projectile/spikedRollers.c +++ b/src/projectile/spikedRollers.c @@ -1,5 +1,6 @@ #define NENT_DEPRECATED #include "entity.h" +#include "functions.h" typedef struct { Entity base; @@ -11,8 +12,6 @@ typedef struct { u16 speed2; } SpikedRollersEntity; -extern s32 sub_080AF090(Entity*); - static void (*const SpikedRollers_Actions[])(SpikedRollersEntity*); static const u8 gSpikedRollersOffsets[]; @@ -49,7 +48,7 @@ void sub_080ABA74(SpikedRollersEntity* this) { void sub_080ABAE0(SpikedRollersEntity* this) { s32 diff, unk_0x6c; - sub_080AF090(super); + ProcessMovement3(super); if (super->type2 == 0) { diff = super->x.HALF.HI - this->x2; diff --git a/src/projectile/torchTrapProjectile.c b/src/projectile/torchTrapProjectile.c index 046d8062..5ff167c0 100644 --- a/src/projectile/torchTrapProjectile.c +++ b/src/projectile/torchTrapProjectile.c @@ -2,9 +2,6 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); - extern void (*const TorchTrapProjectile_Functions[])(Entity*); extern void (*const TorchTrapProjectile_Actions[])(Entity*); @@ -31,7 +28,7 @@ void TorchTrapProjectile_Action1(Entity* this) { if (this->actionDelay != 0) { this->actionDelay -= 1; } else { - if (sub_080AF090(this) == 0) { + if (ProcessMovement3(this) == 0) { LinearMoveUpdate(this); } else { this->action = 2; @@ -41,11 +38,11 @@ void TorchTrapProjectile_Action1(Entity* this) { void TorchTrapProjectile_Action2(Entity* this) { GetNextFrame(this); - sub_080AF090(this); + ProcessMovement3(this); if (this->collisions != 0) { DeleteThisEntity(); } - if (IsProjectileOffScreen(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } } diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index fc863d53..e329945c 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -10,11 +10,6 @@ extern void (*const gUnk_0812A7F8[])(Entity*); extern void (*const gUnk_0812A800[])(Entity*); extern void (*const gUnk_0812A808[])(Entity*); -extern void SoundReqClipped(Entity*, u32); -extern void sub_08079D84(void); - -extern s32 sub_080AF090(Entity*); - void V2Projectile(Entity* this) { V2Projectile_Functions[GetNextFunction(this)](this); } @@ -108,7 +103,7 @@ void sub_080ABD44(Entity* this) { this->action = 2; InitializeAnimation(this, 1); } - sub_080AF090(this); + ProcessMovement3(this); GetNextFrame(this); } diff --git a/src/projectile/v3ElectricProjectile.c b/src/projectile/v3ElectricProjectile.c index e83e68f7..c52258cd 100644 --- a/src/projectile/v3ElectricProjectile.c +++ b/src/projectile/v3ElectricProjectile.c @@ -4,9 +4,6 @@ #include "coord.h" #include "functions.h" -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); - extern void (*const V3ElectricProjectile_Functions[])(Entity*); extern void (*const V3ElectricProjectile_Actions[])(Entity*); static const u16 projectileSpeeds[]; @@ -98,12 +95,12 @@ void V3ElectricProjectile_Action2(Entity* this) { if (this->z.HALF.HI < -6) { this->z.HALF.HI += 3; } - sub_080AF090(this); + ProcessMovement3(this); if (this->collisions != 0) { DeleteThisEntity(); } GetNextFrame(this); - if (IsProjectileOffScreen(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } if (this->actionDelay < 0x1e) { diff --git a/src/projectile/v3HandProjectile.c b/src/projectile/v3HandProjectile.c index d308b7d9..4d4c55bf 100644 --- a/src/projectile/v3HandProjectile.c +++ b/src/projectile/v3HandProjectile.c @@ -1,9 +1,7 @@ #include "entity.h" #include "enemy.h" #include "player.h" - -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); +#include "functions.h" extern void (*const V3HandProjectile_Functions[])(Entity*); @@ -21,12 +19,12 @@ void V3HandProjectile_OnTick(Entity* this) { if (this->z.HALF.HI < -6) { this->z.HALF.HI += 2; } - sub_080AF090(this); + ProcessMovement3(this); if (this->collisions != 0) { DeleteThisEntity(); } GetNextFrame(this); - if (IsProjectileOffScreen(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } } diff --git a/src/projectile/v3TennisBallProjectile.c b/src/projectile/v3TennisBallProjectile.c index b25cbf48..455f67af 100644 --- a/src/projectile/v3TennisBallProjectile.c +++ b/src/projectile/v3TennisBallProjectile.c @@ -1,8 +1,6 @@ #include "entity.h" #include "enemy.h" - -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); +#include "functions.h" extern void (*const V3TennisBallProjectile_Functions[])(Entity*); extern void (*const V3TennisBallProjectile_Actions[])(Entity*); @@ -55,21 +53,21 @@ void V3TennisBallProjectile_Init(Entity* this) { } void V3TennisBallProjectile_Action1(Entity* this) { - sub_080AF090(this); + ProcessMovement3(this); GetNextFrame(this); - if (IsProjectileOffScreen(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } } void V3TennisBallProjectile_Action2(Entity* this) { - sub_080AF090(this); + ProcessMovement3(this); if (this->collisions != 0) { DeleteThisEntity(); } GetNextFrame(this); sub_080ACB90(this); - if (IsProjectileOffScreen(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteThisEntity(); } } diff --git a/src/projectile/windProjectile.c b/src/projectile/windProjectile.c index b5b1133b..96211f1b 100644 --- a/src/projectile/windProjectile.c +++ b/src/projectile/windProjectile.c @@ -2,10 +2,6 @@ #include "enemy.h" #include "functions.h" -extern s32 sub_080AF090(Entity*); -extern s32 IsProjectileOffScreen(Entity*); -extern void sub_08016AD2(Entity*); - extern void (*const WindProjectile_Actions[])(Entity*); void WindProjectile(Entity* this) { @@ -58,8 +54,8 @@ void WindProjectile_Action1(Entity* this) { void WindProjectile_Action2(Entity* this) { GetNextFrame(this); - if (sub_080AF090(this) != 0) { - if (IsProjectileOffScreen(this) != 0) { + if (ProcessMovement3(this) != 0) { + if (IsProjectileOffScreen(this)) { DeleteEntity(this); } else { sub_08016AD2(this); diff --git a/src/projectile/winder.c b/src/projectile/winder.c index 4af9fc9c..bbc49d0d 100644 --- a/src/projectile/winder.c +++ b/src/projectile/winder.c @@ -6,7 +6,6 @@ extern void (*const Winder_Actions[])(Entity*); extern s16 gUnk_080B4488[]; -extern u8* GetLayerByIndex(u32); static const u8 gUnk_0812A6BC[]; static const u16 gUnk_0812A6C4[]; @@ -51,7 +50,7 @@ void Winder_Init(Entity* this) { void sub_080AB950(Entity* this) { if (this->type == 0) { u8 dir; - ProcessMovement(this); + ProcessMovement0(this); dir = this->direction >> 3; if (((gUnk_0812A6C4)[dir] & this->collisions) || sub_080AB9FC(this, this->direction)) { this->direction = gUnk_0812A6BC[(Random() & 0x1) + (dir << 1)]; @@ -87,14 +86,12 @@ void sub_080AB9DC(Entity* this) { bool32 sub_080AB9FC(Entity* this, u32 dir) { u32 val; - u8* layer = GetLayerByIndex(this->collisionLayer); + LayerStruct* layer = GetLayerByIndex(this->collisionLayer); u32 tmp; val = (((this->x.HALF.HI - gRoomControls.origin_x) >> 4) & 0x3f) | ((((this->y.HALF.HI - gRoomControls.origin_y) >> 4) & 0x3f) << 6); val += gUnk_080B4488[dir >> 3]; - layer += 0x2004; - layer += val; - tmp = *layer; + tmp = layer->_2004[val]; if (tmp <= 0x1f) { return 0; } diff --git a/src/roomInit.c b/src/roomInit.c index 0d5e6486..a3b3d970 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -2536,12 +2536,10 @@ u32 sub_unk3_CaveOfFlamesBoss_Main(void) { extern EntityData gUnk_additional_a_CaveOfFlamesBoss_Main; -extern u32 gUnk_0200B650; - void sub_StateChange_CaveOfFlamesBoss_Main(void) { if (CheckGlobalFlag(LV2_CLEAR)) { - gUnk_0200B650 = 0; + gMapTop.bgControlPtr = 0; gScreen.lcd.displayControl &= ~DISPCNT_BG1_ON; sub_0807AABC(&gPlayerEntity); LoadRoomEntityList(&gUnk_additional_a_CaveOfFlamesBoss_Main); diff --git a/src/scroll.c b/src/scroll.c index de61b0ec..7f8b99f8 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -3,11 +3,10 @@ #include "structures.h" #include "functions.h" #include "game.h" +#include "map.h" extern void sub_08080BC4(void); -extern u32 gUnk_0200B650; -extern u32 gUnk_02025EB0; extern u8 gUpdateVisibleTiles; void sub_080808D8(void) { @@ -43,11 +42,11 @@ void sub_08080930(void) { SetInitializationPriority(); } -u32* GetLayerByIndex(u32 param_1) { +LayerStruct* GetLayerByIndex(u32 param_1) { if (param_1 == 2) { - return &gUnk_0200B650; + return &gMapTop; } else { - return &gUnk_02025EB0; + return &gMapBottom; } }