This commit is contained in:
Joshua Bell 2019-01-07 21:15:54 -08:00
parent 6c0f888b07
commit f9a63cea8b
2 changed files with 56 additions and 24 deletions

1
bell.s
View File

@ -5,5 +5,6 @@ BELL := $FBE4
.org $4000 .org $4000
ldy #0
jsr BELL jsr BELL
rts rts

79
path.s
View File

@ -16,7 +16,7 @@
;;; ;;;
;;; Installed command memory structure: ;;; Installed command memory structure:
;;; * 2 pages - code, path buffer ;;; * 2 pages - code, path buffer
;;; * 2 pages - I/O buffer ;;; * 4 pages - I/O buffer
;;; TODO: ;;; TODO:
;;; * Dynamically allocate I/O buffer ;;; * Dynamically allocate I/O buffer
@ -58,9 +58,9 @@ CASE_MASK = $DF
lda EXTRNCMD+2 lda EXTRNCMD+2
sta next_command+1 sta next_command+1
;; Request a 4-page buffer - two pages for handler, ;; Request a 6-page buffer - 2 pages for handler,
;; two pages for I/O buffer. ;; 4 pages for I/O buffer.
lda #4 lda #6
jsr GETBUFR jsr GETBUFR
bcc :+ bcc :+
lda #$C ; NO BUFFERS AVAILABLE lda #$C ; NO BUFFERS AVAILABLE
@ -68,9 +68,8 @@ CASE_MASK = $DF
: sta new_page ; A = MSB of new page : sta new_page ; A = MSB of new page
;; Compute move delta in pages ;; Compute move delta in pages
lda #>handler
sec sec
sbc new_page sbc #>handler
sta page_delta sta page_delta
;; Relocatable routine is aligned to page boundary so only MSB changes ;; Relocatable routine is aligned to page boundary so only MSB changes
@ -83,10 +82,10 @@ CASE_MASK = $DF
lda relocation_table+2,y lda relocation_table+2,y
sta ptr+1 sta ptr+1
lda (ptr),y lda (ptr)
clc clc
adc page_delta adc page_delta
sta (ptr),y sta (ptr)
inx inx
cpx relocation_table cpx relocation_table
bne :- bne :-
@ -162,7 +161,7 @@ nxtchr: lda INBUF,x
;; Set accepted parameter flags (Name, Slot/Drive) ;; Set accepted parameter flags (Name, Slot/Drive)
lda #PBitsFlags::FN1 ; Filename lda #PBitsFlags::FNOPT | PBitsFlags::FN1 ; Filename (optional)
sta PBITS sta PBITS
lda #PBitsFlags::SD ; Slot & Drive handling lda #PBitsFlags::SD ; Slot & Drive handling
@ -175,6 +174,7 @@ nxtchr: lda INBUF,x
check_if_token: check_if_token:
;; Is a PATH set? ;; Is a PATH set?
page_num18 := *+2 ; address needing updating
lda path_buffer lda path_buffer
beq not_ours beq not_ours
@ -248,7 +248,7 @@ access: .byte 0
file_type: .byte 0 file_type: .byte 0
aux_type: .word 0 aux_type: .word 0
storage_type: .byte 0 storage_type: .byte 0
blocks_used: .byte 0 blocks_used: .word 0
mod_date: .word 0 mod_date: .word 0
mod_time: .word 0 mod_time: .word 0
create_date: .word 0 create_date: .word 0
@ -281,47 +281,56 @@ ref_num: .byte 0
maybe_invoke: maybe_invoke:
;; Compose path ;; Compose path
ldx #0 ldx #0
: lda path_buffer+1,x ; TODO: absolute refs page_num12 := *+2 ; address needing updating
sta command_path_buffer+1,x ; TODO: absolute refs : lda path_buffer+1,x
page_num13 := *+2 ; address needing updating
sta command_path_buffer+1,x
inx inx
page_num14 := *+2 ; address needing updating
cpx path_buffer cpx path_buffer
bne :- bne :-
lda #'/' lda #'/'
page_num15 := *+2 ; address needing updating
sta command_path_buffer+1,x sta command_path_buffer+1,x
inx inx
ldy #0 ldy #0
: lda INBUF,y : lda INBUF,y
cmp #'.'|$80 and #$7F
beq @ok cmp #'.'
beq ok
cmp #'0' cmp #'0'
bcc @notok bcc notok
cmp #'9'+1 cmp #'9'+1
bcc @ok bcc ok
cmp #'A' cmp #'A'
bcc @notok bcc notok
cmp #'Z'+1 cmp #'Z'+1
bcc @ok bcc ok
cmp #'a' cmp #'a'
bcc @notok bcc notok
cmp #'z'+1 cmp #'z'+1
bcs @notok bcs notok
@ok: sta command_path_buffer+1,x page_num16 := *+2 ; address needing updating
ok: sta command_path_buffer+1,x
inx inx
iny iny
bne :- bne :-
@notok: stx command_path_buffer page_num17 := *+2 ; address needing updating
notok: stx command_path_buffer
jsr MLI jsr MLI
.byte GET_FILE_INFO .byte GET_FILE_INFO
page_num19 := *+1
.addr get_file_info_params .addr get_file_info_params
beq :+ beq :+
sec ; no such file - signal it's not us sec ; no such file - signal it's not us
rts rts
page_num23 := *+2
: lda get_file_info_params::file_type : lda get_file_info_params::file_type
cmp #$F0 ; CMD cmp #$F0 ; CMD
beq :+ beq :+
@ -343,17 +352,22 @@ maybe_invoke:
;; Now try to open/read/close and invoke it ;; Now try to open/read/close and invoke it
jsr MLI jsr MLI
.byte OPEN .byte OPEN
page_num20 := *+1
.addr open_params .addr open_params
beq :+ beq :+
lda #8 ; I/O ERROR - TODO: is this used??? lda #8 ; I/O ERROR - TODO: is this used???
sec sec
rts rts
page_num24 := *+2
: lda open_params::ref_num : lda open_params::ref_num
page_num25 := *+2
sta read_params::ref_num sta read_params::ref_num
page_num26 := *+2
sta close_params::ref_num sta close_params::ref_num
jsr MLI jsr MLI
.byte READ .byte READ
page_num21 := *+1
.addr read_params .addr read_params
beq :+ beq :+
lda #8 ; I/O ERROR - TODO: is this used??? lda #8 ; I/O ERROR - TODO: is this used???
@ -362,6 +376,7 @@ maybe_invoke:
: jsr MLI : jsr MLI
.byte CLOSE .byte CLOSE
page_num22 := *+1
.addr close_params .addr close_params
;; Invoke command ;; Invoke command
@ -404,7 +419,7 @@ done: clc
set_path: set_path:
lda VPATH1 lda VPATH1
sta ptr sta ptr
ldx VPATH1+1 lda VPATH1+1
sta ptr+1 sta ptr+1
ldy #0 ldy #0
@ -452,7 +467,7 @@ page_delta:
.byte 0 .byte 0
relocation_table: relocation_table:
.byte 5 .byte (table_end - *) / 2
.addr handler::page_num1 .addr handler::page_num1
.addr handler::page_num2 .addr handler::page_num2
.addr handler::page_num3 .addr handler::page_num3
@ -464,3 +479,19 @@ relocation_table:
.addr handler::page_num9 .addr handler::page_num9
.addr handler::page_num10 .addr handler::page_num10
.addr handler::page_num11 .addr handler::page_num11
.addr handler::page_num12
.addr handler::page_num13
.addr handler::page_num14
.addr handler::page_num15
.addr handler::page_num16
.addr handler::page_num17
.addr handler::page_num18
.addr handler::page_num19
.addr handler::page_num20
.addr handler::page_num21
.addr handler::page_num22
.addr handler::page_num23
.addr handler::page_num24
.addr handler::page_num25
.addr handler::page_num26
table_end := *