PPU Palette Mapping (NES to Vs. System)

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

tepples
Posts: 22708
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 »

To count a coin, you need to wait for the coin button to go pressed then unpressed.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

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

Post by lidnariq »

You probably want something like "count the amount of time that the bit reads as true; if it's less than some threshold (perhaps 7 vblanks?) when it becomes 0, grant a credit"

The coin counter behavior is hopefully clear from the description on the wiki page.
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

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

Post by Goose2k »

Goose2k wrote: 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?
It seems like I do. I ended up keeping 2, 70 frame timers (one for each coin slot), which blocks incrementing the coin counter when active.

Edit: Oops, sorry didn't see your replies. Thanks guys!
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

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

Post by calima »

Get rich quick plan by placing an addictive Tetris-like coin-operated game in a public location detected ;)
tepples
Posts: 22708
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 »

So long as Arika and BPS don't catch wind of it...
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

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

Post by Goose2k »

FYI: I have updated list NES->Vs Arcade System palette lookup tables. I now have all 4 of the scrambled PPUs.

http://forums.nesdev.com/viewtopic.php?p=260764#p260764

If you are interested, here is the python script I wrote to generate them. It somewhat manual and outputs a format specific to my use case, but easy enough to extend, and does "best guess" for missing colors.

Code: Select all

def split_list(alist, wanted_parts=1):
    length = len(alist)
    return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts]
             for i in range(wanted_parts) ]


PPU_NES = [
333,14,6,326,403,503,510,420,320,120,31,40,22,0,0,0,
555,36,27,407,507,704,700,630,430,140,40,53,44,0,0,0,
777,357,447,637,707,737,740,750,660,360,70,276,77,444,0,0,
777,567,657,757,747,755,764,772,773,572,473,276,467,666,0,0,
    ]

RP2C04_0001 = [
    755,637,700,447,44,120,222,704,777,333,750,503,403,660,320,777,
    357,653,310,360,467,657,764,27,760,276,0,200,666,444,707,14,
    3,567,757,70,77,22,53,507,0,420,747,510,407,6,740,0,
    0,140,555,31,572,326,770,630,20,36,40,111,773,737,430,473,
]

RP2C04_0002 = [
      0,750,430,572,473,737, 44,567,700,407,773,747,777,637,467, 40,
     20,357,510,666, 53,360,200,447,222,707,  3,276,657,320,  0,326,
    403,764,740,757, 36,310,555,  6,507,760,333,120, 27,  0,660,777,
    653,111, 70,630, 22, 14,704,140,  0, 77,420,770,755,503, 31,444,
    ]

RP2C04_0003 = [
    507,737,473,555,40,777,567,120,14,0,764,320,704,666,653,467,
    447,44,503,27,140,430,630,53,333,326,0,6,700,510,747,755,
    637,20,3,770,111,750,740,777,360,403,357,707,36,444,0,310,
    77,200,572,757,420,70,660,222,31,0,657,773,407,276,760,22,
]

RP2C04_0004 = [
    430,326,44,660,0,755,14,630,555,310,70,3,764,770,40,572,
    737,200,27,747,0,222,510,740,653,53,447,140,403,0,473,357,
    503,31,420,6,407,507,333,704,22,666,36,20,111,773,444,707,
    757,777,320,700,760,276,777,467,0,750,637,567,360,657,77,120,
]

PPU_NEW = RP2C04_0004
PPU_NAME = "_RP2C04_0004"

print("PPU_NES Size: " + str(len(PPU_NES)))
print("PPU_NEW Size: " + str(len(PPU_NEW)))

missing_entries = []
PPU_OUT = []
found = False

for i in PPU_NES:
    index=0
    found = False
    # if i == 100:
    #     i = 120 #manual override
    for j in PPU_NEW:
        if i == j:
            PPU_OUT.append(hex(index))
            found = True
            break
        index+=1
    if found == False:
        missing_entries.append(i)
        PPU_NES_rgb = str(i)
        PPU_NES_rgb = [int(d) for d in str(PPU_NES_rgb)]
        while len(PPU_NES_rgb) < 3:
            PPU_NES_rgb.insert(0, 0)

        #552
        PPU_NES_rgb = [x * x for x in PPU_NES_rgb]
        #54
        PPU_NES_dist = PPU_NES_rgb[0] + PPU_NES_rgb[1] + PPU_NES_rgb[2]

        min_dist = 999999999999
        best_pick = -1
        index = 0
        for j in PPU_NEW:
            #555
            #27
            PPU_NEW_rgb = str(j)
            PPU_NEW_rgb = [int(d) for d in str(PPU_NEW_rgb)]
            while len(PPU_NEW_rgb) < 3:
                PPU_NEW_rgb.insert(0, 0)
            PPU_NEW_rgb = [x * x for x in PPU_NEW_rgb]

            #75
            #53
            PPU_NEW_dist = PPU_NEW_rgb[0] + PPU_NEW_rgb[1] + PPU_NEW_rgb[2]

            #21
            #2
            new_dist = abs((PPU_NEW_dist - PPU_NES_dist))
            new_dist = ((PPU_NEW_rgb[0] - PPU_NES_rgb[0])**2) + ((PPU_NEW_rgb[1] - PPU_NES_rgb[1])**2) + ((PPU_NEW_rgb[2] - PPU_NES_rgb[2])**2)
            if new_dist < min_dist:
                min_dist = new_dist
                best_pick = index
            index += 1

        print("; Remapping (rgb: " + str(i) + ") to [" + str(best_pick) + "] (rgb: " + str(PPU_NEW[best_pick]) + ").")
        PPU_OUT.append(hex(best_pick))

