ovl_Demo_Getitem decompiled (#861)

* ovl_Demo_Getitem decompiled

* * PlayState
* PR reviews

* pr review changes

* renaming

* objectIndex
This commit is contained in:
Alejandro Asenjo 2022-07-11 22:13:29 -03:00 committed by GitHub
parent 5178d2cd9a
commit 35961a7cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 91 additions and 17 deletions

View File

@ -404,7 +404,7 @@ typedef enum {
/* 0x66 */ GID_SWORD_RAZOR = 0x66,
/* 0x67 */ GID_SWORD_GILDED,
/* 0x68 */ GID_SWORD_GREAT_FAIRY,
/* 0x6A */ GID_6A = 0x6A,
/* 0x6A */ GID_MASK_GREAT_FAIRY = 0x6A,
/* 0x6B */ GID_6B,
/* 0x70 */ GID_70 = 0x70,
/* 0x71 */ GID_71

3
spec
View File

@ -2851,8 +2851,7 @@ beginseg
name "ovl_Demo_Getitem"
compress
include "build/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.o"
include "build/data/ovl_Demo_Getitem/ovl_Demo_Getitem.data.o"
include "build/data/ovl_Demo_Getitem/ovl_Demo_Getitem.reloc.o"
include "build/src/overlays/actors/ovl_Demo_Getitem/ovl_Demo_Getitem_reloc.o"
endseg
beginseg

View File

@ -1,7 +1,7 @@
/*
* File: z_demo_getitem.c
* Overlay: ovl_Demo_Getitem
* Description: Cutscene object for Great Fairy's Mask and Great Fairy's Sword
* Description: Cutscene objectIndex for Great Fairy's Mask and Great Fairy's Sword
*/
#include "z_demo_getitem.h"
@ -14,7 +14,10 @@ void DemoGetitem_Init(Actor* thisx, PlayState* play);
void DemoGetitem_Destroy(Actor* thisx, PlayState* play);
void DemoGetitem_Update(Actor* thisx, PlayState* play);
#if 0
void func_80A4FB10(DemoGetitem* this, PlayState* play);
void func_80A4FB68(DemoGetitem* this, PlayState* play2);
void DemoGetitem_Draw(Actor* thisx, PlayState* play);
const ActorInit Demo_Getitem_InitVars = {
ACTOR_DEMO_GETITEM,
ACTORCAT_BG,
@ -27,16 +30,84 @@ const ActorInit Demo_Getitem_InitVars = {
(ActorFunc)NULL,
};
#endif
static s16 sObjectBankIndices[] = { OBJECT_GI_MASK14, OBJECT_GI_SWORD_4 };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Init.s")
static s16 sGetItemDraws[] = { GID_MASK_GREAT_FAIRY, GID_SWORD_GREAT_FAIRY };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Destroy.s")
static u16 sCsActionIndices[] = { 0x6E, 0x236 };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FB10.s")
void DemoGetitem_Init(Actor* thisx, PlayState* play) {
s32 pad;
s32 objectIndex;
s32 itemIndex;
DemoGetitem* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FB68.s")
itemIndex = 0;
if (DEMOGETITEM_GET_F(thisx) == 1) {
itemIndex = 1;
}
Actor_SetScale(&this->actor, 0.25f);
this->actionFunc = func_80A4FB10;
this->item = sGetItemDraws[itemIndex];
this->csAction = sCsActionIndices[itemIndex];
objectIndex = Object_GetIndex(&play->objectCtx, sObjectBankIndices[itemIndex]);
if (objectIndex < 0) {
Actor_MarkForDeath(&this->actor);
} else {
this->objectIndex = objectIndex;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Update.s")
void DemoGetitem_Destroy(Actor* thisx, PlayState* play) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FCF0.s")
void func_80A4FB10(DemoGetitem* this, PlayState* play) {
if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) {
this->actor.draw = NULL;
this->actor.objBankIndex = this->objectIndex;
this->actionFunc = func_80A4FB68;
}
}
void func_80A4FB68(DemoGetitem* this, PlayState* play2) {
PlayState* play = play2;
u16 sp22 = (play->gameplayFrames * 1000) & 0xFFFF;
if (Cutscene_CheckActorAction(play, this->csAction)) {
if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action != 4) {
this->actor.shape.yOffset = 0.0f;
}
switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action) {
case 2:
this->actor.draw = DemoGetitem_Draw;
Cutscene_ActorTranslate(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction));
this->actor.shape.rot.y += 0x3E8;
return;
case 3:
Actor_MarkForDeath(&this->actor);
return;
case 4:
this->actor.draw = DemoGetitem_Draw;
Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction));
this->actor.shape.yOffset = Math_SinS(sp22) * 15.0f;
return;
}
this->actor.draw = NULL;
} else {
this->actor.draw = NULL;
}
}
void DemoGetitem_Update(Actor* thisx, PlayState* play) {
DemoGetitem* this = THIS;
this->actionFunc(this, play);
}
void DemoGetitem_Draw(Actor* thisx, PlayState* play) {
DemoGetitem* this = THIS;
func_800B8050(&this->actor, play, 0);
func_800B8118(&this->actor, play, 0);
GetItem_Draw(play, this->item);
}

View File

@ -3,14 +3,18 @@
#include "global.h"
#define DEMOGETITEM_GET_F(thisx) ((thisx)->params & 0xF)
struct DemoGetitem;
typedef void (*DemoGetitemActionFunc)(struct DemoGetitem*, PlayState*);
typedef struct DemoGetitem {
/* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0x8];
/* 0x014C */ DemoGetitemActionFunc actionFunc;
/* 0x000 */ Actor actor;
/* 0x144 */ s16 item;
/* 0x146 */ u16 csAction;
/* 0x148 */ s8 objectIndex;
/* 0x14C */ DemoGetitemActionFunc actionFunc;
} DemoGetitem; // size = 0x150
extern const ActorInit Demo_Getitem_InitVars;

View File

@ -770,7 +770,7 @@ void func_80AAE030(PlayState* play, DmChar05* this) {
void func_80AAE114(PlayState* play, DmChar05* this) {
s32 sp34;
s16 sp24[] = {
GID_02, GID_6A, GID_70, GID_3A, GID_0E, GID_0F, GID_3E, GID_71,
GID_02, GID_MASK_GREAT_FAIRY, GID_70, GID_3A, GID_0E, GID_0F, GID_3E, GID_71,
};
sp34 = DMCHAR05_GET(&this->actor) - DMCHAR05_5;

View File

@ -10549,7 +10549,7 @@
0x80A4FB10:("func_80A4FB10",),
0x80A4FB68:("func_80A4FB68",),
0x80A4FCCC:("DemoGetitem_Update",),
0x80A4FCF0:("func_80A4FCF0",),
0x80A4FCF0:("DemoGetitem_Draw",),
0x80A4FDD0:("func_80A4FDD0",),
0x80A4FEBC:("func_80A4FEBC",),
0x80A4FFE8:("func_80A4FFE8",),