mGBA Blog
mgba.io · Company blog · on HN since 2015
The developer blog for mGBA, a Game Boy Advance emulator, covering emulation accuracy, hard-to-emulate bugs, and anti-emulation measures in games.
What HN saysHN commenters link it as a source on GBA and NES anti-emulation tricks and on how timing-sensitive copy protection forces cycle-accurate emulation.
22HN people shared it
10linked it in comments
19stories submitted
905story points
2 years agolast shared
2015people per year2026
Most-shared posts
- 1“Holy Grail” Bugs in Emulation7 people · 7 points · first shared 2017 · discussion on HN
- 2Revisiting “Holy Grail” Bugs in Emulation4 people · 3 points · first shared 2018 · discussion on HN
- 3The Infinite Loop That Wasn't3 people · 411 points · first shared 2020 · 35 comments on HN
- 4“Holy Grail” Bugs in Emulation, Part 23 people · 128 points · first shared 2017 · 30 comments on HN
- 5Classic NES Series Anti-Emulation Measures2 people · 215 points · first shared 2017 · 75 comments on HN
- 6mGBA – Modern Gameboy Advance Emulator2 people · 5 points · first shared 2016 · discussion on HN
- 7Emulation Accuracy, Speed, and Optimization2 people · 3 points · first shared 2017 · discussion on HN
- 8Classic nes2 people · first shared 2017
- 9The Importance of Fuzzing Emulators1 people · 97 points · first shared 2016 · 12 comments on HN
- 10MGBA: Dumping the Undumped1 people · 25 points · first shared 2015 · 1 comments on HN
- 11mGBA Adds Game Boy Support1 people · 4 points · first shared 2016 · discussion on HN
- 12MGBA 0.9.01 people · 3 points · first shared 2021 · discussion on HN
- 13Cracking the GBA BIOS1 people · 3 points · first shared 2017 · discussion on HN
- 14MGBA 0.10.0: Lua scripting support1 people · 1 points · first shared 2022 · discussion on HN
What HN people wrote when they linked it
mattbee · 2024-06-08
The simplest trick for detecting old ARM emulation - ISTR was used on some Gameboy Advance copy protection: store a booby-trap instruction at PC+4 (i.e. the very next one). A real ARM has a pipeline that reads PC+8, while decoding PC+4 and while executing at PC. So the newly-stored instruction should have no effect. An emulator (which didn't emulate the hardware pipeline) would execute it.
edit: described in more detail here, among other emulation-busting measures from 2004 https://mgba.io//2014/12/28/classic-nes/
Zancarius · 2017-04-17
Did you ever see this link [1] regarding the GBA anti-emulation features some time back? It's a bit tangential and slightly off-topic, but it might be of interest if you haven't!
[1] https://mgba.io//2014/12/28/classic-nes/
BearOso · 2016-10-25
Just so everyone knows, that GBA emulator is mGBA (https://mGBA.io)
matheusmoreira · 2021-08-07
> also in later years I suspect made the job of emulator writers something of a misery
Most certainly. These tricks force developers to emulate systems down to individual cycles in order to get the timing right because getting them wrong will result in visual glitches or worse.
https://mgba.io/2017/04/30/emulation-accuracy/
https://mgba.io/2017/07/31/holy-grail-bugs-2/
Byuu, the author of bsnes, wrote some very detailed articles about this as well. I can't seem to find them anymore though. His domain has also been excluded from the internet archive for some reason.
duskwuff · 2020-01-22
> A given game might be a hundred hours long and only exercise certain functionality at minutes 5, 37 and 60.
An infamous bug of that variety exists in the SNES game "Speedy Gonzales - Los Gatos Bandidos", where one specific element in one level would freeze the game on most emulators due to a really subtle hardware emulation issue.
https://mgba.io/2017/07/31/holy-grail-bugs-2/#speedy-gonzales-los-gato…
> Also, none of that automation you just did will work w/the actual hardware.
You might be surprised. Consider what the TASBot team has done with the NES, SNES, and various other consoles -- http://tasvideos.org/TASBot.html
djmips · 2019-12-17
Writing a game boy emulator is like climbing Everest now. But be wary of the crevasses!
https://mgba.io/2018/03/09/holy-grail-bugs-revisited/#the-phantom-of-p…
jdietrich · 2018-07-11
Implementing a well-documented spec is fairly mundane, but figuring out that spec on your own is a fascinating puzzle. Emulators are full of curious little edge cases that can drive people to the point of obsession.
https://mgba.io/2017/05/29/holy-grail-bugs/
near · 2018-05-23
The Game Boy is only simple in the early stages of emulator development.
You find quickly that it is full of excruciatingly complex edge cases that aren't documented, and aren't well understood by anyone.
We're still making significant progress to this day on it.
And even in the early stages, the Z80-like Sharp LR35902 is quite a hassle. If you want an educational project, consider an NES emulator instead. Still has lots of edge cases, but the documentation and reverse engineering work is far ahead of the Game Boy.
Some reading if you like:
https://mgba.io/2017/05/29/holy-grail-bugs/#pinball-fantasies
https://mgba.io/2018/03/09/holy-grail-bugs-revisited/#the-phantom-of-p…
MBCook · 2017-08-27
Part one can be found here: https://mgba.io/2017/05/29/holy-grail-bugs/
mikepurvis · 2021-04-11
This would be less about a user peripheral like the gamepad (which is obviously going to be read out exactly once per frame anyway) and more about getting subtle interactions between the CPU, memory/DMA, and specialized systems for graphics/audio correct. And not just correct after thousands of hours of work to smoke out the exact sources of specific title bugs, but correct essentially for free.
See for example the tale of an absolutely wild mGBA investigation that was posted here a while ago:
"What happens if an interrupt gets raised between prefetch and the data load? Will it start prefetching the interrupt vector before the invalid memory access? I quickly mocked this up in mGBA, turned on interrupts in the test ROM, and sure enough it broke out of the loop. So I tried the same test ROM on hardware and…it did not break out of the loop. So there goes that theory. Eventually I realized something. You saw that asterisk earlier I’m sure, so yes, there is one thing that can happen in between prefetch and the memory access, but only if the memory bus gets queried by something other than the CPU between the prefetch and invalid memory access."
https://mgba.io/2020/01/25/infinite-loop-holy-grail/