#109974 - misterDtD - Thu Nov 23, 2006 9:00 pm
Sorry if my terms don't make sense to you, I'm from other programming languages.
I made a bit of code that takes a palette from an array and fades it in (from black), I want to make it a function (I think they call them marcos in C {?} ) so I don't have to write the same 5 lines of code every time I want to fade the palette, but I can't figure out how to pass the array to the function.
Please help.
EDIT: Here's the code if it help (People who want palette fading, feel free to take.) (inpal is the palette to use)
Here's the code that corresponds with the color_* functions:
~DtD
(PS, I'm kinda new to C)
Never mind, I got it fixed, just had to add a [] after the argument, but now I get a message saying "warning: passing argument 1 of 'fadein' disgards qualifiers from pointer target type"
It still works, but I would like to remove this notice.
Last edited by misterDtD on Fri Nov 24, 2006 12:18 am; edited 2 times in total
I made a bit of code that takes a palette from an array and fades it in (from black), I want to make it a function (I think they call them marcos in C {?} ) so I don't have to write the same 5 lines of code every time I want to fade the palette, but I can't figure out how to pass the array to the function.
Please help.
EDIT: Here's the code if it help (People who want palette fading, feel free to take.) (inpal is the palette to use)
Code: |
void fadein(const u16 inpal[])
{ int i,h,r,g,b; for(h=31;h>=0;h-=1) { for(i=0;i<256;i++) { r=color_get_red(inpal[i])-h; if (r<0) {r=0;} g=color_get_green(inpal[i])-h; if (g<0) {g=0;} b=color_get_blue(inpal[i])-h; if (b<0) {b=0;} PAL[i]=color_rgb(r,g,b); } } } |
Here's the code that corresponds with the color_* functions:
Code: |
inline u16 color_rgb(u32 r, u32 g, u32 b) {return (r&31) | ((g&31)<<5) | ((b&31)<<10);}
inline u32 color_get_red(u16 c) {return c&0x1F;}//Gets the red of an image. inline u32 color_get_green(u16 c) {return (c>>5)&0x1F;}//Gets the green of an image. inline u32 color_get_blue(u16 c) {return (c>>10)&0x1F;}//Gets the blue of an image. |
~DtD
(PS, I'm kinda new to C)
Never mind, I got it fixed, just had to add a [] after the argument, but now I get a message saying "warning: passing argument 1 of 'fadein' disgards qualifiers from pointer target type"
It still works, but I would like to remove this notice.
Last edited by misterDtD on Fri Nov 24, 2006 12:18 am; edited 2 times in total