|
The problem here is that your code is simply copying the vertical/horizontal name table select bits ($2000.0 & 2000.1) into your final vram address. This is the formula for a full 4-screen playfield implementation, but you won't get any mirroring out of it.
What you'd have to do is mask out one of the vertical/horizontal name table select bits in order to implement the desired mirroring scheme. For example, mask out the horizontal NT select bit for horizontal mirroring.
I would highly recommend that you implement a look-up table for the 4 possibly selectable name tables. Use the vertical/horizontal name table select value as a 2-bit index into it. The table will naturally contain your PPU's current name table mirroring configuration (i.e., (0,1,0,1) for vertical, (0,0,1,1) for horizontal, (0,1,2,3) for 4 screen, (0,0,0,0) for one screen, etc.).
The beauty of the mirroring lookup table is that it allows you to maintain as many name tables as you want, provided your game has hardware to do so. Games which use more than 4k of RAM for name tables (like for maintaining multiple status screens), would be a cinch to implement into your emulator. Of course, I think the only game that ever used an elaborate name table mapping scheme was Top Gun (all the others fall into well documented categories for NT mapping/mirroring).
- BT
|