Ovl_En_Cha OK (#116)

* EnCha OK

* pr comments, else if branches, file header comment

* Better function names
This commit is contained in:
Derek Hensley 2021-05-04 17:10:30 -07:00 committed by GitHub
parent 751c5e1049
commit 7605041f0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 13 deletions

View File

@ -8444,9 +8444,9 @@ SECTIONS
ovl_En_Cha : AT(RomLocation)
{
build/src/overlays/actors/ovl_En_Cha/z_en_cha.o(.text)
build/asm/overlays/ovl_En_Cha_data.o(.data)
build/src/overlays/actors/ovl_En_Cha/z_en_cha.o(.data)
build/src/overlays/actors/ovl_En_Cha/z_en_cha.o(.rodata)
build/asm/overlays/ovl_En_Cha_rodata.o(.rodata)
build/src/overlays/actors/ovl_En_Cha/z_en_cha_overlay.o(.ovl)
}
SegmentEnd = .;
SegmentSize = SegmentEnd - SegmentStart;

View File

@ -190,3 +190,7 @@ D_06000140 = 0x06000140;
/* bg_lotus */
D_06000A20 = 0x06000A20;
D_06000040 = 0x06000040;
/* en_cha */
D_06000710 = 0x06000710;
D_06000958 = 0x06000958;

View File

@ -1,3 +1,9 @@
/*
* File: z_en_cha.c
* Overlay: ovl_En_Cha
* Description: Laundry Pool Bell
*/
#include "z_en_cha.h"
#define FLAGS 0x00000000
@ -9,7 +15,9 @@ void EnCha_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnCha_Update(Actor* thisx, GlobalContext* globalCtx);
void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void EnCha_Idle(EnCha* this, GlobalContext* globalCtx);
const ActorInit En_Cha_InitVars = {
ACTOR_EN_CHA,
ACTORCAT_PROP,
@ -21,16 +29,97 @@ const ActorInit En_Cha_InitVars = {
(ActorFunc)EnCha_Update,
(ActorFunc)EnCha_Draw
};
*/
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Cha_0x80BEB520/EnCha_Init.asm")
static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_WOOD,
AT_NONE,
AC_ON | AC_HARD | AC_TYPE_PLAYER,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_1,
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0xF7CFFFFF, 0x00, 0x00 },
TOUCH_NONE | TOUCH_SFX_NORMAL,
BUMP_ON,
OCELEM_ON, },
{ 10, 40, 0, { 0, 0, 0 } },
};
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Cha_0x80BEB520/EnCha_Destroy.asm")
extern UNK_TYPE4 D_06000710;
extern UNK_TYPE4 D_06000958;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Cha_0x80BEB520/func_80BEB5DC.asm")
void EnCha_Init(Actor *thisx, GlobalContext *globalCtx) {
EnCha *this = THIS;
s32 pad;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Cha_0x80BEB520/func_80BEB654.asm")
Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
this->actor.colChkInfo.mass = 0xFF;
Collider_UpdateCylinder(&this->actor, &this->collider);
Actor_SetScale(&this->actor, 0.01f);
this->actor.home.rot.z = 0;
this->actionFunc = EnCha_Idle;
this->actor.home.rot.x = this->actor.home.rot.z;
gSaveContext.perm.weekEventReg[60] &= 0xFB;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Cha_0x80BEB520/EnCha_Update.asm")
void EnCha_Destroy(Actor *thisx, GlobalContext *globalCtx) {
EnCha *this = THIS;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Cha_0x80BEB520/EnCha_Draw.asm")
Collider_DestroyCylinder(globalCtx, &this->collider);
}
void EnCha_Ring(EnCha *this, GlobalContext *globalCtx) {
EnCha_Idle(this, globalCtx);
if (this->actor.cutscene == -1) {
this->actionFunc = EnCha_Idle;
}
else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) {
ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor);
this->actionFunc = EnCha_Idle;
} else {
ActorCutscene_SetIntentToPlay(this->actor.cutscene);
}
}
void EnCha_Idle(EnCha *this, GlobalContext *globalCtx) {
if (gSaveContext.perm.weekEventReg[60] & 4) {
Audio_PlayActorSound2(&this->actor, 0x289E);
gSaveContext.perm.weekEventReg[60] &= 0xFB;
this->actor.home.rot.z = 0x7D0;
}
if (this->collider.base.acFlags & AC_HIT) {
Audio_PlayActorSound2(&this->actor, 0x289E);
this->actor.home.rot.z = 0x7D0;
if (!(gSaveContext.perm.weekEventReg[51] & 4)) {
gSaveContext.perm.weekEventReg[51] |= 4;
this->actionFunc = EnCha_Ring;
}
}
this->actor.home.rot.x += this->actor.home.rot.z;
this->actor.home.rot.z -= (s16)(this->actor.home.rot.x * 0.1f);
this->actor.home.rot.z *= 0.96f;
}
void EnCha_Update(Actor *thisx, GlobalContext *globalCtx) {
EnCha *this = THIS;
GlobalContext *globalCtx2 = globalCtx;
CollisionCheck_SetOC(globalCtx, &globalCtx2->colCheckCtx, &this->collider.base);
this->actionFunc(this, globalCtx);
if ((this->actor.shape.rot.z >= -0x1F3F) && (this->actor.shape.rot.z < 0x1F40)) {
CollisionCheck_SetAC(globalCtx, &globalCtx2->colCheckCtx, &this->collider.base);
}
}
void EnCha_Draw(Actor *thisx, GlobalContext *globalCtx) {
EnCha *this = THIS;
func_800BDFC0(globalCtx, &D_06000710);
SysMatrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, 1);
SysMatrix_InsertXRotation_s(this->actor.home.rot.x, 1);
func_800BDFC0(globalCtx, &D_06000958);
}

View File

@ -5,9 +5,12 @@
struct EnCha;
typedef void (*EnChaActionFunc)(struct EnCha*, struct GlobalContext*);
typedef struct EnCha {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x50];
/* 0x144 */ ColliderCylinder collider;
/* 0x190 */ EnChaActionFunc actionFunc;
} EnCha; // size = 0x194
extern const ActorInit En_Cha_InitVars;

View File

@ -16216,8 +16216,8 @@
0x80BEB0A8:("EnDt_Draw",),
0x80BEB520:("EnCha_Init",),
0x80BEB5B0:("EnCha_Destroy",),
0x80BEB5DC:("func_80BEB5DC",),
0x80BEB654:("func_80BEB654",),
0x80BEB5DC:("EnCha_Ring",),
0x80BEB654:("EnCha_Idle",),
0x80BEB76C:("EnCha_Update",),
0x80BEB7F4:("EnCha_Draw",),
0x80BEB940:("ObjDinner_Init",),