Partially document lakitu.c

Also ran the newline portion of format.sh and split some data files
This commit is contained in:
21aslade 2020-07-07 19:24:38 -06:00
parent d21a0afec2
commit f6f4d25bb9
14 changed files with 2412 additions and 2347 deletions

File diff suppressed because it is too large Load Diff

113
data/data_080D0154.s Normal file
View File

@ -0,0 +1,113 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_080D015C:: @ 080D015C
.incbin "baserom.gba", 0x0D015C, 0x0000011
gUnk_080D016D:: @ 080D016D
.incbin "baserom.gba", 0x0D016D, 0x0000011
gUnk_080D017E:: @ 080D017E
.incbin "baserom.gba", 0x0D017E, 0x0000011
gUnk_080D018F:: @ 080D018F
.incbin "baserom.gba", 0x0D018F, 0x0000011
gUnk_080D01A0:: @ 080D01A0
.incbin "baserom.gba", 0x0D01A0, 0x0000011
gUnk_080D01B1:: @ 080D01B1
.incbin "baserom.gba", 0x0D01B1, 0x0000011
gUnk_080D01C2:: @ 080D01C2
.incbin "baserom.gba", 0x0D01C2, 0x0000011
gUnk_080D01D3:: @ 080D01D3
.incbin "baserom.gba", 0x0D01D3, 0x0000011
gUnk_080D01E4:: @ 080D01E4
.incbin "baserom.gba", 0x0D01E4, 0x000000B
gUnk_080D01EF:: @ 080D01EF
.incbin "baserom.gba", 0x0D01EF, 0x000001D
gUnk_080D020C:: @ 080D020C
.incbin "baserom.gba", 0x0D020C, 0x0000004
gUnk_080D0210:: @ 080D0210
.incbin "baserom.gba", 0x0D0210, 0x0000001
gUnk_080D0211:: @ 080D0211
.incbin "baserom.gba", 0x0D0211, 0x0000014
gUnk_080D0225:: @ 080D0225
.incbin "baserom.gba", 0x0D0225, 0x0000041
gUnk_080D0266:: @ 080D0266
.incbin "baserom.gba", 0x0D0266, 0x0000041
gUnk_080D02A7:: @ 080D02A7
.incbin "baserom.gba", 0x0D02A7, 0x0000041
gUnk_080D02E8:: @ 080D02E8
.incbin "baserom.gba", 0x0D02E8, 0x000000B
gUnk_080D02F3:: @ 080D02F3
.incbin "baserom.gba", 0x0D02F3, 0x0000003
gUnk_080D02F6:: @ 080D02F6
.incbin "baserom.gba", 0x0D02F6, 0x0000001
gUnk_080D02F7:: @ 080D02F7
.incbin "baserom.gba", 0x0D02F7, 0x0000002
gUnk_080D02F9:: @ 080D02F9
.incbin "baserom.gba", 0x0D02F9, 0x0000003
gUnk_080D02FC:: @ 080D02FC
.incbin "baserom.gba", 0x0D02FC, 0x0000004
gUnk_080D0300:: @ 080D0300
.incbin "baserom.gba", 0x0D0300, 0x000000A
gUnk_080D030A:: @ 080D030A
.incbin "baserom.gba", 0x0D030A, 0x0000011
gUnk_080D031B:: @ 080D031B
.incbin "baserom.gba", 0x0D031B, 0x0000011
gUnk_080D032C:: @ 080D032C
.incbin "baserom.gba", 0x0D032C, 0x0000011
gUnk_080D033D:: @ 080D033D
.incbin "baserom.gba", 0x0D033D, 0x0000011
gUnk_080D034E:: @ 080D034E
.incbin "baserom.gba", 0x0D034E, 0x0000011
gUnk_080D035F:: @ 080D035F
.incbin "baserom.gba", 0x0D035F, 0x0000011
gUnk_080D0370:: @ 080D0370
.incbin "baserom.gba", 0x0D0370, 0x0000011
gUnk_080D0381:: @ 080D0381
.incbin "baserom.gba", 0x0D0381, 0x0000011
gUnk_080D0392:: @ 080D0392
.incbin "baserom.gba", 0x0D0392, 0x0000011
gUnk_080D03A3:: @ 080D03A3
.incbin "baserom.gba", 0x0D03A3, 0x0000011
gUnk_080D03B4:: @ 080D03B4
.incbin "baserom.gba", 0x0D03B4, 0x000003C
gUnk_080D03F0:: @ 080D03F0
.incbin "baserom.gba", 0x0D03F0, 0x0000014
gUnk_080D0404:: @ 080D0404
.incbin "baserom.gba", 0x0D0404, 0x0000014

