PPU Palette Mapping (NES to Vs. System)

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
Goose2k
Posts: 207
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

PPU Palette Mapping (NES to Vs. System)

Post by Goose2k » Thu Nov 26, 2020 6:03 pm

I want to add settings to my game to support different versions of the NES PPU (specifically for the Vs. system):

http://wiki.nesdev.com/w/index.php/PPU_palettes

PPU RP2C04-0001 to 0004

Has anyone built a mapping/lookup table for mapping for PPU 2C02 colors to RP2C04 colors?

For instance, when you want color "0x00" (dark grey), instead use "0x09" (dark grey on RP2C04-0001). I can do this manually myself, but figured someone may have done it already.

lidnariq
Posts: 10250
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: PPU Palette Mapping (NES to Vs. System)

Post by lidnariq » Thu Nov 26, 2020 6:20 pm

I haven't already written the lookup, but as you've observed it's not hard to map 2C04 colors to 2C03 colors.

But you might wish to do something more sophisticated given that the 2C03 doesn't match the 2C02 all that closely, possibly taking advantage of the 2C04's extra darker colors and greys.

Note that supporting the Vs. System requires more than just changing the palette.

User avatar
Goose2k
Posts: 207
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Goose2k » Thu Nov 26, 2020 6:52 pm

lidnariq wrote:
Thu Nov 26, 2020 6:20 pm
Note that supporting the Vs. System requires more than just changing the palette.
Were you thinking of something in particular? From what I can tell, the game already runs fine (other than the palette issues), but I'm very new to this system:

https://twitter.com/Duey68726260/status ... 0129932290

I have this list of quality of life features though to make it feel more "authentic" (I assume you are talking about this kind of thing):
  • No static screens (to avoid burn in; i guess not totally unique, but more common on an arcade cab).
  • Expectation that input for both p1 and p2 work as the "primary" player.
  • Checking for credits/coins.
  • Using dip switches to adjust settings/difficulty.
  • Using dip switches to adjust palette (as discussed above).
  • Using "number" keys to choose modes.

User avatar
Quietust
Posts: 1685
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Quietust » Thu Nov 26, 2020 7:52 pm

EDIT: Disregard this message.
Last edited by Quietust on Thu Nov 26, 2020 8:26 pm, edited 1 time in total.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
Goose2k
Posts: 207
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Goose2k » Thu Nov 26, 2020 8:02 pm

Quietust wrote:
Thu Nov 26, 2020 7:52 pm
Remapping the colors is certainly an option, but for optimum accuracy it's probably best to just embed the actual palettes in your emulator, since unlike NTSC and PAL, the Vs. PPU palettes are RGB and thus totally unambiguous. Granted, they're RGB333 so you'll need to properly convert them to RGB888 first, but that's pretty straightforward (0/1/2/3/4/5/6/7 -> 00/24/49/6D/92/B6/DB/FF).
Sorry, to be clear I am running on actual Vs hardware (not emulator).

lidnariq
Posts: 10250
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: PPU Palette Mapping (NES to Vs. System)

Post by lidnariq » Thu Nov 26, 2020 8:10 pm

Goose2k wrote:
Thu Nov 26, 2020 6:52 pm
Were you thinking of something in particular?
If the game runs on the second screen (on DualSystems) or only screen (on UniSystems), you must read from $4017 at least once a second. Maybe your read code already does that, but some one-player games don't.

You don't really have "start" and "select" buttons; instead you have a "1 player" through "4 player" buttons, and they're in a less convenient place.

Some NES games rely on specific nametable mirroring; on the Vs. System you always have all four screens and can't change that. Your game appears to just run on a single screen, so that's fine.

I suppose other Vs. UniSystem games just don't use interrupts, so I guess you don't need to change the values you write to $4017

If you use the greyscale or emphasis bits (in PPUMASK) ever, those do something very different in the 2C04.

Other than those, I agree it's almost entirely just a "nice to have" list.


If you use the $2D and $3D greys, you may wish a palette lookup that explicitly uses the extra greys on the 2C04.

User avatar
Quietust
Posts: 1685
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Quietust » Thu Nov 26, 2020 8:25 pm

