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-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 = -Wall -pedantic -std=c99
#CFLAGS = -Os -Wall -peantic
#CFLAGS = -Os -Wall -peantic -fomit-frame-pointer -ffast-math -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -g -O2 -Wall -pedantic
#CFLAGS = -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -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 \
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:
NewWolf: http://wolfgl.narod.ru/
- 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
* now many ports, projects, etc
- 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
P R - create a better "read direction" for menu movement
P M - convert while (Keyboard[sc_Blah]) IN_CheckAck() to IN_WaitKeyDown(sc..
......@@ -21,8 +21,9 @@ B M - port to dreamcast?
B M - add compression to savegames/config
B I - play through game (w/ sound and music) to make sure things work
B M - use stdint.h where appropiate
B M - finish serializing reads/writes, endian issues
P I - fix raycast bug where at certain points you can see through corners
B M - finish serializing reads/writes, endian issues.
- 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 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
......@@ -43,6 +44,8 @@ P M - rename visable to visible
B M - change the commandline handling (use something like getopt?)
P R - rewrite RLEWexpand to not use words
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:
P I - fix or remove fizzle fade
......@@ -63,9 +66,7 @@ PlayDemoFromFile specifically
* deathcam went by too fast, same with the spear of destiny ending animation
- probably due to waiting for sounds to finish
* 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 UpdateInput() / void PollControls() (wl_play.c)
------------------------------------------------------------------------------
......
......@@ -189,6 +189,9 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *htable)
= CAL_CarmackExpand
= 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.
=
======================
*/
......@@ -273,7 +276,8 @@ void CA_RLEWexpand(word *source, word *dest, long length, word rlewtag)
*dest++ = value;
else {
/* compressed string */
count = SwapInt16L(*source); source++;
count = *source++;
value = *source++;
for (i = 0; i < count; i++)
*dest++ = value;
......@@ -383,8 +387,7 @@ static void CAL_SetupMapFile()
if (handle == -1)
CA_CannotOpen(fname);
/* RLEWtag = ReadInt16(handle); */
ReadBytes(handle, (byte *)&RLEWtag, 2); /* RLEWtag = word */
RLEWtag = ReadInt16(handle);
/* open the data file */
strcpy(fname, gmapsname);
......@@ -680,7 +683,6 @@ void CA_CacheMap(int mapnum)
byte *source;
memptr buffer2seg;
long expanded;
int i;
mapon = mapnum;
......@@ -700,16 +702,19 @@ void CA_CacheMap(int mapnum)
expanded = source[0] | (source[1] << 8);
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);
MM_FreePtr((void *)&source);
expanded = 64*64*2;
CA_RLEWexpand(((word *)buffer2seg)+1, mapsegs[plane], expanded, RLEWtag);
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()
memset(PMPages, 0, sizeof(PageListStruct) * ChunksInFile);
/* 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);
}
/* 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);
}
}
static void PML_ClosePageFile()
......
......@@ -5,7 +5,8 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdint.h>
#include <sys/types.h>
#include <inttypes.h>
#include <glob.h>
#include <ctype.h>
#include <math.h>
......
......@@ -14,6 +14,8 @@ int xfrac, yfrac;
/* ======================================================================== */
#define SKIPFADE 0
void VL_FillPalette(int red, int green, int blue)
{
byte pal[768];
......@@ -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)
{
#ifdef SKIPFADE
VL_FillPalette(red, green, blue);
#else
int i,j,orig,delta;
byte *origptr, *newptr;
......@@ -68,6 +73,7 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
/* final color */
VL_FillPalette(red, green, blue);
#endif
screenfaded = true;
}
......@@ -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)
{
#ifdef SKIPFADE
VL_SetPalette(palette);
#else
int i, j, delta;
VL_GetPalette(&palette1[0][0]);
......@@ -104,6 +113,7 @@ void VL_FadeIn(int start, int end, const byte *palette, int steps)
/* final color */
VL_SetPalette(palette);
#endif
screenfaded = false;
}
......
......@@ -46,4 +46,18 @@ extern int16_t ReadInt16(int fp);
extern int32_t ReadInt32(int fp);
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
......@@ -7,7 +7,7 @@
/* SDM = 2 */
/* SOD = 3 */
#ifndef WMODE
#define WMODE 1
#define WMODE 0
#endif
/* --- End of User-Modifiable Variables --- */
......
......@@ -13,6 +13,7 @@
#include <X11/Xatom.h>
#include <X11/extensions/XShm.h>
byte *gfxbuf = NULL;
byte *disbuf = NULL;
......@@ -35,6 +36,9 @@ static byte cpal[768];
static word spal[768];
static dword ipal[768];
static int ByteOrder; /* 0 = LSBFirst, 1 = MSBFirst */
static int NeedSwap;
int MyDepth;
void GetVisual()
......@@ -278,9 +282,16 @@ void VL_Startup()
XDestroyImage(imgtmp);
}
if (img)
MyDepth = GetBPP();
#if BYTE_ORDER == BIG_ENDIAN
ByteOrder = 1;
#else
ByteOrder = 0;
#endif
NeedSwap = (ByteOrder != img->byte_order);
XMapRaised(dpy, win);
}
......@@ -327,12 +338,13 @@ void VW_UpdateScreen()
case 15:
case 16:
ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) {
*ptrs = spal[gfxbuf[i]];
ptrs++;
}
break;
case 24:
case 24: /* Endian Safe? Untested. */
ptrb = disbuf;
for (i = 0; i < 64000; i++) {
*ptrb = cpal[gfxbuf[i]*3+2] << 2; ptrb++;
......@@ -342,10 +354,15 @@ void VW_UpdateScreen()
break;
case 32:
ptri = (dword *)disbuf;
for (i = 0; i < 64000; i++) {
*ptri = ipal[gfxbuf[i]];
ptri++;
}
break;
default:
break;
/* ... */
}
}
......@@ -418,17 +435,24 @@ void VL_SetPalette(const byte *palette)
} else {
memcpy(cpal, palette, 768);
for (i = 0; i < 256; i++) {
/* TODO: this should really use the visual for creating the pixel */
switch(MyDepth) {
case 8:
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);
if (NeedSwap)
spal[i] = SwapInt16(spal[i]);
break;
case 16:
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;
case 32:
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;
}
}
......
......@@ -1249,3 +1249,100 @@ passhoriz:
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