2 * Netris -- A free networked version of T*tris
3 * Copyright (C) 1994-1996,1999 Mark H. Weaver <mhw@netris.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 * $Id: netris.h,v 1.28 1999/05/16 06:56:29 mhw Exp $
31 #define ExtFunc /* Marks functions that need prototypes */
42 # define NULL ((void *)0)
45 #ifdef HAS_SIGPROCMASK
46 typedef sigset_t MySigSet;
52 * The following definitions are to ensure network compatibility even if
53 * the sizes of ints and shorts are different. I'm not sure exactly how
54 * to deal with this problem, so I've added an abstraction layer.
57 typedef short netint2;
60 #define hton2(x) htons(x)
61 #define hton4(x) htonl(x)
63 #define ntoh2(x) ntohs(x)
64 #define ntoh4(x) ntohl(x)
66 #define DEFAULT_PORT 9284 /* Very arbitrary */
68 #define DEFAULT_KEYS "jkl mspf^l"
70 /* Protocol versions */
71 #define MAJOR_VERSION 1
72 #define PROTOCOL_VERSION 3
73 #define ROBOT_VERSION 1
75 #define MAX_BOARD_WIDTH 32
76 #define MAX_BOARD_HEIGHT 64
79 #define DEFAULT_INTERVAL 300000 /* Step-down interval in microseconds */
81 /* NP_startConn flags */
82 #define SCF_usingRobot 000001
83 #define SCF_fairRobot 000002
84 #define SCF_setSeed 000004
87 #define EM_alarm 000001
90 #define EM_robot 000010
93 typedef enum _GameType { GT_onePlayer, GT_classicTwo, GT_len } GameType;
94 typedef enum _BlockTypeA { BT_none, BT_white, BT_blue, BT_magenta,
95 BT_cyan, BT_yellow, BT_green, BT_red,
96 BT_wall, BT_len } BlockTypeA;
97 typedef enum _Dir { D_down, D_right, D_up, D_left } Dir;
98 typedef enum _Cmd { C_end, C_forw, C_back, C_left, C_right, C_plot } Cmd;
99 typedef enum _FDType { FT_read, FT_write, FT_except, FT_len } FDType;
100 typedef enum _MyEventType { E_none, E_alarm, E_key, E_net,
101 E_lostConn, E_robot, E_lostRobot } MyEventType;
102 typedef enum _NetPacketType { NP_endConn, NP_giveJunk, NP_newPiece,
103 NP_down, NP_left, NP_right,
104 NP_rotate, NP_drop, NP_clear,
105 NP_insertJunk, NP_startConn,
106 NP_userName, NP_pause, NP_version,
107 NP_byeBye } NetPacketType;
109 typedef signed char BlockType;
111 typedef struct _MyEvent {
128 typedef MyEventType (*EventGenFunc)(struct _EventGenRec *gen, MyEvent *event);
130 typedef struct _EventGenRec {
131 struct _EventGenRec *next;
139 typedef struct _Shape {
140 struct _Shape *rotateTo;
141 int initY, initX, mirrored;
147 typedef struct _ShapeOption {
152 typedef int (*ShapeDrawFunc)(int scr, int y, int x,
153 BlockType type, void *data);
156 EXT int boardHeight[MAX_SCREENS];
157 EXT int boardVisible[MAX_SCREENS], boardWidth[MAX_SCREENS];
158 EXT Shape *curShape[MAX_SCREENS];
159 EXT int curY[MAX_SCREENS], curX[MAX_SCREENS];
160 EXT char opponentName[16], opponentHost[256];
161 EXT int standoutEnable, colorEnable;
162 EXT int robotEnable, robotVersion, fairRobot;
163 EXT int protocolVersion;
166 EXT long stepDownInterval, speed;
168 EXT int myFlags, opponentFlags;
170 EXT char scratch[1024];
172 extern ShapeOption stdOptions[];
173 extern char *version_string;
177 #endif /* NETRIS_H */