decompile darkNut

This commit is contained in:
Behemoth 2020-08-29 01:05:12 +02:00
parent 6887d83e41
commit 4a61e8727f
7 changed files with 1040 additions and 1827 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
push {lr}
adds r2, r0, #0
movs r0, #7
ands r0, r1
subs r0, #3
cmp r0, #2
bhi _0802129A
movs r3, #0x18
adds r0, r1, #0
ands r0, r3
lsrs r0, r0, #3
cmp r0, r2
beq _080212AA
adds r0, r1, #0
adds r0, #8
ands r0, r3
lsrs r0, r0, #3
cmp r0, r2
beq _080212AA
_0802129A:
adds r0, r1, #4
movs r1, #0x18
ands r0, r1
lsrs r1, r0, #3
cmp r2, r1
beq _080212AA
adds r0, r1, #0
b _080212AC
_080212AA:
movs r0, #0xff
_080212AC:
pop {pc}
.align 2, 0
.syntax divided

239
data/darkNutAnimations.s Normal file
View File

@ -0,0 +1,239 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_080CAB6C:: @ 080CAB6C
.incbin "baserom.gba", 0x0CAB6C, 0x0000004
gUnk_080CAB70:: @ 080CAB70
.incbin "baserom.gba", 0x0CAB70, 0x0000004
gUnk_080CAB74:: @ 080CAB74
.incbin "baserom.gba", 0x0CAB74, 0x0000004
gUnk_080CAB78:: @ 080CAB78
.incbin "baserom.gba", 0x0CAB78, 0x0000004
gUnk_080CAB7C:: @ 080CAB7C
.incbin "baserom.gba", 0x0CAB7C, 0x0000010
gUnk_080CAB8C:: @ 080CAB8C
.incbin "baserom.gba", 0x0CAB8C, 0x0000010
gUnk_080CAB9C:: @ 080CAB9C
.incbin "baserom.gba", 0x0CAB9C, 0x0000010
gUnk_080CABAC:: @ 080CABAC
.incbin "baserom.gba", 0x0CABAC, 0x0000010
gUnk_080CABBC:: @ 080CABBC
.incbin "baserom.gba", 0x0CABBC, 0x0000004
gUnk_080CABC0:: @ 080CABC0
.incbin "baserom.gba", 0x0CABC0, 0x0000004
gUnk_080CABC4:: @ 080CABC4
.incbin "baserom.gba", 0x0CABC4, 0x0000004
gUnk_080CABC8:: @ 080CABC8
.incbin "baserom.gba", 0x0CABC8, 0x0000004
gUnk_080CABCC:: @ 080CABCC
.incbin "baserom.gba", 0x0CABCC, 0x0000019
gUnk_080CABE5:: @ 080CABE5
.incbin "baserom.gba", 0x0CABE5, 0x0000019
gUnk_080CABFE:: @ 080CABFE
.incbin "baserom.gba", 0x0CABFE, 0x0000019
gUnk_080CAC17:: @ 080CAC17
.incbin "baserom.gba", 0x0CAC17, 0x0000019
gUnk_080CAC30:: @ 080CAC30
.incbin "baserom.gba", 0x0CAC30, 0x000000C
gUnk_080CAC3C:: @ 080CAC3C
.incbin "baserom.gba", 0x0CAC3C, 0x000000C
gUnk_080CAC48:: @ 080CAC48
.incbin "baserom.gba", 0x0CAC48, 0x000000C
gUnk_080CAC54:: @ 080CAC54
.incbin "baserom.gba", 0x0CAC54, 0x000000C
gUnk_080CAC60:: @ 080CAC60
.incbin "baserom.gba", 0x0CAC60, 0x0000028
gUnk_080CAC88:: @ 080CAC88
.incbin "baserom.gba", 0x0CAC88, 0x0000028
gUnk_080CACB0:: @ 080CACB0
.incbin "baserom.gba", 0x0CACB0, 0x0000028
gUnk_080CACD8:: @ 080CACD8
.incbin "baserom.gba", 0x0CACD8, 0x0000028
gUnk_080CAD00:: @ 080CAD00
.incbin "baserom.gba", 0x0CAD00, 0x0000019
gUnk_080CAD19:: @ 080CAD19
.incbin "baserom.gba", 0x0CAD19, 0x0000019
gUnk_080CAD32:: @ 080CAD32
.incbin "baserom.gba", 0x0CAD32, 0x0000019
gUnk_080CAD4B:: @ 080CAD4B
.incbin "baserom.gba", 0x0CAD4B, 0x0000019
gUnk_080CAD64:: @ 080CAD64
.incbin "baserom.gba", 0x0CAD64, 0x000000C
gUnk_080CAD70:: @ 080CAD70
.incbin "baserom.gba", 0x0CAD70, 0x000000C
gUnk_080CAD7C:: @ 080CAD7C
.incbin "baserom.gba", 0x0CAD7C, 0x000000C
gUnk_080CAD88:: @ 080CAD88
.incbin "baserom.gba", 0x0CAD88, 0x000000C
gUnk_080CAD94:: @ 080CAD94
.incbin "baserom.gba", 0x0CAD94, 0x0000015
gUnk_080CADA9:: @ 080CADA9
.incbin "baserom.gba", 0x0CADA9, 0x0000015
gUnk_080CADBE:: @ 080CADBE
.incbin "baserom.gba", 0x0CADBE, 0x0000015
gUnk_080CADD3:: @ 080CADD3
.incbin "baserom.gba", 0x0CADD3, 0x0000015
gUnk_080CADE8:: @ 080CADE8
.incbin "baserom.gba", 0x0CADE8, 0x0000019
gUnk_080CAE01:: @ 080CAE01
.incbin "baserom.gba", 0x0CAE01, 0x0000019
gUnk_080CAE1A:: @ 080CAE1A
.incbin "baserom.gba", 0x0CAE1A, 0x0000019
gUnk_080CAE33:: @ 080CAE33
.incbin "baserom.gba", 0x0CAE33, 0x0000019
gUnk_080CAE4C:: @ 080CAE4C
.incbin "baserom.gba", 0x0CAE4C, 0x0000019
gUnk_080CAE65:: @ 080CAE65
.incbin "baserom.gba", 0x0CAE65, 0x0000019
gUnk_080CAE7E:: @ 080CAE7E
.incbin "baserom.gba", 0x0CAE7E, 0x0000019
gUnk_080CAE97:: @ 080CAE97
.incbin "baserom.gba", 0x0CAE97, 0x0000019
gUnk_080CAEB0:: @ 080CAEB0
.incbin "baserom.gba", 0x0CAEB0, 0x0000010
gUnk_080CAEC0:: @ 080CAEC0
.incbin "baserom.gba", 0x0CAEC0, 0x0000010
gUnk_080CAED0:: @ 080CAED0
.incbin "baserom.gba", 0x0CAED0, 0x0000010
gUnk_080CAEE0:: @ 080CAEE0
.incbin "baserom.gba", 0x0CAEE0, 0x0000010
gUnk_080CAEF0:: @ 080CAEF0
.incbin "baserom.gba", 0x0CAEF0, 0x0000030
gUnk_080CAF20:: @ 080CAF20
.incbin "baserom.gba", 0x0CAF20, 0x0000030
gUnk_080CAF50:: @ 080CAF50
.incbin "baserom.gba", 0x0CAF50, 0x0000030
gUnk_080CAF80:: @ 080CAF80
.incbin "baserom.gba", 0x0CAF80, 0x0000030
gUnk_080CAFB0:: @ 080CAFB0
.incbin "baserom.gba", 0x0CAFB0, 0x0000018
gUnk_080CAFC8:: @ 080CAFC8
.incbin "baserom.gba", 0x0CAFC8, 0x0000018
gUnk_080CAFE0:: @ 080CAFE0
.incbin "baserom.gba", 0x0CAFE0, 0x0000018
gUnk_080CAFF8:: @ 080CAFF8
.incbin "baserom.gba", 0x0CAFF8, 0x0000018
gUnk_080CB010:: @ 080CB010
.incbin "baserom.gba", 0x0CB010, 0x0000035
gUnk_080CB045:: @ 080CB045
.incbin "baserom.gba", 0x0CB045, 0x0000035
gUnk_080CB07A:: @ 080CB07A
.incbin "baserom.gba", 0x0CB07A, 0x0000035
gUnk_080CB0AF:: @ 080CB0AF
.incbin "baserom.gba", 0x0CB0AF, 0x0000035
gUnk_080CB0E4:: @ 080CB0E4
.incbin "baserom.gba", 0x0CB0E4, 0x0000008
gUnk_080CB0EC:: @ 080CB0EC
.incbin "baserom.gba", 0x0CB0EC, 0x0000008
gUnk_080CB0F4:: @ 080CB0F4
.incbin "baserom.gba", 0x0CB0F4, 0x0000008
gUnk_080CB0FC:: @ 080CB0FC
.incbin "baserom.gba", 0x0CB0FC, 0x0000008
gUnk_080CB104:: @ 080CB104
.incbin "baserom.gba", 0x0CB104, 0x0000070
gUnk_080CB174:: @ 080CB174
.incbin "baserom.gba", 0x0CB174, 0x0000070
gUnk_080CB1E4:: @ 080CB1E4
.incbin "baserom.gba", 0x0CB1E4, 0x0000070
gUnk_080CB254:: @ 080CB254
.incbin "baserom.gba", 0x0CB254, 0x0000070
gUnk_080CB2C4:: @ 080CB2C4
.incbin "baserom.gba", 0x0CB2C4, 0x0000034
gUnk_080CB2F8:: @ 080CB2F8
.incbin "baserom.gba", 0x0CB2F8, 0x0000034
gUnk_080CB32C:: @ 080CB32C
.incbin "baserom.gba", 0x0CB32C, 0x0000034
gUnk_080CB360:: @ 080CB360
.incbin "baserom.gba", 0x0CB360, 0x0000034
gUnk_080CB394:: @ 080CB394
.incbin "baserom.gba", 0x0CB394, 0x0000029
gUnk_080CB3BD:: @ 080CB3BD
.incbin "baserom.gba", 0x0CB3BD, 0x0000029
gUnk_080CB3E6:: @ 080CB3E6
.incbin "baserom.gba", 0x0CB3E6, 0x0000029
gUnk_080CB40F:: @ 080CB40F
.incbin "baserom.gba", 0x0CB40F, 0x0000029
gUnk_080CB438:: @ 080CB438
.incbin "baserom.gba", 0x0CB438, 0x00000C4
gUnk_080CB4FC:: @ 080CB4FC
.incbin "baserom.gba", 0x0CB4FC, 0x0000074

