AmigaPorts / ACE

Amiga C Engine
Mozilla Public License 2.0
159 stars 26 forks source link

added paletteColorDim function #107

Closed Ozzyboshi closed 5 years ago

Ozzyboshi commented 5 years ago

Dimming a single color can be very useful, in my case more than paletteDim.

tehKaiN commented 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.

Ozzyboshi commented 5 years ago

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?

tehKaiN commented 5 years ago

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. ;)

Ozzyboshi commented 5 years ago

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?

tehKaiN commented 5 years ago

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. ;)

tehKaiN commented 5 years ago

Okay, we're good to go!