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       

[Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merge
Page 1 of 1
DieHard Wolfers Forum Index -> Code Crackers 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: 2248
Location: Ontario
canada.gif

PostPosted: Tue Aug 12, 2003 7:30 pm
   Subject: [Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merge
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts



Ok... On with the tutorials...

First we must install the routines required for both Ceiling/Floor Textures (Darkone) and Outside Atmosphere (Ripper)

Darkone's routine is here:

http://diehardwolfers.areyep.com/viewtopic.php?t=198#3

And Ripper's is here:

http://diehardwolfers.areyep.com/viewtopic.php?t=798#1

Follow the instructions correctly and completely. When you've got them installed, we can have a little fun... Smile

I know... you're probably saying, but the two routines conflict...

Well, yes they do a little.. But it is making the two compatible with one another that is where the fun begins and the possibilities increase...

It may take me a few days, but I will post updates and fixes to these routines so that they are compatible, and to show the various ways that one can have fun with them.. Smile

Greg
BrotherTank


Last edited by BrotherTank on Fri Feb 13, 2004 12:28 pm; edited 11 times in total
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Wed Aug 20, 2003 9:45 am
   Subject: Making the two routines compatible and then some... :)
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

EDITED Sept 4, 2003 - Fixed ASM and small Typo's - BrotherTank

Ok... Now that you have installed the two routines (Darkone's & Rippers), I'm sure you found that there are some interesting differences in the VGAClearScreen routines. Not to worry, as they both assume that you are painting the "ceiling/floor" with a colour... Darkone's routine substitutes 0x0000 (black) for the colour if you aren't using a texture... And Rippers gets it's colour to clear the screen from the original "VGACeiling" array. We want to be able to use both routines, so we have to change something to make them compatible. So here it is... Smile

Open the WL_DRAW.C file....

Modify (REPLACE) the VGAClearScreen routine to look like this:

::: CODE :::

void VGAClearScreen (unsigned ceiling, unsigned floor, int SkyState)
{
   if(!SkyState)
      {
         //
           // clear the screen - The original Way...
           //
         asm mov   dx,SC_INDEX
         asm mov   ax,SC_MAPMASK+15*256   // write through all planes
         asm out   dx,ax
   
         asm mov   dx,80
         asm mov   ax,[viewwidth]
         asm shr   ax,2
         asm sub   dx,ax               // dx = 40-viewwidth/2

         asm mov   bx,[viewwidth]
         asm shr   bx,3               // bl = viewwidth/8
         asm mov   bh,BYTE PTR [viewheight]
         asm shr   bh,1               // half height

         asm mov   es,[screenseg]
         asm mov   di,[bufferofs]
         asm mov   ax,[ceiling]
      
      
toploop:
         asm mov   cl,bl
         asm rep   stosw
         asm add   di,dx
         asm dec   bh
         asm jnz   toploop

         asm mov   bh,BYTE PTR [viewheight]
         asm shr   bh,1               // half height
         asm mov   ax,[floor]
           
           
bottomloop:
         asm mov   cl,bl
         asm rep   stosw
         asm add   di,dx
         asm dec   bh
         asm jnz   bottomloop
           
     }
   else
     {
         long siny,cosy;

         siny=(long)sintable[player->angle];
         cosy=(long)costable[player->angle];

         if(siny<0) siny=-(siny&0x7fffffff);
         if(cosy<0) cosy=-(cosy&0x7fffffff);

         PaintStars(siny,cosy);

         //
         // clear rest of the screen
         //
         asm mov dx,SC_INDEX
   asm mov ax,SC_MAPMASK+15*256         // write through all planes
   asm out dx,ax

   asm mov es,[screenseg]
   asm mov di,[bufferofs]

   asm mov dx,80
   asm mov ax,[viewwidth]
   asm mov bx,ax
   asm shr ax,2
   asm sub dx,ax

   asm shr bx,3

   asm mov al,byte ptr [viewheight]
   asm mov bh,al
   asm shl ax,3
   asm add di,ax
   asm shl ax,2
   asm add di,ax

   asm shr bh,1

   asm mov ax,[floor]  // original value 0x1919
   

   bottomloop2:
   
   asm mov cl,bl
   asm rep stosw
   asm add di,dx
   asm dec bh
   asm jnz bottomloop2
   
     }
}



With this done, we now call the VGAClearScreen using 3 parameters VGAClearScreen (a, b, c) where:

a = The colour of the ceiling we want to use... in format 0x0000
b = The colour of the floor we want to use... in format 0x0000
c = Either 1,2,3 or 0 - 1 or greater = Paint Sky with Stars/Moon - 0 = Use colour "a" above to clear ceiling.

Now we need to come up with a new way of calling these routines and defining which ones we will use. This can be accomplished by replacing ThreeDRefresh routine as follows:

::: CODE :::

void   ThreeDRefresh (void)
{
   int tracedir, texture, SkyState;
   unsigned ceiling, floor;
   boolean flats;
   //
   // Get ceiling colour from vgaCeiling array
   // and set default floor to Gray (original)
   // Set other defaults as well
   //
   ceiling=vgaCeiling[gamestate.episode*10+gamestate.mapon]; 
   floor = 0x1919;
   SkyState = 0;
   flats = false;
   texture = 0;
   
   // this wouldn't need to be done except for my debugger/video wierdness
      outportb (SC_INDEX,SC_MAPMASK);

   //
   // clear out the traced array
   //
   asm mov   ax,ds
   asm mov   es,ax
   asm mov   di,OFFSET spotvis
   asm xor   ax,ax
   asm mov   cx,2048   // 64*64 / 2
   asm rep stosw
   
   bufferofs += screenofs;

   //
   //  Here we define what we are going to use for each map.
   //
   //  SkyState - 0 = Original Coloured Ceiling
   //                1 = Starry Sky
   //               2 = Starry Sky with Rain
   //               3 = Starry Sky with Snow
   //    ceiling, floor - Only if you don't want to use the defaulted originals
   //  flats - true = use defined textures below - false = no ceiling/floor texture
   //  texture - the Texture that you wish to use for your ceiling/floor 
   
      switch (gamestate.mapon) // defining which level and what you want for it.
      {
         //
         // 1 case for each map in your game
         // You need only define the things you are going to
         // use for that level.
         //
      case 0: // Defines for map level 1
         //ceiling = 0x0000;  // Remmed to use the default ceiling colour
         //floor = 0x0000;    // Remmed to use the default floor colour
         //flats = true;      // Remmed - No ceiling floor textures
         //texture = 0;       // Remmed - Not used as flats = false
         SkyState = 1;         // Sky with Stars
         break;
      case 1: // Defines for map level 2
         //ceiling = 0x0000;   // Remmed to use the default ceiling colour
         floor = 0x0000;         // Use "black" as Floor colour
         //flats = false;       // Remmed - No Ceiling/Floor Textures
         //texture = 0;        // Not used as flats = false
         SkyState = 2;          // Sky with Stars and rain
         break;
      case 2: // Defines for map level 3
         ceiling = 0x2a3a       // Use our own defined ceiling colour
         //floor = 0x0000;       // Remmed use default gray colour
         flats = false;        // Use Wolf3d original Look
         //texture = 0;          // Not used as flats = false
         //SkyState = 0;        // Remmed - Use Wolf3d original look
         break;
      case 3: // Defines for map level 4
         //ceiling = 0x0000;   // Remmed to use the default ceiling colour
         //floor = 0x0000;     // Remmed for default Floor colour
         flats = true;           // Use Ceiling/Floor Textures
         texture = 1;            // Used Stone Texture
         //SkyState = 2;       // Using Ceiling/Floor Textures
         break;
         
         //   
         // Continue with "case" defines util you have defined all
         // the levels you wish to use in your game.
         //
         // ie: if you have 10 levels, you need 10 "case" defines
         //
      
      }
      
      // if not using textures clear the screen
      
      if (!flats) VGAClearScreen(ceiling, floor, SkyState);
      
      // next we draw the walls
      
      WallRefresh();
      
      // next we draw the textures if used
      
      if (flats) DrawFlats(texture, texture + 1); // draw textured floor/ceiling

      // then we draw all the scaled images
      // of guards and object sprites

      DrawScaleds();

      // next we call to Rippers Snow & Rain if Skystate > 1

      if(SkyState==3) PaintSnow(viewsin,viewcos);
      else if(SkyState==2) PaintRain(viewsin,viewcos);

      // then we draw the players hands/weapons

        DrawPlayerWeapon ();   

      //
      // show screen and time last cycle
      //
      if (fizzlein)
         {
            FizzleFade(bufferofs,displayofs+screenofs,viewwidth,viewheight,20,false);
            fizzlein = false;
            lasttimecount = TimeCount = 0; // don't make a big tic count
         }

      bufferofs -= screenofs;
      displayofs = bufferofs;

      asm cli
      asm mov   cx,[displayofs]
      asm mov   dx,3d4h   // CRTC address register
      asm mov   al,0ch   // start address high register
      asm out   dx,al
      asm inc   dx
      asm mov   al,ch
      asm out   dx,al      // set the high byte
      asm sti
      
      
      bufferofs += SCREENSIZE;
      if (bufferofs > PAGE3START) bufferofs = PAGE1START;

      frameon++;
      PM_NextFrame();
}


Now that we've done this, we can get rid of some of the code from both original tutorial installs. The following lines can be removed:

From Darkone's routine:

::: CODE :::

#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 (from FloEdit). First texture goes to floor, second to ceiling
*/


Remember to return the vgaCeiling array defines back to factory original.. Smile

And From Ripper's routines:

::: CODE :::

#define LEVELSTATES 10

int levelSkyState[LEVELSTATES]={3,2,1,0,0,0,0,1,0,0};


Voila... the two routines are now compatible, and you can define what you want for each level. Next, we'll look at using different textures for ceilings and floors....

Enjoy...

Greg
BrotherTank


Last edited by BrotherTank on Thu Sep 04, 2003 7:26 pm; edited 1 time in total
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Wed Aug 20, 2003 9:57 am
   Subject: The Next Step... Controlling Textures...
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Where do I store the Textures for Ceiling/Floor - Solution 1

There are probably many solutions to this problem.

The easiest is to just use the original wall tiles as ceiling/floor textures just as Darkone did in his example, but for most that isn't quite enough or they want a different way of dealing with them. James suggested using the "USE_TEX(65) example" where we don't change the code, but rather the defines in the "VgaClearScreen Array".. That works as well, but this example uses code changes... and integrates easily with the routines I modified above...

Lets say for all of our examples we are using 10 maps for our game.

The simplest solution to this problem is to add them to the VSWAP file using a simple technique:

Using Floedit (any version) we add new graphic slots for each level of your game. ie: if you are going to have 10 levels, then you click the "Add a New Object" (Graphic) button 1 time (once) for each level in your game or as in this example 10 times (again once for each level). Now that will add 20 graphic slots (2 slots for each click of the button - 1 for floor - 1 for ceiling ). This can be used to our advantage as it does two things:

1. It allows us to easily define which textures will be used for ceiling/floor..

2. It allows us to use "different" textures for ceiling and floor.

By doing this, we do not need to modify the code each time we want to make a change to the atmosphere of our game. We just swap in and out graphics until we have the look that we are looking for (this is the exact model used in Majik Monkee's Stonehenge code).

In our programming example below, the first slot is the "Floor" and the second slot becomes the "Ceiling". So now you have total control over which graphics you are going to use for each level in the game.

We achieve this by modifying the DrawFlats routine as follows:

::: CODE :::
src_bot=PM_GetPage(tex_f); // load floor texture
src_top=PM_GetPage(tex_c); // load ceiling texture


to look like this:

::: CODE :::
src_bot=PM_GetPage(DOORWALL - 20 + tex_f); // load floor texture
src_top=PM_GetPage(DOORWALL - 20 + tex_c); // load ceiling texture


The 20 is the offset which defines the number of levels * 2 in your game (using our 10 level example).

Finally in the "ThreeDRefresh" Routine, I modified the call to "DrawFlats" so that it passes the gamestate.mapon value rather than the UseTex value.... ie:

::: CODE :::
if(flats)
     DrawFlats(texture, texture+1); // draw textured floor/ceiling


Was changed to:

::: CODE :::
if(flats)
     DrawFlats(gamestate.mapon, gamestate.mapon+1); // draw textured floor/ceiling


If you have entered the code properly, and added your graphics properly, you should now be able to see your new graphics as ceiling and floor textures using whatever graphics that you install into each of the slots. You no longer need the "texture" define... Smile

Now, if you are adding more levels, then you only need to add more graphics and change the offset in the above code.

Using this method, you will not have to worry about the NOEMS bug that crops up with using seperate textures for ceiling and floor.

Greg
BrotherTank


Last edited by BrotherTank on Wed Aug 20, 2003 10:34 am; edited 1 time in total
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Wed Aug 20, 2003 10:02 am
   Subject: Combining Effects of Floor Texture with Starry Sky
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Now we've decided that we want Ripper's Starry Sky with a floor texture... So let's have some more fun...

We need to move the define of "SkyState" from the beginning of the ThreeDRefresh routine and put it in the WL_DEF.H file at the bottom...

ie: ThreeDRefresh used to look like this near the top

::: CODE :::
int tracedir, texture, SkyState;


And now we modify it to look like:

::: CODE :::
int tracedir, texture;


If you modfied your code to use the previous post mod on textures, then your define would look like:

::: CODE :::
int tracedir;
as we no longer require the "texture" variable.

And we add the value "SkyState" to the end of the WL_DEF.H file as:

::: CODE :::
int SkyState;


With that done, we modify the "DrawFlats" routine as follows:

::: CODE :::
// ------------------------- * Textured flats * -------------------------
/*
** Draw Textured Floor/Ceiling
*/

void DrawFlats(unsigned tex_f, unsigned tex_c)
{
  int x, y, y0, halfheight;
  unsigned top_offset0, bot_offset0, top_offset, bot_offset;
  unsigned top_add, bot_add;
  byte p, color;
  byte far *src_bot, far *src_top;
  fixed dist;            // distance to row projection
  fixed tex_step;        // global step per one screen pixel
  fixed gu, gv, du, dv; // global texture coordinates
  int u, v;              // local texture coordinates

// ------ * prepare * --------

  halfheight=viewheight>>1;
  y0=min_wallheight>>3;      // starting y value
  if(y0>halfheight) return;  // view obscued by walls
  if(y0==0) y0=1;           // don't let division by zero
  top_offset0=80*(halfheight-y0-1);  // and will decrease by 80 each row
  bot_offset0=80*(halfheight+y0);  // and will increase by 80 each row

  src_bot=PM_GetPage(tex_f); // load floor texture
  src_top=PM_GetPage(tex_c); // load ceiling texture

// draw horizontal lines

  for(p=0; p<4; p++)
  {
    asm mov ax,0x0102
    asm mov cl,[p]
    asm shl ah,cl
    asm mov dx,0x3c4
    asm out dx,ax

    for(y=y0, top_offset=top_offset0, bot_offset=bot_offset0; y<halfheight; y++, top_offset-=80, bot_offset+=80)
    {
      dist=(heightnumerator/y)<<5;
      gu= viewx+FixedByFrac(dist, viewcos);
      gv=-viewy+FixedByFrac(dist, viewsin);
      tex_step=(dist<<8)/viewwidth/175;
      du= FixedByFrac(tex_step, viewsin);
      dv=-FixedByFrac(tex_step, viewcos);
      gu-=((viewwidth>>1)-p)*du;
      gv-=((viewwidth>>1)-p)*dv; // starting point (leftmost)
      du<<=2; // 4pix step
      dv<<=2;
      for(x=p, top_add=top_offset, bot_add=bot_offset; x<viewwidth; x+=4, top_add++, bot_add++)
      {
        if(wallheight[x]>>3<=y)
        {
          u=(gu>>10)&63; v=(gv>>10)&63;
          color=*(src_top+((63-u)<<6)+(63-v));

// Don't Draw Ceiling tile if SkyState - so we can have textures on floor with Sky

   if (!SkyState)   // added line for mod
   {                   // added line for mod
   
// 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
     }      // added line for mod

          color=*(src_bot+(u<<6)+(63-v));
   
// draw bottom pixel using <color>

          asm mov es,[screenseg]
          asm mov di,[bufferofs]
          asm add di,[bot_add]
          asm mov al,[color]
          asm mov es:[di],al
        }
        gu+=du; gv+=dv;
      }
    }
  }
}


Now with this done... We can go back to the defines in the ThreeDRefresh routine and tell it to use a texture AND the starry sky/snow/rain....

Greg
BrotherTank
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Wed Aug 20, 2003 10:06 am
   Subject: Fun with Textures Questions
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

If you have any questions about the routines I've been workin on

(see http://diehardwolfers.areyep.com/viewtopic.php?p=7862#7862 )

Then this is the place to ask them... I'm trying to keep the other thread as just a tutorial...

Greg
BrotherTank


Last edited by BrotherTank on Wed Aug 20, 2003 10:41 am; edited 1 time in total
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Thu Sep 04, 2003 7:50 pm
   Subject: Re: Fun with Textures (Ceiling/Floor/Sky/Rain/Snow)
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ok... By now, many have sent me PM's saying I can't get it working....

Please go back and follow the directions completely.... Embarassed I have modified the tutorial to reflect the spelling mistakes and repaired the ASM that were giving people problems (I didn't have the same problems here, but I've put things in a different frame now, and this should definitely stop all of the problems). Most people were complaining about ASM problems... Chalk it up to different computer setups...

Now... if you have followed everything properly, you should be able to do quite a bit with your game. Defining what is available on each level is now much easier to deal with, and makes changing things a snap.

If you have played even further (messing with the variables that define what is happening on each level and the "if" conditions that they activate) you can probably get yourself to a point where you have something that I found long ago.... Ceiling and Floor Textures with Rain! Yes Rain.... it actually makes the ceiling look like it's dripping.. Smile Something that may appear in EoD... MCS and I played with this for a while Cheesy Grin

Now some of you have not found this problem yet, but I'm sure you will... If you decide to redefine the way that your textures are grabbed and want to use textures that are not placed beside each other in the vswap, then you can end up with the ceiling/floor textures changing as you turn to different angles. This too can be eliminated... Split the Drawflats into TWO (2) routines. One to draw the ceiling, and one the floor. It's not that difficult...

Hopefully with what I have given here, it will help those that keep asking over and over about ceiling/floor textures and the atmosphere/sky tutorials, and what can be done with them.

Enjoy...
Greg
BrotherTank
Guest




Last Visit:





PostPosted: Fri Sep 19, 2003 9:25 am
   Subject: Re: Fun with Textures Questions
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

The texture sky ceiling floor is possible to do If you don't bieleve me goto my website I have pics from my upcoming tc to prove it. The first post Brother Tank did did not work butg when he revised and posted a second time it worked.

ps. The problem is in your THREEDREFRESH routine.
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Fri Sep 19, 2003 11:07 am
   Subject: Re: Fun with Textures (Ceiling/Floor/Sky/Rain/Snow)
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Ok... Now a few of you have found the memory leak problem...

This occurs when you try and load textures in the drawflats routine that are not concurrent.... better example... you are using the Sky with the Floor texture only... What happens is that the floor seems to change texture/colour.... Yes, this is a memory problem. If you enable EMS, the problem goes away, but for those that don't care to do that, here is a simple fix:

In the Drawflats routine, find:

::: CODE :::
src_top=PM_GetPage(tex_c); // load ceiling texture


and change it to read:

::: CODE :::
if (!SkyState) src_top=PM_GetPage(tex_c); // load ceiling texture


Yep... it's that simple.... As we don't need the ceiling texture when we are using the sky, then we don't need to load the texture, and thus the problem/error goes away....

Greg
BrotherTank
Sockman
Don't Hurt Me
Don't Hurt Me


Joined: 19 Jun 2003
Last Visit: 24 Jun 2008

Topics: 3
Posts: 67
Location: City 17
usa.gif

PostPosted: Fri Sep 19, 2003 2:19 pm
   Subject: Re: Fun with Textures Questions
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I am using his update, and I know the prob is in ThreeDRefresh. All I need to know is how to define it to use Skystate and Floor Texture. In the ThreeDRefresh they have a switch(case); for each level. I need to know how to do a starry sky and a textured floor.

_________________
This isn't revenge; it's punishment.
Guest




Last Visit:





PostPosted: Mon Sep 22, 2003 10:00 am
   Subject: Enable EMS
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hey brother Tank question your routine if (!SkyState) etc. works for some levels but at times I still get the memory issue for the black floor. How do you enable EMS?
Codetech84
Code Master
Code Master


Joined: 12 Mar 2003
Last Visit: 04 Nov 2018

Topics: 22
Posts: 1283
Location: Rauma - Finland
finland.gif

PostPosted: Mon Sep 22, 2003 11:01 am
   Subject: Re: Enable EMS
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I don't see how that would help, but you could try VDMS.

_________________
Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
BrotherTank
Forum Administrator
<B>Forum Administrator</B>


Joined: 01 Mar 2003
Last Visit: 13 Sep 2017

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

PostPosted: Mon Sep 22, 2003 2:50 pm
   Subject: Re: Enable EMS
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Codetech84 wrote:
I don't see how that would help, but you could try VDMS.


Actually, it makes a very big difference. It's obvious that you haven't played with the code as it produces the problem that MCS and I found with Darkone's routine when you try and use two textures that are not sequential ie: Drawflats (ceiling, ceiling +10).... It is a problem with the PM_Getpage routine called within Drawflats. Without EMS enabled, the pages are constantly loaded (graphics) each time the program does a redraw of the screen. Occasionally there is a memory leak, which causes one of the two textures to either disappear or change to the other. With EMS enabled, the graphics are stored in EMS pages and the problem disappears.

Luke wrote:
How do you enable EMS


If you are using windows 98 all you have to do is bring up the "properties" window for the DOS shell ("right click mouse" on the Dos Tab for the window). Select use EMS and give it at least 1024 for memory. The system might want you to reboot if you don't have the EMS enabled in your config.sys file.

Hope that helps,

Greg
BrotherTank
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Wed Sep 24, 2003 1:46 pm
   Subject: Re: Enable EMS
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

There is no memory leak or something like that.
The problem with PM_GetPage is, that inside the PML_GetEMSAddress function at first (when drawing a new frame) 4 textures plus 4*3 textures inside the same page (i.e. 4 + 5,6,7 or 9 + 8,10,11) can be loaded at one time and can be accessed at one time without having to relocate it using PM_GetPage.
But as the PMFrameCount is used to tell, how old a page is, after those 4 loaded pages all pages have the same age, as the PMFrameCount is only increased once per frame. So it simply uses the first page for all the following PM_GetPage calls in this frame.

Now, when DrawFlats is called, PM_GetPage puts the "tex_f" texture including the other 3 textures of that page into the first page and returns the address of the "tex_f" texture into "src_bot". Then PM_GetPage becomes called again, and shall give us a pointer to a second texture we want to use at the same time.
But what does that stupid PM_GetPage do??
It loads the page of "tex_c" into the FIRST page again, where our "tex_f" page was, and simply overrides it...
So what's left is a more or less invalid pointer "src_bot" which now points into the "tex_c" page which works if the floor texture is inside the same page as the ceiling texture Wink
But if it's not, you get a totally different texture for the floor, which isn't really what you want, isn't it? Mr Green

To avoid this complete mess, you can simply add a "PM_NextFrame();" inside the PML_GetEMSAddress function before the "EMSList[emspage].lastHit = PMFrameCount;" line so that EVERY new loaded page will have it's own age, so you'll be able to have 4 seperate textures at once again ;D

Hope that helped Mr Green
Ripper
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 22 Aug 2019

Topics: 56
Posts: 2236
Location: Canada
blank.gif

PostPosted: Thu Nov 06, 2003 5:54 pm
   Subject: Re: Enable EMS
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks Ripper. I was planning on trying to write my own code for textured floors/ceilings (hey, anything's possible! lol), but I decided to plug in Darkone's tutorial just for fun (than realizing how close it was to the original HOS code, so I kept it); and noticed the same problem as you guys in certain environments. I figured that it had to do with the way the Page Manager stores the walls in EMS (after doing some quick testing), but I didn't look at ID_PM.C in as much detail as you before I came across this cool thread.

I think by using the words "memory leak", Greg was trying to imply the same thing you were. You gotta give him credit for realizing that the code incorporated a problem with EMS, but I noticed the exact opposite to his theory; how enabling EMS was what caused the problem in the first place (and using the "-noems" tag worked as a quick fix). Interesting stuff. Well, thanks for posting that line that throws new walls onto a new page Ripper - that definately saved me some time with code tweaking. Wink
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Fri Nov 07, 2003 9:22 am
   Subject: Re: Enable EMS
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

WOW!! At last someone noticed my answer... I was VERY surprised that NOBODY answered this especially as this really is a problem, if you play around with more than one texture (OK, maybe there aren't many people playing around with graphics, but I found it very interesting to find this out...)

The last time I had this problem was, when I wrote the floor/ceiling code, cause I was using many textures and it wasn't possible to load a new texture for every texture change which would really slow down. So I tried to load several textures at once, as the source implied that it would be possible to have 4 different textures... But strangely it didn't work Wink

As my understanding of the wolf code wasn't very deep at that point I simply did a work around and loaded all needed textures at level startup into a buffer inside the main memory instead of EMS. Of course this way, I wasn't able to use too many textures but at first it worked ;D
But as it's been a while I looked at the floor/ceiling code I don't know how it's currently working anymore Mr Green

Anyways, thanks for answering ;D
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 11 Mar 2003
Last Visit: 22 Aug 2019

Topics: 56
Posts: 2236
Location: Canada
blank.gif

PostPosted: Tue Nov 11, 2003 11:17 pm
   Subject: Re: Enable EMS
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

That's pretty cool how, at first, you had to resolve to making your own main memory buffer that refreshed when you start each level. How much memory could it store - 8192 bytes? Sounds like you knew alot more than me about that kinda stuff even back than; haha. Where did you manage to snag the extra memory from anyways? I love just making MAP files for everything in Borland and trying to figure out how much the memory changes with everything you do; and where the difference takes place (turns out you can save atleast 2600 bytes by getting rid of the bosses, 3800 by getting rid of the menu core, and 650 from the debugging codes). I'm sure you found some much better places though (maps seem to eat up 16,640 bytes?); I haven't even looked at some of the main places like graphics/music allocation yet. Oh well, I'm learning too... Smile

One thing I really miss from my old computer was being able compress the Gamemaps file with your ChaosEdit beta. Man, that was interesting stuff (and how you talked about being able to compress the sprites on your webpage). I gotta try playing around with that CarmackExpand and CarmackCompress stuff in ID_CA.C sometime to see if I can get anywhere near the same results as you and Andy did; could be a really fun adventure (wonder why they decided to have Mutants go beyond 255 (1 byte) on the mapsegs[1] list? Or if that even makes a difference - lol). Mr Green
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Wed Nov 12, 2003 1:48 pm
   Subject: Re: Enable EMS
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hmmmm, just had a look at the old code again...
That version just uses GetPage and tries to load up to 8 textures...
But he'll only be able to load 4 textures, as there are only 4 ems pages available (clearscreen is called more or less after the pm_nextframe command, which allows a new set of 4 textures to be loaded as mentioned above).
I remember this bug appearing when we worked on a project under the codename "Totengräber" (I know the name's already used, but it was only a project codename Wink), when we used more than those stupid 4 different textures.
So then (not that early anymore *g*) I came up with the idea of loading it into main memory before all other things to be sure, it REALLY is in main memory. That way there is simply more of the other stuff in EMS but there's no problem with missing main memory Wink
I just added these lines into the PM_Preload function before the first while block:

::: CODE :::
   for(i=0;i<MAXFLCETEX;i++)
   {
      PML_LoadPage(usedtextures[i],true);
      current++;
      maintotal--;
      update(current,total);
   }

It's really that simple ;D
Of course you'll need to free that memory manually when you start the next map. I did it the following way in the SetupGameLevel function:

::: CODE :::
//
// release memory used for floors and ceilings
//

   for(i=0;i<numusedts;i++)
   {
      x=usedtextures[i];
      if(PMPages[x].mainPage<PMMaxMainMem && PMPages[x].mainPage!=-1)
      {
         MainMemUsed[PMPages[x].mainPage]&=~pmba_Used;
      }
      PMPages[x].emsPage=PMPages[x].mainPage=-1;
   }

I guess some people could use this idea to get additional memory for stuff that doesn't fit into main memory anymore (perhaps sprite data saved externally or what ever Wink)

Hope it's of use for anyone ;D
Greets
Ripper

PS: What do you mean with "on your old computer"? Did you loose ChaosEdit? Why didn't you ask for it again? Of course we'd send the last official version! Just ask ;D
Guest




Last Visit:





PostPosted: Wed Nov 12, 2003 5:15 pm
   Subject: Brothertanks 'fun with textures' slight mod
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

i noticed that in that mod, with the new vgacleear screen thing, if you add another variable..... add in the 'texture2' stuff
::: CODE :::

in wl_draw:
ThreeDRefresh()
{
int tracedir,texture, texture2;

<.....>

texture = 0;
texture2=0;

<.....>
switch(gamestate.mapon)
{
case 0:
// Here, you can put the 'texture2' as a variable, (the wall pic you want is the number, just as 'texture'
texture2 = 33;
<.....>
if(flats) DrawFlats(texure,texture2);



and thats that, so now you can use any individual wallpic you want in the drawflats stuff.... hope you can find that useful SOMEHOW, cuz i did.
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Thu Feb 05, 2004 3:01 pm
   Subject: Messed up sky with correct floor
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

For the sky be working together with the floor texture, there's only one thing missing: Open up the WL_DRAW.C and change the ThreeDRefresh like this:

::: CODE :::
      // if not using textures clear the screen
       
      if (!flats || SkyState) VGAClearScreen(ceiling, floor, SkyState);
       
      // next we draw the walls
       
      WallRefresh();

It should be that easy Wink
Guest




Last Visit:





PostPosted: Mon Feb 16, 2004 6:18 pm
   Subject: Re: [Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merg
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Okay, this is great. One problem:

I have 6 episodes in my TC. The way this is written, every single Level 1 will have the same texture/skies, every level 2, etc. I want E1L1 to have different textures than E2L1.

I know I could go do a whole big "if((gamestate.episode)==0)" thing. But I'm not exactly sure how I should go about this.

EDIT:

Nevermind, figured it out. For those of you who are wondering, here's how:

::: CODE :::

case 0:
  if (gamestate.episode==0)
  {
    flats = true;
    texture = 44;
  }
  if (gamestate.episode==1)
  {
    flats = true;
    texture = 20;
  }
  (repeat for how ever many episodes you have)
  break;


There's probably a better way to do this, but just wanted to let people like me, who are less code-savvy, how to do this.
RichterBelmont12
DieHard Wolfer
DieHard Wolfer


Joined: 14 Aug 2004
Last Visit: 07 Aug 2019

Topics: 98
Posts: 1524
Location: New Jersey
usa.gif

PostPosted: Sun Jan 09, 2005 6:43 pm
   Subject: Re: [Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merg
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

ok this code
::: CODE :::


      case 0: // Defines for map level 1
         //ceiling = 0x0000;  // Remmed to use the default ceiling colour
         //floor = 0x0000;    // Remmed to use the default floor colour
         //flats = true;      // Remmed - No ceiling floor textures
         //texture = 0;       // Remmed - Not used as flats = false
         SkyState = 1;         // Sky with Stars
         break;
      case 1: // Defines for map level 2
         //ceiling = 0x0000;   // Remmed to use the default ceiling colour
         floor = 0x0000;         // Use "black" as Floor colour
         //flats = false;       // Remmed - No Ceiling/Floor Textures
         //texture = 0;        // Not used as flats = false
         SkyState = 2;          // Sky with Stars and rain
         break;
      case 2: // Defines for map level 3
         ceiling = 0x2a3a       // Use our own defined ceiling colour
         //floor = 0x0000;       // Remmed use default gray colour
         flats = false;        // Use Wolf3d original Look
         //texture = 0;          // Not used as flats = false
         //SkyState = 0;        // Remmed - Use Wolf3d original look
         break;
      case 3: // Defines for map level 4
         //ceiling = 0x0000;   // Remmed to use the default ceiling colour
         //floor = 0x0000;     // Remmed for default Floor colour
         flats = true;           // Use Ceiling/Floor Textures
         texture = 1;            // Used Stone Texture
         //SkyState = 2;       // Using Ceiling/Floor Textures
         break;
         
         //   
         // Continue with "case" defines util you have defined all
         // the levels you wish to use in your game.
         //
         // ie: if you have 10 levels, you need 10 "case" defines
         //


I put 11 cases & it didn't Work need help fast

_________________
http://www.youtube.com/RichterBelmont12

https://www.facebook.com/RichterBelmont123

https://twitter.com/Richterbelmont6
KyleRTCW
DieHard Officer
DieHard Officer


Joined: 30 Jul 2003
Last Visit: 10 Aug 2019

Topics: 45
Posts: 510
Location: Ohio
usa.gif

PostPosted: Mon Jan 10, 2005 3:48 am
   Subject: Re: [Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merg
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

What do you mean it didn't work? What's wrong with it? Not give you rain? No textures work? For the 158,236th time be accurate, we have to know what exactly is going on.

You probably messed up somewhere, btw, people have posted bug fixes below Greg's Tutorial Post like Ripper, you muist read the whole topic. Mysteriously, Greg never updated his tutorial either. Just read the whole topic, maybe you'll find something. Sarcastic

_________________
Steam: http://steamcommunity.com/id/stormx312
RichterBelmont12
DieHard Wolfer
DieHard Wolfer


Joined: 14 Aug 2004
Last Visit: 07 Aug 2019

Topics: 98
Posts: 1524
Location: New Jersey
usa.gif

PostPosted: Mon Jan 10, 2005 11:57 am
   Subject: Re: [Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merg
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

NVM I got it to work

_________________
http://www.youtube.com/RichterBelmont12

https://www.facebook.com/RichterBelmont123

https://twitter.com/Richterbelmont6
JackaL
DieHard SS
DieHard SS


Joined: 25 Jun 2004
Last Visit: 04 Apr 2011

Topics: 30
Posts: 335
Location: Rotorua, New Zealand
newzealand.gif

PostPosted: Thu Feb 24, 2005 11:50 pm
   Subject: Re: [Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merg
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

How do I set the settings to have a sky and a textured floor only. I've tried many ways, but the result is a HOM (Hall of mirrors) problem on the sky. I've inserted the extra code. This is driving me mad because I've done a lot of different ways Mad !
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 5:11 ago.

Topics: 108
Posts: 1723
Location: A hole in the wall
australia.gif

PostPosted: Fri Feb 25, 2005 2:51 am
   Subject: Re: [Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merg
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Have you coded the fourth post? That's where it does it.

Oh yeah, I finally got this map defined! I simply did this in ThreeD Refresh:

::: CODE :::

//All Map Defined Features below (ceiling and floor colour/texture, Starry Sky)

   ceiling   =   tilemap[0][0];
      floor    =    tilemap[1][0];
      SkyState   =    tilemap[2][0];
      flats    =    tilemap[3][0];
      texture      =    tilemap[4][0];


I then, did everything else of course, but left the switch statement out of it. Works great, although I do get some wierd effects when all of the above are defined Think , but you have to expect that.[/code]

_________________
WolfSource - Your news source since the beginning of time (2019)
Rux
DieHard Guard
DieHard Guard


Joined: 17 Dec 2006
Last Visit: 15 Nov 2015

Topics: 34
Posts: 202
Location: Port Angeles, WA
usa.gif

PostPosted: Wed Dec 20, 2006 2:30 pm
   Subject: Re: [Info] Fun with Textures - CFTextures/Sky/Rain/Snow Merg
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

When are you giving the tutorial to merge shading with this tutorial??

EDIT: Nevermind... I did it on my own... go me! Very Happy

_________________
Like Metroid? Like fangames? Like top-down games? Like FUN? Head over to www.metroidcoven.com and check out my game called Metroid: Coven.
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Crackers 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 Sticky: [Info] Help for newbie coders! C++ Tutorial
Author: Dugtrio17
20 11240 Sun Jan 10, 2010 12:26 pm
Fragstein3D View latest post
No new posts [Info] Tricks - Dogs that shoot - Modifying Behaviour
Author: Guest
19 288 Sat Mar 20, 2004 7:31 am
Dugtrio17 View latest post
No new posts [Info] Alarm Sounding in game?? WSJ...??
Author: Guest
7 310 Tue Jun 17, 2003 10:04 pm
Reivax44 View latest post
No new posts [Info] Silent Gun? - Adding a Silencer
Author: Guest
4 194 Fri Apr 18, 2003 8:34 am
BrotherTank View latest post
No new posts [Info] Adding Locked Doors
Author: Guest
3 244 Thu Apr 17, 2003 6:30 am
Ripper 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