1 /* Tower Toppler - Nebulus
2  * Copyright (C) 2000-2012  Andreas R�ver
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18 
19 #ifndef DECL_H
20 #define DECL_H
21 
22 #include <config.h>
23 
24 #include <stdio.h>
25 #include <stdarg.h>
26 #include <dirent.h>
27 
28 #if ENABLE_NLS == 1
29 #include <libintl.h>
30 #endif
31 
32 /* screen width and height, in pixels. */
33 #define SCREENWID 640
34 #define SCREENHEI 480
35 
36 /* font width and height, in pixels. */
37 #define FONTWID 24
38 #define FONTMINWID 10
39 #define FONTMAXWID 40
40 #define FONTHEI 40
41 
42 /* the tower dimensions */
43 #define TOWER_SLICE_HEIGHT 16
44 #define TOWER_RADIUS 96
45 #define TOWER_COLUMNS 16  // must be a power of 2
46 #define TOWER_STEPS_PER_COLUMN 8
47 #define TOWER_ANGLES (TOWER_COLUMNS*TOWER_STEPS_PER_COLUMN)
48 
49 /* title sprite "NEBULOUS" width and height, in pixels */
50 #define SPR_TITLEWID 602
51 #define SPR_TITLEHEI 90
52 
53 /* star sprite size */
54 #define SPR_STARWID 32
55 #define SPR_STARHEI 32
56 
57 /* size of one layer sprite of tower */
58 #define SPR_SLICEWID 192
59 #define SPR_SLICEHEI 16
60 #define SPR_SLICEANGLES 8
61 #define SPR_SLICEFRAMES 1
62 #define SPR_SLICESPRITES (SPR_SLICEANGLES * SPR_SLICEFRAMES)
63 
64 /* size of the battlement sprite on top of the tower */
65 #define SPR_BATTLWID 144 * 2
66 #define SPR_BATTLHEI 24 * 2
67 #define SPR_BATTLFRAMES 8
68 
69 /* size of platform sprite */
70 #define SPR_STEPWID 40
71 #define SPR_STEPHEI 15
72 #define SPR_STEPFRAMES 1
73 
74 /* size of elevator sprite */
75 #define SPR_ELEVAWID 32
76 #define SPR_ELEVAHEI 15
77 #define SPR_ELEVAFRAMES 1
78 
79 /* size of elevator stick / wall */
80 #define SPR_STICKWID 14
81 #define SPR_STICKHEI 15
82 
83 /* size of shootable flashing box */
84 #define SPR_BOXWID 16
85 #define SPR_BOXHEI 16
86 
87 /* size of our hero */
88 #define SPR_HEROWID 40
89 #define SPR_HEROHEI 40
90 
91 /* size of hero's ammunition, the snowball */
92 #define SPR_AMMOWID 16
93 #define SPR_AMMOHEI 16
94 
95 /* size of robot sprite */
96 #define SPR_ROBOTWID 32
97 #define SPR_ROBOTHEI 32
98 
99 /* cross sprite size */
100 #define SPR_CROSSWID 32
101 #define SPR_CROSSHEI 32
102 
103 /* size of the bonus game fish */
104 #define SPR_FISHWID  40
105 #define SPR_FISHHEI  40
106 
107 /* submarine sprite size */
108 #define SPR_SUBMWID 120
109 #define SPR_SUBMHEI 80
110 
111 /* submarine ammunition, torpedo */
112 #define SPR_TORPWID 32
113 #define SPR_TORPHEI 6
114 
115 /* torpedo launch offset relative to submarine */
116 #define TORPEDO_OFS_X 80
117 #define TORPEDO_OFS_Y 30
118 
119 /* submarine moving limits in bonus game */
120 #define SUBM_MIN_X 0
121 #define SUBM_MIN_Y 60
122 #define SUBM_MAX_X (SCREENWID/2)
123 #define SUBM_MAX_Y 280
124 
125 /* submarine target coord during automatic guidance.
126    the sub also starts from this coord. */
127 #define SUBM_TARGET_X (SCREENWID/2)-(SPR_SUBMWID/2)
128 #define SUBM_TARGET_Y 60
129 
130 /* # of stars on the background during game */
131 #define NUM_STARS 100
132 
133 /* define this if you want debugging keys during game.
134    (press up+down+left+right at the same time.)
135    debuggers don't get their name on hiscore table.  */
136 #ifdef TESTER
137 #define GAME_DEBUG_KEYS
138 #endif
139 
140 /*   define this if you want the bonus game to be accessible
141  from the main menu. */
142 #ifdef TESTER
143 #define HUNT_THE_FISH
144 #endif
145 
146 /* names of the different data files */
147 #define grafdat         "graphics.dat"
148 #define fontdat         "font.dat"
149 #define spritedat       "sprites.dat"
150 #define topplerdat      "dude.dat"
151 #define menudat         "menu.dat"
152 #define crossdat        "cross.dat"
153 #define titledat        "titles.dat"
154 #define scrollerdat     "scroller.dat"
155 
156 /* the special characters in the font */
157 #define fonttoppler     '\x01' // static view of our hero for status lines
158 #define fontpoint       '\x02'
159 #define fontemptytagbox '\x03' // checkbox
160 #define fonttagedtagbox '\x04' // checkbox with tickmark
161 #define fontptrup       '\x05' // arrow up
162 #define fontptrright    '\x06' // arrow right
163 #define fontptrdown     '\x07' // arrow down
164 #define fontptrleft     '\x08' // arrow left
165 
166 #define FDECL(f,p) f p
167 #define SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
168 
169 #define PASSWORD_CHARS "abcdefghijklmnopqrstuvwxyz0123456789"
170 
171 void dcl_setdebuglevel(int level);
172 void debugprintf(int lvl, const char *fmt, ...);
173 
174 /* waits around 1/18 of a second */
175 void dcl_wait(void);
176 
177 /* returns true, if the last wait didn't have enough time */
178 bool dcl_wait_overflow(void);
179 
180 /* true, if files exitst */
181 bool dcl_fileexists(const char *n);
182 
183 /* opens files looking into the right directories */
184 FILE *open_data_file(const char *name);
185 FILE *open_local_config_file(const char *name);
186 FILE *create_local_config_file(const char *name);
187 FILE *open_local_data_file(const char *name);
188 FILE *create_local_data_file(const char *name);
189 char * homedir();
190 
191 /* returns the filename that would be opened with open_data_file in
192  * f, f is max len characters
193  * returns true, if the file pointer of open_data_file would be not NULL
194  */
195 bool get_data_file_path(const char * fname, char * f, int len);
196 
197 /* Is the TT window active? */
198 extern bool tt_has_focus;
199 
200 #define MENU_DCLSPEED 4
201 #define DEFAULT_GAME_SPEED 0
202 #define MAX_GAME_SPEED 3  /* from 0 to this; bigger == faster */
203 /* set dcl_wait() delay, and return the previous delay */
204 int dcl_update_speed(int spd);
205 
206 /* for errorchecking */
207 #define assert_msg(cond,text) if (!(cond)) { printf(_("Assertion failure: %s\n"), text); exit(1); }
208 
209 /* a function that returns a alphabetically sorted list of
210  files in the given dir filtered dith the function given at
211  3rd parameter
212  */
213 int alpha_scandir(const char *dir, struct dirent ***namelist,
214                   int (*select)(const struct dirent *));
215 
216 /* for internationalisation */
217 #if ENABLE_NLS == 1
218 #define _(x) gettext(x)
219 #define N_(x) x
220 #else
221 #define _(x) x
222 #define N_(x) x
223 #endif
224 
225 #ifdef WIN32
226 typedef int mbstate_t;
227 size_t mbrtowc (wchar_t * out, const char *s, int n, mbstate_t * st);
228 #endif
229 
230 #endif
231