With the emulator working on for a few cartridge games such as Tetris, Pokemon Golf and Pokemon Red.
I’ve decided that I now need some sound, and have change it from rendering in a GLUT window to a SDL window since it supports cross platform audio as well.
Now I just need to find out what an envelope is when it comes to sound, and then the next step after this is making making a Gameboy with an FPGA.
Recently I had the urge to play Pokemon Red, however my Gameboy is no longer working, a problem I have yet to diagnose, as replacing the RAM didn’t solve the problem.
So I decided without falling back on buying a new Gameboy, I’ll make one.
Having written an operating system in assembly before, and my playing around with microcontrollers, the concept is simple.
All I required was some informations on the clock timings, and when the vertical sync happens.
There is plenty of documentation on the GB, my favourite of which is the Gameboy CPU Manual since it had a breakdown of the opcodes and registers as well as memory addresses.
After setting up a large switch statement to handle the opcodes, I began by running Pokemon Red, which gave me the initial NINTENDO logo before getting stuck in a loop. After a bit of debugging, it turned out one of my opcodes was functioning wrong (I should have wrote a unit test for all of them).
Using GLUT I was able to read the part of memory where the LCD output gets drawn to and render it.
After some tweaking around with sprites, I finally got the Pokemon to show on the title image. I have yet to setup input so I cannot progress beyond this screen.
I’m starting to wonder if I can make an attachment to my iPhone for the cartridge to plug into so I can play it and other games.