gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > GBA palette correction (?)

#177873 - sverx - Tue Apr 16, 2013 10:35 am

Any suggestions on how to obtain colors closer to the NDS hardware on a GBA? I've read some posts on the Internet (even in this forum) but I didn't found a 'good' solution.
For instance one idea could be to modify 'grit', adding a command line switch or something like that, so that it generates a 'corrected' palette. But I don't know which formula I should use... anyone have a good formula to suggest? Or some other options/approaches I could try?
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177874 - Dwedit - Tue Apr 16, 2013 2:35 pm

How about not correcting the palette at all? The GBA SP has a nice frontlit screen, and the second version of the GBA SP has a NDS-like screen. GBA games can also be played on a NDS, so any corrections you use there will simply backfire. Not to mention GBA emulators, which also display pristine RGB colors.

If you want to do corrections, make it an option after the game has started. Only the original GBA needs corrections, and mine is collecting dust.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#177875 - sverx - Tue Apr 16, 2013 2:53 pm

Quote:
Only the original GBA needs corrections


Well, in fact that's for the original GBA only... which is the only one I've got at the moment (but I'll surely also run tests on my friends' GBA SP and GBA Micro too...)
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177876 - Bregalad - Tue Apr 16, 2013 3:23 pm

I can't commen about the micro, but the SP definitely has significantly less saturated colours than the DS-Lite. I alternate between both and the difference is very noticeable. It also depends on the lightning conditions. The GBA SP screen works better in dark places, while the DS-List screen works better in light places (I think) and hurts eyes in dark places because it's way too bright.

I don't have an original DS so I can't compare.

VisualBoy has an option to simulate the "GameBoy Colors", so you can just use it to check the results. Most games looks better with this option turned on BTW.

When it comes to correction, I think it would almost be equivalent to increase the staturation of all colours.
So if you use RGB, you'd have to convert to HSL, increase S, and convert back to RGB.

Since I use HSL in my GBA projects (and only convert to RGB when I have to write the palete) this would be easier to do.

#177877 - sverx - Tue Apr 16, 2013 4:13 pm

More saturation it's just what I need?
And just multiplying each RGB component by a constant would work?
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177879 - sverx - Wed Apr 17, 2013 8:52 am

I've found a formula that says
Code:
new value= 255 x ( ( old value / 255 ) ^ (1 / gamma) )

I don't even know if it's correct, even if it sounds so...
Do you guys think it's possible to use such formula inside grit adding a command line switch to specify gamma so that when (only if) the palette file is going to be generated then this correction takes place?
This way it would be very feasible for me to compile different GBA files with different gamma values and test them all on GBA/SP/Micro...
Anyone willing to help? :)
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177880 - sverx - Thu Apr 18, 2013 11:01 am

I'm not really good at C++, but I believe I found in grit sources where it creates the palette. In grit_prep.cpp there's a grit_prep_pal function, and at one point it converts each color of the input palette to a RGB16 color in the output palette:
Code:
for(ii=0; ii<nclrs; ii++)
      palOut[ii]= RGB16(palIn[ii].rgbBlue, palIn[ii].rgbGreen, palIn[ii].rgbRed);

Any help on how to code the mentioned gamma correction formula into here? And how can I compile the sources then? (I believe not in devKitARM, unfortunately...)
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177888 - Bregalad - Fri Apr 19, 2013 7:12 pm

It looks like a simple copy/conversion loop to me.

And I didn't ever use grit to create my graphics by the way, manual tile editing is just WAAAAY better.

You can immediately see on demoes that uses a very cheap antialiased logo they were made with girt.

#177889 - sverx - Sat Apr 20, 2013 2:34 pm

Personally, I switched to grit for most of my needs... I think it's very convenient and it does what I need most of times. But I feel that giving that tool a gamma correction option might be exactly what I need to achieve a better result.
Unfortunately I'm still seeking how should I do that. :|
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177890 - FluBBa - Sat Apr 20, 2013 4:16 pm

You can find a gamma routine (asm) in most of my emulators for both GBA and DS.
_________________
I probably suck, my not is a programmer.

#177899 - sverx - Mon Apr 22, 2013 10:12 am

Is that approximate? I don't see any exponentiation, just some multiplications...
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary