From 00a5d4598d4a79e0041ce958fe65a4c20338b6cc Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 19 Jul 2012 02:48:02 +0300 Subject: [PATCH] gpulib: implement rgb888_to_rgb565 and use it for menu --- frontend/menu.c | 4 ++-- plugins/gpulib/cspace.c | 1 + plugins/gpulib/cspace.h | 1 + plugins/gpulib/cspace_neon.s | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/frontend/menu.c b/frontend/menu.c index 3ebe9f5d..3152cb2e 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -590,7 +590,7 @@ static void draw_savestate_bg(int slot) x = gpu->ulControl[5] & 0x3ff; y = (gpu->ulControl[5] >> 10) & 0x1ff; - s = (u16 *)gpu->psxVRam + y * 1024 + (x & ~1); + s = (u16 *)gpu->psxVRam + y * 1024 + x; w = psx_widths[(gpu->ulStatus >> 16) & 7]; tmp = gpu->ulControl[7]; h = ((tmp >> 10) & 0x3ff) - (tmp & 0x3ff); @@ -2242,7 +2242,7 @@ static void menu_leave_emu(void) } else { for (; h > 0; h--, d += g_menuscreen_w, s += last_psx_w * 3) { - bgr888_to_rgb565(d, s, w * 3); + rgb888_to_rgb565(d, s, w * 3); menu_darken_bg(d, d, w, 0); } } diff --git a/plugins/gpulib/cspace.c b/plugins/gpulib/cspace.c index 408211ff..1d5718cd 100644 --- a/plugins/gpulib/cspace.c +++ b/plugins/gpulib/cspace.c @@ -39,5 +39,6 @@ void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) } // TODO? +void rgb888_to_rgb565(void *dst, const void *src, int bytes) {} void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} diff --git a/plugins/gpulib/cspace.h b/plugins/gpulib/cspace.h index 644143bf..8c9bcfa5 100644 --- a/plugins/gpulib/cspace.h +++ b/plugins/gpulib/cspace.h @@ -6,6 +6,7 @@ extern "C" void bgr555_to_rgb565(void *dst, const void *src, int bytes); void bgr888_to_rgb888(void *dst, const void *src, int bytes); void bgr888_to_rgb565(void *dst, const void *src, int bytes); +void rgb888_to_rgb565(void *dst, const void *src, int bytes); #ifdef __cplusplus } diff --git a/plugins/gpulib/cspace_neon.s b/plugins/gpulib/cspace_neon.s index abc03811..b458f06a 100644 --- a/plugins/gpulib/cspace_neon.s +++ b/plugins/gpulib/cspace_neon.s @@ -129,4 +129,37 @@ bgr888_to_rgb565: bx lr +.global rgb888_to_rgb565 +rgb888_to_rgb565: + pld [r1] + @ 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: + pld [r1, #48*3] + 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 d2, d1, #3 @ b + vshr.u8 d6, d5, #3 + vzip.8 d2, d3 @ rb + vzip.8 d6, d7 + vbit q1, q8, q15 + vbit q3, q9, q15 + + vstmia r0!, {d2,d3} + vstmia r0!, {d6,d7} + subs r2, r2, #1 + bne 0b + + bx lr + + @ vim:filetype=armasm -- 2.39.5