Wolf3d Haven Forum

Please log in or register. Smile

Join the forum, it's quick and easy

Wolf3d Haven Forum

Please log in or register. Smile
Wolf3d Haven Forum

A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...


Search found 5 matches for ifdef

SDL Tut for Animated Floor & Ceiling Textures - Tue Aug 01, 2023 7:17 pm

Thanks to insurrectionman wrote the animated Wall Texture tutorial on DHW,

http://dhw.wolfenstein3d.com/viewtopic.php?t=5384

which I implemented a few years ago, that helped me do this, I don't think this was in the comments, but it may have been, I cant remember, but I dug into to my bakups and found this, I will be using it in my next KSS Installment. 

if you want you can use an ifdef for these like I did but I omitted it from this, it's not imperative it just helps keep things clean & tidy and if you are using your engine for multiple games. 

in    wl_floorceiling.cpp

under the first  #ifdef use_shading section 
right below 
 unsigned curtoptex = curtex >> 8;

add the lines for animated ceiling textures 

Code:
if (curtoptex==155) // Whatever your  floor ceiling texture ID is
                        curtoptex+= (frameon>>3)%8; // first number is amount of frames, second number is speed of animation



the if statement for currnet vs last top textures shoulld be right below those lines 
then right below

  unsigned curbottex = curtex & 0xff;

add the lines for animated floor textures

Code:
if (curbottex==155) // Whatever your floor ceiling texture ID is
                       curbottex+= (frameon>>3)%8; // first number is amount of frames, second number is speed of animation



again the if statement for current vs last bottom textures should be right below those lines

compile file to test for typos/errors
build it / compile the code / exe

use chaos edit to know what the floor and ceiling texture is, it will tell you in the floor ceiling texture box label that shows when you select it from the floor ceiling texture select window in chaos edit

put the that animated floor and or ceiling in the map 
compile the map 

Test it and behold the super cool effects. 
Have fun.

[solved] Wall Patches in SDL - Sat Dec 11, 2021 6:58 pm

Topics tagged under ifdef on Wolf3d Haven Forum Right-arrow



Code:
/*
====================
= ApplyPatch2
= Partial Coverage Patches with transparency
= aka 3rd or 4th Index Walls
====================
*/
#ifdef Use_Patch2

byte   patchedwall[PMPageSize];
int      lastpatchnum;
#define FIRSTPATCHTILE   2000
#define NUMPATCHES       1   // This is the number of patch pairs (light/dark) in use.
#define PATCHSTART       DOORWALL-NUMPATCHES*2

unsigned GetPatchNum(boolean useXspot)
{
    // work off xspot/yspot, instead of xtile/ytile
    unsigned spot, x, y;
    (useXspot? spot=xspot : spot=yspot);

    x = (unsigned)((spot+1)/64);
    y = (unsigned)((spot+1)%64) -1;

    spot = MAPSPOT(x,y,1); // adjust for *Planes Exp
// Restrict patch objects to the given range.
   if (spot < FIRSTPATCHTILE || spot >= FIRSTPATCHTILE+NUMPATCHES )
      return 0;
   else
      return spot;

}

