|
| 1 | +#include <stdio.h> |
| 2 | +#include <io.h> |
| 3 | +#include <stdlib.h> |
| 4 | +#include <string.h> |
| 5 | +#include <process.h> |
| 6 | +#include <dos.h> |
| 7 | +#include "doomnet.h" |
| 8 | + |
| 9 | +//#include "serstr.h" |
| 10 | +#include "ser_frch.h" // FRENCH VERSION |
| 11 | + |
| 12 | +#define DOOM2 |
| 13 | + |
| 14 | +extern int myargc; |
| 15 | +extern char **myargv; |
| 16 | + |
| 17 | +doomcom_t doomcom; |
| 18 | +int vectorishooked; |
| 19 | +void interrupt (*olddoomvect) (void); |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +/* |
| 24 | +================= |
| 25 | += |
| 26 | += CheckParm |
| 27 | += |
| 28 | += Checks for the given parameter in the program's command line arguments |
| 29 | += |
| 30 | += Returns the argument number (1 to argc-1) or 0 if not present |
| 31 | += |
| 32 | +================= |
| 33 | +*/ |
| 34 | + |
| 35 | +int CheckParm (char *check) |
| 36 | +{ |
| 37 | + int i; |
| 38 | + |
| 39 | + for (i = 1;i<myargc;i++) |
| 40 | + if ( !stricmp(check,myargv[i]) ) |
| 41 | + return i; |
| 42 | + |
| 43 | + return 0; |
| 44 | +} |
| 45 | + |
| 46 | + |
| 47 | +/* |
| 48 | +============= |
| 49 | += |
| 50 | += LaunchDOOM |
| 51 | += |
| 52 | +These fields in doomcom should be filled in before calling: |
| 53 | +
|
| 54 | + short numnodes; // console is allways node 0 |
| 55 | + short ticdup; // 1 = no duplication, 2-5 = dup for slow nets |
| 56 | + short extratics; // 1 = send a backup tic in every packet |
| 57 | +
|
| 58 | + short consoleplayer; // 0-3 = player number |
| 59 | + short numplayers; // 1-4 |
| 60 | + short angleoffset; // 1 = left, 0 = center, -1 = right |
| 61 | + short drone; // 1 = drone |
| 62 | +============= |
| 63 | +*/ |
| 64 | + |
| 65 | +void LaunchDOOM (void) |
| 66 | +{ |
| 67 | + char *newargs[99]; |
| 68 | + char adrstring[10]; |
| 69 | + long flatadr; |
| 70 | + int p; |
| 71 | + unsigned char far *vector; |
| 72 | + |
| 73 | +// prepare for DOOM |
| 74 | + doomcom.id = DOOMCOM_ID; |
| 75 | + |
| 76 | +// hook an interrupt vector |
| 77 | + p= CheckParm ("-vector"); |
| 78 | + |
| 79 | + if (p) |
| 80 | + { |
| 81 | + doomcom.intnum = sscanf ("0x%x",_argv[p+1]); |
| 82 | + } |
| 83 | + else |
| 84 | + { |
| 85 | + for (doomcom.intnum = 0x60 ; doomcom.intnum <= 0x66 ; doomcom.intnum++) |
| 86 | + { |
| 87 | + vector = *(char far * far *)(doomcom.intnum*4); |
| 88 | + if ( !vector || *vector == 0xcf ) |
| 89 | + break; |
| 90 | + } |
| 91 | + if (doomcom.intnum == 0x67) |
| 92 | + { |
| 93 | + printf (STR_WARNING); |
| 94 | + doomcom.intnum = 0x66; |
| 95 | + } |
| 96 | + } |
| 97 | + printf (STR_COMM"\n",doomcom.intnum); |
| 98 | + |
| 99 | + olddoomvect = getvect (doomcom.intnum); |
| 100 | + setvect (doomcom.intnum,NetISR); |
| 101 | + vectorishooked = 1; |
| 102 | + |
| 103 | +// build the argument list for DOOM, adding a -net &doomcom |
| 104 | + memcpy (newargs, myargv, (myargc+1)*2); |
| 105 | + newargs[myargc] = "-net"; |
| 106 | + flatadr = (long)_DS*16 + (unsigned)&doomcom; |
| 107 | + sprintf (adrstring,"%lu",flatadr); |
| 108 | + newargs[myargc+1] = adrstring; |
| 109 | + newargs[myargc+2] = NULL; |
| 110 | + |
| 111 | +// spawnv (P_WAIT, "m:\\newdoom\\doom", newargs); |
| 112 | + if (!access("doom2.exe",0)) |
| 113 | + spawnv (P_WAIT, "doom2", newargs); |
| 114 | + else |
| 115 | + spawnv (P_WAIT, "doom", newargs); |
| 116 | + |
| 117 | + #ifdef DOOM2 |
| 118 | + printf (STR_RETURNED"\n"); |
| 119 | + #else |
| 120 | + printf ("Returned from DOOM\n"); |
| 121 | + #endif |
| 122 | + |
| 123 | + |
| 124 | +} |
| 125 | + |
| 126 | + |
0 commit comments