Skip to content →

starting the first games

So, now that we have a rudimentary PPU, a functioning CPU, a timer and interrupts, we can try to start out first games.

Dr. Mario

The first boots of Dr. Mario wasn’t exactly looking promising.

wrongly addressed tileData – resulting in wrong VRAM data (Dr. Mario)

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:

First proper boot of Dr. Mario (still with a wrong color palette)

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: – initially playing Dr. Mario demo the wrong way
BGB – proper Dr. Mario demo

As you can see, 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! 😉

Dr. Mario – fixed by preventing invalid memory writes


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:

Tetris – initial boot problem (joypad byte all set)

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:

Tetris – proper 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.


  1. Hakim Hakim

    thank you for your tuto
    indeed shorts but very useful
    using blargg test suite saved my life
    but when i run dr mario , the demo don’t come
    any clue??

Leave a Reply