From 9b207c356a66aec59815cbbd557f40d48d7cccdd Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Sat, 16 Sep 2023 22:16:58 +0100 Subject: [PATCH] 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 * 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 Co-authored-by: Dragorn421 --- include/functions.h | 41 ++--- include/z64.h | 26 +--- include/z64vis.h | 87 +++++++++++ spec | 4 +- src/code/PreRender.c | 80 +++++----- src/code/code_800ACE70.c | 97 ------------ src/code/code_800AD920.c | 60 -------- src/code/game.c | 101 ++++++------ src/code/graph.c | 8 +- src/code/z_play.c | 10 +- src/code/z_rcp.c | 24 +-- src/code/z_view.c | 6 +- src/code/z_viscvg.c | 145 ++++++++++++++++++ src/code/z_vismono.c | 46 +++--- src/code/z_viszbuf.c | 111 ++++++++++++++ src/overlays/actors/ovl_En_Fz/z_en_fz.h | 4 +- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 30 ++-- src/overlays/gamestates/ovl_title/z_title.c | 14 +- .../misc/ovl_kaleido_scope/z_kaleido_debug.c | 6 +- 19 files changed, 532 insertions(+), 368 deletions(-) create mode 100644 include/z64vis.h delete mode 100644 src/code/code_800ACE70.c delete mode 100644 src/code/code_800AD920.c create mode 100644 src/code/z_viscvg.c create mode 100644 src/code/z_viszbuf.c diff --git a/include/functions.h b/include/functions.h index 8430208a24..73ec1d5c73 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1069,7 +1069,7 @@ void Gfx_SetupDL_37Opa(GraphicsContext* gfxCtx); Gfx* Gfx_SetupDL_39(Gfx* gfx); void Gfx_SetupDL_39Opa(GraphicsContext* gfxCtx); void Gfx_SetupDL_39Overlay(GraphicsContext* gfxCtx); -void Gfx_SetupDL_39Ptr(Gfx** gfxp); +void Gfx_SetupDL_39Ptr(Gfx** gfxP); void Gfx_SetupDL_40Opa(GraphicsContext* gfxCtx); void Gfx_SetupDL_41Opa(GraphicsContext* gfxCtx); void Gfx_SetupDL_47Xlu(GraphicsContext* gfxCtx); @@ -1081,8 +1081,8 @@ void Gfx_SetupDL_42Overlay(GraphicsContext* gfxCtx); void Gfx_SetupDL_27Xlu(GraphicsContext* gfxCtx); void Gfx_SetupDL_60NoCDXlu(GraphicsContext* gfxCtx); void Gfx_SetupDL_61Xlu(GraphicsContext* gfxCtx); -void Gfx_SetupDL_56Ptr(Gfx** gfxp); -Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height); +void Gfx_SetupDL_56Ptr(Gfx** gfxP); +Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height); Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y); Gfx* Gfx_TexScroll(GraphicsContext* gfxCtx, u32 x, u32 y, s32 width, s32 height); Gfx* Gfx_TwoTexScroll(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, @@ -1187,7 +1187,7 @@ void View_Apply(View* view, s32 mask); s32 View_ApplyOrthoToOverlay(View* view); s32 View_ApplyPerspectiveToOverlay(View* view); s32 View_UpdateViewingMatrix(View* view); -s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp); +s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxP); s32 View_ErrorCheckEyePosition(f32 eyeX, f32 eyeY, f32 eyeZ); void ViMode_LogPrint(OSViMode* osViMode); void ViMode_Configure(ViMode* viMode, s32 type, s32 tvType, s32 loRes, s32 antialiasOff, s32 modeN, s32 fb16Bit, @@ -1198,15 +1198,6 @@ void ViMode_Init(ViMode* viMode); void ViMode_Destroy(ViMode* viMode); void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures); void ViMode_Update(ViMode* viMode, Input* input); -void func_800ACE70(struct_801664F0* this); -void func_800ACE90(struct_801664F0* this); -void func_800ACE98(struct_801664F0* this, Gfx** gfxp); -void VisMono_Init(VisMono* this); -void VisMono_Destroy(VisMono* this); -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); void PlayerCall_InitFuncPtrs(void); void TransitionTile_Destroy(TransitionTile* this); TransitionTile* TransitionTile_Init(TransitionTile* this, s32 cols, s32 rows); @@ -1305,15 +1296,15 @@ void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void PreRender_Init(PreRender* this); void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf); void PreRender_Destroy(PreRender* this); -void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a); -void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave); -void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxp); -void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp); -void PreRender_DrawCoverage(PreRender* this, Gfx** gfxp); -void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxp); -void func_800C213C(PreRender* this, Gfx** gfxp); -void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxp); -void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxp); +void func_800C170C(PreRender* this, Gfx** gfxP, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a); +void func_800C1AE8(PreRender* this, Gfx** gfxP, void* fbuf, void* fbufSave); +void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxP); +void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxP); +void PreRender_DrawCoverage(PreRender* this, Gfx** gfxP); +void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxP); +void func_800C213C(PreRender* this, Gfx** gfxP); +void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxP); +void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxP); void PreRender_ApplyFilters(PreRender* this); void AudioMgr_StopAllSfx(void); void func_800C3C80(AudioMgr* audioMgr); @@ -1323,8 +1314,8 @@ void AudioMgr_ThreadEntry(void* arg0); void AudioMgr_Unlock(AudioMgr* audioMgr); void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, Scheduler* sched, IrqMgr* irqMgr); void GameState_FaultPrint(void); -void GameState_SetFBFilter(Gfx** gfx); -void GameState_DrawInputDisplay(u16 input, Gfx** gfx); +void GameState_SetFBFilter(Gfx** gfxP); +void GameState_DrawInputDisplay(u16 input, Gfx** gfxP); void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx); void GameState_SetFrameBuffer(GraphicsContext* gfxCtx); void GameState_ReqPadData(GameState* gameState); @@ -1358,7 +1349,7 @@ void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line); Gfx* Graph_GfxPlusOne(Gfx* gfx); Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst); -void* Graph_DlistAlloc(Gfx** gfx, u32 size); +void* Graph_DlistAlloc(Gfx** gfxP, u32 size); ListAlloc* ListAlloc_Init(ListAlloc* this); void* ListAlloc_Alloc(ListAlloc* this, u32 size); void ListAlloc_Free(ListAlloc* this, void* data); diff --git a/include/z64.h b/include/z64.h index d0032b6ea3..0e76981154 100644 --- a/include/z64.h +++ b/include/z64.h @@ -35,6 +35,7 @@ #include "z64skybox.h" #include "z64sram.h" #include "z64view.h" +#include "z64vis.h" #include "alignment.h" #include "seqcmd.h" #include "sequence.h" @@ -795,29 +796,4 @@ typedef struct { /* 0x84 */ u32 unk_84; } ViMode; // size = 0x88 -// Vis... -typedef struct { - /* 0x00 */ u32 type; - /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8_u32 color; - /* 0x0C */ Color_RGBA8_u32 envColor; -} struct_801664F0; // size = 0x10 - -typedef struct { - /* 0x00 */ u32 unk_00; - /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8_u32 primColor; - /* 0x0C */ Color_RGBA8_u32 envColor; - /* 0x10 */ u16* tlut; - /* 0x14 */ Gfx* dList; -} VisMono; // size = 0x18 - -// Vis... -typedef struct { - /* 0x00 */ u32 useRgba; - /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8_u32 primColor; - /* 0x08 */ Color_RGBA8_u32 envColor; -} struct_80166500; // size = 0x10 - #endif diff --git a/include/z64vis.h b/include/z64vis.h new file mode 100644 index 0000000000..c88d6de483 --- /dev/null +++ b/include/z64vis.h @@ -0,0 +1,87 @@ +#ifndef Z64_VIS_H +#define Z64_VIS_H + +#include "ultra64.h" +#include "color.h" + +typedef enum { + /* 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 { + /* 0 */ VIS_NO_SETSCISSOR, + /* 1 */ VIS_SETSCISSOR +} VisScissorType; + +typedef struct { + /* 0x00 */ u32 type; + /* 0x04 */ u32 scissorType; + /* 0x08 */ Color_RGBA8_u32 primColor; + /* 0x0C */ Color_RGBA8_u32 envColor; +} Vis; // size = 0x10 + + + +/* Cvg: Coverage */ + +#define FB_FILTER_TO_CVG_TYPE(filter) (filter) + +typedef enum { + /* 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 { + /* 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 + +typedef struct { + /* 0x00 */ Vis vis; + /* 0x10 */ u16* tlut; + /* 0x14 */ Gfx* dList; +} VisMono; // size = 0x18 + +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 { + /* 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 { + /* 0x00 */ Vis vis; +} VisZBuf; // size = 0x10 + +void VisZBuf_Init(VisZBuf* this); +void VisZBuf_Destroy(VisZBuf* this); +void VisZBuf_Draw(VisZBuf* this, Gfx** gfxP); + +#endif diff --git a/spec b/spec index 375eb73dc6..f4a3bffc3e 100644 --- a/spec +++ b/spec @@ -366,9 +366,9 @@ beginseg include "build/data/unk_8012ABC0.data.o" include "build/src/code/z_view.o" include "build/src/code/z_vimode.o" - include "build/src/code/code_800ACE70.o" + include "build/src/code/z_viscvg.o" include "build/src/code/z_vismono.o" - include "build/src/code/code_800AD920.o" + include "build/src/code/z_viszbuf.o" include "build/src/code/z_vr_box.o" include "build/src/code/z_vr_box_draw.o" include "build/src/code/z_player_call.o" diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 0a1b0f2cf8..fb40f6e381 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -43,19 +43,19 @@ void PreRender_Destroy(PreRender* this) { /** * Copies RGBA16 image `img` to `imgDst` * - * @param gfxp Display list pointer + * @param gfxP Display list pointer * @param img Image to copy from * @param imgDst Buffer to copy to */ -void PreRender_CopyImage(PreRender* this, Gfx** gfxp, void* img, void* imgDst) { +void PreRender_CopyImage(PreRender* this, Gfx** gfxP, void* img, void* imgDst) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LogUtils_CheckNullPointer("this", this, "../PreRender.c", 215); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 216); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 216); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 218); gDPPipeSync(gfx++); @@ -101,22 +101,22 @@ void PreRender_CopyImage(PreRender* this, Gfx** gfxp, void* img, void* imgDst) { gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxp = gfx; + *gfxP = gfx; } /** * Copies part of `this->fbufSave` in the region (this->ulx, this->uly), (this->lrx, this->lry) to the same location in * `this->fbuf`. */ -void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxp) { +void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxP) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LogUtils_CheckNullPointer("this", this, "../PreRender.c", 278); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 279); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 279); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 281); gDPPipeSync(gfx++); @@ -164,22 +164,22 @@ void PreRender_CopyImageRegionImpl(PreRender* this, Gfx** gfxp) { gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, this->width, this->height); - *gfxp = gfx; + *gfxP = gfx; } /** * Copies `buf` to `bufSave`, discarding the alpha channel and modulating the RGB channel by * the color ('r', 'g', 'b', 'a') */ -void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a) { +void func_800C170C(PreRender* this, Gfx** gfxP, void* buf, void* bufSave, u32 r, u32 g, u32 b, u32 a) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LogUtils_CheckNullPointer("this", this, "../PreRender.c", 343); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 344); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 344); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 346); gDPPipeSync(gfx++); @@ -232,33 +232,33 @@ void func_800C170C(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 r, gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxp = gfx; + *gfxP = gfx; } /** * Copies `fbuf` to `fbufSave`, discarding the alpha channel and leaving the rgb channel unchanged */ -void func_800C1AE8(PreRender* this, Gfx** gfxp, void* fbuf, void* fbufSave) { - func_800C170C(this, gfxp, fbuf, fbufSave, 255, 255, 255, 255); +void func_800C1AE8(PreRender* this, Gfx** gfxP, void* fbuf, void* fbufSave) { + func_800C170C(this, gfxP, fbuf, fbufSave, 255, 255, 255, 255); } /** * Reads the coverage values stored in the RGBA16 format `img` with dimensions `this->width`, `this->height` and * converts it to an 8-bpp intensity image. * - * @param gfxp Display list pointer + * @param gfxP Display list pointer * @param img Image to read coverage from * @param cvgDst Buffer to store coverage into */ -void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxp, void* img, void* cvgDst) { +void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxP, void* img, void* cvgDst) { Gfx* gfx; s32 rowsRemaining; s32 curRow; s32 nRows; LogUtils_CheckNullPointer("this", this, "../PreRender.c", 422); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 423); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 423); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 425); gDPPipeSync(gfx++); @@ -326,30 +326,30 @@ void PreRender_CoverageRgba16ToI8(PreRender* this, Gfx** gfxp, void* img, void* // Reset the color image to the current framebuffer gDPPipeSync(gfx++); gDPSetColorImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, this->width, this->fbuf); - *gfxp = gfx; + *gfxP = gfx; } /** * Saves zbuf to zbufSave */ -void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxp) { +void PreRender_SaveZBuffer(PreRender* this, Gfx** gfxP) { LogUtils_CheckNullPointer("this->zbuf_save", this->zbufSave, "../PreRender.c", 481); LogUtils_CheckNullPointer("this->zbuf", this->zbuf, "../PreRender.c", 482); if ((this->zbufSave != NULL) && (this->zbuf != NULL)) { - PreRender_CopyImage(this, gfxp, this->zbuf, this->zbufSave); + PreRender_CopyImage(this, gfxP, this->zbuf, this->zbufSave); } } /** * Saves fbuf to fbufSave */ -void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp) { +void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxP) { LogUtils_CheckNullPointer("this->fbuf_save", this->fbufSave, "../PreRender.c", 495); LogUtils_CheckNullPointer("this->fbuf", this->fbuf, "../PreRender.c", 496); if ((this->fbufSave != NULL) && (this->fbuf != NULL)) { - func_800C1AE8(this, gfxp, this->fbuf, this->fbufSave); + func_800C1AE8(this, gfxP, this->fbuf, this->fbufSave); } } @@ -357,8 +357,8 @@ void PreRender_SaveFramebuffer(PreRender* this, Gfx** gfxp) { * Fetches the coverage of the current framebuffer into an image of the same format as the current color image, storing * it over the framebuffer in memory. */ -void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) { - Gfx* gfx = *gfxp; +void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxP) { + Gfx* gfx = *gfxP; gDPPipeSync(gfx++); // Set the blend color to full white and set maximum depth. @@ -392,33 +392,33 @@ void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) { gDPFillRectangle(gfx++, 0, 0, this->width, this->height); gDPPipeSync(gfx++); - *gfxp = gfx; + *gfxP = gfx; } /** * Draws the coverage of the current framebuffer `this->fbuf` to an I8 image at `this->cvgSave`. Overwrites * `this->fbuf` in the process. */ -void PreRender_DrawCoverage(PreRender* this, Gfx** gfxp) { - PreRender_FetchFbufCoverage(this, gfxp); +void PreRender_DrawCoverage(PreRender* this, Gfx** gfxP) { + PreRender_FetchFbufCoverage(this, gfxP); LogUtils_CheckNullPointer("this->cvg_save", this->cvgSave, "../PreRender.c", 532); if (this->cvgSave != NULL) { - PreRender_CoverageRgba16ToI8(this, gfxp, this->fbuf, this->cvgSave); + PreRender_CoverageRgba16ToI8(this, gfxP, this->fbuf, this->cvgSave); } } /** * Restores zbufSave to zbuf */ -void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxp) { - PreRender_CopyImage(this, gfxp, this->zbufSave, this->zbuf); +void PreRender_RestoreZBuffer(PreRender* this, Gfx** gfxP) { + PreRender_CopyImage(this, gfxP, this->zbufSave, this->zbuf); } /** * Draws a full-screen image to the current framebuffer, that sources the rgb channel from `this->fbufSave` and * the alpha channel from `this->cvgSave` modulated by environment color. */ -void func_800C213C(PreRender* this, Gfx** gfxp) { +void func_800C213C(PreRender* this, Gfx** gfxP) { Gfx* gfx; s32 rowsRemaining; s32 curRow; @@ -427,8 +427,8 @@ void func_800C213C(PreRender* this, Gfx** gfxp) { if (this->cvgSave != NULL) { LogUtils_CheckNullPointer("this", this, "../PreRender.c", 563); - LogUtils_CheckNullPointer("glistpp", gfxp, "../PreRender.c", 564); - gfx = *gfxp; + LogUtils_CheckNullPointer("glistpp", gfxP, "../PreRender.c", 564); + gfx = *gfxP; LogUtils_CheckNullPointer("glistp", gfx, "../PreRender.c", 566); gDPPipeSync(gfx++); @@ -482,23 +482,23 @@ void func_800C213C(PreRender* this, Gfx** gfxp) { } gDPPipeSync(gfx++); - *gfxp = gfx; + *gfxP = gfx; } } /** * Copies fbufSave to fbuf */ -void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxp) { - PreRender_CopyImage(this, gfxp, this->fbufSave, this->fbuf); +void PreRender_RestoreFramebuffer(PreRender* this, Gfx** gfxP) { + PreRender_CopyImage(this, gfxP, this->fbufSave, this->fbuf); } /** * Copies part of `this->fbufSave` in the region (this->ulx, this->uly), (this->lrx, this->lry) to the same location in * `this->fbuf`. */ -void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxp) { - PreRender_CopyImageRegionImpl(this, gfxp); +void PreRender_CopyImageRegion(PreRender* this, Gfx** gfxP) { + PreRender_CopyImageRegionImpl(this, gfxP); } /** diff --git a/src/code/code_800ACE70.c b/src/code/code_800ACE70.c deleted file mode 100644 index a7252904d8..0000000000 --- a/src/code/code_800ACE70.c +++ /dev/null @@ -1,97 +0,0 @@ -#include "global.h" - -// Note : This file is related to z_vismono, the original name was probably z_vis - -Gfx D_8012AC00[] = { - 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: - 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; -} diff --git a/src/code/code_800AD920.c b/src/code/code_800AD920.c deleted file mode 100644 index 94479e164a..0000000000 --- a/src/code/code_800AD920.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "global.h" - -// Note : This file is related to z_vismono, the original name was probably z_vis - -// 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; - this->envColor.a = 255; - this->envColor.r = 0; - this->envColor.g = 0; - this->envColor.b = 0; -} - -// Destroy -void func_800AD950(struct_80166500* this) { -} - -// Draw -void func_800AD958(struct_80166500* this, Gfx** gfxp) { - Gfx* gfx = *gfxp; - 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; -} diff --git a/src/code/game.c b/src/code/game.c index 10fdcbefd9..183a18b46e 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -2,9 +2,9 @@ #include "terminal.h" SpeedMeter D_801664D0; -struct_801664F0 D_801664F0; -struct_80166500 D_80166500; -VisMono sMonoColors; +VisCvg sVisCvg; +VisZBuf sVisZBuf; +VisMono sVisMono; ViMode sViMode; FaultClient sGameFaultClient; u16 sLastButtonPressed; @@ -22,40 +22,43 @@ void GameState_FaultPrint(void) { } } -void GameState_SetFBFilter(Gfx** gfx) { - Gfx* gfxP = *gfx; +void GameState_SetFBFilter(Gfx** gfxP) { + Gfx* gfx = *gfxP; - 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, &gfxP); - } 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, &gfxP); - } 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, &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); } - *gfx = gfxP; + *gfxP = gfx; } void func_800C4344(GameState* gameState) { @@ -110,7 +113,7 @@ void func_800C4344(GameState* gameState) { } } -void GameState_DrawInputDisplay(u16 input, Gfx** gfx) { +void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) { static const u16 sInpDispBtnColors[] = { GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(120, 120, 120, 1), GPACK_RGBA5551(120, 120, 120, 1), @@ -120,10 +123,10 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfx) { GPACK_RGBA5551(0, 0, 255, 1), }; s32 i, j, k; - Gfx* gfxP = *gfx; + Gfx* gfx = *gfxP; - gDPPipeSync(gfxP++); - gDPSetOtherMode(gfxP++, + gDPPipeSync(gfx++); + gDPSetOtherMode(gfx++, 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_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); @@ -131,14 +134,14 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfx) { for (i = 0; i < 16; i++) { j = i; if (input & (1 << i)) { - gDPSetFillColor(gfxP++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]); + gDPSetFillColor(gfx++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]); k = i + 1; - gDPFillRectangle(gfxP++, (j * 4) + 226, 220, (k * 4) + 225, 223); - gDPPipeSync(gfxP++); + gDPFillRectangle(gfx++, (j * 4) + 226, 220, (k * 4) + 225, 223); + gDPPipeSync(gfx++); } } - *gfx = gfxP; + *gfxP = gfx; } void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { @@ -413,9 +416,9 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g startTime = endTime; LogUtils_CheckNullPointer("this->cleanup", gameState->destroy, "../game.c", 1088); - func_800ACE70(&D_801664F0); - func_800AD920(&D_80166500); - VisMono_Init(&sMonoColors); + VisCvg_Init(&sVisCvg); + VisZBuf_Init(&sVisZBuf); + VisMono_Init(&sVisMono); if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) { ViMode_Init(&sViMode); } @@ -443,9 +446,9 @@ void GameState_Destroy(GameState* gameState) { } Rumble_Destroy(); SpeedMeter_Destroy(&D_801664D0); - func_800ACE90(&D_801664F0); - func_800AD950(&D_80166500); - VisMono_Destroy(&sMonoColors); + VisCvg_Destroy(&sVisCvg); + VisZBuf_Destroy(&sVisZBuf); + VisMono_Destroy(&sVisMono); if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) { ViMode_Destroy(&sViMode); } diff --git a/src/code/graph.c b/src/code/graph.c index 3d53f891cb..fd79efac5c 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -513,17 +513,17 @@ Gfx* Graph_BranchDlist(Gfx* gfx, Gfx* dst) { return dst; } -void* Graph_DlistAlloc(Gfx** gfx, u32 size) { +void* Graph_DlistAlloc(Gfx** gfxP, u32 size) { u8* ptr; Gfx* dst; size = ALIGN8(size); - ptr = (u8*)(*gfx + 1); + ptr = (u8*)(*gfxP + 1); dst = (Gfx*)(ptr + size); - gSPBranchList(*gfx, dst); + gSPBranchList(*gfxP, dst); - *gfx = dst; + *gfxP = dst; return ptr; } diff --git a/src/code/z_play.c b/src/code/z_play.c index c1840037e1..c4d8915484 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -8,7 +8,7 @@ Input* D_8012D1F8 = NULL; TransitionTile sTransitionTile; s32 gTransitionTileState; -VisMono D_80161498; +VisMono sPlayVisMono; Color_RGBA8_u32 gVisMonoColor; FaultClient D_801614B8; s16 sTransitionFillTimer; @@ -199,7 +199,7 @@ void Play_Destroy(GameState* thisx) { Letterbox_Destroy(); TransitionFade_Destroy(&this->transitionFadeFlash); - VisMono_Destroy(&D_80161498); + VisMono_Destroy(&sPlayVisMono); if (gSaveContext.save.linkAge != this->linkAgeOnLoad) { Inventory_SwapAgeEquipment(); @@ -390,7 +390,7 @@ void Play_Init(GameState* thisx) { TransitionFade_SetType(&this->transitionFadeFlash, TRANS_INSTANCE_TYPE_FADE_FLASH); TransitionFade_SetColor(&this->transitionFadeFlash, RGBA8(160, 160, 160, 255)); TransitionFade_Start(&this->transitionFadeFlash); - VisMono_Init(&D_80161498); + VisMono_Init(&sPlayVisMono); gVisMonoColor.a = 0; CutsceneFlags_UnsetAll(this); @@ -1103,8 +1103,8 @@ void Play_Draw(PlayState* this) { TransitionFade_Draw(&this->transitionFadeFlash, &gfxP); if (gVisMonoColor.a > 0) { - D_80161498.primColor.rgba = gVisMonoColor.rgba; - VisMono_Draw(&D_80161498, &gfxP); + sPlayVisMono.vis.primColor.rgba = gVisMonoColor.rgba; + VisMono_Draw(&sPlayVisMono, &gfxP); } gSPEndDisplayList(gfxP++); diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index aa4d56998e..3b9a850986 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -907,8 +907,8 @@ Gfx* Gfx_SetupDL(Gfx* gfx, u32 i) { return Gfx_SetupDLImpl(gfx, i); } -void Gfx_SetupDLAtPtr(Gfx** gfxp, u32 i) { - *gfxp = Gfx_SetupDL(*gfxp, i); +void Gfx_SetupDLAtPtr(Gfx** gfxP, u32 i) { + *gfxP = Gfx_SetupDL(*gfxP, i); } Gfx* Gfx_SetupDL_57(Gfx* gfx) { @@ -1193,11 +1193,11 @@ void Gfx_SetupDL_39Overlay(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_rcp.c", 1811); } -void Gfx_SetupDL_39Ptr(Gfx** gfxp) { - Gfx* gfx = *gfxp; +void Gfx_SetupDL_39Ptr(Gfx** gfxP) { + Gfx* gfx = *gfxP; gSPDisplayList(gfx++, sSetupDL[SETUPDL_39]); - *gfxp = gfx; + *gfxP = gfx; } void Gfx_SetupDL_40Opa(GraphicsContext* gfxCtx) { @@ -1345,12 +1345,12 @@ void Gfx_SetupDL_56Opa(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_rcp.c", 2090); } -void Gfx_SetupDL_56Ptr(Gfx** gfxp) { - Gfx* gfx = *gfxp; +void Gfx_SetupDL_56Ptr(Gfx** gfxP) { + Gfx* gfx = *gfxP; gSPDisplayList(gfx++, sSetupDL[SETUPDL_56]); - *gfxp = gfx; + *gfxP = gfx; } void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) { @@ -1361,8 +1361,8 @@ void Gfx_SetupDL_59Opa(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_rcp.c", 2116); } -Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); +Gfx* Gfx_BranchTexScroll(Gfx** gfxP, u32 x, u32 y, s32 width, s32 height) { + Gfx* displayList = Graph_DlistAlloc(gfxP, 3 * sizeof(Gfx)); gDPTileSync(displayList); gDPSetTileSize(displayList + 1, G_TX_RENDERTILE, x, y, x + ((width - 1) << 2), y + ((height - 1) << 2)); @@ -1371,8 +1371,8 @@ Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { return displayList; } -Gfx* func_80094E54(Gfx** gfxp, u32 x, u32 y) { - return Gfx_BranchTexScroll(gfxp, x, y, 0, 0); +Gfx* func_80094E54(Gfx** gfxP, u32 x, u32 y) { + return Gfx_BranchTexScroll(gfxP, x, y, 0, 0); } Gfx* func_80094E78(GraphicsContext* gfxCtx, u32 x, u32 y) { diff --git a/src/code/z_view.c b/src/code/z_view.c index 3284411508..117957d1ba 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -539,8 +539,8 @@ s32 View_UpdateViewingMatrix(View* view) { return 1; } -s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp) { - Gfx* gfx = *gfxp; +s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxP) { + Gfx* gfx = *gfxP; GraphicsContext* gfxCtx = view->gfxCtx; s32 width; s32 height; @@ -606,7 +606,7 @@ s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp) { } view->flags = 0; - *gfxp = gfx; + *gfxP = gfx; return 1; } diff --git a/src/code/z_viscvg.c b/src/code/z_viscvg.c new file mode 100644 index 0000000000..9caf39a3f8 --- /dev/null +++ b/src/code/z_viscvg.c @@ -0,0 +1,145 @@ +/** + * @file z_viscvg.c + * + * This file implements full-screen frame buffer effects involving the visualization of Coverage in various ways. + * + * Coverage is roughly how much of a pixel is covered by a primitive; the final coverage for a frame is stored in the + * color image alpha component where it is used for antialiasing, see PreRender.c and ยง15 of the programming manual for + * details. + * + * To understand this file, it is helpful to remember that A_MEM is essentially synonymous with coverage, and that + * `GBL_c1/2(p, a, m, b)` usually represents the RDP blender calculation `(p * a + m * b)`. + * Note the division step that is often included in the blender calculation is omitted; the division is skipped if + * force blending (FORCE_BL) is set, which is the case for all render modes used in this file. + * + * Coverage is full when not on an edge, while on an edge it is usually lower. Since coverage is treated as an alpha + * value, edges of primitives where coverage is lower will show up darker than primitive interiors in all of the + * available modes. + * + * Coverage is abbreviated to "cvg"; "FB RGB" ("framebuffer red/green/blue") is the color the pixel originally had + * before the filter is applied. + */ + +#include "global.h" + +/** + * Draws only coverage: does not retain any of the original pixel RGB, primColor is used as background color. + */ +Gfx sCoverageOnlyDL[] = { + 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), + // (blendColor RGB) * (cvg) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + gsDPPipeSync(), + gsDPSetBlendColor(0, 0, 0, 8), + gsSPEndDisplayList(), +}; + +/** + * Draws fog + coverage * RGB of pixels + * + * @bug This easily overflows the blender because the fog value is added to the coverage value. + */ +Gfx sCoverageRGBFogDL[] = { + 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)), + // (fog RGB) * (fog alpha) + (FB RGB) * (cvg) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + gsSPEndDisplayList(), +}; + +/** + * Draws coverage and RGB of pixels + */ +Gfx sCoverageRGBDL[] = { + 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)), + // (FB RGB) * (cvg) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + gsSPEndDisplayList(), +}; + +/** + * Two stage filtering: + * + * 1. Apply a uniform color filter by transparently blending primColor with original frame. The "cloud surface" + * RenderMode is used to preserve the coverage for the second stage. + * 2. Second half is the same as `sCoverageRGBDL`'s, i.e. (RGB from stage 1) * cvg + */ +Gfx sCoverageRGBUniformDL[] = { + 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), + // stage 1 color = (primColor RGB) * (primColor Alpha) + (FB RGB) * (1 - primColor Alpha) + 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)), + // final color = (stage 1 RGB) * (cvg) + gsDPFillRectangle(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), + gsSPEndDisplayList(), +}; + +void VisCvg_Init(VisCvg* this) { + this->vis.type = FB_FILTER_NONE; + 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; +} + +void VisCvg_Destroy(VisCvg* this) { +} + +void VisCvg_Draw(VisCvg* this, Gfx** gfxP) { + Gfx* gfx = *gfxP; + + gDPPipeSync(gfx++); + gDPSetPrimDepth(gfx++, 0xFFFF, 0xFFFF); + + if (this->vis.scissorType == VIS_SETSCISSOR) { + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } + + switch (this->vis.type) { + case FB_FILTER_CVG_RGB: + gSPDisplayList(gfx++, sCoverageRGBDL); + break; + + case FB_FILTER_CVG_RGB_UNIFORM: + // Set primitive color for uniform color filter in custom RenderMode + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba); + gSPDisplayList(gfx++, sCoverageRGBUniformDL); + break; + + case FB_FILTER_CVG_ONLY: + // Set background color for G_RM_VISCVG + gDPSetColor(gfx++, G_SETBLENDCOLOR, this->vis.primColor.rgba); + gSPDisplayList(gfx++, sCoverageOnlyDL); + break; + + case FB_FILTER_CVG_RGB_FOG: + // Set fog color for custom RenderMode, needs to be close to 0 to not overflow + gDPSetColor(gfx++, G_SETFOGCOLOR, this->vis.primColor.rgba); + gSPDisplayList(gfx++, sCoverageRGBFogDL); + break; + + default: + break; + } + + gDPPipeSync(gfx++); + *gfxP = gfx; +} diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index de065988e9..8f0a5653f4 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -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) { diff --git a/src/code/z_viszbuf.c b/src/code/z_viszbuf.c new file mode 100644 index 0000000000..90080b79cf --- /dev/null +++ b/src/code/z_viszbuf.c @@ -0,0 +1,111 @@ +/** + * @file z_viszbuf.c + * + * This file implements a full-screen framebuffer effect for visualizing the z-buffer (AKA depth buffer), using either + * cycling RGBA or a single fading color. + * + * This is done by reading the z-buffer as if it were a color image, the format of which is specified by the selected + * vis type: + * - VIS_ZBUF_TYPE_IA : Produces a monotonic fade from primColor to envColor as depth increases. + * - VIS_ZBUF_TYPE_RGBA : Produces vibrant almost-periodic-looking bands. + * + * In both cases this occurs because of the format the depth information takes: it is 18-bit, and is a nonnegative + * floating-point number with + * bbb mmmmmmmmmmm dd|dd + * exponent mantissa dz value (only first 16 bits visible to CPU, the least significant 2 bits of dz are ignored) + * + * Reading z-buffer as IA16: + * bbbmmmmm mmmmmmdd + * iiiiiiii aaaaaaaa + * + * Since floating-point numbers of this format have the same ordering as their binary/hex representation, increasing + * the depth also increases the intensity in the IA16 representation and hence the interpolation parameter used to + * combine primColor and envColor. The alpha is ignored by the RenderMode. + * + * Reading z-buffer as RGBA16: + * bbbmm mmmmm mmmmd d + * rrrrr ggggg bbbbb a + * + * The red increases monotonically with the depth. The significant visible oscillation is the green component, because + * it rolls over every time the second-most-significant bit of the mantissa increments. The blue component oscillates + * too rapidly to be particularly visible (it rolls over when the 7th-most-significant bit increments). The alpha is + * again ignored by the RenderMode. + */ + +#include "global.h" + +// Height of the fragments the z-buffer is split into. +// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into TMEM. +#define VISZBUF_ZBUFFRAG_HEIGHT (TMEM_SIZE / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES)) + +// z-buffer +extern u16 D_0E000000[]; + +/** + * Initialise to IA type with white and black as default colors. + */ +void VisZBuf_Init(VisZBuf* this) { + this->vis.type = VIS_ZBUF_TYPE_IA; + 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.a = 255; + this->vis.envColor.r = 0; + this->vis.envColor.g = 0; + this->vis.envColor.b = 0; +} + +void VisZBuf_Destroy(VisZBuf* this) { +} + +void VisZBuf_Draw(VisZBuf* this, Gfx** gfxP) { + Gfx* gfx = *gfxP; + u16* zbufFrag = D_0E000000; + s32 fmt; + s32 y; + s32 height; + + if (this->vis.type == VIS_ZBUF_TYPE_IA) { + fmt = G_IM_FMT_IA; + } else { // VIS_ZBUF_TYPE_RGBA + fmt = G_IM_FMT_RGBA; + } + + height = VISZBUF_ZBUFFRAG_HEIGHT; + + gDPPipeSync(gfx++); + // Scissoring is only required if the scissor has not been set prior. + if (this->vis.scissorType == VIS_SETSCISSOR) { + gDPSetScissor(gfx++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } + + // No palette so can use all of TMEM. + // G_RM_OPA_SURF discards all information previously in the pixel, and the current alpha, leaving only the color + // from this filter. + 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); + + // LERP between primColor and envColor in 1-cycle mode using the z-buffer value. + gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT); + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->vis.primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, this->vis.envColor.rgba); + + for (y = 0; y <= SCREEN_HEIGHT - height; y += height) { + // Load a few lines of the z-buffer, as many as can fit in TMEM at once. + gDPLoadTextureBlock(gfx++, zbufFrag, 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); + + // Overwrite them with the calculated colors. + gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); + zbufFrag += SCREEN_WIDTH * height; + } + + gDPPipeSync(gfx++); + *gfxP = gfx; +} diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 5c54720f2d..dafada3d25 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -16,7 +16,7 @@ typedef struct { /* 0x0010 */ Vec3f velocity; /* 0x001C */ Vec3f accel; /* 0x0028 */ char unk_28[0x4]; - /* 0x002C */ s16 primAlpha; // transparency in RGBA colour system + /* 0x002C */ s16 primAlpha; // transparency in RGBA color system /* 0x002E */ s16 primAlphaState; // 0: increasing (more opaque) 1: decreasing (more transparent) 2: collision /* 0x0030 */ f32 xyScale; /* 0x0034 */ f32 xyScaleTarget; @@ -42,7 +42,7 @@ typedef struct EnFz { /* 0x024C */ f32 iceSmokeFreezingSpawnHeight; // Height for Ice Smoke Spawn, only when freezing /* 0x0250 */ f32 unusedFloat; // Set to 135.0f /* 0x0254 */ f32 speedXZ; // Set to 4.0f when moving - /* 0x0258 */ u32 envAlpha; // transparency in RGBA colour system + /* 0x0258 */ u32 envAlpha; // transparency in RGBA color system /* 0x025C */ u16 unusedNum1; // Only set to 0 /* 0x025E */ u16 unusedNum2; // Set to either 0 when hidden or 4000 when growing /* 0x0260 */ u8 state; // 0 (hidden) 1 (growning/shrinking) 2 (full size) 3 (melting from fire) diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 60b1867d63..164252b17b 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -262,9 +262,9 @@ void EnMag_Update(Actor* thisx, PlayState* play) { } } -void EnMag_DrawTextureI8(Gfx** gfxp, void* texture, s16 texWidth, s16 texHeight, s16 rectLeft, s16 rectTop, +void EnMag_DrawTextureI8(Gfx** gfxP, void* texture, s16 texWidth, s16 texHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy) { - Gfx* gfx = *gfxp; + Gfx* gfx = *gfxP; gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_I, G_IM_SIZ_8b, texWidth, texHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -272,13 +272,13 @@ void EnMag_DrawTextureI8(Gfx** gfxp, void* texture, s16 texWidth, s16 texHeight, gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - *gfxp = gfx; + *gfxP = gfx; } -void EnMag_DrawEffectTextures(Gfx** gfxp, void* maskTex, void* effectTex, s16 maskWidth, s16 maskHeight, +void EnMag_DrawEffectTextures(Gfx** gfxP, void* maskTex, void* effectTex, s16 maskWidth, s16 maskHeight, s16 effectWidth, s16 effectHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, u16 shifts, u16 shiftt, u16 flag, EnMag* this) { - Gfx* gfx = *gfxp; + Gfx* gfx = *gfxP; gDPLoadMultiBlock_4b(gfx++, maskTex, 0x0000, G_TX_RENDERTILE, G_IM_FMT_I, maskWidth, maskHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, @@ -294,11 +294,11 @@ void EnMag_DrawEffectTextures(Gfx** gfxp, void* maskTex, void* effectTex, s16 ma gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); - *gfxp = gfx; + *gfxP = gfx; } -void EnMag_DrawImageRGBA32(Gfx** gfxp, s16 centerX, s16 centerY, u8* source, u32 width, u32 height) { - Gfx* gfx = *gfxp; +void EnMag_DrawImageRGBA32(Gfx** gfxP, s16 centerX, s16 centerY, u8* source, u32 width, u32 height) { + Gfx* gfx = *gfxP; u8* curTexture; s32 textureCount; u32 rectLeft; @@ -353,11 +353,11 @@ void EnMag_DrawImageRGBA32(Gfx** gfxp, s16 centerX, s16 centerY, u8* source, u32 } } - *gfxp = gfx; + *gfxP = gfx; } -void EnMag_DrawCharTexture(Gfx** gfxp, u8* texture, s32 rectLeft, s32 rectTop) { - Gfx* gfx = *gfxp; +void EnMag_DrawCharTexture(Gfx** gfxP, u8* texture, s32 rectLeft, s32 rectTop) { + Gfx* gfx = *gfxP; YREG(0) = 1024.0f / (YREG(1) / 100.0f); YREG(2) = 16.0f * (YREG(1) / 100.0f); @@ -368,10 +368,10 @@ void EnMag_DrawCharTexture(Gfx** gfxp, u8* texture, s32 rectLeft, s32 rectTop) { gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + YREG(2)) << 2, (rectTop + YREG(2)) << 2, G_TX_RENDERTILE, 0, 0, YREG(0), YREG(0)); - *gfxp = gfx; + *gfxP = gfx; } -void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { +void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxP) { static s16 textAlpha = 0; static s16 textFadeDirection = 0; static s16 textFadeTimer = 0; @@ -389,7 +389,7 @@ void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { EnMag* this = (EnMag*)thisx; Font* font = &this->font; s32 pad; - Gfx* gfx = *gfxp; + Gfx* gfx = *gfxP; u16 i, j, k; u16 rectLeft; u16 rectTop; @@ -559,7 +559,7 @@ void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { } } - *gfxp = gfx; + *gfxP = gfx; } void EnMag_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 30bb737d66..1849b253d6 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -8,15 +8,15 @@ #include "alloca.h" #include "assets/textures/nintendo_rogo_static/nintendo_rogo_static.h" -void ConsoleLogo_PrintBuildInfo(Gfx** gfxp) { - Gfx* g; +void ConsoleLogo_PrintBuildInfo(Gfx** gfxP) { + Gfx* gfx; GfxPrint* printer; - g = *gfxp; - g = Gfx_SetupDL_28(g); + gfx = *gfxP; + gfx = Gfx_SetupDL_28(gfx); printer = alloca(sizeof(GfxPrint)); GfxPrint_Init(printer); - GfxPrint_Open(printer, g); + GfxPrint_Open(printer, gfx); GfxPrint_SetColor(printer, 255, 155, 255, 255); GfxPrint_SetPos(printer, 9, 21); GfxPrint_Printf(printer, "NOT MARIO CLUB VERSION"); @@ -25,9 +25,9 @@ void ConsoleLogo_PrintBuildInfo(Gfx** gfxp) { GfxPrint_Printf(printer, "[Creator:%s]", gBuildTeam); GfxPrint_SetPos(printer, 7, 24); GfxPrint_Printf(printer, "[Date:%s]", gBuildDate); - g = GfxPrint_Close(printer); + gfx = GfxPrint_Close(printer); GfxPrint_Destroy(printer); - *gfxp = g; + *gfxP = gfx; } // Note: In other rom versions this function also updates unk_1D4, coverAlpha, addAlpha, visibleDuration to calculate diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c index 170b5860b6..90c740027e 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c @@ -34,12 +34,12 @@ static s16 sSlotItems[] = { ITEM_BOOMERANG, ITEM_LENS_OF_TRUTH, ITEM_MAGIC_BEAN, ITEM_HAMMER, ITEM_ARROW_LIGHT, ITEM_NAYRUS_LOVE, }; -void KaleidoScope_DrawDebugEditorText(Gfx** gfxp) { +void KaleidoScope_DrawDebugEditorText(Gfx** gfxP) { GfxPrint printer; s32 pad[2]; GfxPrint_Init(&printer); - GfxPrint_Open(&printer, *gfxp); + GfxPrint_Open(&printer, *gfxP); GfxPrint_SetPos(&printer, 4, 2); GfxPrint_SetColor(&printer, 255, 60, 0, 255); @@ -75,7 +75,7 @@ void KaleidoScope_DrawDebugEditorText(Gfx** gfxp) { GfxPrint_SetPos(&printer, 28, 24); GfxPrint_Printf(&printer, "%s", "/4"); - *gfxp = GfxPrint_Close(&printer); + *gfxP = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); }