Commit 296619ee authored by Steven Fuller's avatar Steven Fuller

* Moved more 2D code to SoftDraw2.c

* Fixed OpenGL Automap (everything is now shown correctly)
* Updates to OpenGL code
parent f576b52f
......@@ -33,6 +33,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int UseSharedTexturePalette = 0;
/*
Utility Functions
*/
void xgluPerspective(GLdouble fovx, GLdouble aspect, GLdouble zNear, GLdouble zFar)
{
GLdouble xmin, xmax, ymin, ymax;
......@@ -46,6 +50,10 @@ void xgluPerspective(GLdouble fovx, GLdouble aspect, GLdouble zNear, GLdouble zF
glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}
/*
Temp Stuff
*/
void DisplayScreen(Word res)
{
}
......@@ -88,8 +96,67 @@ void DrawShape(Word x, Word y, void *ShapePtr)
{
}
void SetNumber(LongWord number, Word x, Word y, Word digits)
{
}
/*
Unused Status Bar stuff
*/
Word NumberIndex = 36; /* Argh */
void IO_DrawFloor(Word floor)
{
}
void IO_DrawScore(LongWord score)
{
}
void IO_DrawLives(Word lives)
{
}
void IO_DrawHealth(Word health)
{
}
void IO_DrawAmmo(Word ammo)
{
}
void IO_DrawTreasure(Word treasure)
{
}
void IO_DrawKeys(Word keys)
{
}
void IO_DrawFace(Word face)
{
}
void IO_DrawStatusBar(void)
{
}
void IO_DisplayViewBuffer(void)
{
BlastScreen();
if (firstframe) {
FadeTo(rGamePal);
firstframe = 0;
}
}
GLuint LastTexture;
/*
Automap Drawing
*/
GLuint smltex[65];
void MakeSmallFont()
......@@ -180,19 +247,22 @@ void DrawSmall(Word x, Word y, Word tile)
GLfloat xx, yy;
GLfloat x1, y1, x2, y2;
w = (int)(VidWidth >> 4);
h = (int)(VidHeight >> 4);
w = (int)(640 >> 4);
h = (int)(480 >> 4);
xx = x;
yy = y;
x1 = ((xx * 2.0f) - w) + 1.0;
x1 = ((xx * 2.0f) - w) + 2.0;
x2 = x1 - 2.0;
y1 = -((yy * 2.0f) - h) + 1.0;
y1 = -((yy * 2.0f) - h);
y2 = y1 - 2.0;
x1 /= w;
x2 /= w;
y1 /= h;
y2 /= h;
glViewport(0, 0, VidWidth, VidHeight);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
......@@ -216,7 +286,6 @@ void DrawSmall(Word x, Word y, Word tile)
glPopMatrix();
}
Byte *FlipWall(Byte *dat, int w, int h)
{
Byte *buf;
......@@ -306,13 +375,15 @@ void IO_ClearViewBuffer()
LastTexture = 0;
glBindTexture(GL_TEXTURE_2D, 0);
glViewport(0, VidHeight - ViewHeight, VidWidth, ViewHeight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
#if 0
/* glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); */
glClear(GL_DEPTH_BUFFER_BIT);
......@@ -346,6 +417,11 @@ void IO_ClearViewBuffer()
glDepthFunc(GL_LESS);
#endif
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glRotatef(270.0-((double)gamestate.viewangle / (double)ANGLES * 360.0), 0.0, 1.0, 0.0);
glTranslatef((double)actors[0].x / 256.0, 0, (double)actors[0].y / 256.0);
}
GLuint waltex[64];
......@@ -432,7 +508,22 @@ void InitRenderView()
free(buf);
}
if (weptex[0] == 0) {
if (weptex[0] == 0) {
/* Load GameShapes */
LongWord *LongPtr;
Byte *DestPtr;
int i;
LongPtr = (LongWord *)LoadAResource(rFace640);
GameShapes = (Byte **)AllocSomeMem(lMSB(LongPtr[0]));
DLZSS((Byte *)GameShapes, (Byte *)&LongPtr[1], lMSB(LongPtr[0]));
ReleaseAResource(rFace640);
LongPtr = (LongWord *)GameShapes;
DestPtr = (Byte *)GameShapes;
for (i = 0; i < 47; i++)
GameShapes[i] = DestPtr + lMSB(LongPtr[i]);
glGenTextures(NUMWEAPONS*4, weptex);
for (i = 0; i < NUMWEAPONS*4; i++) {
Byte *buf = DeXMShape(GameShapes[12+i], pal);
......@@ -450,7 +541,10 @@ void InitRenderView()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
free(buf);
}
}
free(GameShapes);
GameShapes = NULL;
}
ReleaseAResource(rGamePal);
......@@ -506,17 +600,6 @@ void IO_AttackShape(Word shape)
glPopMatrix();
}
void StartRenderView()
{
glViewport(0, VidHeight - ViewHeight, VidWidth, ViewHeight);
glMatrixMode(GL_MODELVIEW);
/* glLoadIdentity(); */
glRotatef(270.0-((double)gamestate.viewangle / (double)ANGLES * 360.0), 0.0, 1.0, 0.0);
glTranslatef((double)actors[0].x / 256.0, 0, (double)actors[0].y / 256.0);
}
void DrawSprite(thing_t *t)
{
glPushMatrix();
......
......@@ -10,12 +10,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 Refresh.o Refresh2.o Sight.o Main.o \
StateDef.o WolfMain.o WolfIO.o InterMis.o Burger.o stub.o res.o
SOFTOBJS = RefSprite.o SoftDraw.o
SOFTOBJS = RefSprite.o SoftDraw.o SoftDraw2.o
OGLOBJS = GLDraw.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
SOBJS = $(OBJS) $(SOFTOBJS) vi_svga.o
XOBJS = $(OBJS) $(SOFTOBJS) vi_xlib.o
GOBJS = $(OBJS) $(SOFTOBJS) vi_gtk.o
GLOBJS = $(OBJS) $(OGLOBJS) vi_glx.o
LFLAGS = -lm
#LFLAGS = -lm /home/relnev/ElectricFence-2.1/libefence.a
......
......@@ -451,7 +451,6 @@ void RenderView(void)
memset(areavis, 0, sizeof(areavis)); /* No areas are visible */
IO_ClearViewBuffer(); /* Erase to ceiling / floor colors*/
StartRenderView(); /* Marker to let GL code know */
ClearClipSegs(); /* Clip first seg only to sides of screen */
......
......@@ -179,7 +179,7 @@ void T_Stand(actor_t *ActorPtr)
if (ActorPtr->flags&FL_AMBUSH ) { /* Ambush actor? */
if (!CheckLine(ActorPtr)) { /* Can I see you? */
ActorPtr->reacttime=1; /* be very ready, but*/
return; /* don't attack yet*/
return; /* don't attack yet*/
}
ActorPtr->flags &= ~FL_AMBUSH; /* Clear the ambush flag */
}
......
......@@ -19,17 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "wolfdef.h"
/**********************************
Draw the gun in the foreground
**********************************/
void IO_AttackShape(Word shape)
{
DrawXMShape(ScaleX(128),ScaleY(96),GameShapes[shape+12]);
}
void DisplayScreen(Word res)
{
LongWord *PackPtr;
......@@ -732,9 +721,7 @@ void P_DrawSeg (saveseg_t *seg)
ClipWallSegment(angle1, angle2,seg,distance);
}
void StartRenderView()
{
}
/* OpenGL-based stubs */
void InitRenderView()
{
......
/*
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"
#include <string.h>
/**********************************
Draw a space padded list of numbers
for the score
**********************************/
LongWord pow10[] = {1,10,100,1000,10000,100000,1000000};
Word NumberIndex = 36; /* First number in the shape list... */
void SetNumber(LongWord number,Word x,Word y,Word digits)
{
LongWord val;
Word count;
Word empty;
empty = 1; /* No char's drawn yet */
while (digits) { /* Any digits left? */
count = 0; /* No value yet */
val = pow10[digits-1]; /* Get the power of 10 */
while (number >= val) { /* Any value here? */
count++; /* +1 to the count */
number -= val; /* Remove the value */
}
if (empty && !count && digits!=1) { /* pad on left with blanks rather than 0 */
DrawShape(x,y,GameShapes[NumberIndex]);
} else {
empty = 0; /* I have drawn... */
DrawShape(x,y,GameShapes[count+NumberIndex]); /* Draw the digit */
}
x+=ScaleX(8);
digits--; /* Count down */
}
}
/**********************************
Draw the gun in the foreground
**********************************/
void IO_AttackShape(Word shape)
{
DrawXMShape(ScaleX(128),ScaleY(96),GameShapes[shape+12]);
}
/**********************************
Draw the floor and castle #
**********************************/
void IO_DrawFloor(Word floor)
{
SetNumber(MapListPtr->InfoArray[floor].ScenarioNum,ScaleX(8),ScaleY(176),1);
SetNumber(MapListPtr->InfoArray[floor].FloorNum,ScaleX(32),ScaleY(176),1);
}
/**********************************
Draw the score
**********************************/
void IO_DrawScore(LongWord score)
{
if (!IntermissionHack) { /* Don't draw during intermission! */
SetNumber(score,ScaleX(56),ScaleY(176),7);
}
}
/**********************************
Draw the number of live remaining
**********************************/
void IO_DrawLives(Word lives)
{
if (!IntermissionHack) { /* Don't draw during intermission! */
--lives; /* Adjust for zero start value */
if (lives > 9) {
lives = 9; /* Failsafe */
}
SetNumber(lives,ScaleX(188),ScaleY(176),1); /* Draw the lives count */
}
}
/**********************************
Draw the health
**********************************/
void IO_DrawHealth(Word health)
{
SetNumber(health,ScaleX(210),ScaleY(176),3);
}
/**********************************
Draw the ammo remaining
**********************************/
void IO_DrawAmmo(Word ammo)
{
SetNumber(ammo,ScaleX(268),ScaleY(176),3);
}
/**********************************
Draw the treasure score
**********************************/
void IO_DrawTreasure(Word treasure)
{
SetNumber(treasure,ScaleX(128),ScaleY(176),2);
}
/**********************************
Draw the keys held
**********************************/
void IO_DrawKeys(Word keys)
{
if (keys&1) {
DrawShape(ScaleX(310),ScaleY(164),GameShapes[10]);
}
if (keys&2) {
DrawShape(ScaleX(310),ScaleY(184),GameShapes[11]);
}
}
/**********************************
Draw the BJ's face
**********************************/
void IO_DrawFace(Word face)
{
DrawShape(ScaleX(160),ScaleY(164),GameShapes[face]); /* Draw the face */
}
/**********************************
Redraw the main status bar
**********************************/
void IO_DrawStatusBar(void)
{
DrawShape(ScaleX(0),ScaleY(160),GameShapes[46]);
}
/**********************************
Copy the 3-D screen to display memory
**********************************/
void IO_DisplayViewBuffer (void)
{
BlastScreen();
/* if this is the first frame rendered, upload everything and fade in */
if (firstframe) {
FadeTo(rGamePal);
firstframe = 0;
}
}
......@@ -4,20 +4,23 @@ TODO:
+ Being in a text menu could be the "pause"
- This would be fine for svgalib
* SVGAlib Hack:
- If user requests a gamemode which SVGAlib says it does not support, fail
- Check to make sure linear addressing is supported
- If SVGAlib does not support 512x384x256, allow the user to pan around
with the keypad arrow keys if only mode supported 320x200x256 (center if
640x400 or 480 is supported?)
- Have a "force no 512 mode" for those who do not want mode changing.
* Finish moving all 2D code to SoftDraw.c
- Should move some code so it is not such a large file (SoftDraw2.c)
* Finish OpenGL
+ Status bars, Introscreens [DrawShape]
- Not exactly sure how I will implement this yet.
- Allow window resizing
+ Not exactly sure how I will implement this yet.
- IO_Draw* (status bar versions) are stubbed, update statusbar when
doing screen update
- Finish window resizing
- Could use the LastTexture to have less glBegin/Ends.
- When all drawing is implemented, remove any unnecessary state/matrix
changes.
- Split up GLDraw.c
* Save/Load Games
* Documentation
* Sound!
......@@ -44,14 +47,13 @@ TODO:
* Get it to compile/work with g++ if it is not too much trouble.
* SDL version (software)
* Mouse
* Psyched bar
BUGS:
* Software 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 imprecision?
* Automap may not be "just right" in OpenGL. Some wall tiles extend past
the left side for example.
* If you die/win, and have a key held down, screen passes by too fast
IDEAS:
......
......@@ -18,42 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfdef.h"
#include <string.h>
/**********************************
Draw a space padded list of numbers
for the score
**********************************/
LongWord pow10[] = {1,10,100,1000,10000,100000,1000000};
Word NumberIndex = 36; /* First number in the shape list... */
void SetNumber(LongWord number,Word x,Word y,Word digits)
{
LongWord val;
Word count;
Word empty;
empty = 1; /* No char's drawn yet */
while (digits) { /* Any digits left? */
count = 0; /* No value yet */
val = pow10[digits-1]; /* Get the power of 10 */
while (number >= val) { /* Any value here? */
count++; /* +1 to the count */
number -= val; /* Remove the value */
}
if (empty && !count && digits!=1) { /* pad on left with blanks rather than 0 */
DrawShape(x,y,GameShapes[NumberIndex]);
} else {
empty = 0; /* I have drawn... */
DrawShape(x,y,GameShapes[count+NumberIndex]); /* Draw the digit */
}
x+=ScaleX(8);
digits--; /* Count down */
}
}
/**********************************
......@@ -97,132 +61,3 @@ void IO_CheckInput(void)
buttonstate[bt_select] = 1;
}
}
/**********************************
Draw the floor and castle #
**********************************/
void IO_DrawFloor(Word floor)
{
SetNumber(MapListPtr->InfoArray[floor].ScenarioNum,ScaleX(8),ScaleY(176),1);
SetNumber(MapListPtr->InfoArray[floor].FloorNum,ScaleX(32),ScaleY(176),1);
}
/**********************************
Draw the score
**********************************/
void IO_DrawScore(LongWord score)
{
if (!IntermissionHack) { /* Don't draw during intermission! */
SetNumber(score,ScaleX(56),ScaleY(176),7);
}
}
/**********************************
Draw the number of live remaining
**********************************/
void IO_DrawLives(Word lives)
{
if (!IntermissionHack) { /* Don't draw during intermission! */
--lives; /* Adjust for zero start value */
if (lives > 9) {
lives = 9; /* Failsafe */
}
SetNumber(lives,ScaleX(188),ScaleY(176),1); /* Draw the lives count */
}
}
/**********************************
Draw the health
**********************************/
void IO_DrawHealth(Word health)
{
SetNumber(health,ScaleX(210),ScaleY(176),3);
}
/**********************************
Draw the ammo remaining
**********************************/
void IO_DrawAmmo(Word ammo)
{
SetNumber(ammo,ScaleX(268),ScaleY(176),3);
}
/**********************************
Draw the treasure score
**********************************/
void IO_DrawTreasure(Word treasure)
{
SetNumber(treasure,ScaleX(128),ScaleY(176),2);
}
/**********************************
Draw the keys held
**********************************/
void IO_DrawKeys(Word keys)
{
if (keys&1) {
DrawShape(ScaleX(310),ScaleY(164),GameShapes[10]);
}
if (keys&2) {
DrawShape(ScaleX(310),ScaleY(184),GameShapes[11]);
}
}
/**********************************
Draw the BJ's face
**********************************/
void IO_DrawFace(Word face)
{
DrawShape(ScaleX(160),ScaleY(164),GameShapes[face]); /* Draw the face */
}
/**********************************
Redraw the main status bar
**********************************/
void IO_DrawStatusBar(void)
{
DrawShape(ScaleX(0),ScaleY(160),GameShapes[46]);
}
/**********************************
Copy the 3-D screen to display memory
**********************************/
void IO_DisplayViewBuffer (void)
{
BlastScreen();
/* if this is the first frame rendered, upload everything and fade in */
if (firstframe) {
FadeTo(rGamePal);
firstframe = 0;
}
}
......@@ -145,7 +145,6 @@ void *LoadAResource2(Word RezNum, LongWord Type)
exit(EXIT_FAILURE);
}
void *FindResource(Word RezNum, LongWord Type)
{
ResItem *c = lr;
......
......@@ -239,9 +239,6 @@ Word VidSize = -1;
Word NewGameWindow(Word NewVidSize)
{
XSizeHints sizehints;
LongWord *LongPtr;
Byte *DestPtr;
int i;
if (NewVidSize == VidSize)
return VidSize;
......@@ -267,20 +264,6 @@ Word NewGameWindow(Word NewVidSize)
ClearTheScreen(BLACK);
BlastScreen();
LongPtr = (LongWord *)LoadAResource(VidPics[NewVidSize]);
if (GameShapes)
FreeSomeMem(GameShapes);
GameShapes = (Byte **)AllocSomeMem(lMSB(LongPtr[0]));
DLZSS((Byte *)GameShapes, (Byte *)&LongPtr[1], lMSB(LongPtr[0]));
ReleaseAResource(VidPics[NewVidSize]);
LongPtr = (LongWord *)GameShapes;
DestPtr = (Byte *)GameShapes;
for (i = 0; i < ((NewVidSize == 1) ? 57 : 47); i++)
GameShapes[i] = DestPtr + lMSB(LongPtr[i]);
VidSize = NewVidSize;
return VidSize;
......@@ -300,15 +283,12 @@ void FlushKeys()
struct {
char code[13];
} CheatCodes[] = {
{ "XUSCNIELPPA" }, /* "XUSCNIELPPA" */
{ "IDDQD" }, /* "IDDQD" */
{ "BURGER" }, /* "BURGER" */
{ "WOWZERS" }, /* "WOWZERS" */
{ "LEDOUX" }, /* "LEDOUX" */
{ "SEGER" }, /* "SEGER" */
{ "MCCALL" }, /* "MCCALL" */
{ "APPLEIIGS" } /* "APPLEIIGS" */
{ "XUSCNIELPPA" }, { "IDDQD" },
{ "BURGER" }, { "WOWZERS" },
{ "LEDOUX" }, { "SEGER" },
{ "MCCALL" }, { "APPLEIIGS" }
};
const int CheatCount = sizeof(CheatCodes) / sizeof(CheatCodes[0]);
int CheatIndex;
......
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