PICO-8 Wiki
Advertisement
peek( addr, [n] )
Reads one or more bytes from contiguous memory locations starting at addr.
addr
The address of the first memory location.

n
The number of bytes to return. (1 by default, 8192 max.)

The peek() function reads and returns one or more bytes from the addressable memory region (0x0000-0x7fff).

See Memory for information about the memory layout.

See peek2() for a way to read groups of 16-bit values from two consecutive memory addresses, and peek4() to read groups of 32-bit values from four consecutive memory addresses.

@ operator[]

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

Examples[]

b = peek(0x4300)

b = @0x4300      -- preferred method

delay,interval = peek(0x5f5c, 2) -- assign variables with the btnp() settings

See also[]

Advertisement