Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 24 additions & 66 deletions include/vis.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,39 @@
#include "ultra64.h"
#include "color.h"

typedef enum FramebufferFilterType {
/* 0 */ FB_FILTER_NONE,
/* 1 */ FB_FILTER_CVG_RGB,
/* 2 */ FB_FILTER_CVG_RGB_UNIFORM,
/* 3 */ FB_FILTER_CVG_ONLY,
/* 4 */ FB_FILTER_CVG_RGB_FOG, // Not recommended, easily overflows blender
/* 5 */ FB_FILTER_ZBUF_IA,
/* 6 */ FB_FILTER_ZBUF_RGBA,
/* 7 */ FB_FILTER_MONO
} FramebufferFilterType;

typedef enum VisScissorType {
/* 0 */ VIS_NO_SETSCISSOR,
/* 1 */ VIS_SETSCISSOR
} VisScissorType;

typedef struct Vis {
// Vis...
typedef struct struct_801664F0 {
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
/* 0x00 */ u32 type;
/* 0x04 */ u32 scissorType;
/* 0x08 */ Color_RGBA8_u32 primColor;
/* 0x04 */ u32 setScissor;
/* 0x08 */ Color_RGBA8_u32 color;
/* 0x0C */ Color_RGBA8_u32 envColor;
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
} Vis; // size = 0x10


/* Cvg: Coverage */

#define FB_FILTER_TO_CVG_TYPE(filter) (filter)

typedef enum VisCvgType {
/* 0 */ VIS_CVG_TYPE_NONE = FB_FILTER_TO_CVG_TYPE(FB_FILTER_NONE),
/* 1 */ VIS_CVG_TYPE_CVG_RGB = FB_FILTER_TO_CVG_TYPE(FB_FILTER_CVG_RGB),
/* 2 */ VIS_CVG_TYPE_CVG_RGB_UNIFORM = FB_FILTER_TO_CVG_TYPE(FB_FILTER_CVG_RGB_UNIFORM),
/* 3 */ VIS_CVG_TYPE_CVG_ONLY = FB_FILTER_TO_CVG_TYPE(FB_FILTER_CVG_ONLY),
/* 4 */ VIS_CVG_TYPE_CVG_RGB_FOG = FB_FILTER_TO_CVG_TYPE(FB_FILTER_CVG_RGB_FOG)
} VisCvgType;

typedef struct VisCvg {
/* 0x00 */ Vis vis;
} VisCvg; // size = 0x10

void VisCvg_Init(VisCvg* this);
void VisCvg_Destroy(VisCvg* this);
void VisCvg_Draw(VisCvg* this, Gfx** gfxP);


/* Mono: Desaturation */

// Only one type
} struct_801664F0; // size = 0x10

typedef struct VisMono {
/* 0x00 */ Vis vis;
/* 0x00 */ u32 unk_00;
/* 0x04 */ u32 setScissor;
/* 0x08 */ Color_RGBA8_u32 primColor;
/* 0x0C */ Color_RGBA8_u32 envColor;
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
/* 0x10 */ u16* tlut;
/* 0x14 */ Gfx* dList;
} VisMono; // size = 0x18

// Vis...
typedef struct struct_80166500 {
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
/* 0x00 */ u32 useRgba;
/* 0x04 */ u32 setScissor;
/* 0x08 */ Color_RGBA8_u32 primColor;
/* 0x08 */ Color_RGBA8_u32 envColor;
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
} struct_80166500; // size = 0x10

void func_800ACE70(struct_801664F0* this);
void func_800ACE90(struct_801664F0* this);
void func_800ACE98(struct_801664F0* this, Gfx** gfxp);
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
void VisMono_Init(VisMono* this);
void VisMono_Destroy(VisMono* this);
void VisMono_Draw(VisMono* this, Gfx** gfxP);


/* ZBuf: Z-Buffer */

#define FB_FILTER_TO_ZBUF_TYPE(filter) ((filter) - FB_FILTER_ZBUF_IA)

typedef enum VisZBufType {
/* 0 */ VIS_ZBUF_TYPE_IA = FB_FILTER_TO_ZBUF_TYPE(FB_FILTER_ZBUF_IA),
/* 1 */ VIS_ZBUF_TYPE_RGBA = FB_FILTER_TO_ZBUF_TYPE(FB_FILTER_ZBUF_RGBA)
} VisZBufType;

typedef struct VisZBuf {
/* 0x00 */ Vis vis;
} VisZBuf; // size = 0x10

void VisZBuf_Init(VisZBuf* this);
void VisZBuf_Destroy(VisZBuf* this);
void VisZBuf_Draw(VisZBuf* this, Gfx** gfxP);
void VisMono_Draw(VisMono* this, Gfx** gfxp);
void func_800AD920(struct_80166500* this);
void func_800AD950(struct_80166500* this);
void func_800AD958(struct_80166500* this, Gfx** gfxp);
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated

