BACKENDS: PSP: Support RGBA8888 by swapping bytes

This commit is contained in:
rsn8887 2022-11-05 13:33:21 -05:00
parent de08002679
commit 6ae4512a42
3 changed files with 15 additions and 0 deletions

View file

@ -639,6 +639,7 @@ inline uint32 GuRenderer::convertToGuPixelFormat(PSPPixelFormat::Type format) {
guFormat = GU_PSM_5650;
break;
case PSPPixelFormat::Type_8888:
case PSPPixelFormat::Type_8888_RGBA:
guFormat = GU_PSM_8888;
break;
case PSPPixelFormat::Type_Palette_8bit:

View file

@ -43,6 +43,9 @@ void PSPPixelFormat::set(Type type, bool swap /* = false */) {
bitsPerPixel = 16;
break;
case Type_8888:
case Type_8888_RGBA:
bitsPerPixel = 32;
break;
bitsPerPixel = 32;
break;
case Type_Palette_8bit:
@ -98,6 +101,8 @@ void PSPPixelFormat::convertFromScummvmPixelFormat(const Graphics::PixelFormat *
*target = Type_4444;
} else if (pf->gLoss == 0 && pf->gShift == 8) {
*target = Type_8888;
} else if (pf->gLoss == 0 && pf->gShift == 16) {
*target = Type_8888_RGBA;
} else if ((pf->gLoss == 0 && pf->gShift == 0) ||
(pf->gLoss == 8 && pf->gShift == 0)) { // Default CLUT8 can have weird values
*target = Type_5551;
@ -154,6 +159,7 @@ Graphics::PixelFormat PSPPixelFormat::convertToScummvmPixelFormat(PSPPixelFormat
pf.bShift = 11;
break;
case Type_8888:
case Type_8888_RGBA:
pf.bytesPerPixel = 4;
pf.aLoss = 0;
pf.rLoss = 0;

View file

@ -38,6 +38,7 @@ struct PSPPixelFormat {
Type_5551,
Type_5650,
Type_8888,
Type_8888_RGBA,
Type_Palette_8bit,
Type_Palette_4bit,
Type_Unknown
@ -70,6 +71,7 @@ struct PSPPixelFormat {
color = (((b >> 3) << 11) | ((g >> 2) << 5) | ((r >> 3) << 0));
break;
case Type_8888:
case Type_8888_RGBA:
color = (((b >> 0) << 16) | ((g >> 0) << 8) | ((r >> 0) << 0) | ((a >> 0) << 24));
break;
default:
@ -110,6 +112,7 @@ struct PSPPixelFormat {
r = r << 3 | r >> 2;
break;
case Type_8888:
case Type_8888_RGBA:
a = (color >> 24) & 0xFF;
b = (color >> 16) & 0xFF;
g = (color >> 8) & 0xFF;
@ -130,6 +133,7 @@ struct PSPPixelFormat {
color = (color & 0x7FFF) | (((uint32)alpha >> 7) << 15);
break;
case Type_8888:
case Type_8888_RGBA:
color = (color & 0x00FFFFFF) | ((uint32)alpha << 24);
break;
case Type_5650:
@ -200,6 +204,10 @@ struct PSPPixelFormat {
output = (color & 0xff00ff00) |
((color & 0x000000ff) << 16) | ((color & 0x00ff0000) >> 16);
break;
case Type_8888_RGBA:
output = ((color & 0x000000ff) << 24) | ((color & 0x0000ff00) << 8) |
((color & 0x00ff0000) >> 8) | ((color & 0xff000000) >> 24);
break;
default:
PSP_ERROR("invalid format[%u] for swapping\n", format);
output = 0;