Board index » delphi » Need a new text screen-writing routine

Need a new text screen-writing routine

Hello..
  I need some sample code for a faster text screen-writing technique than
gotoxy...write.  I'd also appreciate it if the cursour wouldn't flash
about the screen like it does now!  Inline assembler is fine, as long as
the bit of code allows me to choose what to write, what colour, and what
location on the screen (80*25).

Thanks,
Lee W Baugh <i...@jove.acs.unt.edu,hams...@utdallas.edu>
--
       +------+
     +-+     o+---\ /
  +--+  The        *-
 ++   Hamster  +--/ \
 >-------------<
"Breakfast in Los Angeles... macrobiotic stuff."
    - Pink Floyd "Atom Heart Mother"

 

Re:Need a new text screen-writing routine


On 18 Nov 1995 Lee W Baugh typed the following

Quote
>Hello..
>  I need some sample code for a faster text screen-writing technique than
>gotoxy...write.  I'd also appreciate it if the cursour wouldn't flash
>about the screen like it does now!  Inline assembler is fine, as long as
>the bit of code allows me to choose what to write, what colour, and what
>location on the screen (80*25).

Here comes a unit w/ two faster write routines:

{$R-}
UNIT FWrite;
{ ************************************************************
  Module: UNIT FWRITE
  File  : FWRITE.pas
  Date  : 23.9.94
  Author: Rubenking

  used units: crt
  used files: none

  2x faster Write-routines

  ************************************************************}

INTERFACE
var
  ScreenWidth,
  ScreenHeight : Byte;

  Procedure FastWrite(S: String; co, ro, at: Byte);
  Procedure FasterWrite(S: String; co, ro, at: Word);
  Procedure CheckWidthHeight;

IMPLEMENTATION
uses crt;
Type
  WordArray = Array[0..65520 DIV 2] of word;
VAR
  Display :^WordArray;
  Crt_Cols: Word ABSOLUTE $40:$4A;
  Crt_Rows: Word ABSOLUTE $40:$84;

procedure FastWrite;
var
  Start, WordAttr: Word;
  N: Byte;
begin
  Start:=pred(ro)*Screenwidth+pred(co);
  wordAttr:=Word(At) shl 8;
  for n:=1 to ord(S[0]) do
    Display^[start+pred(N)]:=WordAttr+ord(S[N]);
end;

procedure FasterWrite(S: String; co, ro, at: word); assembler;
asm
  mov ax, ro;
  dec al;
  shl al,1;
  mul screenwidth;
  add ax,co;
  dec ax;
  mov di,word(display);
  add di, ax;
  mov ax,word(Display+2);
  mov es, ax;
  push ds;
  lds si,s;
  xor cx,cx;
  mov cl, [si];
  inc si;
  mov bh, Byte(At)
  @Loop:
    movsb;
    mov es:[di], bh;
    inc di;
  loop @loop;
  pop ds
end;

procedure checkwidthheight;
begin
  ScreenWidth:=Crt_Cols;
  ScreenHeight:=Succ(Crt_Rows);
end;

begin
  CheckWidthHeight;
  if LastMode = 7 then display:=PTR($B000,0)
    else Display:=PTR($B800,0);
end.

Check out what suits you best...

take care,
--
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Erik Pischel         * email: pisc...@informaik.hu-berlin.de       +
+ ----------------------------------------------------------------   +
+ Plesserstrasse 7     * Tel./Fax : +49 30 5368540                   +
+ 12435 Berlin         * http://www.informatik.hu-berlin.de/~pischel +
+ GERMANY              * Heinrich-Hertz-Gymnasium * Berlin F'hain    +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Re:Need a new text screen-writing routine


Quote
On Sun, 26 Nov 1995, Erik Pischel wrote:
>   Crt_Cols: Word ABSOLUTE $40:$4A;
>   Crt_Rows: Word ABSOLUTE $40:$84;

There is a LITLE mistake:
Crt_Rows should be BYTE ABSOLUTE $40:$84; (works better ! ;) )

------------------------------------------------------------------
        __    _     _
      _(  |__\ \   / /    Alexander Schweimler
     /  ) | __\ \ / /     Gerbertstr. 1
    / * | ||__ \ \ / *    D-79117 Freiburg
   /  * | | __| > / ***   Tel.   : +49-761-66542
  /   _ | ||__ / ^ \ *    e-mail : schwe...@ruf.uni-freiburg.de
 /___/ || |___/ / \ \
-------|  |__/_/---\_\---*--------+++++++-------------------------
    ** (______\ ***

Other Threads