From 062de5bb7badc98914635236cb80ac37ea83166c Mon Sep 17 00:00:00 2001 From: joshuarwood Date: Sun, 11 May 2025 11:59:11 -0500 Subject: [PATCH] clear up debugging statements --- src/game/bondgun.c | 7 ++----- src/game/game_13c510.c | 30 ++++++++---------------------- src/game/zbuf.c | 16 ++++++++++------ src/lib/sched.c | 5 ----- 4 files changed, 20 insertions(+), 38 deletions(-) diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 87edc9b9b..a46e66721 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -57,7 +57,6 @@ #include "game/stagetable.h" #include "video.h" #include "platform.h" -#include // remove after debugging #endif #define GUNLOADSTATE_FLUX 0 @@ -10939,8 +10938,6 @@ glabel var7f1aca90 // Mismatch: Goal uses different codegen for accessing vertices void bgunRender(Gfx **gdlptr) { - printf("\nsrc/game/bondgun.c:bgunRender()"); - fflush(stdout); Gfx *gdl = *gdlptr; struct modelrenderdata renderdata = {NULL, true, 3}; // 10c struct player *player; @@ -10959,7 +10956,9 @@ void bgunRender(Gfx **gdlptr) return; } +#ifdef PLATFORM_N64 gdl = zbufSaveArtifactDepths(gdl); +#endif gdl = viPrepareZbuf(gdl); gdl = vi0000b1d0(gdl); @@ -11193,8 +11192,6 @@ void bgunRender(Gfx **gdlptr) viGetViewLeft() + viGetViewWidth(), viGetViewTop() + viGetViewHeight()); *gdlptr = gdl; - printf("\n done!"); - fflush(stdout); } #endif diff --git a/src/game/game_13c510.c b/src/game/game_13c510.c index fa215a31c..4dde60b57 100644 --- a/src/game/game_13c510.c +++ b/src/game/game_13c510.c @@ -21,7 +21,6 @@ #include "lib/lib_17ce0.h" #include "game/player.h" #include "game/prop.h" -#include // remove after debugging #endif /** @@ -109,7 +108,7 @@ void artifactsTick(void) schedIncrementFrontArtifacts(); } -u16 floatToIntDepth(f32 arg0) +u16 floatToN64Depth(f32 arg0) { /** * Method to convert a 32 bit floating point depth value to the @@ -124,10 +123,6 @@ u16 floatToIntDepth(f32 arg0) * this calculation at values 0x3f800, 0x3f000, etc. is probably * intended to reduce z-fighting by adding more differentiation for * distant z values. - * - * TO DO: figure why the output appears with a >> 2 shift. - * It might be worth it to simplify some of the externally - * applied scaling factors if it can match the N64 compilation. */ u32 value = arg0 * 8.0f; u32 left; // forms the most significant byte of the final u16 @@ -215,9 +210,6 @@ bool artifactTestLos(struct coord *spec, struct coord *roompos, s32 xi, s32 yi) void artifactsCalculateGlaresForRoom(s32 roomnum) { - printf("\nsrc/game/game_13c510.c:artifactsCalculateGlaresForRoom(%d)", roomnum); - fflush(stdout); - s32 i; s32 j; s32 k; @@ -445,7 +437,13 @@ void artifactsCalculateGlaresForRoom(s32 roomnum) #ifndef PLATFORM_N64 artifact->visiblelos = artifactTestLos(&spec, &g_BgRooms[roomnum].pos, xi, yi); #endif - artifact->expecteddepth = floatToIntDepth(f0) >> 2; + /** + * the game performs artifact depth comparison using + * the original N64 depth values divided by 4, which + * is accomplished by bit shifting the N64 depth value + * to the right using >> 2 + */ + artifact->expecteddepth = floatToN64Depth(f0) >> 2; artifact->zbufptr = &g_ZbufPtr1[viGetWidth() * yi + xi]; artifact->light = &roomlights[i]; artifact->type = ARTIFACTTYPE_GLARE; @@ -459,8 +457,6 @@ void artifactsCalculateGlaresForRoom(s32 roomnum) } } } - printf("\n done!"); - fflush(stdout); } u8 artifactsClamp(u8 arg0, u8 arg1) @@ -478,9 +474,6 @@ u8 artifactsClamp(u8 arg0, u8 arg1) Gfx *artifactsConfigureForGlares(Gfx *gdl) { - printf("\nsrc/game/game_13c510.c:artifactsConfigureForGlares()"); - fflush(stdout); - struct stagetableentry *stage = stageGetCurrent(); texSelect(&gdl, &g_TexLightGlareConfigs[stage->light_type], 4, 0, 2, 1, NULL); @@ -495,8 +488,6 @@ Gfx *artifactsConfigureForGlares(Gfx *gdl) gDPSetAlphaDither(gdl++, G_AD_PATTERN); gDPSetTexturePersp(gdl++, G_TP_NONE); - printf("\n done!"); - fflush(stdout); return gdl; } @@ -509,9 +500,6 @@ Gfx *artifactsUnconfigureForGlares(Gfx *gdl) Gfx *artifactsRenderGlaresForRoom(Gfx *gdl, s32 roomnum) { - printf("\nsrc/game/game_13c510.c:artifactsRenderGlaresForRoom(%d)", roomnum); - fflush(stdout); - s32 i; s32 j; s32 lightindex; @@ -754,7 +742,5 @@ Gfx *artifactsRenderGlaresForRoom(Gfx *gdl, s32 roomnum) } } - printf("\n done!"); - fflush(stdout); return gdl; } diff --git a/src/game/zbuf.c b/src/game/zbuf.c index 3668616f3..d64f79f28 100644 --- a/src/game/zbuf.c +++ b/src/game/zbuf.c @@ -10,7 +10,6 @@ #include "lib/memp.h" #include "data.h" #include "types.h" -#include // remove after debugging u32 g_ZbufWidth; u32 g_ZbufHeight; @@ -126,6 +125,7 @@ Gfx *zbufConfigureRdp(Gfx *gdl) */ Gfx *zbufClear(Gfx *gdl) { +#ifdef PLATFORM_N64 s32 left; s32 right; @@ -149,7 +149,7 @@ Gfx *zbufClear(Gfx *gdl) gDPFillRectangle(gdl++, left, 0, right, playerGetFbHeight() - 1); gDPPipeSync(gdl++); -#ifndef PLATFORM_N64 +#else gDPClearDepthEXT(gdl++); #endif @@ -177,6 +177,14 @@ u16 *zbufGetArtifactsCfb(s32 index) return addr; } +/** + * This method is designed to save artifact depths + * prior to drawing the hands and weapon on-screen + * since drawing them requires clearing the zbuffer + * to avoid clipping the gun model on floors and walls. + * + * TODO: determine if this works with the PC port + */ Gfx *zbufSaveArtifactDepths(Gfx *gdl) { struct artifact *artifacts = schedGetWriteArtifacts(); @@ -188,8 +196,6 @@ Gfx *zbufSaveArtifactDepths(Gfx *gdl) u16 *zbufrow; s32 i; - printf("\nsrc/game/zbuf.c:zbufSaveArtifactDepths()"); - fflush(stdout); viGetBackBuffer(); samples = zbufGetArtifactsCfb(g_SchedWriteArtifactsIndex); g_SchedSpecialArtifactIndexes[g_SchedWriteArtifactsIndex] = 1; @@ -255,7 +261,5 @@ Gfx *zbufSaveArtifactDepths(Gfx *gdl) if (samples); - printf("\n done!"); - fflush(stdout); return gdl; } diff --git a/src/lib/sched.c b/src/lib/sched.c index a954357ad..b70906336 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -19,7 +19,6 @@ #include "lib/joy.h" #include "data.h" #include "types.h" -#include // remove after debugging /* * private typedefs and defines @@ -534,8 +533,6 @@ void schedResetArtifacts(void) void schedUpdatePendingArtifacts(void) { - printf("\nsrc/lib/sched.c:schedUpdatePendingArtifacts()"); - fflush(stdout); struct artifact *artifacts = schedGetPendingArtifacts(); s32 i; @@ -564,8 +561,6 @@ void schedUpdatePendingArtifacts(void) g_SchedSpecialArtifactIndexes[g_SchedPendingArtifactsIndex] = 0; schedIncrementPendingArtifacts(); - printf("\n done!"); - fflush(stdout); } /**