mirror of
https://github.com/zeldaret/oot
synced 2026-07-02 20:46:16 -04:00
Document Framebuffer Filters, VisCvg and VisZbuf (#1534)
* Document z_viscvg and z_viszbuf Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Few more notes * Some more notes Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * Review * Americanisation, FB RGB * Oops * Review * Minor documentation modifications * Header, base struct and enums Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * functions.h fix * Suggested changes, further adjustments to file doc comments * Further suggested changes, standardize capitalization of gfxP * g --------- Co-authored-by: Elliptic Ellipsis <elliptic.ellipsis@gmail.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
+27
-19
@@ -1,13 +1,19 @@
|
||||
/**
|
||||
* Color frame buffer effect to desaturate the colors.
|
||||
* @file z_vismono.c
|
||||
*
|
||||
* This file implements a full-screen framebuffer effect for desaturating the contents of the framebuffer image.
|
||||
*
|
||||
* Broadly, this effect is achieved by reinterpreting the contents of the RGBA16 color image as indices into an IA16
|
||||
* color palette that converts each color into the desaturated equivalent. More precise details can be found in inline
|
||||
* comments.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
// Height of the fragments the color frame buffer (CFB) is split into.
|
||||
// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into
|
||||
// the half of tmem (0x800 bytes) dedicated to color-indexed data.
|
||||
#define VISMONO_CFBFRAG_HEIGHT (0x800 / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES))
|
||||
// the half of TMEM dedicated to color-indexed data.
|
||||
#define VISMONO_CFBFRAG_HEIGHT ((TMEM_SIZE / 2) / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES))
|
||||
|
||||
// Maximum size of the dlist written by `VisMono_DesaturateDList`.
|
||||
// `VisMono_DesaturateDList` consistently uses `VISMONO_DLSIZE - 2` double words, so this can be 2 less.
|
||||
@@ -26,16 +32,16 @@ extern u16 D_0F000000[];
|
||||
|
||||
void VisMono_Init(VisMono* this) {
|
||||
bzero(this, sizeof(VisMono));
|
||||
this->unk_00 = 0;
|
||||
this->setScissor = false;
|
||||
this->primColor.r = 255;
|
||||
this->primColor.g = 255;
|
||||
this->primColor.b = 255;
|
||||
this->primColor.a = 255;
|
||||
this->envColor.r = 0;
|
||||
this->envColor.g = 0;
|
||||
this->envColor.b = 0;
|
||||
this->envColor.a = 0;
|
||||
this->vis.type = 0;
|
||||
this->vis.scissorType = VIS_NO_SETSCISSOR;
|
||||
this->vis.primColor.r = 255;
|
||||
this->vis.primColor.g = 255;
|
||||
this->vis.primColor.b = 255;
|
||||
this->vis.primColor.a = 255;
|
||||
this->vis.envColor.r = 0;
|
||||
this->vis.envColor.g = 0;
|
||||
this->vis.envColor.b = 0;
|
||||
this->vis.envColor.a = 0;
|
||||
}
|
||||
|
||||
void VisMono_Destroy(VisMono* this) {
|
||||
@@ -95,6 +101,8 @@ Gfx* VisMono_DesaturateDList(VisMono* this, Gfx* gfx) {
|
||||
|
||||
// Set texel 1 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT`
|
||||
// Its position in texture image space is shifted along +S by 1
|
||||
// Note the palette index for this tile has also been incremented from 0 to 1, however the palette index is
|
||||
// ignored for CI8 texture sampling.
|
||||
gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, 1, 1,
|
||||
G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0);
|
||||
gDPSetTileSize(gfx++, 1, 1 << 2, 0, (SCREEN_WIDTH * 2) << 2, (VISMONO_CFBFRAG_HEIGHT - 1) << 2);
|
||||
@@ -129,8 +137,8 @@ Gfx* VisMono_DesaturateDList(VisMono* this, Gfx* gfx) {
|
||||
return gfx;
|
||||
}
|
||||
|
||||
void VisMono_Draw(VisMono* this, Gfx** gfxp) {
|
||||
Gfx* gfx = *gfxp;
|
||||
void VisMono_Draw(VisMono* this, Gfx** gfxP) {
|
||||
Gfx* gfx = *gfxP;
|
||||
u16* tlut;
|
||||
Gfx* dList;
|
||||
Gfx* dListEnd;
|
||||
@@ -159,12 +167,12 @@ void VisMono_Draw(VisMono* this, Gfx** gfxp) {
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
|
||||
if (this->setScissor == true) {
|
||||
if (this->vis.scissorType == VIS_SETSCISSOR) {
|
||||
gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba);
|
||||
gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba);
|
||||
gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba);
|
||||
gDPSetColor(gfx++, G_SETENVCOLOR, this->vis.envColor.rgba);
|
||||
|
||||
gDPLoadTLUT_pal256(gfx++, tlut);
|
||||
|
||||
@@ -172,7 +180,7 @@ void VisMono_Draw(VisMono* this, Gfx** gfxp) {
|
||||
|
||||
gDPPipeSync(gfx++);
|
||||
|
||||
*gfxp = gfx;
|
||||
*gfxP = gfx;
|
||||
}
|
||||
|
||||
void VisMono_DrawOld(VisMono* this) {
|
||||
|
||||
Reference in New Issue
Block a user