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] Outside Atmosphere - Stars/Rain/Snow -Ripper
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: Tue Aug 12, 2003 7:03 pm
   Subject: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Star/Sky (Outside Atmosphere)

Posted with Permission and edited for formatting...

These features make it possible to create cool snow maps or many other exciting possiblities, if you have the right texture sets Wink

Let's get to work:

As always you should make sure first, that your current Wolfenstein 3D source, you're going to enhance, is working without major problems and create a backup of your source!

Open WL_DEF.H and append (add) the following lines to the end of the file:

::: CODE :::
 #define MAXSTARS 400
extern short far starsx[MAXSTARS];
extern short far starsy[MAXSTARS];
extern short far starsz[MAXSTARS];


Save and Close that file....

These arrays need to be initialised so add these lines to the end of the InitGame function in WL_MAIN.C, so the end of the rotuine looks like this (New lines in Blue):

::: CODE :::
    if (virtualreality)
   {
      NoWait = true;
      geninterrupt(0x60);
   }

   for(i=0;i<MAXSTARS;i++)
   {
      float len;
      int j;
      starsz[i]=16384-random(32677);
      starsx[i]=16384-random(32677);
      len=sqrt( (float)starsx[i]*(float)starsx[i]
               +(float)starsz[i]*(float)starsz[i]);
      j=50;
      do
      {
      starsy[i]=1024+random(8190);
         j--;
      }
      while(j>0 && (float)starsy[i]*256.F/len>=100.F);
   }

}


Save and Close that File...

Now we need to add the main drawing routines into the WL_DRAW.C file, so we open it and add the following code above the vgaCeiling array:

::: CODE :::
void SetPixel(int x,int y,byte col)
{
   asm{
      cli
      mov al,2
      mov cl,byte ptr x
      and cl,3
      mov ah,1
      shl ah,cl
      mov dx,0x3c4
      out dx,ax
      sti
      push es
      push di
      mov ax,0xa000
      mov es,ax
      mov di,word ptr bufferofs
      mov bx,word ptr y
      mov ax,word ptr x
      shr ax,2
      add di,ax
      shl bx,4
      add di,bx
      shl bx,2
      add di,bx
      mov al,byte ptr col
      mov es:[di],al
      pop di
      pop es
   }
}

void ClearScreenH()
{
   asm{
      cli
      mov al,2
      mov ah,15
      shl ah,cl
      mov dx,0x3c4
      out dx,ax
      sti
      push es
      push di
      mov ax,0xa000
      mov es,ax
      mov di,word ptr bufferofs
      mov bx,320
      mov dx,word ptr viewwidth
      sub bx,dx
      shr dx,3
      shr bx,2
      mov dh,byte ptr viewheight
      shr dh,1
      xor ax,ax
   }
nextrow:
   asm{
      mov cl,dl
      rep stosw
      add di,bx
      dec dh
      jne nextrow
      pop di
      pop es
   }
}

short far starsx[MAXSTARS];
short far starsy[MAXSTARS];
short far starsz[MAXSTARS];

byte moon[100]={
     0,  0, 27, 18, 15, 16, 19, 29,  0,  0,
     0, 22, 16, 15, 15, 16, 16, 18, 24,  0,
    27, 17, 15, 17, 16, 16, 17, 17, 18, 29,
    18, 15, 15, 15, 16, 16, 17, 17, 18, 20,
    16, 15, 15, 16, 16, 17, 17, 18, 19, 21,
    16, 15, 17, 20, 18, 17, 18, 18, 20, 22,
    19, 16, 18, 19, 17, 17, 18, 19, 22, 24,
    28, 19, 17, 17, 17, 18, 19, 21, 25, 31,
     0, 23, 18, 19, 18, 20, 22, 24, 28,  0,
     0,  0, 28, 21, 20, 22, 28, 30,  0,  0 };

#define LEVELSTATES 10

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

