later,
James
A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...
#include "version.h"
#ifdef USE_FLOORCEILINGTEX
#include "wl_def.h"
#include "wl_shade.h"
//
// Codetech84's split doorways
//
unsigned GetSplitTexture (int u, int v, int x, int y, boolean vert)
{
unsigned ret;
if (vert)
{
if (u < 32)
ret = MAPSPOT(x-1,y,2);
else
ret = MAPSPOT(x+1,y,2);
}
else
{
if (v < 32)
ret = MAPSPOT(x,y+1,2);
else
ret = MAPSPOT(x,y-1,2);
}
return ret;
}
// Textured Floor and Ceiling by DarkOne
// With multi-textured floors and ceilings stored in lower and upper bytes of
// according tile in third mapplane, respectively.
void DrawFloorAndCeiling(byte *vbuf, unsigned vbufPitch, int min_wallheight)
{
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
byte *toptex, *bottex;
unsigned curtex=0, door;
byte tile;
unsigned lasttoptex = 0xffffffff, lastbottex = 0xffffffff;
boolean uv;
int halfheight = viewheight >> 1;
int y0 = min_wallheight >> 3; // starting y value
if(y0 > halfheight)
return; // view obscured by walls
if(!y0) y0 = 1; // don't let division by zero
unsigned bot_offset0 = vbufPitch * (halfheight + y0);
unsigned top_offset0 = vbufPitch * (halfheight - y0 - 1);
// draw horizontal lines
for(int y = y0, bot_offset = bot_offset0, top_offset = top_offset0;
y < halfheight; y++, bot_offset += vbufPitch, top_offset -= vbufPitch)
{
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) * du;
gv -= (viewwidth >> 1) * dv; // starting point (leftmost)
#ifdef USE_SHADING
byte *curshades = shadetable[GetShade(y << 3)];
#endif
for(int x = 0, bot_add = bot_offset, top_add = top_offset;
x < viewwidth; x++, bot_add++, top_add++)
{
uv = false;
if(wallheight[x] >> 3 <= y)
{
int curx = (gu >> TILESHIFT) & (MAPSIZE - 1);
int cury = (-(gv >> TILESHIFT) - 1) & (MAPSIZE - 1);
tile = tilemap[curx][cury];
if (tile & 0x80)
{
u = (gu >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
v = (gv >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
uv = true;
curtex = GetSplitTexture(u,v, curx,cury, doorobjlist[tile & 0x7f].vertical);
}
else
curtex = MAPSPOT(curx, cury, 2);
if(curtex)
{
unsigned curtoptex = curtex >> 8;
if (curtoptex != lasttoptex)
{
lasttoptex = curtoptex;
toptex = PM_GetTexture(curtoptex);
}
unsigned curbottex = curtex & 0xff;
if (curbottex != lastbottex)
{
lastbottex = curbottex;
bottex = PM_GetTexture(curbottex);
}
if (!uv)
{
u = (gu >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
v = (gv >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
uv = true;
}
unsigned texoffs = (u << TEXTURESHIFT) + (TEXTURESIZE - 1) - v;
#ifdef USE_SHADING
if(curtoptex)
vbuf[top_add] = curshades[toptex[texoffs]];
if(curbottex)
vbuf[bot_add] = curshades[bottex[texoffs]];
#else
if(curtoptex)
vbuf[top_add] = toptex[texoffs];
if(curbottex)
vbuf[bot_add] = bottex[texoffs];
#endif
}
}
gu += du;
gv += dv;
}
}
}
#endif
weapontype gotweapon;
/*
======================
=
= CheckWeaponChange
=
= Keys 1-5 change weapons
=
======================
*/
void CheckWeaponChange (void)
{
int i,newWeapon = -1;
int start;
#ifdef _arch_dreamcast
int joyx, joyy;
IN_GetJoyFineDelta (&joyx, &joyy);
if(joyx < -64)
buttonstate[bt_prevweapon] = true;
else if(joyx > 64)
buttonstate[bt_nextweapon] = true;
#endif
if(buttonstate[bt_nextweapon] && !buttonheld[bt_nextweapon])
{
newWeapon = 0;
buttonheld[bt_nextweapon] = true;
if (gamestate.weapon == gamestate.bestweapon)
start = 0; // jump to first weapon
else
start = gamestate.weapon+1; // jump to next weapon
for (i=start; i<=gamestate.bestweapon; i++)
{
if (gamestate.gotweapon & (1<<i))
{
newWeapon = i;
break;
}
}
}
else if(buttonstate[bt_prevweapon] && !buttonheld[bt_prevweapon])
{
newWeapon = 0;
buttonheld[bt_prevweapon] = true;
if (gamestate.weapon == 0)
start = gamestate.bestweapon; // Jump to bestweapon
else
start = gamestate.weapon-1; // Jump to previous weapon
for (i=start; i>=0; i--)
{
if (gamestate.gotweapon & (1<<i))
{
newWeapon = i;
break;
}
}
}
else
{
for(int i = wp_knife; i <= gamestate.bestweapon; i++)
{
if ((gamestate.gotweapon & (1<<i)) && buttonstate[bt_readyknife + i - wp_knife])
{
newWeapon = i;
break;
}
}
}
if(newWeapon != -1)
{
gamestate.weapon = gamestate.chosenweapon = (weapontype) newWeapon;
DrawWeapon();
}
}
void GiveWeapon (int weapon)
{
GiveAmmo (6);
if (gamestate.bestweapon<weapon)
gamestate.bestweapon = gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;
gamestate.gotweapon = (weapontype) (gamestate.gotweapon | (1<<weapon)); // Make the new weapon available for player
DrawWeapon ();
}
case ssobj:
GivePoints (500);
NewState (ob,&s_ssdie1);
if (!(gamestate.gotweapon & (1<<wp_machinegun)))
PlaceItemType (bo_machinegun,tilex,tiley);
else
PlaceItemType (bo_clip2,tilex,tiley);
break;
if (gamestate.lives > -1)
{
gamestate.health = 110;
gamestate.weapon = gamestate.bestweapon
= gamestate.chosenweapon = wp_pistol;
gamestate.gotweapon = (weapontype)0; // Take away all weapons
gamestate.gotweapon = (weapontype) (gamestate.gotweapon | (1<<wp_knife)); // Give knife
gamestate.gotweapon = (weapontype) (gamestate.gotweapon | (1<<wp_pistol)); // and pistol for free...
gamestate.ammo = STARTAMMO;
void NewGame (int difficulty,int episode)
{
memset (&gamestate,0,sizeof(gamestate));
gamestate.difficulty = difficulty;
gamestate.weapon = gamestate.bestweapon
= gamestate.chosenweapon = wp_pistol;
gamestate.gotweapon = (weapontype)0; // Take away all weapons
gamestate.gotweapon = (weapontype) (gamestate.gotweapon | (1<<wp_knife)); // Give knife
gamestate.gotweapon = (weapontype) (gamestate.gotweapon | (1<<wp_pistol)); // and pistol for free...
gamestate.health = 110;
gamestate.ammo = STARTAMMO;
gamestate.lives = 3;
gamestate.nextextra = EXTRAPOINTS;
gamestate.episode=episode;
startgame = true;
}
//
// SECRET CHEAT CODE: 'MLI'
//
if (Keyboard[sc_M] && Keyboard[sc_L] && Keyboard[sc_I])
{
gamestate.health = 110;
gamestate.ammo = 200;
gamestate.keys = 3;
gamestate.score = 0;
gamestate.TimeCount += 42000L;
GiveWeapon (wp_machinegun); // Give the machinegun
GiveWeapon (wp_chaingun);
I'd say about 90% but then again I'm not the one finishing up the coding.Dark_wizzie wrote:Just out of curiosity, on a scale of 0 to 100% done, how much is done in making FF2?
void DrawPlayBorder (void)
{
const int px = scaleFactor; // size of one "pixel"
if (bordercol != VIEWCOLOR)
DrawStatusBorder(bordercol);
if(viewheight == screenHeight) return;
VWB_BarScaledCoord (0,0,screenWidth,screenHeight-px*STATUSLINES,bordercol);
const int xl = screenWidth/2-viewwidth/2;
const int yl = (screenHeight-px*STATUSLINES-viewheight)/2;
VWB_BarScaledCoord (xl,yl,viewwidth,viewheight,0);
if(xl != 0)
{
// Paint game view border lines
VWB_BarScaledCoord(xl-px, yl-px, viewwidth+px, px, 0); // upper border
VWB_BarScaledCoord(xl, yl+viewheight, viewwidth+px, px, bordercol-2); // lower border
VWB_BarScaledCoord(xl-px, yl-px, px, viewheight+px, 0); // left border
VWB_BarScaledCoord(xl+viewwidth, yl-px, px, viewheight+2*px, bordercol-2); // right border
VWB_BarScaledCoord(xl-px, yl+viewheight, px, px, bordercol-3); // lower left highlight
}
else
{
// Just paint a lower border line
VWB_BarScaledCoord(0, yl+viewheight, viewwidth, px, bordercol-2); // lower border
}
}
void ShowActStatus()
{
// Draw status bar without borders
byte *source = grsegs[STATUSBARPIC];
int picnum = STATUSBARPIC - STARTPICS;
int width = pictable[picnum].width;
int height = pictable[picnum].height;
int destx = (screenWidth-scaleFactor*320)/2 * scaleFactor;
int desty = screenHeight - height * scaleFactor;
VL_MemToScreenScaledCoord(source, width, height, 0, 0, destx, desty, width, height);
ingame = false;
DrawFace ();
DrawHealth ();
DrawLives ();
DrawLevel ();
DrawAmmo ();
DrawKeys ();
DrawWeapon ();
DrawScore ();
ingame = true;
}