shave some bytes

This commit is contained in:
4am 2021-06-17 21:42:58 -04:00
parent ee83034bf1
commit 5e0cac5e0e
3 changed files with 30 additions and 96 deletions

View File

@ -153,93 +153,6 @@ WriteTrackSecondPass
txa
rts
;-------------------------------
; SaveFile1Shot
; save a file to disk all at once,
; using ProDOS MLI calls
;
; in: ProDOS is in memory
; stack contains 11 ($0B) bytes of parameters:
; +1 address of pathname
; +3 [byte] file type
; +4 [word] aux file type
; +6 address of data buffer
; +8 [word] length of data buffer
; +A address of ProDOS file buffer
; out: ProDOS is in memory
; if C set, save failed and A contains error code
; from open or write
; if C clear, save succeeded
; all other flags clobbered
; all registers clobbered
; stack set to next instruction after parameters
;-------------------------------
SaveFile1Shot
clc
pla
sta $00
adc #$0B
tax
pla
sta $01
adc #$00
pha
txa
pha
ldy #$01
lda ($00),y ; lo byte of pathname
sta mliparam+1
iny
lda ($00),y ; hi byte of pathname
sta mliparam+2
jsr DeleteFile ; don't care if this fails
ldy #$03
lda ($00),y ; file type
sta mliparam+4
iny
lda ($00),y ; lo byte of aux file type
sta mliparam+5
iny
lda ($00),y ; hi byte of aux file type
sta mliparam+6
jsr CreateFile
bcs +
ldy #$0A
lda ($00),y ; lo byte of ProDOS file buffer
sta mliparam+3
iny
lda ($00),y ; hi byte of ProDOS file buffer
sta mliparam+4
jsr OpenFile
bcs +
pha ; push file reference number
ldy #$06
lda ($00),y ; lo address of data buffer
sta mliparam+2
iny
lda ($00),y ; hi address of data buffer
sta mliparam+3
iny
lda ($00),y ; lo data length
sta mliparam+4
iny
lda ($00),y ; hi data length
sta mliparam+5
pla ; pull file reference number
jsr WriteFile
php ; save flags from writefile
pha
jsr CloseFile ; always close whether write worked or not
pla
plp ; restore flags from write
; (so caller gets codes from write attempt,
; not close)
+ rts
;-------------------------------
; open file via ProDOS MLI
;

View File

@ -463,8 +463,8 @@ _byte_skip_hi:
!source "cffa.a"
!source "progress.a"
!source "rwts.a"
!source "wholetrack.a"
!source "standarddelivery.a"
!source "wholetrack.a"
!source "adstyle.a"
!source "universalstyle.a"
!source "crackme.a"

View File

@ -28,14 +28,35 @@ PREFSWRITELEN = *-PREFSVER
;-------------------------------
SavePrefs
jsr ValidatePrefs
jsr SaveFile1Shot
!word PREFSFILE
!byte $04 ; text file
!byte $00,$00 ; no aux file type
!word PREFSVER
!word PREFSWRITELEN
!word PREFSBUFFER
rts
lda #<PREFSFILE
sta mliparam+1
lda #>PREFSFILE
sta mliparam+2
jsr DeleteFile ; don't care if this fails
lda #$04 ; text file type
sta mliparam+4
lda #$00
sta mliparam+5 ; no aux file type
sta mliparam+6
jsr CreateFile
bcs +
lda #<PREFSBUFFER
sta mliparam+3
lda #>PREFSBUFFER
sta mliparam+4
jsr OpenFile
bcs +
ldy #<PREFSVER
sty mliparam+2
ldy #>PREFSVER
sty mliparam+3
ldy #<PREFSWRITELEN
sty mliparam+4
ldy #>PREFSWRITELEN
sty mliparam+5
jsr WriteFile
jsr CloseFile
+ rts
;-------------------------------
; ValidatePrefs