;license:MIT ;(c) 2018 by 4am ; ; ProDOS - functions for constructing and passing around ProDOS pathnames ; ; Public functions ; - ResetPath ; - AddToPath ; - SetStartupPath ; ; Public constants ; - kPathSeparator kPathSeparator !byte 1 !raw "/" ;------------------------------------------------------------------------------ ; 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 ; $00/$01 clobbered ; gPathname updated with concatenated length-prefixed string ;------------------------------------------------------------------------------ AddToPathWithHighBit ldx #$80 +HIDE_NEXT_2_BYTES AddToPath ldx #0 stx @mask +STAY $00 ldx gPathname ; current pathname length lda ($00) ; length of this segment inc sta @len ldy #$01 - lda ($00),y @mask=*+1 ora #$FD ; SMC sta gPathname+1,x inx iny @len=*+1 cpy #$FD ; SMC bcc - stx gPathname rts ;------------------------------------------------------------------------------ ; 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 +STAY $00 lda ($00) tay - lda ($00),y and #$7F sta $2006,y dey bpl - rts