Make the code compile for windows (msvc and tcc), added shareware WAD

This commit is contained in:
mattiasgustavsson 2024-03-07 09:45:10 +01:00
parent a77dfb96cb
commit 9a90e215b1
20 changed files with 269 additions and 2174 deletions

BIN
DOOM1.WAD Normal file

Binary file not shown.

99
doom.c Normal file
View File

@ -0,0 +1,99 @@
#pragma warning( disable: 4113 )
#pragma warning( disable: 4311 )
#pragma warning( disable: 4047 )
#pragma warning( disable: 4024 )
#pragma warning( disable: 4312 )
#pragma warning( disable: 4020 )
#pragma warning( disable: 4700 )
#pragma warning( disable: 4133 )
#pragma warning( disable: 4142 )
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define CONCAT_IMPL( x, y ) x##y
#define CONCAT( x, y ) CONCAT_IMPL( x, y )
#define rcsid CONCAT( rcsid, __COUNTER__ )
#define open doom_open
#define close doom_close
#include "libs_win32/unistd.h"
#include "linuxdoom-1.10/am_map.c"
#include "linuxdoom-1.10/doomdef.c"
#include "linuxdoom-1.10/doomstat.c"
#include "linuxdoom-1.10/dstrings.c"
#include "linuxdoom-1.10/d_items.c"
#include "linuxdoom-1.10/d_main.c"
#include "linuxdoom-1.10/d_net.c"
#include "linuxdoom-1.10/f_finale.c"
#include "linuxdoom-1.10/f_wipe.c"
#include "linuxdoom-1.10/g_game.c"
#include "linuxdoom-1.10/hu_lib.c"
#include "linuxdoom-1.10/hu_stuff.c"
#include "linuxdoom-1.10/info.c"
#include "linuxdoom-1.10/i_main.c"
#include "linuxdoom-1.10/i_sound.c"
#include "linuxdoom-1.10/i_system.c"
#include "linuxdoom-1.10/i_video.c"
#include "linuxdoom-1.10/m_argv.c"
#include "linuxdoom-1.10/m_bbox.c"
#include "linuxdoom-1.10/m_cheat.c"
#include "linuxdoom-1.10/m_fixed.c"
#include "linuxdoom-1.10/m_random.c"
#include "linuxdoom-1.10/m_swap.c"
#include "linuxdoom-1.10/p_ceilng.c"
#include "linuxdoom-1.10/p_doors.c"
#include "linuxdoom-1.10/p_enemy.c"
#include "linuxdoom-1.10/p_floor.c"
#include "linuxdoom-1.10/p_inter.c"
#include "linuxdoom-1.10/p_lights.c"
#include "linuxdoom-1.10/p_map.c"
#include "linuxdoom-1.10/p_maputl.c"
#include "linuxdoom-1.10/p_mobj.c"
#include "linuxdoom-1.10/p_plats.c"
#include "linuxdoom-1.10/p_pspr.c"
#include "linuxdoom-1.10/p_saveg.c"
#include "linuxdoom-1.10/p_setup.c"
#include "linuxdoom-1.10/p_sight.c"
#include "linuxdoom-1.10/p_spec.c"
#include "linuxdoom-1.10/p_switch.c"
#include "linuxdoom-1.10/p_telept.c"
#include "linuxdoom-1.10/p_tick.c"
#include "linuxdoom-1.10/p_user.c"
#include "linuxdoom-1.10/r_bsp.c"
#include "linuxdoom-1.10/r_data.c"
#include "linuxdoom-1.10/r_draw.c"
#include "linuxdoom-1.10/r_main.c"
#include "linuxdoom-1.10/r_plane.c"
#include "linuxdoom-1.10/r_segs.c"
#include "linuxdoom-1.10/r_sky.c"
#include "linuxdoom-1.10/r_things.c"
#include "linuxdoom-1.10/sounds.c"
#undef BG
#include "linuxdoom-1.10/st_lib.c"
#include "linuxdoom-1.10/st_stuff.c"
#define channels xchannels
#include "linuxdoom-1.10/s_sound.c"
#undef channels
#include "linuxdoom-1.10/tables.c"
#include "linuxdoom-1.10/v_video.c"
#define anim_t wi_anim_t
#define anims wi_anims
#define time wi_time
#include "linuxdoom-1.10/wi_stuff.c"
#undef anims
#undef anim_t
#undef time
#include "linuxdoom-1.10/z_zone.c"
#undef open
#undef close
#include <io.h>
#include "linuxdoom-1.10/m_menu.c"
#include "linuxdoom-1.10/m_misc.c"
#define strupr xstrupr
#include "linuxdoom-1.10/w_wad.c"
#undef strupr
#include "linuxdoom-1.10/i_net.c"

58
libs_win32/unistd.h Normal file
View File

@ -0,0 +1,58 @@
#ifndef _UNISTD_H
#define _UNISTD_H 1
/* This is intended as a drop-in replacement for unistd.h on Windows.
* Please add functionality as neeeded.
* https://stackoverflow.com/a/826027/1202830
*/
#include <stdlib.h>
//#include <process.h> /* for getpid() and the exec..() family */
//#include <direct.h> /* for _getcwd() and _chdir() */
#define srandom srand
#define random rand
/* Values for the second argument to access.
These may be OR'd together. */
#define R_OK 4 /* Test for read permission. */
#define W_OK 2 /* Test for write permission. */
//#define X_OK 1 /* execute permission - unsupported in windows*/
#define F_OK 0 /* Test for existence. */
#define access _access
#define dup2 _dup2
#define execve _execve
#define ftruncate _chsize
#define unlink _unlink
#define fileno _fileno
#define getcwd _getcwd
#define chdir _chdir
#define isatty _isatty
#define lseek _lseek
/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */
int __cdecl _access( char const* _FileName, int _AccessMode );
int __cdecl mkdir( char const* _Path );
long __cdecl filelength( int _FileHandle );
#ifdef _WIN64
#define ssize_t __int64
#else
#define ssize_t long
#endif
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
/* should be in some equivalent to <sys/types.h> */
//typedef __int8 int8_t;
//typedef __int16 int16_t;
//typedef __int32 int32_t;
//typedef __int64 int64_t;
//typedef unsigned __int8 uint8_t;
//typedef unsigned __int16 uint16_t;
//typedef unsigned __int32 uint32_t;
//typedef unsigned __int64 uint64_t;
#endif /* unistd.h */

