Commit c0fedd7d authored by Steven Fuller's avatar Steven Fuller

Wolfenstein 3D should now work correctly on MSBFirst systems (system tested

has sizeof(int) == sizeof(long) == 4.)
parent 229813c7
CC = gcc CC = gcc
#CC = gcc-3.0
#CFLAGS = -g -O2 -Wall -pedantic
#CFLAGS = -Wall -pedantic -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
CFLAGS = -g -Wall -pedantic CFLAGS = -g -Wall -pedantic
#CFLAGS = -Wall -pedantic -std=c99 #CFLAGS = -g -O2 -Wall -pedantic
#CFLAGS = -Os -Wall -peantic #CFLAGS = -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -Os -Wall -peantic -fomit-frame-pointer -ffast-math -mpentiumpro -mcpu=pentiumpro -march=pentiumpro #CFLAGS = -g -Wall -pedantic -std=gnu99
#CFLAGS = -Os -Wall -pedantic
#CFLAGS = -Os -Wall -fomit-frame-pointer -ffast-math -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_act3.o wl_agent.o wl_game.o \ wl_act1.o wl_act2.o wl_act3.o wl_agent.o wl_game.o \
......
...@@ -27,7 +27,7 @@ Just some random facts/thoughts/ideas/musings: ...@@ -27,7 +27,7 @@ Just some random facts/thoughts/ideas/musings:
NewWolf: http://wolfgl.narod.ru/ NewWolf: http://wolfgl.narod.ru/
- Acorn/Archemedes - Acorn/Archemedes
* PC source released August(?) ??, 1995: * PC source released Jul 21, 1995 [http://www.3dgamers.com/games/wolfenstein3d/]
- ftp://ftp.idsoftware.com/idstuff/source/wolfsrc.zip - ftp://ftp.idsoftware.com/idstuff/source/wolfsrc.zip
* now many ports, projects, etc * now many ports, projects, etc
- http://www.abraxis.com/brucel/wolf3d.html - http://www.abraxis.com/brucel/wolf3d.html
......
Priority Levels: I > R > M (I, R required to be complete before release) Priority Levels: I > R > M (I, R required to be complete before full release)
Program: P=PC Wolf3D, M=Mac Wolf3D, B=Both Program: P=PC Wolf3D, M=Mac Wolf3D, B=Both
P R - create a better "read direction" for menu movement P R - create a better "read direction" for menu movement
P M - convert while (Keyboard[sc_Blah]) IN_CheckAck() to IN_WaitKeyDown(sc.. P M - convert while (Keyboard[sc_Blah]) IN_CheckAck() to IN_WaitKeyDown(sc..
...@@ -21,8 +21,9 @@ B M - port to dreamcast? ...@@ -21,8 +21,9 @@ B M - port to dreamcast?
B M - add compression to savegames/config B M - add compression to savegames/config
B I - play through game (w/ sound and music) to make sure things work B I - play through game (w/ sound and music) to make sure things work
B M - use stdint.h where appropiate B M - use stdint.h where appropiate
B M - finish serializing reads/writes, endian issues B M - finish serializing reads/writes, endian issues.
P I - fix raycast bug where at certain points you can see through corners - PC version should be OK for loading -- savegames not yet tested.
P M - fix raycast bug where at certain points you can see through corners
B I - merge other TODO lists into this list B I - merge other TODO lists into this list
B M - use something like config file or getenv to point at data directories B M - use something like config file or getenv to point at data directories
P I - finish handling/mapping for all keys in sys. specific code P I - finish handling/mapping for all keys in sys. specific code
...@@ -43,10 +44,12 @@ P M - rename visable to visible ...@@ -43,10 +44,12 @@ P M - rename visable to visible
B M - change the commandline handling (use something like getopt?) B M - change the commandline handling (use something like getopt?)
P R - rewrite RLEWexpand to not use words P R - rewrite RLEWexpand to not use words
B M - openal support B M - openal support
B I - when window loses focus, it should clear the keys
B M - [X11] use the data in the visual/image for formatting colors
Complete: Complete:
P I - fix or remove fizzle fade P I - fix or remove fizzle fade
- Removed [nice, but very hacky effect] - Removed [nice, but very hacky effect]
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
* what exactly is the point of all the DigiMode checks in wl_act2.c? * what exactly is the point of all the DigiMode checks in wl_act2.c?
* add ylookup? * add ylookup?
...@@ -63,9 +66,7 @@ PlayDemoFromFile specifically ...@@ -63,9 +66,7 @@ PlayDemoFromFile specifically
* deathcam went by too fast, same with the spear of destiny ending animation * deathcam went by too fast, same with the spear of destiny ending animation
- probably due to waiting for sounds to finish - probably due to waiting for sounds to finish
* split wl_draw into two files (draw independent, draw dependent) * split wl_draw into two files (draw independent, draw dependent)
* when window loses focus, it should clear the keys
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
fix:
void ControlMovement(objtype *ob) (wl_agent.c) void ControlMovement(objtype *ob) (wl_agent.c)
void UpdateInput() / void PollControls() (wl_play.c) void UpdateInput() / void PollControls() (wl_play.c)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
......
...@@ -189,6 +189,9 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable) ...@@ -189,6 +189,9 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
= CAL_CarmackExpand = CAL_CarmackExpand
= Length is the length of the EXPANDED data = Length is the length of the EXPANDED data
= =
= Note: This function happens to implicity swap words' bytes around.
= For maps, this happens to be the desired effect.
=
====================== ======================
*/ */
...@@ -267,13 +270,14 @@ void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag) ...@@ -267,13 +270,14 @@ void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
/* expand it */ /* expand it */
do { do {
value = *source++; value = *source++;
if (value != rlewtag) if (value != rlewtag)
/* uncompressed */ /* uncompressed */
*dest++ = value; *dest++ = value;
else { else {
/* compressed string */ /* compressed string */
count = SwapInt16L(*source); source++; count = *source++;
value = *source++; value = *source++;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
*dest++ = value; *dest++ = value;
...@@ -383,8 +387,7 @@ static void CAL_SetupMapFile() ...@@ -383,8 +387,7 @@ static void CAL_SetupMapFile()
if (handle == -1) if (handle == -1)
CA_CannotOpen(fname); CA_CannotOpen(fname);
/* RLEWtag = ReadInt16(handle); */ RLEWtag = ReadInt16(handle);
ReadBytes(handle, (byte *)&RLEWtag, 2); /* RLEWtag = word */
/* open the data file */ /* open the data file */
strcpy(fname, gmapsname); strcpy(fname, gmapsname);
...@@ -680,7 +683,6 @@ void CA_CacheMap(int mapnum) ...@@ -680,7 +683,6 @@ void CA_CacheMap(int mapnum)
byte *source; byte *source;
memptr buffer2seg; memptr buffer2seg;
long expanded; long expanded;
int i;
mapon = mapnum; mapon = mapnum;
...@@ -697,19 +699,22 @@ void CA_CacheMap(int mapnum) ...@@ -697,19 +699,22 @@ void CA_CacheMap(int mapnum)
ReadBytes(maphandle, (byte *)source, compressed); ReadBytes(maphandle, (byte *)source, compressed);
expanded = source[0] | (source[1] << 8); expanded = source[0] | (source[1] << 8);
MM_GetPtr(&buffer2seg, expanded); MM_GetPtr(&buffer2seg, expanded);
/* NOTE: CarmackExpand implicitly fixes endianness, a RLEW'd only map
would (likely) need to be swapped in CA_RLEWexpand
Wolfenstein 3D/Spear of Destiny maps are always Carmack'd so this
case is OK. CA_RLEWexpand would need to be adjusted for Blake Stone
and the like.
*/
CAL_CarmackExpand(source+2, (word *)buffer2seg, expanded); CAL_CarmackExpand(source+2, (word *)buffer2seg, expanded);
MM_FreePtr((void *)&source); MM_FreePtr((void *)&source);
expanded = 64*64*2; expanded = 64*64*2;
CA_RLEWexpand(((word *)buffer2seg)+1, mapsegs[plane], expanded, RLEWtag); CA_RLEWexpand(((word *)buffer2seg)+1, mapsegs[plane], expanded, RLEWtag);
MM_FreePtr(&buffer2seg); MM_FreePtr(&buffer2seg);
/* swap for big-endian */
for (i = 0; i < 64*64; i++)
mapsegs[plane][i] = SwapInt16L(mapsegs[plane][i]);
} }
} }
...@@ -791,12 +796,14 @@ static void PML_OpenPageFile() ...@@ -791,12 +796,14 @@ static void PML_OpenPageFile()
memset(PMPages, 0, sizeof(PageListStruct) * ChunksInFile); memset(PMPages, 0, sizeof(PageListStruct) * ChunksInFile);
/* Read in the chunk offsets */ /* Read in the chunk offsets */
for (i = 0, page = PMPages; i < ChunksInFile; i++, page++) for (i = 0, page = PMPages; i < ChunksInFile; i++, page++) {
page->offset = ReadInt32(PageFile); page->offset = ReadInt32(PageFile);
}
/* Read in the chunk lengths */ /* Read in the chunk lengths */
for (i = 0, page = PMPages; i < ChunksInFile; i++, page++) for (i = 0, page = PMPages; i < ChunksInFile; i++, page++) {
page->length = ReadInt16(PageFile); page->length = ReadInt16(PageFile);
}
} }
static void PML_ClosePageFile() static void PML_ClosePageFile()
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <stdint.h> #include <sys/types.h>
#include <inttypes.h>
#include <glob.h> #include <glob.h>
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
......
...@@ -14,6 +14,8 @@ int xfrac, yfrac; ...@@ -14,6 +14,8 @@ int xfrac, yfrac;
/* ======================================================================== */ /* ======================================================================== */
#define SKIPFADE 0
void VL_FillPalette(int red, int green, int blue) void VL_FillPalette(int red, int green, int blue)
{ {
byte pal[768]; byte pal[768];
...@@ -39,6 +41,9 @@ void VL_FillPalette(int red, int green, int blue) ...@@ -39,6 +41,9 @@ void VL_FillPalette(int red, int green, int blue)
void VL_FadeOut(int start, int end, int red, int green, int blue, int steps) void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
{ {
#ifdef SKIPFADE
VL_FillPalette(red, green, blue);
#else
int i,j,orig,delta; int i,j,orig,delta;
byte *origptr, *newptr; byte *origptr, *newptr;
...@@ -68,6 +73,7 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps) ...@@ -68,6 +73,7 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
/* final color */ /* final color */
VL_FillPalette(red, green, blue); VL_FillPalette(red, green, blue);
#endif
screenfaded = true; screenfaded = true;
} }
...@@ -82,6 +88,9 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps) ...@@ -82,6 +88,9 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
void VL_FadeIn(int start, int end, const byte *palette, int steps) void VL_FadeIn(int start, int end, const byte *palette, int steps)
{ {
#ifdef SKIPFADE
VL_SetPalette(palette);
#else
int i, j, delta; int i, j, delta;
VL_GetPalette(&palette1[0][0]); VL_GetPalette(&palette1[0][0]);
...@@ -104,6 +113,7 @@ void VL_FadeIn(int start, int end, const byte *palette, int steps) ...@@ -104,6 +113,7 @@ void VL_FadeIn(int start, int end, const byte *palette, int steps)
/* final color */ /* final color */
VL_SetPalette(palette); VL_SetPalette(palette);
#endif
screenfaded = false; screenfaded = false;
} }
......
...@@ -46,4 +46,18 @@ extern int16_t ReadInt16(int fp); ...@@ -46,4 +46,18 @@ extern int16_t ReadInt16(int fp);
extern int32_t ReadInt32(int fp); extern int32_t ReadInt32(int fp);
extern int ReadBytes(int fp, byte *d, int len); extern int ReadBytes(int fp, byte *d, int len);
static __inline__ uint16_t SwapInt16(uint16_t i)
{
return ((uint16_t)i >> 8) | ((uint16_t)i << 8);
}
static __inline__ uint32_t SwapInt32(uint32_t i)
{
return ((uint32_t)(i & 0xFF000000) >> 24) |
((uint32_t)(i & 0x00FF0000) >> 8) |
((uint32_t)(i & 0x0000FF00) << 8) |
((uint32_t)(i & 0x000000FF) << 24);
}
#endif #endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
/* SDM = 2 */ /* SDM = 2 */
/* SOD = 3 */ /* SOD = 3 */
#ifndef WMODE #ifndef WMODE
#define WMODE 1 #define WMODE 0
#endif #endif
/* --- End of User-Modifiable Variables --- */ /* --- End of User-Modifiable Variables --- */
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/extensions/XShm.h> #include <X11/extensions/XShm.h>
byte *gfxbuf = NULL; byte *gfxbuf = NULL;
byte *disbuf = NULL; byte *disbuf = NULL;
...@@ -35,6 +36,9 @@ static byte cpal[768]; ...@@ -35,6 +36,9 @@ static byte cpal[768];
static word spal[768]; static word spal[768];
static dword ipal[768]; static dword ipal[768];
static int ByteOrder; /* 0 = LSBFirst, 1 = MSBFirst */
static int NeedSwap;
int MyDepth; int MyDepth;
void GetVisual() void GetVisual()
...@@ -277,10 +281,17 @@ void VL_Startup() ...@@ -277,10 +281,17 @@ void VL_Startup()
XInitImage(img); XInitImage(img);
XDestroyImage(imgtmp); XDestroyImage(imgtmp);
} }
MyDepth = GetBPP();
#if BYTE_ORDER == BIG_ENDIAN
ByteOrder = 1;
#else
ByteOrder = 0;
#endif
NeedSwap = (ByteOrder != img->byte_order);
if (img)
MyDepth = GetBPP();
XMapRaised(dpy, win); XMapRaised(dpy, win);
} }
...@@ -327,12 +338,13 @@ void VW_UpdateScreen() ...@@ -327,12 +338,13 @@ void VW_UpdateScreen()
case 15: case 15:
case 16: case 16:
ptrs = (word *)disbuf; ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) { for (i = 0; i < 64000; i++) {
*ptrs = spal[gfxbuf[i]]; *ptrs = spal[gfxbuf[i]];
ptrs++; ptrs++;
} }
break; break;
case 24: case 24: /* Endian Safe? Untested. */
ptrb = disbuf; ptrb = disbuf;
for (i = 0; i < 64000; i++) { for (i = 0; i < 64000; i++) {
*ptrb = cpal[gfxbuf[i]*3+2] << 2; ptrb++; *ptrb = cpal[gfxbuf[i]*3+2] << 2; ptrb++;
...@@ -342,10 +354,15 @@ void VW_UpdateScreen() ...@@ -342,10 +354,15 @@ void VW_UpdateScreen()
break; break;
case 32: case 32:
ptri = (dword *)disbuf; ptri = (dword *)disbuf;
for (i = 0; i < 64000; i++) { for (i = 0; i < 64000; i++) {
*ptri = ipal[gfxbuf[i]]; *ptri = ipal[gfxbuf[i]];
ptri++; ptri++;
} }
break;
default:
break;
/* ... */
} }
} }
...@@ -418,17 +435,24 @@ void VL_SetPalette(const byte *palette) ...@@ -418,17 +435,24 @@ void VL_SetPalette(const byte *palette)
} else { } else {
memcpy(cpal, palette, 768); memcpy(cpal, palette, 768);
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
/* TODO: this should really use the visual for creating the pixel */
switch(MyDepth) { switch(MyDepth) {
case 8: case 8:
break; break;
case 15: case 15: /* Endian Safe? Untested. */
spal[i] = ((palette[i*3+0] >> 1) << 10) | ((palette[i*3+1] >> 1) << 5) | ((palette[i*3+2] >> 1) << 0); spal[i] = ((palette[i*3+0] >> 1) << 10) | ((palette[i*3+1] >> 1) << 5) | ((palette[i*3+2] >> 1) << 0);
if (NeedSwap)
spal[i] = SwapInt16(spal[i]);
break; break;
case 16: case 16:
spal[i] = ((palette[i*3+0] >> 1) << 11) | ((palette[i*3+1] >> 0) << 5) | ((palette[i*3+2] >> 1) << 0); spal[i] = ((palette[i*3+0] >> 1) << 11) | ((palette[i*3+1] >> 0) << 5) | ((palette[i*3+2] >> 1) << 0);
if (NeedSwap)
spal[i] = SwapInt16(spal[i]);
break; break;
case 32: case 32:
ipal[i] = (palette[i*3+0] << 18) | (palette[i*3+1] << 10) | (palette[i*3+2] << 2); ipal[i] = (palette[i*3+0] << 18) | (palette[i*3+1] << 10) | (palette[i*3+2] << 2);
if (NeedSwap)
ipal[i] = SwapInt32(ipal[i]);
break; break;
} }
} }
......
...@@ -1249,3 +1249,100 @@ passhoriz: ...@@ -1249,3 +1249,100 @@ passhoriz:
void FizzleFade(boolean abortable, int frames, int color) void FizzleFade(boolean abortable, int frames, int color)
{ {
} }
#if 0
static int xarr[1280];
static int yarr[1280];
static int myrand()
{
return rand();
}
static void fillarray(int *arr, int len)
{
int i;
for (i = 0; i < len; i++)
arr[i] = i;
}
static void randarray(int *arr, int len)
{
int i, j, k;
for (i = 0; i < len; i++) {
j = myrand() % len;
k = arr[i];
arr[i] = arr[j];
arr[j] = k;
}
}
void FizzleFade(boolean abortable, int frames, int color)
{
boolean retr;
int pixperframe;
int x, y, xc, yc;
int count, p, frame;
count = viewwidth * viewheight;
pixperframe = count / frames;
srand(time(NULL));
fillarray(xarr, viewwidth);
randarray(xarr, viewwidth);
fillarray(yarr, viewheight - 1);
randarray(yarr, viewheight - 1);
IN_StartAck();
frame = 0;
set_TimeCount(0);
xc = 0;
yc = 0;
x = 0;
y = 0;
retr = false;
do {
if (abortable && IN_CheckAck())
retr = true;
else
for (p = 0; p < pixperframe; p++) {
gfxbuf[(xarr[x]+xoffset)+(yarr[y]+yoffset)*vwidth] = color;
count--;
x++;
if (x >= viewwidth)
x = 0;
y++;
if (y >= (viewheight-1))
y = 0;
yc++;
if (yc >= (viewheight-1)) {
yc = 0;
y++;
if (y >= (viewheight-1))
y = 0;
}
}
VW_UpdateScreen();
frame++;
while (get_TimeCount() < frame);
} while (!retr && (count > 0));
VW_UpdateScreen();
}
#endif
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