I discuss my progress on my project to write an NES emulator in java. This is largely an educational project. I wanted to learn more about how hardware is emulated, how hardware is tied together in these small computers, and I wanted to learn more about assembly. The source code for the project is open source and is being released here: lambnes google code page
Saturday, March 26, 2011
0.0.1
you may be interested to know that I have released version 0.0.1 of my NES emulator: lambnes. It isn't quite perfect, and it doesn't yet have sound, but it is able to play Balloon Fight pretty accurately.
Wednesday, March 9, 2011
I finally decided to do some further testing of the CPU by running one of the test roms that are around. I used nestest. This was insanely helpful. I fixed over a dozen CPU bugs that would have been insanely difficult to track down and fix if I had used a standard rom like super mario bros. or balloon fight. This fixed the strange pattern table behavior noted in comments on the previous post.
The NES has two pattern tables and there are bits in one of the PPU control registers that you set in order to tell the PPU which pattern table to use for sprites and which one to use for background tiles. It looked like I was ignoring the bit for the background pattern table because I was pulling the background tiles from the sprite pattern table, but when I looked in the logs I saw multiple writes to the PPU control register. One that put told it to use the right pattern table for the background, but around a dozen others that told it to use the same pattern table for background tiles as for sprite tiles.
I guessed that this was due to CPU bugs and it turns out I was right. Correcting the majority of the CPU issues corrected that issue and has made the PPU much easier to debug. I really should have done it much sooner. Having proper test cases is important. I tried to test extensively as I was writing, but I was hampered by my limited knowledge of the 6502 processor. Thankfully, more knowledgable individuals had created a very robust set of tests that allowed me to fix most if not all of my CPU bugs.
I've also fixed a couple of the PPU bugs. It used to have vertical hold issues -- the image looped. That's been fixed. I've also implemented a sort of half-assed implementation of the controllers.
Ought to be able to correct the remaining issues with the PPU and the controllers pretty quickly now.
The NES has two pattern tables and there are bits in one of the PPU control registers that you set in order to tell the PPU which pattern table to use for sprites and which one to use for background tiles. It looked like I was ignoring the bit for the background pattern table because I was pulling the background tiles from the sprite pattern table, but when I looked in the logs I saw multiple writes to the PPU control register. One that put told it to use the right pattern table for the background, but around a dozen others that told it to use the same pattern table for background tiles as for sprite tiles.
I guessed that this was due to CPU bugs and it turns out I was right. Correcting the majority of the CPU issues corrected that issue and has made the PPU much easier to debug. I really should have done it much sooner. Having proper test cases is important. I tried to test extensively as I was writing, but I was hampered by my limited knowledge of the 6502 processor. Thankfully, more knowledgable individuals had created a very robust set of tests that allowed me to fix most if not all of my CPU bugs.
I've also fixed a couple of the PPU bugs. It used to have vertical hold issues -- the image looped. That's been fixed. I've also implemented a sort of half-assed implementation of the controllers.
Ought to be able to correct the remaining issues with the PPU and the controllers pretty quickly now.
Subscribe to:
Posts (Atom)