Commit 238f036d authored by Steven Fuller's avatar Steven Fuller

* FIXED THE BUG! Apparantly some sort of timing differences in my code and

the mac version caused sound areas (when doors are opened) to be added more
than once.. of course they were deleted only once, so the array overfilled
and spilled onto adjacent memory.
* Walls and sprites all draw now (except top sprite).
* Start on Automap drawing.
parent 0f888293
......@@ -34,7 +34,7 @@ Open doors conect two areas, so sounds will travel between them and sight
areaconnect has a list of connected area #'s, used to create the table areabyplayer
Every time a door opens or closes the areabyplayer matrix gets recalculated.
An area is True if it connects with the player's current spor.
An area is True if it connects with the player's current spot.
**********************************/
......@@ -253,7 +253,7 @@ void DoorOpening(door_t *door)
Byte *SoundNumPtr;
position = door->position; /* Get the pixel position */
if (!position) { /* Fully closed? */
/* door is just starting to open, so connect the areas*/
......@@ -265,6 +265,7 @@ void DoorOpening(door_t *door)
if (areabyplayer[area1] || areabyplayer[area2]) { /* Can I hear it? */
PlaySound(SND_OPENDOOR); /* Play the door sound */
}
position = 1; /* Offset by one to prevent multiple adds */
}
/* slide the door open a bit */
......
/*
Copyright (C) 1992-1994 Id Software, Inc.
Copyright (C) 2000 Steven Fuller <relnev@atdot.org>
Portions 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
......@@ -44,42 +44,63 @@ void ClearTheScreen(Word c)
glClear(GL_COLOR_BUFFER_BIT);
}
void DrawShape(Word x, Word y, void *ShapePtr)
Byte *Pal256toRGB(Byte *dat, int len, Byte *pal)
{
Byte *buf;
int i;
buf = (Byte *)malloc(len * 3);
for (i = 0; i < len; i++) {
buf[i*3+0] = pal[dat[i]*3+0];
buf[i*3+1] = pal[dat[i]*3+1];
buf[i*3+2] = pal[dat[i]*3+2];
}
return buf;
}
void DrawXMShape(Word x, Word y, void *ShapePtr)
void DrawShape(Word x, Word y, void *ShapePtr)
{
}
void DrawSmall(Word x,Word y,Word tile)
void DrawXMShape(Word x, Word y, void *ShapePtr)
{
}
void MakeSmallFont(void)
GLuint smltex[65];
void MakeSmallFont()
{
Byte *buf;
buf = (Byte *)malloc(16 * 16);
free(buf);
}
void KillSmallFont(void)
void KillSmallFont()
{
int i;
glDeleteTextures(65, smltex);
}
Byte *Pal256toRGB(Byte *dat, int len, Byte *pal)
void DrawSmall(Word x,Word y,Word tile)
{
Byte *buf;
int i;
buf = (Byte *)malloc(len * 3);
for (i = 0; i < len; i++) {
buf[i*3+0] = pal[dat[i]*3+0];
buf[i*3+1] = pal[dat[i]*3+1];
buf[i*3+2] = pal[dat[i]*3+2];
}
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
return buf;
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
Byte *FlipWall(Byte *dat, int w, int h)
{
Byte *buf;
......@@ -93,6 +114,41 @@ Byte *FlipWall(Byte *dat, int w, int h)
return buf;
}
typedef struct {
unsigned short Topy;
unsigned short Boty;
unsigned short Shape;
} PACKED SpriteRun;
Byte *DeSprite(Byte *data, Byte *pal)
{
Byte *buf;
unsigned short *dat = (unsigned short *)data;
int i, x, width, offset;
buf = (Byte *)malloc(128 * 128 * 4);
memset(buf, 0, 128 * 128 * 4);
width = sMSB(dat[0]);
offset = 64 - width / 2;
for (x = 0; x < width; x++) {
SpriteRun *p = (SpriteRun *)&dat[ sMSB(dat[x+1]) / 2 ];
while (p->Topy != 0xFFFF) {
for (i = sMSB(p->Topy) / 2; i < sMSB(p->Boty) / 2; i++) {
*(buf + (i * 128 + x + offset) * 4 + 0) = pal[data[sMSB(p->Shape)+sMSB(p->Topy)/2 + (i-sMSB(p->Topy)/2)]*3+0];
*(buf + (i * 128 + x + offset) * 4 + 1) = pal[data[sMSB(p->Shape)+sMSB(p->Topy)/2 + (i-sMSB(p->Topy)/2)]*3+1];
*(buf + (i * 128 + x + offset) * 4 + 2) = pal[data[sMSB(p->Shape)+sMSB(p->Topy)/2 + (i-sMSB(p->Topy)/2)]*3+2];
*(buf + (i * 128 + x + offset) * 4 + 3) = 255;
}
p++;
}
}
return buf;
}
void IO_ClearViewBuffer()
{
glBindTexture(GL_TEXTURE_2D, 0);
......@@ -123,6 +179,7 @@ void IO_ClearViewBuffer()
}
GLuint waltex[64];
GLuint sprtex[S_LASTONE];
void InitRenderView()
{
......@@ -130,35 +187,35 @@ void InitRenderView()
int i;
glEnable(GL_TEXTURE_2D);
if (waltex[0]) {
glDeleteTextures(64, waltex);
for (i = 0; i < 64; i++)
waltex[i] = 0;
}
glGenTextures(64, waltex);
pal = LoadAResource(rGamePal);
for (i = 0; i < 64; i++) {
Byte *buf, *buf2;
glBindTexture(GL_TEXTURE_2D, waltex[i]);
if (ArtData[i] == NULL) {
glDeleteTextures(1, &waltex[i]);
waltex[i] = 0;
if (waltex[i]) {
if (ArtData[i] == NULL) {
glDeleteTextures(1, &waltex[i]);
waltex[i] = 0;
}
continue;
} else if (ArtData[i]) {
glGenTextures(1, &waltex[i]);
} else {
continue;
}
glBindTexture(GL_TEXTURE_2D, waltex[i]);
buf2 = FlipWall(ArtData[i], 128, 128);
buf = Pal256toRGB(buf2, 128 * 128, pal);
free(buf2);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
/*
///*
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
*/
//*/
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
......@@ -166,22 +223,59 @@ void InitRenderView()
free(buf);
}
for (i = 1; i < S_LASTONE; i++) {
Byte *buf;
if (sprtex[i]) {
if (SpriteArray[i] == NULL) {
glDeleteTextures(1, &sprtex[i]);
sprtex[i] = 0;
}
continue;
} else if (SpriteArray[i]) {
glGenTextures(1, &sprtex[i]);
} else {
continue;
}
glBindTexture(GL_TEXTURE_2D, sprtex[i]);
buf = DeSprite(SpriteArray[i], pal);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
///*
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//*/
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
free(buf);
}
ReleaseAResource(rGamePal);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);
/* glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); */
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-0.20, 0.20, -0.288675, 0.288675, 0.2, 182.0);
/*
glFrontFace(GL_CCW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
*/
}
void StartRenderView()
......@@ -200,11 +294,12 @@ void DrawSprite(thing_t *t)
glTranslatef(-(double)t->x / 256.0, 0, -(double)t->y / 256.0);
glRotatef(90.0+((double)gamestate.viewangle / (double)ANGLES * 360.0), 0.0, 1.0, 0.0);
glBindTexture(GL_TEXTURE_2D, sprtex[t->sprite]);
glBegin(GL_QUADS);
glTexCoord2f(1.0, 1.0); glVertex2f( 0.5, -1);
glTexCoord2f(0.0, 1.0); glVertex2f( 0.5, 1);
glTexCoord2f(1.0, 0.0); glVertex2f( 0.5, 1);
glTexCoord2f(1.0, 1.0); glVertex2f( 0.5, -1);
glTexCoord2f(0.0, 1.0); glVertex2f(-0.5, -1);
glTexCoord2f(0.0, 0.0); glVertex2f(-0.5, 1);
glTexCoord2f(1.0, 0.0); glVertex2f(-0.5, -1);
glEnd();
glPopMatrix();
......@@ -216,10 +311,7 @@ void DrawSprites(void)
static_t *stat;
actor_t *actor;
missile_t *MissilePtr;
//glRotatef(360.0 - (270.0-((double)gamestate.viewangle / (double)ANGLES * 360.0)), 0.0, 1.0, 0.0);
//glRotatef((((double)gamestate.viewangle / (double)ANGLES * 360.0)), 0.0, 1.0, 0.0);
if (numstatics) {
i = numstatics;
stat = statics;
......
......@@ -7,23 +7,19 @@ TODO:
- Require 320x200x256
- 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.
with the keypad arrow keys if only mode supported 320x200x256 (center if
640x400 or 480 is supported?)
* Finish moving all 2D code to SoftDraw.c
* Compile with -Wall -ansi -pedantic (there shouldn't be much in the way)
* OpenGL
* Finish OpenGL
* Save/Load Games
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?
* it crashes somewhere, no reason why (effects everything)...
#0 0x804fa55 in DrawXMShape (x=128, y=96, ShapePtr=0x8c8c8c8c) at Burger.c:198
and
#0 0x805296e in IO_AttackShape (shape=17) at WolfIO.c:201
(gdb) print GameShapes
$8 = (unsigned char **) 0x7070707
But what is trashing GameShapes or its memory?
* Guns don't work in OpenGL
IDEAS:
* Menu Keys
......
......@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
glXMakeCurrent(dpy, win, ctx);
if (verbose) {
if (verbose) {
printf("GL Library:\n");
printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
......@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
ClearTheScreen(BLACK);
BlastScreen();
NoEnemies = 1;
/* NoEnemies = 1; */
return WolfMain(argc, argv);
}
......
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