(Tutorial) DarkOne's textured floor/ceiling for SDL

View previous topic View next topic Go down

(Tutorial) DarkOne's textured floor/ceiling for SDL

Post by Officer-M. John (Admin) on Tue Mar 21, 2017 6:33 pm

You like use DarkOne's textured floor/ceiling for SDL? You try with original DOS code? Now thet released for SDL too. I edited for SDL and works.

Original code tutorial for DOS:http://diehardwolfers.areyep.com/viewtopic.php?t=1575

SDL version:

You need add in VERSION.H:

Code:

#define USE_DRAWFLATSTEX      // Enables floor and ceiling textures (see wl_drawflatstex.cpp)

And on project (WOLF4SDL.DEV) next file:

WL_DRAWFLATS.CPP

You can download:mediafire.com file/0mw8ky1j2st212d/wl_drawflats.cpp

WL_DEF.H in FEATURE DEFINITIONS:

Code:

#ifdef USE_DRAWFLATSTEX
    void DrawFlats(byte *vbuf, unsigned vbufPitch, int min_wallheight, unsigned tex_f, unsigned tex_c);
#endif

WL_DRAW.CPP:

Under VGAClearScreen part:

Code:

#ifdef USE_DRAWFLATSTEX
#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)
= 1st texture for floor, 2nd to ceiling
=
=======================================
*/

byte texCeiling[]=
{
#ifndef SPEAR
 USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(17),USE_TEX(12),USE_TEX(17),USE_TEX(17),USE_TEX(19),
 USE_TEX(24),USE_TEX(24),USE_TEX(24),USE_TEX(24),USE_TEX(24),USE_TEX(19),USE_TEX(12),USE_TEX(12),USE_TEX(15),USE_TEX(8),
 USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(17),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(8),

 USE_TEX(17),USE_TEX(8),USE_TEX(17),USE_TEX(12),USE_TEX(29),USE_TEX(8),USE_TEX(17),USE_TEX(24),USE_TEX(35),USE_TEX(29),
 USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(12),USE_TEX(29),USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(17),
 USE_TEX(17),USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(29),USE_TEX(29),USE_TEX(29),USE_TEX(29),USE_TEX(17)
#else
 USE_TEX(54),USE_TEX(24),USE_TEX(12),USE_TEX(63),USE_TEX(50),USE_TEX(17),USE_TEX(8),USE_TEX(8),USE_TEX(8),USE_TEX(8),
 USE_TEX(35),USE_TEX(44),USE_TEX(29),USE_TEX(17),USE_TEX(12),USE_TEX(50),USE_TEX(50),USE_TEX(42),USE_TEX(63),USE_TEX(54),USE_TEX(56)
#endif
};

/*
=====================
=
= TEXClearScreen
=
=====================
*/

void TEXClearScreen (unsigned texture)
{    
    int y;
    byte *ptr = vbuf;
}    
#endif

So you modify in ThreeDRefresh:

Code:

/*
========================
=
= ThreeDRefresh
=
========================
*/

void    ThreeDRefresh (void)
{
#ifdef USE_DRAWFLATSTEX
    unsigned texture;
    boolean flats;
#endif  
//
// clear out the traced array
//
    memset(spotvis,0,maparea);
    spotvis[player->tilex][player->tiley] = 1;       // Detect all sprites over player fix

    vbuf = VL_LockSurface(screenBuffer);
    vbuf+=screenofs;
    vbufPitch = bufferPitch;

    CalcViewVariables();

//
// follow the walls from there to the right, drawing as we go
//  
    VGAClearScreen ();
#if defined(USE_FEATUREFLAGS) && defined(USE_STARSKY)
    if(GetFeatureFlags() & FF_STARSKY)
        DrawStarSky(vbuf, vbufPitch);
#endif

#ifdef USE_DRAWFLATSTEX
    texture=texCeiling[gamestate.episode*10+mapon];
    if((texture>>8)==(texture&0xFF))
    {
          TEXClearScreen(texture);
          flats=false;
    }
    else
    {
          flats=true;
          texture=((texture&0xFF)-1)<<1;
    }
#endif    
    
    WallRefresh ();

#if defined(USE_FEATUREFLAGS) && defined(USE_PARALLAX)
    if(GetFeatureFlags() & FF_PARALLAXSKY)
        DrawParallax(vbuf, vbufPitch);
#endif
#if defined(USE_FEATUREFLAGS) && defined(USE_CLOUDSKY)
    if(GetFeatureFlags() & FF_CLOUDSKY)
        DrawClouds(vbuf, vbufPitch, min_wallheight);
#endif
#ifdef USE_FLOORCEILINGTEX
    DrawFloorAndCeiling(vbuf, vbufPitch, min_wallheight);
#endif
#ifdef USE_DRAWFLATSTEX
  if(flats)
    DrawFlats(vbuf, vbufPitch, min_wallheight, texture, texture+1);      
#endif

//
// draw all the scaled images
//
    DrawScaleds();                  // draw scaled stuff

#if defined(USE_FEATUREFLAGS) && defined(USE_RAIN)
    if(GetFeatureFlags() & FF_RAIN)
        DrawRain(vbuf, vbufPitch);
#endif
#if defined(USE_FEATUREFLAGS) && defined(USE_SNOW)
    if(GetFeatureFlags() & FF_SNOW)
        DrawSnow(vbuf, vbufPitch);
#endif

    DrawPlayerWeapon ();    // draw player's hands

    if(Keyboard[sc_Tab] && viewsize == 21 && gamestate.weapon != -1)
        ShowActStatus();

    VL_UnlockSurface(screenBuffer);
    vbuf = NULL;

//
// show screen and time last cycle
//

    if (fizzlein)
    {
        FizzleFade(screenBuffer, 0, 0, screenWidth, screenHeight, 20, false);
        fizzlein = false;

        lasttimecount = GetTimeCount();          // don't make a big tic count
    }
    else
    {
#ifndef REMDEBUG
        if (fpscounter)
        {
            fontnumber = 0;
            SETFONTCOLOR(7,127);
            PrintX=4; PrintY=1;
            VWB_Bar(0,0,50,10,bordercol);
            US_PrintSigned(fps);
            US_Print(" fps");
        }
#endif
        SDL_BlitSurface(screenBuffer, NULL, screen, NULL);
        SDL_Flip(screen);
    }

#ifndef REMDEBUG
    if (fpscounter)
    {
        fps_frames++;
        fps_time+=tics;

        if(fps_time>35)
        {
            fps_time-=35;
            fps=fps_frames<<1;
            fps_frames=0;
        }
    }
#endif
}

If you did in good then textured floor and ceiling will be on your level. Thanks Chris Chokan your help in correct.
avatar
Officer-M. John (Admin)
Admin

Posts : 328
Join date : 2015-10-02
Age : 19

View user profile http://wolf3dfanboys.usersboard.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum