coding:dos:highres

If you're looking to enable this feature in Wolf4SDL, visit How do I enable the built-in features like High Resolution Textures or Cloudy Skies?

:UNTESTED: This tutorial in it's current form has not been tested. If you are/aren't successful in building this feature from this tutorial, let me know via Discord. Always back up your project before pursuing new features! :UNTESTED:

How do I enable High Resolution Sprites in my game? (DOS)

This tutorial, originally posted to the (now down) website of Chaos Software by Ripper, adds support for 128×128 sprites and textures in the DOS Wolf3D engine, allowing for much more detailed sprites and textures in the game.

This assumes you've started a new DOS project that successfully builds in Borland C. If you haven't yet, then click here to start.

This tutorial also assumes that you have implemented Ripper's Remove The Scalers tutorial, which includes a specially altered WL_SCALE.C file. If you haven't, check out the tutorial and possible save yourself some memory!

Please take a seat before I welcome you to my seventh Wolf tutorial ;D

This tutorial will show you how to use 128×128 textures instead of those pixelized 64×64 ones. This doesn't mean at all, that you should blend all your standard textures and sprites to 128×128 pixel, as it can create a bad blurry effect.

- Ripper, from the original tutorial

Requirements:

  • Ripper's Remove The Scalers Tutorial

Open ID_PM.H and look for this line:

#define	PMPageSize		4096

Change it to the following:

#define	PMPageSize		16384

For the sounds still to work, we must not let ID_SD.C see these changes! Open ID_SD.C and locate these lines:

#pragma	hdrstop
#pragma	warn	-pia

#ifdef	nil
#undef	nil

Change it to the following, adding two lines directly above #ifdef nil:

#pragma	hdrstop
#pragma	warn	-pia

#undef   PMPageSize
#define  PMPageSize 4096

#ifdef	nil
#undef	nil

