Apple2: factorize MLI pathname setting (up to -22 bytes)
This commit is contained in:
committed by
Oliver Schmidt
parent
850accee3a
commit
9390e5c2ce
@@ -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
|
||||
|
||||
|
||||
16
libsrc/apple2/mli_set_pathname.s
Normal file
16
libsrc/apple2/mli_set_pathname.s
Normal file
@@ -0,0 +1,16 @@
|
||||
;
|
||||
; Colin Leroy-Mira, 2025 <colin@colino.net>
|
||||
;
|
||||
|
||||
.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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user