typedef union {
struct {
SceUChar8 R;
SceUChar8 G;
SceUChar8 B;
SceUChar8 A;
} components;
SceUInt32 Value;
} mgpColor8888;
typedef union {
struct {
SceUShort16 R: 5;
SceUShort16 G: 5;
SceUShort16 B: 5;
SceUShort16 A: 1;
} components;
SceUShort16 Value;
} mgpColor5555;
the mgp5555 is obviously bugged as a i need the union to create a 16-bit type.
typedef union {
struct {
>>5 bits<< R: 5;
>>5 bits<< G: 5;
>>5 bits <<B: 5;
>>1 bits << A: 1;
} components;
SceUShort16 Value;
} mgpColor5555;
I’ve hit a brick wall and i know this code looks nasty but it does work. However i still hate the fact i can’t individually place these values
SceUShort16 gen5551( SceUChar8 R, SceUChar8 G, SceUChar8 B, SceUChar8 A) {
mgpColor5555 val;
R >>=3;
G >>=3;
B >>=3;
A= (A >= 0x80) ? 0b01 : 0b00;
SceUShort16 temp = ((A & 1) << 15) |((B & 0x1F) <<10 ) | ((G & 0x1F) << 5)| (R & 0x1F);
val.Value = temp;
return val.Value;
}