From 1487b28f5044881aa9b2cc6522170b41e47f5c5b Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Mon, 12 Mar 2018 14:16:24 -0700 Subject: [PATCH] make .sav file optional, warn if missing --- src/onbeyond/z4/z4.s | 61 ++++++++++++++++++++++++++++++++++++++----- src/onbeyond/z5/z5.s | 62 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 110 insertions(+), 13 deletions(-) diff --git a/src/onbeyond/z4/z4.s b/src/onbeyond/z4/z4.s index c05f0f0..ba2c834 100644 --- a/src/onbeyond/z4/z4.s +++ b/src/onbeyond/z4/z4.s @@ -40,7 +40,7 @@ tmp = $8 ;seeking with aligned_read=1 requires non-zero offset check_chksum = 0 ;set to 1 to enforce checksum verification for floppies allow_subdir = 0 ;set to 1 to allow opening subdirectories to access files - might_exist = 0 ;set to 1 if file is not known to always exist already + might_exist = 1 ;set to 1 if file is not known to always exist already ;makes use of status to indicate success or failure allow_aux = 0 ;set to 1 to allow read/write directly to/from aux memory ;requires load_high to be set for arbitrary memory access @@ -451,7 +451,17 @@ skipupper sta hddsavetreelo lda hddgametreehi sta hddsavetreehi - dec $2006 + + ;disable save if no .sav file exists + + lda status + beq + + lda #$38 ;sec + sta $300 + lda #$60 ;rts + sta $301 + ++ dec $2006 ldy $2006 lda #'4' sta $2006,y @@ -485,12 +495,28 @@ brand jsr $dbda lda #>brandtext ldx #nosave + ldx #(hdddirbuf - 1) @@ -527,7 +559,16 @@ hddfirstent lda #NAME_LENGTH hddnextent1 inc blokhi hddnextent ldy #0 - !if allow_trees = 1 { + !if (might_exist + allow_trees) > 0 { + lda (bloklo), y + !if might_exist = 1 { + sty status + + ;skip deleted entries without counting + + and #MASK_ALL + beq + + } ;might_exist lda (bloklo), y ;remember type @@ -542,7 +583,7 @@ hddnextent ldy #0 sta adrhi bit adrhi php - } ;allow_trees + } ;might_exist or allow_trees ;match name lengths before attempting to match names @@ -553,11 +594,19 @@ hddnextent ldy #0 - cmp $2006, y beq hddfoundname + ;match failed, check if any directory entries remain + !if allow_trees = 1 { plp } ;allow_trees + !if might_exist = 1 { + dec entries + bne + + inc status + rts + } ;might_exist - ;match failed, move to next directory in this block, if possible + ;move to next directory in this block, if possible + clc lda bloklo diff --git a/src/onbeyond/z5/z5.s b/src/onbeyond/z5/z5.s index 8390efe..f533f0b 100644 --- a/src/onbeyond/z5/z5.s +++ b/src/onbeyond/z5/z5.s @@ -40,7 +40,7 @@ tmp = $8 ;seeking with aligned_read=1 requires non-zero offset check_chksum = 0 ;set to 1 to enforce checksum verification for floppies allow_subdir = 0 ;set to 1 to allow opening subdirectories to access files - might_exist = 0 ;set to 1 if file is not known to always exist already + might_exist = 1 ;set to 1 if file is not known to always exist already ;makes use of status to indicate success or failure allow_aux = 0 ;set to 1 to allow read/write directly to/from aux memory ;requires load_high to be set for arbitrary memory access @@ -406,7 +406,6 @@ skipupper sta $915 + - ldy #quit_e-waitkey - lda hookquit-1, y sta waitkey-1, y @@ -447,7 +446,17 @@ skipupper sta hddsavetreelo lda hddgametreehi sta hddsavetreehi - dec $2006 + + ;disable save if no .sav file exists + + lda status + beq + + lda #$38 ;sec + sta $300 + lda #$60 ;rts + sta $301 + ++ dec $2006 ldy $2006 lda #'5' sta $2006,y @@ -481,12 +490,28 @@ brand jsr $db5b lda #>brandtext ldx #nosave + ldx #(hdddirbuf - 1) @@ -523,7 +554,16 @@ hddfirstent lda #NAME_LENGTH hddnextent1 inc blokhi hddnextent ldy #0 - !if allow_trees = 1 { + !if (might_exist + allow_trees) > 0 { + lda (bloklo), y + !if might_exist = 1 { + sty status + + ;skip deleted entries without counting + + and #MASK_ALL + beq + + } ;might_exist lda (bloklo), y ;remember type @@ -538,7 +578,7 @@ hddnextent ldy #0 sta adrhi bit adrhi php - } ;allow_trees + } ;might_exist or allow_trees ;match name lengths before attempting to match names @@ -549,11 +589,19 @@ hddnextent ldy #0 - cmp $2006, y beq hddfoundname + ;match failed, check if any directory entries remain + !if allow_trees = 1 { plp } ;allow_trees + !if might_exist = 1 { + dec entries + bne + + inc status + rts + } ;might_exist - ;match failed, move to next directory in this block, if possible + ;move to next directory in this block, if possible + clc lda bloklo