a2d/desktop.system/desktop.system.s

2100 lines
48 KiB
ArmAsm
Raw Normal View History

2018-03-03 03:56:39 +00:00
.setcpu "6502"
.org $2000
2018-03-03 04:06:58 +00:00
.include "apple2.inc"
.include "../inc/apple2.inc"
.include "../inc/prodos.inc"
2018-03-03 03:57:30 +00:00
.include "../macros.inc"
2018-03-04 19:35:04 +00:00
;;; ============================================================
2018-03-07 02:36:51 +00:00
.proc copy_desktop_to_ramcard
2018-03-03 04:06:58 +00:00
2018-03-04 20:04:29 +00:00
jmp start
2018-03-03 04:06:58 +00:00
2018-03-04 20:04:29 +00:00
;;; ============================================================
;;; Data buffers and param blocks
2018-03-03 03:56:39 +00:00
2018-03-04 05:33:40 +00:00
date: .word 0 ; written into file
2018-03-03 04:53:10 +00:00
L2005:
2018-03-04 20:04:29 +00:00
.res 832, 0
2018-03-03 04:53:10 +00:00
2018-03-04 19:35:04 +00:00
.byte $02,$00
2018-03-04 20:04:29 +00:00
.addr L2363
2018-03-04 03:43:41 +00:00
2018-03-07 16:12:30 +00:00
path_buf := $D00
2018-03-04 03:43:41 +00:00
.proc get_prefix_params2
2018-03-04 19:35:04 +00:00
param_count: .byte 2 ; GET_PREFIX, but param_count is 2 ??? Bug???
2018-03-07 16:12:30 +00:00
data_buffer: .addr path_buf
2018-03-04 03:43:41 +00:00
.endproc
2018-03-07 16:12:30 +00:00
DEFINE_GET_FILE_INFO_PARAMS get_file_info_params4, path_buf
2018-03-04 19:35:04 +00:00
.byte $00,$01
2018-03-04 20:04:29 +00:00
.addr L2362
2018-03-15 03:16:15 +00:00
L2362: .byte 0
2018-03-05 03:38:55 +00:00
L2363: .res 15, 0
2018-03-06 05:20:00 +00:00
butn1: .byte 0 ; written, but not read
2018-03-05 03:38:55 +00:00
unit_num:
2018-03-06 05:20:00 +00:00
.byte 0
2018-03-03 17:04:07 +00:00
2018-03-04 19:35:04 +00:00
DEFINE_ON_LINE_PARAMS on_line_params,, on_line_buffer
2018-03-03 17:04:07 +00:00
2018-03-05 03:38:55 +00:00
copy_flag:
.byte 0
2018-03-04 20:04:29 +00:00
L2379: .byte 0
2018-03-04 19:35:04 +00:00
on_line_buffer: .res 17, 0
2018-03-03 17:04:07 +00:00
2018-03-06 05:20:00 +00:00
DEFINE_GET_PREFIX_PARAMS get_prefix_params, buffer
2018-03-05 03:38:55 +00:00
DEFINE_SET_PREFIX_PARAMS set_prefix_params, path0
2018-03-04 19:35:04 +00:00
2018-03-03 17:04:07 +00:00
.byte $0A
2018-03-04 20:04:29 +00:00
.addr L2379
2018-03-04 19:35:04 +00:00
.byte $00,$00,$00,$00,$00,$00
2018-03-03 03:56:39 +00:00
.byte $00,$00,$00,$00,$00,$00,$00,$00
2018-03-04 19:35:04 +00:00
.byte $00,$00,$00
.byte $07,$60,$2B,$C3,$0F
2018-03-03 03:56:39 +00:00
.byte $00,$00,$0D,$00,$00,$00,$00,$04
.byte $00,$00,$03,$00,$01,$00,$00,$01
.byte $00,$03,$F5,$26,$00,$08,$00,$04
2018-03-04 19:35:04 +00:00
.byte $00
2018-03-04 20:04:29 +00:00
.addr L23C9
.byte $04,$00,$00,$00
L23C9: .byte $00
2018-03-03 03:56:39 +00:00
.byte $00,$00,$00,$01,$00,$04,$00,$21
2018-03-04 19:35:04 +00:00
.byte $28,$27,$00,$00,$00,$04,$00
2018-03-04 20:04:29 +00:00
.addr L23DF
.byte $05,$00,$00,$00
L23DF: .byte $00,$00,$00
2018-03-03 03:56:39 +00:00
.byte $00,$00,$00,$00,$00,$00
2018-03-03 17:04:07 +00:00
2018-03-06 04:11:14 +00:00
DEFINE_CLOSE_PARAMS close_srcfile_params
DEFINE_CLOSE_PARAMS close_dstfile_params
2018-03-03 17:04:07 +00:00
2018-03-04 19:35:04 +00:00
.byte $01
2018-03-06 05:20:00 +00:00
.addr buffer
copy_buffer := $4000
max_copy_count := MLI - copy_buffer
2018-03-07 16:12:30 +00:00
open_srcfile_io_buffer := $0D00
open_dstfile_io_buffer := $1100
DEFINE_OPEN_PARAMS open_srcfile_params, buffer, open_srcfile_io_buffer
DEFINE_OPEN_PARAMS open_dstfile_params, path0, open_dstfile_io_buffer
2018-03-06 05:20:00 +00:00
DEFINE_READ_PARAMS read_srcfile_params, copy_buffer, max_copy_count
DEFINE_WRITE_PARAMS write_dstfile_params, copy_buffer, max_copy_count
2018-03-04 03:27:31 +00:00
2018-03-06 05:27:41 +00:00
DEFINE_CREATE_PARAMS create_params, path0, ACCESS_DEFAULT, 0, 0
2018-03-04 19:35:04 +00:00
.byte $07
2018-03-05 03:38:55 +00:00
.addr path0
2018-03-04 19:35:04 +00:00
.byte $00
2018-03-03 03:56:39 +00:00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00
2018-03-03 17:04:07 +00:00
2018-03-06 05:20:00 +00:00
DEFINE_GET_FILE_INFO_PARAMS get_file_info_params, buffer
2018-03-03 17:04:07 +00:00
.byte 0
2018-03-04 04:03:42 +00:00
2018-03-06 04:11:14 +00:00
;; Files/Directories to copy
2018-03-04 04:03:42 +00:00
str_f1: PASCAL_STRING "DESKTOP1"
str_f2: PASCAL_STRING "DESKTOP2"
str_f3: PASCAL_STRING "DESK.ACC"
str_f4: PASCAL_STRING "SELECTOR.LIST"
str_f5: PASCAL_STRING "SELECTOR"
str_f6: PASCAL_STRING "PRODOS"
2018-03-05 03:38:55 +00:00
filename_table:
.addr str_f1,str_f2,str_f3,str_f4,str_f5,str_f6
2018-03-04 04:03:42 +00:00
2018-03-05 03:38:55 +00:00
str_copying_to_ramcard:
PASCAL_STRING "Copying Apple II DeskTop into RAMCard"
2018-03-04 20:04:29 +00:00
;; Jump target from filer launcher - why???
rts1: rts
2018-03-06 05:20:00 +00:00
;; Signature of block storage devices ($Cn0x)
sig_bytes:
.byte $20,$00,$03,$00
sig_offsets:
.byte $01,$03,$05,$07
2018-03-04 20:04:29 +00:00
2018-03-06 05:20:00 +00:00
active_device:
.byte 0
2018-03-04 05:33:40 +00:00
;; Selector signature
2018-03-04 20:04:29 +00:00
selector_signature:
.byte $AD,$8B,$C0,$18,$FB,$5C,$04,$D0,$E0
;;; ============================================================
2018-03-04 05:33:40 +00:00
2018-03-04 20:04:29 +00:00
start: sta MIXCLR
2018-03-04 05:33:40 +00:00
sta HIRES
sta TXTCLR
sta CLR80VID
sta AN3_OFF
sta AN3_ON
sta AN3_OFF
sta AN3_ON
sta SET80VID
sta DHIRESON
sta TXTSET
lda DATELO ; Any date set?
ora DATEHI
2018-03-17 04:19:01 +00:00
bne :+
2018-03-04 05:33:40 +00:00
copy16 date, DATELO ; Copy timestamp embedded in this file
2018-03-17 04:19:01 +00:00
: lda MACHID
2018-03-04 05:33:40 +00:00
and #$30 ; bits 4,5 set = 128k
2018-03-03 03:56:39 +00:00
cmp #$30
2018-03-04 05:33:40 +00:00
beq have128k
;; Relocate FILER launch routine to $300 and invoke
2018-03-04 20:04:29 +00:00
.scope
target := $300
length := $D0
ldy #length
2018-03-04 05:33:40 +00:00
: lda launch_filer,y
2018-03-04 20:04:29 +00:00
sta target,y
2018-03-03 03:56:39 +00:00
dey
2018-03-04 20:04:29 +00:00
cpy #$FF ; why not bpl ???
2018-03-04 05:33:40 +00:00
bne :-
2018-03-04 20:04:29 +00:00
jmp target
.endscope
2018-03-03 03:56:39 +00:00
2018-03-04 05:33:40 +00:00
have128k:
lda #$00
sta SHADOW ; IIgs ???
2018-03-06 05:20:00 +00:00
lda DEVNUM ; Most recent device
sta active_device
2018-03-04 05:33:40 +00:00
lda LCBANK2
lda LCBANK2
;; Check quit routine
2018-03-03 03:56:39 +00:00
ldx #$08
2018-03-04 05:33:40 +00:00
: lda SELECTOR,x ; Quit routine?
2018-03-04 20:04:29 +00:00
cmp selector_signature,x
2018-03-04 05:33:40 +00:00
bne nomatch
2018-03-03 03:56:39 +00:00
dex
2018-03-04 05:33:40 +00:00
bpl :-
lda #0
beq match
nomatch:
lda #$80
match: sta $D3AC
2018-03-03 06:44:28 +00:00
lda ROMIN2
2018-03-15 03:16:15 +00:00
ldx #0
jsr stx_lc_d3ff
2018-03-04 20:04:29 +00:00
;; Point $8 at $C100
2018-03-05 03:38:55 +00:00
lda #0
2018-03-06 05:24:21 +00:00
sta flag
2018-03-03 03:56:39 +00:00
sta $08
lda #$C1
2018-03-04 20:04:29 +00:00
sta $08+1
;; Check slot for signature bytes
check_slot:
ldx #0
: lda sig_offsets,x ; Check $CnXX
2018-03-03 03:56:39 +00:00
tay
lda ($08),y
2018-03-04 20:04:29 +00:00
cmp sig_bytes,x
bne next_slot
2018-03-03 03:56:39 +00:00
inx
2018-03-04 20:04:29 +00:00
cpx #4 ; number of signature bytes
bcc :-
2018-03-03 03:56:39 +00:00
ldy #$FB
2018-03-04 20:04:29 +00:00
lda ($08),y ; Also check $CnFB for low bit
2018-03-03 03:56:39 +00:00
and #$01
2018-03-04 20:04:29 +00:00
beq next_slot
bne found_slot
next_slot:
inc $08+1
lda $08+1
cmp #$C8 ; stop at $C800
bcc check_slot
2018-03-04 05:33:40 +00:00
ldy DEVCNT
2018-03-17 04:19:01 +00:00
: lda DEVLST,y
2018-03-03 03:56:39 +00:00
cmp #$3E
2018-03-17 04:19:01 +00:00
beq :+
2018-03-03 03:56:39 +00:00
dey
2018-03-17 04:19:01 +00:00
bpl :-
2018-03-04 20:04:29 +00:00
jmp fail
2018-03-03 03:56:39 +00:00
2018-03-17 04:19:01 +00:00
: lda #$03
bne :+
2018-03-04 20:04:29 +00:00
found_slot:
lda $08+1
and #$0F ; slot # in A
2018-03-17 04:19:01 +00:00
: sta slot
2018-03-04 20:04:29 +00:00
;; Synthesize unit_num, verify it's a device
2018-03-03 03:56:39 +00:00
asl a
asl a
asl a
asl a
2018-03-03 17:04:07 +00:00
sta on_line_params::unit_num
2018-03-04 20:04:29 +00:00
sta unit_num
2018-03-03 17:04:07 +00:00
MLI_CALL ON_LINE, on_line_params
2018-03-04 20:04:29 +00:00
beq :+
jmp fail
2018-03-03 03:56:39 +00:00
2018-03-04 20:04:29 +00:00
: lda unit_num
cmp #$30 ; make sure it's not slot 3 (aux)
beq :+
2018-03-03 17:04:07 +00:00
sta write_block_params_unit_num
2018-03-07 05:36:55 +00:00
sta write_block2_params_unit_num
2018-03-03 17:04:07 +00:00
MLI_CALL WRITE_BLOCK, write_block_params
2018-03-04 20:04:29 +00:00
bne :+
2018-03-07 05:36:55 +00:00
MLI_CALL WRITE_BLOCK, write_block2_params
2018-03-04 20:04:29 +00:00
: lda on_line_buffer
2018-03-03 03:56:39 +00:00
and #$0F
tay
2018-03-17 04:19:01 +00:00
2018-03-03 03:56:39 +00:00
iny
2018-03-05 03:38:55 +00:00
sty path0
2018-03-04 19:35:04 +00:00
lda #'/'
sta on_line_buffer
2018-03-05 03:38:55 +00:00
sta path0+1
2018-03-17 04:19:01 +00:00
: lda on_line_buffer,y
2018-03-05 03:38:55 +00:00
sta path0+1,y
2018-03-03 03:56:39 +00:00
dey
2018-03-17 04:19:01 +00:00
bne :-
2018-03-03 03:56:39 +00:00
ldx #$C0
2018-03-15 03:16:15 +00:00
jsr stx_lc_d3ff
2018-03-06 16:00:57 +00:00
addr_call copy_to_lc2_b, path0
2018-03-06 05:20:00 +00:00
jsr check_desktop2_on_device
2018-03-17 04:19:01 +00:00
bcs :+
2018-03-03 03:56:39 +00:00
ldx #$80
2018-03-15 03:16:15 +00:00
jsr stx_lc_d3ff
jsr copy_2005_to_lc2_a
2018-03-04 20:04:29 +00:00
jmp fail
2018-03-03 03:56:39 +00:00
2018-03-17 04:19:01 +00:00
: lda BUTN1
2018-03-05 03:38:55 +00:00
sta butn1
2018-03-04 19:35:04 +00:00
lda BUTN0
2018-03-05 03:38:55 +00:00
bpl start_copy
2018-03-04 20:04:29 +00:00
jmp fail
2018-03-03 03:56:39 +00:00
2018-03-05 03:38:55 +00:00
str_slash_desktop:
PASCAL_STRING "/DeskTop"
2018-03-06 05:20:00 +00:00
;; Overwrite first bytes of get_file_info_params
2018-03-15 03:16:15 +00:00
.proc dir_file_info
2018-03-06 05:20:00 +00:00
.byte $A ; param_count
.addr 0 ; pathname
2018-03-15 03:16:15 +00:00
.byte ACCESS_DEFAULT ; access
2018-03-06 05:20:00 +00:00
.byte FT_DIRECTORY ; filetype
.word 0 ; aux_type
.byte ST_LINKED_DIRECTORY ; storage_type
.endproc
2018-03-04 20:04:29 +00:00
2018-03-05 03:38:55 +00:00
start_copy:
2018-03-06 05:20:00 +00:00
jsr show_copying_screen
2018-03-03 17:04:07 +00:00
MLI_CALL GET_PREFIX, get_prefix_params
2018-03-15 03:16:15 +00:00
beq :+
2018-03-05 03:38:55 +00:00
jmp fail_copy
2018-03-15 03:16:15 +00:00
: dec buffer
2018-03-03 03:56:39 +00:00
ldx #$80
2018-03-15 03:16:15 +00:00
jsr stx_lc_d3ff
2018-03-06 05:20:00 +00:00
ldy buffer
2018-03-15 03:16:15 +00:00
: lda buffer,y
2018-03-03 03:56:39 +00:00
sta L2005,y
dey
2018-03-15 03:16:15 +00:00
bpl :-
2018-03-05 03:38:55 +00:00
ldy path0
2018-03-15 03:16:15 +00:00
ldx #0
: iny
2018-03-03 03:56:39 +00:00
inx
2018-03-05 03:38:55 +00:00
lda str_slash_desktop,x
sta path0,y
cpx str_slash_desktop
2018-03-15 03:16:15 +00:00
bne :-
2018-03-05 03:38:55 +00:00
sty path0
2018-03-15 03:16:15 +00:00
;; copy file_type, aux_type, storage_type
2018-03-04 22:01:19 +00:00
ldx #7
2018-03-15 03:16:15 +00:00
: lda dir_file_info,x
2018-03-03 17:04:07 +00:00
sta get_file_info_params,x
2018-03-03 03:56:39 +00:00
dex
2018-03-04 22:01:19 +00:00
cpx #3
2018-03-15 03:16:15 +00:00
bne :-
2018-03-06 04:11:14 +00:00
jsr create_file_for_copy
2018-03-05 03:38:55 +00:00
lda path0
sta copy_flag
lda #0
sta filenum
2018-03-06 04:11:14 +00:00
file_loop:
lda filenum
2018-03-03 03:56:39 +00:00
asl a
tax
2018-03-05 03:38:55 +00:00
lda filename_table,x
2018-03-03 03:56:39 +00:00
sta $06
2018-03-05 03:38:55 +00:00
lda filename_table+1,x
2018-03-04 04:03:42 +00:00
sta $06+1
2018-03-05 03:38:55 +00:00
ldy #0
2018-03-03 03:56:39 +00:00
lda ($06),y
tay
2018-03-05 03:38:55 +00:00
: lda ($06),y
sta filename_buf,y
2018-03-03 03:56:39 +00:00
dey
2018-03-05 03:38:55 +00:00
bpl :-
2018-03-06 04:11:14 +00:00
jsr copy_file
2018-03-05 03:38:55 +00:00
inc filenum
lda filenum
2018-03-03 03:56:39 +00:00
cmp #$06
2018-03-05 03:38:55 +00:00
bne file_loop
jmp fail2
2018-03-03 03:56:39 +00:00
2018-03-05 03:38:55 +00:00
fail2: lda copy_flag
2018-03-15 03:16:15 +00:00
beq :+
2018-03-05 03:38:55 +00:00
sta path0
2018-03-03 17:04:07 +00:00
MLI_CALL SET_PREFIX, set_prefix_params
2018-03-15 03:16:15 +00:00
: jsr write_desktop1
jsr copy_2005_to_lc2_a
2018-03-07 16:12:30 +00:00
2018-03-03 03:56:39 +00:00
lda #$00
2018-03-07 16:12:30 +00:00
sta RAMWORKS_BANK ; ???
2018-03-04 20:04:29 +00:00
ldy #BITMAP_SIZE-1
: sta BITMAP,y
2018-03-03 03:56:39 +00:00
dey
2018-03-04 20:04:29 +00:00
bpl :-
2018-03-07 02:36:51 +00:00
jmp copy_selector_entries_to_ramcard
2018-03-03 03:56:39 +00:00
2018-03-15 03:16:15 +00:00
.proc stx_lc_d3ff
lda LCBANK2
2018-03-04 19:35:04 +00:00
lda LCBANK2
2018-03-03 03:56:39 +00:00
stx $D3FF
2018-03-03 06:44:28 +00:00
lda ROMIN2
rts
2018-03-15 03:16:15 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 16:00:57 +00:00
.proc copy_to_lc2_b
ptr := $6
target := $D3EE
stax ptr
2018-03-04 19:35:04 +00:00
lda LCBANK2
lda LCBANK2
2018-03-06 16:00:57 +00:00
ldy #0
lda (ptr),y
2018-03-03 03:56:39 +00:00
tay
2018-03-06 16:00:57 +00:00
: lda (ptr),y
sta target,y
2018-03-03 03:56:39 +00:00
dey
2018-03-06 04:11:14 +00:00
bpl :-
2018-03-03 06:44:28 +00:00
lda ROMIN2
rts
2018-03-06 16:00:57 +00:00
.endproc
.proc copy_to_lc2_a
ptr := $6
target := $D3AD
2018-03-03 03:56:39 +00:00
2018-03-06 16:00:57 +00:00
stax ptr
2018-03-04 19:35:04 +00:00
lda LCBANK2
lda LCBANK2
2018-03-06 16:00:57 +00:00
ldy #0
lda (ptr),y
2018-03-03 03:56:39 +00:00
tay
2018-03-06 16:00:57 +00:00
: lda (ptr),y
sta target,y
2018-03-03 03:56:39 +00:00
dey
2018-03-06 04:11:14 +00:00
bpl :-
2018-03-03 06:44:28 +00:00
lda ROMIN2
rts
2018-03-06 16:00:57 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 05:24:21 +00:00
fail: lda #0
sta flag
2018-03-05 03:38:55 +00:00
jmp fail2
2018-03-03 03:56:39 +00:00
2018-03-04 20:04:29 +00:00
.byte 0, $D, 0, 0, 0
2018-03-04 03:27:31 +00:00
2018-03-06 05:20:00 +00:00
;; Generic buffer?
buffer: .res 300, 0
2018-03-04 03:27:31 +00:00
2018-03-05 03:38:55 +00:00
filename_buf:
.res 16, 0
2018-03-06 05:20:00 +00:00
file_type: ; written but not read ???
.byte 0
2018-03-07 16:12:30 +00:00
.res 31, 0 ; unused ???
2018-03-06 05:20:00 +00:00
;;; ============================================================
.proc append_filename_to_buffer
lda filename_buf
bne :+
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
: ldx #0
ldy buffer
2018-03-04 19:35:04 +00:00
lda #'/'
2018-03-06 05:20:00 +00:00
sta buffer+1,y
2018-03-03 03:56:39 +00:00
iny
2018-03-06 05:20:00 +00:00
loop: cpx filename_buf
bcs done
2018-03-05 03:38:55 +00:00
lda filename_buf+1,x
2018-03-06 05:20:00 +00:00
sta buffer+1,y
2018-03-03 03:56:39 +00:00
inx
iny
2018-03-06 05:20:00 +00:00
jmp loop
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
done: sty buffer
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
;;; ============================================================
.proc remove_filename_from_buffer
ldx buffer
bne :+
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
: lda buffer,x
2018-03-04 19:35:04 +00:00
cmp #'/'
2018-03-06 05:20:00 +00:00
beq done
2018-03-03 03:56:39 +00:00
dex
2018-03-06 05:20:00 +00:00
bne :-
stx buffer
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
done: dex
stx buffer
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-05 03:38:55 +00:00
;;; ============================================================
.proc append_filename_to_path0
lda filename_buf
bne :+
2018-03-03 03:56:39 +00:00
rts
2018-03-05 03:38:55 +00:00
: ldx #0
ldy path0
2018-03-04 19:35:04 +00:00
lda #'/'
2018-03-05 03:38:55 +00:00
sta path0+1,y
2018-03-03 03:56:39 +00:00
iny
2018-03-05 03:38:55 +00:00
loop: cpx filename_buf
bcs done
lda filename_buf+1,x
sta path0+1,y
2018-03-03 03:56:39 +00:00
inx
iny
2018-03-05 03:38:55 +00:00
jmp loop
2018-03-03 03:56:39 +00:00
2018-03-05 03:38:55 +00:00
done: sty path0
2018-03-03 03:56:39 +00:00
rts
2018-03-05 03:38:55 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-05 03:38:55 +00:00
.proc remove_filename_from_path0
ldx path0
bne :+
2018-03-03 03:56:39 +00:00
rts
2018-03-05 03:38:55 +00:00
: lda path0,x
2018-03-04 19:35:04 +00:00
cmp #'/'
2018-03-05 03:38:55 +00:00
beq done
2018-03-03 03:56:39 +00:00
dex
2018-03-05 03:38:55 +00:00
bne :-
stx path0
2018-03-03 03:56:39 +00:00
rts
2018-03-05 03:38:55 +00:00
done: dex
stx path0
2018-03-03 03:56:39 +00:00
rts
2018-03-05 03:38:55 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
.proc show_copying_screen
;; Turn on 80-column mode
2018-03-04 20:04:29 +00:00
jsr SLOT3ENTRY
2018-03-03 03:56:39 +00:00
jsr HOME
2018-03-06 05:20:00 +00:00
;; Center string
2018-03-04 19:35:04 +00:00
lda #80
2018-03-03 03:56:39 +00:00
sec
2018-03-04 19:35:04 +00:00
sbc str_copying_to_ramcard
lsr a ; / 2 to center
sta CH
lda #12
sta CV
2018-03-03 04:06:58 +00:00
jsr VTAB
2018-03-04 19:35:04 +00:00
ldy #0
2018-03-04 20:04:29 +00:00
loop: iny
2018-03-04 19:35:04 +00:00
lda str_copying_to_ramcard,y
2018-03-03 03:56:39 +00:00
ora #$80
jsr COUT
2018-03-04 19:35:04 +00:00
cpy str_copying_to_ramcard
2018-03-04 20:04:29 +00:00
bne loop
2018-03-03 03:56:39 +00:00
rts
2018-03-04 20:04:29 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
;;; ============================================================
2018-03-05 03:38:55 +00:00
.proc fail_copy
lda #0
sta copy_flag
2018-03-04 20:04:29 +00:00
jmp fail
2018-03-05 03:38:55 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
;;; ============================================================
;;; Unreferenced ???
.proc copy_input_to_buffer
2018-03-07 16:12:30 +00:00
ldy #0
loop: lda IN,y
2018-03-06 05:20:00 +00:00
cmp #$80|CHAR_RETURN
beq done
and #CHAR_MASK
2018-03-06 05:20:00 +00:00
sta buffer+1,y
2018-03-03 03:56:39 +00:00
iny
2018-03-06 05:20:00 +00:00
jmp loop
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
done: sty buffer
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
;;; ============================================================
.proc copy_file
2018-03-05 03:38:55 +00:00
jsr append_filename_to_path0
2018-03-06 05:20:00 +00:00
jsr append_filename_to_buffer
2018-03-03 17:04:07 +00:00
MLI_CALL GET_FILE_INFO, get_file_info_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 05:20:00 +00:00
cmp #ERR_FILE_NOT_FOUND
beq cleanup
2018-03-04 20:04:29 +00:00
jmp fail
2018-03-03 03:56:39 +00:00
2018-03-03 17:04:07 +00:00
: lda get_file_info_params::file_type
2018-03-06 05:20:00 +00:00
sta file_type
2018-03-06 04:11:14 +00:00
cmp #FT_DIRECTORY
2018-03-06 05:20:00 +00:00
bne :+
2018-03-06 04:11:14 +00:00
jsr copy_directory
jmp done
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
: jsr create_file_for_copy
cmp #ERR_DUPLICATE_FILENAME
bne :+
2018-03-05 03:38:55 +00:00
lda filenum
2018-03-06 05:20:00 +00:00
bne cleanup
2018-03-03 03:56:39 +00:00
pla
pla
2018-03-05 03:38:55 +00:00
jmp fail2
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
: jsr copy_normal_file
cleanup:
jsr remove_filename_from_buffer
2018-03-05 03:38:55 +00:00
jsr remove_filename_from_path0
2018-03-06 04:11:14 +00:00
done: rts
2018-03-05 03:38:55 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
;;; ============================================================
.proc copy_directory_impl
ptr := $6
2018-03-07 16:12:30 +00:00
open_io_buffer := $A000
2018-03-06 04:11:14 +00:00
dir_buffer := $A400
2018-03-07 16:12:30 +00:00
dir_bufsize := BLOCK_SIZE
2018-03-06 04:11:14 +00:00
entry_length_offset := $23
file_count_offset := $25
header_length := $2B
2018-03-07 16:12:30 +00:00
DEFINE_OPEN_PARAMS open_params, buffer, open_io_buffer
DEFINE_READ_PARAMS read_params, dir_buffer, dir_bufsize
2018-03-03 17:04:07 +00:00
DEFINE_CLOSE_PARAMS close_params
2018-03-06 04:11:14 +00:00
start: jsr create_file_for_copy
2018-03-06 05:20:00 +00:00
cmp #ERR_DUPLICATE_FILENAME
beq bail
2018-03-06 04:11:14 +00:00
MLI_CALL OPEN, open_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-05 03:38:55 +00:00
jsr fail_copy
2018-03-06 05:20:00 +00:00
bail: rts
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
: lda open_params::ref_num
sta read_params::ref_num
2018-03-03 17:04:07 +00:00
sta close_params::ref_num
2018-03-06 04:11:14 +00:00
MLI_CALL READ, read_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-05 03:38:55 +00:00
jsr fail_copy
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
: lda #0
2018-03-03 03:56:39 +00:00
sta L2A10
2018-03-06 04:11:14 +00:00
lda #<(dir_buffer + header_length)
sta ptr
lda #>(dir_buffer + header_length)
sta ptr+1
L2997: lda dir_buffer + file_count_offset
2018-03-03 03:56:39 +00:00
cmp L2A10
bne L29B1
2018-03-03 17:04:07 +00:00
L299F: MLI_CALL CLOSE, close_params
2018-03-06 05:20:00 +00:00
beq :+
2018-03-05 03:38:55 +00:00
jmp fail_copy
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
: jsr remove_filename_from_buffer
2018-03-05 03:38:55 +00:00
jsr remove_filename_from_path0
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
L29B1: ldy #0
2018-03-06 04:11:14 +00:00
lda (ptr),y
2018-03-17 04:19:01 +00:00
bne :+
2018-03-03 03:56:39 +00:00
jmp L29F6
2018-03-17 04:19:01 +00:00
: and #$0F
2018-03-03 03:56:39 +00:00
tay
2018-03-17 04:19:01 +00:00
: lda (ptr),y
2018-03-05 03:38:55 +00:00
sta filename_buf,y
2018-03-03 03:56:39 +00:00
dey
2018-03-17 04:19:01 +00:00
bne :-
2018-03-06 04:11:14 +00:00
lda (ptr),y
2018-03-03 03:56:39 +00:00
and #$0F
2018-03-05 03:38:55 +00:00
sta filename_buf,y
jsr append_filename_to_path0
2018-03-06 05:20:00 +00:00
jsr append_filename_to_buffer
2018-03-03 17:04:07 +00:00
MLI_CALL GET_FILE_INFO, get_file_info_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-05 03:38:55 +00:00
jmp fail_copy
2018-03-03 03:56:39 +00:00
2018-03-03 17:04:07 +00:00
: lda get_file_info_params::file_type
2018-03-06 05:20:00 +00:00
sta file_type
2018-03-06 04:11:14 +00:00
jsr create_file_for_copy
2018-03-06 05:20:00 +00:00
cmp #ERR_DUPLICATE_FILENAME
2018-03-06 04:11:14 +00:00
beq :+
jsr copy_normal_file
2018-03-06 05:20:00 +00:00
: jsr remove_filename_from_buffer
2018-03-05 03:38:55 +00:00
jsr remove_filename_from_path0
2018-03-03 03:56:39 +00:00
inc L2A10
2018-03-06 04:11:14 +00:00
L29F6: add16_8 ptr, dir_buffer + entry_length_offset, ptr
lda ptr+1
2018-03-07 16:12:30 +00:00
cmp #>(dir_buffer + dir_bufsize)
2018-03-17 04:19:01 +00:00
bcs :+
2018-03-03 03:56:39 +00:00
jmp L2997
2018-03-17 04:19:01 +00:00
: jmp L299F
2018-03-03 03:56:39 +00:00
2018-03-03 03:57:30 +00:00
L2A10: .byte 0
2018-03-06 04:11:14 +00:00
.endproc
copy_directory := copy_directory_impl::start
;;; ============================================================
.proc copy_normal_file
2018-03-06 05:20:00 +00:00
;; Open source
2018-03-06 04:11:14 +00:00
: MLI_CALL OPEN, open_srcfile_params
beq :+
2018-03-05 03:38:55 +00:00
jsr fail_copy
2018-03-06 04:11:14 +00:00
jmp :-
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
;; Open destination
2018-03-06 04:11:14 +00:00
: MLI_CALL OPEN, open_dstfile_params
beq :+
2018-03-05 03:38:55 +00:00
jsr fail_copy
2018-03-06 04:11:14 +00:00
jmp :-
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
: lda open_srcfile_params::ref_num
sta read_srcfile_params::ref_num
sta close_srcfile_params::ref_num
lda open_dstfile_params::ref_num
sta write_dstfile_params::ref_num
sta close_dstfile_params::ref_num
2018-03-06 05:20:00 +00:00
;; Read a chunk
loop: copy16 #max_copy_count, read_srcfile_params::request_count
2018-03-06 04:11:14 +00:00
read: MLI_CALL READ, read_srcfile_params
beq :+
2018-03-06 05:20:00 +00:00
cmp #ERR_END_OF_FILE
2018-03-06 04:11:14 +00:00
beq done
2018-03-05 03:38:55 +00:00
jsr fail_copy
2018-03-06 04:11:14 +00:00
jmp read
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
;; Write the chunk
2018-03-06 04:11:14 +00:00
: copy16 read_srcfile_params::trans_count, write_dstfile_params::request_count
ora read_srcfile_params::trans_count
beq done
write: MLI_CALL WRITE, write_dstfile_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-05 03:38:55 +00:00
jsr fail_copy
2018-03-06 04:11:14 +00:00
jmp write
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
;; More to copy?
2018-03-06 04:11:14 +00:00
: lda write_dstfile_params::trans_count
2018-03-06 05:20:00 +00:00
cmp #<max_copy_count
2018-03-06 04:11:14 +00:00
bne done
lda write_dstfile_params::trans_count+1
2018-03-06 05:20:00 +00:00
cmp #>max_copy_count
2018-03-06 04:11:14 +00:00
beq loop
2018-03-06 05:20:00 +00:00
;; Close source and destination
2018-03-06 04:11:14 +00:00
done: MLI_CALL CLOSE, close_srcfile_params
MLI_CALL CLOSE, close_dstfile_params
2018-03-03 03:56:39 +00:00
rts
2018-03-06 04:11:14 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
;;; ============================================================
.proc create_file_for_copy
2018-03-04 03:43:41 +00:00
;; Copy file_type, aux_type, storage_type
2018-03-06 04:11:14 +00:00
ldx #7
2018-03-04 03:43:41 +00:00
: lda get_file_info_params,x
sta create_params,x
2018-03-03 03:56:39 +00:00
dex
2018-03-04 03:43:41 +00:00
cpx #3
bne :-
MLI_CALL CREATE, create_params
2018-03-06 04:11:14 +00:00
beq :+
2018-03-06 05:20:00 +00:00
cmp #ERR_DUPLICATE_FILENAME
2018-03-06 04:11:14 +00:00
beq :+
2018-03-05 03:38:55 +00:00
jsr fail_copy
2018-03-06 04:11:14 +00:00
: rts
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
;;; ============================================================
2018-03-06 05:20:00 +00:00
.proc check_desktop2_on_device
lda active_device
cmp #$3E ; ???
bne :+
jmp next
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
;; Check slot for signature bytes
: and #$70 ; Compute $Cn00
2018-03-03 03:56:39 +00:00
lsr a
lsr a
lsr a
lsr a
ora #$C0
2018-03-04 22:01:19 +00:00
sta $08+1
lda #0
2018-03-03 03:56:39 +00:00
sta $08
2018-03-04 22:01:19 +00:00
ldx #0 ; Compare signature bytes
2018-03-06 05:20:00 +00:00
bloop: lda sig_offsets,x
2018-03-03 03:56:39 +00:00
tay
lda ($08),y
2018-03-04 20:04:29 +00:00
cmp sig_bytes,x
2018-03-06 05:20:00 +00:00
bne error
2018-03-03 03:56:39 +00:00
inx
2018-03-04 22:01:19 +00:00
cpx #4 ; Number of signature bytes
2018-03-06 05:20:00 +00:00
bcc bloop
2018-03-04 22:01:19 +00:00
ldy #$FB ; Also check $CnFB
2018-03-03 03:56:39 +00:00
lda ($08),y
and #$01
2018-03-06 05:20:00 +00:00
bne next
error: sec
2018-03-03 03:56:39 +00:00
rts
2018-03-06 05:20:00 +00:00
next: MLI_CALL GET_PREFIX, get_prefix_params2
bne error
2018-03-07 16:12:30 +00:00
;; Append "DeskTop2" to path
ldx path_buf
2018-03-05 03:38:55 +00:00
ldy #0
2018-03-06 05:20:00 +00:00
loop: inx
2018-03-03 03:56:39 +00:00
iny
2018-03-05 03:38:55 +00:00
lda str_desktop2,y
2018-03-07 16:12:30 +00:00
sta path_buf,x
2018-03-05 03:38:55 +00:00
cpy str_desktop2
2018-03-06 05:20:00 +00:00
bne loop
2018-03-07 16:12:30 +00:00
stx path_buf
2018-03-06 05:20:00 +00:00
;; ... and get info
2018-03-04 04:03:42 +00:00
MLI_CALL GET_FILE_INFO, get_file_info_params4
2018-03-06 05:20:00 +00:00
beq error
clc ; ok
2018-03-03 03:56:39 +00:00
rts
2018-03-05 03:38:55 +00:00
str_desktop2:
PASCAL_STRING "DeskTop2"
2018-03-06 04:11:14 +00:00
.endproc
2018-03-04 22:01:19 +00:00
;;; ============================================================
.proc write_desktop1_impl
2018-03-07 16:12:30 +00:00
open_io_buffer := $1000
dt1_addr := $2000
dt1_size := $45
DEFINE_OPEN_PARAMS open_params, str_desktop1_path, open_io_buffer
2018-03-04 03:27:31 +00:00
str_desktop1_path:
PASCAL_STRING "DeskTop/DESKTOP1"
2018-03-07 16:12:30 +00:00
DEFINE_WRITE_PARAMS write_params, dt1_addr, dt1_size
2018-03-04 22:01:19 +00:00
DEFINE_CLOSE_PARAMS close_params
2018-03-03 17:04:07 +00:00
2018-03-04 22:01:19 +00:00
start: MLI_CALL OPEN, open_params
bne :+
lda open_params::ref_num
sta write_params::ref_num
sta close_params::ref_num
MLI_CALL WRITE, write_params
bne :+
MLI_CALL CLOSE, close_params
: rts
.endproc
write_desktop1 := write_desktop1_impl::start
2018-03-03 17:04:07 +00:00
2018-03-04 22:01:19 +00:00
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-15 03:16:15 +00:00
.proc copy_2005_to_lc2_a
addr_call copy_to_lc2_a, L2005
2018-03-03 04:32:55 +00:00
rts
2018-03-15 03:16:15 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-03 03:57:30 +00:00
.byte 0
2018-03-04 19:35:04 +00:00
2018-03-05 03:38:55 +00:00
path0: .res 65, 0
2018-03-03 17:04:07 +00:00
;;; ============================================================
2018-03-04 19:35:04 +00:00
;;; Launch FILER - used if machine is not 128k
;;; Relocated to $300 before invoking
2018-03-03 17:04:07 +00:00
2018-03-04 19:35:04 +00:00
saved_org := *
2018-03-04 05:33:40 +00:00
.proc launch_filer
2018-03-03 17:04:07 +00:00
.org $300
sys_start := $2000
MLI_CALL OPEN, open_params
beq :+
2018-03-04 20:04:29 +00:00
jmp rts1
2018-03-03 03:56:39 +00:00
2018-03-03 17:04:07 +00:00
: lda open_params_ref_num
sta read_params_ref_num
MLI_CALL READ, read_params
beq :+
2018-03-04 20:04:29 +00:00
jmp rts1
2018-03-03 06:44:28 +00:00
2018-03-03 17:04:07 +00:00
: MLI_CALL CLOSE, close_params
beq :+
2018-03-04 20:04:29 +00:00
jmp rts1
2018-03-03 03:56:39 +00:00
2018-03-03 17:04:07 +00:00
: jmp sys_start
DEFINE_OPEN_PARAMS open_params, filename, $800
open_params_ref_num := open_params::ref_num
DEFINE_READ_PARAMS read_params, sys_start, MLI - sys_start
read_params_ref_num := read_params::ref_num
DEFINE_CLOSE_PARAMS close_params
2018-03-05 03:38:55 +00:00
filename:
PASCAL_STRING "FILER"
2018-03-03 17:04:07 +00:00
.endproc
2018-03-04 20:04:29 +00:00
.assert .sizeof(launch_filer) <= $D0, error, "Routine length exceeded"
2018-03-03 17:04:07 +00:00
;;; ============================================================
2018-03-04 19:35:04 +00:00
.org (saved_org + .sizeof(launch_filer))
2018-03-03 03:56:39 +00:00
2018-03-05 03:38:55 +00:00
filenum:
.byte 0 ; index of file being copied
2018-03-06 05:24:21 +00:00
flag: .byte 0 ; written but not read ???
2018-03-05 03:38:55 +00:00
slot: .byte 0
2018-03-03 17:04:07 +00:00
2018-03-04 20:04:29 +00:00
DEFINE_WRITE_BLOCK_PARAMS write_block_params, prodos_loader_blocks, 0
2018-03-03 17:04:07 +00:00
write_block_params_unit_num := write_block_params::unit_num
2018-03-07 05:36:55 +00:00
DEFINE_WRITE_BLOCK_PARAMS write_block2_params, prodos_loader_blocks + 512, 1
write_block2_params_unit_num := write_block2_params::unit_num
2018-03-03 17:04:07 +00:00
PAD_TO $2C00
2018-03-03 03:56:39 +00:00
2018-03-03 04:32:55 +00:00
;;; ============================================================
2018-03-04 20:04:29 +00:00
prodos_loader_blocks:
2018-03-03 04:32:55 +00:00
.assert * = $2C00, error, "Segment length mismatch"
.incbin "../inc/pdload.dat"
2018-03-04 20:04:29 +00:00
2018-03-07 02:36:51 +00:00
.endproc ; copy_desktop_to_ramcard
2018-03-04 20:04:29 +00:00
2018-03-03 04:32:55 +00:00
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-04 20:04:29 +00:00
.assert * = $3000, error, "Segment length mismatch"
2018-03-06 05:30:13 +00:00
;;; SPECULATION: This copies Selector entries marked
;;; "Down load" / "At boot" to the RAMCard as well
2018-03-07 02:36:51 +00:00
.proc copy_selector_entries_to_ramcard
;; File format:
2018-03-07 16:12:30 +00:00
;; $ 0 - number of entries (0-7) in first batch (Run List???)
;; $ 1 - number of entries (0-15) in second batch (Other Run List???)
2018-03-07 02:36:51 +00:00
;; $ 2 - 24 * 16-byte data entries
;; $0 - label (length-prefixed, 15 bytes)
2018-03-07 16:12:30 +00:00
;; $F - active_flag (other flags, i.e. download on ... ?)
2018-03-07 02:36:51 +00:00
;; $182 - 24 * 64-byte pathname
;; $782 - EOF
2018-03-06 16:00:57 +00:00
selector_buffer := $4400
selector_buflen := $800
2018-03-07 02:36:51 +00:00
.proc process_selector_list
ptr := $6
2018-03-04 20:04:29 +00:00
jsr SLOT3ENTRY
2018-03-03 03:56:39 +00:00
jsr HOME
2018-03-04 19:35:04 +00:00
lda LCBANK2
lda LCBANK2
2018-03-06 16:00:57 +00:00
lda $D3FF ; ??? last byte of selector routine?
2018-03-03 03:56:39 +00:00
pha
2018-03-04 19:35:04 +00:00
lda ROMIN2
2018-03-03 03:56:39 +00:00
pla
2018-03-06 16:00:57 +00:00
bne :+
2018-03-05 03:38:55 +00:00
jmp invoke_selector_or_desktop
2018-03-03 03:56:39 +00:00
2018-03-06 16:00:57 +00:00
: lda LCBANK2
2018-03-04 19:35:04 +00:00
lda LCBANK2
2018-03-03 03:56:39 +00:00
ldx #$17
2018-03-06 16:00:57 +00:00
lda #0
: sta $D395,x
2018-03-03 03:56:39 +00:00
dex
2018-03-06 16:00:57 +00:00
bpl :-
2018-03-04 19:35:04 +00:00
lda ROMIN2
2018-03-07 02:36:51 +00:00
;; Load and iterate over the selector file
2018-03-04 22:01:19 +00:00
jsr read_selector_list
2018-03-05 03:38:55 +00:00
beq :+
2018-03-06 16:00:57 +00:00
jmp bail
2018-03-05 03:38:55 +00:00
: lda #0
2018-03-07 02:36:51 +00:00
sta entry_num
entry_loop:
lda entry_num
cmp selector_buffer ; done?
beq done_entries
jsr compute_label_addr
stax ptr
ldy #$0F ; check active flag
lda (ptr),y
bne next_entry
lda entry_num
jsr compute_path_addr
2018-03-03 03:56:39 +00:00
jsr L38B2
jsr L3489
2018-03-07 02:36:51 +00:00
2018-03-04 19:35:04 +00:00
lda LCBANK2
lda LCBANK2
2018-03-07 02:36:51 +00:00
ldx entry_num
2018-03-03 03:56:39 +00:00
lda #$FF
sta $D395,x
2018-03-04 19:35:04 +00:00
lda ROMIN2
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
next_entry:
inc entry_num
jmp entry_loop
done_entries:
;; Process entries again ???
lda #0
sta entry_num
entry_loop2:
lda entry_num
cmp selector_buffer + 1 ; ???
2018-03-06 16:00:57 +00:00
beq bail
2018-03-03 03:56:39 +00:00
clc
2018-03-07 02:36:51 +00:00
adc #8 ; offset by 8 ???
jsr compute_label_addr
stax ptr
2018-03-03 03:56:39 +00:00
ldy #$0F
2018-03-07 02:36:51 +00:00
lda (ptr),y ; check active flag
bne next_entry2
lda entry_num
2018-03-03 03:56:39 +00:00
clc
2018-03-07 02:36:51 +00:00
adc #8
jsr compute_path_addr
2018-03-03 03:56:39 +00:00
jsr L38B2
jsr L3489
2018-03-07 02:36:51 +00:00
2018-03-04 19:35:04 +00:00
lda LCBANK2
lda LCBANK2
2018-03-07 02:36:51 +00:00
lda entry_num
2018-03-03 03:56:39 +00:00
clc
2018-03-07 02:36:51 +00:00
adc #8
2018-03-03 03:56:39 +00:00
tax
lda #$FF
sta $D395,x
2018-03-04 19:35:04 +00:00
lda ROMIN2
2018-03-07 02:36:51 +00:00
next_entry2:
inc entry_num
jmp entry_loop2
2018-03-03 03:56:39 +00:00
2018-03-06 16:00:57 +00:00
bail: jmp invoke_selector_or_desktop
2018-03-07 02:36:51 +00:00
entry_num:
.byte 0
.endproc
2018-03-06 16:00:57 +00:00
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 16:12:30 +00:00
open_path2_io_buffer := $0800
DEFINE_OPEN_PARAMS open_path2_params, path2, open_path2_io_buffer
2018-03-07 02:36:51 +00:00
DEFINE_READ_PARAMS read_4bytes_params, buf_4_bytes, 4
buf_4_bytes: .res 4, 0
2018-03-07 05:36:55 +00:00
DEFINE_CLOSE_PARAMS close_params
DEFINE_READ_PARAMS read_39bytes_params, filename, 39
2018-03-07 02:36:51 +00:00
DEFINE_READ_PARAMS read_5bytes_params, buf_5_bytes, 5
buf_5_bytes: .res 5, 0
.res 4, 0
DEFINE_CLOSE_PARAMS close_srcdir_params
DEFINE_CLOSE_PARAMS close_dstdir_params
.byte 1
2018-03-05 03:38:55 +00:00
.addr path2
2018-03-04 03:27:31 +00:00
2018-03-07 16:12:30 +00:00
dircopy_buffer := $1100
dircopy_bufsize := $0B00
2018-03-04 03:43:41 +00:00
2018-03-07 16:12:30 +00:00
open_srcdir_io_buffer := $0D00
open_dstdir_io_buffer := $1C00
DEFINE_OPEN_PARAMS open_srcdir_params, path2, open_srcdir_io_buffer
DEFINE_OPEN_PARAMS open_dstdir_params, path1, open_dstdir_io_buffer
DEFINE_READ_PARAMS read_srcdir_params, dircopy_buffer, dircopy_bufsize
DEFINE_WRITE_PARAMS write_dstdir_params, dircopy_buffer, dircopy_bufsize
2018-03-07 02:36:51 +00:00
DEFINE_CREATE_PARAMS create_dir_params, path1, ACCESS_DEFAULT
2018-03-07 05:36:55 +00:00
DEFINE_CREATE_PARAMS create_params, path1, 0
2018-03-04 03:43:41 +00:00
2018-03-07 16:12:30 +00:00
.byte 0, 0
2018-03-04 04:03:42 +00:00
2018-03-05 03:38:55 +00:00
DEFINE_GET_FILE_INFO_PARAMS get_file_info_params2, path2
2018-03-07 16:12:30 +00:00
.byte 0
2018-03-04 04:03:42 +00:00
2018-03-05 03:38:55 +00:00
DEFINE_GET_FILE_INFO_PARAMS get_file_info_params3, path1
2018-03-07 02:36:51 +00:00
2018-03-04 04:03:42 +00:00
.byte $00,$02,$00,$00,$00
2018-03-04 03:27:31 +00:00
2018-03-07 05:36:55 +00:00
file_info:
filename:
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
2018-03-07 02:36:51 +00:00
.byte $00,$00,$00,$00,$00,$00,$00,$00
2018-03-03 04:22:09 +00:00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $40,$35,$3D,$35,$86,$31,$60,$00
2018-03-04 03:27:31 +00:00
2018-03-05 03:38:55 +00:00
path1: .res 65, 0
path2: .res 65, 0
2018-03-04 03:27:31 +00:00
L320A: .res 64, 0
L324A: .res 64, 0
2018-03-07 02:36:51 +00:00
L328A: .res 16, 0
2018-03-03 04:22:09 +00:00
L329A: .byte $00
2018-03-03 03:56:39 +00:00
L329B: .byte $0D
2018-03-03 04:22:09 +00:00
L329C: .byte $00
2018-03-07 02:36:51 +00:00
ref_num:.byte $00
2018-03-03 04:22:09 +00:00
L329E: .byte $00
2018-03-05 03:38:55 +00:00
L329F: .res 170, 0
2018-03-03 04:22:09 +00:00
L3349: .byte $00
L334A: .byte $00
2018-03-07 02:36:51 +00:00
;;; ============================================================
2018-03-15 03:16:15 +00:00
.proc L334B
ldx L3349
2018-03-03 03:56:39 +00:00
lda L329E
sta L329F,x
inx
stx L3349
rts
2018-03-15 03:16:15 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
2018-03-15 03:16:15 +00:00
.proc L3359
ldx L3349
2018-03-03 03:56:39 +00:00
dex
lda L329F,x
sta L329E
stx L3349
rts
2018-03-15 03:16:15 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
.proc L3367
lda #$00
2018-03-03 03:56:39 +00:00
sta L329C
sta L334A
2018-03-07 02:36:51 +00:00
MLI_CALL OPEN, open_path2_params
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
: lda open_path2_params::ref_num
sta ref_num
sta read_4bytes_params::ref_num
MLI_CALL READ, read_4bytes_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 06:44:28 +00:00
: jsr L33A4
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
2018-03-15 03:16:15 +00:00
.proc L3392
lda ref_num
2018-03-07 05:36:55 +00:00
sta close_params::ref_num
MLI_CALL CLOSE, close_params
2018-03-07 02:36:51 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-07 02:36:51 +00:00
: rts
2018-03-15 03:16:15 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
.proc L33A4
inc L329C
lda ref_num
sta read_39bytes_params::ref_num
MLI_CALL READ, read_39bytes_params
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-07 02:36:51 +00:00
: inc L334A
2018-03-03 03:56:39 +00:00
lda L334A
cmp L329B
2018-03-07 02:36:51 +00:00
bcc done
lda #0
2018-03-03 16:26:04 +00:00
sta L334A
2018-03-07 02:36:51 +00:00
lda ref_num
sta read_5bytes_params::ref_num
MLI_CALL READ, read_5bytes_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-07 02:36:51 +00:00
: lda read_5bytes_params::trans_count
cmp read_5bytes_params::request_count
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
done: return #0
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-15 03:16:15 +00:00
.proc L33E3
lda L329C
2018-03-03 03:56:39 +00:00
sta L329E
jsr L3392
jsr L334B
2018-03-07 05:36:55 +00:00
jsr append_filename_to_path2
2018-03-03 03:56:39 +00:00
jsr L3367
rts
2018-03-15 03:16:15 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-15 03:16:15 +00:00
.proc L33F6
jsr L3392
jsr noop
2018-03-07 05:36:55 +00:00
jsr remove_filename_from_path2
2018-03-03 03:56:39 +00:00
jsr L3359
jsr L3367
jsr L340C
2018-03-15 03:16:15 +00:00
jsr remove_filename_from_path1_alt2
2018-03-03 03:56:39 +00:00
rts
2018-03-15 03:16:15 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-15 03:16:15 +00:00
.proc L340C
lda L329C
2018-03-03 03:56:39 +00:00
cmp L329E
2018-03-07 02:36:51 +00:00
beq :+
2018-03-03 03:56:39 +00:00
jsr L33A4
jmp L340C
2018-03-07 02:36:51 +00:00
: rts
2018-03-15 03:16:15 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
.proc L341B
lda #$00
2018-03-03 03:56:39 +00:00
sta L329A
jsr L3367
2018-03-07 02:36:51 +00:00
loop: jsr L33A4
bne next
2018-03-07 05:36:55 +00:00
lda filename
2018-03-07 02:36:51 +00:00
beq loop
2018-03-07 05:36:55 +00:00
lda filename
2018-03-03 03:56:39 +00:00
sta L346F
and #$0F
2018-03-07 05:36:55 +00:00
sta filename
2018-03-03 03:56:39 +00:00
lda #$00
sta L3467
2018-03-15 03:16:15 +00:00
jsr do_copy_alt
2018-03-03 03:56:39 +00:00
lda L3467
2018-03-07 02:36:51 +00:00
bne loop
2018-03-07 05:36:55 +00:00
lda file_info + 16
2018-03-03 03:56:39 +00:00
cmp #$0F
2018-03-07 02:36:51 +00:00
bne loop
2018-03-03 03:56:39 +00:00
jsr L33E3
inc L329A
2018-03-07 02:36:51 +00:00
jmp loop
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
next: lda L329A
beq done
2018-03-03 03:56:39 +00:00
jsr L33F6
dec L329A
2018-03-07 02:36:51 +00:00
jmp loop
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
done: jsr L3392
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-03 03:57:30 +00:00
L3467: .byte 0
2018-03-07 02:36:51 +00:00
2018-03-15 03:16:15 +00:00
do_copy_alt:
jmp do_copy
2018-03-03 03:56:39 +00:00
2018-03-15 03:16:15 +00:00
remove_filename_from_path1_alt2:
jmp remove_filename_from_path1_alt
2018-03-03 03:56:39 +00:00
2018-03-15 03:16:15 +00:00
noop: rts
2018-03-03 03:56:39 +00:00
2018-03-03 03:57:30 +00:00
L346F: .byte 0
2018-03-07 02:36:51 +00:00
2018-03-07 16:12:30 +00:00
;;; ============================================================
;;; Unreferenced ???
.proc copy_input_to_path2
ldy #0
loop: lda IN,y
cmp #$80|CHAR_RETURN
beq done
and #CHAR_MASK
2018-03-05 03:38:55 +00:00
sta path2+1,y
2018-03-03 03:56:39 +00:00
iny
2018-03-07 16:12:30 +00:00
jmp loop
done: sty path2
2018-03-03 03:56:39 +00:00
rts
2018-03-07 16:12:30 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
.res 3, 0
2018-03-07 02:36:51 +00:00
2018-03-07 05:36:55 +00:00
.proc L3489
lda #$FF
2018-03-03 03:56:39 +00:00
sta L353B
jsr L3777
2018-03-05 03:38:55 +00:00
ldx path1
2018-03-04 19:35:04 +00:00
lda #'/'
2018-03-05 03:38:55 +00:00
sta path1+1,x
inc path1
2018-03-03 03:56:39 +00:00
ldy #$00
2018-03-05 03:38:55 +00:00
ldx path1
2018-03-07 02:36:51 +00:00
: iny
2018-03-03 03:56:39 +00:00
inx
lda L328A,y
2018-03-05 03:38:55 +00:00
sta path1,x
2018-03-03 03:56:39 +00:00
cpy L328A
2018-03-07 02:36:51 +00:00
bne :-
2018-03-05 03:38:55 +00:00
stx path1
2018-03-04 04:03:42 +00:00
MLI_CALL GET_FILE_INFO, get_file_info_params3
2018-03-06 05:20:00 +00:00
cmp #ERR_FILE_NOT_FOUND
2018-03-07 05:36:55 +00:00
beq okerr
2018-03-06 05:20:00 +00:00
cmp #ERR_VOL_NOT_FOUND
2018-03-07 05:36:55 +00:00
beq okerr
2018-03-06 05:20:00 +00:00
cmp #ERR_PATH_NOT_FOUND
2018-03-07 05:36:55 +00:00
beq okerr
2018-03-03 03:56:39 +00:00
rts
2018-03-07 05:36:55 +00:00
okerr: MLI_CALL GET_FILE_INFO, get_file_info_params2
2018-03-03 16:26:04 +00:00
beq L34DD
2018-03-06 05:20:00 +00:00
cmp #ERR_VOL_NOT_FOUND
2018-03-07 05:36:55 +00:00
beq prompt
2018-03-06 05:20:00 +00:00
cmp #ERR_FILE_NOT_FOUND
2018-03-07 05:36:55 +00:00
bne fail
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
prompt: jsr show_insert_prompt
jmp okerr
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
fail: jmp handle_error_code
2018-03-07 02:36:51 +00:00
2018-03-07 05:36:55 +00:00
L34DD: lda get_file_info_params2::storage_type
2018-03-06 05:24:21 +00:00
cmp #ST_VOLUME_DIRECTORY
2018-03-07 02:36:51 +00:00
beq is_dir
2018-03-06 05:24:21 +00:00
cmp #ST_LINKED_DIRECTORY
2018-03-07 02:36:51 +00:00
beq is_dir
2018-03-03 03:56:39 +00:00
lda #$00
2018-03-07 02:36:51 +00:00
beq :+
is_dir: lda #$FF
: sta is_dir_flag
2018-03-04 03:43:41 +00:00
;; copy file_type, aux_type, storage_type
ldy #7
2018-03-04 04:03:42 +00:00
: lda get_file_info_params2,y
2018-03-07 05:36:55 +00:00
sta create_params,y
2018-03-03 03:56:39 +00:00
dey
2018-03-04 03:43:41 +00:00
cpy #3
bne :-
2018-03-06 05:27:41 +00:00
lda #ACCESS_DEFAULT
2018-03-07 05:36:55 +00:00
sta create_params::access
2018-03-03 03:56:39 +00:00
jsr L35A9
2018-03-17 04:19:01 +00:00
bcc :+
2018-03-06 04:11:14 +00:00
jmp show_no_space_prompt
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;; copy dates
2018-03-17 04:19:01 +00:00
: ldx #3
2018-03-07 02:36:51 +00:00
: lda get_file_info_params2::create_date,x
2018-03-07 05:36:55 +00:00
sta create_params::create_date,x
2018-03-03 03:56:39 +00:00
dex
2018-03-07 02:36:51 +00:00
bpl :-
;; create the file
2018-03-07 05:36:55 +00:00
lda create_params::storage_type
2018-03-06 05:27:41 +00:00
cmp #ST_VOLUME_DIRECTORY
2018-03-07 02:36:51 +00:00
bne :+
2018-03-06 05:27:41 +00:00
lda #ST_LINKED_DIRECTORY
2018-03-07 05:36:55 +00:00
sta create_params::storage_type
: MLI_CALL CREATE, create_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
: lda is_dir_flag
beq do_dir
2018-03-03 03:56:39 +00:00
jmp L341B
2018-03-03 03:57:30 +00:00
.byte 0
2018-03-07 02:36:51 +00:00
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
do_dir: jmp copy_dir
is_dir_flag:
.byte 0
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-03 03:57:30 +00:00
L353B: .byte 0
L353C: .byte 0
2018-03-07 05:36:55 +00:00
2018-03-15 03:16:15 +00:00
remove_filename_from_path1_alt:
jmp remove_filename_from_path1
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
;;; ============================================================
2018-03-15 03:16:15 +00:00
.proc do_copy
2018-03-07 05:36:55 +00:00
lda file_info + 16 ; file_type ???
cmp #$0F ; FT_DIRECTORY ???
bne do_file
;; Directory ???
jsr append_filename_to_path2
2018-03-06 04:11:14 +00:00
jsr show_copying_screen
2018-03-04 04:03:42 +00:00
MLI_CALL GET_FILE_INFO, get_file_info_params2
2018-03-07 05:36:55 +00:00
beq ok
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-07 05:36:55 +00:00
onerr: jsr remove_filename_from_path1
jsr remove_filename_from_path2
2018-03-03 03:56:39 +00:00
lda #$FF
sta L3467
2018-03-07 05:36:55 +00:00
jmp exit
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
ok: jsr append_filename_to_path1
2018-03-07 02:36:51 +00:00
jsr create_dir
2018-03-07 05:36:55 +00:00
bcs onerr
jsr remove_filename_from_path2
jmp exit
;; File ???
do_file:
jsr append_filename_to_path1
jsr append_filename_to_path2
2018-03-06 04:11:14 +00:00
jsr show_copying_screen
2018-03-04 04:03:42 +00:00
MLI_CALL GET_FILE_INFO, get_file_info_params2
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 03:56:39 +00:00
2018-03-03 06:44:28 +00:00
: jsr L35A9
2018-03-07 05:36:55 +00:00
bcc :+
2018-03-06 04:11:14 +00:00
jmp show_no_space_prompt
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
: jsr remove_filename_from_path2
2018-03-07 02:36:51 +00:00
jsr create_dir
2018-03-07 05:36:55 +00:00
bcs cleanup
jsr append_filename_to_path2
2018-03-07 02:36:51 +00:00
jsr copy_dir
2018-03-07 05:36:55 +00:00
jsr remove_filename_from_path2
2018-03-07 02:36:51 +00:00
jsr remove_filename_from_path1
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
exit: rts
cleanup:
jsr remove_filename_from_path1
2018-03-03 03:56:39 +00:00
rts
2018-03-07 05:36:55 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
.proc L35A9
MLI_CALL GET_FILE_INFO, get_file_info_params2
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
: lda #0
2018-03-03 03:56:39 +00:00
sta L3641
2018-03-07 05:36:55 +00:00
sta L3641+1
2018-03-04 04:03:42 +00:00
MLI_CALL GET_FILE_INFO, get_file_info_params3
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 05:20:00 +00:00
cmp #ERR_FILE_NOT_FOUND
2018-03-03 03:56:39 +00:00
beq L35D7
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 03:56:39 +00:00
2018-03-04 04:03:42 +00:00
: copy16 get_file_info_params3::blocks_used, L3641
2018-03-05 03:38:55 +00:00
L35D7: lda path1
2018-03-03 03:56:39 +00:00
sta L363F
ldy #$01
L35DF: iny
2018-03-05 03:38:55 +00:00
cpy path1
2018-03-03 03:56:39 +00:00
bcs L3635
2018-03-05 03:38:55 +00:00
lda path1,y
2018-03-04 19:35:04 +00:00
cmp #'/'
2018-03-03 03:56:39 +00:00
bne L35DF
tya
2018-03-05 03:38:55 +00:00
sta path1
2018-03-03 03:56:39 +00:00
sta L3640
2018-03-04 04:03:42 +00:00
MLI_CALL GET_FILE_INFO, get_file_info_params3
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 03:56:39 +00:00
2018-03-04 04:03:42 +00:00
: sub16 get_file_info_params3::aux_type, get_file_info_params3::blocks_used, L363D
2018-03-03 03:57:30 +00:00
sub16 L363D, L3641, L363D
2018-03-04 04:03:42 +00:00
cmp16 L363D, get_file_info_params2::blocks_used
2018-03-03 03:56:39 +00:00
bcs L3635
sec
2018-03-17 04:19:01 +00:00
bcs :+
2018-03-03 03:56:39 +00:00
L3635: clc
2018-03-17 04:19:01 +00:00
: lda L363F
2018-03-05 03:38:55 +00:00
sta path1
2018-03-03 03:56:39 +00:00
rts
2018-03-07 05:36:55 +00:00
L363D: .word 0
2018-03-03 03:57:30 +00:00
L363F: .byte 0
L3640: .byte 0
2018-03-07 05:36:55 +00:00
L3641: .word 0
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
2018-03-04 19:35:04 +00:00
2018-03-07 02:36:51 +00:00
.proc copy_dir
MLI_CALL OPEN, open_srcdir_params
beq :+
jsr handle_error_code
: MLI_CALL OPEN, open_dstdir_params
beq :+
jmp handle_error_code
: lda open_srcdir_params::ref_num
sta read_srcdir_params::ref_num
sta close_srcdir_params::ref_num
lda open_dstdir_params::ref_num
sta write_dstdir_params::ref_num
sta close_dstdir_params::ref_num
2018-03-07 16:12:30 +00:00
loop: copy16 #dircopy_bufsize, read_srcdir_params::request_count
2018-03-07 02:36:51 +00:00
MLI_CALL READ, read_srcdir_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 05:20:00 +00:00
cmp #ERR_END_OF_FILE
2018-03-07 02:36:51 +00:00
beq finish
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
: copy16 read_srcdir_params::trans_count, write_dstdir_params::request_count
ora read_srcdir_params::trans_count
beq finish
MLI_CALL WRITE, write_dstdir_params
2018-03-03 06:44:28 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
: lda write_dstdir_params::trans_count
2018-03-07 16:12:30 +00:00
cmp #<dircopy_bufsize
2018-03-07 02:36:51 +00:00
bne finish
lda write_dstdir_params::trans_count+1
2018-03-07 16:12:30 +00:00
cmp #>dircopy_bufsize
2018-03-07 02:36:51 +00:00
beq loop
finish: MLI_CALL CLOSE, close_dstdir_params
MLI_CALL CLOSE, close_srcdir_params
2018-03-04 19:35:04 +00:00
jsr get_file_info_and_copy
jsr do_set_file_info
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
.proc create_dir
2018-03-07 05:36:55 +00:00
;; Copy file_type, aux_type, storage_type
2018-03-07 02:36:51 +00:00
ldx #7
2018-03-04 04:03:42 +00:00
: lda get_file_info_params2,x
2018-03-07 02:36:51 +00:00
sta create_dir_params,x
2018-03-03 03:56:39 +00:00
dex
2018-03-04 03:43:41 +00:00
cpx #3
bne :-
2018-03-06 05:27:41 +00:00
lda #ACCESS_DEFAULT
2018-03-07 02:36:51 +00:00
sta create_dir_params::access
;; Copy dates
ldx #3
: lda get_file_info_params2::create_date,x
sta create_dir_params::create_date,x
2018-03-03 03:56:39 +00:00
dex
2018-03-07 02:36:51 +00:00
bpl :-
;; Create it
lda create_dir_params::storage_type
2018-03-06 05:27:41 +00:00
cmp #ST_VOLUME_DIRECTORY
2018-03-07 02:36:51 +00:00
bne :+
2018-03-06 05:27:41 +00:00
lda #ST_LINKED_DIRECTORY
2018-03-07 02:36:51 +00:00
sta create_dir_params::storage_type
: MLI_CALL CREATE, create_dir_params
2018-03-03 06:44:28 +00:00
clc
2018-03-07 02:36:51 +00:00
beq :+
2018-03-06 04:11:14 +00:00
jmp handle_error_code
2018-03-07 02:36:51 +00:00
: rts
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
.res 4, 0
2018-03-05 03:38:55 +00:00
2018-03-07 05:36:55 +00:00
;;; ============================================================
.proc append_filename_to_path2
lda filename
bne :+
2018-03-03 03:56:39 +00:00
rts
2018-03-07 05:36:55 +00:00
: ldx #$00
2018-03-05 03:38:55 +00:00
ldy path2
2018-03-04 19:35:04 +00:00
lda #'/'
2018-03-05 03:38:55 +00:00
sta path2+1,y
2018-03-03 03:56:39 +00:00
iny
2018-03-07 05:36:55 +00:00
loop: cpx filename
bcs done
lda filename+1,x
2018-03-05 03:38:55 +00:00
sta path2+1,y
2018-03-03 03:56:39 +00:00
inx
iny
2018-03-07 05:36:55 +00:00
jmp loop
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
done: sty path2
2018-03-03 03:56:39 +00:00
rts
2018-03-07 05:36:55 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
.proc remove_filename_from_path2
ldx path2
bne loop
2018-03-03 03:56:39 +00:00
rts
2018-03-07 05:36:55 +00:00
loop: lda path2,x
2018-03-04 19:35:04 +00:00
cmp #'/'
2018-03-07 05:36:55 +00:00
beq done
2018-03-03 03:56:39 +00:00
dex
2018-03-07 05:36:55 +00:00
bne loop
2018-03-05 03:38:55 +00:00
stx path2
2018-03-03 03:56:39 +00:00
rts
2018-03-07 05:36:55 +00:00
done: dex
2018-03-05 03:38:55 +00:00
stx path2
2018-03-03 03:56:39 +00:00
rts
2018-03-07 05:36:55 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
.proc append_filename_to_path1
2018-03-07 05:36:55 +00:00
lda filename
2018-03-07 02:36:51 +00:00
bne :+
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
: ldx #0
2018-03-05 03:38:55 +00:00
ldy path1
2018-03-04 19:35:04 +00:00
lda #'/'
2018-03-05 03:38:55 +00:00
sta path1+1,y
2018-03-03 03:56:39 +00:00
iny
2018-03-07 05:36:55 +00:00
loop: cpx filename
2018-03-07 02:36:51 +00:00
bcs done
2018-03-07 05:36:55 +00:00
lda filename+1,x
2018-03-05 03:38:55 +00:00
sta path1+1,y
2018-03-03 03:56:39 +00:00
inx
iny
2018-03-07 02:36:51 +00:00
jmp loop
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
done: sty path1
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
.proc remove_filename_from_path1
ldx path1
bne loop
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
loop: lda path1,x
2018-03-04 19:35:04 +00:00
cmp #'/'
2018-03-07 02:36:51 +00:00
beq done
2018-03-03 03:56:39 +00:00
dex
2018-03-07 02:36:51 +00:00
bne loop
2018-03-05 03:38:55 +00:00
stx path1
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
done: dex
2018-03-05 03:38:55 +00:00
stx path1
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
;;; ============================================================
.proc L3777
ldy #0
2018-03-03 03:56:39 +00:00
sta L353C
dey
2018-03-07 02:36:51 +00:00
loop: iny
2018-03-03 03:56:39 +00:00
lda L324A,y
2018-03-04 19:35:04 +00:00
cmp #'/'
2018-03-07 02:36:51 +00:00
bne :+
2018-03-03 03:56:39 +00:00
sty L353C
2018-03-07 02:36:51 +00:00
: sta path2,y
2018-03-03 03:56:39 +00:00
cpy L324A
2018-03-07 02:36:51 +00:00
bne loop
2018-03-03 03:56:39 +00:00
ldy L320A
2018-03-07 02:36:51 +00:00
loop2: lda L320A,y
2018-03-05 03:38:55 +00:00
sta path1,y
2018-03-03 03:56:39 +00:00
dey
2018-03-07 02:36:51 +00:00
bpl loop2
2018-03-03 03:56:39 +00:00
rts
2018-03-07 02:36:51 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-04 19:35:04 +00:00
.proc do_set_file_info
lda #7 ; SET_FILE_INFO param_count
2018-03-04 04:03:42 +00:00
sta get_file_info_params3
MLI_CALL SET_FILE_INFO, get_file_info_params3
2018-03-04 19:35:04 +00:00
lda #10 ; GET_FILE_INFO param_count
2018-03-04 04:03:42 +00:00
sta get_file_info_params3
2018-03-03 03:56:39 +00:00
rts
2018-03-04 19:35:04 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-04 19:35:04 +00:00
.proc get_file_info_and_copy
MLI_CALL GET_FILE_INFO, get_file_info_params2
bne fail
2018-03-03 03:56:39 +00:00
ldx #$0A
2018-03-04 19:35:04 +00:00
: lda get_file_info_params2::access,x
2018-03-04 04:03:42 +00:00
sta get_file_info_params3::access,x
2018-03-03 03:56:39 +00:00
dex
2018-03-04 19:35:04 +00:00
bpl :-
2018-03-03 03:56:39 +00:00
rts
2018-03-04 19:35:04 +00:00
fail: pla
2018-03-03 03:56:39 +00:00
pla
rts
2018-03-04 19:35:04 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 16:00:57 +00:00
;;; ============================================================
2018-03-07 02:36:51 +00:00
;;; Compute first offset into selector file - A*16 + 2
2018-03-06 16:00:57 +00:00
2018-03-07 02:36:51 +00:00
.proc compute_label_addr
2018-03-06 16:00:57 +00:00
addr := selector_buffer + $2
jsr ax_times_16
2018-03-03 03:56:39 +00:00
clc
2018-03-06 16:00:57 +00:00
adc #<addr
2018-03-03 03:56:39 +00:00
tay
txa
2018-03-06 16:00:57 +00:00
adc #>addr
2018-03-03 03:56:39 +00:00
tax
tya
rts
2018-03-06 16:00:57 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 16:00:57 +00:00
;;; ============================================================
2018-03-07 02:36:51 +00:00
;;; Compute second offset into selector file - A*64 + $182
2018-03-06 16:00:57 +00:00
2018-03-07 02:36:51 +00:00
.proc compute_path_addr
2018-03-06 16:00:57 +00:00
addr := selector_buffer + $182
jsr ax_times_64
2018-03-03 03:56:39 +00:00
clc
2018-03-06 16:00:57 +00:00
adc #<addr
2018-03-03 03:56:39 +00:00
tay
txa
2018-03-06 16:00:57 +00:00
adc #>addr
2018-03-03 03:56:39 +00:00
tax
tya
rts
2018-03-06 16:00:57 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-04 02:39:21 +00:00
.byte $00,$00
2018-03-03 16:26:04 +00:00
2018-03-04 22:01:19 +00:00
;;; ============================================================
.proc read_selector_list_impl
2018-03-07 16:12:30 +00:00
open_io_buffer := $4000
DEFINE_OPEN_PARAMS open_params, str_selector_list, open_io_buffer
2018-03-04 03:27:31 +00:00
str_selector_list:
PASCAL_STRING "Selector.List"
2018-03-06 16:00:57 +00:00
DEFINE_READ_PARAMS read_params, selector_buffer, selector_buflen
2018-03-04 22:01:19 +00:00
DEFINE_CLOSE_PARAMS close_params
start: MLI_CALL OPEN, open_params
bne :+
lda open_params::ref_num
sta read_params::ref_num
MLI_CALL READ, read_params
MLI_CALL CLOSE, close_params
lda #0
: rts
.endproc
read_selector_list := read_selector_list_impl::start
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-06 16:00:57 +00:00
.proc ax_times_16
ldx #0
stx bits
.repeat 4
2018-03-03 03:56:39 +00:00
asl a
2018-03-06 16:00:57 +00:00
rol bits
.endrepeat
ldx bits
2018-03-03 03:56:39 +00:00
rts
2018-03-06 16:00:57 +00:00
bits: .byte 0
.endproc
;;; ============================================================
.proc ax_times_64
ldx #0
stx bits
.repeat 6
2018-03-03 03:56:39 +00:00
asl a
2018-03-06 16:00:57 +00:00
rol bits
.endrepeat
ldx bits
2018-03-03 03:56:39 +00:00
rts
2018-03-06 16:00:57 +00:00
bits: .byte $00
.endproc
2018-03-05 03:38:55 +00:00
;;; ============================================================
.proc invoke_selector_or_desktop_impl
sys_start := $2000
2018-03-07 16:12:30 +00:00
sys_size := $400
open_dt2_io_buffer := $5000
open_sel_io_buffer := $5400
2018-03-05 03:38:55 +00:00
2018-03-07 16:12:30 +00:00
DEFINE_OPEN_PARAMS open_desktop2_params, str_desktop2, open_dt2_io_buffer
DEFINE_OPEN_PARAMS open_selector_params, str_selector, open_sel_io_buffer
DEFINE_READ_PARAMS read_params, sys_start, sys_size
2018-03-05 03:38:55 +00:00
DEFINE_CLOSE_PARAMS close_everything_params
2018-03-04 03:43:41 +00:00
str_selector:
2018-03-03 04:53:10 +00:00
PASCAL_STRING "Selector"
2018-03-04 03:43:41 +00:00
str_desktop2:
2018-03-03 04:53:10 +00:00
PASCAL_STRING "DeskTop2"
2018-03-03 06:44:28 +00:00
2018-03-05 03:38:55 +00:00
start: MLI_CALL CLOSE, close_everything_params
MLI_CALL OPEN, open_selector_params
beq selector
MLI_CALL OPEN, open_desktop2_params
beq desktop2
2018-03-03 03:56:39 +00:00
2018-03-05 03:38:55 +00:00
brk ; just crash
desktop2:
lda open_desktop2_params::ref_num
jmp read
selector:
lda open_selector_params::ref_num
read: sta read_params::ref_num
MLI_CALL READ, read_params
MLI_CALL CLOSE, close_everything_params
jmp sys_start
.endproc
invoke_selector_or_desktop := invoke_selector_or_desktop_impl::start
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
.proc L38B2
ptr := $6
stax ptr
2018-03-03 03:56:39 +00:00
ldy #$00
2018-03-07 05:36:55 +00:00
lda (ptr),y
2018-03-17 04:19:01 +00:00
2018-03-03 03:56:39 +00:00
tay
2018-03-17 04:19:01 +00:00
: lda (ptr),y
2018-03-03 03:56:39 +00:00
sta L324A,y
dey
2018-03-17 04:19:01 +00:00
bpl :-
2018-03-03 03:56:39 +00:00
ldy L324A
2018-03-17 04:19:01 +00:00
: lda L324A,y
and #CHAR_MASK
2018-03-04 19:35:04 +00:00
cmp #'/'
2018-03-03 03:56:39 +00:00
beq L38D2
dey
2018-03-17 04:19:01 +00:00
bne :-
2018-03-03 03:56:39 +00:00
L38D2: dey
sty L324A
L38D6: lda L324A,y
and #CHAR_MASK
2018-03-04 19:35:04 +00:00
cmp #'/'
2018-03-17 04:19:01 +00:00
beq :+
2018-03-03 03:56:39 +00:00
dey
bpl L38D6
2018-03-17 04:19:01 +00:00
: ldx #$00
: iny
2018-03-03 03:56:39 +00:00
inx
lda L324A,y
sta L328A,x
cpy L324A
2018-03-17 04:19:01 +00:00
bne :-
2018-03-03 03:56:39 +00:00
stx L328A
2018-03-04 19:35:04 +00:00
lda LCBANK2
lda LCBANK2
2018-03-17 04:19:01 +00:00
2018-03-03 03:56:39 +00:00
ldy $D3EE
2018-03-17 04:19:01 +00:00
: lda $D3EE,y
2018-03-03 03:56:39 +00:00
sta L320A,y
dey
2018-03-17 04:19:01 +00:00
bpl :-
2018-03-03 06:44:28 +00:00
lda ROMIN2
rts
2018-03-07 05:36:55 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-04 04:03:42 +00:00
str_copying:
2018-03-03 04:53:10 +00:00
PASCAL_STRING "Copying:"
2018-03-04 04:03:42 +00:00
str_insert:
2018-03-03 04:53:10 +00:00
PASCAL_STRING "Insert the source disk and press <Return> to continue or <ESC> to cancel"
2018-03-04 04:03:42 +00:00
str_not_enough:
2018-03-03 04:53:10 +00:00
PASCAL_STRING "Not enough room in the RAMCard, press <Return> to continue"
2018-03-04 04:03:42 +00:00
str_error:
2018-03-03 04:53:10 +00:00
PASCAL_STRING "Error $"
2018-03-04 04:03:42 +00:00
str_occured:
2018-03-03 04:53:10 +00:00
PASCAL_STRING " occured when copying "
2018-03-04 04:03:42 +00:00
str_not_completed:
2018-03-03 04:53:10 +00:00
PASCAL_STRING "The copy was not completed, press <Return> to continue."
2018-03-04 04:03:42 +00:00
2018-03-06 04:11:14 +00:00
;;; ============================================================
.proc show_copying_screen
jsr HOME
lda #0
2018-03-03 04:06:58 +00:00
jsr VTABZ
2018-03-06 04:11:14 +00:00
lda #0
jsr set_htab
2018-03-04 05:33:40 +00:00
addr_call cout_string, str_copying
2018-03-05 03:38:55 +00:00
addr_call cout_string_newline, path2
2018-03-03 03:56:39 +00:00
rts
2018-03-06 04:11:14 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
.proc show_insert_prompt
lda #0
2018-03-03 04:06:58 +00:00
jsr VTABZ
2018-03-06 04:11:14 +00:00
lda #0
jsr set_htab
2018-03-04 05:33:40 +00:00
addr_call cout_string, str_insert
jsr wait_enter_escape
cmp #CHAR_ESCAPE
2018-03-06 04:11:14 +00:00
bne :+
jmp finish_and_invoke
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
: jsr HOME
2018-03-03 03:56:39 +00:00
rts
2018-03-06 04:11:14 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
.proc show_no_space_prompt
lda #0
2018-03-03 04:22:09 +00:00
jsr VTABZ
2018-03-06 04:11:14 +00:00
lda #0
jsr set_htab
2018-03-04 05:33:40 +00:00
addr_call cout_string, str_not_enough
jsr wait_enter_escape
2018-03-03 03:56:39 +00:00
jsr HOME
2018-03-05 03:38:55 +00:00
jmp invoke_selector_or_desktop
2018-03-06 04:11:14 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
.proc handle_error_code
2018-03-06 05:20:00 +00:00
cmp #ERR_OVERRUN_ERROR
2018-03-05 03:38:55 +00:00
bne :+
2018-03-06 04:11:14 +00:00
jsr show_no_space_prompt
jmp finish_and_invoke
2018-03-03 03:56:39 +00:00
2018-03-06 05:20:00 +00:00
: cmp #ERR_VOLUME_DIR_FULL
2018-03-04 19:35:04 +00:00
bne show_error
2018-03-06 04:11:14 +00:00
jsr show_no_space_prompt
jmp finish_and_invoke
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-04 19:35:04 +00:00
.proc show_error
;; Show error
pha
2018-03-04 05:33:40 +00:00
addr_call cout_string, str_error
2018-03-03 03:56:39 +00:00
pla
2018-03-03 04:06:58 +00:00
jsr PRBYTE
2018-03-04 05:33:40 +00:00
addr_call cout_string, str_occured
2018-03-05 03:38:55 +00:00
addr_call cout_string_newline, path2
2018-03-04 05:33:40 +00:00
addr_call cout_string, str_not_completed
2018-03-04 19:35:04 +00:00
;; Wait for keyboard
2018-03-04 05:33:40 +00:00
sta KBDSTRB
2018-03-15 03:16:15 +00:00
loop: lda KBD
2018-03-04 19:35:04 +00:00
bpl loop
and #CHAR_MASK
2018-03-04 05:33:40 +00:00
sta KBDSTRB
2018-03-04 19:35:04 +00:00
cmp #'M'
2018-03-15 03:16:15 +00:00
beq monitor
2018-03-04 19:35:04 +00:00
cmp #'m'
2018-03-15 03:16:15 +00:00
beq monitor
2018-03-04 19:35:04 +00:00
cmp #CHAR_RETURN
bne loop
2018-03-03 03:56:39 +00:00
jsr HOME
2018-03-05 03:38:55 +00:00
jmp invoke_selector_or_desktop
2018-03-04 19:35:04 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-15 03:16:15 +00:00
monitor:
jmp MONZ
2018-03-03 03:56:39 +00:00
2018-03-04 19:35:04 +00:00
;;; ============================================================
2018-03-04 05:33:40 +00:00
.proc cout_string_newline
jsr cout_string
lda #$80|CHAR_RETURN
2018-03-03 03:56:39 +00:00
jmp COUT
2018-03-04 05:33:40 +00:00
;; fall through
.endproc
2018-03-03 03:56:39 +00:00
2018-03-04 05:33:40 +00:00
.proc cout_string
ptr := $6
stax ptr
ldy #0
lda (ptr),y
sta len
beq done
loop: iny
2018-03-03 03:56:39 +00:00
lda ($06),y
ora #$80
jsr COUT
2018-03-04 05:33:40 +00:00
len := *+1
2018-03-04 19:35:04 +00:00
cpy #0 ; self-modified
2018-03-04 05:33:40 +00:00
bne loop
done: rts
.endproc
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
.proc set_htab
sta CH
2018-03-03 03:56:39 +00:00
rts
2018-03-06 04:11:14 +00:00
.endproc
2018-03-03 03:56:39 +00:00
2018-03-04 05:33:40 +00:00
;;; ============================================================
.proc wait_enter_escape
lda KBD
bpl wait_enter_escape
sta KBDSTRB
and #CHAR_MASK
2018-03-04 05:33:40 +00:00
cmp #CHAR_ESCAPE
beq done
cmp #CHAR_RETURN
bne wait_enter_escape
done: rts
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-06 04:11:14 +00:00
.proc finish_and_invoke
jsr HOME
2018-03-05 03:38:55 +00:00
jmp invoke_selector_or_desktop
2018-03-06 04:11:14 +00:00
.endproc
;;; ============================================================
2018-03-03 03:56:39 +00:00
2018-03-07 02:36:51 +00:00
.endproc ; copy_selector_entries_to_ramcard
2018-03-04 19:35:04 +00:00
2018-03-07 05:36:55 +00:00
.assert * = $3AD8, error, "Segment size mismatch"
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
;;; ============================================================
;;; This is a chunk of BASIC.SYSTEM 1.1 !!
;;; (ends up in memory at $B0D8, file offset TBD)
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
.incbin "inc/bs.dat"
2018-03-03 03:56:39 +00:00
2018-03-07 05:36:55 +00:00
.assert * = $4000, error, "Segment size mismatch"