decompile beetle

This commit is contained in:
Behemoth 2020-08-29 04:14:07 +02:00
parent c63d80ee1d
commit 5ce1629a81
6 changed files with 398 additions and 858 deletions

View File

@ -1,812 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start Beetle
Beetle: @ 0x08021758
push {lr}
ldr r1, _08021764 @ =gUnk_080CB590
bl EnemyFunctionHandler
pop {pc}
.align 2, 0
_08021764: .4byte gUnk_080CB590
thumb_func_start sub_08021768
sub_08021768: @ 0x08021768
push {lr}
ldr r2, _0802177C @ =gUnk_080CB5A8
ldrb r1, [r0, #0xc]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_0802177C: .4byte gUnk_080CB5A8
thumb_func_start sub_08021780
sub_08021780: @ 0x08021780
push {r4, lr}
adds r4, r0, #0
adds r0, #0x41
ldrb r0, [r0]
cmp r0, #0x80
beq _08021792
cmp r0, #0x93
beq _080217F4
b _080217FA
_08021792:
ldr r0, _080217A4 @ =gPlayerState
adds r0, #0xa8
ldrb r0, [r0]
cmp r0, #0x18
bne _080217A8
adds r0, r4, #0
bl sub_08021768
b _080217FA
.align 2, 0
_080217A4: .4byte gPlayerState
_080217A8:
movs r1, #0
movs r0, #5
strb r0, [r4, #0xc]
movs r0, #0xb4
strb r0, [r4, #0xe]
strb r1, [r4, #0xf]
ldrb r1, [r4, #0x10]
movs r0, #0x7f
ands r0, r1
strb r0, [r4, #0x10]
adds r2, r4, #0
adds r2, #0x29
ldrb r1, [r2]
movs r0, #8
rsbs r0, r0, #0
ands r0, r1
movs r1, #3
orrs r0, r1
strb r0, [r2]
ldr r0, _080217EC @ =gPlayerEntity
adds r1, r4, #0
bl CopyPositionAndSpriteOffset
ldr r0, _080217F0 @ =0x0000FFFF
strh r0, [r4, #0x36]
adds r1, r4, #0
adds r1, #0x87
movs r0, #1
strb r0, [r1]
adds r0, r4, #0
movs r1, #6
bl InitializeAnimation
b _080217FA
.align 2, 0
_080217EC: .4byte gPlayerEntity
_080217F0: .4byte 0x0000FFFF
_080217F4:
adds r0, r4, #0
bl sub_08021768
_080217FA:
adds r0, r4, #0
adds r0, #0x45
ldrb r1, [r0]
cmp r1, #0
bne _08021808
subs r0, #3
strb r1, [r0]
_08021808:
ldr r1, _08021814 @ =gUnk_080CB590
adds r0, r4, #0
bl sub_0804AA30
pop {r4, pc}
.align 2, 0
_08021814: .4byte gUnk_080CB590
thumb_func_start sub_08021818
sub_08021818: @ 0x08021818
push {lr}
adds r3, r0, #0
ldrb r0, [r3, #0xa]
cmp r0, #0
bne _0802182A
adds r0, r3, #0
bl sub_0804A7D4
b _08021844
_0802182A:
ldr r2, [r3, #0x50]
cmp r2, #0
beq _0802183A
ldrb r0, [r2, #0xf]
subs r0, #1
movs r1, #0
strb r0, [r2, #0xf]
str r1, [r3, #0x50]
_0802183A:
adds r0, r3, #0
movs r1, #0xf0
movs r2, #0
bl CreateDeathFx
_08021844:
pop {pc}
.align 2, 0
thumb_func_start sub_08021848
sub_08021848: @ 0x08021848
push {r4, lr}
adds r4, r0, #0
bl sub_0806F520
adds r1, r0, #0
cmp r1, #0
beq _0802186C
ldr r0, _08021868 @ =gUnk_080CB5C8
ldrb r1, [r4, #0xd]
lsls r1, r1, #2
adds r1, r1, r0
ldr r1, [r1]
adds r0, r4, #0
bl _call_via_r1
b _0802187A
.align 2, 0
_08021868: .4byte gUnk_080CB5C8
_0802186C:
movs r0, #3
strb r0, [r4, #0xc]
strh r1, [r4, #0x36]
adds r0, r4, #0
movs r1, #2
bl InitializeAnimation
_0802187A:
pop {r4, pc}
thumb_func_start sub_0802187C
sub_0802187C: @ 0x0802187C
movs r1, #2
strb r1, [r0, #0xd]
bx lr
.align 2, 0
thumb_func_start nullsub_130
nullsub_130: @ 0x08021884
bx lr
.align 2, 0
thumb_func_start sub_08021888
sub_08021888: @ 0x08021888
push {r4, lr}
adds r4, r0, #0
bl sub_0806F3E4
cmp r0, #0
beq _0802189A
adds r0, r4, #0
bl sub_08021818
_0802189A:
pop {r4, pc}
thumb_func_start sub_0802189C
sub_0802189C: @ 0x0802189C
push {r4, lr}
adds r4, r0, #0
bl sub_0804A720
movs r0, #1
strb r0, [r4, #0xc]
strb r0, [r4, #0x1c]
adds r0, r4, #0
movs r1, #3
bl InitializeAnimation
pop {r4, pc}
thumb_func_start sub_080218B4
sub_080218B4: @ 0x080218B4
push {lr}
ldr r2, _080218C8 @ =gUnk_080CB5D4
ldrb r1, [r0, #0xb]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_080218C8: .4byte gUnk_080CB5D4
thumb_func_start sub_080218CC
sub_080218CC: @ 0x080218CC
push {r4, r5, r6, lr}
adds r5, r0, #0
ldrb r0, [r5, #0xd]
cmp r0, #0
bne _08021916
movs r2, #1
movs r0, #1
strb r0, [r5, #0xd]
ldrb r1, [r5, #0x18]
subs r0, #5
ands r0, r1
orrs r0, r2
strb r0, [r5, #0x18]
adds r0, r5, #0
movs r1, #1
bl sub_08049F84
adds r4, r0, #0
bl Random
movs r1, #0x10
eors r4, r1
ldr r2, _08021980 @ =gUnk_080CB5DC
movs r1, #7
ands r1, r0
adds r1, r1, r2
ldrb r0, [r1]
adds r0, r0, r4
movs r1, #0x1f
ands r0, r1
strb r0, [r5, #0x15]
movs r0, #0x80
lsls r0, r0, #1
strh r0, [r5, #0x24]
movs r0, #0x90
lsls r0, r0, #9
str r0, [r5, #0x20]
_08021916:
adds r0, r5, #0
bl GetNextFrame
adds r2, r5, #0
adds r2, #0x5a
ldrb r1, [r2]
movs r6, #1
adds r0, r6, #0
ands r0, r1
adds r4, r2, #0
cmp r0, #0
beq _08021948
adds r0, r5, #0
bl sub_080AEFE0
movs r1, #0xe0
lsls r1, r1, #5
adds r0, r5, #0
bl sub_080044EC
cmp r0, #0
bne _08021948
adds r0, r5, #0
adds r0, #0x59
strb r6, [r0]
_08021948:
ldrb r1, [r4]
movs r0, #0x80
ands r0, r1
cmp r0, #0
beq _0802197C
movs r0, #2
strb r0, [r5, #0xc]
bl Random
movs r1, #0x38
ands r0, r1
adds r0, #8
strb r0, [r5, #0xe]
movs r0, #1
strb r0, [r5, #0xf]
ldrb r1, [r5, #0x10]
movs r0, #0x80
orrs r0, r1
strb r0, [r5, #0x10]
movs r0, #0xc0
lsls r0, r0, #1
strh r0, [r5, #0x24]
adds r0, r5, #0
movs r1, #0
bl InitializeAnimation
_0802197C:
pop {r4, r5, r6, pc}
.align 2, 0
_08021980: .4byte gUnk_080CB5DC
thumb_func_start sub_08021984
sub_08021984: @ 0x08021984
push {r4, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xd]
cmp r0, #0
bne _080219C2
movs r0, #1
strb r0, [r4, #0xd]
ldrb r1, [r4, #0x10]
movs r0, #0x80
orrs r0, r1
strb r0, [r4, #0x10]
ldrb r0, [r4, #0x18]
movs r1, #3
orrs r0, r1
strb r0, [r4, #0x18]
ldr r0, _08021A08 @ =0x0000FF80
strh r0, [r4, #0x36]
ldrb r2, [r4, #0x19]
movs r1, #0x3f
adds r0, r1, #0
ands r0, r2
movs r2, #0x40
orrs r0, r2
strb r0, [r4, #0x19]
ldrb r0, [r4, #0x1b]
ands r1, r0
orrs r1, r2
strb r1, [r4, #0x1b]
ldr r0, _08021A0C @ =0x0000012D
bl sub_08004488
_080219C2:
movs r1, #0xc0
lsls r1, r1, #5
adds r0, r4, #0
bl sub_08003FC4
cmp r0, #0
bne _08021A04
movs r0, #2
strb r0, [r4, #0xc]
movs r0, #0x10
strb r0, [r4, #0xe]
movs r2, #1
movs r0, #1
strb r0, [r4, #0xf]
ldrb r1, [r4, #0x18]
subs r0, #5
ands r0, r1
orrs r0, r2
strb r0, [r4, #0x18]
movs r0, #0xc0
lsls r0, r0, #1
strh r0, [r4, #0x24]
adds r1, r4, #0
adds r1, #0x86
movs r0, #0x3c
strb r0, [r1]
adds r0, r4, #0
movs r1, #0
bl InitializeAnimation
adds r0, r4, #0
bl UpdateSpriteForCollisionLayer
_08021A04:
pop {r4, pc}
.align 2, 0
_08021A08: .4byte 0x0000FF80
_08021A0C: .4byte 0x0000012D
thumb_func_start sub_08021A10
sub_08021A10: @ 0x08021A10
push {r4, lr}
adds r4, r0, #0
bl GetNextFrame
ldr r1, _08021A60 @ =gPlayerEntity
adds r0, r4, #0
movs r2, #0x78
movs r3, #0x50
bl sub_080041A0
cmp r0, #0
beq _08021A5E
adds r0, r4, #0
bl sub_08021D00
cmp r0, #0
bne _08021A5E
ldrb r0, [r4, #0xe]
subs r0, #1
strb r0, [r4, #0xe]
lsls r0, r0, #0x18
cmp r0, #0
bne _08021A5E
movs r0, #3
strb r0, [r4, #0xc]
bl Random
movs r1, #0x3f
ands r0, r1
adds r0, #0x1e
strb r0, [r4, #0xe]
ldrb r1, [r4, #0x15]
adds r0, r4, #0
bl sub_08021D44
adds r0, r4, #0
movs r1, #2
bl InitializeAnimation
_08021A5E:
pop {r4, pc}
.align 2, 0
_08021A60: .4byte gPlayerEntity
thumb_func_start sub_08021A64
sub_08021A64: @ 0x08021A64
push {r4, r5, lr}
adds r4, r0, #0
bl sub_08021D00
cmp r0, #0
bne _08021AD4
ldrb r0, [r4, #0xe]
subs r0, #1
strb r0, [r4, #0xe]
movs r5, #0xff
lsls r0, r0, #0x18
cmp r0, #0
bne _08021A96
movs r0, #2
strb r0, [r4, #0xc]
bl Random
movs r1, #0x1f
ands r0, r1
adds r0, #0x1e
strb r0, [r4, #0xe]
adds r0, r4, #0
movs r1, #0
bl InitializeAnimation
_08021A96:
ldrb r0, [r4, #0xf]
subs r0, #1
strb r0, [r4, #0xf]
ands r0, r5
cmp r0, #0
bne _08021AC8
movs r0, #8
strb r0, [r4, #0xf]
adds r0, r4, #0
movs r1, #1
bl sub_08049F84
adds r1, r0, #0
cmp r1, #0xff
bne _08021AC2
movs r0, #7
strb r0, [r4, #0xc]
adds r0, r4, #0
movs r1, #1
bl InitializeAnimation
b _08021AD4
_08021AC2:
adds r0, r4, #0
bl sub_08021D44
_08021AC8:
adds r0, r4, #0
bl sub_080AEF88
adds r0, r4, #0
bl GetNextFrame
_08021AD4:
pop {r4, r5, pc}
.align 2, 0
thumb_func_start sub_08021AD8
sub_08021AD8: @ 0x08021AD8
push {r4, lr}
adds r4, r0, #0
bl GetNextFrame
adds r0, r4, #0
adds r0, #0x5a
ldrb r1, [r0]
movs r0, #1
ands r0, r1
cmp r0, #0
beq _08021B3A
ldrb r0, [r4, #0xe]
cmp r0, #0
beq _08021B1E
movs r0, #0
strb r0, [r4, #0xe]
adds r0, r4, #0
movs r1, #1
bl sub_08049F84
cmp r0, #0xff
bne _08021B16
movs r0, #2
strb r0, [r4, #0xc]
movs r0, #8
strb r0, [r4, #0xe]
adds r0, r4, #0
movs r1, #0
bl InitializeAnimation
b _08021B60
_08021B16:
strb r0, [r4, #0x15]
movs r0, #0x7c
bl sub_08004488
_08021B1E:
adds r0, r4, #0
bl sub_080AEFE0
movs r1, #0xc0
lsls r1, r1, #5
adds r0, r4, #0
bl sub_08003FC4
cmp r0, #0
bne _08021B3A
adds r1, r4, #0
adds r1, #0x59
movs r0, #1
strb r0, [r1]
_08021B3A:
adds r0, r4, #0
adds r0, #0x5a
ldrb r1, [r0]
movs r0, #0x80
ands r0, r1
cmp r0, #0
beq _08021B60
movs r0, #2
strb r0, [r4, #0xc]
movs r0, #0x14
strb r0, [r4, #0xe]
adds r1, r4, #0
adds r1, #0x86
movs r0, #0x3c
strb r0, [r1]
adds r0, r4, #0
movs r1, #0
bl InitializeAnimation
_08021B60:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08021B64
sub_08021B64: @ 0x08021B64
push {r4, r5, r6, lr}
adds r4, r0, #0
ldr r0, _08021B88 @ =gPlayerState
ldr r1, [r0, #0x30]
movs r2, #4
ands r1, r2
adds r6, r0, #0
cmp r1, #0
beq _08021B8C
movs r1, #0
movs r0, #3
strb r0, [r4, #0xc]
str r1, [r4, #0x34]
adds r0, r4, #0
movs r1, #2
bl InitializeAnimation
b _08021C4E
.align 2, 0
_08021B88: .4byte gPlayerState
_08021B8C:
movs r5, #1
adds r0, r6, #0
adds r0, #0xa8
ldrb r0, [r0]
cmp r0, #0xb
beq _08021BBA
cmp r0, #0x14
beq _08021BBA
bl sub_0807953C
cmp r0, #0
beq _08021BAE
ldrb r1, [r4, #0xa]
lsls r0, r1, #1
adds r0, r0, r1
adds r5, r0, #0
adds r5, #8
_08021BAE:
ldrb r0, [r4, #0xe]
subs r5, r0, r5
cmp r5, #0
bge _08021BB8
movs r5, #0
_08021BB8:
strb r5, [r4, #0xe]
_08021BBA:
ldr r0, [r6, #0x30]
movs r1, #0x88
lsls r1, r1, #1
ands r0, r1
cmp r0, #0
beq _08021BC8
movs r5, #0
_08021BC8:
cmp r5, #0
bne _08021C04
movs r0, #6
strb r0, [r4, #0xc]
movs r0, #0x80
lsls r0, r0, #9
str r0, [r4, #0x20]
adds r0, r4, #0
adds r0, #0x87
strb r5, [r0]
ldr r2, _08021BEC @ =gPlayerEntity
ldrb r1, [r2, #0x15]
adds r0, r1, #0
cmp r0, #0xff
beq _08021BF0
movs r0, #0x10
b _08021BF6
.align 2, 0
_08021BEC: .4byte gPlayerEntity
_08021BF0:
ldrb r0, [r2, #0x14]
lsls r0, r0, #2
movs r1, #0x10
_08021BF6:
eors r0, r1
strb r0, [r4, #0x15]
adds r0, r4, #0
movs r1, #5
bl InitializeAnimation
b _08021C4E
_08021C04:
ldrb r1, [r6, #0x1a]
movs r0, #0x80
orrs r0, r1
strb r0, [r6, #0x1a]
adds r1, r6, #0
adds r1, #0x80
ldrh r0, [r1]
subs r0, #0x50
strh r0, [r1]
adds r1, #0x2a
ldrb r0, [r1]
adds r0, #1
strb r0, [r1]
ldr r0, _08021C50 @ =gPlayerEntity
adds r1, r4, #0
bl CopyPositionAndSpriteOffset
ldr r2, _08021C54 @ =gUnk_080CB5E4
ldrb r1, [r4, #0xf]
adds r0, r1, #1
strb r0, [r4, #0xf]
movs r0, #0xe
ands r0, r1
lsrs r0, r0, #1
adds r0, r0, r2
ldrb r0, [r0]
lsls r0, r0, #0x18
asrs r0, r0, #0x18
ldrh r1, [r4, #0x2e]
adds r0, r0, r1
strh r0, [r4, #0x2e]
ldrh r0, [r4, #0x36]
subs r0, #1
strh r0, [r4, #0x36]
adds r0, r4, #0
bl GetNextFrame
_08021C4E:
pop {r4, r5, r6, pc}
.align 2, 0
_08021C50: .4byte gPlayerEntity
_08021C54: .4byte gUnk_080CB5E4
thumb_func_start sub_08021C58
sub_08021C58: @ 0x08021C58
push {r4, r5, lr}
adds r4, r0, #0
bl GetNextFrame
adds r0, r4, #0
adds r0, #0x5a
ldrb r1, [r0]
movs r5, #1
adds r0, r5, #0
ands r0, r1
cmp r0, #0
beq _08021C8A
adds r0, r4, #0
bl sub_080AEFE0
movs r1, #0xc0
lsls r1, r1, #5
adds r0, r4, #0
bl sub_08003FC4
cmp r0, #0
bne _08021C8A
adds r0, r4, #0
adds r0, #0x59
strb r5, [r0]
_08021C8A:
adds r0, r4, #0
adds r0, #0x5a
ldrb r1, [r0]
movs r0, #0x80
ands r0, r1
cmp r0, #0
beq _08021CCC
movs r0, #2
strb r0, [r4, #0xc]
movs r2, #0x3c
strb r2, [r4, #0xe]
movs r0, #1
strb r0, [r4, #0xf]
ldrb r1, [r4, #0x10]
movs r0, #0x80
orrs r0, r1
strb r0, [r4, #0x10]
adds r3, r4, #0
adds r3, #0x29
ldrb r1, [r3]
movs r0, #8
rsbs r0, r0, #0
ands r0, r1
movs r1, #4
orrs r0, r1
strb r0, [r3]
adds r0, r4, #0
adds r0, #0x86
strb r2, [r0]
adds r0, r4, #0
movs r1, #0
bl InitializeAnimation
_08021CCC:
pop {r4, r5, pc}
.align 2, 0
thumb_func_start sub_08021CD0
sub_08021CD0: @ 0x08021CD0
push {r4, lr}
adds r4, r0, #0
adds r0, #0x5a
ldrb r1, [r0]
movs r0, #0x80
ands r0, r1
cmp r0, #0
bne _08021CE6
adds r0, r4, #0
bl GetNextFrame
_08021CE6:
adds r0, r4, #0
movs r1, #1
bl sub_08049F84
cmp r0, #0xff
beq _08021CFE
movs r0, #3
strb r0, [r4, #0xc]
adds r0, r4, #0
movs r1, #2
bl InitializeAnimation
_08021CFE:
pop {r4, pc}
thumb_func_start sub_08021D00
sub_08021D00: @ 0x08021D00
push {r4, lr}
adds r4, r0, #0
adds r1, r4, #0
adds r1, #0x86
ldrb r0, [r1]
cmp r0, #0
beq _08021D16
subs r0, #1
strb r0, [r1]
movs r0, #0
b _08021D40
_08021D16:
adds r0, r4, #0
movs r1, #1
movs r2, #0x10
bl sub_08049F64
cmp r0, #0
bne _08021D28
movs r0, #0
b _08021D40
_08021D28:
movs r0, #4
strb r0, [r4, #0xc]
movs r0, #1
strb r0, [r4, #0xe]
movs r0, #0xc0
lsls r0, r0, #9
str r0, [r4, #0x20]
adds r0, r4, #0
movs r1, #4
bl InitializeAnimation
movs r0, #1
_08021D40:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08021D44
sub_08021D44: @ 0x08021D44
push {lr}
adds r2, r0, #0
adds r1, #4
movs r0, #0x18
ands r1, r0
strb r1, [r2, #0x15]
movs r0, #8
ands r1, r0
cmp r1, #0
beq _08021D5E
movs r0, #0xc0
lsls r0, r0, #1
b _08021D60
_08021D5E:
movs r0, #0xc0
_08021D60:
strh r0, [r2, #0x24]
pop {pc}

28
data/beetleAnimations.s Normal file
View File

@ -0,0 +1,28 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
gUnk_080CB5EC:: @ 080CB5EC
.incbin "baserom.gba", 0x0CB5EC, 0x0000014
gUnk_080CB600:: @ 080CB600
.incbin "baserom.gba", 0x0CB600, 0x000001C
gUnk_080CB61C:: @ 080CB61C
.incbin "baserom.gba", 0x0CB61C, 0x0000011
gUnk_080CB62D:: @ 080CB62D
.incbin "baserom.gba", 0x0CB62D, 0x0000018
gUnk_080CB645:: @ 080CB645
.incbin "baserom.gba", 0x0CB645, 0x0000018
gUnk_080CB65D:: @ 080CB65D
.incbin "baserom.gba", 0x0CB65D, 0x0000014
gUnk_080CB671:: @ 080CB671
.incbin "baserom.gba", 0x0CB671, 0x000000B
gUnk_080CB67C:: @ 080CB67C
.incbin "baserom.gba", 0x0CB67C, 0x0000020

View File

@ -3,48 +3,6 @@
.section .rodata
gUnk_080CB590:: @ 080CB590
.incbin "baserom.gba", 0x0CB590, 0x0000018
gUnk_080CB5A8:: @ 080CB5A8
.incbin "baserom.gba", 0x0CB5A8, 0x0000020
gUnk_080CB5C8:: @ 080CB5C8
.incbin "baserom.gba", 0x0CB5C8, 0x000000C
gUnk_080CB5D4:: @ 080CB5D4
.incbin "baserom.gba", 0x0CB5D4, 0x0000008
gUnk_080CB5DC:: @ 080CB5DC
.incbin "baserom.gba", 0x0CB5DC, 0x0000008
gUnk_080CB5E4:: @ 080CB5E4
.incbin "baserom.gba", 0x0CB5E4, 0x0000008
gUnk_080CB5EC:: @ 080CB5EC
.incbin "baserom.gba", 0x0CB5EC, 0x0000014
gUnk_080CB600:: @ 080CB600
.incbin "baserom.gba", 0x0CB600, 0x000001C
gUnk_080CB61C:: @ 080CB61C
.incbin "baserom.gba", 0x0CB61C, 0x0000011
gUnk_080CB62D:: @ 080CB62D
.incbin "baserom.gba", 0x0CB62D, 0x0000018
gUnk_080CB645:: @ 080CB645
.incbin "baserom.gba", 0x0CB645, 0x0000018
gUnk_080CB65D:: @ 080CB65D
.incbin "baserom.gba", 0x0CB65D, 0x0000014
gUnk_080CB671:: @ 080CB671
.incbin "baserom.gba", 0x0CB671, 0x000000B
gUnk_080CB67C:: @ 080CB67C
.incbin "baserom.gba", 0x0CB67C, 0x0000020
gUnk_080CB69C:: @ 080CB69C
.incbin "baserom.gba", 0x0CB69C, 0x0000018

View File

@ -33,13 +33,15 @@ typedef struct {
/*0x30*/ union {
/* */ u32 all;
/* */ struct {
/* */ u32 filler9 : 3;
/* */ u32 filler9 : 2;
/* */ u32 unk2 : 1;
/* */ u32 noMinishCap : 1;
/* */ u32 pullingState : 1;
/* */ u32 windyState : 1;
/* */ u32 filler6 : 1;
/* */ u32 unk7 : 1;
/* */ u32 filler8 : 2;
/* */ u32 unk8 : 1;
/* */ u32 unk9 : 1;
/* */ u32 slipperyState : 1;
/* */ u32 filler11 : 5;
/* */ u32 filler11b : 16;
@ -54,7 +56,9 @@ typedef struct {
/* */ u8 swordBlueParticle : 1;
/* */ u8 filler14 : 6;
/*0x3f*/ u8 field_0x3f;
/*0x40*/ u8 field_0x40[75];
/*0x40*/ u8 field_0x40[64];
/*0x80*/ u16 field_0x80;
/*0x82*/ u8 field_0x82[9];
/*0x8b*/ u8 field_0x8b;
/*0x8c*/ u32 field_0x8c;
/*0x90*/ union SplitWord field_0x90;

View File

@ -332,7 +332,7 @@ SECTIONS {
src/enemy/rollobite.o(.text);
src/enemy/darkNut.o(.text);
src/enemy/hangingSeed.o(.text);
asm/beetle.o(.text);
src/enemy/beetle.o(.text);
src/enemy/keese.o(.text);
asm/doorMimic.o(.text);
asm/rockChuchu.o(.text);
@ -918,6 +918,8 @@ SECTIONS {
src/enemy/darkNut.o(.rodata);
data/darkNutAnimations.o(.rodata);
src/enemy/hangingSeed.o(.rodata);
src/enemy/beetle.o(.rodata);
data/beetleAnimations.o(.rodata);
data/data_080CB570.o(.rodata);
src/enemy.o(.rodata);
data/data_080D3D94.o(.rodata);

360
src/enemy/beetle.c Normal file
View File

@ -0,0 +1,360 @@
#include "entity.h"
#include "functions.h"
#include "player.h"
extern u32 sub_08049F64(Entity*, u32, u32);
u32 sub_08021D00();
void sub_08021D44(Entity* this, u32 param_2);
extern void (*const gUnk_080CB590[])(Entity*);
extern void (*const gUnk_080CB5A8[])(Entity*);
extern void (*const gUnk_080CB5C8[])(Entity*);
extern void (*const gUnk_080CB5D4[])(Entity*);
extern const s8 gUnk_080CB5DC[];
extern const s8 gUnk_080CB5E4[];
void Beetle(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CB590);
}
void sub_08021768(Entity* this) {
gUnk_080CB5A8[this->action](this);
}
void sub_08021780(Entity* this) {
switch (this->bitfield) {
case 0x80:
if (gPlayerState.field_0xa8 == 24) {
sub_08021768(this);
} else {
this->action = 5;
this->actionDelay = 0xb4;
this->field_0xf = 0;
this->flags &= ~0x80;
this->spritePriority.b0 = 3;
CopyPositionAndSpriteOffset(&gPlayerEntity, this);
this->height.HALF.HI = -1;
((u8*)&this->field_0x86)[1] = 1;
InitializeAnimation(this, 6);
}
break;
case 0x93:
sub_08021768(this);
break;
}
if (this->currentHealth == 0)
this->field_0x42 = 0;
sub_0804AA30(this, gUnk_080CB590);
}
void sub_08021818(Entity* this) {
if (this->entityType.form == 0) {
sub_0804A7D4(this);
} else {
Entity* ent = this->parent;
if (ent) {
ent->field_0xf--;
this->parent = NULL;
}
CreateDeathFx(this, 0xf0, 0);
}
}
void sub_08021848(Entity* this) {
if (sub_0806F520(this)) {
gUnk_080CB5C8[this->previousActionFlag](this);
} else {
this->action = 3;
this->height.HALF.HI = 0;
InitializeAnimation(this, 2);
}
}
void sub_0802187C(Entity* this) {
this->previousActionFlag = 2;
}
void nullsub_130(Entity* this) {
}
void sub_08021888(Entity* this) {
if (sub_0806F3E4(this))
sub_08021818(this);
}
void sub_0802189C(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x1c = 1;
InitializeAnimation(this, 3);
}
void sub_080218B4(Entity* this) {
gUnk_080CB5D4[this->entityType.parameter](this);
}
void sub_080218CC(Entity* this) {
if (this->previousActionFlag == 0) {
this->previousActionFlag = 1;
this->spriteSettings.b.draw = 1;
this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f;
this->nonPlanarMovement = 0x100;
this->field_0x20 = 0x12000;
}
GetNextFrame(this);
if (this->frames.all & 1) {
sub_080AEFE0(this);
if (sub_080044EC(this, 0x1c00) == 0)
this->frameDuration = 1;
}
if (this->frames.all & 0x80) {
this->action = 2;
this->actionDelay = (Random() & 0x38) + 8;
this->field_0xf = 1;
this->flags |= 0x80;
this->nonPlanarMovement = 0x180;
InitializeAnimation(this, 0);
}
}
void sub_08021984(Entity* this) {
if (this->previousActionFlag == 0) {
this->previousActionFlag = 1;
this->flags |= 0x80;
this->spriteSettings.b.draw = 3;
this->height.HALF.HI = -0x80;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
sub_08004488(0x12d);
}
if (sub_08003FC4(this, 0x1800) == 0) {
this->action = 2;
this->actionDelay = 16;
this->field_0xf = 1;
this->spriteSettings.b.draw = 1;
this->nonPlanarMovement = 0x180;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
UpdateSpriteForCollisionLayer(this);
}
}
void sub_08021A10(Entity* this) {
GetNextFrame(this);
if (sub_080041A0(this, &gPlayerEntity, 120, 80) && sub_08021D00(this) == 0) {
if (--this->actionDelay == 0) {
this->action = 3;
this->actionDelay = (Random() & 0x3f) + 30;
sub_08021D44(this, this->direction);
InitializeAnimation(this, 2);
}
}
}
void sub_08021A64(Entity* this) {
if (!sub_08021D00(this)) {
if (--this->actionDelay == 0) {
this->action = 2;
this->actionDelay = (Random() & 0x1f) + 0x1e;
InitializeAnimation(this, 0);
}
if (--this->field_0xf == 0) {
u32 tmp;
this->field_0xf = 8;
tmp = sub_08049F84(this, 1);
if (tmp == 0xff) {
this->action = 7;
InitializeAnimation(this, 1);
return;
}
sub_08021D44(this, tmp);
}
sub_080AEF88(this);
GetNextFrame(this);
}
}
void sub_08021AD8(Entity* this) {
GetNextFrame(this);
if (this->frames.all & 1) {
if (this->actionDelay) {
u32 tmp;
this->actionDelay = 0;
tmp = sub_08049F84(this, 1);
if (tmp == 0xff) {
this->action = 2;
this->actionDelay = '\b';
InitializeAnimation(this, 0);
return;
}
this->direction = (u8)tmp;
sub_08004488(0x7c);
}
sub_080AEFE0(this);
if (!sub_08003FC4(this, 0x1800))
this->frameDuration = 1;
}
if (this->frames.all & 0x80) {
this->action = 2;
this->actionDelay = 20;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
}
}
void sub_08021B64(Entity* this) {
if (gPlayerState.flags.all & 4) {
this->action = 3;
this->height.WORD = 0;
InitializeAnimation(this, 2);
} else {
int iVar4 = 1;
if (gPlayerState.field_0xa8 != 11 && gPlayerState.field_0xa8 != 20) {
if (sub_0807953C())
iVar4 = this->entityType.form * 3 + 8;
iVar4 = this->actionDelay - iVar4;
if (iVar4 < 0)
iVar4 = 0;
this->actionDelay = (u8)iVar4;
}
if (gPlayerState.flags.all & 0x110)
iVar4 = 0;
if (iVar4 == 0) {
this->action = 6;
this->field_0x20 = 0x10000;
((u8*)&this->field_0x86)[1] = 0;
if (gPlayerEntity.direction != 0xff) {
this->direction = 0x10 ^ gPlayerEntity.direction;
} else {
this->direction = (gPlayerEntity.animationState << 2) ^ 0x10;
}
InitializeAnimation(this, 5);
} else {
gPlayerState.field_0x1a[0] |= 0x80;
gPlayerState.field_0x80 -= 0x50;
gPlayerState.field_0xaa++;
CopyPositionAndSpriteOffset(&gPlayerEntity, this);
this->x.HALF.HI += gUnk_080CB5E4[(this->field_0xf++ & 0xe) >> 1];
this->height.HALF.HI--;
GetNextFrame(this);
}
}
}
void sub_08021C58(Entity* this) {
GetNextFrame(this);
if (this->frames.all & 1) {
sub_080AEFE0(this);
if (sub_08003FC4(this, 0x1800) == 0)
this->frameDuration = 1;
}
if (this->frames.all & 0x80) {
this->action = 2;
this->actionDelay = 60;
this->field_0xf = 1;
this->flags |= 0x80;
this->spritePriority.b0 = 4;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
}
}
void sub_08021CD0(Entity* this) {
if ((this->frames.all & 0x80) == 0)
GetNextFrame(this);
if (sub_08049F84(this, 1) == 0xff)
return;
this->action = 3;
InitializeAnimation(this, 2);
}
u32 sub_08021D00(Entity* this) {
u32 ret;
if (((u8*)&this->field_0x86)[0]) {
((u8*)&this->field_0x86)[0]--;
ret = 0;
} else if (sub_08049F64(this, 1, 0x10) == 0) {
ret = 0;
} else {
this->action = 4;
this->actionDelay = 1;
this->field_0x20 = 0x18000;
InitializeAnimation(this, 4);
ret = 1;
}
return ret;
}
void sub_08021D44(Entity* this, u32 param_2) {
param_2 += 4;
param_2 &= 0x18;
this->direction = param_2;
if (param_2 & 8) {
this->nonPlanarMovement = 0x180;
} else {
this->nonPlanarMovement = 0xc0;
}
}
// clang-format off
void (*const gUnk_080CB590[])(Entity*) = {
sub_08021768,
sub_08021780,
sub_08001324,
sub_08021818,
sub_08001242,
sub_08021848,
};
void (*const gUnk_080CB5A8[])(Entity*) = {
sub_0802189C,
sub_080218B4,
sub_08021A10,
sub_08021A64,
sub_08021AD8,
sub_08021B64,
sub_08021C58,
sub_08021CD0,
};
void (*const gUnk_080CB5C8[])(Entity*) = {
sub_0802187C,
nullsub_130,
sub_08021888,
};
void (*const gUnk_080CB5D4[])(Entity*) = {
sub_080218CC,
sub_08021984,
};
const s8 gUnk_080CB5DC[] = {
-1, -2, 1, 2, -3, 3, -4, 4,
};
const s8 gUnk_080CB5E4[] = {
-1, -2, -1, 0, 1, 2, 1, 0,
};
// clang-format on