Commit 9d9a85aa authored by Steven Fuller's avatar Steven Fuller

A few preperations for the OpenGL renderer

parent 4dce6cc4
/*
Copyright (C) 2000 Steven Fuller <relnev@atdot.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
This diff is collapsed.
......@@ -8,14 +8,16 @@ CFLAGS = -g
#CFLAGS = -Os -g
#CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include
OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \
Missiles.o Sounds.o PlMove.o PlStuff.o PlThink.o PushWall.o \
RefBsp.o RefSprite.o Refresh.o Refresh2.o Sight.o Main.o \
StateDef.o WolfMain.o WolfIO.o InterMis.o Burger.o stub.o res.o
SOBJS = $(OBJS) vi_svga.o
XOBJS = $(OBJS) vi_xlib.o
GOBJS = $(OBJS) vi_gtk.o
GLOBJS = $(OBJS) vi_glx.o
OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \
Missiles.o Sounds.o PlMove.o PlStuff.o PlThink.o PushWall.o \
RefBsp.o RefSprite.o Refresh.o Refresh2.o Sight.o Main.o \
StateDef.o WolfMain.o WolfIO.o InterMis.o Burger.o stub.o res.o
SOFTOBJS = SoftDraw.o
OGLOBJS = SoftDraw.o #
SOBJS = $(SOFTOBJS) $(OBJS) vi_svga.o
XOBJS = $(SOFTOBJS) $(OBJS) vi_xlib.o
GOBJS = $(SOFTOBJS) $(OBJS) vi_gtk.o
GLOBJS = $(OGLOBJS) $(OBJS) vi_glx.o
LFLAGS = -lm
#LFLAGS = -lm -L/home/relnev/cvs/oal/linux/src -lopenal -lpthread -ldl
......@@ -34,9 +36,9 @@ NASM = nasm
all: swolf3d xwolf3d gwolf3d glwolf3d
$(SOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
$(XOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
$(GOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
$(SOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
$(XOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
$(GOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
$(GLOBJS): Sounds.h Sprites.h States.h Wolf.h burger.h wolfdef.h
.asm.o:
......
......@@ -244,9 +244,9 @@ void P_DrawSeg (saveseg_t *seg)
/* adjust pushwall segs */
if (seg == pwallseg) { /* Is this the active pushwall? */
if (seg->dir&1) { /* east/west*/
if (seg->dir&1) { /* east/west */
segplane += PushWallRec.pwallychange;
} else { /* north/south*/
} else { /* north/south */
segplane += PushWallRec.pwallxchange;
}
}
......@@ -467,13 +467,13 @@ void RenderBSPNode(Word bspnum)
}
savedcoordinate = bspcoord[savednum]; /* Save this coord */
bspcoord[savednum] = coordinate; /* Set my new coord boundary */
bspcoord[savednum] = coordinate; /* Set my new coord boundary */
RenderBSPNode(bsp->children[side^1]); /* recursively divide front space*/
bspcoord[savednum] = savedcoordinate; /* Restore the coord */
savednum ^= 1; /* Negate the index */
savednum ^= 1; /* Negate the index */
savedcoordinate = bspcoord[savednum]; /* Save the other side */
bspcoord[savednum] = coordinate; /* Set the new side */
bspcoord[savednum] = coordinate; /* Set the new side */
/* if the back side node is a single seg, don't bother explicitly checking visibility */
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h"
void ScaledDraw(Byte *gfx, Word scale, Byte *vid, LongWord TheFrac, Word TheInt, Word Width, LongWord Delta)
{
LongWord OldDelta;
while (scale--) {
*vid = *gfx;
vid += Width;
OldDelta = Delta;
Delta += TheFrac;
gfx += TheInt;
if (OldDelta > Delta)
gfx += 1;
}
}
void IO_ScaleWallColumn(Word x, Word scale, Word tile, Word column)
{
LongWord TheFrac;
Word TheInt;
LongWord y;
Byte *ArtStart;
if (scale) {
scale*=2;
TheFrac = 0x80000000UL / scale;
ArtStart = &ArtData[tile][column<<7];
if (scale<VIEWHEIGHT) {
y = (VIEWHEIGHT-scale)/2;
TheInt = TheFrac>>24;
TheFrac <<= 8;
ScaledDraw(ArtStart,scale,&VideoPointer[(y*VideoWidth)+x],
TheFrac,TheInt,VideoWidth, 0);
return;
}
y = (scale-VIEWHEIGHT)/2;
y *= TheFrac;
TheInt = TheFrac>>24;
TheFrac <<= 8;
ScaledDraw(&ArtStart[y>>24],VIEWHEIGHT,&VideoPointer[x],
TheFrac,TheInt,VideoWidth,y<<8);
}
}
typedef struct {
SWord Topy;
SWord Boty;
SWord Shape;
} PACKED SpriteRun;
void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column)
{
Byte * CharPtr2;
int Y1,Y2;
Byte *Screenad;
SpriteRun *RunPtr;
LongWord TheFrac;
LongWord TFrac;
LongWord TInt;
Word RunCount;
int TopY;
Word Index;
LongWord Delta;
if (!scale)
return;
CharPtr2 = (Byte *) CharPtr;
TheFrac = 0x40000000/scale;
RunPtr = (SpriteRun *)&CharPtr[sMSB(CharPtr[column+1])/2];
Screenad = &VideoPointer[x];
TFrac = TheFrac<<8;
TInt = TheFrac>>24;
TopY = (VIEWHEIGHT/2)-scale;
while (RunPtr->Topy != 0xFFFF) {
Y1 = scale*(LongWord)sMSB(RunPtr->Topy)/128+TopY;
if (Y1 < VIEWHEIGHT) {
Y2 = scale*(LongWord)sMSB(RunPtr->Boty)/128+TopY;
if (Y2 > 0) {
if (Y2 > VIEWHEIGHT)
Y2 = VIEWHEIGHT;
Index = sMSB(RunPtr->Shape)+sMSB(RunPtr->Topy)/2;
Delta = 0;
if (Y1 < 0) {
Delta = (0-(LongWord)Y1)*TheFrac;
Index += (Delta>>24);
Delta <<= 8;
Y1 = 0;
}
RunCount = Y2-Y1;
if (RunCount)
ScaledDraw(&CharPtr2[Index],RunCount,
&Screenad[Y1*VideoWidth],TFrac,TInt,VideoWidth, Delta);
}
}
RunPtr++;
}
}
Byte *SmallFontPtr;
void MakeSmallFont(void)
{
Word i,j,Width,Height;
Byte *DestPtr,*ArtStart;
Byte *TempPtr;
SmallFontPtr = AllocSomeMem(16*16*65);
if (!SmallFontPtr) {
return;
}
memset(SmallFontPtr,0,16*16*65);
i = 0;
DestPtr = SmallFontPtr;
do {
ArtStart = &ArtData[i][0];
if (!ArtStart) {
DestPtr+=(16*16);
} else {
Height = 0;
do {
Width = 16;
j = Height*8;
do {
DestPtr[0] = ArtStart[j];
++DestPtr;
j+=(WALLHEIGHT*8);
} while (--Width);
} while (++Height<16);
}
} while (++i<64);
TempPtr = LoadAResource(MyBJFace);
memcpy(DestPtr,TempPtr,16*16);
ReleaseAResource(MyBJFace);
}
void KillSmallFont(void)
{
if (SmallFontPtr) {
FreeSomeMem(SmallFontPtr);
SmallFontPtr = 0;
}
}
void DrawSmall(Word x,Word y,Word tile)
{
Byte *Screenad;
Byte *ArtStart;
Word Width,Height;
if (!SmallFontPtr) {
return;
}
x *= 16;
y *= 16;
Screenad = &VideoPointer[YTable[y]+x];
ArtStart = &SmallFontPtr[tile*(16*16)];
Height = 0;
do {
Width = 16;
do {
Screenad[0] = ArtStart[0];
++Screenad;
++ArtStart;
} while (--Width);
Screenad+=VideoWidth-16;
} while (++Height<16);
}
......@@ -8,11 +8,13 @@ TODO:
- If user requests a gamemode which SVGAlib says it does not support, fail
- If SVGAlib does not support 512x384x256, allow the user to pan around
with the keypad arrow keys.
* Finish moving all 2D code to SoftDraw.c
BUGS:
* drawing seems like its imprecise, stationary sprites move back and forth,
and walls 'swim' when you move around, or sprites pop into different sizes
when are far enough and get closer/farther away
* Drawing seems like its imprecise, stationary sprites move back and forth,
and walls 'swim' when you move around, or sprites pop into different sizes
when are far enough and get closer/farther away
- Possibly caused by 8.8 fixed?
* it crashes somewhere, no reason why...
#0 0x804fa55 in DrawXMShape (x=128, y=96, ShapePtr=0x8c8c8c8c) at
Burger.c:198
......@@ -22,8 +24,6 @@ to it...
* added an 'and' hack to lines 33 and 50 in RefBsp.c Not sure if this causes
any problems (value was overflowing finetangent...)
MISC:
IDEAS:
* Menu Keys
- ESC: Quit
......@@ -33,8 +33,8 @@ IDEAS:
- XXX: Save Game
- XXX: Save Game to Previously used File
- XXX: Options
* How about adding red/white shifts (from PC wolf3d)? So screen changes
color when you are hit or pick up items.
* when saving/loading games, run them through htons/etc.
MISC:
......@@ -53,7 +53,6 @@ extern LongWord LastTick;
extern LongWord YTable[480];
void DLZSS(Byte *Dest, Byte *Src,LongWord Length);
unsigned short SwapUShort(unsigned short Val);
void WaitTick(void);
void WaitTicks(Word TickCount);
......
......@@ -72,8 +72,8 @@ ReleaseAResource(MySoundList);
MapListPtr = (maplist_t *) LoadAResource(rMapList);
FixMapList(MapListPtr);
SongListPtr = (unsigned short *) LoadAResource(rSongList);
WallListPtr = (unsigned short *) LoadAResource(MyWallList);
SongListPtr = (unsigned short *)LoadAResource(rSongList);
WallListPtr = (unsigned short *)LoadAResource(MyWallList);
}
......@@ -107,112 +107,6 @@ Word ScaleY(Word y)
return y;
}
void ScaledDraw(Byte *gfx, Word scale, Byte *vid, LongWord TheFrac, Word TheInt, Word Width, LongWord Delta)
{
LongWord OldDelta;
while (scale--) {
*vid = *gfx;
vid += Width;
OldDelta = Delta;
Delta += TheFrac;
gfx += TheInt;
if (OldDelta > Delta)
gfx += 1;
}
}
void IO_ScaleWallColumn(Word x, Word scale, Word tile, Word column)
{
LongWord TheFrac;
Word TheInt;
LongWord y;
Byte *ArtStart;
if (scale) {
scale*=2;
TheFrac = 0x80000000UL / scale;
ArtStart = &ArtData[tile][column<<7];
if (scale<VIEWHEIGHT) {
y = (VIEWHEIGHT-scale)/2;
TheInt = TheFrac>>24;
TheFrac <<= 8;
ScaledDraw(ArtStart,scale,&VideoPointer[(y*VideoWidth)+x],
TheFrac,TheInt,VideoWidth, 0);
return;
}
y = (scale-VIEWHEIGHT)/2;
y *= TheFrac;
TheInt = TheFrac>>24;
TheFrac <<= 8;
ScaledDraw(&ArtStart[y>>24],VIEWHEIGHT,&VideoPointer[x],
TheFrac,TheInt,VideoWidth,y<<8);
}
}
typedef struct {
SWord Topy;
SWord Boty;
SWord Shape;
} PACKED SpriteRun;
void IO_ScaleMaskedColumn(Word x,Word scale, unsigned short *CharPtr,Word column)
{
Byte * CharPtr2;
int Y1,Y2;
Byte *Screenad;
SpriteRun *RunPtr;
LongWord TheFrac;
LongWord TFrac;
LongWord TInt;
Word RunCount;
int TopY;
Word Index;
LongWord Delta;
if (!scale)
return;
CharPtr2 = (Byte *) CharPtr;
TheFrac = 0x40000000/scale;
RunPtr = (SpriteRun *)&CharPtr[sMSB(CharPtr[column+1])/2];
Screenad = &VideoPointer[x];
TFrac = TheFrac<<8;
TInt = TheFrac>>24;
TopY = (VIEWHEIGHT/2)-scale;
while (RunPtr->Topy != 0xFFFF) {
Y1 = scale*(LongWord)sMSB(RunPtr->Topy)/128+TopY;
if (Y1 < VIEWHEIGHT) {
Y2 = scale*(LongWord)sMSB(RunPtr->Boty)/128+TopY;
if (Y2 > 0) {
if (Y2 > VIEWHEIGHT)
Y2 = VIEWHEIGHT;
Index = sMSB(RunPtr->Shape)+sMSB(RunPtr->Topy)/2;
Delta = 0;
if (Y1 < 0) {
Delta = (0-(LongWord)Y1)*TheFrac;
Index += (Delta>>24);
Delta <<= 8;
Y1 = 0;
}
RunCount = Y2-Y1;
if (RunCount)
ScaledDraw(&CharPtr2[Index],RunCount,
&Screenad[Y1*VideoWidth],TFrac,TInt,VideoWidth, Delta);
}
}
RunPtr++;
}
}
Boolean SetupScalers()
{
return TRUE;
......@@ -222,83 +116,6 @@ void ReleaseScalers()
{
}
Byte *SmallFontPtr;
void MakeSmallFont(void)
{
Word i,j,Width,Height;
Byte *DestPtr,*ArtStart;
Byte *TempPtr;
SmallFontPtr = AllocSomeMem(16*16*65);
if (!SmallFontPtr) {
return;
}
memset(SmallFontPtr,0,16*16*65);
i = 0;
DestPtr = SmallFontPtr;
do {
ArtStart = &ArtData[i][0];
if (!ArtStart) {
DestPtr+=(16*16);
} else {
Height = 0;
do {
Width = 16;
j = Height*8;
do {
DestPtr[0] = ArtStart[j];
++DestPtr;
j+=(WALLHEIGHT*8);
} while (--Width);
} while (++Height<16);
}
} while (++i<64);
TempPtr = LoadAResource(MyBJFace);
memcpy(DestPtr,TempPtr,16*16);
ReleaseAResource(MyBJFace);
}
void KillSmallFont(void)
{
if (SmallFontPtr) {
FreeSomeMem(SmallFontPtr);
SmallFontPtr = 0;
}
}
void DrawSmall(Word x,Word y,Word tile)
{
Byte *Screenad;
Byte *ArtStart;
Word Width,Height;
if (!SmallFontPtr) {
return;
}
x *= 16;
y *= 16;
Screenad = &VideoPointer[YTable[y]+x];
ArtStart = &SmallFontPtr[tile*(16*16)];
Height = 0;
do {
Width = 16;
do {
Screenad[0] = ArtStart[0];
++Screenad;
++ArtStart;
} while (--Width);
Screenad+=VideoWidth-16;
} while (++Height<16);
}
LongWord PsyTime;
void ShowGetPsyched(void)
......@@ -322,8 +139,7 @@ void ShowGetPsyched(void)
FreeSomeMem(ShapePtr);
ReleaseAResource(rGetPsychPic);
BlastScreen();
SetAPalette(rGamePal);
SetAPalette(rGamePal);
}
void DrawPsyched(Word Index)
......@@ -361,7 +177,6 @@ LongWord ReadTick()
if (t0.tv_sec == 0) {
gettimeofday(&t0, NULL);
printf("RESET?\n");
return 0;
}
......
......@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/*
This is NOT the OpenGL version!
This is a COPY of vi_xlib.c as a placeholder!
(with minor changes)
*/
#include <stdio.h>
......@@ -31,6 +32,10 @@ This is a COPY of vi_xlib.c as a placeholder!
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glext.h>
#include "wolfdef.h"
Display *dpy;
......@@ -46,6 +51,16 @@ XColor clr[256];
Byte *gfxbuf;
int attrib[] = {
GLX_RGBA,
GLX_RED_SIZE, 5,
GLX_GREEN_SIZE, 5,
GLX_BLUE_SIZE, 5,
GLX_DEPTH_SIZE, 16,
GLX_DOUBLEBUFFER,
None
};
int main(int argc, char *argv[])
{
XSetWindowAttributes attr;
......
......@@ -36,24 +36,31 @@ typedef struct {
int bottom;
} Rect;
#ifdef __BIGENDIAN__
unsigned short int sLSB(unsigned short int i);
#define sMSB(i) i
unsigned long lLSB(unsigned long i);
#define lMSB(i) i
#else /* __BIGENDIAN__ */
unsigned short int sLSB(unsigned short int i);
unsigned short int sMSB(unsigned short int i);
unsigned long lLSB(unsigned long i);
unsigned long lMSB(unsigned long i);
#endif /* __BIGENDIAN__ */
/* an angle_t occupies an entire 16 bits so wraparound is automatically handled */
#define SHORTTOANGLESHIFT 7 /* 0x10000 to ANGLES */
#define SLOPEBITS 9 /* Used in AngleFromSlope2 */
#define SLOPEBITS 9 /* Used in AngleFromSlope2 */
typedef unsigned short angle_t; /* Must be short to allow wraparound */
typedef short fixed_t; /* 8.8 fixed point number */
typedef short fixed_t; /* 8.8 fixed point number */
typedef unsigned short ufixed_t; /* 8.8 unsigned fixed point number */
#include "burger.h" /* My standard system equates */
#include "States.h" /* Think state equates */
#include "Sounds.h" /* Sound equates */
#include "Sprites.h" /* Sprite indexs */
#include "Sprites.h" /* Sprite indexs */
#include "Wolf.h" /* Resource maps */
/**********************************
......@@ -69,22 +76,22 @@ typedef unsigned short ufixed_t; /* 8.8 unsigned fixed point number */
**********************************/
#define MAXVISSPRITES 64 /* Maximum number of sprites to display (Must be a power of 2!) */
#define MAXACTORS 128 /* max number of nazis, etc / map */
#define MAXSTATICS 200 /* max number of lamps, bonus, etc */
#define MAXMISSILES 32 /* max missiles, flames, smokes, etc */
#define MAXDOORS 64 /* max number of sliding doors (64<=) */
#define MAXAREAS 64 /* max number of bsp areas */
#define NUMBUTTONS 10 /* Number of control buttons */
#define WALLHEIGHT 128 /* Height,width of walls */
#define SPRITEHEIGHT 64 /* Height,width of a sprite */
#define PLAYERSIZE 88 /* radius of player in 8.8 fixed point */
#define MAXVISSPRITES 64 /* Maximum number of sprites to display (Must be a power of 2!) */
#define MAXACTORS 128 /* max number of nazis, etc / map */
#define MAXSTATICS 200 /* max number of lamps, bonus, etc */
#define MAXMISSILES 32 /* max missiles, flames, smokes, etc */
#define MAXDOORS 64 /* max number of sliding doors (64<=) */
#define MAXAREAS 64 /* max number of bsp areas */
#define NUMBUTTONS 10 /* Number of control buttons */
#define WALLHEIGHT 128 /* Height,width of walls */
#define SPRITEHEIGHT 64 /* Height,width of a sprite */
#define PLAYERSIZE 88 /* radius of player in 8.8 fixed point */
#define PROJECTIONSCALE (SCREENWIDTH/2)*0x90l
#define FIELDOFVIEW 364*4 /* fineangles in the SCREENWIDTH wide window*/
#define FIELDOFVIEW 364*4 /* fineangles in the SCREENWIDTH wide window*/
#define MINZ 62 /* PLAYERSIZE/sqrt(2) rounded down*/
#define MAXZ (32*FRACUNIT) /* Farthest thing away */
#define FINEANGLES 0x2000 /* Power of 2 */
#define FINEANGLES 0x2000 /* Power of 2 */
#define FINEMASK (FINEANGLES-1)
#define ANGLETOFINESHIFT 3 /* 0x10000 >> 0x2000*/
#define GAMEANGLETOFINE 4 /* 512 << 0x2000 */
......@@ -92,15 +99,16 @@ typedef unsigned short ufixed_t; /* 8.8 unsigned fixed point number */
#define ANGLE180 0x8000 /* Use a 0x10000 angle range */
#if 0
#define SCREENWIDTH 320 /* Size of the offscreen buffer */
#define SCREENHEIGHT 200 /* Height of the offscreen buffer */
#define VIEWHEIGHT 160 /* Height of the viewing area */
#define SCREENWIDTH 320 /* Size of the offscreen buffer */
#define SCREENHEIGHT 200 /* Height of the offscreen buffer */
#define VIEWHEIGHT 160 /* Height of the viewing area */
#endif
#define SCREENWIDTH VidWidth
#define SCREENHEIGHT VidHeight
#define VIEWHEIGHT ViewHeight
extern int VidWidth, VidHeight, ViewHeight;
Word ScaleX(Word x); /* Scale factor for 320 mode points projected to SCREEN */
Word ScaleY(Word y);
......@@ -116,14 +124,14 @@ Word ScaleY(Word y);
#define MAXBONUSCOLOR 8 /* Number of shades of gold to use for damage */
#define EXTRAPOINTS 20000 /* Points for a free man */
#define STARTAMMO 16 /* Ammo to begin the game with */
#define TILEGLOBAL 256 /* Pixels per tile */
#define STARTAMMO 16 /* Ammo to begin the game with */
#define TILEGLOBAL 256 /* Pixels per tile */
#define MINACTORDIST 192 /* minimum dist from player center*/
/* to any actor center*/
#define KNIFEDIST 480 /* max dist for a knife hit (fixed_t) */
#define BITERANGE 350 /* max dist for a bite hit (fixed_t) */
#define MISSILEHITDIST 120 /* max dist for a missile impact (fixed_t) */
#define MAPSIZE 64 /* Size of a map in tiles */
/* to any actor center */
#define KNIFEDIST 480 /* max dist for a knife hit (fixed_t) */
#define BITERANGE 350 /* max dist for a bite hit (fixed_t) */
#define MISSILEHITDIST 120 /* max dist for a missile impact (fixed_t) */
#define MAPSIZE 64 /* Size of a map in tiles */
/* joypad masks */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment