/gg

Primary LanguageRust

gg

WIP GameGear (and possibly Sega Master System) emulator. Most of the information I either figured out by reverse engineering the hardware and software myself or by using the excellent docs found on smspower.org. This project is messed up in some cases and should not be used as direct reference for your own implementation. I mostly implemented everything on a "fuck around and find out" basis, implementing features where needed to get things working. Also, there is no PSG support! Oh, and I used AI to generate the z80 opcode parser / jump table. :)

Demos
Sonic The Hedgehog 2 Demo Lucky Dime Caper Starring Donald Duck Demo Pac-Man Demo Earthworm Jim Demo
sonic.2.demo.0.3.mp4
donald.duck.demo.0.3.mp4
pacman.demo.0.2.mp4
earthworm.jim.demo.0.3.mp4

I would not have gotten this far without the amazing help from the helpful people over on the Emulation Development Discord server:

  • originaldave_
  • ZjoyKiLer
  • Mask of Destiny
  • and everyone else that helped along the way <3

Mandatory quote:

Layle - certified idiot — Yesterday at 9:49 PM
i am
officially an idiot

Compatibility List

Title CRC32 Status
[BIOS] Sega Game Gear (USA) (Majesco) 0ebea9d4 👌
Pac-Man (USA) b318dd37 👌
Sonic The Hedgehog 2 (U) [!] 95a18ec7 👌
Sonic & Tails (Japan) (En) 8ac0dade 👌
Sonic & Tails 2 (Japan) 496bce64 👌
Sonic Labyrinth (World) 5550173b 👌
Sonic The Hedgehog - Triple Trouble (USA, Europe, Brazil) (Beta) (1994-08-08) 80eb7cfb 👌
Lucky Dime Caper Starring Donald Duck, The (USA, Europe) 07a7815a 👌
Sonic The Hedgehog (U) (V1.0) [!] 3e31cb8c 👌
Earthworm Jim (Europe) 691ae339 🐥
Batman Returns (World) 7ac4a3ca 🐥
Ecco the Dolphin (Japan) a32eb9d5 🐥
Ecco - The Tides of Time (USA, Europe, Brazil) e2f3b203 🐥
GG Shinobi II, The ~ Shinobi II - The Silent Fury (World) 6201c694 🐥
Asterix and the Great Rescue (Europe) (En,Fr,De,Es,It) 328c5cc8 🐣
Tom and Jerry - The Movie (USA, Europe) 5cd33ff2 🐞
Shinobi (USA, Europe) 30f1c984 🐞
  • 👌: No known issues
  • 🐥: Playable with a few bugs
  • 🐣: In-Game, but only limited playability
  • 🐞: Bugged/Broken

Note: This rating is completely subjective.

Running

It is strongly recommended to run the emulator in release mode, no matter what.

cargo run --release -- --bios bios.gg --rom game.gg

It is possible to dump debug and/or trace information either to stderr or a file:

Usage: gg.exe [OPTIONS] --bios <BIOS> --rom <ROM>

Options:
  -b, --bios <BIOS>
  -r, --rom <ROM>
  -l, --lua <LUA>
  -c, --cpu-test
  -l, --log-level <LOG_LEVEL>  [default: info]
  -l, --log-to-file
  -h, --help                   Print help

Debugging

The emulator features a debugger built around egui and eframe. It is very simple and hosts the following features:

  • Memory Viewer (ROM, RAM, SRAM, VRAM, CRAM)
  • Display CPU memory address mappings (ROM / RAM banks)
  • "Resume", "Break On" and "Step" debugger controls
  • Disassembly & Trace
  • View CPU and VDP infromation such as registers
  • SDSC Debug Console

There's more features that are CLI only:

  • Lua scripting (pretick/posttick hooks with access to CPU & VDP state and memory)
  • Debug and trace logging ("debug", "trace")

Testing

Currently the Z80 implementation can be tested using ZEXDOC/ZEXALL and using the JSON unit tests provided by jsmoo. However, some features are ignored/disabled/not implemented.

ZEXDOC & ZEXALL

zexdoc is built into the emulator and can be executed by passing the --cpu-test flag.

JSON Tests

cargo test in the workspace folder will launch all unit tests. The current implementation measures only registers and RAM content. Status at the time of writing:

test result: FAILED. 1388 passed; 222 failed; 0 ignored; 0 measured; 0 filtered out; finished in 66.36s