mirror of
https://github.com/a2stuff/prodos-path.git
synced 2024-06-06 04:29:30 +00:00
dynamically allocated load buffer
This commit is contained in:
parent
55daa9a905
commit
aa409cebc5
33
path.s
33
path.s
|
@ -14,11 +14,9 @@
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;;
|
;;;
|
||||||
;;; Installed command memory structure:
|
;;; Installed command memory structure:
|
||||||
;;; * 2 pages - code, path buffer
|
;;; * 3 pages - code, path buffers
|
||||||
;;; * 4 pages - I/O buffer
|
|
||||||
|
|
||||||
;;; TODO:
|
;;; TODO:
|
||||||
;;; * Dynamically allocate I/O buffer
|
|
||||||
;;; * Support multi-segment path (e.g. /hd/bin:/hd/extras/bin
|
;;; * Support multi-segment path (e.g. /hd/bin:/hd/extras/bin
|
||||||
;;; * Fail install if on an Integer BASIC machine
|
;;; * Fail install if on an Integer BASIC machine
|
||||||
;;; * Skip leading spaces
|
;;; * Skip leading spaces
|
||||||
|
@ -57,16 +55,23 @@ CASE_MASK = $DF
|
||||||
lda EXTRNCMD+2
|
lda EXTRNCMD+2
|
||||||
sta next_command+1
|
sta next_command+1
|
||||||
|
|
||||||
;; Request a 6-page buffer - 2 pages for handler,
|
;; Request a buffer for handler.
|
||||||
;; 4 pages for I/O buffer.
|
lda #handler_pages
|
||||||
lda #6
|
|
||||||
jsr GETBUFR
|
jsr GETBUFR
|
||||||
bcc :+
|
bcc :+
|
||||||
lda #$C ; NO BUFFERS AVAILABLE
|
lda #$C ; NO BUFFERS AVAILABLE
|
||||||
rts
|
rts
|
||||||
: sta new_page ; A = MSB of new page
|
: sta new_page ; A = MSB of new page
|
||||||
|
|
||||||
|
;; Reserve buffer permanently.
|
||||||
|
;; ProDOS Technical Note #9: Buffer Management Using BASIC.SYSTEM
|
||||||
|
lda RSHIMEM
|
||||||
|
sec
|
||||||
|
sbc #handler_pages
|
||||||
|
sta RSHIMEM
|
||||||
|
|
||||||
;; Compute move delta in pages
|
;; Compute move delta in pages
|
||||||
|
lda new_page
|
||||||
sec
|
sec
|
||||||
sbc #>handler
|
sbc #>handler
|
||||||
sta page_delta
|
sta page_delta
|
||||||
|
@ -348,12 +353,22 @@ notok: stx command_path_buffer
|
||||||
lda #>XRETURN
|
lda #>XRETURN
|
||||||
sta XTRNADDR+1
|
sta XTRNADDR+1
|
||||||
|
|
||||||
|
;; Reserve buffer for I/O
|
||||||
|
lda #4
|
||||||
|
jsr GETBUFR
|
||||||
|
bcc :+
|
||||||
|
lda #$C ; NO BUFFERS AVAILABLE
|
||||||
|
rts
|
||||||
|
page_num27 := *+2
|
||||||
|
: sta open_params::io_buffer+1
|
||||||
|
|
||||||
;; 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
|
page_num20 := *+1
|
||||||
.addr open_params
|
.addr open_params
|
||||||
beq :+
|
beq :+
|
||||||
|
jsr FREEBUFR
|
||||||
lda #8 ; I/O ERROR - TODO: is this used???
|
lda #8 ; I/O ERROR - TODO: is this used???
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
@ -369,6 +384,7 @@ notok: stx command_path_buffer
|
||||||
page_num21 := *+1
|
page_num21 := *+1
|
||||||
.addr read_params
|
.addr read_params
|
||||||
beq :+
|
beq :+
|
||||||
|
jsr FREEBUFR
|
||||||
lda #8 ; I/O ERROR - TODO: is this used???
|
lda #8 ; I/O ERROR - TODO: is this used???
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
@ -377,6 +393,7 @@ notok: stx command_path_buffer
|
||||||
.byte CLOSE
|
.byte CLOSE
|
||||||
page_num22 := *+1
|
page_num22 := *+1
|
||||||
.addr close_params
|
.addr close_params
|
||||||
|
jsr FREEBUFR
|
||||||
|
|
||||||
;; Invoke command
|
;; Invoke command
|
||||||
jsr cmd_load_addr
|
jsr cmd_load_addr
|
||||||
|
@ -384,7 +401,6 @@ notok: stx command_path_buffer
|
||||||
clc ; Success
|
clc ; Success
|
||||||
rts ; Return to BASIC.SYSTEM
|
rts ; Return to BASIC.SYSTEM
|
||||||
|
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
|
|
||||||
|
@ -457,8 +473,8 @@ command_path_buffer:
|
||||||
.res 65, 0
|
.res 65, 0
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
.assert .sizeof(handler) <= $200, error, "Must fit on two pages"
|
|
||||||
handler_end := *-1
|
handler_end := *-1
|
||||||
|
handler_pages = (.sizeof(handler) + $FF) / $100
|
||||||
next_command := handler::next_command
|
next_command := handler::next_command
|
||||||
|
|
||||||
new_page:
|
new_page:
|
||||||
|
@ -494,4 +510,5 @@ relocation_table:
|
||||||
.addr handler::page_num24
|
.addr handler::page_num24
|
||||||
.addr handler::page_num25
|
.addr handler::page_num25
|
||||||
.addr handler::page_num26
|
.addr handler::page_num26
|
||||||
|
.addr handler::page_num27
|
||||||
table_end := *
|
table_end := *
|
|
@ -58,3 +58,5 @@ SSGINFO := $BEB4 ; Get Info Parameter block
|
||||||
FIFILID := $BEB8 ; (set size $A)
|
FIFILID := $BEB8 ; (set size $A)
|
||||||
|
|
||||||
GETBUFR := $BEF5
|
GETBUFR := $BEF5
|
||||||
|
FREEBUFR := $BEF8
|
||||||
|
RSHIMEM := $BEFB
|
||||||
|
|
Loading…
Reference in New Issue
Block a user