MCPcopy Create free account
hub / github.com/SimHacker/micropolis / drawPowerGrid

Method drawPowerGrid

MicropolisCore/src/MicropolisEngine/src/map.cpp:301–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299
300
301void Micropolis::drawPowerGrid()
302{
303 short col, row;
304 unsigned short tile;
305 short *mp;
306 unsigned char *image, *imageBase;
307 UQuad *mem;
308 UQuad m;
309 int lineBytes = view->line_bytes8;
310 int pixelBytes = view->pixel_bytes;
311
312 int pix;
313 int powered, unpowered, conductive;
314
315 if (view->x->color) {
316 powered = view->pixels[POWERED];
317 unpowered = view->pixels[UNPOWERED];
318 conductive = view->pixels[CONDUCTIVE];
319 } else {
320 powered = 255;
321 unpowered = 0;
322 conductive = 127;
323 }
324
325 mp =
326 &map[0][0];
327 imageBase =
328 view->x->color ? view->data : view->data8;
329
330 for (col = 0; col < WORLD_W; col++) {
331
332 image =
333 imageBase + (3 * pixelBytes * col);
334
335 for (row = 0; row < WORLD_H; row++) {
336 tile = *(mp++);
337
338 if ((tile & LOMASK) >= TILE_COUNT) {
339 tile -= TILE_COUNT;
340 }
341
342 if ((tile & LOMASK) <= LASTFIRE) {
343 tile &= LOMASK;
344 pix = -1;
345 } else if (tile & ZONEBIT) {
346 pix = (tile & PWRBIT) ? powered : unpowered;
347 } else {
348 if (tile & CONDBIT) {
349 pix = conductive;
350 } else {
351 tile = DIRT;
352 pix = -1;
353 }
354 }
355
356 if (pix < 0) {
357 mem = (UQuad *)&view->smalltiles[tile * 4 * 4 * pixelBytes];
358 ROW3

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected