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

View File

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

View File

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