Mercurial > hg > dmlib
comparison tools/lib64fmts.c @ 2580:317d2f4b322c
Reorder some format specific probe functions etc.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 20 Mar 2022 14:50:13 +0200 |
parents | 21d296803fac |
children | 60ffbddedd07 |
comparison
equal
deleted
inserted
replaced
2579:e716a2f18da0 | 2580:317d2f4b322c |
---|---|
1372 return fmtDecode6502SpeedCode( | 1372 return fmtDecode6502SpeedCode( |
1373 dmGrowBufConstCopyOffsSize(&tmp, buf, 0, 0x17b2), img, 0); | 1373 dmGrowBufConstCopyOffsSize(&tmp, buf, 0, 0x17b2), img, 0); |
1374 } | 1374 } |
1375 | 1375 |
1376 | 1376 |
1377 #define XX2_MIN_SIZE 4000 | |
1378 #define XX2_WIDTH_CH 40 | |
1379 #define XX2_HEIGHT_CH 10 | |
1380 #define XX2_SIZE (XX2_WIDTH_CH * XX2_HEIGHT_CH) | |
1381 #define XX2_BSIZE (XX2_SIZE * 8) | |
1382 | |
1383 | |
1384 static int fmtProbeFormatXX2(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) | |
1385 { | |
1386 if (buf->len >= XX2_MIN_SIZE && | |
1387 buf->len <= XX2_MIN_SIZE + 8 && | |
1388 dmCompareAddr16(buf, 0, fmt->addr)) | |
1389 return DM_PROBE_SCORE_MAYBE; | |
1390 | |
1391 return DM_PROBE_SCORE_FALSE; | |
1392 } | |
1393 | |
1394 | |
1395 static int fmtDecodeFormatXX2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) | |
1396 { | |
1397 int res; | |
1398 DMGrowBuf tmp; | |
1399 | |
1400 // If there is only data for less than XX2_MIN_SIZE bytes, | |
1401 // allocate a buffer of that size and copy data there. | |
1402 // Otherwise allocate len bytes. | |
1403 if (dmGrowBufCopy(&tmp, buf, buf->len < XX2_MIN_SIZE ? XX2_MIN_SIZE - buf->len : 0) == NULL) | |
1404 return DMERR_MALLOC; | |
1405 | |
1406 tmp.len = tmp.size; | |
1407 res = dmC64DecodeGenericBMP(img, &tmp, fmt); | |
1408 dmGrowBufFree(&tmp); | |
1409 return res; | |
1410 } | |
1411 | |
1412 | |
1377 static const Uint8 fmtFormatXX3_MagicID_1[] = | 1413 static const Uint8 fmtFormatXX3_MagicID_1[] = |
1378 { | 1414 { |
1379 0x01, 0x08, 0x0B, 0x08, 0xF0, 0x02, 0x9E, 0x32, | 1415 0x01, 0x08, 0x0B, 0x08, 0xF0, 0x02, 0x9E, 0x32, |
1380 0x30, 0x36, 0x31, 0x00, 0x00, 0x00, 0xA9, 0x14, | 1416 0x30, 0x36, 0x31, 0x00, 0x00, 0x00, 0xA9, 0x14, |
1381 0x8D, 0x18, 0xD0, 0xA2, 0x00, 0xA9, 0x20, 0x9D, | 1417 0x8D, 0x18, 0xD0, 0xA2, 0x00, 0xA9, 0x20, 0x9D, |
1437 return dmC64GetGenericMCPixel(scan->col, img, | 1473 return dmC64GetGenericMCPixel(scan->col, img, |
1438 bmoffs, scroffs, | 1474 bmoffs, scroffs, |
1439 6 - (rasterX & 6), | 1475 6 - (rasterX & 6), |
1440 (rasterY & 7), | 1476 (rasterY & 7), |
1441 rasterX & 1, 0, img->bgcolor); | 1477 rasterX & 1, 0, img->bgcolor); |
1442 } | |
1443 | |
1444 | |
1445 #define XX2_MIN_SIZE 4000 | |
1446 #define XX2_WIDTH_CH 40 | |
1447 #define XX2_HEIGHT_CH 10 | |
1448 #define XX2_SIZE (XX2_WIDTH_CH * XX2_HEIGHT_CH) | |
1449 #define XX2_BSIZE (XX2_SIZE * 8) | |
1450 | |
1451 | |
1452 static int fmtProbeFormatXX2(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) | |
1453 { | |
1454 if (buf->len >= XX2_MIN_SIZE && | |
1455 buf->len <= XX2_MIN_SIZE + 8 && | |
1456 dmCompareAddr16(buf, 0, fmt->addr)) | |
1457 return DM_PROBE_SCORE_MAYBE; | |
1458 | |
1459 return DM_PROBE_SCORE_FALSE; | |
1460 } | |
1461 | |
1462 | |
1463 static int fmtDecodeFormatXX2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) | |
1464 { | |
1465 int res; | |
1466 DMGrowBuf tmp; | |
1467 | |
1468 // If there is only data for less than XX2_MIN_SIZE bytes, | |
1469 // allocate a buffer of that size and copy data there. | |
1470 // Otherwise allocate len bytes. | |
1471 if (dmGrowBufCopy(&tmp, buf, buf->len < XX2_MIN_SIZE ? XX2_MIN_SIZE - buf->len : 0) == NULL) | |
1472 return DMERR_MALLOC; | |
1473 | |
1474 tmp.len = tmp.size; | |
1475 res = dmC64DecodeGenericBMP(img, &tmp, fmt); | |
1476 dmGrowBufFree(&tmp); | |
1477 return res; | |
1478 } | 1478 } |
1479 | 1479 |
1480 | 1480 |
1481 static int fmtProbeCosmosDesignsHiresManager(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) | 1481 static int fmtProbeCosmosDesignsHiresManager(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) |
1482 { | 1482 { |