]>
cvs.zerfleddert.de Git - micropolis/blob - src/sim/g_smmaps.c
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) { \
162 assert(0); /* Undefined depth */ \
167 mem = (unsigned QUAD *)&view->smalltiles[tile * 4 * 4 * pixelBytes]; \
173 void drawAll(SimView
*view
)
180 void drawRes(SimView
*view
)
189 void drawCom(SimView
*view
)
193 ((tile
>= 232) && (tile
< 423)))
199 void drawInd(SimView
*view
)
202 if (((tile
>= 240) && (tile
<= 611)) ||
203 ((tile
>= 693) && (tile
<= 851)) ||
204 ((tile
>= 860) && (tile
<= 883)) ||
211 void drawLilTransMap(SimView
*view
)
215 ((tile
>= 207) && tile
<= 220) ||
222 /* color pixel values */
223 #define UNPOWERED COLOR_LIGHTBLUE
224 #define POWERED COLOR_RED
225 #define CONDUCTIVE COLOR_LIGHTGRAY
228 void drawPower(SimView
*view
)
233 unsigned char *image
, *imageBase
;
236 int lineBytes
= view
->line_bytes8
;
237 int pixelBytes
= view
->pixel_bytes
;
240 int powered
, unpowered
, conductive
;
242 if (view
->x
->color
) {
243 powered
= view
->pixels
[POWERED
];
244 unpowered
= view
->pixels
[UNPOWERED
];
245 conductive
= view
->pixels
[CONDUCTIVE
];
253 imageBase
= view
->x
->color
? view
->data
: view
->data8
;
255 for (col
= 0; col
< WORLD_X
; col
++) {
256 image
= imageBase
+ (3 * pixelBytes
* col
);
257 for (row
= 0; row
< WORLD_Y
; row
++) {
260 if ((tile
& LOMASK
) >= TILE_COUNT
) tile
-= TILE_COUNT
;
262 if ((unsigned short)(tile
& LOMASK
) <= (unsigned short)63) {
265 } else if (tile
& ZONEBIT
) {
266 pix
= (tile
& PWRBIT
) ? powered
: unpowered
;
268 if (tile
& CONDBIT
) {
277 mem
= (unsigned QUAD
*)&view
->smalltiles
[tile
* 4 * 4 * pixelBytes
];
280 switch (view
->x
->depth
) {
284 image
[0] = image
[1] = image
[2] = pix
;
286 image
[0] = image
[1] = image
[2] = pix
;
288 image
[0] = image
[1] = image
[2] = pix
;
297 p
[0] = p
[1] = p
[2] = pix
;
300 p
[0] = p
[1] = p
[2] = pix
;
303 p
[0] = p
[1] = p
[2] = pix
;
312 for (y
= 0; y
< 3; y
++) {
315 for (x
= 0; x
< 4; x
++) {
316 *(img
++) = (pix
>> 0) & 0xff;
317 *(img
++) = (pix
>> 8) & 0xff;
318 *(img
++) = (pix
>> 16) & 0xff;
319 if (pixelBytes
== 4) {
329 assert(0); /* Undefined depth */
339 int dynamicFilter(int col
, int row
)
346 if (((DynamicData
[0] > DynamicData
[1]) ||
347 ((x
= PopDensity
[c
][r
]) >= DynamicData
[0]) &&
348 (x
<= DynamicData
[1])) &&
349 ((DynamicData
[2] > DynamicData
[3]) ||
350 ((x
= RateOGMem
[c
>>2][r
>>2]) >= ((2 * DynamicData
[2]) - 256)) &&
351 (x
<= ((2 * DynamicData
[3]) - 256))) &&
352 ((DynamicData
[4] > DynamicData
[5]) ||
353 ((x
= TrfDensity
[c
][r
]) >= DynamicData
[4]) &&
354 (x
<= DynamicData
[5])) &&
355 ((DynamicData
[6] > DynamicData
[7]) ||
356 ((x
= PollutionMem
[c
][r
]) >= DynamicData
[6]) &&
357 (x
<= DynamicData
[7])) &&
358 ((DynamicData
[8] > DynamicData
[9]) ||
359 ((x
= CrimeMem
[c
][r
]) >= DynamicData
[8]) &&
360 (x
<= DynamicData
[9])) &&
361 ((DynamicData
[10] > DynamicData
[11]) ||
362 ((x
= LandValueMem
[c
][r
]) >= DynamicData
[10]) &&
363 (x
<= DynamicData
[11])) &&
364 ((DynamicData
[12] > DynamicData
[13]) ||
365 ((x
= PoliceMapEffect
[c
>>2][r
>>2]) >= DynamicData
[12]) &&
366 (x
<= DynamicData
[13])) &&
367 ((DynamicData
[14] > DynamicData
[15]) ||
368 ((x
= FireRate
[c
>>2][r
>>2]) >= DynamicData
[14]) &&
369 (x
<= DynamicData
[15]))) {
377 void drawDynamic(SimView
*view
)
381 if (!dynamicFilter(col
, row
)) {