DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[Code] Sprite Width Size Limit Fix - Darkone
Page 1 of 1
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

Topics: 153
Posts: 2255
Location: Ontario
canada.gif

PostPosted: Sun Jul 13, 2003 2:10 pm
   Subject: [Code] Sprite Width Size Limit Fix - Darkone
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Direct from Darkone's Old Pages

Sprite Fix - Eliminate errors when using 64 pixel wide sprites

Everybody who does some MODing to Wolf3D knows that it would crash if you used first and (or) last columns in a sprite. They are normally left empty. But sometimes you want to draw some sprite that would require them.
What to do?
Modify source!

Change (Replace) the ScaleShape and SimpleScaleShape functions in WL_SCALE.C as follows:

::: CODE :::
 

void ScaleShape (int xcenter, int shapenum, unsigned height)
{
   t_compshape   _seg *shape;
   t_compscale _seg *comptable;
   unsigned scale,srcx,startx,stopx,next_x;
   unsigned far *cmdptr;
   boolean leftvis, rightvis;

   shape=PM_GetSpritePage(shapenum);

   scale=height>>3;                 // low three bits are fractional
   if(!scale || scale>maxscale) return;   // too close or far away
   comptable=scaledirectory[scale];

   *(((unsigned *)&linescale)+1)=(unsigned)comptable;   // seg of far call
   *(((unsigned *)&linecmds)+1)=(unsigned)shape;      // seg of shape

   next_x=slinex=xcenter-scale;
   cmdptr=shape->dataofs;
   startx=shape->leftpix;
   stopx=shape->rightpix;

   for(srcx=0; srcx<=stopx; srcx++, slinex=next_x)
   {
      if(slinex>=viewwidth) break; // off the screen

      slinewidth=comptable->width[srcx];
      next_x+=slinewidth;       // next slinex
      if(srcx<startx) continue; // before the shape

      (unsigned)linecmds=*cmdptr++;

      if(!slinewidth) continue;

      if(slinewidth==1)
      {
         if(slinex<0 || slinex>=viewwidth) continue;

         if(wallheight[slinex]>=height) continue; // obscured by closer wall
         ScaleLine();
      }
      else
      {
         if(slinex<0)
         {
            if(slinewidth<=-slinex) continue; // still off the left edge

            slinewidth-=slinex;
            slinex=0;
         }
         else if(slinex+slinewidth>viewwidth)
            slinewidth=viewwidth-slinex;

         leftvis=(wallheight[slinex]<height);
         rightvis=(wallheight[slinex+slinewidth-1]<height);

         if(leftvis)
         {
            if(rightvis)
               ScaleLine();
            else
            {
               while(wallheight[slinex+slinewidth-1]>=height) slinewidth--;
               ScaleLine();
               break; // the rest of the shape is gone
            }
         }
         else
         {
            if(rightvis)
            {
               while(wallheight[slinex]>=height)
               {
                  slinex++;
                  slinewidth--;
               }
               ScaleLine ();
            }
            else
               continue;      // totally obscured
         }
      }
   }
}

void SimpleScaleShape (int xcenter, int shapenum, unsigned height)
{
   t_compshape   _seg *shape;
   t_compscale _seg *comptable;
   unsigned   scale,srcx,startx,stopx,next_x;
   int         t;
   unsigned   far *cmdptr;
   boolean      leftvis,rightvis;


   shape = PM_GetSpritePage (shapenum);

   scale = height>>1;
   comptable = scaledirectory[scale];

   *(((unsigned *)&linescale)+1)=(unsigned)comptable;   // seg of far call
   *(((unsigned *)&linecmds)+1)=(unsigned)shape;      // seg of shape

   next_x=slinex=xcenter-scale;
   cmdptr=shape->dataofs;
   startx=shape->leftpix;
   stopx=shape->rightpix;

   for(srcx=0; srcx<=stopx; srcx++, slinex=next_x)
   {
      if(slinex>=viewwidth) break; // off the screen

      slinewidth=comptable->width[srcx];
      next_x+=slinewidth;                        // next slinex
      if(srcx<startx) continue; // before the shape

      (unsigned)linecmds=*cmdptr++;

      if(!slinewidth) continue;

      if(slinewidth==1)
      {
         if(slinex<0 || slinex>=viewwidth) continue;

         ScaleLine();
      }
      else
      {
         if(slinex<0)
         {
            if(slinewidth<=-slinex) continue; // still off the left edge

            slinewidth-=slinex;
            slinex=0;
         }
         else if(slinex+slinewidth>viewwidth)
            slinewidth=viewwidth-slinex;

         ScaleLine();
      }
   }
}
 


You may also want to remove (useless now) variable (just remove this line):
Code:

static long longtemp;


to free some memory, which is precious in Wolf

And voila! You can draw normal sprites....[/b]


Last edited by BrotherTank on Wed Feb 11, 2004 12:53 pm; edited 3 times in total
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 13 Jan 2018

Topics: 55
Posts: 2118
Location: Canada
blank.gif

PostPosted: Sun Mar 20, 2005 10:41 pm
   Subject: Re: [Code] Sprite Width Size Limit Fix - Darkone
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Looks like he did alot more than just getting the outer edges to display (though not nearly as much as Ripper). Laughing

Weird thought: I noticed that when you're really close to unalarmed moving enemies in no clipping mode (perhaps also when walking closely behind them, not sure), that they shake when you have this Sprite Width fix enabled; like they're trying to grind though you - lol. They seem to keep sliding left about 4 times, like they surpass the calculation cycle at close range or something. Probably somewhat intentional, but I'm looking through it for a fix anyway; as noclip mode should RULE!! a.k.a. not suck.

*jumps out of this thread into another one now, spammer Ubermutant style*
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Tutorials View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts [Code] Add Text to Screen at Skill Level select - Chris
Author: Chris
3 2473 Tue Sep 28, 2010 6:59 pm
Tricob View latest post
No new posts [Code] Display Different Ammo Types on Statusbar-BrotherTank
Author: BrotherTank
1 2410 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Adding a Frames per Second Counter - Darkone
Author: BrotherTank
0 1733 Sat Mar 13, 2004 2:07 pm
BrotherTank View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 2003 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 2734 Sun Oct 26, 2003 1:21 am
Guest View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group