don't click here

Genesis colors?

Discussion in 'Engineering & Reverse Engineering' started by MainMemory, Oct 23, 2009.

Thread Status:
Not open for further replies.
  1. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    So, I've noticed that there are at least 3 different ways that Genesis colors are interpreted on a PC.
    First, we have Gens, Gens+, and GSavestate, using a max of 255 (FF):
    [​IMG]
    Then, we have Gens/GS, Sonic CD PC, the wiki, SonED, and every other Sonic hacking tool, using a max of 224 (E0):
    [​IMG]
    [​IMG]
    Note: this screenshot was taken in 256 color mode.
    Then, we have Sonic & Knuckles Collection and the hidden bitmaps for Sonic CD PC, using a max of 238 (EE):
    [​IMG]
    [​IMG]
    I restored this one by copying the palette already present in the file to the correct position.

    So, which of these is "right"? None of them? All of them? Does it matter?
     
  2. Mr. Mash

    Mr. Mash

    All fanbases are awful Member
    1,440
    0
    0
    drawing
    I'd say it probably doesn't matter too much, given the way TV's vary.
     
  3. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    It depends on how you interpret the color values. Technically, a CRAM value of 0xEEE should map to 100% brightness (RGB #FFFFFF). The reason why Gens/GS (r7_pre4 and earlier) doesn't is because it uses simple bitshifting. The end result is that "full brightness" isn't full brightness.

    Gens/GS r7_pre5 scales 0xEEE to RGB #FFFFFF by default. There's an option in the Color Adjust window to disable this feature (labelled "Scale Colors") if you prefer the old scaling method (0xEEE -> RGB #E0E0E0).

    Fun fact: If your desktop color depth is set to 24/32-bit and you run a DirectDraw, OpenGL, or Direct3D app that uses a 16-bit framebuffer, the 16-bit colors will be scaled such that maximum brightness maps to maximum brightness. That is, RGB16 0xFFFF maps to RGB24 0xFFFFFF instead of 0xF8FCF8.
     
  4. Jayextee

    Jayextee

    Unpopular Opinions™ Member
    3,253
    60
    28
    Atro City
    I DONE MAKED GAMES.
    Can't comment on 'correct' but the E0 one is more pleasing to my overly-brightness-sensitive eyes.
     
  5. PsychoSk8r

    PsychoSk8r

    PsychedelAnt | Tone Turner Oldbie
    2,641
    57
    28
    Birmingham, UK
    30 Day Project: Revisited.A New Release!
    I agree completely here. I'm sure E0 is the accurate value anyway.
     
  6. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    What I really don't get is why SEGA can't pick one value and stick with it.

    If you compare the S3K shots, there's definitely a noticeable difference.

    ->$E0 is value*$10, ->$EE is value*$11, ->$FF is value*18.214285714285714285714285714286?
     
  7. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    I know it's NOT correct, but I'd go with $EE. Just multiply the genesis color by $11. This gives you a linear scale, which is important in my opinion. $E0 gives you a linear scale too but it's dark :x
     
  8. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    I think the real question here is, if it isn't correct, why did SEGA use it? And you could use $12 and get a max of $FC.
     
  9. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
    Get Chaotix on real hardware. In the color test, set the Mars values of one bar to the max. Set the corresponding Genesis colors to the max. Compare. I can't provide a pic atm though.

    Note that the brightness of your TV won't really matter unless it's so dark that those colors just blend together.
     
  10. Chilly Willy

    Chilly Willy

    Tech Member
    751
    11
    18
    Doom 32X
    "SEGA" doesn't multiply anything... we're talking HARDWARE here. A palette entry of 0xEEE sends the three bits making each E to a 3 bit digital to analog converter, where a "white" voltage is the reference. A palette entry is (in binary) b2b1b0-g2g1g0-r2r1r0- where b2b1b0 is the three bit value of blue, g2g1g0 is the three bit value of green, and r2r1r0 is the three bit value of red, and - is an ignored bit. So 0xEEE is the brightest white and 0x222 of the darkest gray without being black.
     
  11. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    I'm talking about S&K Collection, which multiplies by $11 to get the RGB values, as you can see in the screenshot.
     
  12. ICEknight

    ICEknight

    Researcher Researcher
    Couldn't resist asking the developer of Genesis Plus for Wii, since he's always pushing for maximum accuracy.

    Here's his answer about it, and about how it's done in his emu.
     
  13. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    Haha it turns out my random guess was just right in the end :]
     
  14. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,218
    965
    93
    Long-term happiness
    Speaking of, it IS an accurate emu - I installed Homebrew Channel on my Wii this afternoon and put this emu on to test it - it's only the second emulator I've ever used (after Fusion) to get the horns right on Micro Machines 2...
     
  15. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    I updated Gens/GS to support this color scaling method in addition to the original two. This method is now called "Full with S/H", and is the default. The other methods are "Raw" (0xEEE -> 0xE0E0E0) and "Full" (0xEEE -> 0xFFFFFF).

    This will be included in Gens/GS r7 Final.
     
  16. Maybe, but in that post it doesn't say that it's the definitively right option, it states that the VDP stuff hasn't correctly been measured yet.

    Or am I missing something?
     
  17. TmEE

    TmEE

    Master of OPL3-SA2/3 Tech Member
    1,726
    2
    18
    Estonia, Rapla City
    T-04YBSC-A !
    [​IMG]

    hääv fann
     
  18. GerbilSoft

    GerbilSoft

    RickRotate'd. Administrator
    2,971
    76
    28
    USA
    rom-properties
    Essentially, to convert it to 32-bit, you simply copy each color component to both nybbles of the 8-bit component.

    mdR: 0xE
    mdG: 0xE
    mdB: 0xE

    pcR = mdR | (mdR << 4);
    pcG = mdG | (mdG << 4);
    pcB = mdB | (mdB << 4);

    Gens/GS uses floating-point arithmetic to calculate the values, since this was needed for the "Full" scaling algorithm (also for 15-bit and 16-bit color); however, it ends up with the same results. I might add an optimized version for 32-bit color later, though it's not really that important since the palette calculation is only done once (unless the palette settings are changed by the user).

    EDIT: With regards to S/H effects, Gens/GS maintains a 256-entry palette. Entries 0-63 are normal, 64-127 are shadow, 128-191 are highlight, and 192-255 are normal. (No, I'm not really sure why the normal entries are duplicated. It was like that in the original Gens.) <a href="http://gs_server.gerbilsoft.ddns.info/cgi-bin/gitweb.cgi?p=gens.git;a=blob;f=src/gens/gens_core/vdp/vdp_rend.cpp;hb=HEAD" target="_blank">T_VDP_Update_Palette()</a> is a templated function that's called whenever the CRAM changes. This function updates the 256-entry palette with "real" (15/16/32-bit) entries based on CRAM.

    The first thing T_VDP_Update_Palette() does when it reads a CRAM entry is AND it with 0x0EEE (or 0x0222 if the Palette Select bit is cleared). It then treats the entry as if it's a Normal color when looking up the palette value. Then, if Shadow/Highlight is enabled, it shifts the CRAM value around to get the shadow and highlight entries: (CRAM >> 1) for shadow, and ((CRAM >> 1) | 0x888) for highlight.
     
  19. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    I'm glad we finally have a definitive answer to this. This proves that eke's idea AND my random guess were right.
     
  20. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    So, this means that Sonic & Knuckles Collection is the winner? I would hope that SEGA knows how their own stuff works.
    In case you didn't know, S&KC uses the Genesis palette format, byteswapped because it's on a PC. (GR 0B)
    Edit: Question, does anybody know where the "Night Mode" flag is in Sonic 3? I can't get it to activate in S&K Collection's S3 Mode.
     
Thread Status:
Not open for further replies.