View File

@ -563,14 +563,14 @@ void D_AddFile (char *file)
void IdentifyVersion (void)
{
char* doom1wad;
char* doomwad;
char* doomuwad;
char* doom2wad;
char* doom1wad = "doom1.wad";
char* doomwad = "doom.wad";
char* doomuwad = "doomu.wad";
char* doom2wad = "doom2.wad";
char* doom2fwad;
char* plutoniawad;
char* tntwad;
char* doom2fwad = "";
char* plutoniawad = "";
char* tntwad = "";
#ifdef NORMALUNIX
char *home;
@ -877,7 +877,7 @@ void D_DoomMain (void)
if (M_CheckParm("-cdrom"))
{
printf(D_CDROM);
mkdir("c:\\doomdata",0);
mkdir("c:\\doomdata");
strcpy (basedefault,"c:/doomdata/default.cfg");
}

View File

@ -30,7 +30,7 @@
// Global parameters/defines.
//
// DOOM version
enum { VERSION = 110 };
enum { VERSION = 109 };
// Game mode handling - identify IWAD version

View File

@ -23,265 +23,19 @@
static const char
rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include "i_system.h"
#include "d_event.h"
#include "d_net.h"
#include "m_argv.h"
#include "doomstat.h"
#ifdef __GNUG__
#pragma implementation "i_net.h"
#endif
#include "i_net.h"
// For some odd reason...
#define ntohl(x) \
((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
(((unsigned long int)(x) & 0x0000ff00U) << 8) | \
(((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
(((unsigned long int)(x) & 0xff000000U) >> 24)))
#define ntohs(x) \
((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
(((unsigned short int)(x) & 0xff00) >> 8))) \
#define htonl(x) ntohl(x)
#define htons(x) ntohs(x)
void NetSend (void);
boolean NetListen (void);
//
// NETWORKING
//
int DOOMPORT = (IPPORT_USERRESERVED +0x1d );
int sendsocket;
int insocket;
struct sockaddr_in sendaddress[MAXNETNODES];
void (*netget) (void);
void (*netsend) (void);
//
// UDPsocket
//
int UDPsocket (void)
{
int s;
// allocate a socket
s = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s<0)
I_Error ("can't create socket: %s",strerror(errno));
return s;
}
//
// BindToLocalPort
//
void
BindToLocalPort
( int s,
int port )
{
int v;
struct sockaddr_in address;
memset (&address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = port;
v = bind (s, (void *)&address, sizeof(address));
if (v == -1)
I_Error ("BindToPort: bind: %s", strerror(errno));
}
//
// PacketSend
//
void PacketSend (void)
{
int c;
doomdata_t sw;
// byte swap
sw.checksum = htonl(netbuffer->checksum);
sw.player = netbuffer->player;
sw.retransmitfrom = netbuffer->retransmitfrom;
sw.starttic = netbuffer->starttic;
sw.numtics = netbuffer->numtics;
for (c=0 ; c< netbuffer->numtics ; c++)
{
sw.cmds[c].forwardmove = netbuffer->cmds[c].forwardmove;
sw.cmds[c].sidemove = netbuffer->cmds[c].sidemove;
sw.cmds[c].angleturn = htons(netbuffer->cmds[c].angleturn);
sw.cmds[c].consistancy = htons(netbuffer->cmds[c].consistancy);
sw.cmds[c].chatchar = netbuffer->cmds[c].chatchar;
sw.cmds[c].buttons = netbuffer->cmds[c].buttons;
}
//printf ("sending %i\n",gametic);
c = sendto (sendsocket , &sw, doomcom->datalength
,0,(void *)&sendaddress[doomcom->remotenode]
,sizeof(sendaddress[doomcom->remotenode]));
// if (c == -1)
// I_Error ("SendPacket error: %s",strerror(errno));
}
//
// PacketGet
//
void PacketGet (void)
{
int i;
int c;
struct sockaddr_in fromaddress;
int fromlen;
doomdata_t sw;
fromlen = sizeof(fromaddress);
c = recvfrom (insocket, &sw, sizeof(sw), 0
, (struct sockaddr *)&fromaddress, &fromlen );
if (c == -1 )
{
if (errno != EWOULDBLOCK)
I_Error ("GetPacket: %s",strerror(errno));
doomcom->remotenode = -1; // no packet
return;
}
{
static int first=1;
if (first)
printf("len=%d:p=[0x%x 0x%x] \n", c, *(int*)&sw, *((int*)&sw+1));
first = 0;
}
// find remote node number
for (i=0 ; i<doomcom->numnodes ; i++)
if ( fromaddress.sin_addr.s_addr == sendaddress[i].sin_addr.s_addr )
break;
if (i == doomcom->numnodes)
{
// packet is not from one of the players (new game broadcast)
doomcom->remotenode = -1; // no packet
return;
}
doomcom->remotenode = i; // good packet from a game player
doomcom->datalength = c;
// byte swap
netbuffer->checksum = ntohl(sw.checksum);
netbuffer->player = sw.player;
netbuffer->retransmitfrom = sw.retransmitfrom;
netbuffer->starttic = sw.starttic;
netbuffer->numtics = sw.numtics;
for (c=0 ; c< netbuffer->numtics ; c++)
{
netbuffer->cmds[c].forwardmove = sw.cmds[c].forwardmove;
netbuffer->cmds[c].sidemove = sw.cmds[c].sidemove;
netbuffer->cmds[c].angleturn = ntohs(sw.cmds[c].angleturn);
netbuffer->cmds[c].consistancy = ntohs(sw.cmds[c].consistancy);
netbuffer->cmds[c].chatchar = sw.cmds[c].chatchar;
netbuffer->cmds[c].buttons = sw.cmds[c].buttons;
}
}
int GetLocalAddress (void)
{
char hostname[1024];
struct hostent* hostentry; // host information entry
int v;
// get local address
v = gethostname (hostname, sizeof(hostname));
if (v == -1)
I_Error ("GetLocalAddress : gethostname: errno %d",errno);
hostentry = gethostbyname (hostname);
if (!hostentry)
I_Error ("GetLocalAddress : gethostbyname: couldn't get local host");
return *(int *)hostentry->h_addr_list[0];
}
//
// I_InitNetwork
//
void I_InitNetwork (void)
{
boolean trueval = true;
int i;
int p;
struct hostent* hostentry; // host information entry
doomcom = malloc (sizeof (*doomcom) );
memset (doomcom, 0, sizeof(*doomcom) );
// set up for network
i = M_CheckParm ("-dup");
if (i && i< myargc-1)
{
doomcom->ticdup = myargv[i+1][0]-'0';
if (doomcom->ticdup < 1)
doomcom-> ticdup = 1;
if (doomcom->ticdup > 9)
doomcom->ticdup = 9;
}
else
doomcom-> ticdup = 1;
if (M_CheckParm ("-extratic"))
doomcom-> extratics = 1;
else
doomcom-> extratics = 0;
p = M_CheckParm ("-port");
if (p && p<myargc-1)
{
DOOMPORT = atoi (myargv[p+1]);
printf ("using alternate port %i\n",DOOMPORT);
}
// parse network game options,
// -net <consoleplayer> <host> <host> ...
i = M_CheckParm ("-net");
if (!i)
{
// single player game
netgame = false;
doomcom->id = DOOMCOM_ID;
doomcom->numplayers = doomcom->numnodes = 1;
@ -290,59 +44,8 @@ void I_InitNetwork (void)
return;
}
netsend = PacketSend;
netget = PacketGet;
netgame = true;
// parse player number and host list
doomcom->consoleplayer = myargv[i+1][0]-'1';
doomcom->numnodes = 1; // this node for sure
i++;
while (++i < myargc && myargv[i][0] != '-')
{
sendaddress[doomcom->numnodes].sin_family = AF_INET;
sendaddress[doomcom->numnodes].sin_port = htons(DOOMPORT);
if (myargv[i][0] == '.')
{
sendaddress[doomcom->numnodes].sin_addr.s_addr
= inet_addr (myargv[i]+1);
}
else
{
hostentry = gethostbyname (myargv[i]);
if (!hostentry)
I_Error ("gethostbyname: couldn't find %s", myargv[i]);
sendaddress[doomcom->numnodes].sin_addr.s_addr
= *(int *)hostentry->h_addr_list[0];
}
doomcom->numnodes++;
}
doomcom->id = DOOMCOM_ID;
doomcom->numplayers = doomcom->numnodes;
// build message to receive
insocket = UDPsocket ();
BindToLocalPort (insocket,htons(DOOMPORT));
ioctl (insocket, FIONBIO, &trueval);
sendsocket = UDPsocket ();
}
void I_NetCmd (void)
{
if (doomcom->command == CMD_SEND)
{
netsend ();
}
else if (doomcom->command == CMD_GET)
{
netget ();
}
else
I_Error ("Bad net cmd: %i\n",doomcom->command);
}

View File

@ -24,365 +24,7 @@
static const char
rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include <sys/time.h>
#include <sys/types.h>
#ifndef LINUX
#include <sys/filio.h>
#endif
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
// Linux voxware output.
#include <linux/soundcard.h>
// Timer stuff. Experimental.
#include <time.h>
#include <signal.h>
#include "z_zone.h"
#include "i_system.h"
#include "i_sound.h"
#include "m_argv.h"
#include "m_misc.h"
#include "w_wad.h"
#include "doomdef.h"
// UNIX hack, to be removed.
#ifdef SNDSERV
// Separate sound server process.
FILE* sndserver=0;
char* sndserver_filename = "./sndserver ";
#elif SNDINTR
// Update all 30 millisecs, approx. 30fps synchronized.
// Linux resolution is allegedly 10 millisecs,
// scale is microseconds.
#define SOUND_INTERVAL 500
// Get the interrupt. Set duration in millisecs.
int I_SoundSetTimer( int duration_of_tick );
void I_SoundDelTimer( void );
#else
// None?
#endif
// A quick hack to establish a protocol between
// synchronous mix buffer updates and asynchronous
// audio writes. Probably redundant with gametic.
static int flag = 0;
// The number of internal mixing channels,
// the samples calculated for each mixing step,
// the size of the 16bit, 2 hardware channel (stereo)
// mixing buffer, and the samplerate of the raw data.
// Needed for calling the actual sound output.
#define SAMPLECOUNT 512
#define NUM_CHANNELS 8
// It is 2 for 16bit, and 2 for two channels.
#define BUFMUL 4
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
#define SAMPLERATE 11025 // Hz
#define SAMPLESIZE 2 // 16bit
// The actual lengths of all sound effects.
int lengths[NUMSFX];
// The actual output device.
int audio_fd;
// The global mixing buffer.
// Basically, samples from all active internal channels
// are modifed and added, and stored in the buffer
// that is submitted to the audio device.
signed short mixbuffer[MIXBUFFERSIZE];
// The channel step amount...
unsigned int channelstep[NUM_CHANNELS];
// ... and a 0.16 bit remainder of last step.
unsigned int channelstepremainder[NUM_CHANNELS];
// The channel data pointers, start and end.
unsigned char* channels[NUM_CHANNELS];
unsigned char* channelsend[NUM_CHANNELS];
// Time/gametic that the channel started playing,
// used to determine oldest, which automatically
// has lowest priority.
// In case number of active sounds exceeds
// available channels.
int channelstart[NUM_CHANNELS];
// The sound in channel handles,
// determined on registration,
// might be used to unregister/stop/modify,
// currently unused.
int channelhandles[NUM_CHANNELS];
// SFX id of the playing sound effect.
// Used to catch duplicates (like chainsaw).
int channelids[NUM_CHANNELS];
// Pitch to stepping lookup, unused.
int steptable[256];
// Volume lookups.
int vol_lookup[128*256];
// Hardware left and right channel volume lookup.
int* channelleftvol_lookup[NUM_CHANNELS];
int* channelrightvol_lookup[NUM_CHANNELS];
//
// Safe ioctl, convenience.
//
void
myioctl
( int fd,
int command,
int* arg )
{
int rc;
extern int errno;
rc = ioctl(fd, command, arg);
if (rc < 0)
{
fprintf(stderr, "ioctl(dsp,%d,arg) failed\n", command);
fprintf(stderr, "errno=%d\n", errno);
exit(-1);
}
}
//
// This function loads the sound data from the WAD lump,
// for single sound.
//
void*
getsfx
( char* sfxname,
int* len )
{
unsigned char* sfx;
unsigned char* paddedsfx;
int i;
int size;
int paddedsize;
char name[20];
int sfxlump;
// Get the sound data from the WAD, allocate lump
// in zone memory.
sprintf(name, "ds%s", sfxname);
// Now, there is a severe problem with the
// sound handling, in it is not (yet/anymore)
// gamemode aware. That means, sounds from
// DOOM II will be requested even with DOOM
// shareware.
// The sound list is wired into sounds.c,
// which sets the external variable.
// I do not do runtime patches to that
// variable. Instead, we will use a
// default sound for replacement.
if ( W_CheckNumForName(name) == -1 )
sfxlump = W_GetNumForName("dspistol");
else
sfxlump = W_GetNumForName(name);
size = W_LumpLength( sfxlump );
// Debug.
// fprintf( stderr, "." );
//fprintf( stderr, " -loading %s (lump %d, %d bytes)\n",
// sfxname, sfxlump, size );
//fflush( stderr );
sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_STATIC );
// Pads the sound effect out to the mixing buffer size.
// The original realloc would interfere with zone memory.
paddedsize = ((size-8 + (SAMPLECOUNT-1)) / SAMPLECOUNT) * SAMPLECOUNT;
// Allocate from zone memory.
paddedsfx = (unsigned char*)Z_Malloc( paddedsize+8, PU_STATIC, 0 );
// ddt: (unsigned char *) realloc(sfx, paddedsize+8);
// This should interfere with zone memory handling,
// which does not kick in in the soundserver.
// Now copy and pad.
memcpy( paddedsfx, sfx, size );
for (i=size ; i<paddedsize+8 ; i++)
paddedsfx[i] = 128;
// Remove the cached lump.
Z_Free( sfx );
// Preserve padded length.
*len = paddedsize;
// Return allocated padded data.
return (void *) (paddedsfx + 8);
}
//
// This function adds a sound to the
// list of currently active sounds,
// which is maintained as a given number
// (eight, usually) of internal channels.
// Returns a handle.
//
int
addsfx
( int sfxid,
int volume,
int step,
int seperation )
{
static unsigned short handlenums = 0;
int i;
int rc = -1;
int oldest = gametic;
int oldestnum = 0;
int slot;
int rightvol;
int leftvol;
// Chainsaw troubles.
// Play these sound effects only one at a time.
if ( sfxid == sfx_sawup
|| sfxid == sfx_sawidl
|| sfxid == sfx_sawful
|| sfxid == sfx_sawhit
|| sfxid == sfx_stnmov
|| sfxid == sfx_pistol )
{
// Loop all channels, check.
for (i=0 ; i<NUM_CHANNELS ; i++)
{
// Active, and using the same SFX?
if ( (channels[i])
&& (channelids[i] == sfxid) )
{
// Reset.
channels[i] = 0;
// We are sure that iff,
// there will only be one.
break;
}
}
}
// Loop all channels to find oldest SFX.
for (i=0; (i<NUM_CHANNELS) && (channels[i]); i++)
{
if (channelstart[i] < oldest)
{
oldestnum = i;
oldest = channelstart[i];
}
}
// Tales from the cryptic.
// If we found a channel, fine.
// If not, we simply overwrite the first one, 0.
// Probably only happens at startup.
if (i == NUM_CHANNELS)
slot = oldestnum;
else
slot = i;
// Okay, in the less recent channel,
// we will handle the new SFX.
// Set pointer to raw data.
channels[slot] = (unsigned char *) S_sfx[sfxid].data;
// Set pointer to end of raw data.
channelsend[slot] = channels[slot] + lengths[sfxid];
// Reset current handle number, limited to 0..100.
if (!handlenums)
handlenums = 100;
// Assign current handle number.
// Preserved so sounds could be stopped (unused).
channelhandles[slot] = rc = handlenums++;
// Set stepping???
// Kinda getting the impression this is never used.
channelstep[slot] = step;
// ???
channelstepremainder[slot] = 0;
// Should be gametic, I presume.
channelstart[slot] = gametic;
// Separation, that is, orientation/stereo.
// range is: 1 - 256
seperation += 1;
// Per left/right channel.
// x^2 seperation,
// adjust volume properly.
leftvol =
volume - ((volume*seperation*seperation) >> 16); ///(256*256);
seperation = seperation - 257;
rightvol =
volume - ((volume*seperation*seperation) >> 16);
// Sanity check, clamp volume.
if (rightvol < 0 || rightvol > 127)
I_Error("rightvol out of bounds");
if (leftvol < 0 || leftvol > 127)
I_Error("leftvol out of bounds");
// Get the proper lookup table piece
// for this volume level???
channelleftvol_lookup[slot] = &vol_lookup[leftvol*256];
channelrightvol_lookup[slot] = &vol_lookup[rightvol*256];
// Preserve sound SFX id,
// e.g. for avoiding duplicates of chainsaw.
channelids[slot] = sfxid;
// You tell me.
return rc;
}
//
// SFX API
@ -395,32 +37,6 @@ addsfx
//
void I_SetChannels()
{
// Init internal lookups (raw data, mixing buffer, channels).
// This function sets up internal lookups used during
// the mixing process.
int i;
int j;
int* steptablemid = steptable + 128;
// Okay, reset internal mixing channels to zero.
/*for (i=0; i<NUM_CHANNELS; i++)
{
channels[i] = 0;
}*/
// This table provides step widths for pitch parameters.
// I fail to see that this is currently used.
for (i=-128 ; i<128 ; i++)
steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
// Generates volume lookup tables
// which also turn the unsigned samples
// into signed samples.
for (i=0 ; i<128 ; i++)
for (j=0 ; j<256 ; j++)
vol_lookup[i*256+j] = (i*(j-128)*256)/127;
}
@ -431,14 +47,13 @@ void I_SetSfxVolume(int volume)
// the menu/config file setting
// to the state variable used in
// the mixing.
snd_SfxVolume = volume;
}
// MUSIC API - dummy. Some code from DOS version.
void I_SetMusicVolume(int volume)
{
// Internal state variable.
snd_MusicVolume = volume;
// Now set volume on output device.
// Whatever( snd_MusciVolume );
}
@ -475,29 +90,7 @@ I_StartSound
int pitch,
int priority )
{
// UNUSED
priority = 0;
#ifdef SNDSERV
if (sndserver)
{
fprintf(sndserver, "p%2.2x%2.2x%2.2x%2.2x\n", id, pitch, vol, sep);
fflush(sndserver);
}
// warning: control reaches end of non-void function.
return id;
#else
// Debug.
//fprintf( stderr, "starting sound %d", id );
// Returns a handle (not used).
id = addsfx( id, vol, steptable[pitch], sep );
// fprintf( stderr, "/handle is %d\n", id );
return id;
#endif
return 0;
}
@ -509,8 +102,6 @@ void I_StopSound (int handle)
// tracking down the handle,
// an setting the channel to zero.
// UNUSED.
handle = 0;
}
@ -538,119 +129,6 @@ int I_SoundIsPlaying(int handle)
//
void I_UpdateSound( void )
{
#ifdef SNDINTR
// Debug. Count buffer misses with interrupt.
static int misses = 0;
#endif
// Mix current sound data.
// Data, from raw sound, for right and left.
register unsigned int sample;
register int dl;
register int dr;
// Pointers in global mixbuffer, left, right, end.
signed short* leftout;
signed short* rightout;
signed short* leftend;
// Step in mixbuffer, left and right, thus two.
int step;
// Mixing channel index.
int chan;
// Left and right channel
// are in global mixbuffer, alternating.
leftout = mixbuffer;
rightout = mixbuffer+1;
step = 2;
// Determine end, for left channel only
// (right channel is implicit).
leftend = mixbuffer + SAMPLECOUNT*step;
// Mix sounds into the mixing buffer.
// Loop over step*SAMPLECOUNT,
// that is 512 values for two channels.
while (leftout != leftend)
{
// Reset left/right value.
dl = 0;
dr = 0;
// Love thy L2 chache - made this a loop.
// Now more channels could be set at compile time
// as well. Thus loop those channels.
for ( chan = 0; chan < NUM_CHANNELS; chan++ )
{
// Check channel, if active.
if (channels[ chan ])
{
// Get the raw data from the channel.
sample = *channels[ chan ];
// Add left and right part
// for this channel (sound)
// to the current data.
// Adjust volume accordingly.
dl += channelleftvol_lookup[ chan ][sample];
dr += channelrightvol_lookup[ chan ][sample];
// Increment index ???
channelstepremainder[ chan ] += channelstep[ chan ];
// MSB is next sample???
channels[ chan ] += channelstepremainder[ chan ] >> 16;
// Limit to LSB???
channelstepremainder[ chan ] &= 65536-1;
// Check whether we are done.
if (channels[ chan ] >= channelsend[ chan ])
channels[ chan ] = 0;
}
}
// Clamp to range. Left hardware channel.
// Has been char instead of short.
// if (dl > 127) *leftout = 127;
// else if (dl < -128) *leftout = -128;
// else *leftout = dl;
if (dl > 0x7fff)
*leftout = 0x7fff;
else if (dl < -0x8000)
*leftout = -0x8000;
else
*leftout = dl;
// Same for right hardware channel.
if (dr > 0x7fff)
*rightout = 0x7fff;
else if (dr < -0x8000)
*rightout = -0x8000;
else
*rightout = dr;
// Increment current pointers in mixbuffer.
leftout += step;
rightout += step;
}
#ifdef SNDINTR
// Debug check.
if ( flag )
{
misses += flag;
flag = 0;
}
if ( misses > 10 )
{
fprintf( stderr, "I_SoundUpdate: missed 10 buffer writes\n");
misses = 0;
}
// Increment flag for update.
flag++;
#endif
}
@ -666,7 +144,6 @@ void
I_SubmitSound(void)
{
// Write it to DSP device.
write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL);
}
@ -692,39 +169,6 @@ I_UpdateSoundParams
void I_ShutdownSound(void)
{
#ifdef SNDSERV
if (sndserver)
{
// Send a "quit" command.
fprintf(sndserver, "q\n");
fflush(sndserver);
}
#else
// Wait till all pending sounds are finished.
int done = 0;
int i;
// FIXME (below).
fprintf( stderr, "I_ShutdownSound: NOT finishing pending sounds\n");
fflush( stderr );
while ( !done )
{
for( i=0 ; i<8 && !channels[i] ; i++);
// FIXME. No proper channel output.
//if (i==8)
done=1;
}
#ifdef SNDINTR
I_SoundDelTimer();
#endif
// Cleaning up -releasing the DSP device.
close ( audio_fd );
#endif
// Done.
return;
}
@ -737,91 +181,6 @@ void I_ShutdownSound(void)
void
I_InitSound()
{
#ifdef SNDSERV
char buffer[256];
if (getenv("DOOMWADDIR"))
sprintf(buffer, "%s/%s",
getenv("DOOMWADDIR"),
sndserver_filename);
else
sprintf(buffer, "%s", sndserver_filename);
// start sound process
if ( !access(buffer, X_OK) )
{
strcat(buffer, " -quiet");
sndserver = popen(buffer, "w");
}
else
fprintf(stderr, "Could not start sound server [%s]\n", buffer);
#else
int i;
#ifdef SNDINTR
fprintf( stderr, "I_SoundSetTimer: %d microsecs\n", SOUND_INTERVAL );
I_SoundSetTimer( SOUND_INTERVAL );
#endif
// Secure and configure sound device first.
fprintf( stderr, "I_InitSound: ");
audio_fd = open("/dev/dsp", O_WRONLY);
if (audio_fd<0)
fprintf(stderr, "Could not open /dev/dsp\n");
i = 11 | (2<<16);
myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i);
myioctl(audio_fd, SNDCTL_DSP_RESET, 0);
i=SAMPLERATE;
myioctl(audio_fd, SNDCTL_DSP_SPEED, &i);
i=1;
myioctl(audio_fd, SNDCTL_DSP_STEREO, &i);
myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i);
if (i&=AFMT_S16_LE)
myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i);
else
fprintf(stderr, "Could not play signed 16 data\n");
fprintf(stderr, " configured audio device\n" );
// Initialize external data (all sounds) at start, keep static.
fprintf( stderr, "I_InitSound: ");
for (i=1 ; i<NUMSFX ; i++)
{
// Alias? Example is the chaingun sound linked to pistol.
if (!S_sfx[i].link)
{
// Load data from WAD file.
S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] );
}
else
{
// Previously loaded already?
S_sfx[i].data = S_sfx[i].link->data;
lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)];
}
}
fprintf( stderr, " pre-cached all sound data\n");
// Now initialize mixbuffer with zero.
for ( i = 0; i< MIXBUFFERSIZE; i++ )
mixbuffer[i] = 0;
// Finished initialization.
fprintf(stderr, "I_InitSound: sound module ready\n");
#endif
}
@ -890,96 +249,3 @@ int I_QrySongPlaying(int handle)
//
// Experimental stuff.
// A Linux timer interrupt, for asynchronous
// sound output.
// I ripped this out of the Timer class in
// our Difference Engine, including a few
// SUN remains...
//
#ifdef sun
typedef sigset_t tSigSet;
#else
typedef int tSigSet;
#endif
// We might use SIGVTALRM and ITIMER_VIRTUAL, if the process
// time independend timer happens to get lost due to heavy load.
// SIGALRM and ITIMER_REAL doesn't really work well.
// There are issues with profiling as well.
static int /*__itimer_which*/ itimer = ITIMER_REAL;
static int sig = SIGALRM;
// Interrupt handler.
void I_HandleSoundTimer( int ignore )
{
// Debug.
//fprintf( stderr, "%c", '+' ); fflush( stderr );
// Feed sound device if necesary.
if ( flag )
{
// See I_SubmitSound().
// Write it to DSP device.
write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL);
// Reset flag counter.
flag = 0;
}
else
return;
// UNUSED, but required.
ignore = 0;
return;
}
// Get the interrupt. Set duration in millisecs.
int I_SoundSetTimer( int duration_of_tick )
{
// Needed for gametick clockwork.
struct itimerval value;
struct itimerval ovalue;
struct sigaction act;
struct sigaction oact;
int res;
// This sets to SA_ONESHOT and SA_NOMASK, thus we can not use it.
// signal( _sig, handle_SIG_TICK );
// Now we have to change this attribute for repeated calls.
act.sa_handler = I_HandleSoundTimer;
#ifndef sun
//ac t.sa_mask = _sig;
#endif
act.sa_flags = SA_RESTART;
sigaction( sig, &act, &oact );
value.it_interval.tv_sec = 0;
value.it_interval.tv_usec = duration_of_tick;
value.it_value.tv_sec = 0;
value.it_value.tv_usec = duration_of_tick;
// Error is -1.
res = setitimer( itimer, &value, &ovalue );
// Debug.
if ( res == -1 )
fprintf( stderr, "I_SoundSetTimer: interrupt n.a.\n");
return res;
}
// Remove the interrupt. Set duration to zero.
void I_SoundDelTimer()
{
// Debug.
if ( I_SoundSetTimer( 0 ) == -1)
fprintf( stderr, "I_SoundDelTimer: failed to remove interrupt. Doh!\n");
}

