Skip to content

shankuniyogi/rustycoat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rustycoat

Rustycoat is a fun little project to create a 6502 emulator in Rust.

The 6502 was a revolutionary 8-bit microprocessor - its simple and inexpensive design made it practical to build low-cost personal computers, and together with the Z80, the 6502 really kickstarted the home computer movement. The 6502, or variants of it, were used in Apple, Atari, Commodore and Nintendo machines.

The core CPU emulator (found in c6502.rs) is pretty much complete, and timing-accurate with the 6502 chip. Tests of the instruction set are found in c6502_tests.rs.

Along with the CPU, there are software equivalents of a few components: a clock with adjustable frequency, a memory implementation with customizable banks (compatible with the 6502's bank-switching memory architecture), a set of gates, and even some "UI", in the form of LEDs built on top of the iui crate.

The programming model is designed to make it easy to hook up and run the CPU with a clock, memory, and some set of components - much like one would with a breadboard. Here's a trivial example that wires up a clock directly to an LED:

    // Create an LED
    let mut led = Led::new(Color::new(1.0, 0.0, 0.0), Color::new(0.4, 0.4, 0.4));

    // Create a 5Hz clock and wire it up to the LED.
    let mut clock = Clock::new(5);
    clock.output().connect_to(led.input());

    // Create the computer, add components, and start it up.
    let mut c = Computer::new();
    c.add_async(clock);
    c.add_ui(led);

    c.run();

An actual CPU example can be found in the examples directory.

This was mostly just a fun project to go down memory lane and learn a bit of Rust while doing it. At some point, maybe it could be grown into an actual computer emulator.

References

While working on Rustycoat, I came across a lot of great materials on the 6502.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages