]>
git.zerfleddert.de Git - micropolis/blob - src/sim/g_smmaps.c
d2646a69251141c6616be506aed57d413a641a7f
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.
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.
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/>.
21 * ADDITIONAL TERMS per GNU GPL Section 7
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.
29 * Any propagation or conveyance of this program must include this
30 * copyright notice and these terms.
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.
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.
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
70 unsigned short tile; \
72 unsigned char *imageBase; \
73 unsigned char *image; \
76 int lineBytes = view->line_bytes8; \
77 int pixelBytes = view->pixel_bytes; \
79 imageBase = view->x->color ? view->data : view->data8; \
80 for (col = 0; col < WORLD_X; col++) { \
81 image = imageBase + (3 * pixelBytes * col); \
82 for (row = 0; row < WORLD_Y; row++) { \
83 tile = *(mp++) & LOMASK; \
84 if (tile >= TILE_COUNT) tile -= TILE_COUNT;
87 #if defined(MSDOS) || defined(OSF1) || defined(IS_INTEL)
97 memcpy((char *)image, ((char *)mem) + (n * 4 * 2), (3 * 2)); \
101 memcpy((char *)image, ((char *)mem) + (n * 4 * 3), (3 * 3)); \
105 memcpy((char *)image, ((char *)mem) + (n * 4 * 4), (3 * 4)); \
118 l = mem[n]; /* XXX: WRONG. handle depth */ \
125 l = mem[n]; /* XXX: WRONG. handle depth */ \
132 l = mem[n]; /* XXX: WRONG. handle depth */ \
140 #define ROW3_8 ROW1_8(0) ROW1_8(1) ROW1_8(2)
141 #define ROW3_16 ROW1_16(0) ROW1_16(1) ROW1_16(2)
142 #define ROW3_24 ROW1_24(0) ROW1_24(1) ROW1_24(2)
143 #define ROW3_32 ROW1_32(0) ROW1_32(1) ROW1_32(2)
146 switch (view->x->depth) { \
160 assert(0); /* Undefined depth */ \
165 mem = (unsigned QUAD *)&view->smalltiles[tile * 4 * 4 * pixelBytes]; \
171 void drawAll(SimView
*view
)
178 void drawRes(SimView
*view
)
187 void drawCom(SimView
*view
)
191 ((tile
>= 232) && (tile
< 423)))
197 void drawInd(SimView
*view
)
200 if (((tile
>= 240) && (tile
<= 611)) ||
201 ((tile
>= 693) && (tile
<= 851)) ||
202 ((tile
>= 860) && (tile
<= 883)) ||
209 void drawLilTransMap(SimView
*view
)
213 ((tile
>= 207) && tile
<= 220) ||
220 /* color pixel values */
221 #define UNPOWERED COLOR_LIGHTBLUE
222 #define POWERED COLOR_RED
223 #define CONDUCTIVE COLOR_LIGHTGRAY
226 void drawPower(SimView
*view
)
231 unsigned char *image
, *imageBase
;
234 int lineBytes
= view
->line_bytes8
;
235 int pixelBytes
= view
->pixel_bytes
;
238 int powered
, unpowered
, conductive
;
240 if (view
->x
->color
) {
241 powered
= view
->pixels
[POWERED
];
242 unpowered
= view
->pixels
[UNPOWERED
];
243 conductive
= view
->pixels
[CONDUCTIVE
];
251 imageBase
= view
->x
->color
? view
->data
: view
->data8
;
253 for (col
= 0; col
< WORLD_X
; col
++) {
254 image
= imageBase
+ (3 * pixelBytes
* col
);
255 for (row
= 0; row
< WORLD_Y
; row
++) {
258 if ((tile
& LOMASK
) >= TILE_COUNT
) tile
-= TILE_COUNT
;
260 if ((unsigned short)(tile
& LOMASK
) <= (unsigned short)63) {
263 } else if (tile
& ZONEBIT
) {
264 pix
= (tile
& PWRBIT
) ? powered
: unpowered
;
266 if (tile
& CONDBIT
) {
275 mem
= (unsigned QUAD
*)&view
->smalltiles
[tile
* 4 * 4 * pixelBytes
];
278 switch (view
->x
->depth
) {
282 image
[0] = image
[1] = image
[2] = pix
;
284 image
[0] = image
[1] = image
[2] = pix
;
286 image
[0] = image
[1] = image
[2] = pix
;
295 p
[0] = p
[1] = p
[2] = pix
;
298 p
[0] = p
[1] = p
[2] = pix
;
301 p
[0] = p
[1] = p
[2] = pix
;
310 for (y
= 0; y
< 3; y
++) {
313 for (x
= 0; x
< 4; x
++) {
314 *(img
++) = (pix
>> 0) & 0xff;
315 *(img
++) = (pix
>> 8) & 0xff;
316 *(img
++) = (pix
>> 16) & 0xff;
317 if (pixelBytes
== 4) {
327 assert(0); /* Undefined depth */
337 int dynamicFilter(int col
, int row
)
344 if (((DynamicData
[0] > DynamicData
[1]) ||
345 ((x
= PopDensity
[c
][r
]) >= DynamicData
[0]) &&
346 (x
<= DynamicData
[1])) &&
347 ((DynamicData
[2] > DynamicData
[3]) ||
348 ((x
= RateOGMem
[c
>>2][r
>>2]) >= ((2 * DynamicData
[2]) - 256)) &&
349 (x
<= ((2 * DynamicData
[3]) - 256))) &&
350 ((DynamicData
[4] > DynamicData
[5]) ||
351 ((x
= TrfDensity
[c
][r
]) >= DynamicData
[4]) &&
352 (x
<= DynamicData
[5])) &&
353 ((DynamicData
[6] > DynamicData
[7]) ||
354 ((x
= PollutionMem
[c
][r
]) >= DynamicData
[6]) &&
355 (x
<= DynamicData
[7])) &&
356 ((DynamicData
[8] > DynamicData
[9]) ||
357 ((x
= CrimeMem
[c
][r
]) >= DynamicData
[8]) &&
358 (x
<= DynamicData
[9])) &&
359 ((DynamicData
[10] > DynamicData
[11]) ||
360 ((x
= LandValueMem
[c
][r
]) >= DynamicData
[10]) &&
361 (x
<= DynamicData
[11])) &&
362 ((DynamicData
[12] > DynamicData
[13]) ||
363 ((x
= PoliceMapEffect
[c
>>2][r
>>2]) >= DynamicData
[12]) &&
364 (x
<= DynamicData
[13])) &&
365 ((DynamicData
[14] > DynamicData
[15]) ||
366 ((x
= FireRate
[c
>>2][r
>>2]) >= DynamicData
[14]) &&
367 (x
<= DynamicData
[15]))) {
375 void drawDynamic(SimView
*view
)
379 if (!dynamicFilter(col
, row
)) {