1 /*
2  *                               Alizarin Tetris
3  * The game board definition structures.
4  *
5  * Copyright 2000, Kiri Wagstaff & Westley Weimer
6  */
7 #ifndef __GRID_H
8 #define __GRID_H
9 #include "piece.h"
10 
11 /* the garbage height goes up every two levels, and the speed goes up
12  * every two levels, but the increases are staggered */
13 #define GARBAGE_LEVEL(level)	(Options.faster_levels ? level : ((level)/2) )
14 #define SPEED_LEVEL(level)	(Options.faster_levels ? level : ((level+1)/2) )
15 
16 typedef struct { /* the playing area */
17     int w;	/* width of the grid (e.g., 10) */
18     int h;	/* height of the grid (e.g., 20) */
19     unsigned char *contents;	/* what is at that square? */
20     unsigned char *fall;	/* what is falling? */
21     unsigned char *changed;	/* has this square changed since last draw? */
22     unsigned char *temp;	/* scratch space for temporary values */
23     SDL_Rect board;	/* ours, the opponents */
24 } Grid;
25 /* accessor macro */
26 #define GRID_CONTENT(g,x,y) ((g).contents[(x) + ((y)*((g).w))])
27 #define GRID_CHANGED(g,x,y) ((g).changed[(x) + ((y)*((g).w))])
28 #define GRID_SET(g,x,y,n)   (((g).changed [(x)+((y)*((g).w))]|=\
29 	    (g).contents[(x)+((y)*((g).w))] != (n)),\
30 	    (g).contents[(x)+((y)*((g).w))]=(n))
31 #define FALL_CONTENT(g,x,y) ((g).fall[(x) + ((y)*((g).w))])
32 #define FALL_SET(g,x,y,n)   (((g).changed[(x)+((y)*((g).w))] |=\
33 	    ((g).fall[(x)+((y)*((g).w))] != (n))),\
34 	    (g).fall[(x)+((y)*((g).w))]=(n))
35 #define TEMP_CONTENT(g,x,y) ((g).temp[(x) + ((y)*((g).w))])
36 
37 #define FALLING 	0
38 #define NOT_FALLING	1
39 #define UNKNOWN		254
40 
41 #define REMOVE_ME	255
42 
43 #include "grid.pro"
44 
45 #endif
46 
47 /*
48  * $Log: grid.h,v $
49  * Revision 1.7  2000/11/10 18:16:48  weimer
50  * changes for Atris 1.0.4 - three new special options
51  *
52  * Revision 1.6  2000/10/26 22:23:07  weimer
53  * double the effective number of levels
54  *
55  * Revision 1.5  2000/10/21 01:14:43  weimer
56  * massic autoconf/automake restructure ...
57  *
58  * Revision 1.4  2000/09/09 17:05:35  wkiri
59  * Hideous log changes (Wes: how dare you include a comment character!)
60  *
61  * Revision 1.3  2000/09/09 16:58:27  weimer
62  * Sweeping Change of Ultimate Mastery. Main loop restructuring to clean up
63  * main(), isolate the behavior of the three game types. Move graphic files
64  * into graphics/-, style files into styles/-, remove some unused files,
65  * add game flow support (breaks between games, remembering your level within
66  * this game), multiplayer support for the event loop, some global variable
67  * cleanup. All that and a bag of chips!
68  *
69  * Revision 1.2  2000/09/03 18:26:10  weimer
70  * major header file and automatic prototype generation changes, restructuring
71  *
72  * Revision 1.1  2000/09/03 17:56:36  wkiri
73  * Reorganization of files (display.[ch], event.c are new).
74  *
75  * Revision 1.7  2000/08/26 02:28:55  weimer
76  * now you can see the other player!
77  *
78  * Revision 1.6  2000/08/26 01:36:25  weimer
79  * fixed a long-running update bug: the grid changed field was being reset to
80  * 0 when falling states or content were set to the same thing, even if they
81  * had actually previously changed ...
82  *
83  * Revision 1.5  2000/08/24 02:32:18  weimer
84  * gameplay changes (key repeats) and speed modifications (falling pieces,
85  * redraws, etc.)
86  *
87  * Revision 1.4  2000/08/22 15:13:53  weimer
88  * added a garbage-generation routine
89  *
90  * Revision 1.3  2000/08/15 00:59:41  weimer
91  * a few more sound things
92  *
93  * Revision 1.2  2000/08/13 19:27:20  weimer
94  * added file changelogs
95  *
96  */
97