void PaintStars(long siny,long cosy)
{
   long x,y,z;
   int xx,yy;
   int i;
   int shade;
   int hvheight=viewheight>>1;
   int hvwidth=viewwidth>>1;
   ClearScreenH();
   for(i=0;i<MAXSTARS;i++)
   {
      x=(long)starsx[i]*cosy+(long)starsz[i]*siny;
      y=(long)starsy[i]<<16;
      z=((long)starsz[i]*cosy-(long)starsx[i]*siny)>>8;
      if(z<=0) continue;
      shade=(z>>18);
      if(shade>15) continue;
      xx=(int)(x/z+hvwidth);
      yy=(int)(hvheight-y/z);
      if(xx>=0 && xx<viewwidth && yy>=0 && yy<hvheight)
         SetPixel(xx,yy,shade+15);
   }

   x=16384L*cosy+16384L*siny;
   z=(16384L*cosy-16384L*siny)>>8;
   if(z<=0) return;
   xx=(int)(x/z+hvwidth);
   yy=(int)(hvheight-(((long)hvheight-((long)hvheight>>3))<<22)/z);
   if(xx>-10 && xx<viewwidth)
   {
      int stop=10,j;
      i=0;
      if(xx<0) i=-xx;
      if(xx>viewwidth-11) stop=viewwidth-xx;
      for(;i<stop;i++)
         for(j=0;j<10;j++)
            SetPixel(xx+i,yy+j,moon[j*10+i]);
   }
}

word rainpos=0;

void PaintRain(long siny,long cosy)
{
   long px=(player->y+FixedByFrac(0x7900,siny))>>6;
   long pz=(player->x-FixedByFrac(0x7900,cosy))>>6;
   long ax,az;
   long x,y,z;
   int xx,yy,height,actheight;
   int i;
   int shade;
   int hvheight=viewheight>>1;
   int hvwidth=viewwidth>>1;

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

   rainpos-=1800;
   for(i=0;i<MAXSTARS;i++)
   {
      ax=(long)starsx[i]+px;
      ax=0x1fff-(ax&0x3fff);
      az=(long)starsz[i]+pz;
      az=0x1fff-(az&0x3fff);
      x=ax*cosy+az*siny;
      y=-(heightnumerator<<7)
        +((((long)(starsy[i]<<6)+(long)rainpos)&0x0ffff)<<11);
      z=(az*cosy-ax*siny)>>8;
      if(z<=0) continue;
      shade=(z>>17);
      if(shade>13) continue;
      xx=(int)(x/z+hvwidth);
      if(xx<0 || xx>viewwidth) continue;
      actheight=(int)(y/z);
      yy=hvheight-actheight;
      height=(int)((heightnumerator<<10)/z);
      if(actheight<0) actheight=-actheight;
      if(actheight<(wallheight[xx]>>3) && height<wallheight[xx]) continue;
      if(xx>=0 && xx<viewwidth && yy>0 && yy<viewheight)
      {
         // the following lines can be optimized

         SetPixel(xx,yy,shade+15);
         SetPixel(xx,yy-1,shade+16);
         if(yy>2)
         {
            SetPixel(xx,yy-2,shade+17);
         }
      }
   }
}

void PaintSnow(long siny,long cosy)
{
   long px=(player->y+FixedByFrac(0x7900,siny))>>6;
   long pz=(player->x-FixedByFrac(0x7900,cosy))>>6;
   long ax,az;
   long x,y,z;
   int xx,yy,height,actheight;
   int i;
   int shade;
   int hvheight=viewheight>>1;
   int hvwidth=viewwidth>>1;

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

   rainpos-=512;
   for(i=0;i<MAXSTARS;i++)
   {
      ax=(long)starsx[i]+px;
      ax=0x1fff-(ax&0x3fff);
      az=(long)starsz[i]+pz;
      az=0x1fff-(az&0x3fff);
      x=ax*cosy+az*siny;
      y=-(heightnumerator<<7)
        +((((long)(starsy[i]<<6)+(long)rainpos)&0x0ffff)<<11);
      z=(az*cosy-ax*siny)>>8;
      if(z<=0) continue;
      shade=(z>>17);
      if(shade>13) continue;
      xx=(int)(x/z+hvwidth);
      if(xx<0 || xx>viewwidth) continue;
      actheight=(int)(y/z);
      yy=hvheight-actheight;
      height=(int)((heightnumerator<<10)/z);
      if(actheight<0) actheight=-actheight;
      if(actheight<(wallheight[xx]>>3) && height<wallheight[xx]) continue;
      if(xx>0 && xx<viewwidth && yy>0 && yy<viewheight)
      {
         if(shade<10)
         {
            // the following lines can be optimized

            SetPixel(xx,yy,shade+17);
            SetPixel(xx-1,yy,shade+16);
            SetPixel(xx,yy-1,shade+16);
            SetPixel(xx-1,yy-1,shade+15);
         }
         else SetPixel(xx,yy,shade+15);
      }
   }
}


