Commit cdea31c5 authored by Steven Fuller's avatar Steven Fuller

Fixed brain-dead file reading in res.c

parent c6be39fe
...@@ -745,13 +745,13 @@ void InitRenderView() ...@@ -745,13 +745,13 @@ void InitRenderView()
glBindTexture(GL_TEXTURE_2D, waltex[i]); glBindTexture(GL_TEXTURE_2D, waltex[i]);
buf = FlipWall(ArtData[i], 128, 128); buf = FlipWall(ArtData[i], 128, 128);
/* #ifdef USE_NEAREST
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 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_MAG_FILTER, GL_NEAREST);
*/ #else
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 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_MAG_FILTER, GL_LINEAR);
#endif
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
...@@ -786,13 +786,13 @@ void InitRenderView() ...@@ -786,13 +786,13 @@ void InitRenderView()
} }
glBindTexture(GL_TEXTURE_2D, sprtex[i]); glBindTexture(GL_TEXTURE_2D, sprtex[i]);
/* #ifdef USE_NEAREST
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 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_MAG_FILTER, GL_NEAREST);
*/ #else
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 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_MAG_FILTER, GL_LINEAR);
#endif
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
...@@ -832,13 +832,13 @@ void InitRenderView() ...@@ -832,13 +832,13 @@ void InitRenderView()
glBindTexture(GL_TEXTURE_2D, weptex[i]); glBindTexture(GL_TEXTURE_2D, weptex[i]);
/* #ifdef USE_NEAREST
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 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_MAG_FILTER, GL_NEAREST);
*/ #else
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 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_MAG_FILTER, GL_LINEAR);
#endif
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
...@@ -1321,8 +1321,8 @@ void P_DrawSeg(saveseg_t *seg) ...@@ -1321,8 +1321,8 @@ void P_DrawSeg(saveseg_t *seg)
Word segplane; Word segplane;
Word door; Word door;
door_t *door_p; door_t *door_p;
unsigned short span, tspan; unsigned short int span, tspan;
unsigned short angle1 = 0, angle2 = 0; unsigned short int angle1 = 0, angle2 = 0;
WallSeen = 0; WallSeen = 0;
...@@ -1386,9 +1386,10 @@ void P_DrawSeg(saveseg_t *seg) ...@@ -1386,9 +1386,10 @@ void P_DrawSeg(saveseg_t *seg)
/* clip to view edges*/ /* clip to view edges*/
span = (angle1 - angle2); span = (angle1 - angle2);
if (span >= 0x8000) { /* Test for negative (32 bit clean) */ if (span >= 0x8000) {
return; return;
} }
angle1 -= centershort; angle1 -= centershort;
angle2 -= centershort; angle2 -= centershort;
++angle2; /* make angle 2 non inclusive*/ ++angle2; /* make angle 2 non inclusive*/
......
...@@ -14,7 +14,7 @@ thought "Why not?" So here it is. My goal is to implement everything the ...@@ -14,7 +14,7 @@ thought "Why not?" So here it is. My goal is to implement everything the
Macintosh version had, and then somehow improve on that. Macintosh version had, and then somehow improve on that.
To use this, you need the resource fork from the First Encounter (the three To use this, you need the resource fork from the First Encounter (the three
level shareware version) or the Second Encounter (the for-sell version). level shareware version) or the Second Encounter (the retail version).
You can find the First Encounter on many web sites (Search for: Macintosh You can find the First Encounter on many web sites (Search for: Macintosh
Wolfenstein 3D download) and you can get the Second Encounter on eBay (I Wolfenstein 3D download) and you can get the Second Encounter on eBay (I
believe it is no longer sold by Interplay, but I got my unopened copy from believe it is no longer sold by Interplay, but I got my unopened copy from
......
...@@ -43,6 +43,7 @@ TODO: ...@@ -43,6 +43,7 @@ TODO:
- Would like to have a "lower level" X Toolkit, to provide menus and - Would like to have a "lower level" X Toolkit, to provide menus and
dialog boxes, and various widgets, but I rather not be "forced" into dialog boxes, and various widgets, but I rather not be "forced" into
losing the ability to call Xlib functions directly. losing the ability to call Xlib functions directly.
- Make them like PC Wolf3D.
* Different depths/visuals for software clients. * Different depths/visuals for software clients.
+ Different functions to draw with different bpps. + Different functions to draw with different bpps.
- 15 bpp uses same draw routes as 16 but different set palette - 15 bpp uses same draw routes as 16 but different set palette
...@@ -50,8 +51,6 @@ TODO: ...@@ -50,8 +51,6 @@ TODO:
- don't support them generally - don't support them generally
- MacPlay->Id Logo: have some sort of redraw. - MacPlay->Id Logo: have some sort of redraw.
- Fades in game can just call renderview each time - Fades in game can just call renderview each time
* Get it to compile/work with g++ if it is not too much trouble.
- Have to rename class..
* SDL version (software) * SDL version (software)
* Mouse * Mouse
* Psyched bar * Psyched bar
...@@ -59,7 +58,6 @@ TODO: ...@@ -59,7 +58,6 @@ TODO:
* vi_glx.c will probably be the most updated of the frontends. Be sure to * vi_glx.c will probably be the most updated of the frontends. Be sure to
update the others later. update the others later.
* Finish moving things out of stub.c * Finish moving things out of stub.c
* Name conflicts between wolf3d and Xt types
BUGS: BUGS:
* Software Drawing seems like its imprecise, stationary sprites move back and * Software Drawing seems like its imprecise, stationary sprites move back and
......
...@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include "wolfdef.h" #include "wolfdef.h"
...@@ -37,6 +38,33 @@ typedef struct ResItem_t ...@@ -37,6 +38,33 @@ typedef struct ResItem_t
ResItem *lr; ResItem *lr;
static int32_t Read32M(FILE *fp)
{
unsigned char d[4];
fread(d, 1, 4, fp);
return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3] << 0);
}
static int32_t Read24M(FILE *fp)
{
unsigned char d[3];
fread(d, 1, 3, fp);
return (d[0] << 16) | (d[1] << 8) | (d[2] << 0);
}
static int16_t Read16M(FILE *fp)
{
unsigned char d[2];
fread(d, 1, 2, fp);
return (d[0] << 8) | (d[1] << 0);
}
int InitResources(char *name) int InitResources(char *name)
{ {
FILE *fp; FILE *fp;
...@@ -51,26 +79,26 @@ int InitResources(char *name) ...@@ -51,26 +79,26 @@ int InitResources(char *name)
if (fp == NULL) if (fp == NULL)
return -1; return -1;
resfork = (fgetc(fp) << 24) | (fgetc(fp) << 16) | (fgetc(fp) << 8) | (fgetc(fp) << 0); resfork = Read32M(fp);
resmap = (fgetc(fp) << 24) | (fgetc(fp) << 16) | (fgetc(fp) << 8) | (fgetc(fp) << 0); resmap = Read32M(fp);
forklen = (fgetc(fp) << 24) | (fgetc(fp) << 16) | (fgetc(fp) << 8) | (fgetc(fp) << 0); forklen = Read32M(fp);
maplen = (fgetc(fp) << 24) | (fgetc(fp) << 16) | (fgetc(fp) << 8) | (fgetc(fp) << 0); maplen = Read32M(fp);
fseek(fp, resmap, SEEK_SET); fseek(fp, resmap, SEEK_SET);
fseek(fp, 24, SEEK_CUR); /* Skip over reserved */ fseek(fp, 24, SEEK_CUR); /* Skip over reserved */
typelist = (fgetc(fp) << 8) | (fgetc(fp) << 0); typelist = Read16M(fp);
namelist = (fgetc(fp) << 8) | (fgetc(fp) << 0); namelist = Read16M(fp);
typecount = ((fgetc(fp) << 8) | (fgetc(fp) << 0)) + 1; typecount = Read16M(fp) + 1;
for (i = 0; i < typecount; i++) { for (i = 0; i < typecount; i++) {
int type; int type;
int off, bak, bak2, data, count, x; int off, bak, bak2, data, count, x;
type = (fgetc(fp) << 24) | (fgetc(fp) << 16) | (fgetc(fp) << 8) | (fgetc(fp) << 0); type = Read32M(fp);
count = ((fgetc(fp) << 8) | fgetc(fp)) + 1; count = Read16M(fp) + 1;
off = (fgetc(fp) << 8) | fgetc(fp); off = Read16M(fp);
bak = ftell(fp); bak = ftell(fp);
...@@ -78,16 +106,18 @@ int InitResources(char *name) ...@@ -78,16 +106,18 @@ int InitResources(char *name)
for (x = 0; x < count; x++) { for (x = 0; x < count; x++) {
int id; int id;
id = (fgetc(fp) << 8) | fgetc(fp); id = Read16M(fp);
off = (fgetc(fp) << 8) | fgetc(fp); off = Read16M(fp);
fgetc(fp);
data = (fgetc(fp) << 16) | (fgetc(fp) << 8) | (fgetc(fp) << 0); fgetc(fp); /* not needed */
data = Read24M(fp);
fgetc(fp); fgetc(fp); fgetc(fp); fgetc(fp); fgetc(fp); fgetc(fp); fgetc(fp); fgetc(fp); /* not needed */
bak2 = ftell(fp); bak2 = ftell(fp);
fseek(fp, resfork + data, SEEK_SET); fseek(fp, resfork + data, SEEK_SET);
datalen = (fgetc(fp) << 24) | (fgetc(fp) << 16) | (fgetc(fp) << 8) | (fgetc(fp) << 0); datalen = Read32M(fp);
t = (ResItem *)malloc(sizeof(ResItem)); t = (ResItem *)malloc(sizeof(ResItem));
......
...@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) ...@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
if (CheckToken(ext, "GL_EXT_shared_texture_palette")) { if (CheckToken(ext, "GL_EXT_shared_texture_palette")) {
pglColorTableEXT = glXGetProcAddressARB((unsigned const char *)"glColorTableEXT"); pglColorTableEXT = glXGetProcAddressARB((unsigned const char *)"glColorTableEXT");
if (pglColorTableEXT) { if (pglColorTableEXT) {
UseSharedTexturePalette = 1; UseSharedTexturePalette = 0;
printf("GL_EXT_shared_texture_palette found...\n"); printf("GL_EXT_shared_texture_palette found...\n");
} }
} }
......
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