Goose2k wrote:
Thu Nov 26, 2020 8:02 pm
Sorry, to be clear I am running on actual Vs hardware (not emulator).
Ah, disregard my comment then - I missed the bit about this being for a game, and I misunderstood the additional remarks about "supporting the Vs. System".
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
Goose2k
Posts: 207
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Goose2k » Fri Nov 27, 2020 10:41 am

lidnariq wrote:
Thu Nov 26, 2020 8:10 pm
Goose2k wrote:
Thu Nov 26, 2020 6:52 pm
Were you thinking of something in particular?
If the game runs on the second screen (on DualSystems) or only screen (on UniSystems), you must read from $4017 at least once a second. Maybe your read code already does that, but some one-player games don't.

You don't really have "start" and "select" buttons; instead you have a "1 player" through "4 player" buttons, and they're in a less convenient place.

Some NES games rely on specific nametable mirroring; on the Vs. System you always have all four screens and can't change that. Your game appears to just run on a single screen, so that's fine.

I suppose other Vs. UniSystem games just don't use interrupts, so I guess you don't need to change the values you write to $4017

If you use the greyscale or emphasis bits (in PPUMASK) ever, those do something very different in the 2C04.

Other than those, I agree it's almost entirely just a "nice to have" list.


If you use the $2D and $3D greys, you may wish a palette lookup that explicitly uses the extra greys on the 2C04.
Thanks for that info. I think I may have just got lucky with my game dodging those issues :)
Goose2k wrote:
Thu Nov 26, 2020 6:03 pm
Has anyone built a mapping/lookup table for mapping for PPU 2C02 colors to RP2C04 colors?
FYI: I think what I found I was looking for: Nope, this wasn't want I needed.

http://forums.nesdev.com/viewtopic.php?p=93718#p93718
Last edited by Goose2k on Fri Nov 27, 2020 1:43 pm, edited 1 time in total.

User avatar
Dwedit
Posts: 4410
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Dwedit » Fri Nov 27, 2020 11:03 am

PocketNES has vs palette mapping tables which will map the VS palette color to the NES palette color. The tables are left over from the early 2000s and may not be all that accurate though.

Code: Select all

vs_palmaps:
@freedomforce/gradius/hoogansalley/pinball/platoon
	.byte 0x35,0x3f,0x16,0x22,0x1c,0x09,0x30,0x15,0x30,0x00,0x27,0x05,0x04,0x28,0x08,0x30
	.byte 0x21,0x3f,0x3f,0x3f,0x3c,0x32,0x36,0x12,0x3f,0x2b,0x3f,0x3f,0x3f,0x3f,0x24,0x01
	.byte 0x3f,0x31,0x3f,0x2a,0x2c,0x0c,0x3f,0x14,0x3f,0x07,0x34,0x06,0x3f,0x02,0x26,0x0f
	.byte 0x3f,0x19,0x10,0x0a,0x3f,0x3f,0x37,0x17,0x3f,0x11,0x1a,0x3f,0x3f,0x25,0x18,0x3f
@castlevania/golf/machrider/slalom
	.byte 0x0f,0x27,0x18,0x3f,0x3f,0x25,0x3f,0x34,0x16,0x13,0x3f,0x34,0x20,0x23,0x3f,0x0b
	.byte 0x3f,0x23,0x06,0x3f,0x1b,0x27,0x3f,0x22,0x3f,0x24,0x3f,0x3f,0x32,0x08,0x3f,0x03
	.byte 0x3f,0x37,0x26,0x33,0x11,0x3f,0x10,0x22,0x14,0x3f,0x00,0x09,0x12,0x0f,0x3f,0x30
	.byte 0x3f,0x3f,0x2a,0x17,0x0c,0x01,0x15,0x19,0x3f,0x2c,0x07,0x37,0x3f,0x05,0x3f,0x3f
@excitebike/excitebike-alt (probably not complete yet)
	.byte 0x3f,0x3f,0x1c,0x3f,0x1a,0x30,0x01,0x07,0x02,0x3f,0x3f,0x30,0x3f,0x3f,0x3f,0x30
	.byte 0x32,0x1c,0x11,0x12,0x3f,0x18,0x17,0x26,0x0c,0x3f,0x3f,0x02,0x16,0x3f,0x3f,0x21
	.byte 0x3f,0x3f,0x0f,0x37,0x3f,0x28,0x27,0x3f,0x29,0x3f,0x21,0x3f,0x11,0x3f,0x0f,0x3f
	.byte 0x31,0x3f,0x3f,0x06,0x0f,0x2a,0x30,0x3f,0x3f,0x28,0x3f,0x3f,0x13,0x3f,0x3f,0x3f
