move stack adjustment code to take effect from the callback routines

This commit is contained in:
Kelvin Sherlock 2021-08-03 20:13:27 -04:00
parent 6da1f9fa3c
commit 0fabe65aca

View File

@ -120,6 +120,8 @@ blockNumber dc.l 0 ; actually 24-bit
endif endif
_stack ds.w 1
getbootname proc getbootname proc
; getbootname(GSString *) ; getbootname(GSString *)
; return string needs a leading colon. ; return string needs a leading colon.
@ -137,6 +139,13 @@ getbootname proc
phk phk
plb plb
; prepare the stack for emulation mode
tsx
stx _stack
ldx #$01ff ; should be enough space
txs
; get the volume name from the HFS MDB.... ; get the volume name from the HFS MDB....
if not __smartport__ then if not __smartport__ then
lda #buffer lda #buffer
@ -144,6 +153,11 @@ getbootname proc
endif endif
lda #2 lda #2
jsr read_block_abs jsr read_block_abs
; restore the stack. does not affect a/carry
ldx _stack
txs
bcs exit bcs exit
with HFSMasterDirectoryBlock with HFSMasterDirectoryBlock
@ -232,6 +246,12 @@ readfile proc
phk phk
plb plb
; prepare the stack for emulation mode
tsx
stx _stack
ldx #$01ff ; should be enough space
txs
jsr prepare_path jsr prepare_path
bcs exit bcs exit
@ -239,6 +259,9 @@ readfile proc
jsr cat_lookup jsr cat_lookup
bcs exit bcs exit
; now read file, one block at a time, ; now read file, one block at a time,
; and copy to ptr. ; and copy to ptr.
lda blocks lda blocks
@ -284,6 +307,9 @@ rdone
; ... ; ...
ldx _stack
txs
; stack: b, rts, ; stack: b, rts,
lda ft lda ft
sta 4,s sta 4,s
@ -296,7 +322,12 @@ rdone
lda #0 lda #0
clc clc
plb
rts
exit exit
ldx _stack
txs
plb plb
rts rts
@ -537,15 +568,6 @@ read_block_abs
sta pro.blockNumber sta pro.blockNumber
endif endif
;
; need to save/restore the stack. start.gs.os will call w/ high stack
;
tsc
sta _stack
lda #$01bf ; should be enough space
tcs
clc
php php
sec sec
xce xce
@ -559,21 +581,16 @@ vector dc.w $ffff
bcs @fail bcs @fail
xce xce
plp plp
lda _stack
tcs
lda #0 lda #0
clc
rts rts
@fail @fail
clc clc
xce xce
plp plp
tax ; save
lda _stack
tcs
sec
txa
and #$ff and #$ff
sec
rts rts
_stack ds.w 1 _stack ds.w 1