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 version_string "0.5.810"
33 #define ExtFunc /* Marks functions that need prototypes */
35 #ifdef NOEXT //prevent re-declaration
41 #ifdef HAS_SIGPROCMASK
42 typedef sigset_t MySigSet;
48 * The following definitions are to ensure network compatibility even if
49 * the sizes of ints and shorts are different. I'm not sure exactly how
50 * to deal with this problem, so I've added an abstraction layer.
53 typedef short netint2;
56 #define hton2(x) htons(x)
57 #define hton4(x) htonl(x)
58 #define ntoh2(x) ntohs(x)
59 #define ntoh4(x) ntohl(x)
61 /* Protocol versions */
62 #define MAJOR_VERSION 1
63 #define PROTOCOL_VERSION 4
64 #define ROBOT_VERSION 1
66 #define DEFAULT_PORT 9284 /* Very arbitrary */
68 #define CONFIG_FILE "netris.conf"
70 //#define DEFAULT_KEYS "hlkj mfp^lq"
71 //#define DEFAULT_KEYS "4685 2fp^lq"
72 #define DEFAULT_KEYS "dcaf b^fp^lq"
74 #define MAX_BOARD_WIDTH 32
75 #define MAX_BOARD_HEIGHT 64
76 #define MAX_SCREENS 9 //8 players
79 #define EM_alarm 000001
82 #define EM_robot 000010
85 typedef enum _GameType { GT_onePlayer, GT_classicTwo, GT_len } GameType;
86 typedef enum _BlockTypeA {
87 BT_none, BT_white, BT_blue, BT_magenta, BT_cyan, BT_yellow, BT_green,
88 BT_red, BT_wall, BT_len
90 typedef enum _Dir { D_down, D_right, D_up, D_left } Dir;
91 typedef enum _Cmd { C_end, C_forw, C_back, C_left, C_right, C_plot } Cmd;
92 typedef enum _FDType { FT_read, FT_write, FT_except, FT_len } FDType;
93 typedef enum _MyEventType {
94 E_none, E_alarm, E_key, E_net, E_lostConn, E_robot, E_lostRobot
96 typedef enum _NetPacketType {
97 NP_endConn, NP_byeBye,
98 NP_error, NP_hello, NP_gamedata, NP_newPlayer, NP_goAhead,
99 NP_pause, NP_argghhh, NP_giveJunk, NP_newPiece, NP_down, NP_left, NP_right,
100 NP_rotright, NP_rotleft, NP_drop, NP_clear, NP_insertJunk
103 typedef signed char BlockType;
105 typedef struct _MyEvent {
123 typedef MyEventType (*EventGenFunc)(struct _EventGenRec *gen, MyEvent *event);
125 typedef struct _EventGenRec {
126 struct _EventGenRec *next;
134 int bufSize, bufGoal;
136 EXT EventGenRec netGen[MAX_SCREENS];
138 MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
140 typedef struct _Shape {
141 struct _Shape *rotateTo, *rotateFrom;
142 int initY, initX, mirrored;
148 typedef struct _ShapeOption {
153 typedef int (*ShapeDrawFunc)(int scr, int y, int x,
154 BlockType type, void *data);
156 /* NP_startConn flags */
157 #define SCF_usingRobot 000001
158 #define SCF_fairRobot 000002
159 #define SCF_paused 000004
161 EXT int totalPlayers;
163 typedef struct _Player {
169 int boardHeight, boardWidth, boardVisible;
171 Shape *curShape, *nextShape;
175 int drops, lines, adds;
177 char host[256]; //last-1
180 EXT Player Players[MAX_SCREENS];
183 #define DEFAULT_INTERVAL 1000000 /* Step-down interval in microseconds */
185 #define SPEEDMINIMUM 40000
187 typedef struct __Game {
191 int standout, color, ascii;
196 EXT int robotEnable, robotVersion, fairRobot;
197 EXT int protocolVersion;
202 EXT char scratch[1024];
204 extern ShapeOption stdOptions[];
208 #endif /* NETRIS_H */