Mercurial > hg > dmlib
comparison tools/lib64gfx.c @ 1919:f0225a52afce
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 27 Jun 2018 19:09:25 +0300 |
parents | ba88ff5e85ea |
children | 3c6f638ce402 |
comparison
equal
deleted
inserted
replaced
1918:ba88ff5e85ea | 1919:f0225a52afce |
---|---|
1244 int rwidth = src->width; | 1244 int rwidth = src->width; |
1245 if ((src->type & D64_FMT_ILACE) && src->laceType == D64_ILACE_RES) | 1245 if ((src->type & D64_FMT_ILACE) && src->laceType == D64_ILACE_RES) |
1246 rwidth /= 2; | 1246 rwidth /= 2; |
1247 | 1247 |
1248 // Perform conversion | 1248 // Perform conversion |
1249 Uint8 *dp = dst->data; | |
1250 for (int yc = 0; yc < src->height; yc++) | 1249 for (int yc = 0; yc < src->height; yc++) |
1251 { | 1250 { |
1252 Uint8 *d = dp; | 1251 Uint8 *dp = dst->data + (yc * dst->pitch); |
1253 const int y = yc / 8, yb = yc & 7; | 1252 const int y = yc / 8, yb = yc & 7; |
1254 const int scroffsy = y * src->chWidth; | 1253 const int scroffsy = y * src->chWidth; |
1255 | 1254 |
1256 if (src->type & D64_FMT_CHAR) | 1255 if (src->type & D64_FMT_CHAR) |
1257 { | 1256 { |
1264 const int scroffs = scroffsy + x; | 1263 const int scroffs = scroffsy + x; |
1265 const int chr = src->screen[0].data[scroffs]; | 1264 const int chr = src->screen[0].data[scroffs]; |
1266 const int v = 7 - (xc & 7); | 1265 const int v = 7 - (xc & 7); |
1267 | 1266 |
1268 if ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 1) | 1267 if ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 1) |
1269 *d++ = src->color[0].data[scroffs]; | 1268 *dp++ = src->color[0].data[scroffs]; |
1270 else | 1269 else |
1271 *d++ = src->bgcolor; | 1270 *dp++ = src->bgcolor; |
1272 } | 1271 } |
1273 else | 1272 else |
1274 // Multicolor variants | 1273 // Multicolor variants |
1275 for (int xc = 0; xc < rwidth; xc++) | 1274 for (int xc = 0; xc < rwidth; xc++) |
1276 { | 1275 { |
1282 if (col & 8) | 1281 if (col & 8) |
1283 { | 1282 { |
1284 const int v = 6 - ((xc * 2) & 6); | 1283 const int v = 6 - ((xc * 2) & 6); |
1285 switch ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 3) | 1284 switch ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 3) |
1286 { | 1285 { |
1287 case 0: *d++ = src->bgcolor; break; | 1286 case 0: *dp++ = src->bgcolor; break; |
1288 case 1: *d++ = src->d022; break; | 1287 case 1: *dp++ = src->d022; break; |
1289 case 2: *d++ = src->d023; break; | 1288 case 2: *dp++ = src->d023; break; |
1290 case 3: *d++ = col; | 1289 case 3: *dp++ = col; |
1291 } | 1290 } |
1292 } | 1291 } |
1293 else | 1292 else |
1294 { | 1293 { |
1295 const int v = 7 - (xc & 7); | 1294 const int v = 7 - (xc & 7); |
1296 if ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 1) | 1295 if ((src->charData[0].data[chr * C64_CHR_SIZE + yb] >> v) & 1) |
1297 *d++ = src->color[0].data[scroffs]; | 1296 *dp++ = src->color[0].data[scroffs]; |
1298 else | 1297 else |
1299 *d++ = src->bgcolor; | 1298 *dp++ = src->bgcolor; |
1300 } | 1299 } |
1301 } | 1300 } |
1302 } | 1301 } |
1303 else | 1302 else |
1304 { | 1303 { |
1312 const int x = xc / 8; | 1311 const int x = xc / 8; |
1313 const int scroffs = scroffsy + x; | 1312 const int scroffs = scroffsy + x; |
1314 const int bmoffs = bmoffsy + (x * 8); | 1313 const int bmoffs = bmoffsy + (x * 8); |
1315 const int vshift = 7 - (xc & 7); | 1314 const int vshift = 7 - (xc & 7); |
1316 | 1315 |
1317 *d++ = getPixel(src, bmoffs, scroffs, vshift, 0, xc, yc); | 1316 *dp++ = getPixel(src, bmoffs, scroffs, vshift, 0, xc, yc); |
1318 } | 1317 } |
1319 else | 1318 else |
1320 // Multicolor bitmap and variants | 1319 // Multicolor bitmap and variants |
1321 for (int xc = 0; xc < rwidth; xc++) | 1320 for (int xc = 0; xc < rwidth; xc++) |
1322 { | 1321 { |
1328 if (src->type & D64_FMT_ILACE) | 1327 if (src->type & D64_FMT_ILACE) |
1329 { | 1328 { |
1330 switch (src->laceType) | 1329 switch (src->laceType) |
1331 { | 1330 { |
1332 case D64_ILACE_RES: | 1331 case D64_ILACE_RES: |
1333 *d++ = getPixel(src, bmoffs, scroffs, vshift, 0, xc, yc); | 1332 *dp++ = getPixel(src, bmoffs, scroffs, vshift, 0, xc, yc); |
1334 *d++ = getPixel(src, bmoffs, scroffs, vshift, 1, xc, yc); | 1333 *dp++ = getPixel(src, bmoffs, scroffs, vshift, 1, xc, yc); |
1335 break; | 1334 break; |
1336 | 1335 |
1337 default: | 1336 default: |
1338 return DMERR_NOT_SUPPORTED; | 1337 return DMERR_NOT_SUPPORTED; |
1339 } | 1338 } |
1340 } | 1339 } |
1341 else | 1340 else |
1342 { | 1341 { |
1343 *d++ = getPixel(src, bmoffs, scroffs, vshift, 0, xc, yc); | 1342 *dp++ = getPixel(src, bmoffs, scroffs, vshift, 0, xc, yc); |
1344 } | 1343 } |
1345 } | 1344 } |
1346 } | 1345 } |
1347 dp += dst->pitch; | |
1348 } | 1346 } |
1349 | 1347 |
1350 return DMERR_OK; | 1348 return DMERR_OK; |
1351 } | 1349 } |
1352 | 1350 |