From 9a2f5f4c83201c193dd1029aeca04cff44574e60 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 13 Nov 2022 17:18:21 -0500 Subject: v0.3.0: save files are now 176x170. --- Makefile | 2 +- README.txt | 6 +++--- VERSION | 2 +- dla.s | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ dla.xex | Bin 4696 -> 4696 bytes dla2csv.c | 19 +++++++++++++------ dla2csv.xex | Bin 11297 -> 11338 bytes dla2img.sh | 6 +++--- dlaver.h | 2 +- dlaver.inc | 2 +- 10 files changed, 70 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index ef1876a..fdede2c 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ dlatbl.s: mkdlatbl.pl dlaver.h: mkver.pl VERSION $(PERL) mkver.pl -dla2csv: dla2csv.c +dla2csv: dla2csv.c dlaver.h @echo $(CC) $(CFLAGS) -o dla2csv dla2csv.c ; \ $(CC) $(CFLAGS) -o dla2csv dla2csv.c \ || echo "Couldn't build host dla2csv; continuing without it" diff --git a/README.txt b/README.txt index 75af7f1..a7a744e 100644 --- a/README.txt +++ b/README.txt @@ -71,8 +71,8 @@ The bottom line shows a menu, from which you can choose to: - Save: Save the image to disk. You'll be prompted for a filename. If you don't include a drive spec (e.g. D: or D2:), drive 1 (D:) is assumed. Emulator users can use the H: drive here. - The file will contain the raw pixels, 8 per byte, 256 pixels (32 - bytes) per line, 170 lines. Size will be 5440 bytes, or 44 sectors + The file will contain the raw pixels, 8 per byte, 176 pixels (22 + bytes) per line, 170 lines. Size will be 3740 bytes, or 30 sectors on a single-density disk. If an error happens while saving, you'll get the chance to retry the save. @@ -102,7 +102,7 @@ Next, you're asked for the output filename[*]. This file will be overwritten if it exists (unless of course it can't be overwritten due to permissions or the Atari locked-file bit). -Next, the conversion process starts. This takes about one minute on +Next, the conversion process starts. This takes about half a minute on the Atari, and is instantaneous on a modern machine. Progress is shown as a percentage. When it's finished, the output CSV file has been written. On the Atari, you can press Ctrl-C during the conversion to diff --git a/VERSION b/VERSION index 0c62199..0d91a54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +0.3.0 diff --git a/dla.s b/dla.s index 5126b50..f08084f 100644 --- a/dla.s +++ b/dla.s @@ -16,6 +16,7 @@ lowcode = $0600 ; memcheck and io.s screen = $4000 ; must be on a x000 (4K) boundary screen2 = screen + $1000 ; rest of screen RAM after 4K boundary + savebuf = screen + $6000 ; prepare_output pixarray = screen + $20 linelen = $20 ; aka 32 bytes, antic F (GR.8) in narrow mode. maxlines = $aa ; 170 lines of display @@ -52,6 +53,7 @@ old_savmsc: .res 2 cloksav: .res 3 ; hold RTCLOK here while we convert to MM:SS.CC fptmp: .res 6 ; used in mmss.s +po_line = fptmp ; used by prepare_output .code @@ -312,10 +314,10 @@ saveimage: ; prepend D: to the filename, if there's no device given. lda linebuf+1 cmp #':' - beq open_output + beq prepare_output lda linebuf+2 cmp #':' - beq open_output + beq prepare_output ldy ICBLL dloop: @@ -332,6 +334,45 @@ dloop: inc ICBLL inc ICBLL + ; DLA pixel size is 170x170, screen memory is 256x170. only save + ; the middle 22 bytes (176 pixels) of each line. Really only need + ; 170 pixels, but of course we can't save a partial byte... +prepare_output: + lda #screen + sta screenptr+1 + lda #savebuf + sta pixptr+1 + lda #0 + sta po_line +polineloop: + ldy #5 + ldx #0 +poloop: + lda (screenptr),y + sta (pixptr,x) + inc pixptr + bne ppok + inc pixptr+1 +ppok: + iny + cpy #$1b + bne poloop + lda screenptr + clc + adc #$20 + sta screenptr + lda screenptr+1 + adc #0 + sta screenptr+1 + inc po_line + ldx po_line + cpx #maxlines + bne polineloop + open_output: ; CIO is nice, but it's kind of a PITA to use... ; OPEN #1,8,0, @@ -359,13 +400,13 @@ open_output: ldx #$10 lda #$0b ; write binary record sta ICCOM,x - lda #screen + lda #>savebuf sta ICBAH,x - lda #screenbytes + lda #>(maxlines*22) sta ICBLH,x jsr CIOV cpy #1 diff --git a/dla.xex b/dla.xex index b4bf550..d6b762b 100644 Binary files a/dla.xex and b/dla.xex differ diff --git a/dla2csv.c b/dla2csv.c index b66b0a4..5d9c083 100644 --- a/dla2csv.c +++ b/dla2csv.c @@ -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'); diff --git a/dla2csv.xex b/dla2csv.xex index 7bf1527..4809291 100644 Binary files a/dla2csv.xex and b/dla2csv.xex differ diff --git a/dla2img.sh b/dla2img.sh index 808f688..637ee7f 100755 --- a/dla2img.sh +++ b/dla2img.sh @@ -16,7 +16,7 @@ SELF="`basename $0`" # This line may get changed by the Makefile (do not hand-edit): -VERSION=0.2.1 +VERSION=0.3.0 # allow overriding magick path via environment. if [ "$MAGICK" = "" ]; then @@ -24,10 +24,10 @@ if [ "$MAGICK" = "" ]; then fi # only change this if the save file size changes in dla.xex. -SIZE="256x170" +SIZE="176x170" # ...and if you change that, change this too: -FILESIZE="5440" +FILESIZE="3740" INFILE="$1" OUTFILE="$2" diff --git a/dlaver.h b/dlaver.h index cb1ae9a..b3a9dfe 100644 --- a/dlaver.h +++ b/dlaver.h @@ -1 +1 @@ -#define VERSION "0.2.1" +#define VERSION "0.3.0" diff --git a/dlaver.inc b/dlaver.inc index 7f669e7..44f0d63 100644 --- a/dlaver.inc +++ b/dlaver.inc @@ -1 +1 @@ - .define VERSION "0.2.1" + .define VERSION "0.3.0" -- cgit v1.2.3