PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

EasyCE Line Problems?

I've been playing around with a new game dev, and I've been trying to use the line function in EasyCE, but no matter what I do I cant get it to draw anything.

i.e line(x1,y1,x2,y2,PIXEL color, buffer)

source for line function:

Code:

void line( int x1, int y1, int x2, int y2, PIXEL color, PIXEL* buff)
{
if (y1>y2)
{
int h=y1;
y1=y2, y2=h;
h=x1, x1=x2, x2=h;
}
int dx, dy, len = abs( x2-x1 );
if (abs( y2 - y1 ) > len) len = abs( y2 - y1 );
len = len >> FPP;
if (len != 0)
{
dx = (x2 - x1) / len;
dy = (y2 - y1) / len;
}
if (y1 < 0)
{
if (dy > 0)
{
int i = -(y1 / dy) + 1;
x1 += dx * i;
y1 += dy * i;
len -= i;
}
else len = 0;
}
if (len > 0) if (x1 < 0)
{
if (dx > 0)
{
int i = -(x1 / dx) + 1;
x1 += dx * i;
y1 += dy * i;
len -= i;
}
else len = 0;
}
if (len > 0) if (y2 > (240 << FPP))
{
if (dy > 0)
{
int i = ((y2 - (240 << FPP)) / dy) + 1;
x2 -= dx * i;
y2 -= dy * i;
len -= i;
}
else len = 0;
}
if (len > 0) if (x2 > (320 << FPP))
{
if (dx > 0)
{
int i = ((x2 - (320 << FPP)) / dx) + 1;
x2 -= dx * i;
y2 -= dy * i;
len -= i;
}
else len = 0;
}
for ( int i = 0; i < len + 1; i++)
{
buff[((y1 >> FPP) * 240) + (x1 >> FPP)] = color;
x1 += dx;
y1 += dy;
}
}


am I missing somthing here?, is there a bug in jakkos code? any ideas?
Brendan,

You might get a quicker response if you ask questions regarding EasyCE in Jacco's "Overloaded" forum.
Hi Brendan,

The key to this code is the #define's of FPP. Have a look in some one of the sample's and you will see it is defined as 10. This function is looking for fixed point numbers. There is another define some where (not got the info with me at the mo) that call's line with I think IFP(int).

Try calling this line procedure with
Code:

line(IFP(0),IFP(0),IFP(240),IFP(320),color,buffer);



it may not be IFP, it could be something else but it is defined somewhere.

Sorry I'm a bit vague, drop me a pm if you are still stuck and I'll reply tomorrow when I have the full info to hand

Speak soon
Bad
brendan · 08 Nov 2002, 03:31 UTC — more problems
using the same function as listed above, the following code will only draw a line for about 0,0 to 200,240 (ish), the rest is just not there?

Code:

line(IFP(0),IFP(0),IFP(239),IFP(319),BLUE,screen_buffer_p);


any ideas why.... I thought my code was stuffed at first until I tryed fixed numbers, it seems that it wont draw any line information below raster 240 ish

any Ideas?
I think this code cuts the line at 320x240 instead 240x320 (or the other way around).. I think Jacco corrected it in a later version of EasyCE? But maybe not.. pls check in code where it performs clipping and eventually flip the 240/320 value... it should work fine then.