2018-04-20 04:23:23 +00:00
|
|
|
.setcpu "6502"
|
|
|
|
|
|
|
|
.include "apple2.inc"
|
|
|
|
.include "../inc/apple2.inc"
|
|
|
|
.include "../inc/prodos.inc"
|
|
|
|
.include "../mgtk.inc"
|
|
|
|
.include "../desktop.inc"
|
|
|
|
.include "../macros.inc"
|
|
|
|
|
2018-05-03 03:04:56 +00:00
|
|
|
;;; ============================================================
|
|
|
|
|
2018-04-20 04:23:23 +00:00
|
|
|
.org $800
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
|
2018-06-02 01:52:26 +00:00
|
|
|
dir_data_buffer := $0E00
|
2018-12-28 23:46:09 +00:00
|
|
|
dir_data_buffer_len = $0E00
|
2018-04-21 04:58:15 +00:00
|
|
|
|
2018-04-20 04:23:23 +00:00
|
|
|
;;; ============================================================
|
|
|
|
|
|
|
|
cli
|
|
|
|
jmp start
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
;; unit_num for active window, for block operations
|
|
|
|
unit_num: .byte 0
|
2018-04-20 04:23:23 +00:00
|
|
|
|
|
|
|
save_stack:
|
|
|
|
.byte 0
|
|
|
|
|
|
|
|
;;; ============================================================
|
|
|
|
|
|
|
|
start: tsx
|
|
|
|
stx save_stack
|
2018-04-21 04:58:15 +00:00
|
|
|
jmp start2
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
.proc exit
|
|
|
|
ldx save_stack
|
2018-04-20 04:23:23 +00:00
|
|
|
txs
|
|
|
|
lda a:$0A
|
2018-04-21 04:58:15 +00:00
|
|
|
bne :+
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
: lda #$40
|
2018-04-20 04:23:23 +00:00
|
|
|
pha
|
|
|
|
lda #$0B
|
|
|
|
pha
|
|
|
|
lda a:$0A
|
|
|
|
rts
|
2018-04-21 04:58:15 +00:00
|
|
|
.endproc
|
2018-04-20 04:23:23 +00:00
|
|
|
|
|
|
|
;;; ============================================================
|
|
|
|
;;; ProDOS Relays
|
|
|
|
|
|
|
|
.proc open
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL OPEN, open_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc read
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL READ, read_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc write_block
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL WRITE_BLOCK, block_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc read_block
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL READ_BLOCK, block_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc on_line
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL ON_LINE, on_line_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
.byte 0
|
|
|
|
|
|
|
|
;;; unused ???
|
|
|
|
.proc write
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL WRITE, write_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; unused ???
|
|
|
|
.proc set_mark
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL SET_MARK, set_mark_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; unused ???
|
|
|
|
.proc get_file_info
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL GET_FILE_INFO, file_info_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; unused ???
|
|
|
|
.proc set_file_info
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL SET_FILE_INFO, file_info_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc close
|
|
|
|
sta ALTZPOFF
|
|
|
|
MLI_CALL CLOSE, close_params
|
|
|
|
sta ALTZPON
|
|
|
|
rts
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; ============================================================
|
2018-04-21 04:58:15 +00:00
|
|
|
;;; ProDOS call parameter blocks
|
2018-04-20 04:23:23 +00:00
|
|
|
|
|
|
|
DEFINE_ON_LINE_PARAMS on_line_params,, on_line_buffer
|
|
|
|
on_line_buffer:
|
|
|
|
.res 16, 0
|
|
|
|
|
|
|
|
DEFINE_SET_MARK_PARAMS set_mark_params, $2B
|
|
|
|
DEFINE_READ_BLOCK_PARAMS block_params, 0, 0
|
|
|
|
|
|
|
|
.byte 0
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
io_buf := $1C00
|
2018-06-02 01:52:26 +00:00
|
|
|
buffer := dir_data_buffer
|
2018-12-28 23:46:09 +00:00
|
|
|
buffer_len = dir_data_buffer_len
|
2018-04-21 04:58:15 +00:00
|
|
|
|
|
|
|
DEFINE_OPEN_PARAMS open_params, path_buf, io_buf
|
|
|
|
DEFINE_READ_PARAMS read_params, buffer, buffer_len
|
|
|
|
DEFINE_WRITE_PARAMS write_params, buffer, buffer_len
|
2018-04-20 04:23:23 +00:00
|
|
|
DEFINE_CLOSE_PARAMS close_params
|
|
|
|
|
|
|
|
DEFINE_GET_FILE_INFO_PARAMS file_info_params, path_buf
|
|
|
|
.res 3 ; for SET_FILE_INFO ???
|
|
|
|
|
|
|
|
path_buf:
|
|
|
|
.res 65, 0
|
|
|
|
|
|
|
|
;;; ============================================================
|
2018-04-21 04:58:15 +00:00
|
|
|
;;; Main DA logic
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
.proc start2
|
|
|
|
sta ALTZPON
|
2018-04-20 04:23:23 +00:00
|
|
|
lda LCBANK1
|
|
|
|
lda LCBANK1
|
2018-04-21 04:58:15 +00:00
|
|
|
|
|
|
|
ptr := $0A
|
|
|
|
|
|
|
|
yax_call JUMP_TABLE_MGTK_RELAY, MGTK::FrontWindow, ptr
|
|
|
|
lda ptr ; any window open?
|
|
|
|
beq bail ; nope, bail
|
|
|
|
|
|
|
|
cmp #9 ; DeskTop windows are 1-8
|
|
|
|
bcc has_window
|
|
|
|
bail: jmp exit
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
has_window:
|
|
|
|
|
|
|
|
.scope
|
|
|
|
;; Copy window path to buffer
|
|
|
|
asl a ; window index * 2
|
2018-04-20 04:23:23 +00:00
|
|
|
tay
|
2018-04-21 04:58:15 +00:00
|
|
|
copy16 path_table,y, $06
|
|
|
|
ldy #0
|
|
|
|
sty $10 ; ???
|
2018-04-20 04:23:23 +00:00
|
|
|
lda ($06),y
|
2018-04-21 04:58:15 +00:00
|
|
|
sta len
|
2018-04-20 04:23:23 +00:00
|
|
|
sta path_buf
|
2018-04-21 04:58:15 +00:00
|
|
|
loop: iny
|
2018-04-20 04:23:23 +00:00
|
|
|
lda ($06),y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #CHAR_MASK
|
|
|
|
cmp #'a' ; lower case?
|
|
|
|
bcc :+
|
|
|
|
and #CASE_MASK ; restore to upper-case
|
|
|
|
: sta path_buf,y
|
|
|
|
len := *+1
|
2018-04-20 04:23:23 +00:00
|
|
|
cpy #0
|
2018-04-21 04:58:15 +00:00
|
|
|
bne loop
|
|
|
|
.endscope
|
|
|
|
|
|
|
|
.scope
|
|
|
|
;; Enumerate devices to find unit_num matching path.
|
|
|
|
ldy DEVCNT
|
|
|
|
sty dev_num
|
|
|
|
loop: ldy dev_num
|
|
|
|
lda DEVLST,y
|
|
|
|
and #$F0 ; mask off drive/slot
|
2018-04-20 04:23:23 +00:00
|
|
|
sta on_line_params::unit_num
|
|
|
|
jsr on_line
|
2018-04-21 04:58:15 +00:00
|
|
|
bne next
|
|
|
|
jsr compare_paths_for_unit_num
|
|
|
|
beq found_unit_num
|
|
|
|
next: dec dev_num
|
|
|
|
bpl loop
|
|
|
|
.endscope
|
|
|
|
|
|
|
|
exit1: jmp exit
|
|
|
|
|
|
|
|
found_unit_num:
|
|
|
|
lda on_line_params::unit_num
|
|
|
|
sta unit_num
|
2018-04-20 04:23:23 +00:00
|
|
|
jsr open
|
2018-04-21 04:58:15 +00:00
|
|
|
bne exit1
|
2018-04-20 04:23:23 +00:00
|
|
|
lda open_params::ref_num
|
|
|
|
sta read_params::ref_num
|
|
|
|
sta close_params::ref_num
|
2018-04-21 04:58:15 +00:00
|
|
|
|
|
|
|
;; Read a chunk of the directory
|
2018-04-20 04:23:23 +00:00
|
|
|
jsr read
|
|
|
|
jsr close
|
2018-04-21 04:58:15 +00:00
|
|
|
bne exit1
|
2018-04-20 04:23:23 +00:00
|
|
|
ldx #$02
|
2018-04-21 04:58:15 +00:00
|
|
|
|
|
|
|
L09BC := *+2
|
|
|
|
L09BA: lda buffer + 2
|
|
|
|
|
|
|
|
sta L0A95,x
|
|
|
|
|
|
|
|
L09C2 := *+2
|
|
|
|
lda buffer + 3
|
|
|
|
|
|
|
|
sta L0A95+1,x
|
|
|
|
|
2018-04-20 04:23:23 +00:00
|
|
|
ora L0A95,x
|
|
|
|
beq L09DD
|
|
|
|
inc L09BC
|
|
|
|
inc L09BC
|
|
|
|
inc L09C2
|
|
|
|
inc L09C2
|
|
|
|
inx
|
|
|
|
inx
|
|
|
|
cpx #$0E
|
|
|
|
bne L09BA
|
2018-04-21 04:58:15 +00:00
|
|
|
|
2018-04-20 04:23:23 +00:00
|
|
|
L09DD: txa
|
|
|
|
clc
|
|
|
|
adc #$0E
|
|
|
|
sta L0A93
|
|
|
|
jsr L0B40
|
|
|
|
L09E7: jsr L0B16
|
|
|
|
bcs L0A3B
|
2018-04-21 04:58:15 +00:00
|
|
|
ldy #0
|
2018-04-20 04:23:23 +00:00
|
|
|
lda ($06),y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #STORAGE_TYPE_MASK
|
2018-04-20 04:23:23 +00:00
|
|
|
beq L09E7
|
2018-04-21 04:58:15 +00:00
|
|
|
ldy #SubdirectoryHeader::file_count
|
2018-11-11 04:31:31 +00:00
|
|
|
copy16in ($06),y, L0A95
|
2018-04-20 04:23:23 +00:00
|
|
|
jsr L0AE8
|
2018-04-21 04:58:15 +00:00
|
|
|
lda unit_num
|
2018-04-20 04:23:23 +00:00
|
|
|
sta block_params::unit_num
|
|
|
|
lda #$00
|
|
|
|
sta L0A94
|
|
|
|
L0A0F: lda L0A94
|
|
|
|
asl a
|
|
|
|
tay
|
2018-04-21 04:58:15 +00:00
|
|
|
copy16 L0A95,y, block_params::block_num
|
2018-04-20 04:23:23 +00:00
|
|
|
ora block_params::block_num
|
|
|
|
beq L0A3E
|
|
|
|
tya
|
|
|
|
clc
|
|
|
|
adc #$0E
|
|
|
|
sta block_params::data_buffer+1
|
|
|
|
lda #$00
|
|
|
|
sta block_params::data_buffer
|
|
|
|
jsr write_block
|
|
|
|
bne L0A3B
|
|
|
|
inc L0A94
|
|
|
|
bne L0A0F
|
2018-04-21 04:58:15 +00:00
|
|
|
L0A3B: jmp exit
|
2018-04-20 04:23:23 +00:00
|
|
|
|
|
|
|
L0A3E: copy16 #$1C00, block_params::data_buffer
|
|
|
|
jsr L0B40
|
|
|
|
L0A4B: jsr L0B16
|
|
|
|
bcs L0A8E
|
2018-04-21 04:58:15 +00:00
|
|
|
ldy #0
|
2018-04-20 04:23:23 +00:00
|
|
|
lda ($06),y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #STORAGE_TYPE_MASK
|
2018-04-20 04:23:23 +00:00
|
|
|
beq L0A4B
|
2018-04-21 04:58:15 +00:00
|
|
|
cmp #(ST_LINKED_DIRECTORY << 4)
|
2018-04-20 04:23:23 +00:00
|
|
|
bne L0A4B
|
|
|
|
ldy #$11
|
2018-11-11 04:31:31 +00:00
|
|
|
copy16in ($06),y, block_params::block_num
|
2018-04-20 04:23:23 +00:00
|
|
|
jsr read_block
|
|
|
|
bne L0A8F
|
|
|
|
lda $07
|
|
|
|
sec
|
|
|
|
sbc #$0E
|
|
|
|
and #$FE
|
|
|
|
tay
|
2018-04-21 04:58:15 +00:00
|
|
|
copy16 L0A95,y, $1C27
|
|
|
|
copy L0AAF, $1C29
|
2018-04-20 04:23:23 +00:00
|
|
|
jsr write_block
|
|
|
|
jmp L0A4B
|
|
|
|
|
|
|
|
L0A8E: pla
|
2018-04-21 04:58:15 +00:00
|
|
|
L0A8F: jmp exit
|
|
|
|
|
|
|
|
dev_num:
|
|
|
|
.byte 0
|
2018-04-20 04:23:23 +00:00
|
|
|
|
|
|
|
L0A93: .byte 0
|
|
|
|
L0A94: .byte 0
|
2018-04-21 04:58:15 +00:00
|
|
|
|
|
|
|
L0A95: .res 26, 0
|
|
|
|
|
2018-04-20 04:23:23 +00:00
|
|
|
L0AAF: .byte 0
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
;;; ============================================================
|
|
|
|
;;; Compare path from ON_LINE vs. path from window, since we
|
|
|
|
;;; need unit_num for block operations.
|
|
|
|
|
|
|
|
.proc compare_paths_for_unit_num
|
|
|
|
lda on_line_buffer
|
2018-04-20 04:23:23 +00:00
|
|
|
and #$0F
|
|
|
|
sta on_line_buffer
|
2018-12-06 03:46:29 +00:00
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
ldy #0
|
2018-12-06 03:46:29 +00:00
|
|
|
loop: iny
|
2018-04-20 04:23:23 +00:00
|
|
|
lda on_line_buffer,y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #CHAR_MASK
|
|
|
|
cmp #'a'
|
2018-12-06 03:46:29 +00:00
|
|
|
bcc :+
|
2018-04-21 04:58:15 +00:00
|
|
|
and #CASE_MASK ; make upper-case
|
2018-12-06 03:46:29 +00:00
|
|
|
: cmp path_buf+1,y
|
|
|
|
bne fail
|
2018-04-20 04:23:23 +00:00
|
|
|
cpy on_line_buffer
|
2018-12-06 03:46:29 +00:00
|
|
|
bne loop
|
|
|
|
|
2018-04-20 04:23:23 +00:00
|
|
|
lda on_line_buffer
|
|
|
|
clc
|
|
|
|
adc #$01
|
|
|
|
cmp path_buf
|
2018-12-06 03:46:29 +00:00
|
|
|
beq success
|
2018-04-20 04:23:23 +00:00
|
|
|
lda path_buf+2,y
|
2018-04-21 04:58:15 +00:00
|
|
|
cmp #'/'
|
2018-12-06 03:46:29 +00:00
|
|
|
bne fail
|
|
|
|
success:
|
|
|
|
return #$00
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-12-06 03:46:29 +00:00
|
|
|
fail: return #$FF
|
2018-04-21 04:58:15 +00:00
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; ============================================================
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
.proc L0AE8
|
2018-06-02 01:52:26 +00:00
|
|
|
lda #0
|
2018-04-20 04:23:23 +00:00
|
|
|
sta L0B15
|
|
|
|
jsr L0B40
|
|
|
|
jsr L0B16
|
2018-12-06 03:46:29 +00:00
|
|
|
loop: copy16 $06, $08
|
2018-04-20 04:23:23 +00:00
|
|
|
jsr L0B16
|
2018-12-06 03:46:29 +00:00
|
|
|
bcs done
|
2018-06-02 01:52:26 +00:00
|
|
|
jsr compare_file_entries
|
2018-12-06 03:46:29 +00:00
|
|
|
bcc loop
|
2018-04-21 04:58:15 +00:00
|
|
|
jsr swap_entries
|
2018-04-20 04:23:23 +00:00
|
|
|
lda #$FF
|
|
|
|
sta L0B15
|
2018-12-06 03:46:29 +00:00
|
|
|
bne loop
|
|
|
|
done: lda L0B15
|
2018-04-20 04:23:23 +00:00
|
|
|
bne L0AE8
|
|
|
|
rts
|
|
|
|
|
|
|
|
L0B15: .byte 0
|
2018-04-21 04:58:15 +00:00
|
|
|
.endproc
|
2018-04-20 04:23:23 +00:00
|
|
|
|
|
|
|
;;; ============================================================
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
.proc L0B16
|
|
|
|
ptr := $06
|
|
|
|
|
|
|
|
inc L0AAF
|
|
|
|
lda ptr
|
2018-04-20 04:23:23 +00:00
|
|
|
clc
|
2018-04-21 04:58:15 +00:00
|
|
|
adc #.sizeof(FileEntry)
|
|
|
|
sta ptr
|
|
|
|
bcc :+
|
|
|
|
inc ptr+1
|
|
|
|
|
|
|
|
: lda ptr
|
2018-04-20 04:23:23 +00:00
|
|
|
cmp #$FF
|
2018-04-21 04:58:15 +00:00
|
|
|
bne rtcc
|
|
|
|
inc ptr+1
|
|
|
|
lda #1
|
2018-04-20 04:23:23 +00:00
|
|
|
sta L0AAF
|
2018-04-21 04:58:15 +00:00
|
|
|
lda #$04 ; skip over block header ???
|
|
|
|
sta ptr
|
|
|
|
lda ptr+1
|
2018-04-20 04:23:23 +00:00
|
|
|
cmp L0A93
|
2018-04-21 04:58:15 +00:00
|
|
|
bcs rtcs
|
|
|
|
|
|
|
|
rtcc: clc
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
rtcs: sec
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
2018-04-21 04:58:15 +00:00
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; ============================================================
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-06-02 01:52:26 +00:00
|
|
|
L0B40: lda #1
|
2018-04-20 04:23:23 +00:00
|
|
|
sta L0AAF
|
2018-06-02 01:52:26 +00:00
|
|
|
copy16 #dir_data_buffer + 4, $06
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
;;; ============================================================
|
|
|
|
;;; Swap file entries
|
|
|
|
|
|
|
|
.proc swap_entries
|
|
|
|
ptr1 := $06
|
|
|
|
ptr2 := $08
|
|
|
|
|
|
|
|
ldy #.sizeof(FileEntry) - 1
|
|
|
|
loop: lda (ptr1),y
|
2018-04-20 04:23:23 +00:00
|
|
|
pha
|
2018-04-21 04:58:15 +00:00
|
|
|
lda (ptr2),y
|
|
|
|
sta (ptr1),y
|
2018-04-20 04:23:23 +00:00
|
|
|
pla
|
2018-04-21 04:58:15 +00:00
|
|
|
sta (ptr2),y
|
2018-04-20 04:23:23 +00:00
|
|
|
dey
|
2018-04-21 04:58:15 +00:00
|
|
|
bpl loop
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
2018-04-21 04:58:15 +00:00
|
|
|
.endproc
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
;;; ============================================================
|
2018-06-02 01:52:26 +00:00
|
|
|
;;; Compare file entries ($06, $08); order returned in carry.
|
|
|
|
|
|
|
|
;;; Uses compare_selection_orders, compare_file_entry_names,
|
|
|
|
;;; and compare_entry_types_and_names as appropriate.
|
2018-04-21 04:58:15 +00:00
|
|
|
|
2018-06-02 01:52:26 +00:00
|
|
|
.proc compare_file_entries
|
2018-04-21 04:58:15 +00:00
|
|
|
ptr1 := $06
|
|
|
|
ptr2 := $08
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
lda (ptr1),y
|
|
|
|
and #STORAGE_TYPE_MASK ; Active file entry?
|
2018-06-02 01:52:26 +00:00
|
|
|
bne :+
|
2018-04-21 04:58:15 +00:00
|
|
|
jmp rtcc
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-06-02 01:52:26 +00:00
|
|
|
: lda (ptr2),y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #STORAGE_TYPE_MASK ; Active file entry?
|
2018-06-02 01:52:26 +00:00
|
|
|
bne :+
|
2018-04-21 04:58:15 +00:00
|
|
|
jmp rtcs
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-06-02 01:52:26 +00:00
|
|
|
: lda selected_file_count
|
|
|
|
beq :+
|
2018-04-21 04:58:15 +00:00
|
|
|
lda path_index
|
2018-06-02 01:52:26 +00:00
|
|
|
beq :+
|
2018-05-26 16:53:55 +00:00
|
|
|
jmp compare_selection_orders
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-06-02 01:52:26 +00:00
|
|
|
: ldax ptr2
|
2018-04-21 04:58:15 +00:00
|
|
|
jsr check_system_file
|
|
|
|
bcc rtcc
|
|
|
|
|
|
|
|
ldax ptr1
|
|
|
|
jsr check_system_file
|
|
|
|
bcc rtcs
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
lda (ptr2),y
|
|
|
|
and #STORAGE_TYPE_MASK
|
|
|
|
sta storage_type2
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
lda (ptr1),y
|
|
|
|
and #STORAGE_TYPE_MASK
|
|
|
|
sta storage_type1
|
|
|
|
|
|
|
|
;; Why does this dir-first comparison not just use FT_DIRECTORY ???
|
|
|
|
|
|
|
|
;; Is #2 a dir?
|
|
|
|
lda storage_type2
|
|
|
|
cmp #(ST_LINKED_DIRECTORY << 4)
|
|
|
|
beq dirs ; yep, check #1
|
|
|
|
|
|
|
|
;; Is #1 a dir?
|
|
|
|
lda storage_type1
|
|
|
|
cmp #(ST_LINKED_DIRECTORY << 4)
|
|
|
|
beq rtcs ; yep, but 2 wasn't, so order
|
|
|
|
bne check_types ; neither are dirs - check types
|
|
|
|
|
|
|
|
;; #2 was a dir - is #1?
|
|
|
|
dirs: lda storage_type1
|
|
|
|
cmp #(ST_LINKED_DIRECTORY << 4)
|
|
|
|
bne rtcc
|
|
|
|
|
|
|
|
;; Both are dirs, order by name
|
|
|
|
jsr compare_file_entry_names
|
|
|
|
bcc rtcc
|
|
|
|
bcs rtcs
|
|
|
|
|
|
|
|
;; TXT files first
|
|
|
|
check_types:
|
|
|
|
lda #FT_TEXT
|
|
|
|
jsr compare_entry_types_and_names
|
|
|
|
bne :+
|
|
|
|
bcc rtcc
|
|
|
|
bcs rtcs
|
|
|
|
|
|
|
|
;; SYS files next
|
|
|
|
: lda #FT_SYSTEM
|
|
|
|
jsr compare_entry_types_and_names
|
|
|
|
bne :+
|
|
|
|
bcc rtcc
|
|
|
|
bcs rtcs
|
|
|
|
|
|
|
|
;; Then order by type from $FD down
|
|
|
|
: lda #$FD
|
|
|
|
sta type
|
|
|
|
loop: dec type
|
|
|
|
lda type
|
|
|
|
beq rtcc
|
|
|
|
jsr compare_entry_types_and_names
|
|
|
|
bne loop
|
|
|
|
bcs rtcs
|
|
|
|
jmp rtcc
|
|
|
|
|
|
|
|
rtcs: sec
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
rtcc: clc
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
storage_type2:
|
|
|
|
.byte 0
|
|
|
|
storage_type1:
|
|
|
|
.byte 0
|
|
|
|
type: .byte 0
|
|
|
|
.endproc
|
2018-04-20 04:23:23 +00:00
|
|
|
|
|
|
|
;;; ============================================================
|
2018-05-26 16:53:55 +00:00
|
|
|
;;; Compare selection order of icons; order returned in carry.
|
|
|
|
;;; Handles either icon being not selected.
|
|
|
|
|
|
|
|
.proc compare_selection_orders
|
|
|
|
entry_ptr := $10
|
|
|
|
filename := $06
|
|
|
|
filename2 := $08
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
ldx selected_file_count
|
2018-05-26 16:53:55 +00:00
|
|
|
loop: dex
|
2018-06-02 01:52:26 +00:00
|
|
|
bmi done1
|
2018-05-26 16:53:55 +00:00
|
|
|
|
|
|
|
;; Look up next icon, compare length.
|
2018-04-21 04:58:15 +00:00
|
|
|
lda selected_file_list,x
|
2018-04-20 04:23:23 +00:00
|
|
|
asl a
|
|
|
|
tay
|
2018-05-26 16:53:55 +00:00
|
|
|
add16 file_table,y, #IconEntry::len, entry_ptr
|
|
|
|
ldy #0
|
|
|
|
lda (entry_ptr),y
|
2018-04-20 04:23:23 +00:00
|
|
|
sec
|
2018-05-26 16:53:55 +00:00
|
|
|
sbc #2 ; remove leading/trailing space
|
|
|
|
sta cmp_len
|
|
|
|
inc16 entry_ptr ; points at start of name
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-05-26 16:53:55 +00:00
|
|
|
lda (filename),y
|
|
|
|
and #NAME_LENGTH_MASK
|
|
|
|
cmp_len := *+1
|
|
|
|
cmp #0
|
|
|
|
bne loop ; lengths don't match, so not a match
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-05-26 16:53:55 +00:00
|
|
|
;; Bytewise compare names.
|
|
|
|
sta cpy_len
|
|
|
|
next: iny ; skip leading space
|
|
|
|
lda (entry_ptr),y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #CHAR_MASK
|
|
|
|
cmp #'a'
|
2018-05-26 16:53:55 +00:00
|
|
|
bcc :+
|
|
|
|
and #CASE_MASK ; make upper-case
|
|
|
|
: sta cmp_char
|
|
|
|
lda (filename),y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #CHAR_MASK
|
|
|
|
cmp #'a'
|
2018-05-26 16:53:55 +00:00
|
|
|
bcc :+
|
|
|
|
and #CASE_MASK ; make upper-case
|
|
|
|
cmp_char := *+1
|
|
|
|
: cmp #0
|
|
|
|
bne loop ; no match - try next icon
|
|
|
|
cpy_len := *+1
|
2018-04-20 04:23:23 +00:00
|
|
|
cpy #0
|
2018-05-26 16:53:55 +00:00
|
|
|
bne next
|
|
|
|
|
2018-06-02 01:52:26 +00:00
|
|
|
done1: stx match ; match, or $FF if none
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
ldx selected_file_count
|
2018-05-26 16:53:55 +00:00
|
|
|
loop2: dex
|
2018-06-02 01:52:26 +00:00
|
|
|
bmi done2
|
2018-05-26 16:53:55 +00:00
|
|
|
|
|
|
|
;; Look up next icon, compare length.
|
2018-04-21 04:58:15 +00:00
|
|
|
lda selected_file_list,x
|
2018-04-20 04:23:23 +00:00
|
|
|
asl a
|
|
|
|
tay
|
2018-05-26 16:53:55 +00:00
|
|
|
add16 file_table,y, #IconEntry::len, entry_ptr
|
|
|
|
ldy #0
|
|
|
|
lda (entry_ptr),y ; len
|
2018-04-20 04:23:23 +00:00
|
|
|
sec
|
2018-05-26 16:53:55 +00:00
|
|
|
sbc #2 ; remove leading/trailing space
|
|
|
|
sta cmp_len2
|
|
|
|
inc16 entry_ptr ; points at start of name
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-05-26 16:53:55 +00:00
|
|
|
lda (filename2),y
|
|
|
|
and #NAME_LENGTH_MASK
|
|
|
|
cmp_len2 := *+1
|
2018-04-20 04:23:23 +00:00
|
|
|
cmp #0
|
2018-05-26 16:53:55 +00:00
|
|
|
bne loop2 ; lengths don't match, so not a match
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-05-26 16:53:55 +00:00
|
|
|
;; Bytewise compare names.
|
|
|
|
sta cpy_len2
|
|
|
|
next2: iny
|
|
|
|
lda (entry_ptr),y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #CHAR_MASK
|
|
|
|
cmp #'a'
|
2018-05-26 16:53:55 +00:00
|
|
|
bcc :+
|
|
|
|
and #CASE_MASK ; make upper-case
|
|
|
|
: sta cmp_char2
|
|
|
|
lda (filename2),y
|
2018-04-21 04:58:15 +00:00
|
|
|
and #CHAR_MASK
|
|
|
|
cmp #'a'
|
2018-05-26 16:53:55 +00:00
|
|
|
bcc :+
|
|
|
|
and #CASE_MASK ; make upper-case
|
|
|
|
cmp_char2 := *+1
|
|
|
|
: cmp #0
|
|
|
|
bne loop2 ; no match - try next icon
|
|
|
|
cpy_len2 := *+1
|
2018-04-20 04:23:23 +00:00
|
|
|
cpy #0
|
2018-05-26 16:53:55 +00:00
|
|
|
bne next2
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-06-02 01:52:26 +00:00
|
|
|
done2: stx match2 ; match, or $FF if none
|
2018-05-26 16:53:55 +00:00
|
|
|
|
|
|
|
lda match
|
|
|
|
and match2
|
|
|
|
cmp #$FF ; if either didn't match
|
|
|
|
beq clear
|
|
|
|
lda match2
|
|
|
|
cmp match
|
|
|
|
beq clear ; if they're the same
|
|
|
|
rts ; otherwise carry is order
|
2018-04-20 04:23:23 +00:00
|
|
|
|
2018-05-26 16:53:55 +00:00
|
|
|
;; No match
|
2018-04-20 04:23:23 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2018-05-26 16:53:55 +00:00
|
|
|
clear: clc
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-05-26 16:53:55 +00:00
|
|
|
match: .byte 0
|
|
|
|
match2: .byte 0
|
2018-04-21 04:58:15 +00:00
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; ============================================================
|
|
|
|
;;; Compare file types/names ($06, $08 = ptrs, A=type)
|
|
|
|
;;;
|
|
|
|
;;; Output: A=$FF if neither matches type; A=$00 and carry is order
|
|
|
|
|
|
|
|
.proc compare_entry_types_and_names
|
|
|
|
ptr1 := $06
|
|
|
|
ptr2 := $08
|
|
|
|
max_length := 16
|
|
|
|
|
|
|
|
sta type0
|
|
|
|
|
|
|
|
ldy #max_length
|
|
|
|
lda (ptr2),y
|
|
|
|
sta type2
|
|
|
|
lda (ptr1),y
|
|
|
|
sta type1
|
|
|
|
|
|
|
|
lda type2
|
|
|
|
cmp type0
|
|
|
|
beq :+
|
|
|
|
|
|
|
|
lda type1
|
|
|
|
cmp type0
|
|
|
|
beq rtcs
|
|
|
|
|
|
|
|
bne neither
|
|
|
|
|
|
|
|
: lda type1
|
|
|
|
cmp type0
|
|
|
|
bne rtcc
|
|
|
|
jsr compare_file_entry_names
|
|
|
|
bcc rtcc
|
|
|
|
bcs rtcs
|
|
|
|
|
|
|
|
neither:
|
|
|
|
return #$FF
|
|
|
|
|
|
|
|
type2: .byte 0
|
|
|
|
type1: .byte 0
|
|
|
|
|
|
|
|
rtcc: lda #0
|
2018-04-20 04:23:23 +00:00
|
|
|
clc
|
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
rtcs: lda #0
|
2018-04-20 04:23:23 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
type0: .byte 0
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; ============================================================
|
|
|
|
;;; Is the file entry a SYS file with .SYSTEM suffix?
|
|
|
|
;;; Returns carry clear if true, set if false.
|
|
|
|
|
|
|
|
.proc check_system_file
|
|
|
|
ptr := $00
|
|
|
|
|
|
|
|
;; Check for SYS
|
|
|
|
stax ptr
|
|
|
|
ldy #FileEntry::file_type
|
|
|
|
lda (ptr),y
|
|
|
|
cmp #$FF ; type=SYS
|
|
|
|
bne fail
|
|
|
|
|
|
|
|
;; Could name end in .SYSTEM?
|
|
|
|
ldy #FileEntry::storage_type_name_length
|
|
|
|
lda (ptr),y
|
|
|
|
and #NAME_LENGTH_MASK
|
2018-04-20 04:23:23 +00:00
|
|
|
sec
|
2018-04-21 04:58:15 +00:00
|
|
|
sbc #.strlen(".SYSTEM")-1
|
|
|
|
bcc fail ; too short
|
2018-04-20 04:23:23 +00:00
|
|
|
tay
|
2018-04-21 04:58:15 +00:00
|
|
|
|
|
|
|
;; Check name suffix
|
|
|
|
ldx #0
|
2018-04-20 04:23:23 +00:00
|
|
|
dey
|
2018-04-21 04:58:15 +00:00
|
|
|
loop: iny
|
2018-04-20 04:23:23 +00:00
|
|
|
inx
|
2018-04-21 04:58:15 +00:00
|
|
|
lda (ptr),y
|
|
|
|
and #CHAR_MASK
|
|
|
|
cmp str_system,x
|
|
|
|
bne fail
|
|
|
|
cpx str_system
|
|
|
|
bne loop
|
|
|
|
|
2018-04-20 04:23:23 +00:00
|
|
|
clc
|
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
fail: sec
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
str_system:
|
|
|
|
PASCAL_STRING ".SYSTEM"
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
;;; ============================================================
|
|
|
|
;;; Compare file entry names; carry indicates order
|
|
|
|
|
|
|
|
.proc compare_file_entry_names
|
|
|
|
ptr1 := $06
|
|
|
|
ptr2 := $08
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
lda (ptr2),y
|
|
|
|
and #NAME_LENGTH_MASK
|
|
|
|
sta len2
|
|
|
|
|
|
|
|
sta len
|
|
|
|
lda (ptr1),y
|
|
|
|
and #NAME_LENGTH_MASK
|
|
|
|
sta len1
|
|
|
|
cmp len
|
|
|
|
bcs :+
|
|
|
|
sta len
|
|
|
|
|
|
|
|
: ldy #0
|
|
|
|
loop: iny
|
|
|
|
lda (ptr2),y
|
|
|
|
cmp (ptr1),y
|
|
|
|
beq next
|
|
|
|
bcc rtcc
|
|
|
|
rtcs: sec
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
len := *+1
|
|
|
|
next: cpy #0
|
|
|
|
|
|
|
|
bne loop
|
|
|
|
lda len2
|
|
|
|
cmp len1
|
|
|
|
beq rtcc
|
|
|
|
bcs rtcs
|
|
|
|
rtcc: clc
|
2018-04-20 04:23:23 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-21 04:58:15 +00:00
|
|
|
len2: .byte 0
|
|
|
|
len1: .byte 0
|
|
|
|
|
|
|
|
.endproc
|