This is (not a libretro core, don't ask) a Java CHIP-8/Superchip emulator library, made from the guts my other CHIP-8 emulator (Batatinha), created to be used on an Android port (Batatinha v2).
It is based on the VIP and SCHIP 1.1 instruction sets, auto choosing which based on the instructions used. Some newer games are made to be run with Octo instruction set, so they might not run correctly.
Usage:
- Instantiate Chip8 class:
final Chip8 chip8 = new Chip8();
- Call the
loadProgram(InputStream program)
method:chip8.loadProgram(new FileInputStream(file));
- Call the
step()
method for each cpu tick:for(int i = 0, i < 8; i++){ chip8.step(); } //~500Hz @ 60fps
- Call the
timerStep()
method separately at 60Hz, it returns true if theres a sound beep - Get the display framebuffer from the
getDisplayBuffer()
method, it is an array composed of 0s and 1s, just draw it using your favorite method - Input is processed using the methods
presKey(Key key)
andreleaseKey(Key key)
- Use the
sineWave(int frequency, int amplitude, int sampleRate, int sampleSize)
method from the classBuzzer
along with the emunNote
to create a sine wave that can be played with a Clip
References:
http://mattmik.com/retro.html
http://devernay.free.fr/hacks/chip8
https://github.com/Chromatophore/HP48-Superchip
https://github.com/AfBu/haxe-CHIP-8-emulator/wiki/(Super)CHIP-8-Secrets
https://github.com/JohnEarnest/Octo