Mercurial > hg > dmlib
comparison tools/lib64fmts.c @ 2287:631bbd451d08
Add write support for Marq's PETSCII editor PRG export format.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 20 Jun 2019 14:49:01 +0300 |
parents | 48b48251610a |
children | 7f6ba3b32f54 |
comparison
equal
deleted
inserted
replaced
2286:e771185db600 | 2287:631bbd451d08 |
---|---|
62 | 62 |
63 | 63 |
64 static const Uint8 fmtMarqPETSCII_ID1[] = | 64 static const Uint8 fmtMarqPETSCII_ID1[] = |
65 { | 65 { |
66 0x01, 0x08, 0x0b, 0x08, 0xef, 0x00, 0x9e, 0x32, 0x30, 0x36, | 66 0x01, 0x08, 0x0b, 0x08, 0xef, 0x00, 0x9e, 0x32, 0x30, 0x36, |
67 0x31, 0x00, 0x00, 0x00, 0xa9, 0x0b, 0x8d, 0x11, 0xd0, 0xa9, | 67 0x31, 0x00, 0x00, 0x00, 0xa9, 0x0b, 0x8d, 0x11, 0xd0, |
68 }; | 68 }; |
69 | 69 |
70 static const Uint8 fmtMarqPETSCII_ID2[] = | 70 static const Uint8 fmtMarqPETSCII_ID2[] = |
71 { | 71 { |
72 0x8d, 0x21, 0xd0, 0xa2, 0x00, 0xa0, 0xfa, 0xbd, 0x61, 0x08, | 72 0xa9, 0x00, 0x8d, 0x18, 0xd0, // lda #? : sta $d018 |
73 0x9d, 0x00, 0x04, 0xbd, 0x5b, 0x09, 0x9d, 0xfa, 0x04, 0xbd, | 73 0xa9, 0x00, 0x8d, 0x20, 0xd0, // lda #? : sta $d020 |
74 0x55, 0x0a, 0x9d, 0xf4, | 74 0xa9, 0x00, 0x8d, 0x21, 0xd0, // lda #? : sta $d021 |
75 }; | |
76 | |
77 static const Uint8 fmtMarqPETSCII_ID3[] = | |
78 { | |
79 0xa2, 0x00, 0xa0, 0xfa, 0xbd, 0x61, | |
80 0x08, 0x9d, 0x00, 0x04, 0xbd, 0x5b, 0x09, 0x9d, 0xfa, 0x04, | |
81 0xbd, 0x55, 0x0a, 0x9d, 0xf4, 0x05, 0xbd, 0x4f, 0x0b, 0x9d, | |
82 0xee, 0x06, 0xbd, 0x49, 0x0c, 0x9d, 0x00, 0xd8, 0xbd, 0x43, | |
83 0x0d, 0x9d, 0xfa, 0xd8, 0xbd, 0x3d, 0x0e, 0x9d, 0xf4, 0xd9, | |
84 0xbd, 0x37, 0x0f, 0x9d, 0xee, 0xda, 0xe8, 0x88, 0xd0, 0xcc, | |
85 0xa9, 0x1b, 0x8d, 0x11, 0xd0, 0x4c, 0x5e, 0x08, | |
75 }; | 86 }; |
76 | 87 |
77 | 88 |
78 static int fmtProbeMarqPETSCII(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) | 89 static int fmtProbeMarqPETSCII(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) |
79 { | 90 { |
80 (void) fmt; | 91 (void) fmt; |
81 | 92 |
82 if (buf->len == 2098 && | 93 if (buf->len == 2098 && |
83 DM_MEMCMP_SIZE(buf->data, fmtMarqPETSCII_ID1) == 0 && | 94 DM_MEMCMP_SIZE(buf->data, fmtMarqPETSCII_ID1) == 0 && |
84 DM_MEMCMP_SIZE(buf->data + 0x1f, fmtMarqPETSCII_ID2) == 0 | 95 DM_MEMCMP_SIZE(buf->data + sizeof(fmtMarqPETSCII_ID1) + |
96 sizeof(fmtMarqPETSCII_ID2), fmtMarqPETSCII_ID3) == 0 | |
85 ) | 97 ) |
86 return DM_PROBE_SCORE_MAX; | 98 return DM_PROBE_SCORE_MAX; |
87 | 99 |
88 return DM_PROBE_SCORE_FALSE; | 100 return DM_PROBE_SCORE_FALSE; |
89 } | 101 } |
90 | 102 |
91 | 103 |
92 static int fmtSetMarqPETSCIIData(const DMC64EncDecOp *op, DMC64Image *img, | 104 static int fmtGetMarqPETSCIIData(const DMC64EncDecOp *op, DMC64Image *img, |
93 const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt) | 105 const DMGrowBuf *buf, const DMC64ImageCommonFormat *fmt) |
94 { | 106 { |
95 (void) op; | 107 (void) op; |
96 (void) buf; | 108 (void) buf; |
97 (void) fmt; | 109 (void) fmt; |
104 return DMERR_INVALID_DATA; | 116 return DMERR_INVALID_DATA; |
105 } | 117 } |
106 | 118 |
107 img->extraInfo[D64_EI_MODE] = D64_FMT_HIRES | D64_FMT_CHAR; | 119 img->extraInfo[D64_EI_MODE] = D64_FMT_HIRES | D64_FMT_CHAR; |
108 img->extraInfo[D64_EI_CHAR_CUSTOM] = 0; | 120 img->extraInfo[D64_EI_CHAR_CUSTOM] = 0; |
121 | |
122 return DMERR_OK; | |
123 } | |
124 | |
125 | |
126 static int fmtSetMarqPETSCIIData(const DMC64EncDecOp *op, DMGrowBuf *buf, | |
127 const DMC64Image *img, const DMC64ImageCommonFormat *fmt) | |
128 { | |
129 (void) op; | |
130 (void) img; | |
131 (void) fmt; | |
132 Uint8 val; | |
133 | |
134 switch (img->extraInfo[D64_EI_CHAR_CASE]) | |
135 { | |
136 case 0: val = 20; break; | |
137 case 1: val = 23; break; | |
138 default: return DMERR_INVALID_DATA; | |
139 } | |
140 | |
141 img->extraData[0].data[0] = val; | |
142 | |
143 memcpy(buf->data, | |
144 fmtMarqPETSCII_ID1, sizeof(fmtMarqPETSCII_ID1)); | |
145 | |
146 memcpy(buf->data + sizeof(fmtMarqPETSCII_ID1), | |
147 fmtMarqPETSCII_ID2, sizeof(fmtMarqPETSCII_ID2)); | |
148 | |
149 memcpy(buf->data + sizeof(fmtMarqPETSCII_ID1) + sizeof(fmtMarqPETSCII_ID2), | |
150 fmtMarqPETSCII_ID3, sizeof(fmtMarqPETSCII_ID3)); | |
109 | 151 |
110 return DMERR_OK; | 152 return DMERR_OK; |
111 } | 153 } |
112 | 154 |
113 | 155 |
2543 fmtDecodeCosmosDesignsHiresManagerPacked, NULL, | 2585 fmtDecodeCosmosDesignsHiresManagerPacked, NULL, |
2544 { }, &dmC64CommonFormats[8] | 2586 { }, &dmC64CommonFormats[8] |
2545 }, | 2587 }, |
2546 | 2588 |
2547 { | 2589 { |
2548 "mrqp", "Marq's PETSCII editor (unpacked)", 0x0801, 0, DM_FMT_RD, | 2590 "mrqp", "Marq's PETSCII editor (unpacked)", 0x0801, 0, DM_FMT_RDWR, |
2549 fmtProbeMarqPETSCII, | 2591 fmtProbeMarqPETSCII, |
2550 NULL, NULL, | 2592 NULL, NULL, |
2551 { | 2593 { |
2552 D64_FMT_HIRES | D64_FMT_CHAR, | 2594 D64_FMT_HIRES | D64_FMT_CHAR, |
2553 D64_SCR_WIDTH , D64_SCR_HEIGHT, | 2595 D64_SCR_WIDTH , D64_SCR_HEIGHT, |
2554 D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT, | 2596 D64_SCR_CH_WIDTH, D64_SCR_CH_HEIGHT, |
2555 1, 1, | 2597 1, 1, |
2556 NULL, NULL, | 2598 NULL, NULL, |
2557 NULL, | 2599 NULL, |
2558 { | 2600 { |
2559 { DO_COPY , DS_SCREEN_RAM , 0x60 , 0, 0, 0, NULL, NULL, DF_NORMAL }, | |
2560 { DO_COPY , DS_COLOR_RAM , 0x60 + 1000, 0, 0, 0, NULL, NULL, DF_NORMAL }, | |
2561 | |
2562 // For offset values see petscii/m_c64.pde :: save_prg() | 2601 // For offset values see petscii/m_c64.pde :: save_prg() |
2602 { DO_FUNC , 0 , 0 , 0, 0, 0, NULL, fmtSetMarqPETSCIIData, DF_NORMAL }, | |
2603 { DO_COPY , DS_SCREEN_RAM , 0x60 , 0, 0, 0, NULL, NULL, DF_NORMAL }, | |
2604 { DO_COPY , DS_COLOR_RAM , 0x60 + 1000,0,0, 0, NULL, NULL, DF_NORMAL }, | |
2563 { DO_SET_MEM_LO , DS_D020 , 25 - 2, 0, 0, 0, NULL, NULL, DF_NORMAL }, | 2605 { DO_SET_MEM_LO , DS_D020 , 25 - 2, 0, 0, 0, NULL, NULL, DF_NORMAL }, |
2564 { DO_SET_MEM_LO , DS_BGCOL , 30 - 2, 0, 0, 0, NULL, NULL, DF_NORMAL }, | 2606 { DO_SET_MEM_LO , DS_BGCOL , 30 - 2, 0, 0, 0, NULL, NULL, DF_NORMAL }, |
2565 { DO_COPY , DS_EXTRA_DATA , 20 - 2, 0, 1, 0, NULL, NULL, DF_NORMAL }, | 2607 { DO_COPY , DS_EXTRA_DATA , 20 - 2, 0, 1, 0, NULL, NULL, DF_NORMAL }, |
2566 { DO_FUNC , 0 , 0 , 0, 0, 0, fmtSetMarqPETSCIIData, NULL, DF_NORMAL }, | 2608 { DO_FUNC , 0 , 0 , 0, 0, 0, fmtGetMarqPETSCIIData, NULL, DF_NORMAL }, |
2567 | 2609 |
2568 { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL, DF_NORMAL }, | 2610 { DO_LAST , 0 , 0 , 0, 0, 0, NULL, NULL, DF_NORMAL }, |
2569 } | 2611 } |
2570 }, | 2612 }, |
2571 NULL | 2613 NULL |