comparison tools/gfxconv.c @ 1545:3b613fcbf3ff

Improve how format read/write capabilities are marked and shown.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 12 May 2018 21:01:46 +0300
parents 416d7b3ba3b2
children 228e71d66089
comparison
equal deleted inserted replaced
1544:48823642c4fb 1545:3b613fcbf3ff
47 47
48 typedef struct 48 typedef struct
49 { 49 {
50 char *name; // Descriptive name of the format 50 char *name; // Descriptive name of the format
51 char *fext; // File extension 51 char *fext; // File extension
52 BOOL in, out; // Can read/write? 52 int flags; // DM_FMT_* flags, see libgfx.h
53 int format; // Format identifier 53 int format; // Format identifier
54 int subformat; // Subformat identifier 54 int subformat; // Subformat identifier
55 } DMConvFormat; 55 } DMConvFormat;
56 56
57 57
58 static DMConvFormat convFormatList[] = 58 static DMConvFormat convFormatList[] =
59 { 59 {
60 { 60 { "ASCII text" , "asc" , DM_FMT_WR , FFMT_ASCII , 0 },
61 "ASCII text", "asc", FALSE, TRUE, 61 { "ANSI colored text" , "ansi" , DM_FMT_WR , FFMT_ANSI , 0 },
62 FFMT_ASCII , 0, 62 { "PNG image" , "png" , DM_FMT_RDWR , FFMT_IMAGE , DM_IMGFMT_PNG },
63 }, 63 { "PPM image" , "ppm" , DM_FMT_WR , FFMT_IMAGE , DM_IMGFMT_PPM },
64 { 64 { "PCX image" , "pcx" , DM_FMT_RDWR , FFMT_IMAGE , DM_IMGFMT_PCX },
65 "ANSI colored text", "ansi", FALSE, TRUE, 65 { "IFF ILBM" , "lbm" , DM_FMT_RD , FFMT_IMAGE , DM_IMGFMT_ILBM },
66 FFMT_ANSI , 0, 66 { "Bitplaned RAW (intl/non-intl) image" , "raw" , DM_FMT_WR , FFMT_IMAGE , DM_IMGFMT_RAW },
67 }, 67 { "IFFMaster RAW image" , "araw" , DM_FMT_WR , FFMT_IMAGE , DM_IMGFMT_ARAW },
68 { 68 { "C64 bitmap image" , NULL , DM_FMT_RDWR , FFMT_BITMAP , -1 },
69 "PNG image file", "png", TRUE, TRUE, 69 { "C64 character/font data" , "chr" , DM_FMT_RDWR , FFMT_CHAR , 0 },
70 FFMT_IMAGE , DM_IMGFMT_PNG, 70 { "C64 sprite data" , "spr" , DM_FMT_RDWR , FFMT_SPRITE , 0 },
71 },
72 {
73 "PPM image file", "ppm", FALSE, TRUE,
74 FFMT_IMAGE , DM_IMGFMT_PPM,
75 },
76 {
77 "PCX image file", "pcx", TRUE, TRUE,
78 FFMT_IMAGE , DM_IMGFMT_PCX,
79 },
80 {
81 "IFF ILBM file", "lbm", TRUE, FALSE,
82 FFMT_IMAGE , DM_IMGFMT_ILBM,
83 },
84 {
85 "Bitplaned RAW (intl/non-intl) image file", "raw", FALSE, TRUE,
86 FFMT_IMAGE , DM_IMGFMT_RAW,
87 },
88 {
89 "IFFMaster RAW image file", "araw", FALSE, TRUE,
90 FFMT_IMAGE , DM_IMGFMT_ARAW,
91 },
92
93 {
94 "C64 bitmap image file", NULL, TRUE, TRUE,
95 FFMT_BITMAP , -1,
96 },
97
98 {
99 "C64 character/font data", "chr", TRUE, TRUE,
100 FFMT_CHAR , 0
101 },
102 {
103 "C64 sprite data", "spr", TRUE, TRUE,
104 FFMT_SPRITE , 0
105 },
106 }; 71 };
107 72
108 static const int nconvFormatList = sizeof(convFormatList) / sizeof(convFormatList[0]); 73 static const int nconvFormatList = sizeof(convFormatList) / sizeof(convFormatList[0]);
109 74
110 75
178 static const int optListN = sizeof(optList) / sizeof(optList[0]); 143 static const int optListN = sizeof(optList) / sizeof(optList[0]);
179 144
180 145
181 void argShowFormats() 146 void argShowFormats()
182 { 147 {
183
184 printf( 148 printf(
185 "Available input/output formats:\n" 149 "Available input/output formats (-f <frmt>):\n"
186 " Ext | I | O | Description\n" 150 " frmt | RW | Description\n"
187 "------+---+---+-----------------------------------------------\n" 151 "------+----+-------------------------------------------------------\n"
188 ); 152 );
189 153
190 for (int i = 0; i < nconvFormatList; i++) 154 for (int i = 0; i < nconvFormatList; i++)
191 { 155 {
192 DMConvFormat *fmt = &convFormatList[i]; 156 const DMConvFormat *fmt = &convFormatList[i];
193 printf("%-5s | %c | %c | %s\n", 157 printf("%-5s | %c%c | %s\n",
194 fmt->fext ? fmt->fext : "", 158 fmt->fext ? fmt->fext : "",
195 fmt->in ? 'X' : ' ', 159 (fmt->flags & DM_FMT_RD) ? 'R' : ' ',
196 fmt->out ? 'X' : ' ', 160 (fmt->flags & DM_FMT_WR) ? 'W' : ' ',
197 fmt->name); 161 fmt->name);
198 } 162 }
199 163
200 printf( 164 printf(
201 "\n" 165 "\n"
202 "(Not all input->output combinations are actually supported.)\n" 166 "(Not all input->output combinations are actually supported.)\n"
203 "\n" 167 "\n"
204 "Available bitmap formats (-f <bfrm>):\n" 168 "Available C64 bitmap formats (-f <bfrm>):\n"
205 " bfrm | Type | Description\n" 169 " frmt | RW | Type | Description\n"
206 "------+-----------------+-------------------------------------\n" 170 "------+----+-----------------+-------------------------------------\n"
207 ); 171 );
208 172
209 for (int i = 0; i < ndmC64ImageFormats; i++) 173 for (int i = 0; i < ndmC64ImageFormats; i++)
210 { 174 {
211 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; 175 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
212 char buf[64]; 176 char buf[64];
213 printf("%-5s | %-15s | %s\n", 177 printf("%-5s | %c%c | %-15s | %s\n",
214 fmt->fext, 178 fmt->fext,
179 (fmt->flags & DM_FMT_RD) ? 'R' : ' ',
180 (fmt->flags & DM_FMT_WR) ? 'W' : ' ',
215 dmC64GetImageTypeString(buf, sizeof(buf), fmt->type, FALSE), 181 dmC64GetImageTypeString(buf, sizeof(buf), fmt->type, FALSE),
216 fmt->name); 182 fmt->name);
217 } 183 }
218 } 184 }
219 185