accept any filename, filter by file type and length instead

This commit is contained in:
4am 2018-03-22 15:55:12 -04:00
parent 3dbc9db268
commit af95bb615a
2 changed files with 25 additions and 19 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.DS_Store .DS_Store
/build/ /build/
/bin/V2Make.scpt

View File

@ -5,13 +5,15 @@
; DHRSLIDE.SYSTEM ; DHRSLIDE.SYSTEM
; (c) 2018 by 4am ; (c) 2018 by 4am
; a small DHGR graphics slideshow ; a small DHGR graphics slideshow
; loads first .a2fc file in current directory, ; loads first double hi-res graphics file (*) in current directory,
; displays it, ; displays it,
; waits, ; waits,
; finds next .a2fc file in same directory, ; finds next suitable file in same directory,
; repeats endlessly until keypress, ; repeats endlessly until keypress,
; quits via MLI ; quits via MLI
; ;
; (*) a double hi-res graphics file has type $06 (BIN) and length $4000
;
; known bugs: ; known bugs:
; - does not reconnect /RAM properly, not sure why ; - does not reconnect /RAM properly, not sure why
; ;
@ -222,23 +224,22 @@ GoToNextEntry
beq GoToNextEntry ; skip inactive entry beq GoToNextEntry ; skip inactive entry
cmp #$D0 cmp #$D0
beq GoToNextEntry ; skip subdirectory beq GoToNextEntry ; skip subdirectory
ldy #$00 ldy #$10
lda (entry), y ; get filename length lda (entry), y
and #$0F
sta (entry), y ; store actual length so we can use this as a length-prefixed string later
cmp #$06 cmp #$06
bcc GoToNextEntry ; filename not long enough, skip entry bne GoToNextEntry ; BIN files only
tay ldy #$15
ldx #$04 lda (entry), y
- lda (entry), y bne GoToNextEntry ; wrong size (must be exactly $4000)
cmp suffix, x ; match required suffix ('.A2FC') ldy #$17
bne GoToNextEntry ; no match, skip entry lda (entry), y
bne GoToNextEntry ; wrong size
dey dey
dex lda (entry), y
bpl - cmp #$40
lda #TRUE bne GoToNextEntry ; wrong size
sta foundAtLeastOne
jsr DisplayFile jsr DisplayFile
; wait loop that exits immediately on keypress
lda #$00 lda #$00
ldy #$15 ldy #$15
.wait0 sec .wait0 sec
@ -252,7 +253,7 @@ GoToNextEntry
bne .wait1 bne .wait1
dey dey
bpl .wait0 bpl .wait0
bmi GoToNextEntry bmi GoToNextEntry ; always branches
CloseAll CloseAll
lda #$00 lda #$00
@ -329,6 +330,10 @@ CheckFor128K
!source "fizzledhgr.a" !source "fizzledhgr.a"
DisplayFile DisplayFile
ldy #$00
lda (entry), y ; get storage type / filename length combination byte
and #$0F ; trim storage type
sta (entry), y ; store actual length so we can use this as a length-prefixed string
lda entry lda entry
sta mliparam+1 ; (entry) points to filename in aDirData sta mliparam+1 ; (entry) points to filename in aDirData
lda entry+1 lda entry+1
@ -385,6 +390,8 @@ copyb sta $FF00, y ; self-modified address
ldy #kMLICloseCount ldy #kMLICloseCount
ldx #FALSE ldx #FALSE
jsr CallMLI jsr CallMLI
lda #TRUE
sta foundAtLeastOne
jmp Fizzle ; fancy memory copy from page 2 to 1 jmp Fizzle ; fancy memory copy from page 2 to 1
CallRAMDriver CallRAMDriver
@ -408,7 +415,5 @@ saveDirRefnum
!byte $00 !byte $00
saveFileRefnum saveFileRefnum
!byte $00 !byte $00
suffix
!text ".A2FC"
} }
CodeEnd CodeEnd