Skip to content

Commit

Permalink
floor fix attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Z committed Apr 11, 2021
1 parent 407e3d8 commit d7bb6cd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

*.rot
build/
.vscode/
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 16 additions & 15 deletions src/rt_floor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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];

Expand All @@ -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)
Expand Down Expand Up @@ -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;
}
}
6 changes: 5 additions & 1 deletion src/w_wad.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// W_wad.c

#include <alloca.h>
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <malloc.h> // alloca
#else
#include <alloca.h> // alloca
#endif
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
Expand Down

0 comments on commit d7bb6cd

Please sign in to comment.