Files
tmc/src/npc/smith.c
T
2020-07-13 15:27:20 -07:00

225 lines
4.6 KiB
C

#include "global.h"
#include "entity.h"
#include "textbox.h"
typedef struct {
u8 filler[8];
u8 unk;
} struct_02002A40;
extern u32 GetFacingDirection(Entity*, Entity*);
extern u32 sub_0806F5A4(u32);
extern void sub_0806F118(Entity*);
extern void sub_0806ED78(Entity*);
extern Entity* CreateFx(Entity*, u32, u32);
extern void PlaySFX(u32);
extern u32 Random(void);
extern void sub_0807000C(Entity*);
extern u32 sub_0801E99C(Entity*);
extern u32 sub_0806ED9C(Entity*, u32, u32);
extern u32 sub_0806F078(Entity*, u32);
extern void sub_0807DD50(Entity*);
extern void sub_0807DD94(Entity*, u32);
extern void sub_0807DDAC(Entity*, u32);
extern void sub_0807DDE4(Entity*);
extern u32 UpdateFuseInteraction(Entity*);
extern u32 GetAnimationState(Entity*);
extern void ShowNPCDialogue(Entity*, u32*);
extern void sub_08078850(u32, u32, u32, u32*);
extern void sub_08078784(Entity*, u32);
extern void (*const gUnk_08110360[])(Entity*);
extern void (*const gUnk_0811036C[])(Entity*);
extern u16 gUnk_08110380[];
extern SpriteLoadData gUnk_08110354;
extern struct_02002A40 gUnk_02002A40;
extern u32 gUnk_08110390[];
extern u16 gUnk_081103D0[];
extern u32 gUnk_081103E0;
#if NON_MATCHING //reg-alloc
void Smith(Entity *this)
{
u32 iVar2;
u32 iVar4;
if ((this->flags & 2) != 0) {
if (this->interactType == 2) {
this->action = 4;
this->interactType = 0;
iVar4 = (this->animIndex == 0xc) ? 8 : 0;
iVar2 = sub_0806F5A4(GetFacingDirection(this, &gLinkEntity));
InitAnimationForceUpdate(this, iVar2 + iVar4);
sub_0806F118(this);
}
gUnk_0811036C[this->action](this);
}
else {
gUnk_08110360[this->action](this);
sub_0806ED78(this);
}
if (this->animIndex == 0xc) {
this->spritePriority.b1 = 0;
}
else {
this->spritePriority.b1 = 1;
}
if ((this->frames.all & 1) != 0) {
this->frames.all &= 0xfe;
CreateFx(this, 0x3d, 0x20);
PlaySFX(gUnk_08110380[(Random() & 7)]);
}
}
#else
NAKED
void Smith(Entity *this) {
asm(".include \"asm/non_matching/smith/smith.inc\"");
}
#endif
void Smith_Head(Entity *this)
{
u8 bVar1;
bVar1 = this->frames.all;
SetExtraSpriteFrame(this, 0, this->frameIndex);
if ((bVar1 & 0x40) != 0) {
SetExtraSpriteFrame(this, 1, 0x16);
}
else {
SetExtraSpriteFrame(this, 1, 0xff);
}
SetSpriteSubEntryOffsetData1(this,0,1);
sub_0807000C(this);
}
void sub_080660EC(Entity *this)
{
if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) {
this->action = 1;
this->field_0x68 = sub_0801E99C(this);
InitAnimationForceUpdate(this, 2);
}
}
void sub_08066118(Entity *this)
{
s32 uVar1;
u32 iVar2;
uVar1 = sub_0806ED9C(this, 0x28, 0x28);
if (uVar1 < 0) {
uVar1 = 2;
}
else {
if (this->field_0xf == 0) {
this->field_0xf = 0x10;
}
else {
--this->field_0xf;
uVar1 = this->animIndex;
}
}
if (sub_0806F078(this, uVar1) == 0) {
UpdateAnimationSingleFrame(this);
}
if (this->interactType != 0) {
this->action = 2;
TextboxNoOverlapFollow(0);
}
}
void sub_08066170(Entity *this)
{
this->action = 1;
}
void sub_08066178(Entity *this)
{
if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) {
this->action = 1;
this->spriteSettings.b.draw = 1;
this->field_0x68 = sub_0801E99C(this);
sub_0807DD50(this);
}
}
void sub_080661B0(Entity *this)
{
sub_0807DD94(this, 0);
}
void sub_080661BC(Entity *this)
{
u32 sVar1;
if (this->animIndex == 0xc) {
UpdateAnimationSingleFrame(this);
if ((this->frames.b.f3) != 0) {
this->field_0x80 = GetAnimationState(this) + 8;
InitAnimationForceUpdate(this, this->field_0x80);
}
}
else {
sub_0807DD94(this,0);
}
}
void sub_08066200(Entity *this)
{
sub_0807DDAC(this, 0);
sub_0807DDE4(this);
UpdateAnimationSingleFrame(this);
}
void sub_08066218(Entity *this)
{
if (UpdateFuseInteraction(this) != 0) {
this->action = 1;
}
}
void sub_0806622C(Entity *this)
{
u32 iVar1;
if (gUnk_02002A40.unk - 2 < 0) {
iVar1 = 0;
}
else {
iVar1 = gUnk_02002A40.unk - 2;
}
ShowNPCDialogue(this, &gUnk_08110390[iVar1 * 2]);
}
void nullsub_501(Entity* this) {}
void sub_08066258(void)
{
PlaySFX(gUnk_081103D0[Random() & 7]);
}
void sub_08066274(u32 arg0)
{
sub_08078850(arg0, 1, 0, &gUnk_081103E0);
}
void sub_08066288(Entity *arg0)
{
sub_08078784(arg0, arg0->field_0x68);
}
void Smith_Fusion(Entity *this)
{
if (this->action == 0) {
if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) {
this->action++;
this->spriteSettings.b.draw = 1;
InitAnimationForceUpdate(this, 6);
}
}
else {
UpdateAnimationSingleFrame(this);
}
}