EightyEighty.js
A nice little Intel 8080 emulator for Node.js and Browser!
About •
Installation •
Usage •
Resources •
License
About
Originally I wrote this because I was interested in how emulators work, and what a CPU actually does.
But, after several days of work, I managed to put together a pretty good codebase,
therefore I've decided to make this emulator available as a library of its own,
so that anyone could embed it in their web pages or applications!
I mostly followed the tutorial here: http://emulator101.com
Installation
With npm:
$ npm install eighty-eighty-js
With pnpm (recommended):
$ pnpm install eighty-eighty-js
With yarn:
$ yarn add eighty-eighty-js
or you can directly add it to your website via unpkg:
<script src="https://unpkg.com/eighty-eighty-js"></script>
Usage
If this project gains more attention I'll add some documentation!
You'll probably need to install typed-numbers
too!
import { Cpu, Memory, Device } from 'eighty-eighty-js';
import { promises as fs } from 'fs';
import { u8 } from 'typed-numbers';
const programBuffer = await fs.readFile('./example-rom.bin');
const mem = new Memory();
mem.load(programBuffer, 0x100);
const device: Device = {
input(port: u8) {
console.log('INPUT', port);
return u8(0);
},
output(port: u8, byte: u8) {
console.log('OUTPUT', port, byte);
},
};
const cpu = new Cpu(mem, device);
while (true) {
if (cpu.halted) break;
cpu.next();
await cpu.step();
}
Resources
These resources helped a lot while developing the emulator:
License
MIT License