comparison tools/lib64fmts.c @ 1788:04e13949b314

Implement support for packed variant of Black Mail FLI format.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 13 Jun 2018 01:57:07 +0300
parents 5ea4713e9e0f
children 9f5c5ab0e85e
comparison
equal deleted inserted replaced
1787:8af6067b6bd7 1788:04e13949b314
380 380
381 return DM_PROBE_SCORE_FALSE; 381 return DM_PROBE_SCORE_FALSE;
382 } 382 }
383 383
384 384
385 static int fmtProbeBlackMailFLIPacked(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
386 {
387 if (buf->len > 16 &&
388 dmCompareAddr16(buf, 0, fmt->addr) &&
389 dmCompareAddr16(buf, 2 + 1, fmt->addr + buf->len - 3) &&
390 dmCompareAddr16(buf, 2 + 3, 0x7f3f))
391 return DM_PROBE_SCORE_MAX;
392
393 return DM_PROBE_SCORE_FALSE;
394 }
395
396
397 static int fmtDecodeBlackMailFLIPacked(DMC64Image *img, const DMGrowBuf *psrc, const DMC64ImageFormat *fmt)
398 {
399 int res;
400 DMGrowBuf dst, src;
401 DMCompParams cfg;
402
403 cfg.func = fmt->name;
404 cfg.type = DM_COMP_RLE_MARKER;
405 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1 | DM_RLE_ZERO_COUNT_MAX |
406 DM_RLE_BACKWARDS_INPUT | DM_RLE_BACKWARDS_OUTPUT | DM_OUT_CROP_END;
407 cfg.rleMarkerB = psrc->data[0];
408 cfg.cropOutLen = 0x4442 - 2; // Crop to unpacked size - load address
409
410 // Skip the RLE marker byte, packed data end address and unpacked data end address
411 dmGrowBufConstCopyOffs(&src, psrc, 1 + 2 + 2);
412
413 if ((res = dmDecodeGenericRLEAlloc(&dst, &src, &cfg)) != DMERR_OK)
414 goto out;
415
416 res = dmC64DecodeGenericBMP(img, &dst, fmt);
417
418 out:
419 dmGrowBufFree(&dst);
420 return res;
421 }
422
423
424 static Uint8 fmtGetPixelBlackMailFLI(
425 const DMC64Image *img, const int bmoffs, const int scroffs,
426 const int shift, const int bitmap, const int rasterX, const int rasterY)
427 {
428 const int vbank = rasterY & 7;
429 (void) rasterX;
430
431 return dmC64GetGenericMCPixel(
432 img, bmoffs, scroffs, shift,
433 vbank, bitmap, 0,
434 img->extraData[0].data[rasterY] & 15);
435 }
436
437
385 static BOOL fmtTruePaintGetLaceType(DMC64Image *img, const DMC64EncDecOp *op, 438 static BOOL fmtTruePaintGetLaceType(DMC64Image *img, const DMC64EncDecOp *op,
386 const DMGrowBuf *buf, const DMC64ImageFormat *fmt) 439 const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
387 { 440 {
388 (void) op; 441 (void) op;
389 (void) buf; 442 (void) buf;
741 // fprintf(stderr, "vbmoffs=%d, scroffs=%d, vshift=%d, vbitmap=%d, vbank=%d, rasterY=%d: pp=%02x\n", vbmoffs, vscroffs, vshift, vbb, vbank, rasterY, pp); 794 // fprintf(stderr, "vbmoffs=%d, scroffs=%d, vshift=%d, vbitmap=%d, vbank=%d, rasterY=%d: pp=%02x\n", vbmoffs, vscroffs, vshift, vbb, vbank, rasterY, pp);
742 795
743 return dmC64GetGenericMCPixel( 796 return dmC64GetGenericMCPixel(
744 img, vbmoffs, vscroffs, shift, 797 img, vbmoffs, vscroffs, shift,
745 vbank, vbb, 0, img->bgcolor); 798 vbank, vbb, 0, img->bgcolor);
746 }
747
748
749 static Uint8 fmtGetPixelBlackMailFLI(
750 const DMC64Image *img, const int bmoffs, const int scroffs,
751 const int shift, const int bitmap, const int rasterX, const int rasterY)
752 {
753 const int vbank = rasterY & 7;
754 (void) rasterX;
755
756 return dmC64GetGenericMCPixel(
757 img, bmoffs, scroffs, shift,
758 vbank, bitmap, 0,
759 img->extraData[0].data[rasterY] & 15);
760 } 799 }
761 800
762 801
763 static Uint8 fmtGetPixelFLIDesigner( 802 static Uint8 fmtGetPixelFLIDesigner(
764 const DMC64Image *img, const int bmoffs, const int scroffs, 803 const DMC64Image *img, const int bmoffs, const int scroffs,
897 { DO_SET_MEM , DS_BGCOL , 0x2710, 0, 0, NULL, NULL }, 936 { DO_SET_MEM , DS_BGCOL , 0x2710, 0, 0, NULL, NULL },
898 { DO_LAST , 0 , 0 , 0, 0, NULL, NULL }, 937 { DO_LAST , 0 , 0 , 0, 0, NULL, NULL },
899 } 938 }
900 }, 939 },
901 940
902 { // #1: UNUSED 941 { // #1: Black Mail FLI Graph
942 D64_FMT_MC | D64_FMT_FLI,
943 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
944 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
945 NULL, NULL,
946 fmtGetPixelBlackMailFLI,
947 {
948 { DO_COPY , DS_EXTRA_DATA , 0x0000, 0, 200, NULL, NULL },
949 { DO_COPY , DS_COLOR_RAM , 0x0100, 0, 0, NULL, NULL },
950 DEF_SCREEN_RAMS_8(0x0500, 0, 0x400),
951 { DO_COPY , DS_BITMAP_RAM , 0x2500, 0, 0, NULL, NULL },
952 { DO_LAST , 0 , 0 , 0, 0, NULL, NULL },
953 }
903 }, 954 },
904 955
905 { // #2: Art Studio etc. Hires 956 { // #2: Art Studio etc. Hires
906 D64_FMT_HIRES, 957 D64_FMT_HIRES,
907 C64_SCR_WIDTH , C64_SCR_HEIGHT, 958 C64_SCR_WIDTH , C64_SCR_HEIGHT,
1434 }, 1485 },
1435 NULL 1486 NULL
1436 }, 1487 },
1437 1488
1438 { 1489 {
1439 "bml", "Blackmail FLI (unpacked)", 0x3b00, 17474, DM_FMT_RDWR, 1490 "bml", "Black Mail FLI (unpacked)", 0x3b00, 17474, DM_FMT_RDWR,
1440 NULL, 1491 NULL,
1441 NULL, NULL, 1492 NULL, NULL,
1442 { 1493 { }, &dmC64CommonFormats[1]
1443 D64_FMT_MC | D64_FMT_FLI, 1494 },
1444 C64_SCR_WIDTH / 2, C64_SCR_HEIGHT, 1495
1445 C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT, 1496 {
1446 NULL, NULL, 1497 "bmlp", "Black Mail FLI (packed)", 0x38f0, 0, DM_FMT_RD,
1447 fmtGetPixelBlackMailFLI, 1498 fmtProbeBlackMailFLIPacked,
1448 { 1499 fmtDecodeBlackMailFLIPacked, NULL,
1449 { DO_COPY , DS_EXTRA_DATA , 0x0000, 0, 200, NULL, NULL }, 1500 { }, &dmC64CommonFormats[1]
1450 { DO_COPY , DS_COLOR_RAM , 0x0100, 0, 0, NULL, NULL },
1451 DEF_SCREEN_RAMS_8(0x0500, 0, 0x400),
1452 { DO_COPY , DS_BITMAP_RAM , 0x2500, 0, 0, NULL, NULL },
1453 { DO_LAST , 0 , 0 , 0, 0, NULL, NULL },
1454 }
1455 },
1456 NULL
1457 }, 1501 },
1458 1502
1459 { 1503 {
1460 "fli", "FLI Designer (unpacked)", 0, 17409, DM_FMT_RD, 1504 "fli", "FLI Designer (unpacked)", 0, 17409, DM_FMT_RD,
1461 fmtProbeFLIDesigner, 1505 fmtProbeFLIDesigner,