Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Proposed OoT Object Docs #1361

Merged
merged 5 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions include/z64object.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#ifndef Z64OBJECT_H
#define Z64OBJECT_H

#define OBJECT_SPACE_SIZE_DEFAULT 1413120
#define OBJECT_SPACE_SIZE_CLOCK_TOWN 1566720
#define OBJECT_SPACE_SIZE_MILK_BAR 1617920
#define OBJECT_SPACE_SIZE_TERMINA_FIELD 1505280

#define OBJECT_EXCHANGE_BANK_MAX 35

#define DEFINE_OBJECT(_name, enumValue) enumValue,
#define DEFINE_OBJECT_UNSET(enumValue) enumValue,
#define DEFINE_OBJECT_SIZE_ZERO(_name, enumValue) enumValue,
Expand Down
26 changes: 13 additions & 13 deletions include/z64scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ typedef struct {
typedef struct {
/* 0x0 */ u8 code;
/* 0x1 */ u8 naviQuestHintFileId;
/* 0x4 */ u32 subKeepIndex;
/* 0x4 */ u32 subKeepId;
} SCmdSpecialFiles; // size = 0x8

typedef struct {
Expand Down Expand Up @@ -415,7 +415,7 @@ typedef struct {
/* 0x08 */ DmaRequest dmaReq;
/* 0x28 */ OSMesgQueue loadQueue;
/* 0x40 */ OSMesg loadMsg;
} ObjectStatus; // size = 0x44
} ObjectEntry; // size = 0x44

typedef struct {
/* 0x0 */ RomFile segment;
Expand Down Expand Up @@ -475,11 +475,11 @@ typedef RoomShapeCullable PolygonType2;
typedef struct {
/* 0x000 */ void* spaceStart;
/* 0x004 */ void* spaceEnd;
/* 0x008 */ u8 num;
/* 0x009 */ u8 spawnedObjectCount;
/* 0x00A */ u8 mainKeepIndex;
/* 0x00B */ u8 subKeepIndex;
/* 0x00C */ ObjectStatus status[OBJECT_EXCHANGE_BANK_MAX];
/* 0x008 */ u8 numEntries; // total amount of used entries
/* 0x009 */ u8 numPersistentEntries; // amount of entries that won't be reused when loading a new object list (when loading a new room)
/* 0x00A */ u8 mainKeepSlot; // "gameplay_keep" slot
/* 0x00B */ u8 subKeepSlot; // "gameplay_field_keep" or "gameplay_dangeon_keep" slot
/* 0x00C */ ObjectEntry slots[35];
} ObjectContext; // size = 0x958

#define PATH_INDEX_NONE -1
Expand Down Expand Up @@ -899,13 +899,13 @@ typedef enum {
#define SCENE_CMD_MISC_SETTINGS SCENE_CMD_SET_REGION_VISITED
#define SCENE_CMD_CUTSCENE_LIST SCENE_CMD_CUTSCENE_SCRIPT_LIST

s32 Object_Spawn(ObjectContext* objectCtx, s16 id);
void Object_InitBank(struct GameState* gameState, ObjectContext* objectCtx);
void Object_UpdateBank(ObjectContext* objectCtx);
s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId);
s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index);
s32 Object_SpawnPersistent(ObjectContext* objectCtx, s16 id);
void Object_InitContext(struct GameState* gameState, ObjectContext* objectCtx);
void Object_UpdateEntries(ObjectContext* objectCtx);
s32 Object_GetSlot(ObjectContext* objectCtx, s16 objectId);
s32 Object_IsLoaded(ObjectContext* objectCtx, s32 slot);
void Object_LoadAll(ObjectContext* objectCtx);
void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id);
void* func_8012F73C(ObjectContext* objectCtx, s32 slot, s16 id);
void Scene_CommandSpawnList(struct PlayState* play, SceneCmd* cmd);
void Scene_CommandActorList(struct PlayState* play, SceneCmd* cmd);
void Scene_CommandActorCutsceneCamList(struct PlayState* play, SceneCmd* cmd);
Expand Down
8 changes: 4 additions & 4 deletions src/code/z_actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ void Actor_SetScale(Actor* actor, f32 scale) {
}

