home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / pascal / passrc / screen.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-11-18  |  4.4 KB  |  189 lines

  1. { -----------------------------------------------------------------------------
  2.  
  3.                                  NOTICE:
  4.  
  5.       THESE MATERIALS are UNSUPPORTED by OSS!  If you do not understand how to
  6.       use them do not contact OSS for help!  We will not teach you how to 
  7.       program in Pascal.  If you find an error in these materials, feel free
  8.       to SEND US A LETTER explaining the error, and how to fix it.
  9.  
  10.       THE BOTTOM LINE:
  11.  
  12.          Use it, enjoy it, but you are on your own when using these materials!
  13.  
  14.  
  15.                                DISCLAIMER:
  16.  
  17.       OSS makes no representations or warranties with respect to the contents
  18.       hereof and specifically disclaim all warranties of merchantability or
  19.       fitness for any particular purpose.   This document is subject to change
  20.       without notice.
  21.       
  22.       OSS provides these materials for use with Personal Pascal.  Use them in
  23.       any way you wish.
  24.  
  25.    -------------------------------------------------------------------------- }
  26.  
  27.  
  28. {$P-} { turn pointer checking off.. }
  29. program scnsave;
  30.  
  31. {
  32.  
  33.         Program to save and restore the ST display to/from files.
  34.  
  35.         8-20-86
  36.  
  37. }
  38.  
  39.  
  40. TYPE
  41.  
  42.         { The ST screen is 32000 bytes of data, soooo.... }
  43.         screen = packed array [ 0..31999 ] of BYTE;
  44.  
  45.         ptr_screen = ^screen;   { pointer to the screen array }
  46.  
  47. VAR
  48.  
  49.         s_ptr : ptr_screen;     { a pointer to a packed array of bytes... }
  50.  
  51. { **********************************************************************
  52.  
  53.         declare routine to get address of screen
  54.  
  55.   *********************************************************************** }
  56.  
  57. { physbase returns a pointer to the start of the ST's screen.  }
  58.  
  59. FUNCTION physbase : ptr_screen;
  60.    XBIOS( 2 );
  61.  
  62.  
  63. { ***********************************************************************
  64.  
  65.         save screen to file.
  66.  
  67.   *********************************************************************** }
  68.  
  69.  
  70. PROCEDURE SSave( name : STRING );
  71.  
  72. VAR
  73.  
  74.    f : file of screen;     { a file containing a screenful of bytes.. }
  75.  
  76.  
  77.    BEGIN
  78.  
  79.         rewrite( f, name ) ;       { bind f to file name }
  80.         f^ := s_ptr^;              { assign screen data to file buffer... }
  81.         put( f );                  { and write it out to file }
  82.  
  83.         { file is automatically closed when we leave this procedure. }
  84.  
  85.    END;
  86.  
  87. { ***************************************************************************
  88.  
  89.         Restore screen data from file.
  90.  
  91.   *************************************************************************  }
  92.  
  93. PROCEDURE SRestore( name : STRING );
  94.  
  95. VAR
  96.  
  97.    f : file of screen;     { a file containing a screenful of bytes.. }
  98.  
  99.    BEGIN
  100.  
  101.         reset( f, name );               { bind f to file name }
  102.  
  103.         { reset automatically fills file buffer with data from first record }
  104.  
  105.         s_ptr^ := f^;                   { and assign file buffer to screen }
  106.  
  107.         { file is automatically closed when we leave this procedure. }
  108.    END;
  109.  
  110.  
  111. { *********************************************************************
  112.  
  113.         miscellaneous subroutines...
  114.  
  115. *********************************************************************** }
  116.  
  117.  
  118. PROCEDURE waitCR;
  119.  
  120.    BEGIN
  121.  
  122.         writeln('Press <RETURN> to continue. ');
  123.         readln;
  124.  
  125.    END;
  126.  
  127.  
  128. { clear screen procedure }
  129.  
  130. PROCEDURE cls;
  131.  
  132.    BEGIN
  133.  
  134.         write( chr( 27 ) );
  135.         write( 'E' );
  136.  
  137.    END;
  138.  
  139.  
  140. { put some stupid stuff on the screen... }
  141.  
  142. PROCEDURE fill_scrn;
  143.  
  144.    VAR
  145.  
  146.         i : integer;
  147.  
  148.    BEGIN
  149.  
  150.         cls;    { clear screen ... }
  151.  
  152.         FOR i := 0 TO 20 DO
  153.            BEGIN
  154.                 writeln('This is line # ', i );
  155.            END;
  156.    END;
  157.  
  158.  
  159.  
  160. { ************************************************************************
  161.  
  162.         Main routine starts here.  Just execute routines in sequence...
  163.  
  164.   ************************************************************************ }
  165.  
  166.  
  167. BEGIN
  168.  
  169.         s_ptr := physbase;      { grab location of screen... }
  170.  
  171.         fill_scrn;              { put junk on screen.... }
  172.  
  173.         writeln('saving screen...');
  174.  
  175.         SSave( 'test.scr' );    { write screen data to file... }
  176.  
  177.         waitCR;
  178.  
  179.         cls;                    { clear screen... }
  180.  
  181.         writeln('restoring screen...');
  182.  
  183.         SRestore( 'test.scr' ); { read screen data from file... }
  184.  
  185.         waitCR;
  186.  
  187. END.
  188.  
  189.