// null0 - Grain bindings for the null0 fantasy console // // use it as a module (the null0-cart-grain docker image copies this file // next to your main.gr automatically if you don't ship your own): // // module Main // // from "./null0.gr" include Null0 // // @unsafe // provide let load = () => { // Null0.initColors() // Null0.clear(Null0.blue) // Null0.draw_circle(100n, 100n, 50n, Null0.red) // } // // provide let update = () => void // // ABI notes: // - everything crosses the wasm boundary as a raw WasmI32/WasmI64/WasmF32 // value - use the literal suffixes 1n/1N/1.0w, NEVER plain Numbers or // fromGrain (those are tagged/boxed grain representations, not raw values) // - handles (Image/Font/Sound), bools and enum values are WasmI32 - the // constants below are already WasmI32, pass them directly // - string is a pointer to a null-terminated UTF8 string in memory (WasmI32) // - Color/Vector/Rectangle/Dimensions/SfxParams are ALWAYS passed and // returned as a WasmI32 pointer into wasm memory, never packed into a // scalar - Color is 4 bytes (r, g, b, a); the color constants below are // pointers - call initColors() once (first thing in load()) to write the // bytes there before first use // - functions returning structs return a WasmI32 pointer into your memory - // read the fields with WasmI32.load / WasmI32.load8U at the offsets noted // below - the pointer is only valid until the current callback returns, // so copy out what you need // - anything touching Wasm types needs an @unsafe attribute module Null0 from "runtime/unsafe/wasmi32" include WasmI32 from "runtime/unsafe/wasmi64" include WasmI64 from "runtime/unsafe/wasmf32" include WasmF32 // constants @unsafe provide let screen = 0n @unsafe provide let screenWidth = 640n @unsafe provide let screenHeight = 480n @unsafe provide let fontDefault = 0n // colors (pointers to r, g, b, a bytes - call initColors() before use) @unsafe provide let lightgray = 65536n // LIGHTGRAY = rgba(200, 200, 200, 255) @unsafe provide let gray = 65540n // GRAY = rgba(130, 130, 130, 255) @unsafe provide let darkgray = 65544n // DARKGRAY = rgba(80, 80, 80, 255) @unsafe provide let yellow = 65548n // YELLOW = rgba(253, 249, 0, 255) @unsafe provide let gold = 65552n // GOLD = rgba(255, 203, 0, 255) @unsafe provide let orange = 65556n // ORANGE = rgba(255, 161, 0, 255) @unsafe provide let pink = 65560n // PINK = rgba(255, 109, 194, 255) @unsafe provide let red = 65564n // RED = rgba(230, 41, 55, 255) @unsafe provide let maroon = 65568n // MAROON = rgba(190, 33, 55, 255) @unsafe provide let green = 65572n // GREEN = rgba(0, 228, 48, 255) @unsafe provide let lime = 65576n // LIME = rgba(0, 158, 47, 255) @unsafe provide let darkgreen = 65580n // DARKGREEN = rgba(0, 117, 44, 255) @unsafe provide let skyblue = 65584n // SKYBLUE = rgba(102, 191, 255, 255) @unsafe provide let blue = 65588n // BLUE = rgba(0, 121, 241, 255) @unsafe provide let darkblue = 65592n // DARKBLUE = rgba(0, 82, 172, 255) @unsafe provide let purple = 65596n // PURPLE = rgba(200, 122, 255, 255) @unsafe provide let violet = 65600n // VIOLET = rgba(135, 60, 190, 255) @unsafe provide let darkpurple = 65604n // DARKPURPLE = rgba(112, 31, 126, 255) @unsafe provide let beige = 65608n // BEIGE = rgba(211, 176, 131, 255) @unsafe provide let brown = 65612n // BROWN = rgba(127, 106, 79, 255) @unsafe provide let darkbrown = 65616n // DARKBROWN = rgba(76, 63, 47, 255) @unsafe provide let white = 65620n // WHITE = rgba(255, 255, 255, 255) @unsafe provide let black = 65624n // BLACK = rgba(0, 0, 0, 255) @unsafe provide let blank = 65628n // BLANK = rgba(0, 0, 0, 0) @unsafe provide let magenta = 65632n // MAGENTA = rgba(255, 0, 255, 255) @unsafe provide let raywhite = 65636n // RAYWHITE = rgba(245, 245, 245, 255) // write every color-constant byte into memory - call once, first thing in load() @unsafe provide let initColors = () => { WasmI32.store8(lightgray, 200n, 0n) WasmI32.store8(lightgray, 200n, 1n) WasmI32.store8(lightgray, 200n, 2n) WasmI32.store8(lightgray, 255n, 3n) WasmI32.store8(gray, 130n, 0n) WasmI32.store8(gray, 130n, 1n) WasmI32.store8(gray, 130n, 2n) WasmI32.store8(gray, 255n, 3n) WasmI32.store8(darkgray, 80n, 0n) WasmI32.store8(darkgray, 80n, 1n) WasmI32.store8(darkgray, 80n, 2n) WasmI32.store8(darkgray, 255n, 3n) WasmI32.store8(yellow, 253n, 0n) WasmI32.store8(yellow, 249n, 1n) WasmI32.store8(yellow, 0n, 2n) WasmI32.store8(yellow, 255n, 3n) WasmI32.store8(gold, 255n, 0n) WasmI32.store8(gold, 203n, 1n) WasmI32.store8(gold, 0n, 2n) WasmI32.store8(gold, 255n, 3n) WasmI32.store8(orange, 255n, 0n) WasmI32.store8(orange, 161n, 1n) WasmI32.store8(orange, 0n, 2n) WasmI32.store8(orange, 255n, 3n) WasmI32.store8(pink, 255n, 0n) WasmI32.store8(pink, 109n, 1n) WasmI32.store8(pink, 194n, 2n) WasmI32.store8(pink, 255n, 3n) WasmI32.store8(red, 230n, 0n) WasmI32.store8(red, 41n, 1n) WasmI32.store8(red, 55n, 2n) WasmI32.store8(red, 255n, 3n) WasmI32.store8(maroon, 190n, 0n) WasmI32.store8(maroon, 33n, 1n) WasmI32.store8(maroon, 55n, 2n) WasmI32.store8(maroon, 255n, 3n) WasmI32.store8(green, 0n, 0n) WasmI32.store8(green, 228n, 1n) WasmI32.store8(green, 48n, 2n) WasmI32.store8(green, 255n, 3n) WasmI32.store8(lime, 0n, 0n) WasmI32.store8(lime, 158n, 1n) WasmI32.store8(lime, 47n, 2n) WasmI32.store8(lime, 255n, 3n) WasmI32.store8(darkgreen, 0n, 0n) WasmI32.store8(darkgreen, 117n, 1n) WasmI32.store8(darkgreen, 44n, 2n) WasmI32.store8(darkgreen, 255n, 3n) WasmI32.store8(skyblue, 102n, 0n) WasmI32.store8(skyblue, 191n, 1n) WasmI32.store8(skyblue, 255n, 2n) WasmI32.store8(skyblue, 255n, 3n) WasmI32.store8(blue, 0n, 0n) WasmI32.store8(blue, 121n, 1n) WasmI32.store8(blue, 241n, 2n) WasmI32.store8(blue, 255n, 3n) WasmI32.store8(darkblue, 0n, 0n) WasmI32.store8(darkblue, 82n, 1n) WasmI32.store8(darkblue, 172n, 2n) WasmI32.store8(darkblue, 255n, 3n) WasmI32.store8(purple, 200n, 0n) WasmI32.store8(purple, 122n, 1n) WasmI32.store8(purple, 255n, 2n) WasmI32.store8(purple, 255n, 3n) WasmI32.store8(violet, 135n, 0n) WasmI32.store8(violet, 60n, 1n) WasmI32.store8(violet, 190n, 2n) WasmI32.store8(violet, 255n, 3n) WasmI32.store8(darkpurple, 112n, 0n) WasmI32.store8(darkpurple, 31n, 1n) WasmI32.store8(darkpurple, 126n, 2n) WasmI32.store8(darkpurple, 255n, 3n) WasmI32.store8(beige, 211n, 0n) WasmI32.store8(beige, 176n, 1n) WasmI32.store8(beige, 131n, 2n) WasmI32.store8(beige, 255n, 3n) WasmI32.store8(brown, 127n, 0n) WasmI32.store8(brown, 106n, 1n) WasmI32.store8(brown, 79n, 2n) WasmI32.store8(brown, 255n, 3n) WasmI32.store8(darkbrown, 76n, 0n) WasmI32.store8(darkbrown, 63n, 1n) WasmI32.store8(darkbrown, 47n, 2n) WasmI32.store8(darkbrown, 255n, 3n) WasmI32.store8(white, 255n, 0n) WasmI32.store8(white, 255n, 1n) WasmI32.store8(white, 255n, 2n) WasmI32.store8(white, 255n, 3n) WasmI32.store8(black, 0n, 0n) WasmI32.store8(black, 0n, 1n) WasmI32.store8(black, 0n, 2n) WasmI32.store8(black, 255n, 3n) WasmI32.store8(blank, 0n, 0n) WasmI32.store8(blank, 0n, 1n) WasmI32.store8(blank, 0n, 2n) WasmI32.store8(blank, 0n, 3n) WasmI32.store8(magenta, 255n, 0n) WasmI32.store8(magenta, 0n, 1n) WasmI32.store8(magenta, 255n, 2n) WasmI32.store8(magenta, 255n, 3n) WasmI32.store8(raywhite, 245n, 0n) WasmI32.store8(raywhite, 245n, 1n) WasmI32.store8(raywhite, 245n, 2n) WasmI32.store8(raywhite, 255n, 3n) } // ImageFilter: Potential image-filtering techniques for scale/etc. @unsafe provide let filterNearestneighbor = 0n @unsafe provide let filterBilinear = 1n @unsafe provide let filterSmooth = 2n // SfxPresetType: Represents a Sfx preset type. @unsafe provide let sfxCoin = 0n @unsafe provide let sfxLaser = 1n @unsafe provide let sfxExplosion = 2n @unsafe provide let sfxPowerup = 3n @unsafe provide let sfxHurt = 4n @unsafe provide let sfxJump = 5n @unsafe provide let sfxSelect = 6n @unsafe provide let sfxSynth = 7n // Key: Represents a keyboard key. @unsafe provide let keyInvalid = 0n @unsafe provide let keySpace = 32n @unsafe provide let keyApostrophe = 39n @unsafe provide let keyComma = 44n @unsafe provide let keyMinus = 45n @unsafe provide let keyPeriod = 46n @unsafe provide let keySlash = 47n @unsafe provide let key0 = 48n @unsafe provide let key1 = 49n @unsafe provide let key2 = 50n @unsafe provide let key3 = 51n @unsafe provide let key4 = 52n @unsafe provide let key5 = 53n @unsafe provide let key6 = 54n @unsafe provide let key7 = 55n @unsafe provide let key8 = 56n @unsafe provide let key9 = 57n @unsafe provide let keySemicolon = 59n @unsafe provide let keyEqual = 61n @unsafe provide let keyA = 65n @unsafe provide let keyB = 66n @unsafe provide let keyC = 67n @unsafe provide let keyD = 68n @unsafe provide let keyE = 69n @unsafe provide let keyF = 70n @unsafe provide let keyG = 71n @unsafe provide let keyH = 72n @unsafe provide let keyI = 73n @unsafe provide let keyJ = 74n @unsafe provide let keyK = 75n @unsafe provide let keyL = 76n @unsafe provide let keyM = 77n @unsafe provide let keyN = 78n @unsafe provide let keyO = 79n @unsafe provide let keyP = 80n @unsafe provide let keyQ = 81n @unsafe provide let keyR = 82n @unsafe provide let keyS = 83n @unsafe provide let keyT = 84n @unsafe provide let keyU = 85n @unsafe provide let keyV = 86n @unsafe provide let keyW = 87n @unsafe provide let keyX = 88n @unsafe provide let keyY = 89n @unsafe provide let keyZ = 90n @unsafe provide let keyLeftBracket = 91n @unsafe provide let keyBackslash = 92n @unsafe provide let keyRightBracket = 93n @unsafe provide let keyGraveAccent = 96n @unsafe provide let keyWorld1 = 161n @unsafe provide let keyWorld2 = 162n @unsafe provide let keyEscape = 256n @unsafe provide let keyEnter = 257n @unsafe provide let keyTab = 258n @unsafe provide let keyBackspace = 259n @unsafe provide let keyInsert = 260n @unsafe provide let keyDelete = 261n @unsafe provide let keyRight = 262n @unsafe provide let keyLeft = 263n @unsafe provide let keyDown = 264n @unsafe provide let keyUp = 265n @unsafe provide let keyPageUp = 266n @unsafe provide let keyPageDown = 267n @unsafe provide let keyHome = 268n @unsafe provide let keyEnd = 269n @unsafe provide let keyCapsLock = 280n @unsafe provide let keyScrollLock = 281n @unsafe provide let keyNumLock = 282n @unsafe provide let keyPrintScreen = 283n @unsafe provide let keyPause = 284n @unsafe provide let keyF1 = 290n @unsafe provide let keyF2 = 291n @unsafe provide let keyF3 = 292n @unsafe provide let keyF4 = 293n @unsafe provide let keyF5 = 294n @unsafe provide let keyF6 = 295n @unsafe provide let keyF7 = 296n @unsafe provide let keyF8 = 297n @unsafe provide let keyF9 = 298n @unsafe provide let keyF10 = 299n @unsafe provide let keyF11 = 300n @unsafe provide let keyF12 = 301n @unsafe provide let keyF13 = 302n @unsafe provide let keyF14 = 303n @unsafe provide let keyF15 = 304n @unsafe provide let keyF16 = 305n @unsafe provide let keyF17 = 306n @unsafe provide let keyF18 = 307n @unsafe provide let keyF19 = 308n @unsafe provide let keyF20 = 309n @unsafe provide let keyF21 = 310n @unsafe provide let keyF22 = 311n @unsafe provide let keyF23 = 312n @unsafe provide let keyF24 = 313n @unsafe provide let keyF25 = 314n @unsafe provide let keyKp0 = 320n @unsafe provide let keyKp1 = 321n @unsafe provide let keyKp2 = 322n @unsafe provide let keyKp3 = 323n @unsafe provide let keyKp4 = 324n @unsafe provide let keyKp5 = 325n @unsafe provide let keyKp6 = 326n @unsafe provide let keyKp7 = 327n @unsafe provide let keyKp8 = 328n @unsafe provide let keyKp9 = 329n @unsafe provide let keyKpDecimal = 330n @unsafe provide let keyKpDivide = 331n @unsafe provide let keyKpMultiply = 332n @unsafe provide let keyKpSubtract = 333n @unsafe provide let keyKpAdd = 334n @unsafe provide let keyKpEnter = 335n @unsafe provide let keyKpEqual = 336n @unsafe provide let keyLeftShift = 340n @unsafe provide let keyLeftControl = 341n @unsafe provide let keyLeftAlt = 342n @unsafe provide let keyLeftSuper = 343n @unsafe provide let keyRightShift = 344n @unsafe provide let keyRightControl = 345n @unsafe provide let keyRightAlt = 346n @unsafe provide let keyRightSuper = 347n @unsafe provide let keyMenu = 348n // GamepadButton: Represents a gamepad button. @unsafe provide let gamepadButtonUnknown = 0n @unsafe provide let gamepadButtonUp = 1n @unsafe provide let gamepadButtonRight = 2n @unsafe provide let gamepadButtonDown = 3n @unsafe provide let gamepadButtonLeft = 4n @unsafe provide let gamepadButtonY = 5n @unsafe provide let gamepadButtonB = 6n @unsafe provide let gamepadButtonA = 7n @unsafe provide let gamepadButtonX = 8n @unsafe provide let gamepadButtonLeftShoulder = 9n @unsafe provide let gamepadButtonLeftTrigger = 10n @unsafe provide let gamepadButtonRightShoulder = 11n @unsafe provide let gamepadButtonRightTrigger = 12n @unsafe provide let gamepadButtonSelect = 13n @unsafe provide let gamepadButtonMenu = 14n @unsafe provide let gamepadButtonStart = 15n @unsafe provide let gamepadButtonLeftThumb = 16n @unsafe provide let gamepadButtonRightThumb = 17n // MouseButton: Represents a mouse button. @unsafe provide let mouseButtonUnknown = 0n @unsafe provide let mouseButtonLeft = 1n @unsafe provide let mouseButtonRight = 2n @unsafe provide let mouseButtonMiddle = 3n // TileLayerKind: The kind of a layer in a tilemap. @unsafe provide let layerNone = 0n @unsafe provide let layerTile = 1n @unsafe provide let layerObject = 2n @unsafe provide let layerImage = 3n @unsafe provide let layerGroup = 4n // TilePropType: The type of a tilemap property's value. Tiled's "file" properties arrive as PROP_STRING. @unsafe provide let propNone = 0n @unsafe provide let propInt = 1n @unsafe provide let propBool = 2n @unsafe provide let propFloat = 3n @unsafe provide let propString = 4n @unsafe provide let propColor = 5n // struct SfxParams: Sfx parameters. // offset 0: randSeed (u32) // offset 4: waveType (i32) // offset 8: attackTime (f32) // offset 12: sustainTime (f32) // offset 16: sustainPunch (f32) // offset 20: decayTime (f32) // offset 24: startFrequency (f32) // offset 28: minFrequency (f32) // offset 32: slide (f32) // offset 36: deltaSlide (f32) // offset 40: vibratoDepth (f32) // offset 44: vibratoSpeed (f32) // offset 48: changeAmount (f32) // offset 52: changeSpeed (f32) // offset 56: squareDuty (f32) // offset 60: dutySweep (f32) // offset 64: repeatSpeed (f32) // offset 68: phaserOffset (f32) // offset 72: phaserSweep (f32) // offset 76: lpfCutoff (f32) // offset 80: lpfCutoffSweep (f32) // offset 84: lpfResonance (f32) // offset 88: hpfCutoff (f32) // offset 92: hpfCutoffSweep (f32) // struct Dimensions: The 2D size of something (width/height.) // offset 0: width (i32) // offset 4: height (i32) // struct Vector: The 2D position of something (x/y.) // offset 0: x (i32) // offset 4: y (i32) // struct Rectangle: The 2D position + size of something (x/y/w/h.) // offset 0: x (i32) // offset 4: y (i32) // offset 8: width (i32) // offset 12: height (i32) // struct Color: An RGBA color. // offset 0: r (u8) // offset 1: g (u8) // offset 2: b (u8) // offset 3: a (u8) // struct TilemapProp: A custom property on a tilemap, layer, object, or tile. Only the member named by `type` is meaningful - a PROP_BOOL is 0/1 in `integer`, and a PROP_COLOR is RGBA bytes in `integer`. // offset 0: name (string) // offset 4: type (TilePropType) // offset 8: integer (i32) // offset 12: number (f32) // offset 16: text (string) // struct TilemapObject: An object from an object-layer of a tilemap. This is the map's initial state - carts own whatever they spawn from it. // offset 0: id (i32) // offset 4: name (string) // offset 8: type (string) // offset 12: gid (i32) // offset 16: x (f32) // offset 20: y (f32) // offset 24: width (f32) // offset 28: height (f32) // offset 32: rotation (f32) // offset 36: visible (i32) // -- COLORS -- // Tint a color with another color. @unsafe provide foreign wasm color_tint: (WasmI32, WasmI32) => WasmI32 from "null0" // Fade a color. @unsafe provide foreign wasm color_fade: (WasmI32, WasmF32) => WasmI32 from "null0" // Change the brightness of a color. @unsafe provide foreign wasm color_brightness: (WasmI32, WasmF32) => WasmI32 from "null0" // Invert a color. @unsafe provide foreign wasm color_invert: (WasmI32) => WasmI32 from "null0" // Blend 2 colors together. @unsafe provide foreign wasm color_alpha_blend: (WasmI32, WasmI32) => WasmI32 from "null0" // Change contrast of a color. @unsafe provide foreign wasm color_contrast: (WasmI32, WasmF32) => WasmI32 from "null0" // Interpolate colors. @unsafe provide foreign wasm color_bilinear_interpolate: (WasmI32, WasmI32, WasmI32, WasmI32, WasmF32, WasmF32) => WasmI32 from "null0" // -- GRAPHICS -- // Create a new blank image. @unsafe provide foreign wasm new_image: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Copy an image to a new image. @unsafe provide foreign wasm image_copy: (WasmI32) => WasmI32 from "null0" // Create an image from a region of another image. @unsafe provide foreign wasm image_subimage: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Clear the screen. @unsafe provide foreign wasm clear: (WasmI32) => Void from "null0" // Draw a single pixel on the screen. @unsafe provide foreign wasm draw_point: (WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a line on the screen. @unsafe provide foreign wasm draw_line: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled rectangle on the screen. @unsafe provide foreign wasm draw_rectangle: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled triangle on the screen. @unsafe provide foreign wasm draw_triangle: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled ellipse on the screen. @unsafe provide foreign wasm draw_ellipse: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled circle on the screen. @unsafe provide foreign wasm draw_circle: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled polygon on the screen. @unsafe provide foreign wasm draw_polygon: (WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled arc on the screen. @unsafe provide foreign wasm draw_arc: (WasmI32, WasmI32, WasmF32, WasmF32, WasmF32, WasmI32, WasmI32) => Void from "null0" // Draw a filled round-rectangle on the screen. @unsafe provide foreign wasm draw_rectangle_rounded: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw an image on the screen. @unsafe provide foreign wasm draw_image: (WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a tinted image on the screen. @unsafe provide foreign wasm draw_image_tint: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw an image, rotated, on the screen. @unsafe provide foreign wasm draw_image_rotated: (WasmI32, WasmI32, WasmI32, WasmF32, WasmF32, WasmF32, WasmI32) => Void from "null0" // Draw an image, flipped, on the screen. @unsafe provide foreign wasm draw_image_flipped: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw an image, scaled, on the screen. @unsafe provide foreign wasm draw_image_scaled: (WasmI32, WasmI32, WasmI32, WasmF32, WasmF32, WasmF32, WasmF32, WasmI32) => Void from "null0" // Draw some text on the screen. @unsafe provide foreign wasm draw_text: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Save an image to persistant storage. @unsafe provide foreign wasm save_image: (WasmI32, WasmI32) => Void from "null0" // Load an image from a file in cart. @unsafe provide foreign wasm load_image: (WasmI32) => WasmI32 from "null0" // Resize an image, return copy. @unsafe provide foreign wasm image_resize: (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Scale an image, return copy. @unsafe provide foreign wasm image_scale: (WasmI32, WasmF32, WasmF32, WasmI32) => WasmI32 from "null0" // Replace a color in an image, in-place. @unsafe provide foreign wasm image_color_replace: (WasmI32, WasmI32, WasmI32) => Void from "null0" // Tint a color in an image, in-place. @unsafe provide foreign wasm image_color_tint: (WasmI32, WasmI32) => Void from "null0" // Fade a color in an image, in-place. @unsafe provide foreign wasm image_color_fade: (WasmI32, WasmF32) => Void from "null0" // Copy a font to a new font. @unsafe provide foreign wasm font_copy: (WasmI32) => WasmI32 from "null0" // Scale a font, return a new font. @unsafe provide foreign wasm font_scale: (WasmI32, WasmF32, WasmF32, WasmI32) => WasmI32 from "null0" // Load a BMF font from a file in cart. @unsafe provide foreign wasm load_font_bmf: (WasmI32, WasmI32) => WasmI32 from "null0" // Load a BMF font from an image. @unsafe provide foreign wasm load_font_bmf_from_image: (WasmI32, WasmI32) => WasmI32 from "null0" // Measure the size of some text. @unsafe provide foreign wasm measure_text: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Meaure an image (use 0 for screen). @unsafe provide foreign wasm measure_image: (WasmI32) => WasmI32 from "null0" // Load a TTY font from a file in cart. @unsafe provide foreign wasm load_font_tty: (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Load a TTY font from an image. @unsafe provide foreign wasm load_font_tty_from_image: (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Load a TTF font from a file in cart. @unsafe provide foreign wasm load_font_ttf: (WasmI32, WasmI32) => WasmI32 from "null0" // Invert the colors in an image, in-place. @unsafe provide foreign wasm image_color_invert: (WasmI32) => Void from "null0" // Calculate a rectangle representing the available alpha border in an image. @unsafe provide foreign wasm image_alpha_border: (WasmI32, WasmF32) => WasmI32 from "null0" // Crop an image, in-place. @unsafe provide foreign wasm image_crop: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Crop an image based on the alpha border, in-place. @unsafe provide foreign wasm image_alpha_crop: (WasmI32, WasmF32) => Void from "null0" // Adjust the brightness of an image, in-place. @unsafe provide foreign wasm image_color_brightness: (WasmI32, WasmF32) => Void from "null0" // Flip an image, in-place. @unsafe provide foreign wasm image_flip: (WasmI32, WasmI32, WasmI32) => Void from "null0" // Change the contrast of an image, in-place. @unsafe provide foreign wasm image_color_contrast: (WasmI32, WasmF32) => Void from "null0" // Use an image as an alpha-mask on another image. @unsafe provide foreign wasm image_alpha_mask: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Create a new image, rotating another image. @unsafe provide foreign wasm image_rotate: (WasmI32, WasmF32, WasmI32) => WasmI32 from "null0" // Create a new image of a gradient. @unsafe provide foreign wasm image_gradient: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Unload an image. @unsafe provide foreign wasm unload_image: (WasmI32) => Void from "null0" // Unload a font. @unsafe provide foreign wasm unload_font: (WasmI32) => Void from "null0" // Clear an image. @unsafe provide foreign wasm clear_image: (WasmI32, WasmI32) => Void from "null0" // Draw a single pixel on an image. @unsafe provide foreign wasm draw_point_on_image: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a line on an image. @unsafe provide foreign wasm draw_line_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled rectangle on an image. @unsafe provide foreign wasm draw_rectangle_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled triangle on an image. @unsafe provide foreign wasm draw_triangle_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled ellipse on an image. @unsafe provide foreign wasm draw_ellipse_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a circle on an image. @unsafe provide foreign wasm draw_circle_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled polygon on an image. @unsafe provide foreign wasm draw_polygon_on_image: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a filled round-rectangle on an image. @unsafe provide foreign wasm draw_rectangle_rounded_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw an image on an image. @unsafe provide foreign wasm draw_image_on_image: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a tinted image on an image. @unsafe provide foreign wasm draw_image_tint_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw an image, rotated, on an image. @unsafe provide foreign wasm draw_image_rotated_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmF32, WasmF32, WasmF32, WasmI32) => Void from "null0" // Draw an image, flipped, on an image. @unsafe provide foreign wasm draw_image_flipped_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw an image, scaled, on an image. @unsafe provide foreign wasm draw_image_scaled_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmF32, WasmF32, WasmF32, WasmF32, WasmI32) => Void from "null0" // Draw some text on an image. @unsafe provide foreign wasm draw_text_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) rectangle on the screen. @unsafe provide foreign wasm draw_rectangle_outline: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) triangle on the screen. @unsafe provide foreign wasm draw_triangle_outline: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) ellipse on the screen. @unsafe provide foreign wasm draw_ellipse_outline: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) circle on the screen. @unsafe provide foreign wasm draw_circle_outline: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) polygon on the screen. @unsafe provide foreign wasm draw_polygon_outline: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) arc on the screen. @unsafe provide foreign wasm draw_arc_outline: (WasmI32, WasmI32, WasmF32, WasmF32, WasmF32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) round-rectangle on the screen. @unsafe provide foreign wasm draw_rectangle_rounded_outline: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) rectangle on an image. @unsafe provide foreign wasm draw_rectangle_outline_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) triangle on an image. @unsafe provide foreign wasm draw_triangle_outline_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) ellipse on an image. @unsafe provide foreign wasm draw_ellipse_outline_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) circle on an image. @unsafe provide foreign wasm draw_circle_outline_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) polygon on an image. @unsafe provide foreign wasm draw_polygon_outline_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a outlined (with thickness) round-rectangle on an image. @unsafe provide foreign wasm draw_rectangle_rounded_outline_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // -- GUI -- // Begin a GUI window. Returns false if the window is collapsed or closed - skip its contents, but still call gui_end_window. @unsafe provide foreign wasm gui_begin_window: (WasmI32, WasmI32) => WasmI32 from "null0" // End the current GUI window. @unsafe provide foreign wasm gui_end_window: () => Void from "null0" // A button. Returns true when it is clicked. @unsafe provide foreign wasm gui_button: (WasmI32) => WasmI32 from "null0" // A static text label. @unsafe provide foreign wasm gui_label: (WasmI32) => Void from "null0" // A block of wrapping text. @unsafe provide foreign wasm gui_text: (WasmI32) => Void from "null0" // A checkbox. Returns the (possibly changed) state. @unsafe provide foreign wasm gui_checkbox: (WasmI32, WasmI32) => WasmI32 from "null0" // A slider. Returns the (possibly changed) value. @unsafe provide foreign wasm gui_slider: (WasmF32, WasmF32, WasmF32) => WasmF32 from "null0" // Set the current layout row - the column widths (negative for flexible), and the row height. @unsafe provide foreign wasm gui_layout_row: (WasmI32, WasmI32, WasmI32) => Void from "null0" // Finish building the GUI for this frame. Called automatically at the end of update if you do not call it. @unsafe provide foreign wasm gui_end: () => Void from "null0" // Draw the GUI to an image (0 is the screen). @unsafe provide foreign wasm gui_draw: (WasmI32) => Void from "null0" // -- INPUT -- // Has the key been pressed? (tracks unpress/read correctly.) @unsafe provide foreign wasm key_pressed: (WasmI32) => WasmI32 from "null0" // Is the key currently down? @unsafe provide foreign wasm key_down: (WasmI32) => WasmI32 from "null0" // Has the key been released? (tracks press/read correctly.) @unsafe provide foreign wasm key_released: (WasmI32) => WasmI32 from "null0" // Is the key currently up? @unsafe provide foreign wasm key_up: (WasmI32) => WasmI32 from "null0" // Has the button been pressed? (tracks unpress/read correctly.) @unsafe provide foreign wasm gamepad_button_pressed: (WasmI32, WasmI32) => WasmI32 from "null0" // Is the button currently down? @unsafe provide foreign wasm gamepad_button_down: (WasmI32, WasmI32) => WasmI32 from "null0" // Has the button been released? (tracks press/read correctly.) @unsafe provide foreign wasm gamepad_button_released: (WasmI32, WasmI32) => WasmI32 from "null0" // Get current position of mouse. @unsafe provide foreign wasm mouse_position: () => WasmI32 from "null0" // Has the button been pressed? (tracks unpress/read correctly.) @unsafe provide foreign wasm mouse_button_pressed: (WasmI32) => WasmI32 from "null0" // Is the button currently down? @unsafe provide foreign wasm mouse_button_down: (WasmI32) => WasmI32 from "null0" // Has the button been released? (tracks press/read correctly.) @unsafe provide foreign wasm mouse_button_released: (WasmI32) => WasmI32 from "null0" // Is the button currently up? @unsafe provide foreign wasm mouse_button_up: (WasmI32) => WasmI32 from "null0" // -- SOUND -- // Load a sound from a file in cart. @unsafe provide foreign wasm load_sound: (WasmI32) => WasmI32 from "null0" // Play a sound. @unsafe provide foreign wasm play_sound: (WasmI32, WasmI32) => Void from "null0" // Stop a sound. @unsafe provide foreign wasm stop_sound: (WasmI32) => Void from "null0" // Unload a sound. @unsafe provide foreign wasm unload_sound: (WasmI32) => Void from "null0" // Speak some text and return a sound. Set things to 0 for defaults. @unsafe provide foreign wasm tts_sound: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Create Sfx sound. @unsafe provide foreign wasm sfx_sound: (WasmI32) => WasmI32 from "null0" // Create Sfx parameters. @unsafe provide foreign wasm sfx_generate: (WasmI32) => WasmI32 from "null0" // -- TILE -- // Load a tilemap (a Tiled map, exported as JSON) from a file in cart. @unsafe provide foreign wasm load_tilemap: (WasmI32) => WasmI32 from "null0" // Unload a tilemap. @unsafe provide foreign wasm unload_tilemap: (WasmI32) => Void from "null0" // Update a tilemap's animation timers (deltaTime is in seconds). @unsafe provide foreign wasm tile_update: (WasmI32, WasmF32) => Void from "null0" // Get the size of a tilemap, in tiles. @unsafe provide foreign wasm tile_map_size: (WasmI32) => WasmI32 from "null0" // Get the size of a single tile of a tilemap, in pixels. @unsafe provide foreign wasm tile_tile_size: (WasmI32) => WasmI32 from "null0" // Get a custom property of a tilemap, by name (PROP_NONE when there is no such property.) @unsafe provide foreign wasm tile_map_prop: (WasmI32, WasmI32) => WasmI32 from "null0" // Get the number of custom properties on a tilemap. @unsafe provide foreign wasm tile_map_prop_count: (WasmI32) => WasmI32 from "null0" // Get a custom property of a tilemap, by index (PROP_NONE when out of range.) @unsafe provide foreign wasm tile_map_prop_at: (WasmI32, WasmI32) => WasmI32 from "null0" // Draw a tilemap on the screen. @unsafe provide foreign wasm tile_draw: (WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a tilemap on the screen, tinted by a color. @unsafe provide foreign wasm tile_draw_tint: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a tilemap on an image. @unsafe provide foreign wasm tile_draw_on_image: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Render a whole tilemap to a new image. @unsafe provide foreign wasm tilemap_image: (WasmI32) => WasmI32 from "null0" // Get the number of layers in a tilemap. Layers are numbered depth-first, so the children of a group layer have their own indexes too. @unsafe provide foreign wasm tile_layer_count: (WasmI32) => WasmI32 from "null0" // Get the index of a layer of a tilemap, by name (-1 when there is no such layer.) @unsafe provide foreign wasm tile_layer_index: (WasmI32, WasmI32) => WasmI32 from "null0" // Get the name of a layer of a tilemap. @unsafe provide foreign wasm tile_layer_name: (WasmI32, WasmI32) => WasmI32 from "null0" // Get the kind of a layer of a tilemap. @unsafe provide foreign wasm tile_layer_type: (WasmI32, WasmI32) => WasmI32 from "null0" // Get the size of a layer of a tilemap, in tiles. @unsafe provide foreign wasm tile_layer_size: (WasmI32, WasmI32) => WasmI32 from "null0" // Get whether a layer of a tilemap is visible. Drawing a layer that Tiled marked hidden draws nothing. @unsafe provide foreign wasm tile_layer_visible: (WasmI32, WasmI32) => WasmI32 from "null0" // Get a custom property of a layer of a tilemap, by name (PROP_NONE when there is no such property.) @unsafe provide foreign wasm tile_layer_prop: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Get the number of custom properties on a layer of a tilemap. @unsafe provide foreign wasm tile_layer_prop_count: (WasmI32, WasmI32) => WasmI32 from "null0" // Get a custom property of a layer of a tilemap, by index (PROP_NONE when out of range.) @unsafe provide foreign wasm tile_layer_prop_at: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Draw a single layer of a tilemap on the screen. @unsafe provide foreign wasm tile_draw_layer: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a single layer of a tilemap on the screen, tinted by a color. @unsafe provide foreign wasm tile_draw_layer_tint: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a single layer of a tilemap on an image. @unsafe provide foreign wasm tile_draw_layer_on_image: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Render a single layer of a tilemap to a new image. @unsafe provide foreign wasm tile_layer_image: (WasmI32, WasmI32) => WasmI32 from "null0" // Get the gid of the tile at a column/row in a tilemap layer. @unsafe provide foreign wasm tile_get_tile: (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Set the gid of the tile at a column/row in a tilemap layer. Swapping a gid is how a cart keeps changing state in the map itself. @unsafe provide foreign wasm tile_set_tile: (WasmI32, WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Draw a single tile from a tilemap on the screen. @unsafe provide foreign wasm tile_draw_tile: (WasmI32, WasmI32, WasmI32, WasmI32) => Void from "null0" // Get a copy of the image of a single tile in a tilemap. @unsafe provide foreign wasm tile_image: (WasmI32, WasmI32) => WasmI32 from "null0" // Get a custom property of a tile of a tilemap, by name (PROP_NONE when there is no such property.) These come from the tileset, so every tile with this gid shares them. @unsafe provide foreign wasm tile_gid_prop: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Get the number of custom properties on a tile of a tilemap. @unsafe provide foreign wasm tile_gid_prop_count: (WasmI32, WasmI32) => WasmI32 from "null0" // Get a custom property of a tile of a tilemap, by index (PROP_NONE when out of range.) @unsafe provide foreign wasm tile_gid_prop_at: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Get the number of objects on an object-layer of a tilemap. @unsafe provide foreign wasm tile_object_count: (WasmI32, WasmI32) => WasmI32 from "null0" // Get an object from an object-layer of a tilemap. @unsafe provide foreign wasm tile_object: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Get the index of an object on an object-layer of a tilemap, by name (-1 when there is no such object.) @unsafe provide foreign wasm tile_object_index: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Get a custom property of an object of a tilemap, by name (PROP_NONE when there is no such property.) @unsafe provide foreign wasm tile_object_prop: (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Get the number of custom properties on an object of a tilemap. @unsafe provide foreign wasm tile_object_prop_count: (WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // Get a custom property of an object of a tilemap, by index (PROP_NONE when out of range.) @unsafe provide foreign wasm tile_object_prop_at: (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "null0" // -- TYPES -- // -- UTILITIES -- // Get system-time (ms) since unix epoch. @unsafe provide foreign wasm current_time: () => WasmI64 from "null0" // Get the change in time (seconds) since the last update run. @unsafe provide foreign wasm delta_time: () => WasmF32 from "null0" // Get a random integer between 2 numbers. @unsafe provide foreign wasm random_int: (WasmI32, WasmI32) => WasmI32 from "null0" // Get the random-seed. @unsafe provide foreign wasm random_seed_get: () => WasmI64 from "null0" // Set the random-seed. @unsafe provide foreign wasm random_seed_set: (WasmI64) => Void from "null0"