2081
data/data_080D0448.s Normal file

File diff suppressed because it is too large Load Diff

84
include/lakitu.h Normal file
View File

@ -0,0 +1,84 @@
#ifndef LAKITU_H
#define LAKITU_H
// Lakitu
extern void EnemyFunctionHandler(Entity *, void (*const funcs[])(Entity*));
extern void SetChildOffset(Entity *, u32, u32, u32);
// sub_0803C784
extern void sub_0804A9FC(Entity *, u32);
extern void sub_0804AA30(Entity *, void (*const funcs[])(Entity *));
// sub_0803C820
extern u32 sub_0806F520(Entity *);
// sub_0803C850
extern void sub_0806F4E8(Entity *);
// Lakitu_Initialize
extern void sub_0804A720(Entity *);
// Lakitu_Cloudless
extern u32 sub_08003FC4(Entity *, u32);
// sub_0803CA4C
extern u32 sub_080041A0(Entity *, Entity *, u32, u32);
// sub_0803CAD0
extern u8 sub_080045D4(s16, s16, u16, u16);
extern void sub_080AEFE0(Entity *);
// Lakitu_SpawnLightning
extern void PositionRelative(Entity *, Entity *, u32, u32);
extern void sub_08004488(u32);
// sub_0803CC08
extern void DeleteEntity(Entity *);
// Part of function tables
extern void sub_08001324(Entity *);
extern void sub_0804A7D4(Entity *);
extern void sub_08001242(Entity *);
// Used in multiple functions
extern Entity *CreateFx(Entity*, u32, u32);
extern Entity *sub_0804A98C(Entity *positionEntity, u8 subtype, u8 form); // Creates a projectile positioned at the given entity
extern void UpdateAnimationSingleFrame(Entity *);
extern void InitAnimationForceUpdate(Entity *, u32);
extern u32 sub_0806FCB8(Entity *, u32, u32, u32);
extern u32 sub_080045C4(Entity *, Entity *);
// Forward references to functions in lakitu.c
extern void sub_0803CAD0(Entity *);
extern void sub_0803CBAC(Entity *);
extern void sub_0803CA84(Entity *, u32);
extern bool32 sub_0803CA4C(Entity *);
extern bool32 sub_0803CB04(Entity *);
extern void Lakitu_SpawnLightning(Entity *);
extern void sub_0803CB34(Entity *);
extern void sub_0803CC08(Entity *this);
enum {
INIT,
HIDDEN,
END_HIDE,
IDLE,
BEGIN_HIDE,
LIGHTNING_THROW,
LIGHTNING_DELAY,
CLOUDLESS,
};
extern void (*const gUnk_080D0110[])(Entity *);
extern void (*const LakituActionFuncs[])(Entity *);
extern void (*const gUnk_080D0148[])(Entity *);
typedef struct {
s8 x;
s8 y;
} PACKED OffsetCoords;
extern const OffsetCoords gUnk_080D0154[];
#endif // LAKITU_H

View File

@ -890,6 +890,10 @@ SECTIONS {
data/data_080B3740.o(.rodata);
src/trig.o(.rodata);
data/data_080C93E0.o(.rodata);
src/lakitu.o(.rodata);
data/data_080D0154.o(.rodata);
src/lakituCloud.o(.rodata);
data/data_080D0448.o(.rodata);
src/enemy.o(.rodata);
data/data_080D3D94.o(.rodata);
data/areaPropertyLists.o(.rodata);

View File

@ -38,4 +38,4 @@ void sub_0803C198(Entity *this)
}
}
void nullsub_168(Entity* this){}
void nullsub_168(Entity* this){}

View File

@ -37,4 +37,4 @@ void sub_08021720(Entity *this)
this->ticks.b0 = 3;
}
void nullsub_08(Entity* this){}
void nullsub_08(Entity* this){}

View File