@battlecity/clucluland/iceclimber/smb/starluster/topgun?
	.byte 0x18,0x3f,0x1c,0x3f,0x3f,0x3f,0x01,0x17,0x10,0x3f,0x2a,0x3f,0x36,0x37,0x1a,0x39
	.byte 0x25,0x3f,0x12,0x3f,0x0f,0x3f,0x3f,0x26,0x3f,0x1b,0x22,0x19,0x04,0x0f,0x3a,0x21
	.byte 0x3f,0x0a,0x07,0x06,0x13,0x3f,0x00,0x15,0x0c,0x3f,0x11,0x3f,0x3f,0x38,0x3f,0x3f
	.byte 0x3f,0x30,0x07,0x16,0x3f,0x3b,0x30,0x3c,0x0f,0x27,0x3f,0x31,0x29,0x3f,0x11,0x09
@drmario/goonies/soccer
	.byte 0x0f,0x3f,0x3f,0x10,0x1a,0x30,0x31,0x3f,0x01,0x0f,0x36,0x3f,0x15,0x3f,0x3f,0x3c
	.byte 0x3f,0x3f,0x3f,0x12,0x19,0x18,0x17,0x3f,0x00,0x3f,0x3f,0x02,0x16,0x3f,0x3f,0x3f
	.byte 0x3f,0x3f,0x3f,0x37,0x3f,0x27,0x26,0x20,0x3f,0x04,0x22,0x3f,0x11,0x3f,0x3f,0x3f
	.byte 0x2c,0x3f,0x3f,0x3f,0x07,0x2a,0x28,0x3f,0x0a,0x3f,0x32,0x38,0x13,0x3f,0x3f,0x0c
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

lidnariq
Posts: 10250
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: PPU Palette Mapping (NES to Vs. System)

Post by lidnariq » Fri Nov 27, 2020 12:04 pm

Goose2k wrote:
Fri Nov 27, 2020 10:41 am
Thanks for that info. I think I may have just got lucky with my game dodging those issues :)
well, other than the select button...

User avatar
Goose2k
Posts: 207
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Goose2k » Fri Nov 27, 2020 1:16 pm

I've started building the mapping tables based on the data here: http://wiki.nesdev.com/w/index.php/PPU_palettes

I am not making use of additional colors available in RGB units. In cases where the exact matching color isn't present, I will put an asterisk* and details of what I mapped to what.

I will post them all here as I build them:

Code: Select all

