home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / pascal / passrc / peekpok2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-11-18  |  3.2 KB  |  136 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. { peekpoke.pas - Include this file  when you compile to implement PEEK and
  29.     POKE functions. }
  30.  
  31.   {$P-}
  32.  
  33.   FUNCTION peek( address: long_integer ): long_integer;
  34.  
  35.     TYPE
  36.       byte_ptr = ^byte;
  37.  
  38.     VAR
  39.       funny: RECORD
  40.                CASE boolean OF
  41.                  true:  ( a: long_integer );
  42.                  false: ( p: byte_ptr );
  43.              END;
  44.  
  45.     BEGIN
  46.       funny.a := address;
  47.       peek := funny.p^;
  48.     END;
  49.  
  50.   FUNCTION wpeek( address: long_integer ): long_integer;
  51.  
  52.     TYPE
  53.       int_ptr = ^integer;
  54.  
  55.     VAR
  56.       funny: RECORD
  57.                CASE boolean OF
  58.                  true:  ( a: long_integer );
  59.                  false: ( p: int_ptr );
  60.              END;
  61.  
  62.     BEGIN
  63.       funny.a := address;
  64.       wpeek := funny.p^;
  65.     END;
  66.  
  67.   FUNCTION lpeek( address: long_integer ): long_integer;
  68.  
  69.     TYPE
  70.       lint_ptr = ^long_integer;
  71.  
  72.     VAR
  73.       funny: RECORD
  74.                CASE boolean OF
  75.                  true:  ( a: long_integer );
  76.                  false: ( p: lint_ptr );
  77.              END;
  78.  
  79.     BEGIN
  80.       funny.a := address;
  81.       lpeek := funny.p^;
  82.     END;
  83.  
  84.   PROCEDURE poke( address: long_integer; value: byte );
  85.  
  86.     TYPE
  87.       lint_ptr = ^long_integer;
  88.  
  89.     VAR
  90.       funny: RECORD
  91.                CASE boolean OF
  92.                  true:  ( a: long_integer );
  93.                  false: ( p: lint_ptr );
  94.              END;
  95.  
  96.     BEGIN
  97.       funny.a := address;
  98.       funny.p^ := value;
  99.     END;
  100.  
  101.   PROCEDURE wpoke( address: long_integer; value: integer );
  102.  
  103.     TYPE
  104.       int_ptr = ^integer;
  105.  
  106.     VAR
  107.       funny: RECORD
  108.                CASE boolean OF
  109.                  true:  ( a: long_integer );
  110.                  false: ( p: int_ptr );
  111.              END;
  112.  
  113.     BEGIN
  114.       funny.a := address;
  115.       funny.p^ := value;
  116.     END;
  117.  
  118.   PROCEDURE lpoke( address, value: long_integer );
  119.  
  120.     TYPE
  121.       lint_ptr = ^long_integer;
  122.  
  123.     VAR
  124.       funny: RECORD
  125.                CASE boolean OF
  126.                  true:  ( a: long_integer );
  127.                  false: ( p: lint_ptr );
  128.              END;
  129.  
  130.     BEGIN
  131.       funny.a := address;
  132.       funny.p^ := value;
  133.     END;
  134.  
  135.   {$P=}
  136.