Skip to content

A nice little Intel 8080 emulator for Node.js and Browser! 💾

License

Notifications You must be signed in to change notification settings

jonasgeiler/EightyEighty.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EightyEighty.js

A nice little Intel 8080 emulator for Node.js and Browser!

NPM VERSION NPM DOWNLOADS DEPENDENCIES

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

Try it out

I've made a little website to showcase this library: arcade.skayo.dev

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';

// Read ROM
const programBuffer = await fs.readFile('./example-rom.bin');

// Init Memory
const mem = new Memory();

// Load ROM into Memory
mem.load(programBuffer, 0x100);

// Device that handles inputs and outputs
const device: Device = {
	input(port: u8) {
		console.log('INPUT', port);
		return u8(0);
	},

	output(port: u8, byte: u8) {
		console.log('OUTPUT', port, byte);
	},
};

// Init CPU
const cpu = new Cpu(mem, device);

// Execution Loop
while (true) {
	// Check if halted
	if (cpu.halted) break;
	
	cpu.next(); // CPU operation without any delays
	// OR
	await cpu.step(); // Simulates real Intel 8080 speed
}

Resources

These resources helped a lot while developing the emulator:

License

MIT License