boolean ApplyPatch(int wallpic, boolean useXspot)
{
      byte   *scan;
      int    pixel;
      unsigned spot;

   spot = GetPatchNum(useXspot);
   if (spot > 0 && wallpic < DOORWALL) // Don't do door-related textures.
   {
      // Keep track of the patch in memory.
      //   The wall is already stored elsewhere.
      lastpatchnum = spot;
      spot -= FIRSTPATCHTILE;
      // Adjust for light/dark patch sides
      spot = spot * 2 + (lastside?1:0);
      // Load the wall into the byte array first.
    scan = PM_GetTexture(wallpic);
for (pixel=0; pixel>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;
    if (xtilestep == -1)
    {
        texture = TEXTUREMASK-texture;
        xintercept += TILEGLOBAL;
    }
#ifdef Use_Patch2
    if(lastside==1 && lastintercept==xtile && lasttilehit==tilehit && !(lasttilehit & BIT_WALL) && GetPatchNum(true)==lastpatchnum)
#else
   if(lastside==1 && lastintercept==xtile && lasttilehit==tilehit && !(lasttilehit & BIT_WALL))
#endif

    {
        if((pixx&3) && texture == lasttexture)
        {
            ScalePost();
            postx = pixx;
            wallheight[pixx] = wallheight[pixx-1];
            return;
        }
        ScalePost();
        wallheight[pixx] = CalcHeight();
        postsource+=texture-lasttexture;
        postwidth=1;
        postx=pixx;
        lasttexture=texture;
        return;
    }

    if(lastside!=-1) ScalePost();

    lastside=1;
    lastintercept=xtile;
    lasttilehit=tilehit;
    lasttexture=texture;
    wallheight[pixx] = CalcHeight();
    postx = pixx;
    postwidth = 1;

    if (tilehit & BIT_WALL)
    {                                                               // check for adjacent doors
        ytile = (short)(yintercept>>TILESHIFT);
        if ( tilemap[xtile-xtilestep][ytile]&BIT_DOOR )
            wallpic = DOORWALL+3;
        else
            wallpic = vertwall[tilehit &BIT_WALL]; // was ~BIT_WALL]; //  *Mod *Max *Flag *!

    }
    else
        wallpic = vertwall[tilehit];
        #ifdef Use_Patch2
        AssignWall (wallpic);  // ?
        if (ApplyPatch (wallpic, true))
                postsource = patchedwall+texture;
        else
                postsource = PM_GetTexture(wallpic)+texture;
#else
    postsource = PM_GetTexture(wallpic) + texture;
#endif

}


Topics tagged under ifdef on Wolf3d Haven Forum Right-arrow I don't know how or why that code got inserted here on this thread, but that was is not the code I am using in that section, and as far as I understand that code would not even compile.

___________________________________________________________

This is what I have in the relevant section of WL_Draw.cpp

However this your code may be different, I have also used the tut from Chokan to Remove the Hard Coded Limits on Walls and Doors thus mine is a bit different(and my comments.... )
Also dont forget to enable this by placing 
#define UsePatch2   // or whatever name you want
in Version.H

(still semi broken, due to incompatibility with my implementation of removing the hard coded wall and door limits)

[why both... there are reasons] 

/*
====================
= ApplyPatch2
= Partial Coverage Patches with transparency
= aka 3rd or 4th Index Walls
====================
*/
#ifdef Use_Patch2

byte   patchedwall[PMPageSize];
int      lastpatchnum;
#define FIRSTPATCHTILE   2000
#define NUMPATCHES       2   // This is the number of patch pairs (light/dark) in use.
#define PATCHSTART       DOORWALL-NUMPATCHES*2

unsigned GetPatchNum(boolean useXspot)
{
   // work off xspot/yspot, instead of xtile/ytile
   unsigned spot, x, y;
   (useXspot? spot=xspot : spot=yspot);

   x = (unsigned)((spot+1)/64);
   y = (unsigned)((spot+1)%64) -1;

   spot = MAPSPOT(x,y,1);  // adjust for *Planes Exp
// Restrict patch objects to the given range.
  if (spot < FIRSTPATCHTILE || spot >= FIRSTPATCHTILE+NUMPATCHES )
     return 0;
  else
     return spot;

}

boolean ApplyPatch(int wallpic, boolean useXspot)
{
     byte   *scan;
     int    pixel;
     unsigned spot;

  spot = GetPatchNum(useXspot);
  if (spot > 0 && wallpic < DOORWALL) // Don't do door-related textures.
  {
     // Keep track of the patch in memory.
     //   The wall is already stored elsewhere.
     lastpatchnum = spot;
     spot -= FIRSTPATCHTILE;
     // Adjust for light/dark patch sides
     spot = spot * 2 + (lastside?1:0);
     // Load the wall into the byte array first.
   scan = PM_GetTexture(wallpic);
for (pixel=0; pixel>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;
   if (xtilestep == -1)
   {
       texture = TEXTUREMASK-texture;
       xintercept += TILEGLOBAL;
   }
#ifdef Use_Patch2
   if(lastside==1 && lastintercept==xtile && lasttilehit==tilehit && !(lasttilehit & BIT_WALL) && GetPatchNum(true)==lastpatchnum)
#else
  if(lastside==1 && lastintercept==xtile && lasttilehit==tilehit && !(lasttilehit & BIT_WALL))
#endif

   {
       if((pixx&3) && texture == lasttexture)
       {
           ScalePost();
           postx = pixx;
           wallheight[pixx] = wallheight[pixx-1];
           return;
       }
       ScalePost();
       wallheight[pixx] = CalcHeight();
       postsource+=texture-lasttexture;
       postwidth=1;
       postx=pixx;
       lasttexture=texture;
       return;
   }

   if(lastside!=-1) ScalePost();

   lastside=1;
   lastintercept=xtile;
   lasttilehit=tilehit;
   lasttexture=texture;
   wallheight[pixx] = CalcHeight();
   postx = pixx;
   postwidth = 1;

   if (tilehit & BIT_WALL)
   {                                                               // check for adjacent doors
       ytile = (short)(yintercept>>TILESHIFT);
       if ( tilemap[xtile-xtilestep][ytile]&BIT_DOOR )
           wallpic = DOORWALL+3;
       else
           #ifdef Ultra_Tex
           wallpic = vertwall[tilehit &BIT_WALL]; 
           #else
           wallpic = vertwall[tilehit &~BIT_WALL]; 
           #endif // Ultra_Tex
   }
   else
       wallpic = vertwall[tilehit];
       #ifdef Use_Patch2
     //  AssignWall (wallpic);  // ?
       if (ApplyPatch (wallpic, true))
               postsource = patchedwall+texture;
       else
               postsource = PM_GetTexture(wallpic)+texture;
#else
   postsource = PM_GetTexture(wallpic) + texture;
#endif

}


/*
====================
=
= HitHorizWall
=
= tilehit bit 7 is 0, because it's not a door tile
= if bit 6 is 1 and the adjacent tile is a door tile, use door side pic
=
====================
*/

void HitHorizWall (void)
{
   int wallpic;
   int texture;

   texture = ((xintercept+texdelta)>>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;
   if (ytilestep == -1)
       yintercept += TILEGLOBAL;
   else
       texture = TEXTUREMASK-texture;
#ifdef Use_Patch2
   if(lastside==1 && lastintercept==ytile && lasttilehit==tilehit && !(lasttilehit & BIT_WALL) && lastpatchnum==GetPatchNum(false))
#else
    if(lastside==0 && lastintercept==ytile && lasttilehit==tilehit && !(lasttilehit & BIT_WALL))
#endif

   {
       if((pixx&3) && texture == lasttexture)
       {
           ScalePost();
           postx=pixx;
           wallheight[pixx] = wallheight[pixx-1];
           return;
       }
       ScalePost();
       wallheight[pixx] = CalcHeight();
       postsource+=texture-lasttexture;
       postwidth=1;
       postx=pixx;
       lasttexture=texture;
       return;
   }

   if(lastside!=-1) ScalePost();

   lastside=0;
   lastintercept=ytile;
   lasttilehit=tilehit;
   lasttexture=texture;
   wallheight[pixx] = CalcHeight();
   postx = pixx;
   postwidth = 1;

   if (tilehit & BIT_WALL)
   {                                                               // check for adjacent doors
       xtile = (short)(xintercept>>TILESHIFT);
       if ( tilemap[xtile][ytile-ytilestep]&BIT_DOOR)
           wallpic = DOORWALL+2;
       else
           wallpic = horizwall[tilehit & ~BIT_WALL];
   }
   else
       wallpic = horizwall[tilehit];

       #ifdef Use_Patch2
    //   AssignWall (wallpic);  // ?
       if (ApplyPatch (wallpic, false))
               postsource = patchedwall+texture;
       else
               postsource = PM_GetTexture(wallpic)+texture;
#else
   postsource = PM_GetTexture(wallpic) + texture;
#endif
}

Asa

Cleaning up Wolf3D - Fri Aug 07, 2020 1:11 pm

So, what do the lines like this mean:

@@ -63,9 +63,11 @@

I'm aware of what #ifdef anf #ifndef directives do. My question was are there places where these directives should be but aren't? Wolf3DGuy did answer that in one specific instance. Finding them all will require me to know exactly what doesn't belong in Wolf3D that does belong in Spear, so be prepared for questions. Like this one. I don't recall where I read it, but somewhere in the source I think I saw it say that bo_gibs is Spear, not Wolf3D. I'll have to look again to be sure, but is it true or do I have it misremembered?

Also, will it have an impact on the game to re-order the list the way you did in your example above? If I should keep the same order, then there will be two #ifdef SPEAR/#endif's in that list. OK, I think I might have looked at your lists incorrectly the first time. It now seems as though they are two different code segments and I got confused by the similarity of item names.

Asa

Cleaning up Wolf3D - Thu Aug 06, 2020 7:30 am

OK, so to begin this, I am going to go through AryanWolf3D's list from the top. To start things off I will ask the question, does the following mean this is what the game started with before making any of the mods you did?

Code:
//
// Initial build: 83 bytes near memory, 184 kb main memory
//


And to dig into coding, let's deal with the general changes:

Code:
///////////////////
//
// General changes:
//
///////////////////

Added a way to show the main memory before the preload: -32 near bytes
Wrapped #ifdef/#ifndef SPEAR directives around exculsive SoD code: 114 near bytes
Turned off Word Alignment: 436 near bytes
Turn off the Treat Enums as Ints option: 1434 near bytes

Total freed: 1984 bytes near memory


What exactly did you change, and where? This seems like a good amount of memory to get back. For the #ifdef/#ifndef directives concerning SoD, I see those everywhere in the code. You mean to say there are parts iD didn't do that with?

Asa

God Mode sprite and BJ panting sprites - Wed Jul 08, 2020 8:51 am

Wolf3DGuy wrote:The god mode graphs can be found in SoD that's true, those are missing in Wolf3D, by the panting sprites I believe you mean the intermission screen inbetween levels with the ratios showing up and there's BJ breathing and holding his gun, those 2 sprites appear in the PC version as well, you don't have to add those, unless if you have the steam version of the game, for some reason they added one panting sprite twice so BJ is not animated there, strange that's for sure, but I believe you can find those sprites on Spriters Resource.

If you want to make the god mode faces appear in Wolf3D then you have to do more than just adding those 3 sprites in the vga files, I do not know if you work with DOS or ECWolf now. If you're trying to do it in DOS you have to add the faces after the mutant BJ sprite, then in GFXV_WL6.h you have to add the faces there as well afte Anyway, I will look for r MUTANTBJPIC, let's just call them GODMODEFACE1PIC, GODMODEFACE2PIC and GODMODEFACE3PIC. Also you have to raise the value in ORDERSCREEN by 3, do the same with the values for LATCHPICS_LUMP_END, NUMCHUNKS and NUMPICS as well also after the "File offsets for data items" lines too except for STRUCTPIC, STARTFONT, STARTFONTM and STARTPICS. Next, open up WL_AGENT in DrawFace remove the #ifdef SPEAR and the #endif lines. Save both files then compile the new exe, I believe it should work, if you want to add these in ECWolf then I have no idea how to do that, I hate scripting Doom after all! Cool  Laughing


I looked at the shareware SoD and found the god mode sprites there. I wish I hadn't lost the registered versions of the game and both mission packs, but that is the past and I have to deal with things as they are. Anyway, yes, I am referring to the intermission screen. I have version 1.1 of Wolf3D and it does not have the differing panting sprites. It has the same sprite twice. I never got the steam version of any game, so I know it isn't that. If 1.1 was supposed to have them, then somehow my copy was different. Anyway, I will see about locating the second sprite in the location you mentioned.

I never did anything in the way of modding the files before, other than to play around with the mapedit editor. I used MapEdit 8 (not 8.4), and found WDC when I wanted to look at the sprites. I used it to get a copy of the god mode image I used for my avatar here. That was many years ago. I have just begun to look at the sprites again, but I have never tried to insert graphics into the files before. I don't have the same computer I had back then (it was stolen when I had it stored at a friend's house), so I had to download the editors all over again. I went with HWE because it doesn't need DOSBox to run. When I downloaded ECWolf, I found that I had to run a patch on it to bring the files up-to-date (to v1.4 apparently). That patch didn't add anything to the sprites as far as I can tell. From your response, I take it that ECWolf is based more on the DOOM engine than the original WOLF engine?

I see that code changes are necessary to effect these changes. Is there a particular compiler I should use for recompiling the game? I have never written code for a PC app before.


Back to top

Current date/time is Fri Apr 19, 2024 7:44 am