TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Lars Hellsten
from: Patrick Annette
date: 1996-01-08 20:40:08
subject: Video I/O

Quoting Lars Hellsten to All in a message dated 01/04

LH> I'm using Virtual Pascal/2 and attempting to write an OS/2 text mode
LH> port of a DOS program I've written.  I've run into a few roadblocks so
LH> far and gotten past them fine, but there's one major problem I'm
LH> having write now.
LH> 
LH> Writing to the screen one character at a time is horribly slow. 
LH> I've had the same results with both Virtual Pascal and Speed-Pascal/2,
LH> so the problem seems to be inherent to the OS/2 API functions.  I've
LH> tried using ALL of the "VioWrt???" calls instead of the
VP/SP "Write"
LH> procedures with no noticable differences.  Even writing full strings
LH> to the screen is slower than it 

[ remainder deleted ]

I haven't used the following, but it claims to solve that problem: 

(if it works, let me know )

+---------------------------------------------------------------------------+
| Date: 07-24-95, 23:13                  Number: 248                       
|
| From: Alexander Kuiper                  Refer: 70                         |
|   To: B.J. Guillot                      Recvd: No                         |
| Subj: OS/2, why text so SLOW??           Conf: Pascal                     |
+---------------------------------------------------------------------------+
Hello B.J.!

Thursday July 20 1995 20:08, B.J. Guillot wrote to All:

 BJG> I've looked at all three OS/2 options available to us 
 BJG> Pascal programmers:
 BJG> The German patch, SpeedPascal, and now Virtual Pascal.

 BJG> There is one thing that is common to all three of these guys...

 BJG> The displaying of text is SUPER SLOW!  Apparently, it seems to be that
 BJG> the OS/2 VIO calls for printing text to the screen are as slow as a
 BJG> snail.

Nope, if you are doing it the right way, it's just as fast...

 BJG> I've tried using the VIO calls to do "direct" screen writes, and
 BJG> it's better, but still very slow (you have to grab the screen image into
 BJG> an array, change the characters you need to, and then 
 BJG> copy the array back
 BJG> using another OS call).

You're doing it wrong, it can be done much easier...

 BJG> Is there ANY way to speed up the screen writing in these OS/2 programs?

Piece of my recently posted code (tested with VP), look at FastWrite


USES CRT,OS2BASE;

TYPE
   ScreenPtr     = ^ScreenImage;

   ScreenImage = Record
      CursorX,
      CursorY,
      ScanTop,
      ScanBot,
      SavedLines : Byte;
      ScreenPtr  : PChar;
   END;

VAR
   Screen : Array[1..99] of ScreenPtr;

Procedure PosCursor (X, Y : Word);
BEGIN
    VioGetCurPos(Y,X,0);
    Inc(x);
    Inc(y);
END;

Procedure SizeCursor (top,bot:Byte);
VAR
   CursorInfo : VioCursorInfo;

BEGIN
   VioGetCurType (CursorInfo,0);
   CursorInfo.YStart := Top;
   CursorInfo.CEnd   := Bot;
   VioSetCurType(CursorInfo,0);
END;

Procedure FindCursor (VAR X, Y, Top, Bot : Byte);
VAR
   CursorInfo : VioCursorInfo;

BEGIN
   VioGetCurType(CursorInfo,0);
   Top := CursorInfo.YStart;
   Bot := CursorInfo.CEnd;
   X := WhereX;
   Y := WhereY;
END;

Procedure SaveScreen (Page : Byte);
VAR
   W : Word;

BEGIN
   IF (Page > 99) THEN Exit;

   GetMem(Screen[Page],SizeOf(Screen[Page]^));

   WITH Screen[Page]^ DO
   BEGIN
      FindCursor(CursorX,CursorY,ScanTop,ScanBot);
      SavedLines := 25;
      GetMem(Screen[Page]^.ScreenPtr,25 * 160);
      W := 25 * 160;
      VioReadCellStr(Screen[Page]^.ScreenPtr^,W,0,0,0);
   END;
END;

Procedure RestoreScreen (Page : Byte);
VAR
   W : Word;

BEGIN
   WITH Screen[Page]^ DO
   BEGIN
      W := SavedLines * 160;
      VioWRTCellStr(Screen[Page]^.ScreenPtr,W,0,0,0);
      PosCursor(CursorX,CursorY);
      SizeCursor(ScanTop,ScanBot);
   END;
END;

Procedure PlainWrite(Col, Row : Byte; St : String);
BEGIN
   VIOWrtCharStr({at}St[1],Length(St),Row - 1,Col - 1,0);
END;

Procedure FastWrite(Col, Row, Attr : Byte; St : String);
BEGIN
   VIOWrtCharStrAtt({at}St[1],Length(St),Row - 1,Col - 1,Attr,0);
END;


BEGIN
END.

Greetz,

     --------- Alexander ----------
     Home of MultiSoft Development!

Oh, pardon me, was that *your* culture? So sorry.

___ ProBoard v2.02g2 [Reg]

                                     
X---------------------------------------------------------------------------X

Hope this helps,

Patrick

 * KWQ/2 1.2i *  

--- Maximus/2 3.01
* Origin: Home of AMP, News-Mgr, AMList, PTrack and many more! (2:285/36)
* Origin: OS/2 Online * Auburn, WA * 206-351-5998 * (1:343/212)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 343/212 800 1 138/103 3615/50 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.