(Tutorial) DarkOne's textured floor/ceiling for 4GW
Page 1 of 1 • Share •
(Tutorial) DarkOne's textured floor/ceiling for 4GW
You like use DarkOne's textured floor/ceiling for 4GW too? You try with original DOS code? Now thet released for 4GW too. It is 4GW version and works.
Original code tutorial for DOS:http://diehardwolfers.areyep.com/viewtopic.php?t=1575
Modified code tutorial for SDL:http://wolf3dfanboys.usersboard.com/t130-tutorial-darkone-s-textured-floor-ceiling-for-sdl#508
4GW version:
WL_DRAW.CPP:
Under Texture floor/ceiling function and VGAClearScreen part:
So you modify in ThreeDRefresh:
If you did in good then textured floor and ceiling will be on your level. Thanks Chris Chokan your help in correct.
Original code tutorial for DOS:http://diehardwolfers.areyep.com/viewtopic.php?t=1575
Modified code tutorial for SDL:http://wolf3dfanboys.usersboard.com/t130-tutorial-darkone-s-textured-floor-ceiling-for-sdl#508
4GW version:
WL_DRAW.CPP:
- Code:
int wallheight[MAXVIEWWIDTH],min_wallheight;
Under Texture floor/ceiling function and VGAClearScreen part:
- 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
*/
// ------------------------- * Textured flats * -------------------------
/*
** Draw Textured Floor/Ceiling (DarkOne)
*/
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_top, far *src_bot;
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
int flatx,flaty;
unsigned curfloortex, lastflattex;
unsigned curceiltex;
// ------ * 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
lastflattex=-1;
// draw horizontal lines
for(p=0; p<4; p++)
{
_asm{
mov eax,0x0102
mov cl,[p]
shl ah,cl
mov edx,0x3c4
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+FixedMul(dist, viewcos);
gv=-viewy+FixedMul(dist, viewsin);
tex_step=(dist<<8)/viewwidth/175;
du= FixedMul(tex_step, viewsin);
dv=-FixedMul(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)
{
flatx = (gu>>TILESHIFT)&63;
flaty = (-(gv>>TILESHIFT)-1)&63;
curfloortex=tex_f;
curceiltex=tex_c;
if (curfloortex != lastflattex)
{
lastflattex=curfloortex;
src_top=Pages+(curceiltex<<12);
src_bot=Pages+(curfloortex<<12);
}
u=(gu>>10)&63; v=(gv>>10)&63;
color=*(src_top+((63-u)<<6)+(63-v));
// draw top pixel using <color>
_asm {
mov edi,[vbuf]
add edi,[top_add]
mov al,[color]
mov es:[edi],al
}
color=*(src_bot+(u<<6)+(63-v));
// draw bottom pixel using <color>
_asm {
mov edi,[vbuf]
add edi,[bot_add]
mov al,[color]
mov es:[edi],al
}
}
gu+=du; gv+=dv;
}
}
}
}
#define USE_TEX(page) (0x0000|(page))
unsigned vgaCeiling[]=
{
#ifndef SPEAR
// 1 2 3 4 5 6 7 8 9 B D
// alte erste Zeile 0x9e9e,0x1d1d,0xdddd,0x1d1d,0x1e1e,0xd7d7,0xdede,0x9e9e,0x1d1d,0x1c1c,0x6565,
USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(17),USE_TEX(12),USE_TEX(17),USE_TEX(17),USE_TEX(19),
USE_TEX(24),USE_TEX(24),USE_TEX(24),USE_TEX(24),USE_TEX(24),USE_TEX(19),USE_TEX(12),USE_TEX(12),USE_TEX(15),USE_TEX(8),
USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(17),USE_TEX(12),USE_TEX(12),USE_TEX(12),USE_TEX(8),
USE_TEX(17),USE_TEX(8),USE_TEX(17),USE_TEX(12),USE_TEX(29),USE_TEX(8),USE_TEX(17),USE_TEX(24),USE_TEX(35),USE_TEX(29),
USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(12),USE_TEX(29),USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(17),
USE_TEX(17),USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(35),USE_TEX(29),USE_TEX(29),USE_TEX(29),USE_TEX(29),USE_TEX(17)
#else
USE_TEX(54),USE_TEX(24),USE_TEX(12),USE_TEX(63),USE_TEX(50),USE_TEX(17),USE_TEX(8),USE_TEX(8),USE_TEX(8),USE_TEX(8),
USE_TEX(35),USE_TEX(44),USE_TEX(29),USE_TEX(17),USE_TEX(12),USE_TEX(50),USE_TEX(50),USE_TEX(42),USE_TEX(63),USE_TEX(54),USE_TEX(56)
#endif
};
/*
=====================
=
= VGAClearScreen
=
=====================
*/
void VGAClearScreen (unsigned ceiling)
{
//unsigned ceiling=vgaCeiling[gamestate.episode*10+mapon];
ceiling|=ceiling<<16;
_asm {
cli
mov edx,SC_INDEX
mov eax,SC_MAPMASK+15*256
out dx,ax
sti
mov edx,80
mov ebx,[viewwidth]
shr ebx,2
sub edx,ebx
shr ebx,2
mov bh,byte ptr [viewheight]
shr bh,1
mov edi,[vbuf]
mov eax,[ceiling]
xor ecx,ecx
toploop:
mov cl,bl
rep stosd
add edi,edx
dec bh
jnz toploop
mov bh,byte ptr [viewheight]
shr bh,1
mov eax,0x19191919
bottomloop:
mov cl,bl
rep stosd
add edi,edx
dec bh
jnz bottomloop
}
}
So you modify in ThreeDRefresh:
- Code:
/*
========================
=
= ThreeDRefresh
=
========================
*/
void ThreeDRefresh (void)
{
unsigned ceiling;
boolean flats;
//
// clear out the traced array
//
memset(spotvis,0,maparea);
spotvis[player->tilex][player->tiley] = 1; // Detect all sprites over player fix
vbuf+=screenofs;
//
// follow the walls from there to the right, drawwing as we go
//
ceiling=vgaCeiling[gamestate.episode*10+mapon];
if((ceiling>>8)==(ceiling&0xFF))
{
VGAClearScreen(ceiling);
flats=false;
}
else
{
flats=true;
ceiling=((ceiling&0xFF)-1)<<1;
}
WallRefresh ();
if(flats)
DrawFlats(ceiling, ceiling+1); // draw textured floor/ceiling
//
// draw all the scaled images
//
playy=(player->y+FixedMul(0x7300,viewsin));
playx=(player->x-FixedMul(0x7300,viewcos));
DrawScaleds(); // draw scaled stuff
DrawPlayerWeapon (); // draw player's hands
//
// show screen and time last cycle
//
if (fizzlein)
{
FizzleFade((long)vbuf-0xa0000,(long)vdisp-0xa0000+screenofs,viewwidth,viewheight,20,false);
fizzlein = false;
lasttimecount = TimeCount = 0; // don't make a big tic count
}
vbuf-=screenofs;
vdisp=vbuf;
_asm {
cli
mov edx,0x3d4
mov al,0x0c
out dx,al
inc edx
mov al,byte ptr vdisp+1
out dx,al
sti
}
vbuf+=SCREENSIZE;
if((long)vbuf > 0xa0000+PAGE3START)
vbuf=(byte *) 0xa0000;
#ifndef REMDEBUG
if (fpscounter)
{
fps_frames++;
fps_time+=tics;
if(fps_time>35)
{
fps_time-=35;
fps=fps_frames<<1;
fps_frames=0;
}
fontnumber = 0;
SETFONTCOLOR(7,127);
PrintX=8; PrintY=190;
VWB_Bar(2,189,50,10,bordercol);
US_PrintSigned(fps);
US_Print(" fps");
}
#endif
}
If you did in good then textured floor and ceiling will be on your level. Thanks Chris Chokan your help in correct.
Last edited by Officer-M. John (Admin) on Tue Jun 13, 2017 1:02 pm; edited 2 times in total
Officer-M. John (Admin)- Admin
- Posts : 377
Join date : 2015-10-02
Age : 20

» "Handy Dandy" Tutorial
» Floor Guide to St. Mungos
» The seventh floor
» Swinging from the vines
» South, Chryl [C-Rank Nukenin]
» Floor Guide to St. Mungos
» The seventh floor
» Swinging from the vines
» South, Chryl [C-Rank Nukenin]
Permissions in this forum:
You cannot reply to topics in this forum