View File

@ -4,282 +4,6 @@
.section .rodata
.align 2
gUnk_080CAA98:: @ 080CAA98
.incbin "baserom.gba", 0x0CAA98, 0x0000018
gUnk_080CAAB0:: @ 080CAAB0
.incbin "baserom.gba", 0x0CAAB0, 0x0000050
gUnk_080CAB00:: @ 080CAB00
.incbin "baserom.gba", 0x0CAB00, 0x0000004
gUnk_080CAB04:: @ 080CAB04
.incbin "baserom.gba", 0x0CAB04, 0x0000004
gUnk_080CAB08:: @ 080CAB08
.incbin "baserom.gba", 0x0CAB08, 0x0000004
gUnk_080CAB0C:: @ 080CAB0C
.incbin "baserom.gba", 0x0CAB0C, 0x0000004
gUnk_080CAB10:: @ 080CAB10
.incbin "baserom.gba", 0x0CAB10, 0x0000004
gUnk_080CAB14:: @ 080CAB14
.incbin "baserom.gba", 0x0CAB14, 0x0000026
gUnk_080CAB3A:: @ 080CAB3A
.incbin "baserom.gba", 0x0CAB3A, 0x0000008
gUnk_080CAB42:: @ 080CAB42
.incbin "baserom.gba", 0x0CAB42, 0x0000008
gUnk_080CAB4A:: @ 080CAB4A
.incbin "baserom.gba", 0x0CAB4A, 0x0000008
gUnk_080CAB52:: @ 080CAB52
.incbin "baserom.gba", 0x0CAB52, 0x0000006
gUnk_080CAB58:: @ 080CAB58
.incbin "baserom.gba", 0x0CAB58, 0x0000010
gUnk_080CAB68:: @ 080CAB68
.incbin "baserom.gba", 0x0CAB68, 0x0000004
gUnk_080CAB6C:: @ 080CAB6C
.incbin "baserom.gba", 0x0CAB6C, 0x0000004
gUnk_080CAB70:: @ 080CAB70
.incbin "baserom.gba", 0x0CAB70, 0x0000004
gUnk_080CAB74:: @ 080CAB74
.incbin "baserom.gba", 0x0CAB74, 0x0000004
gUnk_080CAB78:: @ 080CAB78
.incbin "baserom.gba", 0x0CAB78, 0x0000004
gUnk_080CAB7C:: @ 080CAB7C
.incbin "baserom.gba", 0x0CAB7C, 0x0000010
gUnk_080CAB8C:: @ 080CAB8C
.incbin "baserom.gba", 0x0CAB8C, 0x0000010
gUnk_080CAB9C:: @ 080CAB9C
.incbin "baserom.gba", 0x0CAB9C, 0x0000010
gUnk_080CABAC:: @ 080CABAC
.incbin "baserom.gba", 0x0CABAC, 0x0000010
gUnk_080CABBC:: @ 080CABBC
.incbin "baserom.gba", 0x0CABBC, 0x0000004
gUnk_080CABC0:: @ 080CABC0
.incbin "baserom.gba", 0x0CABC0, 0x0000004
gUnk_080CABC4:: @ 080CABC4
.incbin "baserom.gba", 0x0CABC4, 0x0000004
gUnk_080CABC8:: @ 080CABC8
.incbin "baserom.gba", 0x0CABC8, 0x0000004
gUnk_080CABCC:: @ 080CABCC
.incbin "baserom.gba", 0x0CABCC, 0x0000019
gUnk_080CABE5:: @ 080CABE5
.incbin "baserom.gba", 0x0CABE5, 0x0000019
gUnk_080CABFE:: @ 080CABFE
.incbin "baserom.gba", 0x0CABFE, 0x0000019
gUnk_080CAC17:: @ 080CAC17
.incbin "baserom.gba", 0x0CAC17, 0x0000019
gUnk_080CAC30:: @ 080CAC30
.incbin "baserom.gba", 0x0CAC30, 0x000000C
gUnk_080CAC3C:: @ 080CAC3C
.incbin "baserom.gba", 0x0CAC3C, 0x000000C
gUnk_080CAC48:: @ 080CAC48
.incbin "baserom.gba", 0x0CAC48, 0x000000C
gUnk_080CAC54:: @ 080CAC54
.incbin "baserom.gba", 0x0CAC54, 0x000000C
gUnk_080CAC60:: @ 080CAC60
.incbin "baserom.gba", 0x0CAC60, 0x0000028
gUnk_080CAC88:: @ 080CAC88
.incbin "baserom.gba", 0x0CAC88, 0x0000028
gUnk_080CACB0:: @ 080CACB0
.incbin "baserom.gba", 0x0CACB0, 0x0000028
gUnk_080CACD8:: @ 080CACD8
.incbin "baserom.gba", 0x0CACD8, 0x0000028
gUnk_080CAD00:: @ 080CAD00
.incbin "baserom.gba", 0x0CAD00, 0x0000019
gUnk_080CAD19:: @ 080CAD19
.incbin "baserom.gba", 0x0CAD19, 0x0000019
gUnk_080CAD32:: @ 080CAD32
.incbin "baserom.gba", 0x0CAD32, 0x0000019
gUnk_080CAD4B:: @ 080CAD4B
.incbin "baserom.gba", 0x0CAD4B, 0x0000019
gUnk_080CAD64:: @ 080CAD64
.incbin "baserom.gba", 0x0CAD64, 0x000000C
gUnk_080CAD70:: @ 080CAD70
.incbin "baserom.gba", 0x0CAD70, 0x000000C
gUnk_080CAD7C:: @ 080CAD7C
.incbin "baserom.gba", 0x0CAD7C, 0x000000C
gUnk_080CAD88:: @ 080CAD88
.incbin "baserom.gba", 0x0CAD88, 0x000000C
gUnk_080CAD94:: @ 080CAD94
.incbin "baserom.gba", 0x0CAD94, 0x0000015
gUnk_080CADA9:: @ 080CADA9
.incbin "baserom.gba", 0x0CADA9, 0x0000015
gUnk_080CADBE:: @ 080CADBE
.incbin "baserom.gba", 0x0CADBE, 0x0000015
gUnk_080CADD3:: @ 080CADD3
.incbin "baserom.gba", 0x0CADD3, 0x0000015
gUnk_080CADE8:: @ 080CADE8
.incbin "baserom.gba", 0x0CADE8, 0x0000019
gUnk_080CAE01:: @ 080CAE01
.incbin "baserom.gba", 0x0CAE01, 0x0000019
gUnk_080CAE1A:: @ 080CAE1A
.incbin "baserom.gba", 0x0CAE1A, 0x0000019
gUnk_080CAE33:: @ 080CAE33
.incbin "baserom.gba", 0x0CAE33, 0x0000019
gUnk_080CAE4C:: @ 080CAE4C
.incbin "baserom.gba", 0x0CAE4C, 0x0000019
gUnk_080CAE65:: @ 080CAE65
.incbin "baserom.gba", 0x0CAE65, 0x0000019
gUnk_080CAE7E:: @ 080CAE7E
.incbin "baserom.gba", 0x0CAE7E, 0x0000019
gUnk_080CAE97:: @ 080CAE97
.incbin "baserom.gba", 0x0CAE97, 0x0000019
gUnk_080CAEB0:: @ 080CAEB0
.incbin "baserom.gba", 0x0CAEB0, 0x0000010
gUnk_080CAEC0:: @ 080CAEC0
.incbin "baserom.gba", 0x0CAEC0, 0x0000010
gUnk_080CAED0:: @ 080CAED0
.incbin "baserom.gba", 0x0CAED0, 0x0000010
gUnk_080CAEE0:: @ 080CAEE0
.incbin "baserom.gba", 0x0CAEE0, 0x0000010
gUnk_080CAEF0:: @ 080CAEF0
.incbin "baserom.gba", 0x0CAEF0, 0x0000030
gUnk_080CAF20:: @ 080CAF20
.incbin "baserom.gba", 0x0CAF20, 0x0000030
gUnk_080CAF50:: @ 080CAF50
.incbin "baserom.gba", 0x0CAF50, 0x0000030
gUnk_080CAF80:: @ 080CAF80
.incbin "baserom.gba", 0x0CAF80, 0x0000030
gUnk_080CAFB0:: @ 080CAFB0
.incbin "baserom.gba", 0x0CAFB0, 0x0000018
gUnk_080CAFC8:: @ 080CAFC8
.incbin "baserom.gba", 0x0CAFC8, 0x0000018
gUnk_080CAFE0:: @ 080CAFE0
.incbin "baserom.gba", 0x0CAFE0, 0x0000018
gUnk_080CAFF8:: @ 080CAFF8
.incbin "baserom.gba", 0x0CAFF8, 0x0000018
gUnk_080CB010:: @ 080CB010
.incbin "baserom.gba", 0x0CB010, 0x0000035
gUnk_080CB045:: @ 080CB045
.incbin "baserom.gba", 0x0CB045, 0x0000035
gUnk_080CB07A:: @ 080CB07A
.incbin "baserom.gba", 0x0CB07A, 0x0000035
gUnk_080CB0AF:: @ 080CB0AF
.incbin "baserom.gba", 0x0CB0AF, 0x0000035
gUnk_080CB0E4:: @ 080CB0E4
.incbin "baserom.gba", 0x0CB0E4, 0x0000008
gUnk_080CB0EC:: @ 080CB0EC
.incbin "baserom.gba", 0x0CB0EC, 0x0000008
gUnk_080CB0F4:: @ 080CB0F4
.incbin "baserom.gba", 0x0CB0F4, 0x0000008
gUnk_080CB0FC:: @ 080CB0FC
.incbin "baserom.gba", 0x0CB0FC, 0x0000008
gUnk_080CB104:: @ 080CB104
.incbin "baserom.gba", 0x0CB104, 0x0000070
gUnk_080CB174:: @ 080CB174
.incbin "baserom.gba", 0x0CB174, 0x0000070
gUnk_080CB1E4:: @ 080CB1E4
.incbin "baserom.gba", 0x0CB1E4, 0x0000070
gUnk_080CB254:: @ 080CB254
.incbin "baserom.gba", 0x0CB254, 0x0000070
gUnk_080CB2C4:: @ 080CB2C4
.incbin "baserom.gba", 0x0CB2C4, 0x0000034
gUnk_080CB2F8:: @ 080CB2F8
.incbin "baserom.gba", 0x0CB2F8, 0x0000034
gUnk_080CB32C:: @ 080CB32C
.incbin "baserom.gba", 0x0CB32C, 0x0000034
gUnk_080CB360:: @ 080CB360
.incbin "baserom.gba", 0x0CB360, 0x0000034
gUnk_080CB394:: @ 080CB394
.incbin "baserom.gba", 0x0CB394, 0x0000029
gUnk_080CB3BD:: @ 080CB3BD
.incbin "baserom.gba", 0x0CB3BD, 0x0000029
gUnk_080CB3E6:: @ 080CB3E6
.incbin "baserom.gba", 0x0CB3E6, 0x0000029
gUnk_080CB40F:: @ 080CB40F
.incbin "baserom.gba", 0x0CB40F, 0x0000029
gUnk_080CB438:: @ 080CB438
.incbin "baserom.gba", 0x0CB438, 0x00000C4
gUnk_080CB4FC:: @ 080CB4FC
.incbin "baserom.gba", 0x0CB4FC, 0x0000074
gUnk_080CB570:: @ 080CB570
.incbin "baserom.gba", 0x0CB570, 0x0000018

