Crate wasm4fun_core[][src]

Expand description

Primitives and constants from WASM-4 fantasy console

WASM-4 ships a w4 application that can generate a preconfigured Rust crate to build a game. That crate contains a wasm4 module that exports all primitives and constants exposed by the console.

This crate replicates that module, documenting each public symbol and adding few Rust attributes where needed, so that w4 is no longer necessary to build a game.

Note that w4 application is still required to play the game or to generate a self-contained cartridge from the final .wasm artefact.


Flag for 1-bit-per-pixel sprites

Flag for 2-bits-per-pixel sprites

Flag for horizontally flipping sprites

Flag for vertically flipping sprites

Flag for counter-clockwise rotating sprites

Gamepad X button state bitmask

Gamepad Z button state bitmask

Gamepad down button state bitmask

Gamepad left button state bitmask

Gamepad right button state bitmask

Gamepad up button state bitmask

Address of current drawing colors

Address of first gamepad

Address of second gamepad

Address of third gamepad

Address of fourth gamepad

Address of mouse buttons

Mouse left button state bitmask

Mouse middle button state bitmask

Mouse right button state bitmask

Address of mouse x coordinate

Address of mouse y coordinate

Width and height of the screen in pixels

System flags

Flag for hiding gamepad overlay

Flag for preserving framebuffer content between frames

Select 12.5% duty cycle

Select 25% duty cycle

Select 50% duty cycle

Select 75% duty cycle

Select noise wave form

Select first pulse wave form

Select second pulse wave form

Select triangle wave form


Framebuffer memory region

System palette memory region


Copy pixels to the framebuffer

Copy a subregion within a larger sprite atlas to the framebuffer

Read up to size bytes from persistent storage into the pointer dest

Write up to size bytes from the pointer src into persistent storage

Draw a horizontal line

Draw a line between two points

Draw an oval (or circle)

Draw a rectangle

Draw text using the built-in system font

Play a sound tone

Print a message to the debug console

Draw a vertical line