open and prefix

This commit is contained in:
Joshua Bell 2017-12-09 14:28:54 -08:00
parent dd6a4b319e
commit 714c796605

79
b.s
View File

@ -96,17 +96,16 @@ L2000: jmp install_and_quit
mark_ref_num := $61 mark_ref_num := $61
mark_position := $62 ; 3-bytes mark_position := $62 ; 3-bytes
next_device := $65 ; next device number to try next_device_num := $65 ; next device number to try
current_entry := $67 ; index of current entry current_entry := $67 ; index of current entry
num_entries := $68 ; length of |filenames| num_entries := $68 ; length of |filenames|
curr_len := $69 ; length of current entry name curr_len := $69 ; length of current entry name
curr_ptr := $6C ; address of current entry name (in |filenames|) curr_ptr := $6C ; address of current entry name (in |filenames|)
page_start := $73 ; index of first entry shown on screen page_start := $73 ; index of first entry shown on screen
prefix_depth := $6B ; 0 = root
max_entries := 128 ; max # of entries; more are ignored max_entries := 128 ; max # of entries; more are ignored
types_table := $74 ; high bit clear = dir, set = sys types_table := $74 ; high bit clear = dir, set = sys
@ -140,47 +139,53 @@ L2000: jmp install_and_quit
lda #2 lda #2
sta $60 sta $60
ldx DEVCNT ; max device num ldx DEVCNT ; max device num
stx next_device stx next_device_num
lda DEVNUM lda DEVNUM
bne L1042 bne check_device
check_device: next_device:
ldx next_device ldx next_device_num
lda DEVLST,x lda DEVLST,x
cpx #1 cpx #1
bcs :+ bcs :+
ldx DEVCNT ldx DEVCNT
inx inx
: dex : dex
stx next_device stx next_device_num
L1042: sta on_line_params_unit check_device:
sta on_line_params_unit
MLI_CALL ON_LINE, on_line_params MLI_CALL ON_LINE, on_line_params
bcs check_device bcs next_device
stz $6B stz prefix_depth
lda prefix+1 lda prefix+1
and #$0F and #$0F
beq check_device beq next_device
adc #$02 adc #$02
tax tax
L1059: stx prefix ; truncate prefix to length x ;; Resize prefix to length x and open the directory for reading
resize_prefix_and_open:
stx prefix
lda #'/' lda #'/'
sta prefix+1 sta prefix+1
sta prefix,x sta prefix,x
stz prefix+1,x stz prefix+1,x
MLI_CALL OPEN, open_params MLI_CALL OPEN, open_params
bcc L107F bcc :+
lda $6B
beq check_device ;; Open failed
jsr BELL1 lda prefix_depth ; root?
jsr L11DA beq next_device
jsr BELL1 ; no, but failed; beep
jsr pop_prefix ; and go up a level
stx prefix stx prefix
jmp keyboard_loop jmp keyboard_loop
L107F: inc $6B ; ??? ;; Open succeeded
: inc prefix_depth
stz num_entries stz num_entries
lda open_params_ref_num lda open_params_ref_num
sta read_params_ref_num sta read_params_ref_num
@ -215,7 +220,7 @@ L10B9: lda mark_position+1
bcc L10CE bcc L10CE
tay tay
sty $72 sty $72
inc mark+position+1 inc mark_position+1
L10CC: inc mark_position+1 L10CC: inc mark_position+1
L10CE: dey L10CE: dey
clc clc
@ -258,7 +263,7 @@ L1115: lda read_buffer,y
sta (curr_ptr),y sta (curr_ptr),y
inc num_entries inc num_entries
bne L10B5 bne L10B5
L1126: jmp check_device L1126: jmp next_device
finish_read: finish_read:
MLI_CALL CLOSE, close_params MLI_CALL CLOSE, close_params
@ -378,28 +383,34 @@ draw_current_line_inv:
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
.proc on_escape .proc on_escape
jsr L11DA jsr pop_prefix ; leaves length in X
dec $6B dec prefix_depth
bra L11F1 bra resize_prefix_and_open_jmp
.endproc .endproc
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
L11DA: ldx prefix ;; Remove level from prefix; returns new length in X
L11DD: dex .proc pop_prefix
ldx prefix
loop: dex
lda prefix,x lda prefix,x
cmp #'/' cmp #'/'
bne L11DD bne loop
cpx #$01 cpx #$01
bne L11EC bne done
ldx prefix ldx prefix
L11EC: rts done: rts
.endproc
next_drive: next_drive:
jmp check_device jmp next_device
L11F0: inx dec_resize_prefix_and_open:
L11F1: jmp L1059 inx
resize_prefix_and_open_jmp:
jmp resize_prefix_and_open
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
@ -420,7 +431,7 @@ L11F1: jmp L1059
ldy current_entry ldy current_entry
lda types_table,y lda types_table,y
bpl L11F0 ; is directory??? bpl dec_resize_prefix_and_open ; is directory???
;; nope, system file, so... ;; nope, system file, so...
;; fall through ;; fall through