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.
......@@ -12,10 +12,12 @@ 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
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
......
......@@ -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;
}
}
......
/*
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)
......@@ -323,7 +140,6 @@ void ShowGetPsyched(void)
ReleaseAResource(rGetPsychPic);
BlastScreen();
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,10 +36,17 @@ 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 */
......@@ -101,6 +108,7 @@ typedef unsigned short ufixed_t; /* 8.8 unsigned fixed point number */
#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);
......@@ -119,7 +127,7 @@ Word ScaleY(Word y);
#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*/
/* 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) */
......
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