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

Function iff_write

sys/amiga/bmp2iff_host.c:114–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114static void
115iff_write(int nplanes, int ncolors, uint8_t *cmap,
116 int w, int h, uint8_t **planes,
117 int ntiles, int across, int down)
118{
119 long spos;
120 uint32_t plsz = (uint32_t)(w / 8) * h;
121 int i;
122
123 fwrite("FORM", 1, 4, iff_fp);
124 spos = ftell(iff_fp);
125 wr32(0);
126 fwrite("BMAP", 1, 4, iff_fp);
127
128 /* BMHD */
129 {
130 uint8_t bm[20];
131 memset(bm, 0, 20);
132 bm[0] = w >> 8; bm[1] = w;
133 bm[2] = h >> 8; bm[3] = h;
134 bm[8] = (uint8_t)nplanes;
135 bm[14] = 100; bm[15] = 100;
136 wr_chunk("BMHD", bm, 20);
137 }
138
139 /* CAMG */
140 {
141 uint8_t c[4] = {0,0,0x80,0x04};
142 wr_chunk("CAMG", c, 4);
143 }
144
145 /* CMAP */
146 wr_chunk("CMAP", cmap, (uint32_t)ncolors * 3);
147
148 /* PDAT */
149 {
150 uint8_t pd[28], *p = pd;
151 uint32_t v[7];
152 v[0] = nplanes;
153 v[1] = plsz;
154 v[2] = across;
155 v[3] = down;
156 v[4] = ntiles;
157 v[5] = TILE_X;
158 v[6] = TILE_Y;
159 for (i = 0; i < 7; i++) {
160 p[0] = (v[i]>>24); p[1] = (v[i]>>16);
161 p[2] = (v[i]>> 8); p[3] = v[i];
162 p += 4;
163 }
164 wr_chunk("PDAT", pd, 28);
165 }
166
167 /* PLNE */
168 fwrite("PLNE", 1, 4, iff_fp);
169 wr32(plsz * nplanes);
170 for (i = 0; i < nplanes; i++)
171 fwrite(planes[i], 1, plsz, iff_fp);

Callers 1

mainFunction · 0.85

Calls 5

fwriteFunction · 0.85
ftellFunction · 0.85
wr_chunkFunction · 0.85
fseekFunction · 0.85
wr32Function · 0.70

Tested by

no test coverage detected