Crates.io | intel-8080-emu |
lib.rs | intel-8080-emu |
version | 0.2.0 |
source | src |
created_at | 2018-09-08 17:43:49.48708 |
updated_at | 2018-11-10 15:46:01.158617 |
description | A small library to emulate an intel 8080. |
homepage | |
repository | https://github.com/AurelienRichez/intel-8080-emu |
max_upload_size | |
id | 83635 |
size | 109,417 |
An intel 8080 emulator library (another one). Initially implemeted to build a space invaders emulator (another another one).
This library provides provides utilities to parse 8080 binary and simulate an 8080 microprocessor. All op codes are implemented and there is no external dependencies.
The main struct is intel_8080_emu::proc_state::Proc8080
. It needs basically two things to work :
Box<[u8]>
containing the rom and the ram.intel_8080_emu::proc_state::DataBus
which handles the IN
and OUT
calls.use intel_8080_emu::proc_state::Proc8080;
use foo::bar::MyCustomDataBus;
use std;
// load your rom as an array
let rom: [u8] = load_rom();
// copy the rom into the 8008 memory
let mut memory = Box::new([0x00; 0xffff]);
memory[0..rom.len()].copy_from_slice(&rom);
let i8080 = Proc8080::new(memory, data_bus);
// we're ready !
// Here is naive way to slow down the simulation so that it matches the original speed of the 8080
let mut states = i8080.states();
loop {
// emulates runs one "step" of the simulation by running the next opcode, mutating the
// processor state accordingly and increasing the states count
i8080.emulate();
// you can manage time with Proc8080:states()
// A cycle for the 8080 took approximately 500 nanoseconds
std::thread::sleep(std::time::Duration::from_nanos(500) * (i8080.states() - states)
}
Box<[u8]>
and does not distinguish
between ROM and RAM.