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
|
.struct MLI
|
||||||
.union
|
.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
|
.struct RW_BLOCK
|
||||||
PARAM_COUNT .byte
|
PARAM_COUNT .byte
|
||||||
UNIT_NUM .byte
|
UNIT_NUM .byte
|
||||||
@@ -130,6 +137,13 @@ EOF_COUNT = 2
|
|||||||
.endunion
|
.endunion
|
||||||
.endstruct
|
.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 mliparam
|
||||||
.global callmli
|
.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
|
.constructor raisefilelevel
|
||||||
.destructor closeallfiles, 5
|
.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 iobuf_alloc, iobuf_free
|
||||||
.import addysp, incsp4, incaxy, pushax, popax
|
.import addysp, incsp4, incaxy, pushax, popax
|
||||||
|
|
||||||
@@ -91,10 +91,7 @@ found: sty tmp2
|
|||||||
bne oserr1
|
bne oserr1
|
||||||
|
|
||||||
; Set pushed name
|
; Set pushed name
|
||||||
lda c_sp
|
jsr mli_set_pathname_tos
|
||||||
ldx c_sp+1
|
|
||||||
sta mliparam + MLI::OPEN::PATHNAME
|
|
||||||
stx mliparam + MLI::OPEN::PATHNAME+1
|
|
||||||
|
|
||||||
; Check for create flag
|
; Check for create flag
|
||||||
lda tmp3 ; Restore flags
|
lda tmp3 ; Restore flags
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export __syschdir
|
.export __syschdir
|
||||||
.import pushname, popname
|
.import pushname, popname, mli_set_pathname_tos
|
||||||
.import initcwd
|
.import initcwd
|
||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
@@ -17,10 +17,7 @@ __syschdir:
|
|||||||
bne oserr
|
bne oserr
|
||||||
|
|
||||||
; Set pushed name
|
; Set pushed name
|
||||||
lda c_sp
|
jsr mli_set_pathname_tos
|
||||||
ldx c_sp+1
|
|
||||||
sta mliparam + MLI::PREFIX::PATHNAME
|
|
||||||
stx mliparam + MLI::PREFIX::PATHNAME+1
|
|
||||||
|
|
||||||
; Change directory
|
; Change directory
|
||||||
lda #SET_PREFIX_CALL
|
lda #SET_PREFIX_CALL
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export __sysmkdir
|
.export __sysmkdir
|
||||||
.import pushname_tos, popname
|
.import pushname_tos, popname, mli_set_pathname_tos
|
||||||
.import addysp, popax
|
.import addysp, popax
|
||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
@@ -22,10 +22,7 @@ __sysmkdir:
|
|||||||
bne oserr
|
bne oserr
|
||||||
|
|
||||||
; Set pushed name
|
; Set pushed name
|
||||||
lda c_sp
|
jsr mli_set_pathname_tos
|
||||||
ldx c_sp+1
|
|
||||||
sta mliparam + MLI::CREATE::PATHNAME
|
|
||||||
stx mliparam + MLI::CREATE::PATHNAME+1
|
|
||||||
|
|
||||||
; Set all other parameters from template
|
; Set all other parameters from template
|
||||||
ldx #(MLI::CREATE::CREATE_TIME+1) - (MLI::CREATE::PATHNAME+1) - 1
|
ldx #(MLI::CREATE::CREATE_TIME+1) - (MLI::CREATE::PATHNAME+1) - 1
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export __sysremove
|
.export __sysremove
|
||||||
.import pushname, popname
|
.import pushname, popname, mli_set_pathname_tos
|
||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
.include "mli.inc"
|
.include "mli.inc"
|
||||||
@@ -16,10 +16,7 @@ __sysremove:
|
|||||||
bne oserr
|
bne oserr
|
||||||
|
|
||||||
; Set pushed name
|
; Set pushed name
|
||||||
lda c_sp
|
jsr mli_set_pathname_tos
|
||||||
ldx c_sp+1
|
|
||||||
sta mliparam + MLI::DESTROY::PATHNAME
|
|
||||||
stx mliparam + MLI::DESTROY::PATHNAME+1
|
|
||||||
|
|
||||||
; Remove file
|
; Remove file
|
||||||
lda #DESTROY_CALL
|
lda #DESTROY_CALL
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export __sysrename
|
.export __sysrename
|
||||||
.import pushname, pushname_tos, popname
|
.import pushname, pushname_tos, mli_set_pathname_tos, popname
|
||||||
.import popax
|
.import popax
|
||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
@@ -21,10 +21,7 @@ __sysrename:
|
|||||||
bne oserr1
|
bne oserr1
|
||||||
|
|
||||||
; Set pushed oldname
|
; Set pushed oldname
|
||||||
lda c_sp
|
jsr mli_set_pathname_tos
|
||||||
ldx c_sp+1
|
|
||||||
sta mliparam + MLI::RENAME::PATHNAME
|
|
||||||
stx mliparam + MLI::RENAME::PATHNAME+1
|
|
||||||
|
|
||||||
; Restore and push newname
|
; Restore and push newname
|
||||||
lda ptr2
|
lda ptr2
|
||||||
|
|||||||
Reference in New Issue
Block a user