miinaturvat Posted March 27, 2009 Report Posted March 27, 2009 I'm doing a bit of programming for the PSP in C/C++, using the pspdev thing for compiling. 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.
iKhaosmaster Posted March 27, 2009 Report Posted March 27, 2009 I have no idea what to do on this but gabe said something about patching your mainframes before.... 1
TheEazyB Posted November 26, 2009 Report Posted November 26, 2009 I have no idea what to do on this but gabe said something about patching your mainframes before.... lol the statement is justified. 1
miinaturvat Posted November 26, 2009 Author Report Posted November 26, 2009 Severe bumpage going on here... And if anyone actually cares, the devision works strangely on the PSP. The way I did it was as follows: void printHex( unsigned long color, int x1, int y1, char *str) { char message[999]; unsigned r1; unsigned g1; unsigned b1; unsigned a1; unsigned char r; unsigned char g; unsigned char b; unsigned char a; if( strlen( str ) < 800 ) { sprintf( message, "%s", str); } else { sprintf( message, "String too big (%d chars)", strlen(str) ); } r1 = color & 0xFF000000; g1 = color & 0x00FF0000; b1 = color & 0x0000FF00; a1 = color & 0x000000FF; a = (char)(a1); b = (char)(b1 >> ; g = (char)(g1 >> 16); r = (char)(r1 >> 24); pspDebugScreenSetXY(x1,y1); pspDebugScreenSetTextColor((a * 0x1000000) + (b * 0x10000) + (g * 0x100) + (r)); pspDebugScreenPrintf(message); }
TheEazyB Posted November 27, 2009 Report Posted November 27, 2009 Oh wow, I'm embarassed. I thought the date was this month
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now