[zret] Port some documentation changes (#1164)

* zret: Documentation pass on scene/room commands #1226

* Update OTR scene

* zret: Document the lens system #1079

* zret: Misc. doc/cleanup 4 #1093

* zret: Fix misc 8 #1150

* zret: Document Distortions from z_camera and z_view #1102
pull/1224/head
David Chavez 10 months ago committed by GitHub
parent b4614acf70
commit 6b0338a37d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -78,7 +78,7 @@ OSPiHandle* osDriveRomInit(void);
void StackCheck_Init(StackEntry* entry, void* stackTop, void* stackBottom, u32 initValue, s32 minSpace,
const char* name);
void StackCheck_Cleanup(StackEntry* entry);
StackStatus StackCheck_GetState(StackEntry* entry);
s32 StackCheck_GetState(StackEntry* entry);
u32 StackCheck_CheckAll(void);
u32 StackCheck_Check(StackEntry* entry);
f32 LogUtils_CheckFloatRange(const char* exp, s32 line, const char* valueName, f32 value, const char* minName, f32 min,
@ -477,7 +477,7 @@ void func_8002F948(Actor* actor, u16 sfxId);
void func_8002F974(Actor* actor, u16 sfxId);
void func_8002F994(Actor* actor, s32 arg1);
s32 func_8002F9EC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos);
void func_800304B0(GlobalContext* globalCtx);
void Actor_DisableLens(GlobalContext* globalCtx);
void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry);
void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx);
s32 func_800314D4(GlobalContext* globalCtx, Actor* actorB, Vec3f* arg2, f32 arg3);
@ -1357,13 +1357,13 @@ void func_800AA4A8(View* view, f32 fovy, f32 near, f32 far);
void func_800AA4E0(View* view, f32* fovy, f32* near, f32* far);
void View_SetViewport(View* view, Viewport* viewport);
void View_GetViewport(View* view, Viewport* viewport);
void func_800AA76C(View* view, f32 arg1, f32 arg2, f32 arg3);
void func_800AA78C(View* view, f32 arg1, f32 arg2, f32 arg3);
s32 func_800AA7AC(View* view, f32 arg1);
void func_800AA7B8(View* view);
void func_800AA814(View* view);
void func_800AA840(View* view, Vec3f vec1, Vec3f vec2, f32 arg3);
s32 func_800AA890(View* view, Mtx* mtx);
void View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ);
void View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ);
s32 View_SetDistortionSpeed(View* view, f32 speed);
void View_InitDistortion(View* view);
void View_ClearDistortion(View* view);
void View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed);
s32 View_StepDistortion(View* view, Mtx* projectionMtx);
void func_800AAA50(View* view, s32 arg1);
s32 func_800AAA9C(View* view);
s32 func_800AB0A8(View* view);

@ -101,7 +101,7 @@ extern "C"
extern void* gItemIcons[0x82];
extern u8 gItemAgeReqs[];
extern u8 gItemSlots[56];
extern void (*gSceneCmdHandlers[26])(GlobalContext*, SceneCmd*);
extern void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(GlobalContext*, SceneCmd*);
extern s16 gLinkObjectIds[2];
extern u32 gObjectTableSize;
extern RomFile gObjectTable[OBJECT_ID_MAX];

