Page 1 of 1

Clearing the screen

Posted: Sat Jun 27, 2015 10:02 pm
by ChrisfromUSA
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.

Re: Clearing the screen

Posted: Sat Jun 27, 2015 10:16 pm
by iss
This will do the job:

Code: Select all

printf("\x0cHello world!");
or "more advanced" example: ;)

Code: Select all

#include <lib.h>
main() 
{
     cls(); 
     printf("Hello world!\n");
}

Re: Clearing the screen

Posted: Sat Jun 27, 2015 10:53 pm
by ChrisfromUSA
That looks like C. I was thinking more like assembly.

Re: Clearing the screen

Posted: Sun Jun 28, 2015 12:00 am
by iss

Code: Select all

jsr $ccce

Re: Clearing the screen

Posted: Sun Jun 28, 2015 6:43 am
by coco.oric
and you can add an assembler routine in osdk :
(there's a lot of samples and even complete source code in the defence-force repository)

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
.)

Re: Clearing the screen

Posted: Sun Jun 28, 2015 10:47 am
by Chema
What I would eagerly recommend is, as Didier wrote in your question about colors, that you start by reading one of those books. With this old machines you need to understand the hardware very well in order to do anything.

For instance clearing the screen is a matter of writing empty contents to the memory area where it is mapped. You need to understand this, where it is located (depends on the graphic mode HIRES or TEXT) and how information is stored (bit 7 is inverse flag, bit 6 is 1 for pixels or 0 for an attribute and bits 0-5 are the pixel values (on or off) or the attribute code) so "empty" means binary 01000000. See? You also need to understand how the oric display works (what are attributes?).

You can call the ROM in this case of course, but that won't be always the solution. Specially if you need a very fast or somewhat personalized routine.

Re: Clearing the screen

Posted: Sun Jun 28, 2015 12:16 pm
by Dbug
The concept of "clearing the screen" is complex on the Oric, because you want to make sure you prepare the screen so you can write stuff later, which means having a clear idea of where you want to put your color attributes. It's also important to specify if you are using the TEXT mode, the HIRES mode, or some hybrid mode that switches from one to the other.