diff --git a/libsrc/apple2/mli.inc b/libsrc/apple2/mli.inc index e28981b4a..9b470073e 100644 --- a/libsrc/apple2/mli.inc +++ b/libsrc/apple2/mli.inc @@ -53,6 +53,13 @@ EOF_COUNT = 2 .struct MLI .union + ; Pseudo-struct to make clear that calls with a + ; PATHNAME parameter always have PATHNAME in the + ; same place + .struct PATH + PARAM_COUNT .byte + PATHNAME .addr + .endstruct .struct RW_BLOCK PARAM_COUNT .byte UNIT_NUM .byte @@ -130,6 +137,13 @@ EOF_COUNT = 2 .endunion .endstruct + ; Assert that PATHNAME parameters is always at the same place + .assert MLI::CREATE::PATHNAME = MLI::PATH::PATHNAME, error + .assert MLI::DESTROY::PATHNAME = MLI::PATH::PATHNAME, error + .assert MLI::INFO::PATHNAME = MLI::PATH::PATHNAME, error + .assert MLI::PREFIX::PATHNAME = MLI::PATH::PATHNAME, error + .assert MLI::OPEN::PATHNAME = MLI::PATH::PATHNAME, error + .global mliparam .global callmli diff --git a/libsrc/apple2/mli_set_pathname.s b/libsrc/apple2/mli_set_pathname.s new file mode 100644 index 000000000..90109353e --- /dev/null +++ b/libsrc/apple2/mli_set_pathname.s @@ -0,0 +1,16 @@ +; +; Colin Leroy-Mira, 2025 +; + + .export mli_set_pathname_tos + .include "zeropage.inc" + .include "mli.inc" + + ; Sets MLI PATHNAME parameter from TOS +mli_set_pathname_tos: + ; Set pushed name from TOS + lda c_sp + ldx c_sp+1 + sta mliparam + MLI::PATH::PATHNAME + stx mliparam + MLI::PATH::PATHNAME+1 + rts diff --git a/libsrc/apple2/open.s b/libsrc/apple2/open.s index ec788153e..947e6580f 100644 --- a/libsrc/apple2/open.s +++ b/libsrc/apple2/open.s @@ -9,7 +9,7 @@ .constructor raisefilelevel .destructor closeallfiles, 5 - .import pushname_tos, popname, __dos_type + .import pushname_tos, popname, mli_set_pathname_tos, __dos_type .import iobuf_alloc, iobuf_free .import addysp, incsp4, incaxy, pushax, popax @@ -91,10 +91,7 @@ found: sty tmp2 bne oserr1 ; Set pushed name - lda c_sp - ldx c_sp+1 - sta mliparam + MLI::OPEN::PATHNAME - stx mliparam + MLI::OPEN::PATHNAME+1 + jsr mli_set_pathname_tos ; Check for create flag lda tmp3 ; Restore flags diff --git a/libsrc/apple2/syschdir.s b/libsrc/apple2/syschdir.s index be78a91b9..c1c857a6a 100644 --- a/libsrc/apple2/syschdir.s +++ b/libsrc/apple2/syschdir.s @@ -5,7 +5,7 @@ ; .export __syschdir - .import pushname, popname + .import pushname, popname, mli_set_pathname_tos .import initcwd .include "zeropage.inc" @@ -17,10 +17,7 @@ __syschdir: bne oserr ; Set pushed name - lda c_sp - ldx c_sp+1 - sta mliparam + MLI::PREFIX::PATHNAME - stx mliparam + MLI::PREFIX::PATHNAME+1 + jsr mli_set_pathname_tos ; Change directory lda #SET_PREFIX_CALL diff --git a/libsrc/apple2/sysmkdir.s b/libsrc/apple2/sysmkdir.s index 1f62d323f..f654fcbca 100644 --- a/libsrc/apple2/sysmkdir.s +++ b/libsrc/apple2/sysmkdir.s @@ -5,7 +5,7 @@ ; .export __sysmkdir - .import pushname_tos, popname + .import pushname_tos, popname, mli_set_pathname_tos .import addysp, popax .include "zeropage.inc" @@ -22,10 +22,7 @@ __sysmkdir: bne oserr ; Set pushed name - lda c_sp - ldx c_sp+1 - sta mliparam + MLI::CREATE::PATHNAME - stx mliparam + MLI::CREATE::PATHNAME+1 + jsr mli_set_pathname_tos ; Set all other parameters from template ldx #(MLI::CREATE::CREATE_TIME+1) - (MLI::CREATE::PATHNAME+1) - 1 diff --git a/libsrc/apple2/sysremove.s b/libsrc/apple2/sysremove.s index 088407024..c5eadc85a 100644 --- a/libsrc/apple2/sysremove.s +++ b/libsrc/apple2/sysremove.s @@ -5,7 +5,7 @@ ; .export __sysremove - .import pushname, popname + .import pushname, popname, mli_set_pathname_tos .include "zeropage.inc" .include "mli.inc" @@ -16,10 +16,7 @@ __sysremove: bne oserr ; Set pushed name - lda c_sp - ldx c_sp+1 - sta mliparam + MLI::DESTROY::PATHNAME - stx mliparam + MLI::DESTROY::PATHNAME+1 + jsr mli_set_pathname_tos ; Remove file lda #DESTROY_CALL diff --git a/libsrc/apple2/sysrename.s b/libsrc/apple2/sysrename.s index 927132254..2001f3f5e 100644 --- a/libsrc/apple2/sysrename.s +++ b/libsrc/apple2/sysrename.s @@ -5,7 +5,7 @@ ; .export __sysrename - .import pushname, pushname_tos, popname + .import pushname, pushname_tos, mli_set_pathname_tos, popname .import popax .include "zeropage.inc" @@ -21,10 +21,7 @@ __sysrename: bne oserr1 ; Set pushed oldname - lda c_sp - ldx c_sp+1 - sta mliparam + MLI::RENAME::PATHNAME - stx mliparam + MLI::RENAME::PATHNAME+1 + jsr mli_set_pathname_tos ; Restore and push newname lda ptr2