Cross Platform Save/Restore Screen

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Cross Platform Save/Restore Screen

Michael Preslar
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;

Now I'm stuck. How can I do the same for Win32 Console apps, and
*nix/*bsd console apps?

(For anyone wondering.. I'm the Legend of the Red Dragon developer
[remember that old beast?], and after porting LORD to Win32, *nix [and
mostly *bsd .. Just need to replace the dependance on the 'oldlinux'
unit], and os2, I'm converting LordCfg to a native binary as well, and
need the savescreen/restorescreen for the eyecandy part of the program)

--
Michael Preslar
Landline: (402) 614-3551
Cell: (402) 990-8001

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross Platform Save/Restore Screen

Michael Van Canneyt


On Tue, 20 Jun 2006, Michael Preslar wrote:

> 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;
>
> Now I'm stuck. How can I do the same for Win32 Console apps, and
> *nix/*bsd console apps?

The short answer: You simply can't...

You must use the 'video' unit to do this kind of tricks in a more or less
cross-platform way, but you'll have to rewrite your code completely.

You may also want to have a look at the ncurses unit and the various
descendents, ocrt, ncrt.

video is documented, and is part of the RTL.
The others are in the packages.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross Platform Save/Restore Screen

Marco van de Voort
In reply to this post by Michael Preslar
> 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".
 
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross Platform Save/Restore Screen

Jonas Maebe-2
In reply to this post by Michael Preslar

On 20 jun 2006, at 16:45, Michael Preslar wrote:

> Now I'm stuck. How can I do the same for Win32 Console apps, and
> *nix/*bsd console apps?

See the user screen unit of the IDE:
http://www.freepascal.org/cgi-bin/viewcvs.cgi/trunk/ide/fpusrscr.pas?
rev=3297

> (For anyone wondering.. I'm the Legend of the Red Dragon developer
> [remember that old beast?]

BBS doors! Phone costs were way too high to spend time on things like  
that, so I've never actually played it. I do remember reading about  
it in the FidoNet Pascal echo though :)


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross Platform Save/Restore Screen

Tomas Hajny
In reply to this post by Michael Preslar
Michael Preslar wrote:
> Back in the DOS Turbo Pascal days I could do the following
 .
 .
> Now I'm stuck. How can I do the same for Win32 Console apps, and
> *nix/*bsd console apps?
>
> (For anyone wondering.. I'm the Legend of the Red Dragon developer
> [remember that old beast?], and after porting LORD to Win32, *nix [and
> mostly *bsd .. Just need to replace the dependance on the 'oldlinux'
> unit], and os2, I'm converting LordCfg to a native binary as well, and
> need the savescreen/restorescreen for the eyecandy part of the program)

Whereas the comments from other people in this thread still apply, the
next version of unit Video should provide you with the possibility to save
and restore the current screen - still under the condition that the
platform and terminal/console allow it (which might require all output to
be done via unit Video as well - however, that should include e.g. output
done using Crt unit as well). Regarding availability - well, I'm afraid
that this might not be before August now (another FPC activity which will
take some time from FPC core team members is planned for July - stay tuned
:/ ).

Regards

Tomas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Cross Platform Save/Restore Screen

Michael Preslar
In reply to this post by Jonas Maebe-2
Thanks to all for the pointers. The FPC IDE source is definitly useful.
Will have to play with that and see what I can come up with..

Thanks again!

--
Michael Preslar
Landline: (402) 614-3551
    Cell: (402) 990-8001
 


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Jonas
Maebe
Sent: Tuesday, June 20, 2006 10:01 AM
To: FPC-Pascal users discussions
Subject: Re: [fpc-pascal] Cross Platform Save/Restore Screen



On 20 jun 2006, at 16:45, Michael Preslar wrote:

> Now I'm stuck. How can I do the same for Win32 Console apps, and
> *nix/*bsd console apps?

See the user screen unit of the IDE:
http://www.freepascal.org/cgi-bin/viewcvs.cgi/trunk/ide/fpusrscr.pas?
rev=3297

> (For anyone wondering.. I'm the Legend of the Red Dragon developer
> [remember that old beast?]

BBS doors! Phone costs were way too high to spend time on things like  
that, so I've never actually played it. I do remember reading about  
it in the FidoNet Pascal echo though :)


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross Platform Save/Restore Screen

Marco van de Voort
> Thanks to all for the pointers. The FPC IDE source is definitly useful.
> Will have to play with that and see what I can come up with..

(note that the IDE is based on FV which is based in turn on units
keyboard,video,mouse)

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross Platform Save/Restore Screen

Luiz Americo Pereira Camara-2
In reply to this post by Michael Preslar
Michael Preslar wrote:

> 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;
>
> Now I'm stuck. How can I do the same for Win32 Console apps, and
> *nix/*bsd console apps?
>
> (For anyone wondering.. I'm the Legend of the Red Dragon developer
> [remember that old beast?], and after porting LORD to Win32, *nix [and
> mostly *bsd .. Just need to replace the dependance on the 'oldlinux'
> unit], and os2, I'm converting LordCfg to a native binary as well, and
> need the savescreen/restorescreen for the eyecandy part of the program)
>
>  
I'm sending a unit that has such functions for win32.
I've used this unit in a homebrew console ui "toolkit", but be aware
that the last time i compiled it was in fpc106 days so maybe is not
compiling in today fpc. Anyway, you can have a idea how implement it.
The functions you must look are: SalvarTela(SaveScreen) and
RestaurarTela(RestoreScreen).

Luiz


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

luiunit.tar.gz (6K) Download Attachment