From d7bb6cdea2416aa1c5a8a97e8b64273ba25bd98a Mon Sep 17 00:00:00 2001 From: Z Date: Mon, 5 Apr 2021 22:45:14 -0500 Subject: [PATCH] floor fix attempt --- .gitignore | 4 ++++ src/Makefile | 2 +- src/rt_floor.c | 31 ++++++++++++++++--------------- src/w_wad.c | 6 +++++- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index c6127b3..35c1b81 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ modules.order Module.symvers Mkfile.old dkms.conf + +*.rot +build/ +.vscode/ \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index fb1c9d8..1f1c5e6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,7 +16,7 @@ ROTT ?= rott CC ?= gcc -CFLAGS ?= -std=c17 -g -Og +CFLAGS ?= -std=c17 -g -Og -O0 CFLAGS += -Wall -Wextra -Wshadow -Wpedantic CFLAGS += $(shell sdl2-config --cflags) CFLAGS += $(EXTRACFLAGS) diff --git a/src/rt_floor.c b/src/rt_floor.c index 176c30d..849620b 100644 --- a/src/rt_floor.c +++ b/src/rt_floor.c @@ -493,6 +493,9 @@ void DrawHLine (int xleft, int xright, int yp) buf=floorptr; hd=yp-centery; height=(hd<<13)/(maxheight-pheight+32); + + mr_xstep=FixedScale((viewsin<<8),((maxheight-pheight+32)),hd); + mr_ystep=FixedScale((viewcos<<8),((maxheight-pheight+32)),hd); } else { @@ -505,16 +508,17 @@ void DrawHLine (int xleft, int xright, int yp) hd=centery-yp; height=(hd<<13)/pheight; + + mr_xstep=FixedScale((viewsin<<8),(pheight),hd); + mr_ystep=FixedScale((viewcos<<8),(pheight),hd); } SetFCLightLevel(height>>(8-HEIGHTFRACTION-1)); - mr_xstep = ((viewsin<<8)/(height)); - mr_ystep = ((viewcos<<8)/(height)); - startxfrac = ((viewx>>1) + FixedMulShift(mr_ystep,scale,2))- - FixedMulShift(mr_xstep,(centerx-xleft),2); + startxfrac = ((viewx<<14) + mr_ystep * scale)- + (mr_xstep * (centerx-xleft)); - startyfrac = ((viewy>>1) - FixedMulShift(mr_xstep,scale,2))- - FixedMulShift(mr_ystep,(centerx-xleft),2); + startyfrac = ((viewy<<14) - mr_xstep * scale)- + (mr_ystep * (centerx-xleft)); dest=(byte *)bufferofs+ylookup[yp]; @@ -527,10 +531,6 @@ void DrawHLine (int xleft, int xright, int yp) mr_xfrac = startxfrac; mr_yfrac = startyfrac; - // back off the pixel increment (orig. is 4x) - mr_xstep >>= 2; - mr_ystep >>= 2; - mr_count = xright-xleft+1; if (mr_count) @@ -595,17 +595,18 @@ void DrawPlanes( void ) void DrawRow(int count, byte * dest, byte * src) { - unsigned frac, fracstep; int coord; - frac = (mr_yfrac<<16) + (mr_xfrac&0xffff); - fracstep = (mr_ystep<<16) + (mr_xstep&0xffff); + unsigned xfrac = mr_xfrac; + unsigned yfrac = mr_yfrac; while (count--) { /* extract the x/y coordinates */ - coord = ((frac >> (32-7)) | ((frac >> (32-23)) << 7)) & 16383; + coord = ((yfrac >> 24) & 0b00000001111111) | (( xfrac >> 17) & 0b11111110000000); *dest++ = shadingtable[src[coord]]; - frac += fracstep; + + xfrac += mr_xstep; + yfrac += mr_ystep; } } diff --git a/src/w_wad.c b/src/w_wad.c index b454d90..09ab8c3 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -17,7 +17,11 @@ along with this program. If not, see . */ // W_wad.c -#include +#if defined(_MSC_VER) || defined(__MINGW32__) +#include // alloca +#else +#include // alloca +#endif #include #include #include