Fix stack initialization bug

This commit is contained in:
Lucas Scharenbroich 2021-07-07 16:55:41 -05:00
parent 92611281a4
commit 39f61087ce

View File

@ -9,7 +9,10 @@ PEISlam
stx :screen_width ; save the width stx :screen_width ; save the width
phd ; save the current direct page and assign the base phd ; save the current direct page and assign the base
tcd ; creen address to the direct page register tcd ; screen address to the direct page register
clc
adc :screen_width ; screen address of the right edge (will go in stack)
tax ; but cache in x register for a bit....
tsc tsc
sta :stk_save ; save the stack pointer to restore later sta :stk_save ; save the stack pointer to restore later
@ -37,14 +40,16 @@ PEISlam
dex ; decrement the inner counter dex ; decrement the inner counter
bne :inner ; if not zero, no break; go to the next line bne :inner ; if not zero, no break; go to the next line
tsx ; save the current stack
_R0W0 ; restore the execution environment and _R0W0 ; restore the execution environment and
lda :stk_save ; give a few cycles to catch some interrupts lda :stk_save ; give a few cycles to catch some interrupts
tcs tcs
cli ; fall through here -- saves a BRA instruction cli ; fall through here -- saves a BRA instruction
:outer :outer
ldx #8 ; Enable interrupts at least once every 8 lines
sei sei
txs ; set the stack address to the right edge
ldx #8 ; Enable interrupts at least once every 8 lines
_R1W1 _R1W1
:inner jmp $0000 :inner jmp $0000
@ -110,6 +115,9 @@ PEISlam