]> git.sur5r.net Git - cc65/blobdiff - libsrc/cbm510/clrscr.s
remove superfluous ".code" line
[cc65] / libsrc / cbm510 / clrscr.s
index 73a6c4be1267dee969b7aeeb14bc663994d5fc12..8025a30c1ff4af31fb0f0e210d080b2d26cce61f 100644 (file)
@@ -5,8 +5,8 @@
        .export         _clrscr
        .import         plot
 
-       .include        "zeropage.inc"
-       .include        "io.inc"
+       .include        "cbm510.inc"
+        .include        "extzp.inc"
 
 ; ------------------------------------------------------------------------
 ; void __fastcall__ clrscr (void);
        lda     #0
        sta     CURS_X
        sta     CURS_Y
-               jsr     plot            ; Set cursor to top left corner
+               jsr     plot            ; Set cursor to top left corner
 
-       ldx     #4
-       ldy     #$00
-       lda     #$20            ; Screencode for blank
-L1:    sta     (CharPtr),y
-       iny
-       bne     L1
-       inc     CharPtr+1
-       dex
-       bne     L1
-
-       jmp     plot            ; Set screen pointer again
+               ldx     #$00            ; Count
+       jsr     clearpage
+       jsr     clearpage
+       jsr     clearpage
+               ldx     #<(40*25)       ; Count
+       jsr     clearpage       ; Clear remainder of last page
+       jmp     plot            ; Set screen pointer again
 
 .endproc
 
 
+.proc  clearpage
+
+       txa
+       pha                     ; Save count
+
+       lda     #$20            ; Screencode for blank
+       ldy     #$00
+@L1:   sta     (SCREEN_PTR),y
+       iny
+       dex
+       bne     @L1
+       inc     SCREEN_PTR+1
+
+       pla
+       tax                     ; Reload count
+       lda     IndReg
+       pha
+       lda     #$0F
+       sta     IndReg          ; Switch to the system bank
+       lda     CHARCOLOR       ; Load color
+       ldy     #$00
+@L2:   sta     (CRAM_PTR),y
+       iny
+       dex
+       bne     @L2
+       inc     CRAM_PTR+1
+       pla
+       sta     IndReg          ; Restore the old indirect bank
+       rts
 
+.endproc