Mail Archives: djgpp/1998/09/10/13:48:49
On Thu, 10 Sep 1998, Tal Lavi wrote:
> Can you please tell me how you can make 32-bit writes with a VLine routine?
For vertical lines, you can't. I thought you were drawing horizontal
lines as well.
> Can you think of any optimizations(except of writing everything in ASM)?
I don't think assembly will help you much. If you compile with -O2, GCC
should produce code that's quite good in this case.
But I suggest to use int's instead of shorts in this function, like this:
void VLine(unsigned x,
int y1, int y2,
unsigned short c)
{
unsigned y;
if (y1<=y2)
{
y1=(y1<0)?0:y1;
y2=(y2>=480)?479:y2;
SetScreen;
for (y=y1;y<=y2;y++)
PutPixelns(x,y,c);
}
else
{
y1=(y1>=640)?639:y1;
y2=(y2<0)?0:y2;
SetScreen;
for (y=y2;y<=y1;y++)
PutPixelns(x,y,c);
}
}
This should be faster. In general, a loop variable should always be an
int, unless you have grave reasons to do otherwise. int will produce the
fastest code.
> I downloaded the bug fix for the profiler problem, but I had no idea about
> what to do with it because of lack of documantation. I took the already built
> libc file and was done with it.
This should be enough. Can you now run the profiled program without
wedging your machine? If yes, then that problem is solved.
> I also took the libcpg.zip file. but how can I use it to profile libc
> functions?
The easiest way is to replace your libc.a with libc_pg.a, and then relink
your program. (Actually, the linker should automatically link agains
libc_pg.a when you link with -pg switch, but I don't think DJGPP is set
that way by default, and I don't recommend that you mess with system
files to set that up.)
Btw, I think you shouldn't be worried about profiling the library.
Profile your code first, as most probably, the cause for the slow-down is
in your code.
- Raw text -