1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-30 05:30:41 +00:00
cc65/libsrc/nes/clrscr.s
cuz 58b9530c2b More additions
git-svn-id: svn://svn.cc65.org/cc65/trunk@2128 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-05-02 15:00:45 +00:00

73 lines
1.3 KiB
ArmAsm

;
; Written by Groepaz/Hitmen <groepaz@gmx.net>
; Cleanup by Ullrich von Bassewitz <uz@cc65.org>
;
; void clrscr (void);
;
.export _clrscr
.import ppubuf_waitempty
.include "nes.inc"
.proc _clrscr
; wait until all console data has been written
jsr ppubuf_waitempty
; wait for vblank
lda #0
sta VBLANK_FLAG
@w2: lda VBLANK_FLAG
beq @w2
; switch screen off
lda #%00000000
sta PPU_CTRL2
; Set start address to Name Table #1
lda #$20
sta PPU_VRAM_ADDR2
lda #$00
sta PPU_VRAM_ADDR2
; Clear Name Table #1
lda #' '
ldx #$f0 ; 4*$f0=$03c0
beg: sta PPU_VRAM_IO
sta PPU_VRAM_IO
sta PPU_VRAM_IO
sta PPU_VRAM_IO
dex
bne beg
lda #$23 ;
sta PPU_VRAM_ADDR2 ; Set start address to PPU address $23C0
lda #$C0 ; (1st attribute table)
sta PPU_VRAM_ADDR2
ldx #$00
lll: lda #$00 ; Write attribute table value and auto increment
sta PPU_VRAM_IO ; to next address
inx
cpx #$40
bne lll
; switch screen on again
lda #%00011110
sta PPU_CTRL2
rts
.endproc