View File

@ -60,7 +60,7 @@ extern void sub_080791D0();
extern void sub_0805EC9C();
extern void sub_0805EC60();
extern void sub_080873D0();
extern u8 sub_080045D4(s16, s16, u16, u16);
extern u8 sub_080045D4(s16, s16, u32, u32);
extern void sub_0806F69C(Entity*);
extern void sub_0805E3A0(void*, u32);
extern void sub_0806D0B0(Entity*);

View File

@ -330,7 +330,7 @@ SECTIONS {
src/enemy/leever.o(.text);
src/enemy/peahat.o(.text);
src/enemy/rollobite.o(.text);
asm/darkNut.o(.text);
src/enemy/darkNut.o(.text);
src/enemy/hangingSeed.o(.text);
asm/beetle.o(.text);
src/enemy/keese.o(.text);
@ -915,6 +915,8 @@ SECTIONS {
data/peahatAnimations.o(.rodata);
src/enemy/rollobite.o(.rodata);
data/rollobiteAnimations.o(.rodata);
src/enemy/darkNut.o(.rodata);
data/darkNutAnimations.o(.rodata);
data/data_080CAA98.o(.rodata);
src/enemy.o(.rodata);
data/data_080D3D94.o(.rodata);

754
src/enemy/darkNut.c Normal file
View File

@ -0,0 +1,754 @@
#include "entity.h"
#include "functions.h"
typedef struct {
u8 field_0x0;
u8 field_0x1;
} PACKED stuct_080CAB14;
void sub_08021218();
void sub_08021588();
void sub_080213D0();
void sub_08021390();
void sub_0802159C();
void sub_0804AA1C();
void sub_080213F0();
u32 sub_080214FC();
void sub_08021540();
void sub_08021600();
void sub_080213B0();
u32 sub_08049F64();
u32 sub_0802169C();
void sub_0802124C();
void sub_08021644();
void sub_08021414();
void sub_08021400();
u32 sub_08021274(u32, u32);
u32 sub_08021664(Entity*, Entity*);
u32 sub_0804A044(Entity*, Entity*, u32);
void sub_08021424(Entity*);
extern Entity* gUnk_020000B0;
extern void (*const gUnk_080CAA98[])(Entity*);
extern void (*const gUnk_080CAAB0[])(Entity*);
extern const s8 gUnk_080CAB00[];
extern const s8 gUnk_080CAB04[];
extern const u8 gUnk_080CAB08[];
extern const s8 gUnk_080CAB0C[];
extern const s8 gUnk_080CAB10[];
extern const stuct_080CAB14 gUnk_080CAB14[];
extern const u8 gUnk_080CAB3A[];
extern const u8 gUnk_080CAB42[];
extern const u8 gUnk_080CAB4A[];
extern const u8 gUnk_080CAB52[];
extern const u8 gUnk_080CAB68[];
extern void (*const gUnk_080CAB58[])(Entity*);
void DarkNut(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CAA98);
SetChildOffset(this, 0, 1, -22);
}
void sub_08020BA0(Entity* this) {
gUnk_080CAAB0[this->action](this);
}
void sub_08020BB8(Entity* this) {
switch (this->bitfield & 0x7f) {
case 0x1c:
this->action = 11;
this->actionDelay = gUnk_080CAB0C[this->entityType.form];
this->damageType = 81;
sub_08021218(this, 8, (((this->field_0x3e ^ 0x10) + 4) & 0x18) >> 3);
sub_08021588(this);
sub_0804A9FC(this, 0x1c);
break;
case 0x16:
this->action = 11;
this->actionDelay = gUnk_080CAB10[this->entityType.form];
this->damageType = 81;
sub_08021218(this, 8, (((this->field_0x3e ^ 0x10) + 4) & 0x18) >> 3);
sub_08021588(this);
sub_0804A9FC(this, 0x1c);
break;
case 0x4b:
if (this->action == 13 || this->action == 15 || this->action == 19 || this->action == 18)
break;
switch (this->field_0x78.HALF.HI) {
case 8 ... 12:
this->field_0x7a.HALF.LO = gUnk_080CAB04[this->entityType.form];
break;
case 4 ... 6:
this->field_0x7a.HALF.LO = gUnk_080CAB00[this->entityType.form];
break;
default:
this->field_0x7a.HALF.LO = 0;
break;
}
this->action = 10;
sub_08021218(this, 0xb, this->animationState);
sub_08004488(0x15d);
sub_08021588(this);
break;
case 0x4c:
if (this->action == 15) {
u8 bVar3 = 0xff;
if (this->attachedEntity != NULL) {
bVar3 = this->attachedEntity->bitfield & 0x7f;
}
if (bVar3 == 2) {
sub_080213D0(this, gUnk_080CAB08[this->entityType.form]);
} else {
sub_080213D0(this, 0);
}
}
break;
default:
if (this->currentHealth != this->field_0x78.HALF.LO) {
sub_08021588(this);
sub_08021390(this);
sub_0804AA1C(this);
}
break;
}
this->field_0x78.HALF.LO = this->currentHealth;
sub_0804AA30(this, gUnk_080CAA98);
}
void nullsub_129(Entity* this) {
}
void sub_08020D70(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x74.HALF.HI = 0;
this->field_0x78.HALF.LO = this->currentHealth;
this->animationState = -1;
sub_08021218(this, 0, 2);
}
void sub_08020D9C(Entity* this) {
if (sub_08049FDC(this, 1))
sub_080213F0(this);
}
void sub_08020DB4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 0x80)
sub_08021390(this);
}
void sub_08020DD4(Entity* this) {
if (sub_080214FC(this)) {
sub_080213F0(this);
} else if (--this->field_0x76.HWORD == 0) {
this->action = 5;
sub_08021218(this, 5, this->animationState);
} else {
if (--this->actionDelay == 0)
sub_08021540(this);
sub_080AEF88(this);
UpdateAnimationSingleFrame(this);
}
}
void sub_08020E28(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 0x80)
sub_080213B0(this);
}
void sub_08020E48(Entity* this) {
if (sub_080214FC(this)) {
sub_080213F0(this);
} else {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 0x80)
sub_080213B0(this);
}
}
void sub_08020E78(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 0x80)
sub_08021390(this);
}
void sub_08020E98(Entity* this) {
if (sub_08049F64(this, 1, 0x38)) {
if (sub_0802169C(this, gUnk_020000B0)) {
this->action = 8;
sub_08021218(this, 7, this->animationState);
} else {
this->direction = GetFacingDirection(gUnk_020000B0, this);
if (sub_080AEF88(this) == 0) {
this->action = 8;
sub_08021218(this, 7, this->animationState);
} else {
this->direction ^= 0x10;
sub_0802124C(this);
sub_08021644(this);
}
}
} else {
if (gUnk_020000B0 == NULL) {
sub_08021414(this);
} else {
this->direction = GetFacingDirection(this, gUnk_020000B0);
sub_080AEF88(this);
sub_0802124C(this);
sub_08021644(this);
}
}
}
void sub_08020F28(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 0x80)
sub_08021400(this);
}
void sub_08020F48(Entity* this) {
if (sub_08049F64(this, 1, 0x48)) {
if (sub_08021664(this, gUnk_020000B0)) {
u32 uVar2 = sub_0804A044(this, gUnk_020000B0, 9);
if (uVar2 == 0xff) {
sub_08021424(this);
} else {
Entity* pEVar3;
this->action = 14;
sub_08021218(this, 13, uVar2 >> 3);
pEVar3 = sub_0804A98C(this, 0, 1);
if (pEVar3) {
pEVar3->parent = this;
this->attachedEntity = pEVar3;
}
}
} else {
sub_08021424(this);
}
} else {
sub_08021390(this);
}
}
void sub_08020FAC(Entity* this) {
if (this->frames.all & 0x80) {
if (this->field_0x7a.HALF.LO) {
this->field_0x7a.HALF.LO--;
} else {
this->hurtBlinkTime = -8;
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
}
}
void sub_08020FE4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (--this->actionDelay == 0) {
this->action = 12;
sub_08021218(this, 9, this->animationState);
sub_0804AA1C(this);
}
}
void sub_08021010(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 0x80) {
this->damageType = 0x56;
sub_080213F0(this);
}
}
void sub_08021038(Entity* this) {
if (this->attachedEntity == NULL && this->frames.all) {
Entity* pEVar2 = (Entity*)sub_0804A98C(this, 0, 0);
if (pEVar2) {
pEVar2->parent = this;
this->attachedEntity = pEVar2;
}
sub_08004488(270);
}
if (this->frames.all & 0x80) {
sub_08021588(this);
if (this->field_0x7c.BYTES.byte0) {
this->field_0x7c.BYTES.byte0--;
} else {
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
if (this->frames.all == 4)
this->damageType = 81;
}
}
void sub_080210A8(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 1) {
this->frames.all = 0;
sub_08021588(this);
sub_08004488(349);
} else if (this->frames.all & 0x80) {
sub_08021390(this);
}
}
void sub_080210E4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 1) {
Entity* ent;
this->frames.all &= ~1;
ent = sub_0804A98C(this, 0, 2);
if (ent) {
ent->parent = this;
this->attachedEntity = ent;
}
sub_08004488(270);
}
sub_08021644(this);
if ((this->frames.all & 0x10) &&
(!sub_080AEF88(this) || (this->attachedEntity && (this->attachedEntity->bitfield & 0x80)))) {
sub_080213D0(this, 0);
} else {
if (--this->field_0x76.HWORD == 0)
sub_080213D0(this, 0);
}
}
void sub_08021170(Entity* this) {
if (this->frames.all & 0x80) {
if (this->field_0x7a.HALF.HI) {
this->field_0x7a.HALF.HI--;
} else {
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
}
}
void sub_080211A0(Entity* this) {
if (sub_080214FC(this)) {
sub_08021390(this);
} else {
UpdateAnimationSingleFrame(this);
if (this->frames.all & 0x80)
sub_080213B0(this);
}
}
void sub_080211D0(Entity* this)
{
UpdateAnimationSingleFrame(this);
sub_0802159C(this);
if (this->frames.all & 0x80)
sub_08021390(this);
}
void sub_080211F4(Entity* this) {
UpdateAnimationSingleFrame(this);
sub_08021600(this);
if (this->frames.all & 0x80)
sub_08021390(this);
}
void sub_08021218(Entity* this, u32 param_2, u32 param_3) {
const stuct_080CAB14* unk;
if (this->field_0x74.HALF.LO == param_2 && this->animationState == param_3)
return;
this->animationState = param_3;
this->field_0x74.HALF.LO = param_2;
unk = &gUnk_080CAB14[param_2];
this->spriteIndex = unk->field_0x1;
InitAnimationForceUpdate(this, unk->field_0x0 + param_3);
}
void sub_0802124C(Entity* this) {
u32 iVar1 = sub_08021274(this->animationState, this->direction);
if (iVar1 != 0xff) {
sub_08021218(this, this->field_0x74.HALF.LO, iVar1);
} else {
UpdateAnimationSingleFrame(this);
}
}
NAKED
u32 sub_08021274(u32 a, u32 b) {
asm(".include \"asm/non_matching/darkNut/sub_08021274.inc\"");
}
void sub_080212B0(Entity* this) {
u8 tmp;
switch (this->field_0x74.HALF.HI) {
default:
this->field_0x74.HALF.HI = 1;
tmp = gUnk_080CAB3A[Random() & 7];
break;
case 1:
this->field_0x74.HALF.HI = 2;
tmp = gUnk_080CAB42[Random() & 7];
break;
case 2:
this->field_0x74.HALF.HI = 0;
tmp = gUnk_080CAB4A[Random() & 7];
break;
}
if (this->entityType.form < 2 && tmp == 2)
tmp = gUnk_080CAB52[Random() & 3];
this->attachedEntity = NULL;
gUnk_080CAB58[tmp](this);
}
void sub_08021328(Entity* this) {
this->action = 13;
this->field_0x7c.BYTES.byte0 = gUnk_080CAB68[this->entityType.form];
sub_08021218(this, 0xc, this->animationState);
}
void sub_0802134C(Entity* this) {
this->action = 15;
this->direction = this->animationState << 3;
this->nonPlanarMovement = 0x200;
this->field_0x76.HWORD = 0x78;
sub_08021218(this, 0xe, this->animationState);
}
void sub_08021370(Entity* this) {
this->action = 18;
sub_08021218(this, 0x10, this->animationState);
}
void sub_08021380(Entity* this) {
this->action = 19;
sub_08021218(this, 0x11, this->animationState);
}
void sub_08021390(Entity* this) {
this->action = 7;
this->nonPlanarMovement = 0x200;
this->damageType = 0x56;
sub_08021218(this, 6, this->animationState);
}
void sub_080213B0(Entity* this) {
this->action = 3;
this->actionDelay = 1;
this->nonPlanarMovement = 0xc0;
this->field_0x76.HWORD = 0xf0;
sub_08021218(this, 3, this->animationState);
}
void sub_080213D0(Entity* this, u32 param_2) {
this->action = 16;
this->field_0x7a.HALF.HI = param_2;
sub_08021218(this, 0xf, this->animationState);
sub_08021588(this);
}
void sub_080213F0(Entity* this) {
this->action = 6;
sub_08021218(this, 1, this->animationState);
}
void sub_08021400(Entity* this) {
this->action = 9;
this->nonPlanarMovement = 0x60;
sub_08021218(this, 10, this->animationState);
}
void sub_08021414(Entity* this) {
this->action = 17;
sub_08021218(this, 5, this->animationState);
}
void sub_08021424(Entity* this) {
s32 x, y;
u32 tmp;
u32 dir = GetFacingDirection(this, gUnk_020000B0);
tmp = sub_08021274(this->animationState, dir);
if (tmp != 0xff) {
sub_08021218(this, this->field_0x74.HALF.LO, tmp);
} else {
tmp = this->animationState;
}
switch (tmp) {
case 0:
x = gUnk_020000B0->x.HALF.HI;
y = gUnk_020000B0->y.HALF.HI + 0x2c;
break;
case 1:
x = gUnk_020000B0->x.HALF.HI - 0x24;
y = gUnk_020000B0->y.HALF.HI;
break;
case 2:
x = gUnk_020000B0->x.HALF.HI;
y = gUnk_020000B0->y.HALF.HI - 0x1d;
break;
default:
x = gUnk_020000B0->x.HALF.HI + 0x24;
y = gUnk_020000B0->y.HALF.HI;
break;
}
if (!(6 < (x - this->x.HALF.HI) + 3U) && !(4 < (y - this->y.HALF.HI) + 2U)) {
sub_080212B0(this);
} else {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, x, y);
if (!sub_080AEF88(this)) {
sub_080212B0(this);
} else {
UpdateAnimationSingleFrame(this);
}
}
}
u32 sub_080214FC(Entity* this) {
u32 direction;
if (!sub_08049FDC(this, 1))
return 0;
direction = GetFacingDirection(this, gUnk_020000B0);
if (4 < (direction - (this->frames.all & 0x1f)) - 2)
return 0;
this->animationState = ((direction + 4) & 0x18) >> 3;
return 1;
}
void sub_08021540(Entity* this) {
u32 tmp, tmp2;
u32 rand;
rand = Random();
if (!sub_08049FA0(this) && (rand & 1)) {
tmp2 = (sub_08049EE4(this) + 4) & 0x18;
} else {
tmp2 = (rand >> 0x10) & 0x18;
}
this->direction = tmp2;
tmp = sub_08021274(this->animationState, tmp2);
if (tmp != 0xff)
sub_08021218(this, 3, tmp);
this->actionDelay = 30;
}
void sub_08021588(Entity* this) {
if (this->attachedEntity) {
this->attachedEntity->parent = NULL;
this->attachedEntity = NULL;
}
}
void sub_0802159C(Entity* this) {
if (this->frames.all == 1) {
Entity* ent;
this->frames.all = 0;
this->damageType = 0x51;
ent = sub_0804A98C(this, 0, 3);
if (ent) {
ent->parent = this;
this->attachedEntity = ent;
}
sub_08004488(0x116);
} else if (this->frames.all == 2) {
this->frames.all = 0;
sub_08021588(this);
} else if (this->frames.all & 0x20) {
this->frames.all &= ~0x20;
sub_08004488(0x115);
}
}
void sub_08021600(Entity* this) {
if (this->frames.all == 1) {
Entity* ent;
this->frames.all = 0;
this->damageType = 0x51;
ent = sub_0804A98C(this, 0, 4);
if (ent) {
ent->parent = this;
this->attachedEntity = ent;
}
sub_08004488(0x10e);
} else if (this->frames.all == 2) {
this->frames.all = 0;
sub_08021588(this);
}
}
void sub_08021644(Entity* this) {
if (this->frames.all & 0x20) {
this->frames.all &= ~0x20;
sub_08004488(0x7d);
}
}
extern u32 sub_08049F1C(Entity*, Entity*, u32);
u32 sub_08021664(Entity* this, Entity* ent) {
switch (this->animationState) {
case 0:
return sub_08049F1C(this, ent, 0x22);
case 1:
return sub_08049F1C(this, ent, 0x1a);
case 2:
return sub_08049F1C(this, ent, 0x13);
case 3:
return sub_08049F1C(this, ent, 0x1a);
}
return 0;
}
u32 sub_0802169C(Entity* this, Entity* ent) {
u32 ret;
switch (this->animationState) {
case 0:
ret = 0x2c;
break;
case 2:
ret = 0x1d;
break;
case 1:
case 3:
ret = 0x24;
break;
default:
return 0;
}
if (sub_08049F1C(this, ent, ret)) {
return 0;
} else {
return 1;
}
}
// clang-format off
void (*const gUnk_080CAA98[])(Entity*) = {
sub_08020BA0,
sub_08020BB8,
sub_08001324,
sub_0804A7D4,
sub_08001242,
nullsub_129,
};
void (*const gUnk_080CAAB0[])(Entity*) = {
sub_08020D70,
sub_08020D9C,
sub_08020DB4,
sub_08020DD4,
sub_08020E28,
sub_08020E48,
sub_08020E78,
sub_08020E98,
sub_08020F28,
sub_08020F48,
sub_08020FAC,
sub_08020FE4,
sub_08021010,
sub_08021038,
sub_080210A8,
sub_080210E4,
sub_08021170,
sub_080211A0,
sub_080211D0,
sub_080211F4,
};
const s8 gUnk_080CAB00[] = {
30, 30, 20, 10,
};
const s8 gUnk_080CAB04[] = {
60, 60, 45, 30,
};
const u8 gUnk_080CAB08[] = {
90, 90, 60, 30,
};
const s8 gUnk_080CAB0C[] = {
90, 90, 60, 30,
};
const s8 gUnk_080CAB10[] = {
90, 90, 45, 8,
};
const stuct_080CAB14 gUnk_080CAB14[] = {
{0x00, 0x62},
{0x04, 0x62},
{0x08, 0x62},
{0x0C, 0x62},
{0x10, 0x62},
{0x14, 0x62},
{0x18, 0x62},
{0x1C, 0x62},
{0x20, 0x62},
{0x24, 0x62},
{0x28, 0x62},
{0x2C, 0x62},
{0x00, 0x63},
{0x04, 0x63},
{0x08, 0x63},
{0x0C, 0x63},
{0x10, 0x63},
{0x14, 0x63},
{0x18, 0x63},
};
const u8 gUnk_080CAB3A[] = {
0, 1, 1, 0, 3, 0, 1, 0,
};
const u8 gUnk_080CAB42[] = {
1, 1, 3, 0, 1, 2, 0, 0,
};
const u8 gUnk_080CAB4A[] = {
0, 0, 3, 1, 2, 2, 3, 1,
};
const u8 gUnk_080CAB52[] = {
0, 3, 1, 0, 0, 0
};
void (*const gUnk_080CAB58[])(Entity*) = {
sub_08021328,
sub_0802134C,
sub_08021370,
sub_08021380,
};
const u8 gUnk_080CAB68[] = {
90, 90, 45, 7,
};
// clang-format on