home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / demos / 57 / pascal / screen.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-09-18  |  3.4 KB  |  161 lines

  1. {$P-} { turn pointer checking off.. }
  2. program scnsave;
  3.  
  4. {
  5.  
  6.         Program to save and restore the ST display to/from files.
  7.  
  8.         8-20-86
  9.  
  10. }
  11.  
  12.  
  13. TYPE
  14.  
  15.         { The ST screen is 32000 bytes of data, soooo.... }
  16.         screen = packed array [ 0..31999 ] of BYTE;
  17.  
  18.         ptr_screen = ^screen;   { pointer to the screen array }
  19.  
  20. VAR
  21.  
  22.         s_ptr : ptr_screen;     { a pointer to a packed array of bytes... }
  23.  
  24. { **********************************************************************
  25.  
  26.         declare routine to get address of screen
  27.  
  28.   *********************************************************************** }
  29.  
  30. { physbase returns a pointer to the start of the ST's screen.  }
  31.  
  32. FUNCTION physbase : ptr_screen;
  33.    XBIOS( 2 );
  34.  
  35.  
  36. { ***********************************************************************
  37.  
  38.         save screen to file.
  39.  
  40.   *********************************************************************** }
  41.  
  42.  
  43. PROCEDURE SSave( name : STRING );
  44.  
  45. VAR
  46.  
  47.    f : file of screen;     { a file containing a screenful of bytes.. }
  48.  
  49.  
  50.    BEGIN
  51.  
  52.         rewrite( f, name ) ;       { bind f to file name }
  53.         f^ := s_ptr^;              { assign screen data to file buffer... }
  54.         put( f );                  { and write it out to file }
  55.  
  56.         { file is automatically closed when we leave this procedure. }
  57.  
  58.    END;
  59.  
  60. { ***************************************************************************
  61.  
  62.         Restore screen data from file.
  63.  
  64.   *************************************************************************  }
  65.  
  66. PROCEDURE SRestore( name : STRING );
  67.  
  68. VAR
  69.  
  70.    f : file of screen;     { a file containing a screenful of bytes.. }
  71.  
  72.    BEGIN
  73.  
  74.         reset( f, name );               { bind f to file name }
  75.  
  76.         { reset automatically fills file buffer with data from first record }
  77.  
  78.         s_ptr^ := f^;                   { and assign file buffer to screen }
  79.  
  80.         { file is automatically closed when we leave this procedure. }
  81.    END;
  82.  
  83.  
  84. { *********************************************************************
  85.  
  86.         miscellaneous subroutines...
  87.  
  88. *********************************************************************** }
  89.  
  90.  
  91. PROCEDURE waitCR;
  92.  
  93.    BEGIN
  94.  
  95.         writeln('Press <RETURN> to continue. ');
  96.         readln;
  97.  
  98.    END;
  99.  
  100.  
  101. { clear screen procedure }
  102.  
  103. PROCEDURE cls;
  104.  
  105.    BEGIN
  106.  
  107.         write( chr( 27 ) );
  108.         write( 'E' );
  109.  
  110.    END;
  111.  
  112.  
  113. { put some stupid stuff on the screen... }
  114.  
  115. PROCEDURE fill_scrn;
  116.  
  117.    VAR
  118.  
  119.         i : integer;
  120.  
  121.    BEGIN
  122.  
  123.         cls;    { clear screen ... }
  124.  
  125.         FOR i := 0 TO 20 DO
  126.            BEGIN
  127.                 writeln('This is line # ', i );
  128.            END;
  129.    END;
  130.  
  131.  
  132.  
  133. { ************************************************************************
  134.  
  135.         Main routine starts here.  Just execute routines in sequence...
  136.  
  137.   ************************************************************************ }
  138.  
  139.  
  140. BEGIN
  141.  
  142.         s_ptr := physbase;      { grab location of screen... }
  143.  
  144.         fill_scrn;              { put junk on screen.... }
  145.  
  146.         writeln('saving screen...');
  147.  
  148.         SSave( 'test.scr' );    { write screen data to file... }
  149.  
  150.         waitCR;
  151.  
  152.         cls;                    { clear screen... }
  153.  
  154.         writeln('restoring screen...');
  155.  
  156.         SRestore( 'test.scr' ); { read screen data from file... }
  157.  
  158.         waitCR;
  159.  
  160. END.
  161.