View File

@ -25,12 +25,6 @@
#include "doomdef.h"
// UNIX hack, to be removed.
#ifdef SNDSERV
#include <stdio.h>
extern FILE* sndserver;
extern char* sndserver_filename;
#endif
#include "doomstat.h"
#include "sounds.h"

View File

@ -20,59 +20,27 @@
//
//-----------------------------------------------------------------------------
static const char
rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <sys/time.h>
#include <unistd.h>
#include "doomtype.h"
#include "doomdef.h"
#include "m_misc.h"
#include "i_video.h"
#include "i_sound.h"
#include "d_net.h"
#include "g_game.h"
#ifdef __GNUG__
#pragma implementation "i_system.h"
#endif
#include "i_system.h"
#include "doomstat.h"
#include "d_ticcmd.h"
#include <time.h>
#include <stdarg.h>
void I_Init (void)
{
I_InitSound();
I_InitGraphics();
}
int mb_used = 6;
void
I_Tactile
( int on,
int off,
int total )
{
// UNUSED.
on = off = total = 0;
}
ticcmd_t emptycmd;
ticcmd_t* I_BaseTiccmd(void)
{
return &emptycmd;
}
int I_GetHeapSize (void)
{
return mb_used*1024*1024;
}
// Called by startup code
// to get the ammount of memory to malloc
// for the zone management.
byte* I_ZoneBase (int *size)
{
*size = mb_used*1024*1024;
@ -80,39 +48,56 @@ byte* I_ZoneBase (int* size)
}
//
// I_GetTime
// returns time in 1/70th second tics
//
// Called by D_DoomLoop,
// returns current time in tics.
int I_GetTime (void)
{
struct timeval tp;
struct timezone tzp;
int newtics;
static int basetime=0;
gettimeofday(&tp, &tzp);
if (!basetime)
basetime = tp.tv_sec;
newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000;
return newtics;
return clock()/(CLOCKS_PER_SEC/TICRATE);
}
//
// I_Init
// Called by D_DoomLoop,
// called before processing any tics in a frame
// (just after displaying a frame).
// Time consuming syncronous operations
// are performed here (joystick reading).
// Can call D_PostEvent.
//
void I_Init (void)
void I_StartFrame (void)
{
I_InitSound();
// I_InitGraphics();
}
//
// I_Quit
//
// Called by D_DoomLoop,
// called before processing each tic in a frame.
// Quick syncronous operations are performed here.
// Can call D_PostEvent.
void I_StartTic (void)
{
}
// Asynchronous interrupt functions should maintain private queues
// that are read by the synchronous functions
// to be converted into events.
// Either returns a null ticcmd,
// or calls a loadable driver to build it.
// This ticcmd will then be modified by the gameloop
// for normal input.
ticcmd_t emptycmd;
ticcmd_t* I_BaseTiccmd (void)
{
return &emptycmd;
}
// Called by M_Responder when quit is selected.
// Clean exit, displays sell blurb.
void I_Quit (void)
{
D_QuitNetGame ();
@ -123,27 +108,10 @@ void I_Quit (void)
exit(0);
}
void I_WaitVBL(int count)
{
#ifdef SGI
sginap(1);
#else
#ifdef SUN
sleep(0);
#else
usleep (count * (1000000/70) );
#endif
#endif
}
void I_BeginRead(void)
{
}
void I_EndRead(void)
{
}
// Allocates from low memory under dos,
// just mallocs under unix
byte* I_AllocLow (int length)
{
byte* mem;
@ -153,11 +121,12 @@ byte* I_AllocLow(int length)
return mem;
}
void I_Tactile (int on, int off, int total)
{
// UNUSED.
on = off = total = 0;
}
//
// I_Error
//
extern boolean demorecording;
void I_Error (char *error, ...)
{
@ -181,3 +150,4 @@ void I_Error (char *error, ...)
exit(-1);
}

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@ rcsid[] = "$Id: info.c,v 1.3 1997/01/26 07:45:00 b1 Exp $";
#include "p_mobj.h"
char *sprnames[NUMSPRITES] = {
char *sprnames[NUMSPRITES+1] = {
"TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG",
"MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2",
"PLSS","PLSE","MISL","BFS1","BFE1","BFE2","TFOG","IFOG","PLAY","POSS",
@ -51,7 +51,7 @@ char *sprnames[NUMSPRITES] = {
"POL3","POL1","POL6","GOR2","GOR3","GOR4","GOR5","SMIT","COL1","COL2",
"COL3","COL4","CAND","CBRA","COL6","TRE1","TRE2","ELEC","CEYE","FSKU",
"COL5","TBLU","TGRN","TRED","SMBT","SMGT","SMRT","HDB1","HDB2","HDB3",
"HDB4","HDB5","HDB6","POB1","POB2","BRS1","TLMP","TLP2"
"HDB4","HDB5","HDB6","POB1","POB2","BRS1","TLMP","TLP2", NULL
};

View File

@ -1156,7 +1156,7 @@ typedef struct
} state_t;
extern state_t states[NUMSTATES];
extern char *sprnames[NUMSPRITES];
extern char *sprnames[NUMSPRITES+1];

View File

@ -23,8 +23,7 @@
#ifndef __M_BBOX__
#define __M_BBOX__
#include <values.h>
#include "doomtype.h"
#include "m_fixed.h"

View File

@ -25,7 +25,6 @@
static const char
rcsid[] = "$Id: m_menu.c,v 1.7 1997/02/03 22:45:10 b1 Exp $";
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

View File

@ -31,8 +31,6 @@ rcsid[] = "$Id: m_misc.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>

View File

@ -533,7 +533,7 @@ void P_GroupLines (void)
}
// build line tables for each sector
linebuffer = Z_Malloc (total*4, PU_LEVEL, 0);
linebuffer = Z_Malloc (total*sizeof(*linebuffer), PU_LEVEL, 0);
sector = sectors;
for (i=0 ; i<numsectors ; i++, sector++)
{

View File

@ -87,7 +87,7 @@ typedef struct
boolean masked;
short width;
short height;
void **columndirectory; // OBSOLETE
int obsolete;//void **columndirectory; // OBSOLETE
short patchcount;
mappatch_t patches[1];
} maptexture_t;
@ -319,7 +319,7 @@ void R_GenerateLookup (int texnum)
// that are covered by more than one patch.
// Fill in the lump / offset, so columns
// with only a single patch are all done.
patchcount = (byte *)alloca (texture->width);
patchcount = (byte *)malloc (texture->width);
memset (patchcount, 0, texture->width);
patch = texture->patches;
@ -448,7 +448,7 @@ void R_InitTextures (void)
names = W_CacheLumpName ("PNAMES", PU_STATIC);
nummappatches = LONG ( *((int *)names) );
name_p = names+4;
patchlookup = alloca (nummappatches*sizeof(*patchlookup));
patchlookup = malloc (nummappatches*sizeof(*patchlookup));
for (i=0 ; i<nummappatches ; i++)
{
@ -479,13 +479,13 @@ void R_InitTextures (void)
}
numtextures = numtextures1 + numtextures2;
textures = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturecolumnlump = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturecolumnofs = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturecomposite = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturecompositesize = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturewidthmask = Z_Malloc (numtextures*4, PU_STATIC, 0);
textureheight = Z_Malloc (numtextures*4, PU_STATIC, 0);
textures = Z_Malloc (numtextures*sizeof(*textures), PU_STATIC, 0);
texturecolumnlump = Z_Malloc (numtextures*sizeof(*texturecolumnlump), PU_STATIC, 0);
texturecolumnofs = Z_Malloc (numtextures*sizeof(*texturecolumnofs), PU_STATIC, 0);
texturecomposite = Z_Malloc (numtextures*sizeof(*texturecomposite), PU_STATIC, 0);
texturecompositesize = Z_Malloc (numtextures*sizeof(*texturecompositesize), PU_STATIC, 0);
texturewidthmask = Z_Malloc (numtextures*sizeof(*texturewidthmask), PU_STATIC, 0);
textureheight = Z_Malloc (numtextures*sizeof(*textureheight), PU_STATIC, 0);
totalwidth = 0;
@ -567,7 +567,7 @@ void R_InitTextures (void)
R_GenerateLookup (i);
// Create translation table for global animation.
texturetranslation = Z_Malloc ((numtextures+1)*4, PU_STATIC, 0);
texturetranslation = Z_Malloc ((numtextures+1)*sizeof(*texturetranslation), PU_STATIC, 0);
for (i=0 ; i<numtextures ; i++)
texturetranslation[i] = i;
@ -587,7 +587,7 @@ void R_InitFlats (void)
numflats = lastflat - firstflat + 1;
// Create translation table for global animation.
flattranslation = Z_Malloc ((numflats+1)*4, PU_STATIC, 0);
flattranslation = Z_Malloc ((numflats+1)*sizeof(*flattranslation), PU_STATIC, 0);
for (i=0 ; i<numflats ; i++)
flattranslation[i] = i;
@ -609,9 +609,9 @@ void R_InitSpriteLumps (void)
lastspritelump = W_GetNumForName ("S_END") - 1;
numspritelumps = lastspritelump - firstspritelump + 1;
spritewidth = Z_Malloc (numspritelumps*4, PU_STATIC, 0);
spriteoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0);
spritetopoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0);
spritewidth = Z_Malloc (numspritelumps*sizeof(*spritewidth), PU_STATIC, 0);
spriteoffset = Z_Malloc (numspritelumps*sizeof(*spriteoffset), PU_STATIC, 0);
spritetopoffset = Z_Malloc (numspritelumps*sizeof(*spritetopoffset), PU_STATIC, 0);
for (i=0 ; i< numspritelumps ; i++)
{
@ -639,7 +639,7 @@ void R_InitColormaps (void)
lump = W_GetNumForName("COLORMAP");
length = W_LumpLength (lump) + 255;
colormaps = Z_Malloc (length, PU_STATIC, 0);
colormaps = (byte *)( ((int)colormaps + 255)&~0xff);
colormaps = (byte *)( ((uintptr_t)colormaps + 255)&~0xff);
W_ReadLump (lump,colormaps);
}
@ -759,7 +759,7 @@ void R_PrecacheLevel (void)
return;
// Precache flats.
flatpresent = alloca(numflats);
flatpresent = malloc(numflats);
memset (flatpresent,0,numflats);
for (i=0 ; i<numsectors ; i++)
@ -781,7 +781,7 @@ void R_PrecacheLevel (void)
}
// Precache textures.
texturepresent = alloca(numtextures);
texturepresent = malloc(numtextures);
memset (texturepresent,0, numtextures);
for (i=0 ; i<numsides ; i++)
@ -816,7 +816,7 @@ void R_PrecacheLevel (void)
}
// Precache sprites.
spritepresent = alloca(numsprites);
spritepresent = malloc(numsprites);
memset (spritepresent,0, numsprites);
for (th = thinkercap.next ; th != &thinkercap ; th=th->next)

