Boards with 2 PPUs?

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

Post Reply
AzimuthFE
Posts: 17
Joined: Thu Jun 09, 2016 4:46 pm

Boards with 2 PPUs?

Post by AzimuthFE »

I have been reading documents on the PPU and its EXT pins. I gather that a second PPU can be connected to the master one to make an image instead of a plain background color. I have some questions:

What does the master PPU "do" with the 4-bit value it gets from the EXT pins?
What does the slave PPU output to its own EXT pins?
Did any commercial games actually use 2 PPUs, either to create parallax scrolling or otherwise?

Any help would be appreciated.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Boards with 2 PPUs?

Post by lidnariq »

When the register at $2000 is written with bit 6 clear:

EXT0 through EXT3 are inputs, and specify an extra 4bpp layer, chosen from the first 16 colors in the PPU palette. This layer only shows in places where both the sprite and background layers are transparent.

When that bit is instead set:

EXT0 through EXT3 are outputs, specifying the lower 4 bits of the 5 bit palette index. (bits 0,1 : color within palette entry; bits 2,3 : palette # ; missing bit 4: sprite vs tiles)


We know of no hardware that used this feature.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Boards with 2 PPUs?

Post by tepples »

The backdrop is any pixel where the background is transparent and no opaque sprite pixel is drawn. A PPU with $2000 bit 6 = 0 enters "receive EXTBG" (aka "master") mode. This replaces any backdrop color with the 4-bit color index received on the EXT pins. This can display any color in CGRAM $3F00-$3F0F and is the only way to display the colors in $3F04, $3F08, and $3F0C while rendering is enabled. The sprite colors ($3F11-$3F13, $3F15-$3F17, $3F19-$3F1B, $3F1D-$3F1F) cannot be reached through EXTBG. On the Famicom and NES, this value is fixed at 0, causing $3F00 to appear in all backdrop pixels.

A PPU with $2000 bit 6 = 1 enters "send EXTBG" (aka "slave") mode. This always draws the backdrop from $3F00 but sends the low 4 bits of the CGRAM address on the EXT pins. If these are connected to a PPU set to receive EXTBG, the receiving PPU cannot tell whether, say, $0A means background color $3F0A or sprite color $3F1A. But mods acting as an external color encoder, such as the NESRGB and Hi-Def NES, intercept PPU communication to make the PPU send EXTBG and set the palette to black background and white sprites. This way, the mod can read bit 4 from composite output and bits 3-0 from EXT.

If you're trying to wire two NTSC PPUs into one system, you have to ensure that writes to $2001 go to both PPUs at once. Otherwise, if rendering is enabled on one and not the other, they will fall out of sync by one pixel every two fields, or 30 pixels per second, because the NTSC PPU skips the resting dot between the pre-render line and line 0 in every other field if rendering is enabled but doesn't skip it if rendering is disabled.

There are two practical ways to wire them up.
  1. PPU1 sends, PPU2 receives: PPU2 generates the composite output based on its 25-color palette. PPU1 sprites appear with background palettes. If EXT0 and EXT1 are swapped with EXT2 and EXT3 between the two chips, displaying $3F04, $3F08, and $3F0C is possible for a total of 28 colors.
  2. PPU1 sends, PPU2 sends, external encoder chip: You essentially have the functionality of a PC Engine SuperGrafx. Both PPUs are set up as for NESRGB or Hi-Def NES (black background, white sprites), and the encoder receives the EXT and composite output signals from both PPUs, multiplexes them using configurable layer priority, and encodes the output as a composite, S-Video, or component (YPbPr or RGB) signal. Up to 49 colors are possible. Super NES-style color math is possible, treating PPU1 and PPU2 as sub and main screens. Color math can even be limited to specific color indexes, as in Genesis highlight/shadow mode.
You can't have both PPUs send and then mix the composite output directly because their color subcarriers may not be aligned.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Boards with 2 PPUs?

Post by tokumaru »

Having some extra hardware mix the signals sounds pretty cool, because at that point you could implement other cool enhancements, such as 8x8 attributes, more palettes, a bigger (RGB?) master palette...

The main issue then would be finding the time to update twice the amount of VRAM each frame. Things are already pretty tight with games only having to do 1 sprite DMA and scroll a single background layer, doing twice the work is completely out of question. A dual PPU setup would require some sort of generic DMA functionality in order to be usable.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Boards with 2 PPUs?

Post by lidnariq »

Once you'd added all the remainder, you'd probably call it the SuperGrafx. :)
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Boards with 2 PPUs?

Post by Bregalad »

tokumaru wrote:Having some extra hardware mix the signals sounds pretty cool, because at that point you could implement other cool enhancements, such as 8x8 attributes, more palettes, a bigger (RGB?) master palette...

The main issue then would be finding the time to update twice the amount of VRAM each frame. Things are already pretty tight with games only having to do 1 sprite DMA and scroll a single background layer, doing twice the work is completely out of question. A dual PPU setup would require some sort of generic DMA functionality in order to be usable.
Assuming a motherboard with one CPU and 2 PPUs were made, it would be hard to use sprites on the 2nd PPU, because the CPU is hardwired to write sprite-DMA to $2004. Unless another chip/register swaps between both PPUs at $2000-$3fff, in this case it'd be possible to do sprite DMA for both chips, but mapping the second chip elsewhere in the address map sounds more natural. In that natural case, the only way to get sprites on the 2nd chip is to write each sprite to its register, which is horrifying slow and won't even work properly anyway.

I don't think scrolling is much of a problem because typically only one playfield would scroll with actual level data in it. The other layer could be used for backdrop and/or text.
AzimuthFE
Posts: 17
Joined: Thu Jun 09, 2016 4:46 pm

Re: Boards with 2 PPUs?

Post by AzimuthFE »

Thank you for the interesting answers. I take it then that there were no actual applications of dual PPU systems back in the day? It's a shame since it might have meant that emulators today would have supported this setup, giving programmers an extra layer to play with :lol:
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Boards with 2 PPUs?

Post by Dwedit »

The two PPU setup has a major problem, the single cycle skip at the prerender line that happens depending on whether the PPU is on or not. It is not guaranteed to sync up on the two PPUs.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Boards with 2 PPUs?

Post by tepples »

That's what I meant by "ensure that writes to $2001 go to both PPUs at once." Or can the PPUs boot in opposite phases?
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Boards with 2 PPUs?

Post by Pokun »

The VS DualSystem uses two sets of CPU and PPU boards, but I don't know if the slave mode on the PPU is used or if they works independently in master mode.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Boards with 2 PPUs?

Post by tepples »

As far as I'm aware, RGB PPUs (2C03, 2C04, 2C05) don't have EXTBG functionality because they use the EXT pin for their RGB output. Besides, they operate independently, displaying to two different screens.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Boards with 2 PPUs?

Post by Pokun »

I see, I don't know anything else that's using Nintendo's PPU (besides PC-10 which are also using RGB PPU). I guess the pins were designed for mixing in external video or something, but ended up never being used on any hardware.
Post Reply