2018-02-07 21:02:14 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
2018-04-15 16:29:24 +00:00
|
|
|
; ProDOS - functions for constructing and passing around ProDOS pathnames
|
2018-02-07 21:02:14 +00:00
|
|
|
;
|
|
|
|
; Public functions
|
|
|
|
; - ResetPath
|
|
|
|
; - AddToPath
|
2018-03-16 18:17:45 +00:00
|
|
|
; - SetStartupPath
|
2018-02-07 21:02:14 +00:00
|
|
|
;
|
2018-04-01 16:21:48 +00:00
|
|
|
; Public constants
|
|
|
|
; - kPathSeparator
|
|
|
|
|
|
|
|
kPathSeparator
|
|
|
|
!byte 1
|
|
|
|
!raw "/"
|
2018-03-30 17:19:14 +00:00
|
|
|
|
2018-02-07 21:02:14 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; ResetPath
|
|
|
|
; reset gPathname to length 0
|
|
|
|
;
|
|
|
|
; in: none
|
|
|
|
; out: all registers preserved
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
ResetPath
|
|
|
|
stz gPathname
|
|
|
|
rts
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; AddToPath
|
|
|
|
; append a length-prefixed string to gPathname
|
|
|
|
;
|
|
|
|
; in: A contains low byte of address of length-prefixed string to append
|
|
|
|
; Y contains high byte of address of length-prefixed string to append
|
|
|
|
; out: all registers and flags clobbered
|
2018-02-09 01:38:26 +00:00
|
|
|
; $00/$01 clobbered
|
|
|
|
; gPathname updated with concatenated length-prefixed string
|
2018-02-07 21:02:14 +00:00
|
|
|
;------------------------------------------------------------------------------
|
2018-04-17 03:48:30 +00:00
|
|
|
AddToPathWithHighBit
|
|
|
|
ldx #$80
|
2018-04-18 02:28:22 +00:00
|
|
|
+HIDE_NEXT_2_BYTES
|
2018-02-07 21:02:14 +00:00
|
|
|
AddToPath
|
2018-04-17 03:48:30 +00:00
|
|
|
ldx #0
|
2018-04-19 14:05:48 +00:00
|
|
|
stx @mask
|
2018-03-29 02:49:51 +00:00
|
|
|
+STAY $00
|
2018-02-07 21:02:14 +00:00
|
|
|
ldx gPathname ; current pathname length
|
|
|
|
lda ($00) ; length of this segment
|
|
|
|
inc
|
2018-04-19 14:05:48 +00:00
|
|
|
sta @len
|
2018-02-07 21:02:14 +00:00
|
|
|
ldy #$01
|
|
|
|
- lda ($00),y
|
2018-04-19 14:05:48 +00:00
|
|
|
@mask=*+1
|
2018-04-17 03:48:30 +00:00
|
|
|
ora #$FD ; SMC
|
2018-02-07 21:02:14 +00:00
|
|
|
sta gPathname+1,x
|
|
|
|
inx
|
|
|
|
iny
|
2018-04-19 14:05:48 +00:00
|
|
|
@len=*+1
|
2018-03-29 03:13:24 +00:00
|
|
|
cpy #$FD ; SMC
|
2018-02-07 21:02:14 +00:00
|
|
|
bcc -
|
|
|
|
stx gPathname
|
|
|
|
rts
|
2018-03-16 18:17:45 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; SetStartupPath
|
|
|
|
; copy a length-prefixed string to $2006 (to pass it as the startup file when
|
|
|
|
; launching a .system file)
|
|
|
|
;
|
|
|
|
; in: A contains low byte of address of length-prefixed string to append
|
|
|
|
; Y contains high byte of address of length-prefixed string to append
|
|
|
|
; out: all registers and flags clobbered
|
|
|
|
; $00/$01 clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
SetStartupPath
|
2018-03-29 02:49:51 +00:00
|
|
|
+STAY $00
|
2018-03-16 18:17:45 +00:00
|
|
|
lda ($00)
|
|
|
|
tay
|
|
|
|
- lda ($00),y
|
|
|
|
and #$7F
|
|
|
|
sta $2006,y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
rts
|