X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fgpulib%2Fcspace.c;h=408211ff6478a9178c51932346487763b977ead0;hp=eee56ced2bf090bc41e15b125851aa94982c8305;hb=4ea7de6a1495abfbc49c54fd2a90e902fdfa13d9;hpb=b07c18e8645a17be916266820ae564e0d320cc1a diff --git a/plugins/gpulib/cspace.c b/plugins/gpulib/cspace.c index eee56ced..408211ff 100644 --- a/plugins/gpulib/cspace.c +++ b/plugins/gpulib/cspace.c @@ -1,9 +1,14 @@ #include "cspace.h" +/* + * note: these are intended for testing and should be avoided + * in favor of NEON version or platform-specific conversion + */ + void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) { - unsigned int *src = (unsigned int *)src_; - unsigned int *dst = (unsigned int *)dst_; + const unsigned int *src = src_; + unsigned int *dst = dst_; unsigned int p; int x; @@ -15,7 +20,24 @@ void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) } } +void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) +{ + const unsigned char *src = src_; + unsigned int *dst = dst_; + unsigned int r1, g1, b1, r2, g2, b2; + + for (; bytes >= 6; bytes -= 6, src += 6, dst++) { + r1 = src[0] & 0xf8; + g1 = src[1] & 0xfc; + b1 = src[2] & 0xf8; + r2 = src[3] & 0xf8; + g2 = src[4] & 0xfc; + b2 = src[5] & 0xf8; + *dst = (r2 << 24) | (g2 << 19) | (b2 << 13) | + (r1 << 8) | (g1 << 3) | (b1 >> 3); + } +} + // TODO? void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} -void bgr888_to_rgb565(void *dst, const void *src, int bytes) {}