forked from id-Software/DOOM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The source for the DOOM serial / model driver.
- Loading branch information
Travis Bradshaw
committed
Jan 31, 2012
1 parent
73424b6
commit 77735c3
Showing
8 changed files
with
1,443 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#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 | ||
|
||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// 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); | ||
|
Oops, something went wrong.