#endif
4 changes: 2 additions & 2 deletions spec/spec
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ beginseg
include "$(BUILD_DIR)/data/unk_8012ABC0.data.o"
include "$(BUILD_DIR)/src/code/z_view.o"
include "$(BUILD_DIR)/src/code/z_vimode.o"
include "$(BUILD_DIR)/src/code/z_viscvg.o"
include "$(BUILD_DIR)/src/code/code_800ACE70.o"
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
include "$(BUILD_DIR)/src/code/z_vismono.o"
include "$(BUILD_DIR)/src/code/z_viszbuf.o"
include "$(BUILD_DIR)/src/code/code_800AD920.o"
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
include "$(BUILD_DIR)/src/code/z_vr_box.o"
include "$(BUILD_DIR)/src/code/z_vr_box_draw.o"
include "$(BUILD_DIR)/src/code/z_player_call.o"
Expand Down
99 changes: 99 additions & 0 deletions src/code/code_800ACE70.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#include "ultra64.h"
#include "gfx.h"
#include "vis.h"

// Note : This file is related to z_vismono, the original name was probably z_vis<something before "mono"
// alphabetically>

Gfx D_8012AC00[] = {
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PRIM | G_RM_VISCVG | G_RM_VISCVG2),
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
gsDPPipeSync(),
gsDPSetBlendColor(0, 0, 0, 8),
gsSPEndDisplayList(),
};

Gfx D_8012AC28[] = {
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM) |
GBL_c2(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_A_MEM)),
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
gsSPEndDisplayList(),
};

Gfx D_8012AC40[] = {
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) |
GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)),

gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
gsSPEndDisplayList(),
};

Gfx D_8012AC58[] = {
gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE),
gsDPSetOtherMode(G_AD_NOTPATTERN | G_CD_DISABLE | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2),
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
gsDPSetOtherMode(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PRIM | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL |
GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM) |
GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_A_MEM)),
gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1),
gsSPEndDisplayList(),
};

// Init
void func_800ACE70(struct_801664F0* this) {
this->type = 0;
this->setScissor = false;
this->color.r = 255;
this->color.g = 255;
this->color.b = 255;
this->color.a = 255;
}

// Destroy
void func_800ACE90(struct_801664F0* this) {
}

// Draw
void func_800ACE98(struct_801664F0* this, Gfx** gfxp) {
Gfx* gfx = *gfxp;

gDPPipeSync(gfx++);
gDPSetPrimDepth(gfx++, 0xFFFF, 0xFFFF);

if (this->setScissor == true) {
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}

switch (this->type) {
case 1:
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
gSPDisplayList(gfx++, D_8012AC40);
break;
case 2:
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba);
gSPDisplayList(gfx++, D_8012AC58);
break;
case 3:
gDPSetColor(gfx++, G_SETBLENDCOLOR, this->color.rgba);
gSPDisplayList(gfx++, D_8012AC00);
break;
case 4:
gDPSetColor(gfx++, G_SETFOGCOLOR, this->color.rgba);
gSPDisplayList(gfx++, D_8012AC28);
break;
}

gDPPipeSync(gfx++);
*gfxp = gfx;
}
66 changes: 66 additions & 0 deletions src/code/code_800AD920.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "ultra64.h"
#include "gfx.h"
#include "vis.h"

// Note : This file is related to z_vismono, the original name was probably z_vis<something after "mono" alphabetically>

// z-buffer
extern u16 D_0E000000[];

// Init
void func_800AD920(struct_80166500* this) {
this->useRgba = false;
this->setScissor = false;
this->primColor.r = 255;
this->primColor.g = 255;
this->primColor.b = 255;
this->primColor.a = 255;

// clang-format off
this->envColor.r = 0; \
this->envColor.g = 0; \
this->envColor.b = 0; \
this->envColor.a = 255;
// clang-format on
}

// Destroy
void func_800AD950(struct_80166500* this) {
}

// Draw
void func_800AD958(struct_80166500* this, Gfx** gfxp) {
Gfx* gfx = *gfxp;
s32 pad;
u16* tex = D_0E000000;
s32 fmt = !this->useRgba ? G_IM_FMT_IA : G_IM_FMT_RGBA;
s32 y;
s32 height = 6;

gDPPipeSync(gfx++);
if (this->setScissor == true) {
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}

gDPSetOtherMode(gfx++,
G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PRIM | G_RM_OPA_SURF | G_RM_OPA_SURF2);
gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT,
PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT);

gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba);
gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba);

for (y = 0; y <= SCREEN_HEIGHT - height; y += height) {
gDPLoadTextureBlock(gfx++, tex, fmt, G_IM_SIZ_16b, SCREEN_WIDTH, height, 0, G_TX_NOMIRROR | G_TX_CLAMP,
G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);

gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10,
1 << 10);
tex += SCREEN_WIDTH * height;
}

gDPPipeSync(gfx++);
*gfxp = gfx;
}
79 changes: 38 additions & 41 deletions src/code/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0"

SpeedMeter D_801664D0;
VisCvg sVisCvg;
VisZBuf sVisZBuf;
VisMono sVisMono;
struct_801664F0 D_801664F0;
struct_80166500 D_80166500;
Comment thread
Dragorn421 marked this conversation as resolved.
Outdated
VisMono sMonoColors;
ViMode sViMode;

