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