Crate wasm4fun_core

Source
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.

Constants§

BLIT_1BPP
Flag for 1-bit-per-pixel sprites
BLIT_2BPP
Flag for 2-bits-per-pixel sprites
BLIT_FLIP_X
Flag for horizontally flipping sprites
BLIT_FLIP_Y
Flag for vertically flipping sprites
BLIT_ROTATE
Flag for counter-clockwise rotating sprites
BUTTON_1
Gamepad X button state bitmask
BUTTON_2
Gamepad Z button state bitmask
BUTTON_DOWN
Gamepad down button state bitmask
BUTTON_LEFT
Gamepad left button state bitmask
BUTTON_RIGHT
Gamepad right button state bitmask
BUTTON_UP
Gamepad up button state bitmask
DRAW_COLORS
Address of current drawing colors
GAMEPAD1
Address of first gamepad
GAMEPAD2
Address of second gamepad
GAMEPAD3
Address of third gamepad
GAMEPAD4
Address of fourth gamepad
MOUSE_BUTTONS
Address of mouse buttons
MOUSE_LEFT
Mouse left button state bitmask
MOUSE_MIDDLE
Mouse middle button state bitmask
MOUSE_RIGHT
Mouse right button state bitmask
MOUSE_X
Address of mouse x coordinate
MOUSE_Y
Address of mouse y coordinate
SCREEN_SIZE
Width and height of the screen in pixels
SYSTEM_FLAGS
System flags
SYSTEM_HIDE_GAMEPAD_OVERLAY
Flag for hiding gamepad overlay
SYSTEM_PRESERVE_FRAMEBUFFER
Flag for preserving framebuffer content between frames
TONE_MODE1
Select 12.5% duty cycle
TONE_MODE2
Select 25% duty cycle
TONE_MODE3
Select 50% duty cycle
TONE_MODE4
Select 75% duty cycle
TONE_NOISE
Select noise wave form
TONE_PULSE1
Select first pulse wave form
TONE_PULSE2
Select second pulse wave form
TONE_TRIANGLE
Select triangle wave form

Statics§

FRAMEBUFFER
Framebuffer memory region
PALETTE
System palette memory region

Functions§

blit
Copy pixels to the framebuffer
blit_sub
Copy a subregion within a larger sprite atlas to the framebuffer
diskr
Read up to size bytes from persistent storage into the pointer dest
diskw
Write up to size bytes from the pointer src into persistent storage
hline
Draw a horizontal line
line
Draw a line between two points
oval
Draw an oval (or circle)
rect
Draw a rectangle
text
Draw text using the built-in system font
tone
Play a sound tone
trace
Print a message to the debug console
vline
Draw a vertical line