[fpc-pascal]Reading the screen

Johann Glaser Johann.Glaser at gmx.at
Fri Sep 29 08:21:55 CEST 2000


Hi!

Hmm, I saw this way and I wonder why it is necessary to do such
complicated segment calculations. Is there any reason?

> begin
>     segment:=$a7f7+(10*y)+(x div 8);	{address of char}
>     offset:=$ffee+((x mod 8)*2);
>     dosmemget(segment,offset,ascii,1);	{read ascii}
>     inc(offset);
>     dosmemget(segment,offset,attribut,1);	{read attribut}
> end;

It would more clear and far easier when doing it that way:

Begin
  Segment := $B800;
  Offset  := 2*(Y*80 + X);
  DosMemGet(Segment,Offset,Ascii,1); 
  Inc(Offset);
  DosMemGet(Segment,Offset,Attribut,1);
End;

The value $B800 is the start of the video memory in text mode. 

Be careful with the value "80" for the line width. It is possible (e.g. in
Windows DOS-Boxes or when using SVGATextMode that there are more or less
than 80 chars per line.

A bit better way would be calling "DosMemGet" only once fetchig two bytes.
Therefore "Ascii" and "Attribut" must be on two directly following memory
adresses.

Bye
  Hansi

-- 
Sent through GMX FreeMail - http://www.gmx.net




More information about the fpc-pascal mailing list