Clearing the screen
Posted: Sat Jun 27, 2015 10:02 pm
Is there a little bit of example code pertaining to clearing the screen? I got "Hello World", but I want a blank screen when I print it.
Code: Select all
printf("\x0cHello world!");
Code: Select all
#include <lib.h>
main()
{
cls();
printf("Hello world!\n");
}
Code: Select all
;
; -------------------------------------------------------------------
; This is a simple display module
; called by the C part of the program
; We define the adress of the TEXT screen.
#define DISPLAY_ADRESS $BB80
#define CHAR_HIRES $9800
#define CHAR_HIRES32 $9900
#define CHAR_TEXT $B400
; We use a table of bytes to avoid the multiplication
; by 40. We could have used a multiplication routine
; but introducing table accessing is not a bad thing.
; In order to speed up things, we precompute the real
; adress of each start of line. Each table takes only
; 28 bytes, even if it looks impressive at first glance.
;
; This table contains lower 8 bits of the adress
TextAdressLow
.byt <(DISPLAY_ADRESS+40*0)
.byt <(DISPLAY_ADRESS+40*1)
.byt <(DISPLAY_ADRESS+40*2)
.byt <(DISPLAY_ADRESS+40*3)
.byt <(DISPLAY_ADRESS+40*4)
.byt <(DISPLAY_ADRESS+40*5)
.byt <(DISPLAY_ADRESS+40*6)
.byt <(DISPLAY_ADRESS+40*7)
.byt <(DISPLAY_ADRESS+40*8)
.byt <(DISPLAY_ADRESS+40*9)
.byt <(DISPLAY_ADRESS+40*10)
.byt <(DISPLAY_ADRESS+40*11)
.byt <(DISPLAY_ADRESS+40*12)
.byt <(DISPLAY_ADRESS+40*13)
.byt <(DISPLAY_ADRESS+40*14)
.byt <(DISPLAY_ADRESS+40*15)
.byt <(DISPLAY_ADRESS+40*16)
.byt <(DISPLAY_ADRESS+40*17)
.byt <(DISPLAY_ADRESS+40*18)
.byt <(DISPLAY_ADRESS+40*19)
.byt <(DISPLAY_ADRESS+40*20)
.byt <(DISPLAY_ADRESS+40*21)
.byt <(DISPLAY_ADRESS+40*22)
.byt <(DISPLAY_ADRESS+40*23)
.byt <(DISPLAY_ADRESS+40*24)
.byt <(DISPLAY_ADRESS+40*25)
.byt <(DISPLAY_ADRESS+40*26)
.byt <(DISPLAY_ADRESS+40*27)
; This table contains hight 8 bits of the adress
TextAdressHigh
.byt >(DISPLAY_ADRESS+40*0)
.byt >(DISPLAY_ADRESS+40*1)
.byt >(DISPLAY_ADRESS+40*2)
.byt >(DISPLAY_ADRESS+40*3)
.byt >(DISPLAY_ADRESS+40*4)
.byt >(DISPLAY_ADRESS+40*5)
.byt >(DISPLAY_ADRESS+40*6)
.byt >(DISPLAY_ADRESS+40*7)
.byt >(DISPLAY_ADRESS+40*8)
.byt >(DISPLAY_ADRESS+40*9)
.byt >(DISPLAY_ADRESS+40*10)
.byt >(DISPLAY_ADRESS+40*11)
.byt >(DISPLAY_ADRESS+40*12)
.byt >(DISPLAY_ADRESS+40*13)
.byt >(DISPLAY_ADRESS+40*14)
.byt >(DISPLAY_ADRESS+40*15)
.byt >(DISPLAY_ADRESS+40*16)
.byt >(DISPLAY_ADRESS+40*17)
.byt >(DISPLAY_ADRESS+40*18)
.byt >(DISPLAY_ADRESS+40*19)
.byt >(DISPLAY_ADRESS+40*20)
.byt >(DISPLAY_ADRESS+40*21)
.byt >(DISPLAY_ADRESS+40*22)
.byt >(DISPLAY_ADRESS+40*23)
.byt >(DISPLAY_ADRESS+40*24)
.byt >(DISPLAY_ADRESS+40*25)
.byt >(DISPLAY_ADRESS+40*26)
.byt >(DISPLAY_ADRESS+40*27)
; ----------------------------------------------------------------
; Effacer l'ecran de $BB80 à $BFDF soit 1120 octets
; soit 4*256 + 96 octets
_TextClear
.(
lda #0
ldx #0
loop_x
sta DISPLAY_ADRESS+256*0,x
sta DISPLAY_ADRESS+256*1,x
sta DISPLAY_ADRESS+256*2,x
sta DISPLAY_ADRESS+256*3,x
sta DISPLAY_ADRESS+1120-256,x
dex
bne loop_x
rts
.)