Fix restore code field bug. SMB demo can use renderer

This commit is contained in:
Lucas Scharenbroich 2023-06-26 14:15:20 -05:00
parent eb548343a7
commit 6a0b8cbdc1
3 changed files with 28 additions and 17 deletions

View File

@ -160,7 +160,9 @@ ExtFuncBlock
; Special NES renderer that externalizes the sprite rendering in order to exceed the internal limit of 16 sprites
_RenderNES
jsr _ApplyBG0YPos
; jsr _ApplyBG0YPos
; jsr _ApplyBG0XPosPre
jsr _ApplyBG0YPosLite
jsr _ApplyBG0XPosPre
; Callback to update the tilestore with any new tiles
@ -182,7 +184,8 @@ _RenderNES
lda #16*2
sta tmp2 ; lines_left_x2
lda #0 ; Xmod164
jsr _ApplyBG0XPosAlt
; jsr _ApplyBG0XPosAlt
jsr _ApplyBG0XPosAltLite
lda tmp4 ; :exit_offset
stal nesTopOffset
@ -194,7 +197,8 @@ _RenderNES
asl
sta tmp2 ; lines_left_x2
lda StartXMod164 ; Xmod164
jsr _ApplyBG0XPosAlt
; jsr _ApplyBG0XPosAlt
jsr _ApplyBG0XPosAltLite
lda tmp4
stal nesBottomOffset
@ -246,7 +250,8 @@ _RenderNES
sta tmp2 ; :lines_left_x2
ldal nesTopOffset
sta tmp4 ; :exit_offset
jsr _RestoreBG0OpcodesAlt
; jsr _RestoreBG0OpcodesAlt
jsr _RestoreBG0OpcodesAltLite
lda #16*2
sta tmp1 ; :virt_line_x2
@ -257,7 +262,8 @@ _RenderNES
sta tmp2 ; lines_left_x2
ldal nesBottomOffset
sta tmp4 ; :exit_offset
jsr _RestoreBG0OpcodesAlt
; jsr _RestoreBG0OpcodesAlt
jsr _RestoreBG0OpcodesAltLite
; lda StartYMod208 ; Restore the fields back to their original state
; ldx ScreenHeight

View File

@ -442,7 +442,8 @@ _UTDPatch jsl UserHook1 ; Call the users code
cmp #0
beq :done
jmp FastCopyTmpDataA ; Non-zero value to continue additional work
; jmp FastCopyTmpDataA ; Non-zero value to continue additional work
jmp LiteCopyTmpDataA
:done
rts

View File

@ -245,9 +245,9 @@ _ApplyBG0XPosAltLite
; to account for the position of the BRL instruction
tax
lda Col2CodeOffset-2,x ; offset from _LOOP (0 to 249 step 3)
lda Col2CodeOffset-2,x ; offset from base
clc
adc #-_ENTRY_JMP+3
adc #-{_ENTRY_JMP+3}
sta :opcode
; Now update the code field to get ready to execute. We set the bank register to the code
@ -323,11 +323,13 @@ _ApplyBG0XPosAltLite
ldy :entry_jmp_addr
lda #$82
:do_setopcode_e jsr $0000 ; Copy in the BRL opcode into the entry point
rep #$20
ldx :exit_address
inx
ldy :low_save_addr
:do_save_entry_e jsr $0000 ; Copy a word from offset x to y
iny
:do_save_entry_e jsr $0000 ; Copy a byte from offset x to y
rep #$20
ldy :exit_address
lda :exit_bra
@ -366,12 +368,12 @@ _ApplyBG0XPosAltLite
tax
lda Col2CodeOffset,x
clc
adc #-_ENTRY_JMP+3 ; In this case it gets loaded in the X-register
adc #-{_ENTRY_JMP+3} ; In this case it gets loaded in the X-register
sta :opcode
lda Col2CodeOffset-2,x
clc
adc #-_ENTRY_ODD+3
adc #-{_ENTRY_ODD+3}
sta :odd_entry_offset
; Main loop
@ -448,11 +450,13 @@ _ApplyBG0XPosAltLite
ldy :exit_odd_addr
iny
:do_save_high_byte jsr $0000 ; Copy high byte of the exit location into the odd handling path
rep #$20
ldx :exit_address
inx
ldy :low_save_addr
:do_save_entry_o jsr $0000 ; Save the low word of the exit into a save location for restore later
iny
:do_save_entry_o jsr $0000 ; Save the low byte of the exit operand into a save location for restore later
rep #$20
ldy :exit_address
lda :exit_bra
@ -629,8 +633,8 @@ CopyXToYPrep mac
<<<
]line equ 199
lup 200
lda {]line*_LINE_SIZE},x
sta {]line*_LINE_SIZE},y
lda: {]line*_LINE_SIZE},x
sta: {]line*_LINE_SIZE},y
]line equ ]line-1
--^
x2y_bottom rts
@ -646,7 +650,7 @@ LiteSetConstPrep mac
]line equ 199
lup 200
sta {]line*_LINE_SIZE},y
sta: {]line*_LINE_SIZE},y
]line equ ]line-1
--^
lsc_bottom rts