1 /*****************************************************************************\
2      Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3                 This file is licensed under the Snes9x License.
4    For further information, consult the LICENSE file in the root directory.
5 \*****************************************************************************/
6 
7 /***********************************************************************************
8   SNES9X for Mac OS (c) Copyright John Stiles
9 
10   Snes9x for Mac OS X
11 
12   (c) Copyright 2001 - 2011  zones
13   (c) Copyright 2002 - 2005  107
14   (c) Copyright 2002         PB1400c
15   (c) Copyright 2004         Alexander and Sander
16   (c) Copyright 2004 - 2005  Steven Seeger
17   (c) Copyright 2005         Ryan Vogt
18  ***********************************************************************************/
19 
20 
21 #ifndef _mac_netplay_h_
22 #define _mac_netplay_h_
23 
24 #define	WRITE_LONG(p, v) \
25 { \
26 	*((p) + 0) = (uint8) ((v) >> 24); \
27 	*((p) + 1) = (uint8) ((v) >> 16); \
28 	*((p) + 2) = (uint8) ((v) >>  8); \
29 	*((p) + 3) = (uint8) ((v) >>  0); \
30 }
31 
32 #define	WRITE_BYTE(p, v) \
33 { \
34 	*(p) = (uint8) (v); \
35 }
36 
37 #define READ_LONG(p) \
38 ( \
39 	(((uint8) *((p) + 0)) << 24) | \
40  	(((uint8) *((p) + 1)) << 16) | \
41  	(((uint8) *((p) + 2)) <<  8) | \
42  	(((uint8) *((p) + 3)) <<  0) \
43 )
44 
45 #define READ_BYTE(p) \
46 ( \
47 	(uint8) *(p) \
48 )
49 
50 //#define SELF_TEST
51 
52 #define	NP_SERVER_MAGIC	'S'
53 #define	NP_CLIENT_MAGIC	'C'
54 #define	NP_MAX_PLAYERS	5
55 #define	NP_MAX_CLIENTS	(NP_MAX_PLAYERS - 1)
56 #define NP_PORT			6096
57 
58 #ifdef SELF_TEST
59 #define SOCK_NAME		"/tmp/s9xsocket"
60 #endif
61 
62 enum
63 {
64 	kNPClientNameSent = 101,
65 	kNPClientROMInfoWaiting,
66 	kNPClientROMOpened,
67 	kNPClientSRAMWaiting,
68 	kNPClientSRAMLoaded,
69 	kNPClientPlayerWaiting,
70 	kNPClientPlayWaiting,
71 	kNPClientStartWait
72 };
73 
74 enum
75 {
76 	kNPServerNameRequest = 201,
77 	kNPServerNameReceived,
78 	kNPServerROMInfoWillSend,
79 	kNPServerSRAMWillSend,
80 	kNPServerPlayerWillSend,
81 	kNPServerStart
82 };
83 
84 int socket_read (int, unsigned char *, int);
85 int socket_write (int, unsigned char *, int);
86 void NPError (const char *, int);
87 void NPNotification (const char *, int);
88 
89 #endif
90