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::vic2.border_color.read();
unsafe {
    c64::vic2().border_color.write(vic2::LIGHT_RED);
}

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::ScreenBank::AT_2000.bits();
c64::vic2().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 value = c64::sid().random_byte();

Modules§

  • Commodore 64 support.
  • Registers for the MOS Technology 6526/8520 Complex Interface Adapter (CIA)
  • Commander X16 support.
  • MEGA65 support.
  • Utility functions for working with single PETSCII characters
  • 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)
  • Convert string slice to array of petscii bytes at compile time
  • As petscii_codes! but null-terminated
  • Poke into memory (volatile write)
  • Convert string slice to array of screen codes at compile time
  • As screen_codes! but null-terminated
  • Subtract two integers using wrapping

Constants§

Functions§

  • Returns constantly evaluated scaled and shifted sine table.
  • Repeat each element n times
  • Cyclic sine from 0x80..0..0xff..0x80