millfork

Millfork: a middle-level programming language targeting 6502- and Z80-based microcomputers and home consoles

This project is maintained by KarolS

< back to index

Commander X16-oriented modules

WARNING! Commander X16 is not yet a finalised design. Therefore, both the device itself and the modules for its support may change at any moment.
The X16-oriented modules may be out of date and not support the current design of the device.

x16_kernal

The x16_kernal module is imported automatically on the X16 target.

Currently, it automatically imports the c64_kernal module.

void mouse_config(byte register(a) enable, byte register(x) scale)

Configures the mouse pointer.
enable should be 1 to enable, 0 to disable and $ff to enable without reconfiguration.
scale should be 1 on 640×480 screens, 2 on 320×240 screens, and 0 to keep the current scale.

x16_hardware

The x16_hardware module is imported automatically on the X16 target.

void set_ram_bank(byte)

Switches the RAM segment at $A000-$BFFF.

void set_rom_bank(byte)

Switches the ROM segment at $C000-$DFFF.

void vera_poke(int24 address, byte value)

Writes a byte into the VERA memory space.

byte vera_peek(int24 address)

Reads a byte from the VERA memory space.

void vera_fill(int24 address, byte value, word size)

Writes size bytes into the VERA memory space.

void vera_upload(int24 address, pointer source, byte size)

void vera_upload_large(int24 address, pointer source, word size)

Copies size bytes from the RAM at address source into the VERA memory space at address address.

struct vera_layer_setup

Hardware register values for a video layer. For VERA 0.7 and 0.8:

byte ctrl0
byte ctrl1
word map_base
word tile_base
word hscroll
word vscroll

For VERA 0.9:

byte config
byte map_base
byte tile_base
word hscroll
word vscroll

void set_vera_layer1(pointer.vera_layer_setup)

Sets up the layer 1. VERA 0.7 and 0.8 only.
On VERA 0.9, use vera_layer0 directly.

void set_vera_layer2(pointer.vera_layer_setup)

Sets up the layer 2. VERA 0.7 and 0.8 only.
On VERA 0.9, use vera_layer1 directly.

vera_layer_setup vera_layer0

Direct access to registers for the layer 0. VERA 0.9 only.

vera_layer_setup vera_layer1

Direct access to registers for the layer 1. VERA 0.9 only.

struct vera_sprite_data

Hardware register values for a sprite:

word address
word x
word y
byte ctrl0
byte ctrl1

void vera_upload_sprite(byte sprite_id, pointer.vera_sprite_data source)

Uploads sprite data for given sprite id.

const int24 VERA_PALETTE

const int24 VERA_SPRITES

Various addresses in the VERA memory space.

const int24 VERA_COMPOSER_CTRL

const int24 VERA_LAYER_1

const int24 VERA_LAYER_2

const int24 VERA_SPRITE_CTRL

Various addresses in the VERA memory space. VERA 0.7 and 0.8 only.

void vera_reset()

Resets the VERA.

void vera_set_sprites_enable(bool enabled)

Enables/disables sprites.

void set_border(byte color)

Changes the color of the border.

x16_joy

The x16_joy module implements a joystick driver compatible with the joy module.

void read_joy1()

Reads the joystick from the port 1.

void read_joy2()

Reads the joystick from the port 1.

void read_also_joy1()

Reads the joystick from the port 1 and adds its readouts to the current readouts.

void read_also_joy2()

Reads the joystick from the port 2 and adds its readouts to the current readouts.

byte input_*

The following variables have the value 1 if the key is pressed and 0 if not:

Warning: The assignment of NES controller buttons and keyboard keys may change in the future.

Variable SNES controller NES controller Keyboard (joy 1 only)
input_a A    
input_b B A Ctrl
input_x X B Alt
input_y Y    
input_start Start Start Enter
input_select Select Select Space
input_l L    
input_r R    

input_b is an alias for input_btn. Single-button games should use input_btn for compatibility.

x16_joy_type joy_type

The type of the last read joystick. One of joy_none, joy_nes, joy_snes, joy_keyboard.

x16_joy1_default module

Defines the joystick in port 1 as the default joystick.

alias read_joy = read_joy1

x16_mouse

The x16_mouse module implements a mouse driver compatible with the mouse module.

Before using this, you may want to call mouse_config from the x16_kernal module.

void read_mouse()

Reads the state of the mouse.