diff options
Diffstat (limited to 'dla2csv.c')
-rw-r--r-- | dla2csv.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -19,12 +19,12 @@ #include "dlaver.h" #define HEIGHT 170 -#define WIDTH 256 +#define WIDTH 176 /* cc65 doesn't fold constants, it won't let us do this: #define INBUF_SIZE (WIDTH * HEIGHT) ...it has to be a *constant*. */ -#define INBUF_SIZE 5440 +#define INBUF_SIZE 3740 #define STRINGBUF_SIZE 256 @@ -319,15 +319,16 @@ int check_dla(int bytes) { } fclose(inf); - /* a DLA file never has non-zero bytes at the beginning. */ - for(i = 0; i < 32; i++) { - if(inbuf[i]) { + /* a DLA file never has non-zero pixels in the first 3 columns */ + for(i = 0; i < INBUF_SIZE; i += (WIDTH / 8)) { + if(inbuf[i] & 0xe0) { printf("Warning: File doesn't look like a DLA!\n"); ok = 0; break; } } + return ok; } @@ -377,7 +378,7 @@ int convert(char *eol) { for(y = 0; y < HEIGHT; y++) { #ifdef __ATARI__ /* check for ^C */ - if(OS.ch == KEY_C | KEY_CTRL) { + if(OS.ch == (KEY_C | KEY_CTRL)) { printf("\nUser abort!\n"); fclose(outf); remove(stringbuf); @@ -389,6 +390,12 @@ int convert(char *eol) { printf("%02d%%", y * 100 / HEIGHT); /* percentage */ fflush(stdout); for(x = 0; x < WIDTH; x++) { + /* slight optimization, saves ~12 sec (30% speedup) on Atari */ + if(!*inp) { + inp++; + x += 7; + continue; + } if(*inp & xmask) { if(fprintf(outf, "%d,%d%s", x, y, eol) < 0) { putchar('\n'); |