aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2022-10-31 19:14:13 -0400
committerB. Watson <urchlay@slackware.uk>2022-10-31 19:14:13 -0400
commit6972583ba8a6ef5f949891e283b3a1061d580434 (patch)
treee876fb9047a9683d41d368ddac764a53f94c8f7c
parentcd88b74b498f8559c1eca20139e43543086c9c4c (diff)
downloaddla-asm-6972583ba8a6ef5f949891e283b3a1061d580434.tar.gz
Update README, close IOCB before open, "Saved OK" prompt.
-rw-r--r--README.txt9
-rw-r--r--dla.s33
2 files changed, 31 insertions, 11 deletions
diff --git a/README.txt b/README.txt
index 7bae9a2..c0d1e11 100644
--- a/README.txt
+++ b/README.txt
@@ -54,9 +54,12 @@ After the image is finished generating, the screen DMA will be turned
back on, so you can see it. The bottom line shows a menu, from which you
can choose to:
-- Save: Save the image to disk, with the (hard-coded) filename D:DLA.IMG.
- The file will be the raw pixels, 8 per byte, 256 pixels (32 bytes) per
- line.
+- Save: Save the image to disk. You'll be prompted for a filename, which
+ must be a complete filespec (examples: D:TEST.DLA, D2:THING.DLA).
+ The file will be the raw pixels, 8 per byte, 256 pixels (32 bytes)
+ per line, 192 lines. Size will be 6144 bytes, or 50 sectors on a
+ single-density disk. If an error happens while saving, you'll get
+ the chance to retry the save.
- Redo: Run the generation process again, with the current particle count
and seed type settings.
diff --git a/dla.s b/dla.s
index 3388f6a..c4aaaa9 100644
--- a/dla.s
+++ b/dla.s
@@ -293,6 +293,8 @@ saveimage:
jsr printmsg ; ...prompt for, and...
jsr readline ; ...let the user type a filename.
+ jsr close1 ; make sure the IOCB is closed before we open it!
+
; CIO is nice, but it's kind of a PITA to use...
; OPEN #1,8,0,<filename>
ldx #$10
@@ -312,10 +314,10 @@ saveimage:
lda #8
sta ICAX1,x
jsr CIOV
- cpy #1
+ cpy #1 ; CIO returns with Y=1 for success.
bne save_error
- ; write data to file
+ ; write data to the channel
ldx #$10
lda #$0b ; write binary record
sta ICCOM,x
@@ -331,15 +333,19 @@ saveimage:
cpy #1
bne save_error
- ; CLOSE #1
- ldx #$10
- lda #$0c ; close
- sta ICCOM,x
- jsr CIOV
+ ; close the channel
+ jsr close1
cpy #1
bne save_error
+
+ ; let the user know the save worked.
+ lda #<saveokmsg
+ ldx #>saveokmsg
+ jsr printmsg
+ jsr getchr ; any key
jmp getargs
+ ; print error message, prompt for retry.
save_error:
tya
pha
@@ -353,7 +359,7 @@ save_error:
jsr printmsg
get_retry_key:
jsr getchr
- cmp #$9b
+ cmp #$9b ; return = yes
beq jsaveimage
and #$5f ; ignore case
cmp #'Y'
@@ -705,6 +711,14 @@ restore_gr0:
sta SAVMSC+1
rts
+;;; Subroutine: close1
+;;; Closes IOCB 1, same as CLOSE #1 in BASIC.
+close1:
+ ldx #$10
+ lda #$0c ; close
+ sta ICCOM,x
+ jmp CIOV
+
;;;;; end of executable code, data tables from here on out.
; prompts.
@@ -727,6 +741,9 @@ seedprompt2:
saveprompt:
.byte $7d, "Save: Enter filename, including Dn:",$9b,"> ",$0
+saveokmsg:
+ .byte "Saved OK, press any key...",$0
+
diskerrmsg:
.byte "I/O Error ",$0