Giter Club home page Giter Club logo

coffee-gb's Introduction

Coffee GB

Coffee GB is a Gameboy Color emulator written in Java 8. It's meant to be a development exercise. More info can be found in the blog post Why did I spend 1.5 months creating a Gameboy emulator?

Coffee GB running game

Building

The emulator can be build with Maven:

mvn clean package

The coffee-gb-*-complete.jar executable file will be available in the ./target directory.

Usage

  1. Download the most recent release.
  2. Double-click the JAR or launch it with java -jar coffee-gb-*.jar command.
  3. Load a game.

Play with , , , , Z, X, Enter, Backspace.

Features

  • Cycle-exact Gameboy CPU emulation. Each opcode is split into a few micro-operations (load value from memory, store it to register, etc.) and each micro-operation is run in a separate CPU cycle.
  • Quite compatible (all the Blargg's tests are passed, although some game still doesn't work)
  • GPU
  • Joypad
  • Timer
  • Sound
  • MBC1-5 support
  • Battery saves
  • Support for zipped ROMs
  • ROM-based compatibility tests run from Maven

Running Blargg's tests

The Blargg's test ROMs are used for testing the compatibility. Tests can be launched from Maven using appropriate profile:

mvn clean test -Ptest-blargg
mvn clean test -Ptest-blargg-individual # for running "single" tests providing more diagnostic info

They are also part of the Travis-based CI.

The tests output (normally displayed on the Gameboy screen) is redirected to the stdout:

cpu_instrs

01:ok  02:ok  03:ok  04:ok  05:ok  06:ok  07:ok  08:ok  09:ok  10:ok  11:ok

Passed all tests

Coffee GB passes all the tests:

  • cgb_sound
  • cpu_instrs
  • dmg_sound-2
  • halt_bug
  • instr_timing
  • interrupt_time
  • mem_timing-2
  • oam_bug-2

Mooneye tests

The Mooneye GB emulator comes with a great set of test ROMs. They can be used to test the Coffee GB as well. Use -Ptest-mooneye profile:

mvn clean test -Ptest-mooneye

Screenshots

Coffee GB running game Coffee GB running game Coffee GB running game Coffee GB running game Coffee GB running game Coffee GB running game Coffee GB running game Coffee GB running game Coffee GB running game Coffee GB running game

Key bindings

The default key bindings can be changed with the ~/.coffeegb.properties file. The file has following format:

btn_up=VK_UP
btn_down=VK_DOWN
btn_left=VK_LEFT
btn_right=VK_RIGHT
btn_a=VK_Z
btn_b=VK_X
btn_start=VK_ENTER
btn_select=VK_BACK_SPACE

The key list can be found in the KeyEvent JavaDoc.

Resources

coffee-gb's People

Contributors

7thsamurai avatar dependabot[bot] avatar qlefevre avatar trekawek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffee-gb's Issues

Severe frame skip issues

Not sure why this is happening. The emulator runs (sometimes) at full fps, and sometimes at a severely reduced FPS. Sometimes I only get 1-2 frames per second, with obnoxious beeping sounds because the audio can't smoothly play.

I am running Super Mario Bros Deluxe rom with Oracle JDK 8

Stereo audio is flipped

Discovered playing Pokemon Crystal. If you set the sound to stereo in the game options the left and right side are flipped. Easily noticeable during a Pokemon battle during attacks.

Performance is bad and audio making popping noises (audio is also stuttery)

It runs slowly but sometimes it speeds up and audio is stuttery, causing popping noises. Also, I think there should be a input GUI to assign controls to the keyboard, though the default key layout isn't too bad.
EDIT: The games run better now but it still has problems, GB games run better than GBC games as there is some stuttering in framerate.

Remove SLF4J-Simple binding

coffee-gb/pom.xml

Lines 110 to 113 in 9f2ea20

<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.16</version>
</dependency>

Please remove any concrete SLF4J bindings, such as slf4j-simple from your dependencies. This makes it hard for users of your project to define their own binding, such as log4j2 or similar:

error

This is mainly a problem because your artifacts are fat/uber-jars. So dependency-exclusions dont work. Ideally, a library would never include any concrete bindings but only the facade itself.

Cheers and thanks for this awesome project!

Embedded Emulator Help

Hi there!

I currently host a ROM Hack on my website using an embedded flash emulator, but since Chrome is going to discontinue flash soon I am looking for a Java/other type of embedded emulator to replace it with.

I found your Java GB, and I was wondering if this would work for me. If so, could you help me set it up?

Thanks and let me know :D

run.sh with old version

When I run the run.sh, I got the error following:
Error: Unable to access jarfile target/coffee-gb-1.0.0-SNAPSHOT.jar
Because it's coffee-gb-1.0.1-SNAPSHORT.jar in the target directory.

Pokemon Blue crashes since latest updates

Since the latest updates, Pokemon Blue/Red crashes when loading the game world:

gif

Stacktrace:

Exception in thread "Thread-1" java.lang.IndexOutOfBoundsException: Address: 40960
        at eu.rekawek.coffeegb.memory.Ram.getByte(Ram.java:43)
        at eu.rekawek.coffeegb.gpu.Fetcher.tick(Fetcher.java:133)
        at eu.rekawek.coffeegb.gpu.phase.PixelTransfer.tick(PixelTransfer.java:69)
        at eu.rekawek.coffeegb.gpu.Gpu.tick(Gpu.java:177)
        at eu.rekawek.coffeegb.Gameboy.tick(Gameboy.java:173)
        at eu.rekawek.coffeegb.Gameboy.run(Gameboy.java:132)
        at java.base/java.lang.Thread.run(Thread.java:833)

It still worked fine with commit: 9f2ea20
But is now crashing, commit: 660ce4b

So something in between those commits likely introduced a bug.

How do i save my games

Hey trekawek,
nice work with your gb-emulator. I would love to play some games with it.

Is ther a feature to save my games or open the .sav games again.

Thanks in advance,
Finn

How to open

I came across this developing my own emulator, and gave this a try, but how exactly do you open this?

Framerate not limited

Hi,

I'm writing a port to make this emulator playable in minecraft. I'm noticing an issue where the FPS is not 'limited' resulting my game into running at superspeed. Is there any frame limiter built in? I might be looking over it.

Project license?

I've really been enjoying looking through coffee-gb's code recently. It's been a huge help in drawing inspiration for a Game Boy emulator that I'm currently working on, as the documents linked in the README are great, and your own code is very understandable.

What I'm wondering is, is coffee-gb's source code released under any particular license?

Whatever the answer, thanks for your work on this project!

Permission request

Can I get permission to include and modify this emulator into one of my own projects (it is an minecraft mod)? (I will include credits in the mcmod.info file, curseforge page and github page)

Update README with current usage (flags)

Hey, the usage printed out on the 1.0.0 jar has more info than the README:

Usage:
java -jar coffee-gb.jar [OPTIONS] ROM_FILE

Available options:
  -d  --force-dmg                Emulate classic GB (DMG) for universal ROMs
  -c  --force-cgb                Emulate color GB (CGB) for all ROMs
  -b  --use-bootstrap            Start with the GB bootstrap
  -db --disable-battery-saves    Disable battery saves
      --debug                    Enable debug console
      --headless                 Start in the headless mode

.jar GUI?

is there or can you make a gui for the .jar in the releases?

i can’t use terminal

Map y to "z" for qwertz users

Basically, at the bottom keyboard row I have y x c and not z x c like you.

I would have to put my hands in a weird position if y isn't mapped to z too.

Build instructions

hey, i am not into java that much but i need to build this, can you add how i could build this? Thanks

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.