Skip to content

Types

Munos is statically typed with a small, fixed set of types. Types are known at compile time; the runtime never reasons about types. Annotations use a TypeScript-style name: type shape.

Primitive types

Integers

TypeBitsSignedRange
i88yes−128 … 127
i1616yes−32 768 … 32 767
i3232yes−2 147 483 648 … 2 147 483 647
u88no0 … 255
u1616no0 … 65 535
u3232no0 … 4 294 967 295

Two's complement; arithmetic overflow wraps. Single-byte memory reads return u8; address constants are typically u16 or u32.

There is no floating-point type in Munos, by design — retro consoles are integer machines, and integer-only execution stays bit-identical across every client.

bool

Values true and false. There is no coercion between numbers and bool.

string

An immutable byte sequence. Operations: literal, concatenation (+, both operands must be strings), len(), byte-indexed access, equality. The recommended interchange subset is 7-bit ASCII.

munos
var name: string = "Mario"
var greeting = "hello " + name

+ on strings requires string operands — there is no implicit number-to-string conversion. To print a number alongside text, use the variadic print:

munos
print("score: ", score)       // ok
print("score: " + score)      // type error

image

A mutable 2D buffer of palette indices — width × height of u8. Each pixel is an index resolved against a palette at draw time, not an RGB color. Index 0 is conventionally transparent. See Images & drawing for construction and use.

client

An opaque handle to a connected client, used only in server code. Stable for the duration of that client's connection. You can compare two client values for equality but cannot inspect or construct one — the runtime is the sole source. See Server & slots.

Palettes

A palette is not a distinct type — it's an array of colors, u32[]. Each entry holds a packed 0x00RRGGBB color in its low 24 bits (red high, blue low). The high byte is ignored by the compositor.

munos
var pal: u32[] = [0x00000000, 0x00FF0000, 0x0000FF00, 0x000000FF]
//                 transparent  red         green       blue

Transparency is by index, not by color: palette index 0 is always transparent, whatever value you store there. A typical palette has up to 256 entries (matching the u8 index range), but any size works as long as the script only indexes valid entries — an out-of-range index is skipped at draw time.

Composite types

Beyond primitives, compose data with arrays (T[]) and user-declared structs.

Conversions

There is no implicit conversion between types, including between integer widths. Convert explicitly with a cast named after the target type:

munos
i8(x)   i16(x)   i32(x)
u8(x)   u16(x)   u32(x)

Narrowing casts truncate. A cast takes exactly one integer argument.

munos
var raw: u8  = read_u8(0x0086)
var x:   i32 = i32(raw)

Numeric literals default to i32 when their type can't be inferred from context. Assigning a literal into a smaller type is allowed when the value fits at compile time (var b: i8 = 100 is fine; var b: i8 = 300 is a compile error).

Literals

  • Integers — decimal (42), hex (0x2A), binary (0b101010). Underscores may appear anywhere for readability: 1_000_000, 0xDEAD_BEEF.
  • Strings — double-quoted. Escapes: \n \t \r \\ \" \0 and \xHH (raw byte).
  • Booleanstrue, false.

Part of the MultiNostalgia project.