OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
Volatile Types

Volatile types for hardware register access. More...

Macros

#define FAR   /* host compilers (the clang syntax lint) have no address spaces */
 Place a global in bank $7E WRAM, outside the 8 KB bank-0 band.
#define RAM_CODE   /* host compilers (the clang syntax lint) */
 Run a function from WRAM instead of ROM.

Typedefs

typedef volatile s16 vs16
typedef volatile s32 vs32
typedef volatile s8 vs8
typedef volatile u16 vu16
typedef volatile u32 vu32
typedef volatile u8 vu8

Detailed Description

Volatile types for hardware register access.

Use these when accessing memory-mapped I/O registers to prevent the compiler from optimizing away reads/writes.

Macro Definition Documentation

◆ FAR

#define FAR   /* host compilers (the clang syntax lint) have no address spaces */

Place a global in bank $7E WRAM, outside the 8 KB bank-0 band.

FAR u8 buffer[4096]; — the object lives in $7E:2000-$FFFF and every access to it (direct, buffer[i], or through a u8 FAR * pointer) is compiled with bank-honouring addressing. Use it for bulk state that does not fit the 8 KB band: HDMA tables, tilemaps built in RAM, entity pools. Restrictions: static storage only (the stack is bank 0) and not const (ROM is already reachable from any bank). Initialisers work (the boot data-init copy carries the bank); everything else is zero at boot. Handing a FAR pointer to code expecting a plain pointer is a compile error, as with const; a plain pointer converts to FAR silently and just takes the far path. A T FAR * converts to const T * without a cast — a read through a const pointee is already a far read — so the DMA/HDMA/asset helpers take FAR buffers as they are. Cost: arr[i] on a FAR array is one absolute-long-indexed instruction (cheaper than bank 0); a pointer walk is within 4 % of the bank-0 path.

See also
docs/tutorials/far_ram.md

◆ RAM_CODE

#define RAM_CODE   /* host compilers (the clang syntax lint) */

Run a function from WRAM instead of ROM.

RAM_CODE void wait_for_job(void) { ... } — the function is linked in the RAM code window (RAM_CODE_SIZE in the Makefile, at the top of bank $7E), stored in ROM and copied there by crt0 at boot; callers reach it with an ordinary call. It is for code that must run while the CPU cannot read the ROM (a Super FX job with RON = 1): then it must not call a ROM function (library, runtime helpers such as multiplication, other non-RAM_CODE functions) nor read const data, which lives in ROM. A project with no window fails to assemble with a message naming the function.

See also
docs/tutorials/superfx.md

Typedef Documentation

◆ vs16

typedef volatile s16 vs16

◆ vs32

typedef volatile s32 vs32

◆ vs8

typedef volatile s8 vs8

◆ vu16

typedef volatile u16 vu16

◆ vu32

typedef volatile u32 vu32

◆ vu8

typedef volatile u8 vu8