View File

@ -461,7 +461,7 @@ void R_InitTranslationTables (void)
int i;
translationtables = Z_Malloc (256*3+255, PU_STATIC, 0);
translationtables = (byte *)(( (int)translationtables + 255 )& ~255);
translationtables = (byte *)(( (uintptr_t)translationtables + 255 )& ~255);
// translate just the 16 green colors
for (i=0 ; i<256 ; i++)

View File

@ -368,8 +368,8 @@ S_StartSoundAtVolume
// cache data if necessary
if (!sfx->data)
{
fprintf( stderr,
"S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n");
//fprintf( stderr,
// "S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n");
// DOS remains, 8bit handling
//sfx->data = (void *) W_CacheLumpNum(sfx->lumpnum, PU_MUSIC);

View File

@ -32,7 +32,6 @@ rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $";
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <alloca.h>
#define O_BINARY 0
@ -71,7 +70,7 @@ void strupr (char* s)
while (*s) { *s = toupper(*s); s++; }
}
int filelength (int handle)
int wadfilelength (int handle)
{
struct stat fileinfo;
@ -174,7 +173,7 @@ void W_AddFile (char *filename)
// single lump file
fileinfo = &singleinfo;
singleinfo.filepos = 0;
singleinfo.size = LONG(filelength(handle));
singleinfo.size = LONG(wadfilelength(handle));
ExtractFileBase (filename, singleinfo.name);
numlumps++;
}
@ -196,7 +195,7 @@ void W_AddFile (char *filename)
header.numlumps = LONG(header.numlumps);
header.infotableofs = LONG(header.infotableofs);
length = header.numlumps*sizeof(filelump_t);
fileinfo = alloca (length);
fileinfo = malloc (length);
lseek (handle, header.infotableofs, SEEK_SET);
read (handle, fileinfo, length);
numlumps += header.numlumps;
@ -253,7 +252,7 @@ void W_Reload (void)
lumpcount = LONG(header.numlumps);
header.infotableofs = LONG(header.infotableofs);
length = lumpcount*sizeof(filelump_t);
fileinfo = alloca (length);
fileinfo = malloc (length);
lseek (handle, header.infotableofs, SEEK_SET);
read (handle, fileinfo, length);