comparison tools/lib64fmts.c @ 2343:94a653883a32

Change Uint8 pointer in getPixel functions to DMC64ScanLine pointer in preparation for future changes related to sprites on scanlines.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 Sep 2019 12:11:35 +0300
parents 6dc64deb6718
children 6119b9b560fb
comparison
equal deleted inserted replaced
2342:a5c68b0d6e10 2343:94a653883a32
452 buf->data[op->offs] = (img->extraInfo[D64_EI_ILACE_TYPE] == D64_ILACE_RES) ? 1 : 0; 452 buf->data[op->offs] = (img->extraInfo[D64_EI_ILACE_TYPE] == D64_ILACE_RES) ? 1 : 0;
453 return DMERR_OK; 453 return DMERR_OK;
454 } 454 }
455 455
456 456
457 static int fmtGetPixelDrazLace(Uint8 *col, 457 static int fmtGetPixelDrazLace(DMC64ScanLine *scan,
458 const DMC64Image *img, const int rasterX, const int rasterY) 458 const DMC64Image *img, const int rasterX, const int rasterY)
459 { 459 {
460 DM_C64_GENERIC_SC_PIXEL_DEFS(img) 460 DM_C64_GENERIC_SC_PIXEL_DEFS(img)
461 (void) vshift; 461 (void) vshift;
462 462
463 return dmC64GetGenericMCPixel(col, img, 463 return dmC64GetGenericMCPixel(scan->col, img,
464 bmoffs, scroffs, 464 bmoffs, scroffs,
465 6 - (rasterX & 6), 0, 465 6 - (rasterX & 6), 0,
466 rasterX & 1, 0, img->bgcolor); 466 rasterX & 1, 0, img->bgcolor);
467 } 467 }
468 468
675 675
676 return DM_PROBE_SCORE_FALSE; 676 return DM_PROBE_SCORE_FALSE;
677 } 677 }
678 678
679 679
680 static int fmtGetPixelFLIDesigner(Uint8 *col, 680 static int fmtGetPixelFLIDesigner(DMC64ScanLine *scan,
681 const DMC64Image *img, const int rasterX, const int rasterY) 681 const DMC64Image *img, const int rasterX, const int rasterY)
682 { 682 {
683 DM_C64_GENERIC_MC_PIXEL_DEFS(img) 683 DM_C64_GENERIC_MC_PIXEL_DEFS(img)
684 684
685 return dmC64GetGenericMCPixel(col, img, 685 return dmC64GetGenericMCPixel(scan->col, img,
686 bmoffs, scroffs, 686 bmoffs, scroffs,
687 vshift, rasterY & 7, 687 vshift, rasterY & 7,
688 0, 0, img->bgcolor); 688 0, 0, img->bgcolor);
689 } 689 }
690 690
770 dmGrowBufFree(&tmp2); 770 dmGrowBufFree(&tmp2);
771 return res; 771 return res;
772 } 772 }
773 773
774 774
775 static int fmtGetPixelBlackMailFLI(Uint8 *col, 775 static int fmtGetPixelBlackMailFLI(DMC64ScanLine *scan,
776 const DMC64Image *img, const int rasterX, const int rasterY) 776 const DMC64Image *img, const int rasterX, const int rasterY)
777 { 777 {
778 DM_C64_GENERIC_MC_PIXEL_DEFS(img) 778 DM_C64_GENERIC_MC_PIXEL_DEFS(img)
779 779
780 Uint8 bgcol = (unsigned) rasterY < img->extraData[0].size ? 780 Uint8 bgcol = (unsigned) rasterY < img->extraData[0].size ?
781 img->extraData[0].data[rasterY] : img->bgcolor; 781 img->extraData[0].data[rasterY] : img->bgcolor;
782 782
783 return dmC64GetGenericMCPixel(col, img, 783 return dmC64GetGenericMCPixel(scan->col, img,
784 bmoffs, scroffs, 784 bmoffs, scroffs,
785 vshift, rasterY & 7, 785 vshift, rasterY & 7,
786 0, 0, bgcol); 786 0, 0, bgcol);
787 } 787 }
788 788
789 789
790 static int fmtGetPixelTruePaint(Uint8 *col, 790 static int fmtGetPixelTruePaint(DMC64ScanLine *scan,
791 const DMC64Image *img, const int rasterX, const int rasterY) 791 const DMC64Image *img, const int rasterX, const int rasterY)
792 { 792 {
793 DM_C64_GENERIC_SC_PIXEL_DEFS(img) 793 DM_C64_GENERIC_SC_PIXEL_DEFS(img)
794 (void) vshift; 794 (void) vshift;
795 795
796 return dmC64GetGenericMCPixel(col, img, 796 return dmC64GetGenericMCPixel(scan->col, img,
797 bmoffs, scroffs, 797 bmoffs, scroffs,
798 6 - (rasterX & 6), 0, 798 6 - (rasterX & 6), 0,
799 rasterX & 1, 0, img->bgcolor); 799 rasterX & 1, 0, img->bgcolor);
800 } 800 }
801 801
928 dmGrowBufFree(&dst); 928 dmGrowBufFree(&dst);
929 return res; 929 return res;
930 } 930 }
931 931
932 932
933 static int fmtGetPixelFlinterlazer(Uint8 *col, 933 static int fmtGetPixelFlinterlazer(DMC64ScanLine *scan,
934 const DMC64Image *img, const int rasterX, const int rasterY) 934 const DMC64Image *img, const int rasterX, const int rasterY)
935 { 935 {
936 DM_C64_GENERIC_MC_PIXEL_DEFS(img) 936 DM_C64_GENERIC_MC_PIXEL_DEFS(img)
937 const int vbank = rasterY & 7; 937 const int vbank = rasterY & 7;
938 Uint8 color1, color2, bgcol = img->bgcolor; 938 Uint8 color1, color2, bgcol = img->bgcolor;
940 940
941 if ((res = dmC64GetGenericMCPixel(&color1, img, bmoffs, scroffs, vshift, vbank , 0, 0, bgcol)) != DMERR_OK || 941 if ((res = dmC64GetGenericMCPixel(&color1, img, bmoffs, scroffs, vshift, vbank , 0, 0, bgcol)) != DMERR_OK ||
942 (res = dmC64GetGenericMCPixel(&color2, img, bmoffs, scroffs, vshift, vbank + 8, 1, 0, bgcol)) != DMERR_OK) 942 (res = dmC64GetGenericMCPixel(&color2, img, bmoffs, scroffs, vshift, vbank + 8, 1, 0, bgcol)) != DMERR_OK)
943 return res; 943 return res;
944 944
945 *col = (color1 * D64_NCOLORS) + color2; 945 *(scan->col) = (color1 * D64_NCOLORS) + color2;
946 return DMERR_OK; 946 return DMERR_OK;
947 } 947 }
948 948
949 949
950 enum 950 enum
1271 dmGrowBufFree(&mem); 1271 dmGrowBufFree(&mem);
1272 return res; 1272 return res;
1273 } 1273 }
1274 1274
1275 1275
1276 static int fmtGetPixelFunPaint2(Uint8 *col, 1276 static int fmtGetPixelFunPaint2(DMC64ScanLine *scan,
1277 const DMC64Image *img, const int rasterX, const int rasterY) 1277 const DMC64Image *img, const int rasterX, const int rasterY)
1278 { 1278 {
1279 DM_C64_GENERIC_SC_PIXEL_DEFS(img) 1279 DM_C64_GENERIC_SC_PIXEL_DEFS(img)
1280 const int bitmap = rasterX & 1; 1280 const int bitmap = rasterX & 1;
1281 Uint8 bgcol = (unsigned) rasterY < img->extraData[0].size ? 1281 Uint8 bgcol = (unsigned) rasterY < img->extraData[0].size ?
1282 img->extraData[0].data[rasterY] : img->bgcolor; 1282 img->extraData[0].data[rasterY] : img->bgcolor;
1283 1283
1284 (void) vshift; 1284 (void) vshift;
1285 1285
1286 return dmC64GetGenericMCPixel(col, img, 1286 return dmC64GetGenericMCPixel(scan->col, img,
1287 bmoffs, scroffs, 1287 bmoffs, scroffs,
1288 6 - (rasterX & 6), 1288 6 - (rasterX & 6),
1289 yb + (bitmap * 8), 1289 yb + (bitmap * 8),
1290 bitmap, 0, bgcol); 1290 bitmap, 0, bgcol);
1291 } 1291 }
1292 1292
1293 1293
1294 static int fmtGetPixelBFLI(Uint8 *col, 1294 static int fmtGetPixelBFLI(DMC64ScanLine *scan,
1295 const DMC64Image *img, const int rasterX, const int rasterY) 1295 const DMC64Image *img, const int rasterX, const int rasterY)
1296 { 1296 {
1297 DM_C64_GENERIC_MC_PIXEL_DEFS(img) 1297 DM_C64_GENERIC_MC_PIXEL_DEFS(img)
1298 const int vbb = rasterY < 200 ? 0 : 1; 1298 const int vbb = rasterY < 200 ? 0 : 1;
1299 const int vbank = (rasterY & 7) + (vbb * 8); 1299 const int vbank = (rasterY & 7) + (vbb * 8);
1300 1300
1301 return dmC64GetGenericMCPixel(col, img, 1301 return dmC64GetGenericMCPixel(scan->col, img,
1302 bmoffs & 0x1fff, scroffs & 0x3ff, 1302 bmoffs & 0x1fff, scroffs & 0x3ff,
1303 vshift, vbank, 1303 vshift, vbank,
1304 vbb, 0, img->bgcolor); 1304 vbb, 0, img->bgcolor);
1305 } 1305 }
1306 1306
1307 1307
1308 static int fmtGetPixelPentelPaint(Uint8 *col, 1308 static int fmtGetPixelPentelPaint(DMC64ScanLine *scan,
1309 const DMC64Image *img, const int rasterX, const int rasterY) 1309 const DMC64Image *img, const int rasterX, const int rasterY)
1310 { 1310 {
1311 DM_C64_GENERIC_SC_PIXEL_DEFS(img) 1311 DM_C64_GENERIC_SC_PIXEL_DEFS(img)
1312 const int spr_y = rasterY / D64_SPR_HEIGHT_PX; 1312 const int spr_y = rasterY / D64_SPR_HEIGHT_PX;
1313 const int spr_yd = rasterY % D64_SPR_HEIGHT_PX; 1313 const int spr_yd = rasterY % D64_SPR_HEIGHT_PX;
1322 color3 = img->extraData[0].data[offs + D64_SPR_SIZE * 155] & mask ? img->d022 : 0; 1322 color3 = img->extraData[0].data[offs + D64_SPR_SIZE * 155] & mask ? img->d022 : 0;
1323 1323
1324 if ((res = dmC64GetGenericSCPixel(&color1, img, bmoffs, scroffs, vshift, 0, 0)) != DMERR_OK) 1324 if ((res = dmC64GetGenericSCPixel(&color1, img, bmoffs, scroffs, vshift, 0, 0)) != DMERR_OK)
1325 return res; 1325 return res;
1326 1326
1327 *col = color3 ? color3 : ( color2 ? color2 : color1 ); 1327 *(scan->col) = color3 ? color3 : ( color2 ? color2 : color1 );
1328 return DMERR_OK; 1328 return DMERR_OK;
1329 } 1329 }
1330 1330
1331 1331
1332 // Horizontal character X-offset and scanline Y-offset 1332 // Horizontal character X-offset and scanline Y-offset
1524 1524
1525 return res; 1525 return res;
1526 } 1526 }
1527 1527
1528 1528
1529 static int fmtGetSpritePixelCrestSHFLI(Uint8 *col, 1529 static int fmtGetSpritePixelCrestSHFLI(DMC64ScanLine *scan,
1530 const DMC64Image *img, const int sindex, const int cindex, 1530 const DMC64Image *img, const int sindex, const int cindex,
1531 const int spr_xd, const int spr_yd, const int mask) 1531 const int spr_xd, const int spr_yd, const int mask)
1532 { 1532 {
1533 const size_t offs = sindex * D64_SPR_SIZE + (D64_SPR_WIDTH_UT * spr_yd) + spr_xd; 1533 const size_t offs = sindex * D64_SPR_SIZE + (D64_SPR_WIDTH_UT * spr_yd) + spr_xd;
1534 1534
1535 if (offs >= img->extraData[14].size) 1535 if (offs >= img->extraData[14].size)
1536 return DMERR_BOUNDS; 1536 return DMERR_BOUNDS;
1537 1537
1538 if (img->extraData[14].data[offs] & mask) 1538 if (img->extraData[14].data[offs] & mask)
1539 { 1539 {
1540 *col = img->extraData[15].data[cindex]; 1540 *(scan->col) = img->extraData[15].data[cindex];
1541 return DMERR_OK; 1541 return DMERR_OK;
1542 } 1542 }
1543 1543
1544 return -1; 1544 return -1;
1545 } 1545 }
1546 1546
1547 1547
1548 static int fmtGetPixelCrestSHFLI(Uint8 *col, 1548 static int fmtGetPixelCrestSHFLI(DMC64ScanLine *scan,
1549 const DMC64Image *img, const int rasterX, const int rasterY) 1549 const DMC64Image *img, const int rasterX, const int rasterY)
1550 { 1550 {
1551 DM_C64_GENERIC_SC_PIXEL_DEFS(img) 1551 DM_C64_GENERIC_SC_PIXEL_DEFS(img)
1552 const int sprOffsetX = DM_CREST_SHFLI_IMG_XOFFS * 8, 1552 const int sprOffsetX = DM_CREST_SHFLI_IMG_XOFFS * 8,
1553 sprOffsetY = DM_CREST_SHFLI_IMG_YOFFS; 1553 sprOffsetY = DM_CREST_SHFLI_IMG_YOFFS;
1554 const int nbank = rasterY & 7; 1554 const int nbank = rasterY & 7;
1555 int res; 1555 int res;
1556 1556
1557 if (rasterY / 8 >= DM_CREST_SHFLI_IMG_HEIGHT) 1557 if (rasterY / 8 >= DM_CREST_SHFLI_IMG_HEIGHT)
1558 { 1558 {
1559 *col = 0x0f; 1559 *(scan->col) = 0x0f;
1560 return DMERR_OK; 1560 return DMERR_OK;
1561 } 1561 }
1562 1562
1563 if (rasterY >= sprOffsetY && 1563 if (rasterY >= sprOffsetY &&
1564 rasterX >= sprOffsetX && 1564 rasterX >= sprOffsetX &&
1574 1574
1575 const int spr_offs = spr_x & 3; 1575 const int spr_offs = spr_x & 3;
1576 const int spr_index1 = img->extraData[sbank].data[spr_offs]; 1576 const int spr_index1 = img->extraData[sbank].data[spr_offs];
1577 const int spr_index2 = img->extraData[sbank].data[spr_offs + 4]; 1577 const int spr_index2 = img->extraData[sbank].data[spr_offs + 4];
1578 1578
1579 if ((res = fmtGetSpritePixelCrestSHFLI(col, img, spr_index1, 0, spr_xd, spr_yd, mask)) == DMERR_OK || 1579 if ((res = fmtGetSpritePixelCrestSHFLI(scan, img, spr_index1, 0, spr_xd, spr_yd, mask)) == DMERR_OK ||
1580 res != -1) 1580 res != -1)
1581 return res; 1581 return res;
1582 1582
1583 if ((res = fmtGetSpritePixelCrestSHFLI(col, img, spr_index2, 1, spr_xd, spr_yd, mask)) == DMERR_OK || 1583 if ((res = fmtGetSpritePixelCrestSHFLI(scan, img, spr_index2, 1, spr_xd, spr_yd, mask)) == DMERR_OK ||
1584 res != -1) 1584 res != -1)
1585 return res; 1585 return res;
1586 } 1586 }
1587 1587
1588 if ((res = dmC64GetGenericSCPixel(col, img, bmoffs, scroffs, vshift, nbank, 0)) != DMERR_OK) 1588 if ((res = dmC64GetGenericSCPixel(scan->col, img, bmoffs, scroffs, vshift, nbank, 0)) != DMERR_OK)
1589 return res; 1589 return res;
1590 1590
1591 return DMERR_OK; 1591 return DMERR_OK;
1592 } 1592 }
1593 1593
1594 1594
1595 static int fmtGetPixelHCB(Uint8 *col, 1595 static int fmtGetPixelHCB(DMC64ScanLine *scan,
1596 const DMC64Image *img, const int rasterX, const int rasterY) 1596 const DMC64Image *img, const int rasterX, const int rasterY)
1597 { 1597 {
1598 DM_C64_GENERIC_MC_PIXEL_DEFS(img) 1598 DM_C64_GENERIC_MC_PIXEL_DEFS(img)
1599 const int vbank = (rasterY / 4) & 1; 1599 const int vbank = (rasterY / 4) & 1;
1600 const int ry = rasterY / 5; 1600 const int ry = rasterY / 5;
1601 1601
1602 Uint8 bgcol = (unsigned) ry < img->extraData[0].size ? 1602 Uint8 bgcol = (unsigned) ry < img->extraData[0].size ?
1603 img->extraData[0].data[ry] : img->bgcolor; 1603 img->extraData[0].data[ry] : img->bgcolor;
1604 1604
1605 return dmC64GetGenericMCPixel(col, img, 1605 return dmC64GetGenericMCPixel(scan->col, img,
1606 bmoffs, scroffs, 1606 bmoffs, scroffs,
1607 vshift, vbank, 1607 vshift, vbank,
1608 0, vbank, bgcol); 1608 0, vbank, bgcol);
1609 } 1609 }
1610 1610
1611 1611
1612 static int fmtGetPixelCrestHIFLIorCDHM(Uint8 *col, 1612 static int fmtGetPixelCrestHIFLIorCDHM(DMC64ScanLine *scan,
1613 const DMC64Image *img, const int rasterX, const int rasterY) 1613 const DMC64Image *img, const int rasterX, const int rasterY)
1614 { 1614 {
1615 DM_C64_GENERIC_SC_PIXEL_DEFS(img) 1615 DM_C64_GENERIC_SC_PIXEL_DEFS(img)
1616 1616
1617 return dmC64GetGenericSCPixel(col, img, 1617 return dmC64GetGenericSCPixel(scan->col, img,
1618 bmoffs, scroffs, 1618 bmoffs, scroffs,
1619 vshift, rasterY & 7, 0); 1619 vshift, rasterY & 7, 0);
1620 } 1620 }
1621 1621
1622 1622
1623 static int fmtGetPixelECI(Uint8 *col, 1623 static int fmtGetPixelECI(DMC64ScanLine *scan,
1624 const DMC64Image *img, const int rasterX, const int rasterY) 1624 const DMC64Image *img, const int rasterX, const int rasterY)
1625 { 1625 {
1626 DM_C64_GENERIC_SC_PIXEL_DEFS(img) 1626 DM_C64_GENERIC_SC_PIXEL_DEFS(img)
1627 const int vbank = rasterY & 7; 1627 const int vbank = rasterY & 7;
1628 Uint8 color1, color2; 1628 Uint8 color1, color2;
1630 1630
1631 if ((res = dmC64GetGenericSCPixel(&color1, img, bmoffs, scroffs, vshift, vbank , 0)) != DMERR_OK || 1631 if ((res = dmC64GetGenericSCPixel(&color1, img, bmoffs, scroffs, vshift, vbank , 0)) != DMERR_OK ||
1632 (res = dmC64GetGenericSCPixel(&color2, img, bmoffs, scroffs, vshift, vbank + 8, 1)) != DMERR_OK) 1632 (res = dmC64GetGenericSCPixel(&color2, img, bmoffs, scroffs, vshift, vbank + 8, 1)) != DMERR_OK)
1633 return res; 1633 return res;
1634 1634
1635 *col = (color1 * D64_NCOLORS) + color2; 1635 *(scan->col) = (color1 * D64_NCOLORS) + color2;
1636 return DMERR_OK; 1636 return DMERR_OK;
1637 } 1637 }
1638 1638
1639 1639
1640 static int fmtProbeECIPacked(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) 1640 static int fmtProbeECIPacked(const DMGrowBuf *buf, const DMC64ImageFormat *fmt)