www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/15/10:36:48

From: "Alexei A. Frounze" <dummy_addressee AT hotmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ASCII GUI
Date: Mon, 15 Jan 2001 10:34:27 -0500
Lines: 160
Message-ID: <93v58c$bkkea$1@ID-57378.news.dfncis.de>
References: <57n86.4082$wt2 DOT 26425 AT news1 DOT oke DOT nextra DOT no> <93tlh4$bd027$1 AT ID-57378 DOT news DOT dfncis DOT de> <fFz86.4505$wt2 DOT 38111 AT news1 DOT oke DOT nextra DOT no>
NNTP-Posting-Host: pppa79-resalerochester5-5r7108.dialinx.net (4.4.218.12)
X-Trace: fu-berlin.de 979572815 12210634 4.4.218.12 (16 [57378])
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Your code is not a serious candidate...
And you know why? You call standard library each time you want a simple
thing like writing a character to the screen. Moreover, for some reason, you
update the cursor position.
The better solution is to set up a pointer to the screen buffer and change
characters directly on the screen thus bypassing all irrelevant stuff of the
standard library.
Just find info on how to make a pointer to the screen with DJGPP (either in
the FAQ or just try to read a doc about graphics on DJGPP site -- there
should be something about this). It should point to 0B8000h physical address
if in color text mode and 0B0000h if in monochrome.
And then your screen is an array 80x25 of words (low order byte of each word
corresponds to ASCII code of the character, high order byte of the word is a
background/ink color byte).
This way you'll speed up the stuff at least 10 times. Believe me.
Btw, this is how RHIDE draws itself on the screen (do you know RHIDE?). And
actually RHIDE is made with use of TurboVision or its port.

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:fFz86.4505$wt2 DOT 38111 AT news1 DOT oke DOT nextra DOT no...
> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019