From 932fcaabc84870b5a24dc6b3dd54392977e832ca Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Tue, 12 Dec 2023 13:35:17 +0100 Subject: [PATCH] fix non-power-of-two wide sky textures (#1323) --- src/r_data.c | 17 +++++++++++++++++ src/r_data.h | 1 + src/r_plane.c | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 48183116..bc20306c 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -504,6 +504,23 @@ byte *R_GetColumnMod(int tex, int col) return texturecomposite[tex] + ofs; } +// [FG] wrapping column getter function for non-power-of-two wide sky textures +byte *R_GetColumnMod2(int tex, int col) +{ + int ofs; + + while (col < 0) + col += texturewidth[tex]; + + col %= texturewidth[tex]; + ofs = texturecolumnofs2[tex][col]; + + if (!texturecomposite2[tex]) + R_GenerateComposite(tex); + + return texturecomposite2[tex] + ofs; +} + // // R_InitTextures // Initializes the texture list diff --git a/src/r_data.h b/src/r_data.h index 98c89b04..556c872b 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -31,6 +31,7 @@ // Retrieve column data for span blitting. byte *R_GetColumn(int tex, int col); byte *R_GetColumnMod(int tex, int col); +byte *R_GetColumnMod2(int tex, int col); // I/O, setting up the stuff. void R_InitData (void); diff --git a/src/r_plane.c b/src/r_plane.c index f8cdc25a..8d1728f4 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -423,7 +423,7 @@ static void do_draw_plane(visplane_t *pl) for (x = pl->minx; (dc_x = x) <= pl->maxx; x++) if ((dc_yl = pl->top[x]) != USHRT_MAX && dc_yl <= (dc_yh = pl->bottom[x])) { - dc_source = R_GetColumnMod(texture, ((an + xtoskyangle[x])^flip) >> + dc_source = R_GetColumnMod2(texture, ((an + xtoskyangle[x])^flip) >> ANGLETOSKYSHIFT); colfunc(); }