Board index » delphi » Scolling text in Graph

Scolling text in Graph

Hi there,

I've written a TP 6.0 program to scroll text up and down, but it does not
look very professional.  How can I improve it? (maybe make it move smoother)

Thanks in advance.
Johan Kohler
johan.koh...@als.co.za

-----------------------CUT HERE----------------------------------
Program TeksScroll;
Uses Graph, Crt;
Var Skik : Array[1..100] of String;
    f : text;
    i, j, gd, gm : integer;
    line : string;
    oldn, n : integer;
    ch : char;
{Number of lines displayed = 22}
{use Up and Down arrow keys to scroll}

Begin
 n := 1;
 gd := detect;
 InitGraph(gd, gm, '');
 Randomize;
 SetColor(Blue);
 Rectangle(1, 1, 600, 300);
 Assign(f, '{Put the name of a text file here}');
 Reset(f);
 For i := 1 to 100 do
  Readln(f, Skik[i]);
  Close(F);
 SetTextStyle(SmallFont, HorizDir, 5);
 SetColor(White);
  For i := n to 22 do
   Begin
    line := Skik[i];
    OutTextXY(10, i * 12, line);
   End;

 Repeat
  ch := ' ';
  If keypressed then ch := Readkey;
 Case Upcase(ch) of
  {Decide whether up or down was pressed and act accordingly}
  #80 : If n < 22 then Begin oldn := n; inc(n); ch := '*'; End;
  #72 : If n > 1 then Begin oldn := n; dec(n); ch := '*'; End;
  Else ch := ' ';
  End;

 If ch = '*' then
  Begin
   If n > oldn then
    Begin
     j := 22;
     SetColor(Black);
      For i := 22 + oldn - 1 downto oldn do
       Begin
        line := Skik[i];
        OutTextXY(10, j * 12, line);
        dec(j);
       End;

     j := 22;
     SetColor(White);
     For i := 22 + n - 1 downto n do
      Begin
       line := Skik[i];
       OutTextXY(10, j * 12, line);
       dec(j);
      End;
     End
    Else

     Begin
      j := 0;
      SetColor(Black);
      For i := oldn to 22 + oldn - 1 do
       Begin
        inc(j);
        line := Skik[i];
        OutTextXY(10, j * 12, line);
       End;

      j := 0;
      SetColor(White);
      For i := n to 22 + n - 1 do
      Begin
       inc(j);
       line := Skik[i];
       OutTextXY(10, j * 12, line);
      End;
    End;
  End;
 Until ch = #27;
End.
___ Blue Wave/DOS v2.30 [NR]

 

Re:Scolling text in Graph


Quote
JOHAN KOHLER wrote:
> Hi there,

> I've written a TP 6.0 program to scroll text up and down, but it does not
> look very professional.  How can I improve it? (maybe make it move smoother)

> -----------------------CUT HERE----------------------------------
> Program TeksScroll;
> Uses Graph, Crt;

Don't use the unit 'graph'! It's slow as hell. Try coding some vesa / modeX
functions and you'll get smooth scrolling.

c u,
Malte

--
Malte Clasen (The Update / CoPro)
mailto:Malte.Cla...@koeln.netsurf.de
http://www.koeln.netsurf.de/~Malte.Clasen/
Fight Spam Now ! - Join CAUCE at http://www.cauce.org/

Re:Scolling text in Graph


Hi there
 -=> Quoting Malte Clasen to All <=-

 MC> Don't use the unit 'graph'! It's slow as hell. Try coding some vesa /
 MC> modeX functions and you'll get smooth scrolling.

 I'm afraid I don't have a clue how to :( (I'm doing Computer Studies at
 school)  In any case, I'm trying to improve an existing existing program
 which is written using BGI.

 Thanks anyway.

Groete uit die RSA * Greetings from the RSA * Salutojn el la RSA
Johan Kohler                              
___ Blue Wave/DOS v2.30 [NR]

Re:Scolling text in Graph


In article <8E1A40E.05F10020EB.uu...@als.co.za>, johan.koh...@als.co.za says...

Quote

>Hi there,

>I've written a TP 6.0 program to scroll text up and down, but it does not
>look very professional.  How can I improve it? (maybe make it move smoother)

>Thanks in advance.
>Johan Kohler
>johan.koh...@als.co.za

Another way to do it is to use:

Var
textimage:pointer

begin

GetMem(textimage,imagesize(0,0,50,50));
GetImage(0,0,50,50,textimage^);

PutImage(100,100,textimage^,0);

end.

this is just part of a code fragment. but to explain, you first output all the
text you want to display on the screen. choose the rectange formed by -->
(0,0,50,50) [is the size of the image you want to scroll].  getmem allocates
space for the image, getimage actually gets it.   Finally, putimage  displays
the image you stored in getmem & getimage @ (100,100).

p.s.

you can even do double-buffering.  you draw the image on a "virtual" screen
then change screens to the one you drew it on.

ex)

SetActivePage(0);
SetVisualPage(1);

{ This will do every thing on page 0 while you actually see page 1. Then change
to other screen whenever}

SetVisualPage(0);

Any Questions welcome @ - adam.du...@mail.utexas.edu

Re:Scolling text in Graph


It's probably best to look at MODE13h using CHAIN4 graphics mode, its
brilliant and easy to get to grips with, i think denthor from his vga
trainer series did something about this, get his code and try it out.

Jim

Other Threads