Clearing the screen
-
- Private
- Posts: 7
- Joined: Sat Jun 27, 2015 5:23 pm
- Location: United States
- Contact:
Clearing the screen
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.
"I have not failed 700 times. I have not failed once. I have succeeded in proving that those 700 ways will not work."
-Thomas Edison
-Thomas Edison
Re: Clearing the screen
This will do the job:
or "more advanced" example:
Code: Select all
printf("\x0cHello world!");
Code: Select all
#include <lib.h>
main()
{
cls();
printf("Hello world!\n");
}
-
- Private
- Posts: 7
- Joined: Sat Jun 27, 2015 5:23 pm
- Location: United States
- Contact:
Re: Clearing the screen
That looks like C. I was thinking more like assembly.
"I have not failed 700 times. I have not failed once. I have succeeded in proving that those 700 ways will not work."
-Thomas Edison
-Thomas Edison
Re: Clearing the screen
Code: Select all
jsr $ccce
- coco.oric
- Squad Leader
- Posts: 720
- Joined: Tue Aug 11, 2009 9:50 am
- Location: North of France
- Contact:
Re: Clearing the screen
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)
(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
.)
coco.oric as DidierV, CEO Member
Historic owner of Oric, Apple II, Atari ST, Amiga
Historic owner of Oric, Apple II, Atari ST, Amiga
Re: Clearing the screen
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.
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
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.