MCPcopy Create free account
hub / github.com/NetHack/NetHack / packwritebody

Function packwritebody

outdated/sys/amiga/txt2iff.c:294–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294void
295packwritebody(pixel (*tile)[TILE_X], char **planes, int tileno)
296{
297 register int i, j, k, col;
298 register char *buf;
299 register int across, rowbytes, xoff, yoff;
300
301 /* how many tiles fit across? */
302 across = COLS;
303
304 /* How many bytes per pixel row */
305 rowbytes = ((IFFScreen.Width + 15) / 16) * 2;
306
307 /* How many bytes to account for y distance in planes */
308 yoff = ((tileno / across) * TILE_Y) * rowbytes;
309
310 /* How many bytes to account for x distance in planes */
311 xoff = (tileno % across) * (TILE_X / 8);
312
313 /* For each row... */
314 for (i = 0; i < TILE_Y; ++i) {
315 /* For each bitplane... */
316 for (k = 0; k < nplanes; ++k) {
317 const int mask = 1l << k;
318
319 /* Go across the row */
320 for (j = 0; j < TILE_X; j++) {
321 col = findcolor(&tile[i][j]);
322 if (col == -1) {
323 error("can not convert pixel color to colormap index");
324 return;
325 }
326 /* Shift the colors around to have good complements and to
327 * know the dripen values.
328 */
329 col = colrmap[col];
330
331 /* To top left corner of tile */
332 buf = planes[k] + yoff + xoff;
333
334 /*To i'th row of tile and the correct byte for the j'th
335 * pixel*/
336 buf += (i * rowbytes) + (j / 8);
337
338 /* Or in the bit for this color */
339 *buf |= (((col & mask) != 0) << (7 - (j % 8)));
340 }
341 }
342 }
343}
344
345/* #define DBG */
346

Callers 1

txt2iff.cFile · 0.85

Calls 1

errorFunction · 0.70

Tested by

no test coverage detected