.include "zeropage.inc"
.include "mli.inc"
- .segment "INIT"
-
initcwd:
- ; Use imported buffer
+ ; Set static prefix buffer
lda #<__cwd
ldx #>__cwd
sta mliparam + MLI::PREFIX::PATHNAME
ldx #PREFIX_COUNT
jsr callmli
- ; Check length byte
- ldx __cwd
- beq done
-
- ; Replace trailing slash with zero
- sta __cwd,x ; A = 0
-
- ; Remove length byte
- tax
-: inx
- lda __cwd,x
- sta __cwd-1,x
- bne :-
-
-done: rts
+ ; Check for null prefix
+ lda __cwd
+ beq done
+
+ ; Remove length byte and trailing slash
+ sta tmp1
+ ldx #$01
+: lda __cwd,x
+ sta __cwd - 1,x
+ inx
+ cpx tmp1
+ bcc :-
+
+ ; Add terminating zero
+ lda #$00
+ sta __cwd - 1,x
+
+done: rts