color an area

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
Spocky
2nd Star Corporal
Posts: 28
Joined: Sun Nov 18, 2012 10:56 am
Location: Melun (France)

color an area

Post by Spocky »

Hello everyone.

I've a problem on my C code. I want to color an area after some time. It's all the bottom screen of the HIRES screen.

I've try this:

Code: Select all

	for(i=147;i<=240;i++){
		curset(0,i,0);
		draw(240,0,0);	
	}
But I doesn't work at all. Someone have a solution?

Thanks for your help
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: color an area

Post by Chema »

Hi Spocky.

Let's see if I can be of any help. First notice that this is not at all the fastest way to do this, but anyway.

If I understood correctly you want to fill lines from 147 to bottom with ink color. First thing to tweak is the limit of the for loop. It should go up to 199 (the max. row). Then the draw command which takes the width in pixels in both x and y directions AND an additional parameter which is 0 to draw with paper color and 1 to draw with ink color. So you have to set it to 1. Also beware that the width is 239. Setting it to 240 will attept to draw outside the limits, so an error is produced and nothing is drawn.

So the code would be:

Code: Select all

  for(i=147;i<200;i++){
      curset(0,i,0);
      draw(239,0,1);   
   }
You will notice the first pixel is still black. If you replace the curset parameters with curset(0,i,1) that will do the trick.

If you simply want set the paper or ink color of that area, it is much better to deal with attributes, either directly poke'ing them or using the fill command.

For instance, to set those lines all to red paper, you can do:

Code: Select all

	curset(0,147,0);
	fill(53,1,1+16); /*Red color is 1, add 16 to indicate it is paper color, not ink */
Refer to the Oric's BASIC manual for details on how to use these routines, as the C library simply calls them.

Hope this helps...
Yicker
Pilot Officer
Posts: 97
Joined: Thu Jan 26, 2006 11:27 pm
Location: St. Helens, Merseyside, UK

Re: color an area

Post by Yicker »

Hi,

I haven't done any C programming for the Oric so I might be on the wrong track here but looking at your code there are a couple of things to note. Firstly, your draw statement is using an FB value of 0 which draws a line in the background colour so for a default HIRES screen this would be black so that would explain why you can't see anything on the screen. Another thing, your CURSET command is using 'i' for the screen 'y' value which must be in the range of 0 to 199 however your loop is going upto 240 which is beyond the screen height. The following example might work better.

Code: Select all

for(i=147; i<199; i++)
{
    curset(12, i, 0);
    draw(227, 0, 1);
}
Cheers
Scott
Spocky
2nd Star Corporal
Posts: 28
Joined: Sun Nov 18, 2012 10:56 am
Location: Melun (France)

Re: color an area

Post by Spocky »

I've try the fill function. It's work perfectly as I want. I've seen it before but don't really understood how it's working.
Thanks for your help
Post Reply