2018-02-07 21:02:14 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
|
|
|
; Functions to build a ProDOS pathname from length-prefixed strings
|
|
|
|
;
|
|
|
|
; 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-03-16 18:17:45 +00:00
|
|
|
!zone {
|
2018-02-07 21:02:14 +00:00
|
|
|
AddToPath
|
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-03-29 03:13:24 +00:00
|
|
|
sta .len
|
2018-02-07 21:02:14 +00:00
|
|
|
ldy #$01
|
|
|
|
- lda ($00),y
|
|
|
|
sta gPathname+1,x
|
|
|
|
inx
|
|
|
|
iny
|
2018-03-29 03:13:24 +00:00
|
|
|
.len=*+1
|
|
|
|
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
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
!zone {
|
|
|
|
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
|
|
|
|
}
|
2018-03-31 14:22:09 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; CreateNullTerminatedString
|
|
|
|
; Copy a length-prefixed string to kNullTerminatedBuffer and null-terminate it.
|
|
|
|
; Destination string is left-padded with a single space because reasons.
|
|
|
|
; Maximum length is 127 bytes.
|
|
|
|
;
|
|
|
|
; in: A/Y contains address of length-prefixed string to copy
|
|
|
|
; X contains length of null-terminated string -- if > length of source,
|
|
|
|
; remaining buffer will be padded with spaces (#$A0)
|
2018-03-31 14:28:36 +00:00
|
|
|
; out: X preserved
|
|
|
|
; all other registers and flags clobbered
|
2018-03-31 14:22:09 +00:00
|
|
|
; $00/$01 clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
!zone {
|
|
|
|
CreateNullTerminatedString
|
|
|
|
+STAY $00
|
|
|
|
|
|
|
|
phx
|
|
|
|
lda #$A0
|
|
|
|
- dex
|
|
|
|
sta kNullTerminatedBuffer,x
|
|
|
|
bpl -
|
|
|
|
plx
|
|
|
|
lda #$00
|
|
|
|
sta kNullTerminatedBuffer,x
|
|
|
|
|
|
|
|
lda ($00)
|
|
|
|
tay
|
|
|
|
- lda ($00),y
|
|
|
|
sta kNullTerminatedBuffer,y
|
|
|
|
dey
|
|
|
|
bne -
|
|
|
|
rts
|
|
|
|
}
|