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

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