forked from KolibriOS/kolibrios
Doom alpha 2
git-svn-id: svn://kolibrios.org@333 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a89bf95159
commit
c682e2d8c0
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -28,8 +28,8 @@ rcsid[] = "$Id: f_finale.c,v 1.5 1997/02/03 21:26:34 b1 Exp $";
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
// Functions.
|
// Functions.
|
||||||
#include "m_swap.h"
|
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
#include "m_swap.h"
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -25,11 +25,10 @@ rcsid[] = "$Id: hu_lib.c,v 1.3 1997/01/26 07:44:58 b1 Exp $";
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "m_swap.h"
|
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
|
#include "m_swap.h"
|
||||||
|
|
||||||
#include "hu_lib.h"
|
#include "hu_lib.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
|
@ -17,32 +17,40 @@
|
|||||||
// $Log:$
|
// $Log:$
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
// DESCRIPTION:
|
||||||
// Main program, simply calls D_DoomMain high level loop.
|
// Main program, simply calls D_DoomMain high level loop.
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static const char
|
static const char
|
||||||
rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $";
|
rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $";
|
||||||
|
|
||||||
|
|
||||||
//#include "SDL.h"
|
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
|
|
||||||
#include "m_argv.h"
|
#include "m_argv.h"
|
||||||
#include "d_main.h"
|
#include "d_main.h"
|
||||||
|
#include "kolibri.h"
|
||||||
|
|
||||||
int
|
int main(int argc, char **argv)
|
||||||
main( int argc, char** argv)
|
|
||||||
{
|
{
|
||||||
static char * tmp[]=
|
// static char * tmp[]=
|
||||||
{"/hd/1/menuetos/doom/mdoom",
|
// {"/hd/1/menuetos/doom/mdoom",
|
||||||
NULL};
|
// NULL};
|
||||||
myargc = 1;
|
myargc = 1;
|
||||||
myargv = tmp;
|
myargv = argv;
|
||||||
|
|
||||||
// chdir("/hd/1/menuetos/doom");
|
// InitHeap(32*1024*1024);
|
||||||
|
_asm
|
||||||
|
{
|
||||||
|
push ebx
|
||||||
|
push ecx
|
||||||
|
mov eax, 66
|
||||||
|
mov ebx, 1
|
||||||
|
mov ecx, 1
|
||||||
|
int 0x40
|
||||||
|
pop ecx
|
||||||
|
pop ebx
|
||||||
|
};
|
||||||
|
|
||||||
D_DoomMain ();
|
D_DoomMain ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -9,6 +10,18 @@
|
|||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "i_net.h"
|
#include "i_net.h"
|
||||||
|
|
||||||
|
#ifdef DLHEAP
|
||||||
|
|
||||||
|
void* _cdecl dlmalloc(size_t);
|
||||||
|
void _cdecl dlfree(void*);
|
||||||
|
void _cdecl mf_init();
|
||||||
|
|
||||||
|
#define malloc dlmalloc
|
||||||
|
#define free dlfree
|
||||||
|
#define realloc dlrealloc
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef B_HOST_IS_LENDIAN
|
#ifndef B_HOST_IS_LENDIAN
|
||||||
#define B_HOST_IS_LENDIAN 1
|
#define B_HOST_IS_LENDIAN 1
|
||||||
#endif
|
#endif
|
||||||
@ -26,7 +39,7 @@
|
|||||||
((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
|
((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
|
||||||
(((unsigned short int)(x) & 0xff00) >> 8)))
|
(((unsigned short int)(x) & 0xff00) >> 8)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef htonl
|
#ifndef htonl
|
||||||
#define htonl(x) ntohl(x)
|
#define htonl(x) ntohl(x)
|
||||||
#endif
|
#endif
|
||||||
@ -35,7 +48,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void NetSend (void);
|
void NetSend (void);
|
||||||
int NetListen (void);
|
int NetListen (void);
|
||||||
|
|
||||||
|
|
||||||
@ -44,18 +57,19 @@ int NetListen (void);
|
|||||||
//
|
//
|
||||||
|
|
||||||
#ifndef IPPORT_USERRESERVED
|
#ifndef IPPORT_USERRESERVED
|
||||||
#define IPPORT_USERRESERVED 5000
|
#define IPPORT_USERRESERVED 5000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int DOOMPORT = (IPPORT_USERRESERVED+0x1d);
|
int DOOMPORT = (IPPORT_USERRESERVED+0x1d);
|
||||||
int sendsocket[MAXNETNODES];
|
int sendsocket[MAXNETNODES];
|
||||||
int insocket;
|
int insocket;
|
||||||
|
|
||||||
void (*netget) (void);
|
void (*netget) (void);
|
||||||
void (*netsend) (void);
|
void (*netsend) (void);
|
||||||
|
|
||||||
static int first_user_port=IPPORT_USERRESERVED+0x1D+0x10;
|
static int first_user_port=IPPORT_USERRESERVED+0x1D+0x10;
|
||||||
|
|
||||||
|
/**********
|
||||||
int GetAvailPort(void)
|
int GetAvailPort(void)
|
||||||
{
|
{
|
||||||
int i,d0;
|
int i,d0;
|
||||||
@ -70,11 +84,11 @@ int GetAvailPort(void)
|
|||||||
I_Error("Unable to get new port\n");
|
I_Error("Unable to get new port\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
**********/
|
||||||
|
|
||||||
int CreateInputUDPsocket(void)
|
int CreateInputUDPsocket(void)
|
||||||
{
|
{
|
||||||
int d0;
|
int d0=0;
|
||||||
//__asm__ __volatile__(
|
//__asm__ __volatile__(
|
||||||
// "int $0x40"
|
// "int $0x40"
|
||||||
// :"=a"(d0)
|
// :"=a"(d0)
|
||||||
@ -108,7 +122,12 @@ int CreateOutputUDPSocket(int remote_ip)
|
|||||||
void PacketSend (void)
|
void PacketSend (void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
doomdata_t sw;
|
doomdata_t sw;
|
||||||
|
|
||||||
|
|
||||||
|
//printf("ERROR Packet Send\n\r");
|
||||||
|
|
||||||
|
|
||||||
// byte swap
|
// byte swap
|
||||||
sw.checksum = htonl(netbuffer->checksum);
|
sw.checksum = htonl(netbuffer->checksum);
|
||||||
sw.player = netbuffer->player;
|
sw.player = netbuffer->player;
|
||||||
@ -158,12 +177,13 @@ int GetLocalAddress (void)
|
|||||||
//
|
//
|
||||||
// I_InitNetwork
|
// I_InitNetwork
|
||||||
//
|
//
|
||||||
|
|
||||||
void I_InitNetwork (void)
|
void I_InitNetwork (void)
|
||||||
{
|
{
|
||||||
boolean trueval = true;
|
boolean trueval = true;
|
||||||
int i;
|
int i;
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
doomcom = malloc (sizeof (*doomcom) );
|
doomcom = malloc (sizeof (*doomcom) );
|
||||||
memset (doomcom, 0, sizeof(*doomcom) );
|
memset (doomcom, 0, sizeof(*doomcom) );
|
||||||
|
|
||||||
@ -171,25 +191,25 @@ void I_InitNetwork (void)
|
|||||||
i = M_CheckParm ("-dup");
|
i = M_CheckParm ("-dup");
|
||||||
if (i && i< myargc-1)
|
if (i && i< myargc-1)
|
||||||
{
|
{
|
||||||
doomcom->ticdup = myargv[i+1][0]-'0';
|
doomcom->ticdup = myargv[i+1][0]-'0';
|
||||||
if (doomcom->ticdup < 1)
|
if (doomcom->ticdup < 1)
|
||||||
doomcom->ticdup = 1;
|
doomcom->ticdup = 1;
|
||||||
if (doomcom->ticdup > 9)
|
if (doomcom->ticdup > 9)
|
||||||
doomcom->ticdup = 9;
|
doomcom->ticdup = 9;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
doomcom-> ticdup = 1;
|
doomcom-> ticdup = 1;
|
||||||
|
|
||||||
if (M_CheckParm ("-extratic"))
|
if (M_CheckParm ("-extratic"))
|
||||||
doomcom-> extratics = 1;
|
doomcom-> extratics = 1;
|
||||||
else
|
else
|
||||||
doomcom-> extratics = 0;
|
doomcom-> extratics = 0;
|
||||||
|
|
||||||
p = M_CheckParm ("-port");
|
p = M_CheckParm ("-port");
|
||||||
if (p && p<myargc-1)
|
if (p && p<myargc-1)
|
||||||
{
|
{
|
||||||
DOOMPORT = atoi (myargv[p+1]);
|
DOOMPORT = atoi (myargv[p+1]);
|
||||||
// __libclog_printf ("using alternate port %i\n",DOOMPORT);
|
// __libclog_printf ("using alternate port %i\n",DOOMPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse network game options,
|
// parse network game options,
|
||||||
@ -198,13 +218,13 @@ void I_InitNetwork (void)
|
|||||||
|
|
||||||
if (!i)
|
if (!i)
|
||||||
{
|
{
|
||||||
// single player game
|
// single player game
|
||||||
netgame = false;
|
netgame = false;
|
||||||
doomcom->id = DOOMCOM_ID;
|
doomcom->id = DOOMCOM_ID;
|
||||||
doomcom->numplayers = doomcom->numnodes = 1;
|
doomcom->numplayers = doomcom->numnodes = 1;
|
||||||
doomcom->deathmatch = false;
|
doomcom->deathmatch = false;
|
||||||
doomcom->consoleplayer = 0;
|
doomcom->consoleplayer = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
netsend = PacketSend;
|
netsend = PacketSend;
|
||||||
@ -214,7 +234,7 @@ void I_InitNetwork (void)
|
|||||||
// parse player number and host list
|
// parse player number and host list
|
||||||
doomcom->consoleplayer = myargv[i+1][0]-'1';
|
doomcom->consoleplayer = myargv[i+1][0]-'1';
|
||||||
|
|
||||||
doomcom->numnodes = 1; // this node for sure
|
doomcom->numnodes = 1; // this node for sure
|
||||||
doomcom->id = DOOMCOM_ID;
|
doomcom->id = DOOMCOM_ID;
|
||||||
doomcom->numplayers = doomcom->numnodes;
|
doomcom->numplayers = doomcom->numnodes;
|
||||||
sendsocket[0]=0;
|
sendsocket[0]=0;
|
||||||
@ -226,17 +246,21 @@ void I_InitNetwork (void)
|
|||||||
// __libclog_printf("DOOM: Input UDP socket is %d\n",insocket);
|
// __libclog_printf("DOOM: Input UDP socket is %d\n",insocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void I_NetCmd (void)
|
void I_NetCmd (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
//printf("ERROR NetCmd");
|
||||||
|
|
||||||
|
|
||||||
if (doomcom->command == CMD_SEND)
|
if (doomcom->command == CMD_SEND)
|
||||||
{
|
{
|
||||||
netsend ();
|
// netsend ();
|
||||||
}
|
}
|
||||||
else if (doomcom->command == CMD_GET)
|
else if (doomcom->command == CMD_GET)
|
||||||
{
|
{
|
||||||
netget ();
|
// netget ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
I_Error ("Bad net cmd: %i\n",doomcom->command);
|
I_Error ("Bad net cmd: %i\n",doomcom->command);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
// $Log:$
|
// $Log:$
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
// DESCRIPTION:
|
||||||
// System interface for sound.
|
// System interface for sound.
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -55,37 +55,37 @@ rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
|
|||||||
|
|
||||||
|
|
||||||
// Needed for calling the actual sound output.
|
// Needed for calling the actual sound output.
|
||||||
#define SAMPLECOUNT 512
|
#define SAMPLECOUNT 512
|
||||||
#define NUM_CHANNELS 16
|
#define NUM_CHANNELS 16
|
||||||
// It is 2 for 16bit, and 2 for two channels.
|
// It is 2 for 16bit, and 2 for two channels.
|
||||||
#define BUFMUL 4
|
#define BUFMUL 4
|
||||||
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
|
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
|
||||||
|
|
||||||
#define SAMPLERATE 11025 // Hz
|
#define SAMPLERATE 11025 // Hz
|
||||||
#define SAMPLESIZE 2 // 16bit
|
#define SAMPLESIZE 2 // 16bit
|
||||||
|
|
||||||
// The actual lengths of all sound effects.
|
// The actual lengths of all sound effects.
|
||||||
int lengths[NUMSFX];
|
int lengths[NUMSFX];
|
||||||
|
|
||||||
// The actual output device.
|
// The actual output device.
|
||||||
int audio_fd;
|
int audio_fd;
|
||||||
|
|
||||||
// The global mixing buffer.
|
// The global mixing buffer.
|
||||||
// Basically, samples from all active internal channels
|
// Basically, samples from all active internal channels
|
||||||
// are modifed and added, and stored in the buffer
|
// are modifed and added, and stored in the buffer
|
||||||
// that is submitted to the audio device.
|
// that is submitted to the audio device.
|
||||||
signed short mixbuffer[MIXBUFFERSIZE];
|
signed short mixbuffer[MIXBUFFERSIZE];
|
||||||
|
|
||||||
|
|
||||||
// The channel step amount...
|
// The channel step amount...
|
||||||
unsigned int channelstep[NUM_CHANNELS];
|
unsigned int channelstep[NUM_CHANNELS];
|
||||||
// ... and a 0.16 bit remainder of last step.
|
// ... and a 0.16 bit remainder of last step.
|
||||||
unsigned int channelstepremainder[NUM_CHANNELS];
|
unsigned int channelstepremainder[NUM_CHANNELS];
|
||||||
|
|
||||||
|
|
||||||
// The channel data pointers, start and end.
|
// The channel data pointers, start and end.
|
||||||
unsigned char* channels[NUM_CHANNELS];
|
unsigned char* channels[NUM_CHANNELS];
|
||||||
unsigned char* channelsend[NUM_CHANNELS];
|
unsigned char* channelsend[NUM_CHANNELS];
|
||||||
|
|
||||||
|
|
||||||
// Time/gametic that the channel started playing,
|
// Time/gametic that the channel started playing,
|
||||||
@ -93,27 +93,27 @@ unsigned char* channelsend[NUM_CHANNELS];
|
|||||||
// has lowest priority.
|
// has lowest priority.
|
||||||
// In case number of active sounds exceeds
|
// In case number of active sounds exceeds
|
||||||
// available channels.
|
// available channels.
|
||||||
int channelstart[NUM_CHANNELS];
|
int channelstart[NUM_CHANNELS];
|
||||||
|
|
||||||
// The sound in channel handles,
|
// The sound in channel handles,
|
||||||
// determined on registration,
|
// determined on registration,
|
||||||
// might be used to unregister/stop/modify,
|
// might be used to unregister/stop/modify,
|
||||||
// currently unused.
|
// currently unused.
|
||||||
int channelhandles[NUM_CHANNELS];
|
int channelhandles[NUM_CHANNELS];
|
||||||
|
|
||||||
// SFX id of the playing sound effect.
|
// SFX id of the playing sound effect.
|
||||||
// Used to catch duplicates (like chainsaw).
|
// Used to catch duplicates (like chainsaw).
|
||||||
int channelids[NUM_CHANNELS];
|
int channelids[NUM_CHANNELS];
|
||||||
|
|
||||||
// Pitch to stepping lookup, unused.
|
// Pitch to stepping lookup, unused.
|
||||||
int steptable[256];
|
int steptable[256];
|
||||||
|
|
||||||
// Volume lookups.
|
// Volume lookups.
|
||||||
int vol_lookup[128*256];
|
int vol_lookup[128*256];
|
||||||
|
|
||||||
// Hardware left and right channel volume lookup.
|
// Hardware left and right channel volume lookup.
|
||||||
int* channelleftvol_lookup[NUM_CHANNELS];
|
int* channelleftvol_lookup[NUM_CHANNELS];
|
||||||
int* channelrightvol_lookup[NUM_CHANNELS];
|
int* channelrightvol_lookup[NUM_CHANNELS];
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -155,7 +155,7 @@ void* getsfx (char* sfxname, int* len)
|
|||||||
// Debug.
|
// Debug.
|
||||||
// fprintf( stderr, "." );
|
// fprintf( stderr, "." );
|
||||||
//fprintf( stderr, " -loading %s (lump %d, %d bytes)\n",
|
//fprintf( stderr, " -loading %s (lump %d, %d bytes)\n",
|
||||||
// sfxname, sfxlump, size );
|
// sfxname, sfxlump, size );
|
||||||
//fflush( stderr );
|
//fflush( stderr );
|
||||||
|
|
||||||
sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_STATIC );
|
sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_STATIC );
|
||||||
@ -193,54 +193,54 @@ void* getsfx (char* sfxname, int* len)
|
|||||||
// Returns a handle.
|
// Returns a handle.
|
||||||
//
|
//
|
||||||
|
|
||||||
static unsigned short handlenums = 0;
|
static unsigned short handlenums = 0;
|
||||||
|
|
||||||
int addsfx(int sfxid, int volume, int step, int seperation)
|
int addsfx(int sfxid, int volume, int step, int seperation)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
int oldest = gametic;
|
int oldest = gametic;
|
||||||
int oldestnum = 0;
|
int oldestnum = 0;
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
int rightvol;
|
int rightvol;
|
||||||
int leftvol;
|
int leftvol;
|
||||||
|
|
||||||
// Chainsaw troubles.
|
// Chainsaw troubles.
|
||||||
// Play these sound effects only one at a time.
|
// Play these sound effects only one at a time.
|
||||||
if ( sfxid == sfx_sawup
|
if ( sfxid == sfx_sawup
|
||||||
|| sfxid == sfx_sawidl
|
|| sfxid == sfx_sawidl
|
||||||
|| sfxid == sfx_sawful
|
|| sfxid == sfx_sawful
|
||||||
|| sfxid == sfx_sawhit
|
|| sfxid == sfx_sawhit
|
||||||
|| sfxid == sfx_stnmov
|
|| sfxid == sfx_stnmov
|
||||||
|| sfxid == sfx_pistol )
|
|| sfxid == sfx_pistol )
|
||||||
{
|
{
|
||||||
// Loop all channels, check.
|
// Loop all channels, check.
|
||||||
for (i=0 ; i<NUM_CHANNELS ; i++)
|
for (i=0 ; i<NUM_CHANNELS ; i++)
|
||||||
{
|
{
|
||||||
// Active, and using the same SFX?
|
// Active, and using the same SFX?
|
||||||
if ( (channels[i])
|
if ( (channels[i])
|
||||||
&& (channelids[i] == sfxid) )
|
&& (channelids[i] == sfxid) )
|
||||||
{
|
{
|
||||||
// Reset.
|
// Reset.
|
||||||
channels[i] = 0;
|
channels[i] = 0;
|
||||||
// We are sure that iff,
|
// We are sure that iff,
|
||||||
// there will only be one.
|
// there will only be one.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop all channels to find oldest SFX.
|
// Loop all channels to find oldest SFX.
|
||||||
for (i=0; (i<NUM_CHANNELS) && (channels[i]); i++)
|
for (i=0; (i<NUM_CHANNELS) && (channels[i]); i++)
|
||||||
{
|
{
|
||||||
if (channelstart[i] < oldest)
|
if (channelstart[i] < oldest)
|
||||||
{
|
{
|
||||||
oldestnum = i;
|
oldestnum = i;
|
||||||
oldest = channelstart[i];
|
oldest = channelstart[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tales from the cryptic.
|
// Tales from the cryptic.
|
||||||
@ -248,9 +248,9 @@ int addsfx(int sfxid, int volume, int step, int seperation)
|
|||||||
// If not, we simply overwrite the first one, 0.
|
// If not, we simply overwrite the first one, 0.
|
||||||
// Probably only happens at startup.
|
// Probably only happens at startup.
|
||||||
if (i == NUM_CHANNELS)
|
if (i == NUM_CHANNELS)
|
||||||
slot = oldestnum;
|
slot = oldestnum;
|
||||||
else
|
else
|
||||||
slot = i;
|
slot = i;
|
||||||
|
|
||||||
// Okay, in the less recent channel,
|
// Okay, in the less recent channel,
|
||||||
// we will handle the new SFX.
|
// we will handle the new SFX.
|
||||||
@ -261,7 +261,7 @@ int addsfx(int sfxid, int volume, int step, int seperation)
|
|||||||
|
|
||||||
// Reset current handle number, limited to 0..100.
|
// Reset current handle number, limited to 0..100.
|
||||||
if (!handlenums)
|
if (!handlenums)
|
||||||
handlenums = 100;
|
handlenums = 100;
|
||||||
|
|
||||||
// Assign current handle number.
|
// Assign current handle number.
|
||||||
// Preserved so sounds could be stopped (unused).
|
// Preserved so sounds could be stopped (unused).
|
||||||
@ -282,17 +282,17 @@ int addsfx(int sfxid, int volume, int step, int seperation)
|
|||||||
// x^2 seperation,
|
// x^2 seperation,
|
||||||
// adjust volume properly.
|
// adjust volume properly.
|
||||||
leftvol =
|
leftvol =
|
||||||
volume - ((volume*seperation*seperation) >> 16); ///(256*256);
|
volume - ((volume*seperation*seperation) >> 16); ///(256*256);
|
||||||
seperation = seperation - 257;
|
seperation = seperation - 257;
|
||||||
rightvol =
|
rightvol =
|
||||||
volume - ((volume*seperation*seperation) >> 16);
|
volume - ((volume*seperation*seperation) >> 16);
|
||||||
|
|
||||||
// Sanity check, clamp volume.
|
// Sanity check, clamp volume.
|
||||||
if (rightvol < 0 || rightvol > 127)
|
if (rightvol < 0 || rightvol > 127)
|
||||||
I_Error("rightvol out of bounds");
|
I_Error("rightvol out of bounds");
|
||||||
|
|
||||||
if (leftvol < 0 || leftvol > 127)
|
if (leftvol < 0 || leftvol > 127)
|
||||||
I_Error("leftvol out of bounds");
|
I_Error("leftvol out of bounds");
|
||||||
|
|
||||||
// Get the proper lookup table piece
|
// Get the proper lookup table piece
|
||||||
// for this volume level???
|
// for this volume level???
|
||||||
@ -321,10 +321,10 @@ void I_SetChannels()
|
|||||||
// Init internal lookups (raw data, mixing buffer, channels).
|
// Init internal lookups (raw data, mixing buffer, channels).
|
||||||
// This function sets up internal lookups used during
|
// This function sets up internal lookups used during
|
||||||
// the mixing process.
|
// the mixing process.
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
int* steptablemid = steptable + 128;
|
int* steptablemid = steptable + 128;
|
||||||
|
|
||||||
// Okay, reset internal mixing channels to zero.
|
// Okay, reset internal mixing channels to zero.
|
||||||
for (i=0; i<NUM_CHANNELS; i++)
|
for (i=0; i<NUM_CHANNELS; i++)
|
||||||
@ -332,8 +332,8 @@ void I_SetChannels()
|
|||||||
channels[i] = 0;
|
channels[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=-128 ; i<128 ; i++)
|
// for (i=-128 ; i<128 ; i++)
|
||||||
steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
|
// steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
|
||||||
|
|
||||||
// Generates volume lookup tables
|
// Generates volume lookup tables
|
||||||
// which also turn the unsigned samples
|
// which also turn the unsigned samples
|
||||||
@ -341,7 +341,7 @@ void I_SetChannels()
|
|||||||
for (i=0 ; i<128 ; i++)
|
for (i=0 ; i<128 ; i++)
|
||||||
for (j=0 ; j<256 ; j++)
|
for (j=0 ; j<256 ; j++)
|
||||||
vol_lookup[i*256+j] = (i*(j-128)*256)/127;
|
vol_lookup[i*256+j] = (i*(j-128)*256)/127;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void I_SetSfxVolume(int volume)
|
void I_SetSfxVolume(int volume)
|
||||||
@ -428,19 +428,19 @@ void I_UpdateSound( void )
|
|||||||
|
|
||||||
// Mix current sound data.
|
// Mix current sound data.
|
||||||
// Data, from raw sound, for right and left.
|
// Data, from raw sound, for right and left.
|
||||||
register unsigned int sample;
|
register unsigned int sample;
|
||||||
register int dl;
|
register int dl;
|
||||||
register int dr;
|
register int dr;
|
||||||
|
|
||||||
// Pointers in global mixbuffer, left, right, end.
|
// Pointers in global mixbuffer, left, right, end.
|
||||||
signed short* leftout;
|
signed short* leftout;
|
||||||
signed short* rightout;
|
signed short* rightout;
|
||||||
signed short* leftend;
|
signed short* leftend;
|
||||||
// Step in mixbuffer, left and right, thus two.
|
// Step in mixbuffer, left and right, thus two.
|
||||||
int step;
|
int step;
|
||||||
|
|
||||||
// Mixing channel index.
|
// Mixing channel index.
|
||||||
int chan;
|
int chan;
|
||||||
|
|
||||||
// Left and right channel
|
// Left and right channel
|
||||||
// are in global mixbuffer, alternating.
|
// are in global mixbuffer, alternating.
|
||||||
@ -457,65 +457,65 @@ void I_UpdateSound( void )
|
|||||||
// that is 512 values for two channels.
|
// that is 512 values for two channels.
|
||||||
while (leftout != leftend)
|
while (leftout != leftend)
|
||||||
{
|
{
|
||||||
// Reset left/right value.
|
// Reset left/right value.
|
||||||
dl = 0;
|
dl = 0;
|
||||||
dr = 0;
|
dr = 0;
|
||||||
|
|
||||||
// Love thy L2 chache - made this a loop.
|
// Love thy L2 chache - made this a loop.
|
||||||
// Now more channels could be set at compile time
|
// Now more channels could be set at compile time
|
||||||
// as well. Thus loop those channels.
|
// as well. Thus loop those channels.
|
||||||
for ( chan = 0; chan < NUM_CHANNELS; chan++ )
|
for ( chan = 0; chan < NUM_CHANNELS; chan++ )
|
||||||
{
|
{
|
||||||
// Check channel, if active.
|
// Check channel, if active.
|
||||||
if (channels[ chan ])
|
if (channels[ chan ])
|
||||||
{
|
{
|
||||||
// Get the raw data from the channel.
|
// Get the raw data from the channel.
|
||||||
sample = *channels[ chan ];
|
sample = *channels[ chan ];
|
||||||
// Add left and right part
|
// Add left and right part
|
||||||
// for this channel (sound)
|
// for this channel (sound)
|
||||||
// to the current data.
|
// to the current data.
|
||||||
// Adjust volume accordingly.
|
// Adjust volume accordingly.
|
||||||
dl += channelleftvol_lookup[ chan ][sample];
|
dl += channelleftvol_lookup[ chan ][sample];
|
||||||
dr += channelrightvol_lookup[ chan ][sample];
|
dr += channelrightvol_lookup[ chan ][sample];
|
||||||
|
|
||||||
channelstepremainder[ chan ] += channelstep[ chan ];
|
channelstepremainder[ chan ] += channelstep[ chan ];
|
||||||
|
|
||||||
channels[ chan ] += channelstepremainder[ chan ] >> 16;
|
channels[ chan ] += channelstepremainder[ chan ] >> 16;
|
||||||
|
|
||||||
channelstepremainder[ chan ] &= 65536-1;
|
channelstepremainder[ chan ] &= 65536-1;
|
||||||
|
|
||||||
// Check whether we are done.
|
// Check whether we are done.
|
||||||
if (channels[ chan ] >= channelsend[ chan ])
|
if (channels[ chan ] >= channelsend[ chan ])
|
||||||
channels[ chan ] = 0;
|
channels[ chan ] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clamp to range. Left hardware channel.
|
// Clamp to range. Left hardware channel.
|
||||||
// Has been char instead of short.
|
// Has been char instead of short.
|
||||||
// if (dl > 127) *leftout = 127;
|
// if (dl > 127) *leftout = 127;
|
||||||
// else if (dl < -128) *leftout = -128;
|
// else if (dl < -128) *leftout = -128;
|
||||||
// else *leftout = dl;
|
// else *leftout = dl;
|
||||||
|
|
||||||
if (dl > 0x7fff)
|
if (dl > 0x7fff)
|
||||||
*leftout = 0x7fff;
|
*leftout = 0x7fff;
|
||||||
else if (dl < -0x8000)
|
else if (dl < -0x8000)
|
||||||
*leftout = -0x8000;
|
*leftout = -0x8000;
|
||||||
else
|
else
|
||||||
*leftout = dl;
|
*leftout = dl;
|
||||||
|
|
||||||
// Same for right hardware channel.
|
// Same for right hardware channel.
|
||||||
if (dr > 0x7fff)
|
if (dr > 0x7fff)
|
||||||
*rightout = 0x7fff;
|
*rightout = 0x7fff;
|
||||||
else if (dr < -0x8000)
|
else if (dr < -0x8000)
|
||||||
*rightout = -0x8000;
|
*rightout = -0x8000;
|
||||||
else
|
else
|
||||||
*rightout = dr;
|
*rightout = dr;
|
||||||
|
|
||||||
// Increment current pointers in mixbuffer.
|
// Increment current pointers in mixbuffer.
|
||||||
leftout += step;
|
leftout += step;
|
||||||
rightout += step;
|
rightout += step;
|
||||||
}
|
}
|
||||||
I_SubmitSound(mixbuffer);
|
// I_SubmitSound(mixbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ void I_InitSound()
|
|||||||
{
|
{
|
||||||
// Load data from WAD file.
|
// Load data from WAD file.
|
||||||
S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] );
|
S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Previously loaded already?
|
// Previously loaded already?
|
||||||
@ -603,11 +603,11 @@ void I_InitSound()
|
|||||||
// Still no music done.
|
// Still no music done.
|
||||||
// Remains. Dummies.
|
// Remains. Dummies.
|
||||||
//
|
//
|
||||||
void I_InitMusic(void) { }
|
void I_InitMusic(void) { }
|
||||||
void I_ShutdownMusic(void) { }
|
void I_ShutdownMusic(void) { }
|
||||||
|
|
||||||
static int looping=0;
|
static int looping=0;
|
||||||
static int musicdies=-1;
|
static int musicdies=-1;
|
||||||
|
|
||||||
void I_PlaySong(int handle, int looping)
|
void I_PlaySong(int handle, int looping)
|
||||||
{
|
{
|
||||||
|
@ -26,8 +26,6 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
//#include "SDL.h"
|
|
||||||
//#include "SDL_timer.h"
|
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "m_misc.h"
|
#include "m_misc.h"
|
||||||
@ -39,36 +37,23 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
|
|||||||
|
|
||||||
|
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
|
||||||
#include "kolibri.h"
|
#include "kolibri.h"
|
||||||
|
|
||||||
int mb_used = 6;
|
int mb_used = 8;
|
||||||
|
|
||||||
|
|
||||||
int I_strncasecmp(char *str1, char *str2, int len)
|
|
||||||
{
|
|
||||||
char c1, c2;
|
|
||||||
|
|
||||||
while ( *str1 && *str2 && len-- ) {
|
|
||||||
c1 = *str1++;
|
|
||||||
c2 = *str2++;
|
|
||||||
if ( toupper(c1) != toupper(c2) )
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
I_Tactile
|
I_Tactile
|
||||||
( int on,
|
( int on,
|
||||||
int off,
|
int off,
|
||||||
int total )
|
int total )
|
||||||
{
|
{
|
||||||
// UNUSED.
|
// UNUSED.
|
||||||
on = off = total = 0;
|
on = off = total = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ticcmd_t emptycmd;
|
ticcmd_t emptycmd;
|
||||||
ticcmd_t* I_BaseTiccmd(void)
|
ticcmd_t* I_BaseTiccmd(void)
|
||||||
{
|
{
|
||||||
return &emptycmd;
|
return &emptycmd;
|
||||||
}
|
}
|
||||||
@ -79,7 +64,7 @@ int I_GetHeapSize (void)
|
|||||||
return mb_used*1024*1024;
|
return mb_used*1024*1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte* I_ZoneBase (int* size)
|
byte* I_ZoneBase (int* size)
|
||||||
{
|
{
|
||||||
*size = mb_used*1024*1024;
|
*size = mb_used*1024*1024;
|
||||||
return (byte *) UserAlloc(*size);
|
return (byte *) UserAlloc(*size);
|
||||||
@ -91,21 +76,17 @@ byte* I_ZoneBase (int* size)
|
|||||||
// returns time in 1/35 second tics
|
// returns time in 1/35 second tics
|
||||||
//
|
//
|
||||||
|
|
||||||
__declspec(dllimport) unsigned int __stdcall GetTickCount(void);
|
|
||||||
|
|
||||||
int I_GetTime (void)
|
int I_GetTime (void)
|
||||||
{
|
{
|
||||||
unsigned int tm;
|
unsigned int tm;
|
||||||
// _asm
|
_asm
|
||||||
// {
|
{ push ebx
|
||||||
// mov eax, 26
|
mov eax, 26
|
||||||
// mov ebx, 9
|
mov ebx, 9
|
||||||
// int 0x40
|
int 0x40
|
||||||
// mov [tm], eax
|
mov dword ptr [tm], eax
|
||||||
// };
|
pop ebx
|
||||||
|
};
|
||||||
tm=GetTickCount()/10;
|
|
||||||
|
|
||||||
|
|
||||||
return (tm*TICRATE)/100;
|
return (tm*TICRATE)/100;
|
||||||
}
|
}
|
||||||
@ -118,7 +99,7 @@ int I_GetTime (void)
|
|||||||
void I_Init (void)
|
void I_Init (void)
|
||||||
{
|
{
|
||||||
I_InitGraphics();
|
I_InitGraphics();
|
||||||
I_InitSound();
|
// I_InitSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -148,15 +129,16 @@ void I_EndRead(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
byte* I_AllocLow(int length)
|
/***********
|
||||||
|
byte* I_AllocLow(int length)
|
||||||
{
|
{
|
||||||
byte* mem;
|
byte* mem;
|
||||||
|
|
||||||
mem = (byte *)malloc (length);
|
mem = (byte *)malloc (length);
|
||||||
memset (mem,0,length);
|
memset (mem,0,length);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// I_Error
|
// I_Error
|
||||||
@ -165,18 +147,18 @@ extern boolean demorecording;
|
|||||||
|
|
||||||
void I_Error (char *error, ...)
|
void I_Error (char *error, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
|
||||||
// Message first.
|
// Message first.
|
||||||
va_start (argptr,error);
|
va_start (argptr,error);
|
||||||
printf ("Error: ");
|
printf ("Error: ");
|
||||||
printf (argptr);
|
printf (error,argptr);
|
||||||
printf ("\n");
|
printf ("\n\r");
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
// Shutdown. Here might be other errors.
|
// Shutdown. Here might be other errors.
|
||||||
if (demorecording)
|
if (demorecording)
|
||||||
G_CheckDemoStatus();
|
G_CheckDemoStatus();
|
||||||
|
|
||||||
D_QuitNetGame ();
|
D_QuitNetGame ();
|
||||||
I_ShutdownGraphics();
|
I_ShutdownGraphics();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,58 +1,56 @@
|
|||||||
// Emacs style mode select -*- C++ -*-
|
// Emacs style mode select -*- C++ -*-
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// $Id:$
|
// $Id:$
|
||||||
//
|
//
|
||||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||||
//
|
//
|
||||||
// This source is available for distribution and/or modification
|
// This source is available for distribution and/or modification
|
||||||
// only under the terms of the DOOM Source Code License as
|
// only under the terms of the DOOM Source Code License as
|
||||||
// published by id Software. All rights reserved.
|
// published by id Software. All rights reserved.
|
||||||
//
|
//
|
||||||
// The source is distributed in the hope that it will be useful,
|
// The source is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// $Log:$
|
// $Log:$
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
// DESCRIPTION:
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static const char
|
static const char
|
||||||
rcsid[] = "$Id: m_argv.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
|
rcsid[] = "$Id: m_argv.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "i_system.h"
|
int myargc;
|
||||||
|
char** myargv;
|
||||||
int myargc;
|
|
||||||
char** myargv;
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// M_CheckParm
|
||||||
//
|
// Checks for the given parameter
|
||||||
// M_CheckParm
|
// in the program's command line arguments.
|
||||||
// Checks for the given parameter
|
// Returns the argument number (1 to argc-1)
|
||||||
// in the program's command line arguments.
|
// or 0 if not present
|
||||||
// Returns the argument number (1 to argc-1)
|
int M_CheckParm (char *check)
|
||||||
// or 0 if not present
|
{
|
||||||
int M_CheckParm (char *check)
|
int i;
|
||||||
{
|
|
||||||
int i;
|
for (i = 1;i<myargc;i++)
|
||||||
|
{
|
||||||
for (i = 1;i<myargc;i++)
|
if ( !strnicmp(check, myargv[i], strlen(check)) )
|
||||||
{
|
return i;
|
||||||
if ( !I_strncasecmp(check, myargv[i], strlen(check)) )
|
}
|
||||||
return i;
|
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
// $Log:$
|
// $Log:$
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
// DESCRIPTION:
|
||||||
// Main loop menu stuff.
|
// Main loop menu stuff.
|
||||||
// Default Config File.
|
// Default Config File.
|
||||||
// PCX Screenshots.
|
// PCX Screenshots.
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -29,8 +29,9 @@ rcsid[] = "$Id: m_misc.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
//#include "//kolibc.h"
|
||||||
|
|
||||||
extern int access(char *file, int mode);
|
//extern int access(char *file, int mode);
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
|
|
||||||
@ -60,36 +61,36 @@ extern int access(char *file, int mode);
|
|||||||
// Returns the final X coordinate
|
// Returns the final X coordinate
|
||||||
// HU_Init must have been called to init the font
|
// HU_Init must have been called to init the font
|
||||||
//
|
//
|
||||||
extern patch_t* hu_font[HU_FONTSIZE];
|
extern patch_t* hu_font[HU_FONTSIZE];
|
||||||
|
|
||||||
int
|
int
|
||||||
M_DrawText
|
M_DrawText
|
||||||
( int x,
|
( int x,
|
||||||
int y,
|
int y,
|
||||||
boolean direct,
|
boolean direct,
|
||||||
char* string )
|
char* string )
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
while (*string)
|
while (*string)
|
||||||
{
|
{
|
||||||
c = toupper(*string) - HU_FONTSTART;
|
c = toupper(*string) - HU_FONTSTART;
|
||||||
string++;
|
string++;
|
||||||
if (c < 0 || c> HU_FONTSIZE)
|
if (c < 0 || c> HU_FONTSIZE)
|
||||||
{
|
{
|
||||||
x += 4;
|
x += 4;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = SHORT (hu_font[c]->width);
|
w = SHORT (hu_font[c]->width);
|
||||||
if (x+w > SCREENWIDTH)
|
if (x+w > SCREENWIDTH)
|
||||||
break;
|
break;
|
||||||
if (direct)
|
if (direct)
|
||||||
V_DrawPatchDirect(x, y, 0, hu_font[c]);
|
V_DrawPatchDirect(x, y, 0, hu_font[c]);
|
||||||
else
|
else
|
||||||
V_DrawPatch(x, y, 0, hu_font[c]);
|
V_DrawPatch(x, y, 0, hu_font[c]);
|
||||||
x+=w;
|
x+=w;
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
@ -107,24 +108,24 @@ M_DrawText
|
|||||||
|
|
||||||
boolean
|
boolean
|
||||||
M_WriteFile
|
M_WriteFile
|
||||||
( char const* name,
|
( char const* name,
|
||||||
void* source,
|
void* source,
|
||||||
int length )
|
int length )
|
||||||
{
|
{
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
handle = fopen ( name, "wb");
|
handle = fopen ( name, "wb");
|
||||||
|
|
||||||
if (handle == NULL)
|
if (handle == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
count = fwrite (source, 1, length, handle);
|
// count = fwrite (source, 1, length, handle);
|
||||||
fclose (handle);
|
fclose (handle);
|
||||||
|
|
||||||
if (count < length)
|
if (count < length)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,26 +135,29 @@ M_WriteFile
|
|||||||
//
|
//
|
||||||
int
|
int
|
||||||
M_ReadFile
|
M_ReadFile
|
||||||
( char const* name,
|
( char const* name,
|
||||||
byte** buffer )
|
byte** buffer )
|
||||||
{
|
{
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
int count, length;
|
int count, length;
|
||||||
byte *buf;
|
byte *buf;
|
||||||
|
|
||||||
|
handle=0;
|
||||||
|
buf=0;
|
||||||
|
|
||||||
handle = fopen (name, "rb");
|
handle = fopen (name, "rb");
|
||||||
if (handle == NULL)
|
if (handle == NULL)
|
||||||
I_Error ("Couldn't read file %s", name);
|
I_Error ("Couldn't read file %s", name);
|
||||||
fseek(handle, 0, SEEK_END);
|
fseek(handle, 0, SEEK_END);
|
||||||
length = ftell(handle);
|
length = ftell(handle);
|
||||||
rewind(handle);
|
rewind(handle);
|
||||||
buf = Z_Malloc (length, PU_STATIC, NULL);
|
buf = Z_Malloc (length, PU_STATIC, NULL);
|
||||||
count = fread (buf, 1, length, handle);
|
count = fread (buf, 1, length, handle);
|
||||||
fclose (handle);
|
fclose (handle);
|
||||||
|
|
||||||
if (count < length)
|
if (count < length)
|
||||||
I_Error ("Couldn't read file %s", name);
|
I_Error ("Couldn't read file %s", name);
|
||||||
|
|
||||||
*buffer = buf;
|
*buffer = buf;
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
@ -162,61 +166,61 @@ M_ReadFile
|
|||||||
//
|
//
|
||||||
// DEFAULTS
|
// DEFAULTS
|
||||||
//
|
//
|
||||||
int usemouse;
|
int usemouse;
|
||||||
int usejoystick;
|
int usejoystick;
|
||||||
|
|
||||||
extern int key_right;
|
extern int key_right;
|
||||||
extern int key_left;
|
extern int key_left;
|
||||||
extern int key_up;
|
extern int key_up;
|
||||||
extern int key_down;
|
extern int key_down;
|
||||||
|
|
||||||
extern int key_strafeleft;
|
extern int key_strafeleft;
|
||||||
extern int key_straferight;
|
extern int key_straferight;
|
||||||
|
|
||||||
extern int key_fire;
|
extern int key_fire;
|
||||||
extern int key_use;
|
extern int key_use;
|
||||||
extern int key_strafe;
|
extern int key_strafe;
|
||||||
extern int key_speed;
|
extern int key_speed;
|
||||||
|
|
||||||
extern int mousebfire;
|
extern int mousebfire;
|
||||||
extern int mousebstrafe;
|
extern int mousebstrafe;
|
||||||
extern int mousebforward;
|
extern int mousebforward;
|
||||||
|
|
||||||
extern int joybfire;
|
extern int joybfire;
|
||||||
extern int joybstrafe;
|
extern int joybstrafe;
|
||||||
extern int joybuse;
|
extern int joybuse;
|
||||||
extern int joybspeed;
|
extern int joybspeed;
|
||||||
|
|
||||||
extern int viewwidth;
|
extern int viewwidth;
|
||||||
extern int viewheight;
|
extern int viewheight;
|
||||||
|
|
||||||
extern int mouseSensitivity;
|
extern int mouseSensitivity;
|
||||||
extern int showMessages;
|
extern int showMessages;
|
||||||
|
|
||||||
extern int detailLevel;
|
extern int detailLevel;
|
||||||
|
|
||||||
extern int screenblocks;
|
extern int screenblocks;
|
||||||
|
|
||||||
extern int showMessages;
|
extern int showMessages;
|
||||||
|
|
||||||
// machine-independent sound params
|
// machine-independent sound params
|
||||||
extern int numChannels;
|
extern int numChannels;
|
||||||
|
|
||||||
|
|
||||||
extern char* chat_macros[];
|
extern char* chat_macros[];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
int* location;
|
int* location;
|
||||||
int defaultvalue;
|
int defaultvalue;
|
||||||
int scantranslate; // PC scan code hack
|
int scantranslate; // PC scan code hack
|
||||||
int untranslated; // lousy hack
|
int untranslated; // lousy hack
|
||||||
} default_t;
|
} default_t;
|
||||||
|
|
||||||
default_t defaults[] =
|
default_t defaults[] =
|
||||||
{
|
{
|
||||||
{"mouse_sensitivity",&mouseSensitivity, 5},
|
{"mouse_sensitivity",&mouseSensitivity, 5},
|
||||||
{"sfx_volume",&snd_SfxVolume, 8},
|
{"sfx_volume",&snd_SfxVolume, 8},
|
||||||
@ -228,6 +232,12 @@ default_t defaults[] =
|
|||||||
{"key_left",&key_left, KEY_LEFTARROW},
|
{"key_left",&key_left, KEY_LEFTARROW},
|
||||||
{"key_up",&key_up, KEY_UPARROW},
|
{"key_up",&key_up, KEY_UPARROW},
|
||||||
{"key_down",&key_down, KEY_DOWNARROW},
|
{"key_down",&key_down, KEY_DOWNARROW},
|
||||||
|
|
||||||
|
// {"key_right",&key_right, KEY_D},
|
||||||
|
// {"key_left",&key_left, KEY_A},
|
||||||
|
// {"key_up",&key_up, KEY_W},
|
||||||
|
// {"key_down",&key_down, KEY_S},
|
||||||
|
|
||||||
{"key_strafeleft",&key_strafeleft, ','},
|
{"key_strafeleft",&key_strafeleft, ','},
|
||||||
{"key_straferight",&key_straferight, '.'},
|
{"key_straferight",&key_straferight, '.'},
|
||||||
|
|
||||||
@ -271,8 +281,8 @@ default_t defaults[] =
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int numdefaults;
|
int numdefaults;
|
||||||
char* defaultfile;
|
char* defaultfile;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -280,27 +290,27 @@ char* defaultfile;
|
|||||||
//
|
//
|
||||||
void M_SaveDefaults (void)
|
void M_SaveDefaults (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int v;
|
int v;
|
||||||
FILE* f;
|
FILE* f;
|
||||||
|
|
||||||
f = fopen (defaultfile, "w");
|
f = fopen (defaultfile, "w");
|
||||||
if (!f)
|
if (!f)
|
||||||
return; // can't write the file, but don't complain
|
return; // can't write the file, but don't complain
|
||||||
|
|
||||||
for (i=0 ; i<numdefaults ; i++)
|
for (i=0 ; i<numdefaults ; i++)
|
||||||
{
|
{
|
||||||
if (defaults[i].defaultvalue > -0xfff
|
if (defaults[i].defaultvalue > -0xfff
|
||||||
&& defaults[i].defaultvalue < 0xfff)
|
&& defaults[i].defaultvalue < 0xfff)
|
||||||
{
|
{
|
||||||
v = *defaults[i].location;
|
v = *defaults[i].location;
|
||||||
printf ("%s\t\t%i\n",defaults[i].name,v);
|
printf ("%s\t\t%i\n",defaults[i].name,v);
|
||||||
} else {
|
} else {
|
||||||
printf ("%s\t\t\"%s\"\n",defaults[i].name,
|
printf ("%s\t\t\"%s\"\n",defaults[i].name,
|
||||||
* (char **) (defaults[i].location));
|
* (char **) (defaults[i].location));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,73 +318,88 @@ void M_SaveDefaults (void)
|
|||||||
//
|
//
|
||||||
// M_LoadDefaults
|
// M_LoadDefaults
|
||||||
//
|
//
|
||||||
extern byte scantokey[128];
|
extern byte scantokey[128];
|
||||||
|
|
||||||
|
size_t FileSize(FILE *handle);
|
||||||
|
|
||||||
void M_LoadDefaults (void)
|
void M_LoadDefaults (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int len;
|
int len;
|
||||||
FILE* f;
|
FILE* f;
|
||||||
char def[80];
|
char def[80];
|
||||||
char strparm[100];
|
char strparm[100];
|
||||||
char* newstring;
|
char* newstring;
|
||||||
int parm;
|
int parm;
|
||||||
boolean isstring;
|
boolean isstring;
|
||||||
|
char *buf;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
size_t val;
|
||||||
// set everything to base values
|
// set everything to base values
|
||||||
numdefaults = sizeof(defaults)/sizeof(defaults[0]);
|
numdefaults = sizeof(defaults)/sizeof(defaults[0]);
|
||||||
for (i=0 ; i<numdefaults ; i++)
|
for (i=0 ; i<numdefaults ; i++)
|
||||||
*defaults[i].location = defaults[i].defaultvalue;
|
*defaults[i].location = defaults[i].defaultvalue;
|
||||||
|
|
||||||
// check for a custom default file
|
// check for a custom default file
|
||||||
i = M_CheckParm ("-config");
|
i = M_CheckParm ("-config");
|
||||||
if (i && i<myargc-1)
|
if (i && i<myargc-1)
|
||||||
{
|
{
|
||||||
defaultfile = myargv[i+1];
|
defaultfile = myargv[i+1];
|
||||||
// __libclog_printf (" default file: %s\n",defaultfile);
|
// __libclog_printf (" default file: %s\n",defaultfile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
defaultfile = basedefault;
|
defaultfile = basedefault;
|
||||||
/**********
|
|
||||||
// read the file in, overriding any set defaults
|
// read the file in, overriding any set defaults
|
||||||
f = fopen (defaultfile, "r");
|
f = fopen (defaultfile, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
while (!feof(f))
|
len=FileSize(f)+1;
|
||||||
{
|
buf = malloc(len);
|
||||||
isstring = false;
|
memset(buf,0,len);
|
||||||
if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2)
|
val = fread(buf,1,len,f);
|
||||||
{
|
fclose (f);
|
||||||
if (strparm[0] == '"')
|
|
||||||
{
|
p = buf;
|
||||||
// get a string default
|
|
||||||
isstring = true;
|
while(*p)
|
||||||
len = strlen(strparm);
|
{
|
||||||
newstring = (char *) malloc(len);
|
isstring = false;
|
||||||
strparm[len-1] = 0;
|
|
||||||
strcpy(newstring, strparm+1);
|
if (sscanf (p, "%79s %[^\n]\n", def, strparm) == 2)
|
||||||
}
|
{
|
||||||
else if (strparm[0] == '0' && strparm[1] == 'x')
|
if (strparm[0] == '"')
|
||||||
sscanf(strparm+2, "%x", &parm);
|
{
|
||||||
else
|
// get a string default
|
||||||
sscanf(strparm, "%i", &parm);
|
isstring = true;
|
||||||
for (i=0 ; i<numdefaults ; i++)
|
len = strlen(strparm);
|
||||||
if (!strcmp(def, defaults[i].name))
|
newstring = (char *) malloc(len);
|
||||||
{
|
strparm[len-1] = 0;
|
||||||
if (!isstring)
|
strcpy(newstring, strparm+1);
|
||||||
*defaults[i].location = parm;
|
}
|
||||||
else
|
else
|
||||||
*defaults[i].location =
|
if (strparm[0] == '0' && strparm[1] == 'x')
|
||||||
(int) newstring;
|
sscanf(strparm+2, "%x", &parm);
|
||||||
break;
|
else
|
||||||
}
|
sscanf(strparm, "%i", &parm);
|
||||||
}
|
for (i=0 ; i<numdefaults ; i++)
|
||||||
}
|
if (!strcmp(def, defaults[i].name))
|
||||||
|
{
|
||||||
fclose (f);
|
if (!isstring)
|
||||||
}
|
*defaults[i].location = parm;
|
||||||
**********/
|
else
|
||||||
}
|
*defaults[i].location = (int) newstring;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
p=strchr(p, '\n')+1;
|
||||||
|
};
|
||||||
|
free(buf);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -384,28 +409,28 @@ void M_LoadDefaults (void)
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char manufacturer;
|
char manufacturer;
|
||||||
char version;
|
char version;
|
||||||
char encoding;
|
char encoding;
|
||||||
char bits_per_pixel;
|
char bits_per_pixel;
|
||||||
|
|
||||||
unsigned short xmin;
|
unsigned short xmin;
|
||||||
unsigned short ymin;
|
unsigned short ymin;
|
||||||
unsigned short xmax;
|
unsigned short xmax;
|
||||||
unsigned short ymax;
|
unsigned short ymax;
|
||||||
|
|
||||||
unsigned short hres;
|
unsigned short hres;
|
||||||
unsigned short vres;
|
unsigned short vres;
|
||||||
|
|
||||||
unsigned char palette[48];
|
unsigned char palette[48];
|
||||||
|
|
||||||
char reserved;
|
char reserved;
|
||||||
char color_planes;
|
char color_planes;
|
||||||
unsigned short bytes_per_line;
|
unsigned short bytes_per_line;
|
||||||
unsigned short palette_type;
|
unsigned short palette_type;
|
||||||
|
|
||||||
char filler[58];
|
char filler[58];
|
||||||
unsigned char data; // unbounded
|
unsigned char data; // unbounded
|
||||||
} pcx_t;
|
} pcx_t;
|
||||||
|
|
||||||
|
|
||||||
@ -414,23 +439,23 @@ typedef struct
|
|||||||
//
|
//
|
||||||
void
|
void
|
||||||
WritePCXfile
|
WritePCXfile
|
||||||
( char* filename,
|
( char* filename,
|
||||||
byte* data,
|
byte* data,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
byte* palette )
|
byte* palette )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int length;
|
int length;
|
||||||
pcx_t* pcx;
|
pcx_t* pcx;
|
||||||
byte* pack;
|
byte* pack;
|
||||||
|
|
||||||
pcx = Z_Malloc (width*height*2+1000, PU_STATIC, NULL);
|
pcx = Z_Malloc (width*height*2+1000, PU_STATIC, NULL);
|
||||||
|
|
||||||
pcx->manufacturer = 0x0a; // PCX id
|
pcx->manufacturer = 0x0a; // PCX id
|
||||||
pcx->version = 5; // 256 color
|
pcx->version = 5; // 256 color
|
||||||
pcx->encoding = 1; // uncompressed
|
pcx->encoding = 1; // uncompressed
|
||||||
pcx->bits_per_pixel = 8; // 256 color
|
pcx->bits_per_pixel = 8; // 256 color
|
||||||
pcx->xmin = 0;
|
pcx->xmin = 0;
|
||||||
pcx->ymin = 0;
|
pcx->ymin = 0;
|
||||||
pcx->xmax = SHORT(width-1);
|
pcx->xmax = SHORT(width-1);
|
||||||
@ -438,30 +463,30 @@ WritePCXfile
|
|||||||
pcx->hres = SHORT(width);
|
pcx->hres = SHORT(width);
|
||||||
pcx->vres = SHORT(height);
|
pcx->vres = SHORT(height);
|
||||||
memset (pcx->palette,0,sizeof(pcx->palette));
|
memset (pcx->palette,0,sizeof(pcx->palette));
|
||||||
pcx->color_planes = 1; // chunky image
|
pcx->color_planes = 1; // chunky image
|
||||||
pcx->bytes_per_line = SHORT(width);
|
pcx->bytes_per_line = SHORT(width);
|
||||||
pcx->palette_type = SHORT(2); // not a grey scale
|
pcx->palette_type = SHORT(2); // not a grey scale
|
||||||
memset (pcx->filler,0,sizeof(pcx->filler));
|
memset (pcx->filler,0,sizeof(pcx->filler));
|
||||||
|
|
||||||
|
|
||||||
// pack the image
|
// pack the image
|
||||||
pack = &pcx->data;
|
pack = &pcx->data;
|
||||||
|
|
||||||
for (i=0 ; i<width*height ; i++)
|
for (i=0 ; i<width*height ; i++)
|
||||||
{
|
{
|
||||||
if ( (*data & 0xc0) != 0xc0)
|
if ( (*data & 0xc0) != 0xc0)
|
||||||
*pack++ = *data++;
|
*pack++ = *data++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*pack++ = 0xc1;
|
*pack++ = 0xc1;
|
||||||
*pack++ = *data++;
|
*pack++ = *data++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the palette
|
// write the palette
|
||||||
*pack++ = 0x0c; // palette ID byte
|
*pack++ = 0x0c; // palette ID byte
|
||||||
for (i=0 ; i<768 ; i++)
|
for (i=0 ; i<768 ; i++)
|
||||||
*pack++ = *palette++;
|
*pack++ = *palette++;
|
||||||
|
|
||||||
// write output file
|
// write output file
|
||||||
length = pack - (byte *)pcx;
|
length = pack - (byte *)pcx;
|
||||||
@ -476,9 +501,9 @@ WritePCXfile
|
|||||||
//
|
//
|
||||||
void M_ScreenShot (void)
|
void M_ScreenShot (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
byte* linear;
|
byte* linear;
|
||||||
char lbmname[12];
|
char lbmname[12];
|
||||||
|
|
||||||
// munge planar buffer to linear
|
// munge planar buffer to linear
|
||||||
linear = screens[2];
|
linear = screens[2];
|
||||||
@ -486,22 +511,22 @@ void M_ScreenShot (void)
|
|||||||
|
|
||||||
// find a file name to save it to
|
// find a file name to save it to
|
||||||
strcpy(lbmname,"DOOM00.pcx");
|
strcpy(lbmname,"DOOM00.pcx");
|
||||||
|
|
||||||
for (i=0 ; i<=99 ; i++)
|
for (i=0 ; i<=99 ; i++)
|
||||||
{
|
{
|
||||||
lbmname[4] = i/10 + '0';
|
lbmname[4] = i/10 + '0';
|
||||||
lbmname[5] = i%10 + '0';
|
lbmname[5] = i%10 + '0';
|
||||||
if (access(lbmname,0) == -1)
|
if (access(lbmname,0) == -1)
|
||||||
break; // file doesn't exist
|
break; // file doesn't exist
|
||||||
}
|
}
|
||||||
if (i==100)
|
if (i==100)
|
||||||
I_Error ("M_ScreenShot: Couldn't create a PCX");
|
I_Error ("M_ScreenShot: Couldn't create a PCX");
|
||||||
|
|
||||||
// save the pcx file
|
// save the pcx file
|
||||||
WritePCXfile (lbmname, linear,
|
WritePCXfile (lbmname, linear,
|
||||||
SCREENWIDTH, SCREENHEIGHT,
|
SCREENWIDTH, SCREENHEIGHT,
|
||||||
W_CacheLumpName ("PLAYPAL",PU_CACHE));
|
W_CacheLumpName ("PLAYPAL",PU_CACHE));
|
||||||
|
|
||||||
players[consoleplayer].message = "screen shot";
|
players[consoleplayer].message = "screen shot";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
|
|||||||
#include "m_swap.h"
|
#include "m_swap.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Not needed with big endian.
|
||||||
|
#ifndef __BIG_ENDIAN__
|
||||||
|
|
||||||
// Swap 16bit, that is, MSB and LSB byte.
|
// Swap 16bit, that is, MSB and LSB byte.
|
||||||
unsigned short SwapSHORT(unsigned short x)
|
unsigned short SwapSHORT(unsigned short x)
|
||||||
{
|
{
|
||||||
@ -49,3 +52,6 @@ unsigned long SwapLONG( unsigned long x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -51,37 +51,37 @@ void WriteDebug(char *);
|
|||||||
const char snd_prefixen[]
|
const char snd_prefixen[]
|
||||||
= { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 'M', 'M', 'S', 'S', 'S' };
|
= { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 'M', 'M', 'S', 'S', 'S' };
|
||||||
|
|
||||||
#define S_MAX_VOLUME 127
|
#define S_MAX_VOLUME 127
|
||||||
|
|
||||||
// when to clip out sounds
|
// when to clip out sounds
|
||||||
// Does not fit the large outdoor areas.
|
// Does not fit the large outdoor areas.
|
||||||
#define S_CLIPPING_DIST (1200*0x10000)
|
#define S_CLIPPING_DIST (1200*0x10000)
|
||||||
|
|
||||||
// Distance tp origin when sounds should be maxed out.
|
// Distance tp origin when sounds should be maxed out.
|
||||||
// This should relate to movement clipping resolution
|
// This should relate to movement clipping resolution
|
||||||
// (see BLOCKMAP handling).
|
// (see BLOCKMAP handling).
|
||||||
// Originally: (200*0x10000).
|
// Originally: (200*0x10000).
|
||||||
#define S_CLOSE_DIST (160*0x10000)
|
#define S_CLOSE_DIST (160*0x10000)
|
||||||
|
|
||||||
|
|
||||||
#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS)
|
#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS)
|
||||||
|
|
||||||
// Adjustable by menu.
|
// Adjustable by menu.
|
||||||
#define NORM_VOLUME snd_MaxVolume
|
#define NORM_VOLUME snd_MaxVolume
|
||||||
|
|
||||||
#define NORM_PITCH 128
|
#define NORM_PITCH 128
|
||||||
#define NORM_PRIORITY 64
|
#define NORM_PRIORITY 64
|
||||||
#define NORM_SEP 128
|
#define NORM_SEP 128
|
||||||
|
|
||||||
#define S_PITCH_PERTURB 1
|
#define S_PITCH_PERTURB 1
|
||||||
#define S_STEREO_SWING (96*0x10000)
|
#define S_STEREO_SWING (96*0x10000)
|
||||||
|
|
||||||
// percent attenuation from front to back
|
// percent attenuation from front to back
|
||||||
#define S_IFRACVOL 30
|
#define S_IFRACVOL 30
|
||||||
|
|
||||||
#define NA 0
|
#define NA 0
|
||||||
//#define S_NUMCHANNELS 2
|
//#define S_NUMCHANNELS 2
|
||||||
#define NUM_CHANNELS 16
|
#define NUM_CHANNELS 16
|
||||||
|
|
||||||
// Current music/sfx card - index useless
|
// Current music/sfx card - index useless
|
||||||
// w/o a reference LUT in a sound module.
|
// w/o a reference LUT in a sound module.
|
||||||
@ -95,42 +95,42 @@ extern int snd_DesiredSfxDevice;
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// sound information (if null, channel avail.)
|
// sound information (if null, channel avail.)
|
||||||
sfxinfo_t* sfxinfo;
|
sfxinfo_t* sfxinfo;
|
||||||
|
|
||||||
// origin of sound
|
// origin of sound
|
||||||
void* origin;
|
void* origin;
|
||||||
|
|
||||||
// handle of the sound being played
|
// handle of the sound being played
|
||||||
int handle;
|
int handle;
|
||||||
|
|
||||||
} channel_t;
|
} channel_t;
|
||||||
|
|
||||||
|
|
||||||
// the set of channels available
|
// the set of channels available
|
||||||
static channel_t* channels;
|
static channel_t* channels;
|
||||||
|
|
||||||
// These are not used, but should be (menu).
|
// These are not used, but should be (menu).
|
||||||
// Maximum volume of a sound effect.
|
// Maximum volume of a sound effect.
|
||||||
// Internal default is max out of 0-15.
|
// Internal default is max out of 0-15.
|
||||||
int snd_SfxVolume = 80;
|
int snd_SfxVolume = 80;
|
||||||
|
|
||||||
// Maximum volume of music. Useless so far.
|
// Maximum volume of music. Useless so far.
|
||||||
int snd_MusicVolume = 80;
|
int snd_MusicVolume = 80;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// whether songs are mus_paused
|
// whether songs are mus_paused
|
||||||
static boolean mus_paused;
|
static boolean mus_paused;
|
||||||
|
|
||||||
// music currently being played
|
// music currently being played
|
||||||
static musicinfo_t* mus_playing=0;
|
static musicinfo_t* mus_playing=0;
|
||||||
|
|
||||||
// following is set
|
// following is set
|
||||||
// by the defaults code in M_misc:
|
// by the defaults code in M_misc:
|
||||||
// number of channels available
|
// number of channels available
|
||||||
int numChannels;
|
int numChannels;
|
||||||
|
|
||||||
static int nextcleanup;
|
static int nextcleanup;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -139,18 +139,18 @@ static int nextcleanup;
|
|||||||
//
|
//
|
||||||
int
|
int
|
||||||
S_getChannel
|
S_getChannel
|
||||||
( void* origin,
|
( void* origin,
|
||||||
sfxinfo_t* sfxinfo,
|
sfxinfo_t* sfxinfo,
|
||||||
int sfxid );
|
int sfxid );
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
S_AdjustSoundParams
|
S_AdjustSoundParams
|
||||||
( mobj_t* listener,
|
( mobj_t* listener,
|
||||||
mobj_t* source,
|
mobj_t* source,
|
||||||
int* vol,
|
int* vol,
|
||||||
int* sep,
|
int* sep,
|
||||||
int* pitch );
|
int* pitch );
|
||||||
|
|
||||||
void S_StopChannel(int cnum);
|
void S_StopChannel(int cnum);
|
||||||
|
|
||||||
@ -162,14 +162,14 @@ void S_StopChannel(int cnum);
|
|||||||
// allocates channel buffer, sets S_sfx lookup.
|
// allocates channel buffer, sets S_sfx lookup.
|
||||||
//
|
//
|
||||||
void S_Init
|
void S_Init
|
||||||
( int sfxVolume,
|
( int sfxVolume,
|
||||||
int musicVolume )
|
int musicVolume )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
printf("S_Init: default sfx volume %d\n", sfxVolume);
|
printf("S_Init: default sfx volume %d\n", sfxVolume);
|
||||||
|
|
||||||
I_CreateSound();
|
//I_CreateSound();
|
||||||
numChannels = NUM_CHANNELS;
|
numChannels = NUM_CHANNELS;
|
||||||
|
|
||||||
// Whatever these did with DMX, these are rather dummies now.
|
// Whatever these did with DMX, these are rather dummies now.
|
||||||
@ -217,37 +217,37 @@ void S_Start(void)
|
|||||||
mus_paused = 0;
|
mus_paused = 0;
|
||||||
|
|
||||||
if (gamemode == commercial)
|
if (gamemode == commercial)
|
||||||
mnum = mus_runnin + gamemap - 1;
|
mnum = mus_runnin + gamemap - 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int spmus[]=
|
int spmus[]=
|
||||||
{
|
{
|
||||||
// Song - Who? - Where?
|
// Song - Who? - Where?
|
||||||
mus_e3m4, // American e4m1
|
mus_e3m4, // American e4m1
|
||||||
mus_e3m2, // Romero e4m2
|
mus_e3m2, // Romero e4m2
|
||||||
mus_e3m3, // Shawn e4m3
|
mus_e3m3, // Shawn e4m3
|
||||||
mus_e1m5, // American e4m4
|
mus_e1m5, // American e4m4
|
||||||
mus_e2m7, // Tim e4m5
|
mus_e2m7, // Tim e4m5
|
||||||
mus_e2m4, // Romero e4m6
|
mus_e2m4, // Romero e4m6
|
||||||
mus_e2m6, // J.Anderson e4m7 CHIRON.WAD
|
mus_e2m6, // J.Anderson e4m7 CHIRON.WAD
|
||||||
mus_e2m5, // Shawn e4m8
|
mus_e2m5, // Shawn e4m8
|
||||||
mus_e1m9 // Tim e4m9
|
mus_e1m9 // Tim e4m9
|
||||||
};
|
};
|
||||||
|
|
||||||
if (gameepisode < 4)
|
if (gameepisode < 4)
|
||||||
mnum = mus_e1m1 + (gameepisode-1)*9 + gamemap-1;
|
mnum = mus_e1m1 + (gameepisode-1)*9 + gamemap-1;
|
||||||
else
|
else
|
||||||
mnum = spmus[gamemap-1];
|
mnum = spmus[gamemap-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK FOR COMMERCIAL
|
// HACK FOR COMMERCIAL
|
||||||
// if (commercial && mnum > mus_e3m9)
|
// if (commercial && mnum > mus_e3m9)
|
||||||
// mnum -= mus_e3m9;
|
// mnum -= mus_e3m9;
|
||||||
|
|
||||||
S_ChangeMusic(mnum, true);
|
S_ChangeMusic(mnum, true);
|
||||||
|
|
||||||
nextcleanup = 15;
|
nextcleanup = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
|
void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
|
||||||
{
|
{
|
||||||
@ -259,7 +259,7 @@ void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
|
|||||||
int cnum;
|
int cnum;
|
||||||
// int chnum; <-- 10.9.98 compiler warning
|
// int chnum; <-- 10.9.98 compiler warning
|
||||||
|
|
||||||
mobj_t* origin = (mobj_t *)origin_p;
|
mobj_t* origin = (mobj_t *)origin_p;
|
||||||
|
|
||||||
//WriteDebug("S_StartSoundAtVolume...\n");
|
//WriteDebug("S_StartSoundAtVolume...\n");
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
|
|||||||
|
|
||||||
if (volume > snd_SfxVolume)
|
if (volume > snd_SfxVolume)
|
||||||
volume = snd_SfxVolume;
|
volume = snd_SfxVolume;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pitch = NORM_PITCH;
|
pitch = NORM_PITCH;
|
||||||
@ -301,7 +301,7 @@ void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
|
|||||||
{
|
{
|
||||||
rc = S_AdjustSoundParams(players[consoleplayer].mo, origin, &volume, &sep, &pitch);
|
rc = S_AdjustSoundParams(players[consoleplayer].mo, origin, &volume, &sep, &pitch);
|
||||||
if ( origin->x == players[consoleplayer].mo->x && origin->y == players[consoleplayer].mo->y)
|
if ( origin->x == players[consoleplayer].mo->x && origin->y == players[consoleplayer].mo->y)
|
||||||
{
|
{
|
||||||
sep = NORM_SEP;
|
sep = NORM_SEP;
|
||||||
}
|
}
|
||||||
if (!rc)
|
if (!rc)
|
||||||
@ -309,7 +309,7 @@ void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
|
|||||||
//WriteDebug("No rc from S_AdjustSoundParams...\n");
|
//WriteDebug("No rc from S_AdjustSoundParams...\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sep = NORM_SEP;
|
sep = NORM_SEP;
|
||||||
@ -317,7 +317,7 @@ void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
|
|||||||
|
|
||||||
// hacks to vary the sfx pitches
|
// hacks to vary the sfx pitches
|
||||||
if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit)
|
if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit)
|
||||||
{
|
{
|
||||||
pitch += 8 - (M_Random()&15);
|
pitch += 8 - (M_Random()&15);
|
||||||
if (pitch < 0)
|
if (pitch < 0)
|
||||||
pitch = 0;
|
pitch = 0;
|
||||||
@ -372,12 +372,11 @@ void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
|
|||||||
// Assigns the handle to one of the channels in the
|
// Assigns the handle to one of the channels in the
|
||||||
// mix/output buffer.
|
// mix/output buffer.
|
||||||
//WriteDebug("I_StartSound...\n");
|
//WriteDebug("I_StartSound...\n");
|
||||||
channels[cnum].handle = I_StartSound(sfx_id,/*sfx->data,*/volume,sep,pitch,priority,origin);
|
channels[cnum].handle = I_StartSound(sfx_id,volume,sep,pitch,priority);
|
||||||
//cnum = I_StartSound(sfx_id,/*sfx->data,*/volume,sep,pitch,priority,origin);
|
|
||||||
channels[cnum].handle = cnum;
|
channels[cnum].handle = cnum;
|
||||||
channels[cnum].sfxinfo = sfx;
|
channels[cnum].sfxinfo = sfx;
|
||||||
channels[cnum].origin = origin;
|
channels[cnum].origin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_StartSound( void *origin, int sfx_id )
|
void S_StartSound( void *origin, int sfx_id )
|
||||||
{
|
{
|
||||||
@ -394,53 +393,53 @@ void S_StartSound( void *origin, int sfx_id )
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
static mobj_t* last_saw_origins[10] = {1,1,1,1,1,1,1,1,1,1};
|
static mobj_t* last_saw_origins[10] = {1,1,1,1,1,1,1,1,1,1};
|
||||||
static int first_saw=0;
|
static int first_saw=0;
|
||||||
static int next_saw=0;
|
static int next_saw=0;
|
||||||
|
|
||||||
if (sfx_id == sfx_sawidl
|
if (sfx_id == sfx_sawidl
|
||||||
|| sfx_id == sfx_sawful
|
|| sfx_id == sfx_sawful
|
||||||
|| sfx_id == sfx_sawhit)
|
|| sfx_id == sfx_sawhit)
|
||||||
{
|
{
|
||||||
for (i=first_saw;i!=next_saw;i=(i+1)%10)
|
for (i=first_saw;i!=next_saw;i=(i+1)%10)
|
||||||
if (last_saw_origins[i] != origin)
|
if (last_saw_origins[i] != origin)
|
||||||
fprintf(stderr, "old origin 0x%lx != "
|
fprintf(stderr, "old origin 0x%lx != "
|
||||||
"origin 0x%lx for sfx %d\n",
|
"origin 0x%lx for sfx %d\n",
|
||||||
last_saw_origins[i],
|
last_saw_origins[i],
|
||||||
origin,
|
origin,
|
||||||
sfx_id);
|
sfx_id);
|
||||||
|
|
||||||
last_saw_origins[next_saw] = origin;
|
last_saw_origins[next_saw] = origin;
|
||||||
next_saw = (next_saw + 1) % 10;
|
next_saw = (next_saw + 1) % 10;
|
||||||
if (next_saw == first_saw)
|
if (next_saw == first_saw)
|
||||||
first_saw = (first_saw + 1) % 10;
|
first_saw = (first_saw + 1) % 10;
|
||||||
|
|
||||||
for (n=i=0; i<numChannels ; i++)
|
for (n=i=0; i<numChannels ; i++)
|
||||||
{
|
{
|
||||||
if (channels[i].sfxinfo == &S_sfx[sfx_sawidl]
|
if (channels[i].sfxinfo == &S_sfx[sfx_sawidl]
|
||||||
|| channels[i].sfxinfo == &S_sfx[sfx_sawful]
|
|| channels[i].sfxinfo == &S_sfx[sfx_sawful]
|
||||||
|| channels[i].sfxinfo == &S_sfx[sfx_sawhit]) n++;
|
|| channels[i].sfxinfo == &S_sfx[sfx_sawhit]) n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n>1)
|
if (n>1)
|
||||||
{
|
{
|
||||||
for (i=0; i<numChannels ; i++)
|
for (i=0; i<numChannels ; i++)
|
||||||
{
|
{
|
||||||
if (channels[i].sfxinfo == &S_sfx[sfx_sawidl]
|
if (channels[i].sfxinfo == &S_sfx[sfx_sawidl]
|
||||||
|| channels[i].sfxinfo == &S_sfx[sfx_sawful]
|
|| channels[i].sfxinfo == &S_sfx[sfx_sawful]
|
||||||
|| channels[i].sfxinfo == &S_sfx[sfx_sawhit])
|
|| channels[i].sfxinfo == &S_sfx[sfx_sawhit])
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"chn: sfxinfo=0x%lx, origin=0x%lx, "
|
"chn: sfxinfo=0x%lx, origin=0x%lx, "
|
||||||
"handle=%d\n",
|
"handle=%d\n",
|
||||||
channels[i].sfxinfo,
|
channels[i].sfxinfo,
|
||||||
channels[i].origin,
|
channels[i].origin,
|
||||||
channels[i].handle);
|
channels[i].handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -457,11 +456,11 @@ void S_StopSound(void *origin)
|
|||||||
|
|
||||||
for (cnum=0 ; cnum<numChannels ; cnum++)
|
for (cnum=0 ; cnum<numChannels ; cnum++)
|
||||||
{
|
{
|
||||||
if (channels[cnum].sfxinfo && channels[cnum].origin == origin)
|
if (channels[cnum].sfxinfo && channels[cnum].origin == origin)
|
||||||
{
|
{
|
||||||
S_StopChannel(cnum);
|
S_StopChannel(cnum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,8 +479,8 @@ void S_PauseSound(void)
|
|||||||
{
|
{
|
||||||
if (mus_playing && !mus_paused)
|
if (mus_playing && !mus_paused)
|
||||||
{
|
{
|
||||||
I_PauseSong(mus_playing->handle);
|
I_PauseSong(mus_playing->handle);
|
||||||
mus_paused = true;
|
mus_paused = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,8 +488,8 @@ void S_ResumeSound(void)
|
|||||||
{
|
{
|
||||||
if (mus_playing && mus_paused)
|
if (mus_playing && mus_paused)
|
||||||
{
|
{
|
||||||
I_ResumeSong(mus_playing->handle);
|
I_ResumeSong(mus_playing->handle);
|
||||||
mus_paused = false;
|
mus_paused = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,15 +499,15 @@ void S_ResumeSound(void)
|
|||||||
//
|
//
|
||||||
void S_UpdateSounds(void* listener_p)
|
void S_UpdateSounds(void* listener_p)
|
||||||
{
|
{
|
||||||
int audible;
|
int audible;
|
||||||
int cnum;
|
int cnum;
|
||||||
int volume;
|
int volume;
|
||||||
int sep;
|
int sep;
|
||||||
int pitch;
|
int pitch;
|
||||||
sfxinfo_t* sfx;
|
sfxinfo_t* sfx;
|
||||||
channel_t* c;
|
channel_t* c;
|
||||||
|
|
||||||
mobj_t* listener = (mobj_t*)listener_p;
|
mobj_t* listener = (mobj_t*)listener_p;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -517,78 +516,78 @@ void S_UpdateSounds(void* listener_p)
|
|||||||
// DOS 8bit remains.
|
// DOS 8bit remains.
|
||||||
/*if (gametic > nextcleanup)
|
/*if (gametic > nextcleanup)
|
||||||
{
|
{
|
||||||
for (i=1 ; i<NUMSFX ; i++)
|
for (i=1 ; i<NUMSFX ; i++)
|
||||||
{
|
{
|
||||||
if (S_sfx[i].usefulness < 1
|
if (S_sfx[i].usefulness < 1
|
||||||
&& S_sfx[i].usefulness > -1)
|
&& S_sfx[i].usefulness > -1)
|
||||||
{
|
{
|
||||||
if (--S_sfx[i].usefulness == -1)
|
if (--S_sfx[i].usefulness == -1)
|
||||||
{
|
{
|
||||||
Z_ChangeTag(S_sfx[i].data, PU_CACHE);
|
Z_ChangeTag(S_sfx[i].data, PU_CACHE);
|
||||||
S_sfx[i].data = 0;
|
S_sfx[i].data = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextcleanup = gametic + 15;
|
nextcleanup = gametic + 15;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
for (cnum=0 ; cnum<numChannels ; cnum++)
|
for (cnum=0 ; cnum<numChannels ; cnum++)
|
||||||
{
|
{
|
||||||
c = &channels[cnum];
|
c = &channels[cnum];
|
||||||
sfx = c->sfxinfo;
|
sfx = c->sfxinfo;
|
||||||
|
|
||||||
if (c->sfxinfo)
|
if (c->sfxinfo)
|
||||||
{
|
{
|
||||||
if (I_SoundIsPlaying(c->handle))
|
if (I_SoundIsPlaying(c->handle))
|
||||||
{
|
{
|
||||||
// initialize parameters
|
// initialize parameters
|
||||||
volume = snd_SfxVolume;
|
volume = snd_SfxVolume;
|
||||||
pitch = NORM_PITCH;
|
pitch = NORM_PITCH;
|
||||||
sep = NORM_SEP;
|
sep = NORM_SEP;
|
||||||
|
|
||||||
if (sfx->link)
|
if (sfx->link)
|
||||||
{
|
{
|
||||||
pitch = sfx->pitch;
|
pitch = sfx->pitch;
|
||||||
volume += sfx->volume;
|
volume += sfx->volume;
|
||||||
if (volume < 1)
|
if (volume < 1)
|
||||||
{
|
{
|
||||||
S_StopChannel(cnum);
|
S_StopChannel(cnum);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (volume > snd_SfxVolume)
|
else if (volume > snd_SfxVolume)
|
||||||
{
|
{
|
||||||
volume = snd_SfxVolume;
|
volume = snd_SfxVolume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check non-local sounds for distance clipping
|
// check non-local sounds for distance clipping
|
||||||
// or modify their params
|
// or modify their params
|
||||||
if (c->origin && listener_p != c->origin)
|
if (c->origin && listener_p != c->origin)
|
||||||
{
|
{
|
||||||
audible = S_AdjustSoundParams(listener,
|
audible = S_AdjustSoundParams(listener,
|
||||||
c->origin,
|
c->origin,
|
||||||
&volume,
|
&volume,
|
||||||
&sep,
|
&sep,
|
||||||
&pitch);
|
&pitch);
|
||||||
|
|
||||||
if (!audible)
|
if (!audible)
|
||||||
{
|
{
|
||||||
S_StopChannel(cnum);
|
S_StopChannel(cnum);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
I_UpdateSoundParams(c->handle, volume, sep, pitch);
|
I_UpdateSoundParams(c->handle, volume, sep, pitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if channel is allocated but sound has stopped,
|
// if channel is allocated but sound has stopped,
|
||||||
// free it
|
// free it
|
||||||
S_StopChannel(cnum);
|
S_StopChannel(cnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// kill music if it is a single-play && finished
|
// kill music if it is a single-play && finished
|
||||||
// if ( mus_playing
|
// if ( mus_playing
|
||||||
// && !I_QrySongPlaying(mus_playing->handle)
|
// && !I_QrySongPlaying(mus_playing->handle)
|
||||||
// && !mus_paused )
|
// && !mus_paused )
|
||||||
// S_StopMusic();
|
// S_StopMusic();
|
||||||
@ -599,8 +598,8 @@ void S_SetMusicVolume(int volume)
|
|||||||
{
|
{
|
||||||
if (volume < 0 || volume > 127)
|
if (volume < 0 || volume > 127)
|
||||||
{
|
{
|
||||||
I_Error("Attempt to set music volume at %d",
|
I_Error("Attempt to set music volume at %d",
|
||||||
volume);
|
volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
I_SetMusicVolume(127);
|
I_SetMusicVolume(127);
|
||||||
@ -614,7 +613,7 @@ void S_SetSfxVolume(int volume)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (volume < 0 || volume > 127)
|
if (volume < 0 || volume > 127)
|
||||||
I_Error("Attempt to set sfx volume at %d", volume);
|
I_Error("Attempt to set sfx volume at %d", volume);
|
||||||
|
|
||||||
snd_SfxVolume = volume;
|
snd_SfxVolume = volume;
|
||||||
|
|
||||||
@ -634,7 +633,7 @@ void S_ChangeMusic(int musicnum, int looping)
|
|||||||
{
|
{
|
||||||
|
|
||||||
// I_PlaySong(music->handle, looping);
|
// I_PlaySong(music->handle, looping);
|
||||||
// mus_playing = music;
|
// mus_playing = music;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -642,48 +641,48 @@ void S_StopMusic(void)
|
|||||||
{
|
{
|
||||||
if (mus_playing)
|
if (mus_playing)
|
||||||
{
|
{
|
||||||
if (mus_paused) I_ResumeSong(mus_playing->handle);
|
if (mus_paused) I_ResumeSong(mus_playing->handle);
|
||||||
I_StopSong(mus_playing->handle);
|
I_StopSong(mus_playing->handle);
|
||||||
I_UnRegisterSong(mus_playing->handle);
|
I_UnRegisterSong(mus_playing->handle);
|
||||||
Z_ChangeTag(mus_playing->data, PU_CACHE);
|
Z_ChangeTag(mus_playing->data, PU_CACHE);
|
||||||
mus_playing->data = 0;
|
mus_playing->data = 0;
|
||||||
mus_playing = 0;
|
mus_playing = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_StopChannel(int cnum)
|
void S_StopChannel(int cnum)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
channel_t* c = &channels[cnum];
|
channel_t* c = &channels[cnum];
|
||||||
|
|
||||||
if (c->sfxinfo)
|
if (c->sfxinfo)
|
||||||
{
|
{
|
||||||
// stop the sound playing
|
// stop the sound playing
|
||||||
if (I_SoundIsPlaying(c->handle))
|
if (I_SoundIsPlaying(c->handle))
|
||||||
{
|
{
|
||||||
#ifdef SAWDEBUG
|
#ifdef SAWDEBUG
|
||||||
if (c->sfxinfo == &S_sfx[sfx_sawful])
|
if (c->sfxinfo == &S_sfx[sfx_sawful])
|
||||||
fprintf(stderr, "stopped\n");
|
fprintf(stderr, "stopped\n");
|
||||||
#endif
|
#endif
|
||||||
I_StopSound(c->handle);
|
I_StopSound(c->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check to see
|
// check to see
|
||||||
// if other channels are playing the sound
|
// if other channels are playing the sound
|
||||||
for (i=0 ; i<numChannels ; i++)
|
for (i=0 ; i<numChannels ; i++)
|
||||||
{
|
{
|
||||||
if (cnum != i
|
if (cnum != i
|
||||||
&& c->sfxinfo == channels[i].sfxinfo)
|
&& c->sfxinfo == channels[i].sfxinfo)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// degrade usefulness of sound data
|
// degrade usefulness of sound data
|
||||||
c->sfxinfo->usefulness--;
|
c->sfxinfo->usefulness--;
|
||||||
|
|
||||||
c->sfxinfo = 0;
|
c->sfxinfo = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,10 +697,10 @@ int
|
|||||||
S_AdjustSoundParams (mobj_t* listener, mobj_t* source,
|
S_AdjustSoundParams (mobj_t* listener, mobj_t* source,
|
||||||
int* vol, int* sep, int* pitch)
|
int* vol, int* sep, int* pitch)
|
||||||
{
|
{
|
||||||
fixed_t approx_dist;
|
fixed_t approx_dist;
|
||||||
fixed_t adx;
|
fixed_t adx;
|
||||||
fixed_t ady;
|
fixed_t ady;
|
||||||
angle_t angle;
|
angle_t angle;
|
||||||
|
|
||||||
// calculate the distance to sound origin
|
// calculate the distance to sound origin
|
||||||
// and clip it if necessary
|
// and clip it if necessary
|
||||||
@ -712,21 +711,21 @@ S_AdjustSoundParams (mobj_t* listener, mobj_t* source,
|
|||||||
approx_dist = adx + ady - ((adx < ady ? adx : ady)>>1);
|
approx_dist = adx + ady - ((adx < ady ? adx : ady)>>1);
|
||||||
|
|
||||||
if (gamemap != 8
|
if (gamemap != 8
|
||||||
&& approx_dist > S_CLIPPING_DIST)
|
&& approx_dist > S_CLIPPING_DIST)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// angle of source to listener
|
// angle of source to listener
|
||||||
angle = R_PointToAngle2(listener->x,
|
angle = R_PointToAngle2(listener->x,
|
||||||
listener->y,
|
listener->y,
|
||||||
source->x,
|
source->x,
|
||||||
source->y);
|
source->y);
|
||||||
|
|
||||||
if (angle > listener->angle)
|
if (angle > listener->angle)
|
||||||
angle = angle - listener->angle;
|
angle = angle - listener->angle;
|
||||||
else
|
else
|
||||||
angle = angle + (0xffffffff - listener->angle);
|
angle = angle + (0xffffffff - listener->angle);
|
||||||
|
|
||||||
angle >>= ANGLETOFINESHIFT;
|
angle >>= ANGLETOFINESHIFT;
|
||||||
|
|
||||||
@ -736,23 +735,23 @@ S_AdjustSoundParams (mobj_t* listener, mobj_t* source,
|
|||||||
// volume calculation
|
// volume calculation
|
||||||
if (approx_dist < S_CLOSE_DIST)
|
if (approx_dist < S_CLOSE_DIST)
|
||||||
{
|
{
|
||||||
*vol = snd_SfxVolume;
|
*vol = snd_SfxVolume;
|
||||||
}
|
}
|
||||||
else if (gamemap == 8)
|
else if (gamemap == 8)
|
||||||
{
|
{
|
||||||
if (approx_dist > S_CLIPPING_DIST)
|
if (approx_dist > S_CLIPPING_DIST)
|
||||||
approx_dist = S_CLIPPING_DIST;
|
approx_dist = S_CLIPPING_DIST;
|
||||||
|
|
||||||
*vol = 15+ ((snd_SfxVolume-15)
|
*vol = 15+ ((snd_SfxVolume-15)
|
||||||
*((S_CLIPPING_DIST - approx_dist)>>FRACBITS))
|
*((S_CLIPPING_DIST - approx_dist)>>FRACBITS))
|
||||||
/ S_ATTENUATOR;
|
/ S_ATTENUATOR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// distance effect
|
// distance effect
|
||||||
*vol = (snd_SfxVolume
|
*vol = (snd_SfxVolume
|
||||||
* ((S_CLIPPING_DIST - approx_dist)>>FRACBITS))
|
* ((S_CLIPPING_DIST - approx_dist)>>FRACBITS))
|
||||||
/ S_ATTENUATOR;
|
/ S_ATTENUATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*vol > 0);
|
return (*vol > 0);
|
||||||
@ -765,9 +764,9 @@ S_AdjustSoundParams (mobj_t* listener, mobj_t* source,
|
|||||||
int S_getChannel( void *origin, sfxinfo_t *sfxinfo, int sfxid )
|
int S_getChannel( void *origin, sfxinfo_t *sfxinfo, int sfxid )
|
||||||
{
|
{
|
||||||
// channel number to use
|
// channel number to use
|
||||||
int cnum;
|
int cnum;
|
||||||
|
|
||||||
channel_t* c;
|
channel_t* c;
|
||||||
|
|
||||||
// Find an open channel
|
// Find an open channel
|
||||||
//for (cnum = 0; cnum < numChannels; cnum++)
|
//for (cnum = 0; cnum < numChannels; cnum++)
|
||||||
|
@ -32,6 +32,8 @@ rcsid[] = "$Id: st_lib.c,v 1.4 1997/02/03 16:47:56 b1 Exp $";
|
|||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
|
|
||||||
|
#include "m_swap.h"
|
||||||
|
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
@ -94,8 +96,8 @@ STlib_drawNum
|
|||||||
int numdigits = n->width;
|
int numdigits = n->width;
|
||||||
int num = *n->num;
|
int num = *n->num;
|
||||||
|
|
||||||
int w = (n->p[0]->width);
|
int w = SHORT(n->p[0]->width);
|
||||||
int h = (n->p[0]->height);
|
int h = SHORT(n->p[0]->height);
|
||||||
int x = n->x;
|
int x = n->x;
|
||||||
|
|
||||||
int neg;
|
int neg;
|
||||||
@ -222,10 +224,10 @@ STlib_updateMultIcon
|
|||||||
{
|
{
|
||||||
if (mi->oldinum != -1)
|
if (mi->oldinum != -1)
|
||||||
{
|
{
|
||||||
x = mi->x - (mi->p[mi->oldinum]->leftoffset);
|
x = mi->x - SHORT(mi->p[mi->oldinum]->leftoffset);
|
||||||
y = mi->y - (mi->p[mi->oldinum]->topoffset);
|
y = mi->y - SHORT(mi->p[mi->oldinum]->topoffset);
|
||||||
w = (mi->p[mi->oldinum]->width);
|
w = SHORT(mi->p[mi->oldinum]->width);
|
||||||
h = (mi->p[mi->oldinum]->height);
|
h = SHORT(mi->p[mi->oldinum]->height);
|
||||||
|
|
||||||
if (y - ST_Y < 0)
|
if (y - ST_Y < 0)
|
||||||
I_Error("updateMultIcon: y - ST_Y < 0");
|
I_Error("updateMultIcon: y - ST_Y < 0");
|
||||||
@ -271,10 +273,10 @@ STlib_updateBinIcon
|
|||||||
if (*bi->on
|
if (*bi->on
|
||||||
&& (bi->oldval != *bi->val || refresh))
|
&& (bi->oldval != *bi->val || refresh))
|
||||||
{
|
{
|
||||||
x = bi->x - (bi->p->leftoffset);
|
x = bi->x - SHORT(bi->p->leftoffset);
|
||||||
y = bi->y - (bi->p->topoffset);
|
y = bi->y - SHORT(bi->p->topoffset);
|
||||||
w = (bi->p->width);
|
w = SHORT(bi->p->width);
|
||||||
h = (bi->p->height);
|
h = SHORT(bi->p->height);
|
||||||
|
|
||||||
if (y - ST_Y < 0)
|
if (y - ST_Y < 0)
|
||||||
I_Error("updateBinIcon: y - ST_Y < 0");
|
I_Error("updateBinIcon: y - ST_Y < 0");
|
||||||
|
@ -1074,13 +1074,13 @@ void ST_drawWidgets(boolean refresh)
|
|||||||
|
|
||||||
STlib_updateBinIcon(&w_armsbg, refresh);
|
STlib_updateBinIcon(&w_armsbg, refresh);
|
||||||
|
|
||||||
for (i=0;i<5;i++)
|
for (i=0;i<6;i++)
|
||||||
STlib_updateMultIcon(&w_arms[i], refresh);
|
STlib_updateMultIcon(&w_arms[i], refresh);
|
||||||
|
|
||||||
STlib_updateMultIcon(&w_faces, refresh);
|
STlib_updateMultIcon(&w_faces, refresh);
|
||||||
|
|
||||||
for (i=0;i<3;i++)
|
for (i=0;i<3;i++)
|
||||||
STlib_updateMultIcon(&w_keyboxes[i], refresh);
|
STlib_updateMultIcon(&w_keyboxes[i], refresh);
|
||||||
|
|
||||||
STlib_updateNum(&w_frags, refresh);
|
STlib_updateNum(&w_frags, refresh);
|
||||||
|
|
||||||
@ -1273,7 +1273,7 @@ void ST_initData(void)
|
|||||||
for (i=0;i<3;i++)
|
for (i=0;i<3;i++)
|
||||||
keyboxes[i] = -1;
|
keyboxes[i] = -1;
|
||||||
|
|
||||||
// STlib_init();
|
STlib_init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,493 +1,493 @@
|
|||||||
// Emacs style mode select -*- C++ -*-
|
// Emacs style mode select -*- C++ -*-
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// $Id:$
|
// $Id:$
|
||||||
//
|
//
|
||||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||||
//
|
//
|
||||||
// This source is available for distribution and/or modification
|
// This source is available for distribution and/or modification
|
||||||
// only under the terms of the DOOM Source Code License as
|
// only under the terms of the DOOM Source Code License as
|
||||||
// published by id Software. All rights reserved.
|
// published by id Software. All rights reserved.
|
||||||
//
|
//
|
||||||
// The source is distributed in the hope that it will be useful,
|
// The source is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// $Log:$
|
// $Log:$
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
// DESCRIPTION:
|
||||||
// Gamma correction LUT stuff.
|
// Gamma correction LUT stuff.
|
||||||
// Functions to draw patches (by post) directly to screen.
|
// Functions to draw patches (by post) directly to screen.
|
||||||
// Functions to blit a block to the screen.
|
// Functions to blit a block to the screen.
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
static const char
|
static const char
|
||||||
rcsid[] = "$Id: v_video.c,v 1.5 1997/02/03 22:45:13 b1 Exp $";
|
rcsid[] = "$Id: v_video.c,v 1.5 1997/02/03 22:45:13 b1 Exp $";
|
||||||
|
|
||||||
|
|
||||||
#include "m_swap.h"
|
#include "m_swap.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "doomdata.h"
|
#include "doomdata.h"
|
||||||
|
|
||||||
#include "m_bbox.h"
|
#include "m_bbox.h"
|
||||||
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "kolibri.h"
|
#include "kolibri.h"
|
||||||
|
|
||||||
// Each screen is [SCREENWIDTH*SCREENHEIGHT];
|
// Each screen is [SCREENWIDTH*SCREENHEIGHT];
|
||||||
byte* screens[5];
|
byte* screens[5];
|
||||||
|
|
||||||
int dirtybox[4];
|
int dirtybox[4];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Now where did these came from?
|
// Now where did these came from?
|
||||||
byte gammatable[5][256] =
|
byte gammatable[5][256] =
|
||||||
{
|
{
|
||||||
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
|
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
|
||||||
17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
|
17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
|
||||||
33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
|
33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
|
||||||
49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,
|
49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,
|
||||||
65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
|
65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
|
||||||
81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,
|
81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,
|
||||||
97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,
|
97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,
|
||||||
113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
|
113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
|
||||||
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
|
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
|
||||||
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
|
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
|
||||||
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
|
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
|
||||||
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
|
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
|
||||||
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
|
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
|
||||||
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
|
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
|
||||||
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
|
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
|
||||||
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255},
|
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255},
|
||||||
|
|
||||||
{2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31,
|
{2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31,
|
||||||
32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,54,55,
|
32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,54,55,
|
||||||
56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77,
|
56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77,
|
||||||
78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,
|
78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,
|
||||||
99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,
|
99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,
|
||||||
115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,129,
|
115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,129,
|
||||||
130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,
|
130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,
|
||||||
146,147,148,148,149,150,151,152,153,154,155,156,157,158,159,160,
|
146,147,148,148,149,150,151,152,153,154,155,156,157,158,159,160,
|
||||||
161,162,163,163,164,165,166,167,168,169,170,171,172,173,174,175,
|
161,162,163,163,164,165,166,167,168,169,170,171,172,173,174,175,
|
||||||
175,176,177,178,179,180,181,182,183,184,185,186,186,187,188,189,
|
175,176,177,178,179,180,181,182,183,184,185,186,186,187,188,189,
|
||||||
190,191,192,193,194,195,196,196,197,198,199,200,201,202,203,204,
|
190,191,192,193,194,195,196,196,197,198,199,200,201,202,203,204,
|
||||||
205,205,206,207,208,209,210,211,212,213,214,214,215,216,217,218,
|
205,205,206,207,208,209,210,211,212,213,214,214,215,216,217,218,
|
||||||
219,220,221,222,222,223,224,225,226,227,228,229,230,230,231,232,
|
219,220,221,222,222,223,224,225,226,227,228,229,230,230,231,232,
|
||||||
233,234,235,236,237,237,238,239,240,241,242,243,244,245,245,246,
|
233,234,235,236,237,237,238,239,240,241,242,243,244,245,245,246,
|
||||||
247,248,249,250,251,252,252,253,254,255},
|
247,248,249,250,251,252,252,253,254,255},
|
||||||
|
|
||||||
{4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42,
|
{4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42,
|
||||||
43,45,46,47,48,50,51,52,54,55,56,57,59,60,61,62,63,65,66,67,68,69,
|
43,45,46,47,48,50,51,52,54,55,56,57,59,60,61,62,63,65,66,67,68,69,
|
||||||
70,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,
|
70,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,
|
||||||
94,95,96,97,98,100,101,102,103,104,105,106,107,108,109,110,111,112,
|
94,95,96,97,98,100,101,102,103,104,105,106,107,108,109,110,111,112,
|
||||||
113,114,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
|
113,114,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
|
||||||
129,130,131,132,133,133,134,135,136,137,138,139,140,141,142,143,144,
|
129,130,131,132,133,133,134,135,136,137,138,139,140,141,142,143,144,
|
||||||
144,145,146,147,148,149,150,151,152,153,153,154,155,156,157,158,159,
|
144,145,146,147,148,149,150,151,152,153,153,154,155,156,157,158,159,
|
||||||
160,160,161,162,163,164,165,166,166,167,168,169,170,171,172,172,173,
|
160,160,161,162,163,164,165,166,166,167,168,169,170,171,172,172,173,
|
||||||
174,175,176,177,178,178,179,180,181,182,183,183,184,185,186,187,188,
|
174,175,176,177,178,178,179,180,181,182,183,183,184,185,186,187,188,
|
||||||
188,189,190,191,192,193,193,194,195,196,197,197,198,199,200,201,201,
|
188,189,190,191,192,193,193,194,195,196,197,197,198,199,200,201,201,
|
||||||
202,203,204,205,206,206,207,208,209,210,210,211,212,213,213,214,215,
|
202,203,204,205,206,206,207,208,209,210,210,211,212,213,213,214,215,
|
||||||
216,217,217,218,219,220,221,221,222,223,224,224,225,226,227,228,228,
|
216,217,217,218,219,220,221,221,222,223,224,224,225,226,227,228,228,
|
||||||
229,230,231,231,232,233,234,235,235,236,237,238,238,239,240,241,241,
|
229,230,231,231,232,233,234,235,235,236,237,238,238,239,240,241,241,
|
||||||
242,243,244,244,245,246,247,247,248,249,250,251,251,252,253,254,254,
|
242,243,244,244,245,246,247,247,248,249,250,251,251,252,253,254,254,
|
||||||
255},
|
255},
|
||||||
|
|
||||||
{8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55,
|
{8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55,
|
||||||
57,58,60,61,63,64,65,67,68,70,71,72,74,75,76,77,79,80,81,82,84,85,
|
57,58,60,61,63,64,65,67,68,70,71,72,74,75,76,77,79,80,81,82,84,85,
|
||||||
86,87,88,90,91,92,93,94,95,96,98,99,100,101,102,103,104,105,106,107,
|
86,87,88,90,91,92,93,94,95,96,98,99,100,101,102,103,104,105,106,107,
|
||||||
108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,
|
108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,
|
||||||
125,126,127,128,129,130,131,132,133,134,135,135,136,137,138,139,140,
|
125,126,127,128,129,130,131,132,133,134,135,135,136,137,138,139,140,
|
||||||
141,142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,
|
141,142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,
|
||||||
155,156,157,158,159,160,160,161,162,163,164,165,165,166,167,168,169,
|
155,156,157,158,159,160,160,161,162,163,164,165,165,166,167,168,169,
|
||||||
169,170,171,172,173,173,174,175,176,176,177,178,179,180,180,181,182,
|
169,170,171,172,173,173,174,175,176,176,177,178,179,180,180,181,182,
|
||||||
183,183,184,185,186,186,187,188,189,189,190,191,192,192,193,194,195,
|
183,183,184,185,186,186,187,188,189,189,190,191,192,192,193,194,195,
|
||||||
195,196,197,197,198,199,200,200,201,202,202,203,204,205,205,206,207,
|
195,196,197,197,198,199,200,200,201,202,202,203,204,205,205,206,207,
|
||||||
207,208,209,210,210,211,212,212,213,214,214,215,216,216,217,218,219,
|
207,208,209,210,210,211,212,212,213,214,214,215,216,216,217,218,219,
|
||||||
219,220,221,221,222,223,223,224,225,225,226,227,227,228,229,229,230,
|
219,220,221,221,222,223,223,224,225,225,226,227,227,228,229,229,230,
|
||||||
231,231,232,233,233,234,235,235,236,237,237,238,238,239,240,240,241,
|
231,231,232,233,233,234,235,235,236,237,237,238,238,239,240,240,241,
|
||||||
242,242,243,244,244,245,246,246,247,247,248,249,249,250,251,251,252,
|
242,242,243,244,244,245,246,246,247,247,248,249,249,250,251,251,252,
|
||||||
253,253,254,254,255},
|
253,253,254,254,255},
|
||||||
|
|
||||||
{16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76,
|
{16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76,
|
||||||
78,80,81,83,84,86,87,89,90,92,93,94,96,97,98,100,101,102,103,105,106,
|
78,80,81,83,84,86,87,89,90,92,93,94,96,97,98,100,101,102,103,105,106,
|
||||||
107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,
|
107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,
|
||||||
125,126,128,128,129,130,131,132,133,134,135,136,137,138,139,140,141,
|
125,126,128,128,129,130,131,132,133,134,135,136,137,138,139,140,141,
|
||||||
142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,155,
|
142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,155,
|
||||||
156,157,158,159,159,160,161,162,163,163,164,165,166,166,167,168,169,
|
156,157,158,159,159,160,161,162,163,163,164,165,166,166,167,168,169,
|
||||||
169,170,171,172,172,173,174,175,175,176,177,177,178,179,180,180,181,
|
169,170,171,172,172,173,174,175,175,176,177,177,178,179,180,180,181,
|
||||||
182,182,183,184,184,185,186,187,187,188,189,189,190,191,191,192,193,
|
182,182,183,184,184,185,186,187,187,188,189,189,190,191,191,192,193,
|
||||||
193,194,195,195,196,196,197,198,198,199,200,200,201,202,202,203,203,
|
193,194,195,195,196,196,197,198,198,199,200,200,201,202,202,203,203,
|
||||||
204,205,205,206,207,207,208,208,209,210,210,211,211,212,213,213,214,
|
204,205,205,206,207,207,208,208,209,210,210,211,211,212,213,213,214,
|
||||||
214,215,216,216,217,217,218,219,219,220,220,221,221,222,223,223,224,
|
214,215,216,216,217,217,218,219,219,220,220,221,221,222,223,223,224,
|
||||||
224,225,225,226,227,227,228,228,229,229,230,230,231,232,232,233,233,
|
224,225,225,226,227,227,228,228,229,229,230,230,231,232,232,233,233,
|
||||||
234,234,235,235,236,236,237,237,238,239,239,240,240,241,241,242,242,
|
234,234,235,235,236,236,237,237,238,239,239,240,240,241,241,242,242,
|
||||||
243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,
|
243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,
|
||||||
251,252,252,253,254,254,255,255}
|
251,252,252,253,254,254,255,255}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int usegamma;
|
int usegamma;
|
||||||
|
|
||||||
//
|
//
|
||||||
// V_MarkRect
|
// V_MarkRect
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
V_MarkRect
|
V_MarkRect
|
||||||
( int x,
|
( int x,
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height )
|
int height )
|
||||||
{
|
{
|
||||||
M_AddToBox (dirtybox, x, y);
|
M_AddToBox (dirtybox, x, y);
|
||||||
M_AddToBox (dirtybox, x+width-1, y+height-1);
|
M_AddToBox (dirtybox, x+width-1, y+height-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// V_CopyRect
|
// V_CopyRect
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
V_CopyRect
|
V_CopyRect
|
||||||
( int srcx,
|
( int srcx,
|
||||||
int srcy,
|
int srcy,
|
||||||
int srcscrn,
|
int srcscrn,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int destx,
|
int destx,
|
||||||
int desty,
|
int desty,
|
||||||
int destscrn )
|
int destscrn )
|
||||||
{
|
{
|
||||||
byte* src;
|
byte* src;
|
||||||
byte* dest;
|
byte* dest;
|
||||||
|
|
||||||
#ifdef RANGECHECK
|
#ifdef RANGECHECK
|
||||||
if (srcx<0
|
if (srcx<0
|
||||||
||srcx+width >SCREENWIDTH
|
||srcx+width >SCREENWIDTH
|
||||||
|| srcy<0
|
|| srcy<0
|
||||||
|| srcy+height>SCREENHEIGHT
|
|| srcy+height>SCREENHEIGHT
|
||||||
||destx<0||destx+width >SCREENWIDTH
|
||destx<0||destx+width >SCREENWIDTH
|
||||||
|| desty<0
|
|| desty<0
|
||||||
|| desty+height>SCREENHEIGHT
|
|| desty+height>SCREENHEIGHT
|
||||||
|| (unsigned)srcscrn>4
|
|| (unsigned)srcscrn>4
|
||||||
|| (unsigned)destscrn>4)
|
|| (unsigned)destscrn>4)
|
||||||
{
|
{
|
||||||
I_Error ("Bad V_CopyRect");
|
I_Error ("Bad V_CopyRect");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
V_MarkRect (destx, desty, width, height);
|
V_MarkRect (destx, desty, width, height);
|
||||||
|
|
||||||
src = screens[srcscrn]+SCREENWIDTH*srcy+srcx;
|
src = screens[srcscrn]+SCREENWIDTH*srcy+srcx;
|
||||||
dest = screens[destscrn]+SCREENWIDTH*desty+destx;
|
dest = screens[destscrn]+SCREENWIDTH*desty+destx;
|
||||||
|
|
||||||
for ( ; height>0 ; height--)
|
for ( ; height>0 ; height--)
|
||||||
{
|
{
|
||||||
memcpy (dest, src, width);
|
memcpy (dest, src, width);
|
||||||
src += SCREENWIDTH;
|
src += SCREENWIDTH;
|
||||||
dest += SCREENWIDTH;
|
dest += SCREENWIDTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// V_DrawPatch
|
// V_DrawPatch
|
||||||
// Masks a column based masked pic to the screen.
|
// Masks a column based masked pic to the screen.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
V_DrawPatch
|
V_DrawPatch
|
||||||
( int x,
|
( int x,
|
||||||
int y,
|
int y,
|
||||||
int scrn,
|
int scrn,
|
||||||
patch_t* patch )
|
patch_t* patch )
|
||||||
{
|
{
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
int col;
|
int col;
|
||||||
column_t* column;
|
column_t* column;
|
||||||
byte* desttop;
|
byte* desttop;
|
||||||
byte* dest;
|
byte* dest;
|
||||||
byte* source;
|
byte* source;
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
y -= SHORT(patch->topoffset);
|
y -= SHORT(patch->topoffset);
|
||||||
x -= SHORT(patch->leftoffset);
|
x -= SHORT(patch->leftoffset);
|
||||||
#ifdef RANGECHECK
|
#ifdef RANGECHECK
|
||||||
if (x<0
|
if (x<0
|
||||||
||x+SHORT(patch->width) >SCREENWIDTH
|
||x+SHORT(patch->width) >SCREENWIDTH
|
||||||
|| y<0
|
|| y<0
|
||||||
|| y+SHORT(patch->height)>SCREENHEIGHT
|
|| y+SHORT(patch->height)>SCREENHEIGHT
|
||||||
|| (unsigned)scrn>4)
|
|| (unsigned)scrn>4)
|
||||||
{
|
{
|
||||||
printf("Patch at %d,%d exceeds LFB\n", x,y );
|
//printf("Patch at %d,%d exceeds LFB\n", x,y );
|
||||||
// No I_Error abort - what is up with TNT.WAD?
|
// No I_Error abort - what is up with TNT.WAD?
|
||||||
printf("V_DrawPatch: bad patch (ignored)\n");
|
//printf("V_DrawPatch: bad patch (ignored)\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!scrn)
|
if (!scrn)
|
||||||
V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height));
|
V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height));
|
||||||
|
|
||||||
col = 0;
|
col = 0;
|
||||||
desttop = screens[scrn]+y*SCREENWIDTH+x;
|
desttop = screens[scrn]+y*SCREENWIDTH+x;
|
||||||
|
|
||||||
w = SHORT(patch->width);
|
w = SHORT(patch->width);
|
||||||
|
|
||||||
for ( ; col<w ; x++, col++, desttop++)
|
for ( ; col<w ; x++, col++, desttop++)
|
||||||
{
|
{
|
||||||
column = (column_t *)((byte *)patch + LONG(patch->columnofs[col]));
|
column = (column_t *)((byte *)patch + LONG(patch->columnofs[col]));
|
||||||
|
|
||||||
// step through the posts in a column
|
// step through the posts in a column
|
||||||
while (column->topdelta != 0xff )
|
while (column->topdelta != 0xff )
|
||||||
{
|
{
|
||||||
source = (byte *)column + 3;
|
source = (byte *)column + 3;
|
||||||
dest = desttop + column->topdelta*SCREENWIDTH;
|
dest = desttop + column->topdelta*SCREENWIDTH;
|
||||||
count = column->length;
|
count = column->length;
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
*dest = *source++;
|
*dest = *source++;
|
||||||
dest += SCREENWIDTH;
|
dest += SCREENWIDTH;
|
||||||
}
|
}
|
||||||
column = (column_t *)( (byte *)column + column->length
|
column = (column_t *)( (byte *)column + column->length
|
||||||
+ 4 );
|
+ 4 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// V_DrawPatchFlipped
|
// V_DrawPatchFlipped
|
||||||
// Masks a column based masked pic to the screen.
|
// Masks a column based masked pic to the screen.
|
||||||
// Flips horizontally, e.g. to mirror face.
|
// Flips horizontally, e.g. to mirror face.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
V_DrawPatchFlipped
|
V_DrawPatchFlipped
|
||||||
( int x,
|
( int x,
|
||||||
int y,
|
int y,
|
||||||
int scrn,
|
int scrn,
|
||||||
patch_t* patch )
|
patch_t* patch )
|
||||||
{
|
{
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
int col;
|
int col;
|
||||||
column_t* column;
|
column_t* column;
|
||||||
byte* desttop;
|
byte* desttop;
|
||||||
byte* dest;
|
byte* dest;
|
||||||
byte* source;
|
byte* source;
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
y -= SHORT(patch->topoffset);
|
y -= SHORT(patch->topoffset);
|
||||||
x -= SHORT(patch->leftoffset);
|
x -= SHORT(patch->leftoffset);
|
||||||
#ifdef RANGECHECK
|
#ifdef RANGECHECK
|
||||||
if (x<0
|
if (x<0
|
||||||
||x+SHORT(patch->width) >SCREENWIDTH
|
||x+SHORT(patch->width) >SCREENWIDTH
|
||||||
|| y<0
|
|| y<0
|
||||||
|| y+SHORT(patch->height)>SCREENHEIGHT
|
|| y+SHORT(patch->height)>SCREENHEIGHT
|
||||||
|| (unsigned)scrn>4)
|
|| (unsigned)scrn>4)
|
||||||
{
|
{
|
||||||
printf("Patch origin %d,%d exceeds LFB\n", x,y );
|
//printf("Patch origin %d,%d exceeds LFB\n", x,y );
|
||||||
I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");
|
I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!scrn)
|
if (!scrn)
|
||||||
V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height));
|
V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height));
|
||||||
|
|
||||||
col = 0;
|
col = 0;
|
||||||
desttop = screens[scrn]+y*SCREENWIDTH+x;
|
desttop = screens[scrn]+y*SCREENWIDTH+x;
|
||||||
|
|
||||||
w = SHORT(patch->width);
|
w = SHORT(patch->width);
|
||||||
|
|
||||||
for ( ; col<w ; x++, col++, desttop++)
|
for ( ; col<w ; x++, col++, desttop++)
|
||||||
{
|
{
|
||||||
column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col]));
|
column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col]));
|
||||||
|
|
||||||
// step through the posts in a column
|
// step through the posts in a column
|
||||||
while (column->topdelta != 0xff )
|
while (column->topdelta != 0xff )
|
||||||
{
|
{
|
||||||
source = (byte *)column + 3;
|
source = (byte *)column + 3;
|
||||||
dest = desttop + column->topdelta*SCREENWIDTH;
|
dest = desttop + column->topdelta*SCREENWIDTH;
|
||||||
count = column->length;
|
count = column->length;
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
*dest = *source++;
|
*dest = *source++;
|
||||||
dest += SCREENWIDTH;
|
dest += SCREENWIDTH;
|
||||||
}
|
}
|
||||||
column = (column_t *)( (byte *)column + column->length
|
column = (column_t *)( (byte *)column + column->length
|
||||||
+ 4 );
|
+ 4 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// V_DrawPatchDirect
|
// V_DrawPatchDirect
|
||||||
// Draws directly to the screen on the pc.
|
// Draws directly to the screen on the pc.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
V_DrawPatchDirect
|
V_DrawPatchDirect
|
||||||
( int x,
|
( int x,
|
||||||
int y,
|
int y,
|
||||||
int scrn,
|
int scrn,
|
||||||
patch_t* patch )
|
patch_t* patch )
|
||||||
{
|
{
|
||||||
V_DrawPatch (x,y,scrn, patch);
|
V_DrawPatch (x,y,scrn, patch);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int count;
|
int count;
|
||||||
int col;
|
int col;
|
||||||
column_t* column;
|
column_t* column;
|
||||||
byte* desttop;
|
byte* desttop;
|
||||||
byte* dest;
|
byte* dest;
|
||||||
byte* source;
|
byte* source;
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
y -= SHORT(patch->topoffset);
|
y -= SHORT(patch->topoffset);
|
||||||
x -= SHORT(patch->leftoffset);
|
x -= SHORT(patch->leftoffset);
|
||||||
|
|
||||||
#ifdef RANGECHECK
|
#ifdef RANGECHECK
|
||||||
if (x<0
|
if (x<0
|
||||||
||x+SHORT(patch->width) >SCREENWIDTH
|
||x+SHORT(patch->width) >SCREENWIDTH
|
||||||
|| y<0
|
|| y<0
|
||||||
|| y+SHORT(patch->height)>SCREENHEIGHT
|
|| y+SHORT(patch->height)>SCREENHEIGHT
|
||||||
|| (unsigned)scrn>4)
|
|| (unsigned)scrn>4)
|
||||||
{
|
{
|
||||||
I_Error ("Bad V_DrawPatchDirect");
|
I_Error ("Bad V_DrawPatchDirect");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height));
|
// V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height));
|
||||||
desttop = destscreen + y*SCREENWIDTH/4 + (x>>2);
|
desttop = destscreen + y*SCREENWIDTH/4 + (x>>2);
|
||||||
|
|
||||||
w = SHORT(patch->width);
|
w = SHORT(patch->width);
|
||||||
for ( col = 0 ; col<w ; col++)
|
for ( col = 0 ; col<w ; col++)
|
||||||
{
|
{
|
||||||
outp (SC_INDEX+1,1<<(x&3));
|
outp (SC_INDEX+1,1<<(x&3));
|
||||||
column = (column_t *)((byte *)patch + LONG(patch->columnofs[col]));
|
column = (column_t *)((byte *)patch + LONG(patch->columnofs[col]));
|
||||||
|
|
||||||
// step through the posts in a column
|
// step through the posts in a column
|
||||||
|
|
||||||
while (column->topdelta != 0xff )
|
while (column->topdelta != 0xff )
|
||||||
{
|
{
|
||||||
source = (byte *)column + 3;
|
source = (byte *)column + 3;
|
||||||
dest = desttop + column->topdelta*SCREENWIDTH/4;
|
dest = desttop + column->topdelta*SCREENWIDTH/4;
|
||||||
count = column->length;
|
count = column->length;
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
*dest = *source++;
|
*dest = *source++;
|
||||||
dest += SCREENWIDTH/4;
|
dest += SCREENWIDTH/4;
|
||||||
}
|
}
|
||||||
column = (column_t *)( (byte *)column + column->length
|
column = (column_t *)( (byte *)column + column->length
|
||||||
+ 4 );
|
+ 4 );
|
||||||
}
|
}
|
||||||
if ( ((++x)&3) == 0 )
|
if ( ((++x)&3) == 0 )
|
||||||
desttop++; // go to next byte, not next plane
|
desttop++; // go to next byte, not next plane
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// V_DrawBlock
|
// V_DrawBlock
|
||||||
// Draw a linear block of pixels into the view buffer.
|
// Draw a linear block of pixels into the view buffer.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
V_DrawBlock
|
V_DrawBlock
|
||||||
( int x,
|
( int x,
|
||||||
int y,
|
int y,
|
||||||
int scrn,
|
int scrn,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
byte* src )
|
byte* src )
|
||||||
{
|
{
|
||||||
byte* dest;
|
byte* dest;
|
||||||
|
|
||||||
#ifdef RANGECHECK
|
#ifdef RANGECHECK
|
||||||
if (x<0
|
if (x<0
|
||||||
||x+width >SCREENWIDTH
|
||x+width >SCREENWIDTH
|
||||||
|| y<0
|
|| y<0
|
||||||
|| y+height>SCREENHEIGHT
|
|| y+height>SCREENHEIGHT
|
||||||
|| (unsigned)scrn>4 )
|
|| (unsigned)scrn>4 )
|
||||||
{
|
{
|
||||||
I_Error ("Bad V_DrawBlock");
|
I_Error ("Bad V_DrawBlock");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
V_MarkRect (x, y, width, height);
|
V_MarkRect (x, y, width, height);
|
||||||
|
|
||||||
dest = screens[scrn] + y*SCREENWIDTH+x;
|
dest = screens[scrn] + y*SCREENWIDTH+x;
|
||||||
|
|
||||||
while (height--)
|
while (height--)
|
||||||
{
|
{
|
||||||
memcpy (dest, src, width);
|
memcpy (dest, src, width);
|
||||||
src += width;
|
src += width;
|
||||||
dest += SCREENWIDTH;
|
dest += SCREENWIDTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// V_GetBlock
|
// V_GetBlock
|
||||||
// Gets a linear block of pixels from the view buffer.
|
// Gets a linear block of pixels from the view buffer.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
V_GetBlock
|
V_GetBlock
|
||||||
( int x,
|
( int x,
|
||||||
int y,
|
int y,
|
||||||
int scrn,
|
int scrn,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
byte* dest )
|
byte* dest )
|
||||||
{
|
{
|
||||||
byte* src;
|
byte* src;
|
||||||
|
|
||||||
#ifdef RANGECHECK
|
#ifdef RANGECHECK
|
||||||
if (x<0
|
if (x<0
|
||||||
||x+width >SCREENWIDTH
|
||x+width >SCREENWIDTH
|
||||||
|| y<0
|
|| y<0
|
||||||
|| y+height>SCREENHEIGHT
|
|| y+height>SCREENHEIGHT
|
||||||
|| (unsigned)scrn>4 )
|
|| (unsigned)scrn>4 )
|
||||||
{
|
{
|
||||||
I_Error ("Bad V_DrawBlock");
|
I_Error ("Bad V_DrawBlock");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
src = screens[scrn] + y*SCREENWIDTH+x;
|
src = screens[scrn] + y*SCREENWIDTH+x;
|
||||||
|
|
||||||
while (height--)
|
while (height--)
|
||||||
{
|
{
|
||||||
memcpy (dest, src, width);
|
memcpy (dest, src, width);
|
||||||
src += SCREENWIDTH;
|
src += SCREENWIDTH;
|
||||||
dest += width;
|
dest += width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// V_Init
|
// V_Init
|
||||||
//
|
//
|
||||||
void V_Init (void)
|
void V_Init (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
byte* base;
|
byte* base;
|
||||||
size_t size;
|
size_t size;
|
||||||
// stick these in low dos memory on PCs
|
// stick these in low dos memory on PCs
|
||||||
size = SCREENWIDTH*SCREENHEIGHT*4;
|
size = SCREENWIDTH*SCREENHEIGHT*4;
|
||||||
base = (byte*)UserAlloc(size);
|
base = (byte*)UserAlloc(size);
|
||||||
|
|
||||||
for (i=0 ; i<4 ; i++)
|
for (i=0 ; i<4 ; i++)
|
||||||
screens[i] = base + i*SCREENWIDTH*SCREENHEIGHT;
|
screens[i] = base + i*SCREENWIDTH*SCREENHEIGHT;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
static const char
|
static const char
|
||||||
rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
|
rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <dsound.h>
|
|
||||||
#include "sounds.h"
|
#include "sounds.h"
|
||||||
|
|
||||||
char MsgText[256];
|
char MsgText[256];
|
||||||
@ -67,13 +65,13 @@ void I_CreateSound(void)
|
|||||||
hret = DirectSoundCreate8(NULL, &lpDS, NULL);
|
hret = DirectSoundCreate8(NULL, &lpDS, NULL);
|
||||||
if (hret != DS_OK)
|
if (hret != DS_OK)
|
||||||
{
|
{
|
||||||
printf("failed DirectSoundCreate");
|
//printf("failed DirectSoundCreate");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hret = lpDS->lpVtbl->SetCooperativeLevel(lpDS, win, DSSCL_PRIORITY);
|
hret = lpDS->lpVtbl->SetCooperativeLevel(lpDS, win, DSSCL_PRIORITY);
|
||||||
if (hret != DS_OK)
|
if (hret != DS_OK)
|
||||||
printf("failled DirectSound.SetCooperativeLevel");
|
//printf("failled DirectSound.SetCooperativeLevel");
|
||||||
|
|
||||||
memset( &wfx,0, sizeof(WAVEFORMATEX) );
|
memset( &wfx,0, sizeof(WAVEFORMATEX) );
|
||||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
@ -119,7 +117,7 @@ void I_SubmitSound(signed short *mixbuffer)
|
|||||||
hret=lpMix[mixbuff]->lpVtbl->Lock(lpMix[mixbuff],0,MIXBUFFERSIZE,&pPtr1,
|
hret=lpMix[mixbuff]->lpVtbl->Lock(lpMix[mixbuff],0,MIXBUFFERSIZE,&pPtr1,
|
||||||
&dwSize1,&pPtr2,&dwSize2,0);
|
&dwSize1,&pPtr2,&dwSize2,0);
|
||||||
if (hret!=DS_OK)
|
if (hret!=DS_OK)
|
||||||
{ printf("Error locking on play start");
|
{ //printf("Error locking on play start");
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
memcpy(pPtr1, (void*)mixbuffer, MIXBUFFERSIZE);
|
memcpy(pPtr1, (void*)mixbuffer, MIXBUFFERSIZE);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
// $Log:$
|
// $Log:$
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
// DESCRIPTION:
|
||||||
// Handles WAD file header, directory, lump I/O.
|
// Handles WAD file header, directory, lump I/O.
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -40,45 +40,53 @@ rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $";
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern char *main_file;
|
||||||
|
|
||||||
|
#ifdef DLHEAP
|
||||||
|
|
||||||
|
void* _cdecl dlmalloc(size_t);
|
||||||
|
void _cdecl dlfree(void*);
|
||||||
|
void _cdecl mf_init();
|
||||||
|
|
||||||
|
#define malloc dlmalloc
|
||||||
|
#define free dlfree
|
||||||
|
#define realloc dlrealloc
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size_t FileSize(FILE *handle);
|
||||||
|
|
||||||
|
int _stdcall read_file (char *name, void *buff,
|
||||||
|
size_t offset, size_t count, size_t *reads);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// GLOBALS
|
// GLOBALS
|
||||||
//
|
//
|
||||||
|
|
||||||
// Location of each lump on disk.
|
// Location of each lump on disk.
|
||||||
lumpinfo_t* lumpinfo;
|
lumpinfo_t* lumpinfo;
|
||||||
int numlumps;
|
int numlumps;
|
||||||
|
|
||||||
void** lumpcache;
|
|
||||||
|
|
||||||
|
|
||||||
int filelength (FILE *handle)
|
|
||||||
{
|
|
||||||
unsigned long pos, size;
|
|
||||||
|
|
||||||
pos = ftell(handle);
|
|
||||||
fseek(handle, 0, SEEK_END);
|
|
||||||
size = ftell(handle);
|
|
||||||
fseek(handle, pos, SEEK_SET);
|
|
||||||
return (int)size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void** lumpcache;
|
||||||
|
|
||||||
void
|
void
|
||||||
ExtractFileBase
|
ExtractFileBase
|
||||||
( char* path,
|
( char* path,
|
||||||
char* dest )
|
char* dest )
|
||||||
{
|
{
|
||||||
char* src;
|
char* src;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
src = path + strlen(path) - 1;
|
src = path + strlen(path) - 1;
|
||||||
|
|
||||||
// back up until a \ or the start
|
// back up until a \ or the start
|
||||||
while (src != path
|
while (src != path
|
||||||
&& *(src-1) != '\\'
|
&& *(src-1) != '\\'
|
||||||
&& *(src-1) != '/')
|
&& *(src-1) != '/')
|
||||||
{
|
{
|
||||||
src--;
|
src--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy up to eight characters
|
// copy up to eight characters
|
||||||
@ -87,10 +95,10 @@ ExtractFileBase
|
|||||||
|
|
||||||
while (*src && *src != '.')
|
while (*src && *src != '.')
|
||||||
{
|
{
|
||||||
if (++length == 9)
|
if (++length == 9)
|
||||||
I_Error ("Filename base of %s >8 chars",path);
|
I_Error ("Filename base of %s >8 chars",path);
|
||||||
|
|
||||||
*dest++ = toupper((int)*src++);
|
*dest++ = toupper((int)*src++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,91 +123,81 @@ ExtractFileBase
|
|||||||
// specially to allow map reloads.
|
// specially to allow map reloads.
|
||||||
// But: the reload feature is a fragile hack...
|
// But: the reload feature is a fragile hack...
|
||||||
|
|
||||||
#ifdef __BEOS__
|
|
||||||
#ifdef __GNUC__
|
|
||||||
extern void *alloca(int);
|
|
||||||
#else
|
|
||||||
#include <alloca.h>
|
|
||||||
#endif
|
|
||||||
#endif /* __BEOS__ */
|
|
||||||
|
|
||||||
int reloadlump;
|
int reloadlump;
|
||||||
char* reloadname;
|
char* reloadname;
|
||||||
|
|
||||||
|
|
||||||
void W_AddFile (char *filename)
|
void W_AddFile (char *filename)
|
||||||
{
|
{
|
||||||
wadinfo_t header;
|
wadinfo_t header;
|
||||||
lumpinfo_t* lump_p;
|
lumpinfo_t* lump_p;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
int length;
|
int length;
|
||||||
int startlump;
|
int startlump;
|
||||||
filelump_t* fileinfo;
|
filelump_t* fileinfo;
|
||||||
filelump_t singleinfo;
|
filelump_t singleinfo;
|
||||||
int storehandle;
|
int storehandle;
|
||||||
|
int err;
|
||||||
|
size_t bytes;
|
||||||
|
|
||||||
// open the file and add to directory
|
// open the file and add to directory
|
||||||
|
|
||||||
// handle reload indicator.
|
// handle reload indicator.
|
||||||
if (filename[0] == '~')
|
if (filename[0] == '~')
|
||||||
{
|
{
|
||||||
filename++;
|
filename++;
|
||||||
reloadname = filename;
|
reloadname = filename;
|
||||||
reloadlump = numlumps;
|
reloadlump = numlumps;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (handle = fopen (filename,"rb")) == NULL)
|
if ( (handle = fopen (filename,"rb")) == NULL)
|
||||||
{
|
{
|
||||||
printf (" couldn't open %s\n",filename);
|
printf (" couldn't open %s\n",filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf (" adding %s\n",filename);
|
printf (" adding %s\n\r",filename);
|
||||||
startlump = numlumps;
|
startlump = numlumps;
|
||||||
|
|
||||||
if (I_strncasecmp (filename+strlen(filename)-3 , "wad", 3 ) )
|
if (strnicmp (filename+strlen(filename)-3 , "wad", 3 ) )
|
||||||
{
|
{
|
||||||
// single lump file
|
// single lump file
|
||||||
fileinfo = &singleinfo;
|
fileinfo = &singleinfo;
|
||||||
singleinfo.filepos = 0;
|
singleinfo.filepos = 0;
|
||||||
singleinfo.size = LONG(filelength(handle));
|
singleinfo.size = FileSize(handle);
|
||||||
ExtractFileBase (filename, singleinfo.name);
|
ExtractFileBase (filename, singleinfo.name);
|
||||||
numlumps++;
|
numlumps++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//WAD file
|
//WAD file
|
||||||
printf("f1 at %x,%u\n",&header,handle);
|
fread (&header, 1, sizeof(header), handle);
|
||||||
fread (&header, 1, sizeof(header), handle);
|
|
||||||
printf("f2\n");
|
if (strncmp(header.identification,"IWAD",4))
|
||||||
if (strncmp(header.identification,"IWAD",4))
|
{
|
||||||
{
|
printf("No IWAD id\n");
|
||||||
printf("No IWAD id\n");
|
// Homebrew levels?
|
||||||
// Homebrew levels?
|
if (strncmp(header.identification,"PWAD",4))
|
||||||
if (strncmp(header.identification,"PWAD",4))
|
{
|
||||||
{
|
I_Error ("Wad file %s doesn't have IWAD "
|
||||||
I_Error ("Wad file %s doesn't have IWAD "
|
"or PWAD id\n", filename);
|
||||||
"or PWAD id\n", filename);
|
}
|
||||||
}
|
printf("WAD magic OK\n");
|
||||||
// printf("WAD magic OK\n");
|
// ???modifiedgame = true;
|
||||||
// ???modifiedgame = true;
|
}
|
||||||
}
|
header.numlumps = LONG(header.numlumps);
|
||||||
printf("after checking hdr\n");
|
|
||||||
header.numlumps = LONG(header.numlumps);
|
header.infotableofs = LONG(header.infotableofs);
|
||||||
printf("%u lumps in WAD\n",header.numlumps);
|
|
||||||
header.infotableofs = LONG(header.infotableofs);
|
length = header.numlumps*sizeof(filelump_t);
|
||||||
printf("infor table at %x\n",header.infotableofs);
|
|
||||||
length = header.numlumps*sizeof(filelump_t);
|
fileinfo = alloca(length);
|
||||||
printf("length %u\n",length);
|
|
||||||
fileinfo = alloca(length);
|
fseek (handle, header.infotableofs, SEEK_SET);
|
||||||
|
fread (fileinfo, 1, length, handle);
|
||||||
printf("seeking to info table\n");
|
numlumps += header.numlumps;
|
||||||
fseek (handle, header.infotableofs, SEEK_SET);
|
|
||||||
printf("f3\n");
|
|
||||||
fread (fileinfo, 1, length, handle);
|
|
||||||
printf("f4\n");
|
|
||||||
numlumps += header.numlumps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -207,22 +205,22 @@ void W_AddFile (char *filename)
|
|||||||
lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t));
|
lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t));
|
||||||
|
|
||||||
if (!lumpinfo)
|
if (!lumpinfo)
|
||||||
I_Error ("Couldn't realloc lumpinfo");
|
I_Error ("Couldn't realloc lumpinfo");
|
||||||
|
|
||||||
lump_p = &lumpinfo[startlump];
|
lump_p = &lumpinfo[startlump];
|
||||||
|
|
||||||
storehandle = reloadname ? -1 : (int)handle;
|
storehandle = reloadname ? -1 : (int)handle;
|
||||||
|
|
||||||
for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++)
|
for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++)
|
||||||
{
|
{
|
||||||
lump_p->handle = storehandle;
|
lump_p->handle = storehandle;
|
||||||
lump_p->position = LONG(fileinfo->filepos);
|
lump_p->position = LONG(fileinfo->filepos);
|
||||||
lump_p->size = LONG(fileinfo->size);
|
lump_p->size = LONG(fileinfo->size);
|
||||||
strncpy (lump_p->name, fileinfo->name, 8);
|
strncpy (lump_p->name, fileinfo->name, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reloadname)
|
if (reloadname)
|
||||||
fclose (handle);
|
fclose (handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -235,51 +233,46 @@ void W_AddFile (char *filename)
|
|||||||
//
|
//
|
||||||
void W_Reload (void)
|
void W_Reload (void)
|
||||||
{
|
{
|
||||||
wadinfo_t header;
|
wadinfo_t header;
|
||||||
int lumpcount;
|
int lumpcount;
|
||||||
lumpinfo_t* lump_p;
|
lumpinfo_t* lump_p;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
int length;
|
int length;
|
||||||
filelump_t* fileinfo;
|
filelump_t* fileinfo;
|
||||||
|
|
||||||
if (!reloadname)
|
if (!reloadname)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( (handle = fopen (reloadname,"rb")) == NULL)
|
if ( (handle = fopen (reloadname,"rb")) == NULL)
|
||||||
I_Error ("W_Reload: couldn't open %s",reloadname);
|
I_Error ("W_Reload: couldn't open %s",reloadname);
|
||||||
|
|
||||||
printf("f5\n");
|
|
||||||
fread (&header, 1, sizeof(header), handle);
|
fread (&header, 1, sizeof(header), handle);
|
||||||
printf("f6\n");
|
|
||||||
lumpcount = LONG(header.numlumps);
|
lumpcount = LONG(header.numlumps);
|
||||||
header.infotableofs = LONG(header.infotableofs);
|
header.infotableofs = LONG(header.infotableofs);
|
||||||
length = lumpcount*sizeof(filelump_t);
|
length = lumpcount*sizeof(filelump_t);
|
||||||
fileinfo = malloc (length);
|
fileinfo = malloc (length);
|
||||||
fseek (handle, header.infotableofs, SEEK_SET);
|
fseek (handle, header.infotableofs, SEEK_SET);
|
||||||
printf("f7\n");
|
|
||||||
fread (fileinfo, 1, length, handle);
|
fread (fileinfo, 1, length, handle);
|
||||||
printf("f8\n");
|
|
||||||
|
|
||||||
// Fill in lumpinfo
|
// Fill in lumpinfo
|
||||||
lump_p = &lumpinfo[reloadlump];
|
lump_p = &lumpinfo[reloadlump];
|
||||||
|
|
||||||
for (i=reloadlump ;
|
for (i=reloadlump ;
|
||||||
i<reloadlump+lumpcount ;
|
i<reloadlump+lumpcount ;
|
||||||
i++,lump_p++, fileinfo++)
|
i++,lump_p++, fileinfo++)
|
||||||
{
|
{
|
||||||
if (lumpcache[i])
|
if (lumpcache[i])
|
||||||
Z_Free (lumpcache[i]);
|
Z_Free (lumpcache[i]);
|
||||||
|
|
||||||
lump_p->position = LONG(fileinfo->filepos);
|
lump_p->position = LONG(fileinfo->filepos);
|
||||||
lump_p->size = LONG(fileinfo->size);
|
lump_p->size = LONG(fileinfo->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (handle);
|
fclose (handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// W_InitMultipleFiles
|
// W_InitMultipleFiles
|
||||||
// Pass a null terminated list of files to use.
|
// Pass a null terminated list of files to use.
|
||||||
@ -294,27 +287,27 @@ void W_Reload (void)
|
|||||||
// does override all earlier ones.
|
// does override all earlier ones.
|
||||||
//
|
//
|
||||||
void W_InitMultipleFiles (char** filenames)
|
void W_InitMultipleFiles (char** filenames)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
// open all the files, load headers, and count lumps
|
// open all the files, load headers, and count lumps
|
||||||
numlumps = 0;
|
numlumps = 0;
|
||||||
|
|
||||||
// will be realloced as lumps are added
|
// will be realloced as lumps are added
|
||||||
lumpinfo = malloc(1);
|
lumpinfo = malloc(16384);
|
||||||
|
|
||||||
for ( ; *filenames ; filenames++)
|
for ( ; *filenames ; filenames++)
|
||||||
W_AddFile (*filenames);
|
W_AddFile (*filenames);
|
||||||
|
|
||||||
if (!numlumps)
|
if (!numlumps)
|
||||||
I_Error ("W_InitFiles: no files found");
|
I_Error ("W_InitFiles: no files found");
|
||||||
|
|
||||||
// set up caching
|
// set up caching
|
||||||
size = numlumps * sizeof(*lumpcache);
|
size = numlumps * sizeof(*lumpcache);
|
||||||
lumpcache = malloc (size);
|
lumpcache = malloc (size);
|
||||||
|
|
||||||
if (!lumpcache)
|
if (!lumpcache)
|
||||||
I_Error ("Couldn't allocate lumpcache");
|
I_Error ("Couldn't allocate lumpcache");
|
||||||
|
|
||||||
memset (lumpcache,0, size);
|
memset (lumpcache,0, size);
|
||||||
}
|
}
|
||||||
@ -328,7 +321,7 @@ void W_InitMultipleFiles (char** filenames)
|
|||||||
//
|
//
|
||||||
void W_InitFile (char* filename)
|
void W_InitFile (char* filename)
|
||||||
{
|
{
|
||||||
char* names[2];
|
char* names[2];
|
||||||
|
|
||||||
names[0] = filename;
|
names[0] = filename;
|
||||||
names[1] = NULL;
|
names[1] = NULL;
|
||||||
@ -355,14 +348,14 @@ int W_NumLumps (void)
|
|||||||
int W_CheckNumForName (char* name)
|
int W_CheckNumForName (char* name)
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
char s[9];
|
char s[9];
|
||||||
int x[2];
|
int x[2];
|
||||||
|
|
||||||
} name8;
|
} name8;
|
||||||
|
|
||||||
int v1;
|
int v1;
|
||||||
int v2;
|
int v2;
|
||||||
lumpinfo_t* lump_p;
|
lumpinfo_t* lump_p;
|
||||||
|
|
||||||
// make the name into two integers for easy compares
|
// make the name into two integers for easy compares
|
||||||
strncpy (name8.s,name,8);
|
strncpy (name8.s,name,8);
|
||||||
@ -371,7 +364,7 @@ int W_CheckNumForName (char* name)
|
|||||||
name8.s[8] = 0;
|
name8.s[8] = 0;
|
||||||
|
|
||||||
// case insensitive
|
// case insensitive
|
||||||
strupr (name8.s);
|
strupr (name8.s);
|
||||||
|
|
||||||
v1 = name8.x[0];
|
v1 = name8.x[0];
|
||||||
v2 = name8.x[1];
|
v2 = name8.x[1];
|
||||||
@ -382,11 +375,11 @@ int W_CheckNumForName (char* name)
|
|||||||
|
|
||||||
while (lump_p-- != lumpinfo)
|
while (lump_p-- != lumpinfo)
|
||||||
{
|
{
|
||||||
if ( *(int *)lump_p->name == v1
|
if ( *(int *)lump_p->name == v1
|
||||||
&& *(int *)&lump_p->name[4] == v2)
|
&& *(int *)&lump_p->name[4] == v2)
|
||||||
{
|
{
|
||||||
return lump_p - lumpinfo;
|
return lump_p - lumpinfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TFB. Not found.
|
// TFB. Not found.
|
||||||
@ -402,7 +395,7 @@ int W_CheckNumForName (char* name)
|
|||||||
//
|
//
|
||||||
int W_GetNumForName (char* name)
|
int W_GetNumForName (char* name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = W_CheckNumForName (name);
|
i = W_CheckNumForName (name);
|
||||||
|
|
||||||
@ -420,7 +413,7 @@ int W_GetNumForName (char* name)
|
|||||||
int W_LumpLength (int lump)
|
int W_LumpLength (int lump)
|
||||||
{
|
{
|
||||||
if (lump >= numlumps)
|
if (lump >= numlumps)
|
||||||
I_Error ("W_LumpLength: %i >= numlumps",lump);
|
I_Error ("W_LumpLength: %i >= numlumps",lump);
|
||||||
|
|
||||||
return lumpinfo[lump].size;
|
return lumpinfo[lump].size;
|
||||||
}
|
}
|
||||||
@ -434,38 +427,39 @@ int W_LumpLength (int lump)
|
|||||||
//
|
//
|
||||||
void
|
void
|
||||||
W_ReadLump
|
W_ReadLump
|
||||||
( int lump,
|
( int lump,
|
||||||
void* dest )
|
void* dest )
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
lumpinfo_t* l;
|
lumpinfo_t* l;
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
|
size_t bytes;
|
||||||
|
|
||||||
if (lump >= numlumps)
|
if (lump >= numlumps)
|
||||||
I_Error ("W_ReadLump: %i >= numlumps",lump);
|
I_Error ("W_ReadLump: %i >= numlumps",lump);
|
||||||
|
|
||||||
l = lumpinfo+lump;
|
l = lumpinfo+lump;
|
||||||
|
|
||||||
// ??? I_BeginRead ();
|
// ??? I_BeginRead ();
|
||||||
|
|
||||||
if (l->handle == -1)
|
if (l->handle == -1)
|
||||||
{
|
{
|
||||||
// reloadable file, so use open / read / close
|
// reloadable file, so use open / read / close
|
||||||
if ( (handle = fopen (reloadname,"rb")) == NULL)
|
if ( (handle = fopen (reloadname,"rb")) == NULL)
|
||||||
I_Error ("W_ReadLump: couldn't open %s",reloadname);
|
I_Error ("W_ReadLump: couldn't open %s",reloadname);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
handle = (FILE *)l->handle;
|
handle = (FILE *)l->handle;
|
||||||
|
|
||||||
fseek (handle, l->position, SEEK_SET);
|
fseek (handle, l->position, SEEK_SET);
|
||||||
c = fread (dest, 1, l->size, handle);
|
c = fread (dest, 1, l->size, handle);
|
||||||
if (c < l->size)
|
if (c < l->size)
|
||||||
I_Error ("W_ReadLump: only read %i of %i on lump %i",
|
I_Error ("W_ReadLump: only read %i of %i on lump %i",
|
||||||
c,l->size,lump);
|
c,l->size,lump);
|
||||||
|
|
||||||
if (l->handle == -1)
|
if (l->handle == -1)
|
||||||
fclose (handle);
|
fclose (handle);
|
||||||
|
|
||||||
// ??? I_EndRead ();
|
// ??? I_EndRead ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,28 +471,28 @@ W_ReadLump
|
|||||||
//
|
//
|
||||||
void*
|
void*
|
||||||
W_CacheLumpNum
|
W_CacheLumpNum
|
||||||
( int lump,
|
( int lump,
|
||||||
int tag )
|
int tag )
|
||||||
{
|
{
|
||||||
byte* ptr;
|
byte* ptr;
|
||||||
|
|
||||||
if ((unsigned)lump >= numlumps)
|
if ((unsigned)lump >= (unsigned)numlumps)
|
||||||
I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
|
I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
|
||||||
|
|
||||||
if (!lumpcache[lump])
|
if (!lumpcache[lump])
|
||||||
{
|
{
|
||||||
// read the lump in
|
// read the lump in
|
||||||
|
|
||||||
//printf ("cache miss on lump %i\n",lump);
|
//printf ("cache miss on lump %i\n",lump);
|
||||||
ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]);
|
ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]);
|
||||||
W_ReadLump (lump, lumpcache[lump]);
|
W_ReadLump (lump, lumpcache[lump]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//printf ("cache hit on lump %i\n",lump);
|
//printf ("cache hit on lump %i\n",lump);
|
||||||
Z_ChangeTag (lumpcache[lump],tag);
|
Z_ChangeTag (lumpcache[lump],tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lumpcache[lump];
|
return lumpcache[lump];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,8 +503,8 @@ W_CacheLumpNum
|
|||||||
//
|
//
|
||||||
void*
|
void*
|
||||||
W_CacheLumpName
|
W_CacheLumpName
|
||||||
( char* name,
|
( char* name,
|
||||||
int tag )
|
int tag )
|
||||||
{
|
{
|
||||||
return W_CacheLumpNum (W_GetNumForName(name), tag);
|
return W_CacheLumpNum (W_GetNumForName(name), tag);
|
||||||
}
|
}
|
||||||
@ -520,62 +514,69 @@ W_CacheLumpName
|
|||||||
//
|
//
|
||||||
// W_Profile
|
// W_Profile
|
||||||
//
|
//
|
||||||
int info[2500][10];
|
int info[2500][10];
|
||||||
int profilecount;
|
int profilecount;
|
||||||
|
|
||||||
void W_Profile (void)
|
void W_Profile (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
void* ptr;
|
void* ptr;
|
||||||
char ch;
|
char ch;
|
||||||
FILE* f;
|
FILE* f;
|
||||||
int j;
|
int j;
|
||||||
char name[9];
|
char name[9];
|
||||||
|
|
||||||
|
|
||||||
for (i=0 ; i<numlumps ; i++)
|
for (i=0 ; i<numlumps ; i++)
|
||||||
{
|
{
|
||||||
ptr = lumpcache[i];
|
ptr = lumpcache[i];
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
ch = ' ';
|
ch = ' ';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
|
block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
|
||||||
if (block->tag < PU_PURGELEVEL)
|
if (block->tag < PU_PURGELEVEL)
|
||||||
ch = 'S';
|
ch = 'S';
|
||||||
else
|
else
|
||||||
ch = 'P';
|
ch = 'P';
|
||||||
}
|
}
|
||||||
info[i][profilecount] = ch;
|
info[i][profilecount] = ch;
|
||||||
}
|
}
|
||||||
profilecount++;
|
profilecount++;
|
||||||
|
|
||||||
f = fopen ("waddump.txt","w");
|
f = fopen ("waddump.txt","w");
|
||||||
name[8] = 0;
|
name[8] = 0;
|
||||||
|
|
||||||
for (i=0 ; i<numlumps ; i++)
|
for (i=0 ; i<numlumps ; i++)
|
||||||
{
|
{
|
||||||
memcpy (name,lumpinfo[i].name,8);
|
memcpy (name,lumpinfo[i].name,8);
|
||||||
|
|
||||||
for (j=0 ; j<8 ; j++)
|
for (j=0 ; j<8 ; j++)
|
||||||
if (!name[j])
|
if (!name[j])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for ( ; j<8 ; j++)
|
for ( ; j<8 ; j++)
|
||||||
name[j] = ' ';
|
name[j] = ' ';
|
||||||
|
|
||||||
printf ("%s ",name);
|
//printf ("%s ",name);
|
||||||
|
|
||||||
for (j=0 ; j<profilecount ; j++)
|
for (j=0 ; j<profilecount ; j++)
|
||||||
fprintf (f," %c",info[i][j]);
|
fprintf (f," %c",info[i][j]);
|
||||||
|
|
||||||
printf ("\n");
|
//printf ("\n");
|
||||||
}
|
}
|
||||||
fclose (f);
|
fclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
// DESCRIPTION:
|
||||||
// Zone Memory Allocation. Neat.
|
// Zone Memory Allocation. Neat.
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -49,24 +49,24 @@ z_zone_rcsid[] = "$Id: z_zone.c,v 1.2 1997/12/29 19:51:30 pekangas Exp $";
|
|||||||
// because it will get overwritten automatically if needed.
|
// because it will get overwritten automatically if needed.
|
||||||
//
|
//
|
||||||
|
|
||||||
#define ZONEID 0x1d4a11
|
#define ZONEID 0x1d4a11
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
// total bytes malloced, including header
|
// total bytes malloced, including header
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
// start / end cap for linked list
|
// start / end cap for linked list
|
||||||
memblock_t blocklist;
|
memblock_t blocklist;
|
||||||
|
|
||||||
memblock_t* rover;
|
memblock_t* rover;
|
||||||
|
|
||||||
} memzone_t;
|
} memzone_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
memzone_t* mainzone;
|
memzone_t* mainzone;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -75,21 +75,21 @@ memzone_t* mainzone;
|
|||||||
//
|
//
|
||||||
void Z_ClearZone (memzone_t* zone)
|
void Z_ClearZone (memzone_t* zone)
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
|
|
||||||
// set the entire zone to one free block
|
// set the entire zone to one free block
|
||||||
zone->blocklist.next =
|
zone->blocklist.next =
|
||||||
zone->blocklist.prev =
|
zone->blocklist.prev =
|
||||||
block = (memblock_t *)( (byte *)zone + sizeof(memzone_t) );
|
block = (memblock_t *)( (byte *)zone + sizeof(memzone_t) );
|
||||||
|
|
||||||
zone->blocklist.user = (void *)zone;
|
zone->blocklist.user = (void *)zone;
|
||||||
zone->blocklist.tag = PU_STATIC;
|
zone->blocklist.tag = PU_STATIC;
|
||||||
zone->rover = block;
|
zone->rover = block;
|
||||||
|
|
||||||
block->prev = block->next = &zone->blocklist;
|
block->prev = block->next = &zone->blocklist;
|
||||||
|
|
||||||
// NULL indicates a free block.
|
// NULL indicates a free block.
|
||||||
block->user = NULL;
|
block->user = NULL;
|
||||||
|
|
||||||
block->size = zone->size - sizeof(memzone_t);
|
block->size = zone->size - sizeof(memzone_t);
|
||||||
}
|
}
|
||||||
@ -101,21 +101,21 @@ void Z_ClearZone (memzone_t* zone)
|
|||||||
//
|
//
|
||||||
void Z_Init (void)
|
void Z_Init (void)
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
mainzone = (memzone_t *)I_ZoneBase (&size);
|
mainzone = (memzone_t *)I_ZoneBase (&size);
|
||||||
mainzone->size = size;
|
mainzone->size = size;
|
||||||
|
|
||||||
// set the entire zone to one free block
|
// set the entire zone to one free block
|
||||||
mainzone->blocklist.next =
|
mainzone->blocklist.next =
|
||||||
mainzone->blocklist.prev =
|
mainzone->blocklist.prev =
|
||||||
block = (memblock_t *)( (byte *)mainzone + sizeof(memzone_t) );
|
block = (memblock_t *)( (byte *)mainzone + sizeof(memzone_t) );
|
||||||
|
|
||||||
mainzone->blocklist.user = (void *)mainzone;
|
mainzone->blocklist.user = (void *)mainzone;
|
||||||
mainzone->blocklist.tag = PU_STATIC;
|
mainzone->blocklist.tag = PU_STATIC;
|
||||||
mainzone->rover = block;
|
mainzone->rover = block;
|
||||||
|
|
||||||
block->prev = block->next = &mainzone->blocklist;
|
block->prev = block->next = &mainzone->blocklist;
|
||||||
|
|
||||||
// NULL indicates a free block.
|
// NULL indicates a free block.
|
||||||
@ -130,53 +130,53 @@ void Z_Init (void)
|
|||||||
//
|
//
|
||||||
void Z_Free (void* ptr)
|
void Z_Free (void* ptr)
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
memblock_t* other;
|
memblock_t* other;
|
||||||
|
|
||||||
block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
|
block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
|
||||||
|
|
||||||
if (block->id != ZONEID)
|
if (block->id != ZONEID)
|
||||||
I_Error ("Z_Free: freed a pointer without ZONEID");
|
I_Error ("Z_Free: freed a pointer without ZONEID");
|
||||||
|
|
||||||
if (block->user > (void **)0x100)
|
if (block->user > (void **)0x100)
|
||||||
{
|
{
|
||||||
// smaller values are not pointers
|
// smaller values are not pointers
|
||||||
// Note: OS-dependend?
|
// Note: OS-dependend?
|
||||||
|
|
||||||
// clear the user's mark
|
// clear the user's mark
|
||||||
*block->user = 0;
|
*block->user = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark as free
|
// mark as free
|
||||||
block->user = NULL;
|
block->user = NULL;
|
||||||
block->tag = 0;
|
block->tag = 0;
|
||||||
block->id = 0;
|
block->id = 0;
|
||||||
|
|
||||||
other = block->prev;
|
other = block->prev;
|
||||||
|
|
||||||
if (!other->user)
|
if (!other->user)
|
||||||
{
|
{
|
||||||
// merge with previous free block
|
// merge with previous free block
|
||||||
other->size += block->size;
|
other->size += block->size;
|
||||||
other->next = block->next;
|
other->next = block->next;
|
||||||
other->next->prev = other;
|
other->next->prev = other;
|
||||||
|
|
||||||
if (block == mainzone->rover)
|
if (block == mainzone->rover)
|
||||||
mainzone->rover = other;
|
mainzone->rover = other;
|
||||||
|
|
||||||
block = other;
|
block = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
other = block->next;
|
other = block->next;
|
||||||
if (!other->user)
|
if (!other->user)
|
||||||
{
|
{
|
||||||
// merge the next free block onto the end
|
// merge the next free block onto the end
|
||||||
block->size += other->size;
|
block->size += other->size;
|
||||||
block->next = other->next;
|
block->next = other->next;
|
||||||
block->next->prev = block;
|
block->next->prev = block;
|
||||||
|
|
||||||
if (other == mainzone->rover)
|
if (other == mainzone->rover)
|
||||||
mainzone->rover = block;
|
mainzone->rover = block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,20 +186,20 @@ void Z_Free (void* ptr)
|
|||||||
// Z_Malloc
|
// Z_Malloc
|
||||||
// You can pass a NULL user if the tag is < PU_PURGELEVEL.
|
// You can pass a NULL user if the tag is < PU_PURGELEVEL.
|
||||||
//
|
//
|
||||||
#define MINFRAGMENT 64
|
#define MINFRAGMENT 64
|
||||||
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
Z_Malloc
|
Z_Malloc
|
||||||
( int size,
|
( int size,
|
||||||
int tag,
|
int tag,
|
||||||
void* user )
|
void* user )
|
||||||
{
|
{
|
||||||
int extra;
|
int extra;
|
||||||
memblock_t* start;
|
memblock_t* start;
|
||||||
memblock_t* rover;
|
memblock_t* rover;
|
||||||
memblock_t* newblock;
|
memblock_t* newblock;
|
||||||
memblock_t* base;
|
memblock_t* base;
|
||||||
|
|
||||||
size = (size + 3) & ~3;
|
size = (size + 3) & ~3;
|
||||||
|
|
||||||
@ -216,40 +216,40 @@ Z_Malloc
|
|||||||
base = mainzone->rover;
|
base = mainzone->rover;
|
||||||
|
|
||||||
if (!base->prev->user)
|
if (!base->prev->user)
|
||||||
base = base->prev;
|
base = base->prev;
|
||||||
|
|
||||||
rover = base;
|
rover = base;
|
||||||
start = base->prev;
|
start = base->prev;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (rover == start)
|
if (rover == start)
|
||||||
{
|
{
|
||||||
// scanned all the way around the list
|
// scanned all the way around the list
|
||||||
I_Error ("Z_Malloc: failed on allocation of %i bytes", size);
|
I_Error ("Z_Malloc: failed on allocation of %i bytes", size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rover->user)
|
if (rover->user)
|
||||||
{
|
{
|
||||||
if (rover->tag < PU_PURGELEVEL)
|
if (rover->tag < PU_PURGELEVEL)
|
||||||
{
|
{
|
||||||
// hit a block that can't be purged,
|
// hit a block that can't be purged,
|
||||||
// so move base past it
|
// so move base past it
|
||||||
base = rover = rover->next;
|
base = rover = rover->next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// free the rover block (adding the size to base)
|
// free the rover block (adding the size to base)
|
||||||
|
|
||||||
// the rover can be the base block
|
// the rover can be the base block
|
||||||
base = base->prev;
|
base = base->prev;
|
||||||
Z_Free ((byte *)rover+sizeof(memblock_t));
|
Z_Free ((byte *)rover+sizeof(memblock_t));
|
||||||
base = base->next;
|
base = base->next;
|
||||||
rover = base->next;
|
rover = base->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rover = rover->next;
|
rover = rover->next;
|
||||||
} while (base->user || base->size < size);
|
} while (base->user || base->size < size);
|
||||||
|
|
||||||
|
|
||||||
@ -258,40 +258,40 @@ Z_Malloc
|
|||||||
|
|
||||||
if (extra > MINFRAGMENT)
|
if (extra > MINFRAGMENT)
|
||||||
{
|
{
|
||||||
// there will be a free fragment after the allocated block
|
// there will be a free fragment after the allocated block
|
||||||
newblock = (memblock_t *) ((byte *)base + size );
|
newblock = (memblock_t *) ((byte *)base + size );
|
||||||
newblock->size = extra;
|
newblock->size = extra;
|
||||||
|
|
||||||
// NULL indicates free block.
|
// NULL indicates free block.
|
||||||
newblock->user = NULL;
|
newblock->user = NULL;
|
||||||
newblock->tag = 0;
|
newblock->tag = 0;
|
||||||
newblock->prev = base;
|
newblock->prev = base;
|
||||||
newblock->next = base->next;
|
newblock->next = base->next;
|
||||||
newblock->next->prev = newblock;
|
newblock->next->prev = newblock;
|
||||||
|
|
||||||
base->next = newblock;
|
base->next = newblock;
|
||||||
base->size = size;
|
base->size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
// mark as an in use block
|
// mark as an in use block
|
||||||
base->user = user;
|
base->user = user;
|
||||||
*(void **)user = (void *) ((byte *)base + sizeof(memblock_t));
|
*(void **)user = (void *) ((byte *)base + sizeof(memblock_t));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tag >= PU_PURGELEVEL)
|
if (tag >= PU_PURGELEVEL)
|
||||||
I_Error ("Z_Malloc: an owner is required for purgable blocks");
|
I_Error ("Z_Malloc: an owner is required for purgable blocks");
|
||||||
|
|
||||||
// mark as in use, but unowned
|
// mark as in use, but unowned
|
||||||
base->user = (void *)2;
|
base->user = (void *)2;
|
||||||
}
|
}
|
||||||
base->tag = tag;
|
base->tag = tag;
|
||||||
|
|
||||||
// next allocation will start looking here
|
// next allocation will start looking here
|
||||||
mainzone->rover = base->next;
|
mainzone->rover = base->next;
|
||||||
|
|
||||||
base->id = ZONEID;
|
base->id = ZONEID;
|
||||||
|
|
||||||
return (void *) ((byte *)base + sizeof(memblock_t));
|
return (void *) ((byte *)base + sizeof(memblock_t));
|
||||||
@ -304,25 +304,25 @@ Z_Malloc
|
|||||||
//
|
//
|
||||||
void
|
void
|
||||||
Z_FreeTags
|
Z_FreeTags
|
||||||
( int lowtag,
|
( int lowtag,
|
||||||
int hightag )
|
int hightag )
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
memblock_t* next;
|
memblock_t* next;
|
||||||
|
|
||||||
for (block = mainzone->blocklist.next ;
|
for (block = mainzone->blocklist.next ;
|
||||||
block != &mainzone->blocklist ;
|
block != &mainzone->blocklist ;
|
||||||
block = next)
|
block = next)
|
||||||
{
|
{
|
||||||
// get link before freeing
|
// get link before freeing
|
||||||
next = block->next;
|
next = block->next;
|
||||||
|
|
||||||
// free block?
|
// free block?
|
||||||
if (!block->user)
|
if (!block->user)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (block->tag >= lowtag && block->tag <= hightag)
|
if (block->tag >= lowtag && block->tag <= hightag)
|
||||||
Z_Free ( (byte *)block+sizeof(memblock_t));
|
Z_Free ( (byte *)block+sizeof(memblock_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,37 +334,37 @@ Z_FreeTags
|
|||||||
//
|
//
|
||||||
void
|
void
|
||||||
Z_DumpHeap
|
Z_DumpHeap
|
||||||
( int lowtag,
|
( int lowtag,
|
||||||
int hightag )
|
int hightag )
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
|
|
||||||
printf ("zone size: %i location: %p\n",
|
//printf ("zone size: %i location: %p\n",
|
||||||
mainzone->size,mainzone);
|
// mainzone->size,mainzone);
|
||||||
|
|
||||||
printf ("tag range: %i to %i\n",
|
//printf ("tag range: %i to %i\n",
|
||||||
lowtag, hightag);
|
// lowtag, hightag);
|
||||||
|
|
||||||
for (block = mainzone->blocklist.next ; ; block = block->next)
|
for (block = mainzone->blocklist.next ; ; block = block->next)
|
||||||
{
|
{
|
||||||
if (block->tag >= lowtag && block->tag <= hightag)
|
if (block->tag >= lowtag && block->tag <= hightag)
|
||||||
printf ("block:%p size:%7i user:%p tag:%3i\n",
|
printf ("block:%p size:%7i user:%p tag:%3i\n",
|
||||||
block, block->size, block->user, block->tag);
|
block, block->size, block->user, block->tag);
|
||||||
|
|
||||||
if (block->next == &mainzone->blocklist)
|
if (block->next == &mainzone->blocklist)
|
||||||
{
|
{
|
||||||
// all blocks have been hit
|
// all blocks have been hit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (byte *)block + block->size != (byte *)block->next)
|
if ( (byte *)block + block->size != (byte *)block->next)
|
||||||
printf ("ERROR: block size does not touch the next block\n");
|
printf ("ERROR: block size does not touch the next block\n");
|
||||||
|
|
||||||
if ( block->next->prev != block)
|
if ( block->next->prev != block)
|
||||||
printf ("ERROR: next block doesn't have proper back link\n");
|
printf ("ERROR: next block doesn't have proper back link\n");
|
||||||
|
|
||||||
if (!block->user && !block->next->user)
|
if (!block->user && !block->next->user)
|
||||||
printf ("ERROR: two consecutive free blocks\n");
|
printf ("ERROR: two consecutive free blocks\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,29 +374,29 @@ Z_DumpHeap
|
|||||||
//
|
//
|
||||||
void Z_FileDumpHeap (FILE* f)
|
void Z_FileDumpHeap (FILE* f)
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
|
|
||||||
fprintf (f,"zone size: %i location: %p\n",mainzone->size,mainzone);
|
//printf ("zone size: %i location: %p\n",mainzone->size,mainzone);
|
||||||
|
|
||||||
for (block = mainzone->blocklist.next ; ; block = block->next)
|
for (block = mainzone->blocklist.next ; ; block = block->next)
|
||||||
{
|
{
|
||||||
fprintf (f,"block:%p size:%7i user:%p tag:%3i\n",
|
printf ("block:%p size:%7i user:%p tag:%3i\n",
|
||||||
block, block->size, block->user, block->tag);
|
block, block->size, block->user, block->tag);
|
||||||
|
|
||||||
if (block->next == &mainzone->blocklist)
|
if (block->next == &mainzone->blocklist)
|
||||||
{
|
{
|
||||||
// all blocks have been hit
|
// all blocks have been hit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (byte *)block + block->size != (byte *)block->next)
|
if ( (byte *)block + block->size != (byte *)block->next)
|
||||||
fprintf (f,"ERROR: block size does not touch the next block\n");
|
printf ("ERROR: block size does not touch the next block\n");
|
||||||
|
|
||||||
if ( block->next->prev != block)
|
if ( block->next->prev != block)
|
||||||
fprintf (f,"ERROR: next block doesn't have proper back link\n");
|
printf ("ERROR: next block doesn't have proper back link\n");
|
||||||
|
|
||||||
if (!block->user && !block->next->user)
|
if (!block->user && !block->next->user)
|
||||||
fprintf (f,"ERROR: two consecutive free blocks\n");
|
printf ("ERROR: two consecutive free blocks\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,24 +407,24 @@ void Z_FileDumpHeap (FILE* f)
|
|||||||
//
|
//
|
||||||
void Z_CheckHeap (void)
|
void Z_CheckHeap (void)
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
|
|
||||||
for (block = mainzone->blocklist.next ; ; block = block->next)
|
for (block = mainzone->blocklist.next ; ; block = block->next)
|
||||||
{
|
{
|
||||||
if (block->next == &mainzone->blocklist)
|
if (block->next == &mainzone->blocklist)
|
||||||
{
|
{
|
||||||
// all blocks have been hit
|
// all blocks have been hit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (byte *)block + block->size != (byte *)block->next)
|
if ( (byte *)block + block->size != (byte *)block->next)
|
||||||
I_Error ("Z_CheckHeap: block size does not touch the next block\n");
|
I_Error ("Z_CheckHeap: block size does not touch the next block\n");
|
||||||
|
|
||||||
if ( block->next->prev != block)
|
if ( block->next->prev != block)
|
||||||
I_Error ("Z_CheckHeap: next block doesn't have proper back link\n");
|
I_Error ("Z_CheckHeap: next block doesn't have proper back link\n");
|
||||||
|
|
||||||
if (!block->user && !block->next->user)
|
if (!block->user && !block->next->user)
|
||||||
I_Error ("Z_CheckHeap: two consecutive free blocks\n");
|
I_Error ("Z_CheckHeap: two consecutive free blocks\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,18 +436,18 @@ void Z_CheckHeap (void)
|
|||||||
//
|
//
|
||||||
void
|
void
|
||||||
Z_ChangeTag2
|
Z_ChangeTag2
|
||||||
( void* ptr,
|
( void* ptr,
|
||||||
int tag )
|
int tag )
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
|
|
||||||
block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
|
block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
|
||||||
|
|
||||||
if (block->id != ZONEID)
|
if (block->id != ZONEID)
|
||||||
I_Error ("Z_ChangeTag: freed a pointer without ZONEID");
|
I_Error ("Z_ChangeTag: freed a pointer without ZONEID");
|
||||||
|
|
||||||
if (tag >= PU_PURGELEVEL && (unsigned)block->user < 0x100)
|
if (tag >= PU_PURGELEVEL && (unsigned)block->user < 0x100)
|
||||||
I_Error ("Z_ChangeTag: an owner is required for purgable blocks");
|
I_Error ("Z_ChangeTag: an owner is required for purgable blocks");
|
||||||
|
|
||||||
block->tag = tag;
|
block->tag = tag;
|
||||||
}
|
}
|
||||||
@ -459,17 +459,17 @@ Z_ChangeTag2
|
|||||||
//
|
//
|
||||||
int Z_FreeMemory (void)
|
int Z_FreeMemory (void)
|
||||||
{
|
{
|
||||||
memblock_t* block;
|
memblock_t* block;
|
||||||
int free;
|
int free;
|
||||||
|
|
||||||
free = 0;
|
free = 0;
|
||||||
|
|
||||||
for (block = mainzone->blocklist.next ;
|
for (block = mainzone->blocklist.next ;
|
||||||
block != &mainzone->blocklist;
|
block != &mainzone->blocklist;
|
||||||
block = block->next)
|
block = block->next)
|
||||||
{
|
{
|
||||||
if (!block->user || block->tag >= PU_PURGELEVEL)
|
if (!block->user || block->tag >= PU_PURGELEVEL)
|
||||||
free += block->size;
|
free += block->size;
|
||||||
}
|
}
|
||||||
return free;
|
return free;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user