Now replace the VGAClearScreen function with this VGAClearScreen function replacement:

::: CODE :::
void VGAClearScreen (void)
{
   int lmapon=gamestate.mapon;
   if(lmapon>=LEVELSTATES) lmapon=LEVELSTATES-1;
   if(!levelSkyState[lmapon])
   {
      unsigned ceiling=vgaCeiling[gamestate.episode*10 + gamestate.mapon];

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

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

         mov bx,[viewwidth]
         shr bx,3
         mov bh,BYTE PTR [viewheight]
         shr bh,1

         mov es,[screenseg]
         mov di,[bufferofs]
         mov ax,[ceiling]
      }

toploop:
      asm{
         mov cl,bl
         rep stosw
         add di,dx
         dec bh
         jnz toploop

         mov bh,BYTE PTR [viewheight]
         shr bh,1
         mov ax,0x1919
      }

bottomloop:
      asm{
         mov cl,bl
         rep stosw
         add di,dx
         dec bh
         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
         mov ax,SC_MAPMASK+15*256         // write through all planes
         out dx,ax

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

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

         shr bx,3

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

         shr bh,1

         mov ax,0x1919
      }

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


The last step is to add these lines into the ThreeDRefresh function, so it looks something like this:

::: CODE :::
 //
// draw all the scaled images
//
   DrawScaleds();         // draw scaled stuff

   if(levelSkyState[gamestate.mapon]==3)
      PaintSnow(viewsin,viewcos);
   else if(levelSkyState[gamestate.mapon]==2)
      PaintRain(viewsin,viewcos);

   DrawPlayerWeapon ();   // draw player's hands


Save and Close the WL_Draw.C file....

Now Select Compile -> Build All and then we can start using these arrays to paint sky, rain and snow!

That's it ;D

Now you can change the levelSkyState array to fit your map design by changing the following lines in your newly modified WL_DRAW.C file:

::: CODE :::
#define LEVELSTATES 10


Where the "10" indicates the number of levels in your game.
Once you have increased the number of levelstates, you must now match the array definition by adding a value for each level you added (increase the LEVELSTATES constant and append one state for each level to the end of the array) :

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


So if you have 21 levels, you should set LEVELSTATES to 21 and have 21 definitions in the above array initialization.

There are four different states available:

0: Normal Wolfenstein 3D ceiling filled with the according vgaCeiling color
1: Star sky
2: Raining star sky
3: Snowing star sky

Don't ask where the rain or the snow does come from, as there aren't any clouds . You can add the clouds by yourself, if you want, but don't ask me Wink

The face of the moon can also be changed by simply changing the moon array. The numbers in this array are the exact colors which will be displayed on screen, so you could even make a colored moon.

Now go and create beautiful winter scenes, rainy nights, or just stars inthe sky.

Thanks for reading this and don't forget to give us some credits, if you use this tutorial ;D

Ripper
sentenced
DieHard SS
DieHard SS


Joined: 13 Mar 2004
Last Visit: 22 Oct 2009

Topics: 5
Posts: 381
Location: Liverpool, England
sao_tome.gif

PostPosted: Tue Jun 01, 2004 6:05 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

This is a great tutorial Ripper Cool , however, I have a problem:

Whenever I run "wolf3d.exe", the DOS screen either pops up once and disappears or displays the memory configuration screen, and hangs on it.

I have used VDMSound to display the brief message in the DOS popup and I get:

"Abnormal program termination".

The code has compiled successfully. Everything is in the right directory, according to the "Directories" menu in Borland 3.1 and I am sure that I have made no obvious mistake.

I have attempted to get this thing to work no less than twelve times, changing little things here and there as I go along. Don't think that I have posted this out of the frustration of not getting it to work the first time, because I haven't.

Please can you (or anyone else) help me to solve this problem?

Thanks in advance.

_________________
"Listen and exchange with me, as we both share in common a different value system."
Hair Machine
DieHard SS
DieHard SS


Joined: 24 Nov 2003
Last Visit: 21 Dec 2017

Topics: 8
Posts: 431
Location: editing my profile
uk.gif

PostPosted: Tue Jun 01, 2004 6:59 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Abnormal Program Termination! Well, in that case you've run out of databytes... Rather than me trying to explain it, there are solutions at http://www.areyep.com under MCS' coding tips. You can also check out the Directional 3d Sprites tutorial on http://www.chaos-software.org , which also has information on databytes and APT.

_________________
Rar rar fiddle di dee
sentenced
DieHard SS
DieHard SS


Joined: 13 Mar 2004
Last Visit: 22 Oct 2009

Topics: 5
Posts: 381
Location: Liverpool, England
sao_tome.gif

PostPosted: Tue Jun 01, 2004 7:23 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hair Machine,

You are the best! It all works, and I am now aware of the easiest method needed to overcome this problem:

Download MCS's alternate *ID files off the link you provided.

Thank you.

_________________
"Listen and exchange with me, as we both share in common a different value system."
jamez
I am Death Incarnate
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 13 Aug 2016

Topics: 13
Posts: 186
Location: Yorkshire, UK
uk.gif

PostPosted: Sun Aug 29, 2004 4:17 pm
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Or delete wolfhack.c whack_a.asm and c0.asm

_________________
~ James
lucky_foot
Don't Hurt Me
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 19 Sep 2010

Topics: 13
Posts: 69
Location: Pennsylvania
usa.gif

PostPosted: Sat Nov 27, 2004 12:49 pm
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Question then.

Is it built in to play the neccesary graphcis or do I have to load something in to the VGA to play it? Know what I mean?

_________________
JonathanS
Lucky foot Productions

www.luckyfootproductions.jtworld.net
Hair Machine
DieHard SS
DieHard SS


Joined: 24 Nov 2003
Last Visit: 21 Dec 2017

Topics: 8
Posts: 431
Location: editing my profile
uk.gif

PostPosted: Sun Nov 28, 2004 8:39 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

All graphics are drawn in the code, so all you need is the tutorial. Neat! Wink

_________________
Rar rar fiddle di dee
lucky_foot
Don't Hurt Me
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 19 Sep 2010

Topics: 13
Posts: 69
Location: Pennsylvania
usa.gif

PostPosted: Thu Dec 02, 2004 4:40 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

No, more like AWESOME. Smile

_________________
JonathanS
Lucky foot Productions

www.luckyfootproductions.jtworld.net
lucky_foot
Don't Hurt Me
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 19 Sep 2010

Topics: 13
Posts: 69
Location: Pennsylvania
usa.gif

PostPosted: Thu Dec 09, 2004 5:15 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

jamez wrote:
Or delete wolfhack.c whack_a.asm and c0.asm


These aren't really necessary? I have added an actor to my game after a lot of other edits and even with the new ID files I still get the Abnormal Program Termination order. I can delete those then?

_________________
JonathanS
Lucky foot Productions

www.luckyfootproductions.jtworld.net
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: Thu Dec 09, 2004 7:21 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

lucky_foot wrote:
jamez wrote:
Or delete wolfhack.c whack_a.asm and c0.asm


These aren't really necessary? I have added an actor to my game after a lot of other edits and even with the new ID files I still get the Abnormal Program Termination order. I can delete those then?


Yes, you can delete those 3 files... and use MCS's ID files download as well. By doing both you will gain some extra memory in the dgroup and hopefully stop your "Abnormal Program Termination" error.

Greg
BrotherTank
lucky_foot
Don't Hurt Me
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 19 Sep 2010

Topics: 13
Posts: 69
Location: Pennsylvania
usa.gif

PostPosted: Thu Dec 09, 2004 11:13 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

It did. Thanks. Smile

_________________
JonathanS
Lucky foot Productions

www.luckyfootproductions.jtworld.net
KyleRTCW
DieHard Officer
DieHard Officer


Joined: 30 Jul 2003
Last Visit: 11 Apr 2018

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

PostPosted: Thu Dec 23, 2004 4:22 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

If anyone is making a fun TC, then here's a red moon for you:
::: CODE :::
byte moon[100]={
     0,  0, 43, 34, 55, 32, 35, 45,  0,  0,
     0, 38, 32, 55, 55, 32, 32, 34, 40,  0,
    43, 33, 55, 33, 32, 32, 33, 33, 34, 45,
    34, 55, 55, 55, 32, 32, 33, 33, 34, 36,
    32, 55, 55, 32, 32, 33, 33, 34, 35, 37,
    32, 55, 33, 36, 34, 33, 34, 34, 36, 38,
    35, 32, 34, 35, 33, 33, 34, 35, 38, 40,
    44, 35, 33, 33, 33, 34, 35, 37, 41, 47,
     0, 39, 34, 35, 34, 36, 38, 40, 44,  0,
     0,  0, 44, 37, 36, 38, 44, 46,  0,  0 };

Just replace it with the old byte moon[100]

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


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Sun Jan 23, 2005 10:34 pm
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

How do I use this with Darkone's DrawCeiling and DrawFloor routines?

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb
Guest




Last Visit:





PostPosted: Mon Jan 24, 2005 8:09 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

There`s a topic in the forum. Here is the link
http://diehardwolfers.areyep.com/viewtopic.php?t=799
Zombie_Plan
DieHard Wolfer
DieHard Wolfer


Joined: 12 Oct 2004
Last Visit: 07 Jun 2016

Topics: 101
Posts: 1614
Location: A hole in the wall
australia.gif

PostPosted: Tue Jan 25, 2005 2:01 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

flamer46 wrote:
There`s a topic in the forum. Here is the link
http://diehardwolfers.areyep.com/viewtopic.php?t=799


Yes, but that helps with Textures, if you look at BT's map control, he shows how Darkone split the VGAClearScreen Routine into two: DrawCeiling and DrawFloor. What I need is a way to use the Starry sky stuff with these, instead of VGAClearScreen.

Anyone? BT?

_________________
Zombieskittles

Welcome to 2016, where DHW still thinks it is okay to ban the world's most popular email service provider, and I can't have an avatar over 10kb
Guest




Last Visit:





PostPosted: Tue Jan 25, 2005 6:17 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

maybe i`ll send you my code later this evening...

In the evening

Hello i`m back. So now i`m going to extract the ThreedRefresh routine directly from my code and modify a litlle bit. My Threedrefresh routine supports Ripper starry`s sky and clouds, Darkone`s textured floor and ceiling, Brother Tanks map control stuff. Then it has some if statements to decide if you are in warped area or not. Oh and in this code i eliminated the call to normal flat ceiling and floor

Here it is
::: CODE :::

void   ThreeDRefresh (void)
{
   int tracedir;
   unsigned ceiling, floor;
   boolean flats;
   //
   // Get ceiling colour from vgaCeiling array
   // and set default floor to Gray (original)
   // Set other defaults as well
   //
   SkyState = 0;
   flats = false;

   // 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;

 
   if(!gamestate.warped)
   {
   if(tilemap[1][0] >= 1)
   flats = true;
   if(tilemap[3][0] >= 1)
   SkyState = tilemap[3][0];
   }
   else
   {
    if(tilemap[5][0] >= 1)
   flats = true;
   if(tilemap[7][0] >= 1)
   SkyState = tilemap[7][0];
   }
   
      // if not using textures clear the screen

      if (!flats || SkyState)  VgaClearScreen();   // To save memory my VgaClearScreen only draws the starry sky
      if(flats && SkyState)
      {
       if(!gamestate.warped)
   DrawFlats(tilemap[1][0]*2-2,1);      // the tilemap is multiplied by two so the engine reads the ID and not the index number(In floedit)
       else
   DrawFlats(tilemap[5][0]*2-2,1);
       }

      // next we draw the walls

      WallRefresh();

      // next we draw the textures if used

   
   if(flats)
   {
           if(!gamestate.warped)
      {
      DrawFlats(tilemap[1][0]*2-2,1);
      DrawFlats(tilemap[2][0]*2-2,2);
      }
   else
      {
      DrawFlats(tilemap[5][0]*2-2,1);
      DrawFlats(tilemap[6][0]*2-2,2);
      }
   }

      // then we draw all the scaled images
      // of guards and object sprites
   playy=(player->y+FixedByFrac(0x7300,viewsin));
   playx=(player->x-FixedByFrac(0x7300,viewcos));
      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();
}


This should help you. You`ll have to modify it a bit to make it fit in your code.

Don`t know if you`ve noticed, but when i call the drawFlats routine(texture floor ceiling)
i use two numbers,
The first one is The texture to use , the second is what do draw, 1 is floor and 2 is ceiling.

So here is my DrawFlats routine.
::: CODE :::

void DrawFlats(unsigned tex, int which)
{
  int x, y, y0, halfheight,shade;
  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

  switch(which)
  {
  case 1:
  src_bot=PM_GetPage(tex); // load floor texture
  break;
  case 2:
  if(!SkyState) src_top=PM_GetPage(tex); // load ceiling texture
  break;
  }

// 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;

      shade=(y<<2)/((maxscaleshl2>>8)+1+LSHADE_flag);
      if(shade>32) shade=32;
      else if(shade<1) shade=1;
      shade=32-shade;
      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;
     switch(which)
     {
     case 2:
     if(!SkyState)
     {
     color=shadetable[shade][*(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
     }
     break;
     case 1:
     color=shadetable[shade][*(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
     break;
     }
   }
   gu+=du; gv+=dv;
      }
    }
  }
}


This routine has shading in it. You have to modify it a bit to make it fit in your code.

If you still have problems tell me. Think
WLHack
DieHard Wolfer
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 18 Jan 2018

Topics: 66
Posts: 1242
Location: Loppi - Finland
finland.gif

PostPosted: Mon Aug 15, 2005 3:55 am
   Subject: Problems
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I manage to compile my source files succesfully, but
when I enter level where is a starsky, my statusbar disappears
and is replaced with the color of current floor. So I ask can
anyone help me how to fix this "error" (I'll thank for all the
help).
KyleRTCW
DieHard Officer
DieHard Officer


Joined: 30 Jul 2003
Last Visit: 11 Apr 2018

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

PostPosted: Wed Dec 28, 2005 11:48 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Is it possible to remove the flashes that occur somewhat often in the game caused by VGAClearScreen() mainly on the floor part of the screen(gray and black bars)? I have no knowledge of ASM so i dont know what to remove/slash keep Wink, thanks in advance

EDIT: doh, i always post something then figure out the solution afterwards. Embarassed Angry

_________________
Steam: http://steamcommunity.com/id/stormx312
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 20 Apr 2018

Topics: 46
Posts: 2307
Location: USA
usa.gif

PostPosted: Thu Jun 08, 2006 11:35 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Though this is a great effect, one thing I notice is that PaintRain is called after DrawScaleds. This means that rain gets drawn on top ofthe static and actor objects which means that rain that should be behind the object will also get drawn on top of it. Not that I see any easy way aound this problem...

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
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 Jun 09, 2006 4:09 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Well, one alternative would be, to call PaintRain BEFORE DrawScaleds. Then all sprites would be on top of the rain, which would even look more strange (especially in the distant). I think near sprites will be likely to move fast, so you won't notice it too much... Which doesn't work for silent knife kills of course...
The good way would be to sort each rain drop and sprite by distance and draw it in the correct order. But this would be far too slow Sad

_________________
Life is an awful game, but the graphics resolution rocks ;D
Adam Biser
Utility Developer
Utility Developer


Joined: 06 Jun 2003
Last Visit: 20 Apr 2018

Topics: 46
Posts: 2307
Location: USA
usa.gif

PostPosted: Fri Jun 09, 2006 7:18 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Ripper: yeah, switching the function calls would make it far more obvious, I know. I only noticed this after several months when I stood behind a pillar and saw rain through it. Smile It still looks great, though.

_________________
Orb of Dilaaria now has a Facebook page
Star Wars: Bloodlines now has a Facebook page
wolfwhips
DieHard Officer
DieHard Officer


Joined: 09 Aug 2006
Last Visit: 20 Feb 2018

Topics: 66
Posts: 547

newzealand.gif

PostPosted: Tue Nov 14, 2006 3:38 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hi, I tried ripper's outside atmosphere tutorial and it works, its awesome! But I have a question. Can I combine both so that I have a normal ceiling and a snowing sky in one level? Like, for example, if you start in the outside of a building, and it's dark, but when you enter the building there's a ceiling above you? That would be very cool to have. Too Cool

_________________
MP3 remixes of the ROTT songs!!
lwmxynedtodth
DieHard Officer
DieHard Officer


Joined: 28 May 2006
Last Visit: 24 Aug 2017

Topics: 38
Posts: 570
Location: Neverland
netherlands.gif

PostPosted: Tue Nov 14, 2006 7:31 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yup, you can. See the multi-textured floors and ceiling topic. If you're in trouble with combining it with the starry sky, there is a topic on that too. if you're in trouble with combining it with the parallax sky, I can help you out.

- lwmxynedtodth

_________________
lwmxynedtodth (portfolio, blog and more)
Killer-suit: Masterminds
On a MMORPG trip.
wolfwhips
DieHard Officer
DieHard Officer


Joined: 09 Aug 2006
Last Visit: 20 Feb 2018

Topics: 66
Posts: 547

newzealand.gif

PostPosted: Thu Nov 16, 2006 8:33 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Thanks for the reply lwmxynedtodth! Is it possible to implement paralax skies with this outside atmosphere tutorial?

_________________
MP3 remixes of the ROTT songs!!
wolfwhips
DieHard Officer
DieHard Officer


Joined: 09 Aug 2006
Last Visit: 20 Feb 2018

Topics: 66
Posts: 547

newzealand.gif

PostPosted: Thu Nov 16, 2006 8:38 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

And also, if I want to give the idea that youre standing outside a tall building, can you give the illusion that the building is tall, and you can see it's many floors and its rooftop? I ask, because most wolf3d levels I see only have one height.

_________________
MP3 remixes of the ROTT songs!!
TexZK
DieHard SS
DieHard SS


Joined: 07 Feb 2004
Last Visit: 17 Oct 2016

Topics: 19
Posts: 370
Location: Northern Italy
italy.gif

PostPosted: Fri Nov 17, 2006 5:48 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

For the first question: Yes, just call PaintRain()/PaintSnow() after drawing walls and objects as you wish.
For the other: no, you can't draw taller walls until you don't rewrite the raycaster... But I've seen time ago in Orb Of Dilaaria (from the great Adam Biser) something like different height floors. I was goind to do them for Helvete, but I haven't been active for at least a full year, so now I have to get back onto the code.
Anonymous
Guest



Last Visit:





PostPosted: Mon Dec 18, 2006 8:47 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Hey,

i'm kinda new with all this source code editing and i've been experimenting for a few months now. I've no problems with the basic tutorials but i have a problem with this one.

i compiled the code with out any problems, but when i link it all up i get this:

"Linker Error: Undefined symbol _PaintStars in module WL_DRAW.C"
"Linker Error: Undefined symbol _PaintSnow in module WL_DRAW.C"

and my wolf3d.exe is deleted from the directory...

could anyone help me out?
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: Thu Dec 21, 2006 7:09 pm
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

First thing I would do is redo the whole tutorial and make sure you put everything in the right place. After that, if you're using other big features that conflict with any of the functions changed in this tutorial, you need to merge them. Like textured floor and such... there should be a few topics and posts for that kind of thing.

_________________
Like Metroid? Like fangames? Like top-down games? Like FUN? Head over to www.metroidcoven.com and check out my game called Metroid: Coven.
the_fish
Bring 'em On
Bring 'em On


Joined: 18 Nov 2006
Last Visit: 07 Nov 2008

Topics: 12
Posts: 133
Location: England
uk.gif

PostPosted: Fri Dec 22, 2006 7:50 am
   Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

@Ghavnaa:

I don't use Borland to compile so I'm not sure if this will work, but a guess would be it has something to do with THIS:

Quote:
add the following code above the vgaCeiling array


If it's added just anywhere, the linker might not be able to find it.

Alternatively, shove these prototypes at the start of WL_DRAW.c:

::: CODE :::

void PaintStars(long siny,long cosy);
void PaintRain(long siny,long cosy);


Hope this helps,
tf
thellt
Bring 'em On
Bring 'em On


Joined: 21 Jan 2008
Last Visit: 12 May 2009

Topics: 11
Posts: 85
Location: bloodgulch
usa.gif

PostPosted: Fri Feb 29, 2008 2:06 pm
   Subject: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

how do u make a blood red colerd sky that rains red and black rain Question

_________________
}{even or }{ellt?

look for helt3d
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 2626 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 2532 Fri Feb 11, 2005 9:18 pm
Zombie_Plan View latest post
No new posts [Code] Changing an Enemies Attack Strength - BrotherTank
Author: BrotherTank
0 2138 Tue Jan 27, 2004 10:29 am
BrotherTank View latest post
No new posts [Code] Changing Weapons -CheckWeaponChange- BrotherTank
Author: BrotherTank
2 2884 Sun Oct 26, 2003 1:21 am
Guest View latest post
No new posts [Help] Different Enemy Dying Frames/Views
Author: Guest
7 609 Tue Jul 29, 2003 3:00 pm
Codetech84 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