I can't find it on the wiki now either. My devlog notes the technique on 2016-05-18 as "RTS-display-list-on-stack" and then never mentions it again, but it's definitely right there in the source:
Code: Select all
.org $C000
bank .byte 0,1,2,3,4,5,6,7 ; UNROM conflict-avoidance table
irq:
reset:
lda #0
sta $2000 ; disable NMI
sta $2001 ; disable rendering
sta bank+0 ; switch in bank 0
jmp init
.dsb $FF00 - *
; copy 0-32 bytes to the PPU
nmi_copy:
nop ; offset for RTS (I'm lazy)
.byte $68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20 ; PLA/STA x32
.byte $68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20 ; 4 bytes each
.byte $68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20
.byte $68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20
.byte $68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20
.byte $68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20
.byte $68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20
.byte $68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20,$68,$8D,$07,$20
pla
sta $2006
pla
sta $2006
rts
; write 32 zeroes to the PPU
nmi_zero:
nop
ldy #8
lda #0
nmi_zero1:
sta $2007
sta $2007
sta $2007
sta $2007
dey
bne nmi_zero1
pla
sta $2006
pla
sta $2006
rts
; close the RTS chain
nmi_end:
nop
lda scroll_x
sta $2005
lda scroll_y
sta $2005
lda #$88 ; TODO: nametable select
sta $2000
ldx nmi_s
txs
ldy nmi_y
ldx nmi_x
lda nmi_a
nmi_abort:
rti
nmi:
lsr nmi_flag
bcc nmi_abort
sta nmi_a
stx nmi_x
sty nmi_y
tsx
stx nmi_s
lda #>oam
sta $4014
ldx #$FF
txs
pla
sta $2006
pla
sta $2006
rts
.dsb $FFFA - * ; pad to interrupt vectors
.word nmi
.word reset
.word irq
I also used this method on PC a fair bit, back when I was doing assembler coding for DOS and so on, so maybe I mentally inserted it into the "RTS Trick" page as a matter of course?
the day it was posted, so I may have got it from there. My treatment of $2006 is identical so it's likely that was it.