NES PPU to RP2C04-0001 (Vs Baseball, Freedom Force, Gradius, Hogan's Alley, Mach Rider, Pinball, and Platoon):

$9,$1f,$2d,$35,$c,$b,$2b,$29,$e,$5,$33,$3a,$25,$1a,$1a,$1a
$32,$39,$17,$2c,$27,$7,$2,$37,$3e,$31,$3a,$26,$4,$1a,$1a,$1a
$8,$10,$3,$1,$1e,$3d,$2e,$a,$d,$13,$23,$19,$24,$1d,$1a,$1a
$8,$21,$15,$22,$2a,$0,$16,$36,$3c,$34,$3f,$19,$14,$1c,$1a,$1a

*Mapping 772 to 770 (772 to does not exist on this PPU).

Code: Select all

NES PPU to RP2C04-0002 (Castlevania, Mach Rider (Endurance Course), Raid on Bungeling Bay, Slalom, Soccer, Stroke & Match Golf (both versions), and Wrecking Crew):

$2a,$35,$27,$1f,$20,$3d,$12,$3a,$1d,$2b,$3e,$f,$34,$0,$0,$0
$26,$24,$2c,$9,$28,$36,$8,$33,$2,$37,$f,$14,$6,$0,$0,$0
$c,$11,$17,$d,$19,$5,$22,$1,$2e,$15,$32,$1b,$39,$3f,$0,$0
$c,$7,$1c,$23,$b,$3c,$21,$3b,$a,$3,$4,$1b,$e,$13,$0,$0

*Mapping 772 to 770 (772 to does not exist on this PPU).

Code: Select all

NES PPU to RP2C04-0003 (Balloon Fight, Dr. Mario, Excitebike (US), Goonies, and Soccer):

$18,$8,$1b,$19,$29,$12,$1d,$34,$b,$7,$38,$4,$3f,$9,$9,$9
$3,$2c,$13,$3c,$0,$c,$1c,$16,$15,$14,$4,$17,$11,$9,$9,$9
$5,$2a,$10,$20,$2b,$1,$26,$25,$36,$28,$35,$3d,$30,$2d,$9,$9
$5,$6,$3a,$33,$1e,$1f,$a,$23,$3b,$32,$2,$3d,$f,$d,$9,$9

*Mapping 772 to 770 (772 to does not exist on this PPU).

Code: Select all

NES PPU to RP2C04-0004 (Clu Clu Land, Excitebike (Japan), Ice Climber (both versions), and Super Mario Bros.):

$26,$6,$23,$1,$1c,$20,$16,$22,$32,$3f,$21,$e,$28,$4,$4,$4
$8,$2a,$12,$24,$25,$27,$33,$7,$0,$1b,$e,$19,$2,$4,$4,$4
$31,$1f,$1a,$3a,$2f,$10,$17,$39,$3,$3c,$a,$35,$3e,$2e,$4,$4
$31,$3b,$3d,$30,$13,$5,$c,$d,$2d,$f,$1e,$35,$37,$29,$4,$4

*Mapping 772 to 770 (772 to does not exist on this PPU).
Last edited by Goose2k on Sat Dec 12, 2020 12:14 am, edited 2 times in total.

Pokun
Posts: 1751
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: PPU Palette Mapping (NES to Vs. System)

Post by Pokun » Fri Nov 27, 2020 1:31 pm

That about PPUMASK is true for 2C03 and 2C05 as well I think? I remember hearing that the Sharp C1 or the Titler would show a white screen on games that apply all 3 colour emphasis bits at the same time. So it's not only for an arcade version of the game that you want to be aware of those differences.

And if you want to support the arcade stuff like coin insert you might want to support the service button (button for inserting coins without counting them to the bookkeeping, so that engineers can test the game when servicing the machine) as well. And this happens to be the same bit used for the microphone, meaning a Famicom user could access this button by blowing into the mic.

User avatar
Goose2k
Posts: 207
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Goose2k » Fri Nov 27, 2020 1:44 pm

Pokun wrote:
Fri Nov 27, 2020 1:31 pm
That about PPUMASK is true for 2C03 and 2C05 as well I think? I remember hearing that the Sharp C1 or the Titler would show a white screen on games that apply all 3 colour emphasis bits at the same time. So it's not only for an arcade version of the game that you want to be aware of those differences.
Thank you! My game doesn't use color emphasis at all though. :D
Pokun wrote:
Fri Nov 27, 2020 1:31 pm
And if you want to support the arcade stuff like coin insert you might want to support the service button (button for inserting coins without counting them to the bookkeeping, so that engineers can test the game when servicing the machine) as well. And this happens to be the same bit used for the microphone, meaning a Famicom user could access this button by blowing into the mic.
Good point. I will look into that as well.

tepples
Posts: 22281
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by tepples » Fri Nov 27, 2020 5:39 pm

Other things to watch for when adding coin mode:
  • The coin buttons in bits 6-5 of $4016 stay pressed for about 2 to 3 frames at a time. In order not to miss coins, make sure to read these bits even during lag frames or blank screen transitions. Also take care to handle a coin inserted into both slots at once, or a coin that pushes the switch too long (because it's on a string).
  • The Vs. System has an output for a coin counter. Some cabinets may support, for example, time-of-day revenue analytics. When a coin is recognized, make sure to write $01 to $4020, then write $00 to $4020 three to five frames later.

User avatar
Goose2k
Posts: 207
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

Re: PPU Palette Mapping (NES to Vs. System)

Post by Goose2k » Fri Nov 27, 2020 7:26 pm

tepples wrote:
Fri Nov 27, 2020 5:39 pm
Other things to watch for when adding coin mode:
  • The coin buttons in bits 6-5 of $4016 stay pressed for about 2 to 3 frames at a time.
Do I need to avoid counting the same coin multiple times? Or does the flag get cleared when its read or something? Or should I be manually clearing the flag?

Post Reply