From f3a63e25fac571e222b969f0d16c542061190797 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 3 Feb 2011 23:37:20 +0200 Subject: [PATCH] dfxvideo: add bgr888->rgb565 converter for maemo port --- frontend/arm_utils.h | 3 +++ frontend/arm_utils.s | 31 +++++++++++++++++++++++++++++++ plugins/dfxvideo/draw_fb.c | 16 +++++++--------- 3 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 frontend/arm_utils.h diff --git a/frontend/arm_utils.h b/frontend/arm_utils.h new file mode 100644 index 00000000..f7d637e9 --- /dev/null +++ b/frontend/arm_utils.h @@ -0,0 +1,3 @@ +void bgr555_to_rgb565(void *dst, void *src, int bytes); +void bgr888_to_rgb888(void *dst, void *src, int bytes); +void bgr888_to_rgb565(void *dst, void *src, int bytes); diff --git a/frontend/arm_utils.s b/frontend/arm_utils.s index 47363809..4e561f93 100644 --- a/frontend/arm_utils.s +++ b/frontend/arm_utils.s @@ -75,4 +75,35 @@ bgr888_to_rgb888: bx lr +.global bgr888_to_rgb565 +bgr888_to_rgb565: + @ r2 /= 48 + mov r2, r2, lsr #4 + movw r3, #0x5556 + movt r3, #0x5555 + umull r12,r2, r3, r2 + + mov r3, #0x07e0 + vdup.16 q15, r3 +0: + vld3.8 {d1-d3}, [r1, :64]! + vld3.8 {d5-d7}, [r1, :64]! + + vshll.u8 q8, d2, #3 @ g + vshll.u8 q9, d6, #3 + vshr.u8 d0, d3, #3 @ b + vshr.u8 d4, d7, #3 + vzip.8 d0, d1 @ rb + vzip.8 d4, d5 + vbit q0, q8, q15 + vbit q2, q9, q15 + + vstmia r0!, {d0,d1} + vstmia r0!, {d4,d5} + subs r2, r2, #1 + bne 0b + + bx lr + + @ vim:filetype=armasm diff --git a/plugins/dfxvideo/draw_fb.c b/plugins/dfxvideo/draw_fb.c index afe1d208..dbf0fc84 100644 --- a/plugins/dfxvideo/draw_fb.c +++ b/plugins/dfxvideo/draw_fb.c @@ -10,6 +10,7 @@ #include "gpu.h" #include "plugin_lib.h" +#include "arm_utils.h" #include "pcnt.h" // misc globals @@ -18,15 +19,8 @@ BOOL bCheckMask = FALSE; unsigned short sSetMask; unsigned long lSetMask; -#ifndef __arm__ -#define bgr555_to_rgb565 memcpy -#define bgr888_to_rgb888 memcpy -#endif - static void blit(void) { - extern void bgr555_to_rgb565(void *dst, void *src, int bytes); - extern void bgr888_to_rgb888(void *dst, void *src, int bytes); int px = PSXDisplay.DisplayPosition.x & ~3; // XXX: align needed by bgr*_to_... int py = PSXDisplay.DisplayPosition.y; int w = PreviousPSXDisplay.Range.x1; @@ -38,9 +32,13 @@ static void blit(void) if (w <= 0) return; - // TODO: clear border if centering? - +#ifndef MAEMO pitch *= PSXDisplay.RGB24 ? 3 : 2; +#else + // n900 doesn't do rgb24 for some reason + pitch *= 2; + #define bgr888_to_rgb888 bgr888_to_rgb565 +#endif // account for centering h -= PreviousPSXDisplay.Range.y0; -- 2.39.5