Closed Ozzyboshi closed 5 years ago
I think that having this fn as UWORD paletteDimColor(UWORD uwColor, ubLevel)
wouldn't be better: you pass just reference color and brightness level, you get modified color in return. What's your opinion about such refactor?
Also, paletteDim should use this fn in a loop, I think.
something like paletteColorDim( &s_pVp->pPalette[ubColIndex], (15 * fadeOut) / 50);
No more source and destination as parameters? Source and destination are always the same thing with this approach. What about a new inline function that calls paletteColorDim? Something like paletteColorChange( &s_pVp->pPalette[ubColIndex], (15 * fadeOut) / 50); and inside just a regular call to paletteColorDim?
I thought something like uwNewColor = paletteColorDim(uwFullColor, ubFadeRatio)
I dunno if we need to specify any function as inline - I think it's best to leave it to compiler to optimize it away, just give it a hint using FN_HOTSPOT
tag near your game's loop. ;)
I made a little change that shoud reflect what you asked. This is a little example how to use it
UWORD s_pPaletteRef[32]; paletteLoadFromMem(PRES1_PALETTE_data, s_pPaletteRef, 1 << s_pVp->ubBPP); UWORD uwFullColor = s_pPaletteRef[COLOR_INDEX]; UBYTE ubFadeRatio = (15 * fadeIn) / 50; s_pVp->pPalette[COLOR_INDEX] = paletteColorDim(uwFullColor, ubFadeRatio);
what do you think? is this what you planned to dim a single color?
Yes, that's exactly it! Now I think you just need to refactor paletteDim() so that it will use paletteColorDim() so that we won't have too much code to maintain. ;)
Okay, we're good to go!
Dimming a single color can be very useful, in my case more than paletteDim.