News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: MD/GEN: found a way to detect palettes HivePal can't find, a question remains  (Read 1615 times)

fusaru

  • Jr. Member
  • **
  • Posts: 22
    • View Profile
Some games store their colors in an unusual way. I'm not talking about compression. It's like some games cointain colors the system can't actually output.
These colors look perfectly normal when the game is running but, and this is the issue here, are not visible in HivePal's browser, which seems to be the standard tool for Genesis color editing.

Let's take a look at this screenshot. It's the title screen of "Twin Cobra", a game that stores colors in a way HivePal recognizes, and in a way it doesn't.


The top row (1) is how HivePal displays the colors of the helicopter when you explicitly load them (address is 7C94). However, this palette is invisible when you look for it with HivePal's browser. See that nearly blank spot with the red border around? No helicopter colors to be seen. The palettes right and below that red border are recognized just fine.

Lets concentrate on palette (1). Most colors there have unusual values, exception is 0000, which is pure black.
I've confirmed this with HivePal and a Hex Editor. Starting from the left:
0000, 0DCB, OBA9,0987,0765 and so on. Not only are these not recognized by HivePal's browser, these colors aren't even part of the system's master palette as far as I'm aware. When running the game they get rounded to the next color the system can display. To stick with the previous examples:
0000, 0CCA, 0AA8, 0886, 0664 and so on
These are the colors in the bottom row (2), and these are also the color the helicopter has on the screenshot, and on my television screen when I play the game.

Another game that stores colors in this strange way is GODS. The game's full palette data is invisible to HivePal. I was able to find it by making screenshots of the game with a VDP debugger open, then searching for color patterns in a hex editor (white is stored as 0FFF instead of the usual 0EEE, next to white was a flesh tone that was 0007 instead of 0006. So I've searched for 0FFF0007 and found the palettes. If this is used in more games maybe I should write sort of a color conversion table)

Sorry if this doesn't make any sense. It's a really simple matter but I can't find better words to describe it.

This questions remains unsolved for me:
Why save colors with values the Genesis can't output? This somehow makes sense with Twin Cobra, because that is a sloppy port in many ways. GODS on the other hand was ported over to the last detail by a small but dedicated staff. These people knew exactly what the were doing.
(MD hacks):
Complete --> see contributions page
Twin Hawk (arcade graphics), Toki

tryphon

  • Hero Member
  • *****
  • Posts: 722
    • View Profile
This is indeed very surprising. The MD color scheme is indeed :

Code: [Select]
0000BBB0 GGG0RRR0
(or is it the contrary ? I never know)

I suppose all the 0s are in fact ignored, but never tried (and anyway, an emulator isn't the good place for that). Could the useless bits be used by the engine to determine some special effect to do with these colors (cycling for example) ? You should study the code that reads the ROM to check what it does before sending the value in CRAM.

I know that Gamegear has 4096 colors (yes, more than MD, whereas it's just a portable SMS), using the color scheme
Code: [Select]
0000BBBB GGGGRRRR, but it doesn't have any sense here. A forum where your question could have more success is http://gendev.spritesmind.net/forum/

PresidentLeever

  • Hero Member
  • *****
  • Posts: 790
    • View Profile
    • Mini-Revver
Not sure if it's related but in PSIII, I wasn't able to edit palettes that cycled in-game, like the cyborg transformation cutscene.
Mini-reviews, retro sound chip tribute, romhacks and general listage at my site: Mini-Revver.

fusaru

  • Jr. Member
  • **
  • Posts: 22
    • View Profile
This is indeed very surprising. The MD color scheme is indeed :

Code: [Select]
0000BBB0 GGG0RRR0
...
I didn't know about a specialized Genesis development community. Thanks, I might post there after looking deeper into this (as soon as working on GODS is complete perhaps) and record a few trace logs.

The color scheme you've posted earlier is identical to what I've been looking at:
http://segaretro.org/Palette
The Mega Drive VDP supports four palettes of 16 colors each, with each color being selected from a total of 512 colors; using the Shadow/Highlight capabilities of the VDP, the total raises to 1536. Each palette is 32 bytes, with each color occupying two bytes. These two bytes are in the format 0B GR, where B = blue; G = green; and R = red. The B, G and R can be any of the following values:
Code: [Select]
   
0 (0000)
2 (0010)
4 (0100)
6 (0110)
8 (1000)
A (1010)
C (1100)
E (1110)
Very strange indeed. There should be no B, no 9, no 7...

What I can tell at this point is that it's not related to color cycling. GODS has all palettes stored that way and never cycles through palettes. Pitfall the Mayan Adventure is another game I 've checked yesterday that uses these strange values.

And finally, to get back to the Twin Cobra title screen example: Indeed there seems to be some emulator influence as well. The VDP debugger in Regen shows me the "wrong" colors as seen in palette (1). Interestingly the game windows displays the "correct" colors as seen in palette (2).
Exodus, which is the most accurate emulator I know of shows the "correct" colors in both the VDP debugger and the actual game window.

Not sure if it's related but in PSIII, I wasn't able to edit palettes that cycled in-game, like the cyborg transformation cutscene.
I ran into a similar problem in XDR. Stage 6 or so has a background cycling through purple tones. I thought this was code controlled, might have to check back again.
Other games however have a palette for each cycle, sometimes at a different location than the fist palette of the sequence (from personal experience: Splatterhouse 2, Toki/JuJu Densetsu, Twin Cobra). When looking at them in palette editor, these show up as obscurely long bands of colors.
(MD hacks):
Complete --> see contributions page
Twin Hawk (arcade graphics), Toki