Page 1 of 2

(Solved) (help) DarkOne's Textured floor and ceiling

PostPosted: 02 Jan 2017, 12:26
by Officer-Michael John
I tryed importing DarkOne's Textured floor and ceiling from DOS to SDL. But he makes bug. What is problem? I used this tutorial with modified:http://diehardwolfers.areyep.com/viewtopic.php?t=1575&postdays=0&postorder=asc&&start=0

My modified version on SDL:

VERSION.H:

Code: Select all
#define USE_FLOORCEILINGTEX   // Enables floor and ceiling textures stored in the third mapplane (see wl_floorceiling.cpp)


WL_FLOORCEILING.CPP:

Code: Select all
#include "version.h"

#ifdef USE_FLOORCEILINGTEX

#include "wl_def.h"
#include "wl_shade.h"

// Textured Floor and Ceiling by DarkOne
// With multi-textured floors and ceilings stored in lower and upper bytes of
// according tile in third mapplane, respectively.
void DrawFloorAndCeiling(byte *vbuf, unsigned vbufPitch, int min_wallheight)
{
    fixed dist;                                // distance to row projection
    fixed tex_step;                            // global step per one screen pixel
    fixed gu, gv, du, dv;                      // global texture coordinates
    int u, v;                                  // local texture coordinates
//    byte *toptex, *bottex;
//    unsigned lasttoptex = 0xffffffff, lastbottex = 0xffffffff;

    int halfheight = viewheight >> 1;
    int y0 = min_wallheight >> 3;              // starting y value
    if(y0 > halfheight)
        return;                                // view obscured by walls
    if(!y0) y0 = 1;                            // don't let division by zero
    unsigned bot_offset0 = vbufPitch * (halfheight + y0);
    unsigned top_offset0 = vbufPitch * (halfheight - y0 - 1);

    // draw horizontal lines
    for(int y = y0, bot_offset = bot_offset0, top_offset = top_offset0;
        y < halfheight; y++, bot_offset += vbufPitch, top_offset -= vbufPitch)
    {
        dist = (heightnumerator / (y + 1)) << 5;
        gu =  viewx + FixedMul(dist, viewcos);
        gv = -viewy + FixedMul(dist, viewsin);
        tex_step = (dist << 8) / viewwidth / 175;
        du =  FixedMul(tex_step, viewsin);
        dv = -FixedMul(tex_step, viewcos);
        gu -= (viewwidth >> 1) * du;
        gv -= (viewwidth >> 1) * dv; // starting point (leftmost)
#ifdef USE_SHADING
        byte *curshades = shadetable[GetShade(y << 3)];
#endif
#endif
        for(int x = 0, bot_add = bot_offset, top_add = top_offset;
            x < viewwidth; x++, bot_add++, top_add++)
        {
            if(wallheight[x] >> 3 <= y)
            {
/*       
                int curx = (gu >> TILESHIFT) & (MAPSIZE - 1);
                int cury = (-(gv >> TILESHIFT) - 1) & (MAPSIZE - 1);
                unsigned curtex = MAPSPOT(curx, cury, 2);
                if(curtex)
                {
                    unsigned curtoptex = curtex >> 8;
                    if (curtoptex != lasttoptex)
                    {
                        lasttoptex = curtoptex;
                        toptex = PM_GetTexture(curtoptex);
                    }
                    unsigned curbottex = curtex & 0xff;
                    if (curbottex != lastbottex)
                    {
                        lastbottex = curbottex;
                        bottex = PM_GetTexture(curbottex);
                    }
*/                   
                    u = (gu >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
                    v = (gv >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
                    unsigned texoffs = (u << TEXTURESHIFT) + (TEXTURESIZE - 1) - v;
/*                   
#ifdef USE_SHADING
                    if(curtoptex)
                        vbuf[top_add] = curshades[toptex[texoffs]];
                    if(curbottex)
                        vbuf[bot_add] = curshades[bottex[texoffs]];
#else
                    if(curtoptex)
                        vbuf[top_add] = toptex[texoffs];
                    if(curbottex)
                        vbuf[bot_add] = bottex[texoffs];
#endif
*/
                }
            }
            gu += du;
            gv += dv;
        }
    }
//}

//#endif


WL_DRAW.CPP:

Code: Select all
#define USE_TEX(page) (0x0000|(page))
/*
** use USE_TEX(n) to use floor/ceiling textures for given level
** n should be 1..255 !!!
** it is MAP-ID (from FloEdit). First texture goes to floor, second to ceiling
*/

byte vgaCeiling[]=
{
#ifndef SPEAR
USE_TEX(32),0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0xbf,
0x4e,0x4e,0x4e,0x1d,0x8d,0x4e,0x1d,0x2d,0x1d,0x8d,
0x1d,0x1d,0x1d,0x1d,0x1d,0x2d,0xdd,0x1d,0x1d,0x98,

0x1d,0x9d,0x2d,0xdd,0xdd,0x9d,0x2d,0x4d,0x1d,0xdd,
0x7d,0x1d,0x2d,0x2d,0xdd,0xd7,0x1d,0x1d,0x1d,0x2d,
0x1d,0x1d,0x1d,0x1d,0xdd,0xdd,0x7d,0xdd,0xdd,0xdd
#else
0x6f,0x4f,0x1d,0xde,0xdf,0x2e,0x7f,0x9e,0xae,0x7f,
0x1d,0xde,0xdf,0xde,0xdf,0xde,0xe1,0xdc,0x2e,0x1d,0xdc
#endif
};

void VGAClearScreen (byte ceiling)
{
//    byte ceiling=vgaCeiling[gamestate.episode*10+mapon];

void    ThreeDRefresh (void)
{
    short tracedir;
    byte ceiling;
    boolean flats;   

//
// follow the walls from there to the right, drawing as we go
//
    ceiling=vgaCeiling[gamestate.episode*10+mapon];
    if((ceiling>>8)==(ceiling&0xFF))
    {
          VGAClearScreen(ceiling);
          flats=false;
    }
    else
    {
          flats=true;
          ceiling=((ceiling&0xFF)-1)<<1;
    }
   
//    VGAClearScreen ();

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 02 Jan 2017, 22:39
by Tricob1974
That feature is already in all releases of Wolf4SDL. Just check VERSION.H.

If you try to put the tutorial in there again, you're going to have problems.

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 03 Jan 2017, 10:09
by Officer-Michael John
I do not like Adam Biser's Multiple floor/ceiling texture using. How to I can corrected the Problems?

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 04 Jan 2017, 05:11
by Ron
Why not use Adam Biser's code, and then only put one floor and one ceiling texture per level? Same result with no unnecessary coding hassle.

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 04 Jan 2017, 05:35
by linuxwolf
I really need to release part of my renderer from GA to help OMJ with this problem. I should integrate it into the public Wolf4SDL maintained by AlumiuN on DHW forum. I just wouldnt be able to gaurentee it is as fast as the old renderer in all cases.

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 04 Jan 2017, 11:00
by Officer-Michael John
So what do I do with this code now?

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 05 Jan 2017, 01:00
by Tricob1974
You keep saying there's a bug, but you're not saying what the bug is.

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 05 Jan 2017, 10:14
by Officer-Michael John
I did not understand at first,that you said you found a bug.

Here's in Screenshots bug:

Image
Image

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 06 Jan 2017, 03:27
by Tricob1974
That's not because of the source code. That's because the map is set up wrong.

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 06 Jan 2017, 10:28
by Officer-Michael John
A quick additions:

Code: Select all
#ifdef USE_FLOORCEILINGTEX
   if(flats)
    DrawFloorAndCeiling(vbuf, vbufPitch, min_wallheight);
#endif


Even so, the same error occurs. How do I correct?

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 07 Jan 2017, 00:43
by Tricob1974
By changing the third plane of your map.

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 07 Jan 2017, 15:40
by Officer-Michael John
I changed to the third plane,but can't work. :(

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 08 Jan 2017, 00:30
by Tricob1974
You need to add floor and ceiling tiles, too. And you need to do it to the entire map.

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 08 Jan 2017, 15:14
by Officer-Michael John
I gived with Wood texture,but now not work too.

Re: (help) DarkOne's Textured floor and ceiling

PostPosted: 09 Jan 2017, 02:55
by Tricob1974
"Not working" doesn't tell me much.