DOOMNET.C 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. //#include "serstr.h"
  9. #include "ser_frch.h" // FRENCH VERSION
  10. #define DOOM2
  11. extern int myargc;
  12. extern char **myargv;
  13. doomcom_t doomcom;
  14. int vectorishooked;
  15. void interrupt (*olddoomvect) (void);
  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. int CheckParm (char *check)
  28. {
  29. int i;
  30. for (i = 1;i<myargc;i++)
  31. if ( !stricmp(check,myargv[i]) )
  32. return i;
  33. return 0;
  34. }
  35. /*
  36. =============
  37. =
  38. = LaunchDOOM
  39. =
  40. These fields in doomcom should be filled in before calling:
  41. short numnodes; // console is allways node 0
  42. short ticdup; // 1 = no duplication, 2-5 = dup for slow nets
  43. short extratics; // 1 = send a backup tic in every packet
  44. short consoleplayer; // 0-3 = player number
  45. short numplayers; // 1-4
  46. short angleoffset; // 1 = left, 0 = center, -1 = right
  47. short drone; // 1 = drone
  48. =============
  49. */
  50. void LaunchDOOM (void)
  51. {
  52. char *newargs[99];
  53. char adrstring[10];
  54. long flatadr;
  55. int p;
  56. unsigned char far *vector;
  57. // prepare for DOOM
  58. doomcom.id = DOOMCOM_ID;
  59. // hook an interrupt vector
  60. p= CheckParm ("-vector");
  61. if (p)
  62. {
  63. doomcom.intnum = sscanf ("0x%x",_argv[p+1]);
  64. }
  65. else
  66. {
  67. for (doomcom.intnum = 0x60 ; doomcom.intnum <= 0x66 ; doomcom.intnum++)
  68. {
  69. vector = *(char far * far *)(doomcom.intnum*4);
  70. if ( !vector || *vector == 0xcf )
  71. break;
  72. }
  73. if (doomcom.intnum == 0x67)
  74. {
  75. printf (STR_WARNING);
  76. doomcom.intnum = 0x66;
  77. }
  78. }
  79. printf (STR_COMM"\n",doomcom.intnum);
  80. olddoomvect = getvect (doomcom.intnum);
  81. setvect (doomcom.intnum,NetISR);
  82. vectorishooked = 1;
  83. // build the argument list for DOOM, adding a -net &doomcom
  84. memcpy (newargs, myargv, (myargc+1)*2);
  85. newargs[myargc] = "-net";
  86. flatadr = (long)_DS*16 + (unsigned)&doomcom;
  87. sprintf (adrstring,"%lu",flatadr);
  88. newargs[myargc+1] = adrstring;
  89. newargs[myargc+2] = NULL;
  90. // spawnv (P_WAIT, "m:\\newdoom\\doom", newargs);
  91. if (!access("doom2.exe",0))
  92. spawnv (P_WAIT, "doom2", newargs);
  93. else
  94. spawnv (P_WAIT, "doom", newargs);
  95. #ifdef DOOM2
  96. printf (STR_RETURNED"\n");
  97. #else
  98. printf ("Returned from DOOM\n");
  99. #endif
  100. }