Stuck? Need help? Ask questions on our forums.

View \DIRECTW.PAS

Write a string directly to video memory.

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


program DirectW;
{
  This program shows how to write directly to video memory.
  It will not work in protected mode. There is no reason
  to believe that this runs any faster than the CRT's
  Write procedure, but we're putting it out on the BBS in
  case you are interested.

  As always, this program comes with no guarrantees and even
  less support.
}


var
  VS: Word;

function VidSeg : Word;
begin
  If Mem[$0000:$0449] = 7 Then VidSeg := $B000
  Else VidSeg := $B800;
end;

function MakeWord(H, L: Byte): Word; assembler;
asm
  mov ah, h
  mov al, L
end;

procedure WriteStr(x, y: Integer; var WriteStr: String; Attr: Integer);
var
  i: Integer;
  Loc: Integer;
begin
  dec(y);
  dec(x);
  Loc := (80 * y + x) * 2;
  for i := 1 to Length(WriteStr) do begin
    MemW[VS:Loc] := MakeWord(Attr, Ord(WriteStr[i]));
    inc(Loc, 2);
  end;
end;

var
  S : String;
begin
  S := 'Sambo';
  VS := VidSeg;
  WriteStr(10,10, S, 14 + 1 * 16);
  ReadLn;
end.
 
corner
© 1996-2008. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin.
bootstrapLabs Logo A bootstrapLabs project.