If you didn't already apply Ripper's PMFrameCount bugfix (see http://diehardwolfers.areyep.com/viewtopic.php?p=9517#9517), open ID_PM.C and go to this section of the PML_GetEMSAddress function:

	EMSList[emspage].lastHit = PMFrameCount;
	offset = emspage * EMSPageSizeSeg;
	offset += emsoff * PMPageSizeSeg;
	return((memptr)(EMSPageFrame + offset));

Add this line directly above it:

        PM_NextFrame();

This makes sure that every loaded texture has its own age, so 4 different high resolution textures in EMS can be used at the same time (of course, you can have any number of textures in main memory, as long as there's enough room ).

Open WL_DRAW.C and locate this section of the ScalePost function:

        yoffs+=((postx+i)>>2);
        yendoffs=viewheight/2+ywcount-1;
        yw=63;
        while(yendoffs>=viewheight)
        {
            ywcount-=32;
            while(ywcount<=0)
            {
                ywcount+=yd;
                yw--;
            }
            yendoffs--;
        }
        if(yw<0) break;
#ifdef SHADE_COUNT
        col=curshades[((byte far *)postsource)[yw]];
#else
        col=((byte far *)postsource)[yw];
#endif
        yendoffs=yendoffs*80+((postx+i)>>2);
        while(yoffs<=yendoffs)
        {
            vmem[yendoffs]=col;
            ywcount-=32;
            if(ywcount<=0)

If this code does not exist, make sure you've implemented Ripper's Remove The Scalers Tutorial. Make changes to the commented lines as below:

        yoffs+=((postx+i)>>2);
        yendoffs=viewheight/2+ywcount-1;
        yw=127;                     //THIS LINE IS CHANGED
        while(yendoffs>=viewheight)
        {
            ywcount-=64;            //THIS LINE IS CHANGED
            while(ywcount<=0)
            {
                ywcount+=yd;
                yw--;
            }
            yendoffs--;
        }
        if(yw<0) break;
#ifdef SHADE_COUNT
        col=curshades[((byte far *)postsource)[yw]];
#else
        col=((byte far *)postsource)[yw];
#endif
        yendoffs=yendoffs*80+((postx+i)>>2);
        while(yoffs<=yendoffs)
        {
            vmem[yendoffs]=col;
            ywcount-=64;                //THIS LINE IS CHANGED
            if(ywcount<=0)



In the same file, locate the following lines in HitVertWall:

	texture = (yintercept>>4)&0xfc0;
	texture = 0xfc0-texture;

Change each of them to:

	texture = (yintercept>>2)&0x3f80;
                texture = 0x3f80-texture;

Make the same changes in HitVertPWall.

Now we make similar changes in HitHorizWall and HitHorizPWall. Locate the following lines in these functions:

	texture = (xintercept>>4)&0xfc0;
	        texture = 0xfc0-texture;

Change them to the following:

	texture = (xintercept>>2)&0x3f80;
	        texture = 0x3f80-texture;



In HitHorizDoor, find this line:

	texture = ( (xintercept-doorposition[doornum]) >> 4) &0xfc0;

Change it to:

	texture = ( (xintercept-doorposition[doornum]) >> 2) &0x3f80;

In HitVertDoor, find this line:

	texture = ( (yintercept-doorposition[doornum]) >> 4) &0xfc0;

Change it to:

	texture = ( (yintercept-doorposition[doornum]) >> 2) &0x3f80;



If you're using DarkOne's Texture/Ceiling tutorial, you'll need to make some changes to the DrawFlats function. Locates these lines within that function:

        if(wallheight[x]>>3<=y)
        {
          u=(gu>>10)&63; v=(gv>>10)&63;
          color=*(src_top+((63-u)<<6)+(63-v));

// draw top pixel using <color>

          asm mov es,[screenseg]
          asm mov di,[bufferofs]
          asm add di,[top_add]
          asm mov al,[color]
          asm mov es:[di],al

          color=*(src_bot+(u<<6)+(63-v));

Change them to the following:

        if(wallheight[x]>>3<=y)
        {
            u=(gu>>9)&127; v=(gv>>9)&127;
            color=*(src_top+((127-u)<<7)+(127-v));

// draw top pixel using <color>

            asm mov es,[screenseg]
            asm mov di,[bufferofs]
            asm add di,[top_add]
            asm mov al,[color]
            asm mov es:[di],al

            color=*(src_bot+(u<<7)+(127-v));

Now, in your WL_SCALE.C file (Which has been changed as per the Remove the Scalers routine!), locate the following lines:

    pixheight=scale*2;
    actx=xcenter-scale;
    upperedge=viewheight/2-scale;

Change the first line in that group to read:

    pixheight=scale;

Directional Sprite Support

If you are also using Ripper's Directional Sprites tutorial, there's one final set of changes to be made. Go to the Scale3DShaper further down the file, and locate the following section of code:

    fixed height,dheight;
    int xpos[65];
    int slinex;

Change it to the following:

    fixed height,dheight;
    int xpos[129];
    int slinex;

Next, locate this piece of code which was added in the Directional Sprites tutorial:

    dxa=-(dxx>>1),dza=-(dzz>>1);
    dxx>>=6,dzz>>=6;
    dxa+=shape->leftpix*dxx,dza+=shape->leftpix*dzz;

Change it to:

    dxa=-(dxx>>1),dza=-(dzz>>1);
    dxx>>=7,dzz>>=7;
    dxa+=shape->leftpix*dxx,dza+=shape->leftpix*dzz;

Finally, locate these lines in the same function:

            pixheight=scale1*2;
            upperedge=viewheight/2-scale1;

And remove the *2 so it looks like the following:

    pixheight=scale1;
    upperedge=viewheight/2-scale1;

Save all your files, and compile. If everything has been done correctly, it should build without errors.

Keep in mind, you will need to convert your VSWAP sprites to 128×128. You can do this through specialized Wolf3D editing tools like WDC. To do so, create a project in WDC for your game (if you haven't already), and in Other Options in your Project Information, tick the box labelled Use 128×128 VSWAP images. This will convert all your exisint sprites to 128×128 resolution, ready for your engine changes!

  • coding/dos/highres.txt
  • Last modified: 2020/06/06 05:00
  • by zombie