home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / PEEK.C < prev    next >
Text File  |  1991-08-16  |  2KB  |  75 lines

  1. /*
  2.  * File......: PEEK.C
  3.  * Author....: Ted Means
  4.  * Date......: $Date:   15 Aug 1991 23:08:18  $
  5.  * Revision..: $Revision:   1.2  $
  6.  * Log file..: $Logfile:   E:/nanfor/src/peek.c_v  $
  7.  * 
  8.  * This function is an original work by Ted Means and is placed in the
  9.  * public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   E:/nanfor/src/peek.c_v  $
  15.  * 
  16.  *    Rev 1.2   15 Aug 1991 23:08:18   GLENN
  17.  * Forest Belt proofread/edited/cleaned up doc
  18.  * 
  19.  *    Rev 1.1   14 Jun 1991 19:53:46   GLENN
  20.  * Minor edit to file header
  21.  * 
  22.  *    Rev 1.0   01 Apr 1991 01:02:52   GLENN
  23.  * Nanforum Toolkit
  24.  * 
  25.  *
  26.  */
  27.  
  28.  
  29. /*  $DOC$
  30.  *  $FUNCNAME$
  31.  *     FT_PEEK()
  32.  *  $CATEGORY$
  33.  *     DOS/BIOS
  34.  *  $ONELINER$
  35.  *     Retrieve a byte from a specified memory location.
  36.  *  $SYNTAX$
  37.  *     FT_PEEK( <nSegment>, <nOffset> ) -> nValue
  38.  *  $ARGUMENTS$
  39.  *     <nSegment> is the segment of the desired memory address.
  40.  *
  41.  *     <nOffset>  is the offset of the desired memory address.
  42.  *  $RETURNS$
  43.  *     <nValue> will be a value from 0 to 255 if all parameters were valid and
  44.  *              the function was able to retrieve the desired byte.
  45.  *     <nValue> will be -1 if invalid parameters were passed.
  46.  *  $DESCRIPTION$
  47.  *     Use this function if you have a need to examine a specific memory
  48.  *     location.  The function will return the byte at the specified
  49.  *     address as a numeric value.  If you need this value as a character,
  50.  *     use the Chr() function to convert it.
  51.  *
  52.  *     This function was written for version 5.1 of MicroSoft C.  You may
  53.  *     have to modify the source code to use another compiler.
  54.  *  $EXAMPLES$
  55.  *     local nVMode := FT_PEEK( 0, 1097 )  // Get the current video mode
  56.  *  $END$
  57.  */
  58.  
  59. #include <extend.h>
  60.  
  61. CLIPPER FT_PEEK(void)
  62. {
  63.    auto unsigned char * byteptr;
  64.  
  65.    if ( (PCOUNT >= 2) && (ISNUM(1)) && (ISNUM(2)) )
  66.    {
  67.       * ((unsigned int *) &byteptr)     = _parni(2);
  68.       * ((unsigned int *) &byteptr + 1) = _parni(1);
  69.       _retni( (unsigned int) (*byteptr) );
  70.    }
  71.    else
  72.       _retni( -1 );
  73.    return;
  74. }
  75.