The feature described in this article has been superseded by a newer feature. This feature still works in PICO-8, but the new feature should be used instead. See the article for specific details.
peek2( addr )
Reads a 16-bit value from two consecutive memory locations.
The address of the first memory location.

The peek2() function reads a 16-bit value from two consecutive bytes in the addressable memory region (0x0000-0x7fff). The value is interpreted in the Little Endian representation, which stores the lowest 8 bits in the first byte.

See Memory for information about the memory layout.

Superseded by % operator Edit

The unary-% operator added in 0.2.0 performs the same function as peek2() and is now the recommended way to read 16 bits of memory, as it uses fewer tokens, costs fewer cycles at runtime, and runs on the real host CPU much more efficiently. Simply replace peek2(address) with %address.

Examples Edit

poke(0x4300, 0xff)
poke(0x4301, 0x0c)
b = peek2(0x4300)  -- 0x0cff, or 3327 in decimal
b = %0x4300        -- preferred method

See also Edit

Community content is available under CC-BY-SA unless otherwise noted.