@ -202,11 +202,11 @@ typedef struct {
/* 0x00A0 */ Mtx viewing;
/* 0x00E0 */ Mtx* projectionPtr;
/* 0x00E4 */ Mtx* viewingPtr;
/* 0x00E8 */ Vec3f unk_E8;
/* 0x00F4 */ Vec3f unk_F4;
/* 0x0100 */ f32 unk_100;
/* 0x0104 */ Vec3f unk_104;
/* 0x0110 */ Vec3f unk_110;
/* 0x00E8 */ Vec3f distortionOrientation;
/* 0x00F4 */ Vec3f distortionScale;
/* 0x0100 */ f32 distortionSpeed;
/* 0x0104 */ Vec3f curDistortionOrientation;
/* 0x0110 */ Vec3f curDistortionScale;
/* 0x011C */ u16 normal; // used to normalize the projection matrix
/* 0x0120 */ s32 flags;
/* 0x0124 */ s32 unk_124;
@ -273,11 +273,10 @@ typedef struct {
/* 0x0000 */ u8 freezeFlashTimer;
/* 0x0001 */ char unk_01[0x01];
/* 0x0002 */ u8 unk_02;
/* 0x0003 */ u8 unk_03;
/* 0x0003 */ u8 lensActive;
/* 0x0004 */ char unk_04[0x04];
/* 0x0008 */ u8 total; // total number of actors loaded
/* 0x0009 */ char unk_09[0x03];
/* 0x000C */ ActorListEntry actorLists[12];
/* 0x000C */ ActorListEntry actorLists[ACTORCAT_MAX];
/* 0x006C */ TargetContext targetCtx;
struct {
/* 0x0104 */ u32 swch;
@ -890,13 +889,10 @@ void* xluDL;
typedef struct {
/* 0x00 */ u8 type;
/* 0x01 */ u8 num; // number of dlist entries
/* 0x04 */ void* start;
/* 0x08 */ void* end;
} Polygon; // size = 0xC
} PolygonBase;
typedef struct {
/* 0x00 */ u8 type;
/* 0x00 */ PolygonBase base;
/* 0x01 */ u8 num; // number of dlist entries
/* 0x04 */ void* start;
/* 0x08 */ void* end;
@ -917,7 +913,7 @@ typedef struct {
} BgImage; // size = 0x1C
typedef struct {
/* 0x00 */ u8 type;
/* 0x00 */ PolygonBase base;
/* 0x01 */ u8 format; // 1 = single, 2 = multi
/* 0x04 */ Gfx* dlist;
union {
@ -955,27 +951,51 @@ typedef struct {
} PolygonDlist2; // size = 0x8
typedef struct {
/* 0x00 */ u8 type;
/* 0x00 */ PolygonBase base;
/* 0x01 */ u8 num; // number of dlist entries
/* 0x04 */ void* start;
/* 0x08 */ void* end;
} PolygonType2; // size = 0xC
typedef union {
Polygon polygon;
PolygonBase base;
PolygonType0 polygon0;
PolygonType1 polygon1;
PolygonType2 polygon2;
} Mesh; // "Ground Shape"
} MeshHeader; // "Ground Shape"
typedef enum {
/* 0 */ LENS_MODE_HIDE_ACTORS, // lens actors are visible by default, and hidden by using lens (for example, fake walls)
/* 1 */ LENS_MODE_SHOW_ACTORS // lens actors are invisible by default, and shown by using lens (for example, invisible enemies)
} LensMode;
typedef enum {
/* 0 */ ROOM_BEHAVIOR_TYPE1_0,
/* 1 */ ROOM_BEHAVIOR_TYPE1_1,
/* 2 */ ROOM_BEHAVIOR_TYPE1_2,
/* 3 */ ROOM_BEHAVIOR_TYPE1_3, // unused
/* 4 */ ROOM_BEHAVIOR_TYPE1_4, // unused
/* 5 */ ROOM_BEHAVIOR_TYPE1_5
} RoomBehaviorType1;
typedef enum {
/* 0 */ ROOM_BEHAVIOR_TYPE2_0,
/* 1 */ ROOM_BEHAVIOR_TYPE2_1,
/* 2 */ ROOM_BEHAVIOR_TYPE2_2,
/* 3 */ ROOM_BEHAVIOR_TYPE2_3,
/* 4 */ ROOM_BEHAVIOR_TYPE2_4,
/* 5 */ ROOM_BEHAVIOR_TYPE2_5,
/* 6 */ ROOM_BEHAVIOR_TYPE2_6
} RoomBehaviorType2;
typedef struct {
/* 0x00 */ s8 num;
/* 0x01 */ u8 unk_01;
/* 0x02 */ u8 unk_02;
/* 0x03 */ u8 unk_03;
/* 0x02 */ u8 behaviorType2;
/* 0x03 */ u8 behaviorType1;
/* 0x04 */ s8 echo;
/* 0x05 */ u8 showInvisActors;
/* 0x08 */ Mesh* mesh; // original name: "ground_shape"
/* 0x05 */ u8 lensMode;
/* 0x08 */ MeshHeader* meshHeader; // original name: "ground_shape"
/* 0x0C */ void* segment;
/* 0x10 */ char unk_10[0x4];
} Room; // size = 0x14
@ -1244,7 +1264,7 @@ typedef struct GlobalContext {
/* 0x11DF0 */ RomFile* roomList;
/* 0x11DF4 */ ActorEntry* linkActorEntry;
/* 0x11DF8 */ ActorEntry* setupActorList;
/* 0x11DFC */ UNK_PTR unk_11DFC;
/* 0x11DFC */ void* unk_11DFC;
/* 0x11E00 */ EntranceEntry* setupEntranceList;
/* 0x11E04 */ s16* setupExitList;
/* 0x11E08 */ Path* setupPathList;

@ -79,7 +79,7 @@ typedef struct {
typedef struct {
/* 0x00 */ DamageTable* damageTable;
/* 0x04 */ Vec3f displacement; // Amount to correct velocity (0x5C) by when colliding into a body
/* 0x04 */ Vec3f displacement; // Amount to correct actor velocity by when colliding into a body
/* 0x10 */ s16 cylRadius; // Used for various purposes
/* 0x12 */ s16 cylHeight; // Used for various purposes
/* 0x14 */ s16 cylYShift; // Unused. Purpose inferred from Cylinder16 and CollisionCheck_CylSideVsLineSeg
@ -158,7 +158,7 @@ typedef struct Actor {
/* 0x084 */ f32 yDistToWater; // Distance to the surface of active waterbox. Negative value means above water
/* 0x088 */ u16 bgCheckFlags; // See comments below actor struct for wip docs. TODO: macros for these flags
/* 0x08A */ s16 yawTowardsPlayer; // Y rotation difference between the actor and the player
/* 0x08C */ f32 xyzDistToPlayerSq; // Squared distance between the actor and the player in the x,y,z axis
/* 0x08C */ f32 xyzDistToPlayerSq; // Squared distance between the actor and the player
/* 0x090 */ f32 xzDistToPlayer; // Distance between the actor and the player in the XZ plane
/* 0x094 */ f32 yDistToPlayer; // Dist is negative if the actor is above the player
/* 0x098 */ CollisionCheckInfo colChkInfo; // Variables related to the Collision Check system
@ -338,7 +338,8 @@ typedef enum {
/* 0x08 */ ACTORCAT_MISC,
/* 0x09 */ ACTORCAT_BOSS,
/* 0x0A */ ACTORCAT_DOOR,
/* 0x0B */ ACTORCAT_CHEST
/* 0x0B */ ACTORCAT_CHEST,
/* 0x0C */ ACTORCAT_MAX
} ActorCategory;
//#define DEFINE_ACTOR(_0, enum, _2) enum,

@ -23,7 +23,7 @@ typedef enum {
/* 3 */ ANIMMODE_ONCE_INTERP,
/* 4 */ ANIMMODE_LOOP_PARTIAL,
/* 5 */ ANIMMODE_LOOP_PARTIAL_INTERP
} AnimationModes;
} AnimationMode;
typedef enum {
/* -1 */ ANIMTAPER_DECEL = -1,
@ -241,21 +241,21 @@ typedef s32 (*AnimUpdateFunc)();
typedef struct SkelAnime {
/* 0x00 */ u8 limbCount; // Number of limbs in the skeleton
/* 0x01 */ u8 mode; // 0: loop, 2: play once, 4: partial loop. +1 to interpolate between frames.
/* 0x01 */ u8 mode; // See `AnimationMode`
/* 0x02 */ u8 dListCount; // Number of display lists in a flexible skeleton
/* 0x03 */ s8 taper; // Tapering to use when morphing between animations. Only used by Door_Warp1.
/* 0x04 */ void** skeleton; // An array of pointers to limbs. Can be StandardLimb, LodLimb, or SkinLimb.
/* 0x08 */ void* animation; // Can be an AnimationHeader or LinkAnimationHeader.
/* 0x0C */ f32 startFrame; // In mode 4, start of partial loop.
/* 0x10 */ f32 endFrame; // In mode 2, Update returns true when curFrame is equal to this. In mode 4, end of partial loop.
/* 0x14 */ f32 animLength; // Total number of frames in the current animation's file.
/* 0x0C */ f32 startFrame; // In mode ANIMMODE_LOOP_PARTIAL*, start of partial loop.
/* 0x10 */ f32 endFrame; // In mode ANIMMODE_ONCE*, Update returns true when curFrame is equal to this. In mode ANIMMODE_LOOP_PARTIAL*, end of partial loop.
/* 0x14 */ f32 animLength; // Total number of frames in the current animation.
/* 0x18 */ f32 curFrame; // Current frame in the animation
/* 0x1C */ f32 playSpeed; // Multiplied by R_UPDATE_RATE / 3 to get the animation's frame rate.
/* 0x20 */ Vec3s* jointTable; // Current translation of model and rotations of all limbs
/* 0x24 */ Vec3s* morphTable; // Table of values used to morph between animations
/* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1]
/* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph
/* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph
/* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph.
/* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton
/* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace.
/* 0x36 */ s16 prevRot; // Previous rotation in worldspace.

@ -1203,8 +1203,8 @@ typedef struct {
/* 0x14A */ s16 unk_14A;
/* 0x14C */ s16 unk_14C;
/* 0x14E */ s16 childCamIdx;
/* 0x150 */ s16 unk_150;
/* 0x152 */ s16 unk_152;
/* 0x150 */ s16 waterDistortionTimer;
/* 0x152 */ s16 distortionFlags;
/* 0x154 */ s16 prevSetting;
/* 0x156 */ s16 nextCamDataIdx;
/* 0x158 */ s16 nextBGCheckId;

@ -423,20 +423,20 @@ typedef enum {
typedef enum {
/* 0x00 */ SCENE_CMD_ID_SPAWN_LIST,
/* 0x01 */ SCENE_CMD_ID_ACTOR_LIST,
/* 0x02 */ SCENE_CMD_ID_UNUSED_02,
/* 0x03 */ SCENE_CMD_ID_COL_HEADER,
/* 0x02 */ SCENE_CMD_ID_UNUSED_2,
/* 0x03 */ SCENE_CMD_ID_COLLISION_HEADER,
/* 0x04 */ SCENE_CMD_ID_ROOM_LIST,
/* 0x05 */ SCENE_CMD_ID_WIND_SETTINGS,
/* 0x06 */ SCENE_CMD_ID_ENTRANCE_LIST,
/* 0x07 */ SCENE_CMD_ID_SPECIAL_FILES,
/* 0x08 */ SCENE_CMD_ID_ROOM_BEHAVIOR,
/* 0x09 */ SCENE_CMD_ID_UNK_09,
/* 0x0A */ SCENE_CMD_ID_MESH,
/* 0x09 */ SCENE_CMD_ID_UNDEFINED_9,
/* 0x0A */ SCENE_CMD_ID_MESH_HEADER,
/* 0x0B */ SCENE_CMD_ID_OBJECT_LIST,
/* 0x0C */ SCENE_CMD_ID_LIGHT_LIST,
/* 0x0D */ SCENE_CMD_ID_PATH_LIST,
/* 0x0E */ SCENE_CMD_ID_TRANSI_ACTOR_LIST,
/* 0x0F */ SCENE_CMD_ID_ENV_LIGHT_SETTINGS,
/* 0x0E */ SCENE_CMD_ID_TRANSITION_ACTOR_LIST,
/* 0x0F */ SCENE_CMD_ID_LIGHT_SETTINGS_LIST,
/* 0x10 */ SCENE_CMD_ID_TIME_SETTINGS,
/* 0x11 */ SCENE_CMD_ID_SKYBOX_SETTINGS,
/* 0x12 */ SCENE_CMD_ID_SKYBOX_DISABLES,
@ -446,7 +446,8 @@ typedef enum {
/* 0x16 */ SCENE_CMD_ID_ECHO_SETTINGS,
/* 0x17 */ SCENE_CMD_ID_CUTSCENE_DATA,
/* 0x18 */ SCENE_CMD_ID_ALTERNATE_HEADER_LIST,
/* 0x19 */ SCENE_CMD_ID_MISC_SETTINGS
/* 0x19 */ SCENE_CMD_ID_MISC_SETTINGS,
/* 0x20 */ SCENE_CMD_ID_MAX
} SceneCommandTypeID;
#define SCENE_CMD_SPAWN_LIST(numSpawns, spawnList) \
@ -456,10 +457,10 @@ typedef enum {
{ SCENE_CMD_ID_ACTOR_LIST, numActors, CMD_PTR(actorList) }
#define SCENE_CMD_UNUSED_02(unk, data) \
{ SCENE_CMD_ID_UNUSED_02, unk, CMD_PTR(data) }
{ SCENE_CMD_ID_UNUSED_2, unk, CMD_PTR(data) }
#define SCENE_CMD_COL_HEADER(colHeader) \
{ SCENE_CMD_ID_COL_HEADER, 0, CMD_PTR(colHeader) }
{ SCENE_CMD_ID_COLLISION_HEADER, 0, CMD_PTR(colHeader) }
#define SCENE_CMD_ROOM_LIST(numRooms, roomList) \
{ SCENE_CMD_ID_ROOM_LIST, numRooms, CMD_PTR(roomList) }
@ -478,10 +479,10 @@ typedef enum {
curRoomUnk2 | _SHIFTL(showInvisActors, 8, 1) | _SHIFTL(disableWarpSongs, 10, 1) }
#define SCENE_CMD_UNK_09() \
{ SCENE_CMD_ID_UNK_09, 0, CMD_W(0) }
{ SCENE_CMD_ID_UNDEFINED_9, 0, CMD_W(0) }
#define SCENE_CMD_MESH(meshHeader) \
{ SCENE_CMD_ID_MESH, 0, CMD_PTR(meshHeader) }
{ SCENE_CMD_ID_MESH_HEADER, 0, CMD_PTR(meshHeader) }
#define SCENE_CMD_OBJECT_LIST(numObjects, objectList) \
{ SCENE_CMD_ID_OBJECT_LIST, numObjects, CMD_PTR(objectList) }
@ -493,10 +494,10 @@ typedef enum {
{ SCENE_CMD_ID_PATH_LIST, 0, CMD_PTR(pathList) }
#define SCENE_CMD_TRANSITION_ACTOR_LIST(numActors, list) \
{ SCENE_CMD_ID_TRANSI_ACTOR_LIST, numActors, CMD_PTR(list) }
{ SCENE_CMD_ID_TRANSITION_ACTOR_LIST, numActors, CMD_PTR(list) }
#define SCENE_CMD_ENV_LIGHT_SETTINGS(numLightSettings, lightSettingsList) \
{ SCENE_CMD_ID_ENV_LIGHT_SETTINGS, numLightSettings, CMD_PTR(lightSettingsList) }
{ SCENE_CMD_ID_LIGHT_SETTINGS_LIST, numLightSettings, CMD_PTR(lightSettingsList) }
#define SCENE_CMD_TIME_SETTINGS(hour, min, speed) \
{ SCENE_CMD_ID_TIME_SETTINGS, 0, CMD_BBBB(hour, min, speed, 0) }

@ -85,8 +85,8 @@ typedef struct SaveStateInfo {
OnePointCsFull D_8011D8DC_copy[3];
OnePointCsFull D_8011D954_copy[4];
OnePointCsFull D_8011D9F4_copy[3];
int16_t D_8011DB08_copy;
int16_t D_8011DB0C_copy;
int16_t depthPhase_copy;
int16_t screenPlanePhase_copy;
int32_t sOOBTimer_copy;
f32 D_8015CE50_copy;
f32 D_8015CE54_copy;
@ -437,8 +437,8 @@ void SaveState::BackupCameraData(void) {
memcpy(info->D_8011D8DC_copy, D_8011D8DC, sizeof(info->D_8011D8DC_copy));
memcpy(info->D_8011D954_copy, D_8011D954, sizeof(info->D_8011D954_copy));
memcpy(info->D_8011D9F4_copy, D_8011D9F4, sizeof(info->D_8011D9F4_copy));
info->D_8011DB08_copy = D_8011DB08;
info->D_8011DB0C_copy = D_8011DB0C;
info->depthPhase_copy = depthPhase;
info->screenPlanePhase_copy = screenPlanePhase;
info->sOOBTimer_copy = sOOBTimer;
info->D_8015CE50_copy = D_8015CE50;
info->D_8015CE54_copy = D_8015CE54;
@ -465,8 +465,8 @@ void SaveState::LoadCameraData(void) {
memcpy(D_8011D8DC, info->D_8011D8DC_copy, sizeof(info->D_8011D8DC_copy));
memcpy(D_8011D954, info->D_8011D954_copy, sizeof(info->D_8011D954_copy));
memcpy(D_8011D9F4, info->D_8011D9F4_copy, sizeof(info->D_8011D9F4_copy));
D_8011DB08 = info->D_8011DB08_copy;
D_8011DB0C = info->D_8011DB0C_copy;
depthPhase = info->depthPhase_copy;
screenPlanePhase = info->screenPlanePhase_copy;
sOOBTimer = info->sOOBTimer_copy;
D_8015CE50 = info->D_8015CE50_copy;
D_8015CE54 = info->D_8015CE54_copy;

@ -24,8 +24,8 @@ extern "C" OnePointCsFull D_8011D88C[];
extern "C" OnePointCsFull D_8011D8DC[];
extern "C" OnePointCsFull D_8011D954[];
extern "C" OnePointCsFull D_8011D9F4[];
extern "C" int16_t D_8011DB08;
extern "C" int16_t D_8011DB0C;
extern "C" int16_t depthPhase;
extern "C" int16_t screenPlanePhase;
extern "C" int32_t sOOBTimer;
extern "C" f32 D_8015CE50;
extern "C" f32 D_8015CE54;

@ -16,7 +16,7 @@ extern "C" s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId);
extern "C" RomFile sNaviMsgFiles[];
s32 OTRScene_ExecuteCommands(GlobalContext* globalCtx, Ship::Scene* scene);
bool func_80098508(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandSpawnList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetStartPositionList* cmdStartPos = (Ship::SetStartPositionList*)cmd;
@ -61,8 +61,7 @@ bool func_80098508(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x01: Actor List
bool func_800985DC(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
bool Scene_CommandActorList(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
Ship::SetActorList* cmdActor = (Ship::SetActorList*)cmd;
globalCtx->numSetupActors = cmdActor->entries.size();
@ -92,8 +91,7 @@ bool func_800985DC(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
return false;
}
// Scene Command 0x02: Unused 02
bool func_80098630(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandUnused2(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
// Do we need to implement this?
//globalCtx->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment);
@ -101,8 +99,7 @@ bool func_80098630(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x03: Collision Header
bool func_80098674(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandCollisionHeader(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetCollisionHeader* cmdCol = (Ship::SetCollisionHeader*)cmd;
@ -208,8 +205,7 @@ bool func_80098674(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x04: Room List
bool func_800987A4(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandRoomList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetRoomList* cmdRoomList = (Ship::SetRoomList*)cmd;
@ -226,8 +222,7 @@ bool func_800987A4(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x06: Entrance List
bool func_800987F8(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandEntranceList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetEntranceList* otrEntrance = (Ship::SetEntranceList*)cmd;
@ -249,8 +244,7 @@ bool func_800987F8(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x07: Special Files
bool func_8009883C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandSpecialFiles(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetSpecialObjects* otrSpecial = (Ship::SetSpecialObjects*)cmd;
@ -266,42 +260,40 @@ bool func_8009883C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x08: Room Behavior
bool func_80098904(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandRoomBehavior(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetRoomBehavior* cmdRoom = (Ship::SetRoomBehavior*)cmd;
globalCtx->roomCtx.curRoom.unk_03 = cmdRoom->gameplayFlags;
globalCtx->roomCtx.curRoom.unk_02 = cmdRoom->gameplayFlags2 & 0xFF;
globalCtx->roomCtx.curRoom.showInvisActors = (cmdRoom->gameplayFlags2 >> 8) & 1;
globalCtx->roomCtx.curRoom.behaviorType1 = cmdRoom->gameplayFlags;
globalCtx->roomCtx.curRoom.behaviorType2 = cmdRoom->gameplayFlags2 & 0xFF;
globalCtx->roomCtx.curRoom.lensMode = (cmdRoom->gameplayFlags2 >> 8) & 1;
globalCtx->msgCtx.disableWarpSongs = (cmdRoom->gameplayFlags2 >> 0xA) & 1;
return false;
}
// Scene Command 0x0A: Mesh Header
bool func_80098958(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandMeshHeader(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetMesh* otrMesh = (Ship::SetMesh*)cmd;
if (otrMesh->cachedGameData != nullptr)
globalCtx->roomCtx.curRoom.mesh = (Mesh*)otrMesh->cachedGameData;
globalCtx->roomCtx.curRoom.meshHeader = (MeshHeader*)otrMesh->cachedGameData;
else
{
globalCtx->roomCtx.curRoom.mesh = (Mesh*)malloc(sizeof(Mesh));
globalCtx->roomCtx.curRoom.mesh->polygon.type = otrMesh->meshHeaderType;
globalCtx->roomCtx.curRoom.mesh->polygon.num = otrMesh->meshes.size();
globalCtx->roomCtx.curRoom.meshHeader = (MeshHeader*)malloc(sizeof(MeshHeader));
globalCtx->roomCtx.curRoom.meshHeader->base.type = otrMesh->meshHeaderType;
globalCtx->roomCtx.curRoom.meshHeader->polygon0.num = otrMesh->meshes.size();
if (otrMesh->meshHeaderType == 2)
globalCtx->roomCtx.curRoom.mesh->polygon.start = malloc(sizeof(PolygonDlist2) * globalCtx->roomCtx.curRoom.mesh->polygon.num);
globalCtx->roomCtx.curRoom.meshHeader->polygon0.start = malloc(sizeof(PolygonDlist2) * globalCtx->roomCtx.curRoom.meshHeader->polygon0.num);
else
globalCtx->roomCtx.curRoom.mesh->polygon.start = malloc(sizeof(PolygonDlist) * globalCtx->roomCtx.curRoom.mesh->polygon.num);
globalCtx->roomCtx.curRoom.meshHeader->polygon0.start = malloc(sizeof(PolygonDlist) * globalCtx->roomCtx.curRoom.meshHeader->polygon0.num);
for (int i = 0; i < globalCtx->roomCtx.curRoom.mesh->polygon.num; i++)
for (int i = 0; i < globalCtx->roomCtx.curRoom.meshHeader->polygon0.num; i++)
{
if (otrMesh->meshHeaderType == 2)
{
PolygonDlist2* arr = (PolygonDlist2*)globalCtx->roomCtx.curRoom.mesh->polygon.start;
PolygonDlist2* arr = (PolygonDlist2*)globalCtx->roomCtx.curRoom.meshHeader->polygon0.start;
PolygonDlist2* dlist = &arr[i];
if (otrMesh->meshes[i].opa != "")
@ -331,7 +323,7 @@ bool func_80098958(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
dlist->pos.z = otrMesh->meshes[i].z;
dlist->unk_06 = otrMesh->meshes[i].unk_06;
//globalCtx->roomCtx.curRoom.mesh->polygon.start = dlist;
//globalCtx->roomCtx.curRoom.meshHeader->base.start = dlist;
}
else if (otrMesh->meshHeaderType == 1)
{
@ -347,58 +339,58 @@ bool func_80098958(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
else
pType->xlu = 0;
globalCtx->roomCtx.curRoom.mesh->polygon1.dlist = (Gfx*)pType;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.dlist = (Gfx*)pType;
globalCtx->roomCtx.curRoom.mesh->polygon1.format = otrMesh->meshes[0].imgFmt;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.format = otrMesh->meshes[0].imgFmt;
if (otrMesh->meshes[0].imgFmt == 1)
{
globalCtx->roomCtx.curRoom.mesh->polygon1.single.fmt = otrMesh->meshes[0].images[0].fmt;
globalCtx->roomCtx.curRoom.mesh->polygon1.single.source =
globalCtx->roomCtx.curRoom.meshHeader->polygon1.single.fmt = otrMesh->meshes[0].images[0].fmt;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.single.source =
(void*)(OTRGlobals::Instance->context->GetResourceManager()->LoadFile(
otrMesh->meshes[0].images[0].sourceBackground))
.get()
->buffer.get();
globalCtx->roomCtx.curRoom.mesh->polygon1.single.siz = otrMesh->meshes[0].images[0].siz;
globalCtx->roomCtx.curRoom.mesh->polygon1.single.width = otrMesh->meshes[0].images[0].width;
globalCtx->roomCtx.curRoom.mesh->polygon1.single.height = otrMesh->meshes[0].images[0].height;
globalCtx->roomCtx.curRoom.mesh->polygon1.single.fmt = otrMesh->meshes[0].images[0].fmt;
globalCtx->roomCtx.curRoom.mesh->polygon1.single.mode0 = otrMesh->meshes[0].images[0].mode0;
globalCtx->roomCtx.curRoom.mesh->polygon1.single.tlutCount = otrMesh->meshes[0].images[0].tlutCount;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.single.siz = otrMesh->meshes[0].images[0].siz;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.single.width = otrMesh->meshes[0].images[0].width;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.single.height = otrMesh->meshes[0].images[0].height;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.single.fmt = otrMesh->meshes[0].images[0].fmt;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.single.mode0 = otrMesh->meshes[0].images[0].mode0;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.single.tlutCount = otrMesh->meshes[0].images[0].tlutCount;
}
else
{
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.count = otrMesh->meshes[0].images.size();
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list =
(BgImage*)calloc(sizeof(BgImage), globalCtx->roomCtx.curRoom.mesh->polygon1.multi.count);
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.count = otrMesh->meshes[0].images.size();
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list =
(BgImage*)calloc(sizeof(BgImage), globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.count);
for (size_t i = 0; i < otrMesh->meshes[0].images.size(); i++)
{
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].fmt = otrMesh->meshes[0].images[i].fmt;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].source =
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].fmt = otrMesh->meshes[0].images[i].fmt;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].source =
(void*)(OTRGlobals::Instance->context->GetResourceManager()->LoadFile(
otrMesh->meshes[0].images[i].sourceBackground))
.get()
->buffer.get();
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].siz = otrMesh->meshes[0].images[i].siz;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].width = otrMesh->meshes[0].images[i].width;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].height =
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].siz = otrMesh->meshes[0].images[i].siz;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].width = otrMesh->meshes[0].images[i].width;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].height =
otrMesh->meshes[0].images[i].height;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].fmt = otrMesh->meshes[0].images[i].fmt;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].mode0 = otrMesh->meshes[0].images[i].mode0;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].tlutCount =
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].fmt = otrMesh->meshes[0].images[i].fmt;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].mode0 = otrMesh->meshes[0].images[i].mode0;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].tlutCount =
otrMesh->meshes[0].images[i].tlutCount;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].unk_00 =
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].unk_00 =
otrMesh->meshes[0].images[i].unk_00;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].unk_0C =
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].unk_0C =
otrMesh->meshes[0].images[i].unk_0C;
globalCtx->roomCtx.curRoom.mesh->polygon1.multi.list[i].id = otrMesh->meshes[0].images[i].id;
globalCtx->roomCtx.curRoom.meshHeader->polygon1.multi.list[i].id = otrMesh->meshes[0].images[i].id;
}
}
}
else
{
PolygonDlist* arr = (PolygonDlist*)globalCtx->roomCtx.curRoom.mesh->polygon.start;
PolygonDlist* arr = (PolygonDlist*)globalCtx->roomCtx.curRoom.meshHeader->polygon0.start;
PolygonDlist* dlist = &arr[i];
if (otrMesh->meshes[i].opa != "")
@ -421,11 +413,11 @@ bool func_80098958(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
else
dlist->xlu = 0;
//globalCtx->roomCtx.curRoom.mesh->polygon.start = dlist;
//globalCtx->roomCtx.curRoom.meshHeader->base.start = dlist;
}
}
otrMesh->cachedGameData = globalCtx->roomCtx.curRoom.mesh;
otrMesh->cachedGameData = globalCtx->roomCtx.curRoom.meshHeader;
}
return false;
@ -433,8 +425,7 @@ bool func_80098958(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
extern "C" void* func_800982FC(ObjectContext * objectCtx, s32 bankIndex, s16 objectId);
// Scene Command 0x0B: Object List
bool func_8009899C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandObjectList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetObjectList* cmdObj = (Ship::SetObjectList*)cmd;
@ -496,8 +487,7 @@ bool func_8009899C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x0C: Light List
bool func_80098B74(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandLightList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetLightList* cmdLight = (Ship::SetLightList*)cmd;
@ -521,8 +511,7 @@ bool func_80098B74(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x0D: Path
bool func_80098C24(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandPathList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetPathways* cmdPath = (Ship::SetPathways*)cmd;
@ -548,8 +537,7 @@ bool func_80098C24(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x0E: Transition Actor List
bool func_80098C68(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
bool Scene_CommandTransitionActorList(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
Ship::SetTransitionActorList* cmdActor = (Ship::SetTransitionActorList*)cmd;
globalCtx->transiActorCtx.numActors = cmdActor->entries.size();
@ -576,8 +564,7 @@ bool func_80098C68(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
// transiActorCtx->numActors = 0;
//}
// Scene Command 0x0F: Light Setting List
bool func_80098CC8(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandLightSettingsList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetLightingSettings* otrLight = (Ship::SetLightingSettings*)cmd;
@ -618,7 +605,7 @@ bool func_80098CC8(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
}
// Scene Command 0x11: Skybox Settings
bool func_80098D1C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandSkyboxSettings(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetSkyboxSettings* cmdSky = (Ship::SetSkyboxSettings*)cmd;
@ -629,8 +616,7 @@ bool func_80098D1C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x12: Skybox Disables
bool func_80098D5C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandSkyboxDisables(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetSkyboxModifier* cmdSky = (Ship::SetSkyboxModifier*)cmd;
@ -640,8 +626,7 @@ bool func_80098D5C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x10: Time Settings
bool func_80098D80(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandTimeSettings(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetTimeSettings* cmdTime = (Ship::SetTimeSettings*)cmd;
@ -685,8 +670,7 @@ bool func_80098D80(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x05: Wind Settings
bool func_80099090(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
bool Scene_CommandWindSettings(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
Ship::SetWind* cmdWind = (Ship::SetWind*)cmd;
s8 x = cmdWind->windWest;
@ -702,8 +686,7 @@ bool func_80099090(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
return false;
}
// Scene Command 0x13: Exit List
bool func_800990F0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandExitList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::ExitList* cmdExit = (Ship::ExitList*)cmd;
@ -715,13 +698,11 @@ bool func_800990F0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x09: Undefined
bool func_80099134(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
bool Scene_CommandUndefined9(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
return false;
}
// Scene Command 0x15: Sound Settings
bool func_80099140(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
bool Scene_CommandSoundSettings(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
Ship::SetSoundSettings* cmdSnd = (Ship::SetSoundSettings*)cmd;
globalCtx->sequenceCtx.seqId = cmdSnd->musicSequence;
@ -734,8 +715,7 @@ bool func_80099140(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
return false;
}
// Scene Command 0x16: Echo Setting
bool func_8009918C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandEchoSettings(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetEchoSettings* cmdEcho = (Ship::SetEchoSettings*)cmd;
@ -744,8 +724,7 @@ bool func_8009918C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x18: Alternate Headers
bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandAlternateHeaderList(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetAlternateHeaders* cmdHeaders = (Ship::SetAlternateHeaders*)cmd;
@ -799,8 +778,7 @@ bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x17: Cutscene Data
bool func_8009934C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool Scene_CommandCutsceneData(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetCutscenes* cmdCS = (Ship::SetCutscenes*)cmd;
@ -811,8 +789,8 @@ bool func_8009934C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
return false;
}
// Scene Command 0x19: Misc. Settings (Camera & World Map Area)
bool func_800993C0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
// Camera & World Map Area
bool Scene_CommandMiscSettings(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetCameraSettings* cmdCam = (Ship::SetCameraSettings*)cmd;
@ -838,10 +816,32 @@ bool func_800993C0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool (*sceneCommands[])(GlobalContext*, Ship::SceneCommand*) =
{
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, 0,
func_80099140, func_8009918C, func_8009934C, func_800991A0, func_800993C0,
Scene_CommandSpawnList, // SCENE_CMD_ID_SPAWN_LIST
Scene_CommandActorList, // SCENE_CMD_ID_ACTOR_LIST
Scene_CommandUnused2, // SCENE_CMD_ID_UNUSED_2
Scene_CommandCollisionHeader, // SCENE_CMD_ID_COLLISION_HEADER
Scene_CommandRoomList, // SCENE_CMD_ID_ROOM_LIST
Scene_CommandWindSettings, // SCENE_CMD_ID_WIND_SETTINGS
Scene_CommandEntranceList, // SCENE_CMD_ID_ENTRANCE_LIST
Scene_CommandSpecialFiles, // SCENE_CMD_ID_SPECIAL_FILES
Scene_CommandRoomBehavior, // SCENE_CMD_ID_ROOM_BEHAVIOR
Scene_CommandUndefined9, // SCENE_CMD_ID_UNDEFINED_9
Scene_CommandMeshHeader, // SCENE_CMD_ID_MESH_HEADER
Scene_CommandObjectList, // SCENE_CMD_ID_OBJECT_LIST
Scene_CommandLightList, // SCENE_CMD_ID_LIGHT_LIST
Scene_CommandPathList, // SCENE_CMD_ID_PATH_LIST
Scene_CommandTransitionActorList, // SCENE_CMD_ID_TRANSITION_ACTOR_LIST
Scene_CommandLightSettingsList, // SCENE_CMD_ID_LIGHT_SETTINGS_LIST
Scene_CommandTimeSettings, // SCENE_CMD_ID_TIME_SETTINGS
Scene_CommandSkyboxSettings, // SCENE_CMD_ID_SKYBOX_SETTINGS
Scene_CommandSkyboxDisables, // SCENE_CMD_ID_SKYBOX_DISABLES
Scene_CommandExitList, // SCENE_CMD_ID_EXIT_LIST
NULL, // SCENE_CMD_ID_END
Scene_CommandSoundSettings, // SCENE_CMD_ID_SOUND_SETTINGS
Scene_CommandEchoSettings, // SCENE_CMD_ID_ECHO_SETTINGS
Scene_CommandCutsceneData, // SCENE_CMD_ID_CUTSCENE_DATA
Scene_CommandAlternateHeaderList, // SCENE_CMD_ID_ALTERNATE_HEADER_LIST
Scene_CommandMiscSettings, // SCENE_CMD_ID_MISC_SETTINGS
};
s32 OTRScene_ExecuteCommands(GlobalContext* globalCtx, Ship::Scene* scene)

@ -72,7 +72,7 @@ void StackCheck_Cleanup(StackEntry* entry) {
}
}
StackStatus StackCheck_GetState(StackEntry* entry) {
s32 StackCheck_GetState(StackEntry* entry) {
u32* last;
size_t used;
size_t free;

@ -11,7 +11,7 @@ s32 sDmaMgrCurFileLine;
u32 D_80009460 = 0;
u32 gDmaMgrDmaBuffSize = 0x2000;
u32 sDmaMgrDataExistError = 0;
u32 sDmaMgrIsRomCompressed = false;
// dmadata filenames
#define DEFINE_DMA_ENTRY(name) #name,
@ -289,7 +289,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) {
}
if (!found) {
if (sDmaMgrDataExistError) {
if (sDmaMgrIsRomCompressed) {
DmaMgr_Error(req, NULL, "DATA DON'T EXIST", "該当するデータが存在しません");
return;
}
@ -385,14 +385,14 @@ void DmaMgr_Init(void) {
//(uintptr_t)(_dmadataSegmentRomEnd - _dmadataSegmentRomStart));
osSyncPrintf("dma_rom_ad[]\n");
sDmaMgrDataExistError = 0;
sDmaMgrIsRomCompressed = false;
name = sDmaMgrFileNames;
iter = gDmaDataTable;
idx = 0;
while (iter->vromEnd != 0) {
if (iter->romEnd != 0) {
sDmaMgrDataExistError = 1;
sDmaMgrIsRomCompressed = true;
}
osSyncPrintf(

@ -651,7 +651,7 @@ void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag) {
}
/**
* Tests if current scene unknown flag is set.
* Tests if unknown flag is set.
*/
s32 Flags_GetUnknown(GlobalContext* globalCtx, s32 flag) {
if (flag < 0x20) {
@ -662,7 +662,7 @@ s32 Flags_GetUnknown(GlobalContext* globalCtx, s32 flag) {
}
/**
* Sets current scene unknown flag.
* Sets unknown flag.
*/
void Flags_SetUnknown(GlobalContext* globalCtx, s32 flag) {
if (flag < 0x20) {
@ -673,7 +673,7 @@ void Flags_SetUnknown(GlobalContext* globalCtx, s32 flag) {
}
/**
* Unsets current scene unknown flag.
* Unsets unknown flag.
*/
void Flags_UnsetUnknown(GlobalContext* globalCtx, s32 flag) {
if (flag < 0x20) {
@ -1395,7 +1395,7 @@ void func_8002DE04(GlobalContext* globalCtx, Actor* actorA, Actor* actorB) {
}
void func_8002DE74(GlobalContext* globalCtx, Player* player) {
if ((globalCtx->roomCtx.curRoom.unk_03 != 4) && func_800C0CB8(globalCtx)) {
if ((globalCtx->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_4) && func_800C0CB8(globalCtx)) {
Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, MAIN_CAM), CAM_SET_HORSE);
}
}
@ -2348,9 +2348,9 @@ void func_80030488(GlobalContext* globalCtx) {
LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, D_8015BC10);
}
void func_800304B0(GlobalContext* globalCtx) {
if (globalCtx->actorCtx.unk_03 != 0) {
globalCtx->actorCtx.unk_03 = 0;
void Actor_DisableLens(GlobalContext* globalCtx) {
if (globalCtx->actorCtx.lensActive) {
globalCtx->actorCtx.lensActive = false;
func_800876C8(globalCtx);
}
}
@ -2390,7 +2390,7 @@ void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry*
func_8002FA60(globalCtx);
}
u32 D_80116068[] = {
u32 D_80116068[ACTORCAT_MAX] = {
0x100000C0, 0x100000C0, 0x00000000, 0x100004C0, 0x00000080, 0x300000C0,
0x10000080, 0x00000000, 0x300000C0, 0x100004C0, 0x00000000, 0x100000C0,
};
@ -2643,26 +2643,35 @@ void func_80030ED8(Actor* actor) {
}
}
void func_80030FA8(GraphicsContext* gfxCtx) {
#define LENS_MASK_WIDTH 64
#define LENS_MASK_HEIGHT 64
// 26 and 6 are for padding between the mask texture and the screen borders
#define LENS_MASK_OFFSET_S ((SCREEN_WIDTH / 2 - LENS_MASK_WIDTH) - 26)
#define LENS_MASK_OFFSET_T ((SCREEN_HEIGHT / 2 - LENS_MASK_HEIGHT) - 6)
void Actor_DrawLensOverlay(GraphicsContext* gfxCtx) {
OPEN_DISPS(gfxCtx);
gDPLoadTextureBlock(POLY_XLU_DISP++, gLensOfTruthMaskTex, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0,
G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD);
gDPLoadTextureBlock(POLY_XLU_DISP++, gLensOfTruthMaskTex, G_IM_FMT_I, G_IM_SIZ_8b, LENS_MASK_WIDTH,
LENS_MASK_HEIGHT, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD,
G_TX_NOLOD);
s32 x = OTRGetRectDimensionFromLeftEdge(0) << 2;
s32 w = OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) << 2;
float ratio = OTRGetAspectRatio();
gDPSetTileSize(POLY_XLU_DISP++, G_TX_RENDERTILE, 384, 224, 892, 732);
// TODO: Do correct math to fix it
gSPWideTextureRectangle(POLY_XLU_DISP++, x, 0, x + abs(x), 960, G_TX_RENDERTILE, 0, 0, 0, 0);
gSPWideTextureRectangle(POLY_XLU_DISP++, 0, 0, w, 960, G_TX_RENDERTILE, 2240, 1600, 576, 597);
gDPSetTileSize(POLY_XLU_DISP++, G_TX_RENDERTILE, (SCREEN_WIDTH / 2 - LENS_MASK_WIDTH) << 2,
(SCREEN_HEIGHT / 2 - LENS_MASK_HEIGHT) << 2, (SCREEN_WIDTH / 2 + LENS_MASK_WIDTH - 1) << 2,
(SCREEN_HEIGHT / 2 + LENS_MASK_HEIGHT - 1) << 2);
gSPWideTextureRectangle(POLY_XLU_DISP++, x, 0, x + abs(x), SCREEN_HEIGHT << 2, G_TX_RENDERTILE, 0, 0, 0, 0);
gSPWideTextureRectangle(POLY_XLU_DISP++, 0, 0, w, SCREEN_HEIGHT << 2, G_TX_RENDERTILE,
LENS_MASK_OFFSET_S << 5, LENS_MASK_OFFSET_T << 5,
(1 << 10) * (SCREEN_WIDTH - 2 * LENS_MASK_OFFSET_S) / SCREEN_WIDTH,
(1 << 10) * (SCREEN_HEIGHT - 2 * LENS_MASK_OFFSET_T) / SCREEN_HEIGHT);
gDPPipeSync(POLY_XLU_DISP++);
CLOSE_DISPS(gfxCtx);
}
void func_8003115C(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** invisibleActors) {
void Actor_DrawLensActors(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** invisibleActors) {
Actor** invisibleActor;
GraphicsContext* gfxCtx;
s32 i;
@ -2675,28 +2684,41 @@ void func_8003115C(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** inv
gDPPipeSync(POLY_XLU_DISP++);
if (globalCtx->roomCtx.curRoom.showInvisActors == 0) {
if (globalCtx->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) {
// Update both the color frame buffer and the z-buffer
gDPSetOtherMode(POLY_XLU_DISP++,
G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | G_RM_CLD_SURF | G_RM_CLD_SURF2);
gDPSetCombineMode(POLY_XLU_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 0, 255);
// the z-buffer will later only allow drawing inside the lens circle
} else {
// Update the z-buffer but not the color frame buffer
gDPSetOtherMode(POLY_XLU_DISP++,
G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL |
GBL_c1(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA) |
GBL_c2(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA));
// inverts the mask image, which initially is 0 inner and 74 outer,
// by setting the combiner to draw 74 - image instead of the image
gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0,
PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0, PRIMITIVE, TEXEL0, PRIM_LOD_FRAC, 0);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 74, 74, 74, 74);
// the z-buffer will later only allow drawing outside the lens circle
}
// Together with the depth source set above, this sets the depth to the closest.
// For a pixel with such a depth value, the z-buffer will reject drawing to that pixel.
gDPSetPrimDepth(POLY_XLU_DISP++, 0, 0);
func_80030FA8(gfxCtx);
// The z-buffer will be updated where the mask is not fully transparent.
Actor_DrawLensOverlay(gfxCtx);
// "Magic lens invisible Actor display START"
gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないc表示 START", numInvisibleActors);
@ -2711,7 +2733,9 @@ void func_8003115C(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** inv
// "Magic lens invisible Actor display END"
gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないc表示 END", numInvisibleActors);
if (globalCtx->roomCtx.curRoom.showInvisActors != 0) {
if (globalCtx->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) {
// Draw the lens overlay to the color frame buffer
gDPNoOpString(POLY_OPA_DISP++, "青い眼鏡(外側)", 0); // "Blue spectacles (exterior)"
gDPPipeSync(POLY_XLU_DISP++);
@ -2723,7 +2747,7 @@ void func_8003115C(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** inv
gDPSetCombineMode(POLY_XLU_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 0, 0, 255);
func_80030FA8(gfxCtx);
Actor_DrawLensOverlay(gfxCtx);
gDPNoOpString(POLY_OPA_DISP++, "青い眼鏡(外側)", 1); // "Blue spectacles (exterior)"
}
@ -2808,8 +2832,8 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) {
if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(71) == 0)) {
if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & (ACTOR_FLAG_5 | ACTOR_FLAG_6))) {
if ((actor->flags & ACTOR_FLAG_7) &&
((globalCtx->roomCtx.curRoom.showInvisActors == 0) || (globalCtx->actorCtx.unk_03 != 0) ||
(actor->room != globalCtx->roomCtx.curRoom.num))) {
((globalCtx->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) ||
globalCtx->actorCtx.lensActive || (actor->room != globalCtx->roomCtx.curRoom.num))) {
ASSERT(invisibleActorCounter < INVISIBLE_ACTOR_MAX);
invisibleActors[invisibleActorCounter] = actor;
invisibleActorCounter++;
@ -2835,10 +2859,10 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) {
}
if ((HREG(64) != 1) || (HREG(72) != 0)) {
if (globalCtx->actorCtx.unk_03 != 0) {
func_8003115C(globalCtx, invisibleActorCounter, invisibleActors);
if (globalCtx->actorCtx.lensActive) {
Actor_DrawLensActors(globalCtx, invisibleActorCounter, invisibleActors);
if ((globalCtx->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(globalCtx)) {
func_800304B0(globalCtx);
Actor_DisableLens(globalCtx);
}
}
}
@ -3195,6 +3219,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId
Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX,
f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s16 params) {
Actor* spawnedActor = Actor_Spawn(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params);
if (spawnedActor == NULL) {
return NULL;
}

@ -11,7 +11,7 @@
s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags);
s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags);
s32 Camera_QRegInit(void);
s32 Camera_CheckWater(Camera* camera);
s32 Camera_UpdateWater(Camera* camera);
#define RELOAD_PARAMS \
(camera->animState == 0 || camera->animState == 0xA || camera->animState == 0x14 || R_RELOAD_CAM_PARAMS)
@ -28,6 +28,12 @@ s32 Camera_CheckWater(Camera* camera);
#define FLG_ADJSLOPE (1 << 0)
#define FLG_OFFGROUND (1 << 7)
#define DISTORTION_HOT_ROOM (1 << 0)
#define DISTORTION_UNDERWATER_WEAK (1 << 1)
#define DISTORTION_UNDERWATER_MEDIUM (1 << 2)
#define DISTORTION_UNDERWATER_STRONG (1 << 3)
#define DISTORTION_UNDERWATER_FISHING (1 << 4)
#include "z_camera_data.inc"
/*===============================================================*/
@ -972,7 +978,7 @@ s32 func_80045B08(Camera* camera, VecSph* eyeAtDir, f32 yExtra, s16 arg3) {
f32 phi_f2;
Vec3f posOffsetTarget;
Vec3f atTarget;
f32 sp38; // unused
f32 pad;
f32 temp_ret;
PosRot* playerPosRot = &camera->playerPosRot;
@ -7004,19 +7010,20 @@ void func_80057FC4(Camera* camera) {
if (camera != &camera->globalCtx->mainCamera) {
camera->prevSetting = camera->setting = CAM_SET_FREE0;
camera->unk_14C &= ~0x4;
} else if (camera->globalCtx->roomCtx.curRoom.mesh->polygon.type != 1) {
switch (camera->globalCtx->roomCtx.curRoom.unk_03) {
case 1:
} else if (camera->globalCtx->roomCtx.curRoom.meshHeader->base.type != 1) {
switch (camera->globalCtx->roomCtx.curRoom.behaviorType1) {
case ROOM_BEHAVIOR_TYPE1_1:
Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10);
camera->prevSetting = camera->setting = CAM_SET_DUNGEON0;
break;
case 0:
case ROOM_BEHAVIOR_TYPE1_0:
osSyncPrintf("camera: room type: default set field\n");
Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10);
camera->prevSetting = camera->setting = CAM_SET_NORMAL0;
break;
default:
osSyncPrintf("camera: room type: default set etc (%d)\n", camera->globalCtx->roomCtx.curRoom.unk_03);
osSyncPrintf("camera: room type: default set etc (%d)\n",
camera->globalCtx->roomCtx.curRoom.behaviorType1);
Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10);
camera->prevSetting = camera->setting = CAM_SET_NORMAL0;
camera->unk_14C |= 4;
@ -7095,7 +7102,7 @@ void Camera_InitPlayerSettings(Camera* camera, Player* player) {
osSyncPrintf(VT_FGCOL(BLUE) "camera: personalize ---" VT_RST "\n");
if (camera->thisIdx == MAIN_CAM) {
Camera_CheckWater(camera);
Camera_UpdateWater(camera);
}
}
@ -7203,7 +7210,7 @@ void Camera_PrintSettings(Camera* camera) {
}
}
s32 Camera_CheckWater(Camera* camera) {
s32 Camera_UpdateWater(Camera* camera) {
f32 waterY;
s16 newQuakeId;
s32 waterLightsIndex;
@ -7280,7 +7287,7 @@ s32 Camera_CheckWater(Camera* camera) {
camera->unk_14C |= 0x100;
osSyncPrintf("kankyo changed water, sound on\n");
Environment_EnableUnderwaterLights(camera->globalCtx, waterLightsIndex);
camera->unk_150 = 0x50;
camera->waterDistortionTimer = 80;
}
Audio_SetExtraFilter(0x20);
@ -7299,13 +7306,13 @@ s32 Camera_CheckWater(Camera* camera) {
}
}
if (camera->unk_150 > 0) {
camera->unk_150--;
camera->unk_152 |= 8;
} else if (camera->globalCtx->sceneNum == 0x49) {
camera->unk_152 |= 0x10;
if (camera->waterDistortionTimer > 0) {
camera->waterDistortionTimer--;
camera->distortionFlags |= DISTORTION_UNDERWATER_STRONG;
} else if (camera->globalCtx->sceneNum == SCENE_TURIBORI) {
camera->distortionFlags |= DISTORTION_UNDERWATER_FISHING;
} else {
camera->unk_152 |= 2;
camera->distortionFlags |= DISTORTION_UNDERWATER_WEAK;
}
} else {
if (camera->unk_14C & 0x100) {
@ -7315,21 +7322,18 @@ s32 Camera_CheckWater(Camera* camera) {
if (*quakeId != 0) {
Quake_RemoveFromIdx(*quakeId);
}
camera->unk_150 = 0;
camera