mirror of
https://github.com/zeldaret/mm.git
synced 2026-06-19 07:17:12 -04:00
Scene Changes (#114)
* match function * major cleanups * rename switch functions * use graph_alloc to fix fake matches * more documentation * more matches, lots of changes * lots more work * format * Update z_scene_proc.c * very hard lagrange interpolation function OK! * remove any remaining * documentation done, only two functions left * a few more things * one function left! * document another oot leftover * last function decompiled, not matched yet * scene_proc complete * start work on z_scene * done with z_scene * remove unessecary typedefs * fix some things to remove warnings * Add z_scene_table and decomp data * Delete ctx.c * add draw cfg enum * cleanup * most scene table functions done * done for now * all scene files done * Update include/z64scene.h Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl> * add missing macros * fix some renames * scene texture file rename * added temporary structs so it still builds * more structs * even more old structs * fix boyo * should fix compile error * lets hope nothing broke * ub comment back Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl>
This commit is contained in:
+3
-3
@@ -171,7 +171,7 @@ void Actor_TargetContextInit(TargetContext* targetCtxt, Actor* actor, GlobalCont
|
||||
|
||||
#pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800B5814.asm")
|
||||
|
||||
u32 Actor_GetSwitchFlag(GlobalContext* ctxt, s32 flag) {
|
||||
u32 Flags_GetSwitch(GlobalContext* ctxt, s32 flag) {
|
||||
if (flag >= 0 && flag < 0x80) {
|
||||
return ctxt->actorCtx.switchFlags[(flag & -0x20) >> 5] & (1 << (flag & 0x1F));
|
||||
}
|
||||
@@ -327,7 +327,7 @@ void Actor_SetScale(Actor* actor, f32 scale) {
|
||||
|
||||
void Actor_SetObjectSegment(GlobalContext* ctxt, Actor* actor) {
|
||||
// TODO: Segment number enum
|
||||
gSegments[6] = PHYSICAL_TO_VIRTUAL(ctxt->sceneContext.objects[actor->objBankIndex].segment);
|
||||
gSegments[6] = PHYSICAL_TO_VIRTUAL(ctxt->objectCtx.status[actor->objBankIndex].segment);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -351,7 +351,7 @@ void Actor_InitToDefaultValues(Actor* actor, GlobalContext* ctxt) {
|
||||
actor->naviMsgId = 255;
|
||||
|
||||
Actor_Setshape(&actor->shape, 0, 0, 0);
|
||||
if (Scene_IsObjectLoaded(&ctxt->sceneContext, actor->objBankIndex) != 0) {
|
||||
if (Object_IsLoaded(&ctxt->objectCtx, actor->objBankIndex) != 0) {
|
||||
Actor_SetObjectSegment(ctxt, actor);
|
||||
actor->init(actor, ctxt);
|
||||
actor->init = NULL;
|
||||
|
||||
@@ -10,7 +10,7 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur
|
||||
MtxF mfTrans11DA0;
|
||||
s32 pad1;
|
||||
Mtx* mtx;
|
||||
void* object = globalCtx->sceneContext.objects[this->rgObjBankIdx].segment;
|
||||
void* object = globalCtx->objectCtx.status[this->rgObjBankIdx].segment;
|
||||
|
||||
OPEN_DISPS(gfxCtx);
|
||||
|
||||
|
||||
+10
-10
@@ -149,15 +149,15 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
this->unk154 = 0.01f;
|
||||
break;
|
||||
case ITEM00_SHIELD_HERO:
|
||||
this->actor.objBankIndex = Scene_FindSceneObjectIndex(&globalCtx->sceneContext, OBJECT_GI_SHIELD_2);
|
||||
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_2);
|
||||
EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
|
||||
break;
|
||||
case ITEM00_MAP:
|
||||
this->actor.objBankIndex = Scene_FindSceneObjectIndex(&globalCtx->sceneContext, OBJECT_GI_MAP);
|
||||
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MAP);
|
||||
EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
|
||||
break;
|
||||
case ITEM00_COMPASS:
|
||||
this->actor.objBankIndex = Scene_FindSceneObjectIndex(&globalCtx->sceneContext, OBJECT_GI_COMPASS);
|
||||
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_COMPASS);
|
||||
EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
|
||||
break;
|
||||
default:
|
||||
@@ -263,8 +263,8 @@ void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
void EnItem00_WaitForHeartObject(EnItem00* this, GlobalContext* globalCtx) {
|
||||
s32 sp1C;
|
||||
|
||||
sp1C = Scene_FindSceneObjectIndex(&globalCtx->sceneContext, OBJECT_GI_HEARTS);
|
||||
if (Scene_IsObjectLoaded(&globalCtx->sceneContext, sp1C)) {
|
||||
sp1C = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS);
|
||||
if (Object_IsLoaded(&globalCtx->objectCtx, sp1C)) {
|
||||
this->actor.objBankIndex = sp1C;
|
||||
this->actionFunc = func_800A640C;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ void func_800A6650(EnItem00* this, GlobalContext* globalCtx) {
|
||||
if (this->actor.params <= ITEM00_RUPEE_RED) {
|
||||
this->actor.shape.rot.y = this->actor.shape.rot.y + 960;
|
||||
}
|
||||
if ((globalCtx->unk18840 & 1) != 0) {
|
||||
if ((globalCtx->gameplayFrames & 1) != 0) {
|
||||
pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(10.0f);
|
||||
pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(10.0f);
|
||||
pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(10.0f);
|
||||
@@ -377,7 +377,7 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((globalCtx->unk18840 & 1) == 0) {
|
||||
if ((globalCtx->gameplayFrames & 1) == 0) {
|
||||
pos.x = this->actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 10.0f);
|
||||
pos.y = this->actor.world.pos.y + ((Rand_ZeroOne() - 0.5f) * 10.0f);
|
||||
pos.z = this->actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 10.0f);
|
||||
@@ -639,8 +639,8 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
case ITEM00_HEART:
|
||||
if (this->unk152 < 0) {
|
||||
if (this->unk152 == -1) {
|
||||
s8 bankIndex = Scene_FindSceneObjectIndex(&globalCtx->sceneContext, OBJECT_GI_HEART);
|
||||
if (Scene_IsObjectLoaded(&globalCtx->sceneContext, bankIndex)) {
|
||||
s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART);
|
||||
if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) {
|
||||
this->actor.objBankIndex = bankIndex;
|
||||
Actor_SetObjectSegment(globalCtx, &this->actor);
|
||||
this->unk152 = -2;
|
||||
@@ -767,7 +767,7 @@ void EnItem00_DrawHeartContainer(EnItem00* actor, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
s32 pad2;
|
||||
|
||||
if (Scene_FindSceneObjectIndex(&globalCtx->sceneContext, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) {
|
||||
if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) {
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
|
||||
func_8012C2DC(globalCtx->state.gfxCtx);
|
||||
|
||||
+341
-285
@@ -1,83 +1,72 @@
|
||||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
/*
|
||||
TODO:
|
||||
There are a few issues left with this file, but many rely on larger structural project changes.
|
||||
I am avoiding these in the mean time in order to not break the Ghidra project structures.
|
||||
We need a header file for just z_scene. Including relevant structs, scene, and object enums.
|
||||
Needs definition for OBJECT_EXCHANGE_BANK_MAX
|
||||
The .data, .bss, and .rodata sections are not migrated to this file yet.
|
||||
*/
|
||||
|
||||
s32 Scene_LoadObject(SceneContext* sceneCtxt, s16 id) {
|
||||
s32 Object_Spawn(ObjectContext* objectCtx, s16 id) {
|
||||
u32 size;
|
||||
|
||||
sceneCtxt->objects[sceneCtxt->objectCount].id = id;
|
||||
objectCtx->status[objectCtx->num].id = id;
|
||||
size = objectFileTable[id].vromEnd - objectFileTable[id].vromStart;
|
||||
|
||||
if (sceneCtxt) {}
|
||||
if (1) {}
|
||||
|
||||
if (size) {
|
||||
DmaMgr_SendRequest0(sceneCtxt->objects[sceneCtxt->objectCount].segment, objectFileTable[id].vromStart, size);
|
||||
if (size != 0) {
|
||||
DmaMgr_SendRequest0(objectCtx->status[objectCtx->num].segment, objectFileTable[id].vromStart, size);
|
||||
}
|
||||
|
||||
// TODO: This 0x22 is OBJECT_EXCHANGE_BANK_MAX - 1 in OOT
|
||||
if (sceneCtxt->objectCount < 0x22) {
|
||||
sceneCtxt->objects[sceneCtxt->objectCount + 1].segment =
|
||||
// UB to cast pointer to u32
|
||||
(void*)ALIGN16((u32)sceneCtxt->objects[sceneCtxt->objectCount].segment + size);
|
||||
if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) {
|
||||
objectCtx->status[objectCtx->num + 1].segment =
|
||||
(void*)ALIGN16((u32)objectCtx->status[objectCtx->num].segment + size);
|
||||
}
|
||||
|
||||
sceneCtxt->objectCount++;
|
||||
sceneCtxt->spawnedObjectCount = sceneCtxt->objectCount;
|
||||
objectCtx->num++;
|
||||
objectCtx->spawnedObjectCount = objectCtx->num;
|
||||
|
||||
return sceneCtxt->objectCount - 1;
|
||||
return objectCtx->num - 1;
|
||||
}
|
||||
|
||||
void Scene_Init(GlobalContext* ctxt, SceneContext* sceneCtxt) {
|
||||
GlobalContext* global = ctxt; // Needs to be a new variable to match (possibly a sub struct?)
|
||||
u32 unused;
|
||||
void Object_InitBank(GameState* state, ObjectContext* objectCtx) {
|
||||
GlobalContext* globalCtx = (GlobalContext*)state;
|
||||
s32 pad;
|
||||
u32 spaceSize;
|
||||
s32 i;
|
||||
|
||||
if (global->sceneNum == SCENE_CLOCKTOWER || global->sceneNum == SCENE_TOWN || global->sceneNum == SCENE_BACKTOWN || global->sceneNum == SCENE_ICHIBA) {
|
||||
spaceSize = 1566720;
|
||||
} else if (global->sceneNum == SCENE_MILK_BAR) {
|
||||
spaceSize = 1617920;
|
||||
} else if (global->sceneNum == SCENE_00KEIKOKU) {
|
||||
spaceSize = 1505280;
|
||||
if (globalCtx->sceneNum == SCENE_CLOCKTOWER || globalCtx->sceneNum == SCENE_TOWN ||
|
||||
globalCtx->sceneNum == SCENE_BACKTOWN || globalCtx->sceneNum == SCENE_ICHIBA) {
|
||||
spaceSize = OBJECT_SPACE_SIZE_CLOCK_TOWN;
|
||||
} else if (globalCtx->sceneNum == SCENE_MILK_BAR) {
|
||||
spaceSize = OBJECT_SPACE_SIZE_MILK_BAR;
|
||||
} else if (globalCtx->sceneNum == SCENE_00KEIKOKU) {
|
||||
spaceSize = OBJECT_SPACE_SIZE_TERMINA_FIELD;
|
||||
} else {
|
||||
spaceSize = 1413120;
|
||||
spaceSize = OBJECT_SPACE_SIZE_DEFAULT;
|
||||
}
|
||||
|
||||
sceneCtxt->objectCount = 0;
|
||||
sceneCtxt->spawnedObjectCount = 0;
|
||||
sceneCtxt->mainKeepIndex = 0;
|
||||
sceneCtxt->keepObjectId = 0;
|
||||
objectCtx->num = 0;
|
||||
objectCtx->spawnedObjectCount = 0;
|
||||
objectCtx->mainKeepIndex = 0;
|
||||
objectCtx->subKeepIndex = 0;
|
||||
|
||||
// TODO: 0x23 is OBJECT_EXCHANGE_BANK_MAX in OOT
|
||||
for (i = 0; i < 0x23; i++) sceneCtxt->objects[i].id = 0;
|
||||
// clang-format off
|
||||
for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) { objectCtx->status[i].id = 0; }
|
||||
// clang-format on
|
||||
|
||||
sceneCtxt->objectVramStart = sceneCtxt->objects[0].segment = THA_AllocEndAlign16(&ctxt->state.heap, spaceSize);
|
||||
// UB to cast sceneCtxt->objectVramStart to s32
|
||||
sceneCtxt->objectVramEnd = (void*)((u32)sceneCtxt->objectVramStart + spaceSize);
|
||||
// TODO: Second argument here is an object enum
|
||||
sceneCtxt->mainKeepIndex = Scene_LoadObject(sceneCtxt, 1);
|
||||
// TODO: Segment number enum?
|
||||
gSegments[4] = PHYSICAL_TO_VIRTUAL(sceneCtxt->objects[sceneCtxt->mainKeepIndex].segment);
|
||||
objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocEndAlign16(&state->heap, spaceSize);
|
||||
objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize);
|
||||
objectCtx->mainKeepIndex = Object_Spawn(objectCtx, GAMEPLAY_KEEP);
|
||||
|
||||
gSegments[4] = PHYSICAL_TO_VIRTUAL(objectCtx->status[objectCtx->mainKeepIndex].segment);
|
||||
}
|
||||
|
||||
void Scene_ReloadUnloadedObjects(SceneContext* sceneCtxt) {
|
||||
void Object_UpdateBank(ObjectContext* objectCtx) {
|
||||
s32 i;
|
||||
ObjectStatus* status;
|
||||
ObjectFileTableEntry* objectFile;
|
||||
ObjectStatus* status = &objectCtx->status[0];
|
||||
RomFile* objectFile;
|
||||
u32 size;
|
||||
|
||||
status = &sceneCtxt->objects[0];
|
||||
for (i = 0; i < sceneCtxt->objectCount; i++) {
|
||||
for (i = 0; i < objectCtx->num; i++) {
|
||||
if (status->id < 0) {
|
||||
s32 id = -status->id;
|
||||
|
||||
if (status->dmaReq.vromAddr == 0) {
|
||||
objectFile = &objectFileTable[id];
|
||||
size = objectFile->vromEnd - objectFile->vromStart;
|
||||
@@ -86,175 +75,185 @@ void Scene_ReloadUnloadedObjects(SceneContext* sceneCtxt) {
|
||||
status->id = 0;
|
||||
} else {
|
||||
osCreateMesgQueue(&status->loadQueue, &status->loadMsg, 1);
|
||||
DmaMgr_SendRequestImpl(&status->dmaReq, status->segment, objectFile->vromStart,
|
||||
size, 0, &status->loadQueue, NULL);
|
||||
DmaMgr_SendRequestImpl(&status->dmaReq, status->segment, objectFile->vromStart, size, 0,
|
||||
&status->loadQueue, NULL);
|
||||
}
|
||||
} else if (!osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK)) {
|
||||
status->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
status++;
|
||||
}
|
||||
}
|
||||
|
||||
s32 Scene_FindSceneObjectIndex(SceneContext* sceneCtxt, s16 objectId) {
|
||||
s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) {
|
||||
s32 i;
|
||||
for(i = 0; i < sceneCtxt->objectCount; i++) {
|
||||
if((sceneCtxt->objects[i].id < 0 ? -sceneCtxt->objects[i].id : sceneCtxt->objects[i].id) == objectId) {
|
||||
|
||||
for (i = 0; i < objectCtx->num; i++) {
|
||||
if ((objectCtx->status[i].id < 0 ? -objectCtx->status[i].id : objectCtx->status[i].id) == objectId) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 Scene_IsObjectLoaded(SceneContext* actorShape, s32 index) {
|
||||
if (actorShape->objects[index].id > 0) {
|
||||
return 1;
|
||||
s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index) {
|
||||
if (objectCtx->status[index].id > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Scene_DmaAllObjects(SceneContext* sceneCtxt) {
|
||||
void Object_LoadAll(ObjectContext* objectCtx) {
|
||||
s32 i;
|
||||
s32 id;
|
||||
u32 vromSize;
|
||||
|
||||
for (i = 0; i < sceneCtxt->objectCount; i++) {
|
||||
id = sceneCtxt->objects[i].id;
|
||||
for (i = 0; i < objectCtx->num; i++) {
|
||||
id = objectCtx->status[i].id;
|
||||
vromSize = objectFileTable[id].vromEnd - objectFileTable[id].vromStart;
|
||||
|
||||
if (vromSize == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DmaMgr_SendRequest0(sceneCtxt->objects[i].segment, objectFileTable[id].vromStart, vromSize);
|
||||
DmaMgr_SendRequest0(objectCtx->status[i].segment, objectFileTable[id].vromStart, vromSize);
|
||||
}
|
||||
}
|
||||
|
||||
void* func_8012F73C(SceneContext* sceneCtxt, s32 iParm2, s16 id) {
|
||||
void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) {
|
||||
u32 addr;
|
||||
u32 vromSize;
|
||||
ObjectFileTableEntry* fileTableEntry;
|
||||
RomFile* fileTableEntry;
|
||||
|
||||
sceneCtxt->objects[iParm2].id = -id;
|
||||
sceneCtxt->objects[iParm2].dmaReq.vromAddr = 0;
|
||||
objectCtx->status[iParm2].id = -id;
|
||||
objectCtx->status[iParm2].dmaReq.vromAddr = 0;
|
||||
|
||||
fileTableEntry = &objectFileTable[id];
|
||||
vromSize = fileTableEntry->vromEnd - fileTableEntry->vromStart;
|
||||
|
||||
// TODO: UB to cast void to u32
|
||||
addr = ((u32)sceneCtxt->objects[iParm2].segment) + vromSize;
|
||||
addr = ((u32)objectCtx->status[iParm2].segment) + vromSize;
|
||||
addr = ALIGN16(addr);
|
||||
// UB to cast u32 to pointer
|
||||
|
||||
return (void*)addr;
|
||||
}
|
||||
|
||||
// Scene Command 0x00: Link Spawn List
|
||||
void Scene_HeaderCommand00(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
GlobalContext* global = ctxt; // Needs to be a new variable to match (possibly a sub struct?)
|
||||
// Scene Header Command 0x00: Spawn List
|
||||
void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
GlobalContext* globalCtx2 = globalCtx;
|
||||
s32 loadedCount;
|
||||
void* objectVramAddr;
|
||||
s16 temp16;
|
||||
void* nextObject;
|
||||
s16 playerObjectId;
|
||||
u8 unk20;
|
||||
|
||||
ctxt->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(entry->spawnList.segment) +
|
||||
ctxt->setupEntranceList[ctxt->curSpawn].spawn;
|
||||
if ( (ctxt->linkActorEntry->params & 0x0F00) >> 8 == 0x0C ||
|
||||
(gSaveContext.extra.unk10 == 0x02 && gSaveContext.extra.unk42 == 0x0CFF)
|
||||
) {
|
||||
Scene_LoadObject(&ctxt->sceneContext, OBJECT_STK);
|
||||
globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) +
|
||||
globalCtx->setupEntranceList[globalCtx->curSpawn].spawn;
|
||||
if ((globalCtx->linkActorEntry->params & 0x0F00) >> 8 == 0x0C ||
|
||||
(gSaveContext.extra.unk10 == 0x02 && gSaveContext.extra.unk42 == 0x0CFF)) {
|
||||
// Skull Kid Object
|
||||
Object_Spawn(&globalCtx->objectCtx, OBJECT_STK);
|
||||
return;
|
||||
}
|
||||
|
||||
loadedCount = Scene_LoadObject(&ctxt->sceneContext, OBJECT_LINK_CHILD);
|
||||
objectVramAddr = global->sceneContext.objects[global->sceneContext.objectCount].segment;
|
||||
ctxt->sceneContext.objectCount = loadedCount;
|
||||
ctxt->sceneContext.spawnedObjectCount = loadedCount;
|
||||
loadedCount = Object_Spawn(&globalCtx->objectCtx, OBJECT_LINK_CHILD);
|
||||
nextObject = globalCtx2->objectCtx.status[globalCtx2->objectCtx.num].segment;
|
||||
globalCtx->objectCtx.num = loadedCount;
|
||||
globalCtx->objectCtx.spawnedObjectCount = loadedCount;
|
||||
unk20 = gSaveContext.perm.unk20;
|
||||
temp16 = D_801C2730[unk20];
|
||||
gActorOverlayTable[0].initInfo->objectId = temp16;
|
||||
Scene_LoadObject(&ctxt->sceneContext, temp16);
|
||||
playerObjectId = gLinkFormObjectIndexes[unk20];
|
||||
gActorOverlayTable[0].initInfo->objectId = playerObjectId;
|
||||
Object_Spawn(&globalCtx->objectCtx, playerObjectId);
|
||||
|
||||
ctxt->sceneContext.objects[ctxt->sceneContext.objectCount].segment = objectVramAddr;
|
||||
globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment = nextObject;
|
||||
}
|
||||
|
||||
// Scene Command 0x01: Actor List
|
||||
void Scene_HeaderCommand01(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->sceneNumActorsToLoad = (u16)entry->actorList.num;
|
||||
ctxt->setupActorList = (ActorEntry*)Lib_SegmentedToVirtual(entry->actorList.segment);
|
||||
ctxt->actorCtx.unkC = (u16)0;
|
||||
// Scene Header Command 0x01: Actor List
|
||||
void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->sceneNumActorsToLoad = (u16)cmd->actorList.num;
|
||||
globalCtx->setupActorList = (ActorEntry*)Lib_SegmentedToVirtual(cmd->actorList.segment);
|
||||
globalCtx->actorCtx.unkC = (u16)0;
|
||||
}
|
||||
|
||||
// Scene Command 0x02: Cutscene Camera List
|
||||
void Scene_HeaderCommand02(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->unk18858 = (UNK_PTR)Lib_SegmentedToVirtual(entry->csCameraList.segment);
|
||||
// Scene Header Command 0x02: List of cameras for actor cutscenes
|
||||
void Scene_HeaderCmdActorCutsceneCamList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->unk18858 = (UNK_PTR)Lib_SegmentedToVirtual(cmd->csCameraList.segment);
|
||||
}
|
||||
|
||||
// Scene Command 0x03: Collision Header
|
||||
void Scene_HeaderCommand03(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
CollisionHeader* temp_ret;
|
||||
CollisionHeader* temp_s0;
|
||||
// Scene Header Command 0x03: Collision Header
|
||||
void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
CollisionHeader* colHeaderTemp;
|
||||
CollisionHeader* colHeader;
|
||||
|
||||
temp_ret = (CollisionHeader*)Lib_SegmentedToVirtual(entry->colHeader.segment);
|
||||
temp_s0 = temp_ret;
|
||||
temp_s0->vtxList = (Vec3s*)Lib_SegmentedToVirtual(temp_ret->vtxList);
|
||||
temp_s0->polyList = (CollisionPoly*)Lib_SegmentedToVirtual(temp_s0->polyList);
|
||||
if (temp_s0->surfaceTypeList != 0) {
|
||||
temp_s0->surfaceTypeList = (SurfaceType*)Lib_SegmentedToVirtual(temp_s0->surfaceTypeList);
|
||||
}
|
||||
if (temp_s0->cameraDataList != 0) {
|
||||
temp_s0->cameraDataList = (void*)Lib_SegmentedToVirtual(temp_s0->cameraDataList);
|
||||
}
|
||||
if (temp_s0->waterBoxes != 0) {
|
||||
temp_s0->waterBoxes = (WaterBox*)Lib_SegmentedToVirtual(temp_s0->waterBoxes);
|
||||
colHeaderTemp = (CollisionHeader*)Lib_SegmentedToVirtual(cmd->colHeader.segment);
|
||||
colHeader = colHeaderTemp;
|
||||
colHeader->vtxList = (Vec3s*)Lib_SegmentedToVirtual(colHeaderTemp->vtxList);
|
||||
colHeader->polyList = (CollisionPoly*)Lib_SegmentedToVirtual(colHeader->polyList);
|
||||
|
||||
if (colHeader->surfaceTypeList != NULL) {
|
||||
colHeader->surfaceTypeList = (SurfaceType*)Lib_SegmentedToVirtual(colHeader->surfaceTypeList);
|
||||
}
|
||||
|
||||
BgCheck_Init(&ctxt->colCtx, ctxt, temp_s0);
|
||||
if (colHeader->cameraDataList != NULL) {
|
||||
colHeader->cameraDataList = (void*)Lib_SegmentedToVirtual(colHeader->cameraDataList);
|
||||
}
|
||||
|
||||
if (colHeader->waterBoxes != NULL) {
|
||||
colHeader->waterBoxes = (WaterBox*)Lib_SegmentedToVirtual(colHeader->waterBoxes);
|
||||
}
|
||||
|
||||
BgCheck_Init(&globalCtx->colCtx, globalCtx, colHeader);
|
||||
}
|
||||
|
||||
// Scene Command 0x04: Room List
|
||||
void Scene_HeaderCommand04(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->numRooms = entry->roomList.num;
|
||||
ctxt->roomList = (RomFile*)Lib_SegmentedToVirtual(entry->roomList.segment);
|
||||
// Scene Header Command 0x04: Room List
|
||||
void Scene_HeaderCmdRoomList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->numRooms = cmd->roomList.num;
|
||||
globalCtx->roomList = (RomFile*)Lib_SegmentedToVirtual(cmd->roomList.segment);
|
||||
}
|
||||
|
||||
// Scene Command 0x06: Entrance List
|
||||
void Scene_HeaderCommand06(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->setupEntranceList = (EntranceEntry*)Lib_SegmentedToVirtual(entry->entranceList.segment);
|
||||
// Scene Header Command 0x06: Entrance List
|
||||
void Scene_HeaderCmdEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->setupEntranceList = (EntranceEntry*)Lib_SegmentedToVirtual(cmd->entranceList.segment);
|
||||
}
|
||||
|
||||
// Scene Command 0x07: Special Files
|
||||
void Scene_HeaderCommand07(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
if (entry->specialFiles.keepObjectId != 0) {
|
||||
ctxt->sceneContext.keepObjectId = Scene_LoadObject(&ctxt->sceneContext,
|
||||
entry->specialFiles.keepObjectId);
|
||||
// Scene Header Command 0x07: Special Files
|
||||
void Scene_HeaderCmdSpecialFiles(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
static RomFile tatlMessageFiles[2] = {
|
||||
{ (u32)_elf_message_fieldSegmentRomStart, (u32)_elf_message_fieldSegmentRomEnd },
|
||||
{ (u32)_elf_message_ydanSegmentRomStart, (u32)_elf_message_ydanSegmentRomEnd },
|
||||
};
|
||||
|
||||
if (cmd->specialFiles.subKeepIndex != 0) {
|
||||
globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.subKeepIndex);
|
||||
// TODO: Segment number enum?
|
||||
gSegments[5] =
|
||||
PHYSICAL_TO_VIRTUAL(ctxt->sceneContext.objects[ctxt->sceneContext.keepObjectId].segment);
|
||||
gSegments[5] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
|
||||
}
|
||||
|
||||
if (entry->specialFiles.cUpElfMsgNum != 0) {
|
||||
ctxt->unk18868 = Play_LoadScene(ctxt, &D_801C2650[entry->specialFiles.cUpElfMsgNum - 1]);
|
||||
if (cmd->specialFiles.cUpElfMsgNum != 0) {
|
||||
globalCtx->unk18868 = Play_LoadScene(globalCtx, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Scene Command 0x08: Room Behavior
|
||||
void Scene_HeaderCommand08(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->roomContext.currRoom.unk3 = entry->roomBehavior.gpFlag1;
|
||||
ctxt->roomContext.currRoom.unk2 = entry->roomBehavior.gpFlag2 & 0xFF;
|
||||
ctxt->roomContext.currRoom.unk5 = (entry->roomBehavior.gpFlag2 >> 8) & 1;
|
||||
ctxt->msgCtx.unk12044 = (entry->roomBehavior.gpFlag2 >> 0xa) & 1;
|
||||
ctxt->roomContext.currRoom.enablePosLights = (entry->roomBehavior.gpFlag2 >> 0xb) & 1;
|
||||
ctxt->kankyoContext.unkE2 = (entry->roomBehavior.gpFlag2 >> 0xc) & 1;
|
||||
// Scene Header Command 0x08: Room Behavior
|
||||
void Scene_HeaderCmdRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->roomContext.currRoom.unk3 = cmd->roomBehavior.gpFlag1;
|
||||
globalCtx->roomContext.currRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF;
|
||||
globalCtx->roomContext.currRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1;
|
||||
globalCtx->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xa) & 1;
|
||||
globalCtx->roomContext.currRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xb) & 1;
|
||||
globalCtx->kankyoContext.unkE2 = (cmd->roomBehavior.gpFlag2 >> 0xc) & 1;
|
||||
}
|
||||
|
||||
// Scene Command 0x0A: Mesh Header
|
||||
void Scene_HeaderCommand0A(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->roomContext.currRoom.mesh = (RoomMesh*)Lib_SegmentedToVirtual(entry->mesh.segment);
|
||||
// Scene Header Command 0x0A: Mesh Header
|
||||
void Scene_HeaderCmdMesh(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->roomContext.currRoom.mesh = (RoomMesh*)Lib_SegmentedToVirtual(cmd->mesh.segment);
|
||||
}
|
||||
|
||||
// Scene Command 0x0B: Object List
|
||||
void Scene_HeaderCommand0B(GlobalContext *ctxt, SceneCmd *entry) {
|
||||
// Scene Header Command 0x0B: Object List
|
||||
void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
s32 i, j, k;
|
||||
ObjectStatus* firstObject;
|
||||
ObjectStatus* status;
|
||||
@@ -262,21 +261,23 @@ void Scene_HeaderCommand0B(GlobalContext *ctxt, SceneCmd *entry) {
|
||||
s16* objectEntry;
|
||||
void* nextPtr;
|
||||
|
||||
objectEntry = (s16*)Lib_SegmentedToVirtual(entry->objectList.segment);
|
||||
objectEntry = (s16*)Lib_SegmentedToVirtual(cmd->objectList.segment);
|
||||
k = 0;
|
||||
i = ctxt->sceneContext.spawnedObjectCount;
|
||||
status = &ctxt->sceneContext.objects[i];
|
||||
firstObject = ctxt->sceneContext.objects;
|
||||
i = globalCtx->objectCtx.spawnedObjectCount;
|
||||
status = &globalCtx->objectCtx.status[i];
|
||||
firstObject = globalCtx->objectCtx.status;
|
||||
|
||||
while (i < ctxt->sceneContext.objectCount) {
|
||||
while (i < globalCtx->objectCtx.num) {
|
||||
if (status->id != *objectEntry) {
|
||||
status2 = &ctxt->sceneContext.objects[i];
|
||||
for (j = i; j < ctxt->sceneContext.objectCount; j++) {
|
||||
status2 = &globalCtx->objectCtx.status[i];
|
||||
|
||||
for (j = i; j < globalCtx->objectCtx.num; j++) {
|
||||
status2->id = 0;
|
||||
status2++;
|
||||
}
|
||||
ctxt->sceneContext.objectCount = i;
|
||||
func_800BA6FC(ctxt, &ctxt->actorCtx);
|
||||
|
||||
globalCtx->objectCtx.num = i;
|
||||
func_800BA6FC(globalCtx, &globalCtx->actorCtx);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -287,116 +288,128 @@ void Scene_HeaderCommand0B(GlobalContext *ctxt, SceneCmd *entry) {
|
||||
status++;
|
||||
}
|
||||
|
||||
while (k < entry->objectList.num) {
|
||||
nextPtr = func_8012F73C(&ctxt->sceneContext, i, *objectEntry);
|
||||
while (k < cmd->objectList.num) {
|
||||
nextPtr = func_8012F73C(&globalCtx->objectCtx, i, *objectEntry);
|
||||
|
||||
// TODO: This 0x22 is OBJECT_EXCHANGE_BANK_MAX - 1 in OOT
|
||||
if (i < 0x22) {
|
||||
if (i < OBJECT_EXCHANGE_BANK_MAX - 1) {
|
||||
firstObject[i + 1].segment = nextPtr;
|
||||
}
|
||||
|
||||
i++;
|
||||
k++;
|
||||
objectEntry++;
|
||||
}
|
||||
|
||||
ctxt->sceneContext.objectCount = i;
|
||||
globalCtx->objectCtx.num = i;
|
||||
}
|
||||
|
||||
// Scene Command 0x0C: Light List
|
||||
void Scene_HeaderCommand0C(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
// Scene Header Command 0x0C: Light List
|
||||
void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
s32 i;
|
||||
LightInfo* lightInfo;
|
||||
LightInfo* lightInfo = (LightInfo*)Lib_SegmentedToVirtual(cmd->lightList.segment);
|
||||
|
||||
lightInfo = (LightInfo*)Lib_SegmentedToVirtual(entry->lightList.segment);
|
||||
for (i = 0; i < entry->lightList.num; i++)
|
||||
{
|
||||
LightContext_InsertLight(ctxt, &ctxt->lightCtx, lightInfo);
|
||||
for (i = 0; i < cmd->lightList.num; i++) {
|
||||
LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo);
|
||||
lightInfo++;
|
||||
}
|
||||
}
|
||||
|
||||
// Scene Command 0x0D: Path List
|
||||
void Scene_HeaderCommand0D(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->setupPathList = (void*)Lib_SegmentedToVirtual(entry->pathList.segment);
|
||||
// Scene Header Command 0x0D: Path List
|
||||
void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->setupPathList = (void*)Lib_SegmentedToVirtual(cmd->pathList.segment);
|
||||
}
|
||||
|
||||
// Scene Command 0x0E: Transition Actor List
|
||||
void Scene_HeaderCommand0E(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->transitionActorCount = entry->transiActorList.num;
|
||||
ctxt->transitionActorList = (TransitionActorEntry*)Lib_SegmentedToVirtual((void*)entry->transiActorList.segment);
|
||||
func_80105818(ctxt, ctxt->transitionActorCount, ctxt->transitionActorList);
|
||||
// Scene Header Command 0x0E: Transition Actor List
|
||||
void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->transitionCtx.nbTransitionActors = cmd->transiActorList.num;
|
||||
globalCtx->transitionCtx.transitionActorList =
|
||||
(TransitionActorEntry*)Lib_SegmentedToVirtual((void*)cmd->transiActorList.segment);
|
||||
func_80105818(globalCtx, globalCtx->transitionCtx.nbTransitionActors, globalCtx->transitionCtx.transitionActorList);
|
||||
}
|
||||
|
||||
void func_8012FEBC(GlobalContext* ctxt, u8* nbTransitionActors) {
|
||||
*nbTransitionActors = 0;
|
||||
// Init function for the transition system.
|
||||
void Transition_Init(GameState* state, TransitionContext* transitionCtx) {
|
||||
transitionCtx->nbTransitionActors = 0;
|
||||
}
|
||||
|
||||
// Scene Command 0x0F: Light Setting List
|
||||
void Scene_HeaderCommand0F(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->kankyoContext.environmentSettingsCount = entry->lightSettingList.num;
|
||||
ctxt->kankyoContext.environmentSettingsList = (void*)Lib_SegmentedToVirtual(entry->lightSettingList.segment);
|
||||
// Scene Header Command 0x0F: Environment Light Settings List
|
||||
void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->kankyoContext.environmentSettingsCount = cmd->lightSettingList.num;
|
||||
globalCtx->kankyoContext.environmentSettingsList = (void*)Lib_SegmentedToVirtual(cmd->lightSettingList.segment);
|
||||
}
|
||||
|
||||
s32 func_8012FF10(GlobalContext* ctxt, s32 fileIndex) {
|
||||
u32 vromStart = D_801C2660[fileIndex].vromStart;
|
||||
u32 fileSize = D_801C2660[fileIndex].vromEnd - vromStart;
|
||||
/**
|
||||
* Loads different texture files for each region of the world.
|
||||
* These later are stored in segment 0x06, and used in maps.
|
||||
*/
|
||||
s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) {
|
||||
static RomFile sceneTextureFiles[9] = {
|
||||
{ 0, 0 }, // Default
|
||||
{ (u32)_scene_texture_01SegmentRomStart, (u32)_scene_texture_01SegmentRomEnd },
|
||||
{ (u32)_scene_texture_02SegmentRomStart, (u32)_scene_texture_02SegmentRomEnd },
|
||||
{ (u32)_scene_texture_03SegmentRomStart, (u32)_scene_texture_03SegmentRomEnd },
|
||||
{ (u32)_scene_texture_04SegmentRomStart, (u32)_scene_texture_04SegmentRomEnd },
|
||||
{ (u32)_scene_texture_05SegmentRomStart, (u32)_scene_texture_05SegmentRomEnd },
|
||||
{ (u32)_scene_texture_06SegmentRomStart, (u32)_scene_texture_06SegmentRomEnd },
|
||||
{ (u32)_scene_texture_07SegmentRomStart, (u32)_scene_texture_07SegmentRomEnd },
|
||||
{ (u32)_scene_texture_08SegmentRomStart, (u32)_scene_texture_08SegmentRomEnd },
|
||||
};
|
||||
u32 vromStart = sceneTextureFiles[fileIndex].vromStart;
|
||||
u32 size = sceneTextureFiles[fileIndex].vromEnd - vromStart;
|
||||
|
||||
if (fileSize) {
|
||||
ctxt->roomContext.unk74 = THA_AllocEndAlign16(&ctxt->state.heap, fileSize);
|
||||
return DmaMgr_SendRequest0(ctxt->roomContext.unk74, vromStart, fileSize);
|
||||
if (size != 0) {
|
||||
globalCtx->roomContext.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size);
|
||||
return DmaMgr_SendRequest0(globalCtx->roomContext.unk74, vromStart, size);
|
||||
}
|
||||
|
||||
// UB: Undefined behaviour to not have a return statement here, but it breaks matching to add one.
|
||||
}
|
||||
|
||||
// Scene Command 0x11: Skybox Settings
|
||||
void Scene_HeaderCommand11(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->unk18874 = entry->skyboxSettings.skyboxId & 3;
|
||||
ctxt->kankyoContext.unk17 = ctxt->kankyoContext.unk18 = entry->skyboxSettings.unk5;
|
||||
ctxt->kankyoContext.unk1E = entry->skyboxSettings.unk6;
|
||||
func_8012FF10(ctxt, entry->skyboxSettings.data1);
|
||||
// Scene Header Command 0x11: Skybox Settings
|
||||
void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->unk18874 = cmd->skyboxSettings.skyboxId & 3;
|
||||
globalCtx->kankyoContext.unk17 = globalCtx->kankyoContext.unk18 = cmd->skyboxSettings.unk5;
|
||||
globalCtx->kankyoContext.unk1E = cmd->skyboxSettings.unk6;
|
||||
Scene_LoadAreaTextures(globalCtx, cmd->skyboxSettings.data1);
|
||||
}
|
||||
|
||||
// Scene Command 0x12: Skybox Disables
|
||||
void Scene_HeaderCommand12(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->kankyoContext.unk15 = entry->skyboxDisables.unk4;
|
||||
ctxt->kankyoContext.unk16 = entry->skyboxDisables.unk5;
|
||||
// Scene Header Command 0x12: Skybox Disables
|
||||
void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->kankyoContext.unk15 = cmd->skyboxDisables.unk4;
|
||||
globalCtx->kankyoContext.unk16 = cmd->skyboxDisables.unk5;
|
||||
}
|
||||
|
||||
// Scene Command 0x10: Time Settings
|
||||
void Scene_HeaderCommand10(GlobalContext *ctxt, SceneCmd *entry) {
|
||||
// Scene Header Command 0x10: Time Settings
|
||||
void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
u32 dayTime;
|
||||
|
||||
if (entry->timeSettings.hour != 0xFF && entry->timeSettings.min != 0xFF) {
|
||||
if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) {
|
||||
gSaveContext.extra.environmentTime = gSaveContext.perm.time =
|
||||
(u16)(((entry->timeSettings.hour + (entry->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f);
|
||||
(u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f);
|
||||
}
|
||||
|
||||
if (entry->timeSettings.unk6 != 0xFF) {
|
||||
ctxt->kankyoContext.unk2 = entry->timeSettings.unk6;
|
||||
if (cmd->timeSettings.unk6 != 0xFF) {
|
||||
globalCtx->kankyoContext.unk2 = cmd->timeSettings.unk6;
|
||||
} else {
|
||||
ctxt->kankyoContext.unk2 = 0;
|
||||
globalCtx->kankyoContext.unk2 = 0;
|
||||
}
|
||||
|
||||
if (gSaveContext.perm.inv.items[0] == 0xFF) {
|
||||
if (ctxt->kankyoContext.unk2 != 0) {
|
||||
ctxt->kankyoContext.unk2 = 5;
|
||||
}
|
||||
if ((gSaveContext.perm.inv.items[0] == 0xFF) && (globalCtx->kankyoContext.unk2 != 0)) {
|
||||
globalCtx->kankyoContext.unk2 = 5;
|
||||
}
|
||||
|
||||
if (gSaveContext.extra.unk2b8 == 0) {
|
||||
// TODO: Needs REG macro
|
||||
gGameInfo->data[0x0F] = ctxt->kankyoContext.unk2;
|
||||
REG(15) = globalCtx->kankyoContext.unk2;
|
||||
}
|
||||
|
||||
dayTime = gSaveContext.perm.time;
|
||||
ctxt->kankyoContext.unk4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f;
|
||||
globalCtx->kankyoContext.unk4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f;
|
||||
dayTime = gSaveContext.perm.time;
|
||||
ctxt->kankyoContext.unk8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f;
|
||||
globalCtx->kankyoContext.unk8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f;
|
||||
dayTime = gSaveContext.perm.time;
|
||||
ctxt->kankyoContext.unkC = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f;
|
||||
globalCtx->kankyoContext.unkC = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f;
|
||||
|
||||
if (ctxt->kankyoContext.unk2 == 0 && gSaveContext.perm.cutscene < 0xFFF0) {
|
||||
if (globalCtx->kankyoContext.unk2 == 0 && gSaveContext.perm.cutscene < 0xFFF0) {
|
||||
gSaveContext.extra.environmentTime = gSaveContext.perm.time;
|
||||
|
||||
if (gSaveContext.extra.environmentTime >= 0x2AAA && gSaveContext.extra.environmentTime < 0x4555) {
|
||||
@@ -411,135 +424,172 @@ void Scene_HeaderCommand10(GlobalContext *ctxt, SceneCmd *entry) {
|
||||
}
|
||||
}
|
||||
|
||||
// Scene Command 0x05: Wind Settings
|
||||
void Scene_HeaderCommand05(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
s8 temp1 = entry->windSettings.west;
|
||||
s8 temp2 = entry->windSettings.vertical;
|
||||
s8 temp3 = entry->windSettings.south;
|
||||
ctxt->kankyoContext.windWest = temp1;
|
||||
ctxt->kankyoContext.windVertical = temp2;
|
||||
ctxt->kankyoContext.windSouth = temp3;
|
||||
ctxt->kankyoContext.windClothIntensity = entry->windSettings.clothIntensity;
|
||||
// Scene Header Command 0x05: Wind Settings
|
||||
void Scene_HeaderCmdWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
s8 temp1 = cmd->windSettings.west;
|
||||
s8 temp2 = cmd->windSettings.vertical;
|
||||
s8 temp3 = cmd->windSettings.south;
|
||||
|
||||
globalCtx->kankyoContext.windWest = temp1;
|
||||
globalCtx->kankyoContext.windVertical = temp2;
|
||||
globalCtx->kankyoContext.windSouth = temp3;
|
||||
globalCtx->kankyoContext.windClothIntensity = cmd->windSettings.clothIntensity;
|
||||
}
|
||||
|
||||
void Scene_HeaderCommand13(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->setupExitList = (void*)Lib_SegmentedToVirtual(entry->exitList.segment);
|
||||
// Scene Header Command 0x13: Exit List
|
||||
void Scene_HeaderCmdExitList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->setupExitList = (u16*)Lib_SegmentedToVirtual(cmd->exitList.segment);
|
||||
}
|
||||
|
||||
// Scene Command 0x09: Undefined
|
||||
void Scene_HeaderCommand09(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
|
||||
// Scene Header Command 0x09: Undefined
|
||||
void Scene_HeaderCmd09(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
}
|
||||
|
||||
// Scene Command 0x15: Sound Settings
|
||||
void Scene_HeaderCommand15(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->unk814 = entry->soundSettings.musicSeq;
|
||||
ctxt->unk815 = entry->soundSettings.nighttimeSFX;
|
||||
// Scene Header Command 0x15: Sound Settings=
|
||||
void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->unk814 = cmd->soundSettings.musicSeq;
|
||||
globalCtx->unk815 = cmd->soundSettings.nighttimeSFX;
|
||||
|
||||
if (gSaveContext.extra.unk276 == 0xFF || func_801A8A50(0) == 0x57) {
|
||||
audio_setBGM(entry->soundSettings.bgmId);
|
||||
audio_setBGM(cmd->soundSettings.bgmId);
|
||||
}
|
||||
}
|
||||
|
||||
// Scene Command 0x16: Echo Setting
|
||||
void Scene_HeaderCommand16(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->roomContext.currRoom.echo = entry->echoSettings.echo;
|
||||
// Scene Header Command 0x16: Echo Setting
|
||||
void Scene_HeaderCmdEchoSetting(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->roomContext.currRoom.echo = cmd->echoSettings.echo;
|
||||
}
|
||||
|
||||
// Scene Command 0x18: Alternate Headers
|
||||
void Scene_HeaderCommand18(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
// Scene Header Command 0x18: Alternate Header List=
|
||||
void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
SceneCmd** altHeaderList;
|
||||
SceneCmd* altHeader;
|
||||
|
||||
if (gSaveContext.extra.sceneSetupIndex) {
|
||||
altHeaderList = (SceneCmd**)Lib_SegmentedToVirtual(entry->altHeaders.segment);
|
||||
altHeaderList = (SceneCmd**)Lib_SegmentedToVirtual(cmd->altHeaders.segment);
|
||||
altHeader = altHeaderList[gSaveContext.extra.sceneSetupIndex - 1];
|
||||
|
||||
if (altHeader != NULL) {
|
||||
Scene_ProcessHeader(ctxt, (SceneCmd*)Lib_SegmentedToVirtual(altHeader));
|
||||
(entry + 1)->base.code = 0x14;
|
||||
Scene_ProcessHeader(globalCtx, (SceneCmd*)Lib_SegmentedToVirtual(altHeader));
|
||||
(cmd + 1)->base.code = 0x14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scene Command 0x17: Cutscene Data
|
||||
void Scene_HeaderCommand17(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->csCtx.cutsceneCount = (u8)entry->base.data1;
|
||||
ctxt->cutsceneList = (CutsceneEntry*)Lib_SegmentedToVirtual((void*)entry->base.data2);
|
||||
// Scene Header Command 0x17: Cutscene List
|
||||
void Scene_HeaderCmdCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->csCtx.cutsceneCount = (u8)cmd->base.data1;
|
||||
globalCtx->cutsceneList = (CutsceneEntry*)Lib_SegmentedToVirtual((void*)cmd->base.data2);
|
||||
}
|
||||
|
||||
// Scene Command 0x1B: Cutscene Actor List
|
||||
void Scene_HeaderCommand1B(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ActorCutscene_Init(ctxt, (ActorCutscene*)Lib_SegmentedToVirtual(entry->cutsceneActorList.segment),
|
||||
entry->cutsceneActorList.num);
|
||||
// Scene Header Command 0x1B: Actor Cutscene List
|
||||
void Scene_HeaderCmdActorCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
ActorCutscene_Init(globalCtx, (ActorCutscene*)Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment),
|
||||
cmd->cutsceneActorList.num);
|
||||
}
|
||||
|
||||
// Scene Command 0x1C: Mini Maps
|
||||
void Scene_HeaderCommand1C(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
func_80104CF4(ctxt);
|
||||
func_8010549C(ctxt, entry->minimapSettings.segment);
|
||||
// Scene Header Command 0x1C: Mini Maps
|
||||
void Scene_HeaderCmdMiniMap(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
func_80104CF4(globalCtx);
|
||||
func_8010549C(globalCtx, cmd->minimapSettings.segment);
|
||||
}
|
||||
|
||||
// Scene Command 0x1D: Undefined
|
||||
void Scene_HeaderCommand1D(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
|
||||
// Scene Header Command 0x1D: Undefined
|
||||
void Scene_HeaderCmd1D(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
}
|
||||
|
||||
// Scene Command 0x1E: Minimap Chests
|
||||
void Scene_HeaderCommand1E(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
func_8010565C(ctxt, entry->minimapChests.num, entry->minimapChests.segment);
|
||||
// Scene Header Command 0x1E: Minimap Compass Icon Info
|
||||
void Scene_HeaderCmdMiniMapCompassInfo(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
func_8010565C(globalCtx, cmd->minimapChests.num, cmd->minimapChests.segment);
|
||||
}
|
||||
|
||||
// Scene Command 0x19: Misc. Settings (Camera & World Map Area)
|
||||
void Scene_HeaderCommand19(GlobalContext *ctxt, SceneCmd *entry) {
|
||||
s16 j;
|
||||
s16 i;
|
||||
// Scene Header Command 0x1A: Sets Area Visited Flag
|
||||
void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
s16 j = 0;
|
||||
s16 i = 0;
|
||||
|
||||
j = 0;
|
||||
i = 0;
|
||||
while (1) {
|
||||
while (true) {
|
||||
if (scenesPerMapArea[i].scenes[j] == 0xFFFF) {
|
||||
i++;
|
||||
j=0;
|
||||
j = 0;
|
||||
|
||||
// 0x0B is sizeof(scenesPerMapArea) / sizeof(SceneIdList) ... but does not match calculated
|
||||
if (i == 0x0B) {
|
||||
if (i == (s32)(sizeof(scenesPerMapArea) / sizeof(SceneIdList))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctxt->sceneNum == scenesPerMapArea[i].scenes[j]) {
|
||||
if (globalCtx->sceneNum == scenesPerMapArea[i].scenes[j]) {
|
||||
break;
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
// 0x0B is sizeof(scenesPerMapArea) / sizeof(SceneIdList) ... but does not match calculated
|
||||
if (i < 0x0B) {
|
||||
// This bitwise OR could be a macro, but all sane looking versions break matching.
|
||||
if (i < (s32)(sizeof(scenesPerMapArea) / sizeof(SceneIdList))) {
|
||||
gSaveContext.perm.mapsVisited = (gBitFlags[i] | gSaveContext.perm.mapsVisited) | gSaveContext.perm.mapsVisited;
|
||||
}
|
||||
}
|
||||
|
||||
// Scene Command 0x1A: Texture Animations
|
||||
void Scene_HeaderCommand1A(GlobalContext* ctxt, SceneCmd* entry) {
|
||||
ctxt->sceneTextureAnimations = (AnimatedTexture*)Lib_SegmentedToVirtual(entry->textureAnimations.segment);
|
||||
// Scene Header Command 0x1A: Material Animations
|
||||
void Scene_HeaderCmdAnimatedMaterials(GlobalContext* globalCtx, SceneCmd* cmd) {
|
||||
globalCtx->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment);
|
||||
}
|
||||
|
||||
void func_801306A4(GlobalContext *ctxt) {
|
||||
ctxt->unk1887F = func_801323A0(ctxt->nextEntranceIndex) & 0x7F;
|
||||
/**
|
||||
* Sets the exit fade from the next entrance index.
|
||||
*/
|
||||
void Scene_SetExitFade(GlobalContext* globalCtx) {
|
||||
globalCtx->unk1887F = Entrance_GetTransitionFlags(globalCtx->nextEntranceIndex) & 0x7F;
|
||||
}
|
||||
|
||||
s32 Scene_ProcessHeader(GlobalContext* ctxt, SceneCmd* header) {
|
||||
u32 cmdCode;
|
||||
/**
|
||||
* Executes all of the commands in a scene or room header.
|
||||
*/
|
||||
s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) {
|
||||
static void (*sceneCmdHandlers[])(GlobalContext*, SceneCmd*) = {
|
||||
Scene_HeaderCmdSpawnList,
|
||||
Scene_HeaderCmdActorList,
|
||||
Scene_HeaderCmdActorCutsceneCamList,
|
||||
Scene_HeaderCmdColHeader,
|
||||
Scene_HeaderCmdRoomList,
|
||||
Scene_HeaderCmdWindSettings,
|
||||
Scene_HeaderCmdEntranceList,
|
||||
Scene_HeaderCmdSpecialFiles,
|
||||
Scene_HeaderCmdRoomBehavior,
|
||||
Scene_HeaderCmd09,
|
||||
Scene_HeaderCmdMesh,
|
||||
Scene_HeaderCmdObjectList,
|
||||
Scene_HeaderCmdLightList,
|
||||
Scene_HeaderCmdPathList,
|
||||
Scene_HeaderCmdTransiActorList,
|
||||
Scene_HeaderCmdEnvLightSettings,
|
||||
Scene_HeaderCmdTimeSettings,
|
||||
Scene_HeaderCmdSkyboxSettings,
|
||||
Scene_HeaderCmdSkyboxDisables,
|
||||
Scene_HeaderCmdExitList,
|
||||
NULL,
|
||||
Scene_HeaderCmdSoundSettings,
|
||||
Scene_HeaderCmdEchoSetting,
|
||||
Scene_HeaderCmdCutsceneList,
|
||||
Scene_HeaderCmdAltHeaderList,
|
||||
Scene_HeaderCmdSetAreaVisitedFlag,
|
||||
Scene_HeaderCmdAnimatedMaterials,
|
||||
Scene_HeaderCmdActorCutsceneList,
|
||||
Scene_HeaderCmdMiniMap,
|
||||
Scene_HeaderCmd1D,
|
||||
Scene_HeaderCmdMiniMapCompassInfo,
|
||||
};
|
||||
u32 cmdId;
|
||||
|
||||
while (1) {
|
||||
cmdCode = header->base.code;
|
||||
while (true) {
|
||||
cmdId = header->base.code;
|
||||
|
||||
if (cmdCode == 0x14) {
|
||||
if (cmdId == SCENE_CMD_ID_END) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmdCode < 0x1F) {
|
||||
sceneHeaderFuncTable[cmdCode](ctxt, header);
|
||||
if (cmdId < SCENE_CMD_MAX) {
|
||||
sceneCmdHandlers[cmdId](globalCtx, header);
|
||||
}
|
||||
|
||||
header++;
|
||||
@@ -548,10 +598,16 @@ s32 Scene_ProcessHeader(GlobalContext* ctxt, SceneCmd* header) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 Scene_CreateEntrance(u32 sceneIndex, u32 spawnIndex, u32 offset) {
|
||||
return (((sceneIndex << 9) | (spawnIndex << 4)) | offset) & 0xFFFF;
|
||||
/**
|
||||
* Creates an entrance index from the scene index, spawn index, and scene setup.
|
||||
*/
|
||||
u16 Entrance_CreateIndex(s32 sceneIndex, s32 spawnIndex, s32 sceneSetup) {
|
||||
return (((sceneIndex << 9) | (spawnIndex << 4)) | sceneSetup) & 0xFFFF;
|
||||
}
|
||||
|
||||
void func_80130784(u32 spawnIndex) {
|
||||
Scene_CreateEntrance(gSaveContext.perm.entranceIndex >> 9, spawnIndex, 0);
|
||||
/**
|
||||
* Creates an entrance index from the current entrance index with the given spawn index.
|
||||
*/
|
||||
u16 Entrance_CreateIndexFromSpawn(s32 spawnIndex) {
|
||||
return Entrance_CreateIndex(gSaveContext.perm.entranceIndex >> 9, spawnIndex, 0);
|
||||
}
|
||||
|
||||
+668
-389
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user