Decompile cuccoAggr

This commit is contained in:
Tal Hayon 2022-01-28 20:14:47 +02:00
parent fd9049f598
commit ef103fd121
5 changed files with 385 additions and 889 deletions

View File

@ -1,794 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start CuccoAggr
CuccoAggr: @ 0x08038CA4
push {r4, r5, lr}
adds r5, r0, #0
bl sub_080012DC
adds r1, r0, #0
cmp r1, #0
beq _08038CC8
ldr r0, _08038CC4 @ =gUnk_080012C8
lsls r1, r1, #2
adds r1, r1, r0
ldr r1, [r1]
adds r0, r5, #0
bl _call_via_r1
b _08038CF0
.align 2, 0
_08038CC4: .4byte gUnk_080012C8
_08038CC8:
ldr r4, _08038CF4 @ =gUnk_080CF778
adds r0, r5, #0
bl GetNextFunction
lsls r0, r0, #2
adds r0, r0, r4
ldr r1, [r0]
adds r0, r5, #0
bl _call_via_r1
movs r3, #0x10
rsbs r3, r3, #0
adds r0, r5, #0
movs r1, #0
movs r2, #1
bl SetChildOffset
adds r0, r5, #0
bl sub_080391B4
_08038CF0:
pop {r4, r5, pc}
.align 2, 0
_08038CF4: .4byte gUnk_080CF778
thumb_func_start sub_08038CF8
sub_08038CF8: @ 0x08038CF8
push {lr}
ldr r2, _08038D0C @ =gUnk_080CF790
ldrb r1, [r0, #0xc]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_08038D0C: .4byte gUnk_080CF790
thumb_func_start sub_08038D10
sub_08038D10: @ 0x08038D10
push {r4, r5, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xa]
cmp r0, #2
beq _08038D52
adds r5, r4, #0
adds r5, #0x7a
ldrb r0, [r5]
cmp r0, #0
bne _08038D3E
movs r0, #1
bl CheckRoomFlag
cmp r0, #0
bne _08038D3E
adds r0, r4, #0
adds r0, #0x45
ldrb r0, [r0]
cmp r0, #0xbf
bhi _08038D46
movs r0, #1
strb r0, [r5]
b _08038D46
_08038D3E:
adds r1, r4, #0
adds r1, #0x45
movs r0, #0xff
strb r0, [r1]
_08038D46:
adds r0, r4, #0
bl sub_08039218
adds r0, r4, #0
bl sub_08039260
_08038D52:
adds r0, r4, #0
adds r0, #0x43
ldrb r0, [r0]
cmp r0, #0
beq _08038D64
adds r0, r4, #0
movs r1, #0x1c
bl sub_0804A9FC
_08038D64:
ldr r1, _08038D70 @ =gUnk_080CF778
adds r0, r4, #0
bl sub_0804AA30
pop {r4, r5, pc}
.align 2, 0
_08038D70: .4byte gUnk_080CF778
thumb_func_start nullsub_165
nullsub_165: @ 0x08038D74
bx lr
.align 2, 0
thumb_func_start sub_08038D78
sub_08038D78: @ 0x08038D78
push {r4, lr}
adds r4, r0, #0
bl sub_0804A720
ldrb r0, [r4, #0xa]
cmp r0, #2
beq _08038D96
movs r0, #0
strb r0, [r4, #0xb]
movs r0, #0x30
strb r0, [r4, #0x16]
adds r0, r4, #0
bl sub_08039120
b _08038D9C
_08038D96:
adds r0, r4, #0
bl sub_08039140
_08038D9C:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08038DA0
sub_08038DA0: @ 0x08038DA0
push {r4, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xe]
subs r0, #1
strb r0, [r4, #0xe]
lsls r0, r0, #0x18
cmp r0, #0
bne _08038DB6
adds r0, r4, #0
bl sub_0803901C
_08038DB6:
adds r0, r4, #0
bl sub_08039298
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08038DC0
sub_08038DC0: @ 0x08038DC0
push {lr}
ldr r2, _08038DD4 @ =gUnk_080CF7AC
ldrb r1, [r0, #0xd]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_08038DD4: .4byte gUnk_080CF7AC
thumb_func_start sub_08038DD8
sub_08038DD8: @ 0x08038DD8
push {lr}
movs r1, #1
strb r1, [r0, #0xd]
movs r1, #0x10
strb r1, [r0, #0xe]
ldr r2, _08038E10 @ =gUnk_080CF7BC
ldrb r1, [r0, #0xa]
adds r1, r1, r2
ldrb r1, [r1]
strb r1, [r0, #0xf]
ldrb r2, [r0, #0x10]
movs r1, #0x7f
ands r1, r2
strb r1, [r0, #0x10]
adds r3, r0, #0
adds r3, #0x29
ldrb r2, [r3]
movs r1, #0x39
rsbs r1, r1, #0
ands r1, r2
strb r1, [r3]
movs r1, #4
bl InitializeAnimation
ldr r0, _08038E14 @ =0x000001D9
bl EnqueueSFX
pop {pc}
.align 2, 0
_08038E10: .4byte gUnk_080CF7BC
_08038E14: .4byte 0x000001D9
thumb_func_start sub_08038E18
sub_08038E18: @ 0x08038E18
push {r4, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xf]
cmp r0, #0
beq _08038E70
subs r0, #1
strb r0, [r4, #0xf]
lsls r0, r0, #0x18
cmp r0, #0
bne _08038E70
bl sub_08079184
adds r0, r4, #0
bl sub_08039218
ldrb r0, [r4, #0x10]
movs r1, #0x80
orrs r0, r1
strb r0, [r4, #0x10]
adds r2, r4, #0
adds r2, #0x29
ldrb r1, [r2]
movs r0, #0x39
rsbs r0, r0, #0
ands r0, r1
movs r1, #8
orrs r0, r1
movs r1, #8
rsbs r1, r1, #0
ands r0, r1
movs r1, #4
orrs r0, r1
strb r0, [r2]
bl Random
movs r1, #0x1f
ands r0, r1
strb r0, [r4, #0x15]
adds r0, r4, #0
bl ProcessMovement
adds r0, r4, #0
bl UpdateSpriteForCollisionLayer
_08038E70:
ldrb r0, [r4, #0xe]
subs r0, #1
strb r0, [r4, #0xe]
lsls r0, r0, #0x18
cmp r0, #0
bne _08038EA2
movs r0, #0x10
strb r0, [r4, #0xe]
bl Random
ldrb r3, [r4, #0x18]
lsls r2, r3, #0x19
lsrs r2, r2, #0x1f
movs r1, #1
ands r1, r0
eors r2, r1
lsls r2, r2, #6
movs r0, #0x41
rsbs r0, r0, #0
ands r0, r3
orrs r0, r2
strb r0, [r4, #0x18]
adds r0, r4, #0
bl sub_08039260
_08038EA2:
adds r0, r4, #0
bl GetNextFrame
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08038EAC
sub_08038EAC: @ 0x08038EAC
push {r4, lr}
adds r4, r0, #0
adds r2, r4, #0
adds r2, #0x29
ldrb r1, [r2]
movs r0, #0x39
rsbs r0, r0, #0
ands r0, r1
movs r1, #8
orrs r0, r1
strb r0, [r2]
adds r0, r4, #0
bl sub_080390F8
adds r0, r4, #0
bl GetNextFrame
pop {r4, pc}
thumb_func_start sub_08038ED0
sub_08038ED0: @ 0x08038ED0
push {lr}
ldrb r2, [r0, #0x10]
movs r1, #0x80
orrs r1, r2
strb r1, [r0, #0x10]
bl sub_08039218
pop {pc}
thumb_func_start sub_08038EE0
sub_08038EE0: @ 0x08038EE0
push {r4, lr}
adds r4, r0, #0
bl ProcessMovement
adds r0, r4, #0
bl GetNextFrame
adds r0, r4, #0
bl sub_08039298
movs r1, #0xe0
lsls r1, r1, #5
adds r0, r4, #0
bl GravityUpdate
cmp r0, #0
bne _08038F1C
ldrb r0, [r4, #0xe]
subs r0, #1
strb r0, [r4, #0xe]
lsls r0, r0, #0x18
cmp r0, #0
bne _08038F16
adds r0, r4, #0
bl sub_0803901C
b _08038F1C
_08038F16:
movs r0, #0x80
lsls r0, r0, #8
str r0, [r4, #0x20]
_08038F1C:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08038F20
sub_08038F20: @ 0x08038F20
push {r4, lr}
adds r4, r0, #0
bl sub_08039298
adds r0, r4, #0
bl GetNextFrame
adds r0, r4, #0
adds r0, #0x5a
ldrb r1, [r0]
movs r0, #0x80
ands r0, r1
cmp r0, #0
beq _08038F42
adds r0, r4, #0
bl sub_0803901C
_08038F42:
pop {r4, pc}
thumb_func_start sub_08038F44
sub_08038F44: @ 0x08038F44
push {r4, lr}
adds r4, r0, #0
ldr r0, _08038F8C @ =gPlayerEntity
adds r1, r4, #0
bl GetFacingDirection
strb r0, [r4, #0x15]
adds r0, r4, #0
bl sub_080390F8
adds r0, r4, #0
bl ProcessMovement
movs r1, #0xc0
lsls r1, r1, #5
adds r0, r4, #0
bl sub_080044EC
adds r0, r4, #0
bl GetNextFrame
adds r0, r4, #0
bl sub_08039298
adds r1, r4, #0
adds r1, #0x78
ldrh r0, [r1]
subs r2, r0, #1
strh r2, [r1]
lsls r0, r2, #0x10
cmp r0, #0
bne _08038F90
adds r0, r4, #0
bl sub_08039120
b _08038F9E
.align 2, 0
_08038F8C: .4byte gPlayerEntity
_08038F90:
movs r0, #0x1f
ands r2, r0
cmp r2, #0
bne _08038F9E
adds r0, r4, #0
bl sub_08039260
_08038F9E:
pop {r4, pc}
thumb_func_start sub_08038FA0
sub_08038FA0: @ 0x08038FA0
push {r4, lr}
adds r4, r0, #0
ldrb r1, [r4, #0xe]
adds r0, r1, #1
strb r0, [r4, #0xe]
movs r0, #0x1f
ands r0, r1
cmp r0, #0
bne _08038FB8
adds r0, r4, #0
bl sub_08039260
_08038FB8:
adds r2, r4, #0
adds r2, #0x78
ldrh r1, [r2]
cmp r1, #0
beq _08038FFC
ldr r3, _08038FF4 @ =0x0000FFFF
adds r0, r1, r3
strh r0, [r2]
movs r0, #7
ands r0, r1
cmp r0, #0
bne _08038FE0
ldr r1, _08038FF8 @ =gPlayerEntity
adds r0, r4, #0
bl GetFacingDirection
adds r1, r0, #0
adds r0, r4, #0
bl sub_08004596
_08038FE0:
adds r0, r4, #0
bl sub_080390F8
adds r0, r4, #0
bl LinearMoveUpdate
adds r0, r4, #0
bl GetNextFrame
b _08039018
.align 2, 0
_08038FF4: .4byte 0x0000FFFF
_08038FF8: .4byte gPlayerEntity
_08038FFC:
adds r0, r4, #0
bl LinearMoveUpdate
adds r0, r4, #0
bl GetNextFrame
adds r0, r4, #0
bl sub_0803917C
cmp r0, #0
beq _08039018
adds r0, r4, #0
bl DeleteEntity
_08039018:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_0803901C
sub_0803901C: @ 0x0803901C
push {r4, r5, lr}
adds r4, r0, #0
bl Random
adds r3, r0, #0
movs r5, #3
ands r5, r3
cmp r3, #3
bne _08039042
ldrb r0, [r4, #0xc]
cmp r0, #3
beq _0803903C
cmp r0, #4
beq _08039040
movs r5, #0
b _08039042
_0803903C:
movs r5, #1
b _08039042
_08039040:
movs r5, #2
_08039042:
cmp r5, #1
beq _0803906C
cmp r5, #2
beq _080390AA
movs r0, #1
strb r0, [r4, #0xc]
ldr r2, _08039068 @ =gUnk_080CF7BE
lsrs r0, r3, #0x10
movs r1, #3
ands r0, r1
adds r0, r0, r2
ldrb r0, [r0]
strb r0, [r4, #0xe]
adds r0, r4, #0
movs r1, #0
bl InitializeAnimation
b _080390BC
.align 2, 0
_08039068: .4byte gUnk_080CF7BE
_0803906C:
movs r1, #3
movs r0, #3
strb r0, [r4, #0xc]
lsrs r0, r3, #8
ands r0, r1
adds r0, #2
strb r0, [r4, #0xe]
movs r0, #0x80
lsls r0, r0, #8
str r0, [r4, #0x20]
adds r0, r4, #0
bl sub_080390C0
adds r0, r4, #0
movs r1, #1
bl InitializeAnimation
bl Random
ands r0, r5
cmp r0, #0
beq _080390BC
bl Random
ands r5, r0
movs r1, #0xeb
lsls r1, r1, #1
adds r0, r5, r1
bl EnqueueSFX
b _080390BC
_080390AA:
movs r0, #4
strb r0, [r4, #0xc]
lsrs r1, r3, #0x10
movs r0, #1
ands r1, r0
adds r1, #2
adds r0, r4, #0
bl InitializeAnimation
_080390BC:
pop {r4, r5, pc}
.align 2, 0
thumb_func_start sub_080390C0
sub_080390C0: @ 0x080390C0
push {r4, r5, lr}
adds r4, r0, #0
bl Random
adds r5, r0, #0
adds r0, r4, #0
bl sub_08049FA0
cmp r0, #0
beq _080390E0
movs r0, #1
ands r0, r5
cmp r0, #0
beq _080390E0
lsrs r0, r5, #0x10
b _080390E8
_080390E0:
adds r0, r4, #0
bl sub_08049EE4
adds r0, #2
_080390E8:
movs r1, #0x1c
ands r0, r1
strb r0, [r4, #0x15]
adds r0, r4, #0
bl sub_080390F8
pop {r4, r5, pc}
.align 2, 0
thumb_func_start sub_080390F8
sub_080390F8: @ 0x080390F8
push {lr}
adds r3, r0, #0
ldrb r1, [r3, #0x15]
movs r0, #0xf
ands r0, r1
cmp r0, #0
beq _0803911C
lsrs r1, r1, #4
movs r0, #1
eors r1, r0
ands r1, r0
lsls r1, r1, #6
ldrb r2, [r3, #0x18]
movs r0, #0x41
rsbs r0, r0, #0
ands r0, r2
orrs r0, r1
strb r0, [r3, #0x18]
_0803911C:
pop {pc}
.align 2, 0
thumb_func_start sub_08039120
sub_08039120: @ 0x08039120
push {lr}
ldr r2, _0803913C @ =gUnk_080CF7C2
ldrb r1, [r0, #0xa]
adds r1, r1, r2
ldrb r1, [r1]
movs r2, #0
strh r1, [r0, #0x24]
adds r1, r0, #0
adds r1, #0x7a
strb r2, [r1]
bl sub_0803901C
pop {pc}
.align 2, 0
_0803913C: .4byte gUnk_080CF7C2
thumb_func_start sub_08039140
sub_08039140: @ 0x08039140
push {r4, lr}
adds r4, r0, #0
movs r0, #6
strb r0, [r4, #0xc]
bl Random
strb r0, [r4, #0xe]
ldr r1, _08039174 @ =gPlayerEntity
adds r0, r4, #0
bl GetFacingDirection
strb r0, [r4, #0x15]
ldr r0, _08039178 @ =0x0000FFFC
strh r0, [r4, #0x36]
adds r1, r4, #0
adds r1, #0x78
movs r0, #0xb4
strh r0, [r1]
adds r0, r4, #0
bl sub_080390F8
adds r0, r4, #0
movs r1, #4
bl InitializeAnimation
pop {r4, pc}
.align 2, 0
_08039174: .4byte gPlayerEntity
_08039178: .4byte 0x0000FFFC
thumb_func_start sub_0803917C
sub_0803917C: @ 0x0803917C
push {r4, lr}
adds r2, r0, #0
movs r1, #0x2e
ldrsh r0, [r2, r1]
ldr r3, _080391AC @ =gRoomControls
movs r4, #0xa
ldrsh r1, [r3, r4]
adds r1, #0xc
subs r0, r0, r1
movs r1, #0x84
lsls r1, r1, #1
cmp r0, r1
bhi _080391B0
movs r0, #0x32
ldrsh r1, [r2, r0]
movs r2, #0xc
ldrsh r0, [r3, r2]
adds r0, #0xc
subs r1, r1, r0
cmp r1, #0xb8
bhi _080391B0
movs r0, #0
b _080391B2
.align 2, 0
_080391AC: .4byte gRoomControls
_080391B0:
movs r0, #1
_080391B2:
pop {r4, pc}
thumb_func_start sub_080391B4
sub_080391B4: @ 0x080391B4
push {r4, r5, lr}
adds r5, r0, #0
adds r0, #0x7a
ldrb r0, [r0]
cmp r0, #0
beq _0803920C
adds r2, r5, #0
adds r2, #0x7b
ldrb r1, [r2]
adds r0, r1, #1
strb r0, [r2]
movs r0, #0x1f
ands r0, r1
cmp r0, #0
bne _0803920C
movs r0, #0x41
movs r1, #2
bl CreateEnemy
adds r4, r0, #0
cmp r4, #0
beq _0803920C
bl Random
movs r1, #0x17
ands r1, r0
lsls r1, r1, #2
ldr r0, _08039210 @ =gUnk_080CF7C4
adds r1, r1, r0
ldr r2, _08039214 @ =gRoomControls
ldrh r0, [r1]
ldrh r3, [r2, #0xa]
adds r0, r0, r3
strh r0, [r4, #0x2e]
ldrh r0, [r1, #2]
ldrh r2, [r2, #0xc]
adds r0, r0, r2
strh r0, [r4, #0x32]
adds r0, r5, #0
adds r0, #0x38
ldrb r1, [r0]
adds r0, r4, #0
adds r0, #0x38
strb r1, [r0]
_0803920C:
pop {r4, r5, pc}
.align 2, 0
_08039210: .4byte gUnk_080CF7C4
_08039214: .4byte gRoomControls
thumb_func_start sub_08039218
sub_08039218: @ 0x08039218
push {lr}
adds r2, r0, #0
movs r0, #5
strb r0, [r2, #0xc]
ldr r1, _08039254 @ =gUnk_080CF824
ldrb r0, [r2, #0xa]
lsls r0, r0, #1
adds r0, r0, r1
ldrh r0, [r0]
strh r0, [r2, #0x24]
ldr r1, _08039258 @ =gUnk_080CF828
ldrb r0, [r2, #0xa]
lsls r0, r0, #1
adds r0, r0, r1
ldrh r1, [r0]
adds r0, r2, #0
adds r0, #0x78
strh r1, [r0]
subs r0, #0x20
ldrb r0, [r0]
cmp r0, #4
beq _0803924C
adds r0, r2, #0
movs r1, #4
bl InitializeAnimation
_0803924C:
ldr r0, _0803925C @ =0x000001D9
bl EnqueueSFX
pop {pc}
.align 2, 0
_08039254: .4byte gUnk_080CF824
_08039258: .4byte gUnk_080CF828
_0803925C: .4byte 0x000001D9
thumb_func_start sub_08039260
sub_08039260: @ 0x08039260
push {r4, lr}
adds r4, r0, #0
ldr r0, _08039290 @ =gUnk_080CF82E
ldrb r1, [r4, #0xa]
adds r1, r1, r0
ldrb r1, [r1]
adds r0, r4, #0
movs r2, #0
bl CreateFx
adds r2, r0, #0
cmp r2, #0
beq _0803928E
ldr r0, _08039294 @ =gUnk_080CF82C
ldrb r1, [r4, #0x18]
lsls r1, r1, #0x19
lsrs r1, r1, #0x1f
adds r1, r1, r0
movs r0, #0
ldrsb r0, [r1, r0]
ldrh r1, [r2, #0x2e]
adds r0, r0, r1
strh r0, [r2, #0x2e]
_0803928E:
pop {r4, pc}
.align 2, 0
_08039290: .4byte gUnk_080CF82E
_08039294: .4byte gUnk_080CF82C
thumb_func_start sub_08039298
sub_08039298: @ 0x08039298
push {lr}
adds r1, r0, #0
ldrb r0, [r1, #0xb]
cmp r0, #0
bne _080392A8
adds r0, r1, #0
bl sub_08078930
_080392A8:
pop {pc}
.align 2, 0

View File

@ -26627,46 +26627,6 @@
"size": 17,
"type": "animation"
},
{
"path": "cuccoAggr/gUnk_080CF7BC.bin",
"start": 849852,
"size": 2
},
{
"path": "cuccoAggr/gUnk_080CF7BE.bin",
"start": 849854,
"size": 4
},
{
"path": "cuccoAggr/gUnk_080CF7C2.bin",
"start": 849858,
"size": 2
},
{
"path": "cuccoAggr/gUnk_080CF7C4.bin",
"start": 849860,
"size": 96
},
{
"path": "cuccoAggr/gUnk_080CF824.bin",
"start": 849956,
"size": 4
},
{
"path": "cuccoAggr/gUnk_080CF828.bin",
"start": 849960,
"size": 4
},
{
"path": "cuccoAggr/gUnk_080CF82C.bin",
"start": 849964,
"size": 2
},
{
"path": "cuccoAggr/gUnk_080CF82E.bin",
"start": 849966,
"size": 3
},
{
"path": "animations/gSpriteAnimations_Stalfos_0.bin",
"start": 850242,

View File

@ -1,53 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_080CF778:: @ 080CF778
.4byte sub_08038CF8
.4byte sub_08038D10
.4byte sub_08001324
.4byte sub_0804A7D4
.4byte sub_08001242
.4byte nullsub_165
gUnk_080CF790:: @ 080CF790
.4byte sub_08038D78
.4byte sub_08038DA0
.4byte sub_08038DC0
.4byte sub_08038EE0
.4byte sub_08038F20
.4byte sub_08038F44
.4byte sub_08038FA0
gUnk_080CF7AC:: @ 080CF7AC
.4byte sub_08038DD8
.4byte sub_08038E18
.4byte sub_08038EAC
.4byte sub_08038ED0
gUnk_080CF7BC:: @ 080CF7BC
.incbin "cuccoAggr/gUnk_080CF7BC.bin"
gUnk_080CF7BE:: @ 080CF7BE
.incbin "cuccoAggr/gUnk_080CF7BE.bin"
gUnk_080CF7C2:: @ 080CF7C2
.incbin "cuccoAggr/gUnk_080CF7C2.bin"
gUnk_080CF7C4:: @ 080CF7C4
.incbin "cuccoAggr/gUnk_080CF7C4.bin"
gUnk_080CF824:: @ 080CF824
.incbin "cuccoAggr/gUnk_080CF824.bin"
gUnk_080CF828:: @ 080CF828
.incbin "cuccoAggr/gUnk_080CF828.bin"
gUnk_080CF82C:: @ 080CF82C
.incbin "cuccoAggr/gUnk_080CF82C.bin"
gUnk_080CF82E:: @ 080CF82E
.incbin "cuccoAggr/gUnk_080CF82E.bin"

View File

@ -388,7 +388,7 @@ SECTIONS {
src/enemy/ropeGolden.o(.text);
asm/enemy/cloudPiranha.o(.text);
asm/enemy/scissorsBeetle.o(.text);
asm/enemy/cuccoAggr.o(.text);
src/enemy/cuccoAggr.o(.text);
asm/enemy/stalfos.o(.text);
src/enemy/flyingSkull.o(.text);
src/enemy/mazaalBracelet.o(.text);
@ -1057,7 +1057,7 @@ SECTIONS {
data/animations/enemy/cloudPiranha.o(.rodata);
data/const/enemy/scissorsBeetle.o(.rodata);
data/animations/enemy/scissorsBeetle.o(.rodata);
data/const/enemy/cuccoAggr.o(.rodata);
src/enemy/cuccoAggr.o(.rodata);
data/animations/enemy/cuccoAggr.o(.rodata);
data/const/enemy/stalfos.o(.rodata);
data/animations/enemy/stalfos.o(.rodata);

383
src/enemy/cuccoAggr.c Normal file
View File

@ -0,0 +1,383 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "functions.h"
typedef struct {
Entity base;
u8 filler[0x10];
u16 unk_78;
u8 unk_7a;
u8 unk_7b;
} CuccoAggrEntity;
extern void (*const gUnk_080012C8[])(Entity*);
typedef struct {
u16 x;
u16 y;
} PosOffset;
void (*const gUnk_080CF778[])(Entity*);
void (*const gUnk_080CF790[])(CuccoAggrEntity*);
void (*const gUnk_080CF7AC[])(CuccoAggrEntity*);
const u8 gUnk_080CF7BC[];
const u8 gUnk_080CF7BE[];
const u8 gUnk_080CF7C2[];
const PosOffset gCuccoAggrSpawnPoints[];
const u16 gUnk_080CF824[];
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 CuccoAggr(Entity* this) {
u32 index = sub_080012DC(this);
if (index) {
gUnk_080012C8[index](this);
} else {
gUnk_080CF778[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
sub_080391B4((CuccoAggrEntity*)this);
}
}
void sub_08038CF8(CuccoAggrEntity* this) {
gUnk_080CF790[super->action](this);
}
void sub_08038D10(CuccoAggrEntity* this) {
if (super->type != 2) {
if (this->unk_7a == 0 && CheckRoomFlag(1) == 0) {
if (super->health <= 0xbf) {
this->unk_7a = 1;
}
} else {
super->health = 0xff;
}
sub_08039218(this);
CuccoAggr_CreateFx(this);
}
if (super->field_0x43) {
sub_0804A9FC(super, 0x1c);
}
sub_0804AA30(super, gUnk_080CF778);
}
void nullsub_165(CuccoAggrEntity* this) {
}
void sub_08038D78(CuccoAggrEntity* this) {
sub_0804A720(super);
if (super->type != 2) {
super->type2 = 0;
super->field_0x16 = 0x30;
sub_08039120(this);
} else {
sub_08039140(this);
}
}
void sub_08038DA0(CuccoAggrEntity* this) {
if (--super->actionDelay == 0) {
sub_0803901C(this);
}
sub_08039298(this);
}
void sub_08038DC0(CuccoAggrEntity* this) {
gUnk_080CF7AC[super->subAction](this);
}
void sub_08038DD8(CuccoAggrEntity* this) {
super->subAction = 1;
super->actionDelay = 0x10;
super->field_0xf = gUnk_080CF7BC[super->type];
COLLISION_OFF(super);
super->spritePriority.b1 = 0;
InitializeAnimation(super, 4);
EnqueueSFX(SFX_VO_CUCCO4);
}
void sub_08038E18(CuccoAggrEntity* this) {
if (super->field_0xf) {
if (--super->field_0xf == 0) {
sub_08079184();
sub_08039218(this);
COLLISION_ON(super);
super->spritePriority.b1 = 1;
super->spritePriority.b0 = 4;
super->direction = Random() & 0x1f;
ProcessMovement(super);
UpdateSpriteForCollisionLayer(super);
}
}
if (--super->actionDelay == 0) {
super->actionDelay = 0x10;
super->spriteSettings.flipX ^= (Random() & 1);
CuccoAggr_CreateFx(this);
}
GetNextFrame(super);
}
void sub_08038EAC(CuccoAggrEntity* this) {
super->spritePriority.b1 = 1;
sub_080390F8(this);
GetNextFrame(super);
}
void sub_08038ED0(CuccoAggrEntity* this) {
COLLISION_ON(super);
sub_08039218(this);
}
void sub_08038EE0(CuccoAggrEntity* this) {
ProcessMovement(super);
GetNextFrame(super);
sub_08039298(this);
if (GravityUpdate(super, 0x1C00) == 0) {
if (--super->actionDelay == 0) {
sub_0803901C(this);
} else {
super->zVelocity = 0x8000;
}
}
}
void sub_08038F20(CuccoAggrEntity* this) {
sub_08039298(this);
GetNextFrame(super);
if (super->frame & 0x80) {
sub_0803901C(this);
}
}
void sub_08038F44(CuccoAggrEntity* this) {
super->direction = GetFacingDirection(&gPlayerEntity, super);
sub_080390F8(this);
ProcessMovement(super);
sub_080044EC(super, 0x1800);
GetNextFrame(super);
sub_08039298(this);
if (--this->unk_78 == 0) {
sub_08039120(this);
} else if ((this->unk_78 & 0x1f) == 0) {
CuccoAggr_CreateFx(this);
}
}
void sub_08038FA0(CuccoAggrEntity* this) {
if ((super->actionDelay++ & 0x1f) == 0) {
CuccoAggr_CreateFx(this);
}
if (this->unk_78) {
if ((this->unk_78-- & 0x7) == 0) {
sub_08004596(super, GetFacingDirection(super, &gPlayerEntity));
}
sub_080390F8(this);
LinearMoveUpdate(super);
GetNextFrame(super);
} else {
LinearMoveUpdate(super);
GetNextFrame(super);
if (CuccoAggr_IsOutsideScroll(this)) {
DeleteEntity(super);
}
}
}
void sub_0803901C(CuccoAggrEntity* this) {
u32 r3 = Random();
u32 r5 = r3 & 3;
//! @bug This if was meant to check r5 instead of r3.
// The result is that this if practically never happens and
// there's a higher chance of the default branch of the next switch.
if (r3 == 3) {
switch (super->action) {
case 3:
r5 = 1;
break;
case 4:
r5 = 2;
break;
default:
r5 = 0;
}
}
switch (r5) {
default:
super->action = 1;
super->actionDelay = gUnk_080CF7BE[(r3 >> 0x10) & 3];
InitializeAnimation(super, 0);
break;
case 1:
super->action = 3;
super->actionDelay = ((r3 >> 8) & 3) + 2;
super->zVelocity = 0x8000;
sub_080390C0(this);
InitializeAnimation(super, 1);
if (Random() & 1) {
r5 = Random() & 1;
EnqueueSFX(SFX_VO_CUCCO1 + r5);
}
break;
case 2:
super->action = 4;
InitializeAnimation(super, ((r3 >> 0x10) & 1) + 2);
break;
}
}
void sub_080390C0(CuccoAggrEntity* this) {
u32 rand = Random();
if (sub_08049FA0(super) && (rand & 1)) {
super->direction = (rand >> 0x10) & 0x1c;
} else {
super->direction = (sub_08049EE4(super) + 2) & 0x1c;
}
sub_080390F8(this);
}
void sub_080390F8(CuccoAggrEntity* this) {
if (super->direction & 0xf) {
super->spriteSettings.flipX = ((super->direction >> 4) ^ 1);
}
}
void sub_08039120(CuccoAggrEntity* this) {
super->speed = gUnk_080CF7C2[super->type];
this->unk_7a = 0;
sub_0803901C(this);
}
void sub_08039140(CuccoAggrEntity* this) {
super->action = 6;
super->actionDelay = Random();
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->z.HALF.HI = 0xfffc;
this->unk_78 = 0xb4;
sub_080390F8(this);
InitializeAnimation(super, 4);
}
bool32 CuccoAggr_IsOutsideScroll(CuccoAggrEntity* this) {
if ((u32)super->x.HALF.HI - 0xc - gRoomControls.scroll_x > 0x108)
return 1;
if ((u32)super->y.HALF.HI - 0xc - gRoomControls.scroll_y > 0xb8)
return 1;
return 0;
}
void sub_080391B4(CuccoAggrEntity* this) {
if (this->unk_7a) {
if ((this->unk_7b++ & 0x1f) == 0) {
Entity* ent = CreateEnemy(CUCCO_AGGR, 2);
if (ent) {
u32 rand = (Random() & 0x17);
const PosOffset* ptr = &gCuccoAggrSpawnPoints[rand];
ent->x.HALF.HI = gRoomControls.scroll_x + ptr->x;
ent->y.HALF.HI = gRoomControls.scroll_y + ptr->y;
ent->collisionLayer = super->collisionLayer;
}
}
}
}
void sub_08039218(CuccoAggrEntity* this) {
super->action = 5;
super->speed = gUnk_080CF824[super->type];
this->unk_78 = gUnk_080CF828[super->type];
if (super->animIndex != 4) {
InitializeAnimation(super, 4);
}
EnqueueSFX(SFX_VO_CUCCO4);
}
void CuccoAggr_CreateFx(CuccoAggrEntity* this) {
Entity* ent = CreateFx(super, gCuccoAggrFx[super->type], 0);
if (ent) {
ent->x.HALF.HI += gCuccoAggrFxHorizontalOffsets[super->spriteSettings.flipX];
}
}
void sub_08039298(CuccoAggrEntity* this) {
if (super->type2 == 0) {
sub_08078930(super);
}
}
void (*const gUnk_080CF778[])(Entity*) = {
(EntityActionPtr)sub_08038CF8, (EntityActionPtr)sub_08038D10, sub_08001324, sub_0804A7D4, sub_08001242,
(EntityActionPtr)nullsub_165,
};
void (*const gUnk_080CF790[])(CuccoAggrEntity*) = {
sub_08038D78, sub_08038DA0, sub_08038DC0, sub_08038EE0, sub_08038F20, sub_08038F44, sub_08038FA0,
};
void (*const gUnk_080CF7AC[])(CuccoAggrEntity*) = {
sub_08038DD8,
sub_08038E18,
sub_08038EAC,
sub_08038ED0,
};
const u8 gUnk_080CF7BC[] = { 0, 0x78 };
const u8 gUnk_080CF7BE[] = { 0x1e, 0x2d, 0x3c, 0x4b };
const u8 gUnk_080CF7C2[] = { 0x80, 0xc0 };
const PosOffset gCuccoAggrSpawnPoints[] = {
{ 0x18, -0x8 }, { 0x38, -0x8 }, { 0x58, -0x8 }, { 0x78, -0x8 }, { 0x98, -0x8 }, { 0xB8, -0x8 },
{ 0xD8, -0x8 }, { 0x18, 0xA8 }, { 0x38, 0xA8 }, { 0x58, 0xA8 }, { 0x78, 0xA8 }, { 0x98, 0xA8 },
{ 0xB8, 0xA8 }, { 0xD8, 0xA8 }, { -0x8, 0x10 }, { -0x8, 0x30 }, { -0x8, 0x50 }, { -0x8, 0x70 },
{ -0x8, 0x90 }, { 0xF8, 0x10 }, { 0xF8, 0x30 }, { 0xF8, 0x50 }, { 0xF8, 0x70 }, { 0xF8, 0x90 },
};
const u16 gUnk_080CF824[] = {
0x140,
0x200,
};
const u16 gUnk_080CF828[] = {
0x384,
0x3c,
};
const s8 gCuccoAggrFxHorizontalOffsets[] = {
8,
-8,
};
const u8 gCuccoAggrFx[] = {
FX_EGG,
FX_WOOD2,
FX_EGG,
};