]> git.sur5r.net Git - cc65/blob - libsrc/nes/clrscr.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / nes / clrscr.s
1 ;
2 ; Written by Groepaz/Hitmen <groepaz@gmx.net>
3 ; Cleanup by Ullrich von Bassewitz <uz@cc65.org>
4 ;
5 ; void clrscr (void);
6 ;
7
8         .export         _clrscr
9         .import         ppubuf_waitempty
10
11         .include        "nes.inc"
12
13
14 .proc   _clrscr
15
16 ; wait until all console data has been written
17
18         jsr     ppubuf_waitempty
19
20 ; wait for vblank
21
22         lda     #0
23         sta     VBLANK_FLAG
24 @w2:    lda     VBLANK_FLAG
25         beq     @w2
26
27 ; switch screen off
28
29         lda     #%00000000
30         sta     PPU_CTRL2
31
32 ; Set start address to Name Table #1
33
34         lda     #$20
35         sta     PPU_VRAM_ADDR2
36         lda     #$00
37         sta     PPU_VRAM_ADDR2
38
39 ; Clear Name Table #1
40
41         lda     #' '
42         ldx     #$f0            ; 4*$f0=$03c0
43
44 beg:    sta     PPU_VRAM_IO
45         sta     PPU_VRAM_IO
46         sta     PPU_VRAM_IO
47         sta     PPU_VRAM_IO
48         dex
49         bne     beg
50
51         lda     #$23            ;
52         sta     PPU_VRAM_ADDR2  ; Set start address to PPU address $23C0
53         lda     #$C0            ; (1st attribute table)
54         sta     PPU_VRAM_ADDR2
55
56         ldx     #$00
57
58 lll:    lda     #$00            ; Write attribute table value and auto increment
59         sta     PPU_VRAM_IO     ; to next address
60         inx
61         cpx     #$40
62         bne     lll
63
64 ; switch screen on again
65
66         lda     #%00011110
67         sta     PPU_CTRL2
68         rts
69
70 .endproc
71
72