I'm trying to make a function to print in color.
Basically, I call my function, giving it a string I want to print, and a RGBA (red, green, blue, alpha) hex color code. Then my function should print the message in that color.
I have some code to do this:
void printStuff( long colour, char *message ) { int r; int g; int b; int a; int c; c = colour; r = c / 0x01000000; c -= (r * 0x01000000 ); g = c / 0x00010000; c -= (g * 0x00010000 ); b = c / 0x00000100; c -= (b * 0x0100 ); a = c; pspDebugScreenSetTextColor((a * 0x1000000) + (b * 0x10000) + (g * 0x100) + (r)); pspDebugScreenPrintf(message); }
In theory, if I use:
printStuff(0xFF7F0FF, "Hello");
...it should print the text "Hello" in orange.
It compiles fine, and when I do the sums on a calculator, it works fine.
But when I run it on the PSP, it doesn't work at all...
I think the problem lies when I'm doing "r = c / 0x01000000 ;", like it can't divide properly or something.
Does anyone know why this doesn't work?
Or, can anyone think of a better way of getting r, g, b and a from the color?
Thanks.