]>
Commit | Line | Data |
---|---|---|
6a5fa4e0 MG |
1 | /* view.h |
2 | * | |
3 | * Micropolis, Unix Version. This game was released for the Unix platform | |
4 | * in or about 1990 and has been modified for inclusion in the One Laptop | |
5 | * Per Child program. Copyright (C) 1989 - 2007 Electronic Arts Inc. If | |
6 | * you need assistance with this program, you may contact: | |
7 | * http://wiki.laptop.org/go/Micropolis or email micropolis@laptop.org. | |
8 | * | |
9 | * This program is free software: you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation, either version 3 of the License, or (at | |
12 | * your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. You should have received a | |
18 | * copy of the GNU General Public License along with this program. If | |
19 | * not, see <http://www.gnu.org/licenses/>. | |
20 | * | |
21 | * ADDITIONAL TERMS per GNU GPL Section 7 | |
22 | * | |
23 | * No trademark or publicity rights are granted. This license does NOT | |
24 | * give you any right, title or interest in the trademark SimCity or any | |
25 | * other Electronic Arts trademark. You may not distribute any | |
26 | * modification of this program using the trademark SimCity or claim any | |
27 | * affliation or association with Electronic Arts Inc. or its employees. | |
28 | * | |
29 | * Any propagation or conveyance of this program must include this | |
30 | * copyright notice and these terms. | |
31 | * | |
32 | * If you convey this program (or any modifications of it) and assume | |
33 | * contractual liability for the program to recipients of it, you agree | |
34 | * to indemnify Electronic Arts for any liability that those contractual | |
35 | * assumptions impose on Electronic Arts. | |
36 | * | |
37 | * You may not misrepresent the origins of this program; modified | |
38 | * versions of the program must be marked as such and not identified as | |
39 | * the original program. | |
40 | * | |
41 | * This disclaimer supplements the one included in the General Public | |
42 | * License. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THIS | |
43 | * PROGRAM IS PROVIDED TO YOU "AS IS," WITH ALL FAULTS, WITHOUT WARRANTY | |
44 | * OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK OF | |
45 | * SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. ELECTRONIC ARTS | |
46 | * DISCLAIMS ANY AND ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES, | |
47 | * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, | |
48 | * FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY | |
49 | * RIGHTS, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING, | |
50 | * USAGE, OR TRADE PRACTICE. ELECTRONIC ARTS DOES NOT WARRANT AGAINST | |
51 | * INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL | |
52 | * MEET YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE | |
53 | * UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM WILL BE COMPATIBLE | |
54 | * WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE | |
55 | * CORRECTED. NO ORAL OR WRITTEN ADVICE PROVIDED BY ELECTRONIC ARTS OR | |
56 | * ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME | |
57 | * JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED | |
58 | * WARRANTIES OR THE LIMITATIONS ON THE APPLICABLE STATUTORY RIGHTS OF A | |
59 | * CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY | |
60 | * NOT APPLY TO YOU. | |
61 | */ | |
62 | ||
63 | #define X_Mem_View 1 | |
64 | #define X_Wire_View 2 | |
65 | ||
66 | #define Editor_Class 0 | |
67 | #define Map_Class 1 | |
68 | ||
69 | #define Button_Press 0 | |
70 | #define Button_Move 1 | |
71 | #define Button_Release 2 | |
72 | ||
73 | #define VIEW_REDRAW_PENDING 1 | |
74 | ||
75 | ||
76 | typedef struct Ink { | |
77 | struct Ink *next; | |
78 | int x, y; | |
79 | int color; | |
80 | int length; | |
81 | int maxlength; | |
82 | XPoint *points; | |
83 | int left, top, right, bottom; | |
84 | int last_x, last_y; | |
85 | } Ink; | |
86 | ||
87 | ||
88 | typedef struct XDisplay { | |
89 | struct XDisplay *next; | |
90 | int references; | |
91 | char *display; | |
92 | TkDisplay *tkDisplay; | |
93 | Display *dpy; | |
94 | Screen *screen; | |
95 | Window root; | |
96 | Visual *visual; | |
97 | int depth; | |
98 | int color; | |
99 | Colormap colormap; | |
100 | int *pixels; | |
101 | GC gc; | |
102 | int shared; | |
103 | unsigned long last_request_read; | |
104 | unsigned long request; | |
105 | XImage *big_tile_image; | |
106 | XImage *small_tile_image; | |
107 | Pixmap big_tile_pixmap; | |
108 | Pixmap **objects; | |
109 | GC overlay_gc; | |
110 | Pixmap gray25_stipple; | |
111 | Pixmap gray50_stipple; | |
112 | Pixmap gray75_stipple; | |
113 | Pixmap vert_stipple; | |
114 | Pixmap horiz_stipple; | |
115 | Pixmap diag_stipple; | |
efad9d6d | 116 | int needs_swap; |
276e43ba | 117 | int x_big_endian; |
6a5fa4e0 MG |
118 | } XDisplay; |
119 | ||
120 | ||
121 | typedef struct SimView { | |
122 | struct SimView *next; | |
123 | char *title; | |
124 | int type; | |
125 | int class; | |
126 | ||
127 | /* graphics stuff */ | |
128 | int *pixels; | |
129 | int line_bytes; | |
130 | int pixel_bytes; | |
131 | int depth; | |
132 | unsigned char *data; | |
133 | int line_bytes8; | |
134 | unsigned char *data8; | |
135 | int visible; | |
136 | int invalid; | |
137 | int skips; | |
138 | int skip; | |
139 | int update; | |
140 | ||
141 | /* map stuff */ | |
142 | unsigned char *smalltiles; | |
143 | short map_state; | |
144 | int show_editors; | |
145 | ||
146 | /* editor stuff */ | |
147 | unsigned char *bigtiles; | |
148 | short power_type; | |
149 | short tool_showing; | |
150 | short tool_mode; | |
151 | short tool_x, tool_y; | |
152 | short tool_x_const, tool_y_const; | |
153 | short tool_state; | |
154 | short tool_state_save; | |
155 | short super_user; | |
156 | short show_me; | |
157 | short dynamic_filter; | |
158 | Tk_TimerToken auto_scroll_token; | |
159 | Time tool_event_time; | |
160 | Time tool_last_event_time; | |
161 | ||
162 | /* scrolling */ | |
163 | int w_x, w_y; /* view window position */ | |
164 | int w_width, w_height; /* view window size */ | |
165 | int m_width, m_height; /* memory buffer size */ | |
166 | int i_width, i_height; /* ideal whole size */ | |
167 | int pan_x, pan_y; /* centered in window */ | |
168 | int tile_x, tile_y, tile_width, tile_height; /* visible tiles */ | |
169 | int screen_x, screen_y, screen_width, screen_height; /* visible pixels */ | |
170 | ||
171 | /* tracking */ | |
172 | int orig_pan_x, orig_pan_y; | |
173 | int last_x, last_y; | |
174 | int last_button; | |
175 | char *track_info; | |
176 | char *message_var; | |
177 | ||
178 | /* window system */ | |
179 | Tk_Window tkwin; | |
180 | Tcl_Interp *interp; | |
181 | int flags; | |
182 | ||
183 | XDisplay *x; | |
184 | XShmSegmentInfo *shminfo; | |
185 | short **tiles; | |
186 | short **other_tiles; | |
187 | XImage *image; | |
188 | XImage *other_image; | |
189 | unsigned char *other_data; | |
190 | Pixmap pixmap; | |
191 | Pixmap pixmap2; | |
192 | Pixmap overlay_pixmap; | |
193 | Pixmap overlay_valid; | |
194 | XFontStruct *fontPtr; | |
195 | ||
196 | /* timing */ | |
197 | int updates; | |
198 | double update_real; | |
199 | double update_user; | |
200 | double update_system; | |
201 | int update_context; | |
202 | ||
203 | /* auto goto */ | |
204 | int auto_goto; | |
205 | int auto_going; | |
206 | int auto_x_goal, auto_y_goal; | |
207 | int auto_speed; | |
208 | struct SimSprite *follow; | |
209 | ||
210 | /* sound */ | |
211 | int sound; | |
212 | ||
213 | /* configuration */ | |
214 | int width, height; | |
215 | ||
216 | /* overlay */ | |
217 | int show_overlay; | |
218 | int overlay_mode; | |
219 | struct timeval overlay_time; | |
220 | } SimView; | |
221 | ||
222 | ||
223 | typedef struct SimGraph { | |
224 | struct SimGraph *next; | |
225 | int range; | |
226 | int mask; | |
227 | Tk_Window tkwin; | |
228 | Tcl_Interp *interp; | |
229 | int flags; | |
230 | XDisplay *x; | |
231 | int visible; | |
232 | int w_x, w_y; | |
233 | int w_width, w_height; | |
234 | Pixmap pixmap; | |
235 | int *pixels; | |
236 | XFontStruct *fontPtr; | |
237 | Tk_3DBorder border; | |
238 | int borderWidth; | |
239 | int relief; | |
240 | Tk_TimerToken draw_graph_token; | |
241 | } SimGraph; | |
242 | ||
243 | ||
244 | typedef struct SimDate { | |
245 | struct SimDate *next; | |
246 | int reset; | |
247 | int month; | |
248 | int year; | |
249 | int lastmonth; | |
250 | int lastyear; | |
251 | Tk_Window tkwin; | |
252 | Tcl_Interp *interp; | |
253 | int flags; | |
254 | XDisplay *x; | |
255 | int visible; | |
256 | int w_x, w_y; | |
257 | int w_width, w_height; | |
258 | Pixmap pixmap; | |
259 | int *pixels; | |
260 | XFontStruct *fontPtr; | |
261 | Tk_3DBorder border; | |
262 | int borderWidth; | |
263 | int padX; | |
264 | int padY; | |
265 | int width; | |
266 | int monthTab; | |
267 | int monthTabX; | |
268 | int yearTab; | |
269 | int yearTabX; | |
270 | Tk_TimerToken draw_date_token; | |
271 | } SimDate; | |
272 | ||
273 | ||
274 | typedef struct SimSprite { | |
275 | struct SimSprite *next; | |
276 | char *name; | |
277 | int type; | |
278 | int frame; | |
279 | int x, y; | |
280 | int width, height; | |
281 | int x_offset, y_offset; | |
282 | int x_hot, y_hot; | |
283 | int orig_x, orig_y; | |
284 | int dest_x, dest_y; | |
285 | int count, sound_count; | |
286 | int dir, new_dir; | |
287 | int step, flag, control; | |
288 | int turn; | |
289 | int accel; | |
290 | int speed; | |
291 | } SimSprite; | |
292 | ||
293 | ||
294 | #ifdef CAM | |
295 | #include "cam.h" | |
296 | #endif | |
297 | ||
298 | ||
299 | typedef struct Person { | |
300 | int id; | |
301 | char *name; | |
302 | } Person; | |
303 | ||
304 | ||
305 | typedef struct Sim { | |
306 | int editors; | |
307 | SimView *editor; | |
308 | int maps; | |
309 | SimView *map; | |
310 | int graphs; | |
311 | SimGraph *graph; | |
312 | int dates; | |
313 | SimDate *date; | |
314 | int sprites; | |
315 | SimSprite *sprite; | |
316 | #ifdef CAM | |
317 | int scams; | |
318 | SimCam *scam; | |
319 | #endif | |
320 | Ink *overlay; | |
321 | } Sim; | |
322 | ||
323 | ||
324 | typedef struct Cmd { | |
325 | char *name; | |
326 | int (*cmd)(); | |
327 | } Cmd; | |
328 |