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 - poke() write a byte to a memory address http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 poke()              Write a byte to a memory address
------------------------------------------------------------------------------
 Declaration
   memory.hdr

 Syntax
   proc poke extern
   param value uint uSegment, ;
         value uint uOffset, ;
         value uint uValue

 Arguments
   uSegment is the target segment address.
   uOffset is the target offset address.
   uValue is the value to place in memory.

 Return
   None.

 Description
   The poke() procedure writes the value passed in uValue to the memory byte
   with the address 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_poke
   vardef
      ptr( byte ) pMem
   enddef
   // Write an 'A' at the top left corner of the screen using direct access
   // to the screen memory, and set the attribute to black on cyan
   poke( scrseg(), 0x00, 'A' )
   poke( scrseg(), 0x01, CYAN_BLACK )
   
   // Write a 'b' next to the 'A' using pointer
   pMem := makeptr( scrseg(), 4 )
   *pMem := 'b'
   pMem++
   *pMem := BLUE_WHITE
   getkey()                            // wait for keypress
   endproc

   proc main
   Test_poke()
   endproc

See Also: & peek() peekw() pokew() ptr()

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