summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Hensley <hensley.derek58@gmail.com>2023-04-18 09:42:08 -0700
committerGitHub <noreply@github.com>2023-04-18 12:42:08 -0400
commit8efba39749a90191d03ec4a046cb11d6ac9d2198 (patch)
treec31ccbbae2f478741042d7df824f5d506d70e802
parent255c4599bf847013d323d7ec7b6db81c072bdd1b (diff)
z_viszbuf (code_801420C0) OK (#1211)
* first pass * Match * variables.txt * Update include/functions.h Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com> --------- Co-authored-by: angie <angheloalf95@gmail.com>
-rw-r--r--include/functions.h9
-rw-r--r--include/variables.h2
-rw-r--r--include/z64.h6
-rw-r--r--spec2
-rw-r--r--src/code/code_801420C0.c7
-rw-r--r--src/code/game.c58
-rw-r--r--src/code/z_viszbuf.c56
-rw-r--r--tools/disasm/files.txt2
-rw-r--r--tools/disasm/functions.txt6
-rw-r--r--tools/disasm/variables.txt2
-rw-r--r--tools/sizes/code_functions.csv6
11 files changed, 101 insertions, 55 deletions
diff --git a/include/functions.h b/include/functions.h
index f87ec4ff6..aff5ae5a1 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -2133,9 +2133,10 @@ void VisMono_Destroy(VisMono* this);
// void VisMono_DesaturateDList(Gfx* gfx);
void VisMono_Draw(VisMono* this, Gfx** gfxp);
// void VisMono_DrawOld(VisMono* this);
-void func_801420C0(void* arg0);
-void func_801420F4(void* arg0);
-void func_80142100(void* arg0, Gfx** gfx, u32 arg2);
+
+void VisZbuf_Init(VisZbuf* this);
+void VisZbuf_Destroy(VisZbuf* this);
+void VisZbuf_Draw(VisZbuf* this, Gfx** gfxP, void* zbuffer);
// void func_80147520(void);
void func_80147564(PlayState* play);
@@ -2374,7 +2375,7 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon
void Game_UpdateFramerateVariables(s32 divisor);
void Game_SetFramerateDivisor(GameState* gameState, s32 divisor);
-void GameState_SetFBFilter(Gfx** gfx, u32 arg1);
+void GameState_SetFBFilter(Gfx** gfx, void* zbuffer);
void Game_Nop80173534(GameState* gameState);
void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx);
void GameState_SetFrameBuffer(GraphicsContext* gfxCtx);
diff --git a/include/variables.h b/include/variables.h
index 745c019a8..90063b774 100644
--- a/include/variables.h
+++ b/include/variables.h
@@ -2440,7 +2440,7 @@ extern u8 sMotionBlurStatus;
extern UNK_TYPE1 D_801F7FF0;
extern struct_801F8010 D_801F8010;
-extern struct_801F8020 D_801F8020;
+extern VisZbuf sVisZbuf;
extern VisMono sMonoColors;
extern UNK_TYPE1 D_801F8048;
extern FaultAddrConvClient sGraphFaultAddrConvClient;
diff --git a/include/z64.h b/include/z64.h
index b91333288..331077723 100644
--- a/include/z64.h
+++ b/include/z64.h
@@ -755,9 +755,9 @@ typedef struct {
typedef struct {
/* 0x0 */ u32 useRgba;
/* 0x4 */ u32 setScissor;
- /* 0x8 */ Color_RGBA8 primColor;
- /* 0xC */ Color_RGBA8 envColor;
-} struct_801F8020; // size = 0x10
+ /* 0x8 */ Color_RGBA8_u32 primColor;
+ /* 0xC */ Color_RGBA8_u32 envColor;
+} VisZbuf; // size = 0x10
typedef struct {
/* 0x00 */ u32 unk_00;
diff --git a/spec b/spec
index dcf76f66b..417609b6f 100644
--- a/spec
+++ b/spec
@@ -527,7 +527,7 @@ beginseg
include "build/data/code/code_80140CE0.data.o"
include "build/src/code/code_80140E80.o"
include "build/src/code/z_vismono.o"
- include "build/src/code/code_801420C0.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_sram_NES.o"
diff --git a/src/code/code_801420C0.c b/src/code/code_801420C0.c
deleted file mode 100644
index 63c96571e..000000000
--- a/src/code/code_801420C0.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "global.h"
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_801420C0/func_801420C0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_801420C0/func_801420F4.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_801420C0/func_80142100.s")
diff --git a/src/code/game.c b/src/code/game.c
index 4a4be5291..3ff4f9962 100644
--- a/src/code/game.c
+++ b/src/code/game.c
@@ -22,7 +22,7 @@ void Game_SetFramerateDivisor(GameState* gameState, s32 divisor) {
Game_UpdateFramerateVariables(divisor);
}
-void GameState_SetFBFilter(Gfx** gfx, u32 arg1) {
+void GameState_SetFBFilter(Gfx** gfx, void* zbuffer) {
Gfx* dlist = *gfx;
if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) {
@@ -31,33 +31,29 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) {
D_801F8010.color.g = R_FB_FILTER_PRIM_COLOR(1);
D_801F8010.color.b = R_FB_FILTER_PRIM_COLOR(2);
D_801F8010.color.a = R_FB_FILTER_A;
- func_80140D10(&D_801F8010, &dlist, arg1);
- } else {
- if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) {
- D_801F8020.useRgba = (R_FB_FILTER_TYPE == 6);
- D_801F8020.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
- D_801F8020.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
- D_801F8020.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
- D_801F8020.primColor.a = R_FB_FILTER_A;
- D_801F8020.envColor.r = R_FB_FILTER_ENV_COLOR(0);
- D_801F8020.envColor.g = R_FB_FILTER_ENV_COLOR(1);
- D_801F8020.envColor.b = R_FB_FILTER_ENV_COLOR(2);
- D_801F8020.envColor.a = R_FB_FILTER_A;
- func_80142100(&D_801F8020, &dlist, arg1);
- } 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, &dlist);
- }
- }
+ func_80140D10(&D_801F8010, &dlist, zbuffer);
+ } else if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) {
+ sVisZbuf.useRgba = (R_FB_FILTER_TYPE == 6);
+ sVisZbuf.primColor.r = R_FB_FILTER_PRIM_COLOR(0);
+ sVisZbuf.primColor.g = R_FB_FILTER_PRIM_COLOR(1);
+ sVisZbuf.primColor.b = R_FB_FILTER_PRIM_COLOR(2);
+ sVisZbuf.primColor.a = R_FB_FILTER_A;
+ sVisZbuf.envColor.r = R_FB_FILTER_ENV_COLOR(0);
+ sVisZbuf.envColor.g = R_FB_FILTER_ENV_COLOR(1);
+ sVisZbuf.envColor.b = R_FB_FILTER_ENV_COLOR(2);
+ sVisZbuf.envColor.a = R_FB_FILTER_A;
+ VisZbuf_Draw(&sVisZbuf, &dlist, zbuffer);
+ } 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, &dlist);
}
*gfx = dlist;
@@ -76,7 +72,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
gSPDisplayList(OVERLAY_DISP++, nextDisplayList);
if (R_FB_FILTER_TYPE && R_FB_FILTER_ENV_COLOR(3) == 0) {
- GameState_SetFBFilter(&nextDisplayList, (u32)gfxCtx->zbuffer);
+ GameState_SetFBFilter(&nextDisplayList, gfxCtx->zbuffer);
}
if (R_ENABLE_ARENA_DBG < 0) {
@@ -215,7 +211,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
init(gameState);
func_80140CE0(&D_801F8010);
- func_801420C0(&D_801F8020);
+ VisZbuf_Init(&sVisZbuf);
VisMono_Init(&sMonoColors);
func_80140898(&D_801F8048);
func_801773A0(&D_801F7FF0);
@@ -237,7 +233,7 @@ void GameState_Destroy(GameState* gameState) {
Rumble_Destroy();
func_801773C4(&D_801F7FF0);
func_80140D04(&D_801F8010);
- func_801420F4(&D_801F8020);
+ VisZbuf_Destroy(&sVisZbuf);
VisMono_Destroy(&sMonoColors);
func_80140900(&D_801F8048);
THA_Destroy(&gameState->heap);
diff --git a/src/code/z_viszbuf.c b/src/code/z_viszbuf.c
new file mode 100644
index 000000000..9970a1e1b
--- /dev/null
+++ b/src/code/z_viszbuf.c
@@ -0,0 +1,56 @@
+#include "global.h"
+
+#define VISZBUF_ZBUFFRAG_HEIGHT (TMEM_SIZE / (D_801FBBCC * G_IM_SIZ_16b_BYTES))
+
+void VisZbuf_Init(VisZbuf* 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.r = 0;
+ this->envColor.g = 0;
+ this->envColor.b = 0;
+ this->envColor.a = 255;
+}
+
+void VisZbuf_Destroy(VisZbuf* this) {
+}
+
+void VisZbuf_Draw(VisZbuf* this, Gfx** gfxP, void* zbuffer) {
+ Gfx* gfx = *gfxP;
+ s32 height = VISZBUF_ZBUFFRAG_HEIGHT;
+ s32 y;
+ s32 fmt = !this->useRgba ? G_IM_FMT_IA : G_IM_FMT_RGBA;
+
+ if (zbuffer == NULL) {
+ return;
+ }
+
+ gDPPipeSync(gfx++);
+ if (this->setScissor == true) {
+ gSPDisplayList(gfx++, D_0E000000.setScissor);
+ }
+
+ 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 < (D_801FBBCE - height) + 1; y += height) {
+ gDPLoadTextureTile(gfx++, zbuffer, fmt, G_IM_SIZ_16b, D_801FBBCC, 0, 0, y, D_801FBBCC - 1, (y + height) - 1, 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, D_801FBBCC << 2, (y + height) << 2, G_TX_RENDERTILE, 0, y << 5, 1 << 10,
+ 1 << 10);
+ }
+
+ gDPPipeSync(gfx++);
+ *gfxP = gfx;
+}
diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt
index 81701e140..372557384 100644
--- a/tools/disasm/files.txt
+++ b/tools/disasm/files.txt
@@ -431,7 +431,7 @@
0x80140CE0 : "code_80140CE0",
0x80140E80 : "code_80140E80",
0x801418B0 : "z_vismono",
- 0x801420C0 : "code_801420C0",
+ 0x801420C0 : "z_viszbuf",
0x80142440 : "z_vr_box",
0x801435A0 : "z_vr_box_draw",
0x80143A10 : "z_sram_NES",
diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt
index c9f7ab6cd..aa6770307 100644
--- a/tools/disasm/functions.txt
+++ b/tools/disasm/functions.txt
@@ -2775,9 +2775,9 @@
0x80141C34:("VisMono_DesaturateDList",),
0x80141E60:("VisMono_Draw",),
0x8014204C:("VisMono_DrawOld",),
- 0x801420C0:("func_801420C0",),
- 0x801420F4:("func_801420F4",),
- 0x80142100:("func_80142100",),
+ 0x801420C0:("VisZbuf_Init",),
+ 0x801420F4:("VisZbuf_Destroy",),
+ 0x80142100:("VisZbuf_Draw",),
0x80142440:("func_80142440",),
0x80143148:("func_80143148",),
0x801431E8:("Skybox_Setup",),
diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt
index 133034f3a..38aa66512 100644
--- a/tools/disasm/variables.txt
+++ b/tools/disasm/variables.txt
@@ -4067,7 +4067,7 @@
0x801F6FE8:("sSlowlyStack","u8","[4096]",0x1000),
0x801F7FF0:("D_801F7FF0","UNK_TYPE1","",0x1),
0x801F8010:("D_801F8010","struct_801F8010","",0x10),
- 0x801F8020:("D_801F8020","struct_801F8020","",0x10),
+ 0x801F8020:("sVisZbuf","VisZbuf","",0x10),
0x801F8030:("sMonoColors","VisMono","",0x18),
0x801F8048:("D_801F8048","UNK_TYPE1","",0x1),
0x801F80D0:("sGraphFaultAddrConvClient","FaultAddrConvClient","",0xc),
diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv
index 1d08b2962..a18086d38 100644
--- a/tools/sizes/code_functions.csv
+++ b/tools/sizes/code_functions.csv
@@ -2289,9 +2289,9 @@ asm/non_matchings/code/z_vismono/VisMono_DesaturateTLUT.s,VisMono_DesaturateTLUT
asm/non_matchings/code/z_vismono/VisMono_DesaturateDList.s,VisMono_DesaturateDList,0x80141C34,0x8B
asm/non_matchings/code/z_vismono/VisMono_Draw.s,VisMono_Draw,0x80141E60,0x7B
asm/non_matchings/code/z_vismono/VisMono_DrawOld.s,VisMono_DrawOld,0x8014204C,0x1D
-asm/non_matchings/code/code_801420C0/func_801420C0.s,func_801420C0,0x801420C0,0xD
-asm/non_matchings/code/code_801420C0/func_801420F4.s,func_801420F4,0x801420F4,0x3
-asm/non_matchings/code/code_801420C0/func_80142100.s,func_80142100,0x80142100,0xD0
+asm/non_matchings/code/z_viszbuf/VisZbuf_Init.s,VisZbuf_Init,0x801420C0,0xD
+asm/non_matchings/code/z_viszbuf/VisZbuf_Destroy.s,VisZbuf_Destroy,0x801420F4,0x3
+asm/non_matchings/code/z_viszbuf/VisZbuf_Draw.s,VisZbuf_Draw,0x80142100,0xD0
asm/non_matchings/code/z_vr_box/func_80142440.s,func_80142440,0x80142440,0x342
asm/non_matchings/code/z_vr_box/func_80143148.s,func_80143148,0x80143148,0x28
asm/non_matchings/code/z_vr_box/Skybox_Setup.s,Skybox_Setup,0x801431E8,0x4F