Skip to main content

Memory Map

WASM-4 uses a fixed memory layout of 64 KB.

AddressSize (Bytes)Description
$000416PALETTE
$00142DRAW_COLORS
$00164GAMEPADS
$001a2MOUSE_X
$001c2MOUSE_Y
$001e1MOUSE_BUTTONS
$00a06400FRAMEBUFFER
$19a058975Available program memory

PALETTE#

4 colors, with each color represented by a 32 bit integer.

BitsDescription
0 - 7Blue channel
8 - 15Green channel
16 - 23Red channel
24 - 31-

DRAW_COLORS#

Indexes into the color palette used by all drawing functions.

BitsDescription
0 - 3Draw color 0
4 - 7Draw color 1
8 - 11Draw color 2
12 - 15Draw color 3

Each draw color can be a value between 1 and 4 representing a palette color, or 0 to signify transparency.

Example:

// Set the first draw color to palette color #2, the second to// transparent, and the third to palette color #4.*DRAW_COLORS = 0x402;

GAMEPADS#

4 gamepads, with each gamepad represented by a single byte.

BitDescription
0X button
1Z button
2-
3-
4D-pad left
5D-pad right
6D-pad up
7D-pad down

MOUSE_X#

Signed 16 bit integer containing the X position of the mouse.

MOUSE_Y#

Signed 16 bit integer containing the Y position of the mouse.

MOUSE_BUTTONS#

Byte containing the mouse buttons state.

BitDescription
0Left button
1Right button
2Middle button

FRAMEBUFFER#

Array of 160x160 pixels, with each pixel packed into 2 bits (colors 0 to 3).

This region can be freely modified for direct pixel manipulation.