Wolf Planet Forum Index Wolf Planet
We want you here!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adam's Multi Floors - Making it Work With Ceilings

 
Post new topic   Reply to topic    Wolf Planet Forum Index -> Coding Alliance
View previous topic :: View next topic  
Author Message
Conner94
Moderator


Joined: 15 Jan 2005
Posts: 249
Location: ???

PostPosted: Mon Jul 04, 2005 3:21 pm    Post subject: Adam's Multi Floors - Making it Work With Ceilings Reply with quote

This is Adam's Multi Floors, but motified for ceilings too. It uses the third plane for both the ceiling and floor.
Code:

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
   int floorx,floory;
   unsigned curfloortex, lastfloortex;
  int roofx,roofy;
  unsigned currooftex, lastrooftex;

   // ------ * 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_top=PM_GetPage(tex_c); // load ceiling texture
      lastrooftex=-1;
   // 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; y<halfheight; y++, top_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; x<viewwidth; x+=4, top_add++)
         {
             if(wallheight[x]>>3<=y)
            {
               roofx = (gu>>TILESHIFT)&63;
               roofy = (-(gv>>TILESHIFT)-1)&63;
      currooftex=MAPSPOT(roofx,roofy,2)+1;
               if (currooftex != lastrooftex)
               {   
                  lastrooftex=currooftex;
                  src_top=PM_GetPage(currooftex);
               }
               u=(gu>>10)&63;
               v=(gv>>10)&63;
               color=*(src_top+((63-u)<<6)+(63-v));
               // draw top pixel using <color>
               asm mov es,[screenseg]
               asm mov di,[bufferofs]
               asm add di,[top_add]
               asm mov al,[color]
               asm mov es:[di],al
            }
            gu+=du;
            gv+=dv;
         }
      }
   }
//   src_bot=PM_GetPage(tex_f); // load floor texture
   lastfloortex=-1;
   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, bot_offset=bot_offset0; y<halfheight; y++, 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, bot_add=bot_offset; x<viewwidth; x+=4, bot_add++)
         {
            if(wallheight[x]>>3<=y)
            {
               floorx = (gu>>TILESHIFT)&63;
               floory = (-(gv>>TILESHIFT)-1)&63;
      curfloortex=MAPSPOT(floorx,floory,2);
               if (curfloortex != lastfloortex)
               {   
                  lastfloortex=curfloortex;
                  src_bot=PM_GetPage(curfloortex);
               }
               u=(gu>>10)&63;
               v=(gv>>10)&63;
               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, if you noticed, the ceiling checks MAPSPOT(roofx,roofy,2)+1. This sets the ceiling to the wall image after the floor image. THIS IS NOT THE NEXT WALL ID, that is not how it works. If you want the 4th plane (you would need WDC to place these) for the ceiling, change:
Code:
MAPSPOT(roofx,roofy,2)+1


to:

Code:
MAPSPOT(roofx,roofy,3)

Of course, you need to follow the tutorial in the WDC help to allow more than 3 planes.

Credit goes to Adam, Deathshead, and just a tad to me. Thanks to Adam for the base!
_________________
My Wolfenstein Website:
http://www.wolf94.cjb.net

Status: Falling apart over a product I ordered that is taking forever to arrive.
Back to top
View user's profile Send private message Visit poster's website
Kyo Kusanagi
Corporal


Joined: 18 Jan 2005
Posts: 95
Location: New Jersey\USA

PostPosted: Tue Jul 05, 2005 1:38 am    Post subject: Reply with quote

kool I'll try it out on my Part 3 of my Spear of Dreams saga
_________________
I'm The DDR King!!!!!!!!!!!!!!!!!! Laughing Laughing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Wolf Planet Forum Index -> Coding Alliance All times are GMT
Page 1 of 1

Jump to:  

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


Powered by phpBB © 2001 phpBB Group

Chronicles phpBB2 theme by Jakob Persson (http://www.eddingschronicles.com). Stone textures by Patty Herford.