Crate mos_hardware

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§

c64
Commodore 64 support.
cbm_kernal
cia
Registers for the MOS Technology 6526/8520 Complex Interface Adapter (CIA)
cx16
Commander X16 support.
mega65
MEGA65 support.
petscii
Utility functions for working with single PETSCII characters
sid
Registers for the MOS Technology 6581/8580 SID (Sound Interface Device)
vera
Registers for the Versatile Embedded Retro Adapter (VERA) graphics chip.
vic2
Registers for the MOS 6566/6567 (VIC-II) Chip

Macros§

add
Add two integers using wrapping
highbyte
Get high byte from a 16-bit integer using pointer arithmetic
lowbyte
Get low byte from a 16-bit integer using pointer arithmetic
peek
Peek into memory (volatile read)
petscii_codes
Convert string slice to array of petscii bytes at compile time
petscii_codes_null
As petscii_codes! but null-terminated
poke
Poke into memory (volatile write)
screen_codes
Convert string slice to array of screen codes at compile time
screen_codes_null
As screen_codes! but null-terminated
sub
Subtract two integers using wrapping

Constants§

SINETABLE
Tabulated, cyclic sine table

Functions§

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