Mail Archives: djgpp/2001/01/15/05:08:13
I can't really compare to Turbo Vision, since DJGPP is currently the only
compiler I have used.
Im not sure of how to hide the cursor either, usually I place the cursor at
a position above the screen,
so it wont show to much. And im new with C also, so there is perhaps
something wrong with my code.
The following is an example of the function I use which moves very slow.
#include <conio.h>
#include <dos.h>
void frame(char x, char y, char x2, char y2, char color);
int main()
{
char x=30, y=5, x2=50, y2=10;
while(x != 1)
{
delay(100);
clrscr();
frame(x, y, x2, y2, 15);
if(y>1)
y--;
if(y2<24)
y2++;
x--;
x2++;
}
return 0;
}
void frame(char x, char y, char x2, char y2, char color)
{
char c;
textcolor(color);
for(c=x; c<x2; c++) /*draws top and bottom lines.*/
{
gotoxy(c,y);
cputs("\xCD");
gotoxy(c,y2);
cputs("\xCD");
}
for(c=y+1; c<y2; c++) /*draws left and right lines.*/
{
gotoxy(x-1,c);
cputs("\xBA");
gotoxy(x2,c);
cputs("\xBA");
}
gotoxy(x-1,y);
cputs("\xC9"); /* draws top-left corner*/
gotoxy(x-1,y2);
cputs("\xC8"); /*draws bottom-left corner*/
gotoxy(x2,y2);
cputs("\xBC"); /*draws bottom-right corner*/
gotoxy(x2,y);
cputs("\xBB"); /*draws top-right corner*/
gotoxy(0,0); /*goes to this pos. to hide cursor.*/
}
Alexei A. Frounze <dummy_addressee AT hotmail DOT com> wrote in message
news:93tlh4$bd027$1 AT ID-57378 DOT news DOT dfncis DOT de...
> Hey!
>
> You may notice how fast TurboVision (text GUI from Turbo Pascal) is. It's
> even fast on 286!
> So the things to think of are:
> 1. turn off cursor while redrawing, if it bores you
> 2. perform redraws in an off-screen buffer which should be a) usually
> noticable faster and b) is hidden from user
> 3. think of window clipping. if you redraw a window entirely regardless of
> whether it's visible to user or not (e.g. under other windows). this
should
> make some performance improvements
> 4. turn on optimizations in GCC (perhaps this should go before 1 and 2 :))
> 5. if the thing is still slow, then there's something wrong with your code
> because GCC does very good optimization so that you often don't need to
> think of ASM at all
>
> Good Luck
> --
> Alexei A. Frounze
> alexfru [AT] chat [DOT] ru
> frounze [AT] ece [DOT] rochester [DOT] edu
> http://alexfru.chat.ru
> http://members.xoom.com/alexfru/
> http://welcome.to/pmode/
>
> "Jon" <lennier AT online DOT no> wrote in message
> news:57n86.4082$wt2 DOT 26425 AT news1 DOT oke DOT nextra DOT no...
> > I'm fairly new to programming, and have just started writing a program
in
> > DJGPP which uses
> > an ASCII GUI. The problem is that, it redraws the GUI very slow. Even on
> my
> > 850 MHZ Athlon, I can see the cursor drawing up the GUI. Currently I use
> the
> > gotoxy(); function and cprintf(); to draw the GUI.
> > But when doing big redraws, it just become too slow, like on another
> program
> > I made, I used the ASCII character 219 to form a word, which I moved
> across
> > the screen. This was also terrible slow.
> > So, do anyone know of a better way to draw up ASCII graphics without
using
> > the gotoxy and cprintf?
> >
> > Jon
> >
> >
>
>
- Raw text -