void Actor_SetObjectDependency(PlayState* play, Actor* actor) {
gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[actor->objBankIndex].segment);
gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[actor->objBankIndex].segment);
}

void Actor_Init(Actor* actor, PlayState* play) {
Expand Down Expand Up @@ -2654,8 +2654,8 @@ void Actor_Draw(PlayState* play, Actor* actor) {
Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY);
Actor_SetObjectDependency(play, actor);

gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment);
gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment);
gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[actor->objBankIndex].segment);
gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.slots[actor->objBankIndex].segment);

if (actor->colorFilterTimer != 0) {
s32 colorFlag = COLORFILTER_GET_COLORFLAG(actor->colorFilterParams);
Expand Down Expand Up @@ -3253,7 +3253,7 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1
return NULL;
}

objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId);
objBankIndex = Object_GetSlot(&play->objectCtx, actorInit->objectId);
if ((objBankIndex < 0) || ((actorInit->type == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num) &&
(actorInit->id != ACTOR_BOSS_05))) {
Actor_FreeOverlay(&gActorOverlayTable[index]);
Expand Down
4 changes: 2 additions & 2 deletions src/code/z_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,9 @@ void GetItem_DrawRemains(PlayState* play, s16 drawId) {

OPEN_DISPS(play->state.gfxCtx);

objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_BSMASK);
objectIndex = Object_GetSlot(&play->objectCtx, OBJECT_BSMASK);

gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[objectIndex].segment);
gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.slots[objectIndex].segment);

Gfx_SetupDL25_Opa(play->state.gfxCtx);
Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY);
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_effect_soft_sprite_old_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, TexturePtr texture) {
MtxF mfTrans11DA0;
s32 pad1;
Mtx* mtx;
void* object = play->objectCtx.status[this->rgObjBankIndex].segment;
void* object = play->objectCtx.slots[this->rgObjBankIndex].segment;

OPEN_DISPS(gfxCtx);

Expand Down
6 changes: 3 additions & 3 deletions src/code/z_en_hy_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) {
}

void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex) {
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[enHy->animObjIndex].segment);
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjIndex].segment);
EnHy_ChangeAnim(&enHy->skelAnime, animIndex);
}

s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play) {
s32 isUpdated = false;

if (enHy->actor.draw != NULL) {
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[enHy->animObjIndex].segment);
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjIndex].segment);
SkelAnime_Update(&enHy->skelAnime);
isUpdated = true;
}
Expand All @@ -168,7 +168,7 @@ s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg
enHy->actor.objBankIndex = enHy->skelLowerObjIndex;
isInitialized = true;
ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f);
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[enHy->actor.objBankIndex].segment);
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->actor.objBankIndex].segment);
SkelAnime_InitFlex(play, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable,
ENHY_LIMB_MAX);
EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
Expand Down
12 changes: 6 additions & 6 deletions src/code/z_en_item00.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ void EnItem00_Init(Actor* thisx, PlayState* play) {
break;

case ITEM00_SHIELD_HERO:
thisx->objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_2);
thisx->objBankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_SHIELD_2);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;

case ITEM00_MAP:
thisx->objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_MAP);
thisx->objBankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_MAP);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;

case ITEM00_COMPASS:
thisx->objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_COMPASS);
thisx->objBankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_COMPASS);
EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;

Expand Down Expand Up @@ -316,7 +316,7 @@ void EnItem00_Destroy(Actor* thisx, PlayState* play) {
}

void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play) {
s32 objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS);
s32 objBankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_HEARTS);