@ -4,78 +4,7 @@
#include "random.h"
#include "link.h"
// Lakitu
extern void EnemyFunctionHandler(Entity *, void (*const funcs[])(Entity*));
extern void SetChildOffset(Entity *, u32, u32, u32);
// sub_0803C758
extern void sub_0803CAD0(Entity *);
// sub_0803C784
extern void sub_0803CBAC(Entity *); // Also used in sub_0803C86C
extern Entity *CreateFx(Entity*, u32, u32);
extern void sub_0804A9FC(Entity *, u32);
extern void sub_0804AA30(Entity *, void (*const funcs[])(Entity *));
// sub_0803C820
extern u32 sub_0806F520(Entity *);
// sub_0803C850
extern void sub_0806F4E8(Entity *);
// sub_0803C87C
extern Entity *sub_0804A98C(Entity *, u32, u32);
extern void sub_0804A720(Entity *);
// sub_0803C8BC and sub_0803C918
extern void sub_0803CA84(Entity *, u32);
extern bool32 sub_0803CA4C(Entity *);
// Many functions
extern void UpdateAnimationSingleFrame(Entity *);
extern void InitAnimationForceUpdate(Entity *, u32);
// sub_0803C918
extern u32 sub_0803CB04(Entity *);
// sub_0803C97C
extern void sub_0803CB64(Entity *);
// sub_0803C9D4 and sub_0803CB04
extern void sub_0803CB34(Entity *);
// sub_0803CA0C
extern u32 sub_08003FC4(Entity *, u32);
extern void sub_0803CC08(Entity *this);
// sub_0803CA4C
extern u32 sub_0806FCB8(Entity *, u32, u32, u32);
extern u32 sub_080041A0(Entity *, Entity *, u32, u32);
// sub_0803CA84
extern u32 sub_080045C4(Entity *, Entity *);
// sub_0803CAD0
extern u8 sub_080045D4(s16, s16, u16, u16);
extern void sub_080AEFE0(Entity *);
// sub_0803CB64
extern void PositionRelative(Entity *, Entity *, u32, u32);
extern void sub_08004488(u32);
typedef struct {
s8 x;
s8 y;
} PACKED OffsetCoords;
// sub_0803CC08
extern void DeleteEntity(Entity *);
// Variables
extern void (*const gUnk_080D0110[])(Entity *);
extern void (*const gUnk_080D0128[])(Entity *);
extern void (*const gUnk_080D0148[])(Entity *);
extern const OffsetCoords gUnk_080D0154[];
#include "lakitu.h"
void Lakitu(Entity *this) {
EnemyFunctionHandler(this, gUnk_080D0110);
@ -83,12 +12,12 @@ void Lakitu(Entity *this) {
SetChildOffset(this, 0, 1, -16);
}
void sub_0803C758(Entity *this) {
void Lakitu_DoAction(Entity *this) {
if (this->action != 0 && this->action != 7) {
sub_0803CAD0(this);
}
gUnk_080D0128[this->action](this);
LakituActionFuncs[this->action](this);
}
void sub_0803C784(Entity *this) {
@ -99,9 +28,9 @@ void sub_0803C784(Entity *this) {
}
else {
if (this->damageType == 0x43) {
Entity *sound = CreateFx(this, 2, 0);
Entity *fx = CreateFx(this, 2, 0);
if (sound != 0) {
if (fx != NULL) {
u32 angle = (this->field_0x3e ^ 0x10) << 3;
s32 sine;
@ -110,14 +39,14 @@ void sub_0803C784(Entity *this) {
sine += 0x1f;
}
sound->x.HALF.HI += sine >> 5;
fx->x.HALF.HI += sine >> 5;
sine = gSineTable[angle + 0x40];
if (sine < 0) {
sine += 0x1f;
}
sound->y.HALF.HI -= sine >> 5;
fx->y.HALF.HI -= sine >> 5;
}
}
}
@ -142,7 +71,7 @@ void sub_0803C844(Entity *this) {
void sub_0803C850(Entity *this) {
Entity *cloud = this->attachedEntity;
if (cloud != 0) {
if (cloud != NULL) {
cloud->spriteOffsetX = this->spriteOffsetX;
}
@ -151,12 +80,12 @@ void sub_0803C850(Entity *this) {
void sub_0803C86C(Entity *this) {
sub_0803CBAC(this);
this->attachedEntity = 0;
this->attachedEntity = NULL;
}
void sub_0803C87C(Entity *this) {
void Lakitu_Initialize(Entity *this) {
Entity *cloud = sub_0804A98C(this, 17, 0);
if (cloud == 0) {
if (cloud == NULL) {
return;
}
@ -165,7 +94,7 @@ void sub_0803C87C(Entity *this) {
sub_0804A720(this);
this->action = 1;
this->action = HIDDEN;
this->height.HALF.HI = -2;
@ -175,20 +104,20 @@ void sub_0803C87C(Entity *this) {
this->field_0x76 = this->y.HALF.HI;
}
void sub_0803C8BC(Entity *this) {
void Lakitu_Hide(Entity *this) {
sub_0803CA84(this, 0);
if (sub_0803CA4C(this)) {
this->action = 2;
this->action = END_HIDE;
this->spriteSettings.b.ss0 = 1;
}
}
void sub_0803C8E4(Entity *this) {
void Lakitu_EndHide(Entity *this) {
UpdateAnimationSingleFrame(this);
if (this->frames.b.f3) {
this->action = 3;
this->action = IDLE;
this->actionDelay = 0x3c;
this->damageType = 0x42;
@ -197,13 +126,13 @@ void sub_0803C8E4(Entity *this) {
}
}
void sub_0803C918(Entity *this) {
if (sub_0803CB04(this) != 0) {
void Lakitu_Idle(Entity *this) {
if (sub_0803CB04(this)) {
return;
}
if (sub_0803CA4C(this) == 0) {
this->action = 4;
if (!sub_0803CA4C(this)) {
this->action = BEGIN_HIDE;
this->damageType = 0x43;
InitAnimationForceUpdate(this, this->animationState + 0xc);
@ -213,42 +142,44 @@ void sub_0803C918(Entity *this) {
}
}
void sub_0803C950(Entity *this) {
void Lakitu_BeginHide(Entity *this) {
UpdateAnimationSingleFrame(this);
if (this->frames.b.f3 != 0) {
this->action = 1;
this->action = HIDDEN;
this->spriteSettings.b.ss0 = 0;
InitAnimationForceUpdate(this, this->animationState);
}
}
void sub_0803C97C(Entity *this) {
void Lakitu_Lightning(Entity *this) {
UpdateAnimationSingleFrame(this);
if (this->frames.b.f3 == 0) {
return;
}
sub_0803CB64(this);
this->action = 6;
Lakitu_SpawnLightning(this);
this->action = LIGHTNING_DELAY;
this->damageType = 0x42;
if ((Random() & 1) && this->field_0x78.HALF.HI == 0) {
if ((Random() & 1) && !this->field_0x78.HALF.HI) {
this->actionDelay = 0xf;
this->field_0x78.HALF.HI = 1;
this->field_0x78.HALF.HI = TRUE;
}
else {
this->actionDelay = 0x1e;
this->field_0x78.HALF.HI = 0;
this->field_0x78.HALF.HI = FALSE;
InitAnimationForceUpdate(this->attachedEntity, this->animationState);
}
}
void sub_0803C9D4(Entity *this) {
void Lakitu_LightningDelay(Entity *this) {
this->actionDelay--;
if (this->actionDelay != 0) {
@ -259,14 +190,14 @@ void sub_0803C9D4(Entity *this) {
sub_0803CB34(this);
}
else {
this->action = 3;
this->action = IDLE;
this->actionDelay = 0xb4;
InitAnimationForceUpdate(this, this->animationState + 4);
}
}
void sub_0803CA0C(Entity *this) {
void Lakitu_Cloudless(Entity *this) {
if (sub_08003FC4(this, 0x1800) == 0 && this->animIndex <= 19) {
InitAnimationForceUpdate(this, this->animationState + 20);
@ -331,7 +262,7 @@ bool32 sub_0803CB04(Entity *this) {
}
void sub_0803CB34(Entity *this) {
this->action = 5;
this->action = LIGHTNING_THROW;
this->damageType = 0xa6;
this->field_0x78.HALF.LO = sub_080045C4(this, &gLinkEntity);
@ -339,21 +270,21 @@ void sub_0803CB34(Entity *this) {
InitAnimationForceUpdate(this, this->animationState + 8);
}
void sub_0803CB64(Entity *this) {
Entity *cloud;
void Lakitu_SpawnLightning(Entity *this) {
Entity *lightning;
const OffsetCoords *offset;
cloud = sub_0804A98C(this, 18, 0);
lightning = sub_0804A98C(this, 18, 0);
if (cloud == 0) {
if (lightning == NULL) {
return;
}
offset = &gUnk_080D0154[this->animationState];
cloud->direction = this->field_0x78.HALF.LO;
lightning->direction = this->field_0x78.HALF.LO;
PositionRelative(this, cloud, offset->x << 16, offset->y << 16);
PositionRelative(this, lightning, offset->x << 16, offset->y << 16);
sub_08004488(0x193);
}
@ -362,12 +293,12 @@ void sub_0803CBAC(Entity *this) {
Entity *cloud;
cloud = this->attachedEntity;
if (cloud != 0) {
if (cloud != NULL) {
cloud->flags |= 0x80;
cloud->damageType = 0x43;
}
this->action = 7;
this->action = CLOUDLESS;
this->spriteSettings.b.ss0 = 1;
this->ticks.b1 = 1;
@ -381,10 +312,10 @@ void sub_0803CBAC(Entity *this) {
void sub_0803CC08(Entity *this) {
Entity *cloud;
Entity *sound;
Entity *fx;
cloud = this->attachedEntity;
if (cloud == 0) {
if (cloud == NULL) {
return;
}
@ -400,30 +331,63 @@ void sub_0803CC08(Entity *this) {
return;
}
sound = CreateFx(this, 2, 0);
if (sound != 0) {
sound->x.HALF.HI += 6;
sound->y.HALF.HI += 6;
fx = CreateFx(this, 2, 0);
if (fx != NULL) {
fx->x.HALF.HI += 6;
fx->y.HALF.HI += 6;
}
sound = CreateFx(this, 2, 0);
if (sound != 0) {
sound->x.HALF.HI -= 6;
sound->y.HALF.HI += 6;
fx = CreateFx(this, 2, 0);
if (fx != NULL) {
fx->x.HALF.HI -= 6;
fx->y.HALF.HI += 6;
}
sound = CreateFx(this, 2, 0);
if (sound != 0) {
sound->x.HALF.HI += 6;
sound->y.HALF.HI -= 6;
fx = CreateFx(this, 2, 0);
if (fx != NULL) {
fx->x.HALF.HI += 6;
fx->y.HALF.HI -= 6;
}
sound = CreateFx(this, 2, 0);
if (sound != 0) {
sound->x.HALF.HI -= 6;
sound->y.HALF.HI -= 6;
fx = CreateFx(this, 2, 0);
if (fx != NULL) {
fx->x.HALF.HI -= 6;
fx->y.HALF.HI -= 6;
}
this->attachedEntity = 0;
this->attachedEntity = NULL;
DeleteEntity(cloud);
}
}
void (*const gUnk_080D0110[])(Entity *) = {
Lakitu_DoAction,
sub_0803C784,
sub_08001324,
sub_0804A7D4,
sub_08001242,
sub_0803C820,
};
void (*const LakituActionFuncs[])(Entity *) = {
Lakitu_Initialize,
Lakitu_Hide,
Lakitu_EndHide,
Lakitu_Idle,
Lakitu_BeginHide,
Lakitu_Lightning,
Lakitu_LightningDelay,
Lakitu_Cloudless,
};
void (*const gUnk_080D0148[])(Entity *) = {
sub_0803C844,
sub_0803C850,
sub_0803C86C,
};
const OffsetCoords gUnk_080D0154[] = {
{ 0x00, 0xEE },
{ 0x12, 0x00 },
{ 0x00, 0x08 },
{ 0xEE, 0x00 },
};

View File

@ -9,9 +9,12 @@ extern u32 GetNextFunction(Entity *);
extern void ModHealth(s32);
extern void CreateFx(Entity *, u16, u16);
extern void (* const gUnk_080D0418[])(Entity *);
extern void (* const gUnk_080D0430[])(Entity *);
extern void (* const gUnk_080D043C[])(Entity *);
extern void sub_0804A7D4(Entity *);
extern void sub_08001242(Entity *);
extern void (*const gUnk_080D0418[6])(Entity *);
extern void (*const gUnk_080D0430[3])(Entity *);
extern void (*const gUnk_080D043C[3])(Entity *);
extern bool32 sub_0806F3E4(Entity *);
extern bool32 sub_0806F520(Entity *);
@ -153,3 +156,24 @@ 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 gUnk_080D0430[])(Entity *) = {
sub_0803CD6C,
sub_0803CDA8,
sub_0803CDD8,
};
void (*const gUnk_080D043C[])(Entity *) = {
sub_0803CD2C,
sub_0803CD38,
sub_0803CD40,
};

View File

@ -87,4 +87,4 @@ void sub_0805C908(Entity *this)
u32 sub_0805C920(Entity *this)
{
return CheckLocalFlagByOffset(0x300, (this->entityType).form + 0x67);
}
}

View File

@ -12,4 +12,4 @@ void sub_0805D250(Entity *this)
void sub_0805D268(Entity *this)
{
gUnk_08108D44[this->action](this);
}
}

View File

@ -44,4 +44,4 @@ void MineralWaterSource_Init(Entity *this) {
void sub_080973DC(Entity *this) {
this->bitfield = 0;
}
}

View File

@ -23,4 +23,4 @@ void Wheaton(Entity *this) {
}
sub_0807DD94(this, 0);
}
}

View File

@ -154,4 +154,4 @@ void sub_0806C944(Entity *this)
}
}
TextboxNoOverlap(gUnk_08113B0C[iVar2], this);
}
}