Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - peek() return the byte at a memory address http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 peek()              Return the byte at a memory address
------------------------------------------------------------------------------
 Declaration
   memory.hdr

 Syntax
   func uint peek extern
   param value uint uSegment, ;
         value uint uOffset

 Arguments
   uSegment is a segment address.
   uOffset is an offset address.

 Return
   The byte found at the specified memory address.

 Description
   The peek() function returns the contents of a byte in memory whose address
   is specified by the parameters uSegment and uOffset.

   The procedure is included for compatibility with earlier Force versions.
   Use the ptr() data type in conjunction with the & and * operators for
   directly writing to explicit memory addresses.

 Example
   #define EXAMPLE_MEMORY
   #include example.hdr

   proc Test_peek
   vardef
      ptr( byte ) pMem
   enddef
   // Read the first two bytes in the screen memory (page 0)
   ? peek( scrseg(), 0x00 )             // character first
   ? peek( scrseg(), 0x01 )             // attribute next
   ?
   // Do the same using pointer
   pMem := makeptr( scrseg(), 0 )
   ? *pMem
   pMem++
   ? *pMem
   endproc

   proc main
   Test_peek()
   endproc

See Also: * peekw() poke() pokew() ptr()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson