diff options
author | B. Watson <urchlay@slackware.uk> | 2022-11-16 04:00:54 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2022-11-16 04:00:54 -0500 |
commit | 439448f01820445bb42354b7e781c46cfed87f82 (patch) | |
tree | 67c4dbf6c619bbb4d66a71cf2081e2d2fd30c534 | |
parent | bd5f42cd72a25d82e5e9f5f88967e50bc09549a6 (diff) | |
download | dla-asm-439448f01820445bb42354b7e781c46cfed87f82.tar.gz |
enhance autorun.sys.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | autorun.s | 117 | ||||
-rw-r--r-- | autorun.sys | bin | 1172 -> 1338 bytes | |||
-rw-r--r-- | dla.atr | bin | 92176 -> 92176 bytes |
4 files changed, 86 insertions, 33 deletions
@@ -41,7 +41,7 @@ dla2csv.xex: dla2csv.c dlaver.h $(CL65) $(CL65FLAGS) -t atari -W -unused-param -m dla2csv.map --start-addr 0x2800 -o $@ dla2csv.c autorun.sys: autorun.s about.dat - $(CL65) $(CL65FLAGS) -l about.list -t none -o autorun.sys autorun.s + $(CL65) $(CL65FLAGS) -l autorun.list -t none -o autorun.sys autorun.s about.dat: text2screen.pl ABOUT.txt perl text2screen.pl < ABOUT.txt > about.dat @@ -1,3 +1,13 @@ +; autorun.s - display an intro screen and a menu from which the user +; can launch dla.xex or dla2csv.xex, or exit to DOS. + +; I was *going* to write this in C, using cc65's exec()... but it +; turns out to only be implemented on XDOS, which is a rather uncommon +; DOS. MyDOS has XIO 40 (execute binary file), which is a lot easier +; to deal with in asm. Other DOSes might support XIO 40, and/or this +; might support other DOSes someday... Or I could write my own xex +; file loader (rather not). + .include "atari.inc" .include "xex.inc" @@ -8,19 +18,24 @@ old_sdlstl: .res 1 old_sdlsth: .res 1 old_color2: .res 1 old_color1: .res 1 +keycode: .res 1 .code + ; this doesn't have to be aligned on a 4K boundary, but it should + ; be aligned to 1K. loadaddr = $3000 xex_org loadaddr screendata: - .incbin "about.dat" + .incbin "about.dat" ; generated from ABOUT.txt, by text2screen.pl + ; 960 bytes is exactly one GR.0 screen (40x24) .if ((* - screendata) <> 960) .error .sprintf("%c*** about.dat is %d bytes (should be 960)", 10, * - screendata) .endif + ; bog-standard GRAPHICS 0 display list (except the LMS address) dlist: .byte DL_BLK8, DL_BLK8, DL_BLK8 .byte DL_CHR40x8x1 | DL_LMS @@ -31,14 +46,22 @@ dlist: .byte DL_JVB .word dlist + .if ((* / 1024) <> (screendata / 1024)) + .error .sprintf("%c*** screendata and dlist cross a 1K boundary!", 10) + .endif + + .include "io.s" + .include "printint.s" + main: ; fix things so the Reset key doesn't do a coldstart, see ; BOOT? and COLDST in Mapping. - lda #0 - sta COLDST - lda #1 - sta BOOTQ + ldx #0 + stx COLDST + inx + stx BOOTQ + ; save the OS's colors and display list. lda SDLSTL sta old_sdlstl lda SDLSTH @@ -48,6 +71,7 @@ main: lda COLOR2 sta old_color2 + ; use our own colors and display list (displays our message). lda #$90 sta COLOR2 lda #$0e @@ -57,14 +81,19 @@ main: lda #>dlist sta SDLSTH -loop: - ldx CH - cpx #$ff - beq loop + ; wait for a keypress +keyloop: + lda CH + cmp #KEY_NONE + beq keyloop + + sta keycode ; got a keypress, save it for later + ; clear keypress so the loaded program won't see it lda #$ff sta CH + ; restore OS's colors and display list (back to regular E:) lda old_sdlstl sta SDLSTL lda old_sdlsth @@ -74,48 +103,72 @@ loop: lda old_color2 sta COLOR2 - cpx #KEY_1 - bne not_1 + ; see what key was hit ldy #0 - beq setup_iocb - -not_1: - cpx #KEY_2 - bne not_2 - ldy #1 - bne setup_iocb - -not_2: - ; 3, or actually any other key - rts - -setup_iocb: - ldx #$10 - lda #$28 ; MyDOS XIO 40 +keytabloop: + lda keytab,y ; get table entry + cmp #KEY_NONE ; did we hit the end of the table with no match? + beq exit ; yes, we're done + cmp keycode ; no, see if this table entry matches + beq load_file ; yes, use it + iny ; no, look at next entry + bne keytabloop ; branch always + + ; load and run the file (Y is index into filename table) +load_file: + ldx #$10 ; IOCB #1 + lda #$28 ; MyDOS XIO 40. 39 also works (same thing?), neither works on SDX sta ICCOM,x - lda fntab_l,y + lda fntab_l,y ; filename sta ICBAL,x lda fntab_h,y sta ICBAH,x - lda fnlentab,y + lda fnlentab,y ; filename length sta ICBLL,x lda #0 sta ICBLH,x - jsr CIOV + jsr CIOV ; pull the trigger ; CIOV should never return on success, so if we get here, give up. - lda #0 - sta COLOR2 -hang: jmp hang + tya + pha ; save CIO return status (aka error number) + lda #<diskerrmsg + ldx #>diskerrmsg + jsr printmsg ; print error message + pla + jsr printdecb ; print error number + lda #<presskeymsg + ldx #>presskeymsg + jsr printmsg ; press a key... + + ; wait for a keypress, to give the user a chance to read the + ; error message. +keyloop2: + lda CH + cmp #KEY_NONE + beq keyloop2 + lda #KEY_NONE + sta CH +exit: rts dla_filename: .byte "D:DLA.XEX" dla_fn_len = * - dla_filename + csv_filename: .byte "D:DLA2CSV.XEX" csv_fn_len = * - csv_filename +; these tables only have 2 entries, but could have many more if +; we ever need them (up to 255). fntab_l: .byte <dla_filename, <csv_filename fntab_h: .byte >dla_filename, >csv_filename + fnlentab: .byte dla_fn_len, csv_fn_len +; KEY_NONE marks the end of this table. +keytab: .byte KEY_1, KEY_2, KEY_NONE + +diskerrmsg: .byte "I/O Error ",0 +presskeymsg: .byte $9b,"Press any key...",0 + xex_run main diff --git a/autorun.sys b/autorun.sys Binary files differBinary files differindex b3a58f9..ab38cae 100644 --- a/autorun.sys +++ b/autorun.sys |