Skip to content
Drew Wibbenmeyer edited this page Apr 20, 2022 · 3 revisions

Something that makes draxel-0 somewhat unique is it can have both system scripts that can be used for various development tasks... like extending the functionality of the internal command line. It also has the normal concept of "cartridges" that will be used for playing games.

A large part of the user API is shared between "system" and "cartridge" code. But generally "system" scripts are allowed to do more things... like directly interacting the the OS that draxel-0 is being ran on. Also, when running in "system" mode each function call invokes some synchronization code with the draxel-0 which automatically updates the state of the machine while the script is running, which is different than "cartridge" scripts. "Cartridge" scripts are ran through a set of pre-defined callback functions that get called at specific times in draxel-0's execution (much like typical fantasy consoles).

Also, some API's might be added through the boot script (data/scripts/lua/boot.lua) that are not embedded directly into draxel-0. There is always the chance they might get moved if performance is a concern.

Shared API

⌨️ Input

kb.keyp

  • kb.keyp(key: int): bool

    Was key pressed in the previous frame?

kb.key

  • kb.key(key: int): bool

    Is key pressed in the current frame?

🎨 Graphics

gpu.text.csrx

  • gpu.text.csrx(x: int)

    Set textmode cursor X position to x

  • gpu.text.csrx(): int

    Get textmode cursor X position

gpu.text.csry

  • gpu.text.csry(y: int)

    Set textmode cursor Y position to y

  • gpu.text.csry(): int

    Get textmode cursor Y position

gpu.text.csrpos

  • gpu.text.csrpos(x: int, y: int)

    Set textmode cursor position to (x, y)

  • gpu.text.csrpos(): [int, int]

    Get textmode cursor position [x, y]

gpu.text.csren

  • gpu.text.csren(enable: bool)

    Enable or disable the textmode cursor according to enable

  • gpu.text.csren(): bool

    Get whether or not the textmode cursor is enabled

gpu.text.csrcol

  • gpu.text.csrcol(color: int)

    Set the color of the textmode cursor to color

  • gpu.text.csrcol(): int

    Get the color of the textmode cursor

gpu.text.csrch

  • gpu.text.csrch(ch: char)

    Set the character that represents the textmode cursor to ch

  • gpu.text.csrch(): char

    Get the character that represents the textmode cursor

gpu.text.putc

  • gpu.text.putc(x: int, y: int, fg: int, bg: int, ch: char)

    Set the character at (x, y) to the character ch with foreground color fg and background color bg

gpu.text.puts

  • gpu.text.puts(x: int, y: int, fg: int, bg: int, str: string)

    Puts the string str onto the screen at (x, y) with foreground color fg and background color bg. Also, the text will not be wrapped at the right edge of the screen.

gpu.text.scrollu

  • gpu.text.scrollu(lines: int, fg: int, bg: int, ch: char)

    Scrolls the contents of the screen up by lines lines. The cleared space is filled with characters ch with foreground color fg and background color bg.

gpu.text.scrolld

  • gpu.text.scrolld(lines: int, fg: int, bg: int, ch: char)

    Scrolls the contents of the screen down by lines lines. The cleared space is filled with characters ch with foreground color fg and background color bg.

gpu.text.scrolll

  • gpu.text.scrolll(cols: int, fg: int, bg: int, ch: char)

    Scrolls the contents of the screen left by cols columns. The cleared space is filled with characters ch with foreground color fg and background color bg.

gpu.text.scrollr

  • gpu.text.scrollr(cols: int, fg: int, bg: int, ch: char)

    Scrolls the contents of the screen right by cols columns. The cleared space is filled with characters ch with foreground color fg and background color bg.

gpu.text.cls

  • gpu.text.cls(fg: int, bg: int, ch: char)

    Clears the screen with characters ch with foreground color fg and background color bg.

gpu.text.getch

  • gpu.text.getch(x: int, y: int): [int, int, char]

    Gets the character [fg, bg, ch] at position (x, y).

💻 System API

TODO

🎮 Cartridge API

TODO