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

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Wolf3d Haven Forum

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


    [solved] Wall Patches in SDL

    Agent_Falcon93
    Agent_Falcon93
    Can I Play, Daddy?
    Can I Play, Daddy?


    Male
    Number of posts : 39
    Age : 37
    Location : subterranean caverns & catacombs
    Job : Entrepreneur
    Hobbie : Beach Days & Gardening
    Message : Author of Castle Erzengel Demo, and the upcoming Runes of North Castle Court, and the rest of the Series : Knights of the ᛋᛋ.
    Registration date : 2021-12-05

    endif - [solved] Wall Patches in SDL Empty [solved] Wall Patches in SDL

    Post by Agent_Falcon93 Sat Dec 11, 2021 4:30 pm

    The problem was due to another alteration, see a few replies down for a simplified guide to making this work on SDL, since Haasboy's site is down and the original tut for from Adam Biser is for DOS Wolf. 

    That Bird Fellow
    anyone had a crash from attempting the changes discussed in the DHW thread from Nembo about porting Adam Biser's wall patch tut to SDL, which also referenced a  conversion tut from Haasboy's website which is MIA as is his site.

    I cannot post links yet. 

    I get a shade table error crash on level start             




    WL_Shade.cpp 

    Line: 30 

    Expression: shadeID >=&& shadeID > lengthof(shadeDefs)
                   

    I have been able to sort through more stuff on my own, often it's something that should have been obvious, but with this shade table error I think this might be out of my realm.
    OK so I thought I had this working........ (My code is in the reply below).
    .... but...Now I am getting strange effects, the N-S axis shows a dif texture pair as the E-W axis shows, but the rest of my walls are fine.
    (That was caused by a vswap issue, textures now match - but other issues and crashes still occur, there are still very bad bugs) 
    ..Then when I turn around to the door in my test map, I get a crash, with an error 
    "  PM_GetPage: Tried to access illegal page: 54240  "
    (now 62496)

    [This seems IS due to issues with my implementation of removing the hard coded door and wall limits, see my reply 2x down, the issues seem to have nothing to do with the wall patches]


    O my.  scratch That's all for tonight. I will look into it tomorrow after my coffee.


    Last edited by Agent_Falcon93 on Sun Dec 12, 2021 2:16 pm; edited 11 times in total (Reason for editing : update.)



    endif - [solved] Wall Patches in SDL Right-arrow



    endif - [solved] Wall Patches in SDL Right-arrow farao "Call Pizza Hut and say Ardwolf"  endif - [solved] Wall Patches in SDL 1f355
    Agent_Falcon93
    Agent_Falcon93
    Can I Play, Daddy?
    Can I Play, Daddy?


    Male
    Number of posts : 39
    Age : 37
    Location : subterranean caverns & catacombs
    Job : Entrepreneur
    Hobbie : Beach Days & Gardening
    Message : Author of Castle Erzengel Demo, and the upcoming Runes of North Castle Court, and the rest of the Series : Knights of the ᛋᛋ.
    Registration date : 2021-12-05

    endif - [solved] Wall Patches in SDL Empty Re: [solved] Wall Patches in SDL

    Post by Agent_Falcon93 Sat Dec 11, 2021 6:58 pm

    endif - [solved] Wall Patches in SDL 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

    }

    endif - [solved] Wall Patches in SDL 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
    }


    Last edited by Agent_Falcon93 on Sat Dec 18, 2021 9:55 am; edited 3 times in total (Reason for editing : format issue)



    endif - [solved] Wall Patches in SDL Right-arrow



    endif - [solved] Wall Patches in SDL Right-arrow farao "Call Pizza Hut and say Ardwolf"  endif - [solved] Wall Patches in SDL 1f355
    Agent_Falcon93
    Agent_Falcon93
    Can I Play, Daddy?
    Can I Play, Daddy?


    Male
    Number of posts : 39
    Age : 37
    Location : subterranean caverns & catacombs
    Job : Entrepreneur
    Hobbie : Beach Days & Gardening
    Message : Author of Castle Erzengel Demo, and the upcoming Runes of North Castle Court, and the rest of the Series : Knights of the ᛋᛋ.
    Registration date : 2021-12-05

    endif - [solved] Wall Patches in SDL Empty Re: [solved] Wall Patches in SDL

    Post by Agent_Falcon93 Sun Dec 12, 2021 8:44 am

    So I implemented this feature on a version of my code from before I had implemented Chokans Removing the Hard Coded Limits of Walls and Doors tut, and it works fine
    It also works fine when the switch activated pushwalls are implemented (in the same code/engine, not patching the pwalls), and the doors and pwalls are functional on both axes. 

    Now back to my current codebase :
    I did have some severe mistakes in one files alterations for Remov. HC L DnWs tut, I have fixed that, except there are some lines dealing with pwalls that I am concerned with, but that does not explain the crashes caused when attempting to draw doors, which happens consistently on the N-S axis and occasionally on the E-W axis, factors / cause unknown.

    Again, I know it sounds redundant to use both features, but I have reasons, the explanation of which is better suited for a separate thread.



    endif - [solved] Wall Patches in SDL Right-arrow



    endif - [solved] Wall Patches in SDL Right-arrow farao "Call Pizza Hut and say Ardwolf"  endif - [solved] Wall Patches in SDL 1f355
    avatar
    Guest
    Guest


    endif - [solved] Wall Patches in SDL Empty Re: [solved] Wall Patches in SDL

    Post by Guest Sun Dec 12, 2021 9:42 am

    There's a few other ways to get 190 walls without changing tilemap, but they were written for DOS. Maybe I'll try porting them to SDL later or try and figure out how to get the version you tried working with wall patches but it sounds like a headache. WHY WON'T MY BROWSER LET ME CLICK ON THE EMOJIS AAAAA
    Agent_Falcon93
    Agent_Falcon93
    Can I Play, Daddy?
    Can I Play, Daddy?


    Male
    Number of posts : 39
    Age : 37
    Location : subterranean caverns & catacombs
    Job : Entrepreneur
    Hobbie : Beach Days & Gardening
    Message : Author of Castle Erzengel Demo, and the upcoming Runes of North Castle Court, and the rest of the Series : Knights of the ᛋᛋ.
    Registration date : 2021-12-05

    endif - [solved] Wall Patches in SDL Empty Re: [solved] Wall Patches in SDL

    Post by Agent_Falcon93 Sun Dec 12, 2021 10:14 am

    I have  just deactivated the Patches feature, it seems my implementation of removing the h lims is the issue.
    I can post links now, here it is. 
     http://dhw.wolfenstein3d.com/viewtopic.php?t=5450



    endif - [solved] Wall Patches in SDL Right-arrow



    endif - [solved] Wall Patches in SDL Right-arrow farao "Call Pizza Hut and say Ardwolf"  endif - [solved] Wall Patches in SDL 1f355

    Sponsored content


    endif - [solved] Wall Patches in SDL Empty Re: [solved] Wall Patches in SDL

    Post by Sponsored content


      Current date/time is Fri Apr 26, 2024 7:38 am