fix Reenter race-condition and mini-attract off-by-one

This commit is contained in:
Peter Ferrie 2021-10-29 11:32:14 -07:00
parent 92aefda47f
commit f287cc4d98
3 changed files with 18 additions and 18 deletions

View File

@ -78,15 +78,15 @@ RestoreStackNextTime
; reset to branch so we don't try to
sta RestoreStackNextTime + 1
; restore the same stack twice
ldx #-gStackSize
- lda STACKBASE - $FE + gStackSize,x
STACKPTR
ldx #$D1 ; SMC, restore stack pointer
txs
inx
- lda STACKBASE - $100 + gStackSize,x
; restore stack
sta $100,x
inx
bne -
STACKPTR
ldx #$D1 ; SMC, restore stack pointer
txs
SwitchToBank1
+READ_RAM1_WRITE_RAM1
rts
@ -177,7 +177,7 @@ COPYSRC = *
!source "src/glue.launch.lc2.a"
!source "src/hw.accel.lc2.a"
STACKBASE = *
LCRAM2_END = STACKBASE + gStackSize
LCRAM2_END = STACKBASE + gStackSize - 1
!if LCRAM2_END >= DisableAccelerator {
!error "code is too large: ends at ", LCRAM2_END
}

View File

@ -1,5 +1,5 @@
;license:MIT
;(c) 2018-9 by 4am & qkumba
;(c) 2018-2021 by 4am & qkumba
;
; Functions to launch games and self-running demos
;
@ -8,18 +8,18 @@
; which handle bank switching for you.
LaunchInternal
ldy #-gStackSize
- lda $100,y
sta STACKBASE - $FE + gStackSize,y
; back up stack
iny
bne -
tsx ; back up stack pointer
stx STACKPTR + 1
sty RestoreStackNextTime + 1
inx
- pla
sta STACKBASE - $100 + gStackSize,x
; back up stack
inx
bne -
stx RestoreStackNextTime + 1
; tell |Reenter| to restore the stack and stack pointer
tya
txa
ldy #$18
- sta $bf57,y
dey

View File

@ -78,10 +78,10 @@ MiniAttractMode
!word -
+ !word $FDFD ; SMC
jsr okvs_get_current
sty $1FFB
sty $1FFA
ldy #4
- lda (PTR), y
sta $1FFC, y
sta $1FFB, y
dey
bpl -
@ -93,7 +93,7 @@ MiniAttractMode
jsr LoadIndexedFile
!word kAttractModeFulFile
- !word $6000
!word $1FFB
!word $1FFA
+LDADDR -
jsr okvs_len