Crates.io

MOS-Hardware

This crate contains hardware register tables and support functions for 8-bit retro computers like the Commodore 64, MEGA65 and others. Please check the examples/ directory to see how Rust can be used to generate demo effects.

Aims

Examples

Read and write to labelled hardware registers

~~~ rust use mos_hardware::{c64,vic2};

let oldbordercolor = (c64::VIC).border_color.read(); (c64::VIC).bordercolor.write(vic2::LIGHTRED); (*c64::SID).potentiometer_x.write(3); // error: read-only register ~~~

Use bitflags to safely control hardware behaviour

...for example where the VIC-II chip accesses screen memory and character sets:

~~~ rust let bank = vic2::ScreenBank::AT2C00.bits() | vic2::CharsetBank::AT2000.bits(); (*c64::VIC).screenandcharset_bank.write(bank); ~~~

Convenience functions to perform hardware-specific tasks

...for example to generate random numbers using noise from the C64's SID chip:

~~~ rust (*c64::SID).startrandomgenerator(); let random_number : u8 = rand8!(c64::SID); ~~~

Getting started

The project requires rust-mos and is setup to build for C64 by default. A docker image of rust-mos is available if you do not fancy compiling LLVM.

Docker and Visual Studio Code

The easiest way is to use provided devcontainer.json configuration for vscode:

  1. Configure Visual Studio Code with Remote - Containers extension
  2. Open this project inside devcontainer
  3. In vscode terminal do: # build for mos-atari8-none target cargo build --target mos-mega65-none

Status

The hardware registers are currently incomplete and the library may be subject to significant changes.