This crate contains hardware register tables and support functions for
8-bit retro computers like the Commodore 64, Commander X16, MEGA65 and others.
Please check the examples
directory to see how Rust can be used to generate simple demo effects.
~~~ rust use moshardware::{c64, vic2}; let oldbordercolor = c64::vic2().bordercolor.read(); unsafe { c64::vic2().bordercolor.write(vic2::LIGHTRED); c64::sid().potentiometer_x.write(3); // compile error: read-only register } ~~~
...for example where the VIC-II chip accesses screen memory and character sets:
~~~ rust use moshardware::{c64, vic2}; let bank = vic2::ScreenBank::AT2C00.bits() | vic2::CharsetBank::AT2000.bits(); unsafe { c64::vic2().screenandcharsetbank.write(bank); } ~~~
...for example to generate random numbers using noise from the C64's SID chip:
~~~ rust use moshardware::c64::*; clearscreen(); sid().startrandomgenerator(); let value = sid().random_byte(); ~~~
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.
If you want to start a new project which uses mos-hardware
, there's a
Github Template.
The easiest way is to use the provided .devcontainer.json
configuration for vscode
by clicking the Dev Containers Open badge above, assuming you have VSC and Docker installed.
You can also do this manually:
In the vscode terminal do: ~~~ bash
export CARGONETGITFETCHWITH_CLI=true
cargo build --target mos-mega65-none ~~~
The hardware registers are currently incomplete and the library may be subject to significant changes.
sid
vic2
cia
(partially)c64
memory map (particlly)RngCore
)vera
via
(partially)cx16
Memory map (partially)RngCore
, SeedableRng
)