GithubHelp home page GithubHelp logo

nirvananimbusa / intel-8080-emu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aurelienrichez/intel-8080-emu

0.0 1.0 0.0 27 KB

An intel 8080 emulator library written in rust

License: Mozilla Public License 2.0

Rust 100.00%

intel-8080-emu's Introduction

Intel 8080 emu

Crates.io

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.

Quickstart

The main struct is intel_8080_emu::proc_state::Proc8080. It needs basically two things to work :

  • The memory, a simple Box<[u8]> containing the rom and the ram.
  • A structure implementing 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)
}   

Possible improvements

  • Maybe better memory handling. It is currently a simple Box<[u8]> and does not distinguish between ROM and RAM.

intel-8080-emu's People

Contributors

aurelienrichez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.