#if DEBUG_FEATURES
Expand All @@ -61,38 +61,35 @@ void GameState_FaultPrint(void) {
void GameState_SetFBFilter(Gfx** gfxP) {
Gfx* gfx = *gfxP;

if ((R_FB_FILTER_TYPE >= FB_FILTER_CVG_RGB) && (R_FB_FILTER_TYPE <= FB_FILTER_CVG_RGB_FOG)) {
// Visualize coverage
sVisCvg.vis.type = FB_FILTER_TO_CVG_TYPE(R_FB_FILTER_TYPE);
sVisCvg.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
sVisCvg.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
sVisCvg.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
sVisCvg.vis.primColor.a = R_FB_FILTER_A;
VisCvg_Draw(&sVisCvg, &gfx);
} else if ((R_FB_FILTER_TYPE == FB_FILTER_ZBUF_IA) || (R_FB_FILTER_TYPE == FB_FILTER_ZBUF_RGBA)) {
// Visualize z-buffer
sVisZBuf.vis.type = (R_FB_FILTER_TYPE == FB_FILTER_ZBUF_RGBA);
sVisZBuf.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
sVisZBuf.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
sVisZBuf.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
sVisZBuf.vis.primColor.a = R_FB_FILTER_A;
sVisZBuf.vis.envColor.r = R_FB_FILTER_ENV_COLOR(0);
sVisZBuf.vis.envColor.g = R_FB_FILTER_ENV_COLOR(1);
sVisZBuf.vis.envColor.b = R_FB_FILTER_ENV_COLOR(2);
sVisZBuf.vis.envColor.a = R_FB_FILTER_A;
VisZBuf_Draw(&sVisZBuf, &gfx);
} else if (R_FB_FILTER_TYPE == FB_FILTER_MONO) {
// Monochrome filter
sVisMono.vis.type = 0;
sVisMono.vis.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
sVisMono.vis.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
sVisMono.vis.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
sVisMono.vis.primColor.a = R_FB_FILTER_A;
sVisMono.vis.envColor.r = R_FB_FILTER_ENV_COLOR(0);
sVisMono.vis.envColor.g = R_FB_FILTER_ENV_COLOR(1);
sVisMono.vis.envColor.b = R_FB_FILTER_ENV_COLOR(2);
sVisMono.vis.envColor.a = R_FB_FILTER_A;
VisMono_Draw(&sVisMono, &gfx);
if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) {
D_801664F0.type = R_FB_FILTER_TYPE;
D_801664F0.color.r = R_FB_FILTER_PRIM_COLOR(0);
D_801664F0.color.g = R_FB_FILTER_PRIM_COLOR(1);
D_801664F0.color.b = R_FB_FILTER_PRIM_COLOR(2);
D_801664F0.color.a = R_FB_FILTER_A;
func_800ACE98(&D_801664F0, &gfx);
} else if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) {
D_80166500.useRgba = (R_FB_FILTER_TYPE == 6);
D_80166500.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
D_80166500.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
D_80166500.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
D_80166500.primColor.a = R_FB_FILTER_A;
D_80166500.envColor.r = R_FB_FILTER_ENV_COLOR(0);
D_80166500.envColor.g = R_FB_FILTER_ENV_COLOR(1);
D_80166500.envColor.b = R_FB_FILTER_ENV_COLOR(2);
D_80166500.envColor.a = R_FB_FILTER_A;
func_800AD958(&D_80166500, &gfx);
} else if (R_FB_FILTER_TYPE == 7) {
sMonoColors.unk_00 = 0;
sMonoColors.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
sMonoColors.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
sMonoColors.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
sMonoColors.primColor.a = R_FB_FILTER_A;
sMonoColors.envColor.r = R_FB_FILTER_ENV_COLOR(0);
sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1);
sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2);
sMonoColors.envColor.a = R_FB_FILTER_A;
VisMono_Draw(&sMonoColors, &gfx);
}
*gfxP = gfx;
}
Expand Down Expand Up @@ -498,9 +495,9 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g

startTime = endTime;
LOG_UTILS_CHECK_NULL_POINTER("this->cleanup", gameState->destroy, "../game.c", 1088);
VisCvg_Init(&sVisCvg);
VisZBuf_Init(&sVisZBuf);
VisMono_Init(&sVisMono);
func_800ACE70(&D_801664F0);
func_800AD920(&D_80166500);
VisMono_Init(&sMonoColors);
if ((R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) || !DEBUG_FEATURES) {
ViMode_Init(&sViMode);
}
Expand Down Expand Up @@ -529,9 +526,9 @@ void GameState_Destroy(GameState* gameState) {
}
Rumble_Destroy();
SpeedMeter_Destroy(&D_801664D0);
VisCvg_Destroy(&sVisCvg);
VisZBuf_Destroy(&sVisZBuf);
VisMono_Destroy(&sVisMono);
func_800ACE90(&D_801664F0);
func_800AD950(&D_80166500);
VisMono_Destroy(&sMonoColors);
if ((R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) || !DEBUG_FEATURES) {
ViMode_Destroy(&sViMode);
}
Expand Down
Loading