home *** CD-ROM | disk | FTP | other *** search
/ WADS of WADS / WadsOfWads.1994.zip / MULTI / IPXSRC / DOOMNET.C next >
C/C++ Source or Header  |  1994-02-13  |  2KB  |  114 lines

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