4cade/src/prodos.path.a

80 lines
1.8 KiB
Plaintext

;license:MIT
;(c) 2018-9 by 4am
;
; ProDOS - functions for constructing and passing around ProDOS pathnames
;
; Public functions
; - SetPath
; - AddToPath
;
kHGRTitleDirectory
!byte 10
!raw "TITLE.HGR/"
kDHGRTitleDirectory
!byte 11
!raw "TITLE.DHGR/"
kHGRActionDirectory
!byte 11
!raw "ACTION.HGR/"
kDHGRActionDirectory
!byte 12
!raw "ACTION.DHGR/"
kSHRArtworkDirectory
!byte 12
!raw "ARTWORK.SHR/"
kAttractModeSlideshowDirectory
!byte 3
!raw "SS/"
kDemoDirectory
!byte 5
!raw "DEMO/"
kGameDirectory
!byte 2
!raw "X/"
kFXDirectory
!byte 3
!raw "FX/"
;------------------------------------------------------------------------------
; SetPath/AddToPath
; append a length-prefixed string to gPathname
; SetPath will reset the path first
;
; 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
; gPathname updated with concatenated length-prefixed string
;------------------------------------------------------------------------------
SetPath
ldx #0
stx gPathname
; execution falls through here
AddToPath
+STAY $00
ldx gPathname ; current pathname length
ldy #0
lda ($00),y ; length of this segment
tay
iny
sty @len
ldy #$01
- lda ($00),y
sta gPathname+1,x
inx
iny
@len=*+1
cpy #$FD ; SMC
bcc -
stx gPathname
rts