From b9dd67a0912291afb73ec0faa287b718c1f9a041 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Tue, 3 Jan 2023 20:49:27 +0100 Subject: [PATCH] Add z-buffer mod --- README.md | 2 ++ mods/full_zbuffer.diff | 78 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 mods/full_zbuffer.diff diff --git a/README.md b/README.md index 2d16eda..428152b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ everywhere, made for the benefit of all living beings* ![](media/3screens.png) +**NOTE: for a more consoomerist experience there are now mods in the mod directory with which you may rice the game.** + This game got some attention on 4chan: [1](https://archive.li/Yzcwt), [2](https://archive.li/xY4ia), [3](https://archive.li/tFWrL). - [why this game is special](#why-this-game-is-special) diff --git a/mods/full_zbuffer.diff b/mods/full_zbuffer.diff new file mode 100644 index 0000000..9a3ec2f --- /dev/null +++ b/mods/full_zbuffer.diff @@ -0,0 +1,78 @@ +This mod adds full z-buffer that mostly fixes the incorrect sprite visibility, +however RAM consumption increases quite a bit. Note that visiblity inaccuracies +may still occur as e.g. floor depth is not accurate and isn't used, but the game +generally looks much better. By drummyfish, released under CC0 1.0, public +domain. + +diff --git a/constants.h b/constants.h +index 956baa0..da72f24 100644 +--- a/constants.h ++++ b/constants.h +@@ -352,7 +352,7 @@ + #define SFG_FONT_SIZE_BIG 1 + #endif + +-#define SFG_Z_BUFFER_SIZE SFG_GAME_RESOLUTION_X ++#define SFG_Z_BUFFER_SIZE (SFG_GAME_RESOLUTION_X * SFG_GAME_RESOLUTION_Y) + + /** + Step in which walls get higher, in raycastlib units. +diff --git a/game.h b/game.h +index 24285cb..f8ef257 100755 +--- a/game.h ++++ b/game.h +@@ -951,6 +951,14 @@ void SFG_pixelFunc(RCL_PixelInfo *pixel) + : + SFG_TRANSPARENT_COLOR; + ++ uint8_t *zValue = SFG_game.zBuffer + ++ pixel->position.y * SFG_GAME_RESOLUTION_X + pixel->position.x; ++ ++ uint8_t zDistance = SFG_RCLUnitToZBuffer(pixel->depth); ++ ++ if (*zValue >= zDistance) ++ *zValue = zDistance; ++ + shadow = pixel->hit.direction >> 1; + } + else // floor/ceiling +@@ -1216,29 +1224,25 @@ void SFG_drawScaledSprite( + + for (int16_t x = x0, u = u0; x <= x1; ++x, ++u) + { +- if (SFG_game.zBuffer[x] >= zDistance) ++ for (int16_t y = y0, v = v0; y <= y1; ++y, ++v) + { +- int8_t columnTransparent = 1; ++ uint8_t color = ++ SFG_getTexel(image,SFG_game.spriteSamplingPoints[u], ++ SFG_game.spriteSamplingPoints[v]); + +- for (int16_t y = y0, v = v0; y <= y1; ++y, ++v) ++ if (color != SFG_TRANSPARENT_COLOR) + { +- uint8_t color = +- SFG_getTexel(image,SFG_game.spriteSamplingPoints[u], +- SFG_game.spriteSamplingPoints[v]); +- +- if (color != SFG_TRANSPARENT_COLOR) +- { + #if SFG_DIMINISH_SPRITES +- color = palette_minusValue(color,minusValue); ++ color = palette_minusValue(color,minusValue); + #endif +- columnTransparent = 0; ++ uint8_t *zValue = SFG_game.zBuffer + y * SFG_GAME_RESOLUTION_X + x; + ++ if (*zValue >= zDistance) ++ { + SFG_setGamePixel(x,y,color); ++ *zValue = zDistance; + } + } +- +- if (!columnTransparent) +- SFG_game.zBuffer[x] = zDistance; + } + } + }