Git Product home page Git Product logo

mizu's Introduction

Mizu

Build status codecov crate.io dependency status

Mizu is an accurate Gameboy emulator built in Rust.

Features

  • Emulating The original gameboy (DMG) and gameboy color hardware.
  • Passing most hardware tests (see TESTING.md).
  • Bettery save support.
  • Control SRAM save file and ability to disable SRAM save.
  • Accurate RTC emulation for MBC3 mapper.
  • Accurate APU emulation with 48KHz audio.
  • SFML gui front-end.
  • Robust testing framework for continous testing.
  • Easily change emulation speed.
  • Functional mappers:
    • NoMapper
    • MBC1
    • MBC2
    • MBC3
    • MBC5
  • Printer emulation
  • Save states

Controls

The SFML front-end provide these keyboard bindings:

Gameboy

Key Gameboy
J B
K A
U Select
I Start
W Up
S Down
A Left
D Right

Extra

Key Function
Enter A+B+Select+Start*
+ Increase 5 to FPS**
- Recude 5 from FPS**
P Open Printer
(NUM1~NUM0) Save state
Shift + (NUM1~NUM0) Load state
C Output All audio channels (default)
V Output Pulse1 audio channel only
B Output Pulse2 audio channel only
N Output Wave audio channel only
M Output Noise audio channel only

* I made this because in Zelda: Link's awakening you need to press all of these buttons on the same frame to bring the save menu, which is annoying.

** FPS here is not the same with normal games FPS, where low FPS just makes the game laggy, here FPS control the emulation speed. Normally it will run on 60 FPS. If the user set FPS to 30 it will emulate in half the speed, this include audio, and CPU emulation.

Printer window keys

Key Function
C Clear current image buffer
S Save image buffer to file

Printer

Gameboy Printer is a serial device that can be connected to the gameboy and used by some cartridges to print images. Popular cartidges that uses it are:

  • Gameboy Camera.
  • Zelda: Link's Awakening DX (to print images from the album).
  • Pokemon (several versions) (to print pokemon info from the Pokedex).

The printer can be opened by pressing the P key.

The printer emulation allows to save the printed images into disk. The window will only show 160x144 pixels, but the image is scrollable.

Save states

Save state is a very useful features emulators should have, it allows to save the state of the whole emulator at any point in time and be loaded any time later. mizu's save states files are saved in these folders:

Linux:   /home/<user>/.local/share/mizu/saved_states
Windows: C:\Users\<user>\AppData\Local\Amjad50\Mizu\data\saved_states
macOS:   /Users/<user>/Library/Application Support/Amjad50.Mizu/saved_states

The structure of the save file is at version 2:

Offset Size Field
0x00 4 MAGIC: "MST\xee" (4D 53 54 EE)
0x04 8 save state file version
0x0C 32 cartridge sha256 hash
0x2C variable zstd default level compressed saved state

There is no migrations between file versions (except from 1 to 2), that means that a file saved from a past version of the emulator will not be able to be loaded in a future version of the emulator. (If any suggestions on how we can achieve this, you are welcome to open a PR).

The hash is used to make sure that we are loading for the same game.

The zstd compression appeared in version 2, that is the reason we can load version s by loading with decompression. The compressed content, is the content we get by using the save_state library.

Building and Installation

For installing or building mizu we would use cargo.

Building

If you want to use the development version of mizu you can build the project yourself. After downloading/cloning the repository, it can be build with:

$ cargo build

With release option:

$ cargo build --release

Installing

If you want to use the latest stable version from crates.io:

$ cargo install mizu

Yet another gameboy emulator?

Why not?. it is fun and educational, but even though I'm planning to make it as accurate as I can. If you want to see cool emulators, check my previous work Plastic.

References

General Gameboy

CPU instructions

Debugging and testing

mizu's People

Contributors

amjad50 avatar crumblingstatue 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

Watchers

 avatar  avatar  avatar  avatar

mizu's Issues

Pass in a different path for SRAM

Right now GameBoy::new() takes a ROM path and assumes the sav is next to it with .sav suffixed.

Can we change new() to take something like sav: Option<P>? Not all LSDJ sav files are stored next to a .gb with the same name.

Audio Panic on Windows

Hi team,

trying to build this on a Windows machine and getting an error with the audio config that's created. It seems not every device would support the 44100 sample_rate and cpal expects that you match the output of the device that's chosen.

It seems some resampling would need to take place before the step of outputting to the cpal audio device.

GameBoy shutdown always writes sav

This is more of a nitpick, but usually after rendering out audio using the LSDJ ROM I wouldn't want the sav to be rewritten. It updates the timestamp and internally the clock time is also saved in the LSDJ SRAM.

Is it an idea to add some way to not save on shutdown?

If that's too much of a hassle I can always copy the sram to a temporary file for my usage.

Separate audio channel rendering

Hey!

I'm building a set of command-line tools for working with Little Sound Dj files (a music tracker for the gameboy). Little Sound Dj musicians often render out the channels separately and then post-process them in their software of choice.

I know very little of gameboy emulation, but I thought it'd be cool if I could leverage mizu-core to do the audio rendering. Would it be possible to get out the four separate channel streams somehow, instead of just Gameboy::audio_buffer()?

If not, maybe it's possible to add solo/mute certain channels (I'd just run the emulator four times)?

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.