Crate z80

source ·
Expand description

A fast and accurate instruction-stepped Z80 emulator written in C11 and ported to Rust

Basic usage:

use z80::{Z80, Z80_io};

struct IO {
   pub mem: [u8; 0x10000],
}

impl Z80_io for IO {
   fn read_byte(&self, addr: u16) -> u8 {
       self.mem[addr as usize]
   }

   fn write_byte(&mut self, addr: u16, value: u8) {
       self.mem[addr as usize] = value;
   }
}

let mut cpu = Z80::new(IO {
   mem: [0; 0x10000],
});

let rom = vec![0, 0, 0]; // etc

for (i, byte) in rom.iter().enumerate() {
   cpu.io.write_byte(i as _, *byte);
}

loop {
   cpu.step();
   break;
}

Structs

Traits

  • Trait for controlling IO behaviour