So, now that we have a rudimentary PPU, a functioning CPU, a timer and interrupts, we can try to start out first games.
The first boots of Dr. Mario wasn’t exactly looking promising.
As it turned out, after quite a bit of debugging, I was setting a wrong base address for the tileData area, that is addressed with signed values. This resulted in a garbled mess of graphics. As usual, the spotting of the bug took quite a bit of time, the actual fix was done in a few seconds, resulting in a much better image:
Since I didn’t have any controls implemented at this point, the only thing doable was to wait for the demo to kick in. Sadly, the demo wasn’t flawless either:
As you can see, q00.gb would fail to properly play the demo. It would fail after a very short period, although it’s supposed to play for quite a while. Hunting down this bug, would really take up a lot of time. I refactored my CPU, double- and triple checked my timings and interrupts. Finally I was able to pin it down to the game writing to addresses, that it isn’t allowed to write to. That’s where the MMU will come into play later on, to actually prevent the code from accessing certain memory ranges.
After that was done, Dr. Mario himself apparently felt a little bit more intelligent, and was actually able to complete his own demo! 😉
This game gave me headaches. I was briefly able to boot into other games, at least showing me some menus, garbled up graphics, or something. But Tetris only showed up this:
It turned out, because we didn’t implement controls yet, the emulator constantly thought all available buttons are pressed. Tetris especially has a reset combination (A + B + Start + Select), that will reset the cartridge. So, I was constantly resetting the game, without even knowing. After implementing controls (next chapter) Tetris finally was able to properly boot:
Super Mario Land
As it turned out, Super Mario Land would not boot at all, because it was the first game, that was above 32 kb of size, and therefore was in need of implementing memory banking.