/gb-js-multi-emu

GameBoy and GameBoy Color emulation written in JavaScript (with TypeScript) for mulitple platforms

Primary LanguageTypeScriptMIT LicenseMIT

What is this project?

This project is yet another Gameboy + Gameboy Color emulator written entirely in TypeScript. The goal of this project was to write core of the emulator in TypeScript and then port the emulation to all platforms - web, desktop and mobile.

Demo

You can checkout running Emulator in web on GitHub pages here

What is status of this project? Is it finished, is it still in development?

It's just fun little project done on the side. Ultimate goal is to support MBC0, MBC1, MBC2, sound, most possible accurate timing, saving and loading emulation state to run all Pokemon ROMs.

Project structure

Theare are three four main directories in repository:

core - holds Emulator source code for every component such as CPU, Memory, GPU, Timers etc. This is completely separatered from any kind of rendering environment such as web / mobile / desktop. Emulator exposes events or callback allowing to retrieve events such as draw frame or input handlers.

desktop - this is desktop GUI implementation for Emulator. It uses core package for emulation and currently is running via Electron on desktop. Releases currently are build only for Linux since I am running Ubuntu.

mobile - this is mobile GUI implementation for Emulator. It ueses core pacakge for emulation and currently is running via Ionic framework on mobile. Releases currently are build only for Android since I do not own IOS device.

website - this is web GUI implementation for Emulator. It uses core package for emulation and currently is running via HTML5 canvas on web. Release is available under GitHub page link here. It's tested on Firefox and Chromium.

Each of these directories contains it's own README.md file. Please refer to them for more documenation on each component including npm scripts description, directory structure, etc.

What are the supported features / what is missing?

Feature Status Addtional description
CPU ✔️ Done, CPU running at 4.194304 MHz
CPU + Memory Timing There is problem with passing instr_timing test tests. The issue arrises from the fact that each CPU OP Code is retuning number of cycles by the end of execeution and ticks are incremented once at the end. Correct implementation would increase ticks at each memory read / write so that it could be synced correectly
Timer - DIV ✔️ Done
Timer - TIMA ✔️ Done
Joypad ✔️ Done
GPU - Classic ✔️ GPU is only not passing timing test in DMG_ACID test ROM. It's due to timing implementation issues mentioned earlier in CPU
GPU - Color Not started at all
MBC 0 ✔️ Done, Tetris and Dr Mario both launches
MBC 1 Coming soon
MBC 2 Coming soon
Sound Not started at all, coming after MBC1 and MBC2 support + timing issues resolved
Saving state Not started at all, coming after sound support
Loading state Not started at all, coming after sound support
60 FPS constant It's not an issue on web or desktop but on mobile devices there are sometimes drops to under 40 FPS. Consider adding cache for graphics so that background + tiles are re-rendered only when they are changed.
Upscaling ✔️ Working, scaling up to 5 times original resolution. Algorithm is pretty dumb but it is enough for now

E2E Tests Status

This section is to show emulator compability status by running E2E Tests for various components such as CPU or GPU. Currently those tests are run manually, but in future those will run automatically by comparing hash checksum of VRAM content with baseline hash.

CPU Tests

- Blargg's test suite:

01-special:

special

02-interrupts:

interrupts

03-op sp,hl:

op-sp-hl

04-op r,imm:

op-r-imm

05-op rp:

op-rp

06-ld r,r:

ld-rr

07-jr,jp,call,ret,rst:

jr-jp-call-ret-rst

08-misc instrs:

misc-instrs

09-op r,r:

op-r-r

10-bit ops:

bit-ops

11-op a,(hl):

op-a-hl

GPU Tests

DMG ACID2

dmg-acid2

It's not 100% accurate due to incorrect CPU / Memory timing

Fairy lake

fairy-lake

Runnable ROMs

MBC 0

Tetris:

tetris_title_screen tetris_running_game

Dr Mario:

dr_mario_title_screen dr_mario_running

Knowledge list - articles / tutorials / videos / specs / repos / test ROMs: