Skip to content

GB_read_memory

Lior Halphon edited this page Nov 30, 2024 · 5 revisions

Definition

uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr);

In memory.h

Description

Performs a memory read on a 16-bit address on the emulator instance, as if it were performed by the SM83 CPU, and returns the 8-bit read value.

Thread Safety

GB_read_memory must not be called if the instance is being run in another thread, but may be called from the current one (via a callback).

Notes

To read data outside of a currently mapped bank, or to read from a memory region that might not be currently readable (e.g., VRAM during mode 3), you can use GB_get_direct_access.

Because this function goes through the same routines used by a CPU memory read, it will trigger any side effect caused by a memory read, including, for example, OAM corruption. If you wish to avoid this behavior, you can use either GB_safe_read_memory or GB_get_direct_access.

See Also

Clone this wiki locally