Support multi-segment paths

This commit is contained in:
Joshua Bell 2019-01-09 21:20:16 -08:00
parent 719bca04ac
commit 19bf11b42a
2 changed files with 36 additions and 27 deletions

View File

@ -8,18 +8,19 @@ Installation:
Usage:
```
PATH - view current search path
PATH prefix - set search path
PATH - view current search path(s)
PATH prefix - set search path(s) - colon delimited
```
Once set, binary files of type `CMD` in the specified directory can be invoked by name.
* CMD file is loaded at $4000 and invoked; should return (`rts`) on with carry clear completion
Once set, binary files of type `CMD` in the specified directories can be invoked by name.
* CMD file is loaded at $4000 and invoked; should return (`rts`) on completion.
* The command line will be present at $200 (`GETLN` input buffer).
* Supports multi-segment paths (e.g. `/hd/cmds:/hd2/more.cmds`)
Example:
```
] -/hd/path - install it
] PATH /hd/cmds - set PATH
] PATH /hd/cmds:/h2/bin - set PATH
] PATH - verify path
/hd/cmds
] BELL - will invoke /hd/cmds/BELL if present
@ -27,9 +28,6 @@ Example:
```
Notes:
* Allocates a buffer to store the code and path
* Allocates a permanent buffer to store the code and path (2 pages)
* Can be invoked as lower case (e.g. `path ...`)
* Applesoft BASIC commands are unaffected (but can't be CMD names)
Future:
* Support multi-segment paths (e.g. `/hd/cmds:/hd2/more.cmds`)

47
path.s
View File

@ -11,14 +11,6 @@
.include "apple2.inc"
.include "prodos.inc"
;;; ============================================================
;;;
;;; Installed command memory structure:
;;; * 2 pages - code, path buffer
;;; TODO:
;;; * Support multi-segment path (e.g. /hd/bin:/hd/extras/bin)
;;; ============================================================
cmd_load_addr := $4000
@ -277,22 +269,45 @@ not_ours:
;;; ============================================================
fail_invoke:
sec
rts
maybe_invoke:
ppos := $D6 ; position into path_buffer
lda #0
sta ppos
;; Compose path
compose:
ldx ppos
reloc_point *+2
ldx path_buffer
cpx path_buffer
beq fail_invoke
;; Entry from path list
ldy #1
reloc_point *+2
: lda path_buffer,y
: lda path_buffer+1,x
inx
cmp #':' ; separator
beq :+
sta (ptr),y
iny
dex
reloc_point *+2
cpx path_buffer
bne :-
;; Slash separator
: stx ppos
lda #'/'
sta (ptr),y
iny
;; Name from command line
reloc_point *+2
jsr skip_leading_spaces
reloc_point *+2
@ -313,7 +328,7 @@ ok: sta (ptr),y
inx
cpx #65 ; Maximum path length+1
bcc :-
bcs fail_gfi
bcs compose
notok: dey
tya
@ -324,16 +339,12 @@ notok: dey
lda #$A ; param length
sta SSGINFO
MLI_CALL GET_FILE_INFO, SSGINFO
beq :+
fail_gfi:
sec ; no such file - signal it's not us
rts
bne compose ; no such file - try next path directory
;; Check to see if type is CMD.
: lda FIFILID
cmp #$F0 ; CMD
bne fail_gfi ; wrong type - ignore it
bne compose ; wrong type - try next path directory
;; Tell BASIC.SYSTEM it was handled.
lda #0