This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

PPU CLEARN

PPU CLEARN
by on (#198016)
Code:
;[FC][PPU数据清除]
;FlameCyclone 2017.6.11


 .ORG $A180

COPY_TO_L = $40
COPY_TO_H = $41


COPY_DATA:
 LDX #$00
 LDY #$00
 LDA #$00
 STA $2001
 JSR TIMEDELAY
COPY_TO_SET:   ;目的开始地址设置
 LDA COPY_TO_ADDR
 STA COPY_TO_H
 LDA COPY_TO_ADDR+1
 STA COPY_TO_L
 JSR COPY_TO_PPU
 
COPY_START:   ;复制开始
 LDA COPY_TO_L
 CMP COPY_OVER_ADDR+1
 BNE COPY_DATA_START
 LDA COPY_TO_H
 CMP COPY_OVER_ADDR
 BEQ COPY_OVER
COPY_DATA_START:   ;开始复制数据
 LDA #$00
 STA $2007
 JSR COPY_TO_ADD
 JMP COPY_START

COPY_OVER:    ;结束数据复制
 LDA #$00
 STA $2007
 JSR TIMEDELAY
 RTS
 
 
COPY_TO_ADD:    ;目的地址递增
 INC COPY_TO_L
 BNE COPY_TO_ADD_RTS
 INC COPY_TO_H
COPY_TO_ADD_RTS:
 JSR COPY_TO_PPU
 RTS


COPY_TO_PPU:    ;设置目的PPU地址
 LDA COPY_TO_H
 STA $2006
 LDA COPY_TO_L
 STA $2006
 RTS

COPY_TO_ADDR:    ;目的开始地址
 .DB $30,$00
COPY_OVER_ADDR:    ;目的结束地址
 .DB $3E,$FF
 
TIMEDELAY:
 LDA $2002
 BPL TIMEDELAY
 RTS