ovl_obj_lightblock OK (#282)

* initial commit

* review suggestions

* changed opacity to alpha

* changed to multiple of 10
This commit is contained in:
emilybrooks 2021-09-22 17:46:26 -07:00 committed by GitHub
parent 01a6dea813
commit a59943bc4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 172 additions and 28 deletions

3
spec
View File

@ -3808,8 +3808,7 @@ beginseg
name "ovl_Obj_Lightblock" name "ovl_Obj_Lightblock"
compress compress
include "build/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.o" include "build/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.o"
include "build/data/ovl_Obj_Lightblock/ovl_Obj_Lightblock.data.o" include "build/src/overlays/actors/ovl_Obj_Lightblock/ovl_Obj_Lightblock_reloc.o"
include "build/data/ovl_Obj_Lightblock/ovl_Obj_Lightblock.reloc.o"
endseg endseg
beginseg beginseg

View File

@ -1,3 +1,9 @@
/*
* File: z_obj_lightblock.c
* Overlay: ovl_Obj_Lightblock
* Description: Sun Block
*/
#include "z_obj_lightblock.h" #include "z_obj_lightblock.h"
#define FLAGS 0x00000000 #define FLAGS 0x00000000
@ -8,8 +14,13 @@ void ObjLightblock_Init(Actor* thisx, GlobalContext* globalCtx);
void ObjLightblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjLightblock_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ObjLightblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjLightblock_Update(Actor* thisx, GlobalContext* globalCtx);
void ObjLightblock_Draw(Actor* thisx, GlobalContext* globalCtx); void ObjLightblock_Draw(Actor* thisx, GlobalContext* globalCtx);
void func_80AF3AC8(ObjLightblock* this);
void func_80AF3ADC(ObjLightblock* this, GlobalContext* globalCtx);
void func_80AF3B8C(ObjLightblock* this);
void func_80AF3BA0(ObjLightblock* this, GlobalContext* globalCtx);
void func_80AF3C18(ObjLightblock* this);
void func_80AF3C34(ObjLightblock* this, GlobalContext* globalCtx);
#if 0
const ActorInit Obj_Lightblock_InitVars = { const ActorInit Obj_Lightblock_InitVars = {
ACTOR_OBJ_LIGHTBLOCK, ACTOR_OBJ_LIGHTBLOCK,
ACTORCAT_BG, ACTORCAT_BG,
@ -22,46 +33,175 @@ const ActorInit Obj_Lightblock_InitVars = {
(ActorFunc)ObjLightblock_Draw, (ActorFunc)ObjLightblock_Draw,
}; };
// static ColliderCylinderInit sCylinderInit = { static ColliderCylinderInit sCylinderInit = {
static ColliderCylinderInit D_80AF3EA0 = { {
{ COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, COLTYPE_NONE,
{ ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00202000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, AT_NONE,
AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER,
OC1_NONE,
OC2_NONE,
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00202000, 0x00, 0x00 },
TOUCH_NONE | TOUCH_SFX_NORMAL,
BUMP_ON,
OCELEM_NONE,
},
{ 84, 120, 0, { 0, 0, 0 } }, { 84, 120, 0, { 0, 0, 0 } },
}; };
// static InitChainEntry sInitChain[] = { typedef struct {
static InitChainEntry D_80AF3EEC[] = { /* 0x00 */ f32 scale;
/* 0x04 */ s16 radius;
/* 0x06 */ s16 height;
/* 0x08 */ s16 yShift;
/* 0x0C */ s32 params;
} LightblockTypeVars; // size = 0x10
static LightblockTypeVars sLightblockTypeVars[] = {
{ 0.1f, 76, 80, 19, 2 },
{ (1.0f / 6), 126, 144, 19, 3 },
};
static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP),
}; };
#endif extern CollisionHeader D_06000B80;
extern Gfx D_801AEF88[];
extern Gfx D_06000178[];
extern Gfx D_801AEFA0[];
extern ColliderCylinderInit D_80AF3EA0; void func_80AF3910(ObjLightblock* this, GlobalContext* globalCtx) {
extern InitChainEntry D_80AF3EEC[]; LightblockTypeVars* typeVars = &sLightblockTypeVars[LIGHTBLOCK_TYPE(&this->dyna.actor)];
extern UNK_TYPE D_06000178; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->dyna.actor.world.pos.x,
extern UNK_TYPE D_06000B80; this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0, typeVars->params);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/func_80AF3910.s") void ObjLightblock_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
ObjLightblock* this = THIS;
LightblockTypeVars* typeVars = &sLightblockTypeVars[LIGHTBLOCK_TYPE(&this->dyna.actor)];
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/ObjLightblock_Init.s") Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
Actor_SetScale(&this->dyna.actor, typeVars->scale);
BcCheck3_BgActorInit(&this->dyna, 0);
Collider_InitCylinder(globalCtx, &this->collider);
if (Flags_GetSwitch(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor))) {
Actor_MarkForDeath(&this->dyna.actor);
} else {
BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06000B80);
Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit);
Collider_UpdateCylinder(&this->dyna.actor, &this->collider);
this->collider.dim.radius = typeVars->radius;
this->collider.dim.height = typeVars->height;
this->collider.dim.yShift = typeVars->yShift;
this->alpha = 255;
func_80AF3AC8(this);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/ObjLightblock_Destroy.s") void ObjLightblock_Destroy(Actor* thisx, GlobalContext* globalCtx) {
ObjLightblock* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/func_80AF3AC8.s") BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
Collider_DestroyCylinder(globalCtx, &this->collider);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/func_80AF3ADC.s") void func_80AF3AC8(ObjLightblock* this) {
this->actionFunc = func_80AF3ADC;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/func_80AF3B8C.s") void func_80AF3ADC(ObjLightblock* this, GlobalContext* globalCtx) {
if (this->collider.base.acFlags & AC_HIT) {
this->collider.base.acFlags &= ~AC_HIT;
// light arrows
if (this->collider.info.acHitInfo->toucher.dmgFlags & (1 << 13)) {
this->collisionCounter = 8;
}
// light ray
else {
this->collisionCounter++;
}
} else {
this->collisionCounter = 0;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/func_80AF3BA0.s") if (this->collisionCounter >= 8) {
ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
func_80AF3B8C(this);
} else {
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/func_80AF3C18.s") void func_80AF3B8C(ObjLightblock* this) {
this->actionFunc = func_80AF3BA0;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/func_80AF3C34.s") void func_80AF3BA0(ObjLightblock* this, GlobalContext* globalCtx) {
if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
Actor_SetSwitchFlag(globalCtx, LIGHTBLOCK_DESTROYED(&this->dyna.actor));
func_80AF3910(this, globalCtx);
func_80AF3C18(this);
} else {
ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/ObjLightblock_Update.s") void func_80AF3C18(ObjLightblock* this) {
this->timer = 80;
this->actionFunc = func_80AF3C34;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lightblock/ObjLightblock_Draw.s") void func_80AF3C34(ObjLightblock* this, GlobalContext* globalCtx) {
s8 temp_a0;
this->timer--;
if (this->timer <= 0) {
temp_a0 = this->dyna.actor.cutscene;
ActorCutscene_Stop(temp_a0);
Actor_MarkForDeath(&this->dyna.actor);
} else if (this->timer <= 60) {
if (this->alpha > 40) {
this->alpha -= 40;
} else {
this->alpha = 0;
this->dyna.actor.draw = NULL;
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
}
}
}
void ObjLightblock_Update(Actor* thisx, GlobalContext* globalCtx) {
ObjLightblock* this = THIS;
this->actionFunc(this, globalCtx);
}
void ObjLightblock_Draw(Actor* thisx, GlobalContext* globalCtx) {
ObjLightblock* this = THIS;
OPEN_DISPS(globalCtx->state.gfxCtx);
if (this->alpha < 255) {
func_8012C2DC(globalCtx->state.gfxCtx);
gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->alpha);
gSPDisplayList(POLY_XLU_DISP++, D_06000178);
} else {
func_8012C28C(globalCtx->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255);
gSPDisplayList(POLY_OPA_DISP++, D_06000178);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
}

