Approaches to emulating Classic GB on the NES

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Re: Approaches to emulating Classic GB on the NES

Post by Shiru »

No, NES only have 2K RAM and 2K VRAM, which is four times less than GB has. It could have any amount of extra RAM and VRAM on cartridge, though. Existing mappers allows up to 32K for both (in 4K or 8K pieces, with paging).
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Approaches to emulating Classic GB on the NES

Post by tokumaru »

org wrote:Not sure you can even emulate it on NES, since GB use different memory mapping and RAM size.
It's definitely possible. Doesn't a PC have different memory mapping from that of the GB? By emulating the CPU you can always check which addresses are accessed and reroute them as necessary. RAM size can be handled with extra RAM on the cart, which is supported by current ROM formats.
NES just have not enough RAM to emulate 8+8 KB of GameBoy's RAM and VRAM.
The NES can have more than 8KB of VRAM if you use CHR-RAM, but you'd probably need even more space to double-buffer everything, since the mulator won't be fast enough to perform all updates necessary from one frame to the next. It's doable, it's just slow.

What I'm really not sure is whether using the PPU features directly would work reasonably well for a decent number of games, because there are 3 very significant incompatibilities:
1. There's no way to mask the sides of the background, so you're going to see garbage tiles;
2. The NES can only display 8 sprites per scanline, while the GB can do 10, so there might be some additional flickering;
3. The NES will not be able to properly overlap the window on top of the background;

To help with problem number 1, you could maybe assign all black palettes the the tiles that should be outside of the visible area and mask *most* of the garbage, but that would get in the way of treating the 32x30 name table as if it were 32x32 (which requires all palettes to look the same). Mid screen scroll changes also would ruin this solution.

Flickering is not such a big issue, we're used to flickering sprites. There could be a few games that use sprites for static objects that could look weird when flickering, but I don't expect that to happen very often.

The window is also a big issue, but most games I can think of use it like a background scroll split, and don't really require actual overlapping of the layers. Some games certainly do though, and those will look slightly broken.

If this approach is used, the overhead will be all in emulating the CPU and the memory map, and we'd get better performance, but there would be a few graphical issues. To get a perfectly clean display, you'd have to emulate the VRAM in PRG-RAM and periodically render the entire screen in software, which would be significantly slower!
Memblers wrote:This thread reminded me of an emulation approach I thought of a while back, if you want to hear my weird mapper-assisted idea.
Mapper assistance is cool and all, but if you're gonna go that route you might as well go all the way and put an entire Game Boy in the cartridge.
I always thought a Colecovision emu for NES would be amusing
I don't know how I'd approach the coloring of the background in that one. Each tile can have 2 colors per line, and the mapper can manipulate the attributes per tile, but you can't really predict or expect that all 2 color combinations will fit in the limited number of palettes the NES has.
Also funny to note in this thread, is that the CopyNES debugger "Microbug" emulates a 6502 on the 6502. It's pretty nifty to see it in action.
I didn't know that. Sounds interesting.
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Approaches to emulating Classic GB on the NES

Post by orlaisadog »

Bump
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Approaches to emulating Classic GB on the NES

Post by tokumaru »

Please don't bump threads if you don't have anything to add.
Post Reply