Clearing the screen

Here you can ask questions or provide insights about how to use efficiently 6502 assembly code on the Oric.
Post Reply
ChrisfromUSA
Private
Posts: 7
Joined: Sat Jun 27, 2015 5:23 pm
Location: United States
Contact:

Clearing the screen

Post by ChrisfromUSA » 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.
"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

User avatar
iss
Flight Lieutenant
Posts: 476
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Clearing the screen

Post by iss » Sat Jun 27, 2015 10:16 pm

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");
}

ChrisfromUSA
Private
Posts: 7
Joined: Sat Jun 27, 2015 5:23 pm
Location: United States
Contact:

Re: Clearing the screen

Post by ChrisfromUSA » Sat Jun 27, 2015 10:53 pm

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

User avatar
iss
Flight Lieutenant
Posts: 476
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Clearing the screen

Post by iss » Sun Jun 28, 2015 12:00 am

Code: Select all

jsr $ccce

User avatar
coco.oric
Flight Lieutenant
Posts: 420
Joined: Tue Aug 11, 2009 9:50 am
Location: North of France
Contact:

Re: Clearing the screen

Post by coco.oric » Sun Jun 28, 2015 6:43 am

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
.)
coco.oric as DidierV, CEO Member
Image Image

User avatar
Chema
Game master
Posts: 2016
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Clearing the screen

Post by Chema » Sun Jun 28, 2015 10:47 am

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.

User avatar
Dbug
Site Admin
Posts: 2345
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Clearing the screen

Post by Dbug » Sun Jun 28, 2015 12:16 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest