PICO-8 Wiki
m (put the ref to memory on its own line to draw attention to it)
Tag: Source edit
(revert to actually specifying a first argument, just for the sake of clarity with new users, but keep the varargs documentation too; some link formatting)
Tag: Source edit
 
Line 3: Line 3:
 
|shortdesc=Writes one or more bytes to contiguous memory locations.
 
|shortdesc=Writes one or more bytes to contiguous memory locations.
 
|addr||The address of the first memory location.
 
|addr||The address of the first memory location.
|...|[]|The byte values to write to memory. If these are omitted, a single zero is written.
+
|value|optional|The byte value to write to memory. Defaults to 0.
  +
|...|optional|Additional byte values to be written consecutively to memory.
 
}}
 
}}
The <code>poke()</code> function writes one or more bytes to the addressable memory region (0x0000-0x7fff).
+
The <code>poke()</code> function writes one or more bytes to the 16-bit-addressable memory region.
   
 
See [[Memory]] for information about the memory layout.
 
See [[Memory]] for information about the memory layout.
Line 20: Line 21:
   
 
* [[Memory]]
 
* [[Memory]]
* [[Peek|<code>peek()</code>]]
+
* <code>[[Peek|peek()]]</code>
* [[Peek2|<code>peek2()</code>]]
+
* <code>[[Peek2|peek2()]]</code>
* [[Peek4|<code>peek4()</code>]]
+
* <code>[[Peek4|peek4()]]</code>
* [[Poke2|<code>poke2()</code>]]
+
* <code>[[Poke2|poke2()]]</code>
* [[Poke4|<code>poke4()</code>]]
+
* <code>[[Poke4|poke4()]]</code>
* [[Memcpy|<code>memcpy()</code>]]
+
* <code>[[Memcpy|memcpy()]]</code>
* [[Reload|<code>reload()</code>]]
+
* <code>[[Reload|reload()]]</code>
* [[Cstore|<code>cstore()</code>]]
+
* <code>[[Cstore|cstore()]]</code>
* [[Memset|<code>memset()</code>]]
+
* <code>[[Memset|memset()]]</code>
 
[[Category:Reference]]
 
[[Category:Reference]]
 
[[Category:API]]
 
[[Category:API]]

Latest revision as of 22:35, 29 June 2021

poke( addr, [value,] [...] )
Writes one or more bytes to contiguous memory locations.
addr
The address of the first memory location.

value
The byte value to write to memory. Defaults to 0.

...
Additional byte values to be written consecutively to memory.

The poke() function writes one or more bytes to the 16-bit-addressable memory region.

See Memory for information about the memory layout.

See poke2() for a way to write 16-bit values to groups of two consecutive memory addresses, and poke4() to write 32-bit values to groups of four consecutive memory addresses.

Examples[]

poke(0x4300, 255)             -- write a byte to user RAM
poke(0x5f5c, delay, interval) -- set up btnp() intervals

See also[]