Crates.io | mos-hardware |
lib.rs | mos-hardware |
version | 0.4.0 |
source | src |
created_at | 2022-07-15 15:48:43.916651 |
updated_at | 2024-03-03 12:33:09.490949 |
description | Hardware register tables and support functions for 8-bit retro computers like the Commodore 64, MEGA65 and others. |
homepage | https://github.com/mlund/mos-hardware |
repository | https://github.com/mlund/mos-hardware |
max_upload_size | |
id | 626276 |
size | 432,073 |
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.
use mos_hardware::{c64, vic2};
let old_border_color = c64::vic2().border_color.read();
unsafe {
c64::vic2().border_color.write(vic2::LIGHT_RED);
c64::sid().potentiometer_x.write(3); // compile error: read-only register
}
...for example where the VIC-II chip accesses screen memory and character sets:
use mos_hardware::{c64, vic2};
let bank = vic2::ScreenBank::AT_2C00.bits() | vic2::CharsetBank::AT_2000.bits();
unsafe {
c64::vic2().screen_and_charset_bank.write(bank);
}
...for example to generate random numbers using noise from the C64's SID chip:
use mos_hardware::c64::*;
clear_screen();
sid().start_random_generator();
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 Visual Studio Code.
Before starting up VSC, you may want to edit .devcontainer.json
to point to a recent, tagged image of
mrkits/rust-mos
.
In particular, if you're on an ARM architecture, e.g. Apple Silicon, make sure to use an image compiled for
linux/arm64
as emulating x86 in Docker is painfully slow.
cd mos-hardware
code --install-extension ms-vscode-remote.remote-containers
code .
When asked, re-open in Dev container.cargo build --release --target mos-c64-none --example c64-plasma
target/
and run in an emulator or transfer to real hardware.cargo/home
, force older version cargo update -p home@0.5.9 --precise 0.5.5
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
)