================
-= fbDOOM =
+= doomgeneric =
================
-Adaptation of the original DOOM
-to be easily portable to framebuffer devices with minimal depenencies.
-Runs on:
-* Plain desktop Linux framebuffer,
-* Siglent SSA 3021X Spectrum Analyzer,
-* Frosted OS
-
-To build (example):
-* cd fbdoom
-* make CROSS_COMPILE=arm-linux-gnueabihf-
-
+To port DOOM easly, I made some changes to source code.
+Now, all you need to do is implement the functions in doomgeneric.h to port DOOM to a new system.
+doomgeneric_win.c is a Windows GDI port. It is also a good example for how to port doomgeneric.
+Sound is not supported for now.
Original readme
===============
+++ /dev/null
-//#define DOOM2
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <process.h>
-#include <conio.h>
-#include <dos.h>
-
-#include "doomnet.h"
-//#include "ipxstr.h"
-#include "ipx_frch.h" // FRENCH VERSION
-
-doomcom_t doomcom;
-int vectorishooked;
-void interrupt (*olddoomvect) (void);
-
-
-
-/*
-=============
-=
-= LaunchDOOM
-=
-These fields in doomcom should be filled in before calling:
-
- short numnodes; // console is allways node 0
- short ticdup; // 1 = no duplication, 2-5 = dup for
-slow nets
- short extratics; // 1 = send a backup tic in every
-packet
-
- short consoleplayer; // 0-3 = player number
- short numplayers; // 1-4
- short angleoffset; // 1 = left, 0 = center, -1 = right
- short drone; // 1 = drone
-=============
-*/
-
-void LaunchDOOM (void)
-{
- char *newargs[99];
- char adrstring[10];
- long flatadr;
-
-// prepare for DOOM
- doomcom.id = DOOMCOM_ID;
-
-// hook the interrupt vector
- olddoomvect = getvect (doomcom.intnum);
- setvect (doomcom.intnum,(void interrupt (*)(void))MK_FP(_CS,
-(int)NetISR));
- vectorishooked = 1;
-
-// build the argument list for DOOM, adding a -net &doomcom
- memcpy (newargs, _argv, (_argc+1)*2);
- newargs[_argc] = "-net";
- flatadr = (long)_DS*16 + (unsigned)&doomcom;
- sprintf (adrstring,"%lu",flatadr);
- newargs[_argc+1] = adrstring;
- newargs[_argc+2] = NULL;
-
- if (!access("doom2.exe",0))
- spawnv (P_WAIT, "doom2", newargs);
- else
- spawnv (P_WAIT, "doom", newargs);
-
- #ifdef DOOM2
- printf (STR_RETURNED"\n");
- #else
- printf ("Returned from DOOM\n");
- #endif
-}
+++ /dev/null
-// doomnet.h
-
-#define PEL_WRITE_ADR 0x3c8
-#define PEL_DATA 0x3c9
-
-#define I_ColorBlack(r,g,b) {outp(PEL_WRITE_ADR,0);outp(PEL_DATA,r);outp(PEL_DATA,g);outp(PEL_DATA,b);};
-
-
-
-#define MAXNETNODES 8 // max computers in a game
-#define MAXPLAYERS 4 // 4 players max + drones
-
-
-#define CMD_SEND 1
-#define CMD_GET 2
-
-#define DOOMCOM_ID 0x12345678l
-
-typedef struct
-{
- long id;
- short intnum; // DOOM executes an int to send commands
-
-// communication between DOOM and the driver
- short command; // CMD_SEND or CMD_GET
- short remotenode; // dest for send, set by get (-1 = no packet)
- short datalength; // bytes in doomdata to be sent / bytes read
-
-// info common to all nodes
- short numnodes; // console is allways node 0
- short ticdup; // 1 = no duplication, 2-5 = dup for slow nets
- short extratics; // 1 = send a backup tic in every packet
- short deathmatch; // 1 = deathmatch
- short savegame; // -1 = new game, 0-5 = load savegame
- short episode; // 1-3
- short map; // 1-9
- short skill; // 1-5
-
-// info specific to this node
- short consoleplayer; // 0-3 = player number
- short numplayers; // 1-4
- short angleoffset; // 1 = left, 0 = center, -1 = right
- short drone; // 1 = drone
-
-// packet data to be sent
- char data[512];
-} doomcom_t;
-
-
-
-extern doomcom_t doomcom;
-extern void interrupt (*olddoomvect) (void);
-extern int vectorishooked;
-
-int CheckParm (char *check);
-void LaunchDOOM (void);
-void interrupt NetISR (void);
-
+++ /dev/null
-// ipxnet.c
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <dos.h>
-#include <string.h>
-#include <process.h>
-#include <values.h>
-
-#include "ipxnet.h"
-
-/*
-==========================================================================
-===
-
- IPX PACKET DRIVER
-
-==========================================================================
-===
-*/
-
-packet_t packets[NUMPACKETS];
-
-nodeadr_t nodeadr[MAXNETNODES+1]; // first is local, last is broadcast
-
-nodeadr_t remoteadr; // set by each GetPacket
-
-localadr_t localadr; // set at startup
-
-extern int socketid;
-
-void far (*IPX)(void);
-
-long localtime; // for time stamp in packets
-long remotetime;
-
-//===========================================================================
-
-int OpenSocket(short socketNumber)
-{
- _DX = socketNumber;
- _BX = 0;
- _AL = 0;
- IPX();
- if(_AL)
- Error ("OpenSocket: 0x%x", _AL);
- return _DX;
-}
-
-
-void CloseSocket(short socketNumber)
-{
- _DX = socketNumber;
- _BX = 1;
- IPX();
-}
-
-void ListenForPacket(ECB *ecb)
-{
- _SI = FP_OFF(ecb);
- _ES = FP_SEG(ecb);
- _BX = 4;
- IPX();
- if(_AL)
- Error ("ListenForPacket: 0x%x", _AL);
-}
-
-
-void GetLocalAddress (void)
-{
- _SI = FP_OFF(&localadr);
- _ES = FP_SEG(&localadr);
- _BX = 9;
- IPX();
-}
-
-
-
-/*
-====================
-=
-= InitNetwork
-=
-====================
-*/
-
-void InitNetwork (void)
-{
- int i,j;
-
-//
-// get IPX function address
-//
- _AX = 0x7a00;
- geninterrupt(0x2f);
- if(_AL != 0xff)
- Error ("IPX not detected\n");
- IPX = MK_FP(_ES, _DI);
-
-
-//
-// allocate a socket for sending and receiving
-//
- socketid = OpenSocket ( (socketid>>8) + ((socketid&255)<<8) );
-
- GetLocalAddress();
-
-//
-// set up several receiving ECBs
-//
- memset (packets,0,NUMPACKETS*sizeof(packet_t));
-
- for (i=1 ; i<NUMPACKETS ; i++)
- {
- packets[i].ecb.ECBSocket = socketid;
- packets[i].ecb.FragmentCount = 1;
- packets[i].ecb.fAddress[0] = FP_OFF(&packets[i].ipx);
- packets[i].ecb.fAddress[1] = FP_SEG(&packets[i].ipx);
- packets[i].ecb.fSize = sizeof(packet_t)-sizeof(ECB);
-
- ListenForPacket (&packets[i].ecb);
- }
-
-//
-// set up a sending ECB
-//
- memset (&packets[0],0,sizeof(packets[0]));
-
- packets[0].ecb.ECBSocket = socketid;
- packets[0].ecb.FragmentCount = 2;
- packets[0].ecb.fAddress[0] = FP_OFF(&packets[0].ipx);
- packets[0].ecb.fAddress[1] = FP_SEG(&packets[0].ipx);
- for (j=0 ; j<4 ; j++)
- packets[0].ipx.dNetwork[j] = localadr.network[j];
- packets[0].ipx.dSocket[0] = socketid&255;
- packets[0].ipx.dSocket[1] = socketid>>8;
- packets[0].ecb.f2Address[0] = FP_OFF(&doomcom.data);
- packets[0].ecb.f2Address[1] = FP_SEG(&doomcom.data);
-
-// known local node at 0
- for (i=0 ; i<6 ; i++)
- nodeadr[0].node[i] = localadr.node[i];
-
-// broadcast node at MAXNETNODES
- for (j=0 ; j<6 ; j++)
- nodeadr[MAXNETNODES].node[j] = 0xff;
-}
-
-
-/*
-====================
-=
-= ShutdownNetwork
-=
-====================
-*/
-
-void ShutdownNetwork (void)
-{
- if (IPX)
- CloseSocket (socketid);
-}
-
-
-/*
-==============
-=
-= SendPacket
-=
-= A destination of MAXNETNODES is a broadcast
-==============
-*/
-
-void SendPacket (int destination)
-{
- int j;
-
-// set the time
- packets[0].time = localtime;
-
-// set the address
- for (j=0 ; j<6 ; j++)
- packets[0].ipx.dNode[j] =
-packets[0].ecb.ImmediateAddress[j] =
- nodeadr[destination].node[j];
-
-// set the length (ipx + time + datalength)
- packets[0].ecb.fSize = sizeof(IPXPacket) + 4;
- packets[0].ecb.f2Size = doomcom.datalength + 4;
-
-// send the packet
- _SI = FP_OFF(&packets[0]);
- _ES = FP_SEG(&packets[0]);
- _BX = 3;
- IPX();
- if(_AL)
- Error("SendPacket: 0x%x", _AL);
-
- while(packets[0].ecb.InUseFlag != 0)
- {
- // IPX Relinquish Control - polled drivers MUST have this here!
- _BX = 10;
- IPX();
- }
-}
-
-
-unsigned short ShortSwap (unsigned short i)
-{
- return ((i&255)<<8) + ((i>>8)&255);
-}
-
-/*
-==============
-=
-= GetPacket
-=
-= Returns false if no packet is waiting
-=
-==============
-*/
-
-int GetPacket (void)
-{
- int packetnum;
- int i, j;
- long besttic;
- packet_t *packet;
-
-// if multiple packets are waiting, return them in order by time
-
- besttic = MAXLONG;
- packetnum = -1;
- doomcom.remotenode = -1;
-
- for ( i = 1 ; i < NUMPACKETS ; i++)
- {
- if (packets[i].ecb.InUseFlag)
- {
- continue;
- }
-
- if (packets[i].time < besttic)
- {
- besttic = packets[i].time;
- packetnum = i;
- }
- }
-
- if (besttic == MAXLONG)
- return 0; // no packets
-
- packet = &packets[packetnum];
-
- if (besttic == -1 && localtime != -1)
- {
- ListenForPacket (&packet->ecb);
- return 0; // setup broadcast from other game
- }
-
- remotetime = besttic;
-
-//
-// got a good packet
-//
- if (packet->ecb.CompletionCode)
- Error ("GetPacket: ecb.ComletionCode = 0x%x",packet->ecb.CompletionCode);
-
-// set remoteadr to the sender of the packet
- memcpy (&remoteadr, packet->ipx.sNode, sizeof(remoteadr));
- for (i=0 ; i<doomcom.numnodes ; i++)
- if (!memcmp(&remoteadr, &nodeadr[i], sizeof(remoteadr)))
- break;
- if (i < doomcom.numnodes)
- doomcom.remotenode = i;
- else
- {
- if (localtime != -1)
- { // this really shouldn't happen
- ListenForPacket (&packet->ecb);
- return 0;
- }
- }
-
-// copy out the data
- doomcom.datalength = ShortSwap(packet->ipx.PacketLength) - 38;
- memcpy (&doomcom.data, &packet->data, doomcom.datalength);
-
-// repost the ECB
- ListenForPacket (&packet->ecb);
-
- return 1;
-}
-
+++ /dev/null
-// ipxnet.h
-
-
-typedef struct
-{
- char private[512];
-} doomdata_t;
-
-
-#include "DoomNet.h"
-
-//===========================================================================
-
-#define NUMPACKETS 10 // max outstanding packets before loss
-
-// setupdata_t is used as doomdata_t during setup
-typedef struct
-{
- short gameid; // so multiple games can setup at once
- short drone;
- short nodesfound;
- short nodeswanted;
-} setupdata_t;
-
-
-
-typedef unsigned char BYTE;
-typedef unsigned short WORD;
-typedef unsigned long LONG;
-
-typedef struct IPXPacketStructure
-{
- WORD PacketCheckSum; /* high-low */
- WORD PacketLength; /* high-low */
- BYTE PacketTransportControl;
- BYTE PacketType;
-
- BYTE dNetwork[4]; /* high-low */
- BYTE dNode[6]; /* high-low */
- BYTE dSocket[2]; /* high-low */
-
- BYTE sNetwork[4]; /* high-low */
- BYTE sNode[6]; /* high-low */
- BYTE sSocket[2]; /* high-low */
-} IPXPacket;
-
-
-typedef struct
-{
- BYTE network[4]; /* high-low */
- BYTE node[6]; /* high-low */
-} localadr_t;
-
-typedef struct
-{
- BYTE node[6]; /* high-low */
-} nodeadr_t;
-
-typedef struct ECBStructure
-{
- WORD Link[2]; /* offset-segment */
- WORD ESRAddress[2]; /* offset-segment */
- BYTE InUseFlag;
- BYTE CompletionCode;
- WORD ECBSocket; /* high-low */
- BYTE IPXWorkspace[4]; /* N/A */
- BYTE DriverWorkspace[12]; /* N/A */
- BYTE ImmediateAddress[6]; /* high-low */
- WORD FragmentCount; /* low-high */
-
- WORD fAddress[2]; /* offset-segment */
- WORD fSize; /* low-high */
-
- WORD f2Address[2]; /* offset-segment */
- WORD f2Size; /* low-high */
-} ECB;
-
-
-// time is used by the communication driver to sequence packets returned
-// to DOOM when more than one is waiting
-
-typedef struct
-{
- ECB ecb;
- IPXPacket ipx;
-
- long time;
- doomdata_t data;
-} packet_t;
-
-
-extern doomcom_t doomcom;
-extern int gameid;
-
-extern nodeadr_t nodeadr[MAXNETNODES+1];
-extern int localnodenum;
-
-extern long localtime; // for time stamp in packets
-extern long remotetime; // timestamp of last packet gotten
-
-extern nodeadr_t remoteadr;
-
-extern int myargc;
-
-extern char **myargv;
-
-void Error (char *error, ...);
-
-
-void InitNetwork (void);
-void ShutdownNetwork (void);
-void SendPacket (int destination);
-int GetPacket (void);
-int CheckParm (char *check);
-
-void PrintAddress (nodeadr_t *adr, char *str);
-
+++ /dev/null
-// ipxsetup.c
-
-#define DOOM2
-
-#include <conio.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <dos.h>
-#include <string.h>
-#include <process.h>
-#include <stdarg.h>
-#include <bios.h>
-
-#include "ipxnet.h"
-//#include "ipxstr.h"
-#include "ipx_frch.h" // FRENCH VERSION
-
-int gameid;
-int numnetnodes;
-int socketid = 0x869c; // 0x869c is the official DOOM socket
-int myargc;
-char **myargv;
-
-setupdata_t nodesetup[MAXNETNODES];
-
-
-/*
-=================
-=
-= Error
-=
-= For abnormal program terminations
-=
-=================
-*/
-
-void Error (char *error, ...)
-{
- va_list argptr;
-
- if (vectorishooked)
- setvect (doomcom.intnum,olddoomvect);
-
- va_start (argptr,error);
- vprintf (error,argptr);
- va_end (argptr);
- printf ("\n");
- ShutdownNetwork ();
- exit (1);
-}
-
-
-/*
-=================
-=
-= 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 CheckParm(char *parm)
- {
- int i;
-
- for(i = 1; i < myargc; i++)
- if(stricmp(parm, myargv[i]) == 0)
- return i;
-
- return 0;
- }
-
-
-/*
-=============
-=
-= NetISR
-=
-=============
-*/
-
-void interrupt NetISR (void)
-{
- if (doomcom.command == CMD_SEND)
- {
- localtime++;
- SendPacket (doomcom.remotenode);
- }
- else if (doomcom.command == CMD_GET)
- {
- GetPacket ();
- }
-}
-
-
-
-/*
-===================
-=
-= LookForNodes
-=
-= Finds all the nodes for the game and works out player numbers among
-them
-=
-= Exits with nodesetup[0..numnodes] and nodeadr[0..numnodes] filled in
-===================
-*/
-
-void LookForNodes (void)
-{
- int i,j,k;
- int netids[MAXNETNODES];
- int netplayer[MAXNETNODES];
- struct time time;
- int oldsec;
- setupdata_t *setup, *dest;
- char str[80];
- int total, console;
-
-//
-// wait until we get [numnetnodes] packets, then start playing
-// the playernumbers are assigned by netid
-//
- printf(STR_ATTEMPT, numnetnodes);
-
- printf (STR_LOOKING);
-
- oldsec = -1;
- setup = (setupdata_t *)&doomcom.data;
- localtime = -1; // in setup time, not game time
-
-//
-// build local setup info
-//
- nodesetup[0].nodesfound = 1;
- nodesetup[0].nodeswanted = numnetnodes;
- doomcom.numnodes = 1;
-
- do
- {
-//
-// check for aborting
-//
- while ( bioskey(1) )
- {
- if ( (bioskey (0) & 0xff) == 27)
- Error ("\n\n"STR_NETABORT);
- }
-
-//
-// listen to the network
-//
- while (GetPacket ())
- {
- if (doomcom.remotenode == -1)
- dest = &nodesetup[doomcom.numnodes];
- else
- dest = &nodesetup[doomcom.remotenode];
-
- if (remotetime != -1)
- { // an early game packet, not a setup packet
- if (doomcom.remotenode == -1)
- Error (STR_UNKNOWN);
- // if it allready started, it must have found all nodes
- dest->nodesfound = dest->nodeswanted;
- continue;
- }
-
- // update setup ingo
- memcpy (dest, setup, sizeof(*dest) );
-
- if (doomcom.remotenode != -1)
- continue; // allready know that node address
-
- //
- // this is a new node
- //
- memcpy (&nodeadr[doomcom.numnodes], &remoteadr
- , sizeof(nodeadr[doomcom.numnodes]) );
-
- //
- // if this node has a lower address, take all startup info
- //
- if ( memcmp (&remoteadr, &nodeadr[0], sizeof(&remoteadr) )
-< 0 )
- {
- }
-
- doomcom.numnodes++;
-
- printf ("\n"STR_FOUND"\n");
-
- if (doomcom.numnodes < numnetnodes)
- printf (STR_LOOKING);
- }
-//
-// we are done if all nodes have found all other nodes
-//
- for (i=0 ; i<doomcom.numnodes ; i++)
- if (nodesetup[i].nodesfound != nodesetup[i].nodeswanted)
- break;
-
- if (i == nodesetup[0].nodeswanted)
- break; // got them all
-
-//
-// send out a broadcast packet every second
-//
- gettime (&time);
- if (time.ti_sec == oldsec)
- continue;
- oldsec = time.ti_sec;
-
- printf (".");
- doomcom.datalength = sizeof(*setup);
-
- nodesetup[0].nodesfound = doomcom.numnodes;
-
- memcpy (&doomcom.data, &nodesetup[0], sizeof(*setup));
-
- SendPacket (MAXNETNODES); // send to all
-
- } while (1);
-
-//
-// count players
-//
- total = 0;
- console = 0;
-
- for (i=0 ; i<numnetnodes ; i++)
- {
- if (nodesetup[i].drone)
- continue;
- total++;
- if (total > MAXPLAYERS)
- Error (STR_MORETHAN,MAXPLAYERS);
- if (memcmp (&nodeadr[i], &nodeadr[0], sizeof(nodeadr[0])) < 0)
- console++;
- }
-
-
- if (!total)
- Error (STR_NONESPEC);
-
- doomcom.consoleplayer = console;
- doomcom.numplayers = total;
-
- printf (STR_CONSOLEIS"\n", console+1, total);
-}
-
-
-//========================================================
-//
-// Find a Response File
-//
-//========================================================
-void FindResponseFile (void)
-{
- int i;
- #define MAXARGVS 100
-
- for (i = 1;i < myargc;i++)
- if (myargv[i][0] == '@')
- {
- FILE * handle;
- int size;
- int k;
- int index;
- int indexinfile;
- char *infile;
- char *file;
- char *moreargs[20];
- char *firstargv;
-
- // READ THE RESPONSE FILE INTO MEMORY
- handle = fopen (&myargv[i][1],"rb");
- if (!handle)
- Error (STR_NORESP);
- printf(STR_FOUNDRESP" \"%s\"!\n",strupr(&myargv[i][1]));
- fseek (handle,0,SEEK_END);
- size = ftell(handle);
- fseek (handle,0,SEEK_SET);
- file = malloc (size);
- fread (file,size,1,handle);
- fclose (handle);
-
- // KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
- for (index = 0,k = i+1; k < myargc; k++)
- moreargs[index++] = myargv[k];
-
- firstargv = myargv[0];
- myargv = malloc(sizeof(char *)*MAXARGVS);
- memset(myargv,0,sizeof(char *)*MAXARGVS);
- myargv[0] = firstargv;
-
- infile = file;
- indexinfile = k = 0;
- indexinfile++; // SKIP PAST ARGV[0] (KEEP IT)
- do
- {
- myargv[indexinfile++] = infile+k;
- while(k < size &&
- ((*(infile+k)>= ' '+1) && (*(infile+k)<='z')))
- k++;
- *(infile+k) = 0;
- while(k < size &&
- ((*(infile+k)<= ' ') || (*(infile+k)>'z')))
- k++;
- } while(k < size);
-
- for (k = 0;k < index;k++)
- myargv[indexinfile++] = moreargs[k];
- myargc = indexinfile;
-
- // DISPLAY ARGS
-// printf("%d command-line args:\n",myargc);
-// for (k=1;k<myargc;k++)
-// printf("%s\n",myargv[k]);
-
- break;
- }
-}
-
-
-/*
-=============
-=
-= main
-=
-=============
-*/
-
-void main (void)
- {
- int i;
- unsigned char far *vector;
-
-//
-// determine game parameters
-//
- gameid = 0;
- numnetnodes = 2;
- doomcom.ticdup = 1;
- doomcom.extratics = 1;
- doomcom.episode = 1;
- doomcom.map = 1;
- doomcom.skill = 2;
- doomcom.deathmatch = 0;
-
- printf("\n"
- "-----------------------------\n"
- #ifdef DOOM2
- STR_DOOMNETDRV"\n"
- #else
- "DOOM NETWORK DEVICE DRIVER\n"
- #endif
- "v1.22\n"
- "-----------------------------\n");
-
- myargc = _argc;
- myargv = _argv;
- FindResponseFile();
-
- if((i = CheckParm("-nodes")) != 0)
- numnetnodes = atoi(myargv[i+1]);
-
- if((i = CheckParm("-vector")) != 0)
- {
- doomcom.intnum = sscanf ("0x%x",myargv[i+1]);
- vector = *(char far * far *)(doomcom.intnum*4);
- if(vector != NULL && *vector != 0xcf)
- {
- printf(STR_VECTSPEC"\n", doomcom.intnum);
- exit(-1);
- }
- }
- else
- {
- for(doomcom.intnum = 0x60 ; doomcom.intnum <= 0x66 ;
-doomcom.intnum++)
- {
- vector = *(char far * far *)(doomcom.intnum*4);
- if(vector == NULL || *vector == 0xcf)
- break;
- }
- if(doomcom.intnum == 0x67)
- {
- printf(STR_NONULL"\n");
- exit(-1);
- }
- }
- printf(STR_COMMVECT"\n",doomcom.intnum);
-
- if((i = CheckParm("-port")) != 0)
- {
- socketid = atoi (myargv[i+1]);
- printf (STR_USEALT"\n", socketid);
- }
-
- InitNetwork ();
-
- LookForNodes ();
-
- localtime = 0;
-
- LaunchDOOM ();
-
- ShutdownNetwork ();
-
- if (vectorishooked)
- setvect (doomcom.intnum,olddoomvect);
-
- exit(0);
- }
-
-
+++ /dev/null
-#define STR_NETABORT "Network game synchronization aborted."
-#define STR_UNKNOWN "Got an unknown game packet during setup"
-#define STR_FOUND "Found a node!"
-#define STR_LOOKING "Looking for a node"
-#define STR_MORETHAN "More than %i players specified!"
-#define STR_NONESPEC "No players specified for game!"
-#define STR_CONSOLEIS "Console is player %i of %i"
-#define STR_NORESP "No such response file!"
-#define STR_FOUNDRESP "Found response file"
-#define STR_DOOMNETDRV "DOOM II NETWORK DEVICE DRIVER"
-#define STR_VECTSPEC "The specified vector (0x%02x) was already hooked."
-#define STR_NONULL \
-"Warning: no NULL or iret interrupt vectors were found in the 0x60 to 0x66\n"\
-"range. You can specify a vector with the -vector 0x<num> parameter."
-#define STR_COMMVECT "Communicating with interrupt vector 0x%x"
-#define STR_USEALT "Using alternate port %i for network"
-#define STR_RETURNED "Returned from DOOM II"
-#define STR_ATTEMPT "Attempting to find all players for %i player net play. "\
- "Press ESC to exit.\n"
+++ /dev/null
-#define STR_NETABORT "Synchronisation du jeu sur r\82seau annul\82e."
-#define STR_UNKNOWN "Paquet de jeu inconnu durant la configuration"
-#define STR_FOUND "Noeud d\82tect\82!"
-#define STR_LOOKING "Recherche d'un noeud"
-#define STR_MORETHAN "Plus de %i joueurs sp\82cifi\82s!"
-#define STR_NONESPEC "Pas de joueurs sp\82cifi\82s pour le jeu!"
-#define STR_CONSOLEIS "Console: joueur %i sur %i"
-#define STR_NORESP "Ce fichier de r\82ponse n'existe pas!"
-#define STR_FOUNDRESP "Fichier de r\82ponse trouv\82"
-#define STR_DOOMNETDRV "GESTIONNAIRE DE RESEAU DOOM II"
-#define STR_VECTSPEC "Le vecteur sp\82cifi\82 (0x%02x) \82tait d\82j\85 connect\82."
-#define STR_NONULL \
-"Attention: pas de vecteurs d'interruption NULL ou iret trouv\82s entre 0x60 et 0x66.\n"\
-"Vous pouvez sp\82cifier un vecteur avec le param\8atre -vector 0x<num\82ro>."
-#define STR_COMMVECT "Communication avec le vecteur d'interruption 0x%x"
-#define STR_USEALT "Utilisation du port alternatif %i pour le r\82seau"
-#define STR_RETURNED "Retour de DOOM II"
-#define STR_ATTEMPT \
-"Tentatative de recherche de tous les joueurs pour le jeu en riseau `%i jouers\n" \
-"Appuyez sur ECHAP pour quitter.\n"
-
+++ /dev/null
-This is the source for the DOOM ipx network driver.
+++ /dev/null
-#include <stdio.h>
-#include <io.h>
-#include <stdlib.h>
-#include <string.h>
-#include <process.h>
-#include <dos.h>
-#include "doomnet.h"
-
-//#include "serstr.h"
-#include "ser_frch.h" // FRENCH VERSION
-
-#define DOOM2
-
-extern int myargc;
-extern char **myargv;
-
-doomcom_t doomcom;
-int vectorishooked;
-void interrupt (*olddoomvect) (void);
-
-
-
-/*
-=================
-=
-= 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 CheckParm (char *check)
-{
- int i;
-
- for (i = 1;i<myargc;i++)
- if ( !stricmp(check,myargv[i]) )
- return i;
-
- return 0;
-}
-
-
-/*
-=============
-=
-= LaunchDOOM
-=
-These fields in doomcom should be filled in before calling:
-
- short numnodes; // console is allways node 0
- short ticdup; // 1 = no duplication, 2-5 = dup for slow nets
- short extratics; // 1 = send a backup tic in every packet
-
- short consoleplayer; // 0-3 = player number
- short numplayers; // 1-4
- short angleoffset; // 1 = left, 0 = center, -1 = right
- short drone; // 1 = drone
-=============
-*/
-
-void LaunchDOOM (void)
-{
- char *newargs[99];
- char adrstring[10];
- long flatadr;
- int p;
- unsigned char far *vector;
-
-// prepare for DOOM
- doomcom.id = DOOMCOM_ID;
-
-// hook an interrupt vector
- p= CheckParm ("-vector");
-
- if (p)
- {
- doomcom.intnum = sscanf ("0x%x",_argv[p+1]);
- }
- else
- {
- for (doomcom.intnum = 0x60 ; doomcom.intnum <= 0x66 ; doomcom.intnum++)
- {
- vector = *(char far * far *)(doomcom.intnum*4);
- if ( !vector || *vector == 0xcf )
- break;
- }
- if (doomcom.intnum == 0x67)
- {
- printf (STR_WARNING);
- doomcom.intnum = 0x66;
- }
- }
- printf (STR_COMM"\n",doomcom.intnum);
-
- olddoomvect = getvect (doomcom.intnum);
- setvect (doomcom.intnum,NetISR);
- vectorishooked = 1;
-
-// build the argument list for DOOM, adding a -net &doomcom
- memcpy (newargs, myargv, (myargc+1)*2);
- newargs[myargc] = "-net";
- flatadr = (long)_DS*16 + (unsigned)&doomcom;
- sprintf (adrstring,"%lu",flatadr);
- newargs[myargc+1] = adrstring;
- newargs[myargc+2] = NULL;
-
-// spawnv (P_WAIT, "m:\\newdoom\\doom", newargs);
- if (!access("doom2.exe",0))
- spawnv (P_WAIT, "doom2", newargs);
- else
- spawnv (P_WAIT, "doom", newargs);
-
- #ifdef DOOM2
- printf (STR_RETURNED"\n");
- #else
- printf ("Returned from DOOM\n");
- #endif
-
-
-}
-
-
+++ /dev/null
-// doomnet.h
-
-
-#define PEL_WRITE_ADR 0x3c8
-#define PEL_DATA 0x3c9
-
-#define I_ColorBlack(r,g,b) {outp(PEL_WRITE_ADR,0);outp(PEL_DATA,r);outp(PEL_DATA,g);outp(PEL_DATA,b);};
-
-
-
-
-#define MAXNETNODES 8 // max computers in a game
-#define MAXPLAYERS 4 // 4 players max + drones
-
-
-#define CMD_SEND 1
-#define CMD_GET 2
-
-#define DOOMCOM_ID 0x12345678l
-
-typedef struct
-{
- long id;
- short intnum; // DOOM executes an int to send commands
-
-// communication between DOOM and the driver
- short command; // CMD_SEND or CMD_GET
- short remotenode; // dest for send, set by get (-1 = no packet)
- short datalength; // bytes in doomdata to be sent / bytes read
-
-// info common to all nodes
- short numnodes; // console is allways node 0
- short ticdup; // 1 = no duplication, 2-5 = dup for slow nets
- short extratics; // 1 = send a backup tic in every packet
- short deathmatch; // 1 = deathmatch
- short savegame; // -1 = new game, 0-5 = load savegame
- short episode; // 1-3
- short map; // 1-9
- short skill; // 1-5
-
-// info specific to this node
- short consoleplayer; // 0-3 = player number
- short numplayers; // 1-4
- short angleoffset; // 1 = left, 0 = center, -1 = right
- short drone; // 1 = drone
-
-// packet data to be sent
- char data[512];
-} doomcom_t;
-
-
-
-extern doomcom_t doomcom;
-extern void interrupt (*olddoomvect) (void);
-extern int vectorishooked;
-
-int CheckParm (char *check);
-void LaunchDOOM (void);
-void interrupt NetISR (void);
-
+++ /dev/null
-// port.c
-
-#include "doomnet.h"
-#include "sersetup.h"
-//#include "serstr.h"
-#include "ser_frch.h" // FRENCH VERSION
-
-
-void jump_start( void );
-
-void interrupt isr_8250 (void);
-void interrupt isr_16550 (void);
-
-union REGS regs;
-struct SREGS sregs;
-
-que_t inque, outque;
-
-
-int uart; // io address
-enum {UART_8250, UART_16550} uart_type;
-int irq;
-
-int modem_status = -1;
-int line_status = -1;
-
-void interrupt (*oldirqvect) (void);
-int irqintnum;
-
-int comport;
-
-int baudbits;
-
-
-/*
-==============
-=
-= GetUart
-=
-==============
-*/
-
-void GetUart (void)
-{
- char far *system_data;
- static int ISA_uarts[] = {0x3f8,0x2f8,0x3e8,0x2e8};
- static int ISA_IRQs[] = {4,3,4,3};
- static int MCA_uarts[] = {0x03f8,0x02f8,0x3220,0x3228};
- static int MCA_IRQs[] = {4,3,3,3};
- int p;
-
- if (CheckParm ("-com2"))
- comport = 2;
- else if (CheckParm ("-com3"))
- comport = 3;
- else if (CheckParm ("-com4"))
- comport = 4;
- else
- comport = 1;
-
- regs.h.ah = 0xc0;
- int86x( 0x15, ®s, ®s, &sregs );
- if ( regs.x.cflag )
- {
- irq = ISA_IRQs[ comport-1 ];
- uart = ISA_uarts[ comport-1 ];
- return;
- }
- system_data = ( char far *) ( ( (long) sregs.es << 16 ) + regs.x.bx );
- if ( system_data[ 5 ] & 0x02 )
- {
- irq = MCA_IRQs[ comport-1 ];
- uart = MCA_uarts[ comport-1 ];
- }
- else
- {
- irq = ISA_IRQs[ comport-1 ];
- uart = ISA_uarts[ comport-1 ];
- }
-
- p = CheckParm ("-port");
- if (p)
- sscanf (_argv[p+1],"0x%x",&uart);
- p = CheckParm ("-irq");
- if (p)
- sscanf (_argv[p+1],"%i",&irq);
-
-
- printf (STR_PORTLOOK" 0x%x, irq %i\n",uart,irq);
-}
-
-
-
-
-/*
-===============
-=
-= InitPort
-=
-===============
-*/
-
-void InitPort (void)
-{
- int mcr;
- int temp;
- int u;
-
-//
-// find the irq and io address of the port
-//
- GetUart ();
-
-//
-// disable all uart interrupts
-//
- OUTPUT( uart + INTERRUPT_ENABLE_REGISTER, 0 );
-
-//
-// init com port settings
-//
-
- printf (STR_PORTSET"\n",115200l/baudbits);
-
-// set baud rate
- OUTPUT(uart + LINE_CONTROL_REGISTER, 0x83);
- OUTPUT(uart, baudbits);
- OUTPUT(uart + 1, 0);
-
-// set line control register (N81)
- OUTPUT(uart + LINE_CONTROL_REGISTER, 0x03);
-
-// set modem control register (OUT2+RTS+DTR)
- OUTPUT( uart + MODEM_CONTROL_REGISTER,8+2+1);
-
-//
-// check for a 16550
-//
- if (CheckParm("-8250"))
- // allow a forced 8250
- {
- uart_type = UART_8250;
- printf (STR_UART8250"\n\n");
- }
- else
- {
- OUTPUT ( uart + FIFO_CONTROL_REGISTER,
- FCR_FIFO_ENABLE + FCR_TRIGGER_04 );
- temp = INPUT( uart + INTERRUPT_ID_REGISTER );
- if ( ( temp & 0xf8 ) == 0xc0 )
- {
- uart_type = UART_16550;
- }
- else
- {
- uart_type = UART_8250;
- OUTPUT( uart + FIFO_CONTROL_REGISTER, 0 );
- }
- }
-
-//
-// clear out any pending uart events
-//
- printf (STR_CLEARPEND);
- for (u=0 ; u<16 ; u++) // clear an entire 16550 silo
- INPUT( uart + RECEIVE_BUFFER_REGISTER );
-
- do
- {
- switch( u = INPUT( uart + INTERRUPT_ID_REGISTER ) & 7 )
- {
- case IIR_MODEM_STATUS_INTERRUPT :
- modem_status = INPUT( uart + MODEM_STATUS_REGISTER );
- break;
-
- case IIR_LINE_STATUS_INTERRUPT :
- line_status = INPUT( uart + LINE_STATUS_REGISTER );
- break;
-
- case IIR_TX_HOLDING_REGISTER_INTERRUPT :
- break;
-
- case IIR_RX_DATA_READY_INTERRUPT :
- INPUT( uart + RECEIVE_BUFFER_REGISTER );
- break;
- }
- } while (! (u&1) );
-
-
-//
-// hook the irq vector
-//
- irqintnum = irq + 8;
-
- oldirqvect = getvect (irqintnum);
- if (uart_type == UART_16550)
- {
- setvect (irqintnum,isr_16550);
- printf (STR_UART16550"\n\n");
- }
- else
- {
- setvect (irqintnum,isr_8250);
- printf (STR_UART8250"\n\n");
-
- }
-
-
- OUTPUT( 0x20 + 1, INPUT( 0x20 + 1 ) & ~(1<<irq) );
-
- CLI();
-
-// enable RX and TX interrupts at the uart
-
- OUTPUT( uart + INTERRUPT_ENABLE_REGISTER,IER_RX_DATA_READY + IER_TX_HOLDING_REGISTER_EMPTY);
-
-// enable interrupts through the interrupt controller
-
- OUTPUT( 0x20, 0xc2 );
-
- STI();
-}
-
-
-/*
-=============
-=
-= ShutdownPort
-=
-=============
-*/
-
-void ShutdownPort ( void )
-{
- int u;
-
- OUTPUT( uart + INTERRUPT_ENABLE_REGISTER, 0 );
- OUTPUT( uart + MODEM_CONTROL_REGISTER, 0 );
-
- for (u=0 ; u<16 ; u++) // clear an entire 16550 silo
- INPUT( uart + RECEIVE_BUFFER_REGISTER );
-
- OUTPUT( 0x20 + 1, INPUT( 0x20 + 1 ) | (1<<irq) );
-
- setvect (irqintnum,oldirqvect);
-
-//
-// init com port settings to defaults
-//
- regs.x.ax = 0xf3; //f3= 9600 n 8 1
- regs.x.dx = comport - 1;
- int86 (0x14, ®s, ®s);
-}
-
-
-int read_byte( void )
-{
- int c;
-
- if (inque.tail >= inque.head)
- return -1;
- c = inque.data[inque.tail&(QUESIZE-1)];
- inque.tail++;
- return c;
-}
-
-
-void write_byte( int c )
-{
- outque.data[outque.head&(QUESIZE-1)] = c;
- outque.head++;
-}
-
-
-
-//==========================================================================
-
-
-/*
-==============
-=
-= isr_8250
-=
-==============
-*/
-
-void interrupt isr_8250(void)
-{
- int c;
-
- while (1)
- {
- switch( INPUT( uart + INTERRUPT_ID_REGISTER ) & 7 )
- {
-// not enabled
- case IIR_MODEM_STATUS_INTERRUPT :
- modem_status = INPUT( uart + MODEM_STATUS_REGISTER );
- break;
-
-// not enabled
- case IIR_LINE_STATUS_INTERRUPT :
- line_status = INPUT( uart + LINE_STATUS_REGISTER );
- break;
-
-//
-// transmit
-//
- case IIR_TX_HOLDING_REGISTER_INTERRUPT :
-//I_ColorBlack (63,0,0);
- if (outque.tail < outque.head)
- {
- c = outque.data[outque.tail&(QUESIZE-1)];
- outque.tail++;
- OUTPUT( uart + TRANSMIT_HOLDING_REGISTER, c );
- }
- break;
-
-//
-// receive
-//
- case IIR_RX_DATA_READY_INTERRUPT :
-//I_ColorBlack (0,63,0);
- c = INPUT( uart + RECEIVE_BUFFER_REGISTER );
- inque.data[inque.head&(QUESIZE-1)] = c;
- inque.head++;
- break;
-
-//
-// done
-//
- default :
-//I_ColorBlack (0,0,0);
- OUTPUT( 0x20, 0x20 );
- return;
- }
- }
-}
-
-
-/*
-==============
-=
-= isr_16550
-=
-==============
-*/
-
-void interrupt isr_16550(void)
-{
- int c;
- int count;
-
- while (1)
- {
- switch( INPUT( uart + INTERRUPT_ID_REGISTER ) & 7 )
- {
-// not enabled
- case IIR_MODEM_STATUS_INTERRUPT :
- modem_status = INPUT( uart + MODEM_STATUS_REGISTER );
- break;
-
-// not enabled
- case IIR_LINE_STATUS_INTERRUPT :
- line_status = INPUT( uart + LINE_STATUS_REGISTER );
- break;
-
-//
-// transmit
-//
- case IIR_TX_HOLDING_REGISTER_INTERRUPT :
-//I_ColorBlack (63,0,0);
- count = 16;
- while (outque.tail < outque.head && count--)
- {
- c = outque.data[outque.tail&(QUESIZE-1)];
- outque.tail++;
- OUTPUT( uart + TRANSMIT_HOLDING_REGISTER, c );
- }
- break;
-
-//
-// receive
-//
- case IIR_RX_DATA_READY_INTERRUPT :
-//I_ColorBlack (0,63,0);
- do
- {
- c = INPUT( uart + RECEIVE_BUFFER_REGISTER );
- inque.data[inque.head&(QUESIZE-1)] = c;
- inque.head++;
- } while (INPUT( uart + LINE_STATUS_REGISTER ) & LSR_DATA_READY );
-
- break;
-
-//
-// done
-//
- default :
-//I_ColorBlack (0,0,0);
- OUTPUT( 0x20, 0x20 );
- return;
- }
- }
-}
-
-
-/*
-===============
-=
-= jump_start
-=
-= Start up the transmition interrupts by sending the first char
-===============
-*/
-
-void jump_start( void )
-{
- int c;
-
- if (outque.tail < outque.head)
- {
- c = outque.data [outque.tail&(QUESIZE-1)];
- outque.tail++;
- OUTPUT( uart, c );
- }
-}
-
-
+++ /dev/null
-This is the source for the DOOM serial / modem driver.
+++ /dev/null
-// sersetup.c
-#define DOOM2
-#include "sersetup.h"
-//#include "serstr.h"
-#include "ser_frch.h" // FRENCH VERSION
-#include "DoomNet.h"
-
-extern que_t inque, outque;
-
-void jump_start( void );
-extern int uart;
-
-int usemodem;
-char startup[256], shutdown[256], baudrate[256];
-
-extern int baudbits;
-
-void ModemCommand (char *str);
-
-int myargc;
-char **myargv;
-
-//======================================
-//
-// I_Error
-//
-//======================================
-void I_Error(char *string)
-{
- printf("%s\n",string);
- exit(1);
-}
-
-/*
-================
-=
-= write_buffer
-=
-================
-*/
-
-void write_buffer( char *buffer, unsigned int count )
-{
- int i;
-
-// if this would overrun the buffer, throw everything else out
- if (outque.head-outque.tail+count > QUESIZE)
- outque.tail = outque.head;
-
- while (count--)
- write_byte (*buffer++);
-
- if ( INPUT( uart + LINE_STATUS_REGISTER ) & 0x40)
- jump_start();
-}
-
-
-/*
-=================
-=
-= Error
-=
-= For abnormal program terminations
-=
-=================
-*/
-
-void Error (char *error, ...)
-{
- va_list argptr;
-
- if (usemodem)
- {
- printf ("\n");
- printf ("\n"STR_DROPDTR"\n");
-
- OUTPUT(uart+MODEM_CONTROL_REGISTER, INPUT(uart+MODEM_CONTROL_REGISTER)&~MCR_DTR);
- delay (1250);
- OUTPUT( uart + MODEM_CONTROL_REGISTER, INPUT( uart + MODEM_CONTROL_REGISTER ) | MCR_DTR );
- ModemCommand("+++");
- delay (1250);
- ModemCommand(shutdown);
- delay (1250);
-
- }
-
- ShutdownPort ();
-
- if (vectorishooked)
- setvect (doomcom.intnum,olddoomvect);
-
- if (error)
- {
- va_start (argptr,error);
- vprintf (error,argptr);
- va_end (argptr);
- printf ("\n");
- exit (1);
- }
-
- printf (STR_CLEANEXIT"\n");
- exit (0);
-}
-
-
-/*
-================
-=
-= ReadPacket
-=
-================
-*/
-
-#define MAXPACKET 512
-#define FRAMECHAR 0x70
-
-char packet[MAXPACKET];
-int packetlen;
-int inescape;
-int newpacket;
-
-boolean ReadPacket (void)
-{
- int c;
-
-// if the buffer has overflowed, throw everything out
-
- if (inque.head-inque.tail > QUESIZE - 4) // check for buffer overflow
- {
- inque.tail = inque.head;
- newpacket = true;
- return false;
- }
-
- if (newpacket)
- {
- packetlen = 0;
- newpacket = 0;
- }
-
- do
- {
- c = read_byte ();
- if (c < 0)
- return false; // haven't read a complete packet
-//printf ("%c",c);
- if (inescape)
- {
- inescape = false;
- if (c!=FRAMECHAR)
- {
- newpacket = 1;
- return true; // got a good packet
- }
- }
- else if (c==FRAMECHAR)
- {
- inescape = true;
- continue; // don't know yet if it is a terminator
- } // or a literal FRAMECHAR
-
- if (packetlen >= MAXPACKET)
- continue; // oversize packet
- packet[packetlen] = c;
- packetlen++;
- } while (1);
-
-}
-
-
-/*
-=============
-=
-= WritePacket
-=
-=============
-*/
-
-
-
-void WritePacket (char *buffer, int len)
-{
- int b;
- char static localbuffer[MAXPACKET*2+2];
-
- b = 0;
- if (len > MAXPACKET)
- return;
-
- while (len--)
- {
- if (*buffer == FRAMECHAR)
- localbuffer[b++] = FRAMECHAR; // escape it for literal
- localbuffer[b++] = *buffer++;
- }
-
- localbuffer[b++] = FRAMECHAR;
- localbuffer[b++] = 0;
-
- write_buffer (localbuffer, b);
-}
-
-
-/*
-=============
-=
-= NetISR
-=
-=============
-*/
-
-void interrupt NetISR (void)
-{
- if (doomcom.command == CMD_SEND)
- {
-//I_ColorBlack (0,0,63);
- WritePacket ((char *)&doomcom.data, doomcom.datalength);
- }
- else if (doomcom.command == CMD_GET)
- {
-//I_ColorBlack (63,63,0);
-
- if (ReadPacket () && packetlen <= sizeof(doomcom.data) )
- {
- doomcom.remotenode = 1;
- doomcom.datalength = packetlen;
- memcpy (&doomcom.data, &packet, packetlen);
- }
- else
- doomcom.remotenode = -1;
-
- }
-//I_ColorBlack (0,0,0);
-}
-
-
-
-
-/*
-=================
-=
-= Connect
-=
-= Figures out who is player 0 and 1
-=================
-*/
-
-void Connect (void)
-{
- struct time time;
- int oldsec;
- int localstage, remotestage;
- char str[20];
- char idstr[7];
- char remoteidstr[7];
- unsigned long idnum;
- int i;
-
-//
-// wait for a good packet
-//
- printf (STR_ATTEMPT"\n");
-
-//
-// build a (hopefully) unique id string by hashing up the current milliseconds
-// and the interrupt table
-//
- if (CheckParm ("-player1"))
- idnum = 0;
- else if (CheckParm ("-player2"))
- idnum = 999999;
- else
- {
- gettime (&time);
- idnum = time.ti_sec*100+time.ti_hund;
- for (i=0 ; i<512 ; i++)
- idnum += ((unsigned far *)0)[i];
- idnum %= 1000000;
- }
-
- idstr[0] = '0' + idnum/ 100000l;
- idnum -= (idstr[0]-'0')*100000l;
- idstr[1] = '0' + idnum/ 10000l;
- idnum -= (idstr[1]-'0')*10000l;
- idstr[2] = '0' + idnum/ 1000l;
- idnum -= (idstr[2]-'0')*1000l;
- idstr[3] = '0' + idnum/ 100l;
- idnum -= (idstr[3]-'0')*100l;
- idstr[4] = '0' + idnum/ 10l;
- idnum -= (idstr[4]-'0')*10l;
- idstr[5] = '0' + idnum;
- idstr[6] = 0;
-
-//
-// sit in a loop until things are worked out
-//
-// the packet is: ID000000_0
-// the first field is the idnum, the second is the acknowledge stage
-// ack stage starts out 0, is bumped to 1 after the other computer's id
-// is known, and is bumped to 2 after the other computer has raised to 1
-//
- oldsec = -1;
- localstage = remotestage = 0;
-
- do
- {
- while ( bioskey(1) )
- {
- if ( (bioskey (0) & 0xff) == 27)
- Error ("\n\n"STR_NETABORT);
- }
-
- if (ReadPacket ())
- {
- packet[packetlen] = 0;
- printf ("read : %s\n",packet);
- if (packetlen != 10)
- continue;
- if (strncmp(packet,"ID",2) )
- continue;
- if (!strncmp (packet+2,idstr,6))
- Error ("\n\n"STR_DUPLICATE);
- strncpy (remoteidstr,packet+2,6);
-
- remotestage = packet[9] - '0';
- localstage = remotestage+1;
- oldsec = -1;
- }
-
- gettime (&time);
- if (time.ti_sec != oldsec)
- {
- oldsec = time.ti_sec;
- sprintf (str,"ID%s_%i",idstr,localstage);
- WritePacket (str,strlen(str));
- printf ("wrote: %s\n",str);
- }
-
- } while (localstage < 2);
-
-//
-// decide who is who
-//
- if (strcmp(remoteidstr,idstr) > 0)
- doomcom.consoleplayer = 0;
- else
- doomcom.consoleplayer = 1;
-
-
-//
-// flush out any extras
-//
- while (ReadPacket ())
- ;
-}
-
-
-
-/*
-==============
-=
-= ModemCommand
-=
-==============
-*/
-
-void ModemCommand (char *str)
-{
- int i,l;
-
- printf (STR_MODEMCMD,str);
- l = strlen(str);
- for (i=0 ; i<l ; i++)
- {
- write_buffer (str+i,1);
- printf ("%c",str[i]);
- delay (100);
- }
-
- write_buffer ("\r",1);
- printf ("\n");
-}
-
-
-/*
-==============
-=
-= ModemResponse
-=
-= Waits for OK, RING, CONNECT, etc
-==============
-*/
-
-char response[80];
-
-void ModemResponse (char *resp)
-{
- int c;
- int respptr;
-
- do
- {
- printf (STR_MODEMRESP);
- respptr=0;
- do
- {
- while ( bioskey(1) )
- {
- if ( (bioskey (0) & 0xff) == 27)
- Error ("\n"STR_RESPABORT);
- }
- c = read_byte ();
- if (c==-1)
- continue;
- if (c=='\n' || respptr == 79)
- {
- response[respptr] = 0;
- printf ("%s\n",response);
- break;
- }
- if (c>=' ')
- {
- response[respptr] = c;
- respptr++;
- }
- } while (1);
-
- } while (strncmp(response,resp,strlen(resp)));
-}
-
-
-/*
-=============
-=
-= ReadLine
-=
-=============
-*/
-
-void ReadLine (FILE *f, char *dest)
-{
- int c;
-
- do
- {
- c = fgetc (f);
- if (c == EOF || c == '\r' || c == '\n')
- break;
- *dest++ = c;
- } while (1);
- *dest = 0;
-}
-
-
-/*
-=============
-=
-= ReadModemCfg
-=
-=============
-*/
-
-void ReadModemCfg (void)
-{
- int mcr;
- FILE *f;
- unsigned baud;
-
- f = fopen ("modem.cfg","r");
- if (!f)
- Error (STR_CANTREAD);
- ReadLine (f, startup);
- ReadLine (f, shutdown);
- ReadLine (f, baudrate);
- fclose (f);
-
- baud = atol(baudrate);
- if (baud)
- baudbits = 115200l/baud;
-
- usemodem = true;
-}
-
-
-/*
-=============
-=
-= Dial
-=
-=============
-*/
-
-void Dial (void)
-{
- char cmd[80];
- int p;
-
- ModemCommand(startup);
- ModemResponse ("OK");
-
- printf ("\n"STR_DIALING"\n\n");
- p = CheckParm ("-dial");
- sprintf (cmd,"ATDT%s",myargv[p+1]);
-
- ModemCommand(cmd);
- ModemResponse (STR_CONNECT);
- doomcom.consoleplayer = 1;
-}
-
-
-/*
-=============
-=
-= Answer
-=
-=============
-*/
-
-void Answer (void)
-{
- ModemCommand(startup);
- ModemResponse ("OK");
- printf ("\n"STR_WAITRING"\n\n");
-
- ModemResponse (STR_RING);
- ModemCommand ("ATA");
- ModemResponse (STR_CONNECT);
-
- doomcom.consoleplayer = 0;
-}
-
-//========================================================
-//
-// Find a Response File
-//
-//========================================================
-void FindResponseFile (void)
-{
- int i;
- #define MAXARGVS 100
-
- for (i = 1;i < myargc;i++)
- if (myargv[i][0] == '@')
- {
- FILE * handle;
- int size;
- int k;
- int index;
- int indexinfile;
- char *infile;
- char *file;
- char *moreargs[20];
- char *firstargv;
-
- // READ THE RESPONSE FILE INTO MEMORY
- handle = fopen (&myargv[i][1],"rb");
- if (!handle)
- I_Error (STR_NORESP);
- printf("Found response file \"%s\"!\n",strupr(&myargv[i][1]));
- fseek (handle,0,SEEK_END);
- size = ftell(handle);
- fseek (handle,0,SEEK_SET);
- file = malloc (size);
- fread (file,size,1,handle);
- fclose (handle);
-
- // KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
- for (index = 0,k = i+1; k < myargc; k++)
- moreargs[index++] = myargv[k];
-
- firstargv = myargv[0];
- myargv = malloc(sizeof(char *)*MAXARGVS);
- memset(myargv,0,sizeof(char *)*MAXARGVS);
- myargv[0] = firstargv;
-
- infile = file;
- indexinfile = k = 0;
- indexinfile++; // SKIP PAST ARGV[0] (KEEP IT)
- do
- {
- myargv[indexinfile++] = infile+k;
- while(k < size &&
- ((*(infile+k)>= ' '+1) && (*(infile+k)<='z')))
- k++;
- *(infile+k) = 0;
- while(k < size &&
- ((*(infile+k)<= ' ') || (*(infile+k)>'z')))
- k++;
- } while(k < size);
-
- for (k = 0;k < index;k++)
- myargv[indexinfile++] = moreargs[k];
- myargc = indexinfile;
-
- // DISPLAY ARGS
-// printf("%d command-line args:\n",myargc);
-// for (k=1;k<myargc;k++)
-// printf("%s\n",myargv[k]);
-
- break;
- }
-}
-
-
-
-/*
-=================
-=
-= main
-=
-=================
-*/
-
-void main(void)
-{
- int p;
-
-//
-// set network characteristics
-//
- doomcom.ticdup = 1;
- doomcom.extratics = 0;
- doomcom.numnodes = 2;
- doomcom.numplayers = 2;
- doomcom.drone = 0;
-
- printf("\n"
- "---------------------------------\n"
- #ifdef DOOM2
- STR_DOOMSERIAL"\n"
- #else
- "DOOM SERIAL DEVICE DRIVER v1.4\n"
- #endif
- "---------------------------------\n");
- myargc = _argc;
- myargv = _argv;
- FindResponseFile();
-
-//
-// allow override of automatic player ordering to allow a slower computer
-// to be set as player 1 allways
-//
-
-//
-// establish communications
-//
-
- baudbits = 0x08; // default to 9600 if not specified on cmd line
- // or in modem.cfg
-
- if (CheckParm ("-dial") || CheckParm ("-answer") )
- ReadModemCfg (); // may set baudbits
-
-//
-// allow command-line override of modem.cfg baud rate
-//
- if (CheckParm ("-9600")) baudbits = 0x0c;
- else if (CheckParm ("-14400")) baudbits = 0x08;
- else if (CheckParm ("-19200")) baudbits = 0x06;
- else if (CheckParm ("-38400")) baudbits = 0x03;
- else if (CheckParm ("-57600")) baudbits = 0x02;
- else if (CheckParm ("-115200")) baudbits = 0x01;
-
- InitPort ();
-
- if (CheckParm ("-dial"))
- Dial ();
- else if (CheckParm ("-answer"))
- Answer ();
-
- Connect ();
-
-//
-// launch DOOM
-//
- LaunchDOOM ();
-
- Error (NULL);
-}
-
+++ /dev/null
-#include <conio.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <conio.h>
-#include <ctype.h>
-#include <dos.h>
-#include <process.h>
-#include <stdarg.h>
-#include <bios.h>
-#include <ctype.h>
-
-
-#define INPUT(port) inportb(port)
-#define OUTPUT(port,data) outportb(port,data)
-#define CLI() disable()
-#define STI() enable()
-
-
-typedef enum {false, true} boolean;
-typedef unsigned char byte;
-
-
-#define TRANSMIT_HOLDING_REGISTER 0x00
-#define RECEIVE_BUFFER_REGISTER 0x00
-#define INTERRUPT_ENABLE_REGISTER 0x01
-#define IER_RX_DATA_READY 0x01
-#define IER_TX_HOLDING_REGISTER_EMPTY 0x02
-#define IER_LINE_STATUS 0x04
-#define IER_MODEM_STATUS 0x08
-#define INTERRUPT_ID_REGISTER 0x02
-#define IIR_MODEM_STATUS_INTERRUPT 0x00
-#define IIR_TX_HOLDING_REGISTER_INTERRUPT 0x02
-#define IIR_RX_DATA_READY_INTERRUPT 0x04
-#define IIR_LINE_STATUS_INTERRUPT 0x06
-#define FIFO_CONTROL_REGISTER 0x02
-#define FCR_FIFO_ENABLE 0x01
-#define FCR_RCVR_FIFO_RESET 0x02
-#define FCR_XMIT_FIFO_RESET 0x04
-#define FCR_RCVR_TRIGGER_LSB 0x40
-#define FCR_RCVR_TRIGGER_MSB 0x80
-#define FCR_TRIGGER_01 0x00
-#define FCR_TRIGGER_04 0x40
-#define FCR_TRIGGER_08 0x80
-#define FCR_TRIGGER_14 0xc0
-#define LINE_CONTROL_REGISTER 0x03
-#define LCR_WORD_LENGTH_MASK 0x03
-#define LCR_WORD_LENGTH_SELECT_0 0x01
-#define LCR_WORD_LENGTH_SELECT_1 0x02
-#define LCR_STOP_BITS 0x04
-#define LCR_PARITY_MASK 0x38
-#define LCR_PARITY_ENABLE 0x08
-#define LCR_EVEN_PARITY_SELECT 0x10
-#define LCR_STICK_PARITY 0x20
-#define LCR_SET_BREAK 0x40
-#define LCR_DLAB 0x80
-#define MODEM_CONTROL_REGISTER 0x04
-#define MCR_DTR 0x01
-#define MCR_RTS 0x02
-#define MCR_OUT1 0x04
-#define MCR_OUT2 0x08
-#define MCR_LOOPBACK 0x10
-#define LINE_STATUS_REGISTER 0x05
-#define LSR_DATA_READY 0x01
-#define LSR_OVERRUN_ERROR 0x02
-#define LSR_PARITY_ERROR 0x04
-#define LSR_FRAMING_ERROR 0x08
-#define LSR_BREAK_DETECT 0x10
-#define LSR_THRE 0x20
-#define MODEM_STATUS_REGISTER 0x06
-#define MSR_DELTA_CTS 0x01
-#define MSR_DELTA_DSR 0x02
-#define MSR_TERI 0x04
-#define MSR_DELTA_CD 0x08
-#define MSR_CTS 0x10
-#define MSR_DSR 0x20
-#define MSR_RI 0x40
-#define MSR_CD 0x80
-#define DIVISOR_LATCH_LOW 0x00
-#define DIVISOR_LATCH_HIGH 0x01
-
-
-
-#define QUESIZE 2048
-
-typedef struct
-{
- long head, tail; // bytes are put on head and pulled from tail
- unsigned char data[QUESIZE];
-} que_t;
-
-void InitPort (void);
-void ShutdownPort (void);
-
-int read_byte( void );
-void write_byte( int c );
-
-
-void Error (char *error, ...);
-
-extern int argc;
-extern char **argv;
+++ /dev/null
-#define STR_DROPDTR "Dropping DTR"
-#define STR_CLEANEXIT "Clean exit from SERSETUP"
-#define STR_ATTEMPT "Attempting to connect across serial link, press escape to abort."
-#define STR_NETABORT "Network game synchronization aborted."
-#define STR_DUPLICATE "Duplicate id string, try again or check modem init string."
-#define STR_MODEMCMD "Modem command : "
-#define STR_MODEMRESP "Modem response: "
-#define STR_RESPABORT "Modem response aborted."
-#define STR_CANTREAD "Couldn't read MODEM.CFG"
-#define STR_DIALING "Dialing..."
-#define STR_CONNECT "CONNECT"
-#define STR_WAITRING "Waiting for ring..."
-#define STR_RING "RING"
-#define STR_NORESP "No such response file!"
-#define STR_DOOMSERIAL "DOOM II SERIAL DEVICE DRIVER v1.4"
-#define STR_WARNING \
-"Warning: no NULL or iret interrupt vectors were found in the 0x60 to 0x66\n"\
-"range. You can specify a vector with the -vector 0x<num> parameter.\n"
-#define STR_COMM "Communicating with interrupt vector 0x%x"
-#define STR_RETURNED "Returned from DOOM II"
-#define STR_PORTSET "Setting port to %lu baud"
+++ /dev/null
-#define STR_DROPDTR "Abandon de DTR"
-#define STR_CLEANEXIT "Sortie normale de SERSETUP"
-#define STR_ATTEMPT "Tentative de connexion en s\82rie, appuyez sur ESC pour annuler."
-#define STR_NETABORT "Synchronisation de jeu sur r\82seau annul\82e."
-#define STR_DUPLICATE "Cha\8cne id en double. R\82essayez ou v\82rifiez la cha\8cne d'initialistion du modem."
-#define STR_MODEMCMD "Commande du modem: "
-#define STR_MODEMRESP "R\82ponse du modem: "
-#define STR_RESPABORT "R\82ponse du modem annul\82e."
-#define STR_CANTREAD "Lecture de MODEM.CFG impossible"
-#define STR_DIALING "Composition du num\82ro..."
-#define STR_CONNECT "CONNECTION"
-#define STR_WAITRING "Attente d'appel..."
-#define STR_RING "APPEL"
-#define STR_NORESP "Ce fichier de r\82ponse n'existe pas!"
-#define STR_DOOMSERIAL "GESTIONNAIRE DE LIAISON SERIE DOOM II v1.4"
-#define STR_WARNING \
-"Attention: pas de vecteurs d'interruption NULL ou iret trouv\82s entre 0x60 et 0x66.\n"\
-"Vous pouvez sp\82cifier un vecteur avec le param\8atre -vector 0x<num\82ro>."
-#define STR_COMM "Communication avec le vecteur d'interruption 0x%x"
-#define STR_RETURNED "Retour de DOOM II"
-#define STR_PORTLOOK "Recherche de l'UART sur le port"
-#define STR_UART8250 "UART = 8250"
-#define STR_UART16550 "UART = 16550"
-#define STR_CLEARPEND "Riinitilisation des interruptions en attente.\n"
-#define STR_PORTSET "Réglage du port à %lu baud"
+++ /dev/null
-##########################################################
-#
-# $Id:$
-#
-# $Log:$
-#
-#
-
-CC=gcc
-CFLAGS=-O -DNORMALUNIX -DLINUX
-LDFLAGS=
-LIBS=-lm
-
-O=linux
-
-all: $(O)/sndserver
-
-clean:
- rm -f *.o *~ *.flc
- rm -f linux/*
-
-# Target
-$(O)/sndserver: \
- $(O)/soundsrv.o \
- $(O)/sounds.o \
- $(O)/wadread.o \
- $(O)/linux.o
- $(CC) $(CFLAGS) $(LDFLAGS) \
- $(O)/soundsrv.o \
- $(O)/sounds.o \
- $(O)/wadread.o \
- $(O)/linux.o -o $(O)/sndserver $(LIBS)
- echo make complete.
-
-# Rule
-$(O)/%.o: %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-
+++ /dev/null
-
-This is the soundserver as used by the original
-Linuxdoom release. I separated the source from
-the actual Linuxduum source. For various reasons
-the separate sound process seems to give the
-best results - both synchronous and timer driven
-output demonstrate glitches. These might either
-be timing issues, or introduced by the changes
-I made to the linux sound code while merging it
-back into the main tree.
-
-Note that neither John Carmack nor Dave Taylor
-are responsible for the current sound handling.
-
-
\ No newline at end of file
+++ /dev/null
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// $Id: linux.c,v 1.3 1997/01/26 07:45:01 b1 Exp $
-//
-// 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: linux.c,v $
-// Revision 1.3 1997/01/26 07:45:01 b1
-// 2nd formatting run, fixed a few warnings as well.
-//
-// Revision 1.2 1997/01/21 19:00:01 b1
-// First formatting run:
-// using Emacs cc-mode.el indentation for C++ now.
-//
-// Revision 1.1 1997/01/19 17:22:45 b1
-// Initial check in DOOM sources as of Jan. 10th, 1997
-//
-//
-// DESCRIPTION:
-// UNIX, soundserver for Linux i386.
-//
-//-----------------------------------------------------------------------------
-
-static const char rcsid[] = "$Id: linux.c,v 1.3 1997/01/26 07:45:01 b1 Exp $";
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <linux/soundcard.h>
-
-#include "soundsrv.h"
-
-int audio_fd;
-
-void
-myioctl
-( int fd,
- int command,
- int* arg )
-{
- int rc;
- extern int errno;
-
- rc = ioctl(fd, command, arg);
- if (rc < 0)
- {
- fprintf(stderr, "ioctl(dsp,%d,arg) failed\n", command);
- fprintf(stderr, "errno=%d\n", errno);
- exit(-1);
- }
-}
-
-void I_InitMusic(void)
-{
-}
-
-void
-I_InitSound
-( int samplerate,
- int samplesize )
-{
-
- int i;
-
- audio_fd = open("/dev/dsp", O_WRONLY);
- if (audio_fd<0)
- fprintf(stderr, "Could not open /dev/dsp\n");
-
-
- i = 11 | (2<<16);
- myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i);
-
- myioctl(audio_fd, SNDCTL_DSP_RESET, 0);
- i=11025;
- myioctl(audio_fd, SNDCTL_DSP_SPEED, &i);
- i=1;
- myioctl(audio_fd, SNDCTL_DSP_STEREO, &i);
-
- myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i);
- if (i&=AFMT_S16_LE)
- myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i);
- else
- fprintf(stderr, "Could not play signed 16 data\n");
-
-}
-
-void
-I_SubmitOutputBuffer
-( void* samples,
- int samplecount )
-{
- write(audio_fd, samples, samplecount*4);
-}
-
-void I_ShutdownSound(void)
-{
-
- close(audio_fd);
-
-}
-
-void I_ShutdownMusic(void)
-{
-}
+++ /dev/null
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// $Id: sounds.c,v 1.3 1997/01/29 22:40:44 b1 Exp $
-//
-// 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: sounds.c,v $
-// Revision 1.3 1997/01/29 22:40:44 b1
-// Reformatting, S (sound) module files.
-//
-// Revision 1.2 1997/01/21 19:00:07 b1
-// First formatting run:
-// using Emacs cc-mode.el indentation for C++ now.
-//
-// Revision 1.1 1997/01/19 17:22:50 b1
-// Initial check in DOOM sources as of Jan. 10th, 1997
-//
-//
-// DESCRIPTION:
-// Created by Dave Taylor's sound utility.
-// Kept as a sample, DOOM sounds.
-//
-//-----------------------------------------------------------------------------
-
-
-static const char rcsid[] = "$Id: sounds.c,v 1.3 1997/01/29 22:40:44 b1 Exp $";
-
-
-
-// Not exactly a good idea.
-enum { false, true };
-
-#include "sounds.h"
-
-//
-// Information about all the music
-//
-
-musicinfo_t S_music[] =
-{
- { 0 },
- { "e1m1", 0 },
- { "e1m2", 0 },
- { "e1m3", 0 },
- { "e1m4", 0 },
- { "e1m5", 0 },
- { "e1m6", 0 },
- { "e1m7", 0 },
- { "e1m8", 0 },
- { "e1m9", 0 },
- { "e2m1", 0 },
- { "e2m2", 0 },
- { "e2m3", 0 },
- { "e2m4", 0 },
- { "e2m5", 0 },
- { "e2m6", 0 },
- { "e2m7", 0 },
- { "e2m8", 0 },
- { "e2m9", 0 },
- { "e3m1", 0 },
- { "e3m2", 0 },
- { "e3m3", 0 },
- { "e3m4", 0 },
- { "e3m5", 0 },
- { "e3m6", 0 },
- { "e3m7", 0 },
- { "e3m8", 0 },
- { "e3m9", 0 },
- { "inter", 0 },
- { "intro", 0 },
- { "bunny", 0 },
- { "victor", 0 },
- { "introa", 0 },
- { "runnin", 0 },
- { "stalks", 0 },
- { "countd", 0 },
- { "betwee", 0 },
- { "doom", 0 },
- { "the_da", 0 },
- { "shawn", 0 },
- { "ddtblu", 0 },
- { "in_cit", 0 },
- { "dead", 0 },
- { "stlks2", 0 },
- { "theda2", 0 },
- { "doom2", 0 },
- { "ddtbl2", 0 },
- { "runni2", 0 },
- { "dead2", 0 },
- { "stlks3", 0 },
- { "romero", 0 },
- { "shawn2", 0 },
- { "messag", 0 },
- { "count2", 0 },
- { "ddtbl3", 0 },
- { "ampie", 0 },
- { "theda3", 0 },
- { "adrian", 0 },
- { "messg2", 0 },
- { "romer2", 0 },
- { "tense", 0 },
- { "shawn3", 0 },
- { "openin", 0 },
- { "evil", 0 },
- { "ultima", 0 },
- { "read_m", 0 },
- { "dm2ttl", 0 },
- { "dm2int", 0 }
-};
-
-
-//
-// Information about all the sfx
-//
-
-sfxinfo_t S_sfx[] =
-{
- { 0 },
- { "pistol", false, 64, 0, -1, -1, 0 },
- { "shotgn", false, 64, 0, -1, -1, 0 },
- { "sgcock", false, 64, 0, -1, -1, 0 },
- { "dshtgn", false, 64, 0, -1, -1, 0 },
- { "dbopn", false, 64, 0, -1, -1, 0 },
- { "dbcls", false, 64, 0, -1, -1, 0 },
- { "dbload", false, 64, 0, -1, -1, 0 },
- { "plasma", false, 64, 0, -1, -1, 0 },
- { "bfg", false, 64, 0, -1, -1, 0 },
- { "sawup", false, 64, 0, -1, -1, 0 },
- { "sawidl", false, 118, 0, -1, -1, 0 },
- { "sawful", false, 64, 0, -1, -1, 0 },
- { "sawhit", false, 64, 0, -1, -1, 0 },
- { "rlaunc", false, 64, 0, -1, -1, 0 },
- { "rxplod", false, 70, 0, -1, -1, 0 },
- { "firsht", false, 70, 0, -1, -1, 0 },
- { "firxpl", false, 70, 0, -1, -1, 0 },
- { "pstart", false, 100, 0, -1, -1, 0 },
- { "pstop", false, 100, 0, -1, -1, 0 },
- { "doropn", false, 100, 0, -1, -1, 0 },
- { "dorcls", false, 100, 0, -1, -1, 0 },
- { "stnmov", false, 119, 0, -1, -1, 0 },
- { "swtchn", false, 78, 0, -1, -1, 0 },
- { "swtchx", false, 78, 0, -1, -1, 0 },
- { "plpain", false, 96, 0, -1, -1, 0 },
- { "dmpain", false, 96, 0, -1, -1, 0 },
- { "popain", false, 96, 0, -1, -1, 0 },
- { "vipain", false, 96, 0, -1, -1, 0 },
- { "mnpain", false, 96, 0, -1, -1, 0 },
- { "pepain", false, 96, 0, -1, -1, 0 },
- { "slop", false, 78, 0, -1, -1, 0 },
- { "itemup", true, 78, 0, -1, -1, 0 },
- { "wpnup", true, 78, 0, -1, -1, 0 },
- { "oof", false, 96, 0, -1, -1, 0 },
- { "telept", false, 32, 0, -1, -1, 0 },
- { "posit1", true, 98, 0, -1, -1, 0 },
- { "posit2", true, 98, 0, -1, -1, 0 },
- { "posit3", true, 98, 0, -1, -1, 0 },
- { "bgsit1", true, 98, 0, -1, -1, 0 },
- { "bgsit2", true, 98, 0, -1, -1, 0 },
- { "sgtsit", true, 98, 0, -1, -1, 0 },
- { "cacsit", true, 98, 0, -1, -1, 0 },
- { "brssit", true, 94, 0, -1, -1, 0 },
- { "cybsit", true, 92, 0, -1, -1, 0 },
- { "spisit", true, 90, 0, -1, -1, 0 },
- { "bspsit", true, 90, 0, -1, -1, 0 },
- { "kntsit", true, 90, 0, -1, -1, 0 },
- { "vilsit", true, 90, 0, -1, -1, 0 },
- { "mansit", true, 90, 0, -1, -1, 0 },
- { "pesit", true, 90, 0, -1, -1, 0 },
- { "sklatk", false, 70, 0, -1, -1, 0 },
- { "sgtatk", false, 70, 0, -1, -1, 0 },
- { "skepch", false, 70, 0, -1, -1, 0 },
- { "vilatk", false, 70, 0, -1, -1, 0 },
- { "claw", false, 70, 0, -1, -1, 0 },
- { "skeswg", false, 70, 0, -1, -1, 0 },
- { "pldeth", false, 32, 0, -1, -1, 0 },
- { "pdiehi", false, 32, 0, -1, -1, 0 },
- { "podth1", false, 70, 0, -1, -1, 0 },
- { "podth2", false, 70, 0, -1, -1, 0 },
- { "podth3", false, 70, 0, -1, -1, 0 },
- { "bgdth1", false, 70, 0, -1, -1, 0 },
- { "bgdth2", false, 70, 0, -1, -1, 0 },
- { "sgtdth", false, 70, 0, -1, -1, 0 },
- { "cacdth", false, 70, 0, -1, -1, 0 },
- { "skldth", false, 70, 0, -1, -1, 0 },
- { "brsdth", false, 32, 0, -1, -1, 0 },
- { "cybdth", false, 32, 0, -1, -1, 0 },
- { "spidth", false, 32, 0, -1, -1, 0 },
- { "bspdth", false, 32, 0, -1, -1, 0 },
- { "vildth", false, 32, 0, -1, -1, 0 },
- { "kntdth", false, 32, 0, -1, -1, 0 },
- { "pedth", false, 32, 0, -1, -1, 0 },
- { "skedth", false, 32, 0, -1, -1, 0 },
- { "posact", true, 120, 0, -1, -1, 0 },
- { "bgact", true, 120, 0, -1, -1, 0 },
- { "dmact", true, 120, 0, -1, -1, 0 },
- { "bspact", true, 100, 0, -1, -1, 0 },
- { "bspwlk", true, 100, 0, -1, -1, 0 },
- { "vilact", true, 100, 0, -1, -1, 0 },
- { "noway", false, 78, 0, -1, -1, 0 },
- { "barexp", false, 60, 0, -1, -1, 0 },
- { "punch", false, 64, 0, -1, -1, 0 },
- { "hoof", false, 70, 0, -1, -1, 0 },
- { "metal", false, 70, 0, -1, -1, 0 },
- { "chgun", false, 64, &S_sfx[sfx_pistol], 150, 0, 0 },
- { "tink", false, 60, 0, -1, -1, 0 },
- { "bdopn", false, 100, 0, -1, -1, 0 },
- { "bdcls", false, 100, 0, -1, -1, 0 },
- { "itmbk", false, 100, 0, -1, -1, 0 },
- { "flame", false, 32, 0, -1, -1, 0 },
- { "flamst", false, 32, 0, -1, -1, 0 },
- { "getpow", false, 60, 0, -1, -1, 0 },
- { "bospit", false, 70, 0, -1, -1, 0 },
- { "boscub", false, 70, 0, -1, -1, 0 },
- { "bossit", false, 70, 0, -1, -1, 0 },
- { "bospn", false, 70, 0, -1, -1, 0 },
- { "bosdth", false, 70, 0, -1, -1, 0 },
- { "manatk", false, 70, 0, -1, -1, 0 },
- { "mandth", false, 70, 0, -1, -1, 0 },
- { "sssit", false, 70, 0, -1, -1, 0 },
- { "ssdth", false, 70, 0, -1, -1, 0 },
- { "keenpn", false, 70, 0, -1, -1, 0 },
- { "keendt", false, 70, 0, -1, -1, 0 },
- { "skeact", false, 70, 0, -1, -1, 0 },
- { "skesit", false, 70, 0, -1, -1, 0 },
- { "skeatk", false, 70, 0, -1, -1, 0 },
- { "radio", false, 60, 0, -1, -1, 0 }
-};
-
+++ /dev/null
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// $Id: sounds.h,v 1.3 1997/01/29 22:40:44 b1 Exp $
-//
-// 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: sounds.h,v $
-// Revision 1.3 1997/01/29 22:40:44 b1
-// Reformatting, S (sound) module files.
-//
-// Revision 1.2 1997/01/21 19:00:07 b1
-// First formatting run:
-// using Emacs cc-mode.el indentation for C++ now.
-//
-// Revision 1.1 1997/01/19 17:22:50 b1
-// Initial check in DOOM sources as of Jan. 10th, 1997
-//
-//
-// DESCRIPTION:
-// Created by Dave Taylor's sound utility.
-// Kept as a sample, DOOM sounds.
-//
-//-----------------------------------------------------------------------------
-
-#ifndef __SOUNDSH__
-#define __SOUNDSH__
-
-#include "soundst.h"
-
-//
-// Identifiers for all music in game.
-//
-
-typedef enum
-{
- mus_None,
- mus_e1m1,
- mus_e1m2,
- mus_e1m3,
- mus_e1m4,
- mus_e1m5,
- mus_e1m6,
- mus_e1m7,
- mus_e1m8,
- mus_e1m9,
- mus_e2m1,
- mus_e2m2,
- mus_e2m3,
- mus_e2m4,
- mus_e2m5,
- mus_e2m6,
- mus_e2m7,
- mus_e2m8,
- mus_e2m9,
- mus_e3m1,
- mus_e3m2,
- mus_e3m3,
- mus_e3m4,
- mus_e3m5,
- mus_e3m6,
- mus_e3m7,
- mus_e3m8,
- mus_e3m9,
- mus_inter,
- mus_intro,
- mus_bunny,
- mus_victor,
- mus_introa,
- mus_runnin,
- mus_stalks,
- mus_countd,
- mus_betwee,
- mus_doom,
- mus_the_da,
- mus_shawn,
- mus_ddtblu,
- mus_in_cit,
- mus_dead,
- mus_stlks2,
- mus_theda2,
- mus_doom2,
- mus_ddtbl2,
- mus_runni2,
- mus_dead2,
- mus_stlks3,
- mus_romero,
- mus_shawn2,
- mus_messag,
- mus_count2,
- mus_ddtbl3,
- mus_ampie,
- mus_theda3,
- mus_adrian,
- mus_messg2,
- mus_romer2,
- mus_tense,
- mus_shawn3,
- mus_openin,
- mus_evil,
- mus_ultima,
- mus_read_m,
- mus_dm2ttl,
- mus_dm2int,
- NUMMUSIC
-} musicenum_t;
-
-
-//
-// Identifiers for all sfx in game.
-//
-
-typedef enum
-{
- sfx_None,
- sfx_pistol,
- sfx_shotgn,
- sfx_sgcock,
- sfx_dshtgn,
- sfx_dbopn,
- sfx_dbcls,
- sfx_dbload,
- sfx_plasma,
- sfx_bfg,
- sfx_sawup,
- sfx_sawidl,
- sfx_sawful,
- sfx_sawhit,
- sfx_rlaunc,
- sfx_rxplod,
- sfx_firsht,
- sfx_firxpl,
- sfx_pstart,
- sfx_pstop,
- sfx_doropn,
- sfx_dorcls,
- sfx_stnmov,
- sfx_swtchn,
- sfx_swtchx,
- sfx_plpain,
- sfx_dmpain,
- sfx_popain,
- sfx_vipain,
- sfx_mnpain,
- sfx_pepain,
- sfx_slop,
- sfx_itemup,
- sfx_wpnup,
- sfx_oof,
- sfx_telept,
- sfx_posit1,
- sfx_posit2,
- sfx_posit3,
- sfx_bgsit1,
- sfx_bgsit2,
- sfx_sgtsit,
- sfx_cacsit,
- sfx_brssit,
- sfx_cybsit,
- sfx_spisit,
- sfx_bspsit,
- sfx_kntsit,
- sfx_vilsit,
- sfx_mansit,
- sfx_pesit,
- sfx_sklatk,
- sfx_sgtatk,
- sfx_skepch,
- sfx_vilatk,
- sfx_claw,
- sfx_skeswg,
- sfx_pldeth,
- sfx_pdiehi,
- sfx_podth1,
- sfx_podth2,
- sfx_podth3,
- sfx_bgdth1,
- sfx_bgdth2,
- sfx_sgtdth,
- sfx_cacdth,
- sfx_skldth,
- sfx_brsdth,
- sfx_cybdth,
- sfx_spidth,
- sfx_bspdth,
- sfx_vildth,
- sfx_kntdth,
- sfx_pedth,
- sfx_skedth,
- sfx_posact,
- sfx_bgact,
- sfx_dmact,
- sfx_bspact,
- sfx_bspwlk,
- sfx_vilact,
- sfx_noway,
- sfx_barexp,
- sfx_punch,
- sfx_hoof,
- sfx_metal,
- sfx_chgun,
- sfx_tink,
- sfx_bdopn,
- sfx_bdcls,
- sfx_itmbk,
- sfx_flame,
- sfx_flamst,
- sfx_getpow,
- sfx_bospit,
- sfx_boscub,
- sfx_bossit,
- sfx_bospn,
- sfx_bosdth,
- sfx_manatk,
- sfx_mandth,
- sfx_sssit,
- sfx_ssdth,
- sfx_keenpn,
- sfx_keendt,
- sfx_skeact,
- sfx_skesit,
- sfx_skeatk,
- sfx_radio,
- NUMSFX
-} sfxenum_t;
-
-extern musicinfo_t S_music[];
-extern sfxinfo_t S_sfx[];
-
-#endif
-
+++ /dev/null
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// $Id: soundsrv.c,v 1.3 1997/01/29 22:40:44 b1 Exp $
-//
-// 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: soundsrv.c,v $
-// Revision 1.3 1997/01/29 22:40:44 b1
-// Reformatting, S (sound) module files.
-//
-// Revision 1.2 1997/01/21 19:00:07 b1
-// First formatting run:
-// using Emacs cc-mode.el indentation for C++ now.
-//
-// Revision 1.1 1997/01/19 17:22:50 b1
-// Initial check in DOOM sources as of Jan. 10th, 1997
-//
-//
-// DESCRIPTION:
-// UNIX soundserver, run as a separate process,
-// started by DOOM program.
-// Originally conceived fopr SGI Irix,
-// mostly used with Linux voxware.
-//
-//-----------------------------------------------------------------------------
-
-
-static const char rcsid[] = "$Id: soundsrv.c,v 1.3 1997/01/29 22:40:44 b1 Exp $";
-
-
-
-#include <math.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-
-#include "sounds.h"
-#include "soundsrv.h"
-#include "wadread.h"
-
-
-
-//
-// Department of Redundancy Department.
-//
-typedef struct wadinfo_struct
-{
- // should be IWAD
- char identification[4];
- int numlumps;
- int infotableofs;
-
-} wadinfo_t;
-
-
-typedef struct filelump_struct
-{
- int filepos;
- int size;
- char name[8];
-
-} filelump_t;
-
-
-// an internal time keeper
-static int mytime = 0;
-
-// number of sound effects
-int numsounds;
-
-// longest sound effect
-int longsound;
-
-// lengths of all sound effects
-int lengths[NUMSFX];
-
-// mixing buffer
-signed short mixbuffer[MIXBUFFERSIZE];
-
-// file descriptor of sfx device
-int sfxdevice;
-
-// file descriptor of music device
-int musdevice;
-
-// the channel data pointers
-unsigned char* channels[8];
-
-// the channel step amount
-unsigned int channelstep[8];
-
-// 0.16 bit remainder of last step
-unsigned int channelstepremainder[8];
-
-// the channel data end pointers
-unsigned char* channelsend[8];
-
-// time that the channel started playing
-int channelstart[8];
-
-// the channel handles
-int channelhandles[8];
-
-// the channel left volume lookup
-int* channelleftvol_lookup[8];
-
-// the channel right volume lookup
-int* channelrightvol_lookup[8];
-
-// sfx id of the playing sound effect
-int channelids[8];
-
-int snd_verbose=1;
-
-int steptable[256];
-
-int vol_lookup[128*256];
-
-static void derror(char* msg)
-{
- fprintf(stderr, "error: %s\n", msg);
- exit(-1);
-}
-
-int mix(void)
-{
-
- register int dl;
- register int dr;
- register unsigned int sample;
-
- signed short* leftout;
- signed short* rightout;
- signed short* leftend;
-
- int step;
-
- leftout = mixbuffer;
- rightout = mixbuffer+1;
- step = 2;
-
- leftend = mixbuffer + SAMPLECOUNT*step;
-
- // mix into the mixing buffer
- while (leftout != leftend)
- {
-
- dl = 0;
- dr = 0;
-
- if (channels[0])
- {
- sample = *channels[0];
- dl += channelleftvol_lookup[0][sample];
- dr += channelrightvol_lookup[0][sample];
- channelstepremainder[0] += channelstep[0];
- channels[0] += channelstepremainder[0] >> 16;
- channelstepremainder[0] &= 65536-1;
-
- if (channels[0] >= channelsend[0])
- channels[0] = 0;
- }
-
- if (channels[1])
- {
- sample = *channels[1];
- dl += channelleftvol_lookup[1][sample];
- dr += channelrightvol_lookup[1][sample];
- channelstepremainder[1] += channelstep[1];
- channels[1] += channelstepremainder[1] >> 16;
- channelstepremainder[1] &= 65536-1;
-
- if (channels[1] >= channelsend[1])
- channels[1] = 0;
- }
-
- if (channels[2])
- {
- sample = *channels[2];
- dl += channelleftvol_lookup[2][sample];
- dr += channelrightvol_lookup[2][sample];
- channelstepremainder[2] += channelstep[2];
- channels[2] += channelstepremainder[2] >> 16;
- channelstepremainder[2] &= 65536-1;
-
- if (channels[2] >= channelsend[2])
- channels[2] = 0;
- }
-
- if (channels[3])
- {
- sample = *channels[3];
- dl += channelleftvol_lookup[3][sample];
- dr += channelrightvol_lookup[3][sample];
- channelstepremainder[3] += channelstep[3];
- channels[3] += channelstepremainder[3] >> 16;
- channelstepremainder[3] &= 65536-1;
-
- if (channels[3] >= channelsend[3])
- channels[3] = 0;
- }
-
- if (channels[4])
- {
- sample = *channels[4];
- dl += channelleftvol_lookup[4][sample];
- dr += channelrightvol_lookup[4][sample];
- channelstepremainder[4] += channelstep[4];
- channels[4] += channelstepremainder[4] >> 16;
- channelstepremainder[4] &= 65536-1;
-
- if (channels[4] >= channelsend[4])
- channels[4] = 0;
- }
-
- if (channels[5])
- {
- sample = *channels[5];
- dl += channelleftvol_lookup[5][sample];
- dr += channelrightvol_lookup[5][sample];
- channelstepremainder[5] += channelstep[5];
- channels[5] += channelstepremainder[5] >> 16;
- channelstepremainder[5] &= 65536-1;
-
- if (channels[5] >= channelsend[5])
- channels[5] = 0;
- }
-
- if (channels[6])
- {
- sample = *channels[6];
- dl += channelleftvol_lookup[6][sample];
- dr += channelrightvol_lookup[6][sample];
- channelstepremainder[6] += channelstep[6];
- channels[6] += channelstepremainder[6] >> 16;
- channelstepremainder[6] &= 65536-1;
-
- if (channels[6] >= channelsend[6])
- channels[6] = 0;
- }
- if (channels[7])
- {
- sample = *channels[7];
- dl += channelleftvol_lookup[7][sample];
- dr += channelrightvol_lookup[7][sample];
- channelstepremainder[7] += channelstep[7];
- channels[7] += channelstepremainder[7] >> 16;
- channelstepremainder[7] &= 65536-1;
-
- if (channels[7] >= channelsend[7])
- channels[7] = 0;
- }
-
- // Has been char instead of short.
- // if (dl > 127) *leftout = 127;
- // else if (dl < -128) *leftout = -128;
- // else *leftout = dl;
-
- // if (dr > 127) *rightout = 127;
- // else if (dr < -128) *rightout = -128;
- // else *rightout = dr;
-
- if (dl > 0x7fff)
- *leftout = 0x7fff;
- else if (dl < -0x8000)
- *leftout = -0x8000;
- else
- *leftout = dl;
-
- if (dr > 0x7fff)
- *rightout = 0x7fff;
- else if (dr < -0x8000)
- *rightout = -0x8000;
- else
- *rightout = dr;
-
- leftout += step;
- rightout += step;
-
- }
- return 1;
-}
-
-
-
-void
-grabdata
-( int c,
- char** v )
-{
- int i;
- char* name;
- char* doom1wad;
- char* doomwad;
- char* doomuwad;
- char* doom2wad;
- char* doom2fwad;
- // Now where are TNT and Plutonia. Yuck.
-
- // char *home;
- char* doomwaddir;
-
- doomwaddir = getenv("DOOMWADDIR");
-
- if (!doomwaddir)
- doomwaddir = ".";
-
- doom1wad = malloc(strlen(doomwaddir)+1+9+1);
- sprintf(doom1wad, "%s/doom1.wad", doomwaddir);
-
- doom2wad = malloc(strlen(doomwaddir)+1+9+1);
- sprintf(doom2wad, "%s/doom2.wad", doomwaddir);
-
- doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
- sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);
-
- doomuwad = malloc(strlen(doomwaddir)+1+8+1);
- sprintf(doomuwad, "%s/doomu.wad", doomwaddir);
-
- doomwad = malloc(strlen(doomwaddir)+1+8+1);
- sprintf(doomwad, "%s/doom.wad", doomwaddir);
-
- // home = getenv("HOME");
- // if (!home)
- // derror("Please set $HOME to your home directory");
- // sprintf(basedefault, "%s/.doomrc", home);
-
-
- for (i=1 ; i<c ; i++)
- {
- if (!strcmp(v[i], "-quiet"))
- {
- snd_verbose = 0;
- }
- }
-
- numsounds = NUMSFX;
- longsound = 0;
-
- if (! access(doom2fwad, R_OK) )
- name = doom2fwad;
- else if (! access(doom2wad, R_OK) )
- name = doom2wad;
- else if (! access(doomuwad, R_OK) )
- name = doomuwad;
- else if (! access(doomwad, R_OK) )
- name = doomwad;
- else if (! access(doom1wad, R_OK) )
- name = doom1wad;
- // else if (! access(DEVDATA "doom2.wad", R_OK) )
- // name = DEVDATA "doom2.wad";
- // else if (! access(DEVDATA "doom.wad", R_OK) )
- // name = DEVDATA "doom.wad";
- else
- {
- fprintf(stderr, "Could not find wadfile anywhere\n");
- exit(-1);
- }
-
-
- openwad(name);
- if (snd_verbose)
- fprintf(stderr, "loading from [%s]\n", name);
-
- for (i=1 ; i<NUMSFX ; i++)
- {
- if (!S_sfx[i].link)
- {
- S_sfx[i].data = getsfx(S_sfx[i].name, &lengths[i]);
- if (longsound < lengths[i]) longsound = lengths[i];
- } else {
- S_sfx[i].data = S_sfx[i].link->data;
- lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)];
- }
- // test only
- // {
- // int fd;
- // char name[10];
- // sprintf(name, "sfx%d", i);
- // fd = open(name, O_WRONLY|O_CREAT, 0644);
- // write(fd, S_sfx[i].data, lengths[i]);
- // close(fd);
- // }
- }
-
-}
-
-static struct timeval last={0,0};
-//static struct timeval now;
-
-static struct timezone whocares;
-
-void updatesounds(void)
-{
-
- mix();
- I_SubmitOutputBuffer(mixbuffer, SAMPLECOUNT);
-
-}
-
-int
-addsfx
-( int sfxid,
- int volume,
- int step,
- int seperation )
-{
- static unsigned short handlenums = 0;
-
- int i;
- int rc = -1;
-
- int oldest = mytime;
- int oldestnum = 0;
- int slot;
- int rightvol;
- int leftvol;
-
- // 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 )
- {
- for (i=0 ; i<8 ; i++)
- {
- if (channels[i] && channelids[i] == sfxid)
- {
- channels[i] = 0;
- break;
- }
- }
- }
-
- for (i=0 ; i<8 && channels[i] ; i++)
- {
- if (channelstart[i] < oldest)
- {
- oldestnum = i;
- oldest = channelstart[i];
- }
- }
-
- if (i == 8)
- slot = oldestnum;
- else
- slot = i;
-
- channels[slot] = (unsigned char *) S_sfx[sfxid].data;
- channelsend[slot] = channels[slot] + lengths[sfxid];
-
- if (!handlenums)
- handlenums = 100;
-
- channelhandles[slot] = rc = handlenums++;
- channelstep[slot] = step;
- channelstepremainder[slot] = 0;
- channelstart[slot] = mytime;
-
- // (range: 1 - 256)
- seperation += 1;
-
- // (x^2 seperation)
- leftvol =
- volume - (volume*seperation*seperation)/(256*256);
-
- seperation = seperation - 257;
-
- // (x^2 seperation)
- rightvol =
- volume - (volume*seperation*seperation)/(256*256);
-
- // sanity check
- if (rightvol < 0 || rightvol > 127)
- derror("rightvol out of bounds");
-
- if (leftvol < 0 || leftvol > 127)
- derror("leftvol out of bounds");
-
- // get the proper lookup table piece
- // for this volume level
- channelleftvol_lookup[slot] = &vol_lookup[leftvol*256];
- channelrightvol_lookup[slot] = &vol_lookup[rightvol*256];
-
- channelids[slot] = sfxid;
-
- return rc;
-
-}
-
-
-void outputushort(int num)
-{
-
- static unsigned char buff[5] = { 0, 0, 0, 0, '\n' };
- static char* badbuff = "xxxx\n";
-
- // outputs a 16-bit # in hex or "xxxx" if -1.
- if (num < 0)
- {
- write(1, badbuff, 5);
- }
- else
- {
- buff[0] = num>>12;
- buff[0] += buff[0] > 9 ? 'a'-10 : '0';
- buff[1] = (num>>8) & 0xf;
- buff[1] += buff[1] > 9 ? 'a'-10 : '0';
- buff[2] = (num>>4) & 0xf;
- buff[2] += buff[2] > 9 ? 'a'-10 : '0';
- buff[3] = num & 0xf;
- buff[3] += buff[3] > 9 ? 'a'-10 : '0';
- write(1, buff, 5);
- }
-}
-
-void initdata(void)
-{
-
- int i;
- int j;
-
- int* steptablemid = steptable + 128;
-
- for (i=0 ;
- i<sizeof(channels)/sizeof(unsigned char *) ;
- i++)
- {
- channels[i] = 0;
- }
-
- gettimeofday(&last, &whocares);
-
- for (i=-128 ; i<128 ; i++)
- steptablemid[i] = pow(2.0, (i/64.0))*65536.0;
-
- // generates volume lookup tables
- // which also turn the unsigned samples
- // into signed samples
- // for (i=0 ; i<128 ; i++)
- // for (j=0 ; j<256 ; j++)
- // vol_lookup[i*256+j] = (i*(j-128))/127;
-
- for (i=0 ; i<128 ; i++)
- for (j=0 ; j<256 ; j++)
- vol_lookup[i*256+j] = (i*(j-128)*256)/127;
-
-}
-
-
-
-
-void quit(void)
-{
- I_ShutdownMusic();
- I_ShutdownSound();
- exit(0);
-}
-
-
-
-fd_set fdset;
-fd_set scratchset;
-
-
-
-int
-main
-( int c,
- char** v )
-{
-
- int done = 0;
- int rc;
- int nrc;
- int sndnum;
- int handle = 0;
-
- unsigned char commandbuf[10];
- struct timeval zerowait = { 0, 0 };
-
-
- int step;
- int vol;
- int sep;
-
- int i;
- int waitingtofinish=0;
-
- // get sound data
- grabdata(c, v);
-
- // init any data
- initdata();
-
- I_InitSound(11025, 16);
-
- I_InitMusic();
-
- if (snd_verbose)
- fprintf(stderr, "ready\n");
-
- // parse commands and play sounds until done
- FD_ZERO(&fdset);
- FD_SET(0, &fdset);
-
- while (!done)
- {
- mytime++;
-
- if (!waitingtofinish)
- {
- do {
- scratchset = fdset;
- rc = select(FD_SETSIZE, &scratchset, 0, 0, &zerowait);
-
- if (rc > 0)
- {
- // fprintf(stderr, "select is true\n");
- // got a command
- nrc = read(0, commandbuf, 1);
-
- if (!nrc)
- {
- done = 1;
- rc = 0;
- }
- else
- {
- if (snd_verbose)
- fprintf(stderr, "cmd: %c", commandbuf[0]);
-
- switch (commandbuf[0])
- {
- case 'p':
- // play a new sound effect
- read(0, commandbuf, 9);
-
- if (snd_verbose)
- {
- commandbuf[9]=0;
- fprintf(stderr, "%s\n", commandbuf);
- }
-
- commandbuf[0] -=
- commandbuf[0]>='a' ? 'a'-10 : '0';
- commandbuf[1] -=
- commandbuf[1]>='a' ? 'a'-10 : '0';
- commandbuf[2] -=
- commandbuf[2]>='a' ? 'a'-10 : '0';
- commandbuf[3] -=
- commandbuf[3]>='a' ? 'a'-10 : '0';
- commandbuf[4] -=
- commandbuf[4]>='a' ? 'a'-10 : '0';
- commandbuf[5] -=
- commandbuf[5]>='a' ? 'a'-10 : '0';
- commandbuf[6] -=
- commandbuf[6]>='a' ? 'a'-10 : '0';
- commandbuf[7] -=
- commandbuf[7]>='a' ? 'a'-10 : '0';
-
- // p<snd#><step><vol><sep>
- sndnum = (commandbuf[0]<<4) + commandbuf[1];
- step = (commandbuf[2]<<4) + commandbuf[3];
- step = steptable[step];
- vol = (commandbuf[4]<<4) + commandbuf[5];
- sep = (commandbuf[6]<<4) + commandbuf[7];
-
- handle = addsfx(sndnum, vol, step, sep);
- // returns the handle
- // outputushort(handle);
- break;
-
- case 'q':
- read(0, commandbuf, 1);
- waitingtofinish = 1; rc = 0;
- break;
-
- case 's':
- {
- int fd;
- read(0, commandbuf, 3);
- commandbuf[2] = 0;
- fd = open((char*)commandbuf, O_CREAT|O_WRONLY, 0644);
- commandbuf[0] -= commandbuf[0]>='a' ? 'a'-10 : '0';
- commandbuf[1] -= commandbuf[1]>='a' ? 'a'-10 : '0';
- sndnum = (commandbuf[0]<<4) + commandbuf[1];
- write(fd, S_sfx[sndnum].data, lengths[sndnum]);
- close(fd);
- }
- break;
-
- default:
- fprintf(stderr, "Did not recognize command\n");
- break;
- }
- }
- }
- else if (rc < 0)
- {
- quit();
- }
- } while (rc > 0);
- }
-
- updatesounds();
-
- if (waitingtofinish)
- {
- for(i=0 ; i<8 && !channels[i] ; i++);
-
- if (i==8)
- done=1;
- }
-
- }
-
- quit();
- return 0;
-}
+++ /dev/null
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// $Id: soundsrv.h,v 1.3 1997/01/29 22:40:44 b1 Exp $
-//
-// 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: soundsrv.h,v $
-// Revision 1.3 1997/01/29 22:40:44 b1
-// Reformatting, S (sound) module files.
-//
-// Revision 1.2 1997/01/21 19:00:07 b1
-// First formatting run:
-// using Emacs cc-mode.el indentation for C++ now.
-//
-// Revision 1.1 1997/01/19 17:22:50 b1
-// Initial check in DOOM sources as of Jan. 10th, 1997
-//
-//
-// DESCRIPTION:
-// UNIX soundserver, separate process.
-//
-//-----------------------------------------------------------------------------
-
-#ifndef __SNDSERVER_H__
-#define __SNDSERVER_H__
-
-#define SAMPLECOUNT 512
-#define MIXBUFFERSIZE (SAMPLECOUNT*2*2)
-#define SPEED 11025
-
-
-void I_InitMusic(void);
-
-void
-I_InitSound
-( int samplerate,
- int samplesound );
-
-void
-I_SubmitOutputBuffer
-( void* samples,
- int samplecount );
-
-void I_ShutdownSound(void);
-void I_ShutdownMusic(void);
-
-#endif
+++ /dev/null
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// $Id: soundst.h,v 1.3 1997/01/29 22:40:45 b1 Exp $
-//
-// 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: soundst.h,v $
-// Revision 1.3 1997/01/29 22:40:45 b1
-// Reformatting, S (sound) module files.
-//
-// Revision 1.2 1997/01/21 19:00:07 b1
-// First formatting run:
-// using Emacs cc-mode.el indentation for C++ now.
-//
-// Revision 1.1 1997/01/19 17:22:50 b1
-// Initial check in DOOM sources as of Jan. 10th, 1997
-//
-//
-// DESCRIPTION:
-// Sound (utility) related. Hang on.
-// See gensounds.h and gensounds.c for what soundst.h is made of.
-//
-//-----------------------------------------------------------------------------
-
-#ifndef __SOUNDSTH__
-#define __SOUNDSTH__
-
-#define S_MAX_VOLUME 127
-
-// when to clip out sounds
-// Doesn't fit the large outdoor areas.
-#define S_CLIPPING_DIST (1200*0x10000)
-
-// when sounds should be max'd out
-#define S_CLOSE_DIST (200*0x10000)
-
-
-#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS)
-
-#define NORM_PITCH 128
-#define NORM_PRIORITY 64
-#define NORM_VOLUME snd_MaxVolume
-
-#define S_PITCH_PERTURB 1
-#define NORM_SEP 128
-#define S_STEREO_SWING (96*0x10000)
-
-// % attenuation from front to back
-#define S_IFRACVOL 30
-
-#define NA 0
-#define S_NUMCHANNELS 2
-
-
-
-
-//
-// MusicInfo struct.
-//
-typedef struct
-{
- // up to 6-character name
- char* name;
-
- // lump number of music
- int lumpnum;
-
- // music data
- void* data;
-
- // music handle once registered
- int handle;
-
-} musicinfo_t;
-
-
-
-//
-// SoundFX struct.
-//
-typedef struct sfxinfo_struct sfxinfo_t;
-
-struct sfxinfo_struct
-{
- // up to 6-character name
- char* name;
-
- // Sfx singularity (only one at a time)
- int singularity;
-
- // Sfx priority
- int priority;
-
- // referenced sound if a link
- sfxinfo_t* link;
-
- // pitch if a link
- int pitch;
-
- // volume if a link
- int volume;
-
- // sound data
- void* data;
-
- // this is checked every second to see if sound
- // can be thrown out (if 0, then decrement, if -1,
- // then throw out, if > 0, then it's in use)
- int usefulness;
-
- // lump number of sfx
- int lumpnum;
-};
-
-
-
-typedef struct
-{
- // sound information (if null, channel avail.)
- sfxinfo_t* sfxinfo;
-
- // origin of sound
- void* origin;
-
- // handle of the sound being played
- int handle;
-
-} channel_t;
-
-
-
-enum
-{
- Music,
- Sfx,
- SfxLink
-};
-
-enum
-{
- PC=1,
- Adlib=2,
- SB=4,
- Midi=8
-}; // cards available
-
-enum
-{
- sfxThrowOut=-1,
- sfxNotUsed=0
-};
-
-
-//
-// Initialize the sound code at start of level
-//
-void S_Start(void);
-
-//
-// Start sound for thing at <origin>
-// using <sound_id> from sounds.h
-//
-extern void
-S_StartSound
-( void* origin,
- int sound_id );
-
-
-
-// Will start a sound at a given volume.
-extern void
-S_StartSoundAtVolume
-( void* origin,
- int sound_id,
- int volume );
-
-
-// Stop sound for thing at <origin>
-extern void S_StopSound(void* origin);
-
-// Start music using <music_id> from sounds.h
-extern void S_StartMusic(int music_id);
-
-// Start music using <music_id> from sounds.h,
-// and set whether looping
-extern void
-S_ChangeMusic
-( int music_id,
- int looping );
-
-
-// Stops the music
-extern void S_StopMusic(void);
-
-void S_PauseSound(void);
-void S_ResumeSound(void);
-
-
-//
-// Updates music & sounds
-//
-extern void S_UpdateSounds(void* listener);
-
-void S_SetMusicVolume(int volume);
-void S_SetSfxVolume(int volume);
-
-//
-// Initializes sound stuff, including volume
-//
-void
-S_Init
-( int ,
- int );
-
-
-
-//
-// SOUND IO
-//
-#define FREQ_LOW 0x40
-#define FREQ_NORM 0x80
-#define FREQ_HIGH 0xff
-
-
-void I_SetMusicVolume(int volume);
-void I_SetSfxVolume(int volume);
-
-//
-// MUSIC I/O
-//
-void I_PauseSong(int handle);
-void I_ResumeSong(int handle);
-
-//
-// Called by anything that wishes to start music.
-// plays a song, and when the song is done,
-// starts playing it again in an endless loop.
-// Horrible thing to do, considering.
-void
-I_PlaySong
-( int handle,
- int looping );
-
-
-// stops a song over 3 seconds.
-void I_StopSong(int handle);
-
-// registers a song handle to song data
-int I_RegisterSong(void *data);
-
-// see above then think backwards
-void I_UnRegisterSong(int handle);
-
-// is the song playing?
-int I_QrySongPlaying(int handle);
-
-
-//
-// SFX I/O
-//
-void I_SetChannels(int channels);
-
-int I_GetSfxLumpNum (sfxinfo_t*);
-
-
-// Starts a sound in a particular sound channel.
-int
-I_StartSound
-( int id,
- void* data,
- int vol,
- int sep,
- int pitch,
- int priority );
-
-
-// Updates the volume, separation,
-// and pitch of a sound channel.
-void
-I_UpdateSoundParams
-( int handle,
- int vol,
- int sep,
- int pitch );
-
-
-// Stops a sound channel.
-void I_StopSound(int handle);
-
-// Called by S_*()'s to see if a channel is still playing.
-// Returns 0 if no longer playing, 1 if playing.
-int I_SoundIsPlaying(int handle);
-
-
-// the complete set of sound effects
-extern sfxinfo_t S_sfx[];
-
-// the complete set of music
-extern musicinfo_t S_music[];
-
-#endif
+++ /dev/null
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// $Id: wadread.c,v 1.3 1997/01/30 19:54:23 b1 Exp $
-//
-// 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: wadread.c,v $
-// Revision 1.3 1997/01/30 19:54:23 b1
-// Final reformatting run. All the remains (ST, W, WI, Z).
-//
-// Revision 1.2 1997/01/21 19:00:10 b1
-// First formatting run:
-// using Emacs cc-mode.el indentation for C++ now.
-//
-// Revision 1.1 1997/01/19 17:22:51 b1
-// Initial check in DOOM sources as of Jan. 10th, 1997
-//
-//
-// DESCRIPTION:
-// WAD and Lump I/O, the second.
-// This time for soundserver only.
-// Welcome to Department of Redundancy Department. Again :-).
-//
-//-----------------------------------------------------------------------------
-
-
-static const char rcsid[] = "$Id: wadread.c,v 1.3 1997/01/30 19:54:23 b1 Exp $";
-
-
-
-#include <malloc.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.h>
-
-#include "soundsrv.h"
-#include "wadread.h"
-
-
-int* sfxlengths;
-
-typedef struct wadinfo_struct
-{
- char identification[4];
- int numlumps;
- int infotableofs;
-
-} wadinfo_t;
-
-typedef struct filelump_struct
-{
- int filepos;
- int size;
- char name[8];
-
-} filelump_t;
-
-typedef struct lumpinfo_struct
-{
- int handle;
- int filepos;
- int size;
- char name[8];
-
-} lumpinfo_t;
-
-
-
-lumpinfo_t* lumpinfo;
-int numlumps;
-
-void** lumpcache;
-
-
-#define strcmpi strcasecmp
-
-
-//
-// Something new.
-// This version of w_wad.c does handle endianess.
-//
-#ifndef __BIG_ENDIAN__
-
-#define LONG(x) (x)
-#define SHORT(x) (x)
-
-#else
-
-#define LONG(x) ((long)SwapLONG((unsigned long) (x)))
-#define SHORT(x) ((short)SwapSHORT((unsigned short) (x)))
-
-unsigned long SwapLONG(unsigned long x)
-{
- return
- (x>>24)
- | ((x>>8) & 0xff00)
- | ((x<<8) & 0xff0000)
- | (x<<24);
-}
-
-unsigned short SwapSHORT(unsigned short x)
-{
- return
- (x>>8) | (x<<8);
-}
-
-#endif
-
-
-
-// Way too many of those...
-static void derror(char* msg)
-{
- fprintf(stderr, "\nwadread error: %s\n", msg);
- exit(-1);
-}
-
-
-void strupr (char *s)
-{
- while (*s)
- *s++ = toupper(*s);
-}
-
-int filelength (int handle)
-{
- struct stat fileinfo;
-
- if (fstat (handle,&fileinfo) == -1)
- fprintf (stderr, "Error fstating\n");
-
- return fileinfo.st_size;
-}
-
-
-
-void openwad(char* wadname)
-{
-
- int wadfile;
- int tableoffset;
- int tablelength;
- int tablefilelength;
- int i;
- wadinfo_t header;
- filelump_t* filetable;
-
- // open and read the wadfile header
- wadfile = open(wadname, O_RDONLY);
-
- if (wadfile < 0)
- derror("Could not open wadfile");
-
- read(wadfile, &header, sizeof header);
-
- if (strncmp(header.identification, "IWAD", 4))
- derror("wadfile has weirdo header");
-
- numlumps = LONG(header.numlumps);
- tableoffset = LONG(header.infotableofs);
- tablelength = numlumps * sizeof(lumpinfo_t);
- tablefilelength = numlumps * sizeof(filelump_t);
- lumpinfo = (lumpinfo_t *) malloc(tablelength);
- filetable = (filelump_t *) ((char*)lumpinfo + tablelength - tablefilelength);
-
- // get the lumpinfo table
- lseek(wadfile, tableoffset, SEEK_SET);
- read(wadfile, filetable, tablefilelength);
-
- // process the table to make the endianness right and shift it down
- for (i=0 ; i<numlumps ; i++)
- {
- strncpy(lumpinfo[i].name, filetable[i].name, 8);
- lumpinfo[i].handle = wadfile;
- lumpinfo[i].filepos = LONG(filetable[i].filepos);
- lumpinfo[i].size = LONG(filetable[i].size);
- // fprintf(stderr, "lump [%.8s] exists\n", lumpinfo[i].name);
- }
-
-}
-
-void*
-loadlump
-( char* lumpname,
- int* size )
-{
-
- int i;
- void* lump;
-
- for (i=0 ; i<numlumps ; i++)
- {
- if (!strncasecmp(lumpinfo[i].name, lumpname, 8))
- break;
- }
-
- if (i == numlumps)
- {
- // fprintf(stderr,
- // "Could not find lumpname [%s]\n", lumpname);
- lump = 0;
- }
- else
- {
- lump = (void *) malloc(lumpinfo[i].size);
- lseek(lumpinfo[i].handle, lumpinfo[i].filepos, SEEK_SET);
- read(lumpinfo[i].handle, lump, lumpinfo[i].size);
- *size = lumpinfo[i].size;
- }
-
- return lump;
-
-}
-
-void*
-getsfx
-( char* sfxname,
- int* len )
-{
-
- unsigned char* sfx;
- unsigned char* paddedsfx;
- int i;
- int size;
- int paddedsize;
- char name[20];
-
- sprintf(name, "ds%s", sfxname);
-
- sfx = (unsigned char *) loadlump(name, &size);
-
- // pad the sound effect out to the mixing buffer size
- paddedsize = ((size-8 + (SAMPLECOUNT-1)) / SAMPLECOUNT) * SAMPLECOUNT;
- paddedsfx = (unsigned char *) realloc(sfx, paddedsize+8);
- for (i=size ; i<paddedsize+8 ; i++)
- paddedsfx[i] = 128;
-
- *len = paddedsize;
- return (void *) (paddedsfx + 8);
-
-}
+++ /dev/null
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// $Id: wadread.h,v 1.3 1997/01/30 19:54:23 b1 Exp $
-//
-// 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: wadread.h,v $
-// Revision 1.3 1997/01/30 19:54:23 b1
-// Final reformatting run. All the remains (ST, W, WI, Z).
-//
-// Revision 1.2 1997/01/21 19:00:10 b1
-// First formatting run:
-// using Emacs cc-mode.el indentation for C++ now.
-//
-// Revision 1.1 1997/01/19 17:22:52 b1
-// Initial check in DOOM sources as of Jan. 10th, 1997
-//
-//
-// DESCRIPTION:
-// WAD and Lump I/O, the second.
-// This time for soundserver only.
-// Welcome to Department of Redundancy Department.
-// (Yeah, I said that elsewhere already).
-// Note: makes up for a nice w_wad.h.
-//
-//-----------------------------------------------------------------------------
-
-#ifndef __WADREAD_H__
-#define __WADREAD_H__
-
-//
-// Opens the wadfile specified.
-// Must be called before any calls to loadlump() or getsfx().
-//
-
-void openwad(char* wadname);
-
-//
-// Gets a sound effect from the wad file. The pointer points to the
-// start of the data. Returns a 0 if the sfx was not
-// found. Sfx names should be no longer than 6 characters. All data is
-// rounded up in size to the nearest MIXBUFFERSIZE and is padded out with
-// 0x80's. Returns the data length in len.
-//
-
-void*
-getsfx
-( char* sfxname,
- int* len );
-
-#endif