if (Object_IsLoaded(&play->objectCtx, objBankIndex)) {
this->actor.objBankIndex = objBankIndex;
Expand Down Expand Up @@ -724,7 +724,7 @@ void EnItem00_Draw(Actor* thisx, PlayState* play) {
case ITEM00_RECOVERY_HEART:
if (this->unk152 < 0) {
if (this->unk152 == -1) {
s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART);
s8 bankIndex = Object_GetSlot(&play->objectCtx, OBJECT_GI_HEART);

if (Object_IsLoaded(&play->objectCtx, bankIndex)) {
this->actor.objBankIndex = bankIndex;
Expand Down Expand Up @@ -851,7 +851,7 @@ void EnItem00_DrawSprite(EnItem00* this, PlayState* play) {
void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play) {
s32 pad[2];

if (Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS) == this->actor.objBankIndex) {
if (Object_GetSlot(&play->objectCtx, OBJECT_GI_HEARTS) == this->actor.objBankIndex) {
OPEN_DISPS(play->state.gfxCtx);

Gfx_SetupDL25_Xlu(play->state.gfxCtx);
Expand Down
24 changes: 12 additions & 12 deletions src/code/z_play.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,8 @@ void Play_UpdateMain(PlayState* this) {
u8 freezeFlashTimer;
s32 sp5C = false;

gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment);

if (R_PICTO_PHOTO_STATE == PICTO_PHOTO_STATE_PROCESS) {
Expand Down Expand Up @@ -971,7 +971,7 @@ void Play_UpdateMain(PlayState* this) {
sp5C = (this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE);

AnimationContext_Reset(&this->animationCtx);
Object_UpdateBank(&this->objectCtx);
Object_UpdateEntries(&this->objectCtx);

if (!sp5C && (IREG(72) == 0)) {
this->gameplayFrames++;
Expand Down Expand Up @@ -1152,17 +1152,17 @@ void Play_DrawMain(PlayState* this) {

OPEN_DISPS(gfxCtx);

gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment);

gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
gSPSegment(OVERLAY_DISP++, 0x04, this->objectCtx.status[this->objectCtx.mainKeepIndex].segment);
gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
gSPSegment(OVERLAY_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);

gSPSegment(POLY_OPA_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
gSPSegment(POLY_XLU_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
gSPSegment(OVERLAY_DISP++, 0x05, this->objectCtx.status[this->objectCtx.subKeepIndex].segment);
gSPSegment(POLY_OPA_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
gSPSegment(POLY_XLU_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
gSPSegment(OVERLAY_DISP++, 0x05, this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);

gSPSegment(POLY_OPA_DISP++, 0x02, this->sceneSegment);
gSPSegment(POLY_XLU_DISP++, 0x02, this->sceneSegment);
Expand Down Expand Up @@ -1584,7 +1584,7 @@ void Play_InitScene(PlayState* this, s32 spawn) {
this->sceneMaterialAnims = NULL;
this->roomCtx.unk74 = NULL;
this->numSetupActors = 0;
Object_InitBank(&this->state, &this->objectCtx);
Object_InitContext(&this->state, &this->objectCtx);
LightContext_Init(this, &this->lightCtx);
Door_InitContext(&this->state, &this->doorCtx);
Room_Init(this, &this->roomCtx);
Expand Down
6 changes: 3 additions & 3 deletions src/code/z_player_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ void func_8012301C(Actor* thisx, PlayState* play2) {

gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId = objectId;
func_8012F73C(&play->objectCtx, this->actor.objBankIndex, objectId);
this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, GAMEPLAY_KEEP);
this->actor.objBankIndex = Object_GetSlot(&play->objectCtx, GAMEPLAY_KEEP);
} else if (this->unk_AE7 >= 3) {
s32 objBankIndex = Object_GetIndex(&play->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId);
s32 objBankIndex = Object_GetSlot(&play->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId);

if (Object_IsLoaded(&play->objectCtx, objBankIndex)) {
this->actor.objBankIndex = objBankIndex;
Expand Down Expand Up @@ -1863,7 +1863,7 @@ void Player_DrawHookshotReticle(PlayState* play, Player* player, f32 hookshotDis

gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);

gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.status[player->actor.objBankIndex].segment);
gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.slots[player->actor.objBankIndex].segment);
gSPDisplayList(OVERLAY_DISP++, gHookshotReticleDL);

CLOSE_DISPS(play->state.gfxCtx);
Expand Down
Loading