View File

@ -3,15 +3,20 @@
#include "global.h" #include "global.h"
#define LIGHTBLOCK_TYPE(thisx) ((thisx)->params & 1)
#define LIGHTBLOCK_DESTROYED(thisx) (((thisx)->params >> 8) & 0x7F)
struct ObjLightblock; struct ObjLightblock;
typedef void (*ObjLightblockActionFunc)(struct ObjLightblock*, GlobalContext*); typedef void (*ObjLightblockActionFunc)(struct ObjLightblock*, GlobalContext*);
typedef struct ObjLightblock { typedef struct ObjLightblock {
/* 0x0000 */ Actor actor; /* 0x0000 */ DynaPolyActor dyna;
/* 0x0144 */ char unk_144[0x64]; /* 0x015C */ ColliderCylinder collider;
/* 0x01A8 */ ObjLightblockActionFunc actionFunc; /* 0x01A8 */ ObjLightblockActionFunc actionFunc;
/* 0x01AC */ char unk_1AC[0x4]; /* 0x01AC */ s8 timer;
/* 0x01AD */ u8 alpha;
/* 0x01AE */ s8 collisionCounter;
} ObjLightblock; // size = 0x1B0 } ObjLightblock; // size = 0x1B0
extern const ActorInit Obj_Lightblock_InitVars; extern const ActorInit Obj_Lightblock_InitVars;