[fpc-pascal] Cross Platform Save/Restore Screen
Marco van de Voort
marcov at stack.nl
Tue Jun 20 16:55:00 CEST 2006
> Back in the DOS Turbo Pascal days I could do the following
>
> type
> screentype= array[1..4000] of byte;
> screenptr=^screentype;
> var
> screen1: screenptr;
>
> procedure savescreen(scr:byte);
> var
> sc1: byte absolute $b000:0;
> sc2: byte absolute $b800:0;
> begin;
> if screenaddress=$b000 then move(sc1,screens1^,4000);
> if screenaddress=$b800 then move(sc2,screens1^,4000);
> end;
>
> procedure restorescreen(scr:byte);
> var
> sc1: byte absolute $b800:0;
> sc2: byte absolute $b000:0;
> begin;
> if screenaddress=$b000 then move(screens1^, sc2,4000);
> if screenaddress=$b800 then move(screens1^, sc1,4000);
> end;
(this code would fail even on dos if I set a high resolution 132x60 is 16k)
> Now I'm stuck. How can I do the same for Win32 Console apps, and
> *nix/*bsd console apps?
You can't. Most OSes don't even have a way to read the screen.
So what we do is make a virtual screen using unit "Video". For the OSes that
can read the screen we preload the virtual screen with the screen contents,
and then we update it with all screenwrites. However for this to work, all
I/O must go through it,
Since the unit Video (which is documented btw) is a backend for our Turbo
Vision equivalent, it is a bit sparse. To see how the video I/O works, see
the demo "lister".
More information about the fpc-pascal
mailing list