.include "validation.a" .include "ppu_sync.a" .default palette = default_palette .default tiles = default_tiles begin_ppu_test: lda #40 jsr delay_msec jsr wait_vbl jsr disable_ppu jsr clear_vram jsr clear_sprites rts .code default_palette: .db $0f,$01,$02,$39 .db $0f,$03,$04,$38 .db $0f,$05,$06,$38 .db $0f,$11,$12,$38 .db $0f,$32,$32,$21 .db $0f,$32,$32,$32 .db $0f,$32,$32,$32 .db $0f,$32,$32,$32 .code default_tiles: .db $00,$00,$00,$00,$00,$00,$00,$00 .db $00,$00,$00,$00,$00,$00,$00,$00 .db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff .db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff .db $f0,$0f,$f0,$0f,$f0,$0f,$f0,$0f .db $f0,$0f,$f0,$0f,$f0,$0f,$f0,$0f .db $80,$00,$00,$00,$00,$00,$00,$00 .db $80,$00,$00,$00,$00,$00,$00,$00 .db $81,$00,$00,$00,$00,$00,$00,$81 .db $81,$00,$00,$00,$00,$00,$00,$81 .code clear_palette: jsr wait_vbl lda #$3f jsr set_vpage lda #$0f ldx #$20 : sta $2007 dex bne - rts .code ; A = # of tiles load_tiles: asl a asl a asl a asl a tax jsr wait_vbl lda #0 jsr set_vpage ldy #0 : lda tiles,y sta $2007 iny dex bne - rts .code load_test_chr: jsr wait_vbl lda #0 jsr set_vpage ldy #0 : lda tiles,y sta $2007 iny cpy #$40 bne - rts .code load_palette: lda #$3f jsr set_vpage ldy #0 : lda palette,y sta $2007 iny cpy #$20 bne - rts .code load_graphics: jsr wait_vbl jsr load_palette jsr load_test_chr jsr clear_nametable rts .code ; Find first byte in VRAM which doesn't match A. ; Address is Y * $100 + X find_changed_vram: pha lda #0 jsr set_vpage bit $2007 pla ldx #0 ldy #0 : cmp $2007 bne found inx bne - iny cpy #$24 bne - found: rts .code delay_29781: ldy #141 ; 29769 delay lda #41 jsr delay_ya1 rts .code delay_29780: ldy #141 ; 29768 delay lda #41 jsr delay_ya0 rts .code