Mercurial > hg > dmlib
comparison tools/lib64fmts.c @ 2299:ad019d930401
Add initial (broken) read support for Flinterlazer 1.0 images.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 04 Jul 2019 11:09:51 +0300 |
parents | 7f6ba3b32f54 |
children | a494e4a4b6bc |
comparison
equal
deleted
inserted
replaced
2298:b5abfff07ca9 | 2299:ad019d930401 |
---|---|
930 res = dmC64DecodeGenericBMP(img, &dst, fmt); | 930 res = dmC64DecodeGenericBMP(img, &dst, fmt); |
931 | 931 |
932 out: | 932 out: |
933 dmGrowBufFree(&dst); | 933 dmGrowBufFree(&dst); |
934 return res; | 934 return res; |
935 } | |
936 | |
937 | |
938 static int fmtGetPixelFlinterlazer(Uint8 *col, | |
939 const DMC64Image *img, const int rasterX, const int rasterY) | |
940 { | |
941 DM_C64_GENERIC_MC_PIXEL_DEFS(img) | |
942 const int vbank = rasterY & 7; | |
943 int res; | |
944 Uint8 color1, color2; | |
945 Uint8 bgcol = img->bgcolor; | |
946 if ((res = dmC64GetGenericMCPixel(&color1, img, bmoffs, scroffs, vshift, vbank , 0, 0, bgcol)) != DMERR_OK) | |
947 return res; | |
948 *col = color1 * 17; | |
949 return DMERR_OK; | |
950 } | |
951 | |
952 | |
953 enum | |
954 { | |
955 I_BRK = 0x00, | |
956 I_RTS = 0x60, | |
957 I_LDA_IMD = 0xa9, | |
958 I_STA_ABS = 0x8d, | |
959 }; | |
960 | |
961 | |
962 static int fmtDecode6502SpeedCode(const DMGrowBuf *buf, DMC64Image *img, const int cbank) | |
963 { | |
964 size_t reg_pc = 0; | |
965 Uint8 reg_accu = 0;//, reg_x = 0, reg_y = 0; | |
966 Uint16 reg_ptr; | |
967 | |
968 while (reg_pc < buf->size) | |
969 { | |
970 Uint8 instr = buf->data[reg_pc++]; | |
971 | |
972 switch (instr) | |
973 { | |
974 case I_LDA_IMD: | |
975 if (reg_pc >= buf->size) | |
976 goto out; | |
977 | |
978 reg_accu = buf->data[reg_pc++]; | |
979 break; | |
980 | |
981 case I_STA_ABS: | |
982 if (reg_pc >= buf->size) | |
983 goto out; | |
984 reg_ptr = buf->data[reg_pc++]; | |
985 | |
986 if (reg_pc >= buf->size) | |
987 goto out; | |
988 reg_ptr |= buf->data[reg_pc++] << 8; | |
989 | |
990 if (reg_ptr >= 0xd800 && reg_ptr <= 0xdbff) | |
991 { | |
992 img->color[cbank].data[reg_ptr - 0xd800] = reg_accu; | |
993 } | |
994 break; | |
995 | |
996 case I_RTS: | |
997 return DMERR_OK; | |
998 | |
999 default: | |
1000 return DMERR_INVALID_DATA; | |
1001 } | |
1002 } | |
1003 | |
1004 out: | |
1005 return DMERR_INVALID_DATA; | |
1006 } | |
1007 | |
1008 | |
1009 static int fmtDecodeFlinterlazer(const DMC64EncDecOp *op, DMC64Image *img, | |
1010 const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt) | |
1011 { | |
1012 DMGrowBuf tmp; | |
1013 (void) op; | |
1014 (void) fmt; | |
1015 | |
1016 // Flinterlazer stores color RAMs as speedcode, so we need to | |
1017 // decode some 6510 instructions to get the data. | |
1018 return fmtDecode6502SpeedCode( | |
1019 dmGrowBufConstCopyOffsSize(&tmp, buf, 0, 0x17b2), img, 0); | |
935 } | 1020 } |
936 | 1021 |
937 | 1022 |
938 #define XX2_MIN_SIZE 4000 | 1023 #define XX2_MIN_SIZE 4000 |
939 #define XX2_WIDTH_CH 40 | 1024 #define XX2_WIDTH_CH 40 |
2359 { | 2444 { |
2360 "fd2", "FLI Designer 2 (unpacked)", 0x3ff0, 17409, DM_FMT_RDWR, | 2445 "fd2", "FLI Designer 2 (unpacked)", 0x3ff0, 17409, DM_FMT_RDWR, |
2361 NULL, | 2446 NULL, |
2362 NULL, NULL, | 2447 NULL, NULL, |
2363 { }, &dmC64CommonFormats[9] | 2448 { }, &dmC64CommonFormats[9] |
2449 }, | |
2450 | |
2451 { | |
2452 "flnt", "Flinterlazer 1.0 (unpacked)", 0x284e, 38812, DM_FMT_RD | DM_FMT_BROKEN, | |
2453 NULL, | |
2454 NULL, NULL, | |
2455 { | |
2456 D64_FMT_MC | D64_FMT_FLI | D64_FMT_ILACE, | |
2457 D64_SCR_WIDTH / 2, D64_SCR_HEIGHT, | |
2458 D64_SCR_CH_WIDTH , D64_SCR_CH_HEIGHT, | |
2459 2, 1, | |
2460 NULL, NULL, | |
2461 fmtGetPixelFlinterlazer, | |
2462 { | |
2463 { DO_COPY , DS_COLOR_RAM , 0x0000 , 0, 0 , 0, NULL, NULL, DF_NORMAL }, | |
2464 { DO_COPY , DS_COLOR_RAM , 0x0000 , 1, 0 , 0, NULL, NULL, DF_NORMAL }, | |
2465 | |
2466 { DO_COPY , DS_BITMAP_RAM , 0x4000 - 0x284e, 0, 0 , 0, NULL, NULL, DF_NORMAL }, | |
2467 DEF_REPEAT_BLOCK_8(DS_SCREEN_RAM , 0x6000 - 0x284e, 0, 0x400, 0, DF_NORMAL), | |
2468 | |
2469 { DO_COPY , DS_BITMAP_RAM , 0x8000 - 0x284e, 1, 0 , 0, NULL, NULL, DF_NORMAL }, | |
2470 DEF_REPEAT_BLOCK_8(DS_SCREEN_RAM , 0xA000 - 0x284e, 1, 0x400, 0, DF_NORMAL), | |
2471 | |
2472 { DO_SET_OP , DS_EXTRA_INFO , D64_ILACE_COLOR, 0 , 0 , D64_EI_ILACE_TYPE, NULL, NULL, DF_DECODE }, | |
2473 { DO_SET_OP , DS_EXTRA_INFO , D64_FLI_8 , 0, 0 , D64_EI_FLI_TYPE, NULL, NULL, DF_DECODE }, | |
2474 { DO_FUNC , 0 , 0 , 0, 0, 0, fmtDecodeFlinterlazer, NULL, DF_NORMAL }, | |
2475 { DO_LAST , 0 , 0 , 0, 0 , 0, NULL, NULL, DF_NORMAL }, | |
2476 } | |
2477 }, | |
2478 NULL | |
2364 }, | 2479 }, |
2365 | 2480 |
2366 { | 2481 { |
2367 "eci", "ECI Graphic Editor 1.0 (unpacked)", 0x4000, 32770, DM_FMT_RDWR, | 2482 "eci", "ECI Graphic Editor 1.0 (unpacked)", 0x4000, 32770, DM_FMT_RDWR, |
2368 NULL, | 2483 NULL, |