
|
|
| Author |
Message |
BrotherTank
Forum Administrator

Joined: 01 Mar 2003
Last Visit: 30 Aug 2010
Topics: 145
Posts: 2087
Location: Ontario

|
Posted: Wed Aug 13, 2003 2:03 am
Subject: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

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


Joined: 13 Mar 2004
Last Visit: 22 Oct 2009
Topics: 5
Posts: 381
Location: Liverpool, England

|
Posted: Tue Jun 01, 2004 1:05 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
This is a great tutorial Ripper , 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


Joined: 24 Nov 2003
Last Visit: 15 Dec 2009
Topics: 8
Posts: 394
Location: Nodnol, Sdrawkcab

|
Posted: Tue Jun 01, 2004 1:59 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
| 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. |
_________________ Rear one!
|
|
 |
sentenced
DieHard SS


Joined: 13 Mar 2004
Last Visit: 22 Oct 2009
Topics: 5
Posts: 381
Location: Liverpool, England

|
Posted: Tue Jun 01, 2004 2:23 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

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


Joined: 16 Mar 2003
Last Visit: 24 Dec 2009
Topics: 13
Posts: 186
Location: UK

|
Posted: Sun Aug 29, 2004 11:17 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
| Or delete wolfhack.c whack_a.asm and c0.asm |
_________________ ~ James
|
|
 |
lucky_foot
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 15 Mar 2007
Topics: 12
Posts: 67
Location: Pennsylvania

|
Posted: Sat Nov 27, 2004 8:49 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

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


Joined: 24 Nov 2003
Last Visit: 15 Dec 2009
Topics: 8
Posts: 394
Location: Nodnol, Sdrawkcab

|
Posted: Sun Nov 28, 2004 4:39 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
All graphics are drawn in the code, so all you need is the tutorial. Neat!  |
_________________ Rear one!
|
|
 |
lucky_foot
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 15 Mar 2007
Topics: 12
Posts: 67
Location: Pennsylvania

|
Posted: Thu Dec 02, 2004 12:40 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
No, more like AWESOME.  |
_________________ JonathanS
Lucky foot Productions
www.luckyfootproductions.jtworld.net
|
|
 |
lucky_foot
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 15 Mar 2007
Topics: 12
Posts: 67
Location: Pennsylvania

|
|
 |
BrotherTank
Forum Administrator

Joined: 01 Mar 2003
Last Visit: 30 Aug 2010
Topics: 145
Posts: 2087
Location: Ontario

|
Posted: Thu Dec 09, 2004 3:21 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

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


Joined: 05 Nov 2004
Last Visit: 15 Mar 2007
Topics: 12
Posts: 67
Location: Pennsylvania

|
Posted: Thu Dec 09, 2004 7:13 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
It did. Thanks.  |
_________________ JonathanS
Lucky foot Productions
www.luckyfootproductions.jtworld.net
|
|
 |
KyleRTCW
DieHard SS

Joined: 31 Jul 2003
Last Visit: 28 May 2010
Topics: 41
Posts: 458
Location: Ohio

|
Posted: Thu Dec 23, 2004 12:22 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
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] |
_________________ KyleRTCW
|
|
 |
Zombie_Plan
DieHard Wolfer


Joined: 13 Oct 2004
Last Visit: 21:35 ago.
Topics: 90
Posts: 1471
Location: A hole in the wall

|
Posted: Mon Jan 24, 2005 6:34 am
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
| How do I use this with Darkone's DrawCeiling and DrawFloor routines? |
_________________ BLOGS
WolfingTime - RSS Feed
HELP ME
|
|
 |
Guest

Last Visit:
|
|
 |
Zombie_Plan
DieHard Wolfer


Joined: 13 Oct 2004
Last Visit: 21:35 ago.
Topics: 90
Posts: 1471
Location: A hole in the wall

|
|
 |
Guest

Last Visit:
|
Posted: Tue Jan 25, 2005 2:17 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
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.  |
|
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 03 Aug 2010
Topics: 60
Posts: 1189
Location: Loppi - Finland

|
Posted: Mon Aug 15, 2005 10:55 am
Subject: Problems
[ IP : Logged ]
|

  
|
|
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 SS

Joined: 31 Jul 2003
Last Visit: 28 May 2010
Topics: 41
Posts: 458
Location: Ohio

|
Posted: Wed Dec 28, 2005 7:48 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

  
|
|
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 , thanks in advance
EDIT: doh, i always post something then figure out the solution afterwards.  |
_________________ KyleRTCW
|
|
 |
Adam Biser
Utility Developer


Joined: 06 Jun 2003
Last Visit: 01 Sep 2010
Topics: 32
Posts: 1973
Location: Midsouth

|
Posted: Thu Jun 08, 2006 6:35 pm
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

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


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008
Topics: 21
Posts: 527
Location: Germany

|
Posted: Fri Jun 09, 2006 11:09 am
Subject: Re: [Code] Outside Atmosphere - Stars/Rain/Snow -Ripper
[ IP : Logged ]
|

 
|
|
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  |
_________________ Life is an awful game, but the graphics resolution rocks ;D
|
|
 |
|
|
|
|
|
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 subSilver Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group
|