mirror of
https://github.com/daniel5151/ANESE.git
synced 2025-04-02 10:32:00 -04:00
123 lines
1.4 KiB
Text
Vendored
123 lines
1.4 KiB
Text
Vendored
|
|
; Clear VBL flag then wait for it to be set
|
|
; Preserved: A, X, Y
|
|
wait_vbl:
|
|
bit $2002
|
|
: bit $2002
|
|
bpl -
|
|
rts
|
|
.code
|
|
|
|
; Set VRAM address to A * $100
|
|
; Preserved: X, Y
|
|
set_vpage:
|
|
bit $2002
|
|
sta $2006
|
|
lda #0
|
|
sta $2006
|
|
rts
|
|
.code
|
|
|
|
; Set VRAM address to A * $100 + X
|
|
; Preserved: A, X, Y
|
|
set_vaddr:
|
|
bit $2002
|
|
sta $2006
|
|
stx $2006
|
|
rts
|
|
.code
|
|
|
|
; Set X and Y scroll
|
|
; Preserved: A, X, Y
|
|
set_vscroll:
|
|
bit $2002
|
|
stx $2005
|
|
sty $2005
|
|
rts
|
|
.code
|
|
|
|
; Turn off NMI and disable BG and sprites
|
|
; Preserved: A, X, Y
|
|
disable_ppu:
|
|
pha
|
|
lda #0
|
|
sta $2000
|
|
sta $2001
|
|
bit $2002
|
|
sta $2006
|
|
sta $2006
|
|
pla
|
|
rts
|
|
.code
|
|
|
|
; Set sprite memory to $ff
|
|
; Preserved: Y
|
|
clear_sprites:
|
|
lda #$ff
|
|
ldx #0
|
|
: sta $2004
|
|
dex
|
|
bne -
|
|
rts
|
|
.code
|
|
|
|
; Clear/fill nametable with 0/A and clear attributes to 0
|
|
clear_nametable:
|
|
lda #0
|
|
fill_nametable:
|
|
pha
|
|
lda #$20
|
|
jsr set_vpage
|
|
pla
|
|
ldx #240
|
|
: sta $2007
|
|
sta $2007
|
|
sta $2007
|
|
sta $2007
|
|
dex
|
|
bne -
|
|
lda #0
|
|
ldx #64
|
|
: sta $2007
|
|
dex
|
|
bne -
|
|
rts
|
|
.code
|
|
|
|
; Clear/fill VRAM with 0/A
|
|
clear_vram:
|
|
lda #0
|
|
fill_vram:
|
|
ldx #0
|
|
ldy #$24
|
|
bne fill_vram_
|
|
|
|
; Clear/fill CHR with 0/A
|
|
fill_chr1:
|
|
ldx #$10
|
|
ldy #$10
|
|
bne fill_vram_
|
|
|
|
fill_chr0:
|
|
ldx #0
|
|
ldy #$10
|
|
bne fill_vram_
|
|
|
|
clear_chr:
|
|
lda #0
|
|
fill_chr:
|
|
ldx #0
|
|
ldy #$20
|
|
; Fill Y*$100 bytes of VRAM with A, starting at X*$100
|
|
fill_vram_:
|
|
bit $2002
|
|
stx $2006
|
|
ldx #0
|
|
stx $2006
|
|
: sta $2007
|
|
dex
|
|
bne -
|
|
dey
|
|
bne -
|
|
rts
|
|
.code
|