mirror of
https://github.com/a2stuff/prodos-path.git
synced 2025-02-13 22:31:37 +00:00
Support multi-segment paths
This commit is contained in:
parent
719bca04ac
commit
19bf11b42a
16
README.md
16
README.md
@ -8,18 +8,19 @@ Installation:
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
```
|
```
|
||||||
PATH - view current search path
|
PATH - view current search path(s)
|
||||||
PATH prefix - set search path
|
PATH prefix - set search path(s) - colon delimited
|
||||||
```
|
```
|
||||||
|
|
||||||
Once set, binary files of type `CMD` in the specified directory can be invoked by name.
|
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 with carry clear completion
|
* CMD file is loaded at $4000 and invoked; should return (`rts`) on completion.
|
||||||
* The command line will be present at $200 (`GETLN` input buffer).
|
* The command line will be present at $200 (`GETLN` input buffer).
|
||||||
|
* Supports multi-segment paths (e.g. `/hd/cmds:/hd2/more.cmds`)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```
|
```
|
||||||
] -/hd/path - install it
|
] -/hd/path - install it
|
||||||
] PATH /hd/cmds - set PATH
|
] PATH /hd/cmds:/h2/bin - set PATH
|
||||||
] PATH - verify path
|
] PATH - verify path
|
||||||
/hd/cmds
|
/hd/cmds
|
||||||
] BELL - will invoke /hd/cmds/BELL if present
|
] BELL - will invoke /hd/cmds/BELL if present
|
||||||
@ -27,9 +28,6 @@ Example:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Notes:
|
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 ...`)
|
* Can be invoked as lower case (e.g. `path ...`)
|
||||||
* Applesoft BASIC commands are unaffected (but can't be CMD names)
|
* 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
47
path.s
@ -11,14 +11,6 @@
|
|||||||
.include "apple2.inc"
|
.include "apple2.inc"
|
||||||
.include "prodos.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
|
cmd_load_addr := $4000
|
||||||
@ -277,22 +269,45 @@ not_ours:
|
|||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
|
|
||||||
|
fail_invoke:
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
maybe_invoke:
|
maybe_invoke:
|
||||||
|
|
||||||
|
ppos := $D6 ; position into path_buffer
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta ppos
|
||||||
|
|
||||||
;; Compose path
|
;; Compose path
|
||||||
|
compose:
|
||||||
|
ldx ppos
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
ldx path_buffer
|
cpx path_buffer
|
||||||
|
beq fail_invoke
|
||||||
|
|
||||||
|
;; Entry from path list
|
||||||
ldy #1
|
ldy #1
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
: lda path_buffer,y
|
: lda path_buffer+1,x
|
||||||
|
inx
|
||||||
|
cmp #':' ; separator
|
||||||
|
beq :+
|
||||||
sta (ptr),y
|
sta (ptr),y
|
||||||
iny
|
iny
|
||||||
dex
|
reloc_point *+2
|
||||||
|
cpx path_buffer
|
||||||
bne :-
|
bne :-
|
||||||
|
|
||||||
|
;; Slash separator
|
||||||
|
: stx ppos
|
||||||
lda #'/'
|
lda #'/'
|
||||||
sta (ptr),y
|
sta (ptr),y
|
||||||
iny
|
iny
|
||||||
|
|
||||||
|
;; Name from command line
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr skip_leading_spaces
|
||||||
reloc_point *+2
|
reloc_point *+2
|
||||||
@ -313,7 +328,7 @@ ok: sta (ptr),y
|
|||||||
inx
|
inx
|
||||||
cpx #65 ; Maximum path length+1
|
cpx #65 ; Maximum path length+1
|
||||||
bcc :-
|
bcc :-
|
||||||
bcs fail_gfi
|
bcs compose
|
||||||
|
|
||||||
notok: dey
|
notok: dey
|
||||||
tya
|
tya
|
||||||
@ -324,16 +339,12 @@ notok: dey
|
|||||||
lda #$A ; param length
|
lda #$A ; param length
|
||||||
sta SSGINFO
|
sta SSGINFO
|
||||||
MLI_CALL GET_FILE_INFO, SSGINFO
|
MLI_CALL GET_FILE_INFO, SSGINFO
|
||||||
beq :+
|
bne compose ; no such file - try next path directory
|
||||||
|
|
||||||
fail_gfi:
|
|
||||||
sec ; no such file - signal it's not us
|
|
||||||
rts
|
|
||||||
|
|
||||||
;; Check to see if type is CMD.
|
;; Check to see if type is CMD.
|
||||||
: lda FIFILID
|
: lda FIFILID
|
||||||
cmp #$F0 ; CMD
|
cmp #$F0 ; CMD
|
||||||
bne fail_gfi ; wrong type - ignore it
|
bne compose ; wrong type - try next path directory
|
||||||
|
|
||||||
;; Tell BASIC.SYSTEM it was handled.
|
;; Tell BASIC.SYSTEM it was handled.
|
||||||
lda #0
|
lda #0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user