Crate mos_hardware
source · [−]Expand description
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 generate basic graphics effects and interact with hardware.
Examples
Read and write to labelled hardware registers:
use mos_hardware::{c64,vic2};
let old_border_color = (*c64::VIC).border_color.read();
(*c64::VIC).border_color.write(vic2::LIGHT_RED);
(*c64::SID).potentiometer_x.write(3); // error: read-only registerUse bitflags to control hardware behaviour, e.g. where the VIC-II chip accesses screen memory and character sets:
let bank = vic2::ScreenBank::AT_2C00.bits() | vic2::ScreenBank::AT_2000.bits();
(*c64::VIC).screen_and_charset_bank.write(bank);Convenience functions to perform hardware-specific tasks, e.g. generate random numbers using noise from the C64’s SID chip:
(*c64::SID).start_random_generator();
let random_number : u8 = rand8!(c64::SID);Modules
Commodore 64 support.
Registers for the MOS Technology 6526/8520 Complex Interface Adapter (CIA)
Commander X16 support.
MEGA65 support.
Registers for the MOS Technology 6581/8580 SID (Sound Interface Device)
Registers for the Versatile Embedded Retro Adapter (VERA) graphics chip.
Registers for the MOS 6566/6567 (VIC-II) Chip
Macros
Add two integers using wrapping
Get high byte from a 16-bit integer using pointer arithmetic
Get low byte from a 16-bit integer using pointer arithmetic
Peek into memory (volatile read)
Poke into memory (volatile write)
Use SID entropy to generate a random byte.
Subtract two integers using wrapping
Functions
Repeat each element n times