[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
This commit is contained in:
David Chavez
2022-08-17 03:53:28 +02:00
committed by GitHub
parent b4614acf70
commit 6b0338a37d
73 changed files with 898 additions and 833 deletions
+52 -27
View File
@@ -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++, "魔法のメガネ 見えないActor表示 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++, "魔法のメガネ 見えないActor表示 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;
}