drhelius / Gearsystem

Sega Master System / Game Gear / SG-1000 emulator for macOS, Windows, Linux, BSD and RetroArch.
https://x.com/drhelius
GNU General Public License v3.0
250 stars 45 forks source link

Impossible jp instruction #34

Closed WaferMouse closed 3 years ago

WaferMouse commented 3 years ago

We found this when trying to reverse and fix the new GG Aleste game, hopefully the image speaks for itself. It looks as though somehow data got duplicated. This isn't just the debugger, either, the emulator actually jumps there. We found this bug because we were hacking Gearsystem with some primitive logging functions to figure out where/why the PC was jumping to RAM, and I've confirmed the same behavior in the latest stock release. debug1

drhelius commented 3 years ago

Thanks for reporting!

It's probably due to the protection or the custom mapper in the game that is tricking the emulator. I'm not going to participate in a commercial rom hacking but if you share the rom I can check if there is a bug in the emulator.

drhelius commented 3 years ago

Looking at the image I can see a simple explanation without being a bug in the emulator. In a first pass, the emulator goes through 00:037D, 00:0380, 00:0381 normally and without issues, later and incorrectly the game jumps to 00:037F, then the emulator interprets it as a JP to RAM.

WaferMouse commented 3 years ago

I've just confirmed that using Emulicious and you're absolutely on the money. My apologies, no bug here, at least not with your code :)