ovl_Obj_Roomtimer OK (#505)

* ovl_Obj_Roomtimer OK

* add packed params

* made suggested changes

* fixed
This commit is contained in:
Lucas Shaw 2022-01-04 00:25:41 -05:00 committed by GitHub
parent c1858172b5
commit 9e5382076a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 11 deletions

3
spec
View File

@ -1818,8 +1818,7 @@ beginseg
name "ovl_Obj_Roomtimer"
compress
include "build/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.o"
include "build/data/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer.data.o"
include "build/data/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer.reloc.o"
include "build/src/overlays/actors/ovl_Obj_Roomtimer/ovl_Obj_Roomtimer_reloc.o"
endseg
beginseg

View File

@ -18,7 +18,6 @@ void func_80973CD8(ObjRoomtimer* this, GlobalContext* globalCtx);
void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx);
void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx);
#if 0
const ActorInit Obj_Roomtimer_InitVars = {
ACTOR_OBJ_ROOMTIMER,
ACTORCAT_ENEMY,
@ -31,16 +30,64 @@ const ActorInit Obj_Roomtimer_InitVars = {
(ActorFunc)NULL,
};
#endif
void ObjRoomtimer_Init(Actor* thisx, GlobalContext* globalCtx) {
ObjRoomtimer* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Init.s")
this->switchFlag = ROOMTIMER_GET_SWITCHFLAG(thisx);
this->actor.params &= 0x1FF;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Destroy.s")
if (this->actor.params != 0x1FF) {
this->actor.params = CLAMP_MAX(this->actor.params, 500);
}
this->actionFunc = func_80973CD8;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973CD8.s")
void ObjRoomtimer_Destroy(Actor* thisx, GlobalContext* globalCtx) {
ObjRoomtimer* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973D3C.s")
if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] > 0) {
gSaveContext.unk_3DD0[4] = 5;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/func_80973DE0.s")
void func_80973CD8(ObjRoomtimer* this, GlobalContext* globalCtx) {
if (this->actor.params != 0x1FF) {
func_8010E9F0(4, this->actor.params);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Roomtimer/ObjRoomtimer_Update.s")
func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP);
this->actionFunc = func_80973D3C;
}
void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx) {
if (Actor_GetRoomClearedTemp(globalCtx, this->actor.room)) {
if (this->actor.params != 0x1FF) {
gSaveContext.unk_3DD0[4] = 5;
}
ActorCutscene_SetIntentToPlay(this->actor.cutscene);
this->actionFunc = func_80973DE0;
} else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) {
play_sound(NA_SE_OC_ABYSS);
func_80169EFC(globalCtx);
Actor_MarkForDeath(&this->actor);
}
}
void func_80973DE0(ObjRoomtimer* this, GlobalContext* globalCtx) {
if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) {
Actor_SetRoomCleared(globalCtx, this->actor.room);
Actor_SetSwitchFlag(globalCtx, this->switchFlag);
if (ActorCutscene_GetLength(this->actor.cutscene) != -1) {
ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor);
}
Actor_MarkForDeath(&this->actor);
} else {
ActorCutscene_SetIntentToPlay(this->actor.cutscene);
}
}
void ObjRoomtimer_Update(Actor* thisx, GlobalContext* globalCtx) {
ObjRoomtimer* this = THIS;
this->actionFunc(this, globalCtx);
}

View File

@ -3,6 +3,8 @@
#include "global.h"
#define ROOMTIMER_GET_SWITCHFLAG(thisx) (((thisx)->params >> 9) & 0x7F)
struct ObjRoomtimer;
typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, GlobalContext*);
@ -10,7 +12,7 @@ typedef void (*ObjRoomtimerActionFunc)(struct ObjRoomtimer*, GlobalContext*);
typedef struct ObjRoomtimer {
/* 0x0000 */ Actor actor;
/* 0x0144 */ ObjRoomtimerActionFunc actionFunc;
/* 0x0148 */ char unk_148[0x4];
/* 0x0148 */ s32 switchFlag;
} ObjRoomtimer; // size = 0x14C
extern const ActorInit Obj_Roomtimer_InitVars;