MULTI.H 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef __MULTI_H
  2. #define __MULTI_H
  3. #define MAXPLAYERS 16
  4. /***********************************************************************
  5. * Multiplayer functions
  6. **********************************************************************/
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. extern short numplayers, myconnectindex;
  11. extern short connecthead, connectpoint2[MAXPLAYERS];
  12. extern char syncstate; // if becomes non-zero, then a packet was dropped
  13. extern long *lastpacket2clock;
  14. void initmultiplayers(char mode, char comRate, char priority);
  15. /* Call this right after initengine.
  16. mode =
  17. 1 = COM1
  18. 2 = COM2
  19. 3 = COM3
  20. 4 = COM4
  21. 5 = IPX 2 player
  22. 6 = IPX 3 player
  23. 7 = IPX 4 player
  24. comRate =
  25. upper 4 bits = IRQ - 2
  26. lower 4 bits =
  27. 0 = 2400
  28. 1 = 4800
  29. 2 = 9600
  30. 3 = 14400
  31. 4 = 19200
  32. 5 = 28800
  33. */
  34. void uninitmultiplayers( void );
  35. /* Call this right before uninitengine. */
  36. void sendlogon( void );
  37. /* Use this function after everything's initialized, but before you go into the
  38. main game loop. Right after you call sendlogon(), you should run a loop that
  39. will wait until a specified number of players. Here's some example code:
  40. sendlogon();
  41. while (numplayers < waitplayers)
  42. {
  43. getpackets();
  44. }
  45. screenpeek = myconnectindex;
  46. Getpackets reserves the packet header range from 200-255. If you keep calling
  47. getpackets after sendlogon, the numplayers variable will automatically be
  48. incremented when other people log on. */
  49. void sendlogoff( void );
  50. /* Call this before leaving, before uninitializing the multiplayer code. */
  51. void sendpacket(short nIndex, char *bufptr, short buflen);
  52. /* For COM(modem) communications, the otherconnectindex doesn't matter. For
  53. network communcations, you can specify which computer to send to by setting
  54. nIndex to the proper index number. You can also do a broadcast by setting
  55. nIndex to -1. Also pass the buffer and length parameters. The first character
  56. of the buffer normally contains the packet type. Packets types 200-255 are
  57. used internally. 255 is send logoff. */
  58. short getpacket (short *nIndex, char *bufptr);
  59. /* returns bufleng. When using getpacket, first check the value it returns.
  60. If the value is 0, then the buffer length is 0 which means there are no packets
  61. available. If the buffer length is greater than 0, then use that value as the
  62. length of the buffer. Getpacket also tells you what computer the message was
  63. received from in nIndex. */
  64. long getoutputcirclesize( void );
  65. /* This function returns the number of bytes that have not yet been copied. If
  66. there are still more than say, 16 bytes, then you may be sending too many bytes
  67. per second. This can happen if the frame rate of a computer is faster than the
  68. speed of the serial mode (Ex: Try 2400 baud with a Pentium 90!) this function
  69. will tell you how many bytes are left to copy In other words, if
  70. getoutputcirclesize() < 16 then it is safe to send a packet. If you already
  71. have serial mode working all you have to do to update your code is to copy the
  72. lines in my sync() function the deal with the getoutputcirclesize function.
  73. Everything else in sync() and getpackets() is pretty much the same. */
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif