aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2022-11-14 20:09:31 -0500
committerB. Watson <urchlay@slackware.uk>2022-11-14 20:09:31 -0500
commit6fab50c592c77c890f45c283813f451f22156dc0 (patch)
treebe969412aa4043f2bbfaa44a02893e8c3a6e1c7e
parent36dcaa5343f1abbf76df9e34f25a61d322eb9388 (diff)
downloaddla-asm-6fab50c592c77c890f45c283813f451f22156dc0.tar.gz
dla.xex: add quit option, play nicer with various DOSes.
-rw-r--r--dla.s98
-rw-r--r--dla.xexbin4696 -> 4953 bytes
2 files changed, 85 insertions, 13 deletions
diff --git a/dla.s b/dla.s
index 627ebe9..750682e 100644
--- a/dla.s
+++ b/dla.s
@@ -12,7 +12,11 @@
.include "xex.inc"
.include "nextpage.inc"
- loadaddr = $2000
+ ; This used to be $2000, which worked fine with DOS 2.0S and
+ ; Sparta 3.2d. But there's no reason to make it that low, and
+ ; making it higher lets it work with more memory-hungry DOSes.
+ loadaddr = $2a00
+
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
@@ -50,6 +54,9 @@ spawn_y: .res 2
old_dma: .res 1 ; these 3 are for restoring GR.0 mode
old_dl: .res 2
old_savmsc: .res 2
+old_color0: .res 1
+old_color1: .res 1
+old_color2: .res 1
cloksav: .res 3 ; hold RTCLOK here while we convert to MM:SS.CC
fptmp: .res 6 ; used in mmss.s
@@ -59,9 +66,19 @@ po_line = fptmp ; used by prepare_output
;;; init xex segment: check that there's enough memory.
xex_org lowcode
+ rts ; this is here for DOS XL
.include "io.s" ; printchrx and getchrx
.include "printint.s"
+ ; If memcheck doesn't see >=48K of RAM, abort loading.
+ ; The only 2 ways I know of for an init segment of a xex file
+ ; to abort loading to rest of the file are jmp (DOSVEC) and jmp
+ ; WARMST. An rts just continues the load. Closing IOCB #1, then doing
+ ; an rts, causes the Atari to lock up. Of the two, jumping though
+ ; DOSVEC seems more polite to the user: It returns to the DOS menu.
+ ; With a non-DOS setup ("atari800 dla.xex" or "atariserver dla.xex"),
+ ; it ends up at the self-test menu (from which, Reset will get him
+ ; back to BASIC, if it's enabled).
memcheck:
lda RAMTOP
cmp #$c0 ; 48K
@@ -77,7 +94,7 @@ memcheck:
ldx #>memmsg2
jsr printmsg
jsr getchr ; wait for user to press a key
- jmp WARMSV ; get outta here (simulate Reset keypress)
+ jmp (DOSVEC) ; get outta here (back to DOS)
mem_ok:
rts
@@ -90,6 +107,7 @@ memmsg2: .byte "K.",$9b,"Disable BASIC, remove cartridge?",$9b
;;; main xex segment: the actual program. the functions in io.s
;;; and printint.s are still in low memory.
xex_org loadaddr
+ rts ; this is here for DOS XL
.include "mmss.s"
; init stuff gets done once, at startup
@@ -99,6 +117,7 @@ init:
sta LMARGN
lda SDMCTL
sta old_dma
+
lda SDLSTL
sta old_dl
lda SDLSTH
@@ -108,6 +127,13 @@ init:
lda SAVMSC+1
sta old_savmsc+1
+ lda COLOR0
+ sta old_color0
+ lda COLOR1
+ sta old_color1
+ lda COLOR2
+ sta old_color2
+
; set default particles (if user just hits return)
lda #<DEFAULTPART
sta maxparticles
@@ -119,43 +145,56 @@ init:
getargs:
jsr restore_gr0
- ; print banner and prompt.
printbanner:
lda #<banner
ldx #>banner
jsr printmsg
+ ; prompt for # of particles.
+prompt4part:
+ lda #<partprompt
+ ldx #>partprompt
+ jsr printmsg
+
lda maxparticles
ldx maxparticles+1
jsr printdecw
- lda #<partprompt
- ldx #>partprompt
+ lda #<partprompt2
+ ldx #>partprompt2
jsr printmsg
; use CIO to read input, so user can use backspace/etc.
jsr readline
- lda linebuf
; check for error (user hit Break or Ctrl-3 for EOF).
cpy #1
- bne printbanner
+ bne prompt4part
+
+ lda linebuf ; look at first character entered
; if user hit Return by itself, use the old value.
cmp #$9b
beq prompt4seed
+ ora #$20 ; ignore case...
+ cmp #'q' ; Q means Quit.
+ bne convinput
+
+ jsr confirm_quit ; this doesn't return, if the user quits.
+
+convinput:
; use floating point ROM to convert input to an integer.
lda #0
sta CIX
jsr AFP ; ASCII to floating point, result in FR0
- bcs printbanner ; C set means error (negative or >65535)
+ bcs prompt4part ; C set means error (negative or >65535)
jsr FPI ; convert FR0 to integer (result in FR0)
- bcs printbanner
+ bcs prompt4part
lda FR0
tax
ora FR0+1 ; we don't accept 0 for an answer!
- beq printbanner
+ beq prompt4part
lda FR0+1
stx maxparticles
sta maxparticles+1
@@ -696,17 +735,43 @@ close1:
sta ICCOM,x
jmp CIOV
+;;; Subroutine: confirm_quit
+confirm_quit:
+ lda #<exit_prog_msg
+ ldx #>exit_prog_msg
+ jsr printmsg
+ jsr getchr
+ ora #$20 ; ignore case, Y or y
+ cmp #'y'
+ beq quit
+ rts ; user changed his mind
+
+quit:
+ ; user wants to quit.
+ ; before we bail out, restore the console colors. this won't
+ ; matter for DOS 2 style DOSes, but it will for Sparta.
+ lda old_color0
+ sta COLOR0
+ lda old_color1
+ sta COLOR1
+ lda old_color2
+ sta COLOR2
+ ; exit, stage left.
+ jmp (DOSVEC)
+
;;;;; end of executable code, data tables from here on out.
; prompts.
; banner and saveprompt must start with a clear-screen code.
banner:
.byte $7d, "Diffusion Limited Aggregate",$9b
- .byte "Urchlay's ASM version ",VERSION,$9b,$9b
- .byte "Particle count range: 1 to 65535",$9b
- .byte "How many particles [",$0
+ .byte "Urchlay's ASM version ",VERSION,$9b,$0
partprompt:
+ .byte $9b,"Particle count range: 1 to 65535",$9b
+ .byte "How many particles [",$0
+
+partprompt2:
.byte "]? ",$0
seedprompt:
@@ -738,6 +803,9 @@ menumsg:
.byte ' ','N'|$80,"ew? "
.byte 0
+exit_prog_msg:
+ .byte "Exit program[y/N]? ", 0
+
; jump table for seed functions
seeds_l: .byte <(seed_point-1),<(seed_plus-1),<(seed_4pt-1),<(seed_long-1)
seeds_h: .byte >(seed_point-1),>(seed_plus-1),>(seed_4pt-1),>(seed_long-1)
@@ -765,6 +833,10 @@ lineaddrs_h:
laddr .set laddr + 170
.endrep
+ .if dlist < *
+ .error .sprintf("main program too long, %d byte overlap with dlist", * - dlist)
+ .endif
+
;;; display list
; ANTIC opcodes
blank8 = $70
diff --git a/dla.xex b/dla.xex
index 78fd3ca..3fdc643 100644
--- a/dla.xex
+++ b/dla.xex
Binary files differ