Mercurial > hg > dmlib
comparison tools/lib64fmts.c @ 2165:3d3094ba21c5
Add read-only support for Crest Super Hires FLI Editor v1.0 (unpacked) format.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 11 Jun 2019 05:11:31 +0300 |
parents | ed079e869d64 |
children | 4c3fdc9c0056 |
comparison
equal
deleted
inserted
replaced
2164:ed079e869d64 | 2165:3d3094ba21c5 |
---|---|
1238 | 1238 |
1239 if ((res = dmC64GetGenericSCPixel(&color1, img, bmoffs, scroffs, vshift, 0, 0)) != DMERR_OK) | 1239 if ((res = dmC64GetGenericSCPixel(&color1, img, bmoffs, scroffs, vshift, 0, 0)) != DMERR_OK) |
1240 return res; | 1240 return res; |
1241 | 1241 |
1242 *col = color3 ? color3 : ( color2 ? color2 : color1 ); | 1242 *col = color3 ? color3 : ( color2 ? color2 : color1 ); |
1243 return DMERR_OK; | |
1244 } | |
1245 | |
1246 | |
1247 static int fmtGetSpritePixelCrestSHFLI(Uint8 *col, | |
1248 const DMC64Image *img, const int sindex, const int cindex, | |
1249 const int spr_xd, const int spr_yd, const int mask) | |
1250 { | |
1251 const size_t offs = sindex * D64_SPR_SIZE + (D64_SPR_WIDTH_UT * spr_yd) + spr_xd; | |
1252 | |
1253 if (offs >= img->extraData[14].size) | |
1254 return DMERR_BOUNDS; | |
1255 | |
1256 if (img->extraData[14].data[offs] & mask) | |
1257 { | |
1258 *col = img->extraData[15].data[cindex]; | |
1259 return DMERR_OK; | |
1260 } | |
1261 | |
1262 return -1; | |
1263 } | |
1264 | |
1265 | |
1266 static int fmtGetPixelCrestSHFLI(Uint8 *col, | |
1267 const DMC64Image *img, const int rasterX, const int rasterY) | |
1268 { | |
1269 DM_C64_GENERIC_SC_PIXEL_DEFS(img) | |
1270 const int sprOffsetX = 112, sprOffsetY = 1; | |
1271 const int nbank = rasterY & 7; | |
1272 int res; | |
1273 | |
1274 if (rasterY / 8 >= img->fmt->chHeight) | |
1275 { | |
1276 *col = img->bgcolor; | |
1277 return DMERR_OK; | |
1278 } | |
1279 | |
1280 if (rasterY >= sprOffsetY && | |
1281 rasterX >= sprOffsetX && | |
1282 rasterX < sprOffsetX + 4 * D64_SPR_WIDTH_PX) | |
1283 { | |
1284 const int localX = rasterX - sprOffsetX, | |
1285 localY = rasterY - sprOffsetY; | |
1286 const int sbank = localY & 7; | |
1287 const int spr_yd = localY % D64_SPR_HEIGHT_PX; | |
1288 const int spr_x = localX / D64_SPR_WIDTH_PX; | |
1289 const int spr_xd = (localX % D64_SPR_WIDTH_PX) / 8; | |
1290 const int mask = 1 << (7 - (localX & 7)); | |
1291 | |
1292 const int spr_offs = spr_x & 3; | |
1293 const int spr_index1 = img->extraData[sbank].data[spr_offs]; | |
1294 const int spr_index2 = img->extraData[sbank].data[spr_offs + 4]; | |
1295 | |
1296 if ((res = fmtGetSpritePixelCrestSHFLI(col, img, spr_index1, 0, spr_xd, spr_yd, mask)) == DMERR_OK || | |
1297 res != -1) | |
1298 return res; | |
1299 | |
1300 if ((res = fmtGetSpritePixelCrestSHFLI(col, img, spr_index2, 1, spr_xd, spr_yd, mask)) == DMERR_OK || | |
1301 res != -1) | |
1302 return res; | |
1303 } | |
1304 | |
1305 if ((res = dmC64GetGenericSCPixel(col, img, bmoffs, scroffs, vshift, nbank, 0)) != DMERR_OK) | |
1306 return res; | |
1307 | |
1243 return DMERR_OK; | 1308 return DMERR_OK; |
1244 } | 1309 } |
1245 | 1310 |
1246 | 1311 |
1247 static int fmtGetPixelHCB(Uint8 *col, | 1312 static int fmtGetPixelHCB(Uint8 *col, |
2271 }, | 2336 }, |
2272 NULL | 2337 NULL |
2273 }, | 2338 }, |
2274 | 2339 |
2275 { | 2340 { |
2341 "cshf", "Crest Super Hires FLI Editor v1.0 (unpacked)", 0x4000, 15874, DM_FMT_RD, | |
2342 NULL, | |
2343 NULL, NULL, | |
2344 { | |
2345 D64_FMT_HIRES | D64_FMT_FLI, | |
2346 D64_SCR_WIDTH, D64_SCR_HEIGHT, | |
2347 D64_SCR_CH_WIDTH, 21, | |
2348 1, 1, | |
2349 NULL, NULL, | |
2350 fmtGetPixelCrestSHFLI, | |
2351 { | |
2352 DEF_REPEAT_BLOCK_8(DS_SCREEN_RAM, 0x0000, 0, 0x400, 0), | |
2353 DEF_REPEAT_BLOCK_8(DS_EXTRA_DATA, 0x03f8, 0, 0x400, 8), // Sprite pointers for each bank | |
2354 { DO_COPY , DS_EXTRA_DATA , 0x03e8, 15, 2 , 0, NULL, NULL }, // 2 sprite colors | |
2355 { DO_COPY , DS_EXTRA_DATA , 0x0000, 14, 0x3e00, 0, NULL, NULL }, // Lazily copy whole data for sprite data | |
2356 { DO_COPY , DS_BITMAP_RAM , 0x2000, 0, 0, 0, NULL, NULL }, | |
2357 { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL }, | |
2358 } | |
2359 }, | |
2360 NULL | |
2361 }, | |
2362 | |
2363 { | |
2276 "cdhm", "Cosmos Designs Hires Manager (unpacked)", 0x4000, 16385, DM_FMT_RDWR, | 2364 "cdhm", "Cosmos Designs Hires Manager (unpacked)", 0x4000, 16385, DM_FMT_RDWR, |
2277 fmtProbeCosmosDesignsHiresManager, | 2365 fmtProbeCosmosDesignsHiresManager, |
2278 NULL, NULL, | 2366 NULL, NULL, |
2279 { }, &dmC64CommonFormats[8] | 2367 { }, &dmC64CommonFormats[8] |
2280 }, | 2368 }, |