Expand description

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 generate demo effects.

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(c64::LIGHT_RED);
 
(*c64::SID).potentiometer_x.write(3); // error: read-only register

Use 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::CharsetBank::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

Macros

Add two integers using wrapping

Peek into memory (read)

Poke into memory (read)

Use SID entropy to generate a random byte in the interval.

Subtract two integers using wrapping

Functions

Repeat each element n times