1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-02 15:55:59 +00:00
oot/src/code/z_scene.c

533 lines
19 KiB
C
Raw Normal View History

#include "global.h"
#include "vt.h"
2020-03-17 04:31:30 +00:00
RomFile sNaviMsgFiles[];
2020-03-22 21:19:43 +00:00
s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) {
2020-03-17 04:31:30 +00:00
u32 size;
objectCtx->status[objectCtx->num].id = objectId;
size = gObjectTable[objectId].vromEnd - gObjectTable[objectId].vromStart;
2020-10-13 16:32:19 +00:00
osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectId, size / 1024.0f, objectCtx->status[objectCtx->num].segment);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (s32)objectCtx->status[objectCtx->num].segment + size,
objectCtx->spaceEnd);
2020-03-17 04:31:30 +00:00
ASSERT(((objectCtx->num < OBJECT_EXCHANGE_BANK_MAX) &&
(((s32)objectCtx->status[objectCtx->num].segment + size) < (u32)objectCtx->spaceEnd)),
"this->num < OBJECT_EXCHANGE_BANK_MAX && (this->status[this->num].Segment + size) < this->endSegment",
"../z_scene.c", 142);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
DmaMgr_SendRequest1(objectCtx->status[objectCtx->num].segment, gObjectTable[objectId].vromStart, size,
"../z_scene.c", 145);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) {
objectCtx->status[objectCtx->num + 1].segment =
(void*)ALIGN16((s32)objectCtx->status[objectCtx->num].segment + size);
}
2020-03-17 04:31:30 +00:00
objectCtx->num++;
objectCtx->unk_09 = objectCtx->num;
return objectCtx->num - 1;
}
2020-03-22 21:19:43 +00:00
void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx) {
2020-03-17 04:31:30 +00:00
GlobalContext* globalCtx2 = globalCtx; // Needs to be a new variable to match (possibly a sub struct?)
u32 spaceSize;
s32 i;
2020-03-22 21:19:43 +00:00
if (globalCtx2->sceneNum == SCENE_SPOT00) {
2020-03-17 04:31:30 +00:00
spaceSize = 1024000;
2020-03-22 21:19:43 +00:00
} else if (globalCtx2->sceneNum == SCENE_GANON_DEMO) {
if (gSaveContext.sceneSetupIndex != 4) {
2020-03-17 04:31:30 +00:00
spaceSize = 1177600;
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
spaceSize = 1024000;
2020-03-22 21:19:43 +00:00
}
} else if (globalCtx2->sceneNum == SCENE_JYASINBOSS) {
2020-03-17 04:31:30 +00:00
spaceSize = 1075200;
2020-03-22 21:19:43 +00:00
} else if (globalCtx2->sceneNum == SCENE_KENJYANOMA) {
2020-03-17 04:31:30 +00:00
spaceSize = 1075200;
2020-03-22 21:19:43 +00:00
} else if (globalCtx2->sceneNum == SCENE_GANON_BOSS) {
2020-03-17 04:31:30 +00:00
spaceSize = 1075200;
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
spaceSize = 1024000;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
objectCtx->num = objectCtx->unk_09 = 0;
objectCtx->mainKeepIndex = objectCtx->subKeepIndex = 0;
2020-03-22 21:19:43 +00:00
for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) {
objectCtx->status[i].id = OBJECT_INVALID;
2020-03-17 04:31:30 +00:00
}
osSyncPrintf(VT_FGCOL(GREEN));
// "Object exchange bank data %8.3fKB"
2020-10-13 16:32:19 +00:00
osSyncPrintf("オブジェクト入れ替えバンク情報 %8.3fKB\n", spaceSize / 1024.0f);
2020-03-17 04:31:30 +00:00
osSyncPrintf(VT_RST);
2020-03-22 21:19:43 +00:00
objectCtx->spaceStart = objectCtx->status[0].segment =
GameState_Alloc(&globalCtx->state, spaceSize, "../z_scene.c", 219);
2020-03-17 04:31:30 +00:00
objectCtx->spaceEnd = (void*)((s32)objectCtx->spaceStart + spaceSize);
objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP);
gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
void Object_UpdateBank(ObjectContext* objectCtx) {
2020-03-17 04:31:30 +00:00
s32 i;
ObjectStatus* status = &objectCtx->status[0];
2020-03-17 04:31:30 +00:00
RomFile* objectFile;
u32 size;
2020-03-22 21:19:43 +00:00
for (i = 0; i < objectCtx->num; i++) {
if (status->id < 0) {
if (status->dmaRequest.vromAddr == 0) {
2020-03-17 04:31:30 +00:00
osCreateMesgQueue(&status->loadQueue, &status->loadMsg, 1);
objectFile = &gObjectTable[-status->id];
size = objectFile->vromEnd - objectFile->vromStart;
2020-10-13 16:32:19 +00:00
osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, size / 1024.0f, status->segment);
2020-03-22 21:19:43 +00:00
DmaMgr_SendRequest2(&status->dmaRequest, status->segment, objectFile->vromStart, size, 0,
&status->loadQueue, NULL, "../z_scene.c", 266);
} else if (!osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK)) {
2020-03-17 04:31:30 +00:00
status->id = -status->id;
}
}
status++;
}
}
2020-03-22 21:19:43 +00:00
s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId) {
2020-03-17 04:31:30 +00:00
s32 i;
2020-03-22 21:19:43 +00:00
for (i = 0; i < objectCtx->num; i++) {
if (ABS(objectCtx->status[i].id) == objectId) {
2020-03-17 04:31:30 +00:00
return i;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}
return -1;
}
2020-03-22 21:19:43 +00:00
s32 Object_IsLoaded(ObjectContext* objectCtx, s32 bankIndex) {
if (objectCtx->status[bankIndex].id > 0) {
2020-03-17 04:31:30 +00:00
return 1;
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
return 0;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
void func_800981B8(ObjectContext* objectCtx) {
2020-03-17 04:31:30 +00:00
s32 i;
s32 id;
u32 size;
2020-03-22 21:19:43 +00:00
for (i = 0; i < objectCtx->num; i++) {
2020-03-17 04:31:30 +00:00
id = objectCtx->status[i].id;
size = gObjectTable[id].vromEnd - gObjectTable[id].vromStart;
2020-10-13 16:32:19 +00:00
osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->status[i].id, size / 1024.0f,
2020-03-22 21:19:43 +00:00
objectCtx->status[i].segment);
osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (s32)objectCtx->status[i].segment + size,
objectCtx->spaceEnd);
2020-03-17 04:31:30 +00:00
DmaMgr_SendRequest1(objectCtx->status[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342);
}
}
2020-03-22 21:19:43 +00:00
void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) {
2020-03-17 04:31:30 +00:00
ObjectStatus* status = &objectCtx->status[bankIndex];
RomFile* objectFile = &gObjectTable[objectId];
u32 size;
void* nextPtr;
status->id = -objectId;
status->dmaRequest.vromAddr = 0;
size = objectFile->vromEnd - objectFile->vromStart;
2020-10-13 16:32:19 +00:00
osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", bankIndex, objectId, size / 1024.0f);
2020-03-17 04:31:30 +00:00
nextPtr = (void*)ALIGN16((s32)status->segment + size);
if (1) {} // Necessary to match
2020-03-17 04:31:30 +00:00
ASSERT(nextPtr < objectCtx->spaceEnd, "nextptr < this->endSegment", "../z_scene.c", 381);
2020-03-17 04:31:30 +00:00
// "Object exchange free size=%08x"
2020-03-17 04:31:30 +00:00
osSyncPrintf("オブジェクト入れ替え空きサイズ=%08x\n", (s32)objectCtx->spaceEnd - (s32)nextPtr);
return nextPtr;
}
2020-03-22 21:19:43 +00:00
s32 Scene_ExecuteCommands(GlobalContext* globalCtx, SceneCmd* sceneCmd) {
2020-03-17 04:31:30 +00:00
u32 cmdCode;
while (true) {
2020-03-17 04:31:30 +00:00
cmdCode = sceneCmd->base.code;
2020-03-22 21:19:43 +00:00
osSyncPrintf("*** Scene_Word = { code=%d, data1=%02x, data2=%04x } ***\n", cmdCode, sceneCmd->base.data1,
sceneCmd->base.data2);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (cmdCode == 0x14) {
2020-03-17 04:31:30 +00:00
break;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (cmdCode <= 0x19) {
2020-03-17 04:31:30 +00:00
gSceneCmdHandlers[cmdCode](globalCtx, sceneCmd);
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("code の値が異常です\n"); // "code variable is abnormal"
2020-03-17 04:31:30 +00:00
osSyncPrintf(VT_RST);
}
sceneCmd++;
}
return 0;
}
2020-03-22 21:19:43 +00:00
void func_80098508(GlobalContext* globalCtx, SceneCmd* cmd) {
ActorEntry* linkEntry = globalCtx->linkActorEntry = (ActorEntry*)SEGMENTED_TO_VIRTUAL(cmd->spawnList.segment) +
globalCtx->setupEntranceList[globalCtx->curSpawn].spawn;
2020-03-17 04:31:30 +00:00
s16 linkObjectId;
globalCtx->linkAgeOnLoad = ((void)0, gSaveContext.linkAge);
2020-03-17 04:31:30 +00:00
linkObjectId = gLinkObjectIds[((void)0, gSaveContext.linkAge)];
2020-03-17 04:31:30 +00:00
gActorOverlayTable[linkEntry->id].initInfo->objectId = linkObjectId;
Object_Spawn(&globalCtx->objectCtx, linkObjectId);
}
// Scene Command 0x01: Actor List
2020-03-22 21:19:43 +00:00
void func_800985DC(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->numSetupActors = cmd->actorList.num;
2020-03-17 04:31:30 +00:00
globalCtx->setupActorList = SEGMENTED_TO_VIRTUAL(cmd->actorList.segment);
}
// Scene Command 0x02: Unused 02
2020-03-22 21:19:43 +00:00
void func_80098630(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment);
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x03: Collision Header
2020-03-22 21:19:43 +00:00
void func_80098674(GlobalContext* globalCtx, SceneCmd* cmd) {
CollisionHeader* colHeader = SEGMENTED_TO_VIRTUAL(cmd->colHeader.segment);
2020-03-17 04:31:30 +00:00
z_bgcheck.c, 800430A0.c, 80043480.c (#256) * beginning of migrating changes * got matching * changed order a bit * clean up bgcheck * fix conflict * fix conflict again * first stab at identifying types, some oks * Clean up most bad structs/pointer math, move relevant structs to z64bgcheck.h, get some OKs * more OKs, z_bgcheck.bss migration, update some sys_math3d.c args * couple more OKs * pushing some OKs * fix compilation issues * code_800430A0.c OK, more files decomp'd * 8003A3E0 big OK :) * Decomp most of func_8003C614, decomp helper funcs * Decomp SurfaceType, CamData, and WaterBox property related functions * more OKs, big OK in 8003C078 * more OKs, more progress, move a function definition in z_collision_check to functions.h * more clean-ups, more OKs, dyn_vtx is now defined as u8* * 8003A5B8, 8003A7D8, 8003C614, 8003DD6C OK, document function args better * data migrated, more OKs * 80041240 OK, func_8003B3C8 and func_8003BB18 disassembled * func_80040284, 800409A8 non_matching, add IS_ZERO macro * All asm files have C representations, some big OKs, lots of minor tweaks * More OKs, non-matching code cleanup * 8003FBF4 and 80040BE4 OK, improve codegen for most functions * format z_bgcheck.c * fix warnings, compile errors on NON_MATCHING * func_8003EE80 is now NON_MATCHING * begin documenting some functions * formatting * more documentation, func_8003A95C OK * fix PHYSICAL_TO_VIRTUAL changes * fix var rename * More documentation, functions 80040E40, 80041648 OK, change types to not be compatible with ZAP * func_8004239C ok, more NON_MATCHING improvements, more documentation * Implement most suggested changes * Convert comments to slower comments * /** * Implement ZAP2 changes * my anti-virus ate my format.sh results * Rename a couple hundred functions, fix minor stuff * rename var so that clang formats correctly * run format.sh * implement Petrie's matches/suggestions * format * matches * and the asm * slight error * Add SSList * two more matches * stuff * implement code changes * clean up Petrie's matchings Co-authored-by: Arthur <arthurtilly413@gmail.com> Co-authored-by: fig02 <fig02srl@gmail.com> Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
2021-01-08 11:12:58 +00:00
colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList);
colHeader->polyList = SEGMENTED_TO_VIRTUAL(colHeader->polyList);
colHeader->surfaceTypeList = SEGMENTED_TO_VIRTUAL(colHeader->surfaceTypeList);
colHeader->cameraDataList = SEGMENTED_TO_VIRTUAL(colHeader->cameraDataList);
2020-03-17 04:31:30 +00:00
colHeader->waterBoxes = SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes);
z_bgcheck.c, 800430A0.c, 80043480.c (#256) * beginning of migrating changes * got matching * changed order a bit * clean up bgcheck * fix conflict * fix conflict again * first stab at identifying types, some oks * Clean up most bad structs/pointer math, move relevant structs to z64bgcheck.h, get some OKs * more OKs, z_bgcheck.bss migration, update some sys_math3d.c args * couple more OKs * pushing some OKs * fix compilation issues * code_800430A0.c OK, more files decomp'd * 8003A3E0 big OK :) * Decomp most of func_8003C614, decomp helper funcs * Decomp SurfaceType, CamData, and WaterBox property related functions * more OKs, big OK in 8003C078 * more OKs, more progress, move a function definition in z_collision_check to functions.h * more clean-ups, more OKs, dyn_vtx is now defined as u8* * 8003A5B8, 8003A7D8, 8003C614, 8003DD6C OK, document function args better * data migrated, more OKs * 80041240 OK, func_8003B3C8 and func_8003BB18 disassembled * func_80040284, 800409A8 non_matching, add IS_ZERO macro * All asm files have C representations, some big OKs, lots of minor tweaks * More OKs, non-matching code cleanup * 8003FBF4 and 80040BE4 OK, improve codegen for most functions * format z_bgcheck.c * fix warnings, compile errors on NON_MATCHING * func_8003EE80 is now NON_MATCHING * begin documenting some functions * formatting * more documentation, func_8003A95C OK * fix PHYSICAL_TO_VIRTUAL changes * fix var rename * More documentation, functions 80040E40, 80041648 OK, change types to not be compatible with ZAP * func_8004239C ok, more NON_MATCHING improvements, more documentation * Implement most suggested changes * Convert comments to slower comments * /** * Implement ZAP2 changes * my anti-virus ate my format.sh results * Rename a couple hundred functions, fix minor stuff * rename var so that clang formats correctly * run format.sh * implement Petrie's matches/suggestions * format * matches * and the asm * slight error * Add SSList * two more matches * stuff * implement code changes * clean up Petrie's matchings Co-authored-by: Arthur <arthurtilly413@gmail.com> Co-authored-by: fig02 <fig02srl@gmail.com> Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
2021-01-08 11:12:58 +00:00
BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader);
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x04: Room List
2020-03-22 21:19:43 +00:00
void func_800987A4(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->numRooms = cmd->roomList.num;
2020-03-17 04:31:30 +00:00
globalCtx->roomList = SEGMENTED_TO_VIRTUAL(cmd->roomList.segment);
}
// Scene Command 0x06: Entrance List
2020-03-22 21:19:43 +00:00
void func_800987F8(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
globalCtx->setupEntranceList = SEGMENTED_TO_VIRTUAL(cmd->entranceList.segment);
}
// Scene Command 0x07: Special Files
2020-03-22 21:19:43 +00:00
void func_8009883C(GlobalContext* globalCtx, SceneCmd* cmd) {
if (cmd->specialFiles.keepObjectId != 0) {
2020-03-17 04:31:30 +00:00
globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.keepObjectId);
gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
2020-03-17 04:31:30 +00:00
}
if (cmd->specialFiles.cUpElfMsgNum != 0) {
globalCtx->cUpElfMsgs = Gameplay_LoadFile(globalCtx, &sNaviMsgFiles[cmd->specialFiles.cUpElfMsgNum - 1]);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x08: Room Behavior
2020-03-22 21:19:43 +00:00
void func_80098904(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
globalCtx->roomCtx.curRoom.unk_03 = cmd->roomBehavior.gpFlag1;
globalCtx->roomCtx.curRoom.unk_02 = cmd->roomBehavior.gpFlag2 & 0xFF;
globalCtx->roomCtx.curRoom.showInvisActors = (cmd->roomBehavior.gpFlag2 >> 8) & 1;
globalCtx->msgCtx.unk_E40C = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1;
}
// Scene Command 0x0A: Mesh Header
2020-03-22 21:19:43 +00:00
void func_80098958(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
globalCtx->roomCtx.curRoom.mesh = SEGMENTED_TO_VIRTUAL(cmd->mesh.segment);
}
// Scene Command 0x0B: Object List
2020-03-22 21:19:43 +00:00
void func_8009899C(GlobalContext* globalCtx, SceneCmd* cmd) {
s32 i;
s32 j;
s32 k;
2020-03-17 04:31:30 +00:00
ObjectStatus* status;
ObjectStatus* status2;
ObjectStatus* firstStatus;
s16* objectEntry = SEGMENTED_TO_VIRTUAL(cmd->objectList.segment);
2020-03-17 04:31:30 +00:00
void* nextPtr;
k = 0;
i = globalCtx->objectCtx.unk_09;
firstStatus = &globalCtx->objectCtx.status[0];
status = &globalCtx->objectCtx.status[i];
2020-03-22 21:19:43 +00:00
while (i < globalCtx->objectCtx.num) {
if (status->id != *objectEntry) {
status2 = &globalCtx->objectCtx.status[i];
2020-03-22 21:19:43 +00:00
for (j = i; j < globalCtx->objectCtx.num; j++) {
status2->id = OBJECT_INVALID;
status2++;
2020-03-17 04:31:30 +00:00
}
globalCtx->objectCtx.num = i;
func_80031A28(globalCtx, &globalCtx->actorCtx);
continue;
2020-03-17 04:31:30 +00:00
}
i++;
k++;
objectEntry++;
status++;
2020-03-17 04:31:30 +00:00
}
ASSERT(cmd->objectList.num <= OBJECT_EXCHANGE_BANK_MAX, "scene_info->object_bank.num <= OBJECT_EXCHANGE_BANK_MAX",
"../z_scene.c", 705);
if (1) {}
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
while (k < cmd->objectList.num) {
2020-03-17 04:31:30 +00:00
nextPtr = func_800982FC(&globalCtx->objectCtx, i, *objectEntry);
2020-03-23 23:11:21 +00:00
if (i < OBJECT_EXCHANGE_BANK_MAX - 1) {
firstStatus[i + 1].segment = nextPtr;
2020-03-23 23:11:21 +00:00
}
i++;
2020-03-17 04:31:30 +00:00
k++;
objectEntry++;
}
globalCtx->objectCtx.num = i;
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x0C: Light List
2020-03-22 21:19:43 +00:00
void func_80098B74(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
s32 i;
LightInfo* lightInfo = SEGMENTED_TO_VIRTUAL(cmd->lightList.segment);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
for (i = 0; i < cmd->lightList.num; i++) {
LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo);
2020-03-17 04:31:30 +00:00
lightInfo++;
}
}
// Scene Command 0x0D: Path List
2020-03-22 21:19:43 +00:00
void func_80098C24(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
globalCtx->setupPathList = SEGMENTED_TO_VIRTUAL(cmd->pathList.segment);
}
// Scene Command 0x0E: Transition Actor List
2020-03-22 21:19:43 +00:00
void func_80098C68(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->transiActorCtx.numActors = cmd->transiActorList.num;
globalCtx->transiActorCtx.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.segment);
2020-03-17 04:31:30 +00:00
}
void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx) {
transiActorCtx->numActors = 0;
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x0F: Light Setting List
2020-03-22 21:19:43 +00:00
void func_80098CC8(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num;
globalCtx->envCtx.lightSettingsList = SEGMENTED_TO_VIRTUAL(cmd->lightSettingList.segment);
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x11: Skybox Settings
2020-03-22 21:19:43 +00:00
void func_80098D1C(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
globalCtx->skyboxId = cmd->skyboxSettings.skyboxId;
globalCtx->envCtx.unk_17 = globalCtx->envCtx.unk_18 = cmd->skyboxSettings.unk_05;
globalCtx->envCtx.indoors = cmd->skyboxSettings.unk_06;
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x12: Skybox Disables
2020-03-22 21:19:43 +00:00
void func_80098D5C(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk_04;
globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk_05;
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x10: Time Settings
2020-03-22 21:19:43 +00:00
void func_80098D80(GlobalContext* globalCtx, SceneCmd* cmd) {
if ((cmd->timeSettings.hour != 0xFF) && (cmd->timeSettings.min != 0xFF)) {
gSaveContext.skyboxTime = gSaveContext.dayTime =
((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / ((f32)(24 * 60) / 0x10000);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (cmd->timeSettings.unk_06 != 0xFF) {
globalCtx->envCtx.timeIncrement = cmd->timeSettings.unk_06;
2020-03-22 21:19:43 +00:00
} else {
globalCtx->envCtx.timeIncrement = 0;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
if (gSaveContext.sunsSongState == SUNSSONG_INACTIVE) {
gTimeIncrement = globalCtx->envCtx.timeIncrement;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
globalCtx->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f;
globalCtx->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f;
globalCtx->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 20.0f) * 25.0f;
if (((globalCtx->envCtx.timeIncrement == 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) ||
(gSaveContext.entranceIndex == 0x0604)) {
gSaveContext.skyboxTime = ((void)0, gSaveContext.dayTime);
if ((gSaveContext.skyboxTime >= 0x2AAC) && (gSaveContext.skyboxTime < 0x4555)) {
gSaveContext.skyboxTime = 0x3556;
} else if ((gSaveContext.skyboxTime >= 0x4555) && (gSaveContext.skyboxTime < 0x5556)) {
gSaveContext.skyboxTime = 0x5556;
} else if ((gSaveContext.skyboxTime >= 0xAAAB) && (gSaveContext.skyboxTime < 0xB556)) {
gSaveContext.skyboxTime = 0xB556;
} else if ((gSaveContext.skyboxTime >= 0xC001) && (gSaveContext.skyboxTime < 0xCAAC)) {
gSaveContext.skyboxTime = 0xCAAC;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}
}
// Scene Command 0x05: Wind Settings
2020-03-22 21:19:43 +00:00
void func_80099090(GlobalContext* globalCtx, SceneCmd* cmd) {
s8 x = cmd->windSettings.x;
s8 y = cmd->windSettings.y;
s8 z = cmd->windSettings.z;
globalCtx->envCtx.windDirection.x = x;
globalCtx->envCtx.windDirection.y = y;
globalCtx->envCtx.windDirection.z = z;
2020-03-17 04:31:30 +00:00
globalCtx->envCtx.windSpeed = cmd->windSettings.unk_07;
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x13: Exit List
2020-03-22 21:19:43 +00:00
void func_800990F0(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
globalCtx->setupExitList = SEGMENTED_TO_VIRTUAL(cmd->exitList.segment);
}
// Scene Command 0x09: Undefined
2020-03-22 21:19:43 +00:00
void func_80099134(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x15: Sound Settings
2020-03-22 21:19:43 +00:00
void func_80099140(GlobalContext* globalCtx, SceneCmd* cmd) {
globalCtx->soundCtx.seqIndex = cmd->soundSettings.seqIndex;
globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nightSeqIndex;
2020-03-17 04:31:30 +00:00
if (gSaveContext.seqIndex == 0xFF) {
Audio_QueueSeqCmd(cmd->soundSettings.bgmId | 0xF0000000);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}
// Scene Command 0x16: Echo Setting
2020-03-22 21:19:43 +00:00
void func_8009918C(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
globalCtx->roomCtx.curRoom.echo = cmd->echoSettings.echo;
}
// Scene Command 0x18: Alternate Headers
2020-03-22 21:19:43 +00:00
void func_800991A0(GlobalContext* globalCtx, SceneCmd* cmd) {
s32 pad;
2020-03-17 04:31:30 +00:00
SceneCmd* altHeader;
osSyncPrintf("\n[ZU]sceneset age =[%X]", ((void)0, gSaveContext.linkAge));
osSyncPrintf("\n[ZU]sceneset time =[%X]", ((void)0, gSaveContext.cutsceneIndex));
osSyncPrintf("\n[ZU]sceneset counter=[%X]", ((void)0, gSaveContext.sceneSetupIndex));
2020-03-17 04:31:30 +00:00
if (gSaveContext.sceneSetupIndex != 0) {
altHeader = ((SceneCmd**)SEGMENTED_TO_VIRTUAL(cmd->altHeaders.segment))[gSaveContext.sceneSetupIndex - 1];
if (1) {}
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (altHeader != NULL) {
2020-03-17 04:31:30 +00:00
Scene_ExecuteCommands(globalCtx, SEGMENTED_TO_VIRTUAL(altHeader));
(cmd + 1)->base.code = 0x14;
2020-03-22 21:19:43 +00:00
} else {
// "Coughh! There is no specified dataaaaa!"
2020-03-17 04:31:30 +00:00
osSyncPrintf("\nげぼはっ! 指定されたデータがないでええっす!");
if (gSaveContext.sceneSetupIndex == 3) {
altHeader =
((SceneCmd**)SEGMENTED_TO_VIRTUAL(cmd->altHeaders.segment))[gSaveContext.sceneSetupIndex - 2];
2020-03-17 04:31:30 +00:00
// "Using adult day data there!"
2020-03-17 04:31:30 +00:00
osSyncPrintf("\nそこで、大人の昼データを使用するでええっす!!");
2020-03-22 21:19:43 +00:00
if (altHeader != NULL) {
2020-03-17 04:31:30 +00:00
Scene_ExecuteCommands(globalCtx, SEGMENTED_TO_VIRTUAL(altHeader));
(cmd + 1)->base.code = 0x14;
}
}
}
}
}
// Scene Command 0x17: Cutscene Data
2020-03-22 21:19:43 +00:00
void func_8009934C(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
osSyncPrintf("\ngame_play->demo_play.data=[%x]", globalCtx->csCtx.segment);
globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(cmd->cutsceneData.segment);
}
// Scene Command 0x19: Misc. Settings (Camera & World Map Area)
2020-03-22 21:19:43 +00:00
void func_800993C0(GlobalContext* globalCtx, SceneCmd* cmd) {
2020-03-17 04:31:30 +00:00
YREG(15) = cmd->miscSettings.cameraMovement;
gSaveContext.worldMapArea = cmd->miscSettings.area;
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if ((globalCtx->sceneNum == SCENE_SHOP1) || (globalCtx->sceneNum == SCENE_SYATEKIJYOU)) {
if (LINK_AGE_IN_YEARS == YEARS_ADULT) {
gSaveContext.worldMapArea = 1;
2020-03-17 04:31:30 +00:00
}
}
if (((globalCtx->sceneNum >= SCENE_SPOT00) && (globalCtx->sceneNum <= SCENE_GANON_TOU)) ||
2020-03-22 21:19:43 +00:00
((globalCtx->sceneNum >= SCENE_ENTRA) && (globalCtx->sceneNum <= SCENE_SHRINE_R))) {
if (gSaveContext.cutsceneIndex < 0xFFF0) {
gSaveContext.worldMapAreaData |= gBitFlags[gSaveContext.worldMapArea];
osSyncPrintf(" _%x (%d)\n", gSaveContext.worldMapAreaData,
gSaveContext.worldMapArea);
2020-03-17 04:31:30 +00:00
}
}
}
2020-03-22 21:19:43 +00:00
void (*gSceneCmdHandlers[])(GlobalContext*, SceneCmd*) = {
func_80098508, func_800985DC, func_80098630, func_80098674, func_800987A4, func_80099090, func_800987F8,
func_8009883C, func_80098904, func_80099134, func_80098958, func_8009899C, func_80098B74, func_80098C24,
func_80098C68, func_80098CC8, func_80098D80, func_80098D1C, func_80098D5C, func_800990F0, NULL,
func_80099140, func_8009918C, func_8009934C, func_800991A0, func_800993C0,
2020-03-17 04:31:30 +00:00
};
2020-03-22 21:19:43 +00:00
RomFile sNaviMsgFiles[] = {
2020-03-17 04:31:30 +00:00
ROM_FILE(elf_message_field),
ROM_FILE(elf_message_ydan),
ROM_FILE_UNSET,
};
s16 gLinkObjectIds[] = { OBJECT_LINK_BOY, OBJECT_LINK_CHILD };
u32 gObjectTableSize = ARRAY_COUNT(gObjectTable);
2020-03-17 04:31:30 +00:00
// Object linker symbol declarations (used in the table below)
#define DEFINE_OBJECT(name, _1) DECLARE_ROM_SEGMENT(name)
#define DEFINE_OBJECT_NULL(_0, _1)
#define DEFINE_OBJECT_UNSET(_0)
#include "tables/object_table.h"
#undef DEFINE_OBJECT
#undef DEFINE_OBJECT_NULL
#undef DEFINE_OBJECT_UNSET
// Object Table definition
#define DEFINE_OBJECT(name, _1) ROM_FILE(name),
#define DEFINE_OBJECT_NULL(name, _1) ROM_FILE_EMPTY(name),
#define DEFINE_OBJECT_UNSET(_0) { 0 },
2020-03-22 21:19:43 +00:00
RomFile gObjectTable[] = {
#include "tables/object_table.h"
2020-03-17 04:31:30 +00:00
};
#undef DEFINE_OBJECT
#undef DEFINE_OBJECT_NULL
#undef DEFINE_OBJECT_UNSET