Skip to content

Buttons & palette constants

Every Munos script gets two sets of named constants auto-injected by the compiler — you can use them without declaring anything.

Button constants

Gamepad buttons, normalized across NES, Game Boy, and the common SNES subset. Declared as const … : i32. Always use the names, never the raw numbers — the values are an implementation detail.

ConstantValue
BUTTON_A0
BUTTON_B1
BUTTON_SELECT2
BUTTON_START3
BUTTON_UP4
BUTTON_DOWN5
BUTTON_LEFT6
BUTTON_RIGHT7

Used with event input, input_held, input_pressed. The v1 surface reads controller 1 only.

NES palette constants

The compiler also injects the NES master palette as named const … : u32 colors, so you can build palettes from readable names instead of raw hex:

munos
var pal: u32[] = [0x00000000, NES_RED, NES_WHITE, NES_DARK_BLUE]

Each color resolves to the RGB the NES actually renders for that hardware index. (The constants carry 0xFF in the high byte; the draw compositor ignores the high byte, so it's harmless — transparency is still by palette index 0.)

Naming scheme

Most hues come in four shades — NES_DARK_*, NES_*, NES_LIGHT_*, NES_PALE_*:

FamilyConstants
GreyNES_BLACK, NES_DARK_GREY, NES_GREY, NES_LIGHT_GREY, NES_WHITE
BlueNES_DARK_BLUE, NES_BLUE, NES_LIGHT_BLUE, NES_PALE_BLUE
PurpleNES_DARK_PURPLE, NES_PURPLE, NES_LIGHT_PURPLE, NES_PALE_PURPLE
MagentaNES_DARK_MAGENTA, NES_MAGENTA, NES_LIGHT_MAGENTA, NES_PALE_MAGENTA
RedNES_DARK_RED, NES_RED, NES_LIGHT_RED, NES_PALE_RED
OrangeNES_DARK_ORANGE, NES_ORANGE, NES_LIGHT_ORANGE, NES_PALE_ORANGE
YellowNES_DARK_YELLOW, NES_YELLOW, NES_LIGHT_YELLOW, NES_PALE_YELLOW
LimeNES_DARK_LIME, NES_LIME, NES_LIGHT_LIME, NES_PALE_LIME
GreenNES_DARK_GREEN, NES_GREEN, NES_LIGHT_GREEN, NES_PALE_GREEN
TealNES_DARK_TEAL, NES_TEAL, NES_LIGHT_TEAL, NES_PALE_TEAL
CyanNES_DARK_CYAN, NES_CYAN, NES_LIGHT_CYAN, NES_PALE_CYAN

These name the genuine NES hardware colors, so a palette built from them looks right on a real NES render. For non-NES targets they're still perfectly good named RGB values.

Part of the MultiNostalgia project.