for i, string in enumerate(PPU_OUT):
    PPU_OUT[i] = string.replace("0x", "$")

chunks = split_list(PPU_OUT, 4)
final_string = ""
final_string += "palBrightTable4" +PPU_NAME+ ":\n	.byte "
for i in chunks[0]:
    final_string += i + ","
final_string = final_string[:-1]
final_string += "\npalBrightTable5" +PPU_NAME+ ":\n	.byte "
for i in chunks[1]:
    final_string += i + ","
final_string = final_string[:-1]
final_string += "\npalBrightTable6" +PPU_NAME+ ":\n	.byte "
for i in chunks[2]:
    final_string += i + ","
final_string = final_string[:-1]
final_string += "\npalBrightTable7" +PPU_NAME+ ":\n	.byte "
for i in chunks[3]:
    final_string += i + ","
final_string = final_string[:-1]

print(final_string)

#print("Could not find " + str(len(missing_entries)) + " RGB value: " + str(missing_entries))
print(PPU_OUT)
print("Size: " + str(len(PPU_OUT)))
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

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

Post by lidnariq »

So these are really 2C03→2C04 remaps, complete with the duplicate green and cyan? (reads script) So it appears.
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

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

Post by Goose2k »

lidnariq wrote: Sat Dec 12, 2020 12:18 am So these are really 2C03→2C04 remaps, complete with the duplicate green and cyan? (reads script) So it appears.
More or less, except that I added the 2 missing grey colors (0x2d and 0x3d) to the source table (they are missing on 2C03/05).

The idea is to say "when you ask for THIS color index on the NES, you probably mean THIS index on the Vs PPUX".

I didn't notice the dupe colors before though. I think that means I am missing some color detail in my table. I would need to figure out what RBG value those map closest to, and add them to the source table.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

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

Post by lidnariq »

The extra green on the 2C04 (020) is an easy patch for the $0a and $0b colors (becoming the 020 and 031 entries, instead of 031 and 040). The extra dilute cyan ($2B = $3B = 276) doesn't have a trivial solution, unfortunately.

Many years ago I plotted the 2C04 palette in a radial plot: nesdevwiki:File:2C04_Palette_(Voronoi).png and there's just a lot fewer available colors in the green-cyan-blue-lavender side.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

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

Post by oRBIT2002 »

Been trying to use the RPC002 table (tried them all btw) for VS Wrecking Crew to make it look ok in Mesen but never get it working correctly, here's how it looks (see attachment). Is there's anything strange going on with Vs Wrecking Crew? Or do I have bugs? :)
Attachments
ws.png
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

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

Post by lidnariq »

These tables are the wrong direction for that.

These tables are "so you want to pretend you're drawing on a 2C02, and have some abstraction against the hardware numbers".

For Vs. Wrecking Crew (which ran on the 2C04-0002), you need the exact inverse.
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

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

Post by Goose2k »

oRBIT2002 wrote: Mon Mar 15, 2021 7:08 am Been trying to use the RPC002 table (tried them all btw) for VS Wrecking Crew to make it look ok in Mesen but never get it working correctly, here's how it looks (see attachment). Is there's anything strange going on with Vs Wrecking Crew? Or do I have bugs? :)
I think you want this: http://forums.nesdev.com/viewtopic.php?p=93718#p93718

(it should use the same as Castlevania I believe)
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

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

Post by oRBIT2002 »

Goose2k wrote: Mon Mar 15, 2021 11:48 am I think you want this: http://forums.nesdev.com/viewtopic.php?p=93718#p93718

(it should use the same as Castlevania I believe)
No that didn't work at all. However I think I've figured out the palettestuff pretty ok now. If I could figure out how to get "VS Wrecking Crew" to run in DualSystem-mode in Mesen now... :)
I get this error (unless I set VS System Type to DualSystem, then Mesen opens two windows and then crash)
"Unsupported mapper (UNIF: BADROM), cannot load game"
Attachments
header.png
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

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

Post by Goose2k »

oRBIT2002 wrote: Mon Mar 15, 2021 1:36 pm
Goose2k wrote: Mon Mar 15, 2021 11:48 am I think you want this: http://forums.nesdev.com/viewtopic.php?p=93718#p93718

(it should use the same as Castlevania I believe)
No that didn't work at all. However I think I've figured out the palettestuff pretty ok now. If I could figure out how to get "VS Wrecking Crew" to run in DualSystem-mode in Mesen now... :)
I get this error (unless I set VS System Type to DualSystem, then Mesen opens two windows and then crash)
"Unsupported mapper (UNIF: BADROM), cannot load game"
Is that CHR ROM value correct (16 rather than 8)? Does this Vs game use a daughterboard? Maybe that is the difference. I'm not sure I have run anything in Mesen that required a daughter board (which may confuse the mapper system, since the daughter boards have equivalent NES mappers, so mapper 99 might not be sufficient - but I am way out of my expertise on this).
Post Reply