From b885cf27011979af66b81a72aae5b612cbcc6be2 Mon Sep 17 00:00:00 2001 From: Pecusx Date: Sat, 8 May 2021 14:50:10 +0200 Subject: [PATCH] Still testing VKBD opacity --- libretro/graph.c | 33 ++++++++++++++++++++++----------- libretro/libretro-core.h | 9 +++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/libretro/graph.c b/libretro/graph.c index a63a1c8..51bfe79 100755 --- a/libretro/graph.c +++ b/libretro/graph.c @@ -9,6 +9,17 @@ extern int VIRTUAL_WIDTH; +unsigned Opacity(unsigned color1, unsigned color2){ + + unsigned r,g,b; + + r=(R_RGB565(color1)/2)+(R_RGB565(color2)/2); + g=(G_RGB565(color1)/2)+(G_RGB565(color2)/2); + b=(B_RGB565(color1)/2)+(B_RGB565(color2)/2); + return RGB565(r,g,b); + +} + void DrawFBoxBmp(char *buffer,int x,int y,int dx,int dy,unsigned color){ int i,j,idx; @@ -24,7 +35,7 @@ unsigned short *mbuffer=(unsigned short *)buffer; for(j=y;j= dx) { y -= dx; @@ -343,7 +354,7 @@ unsigned char *mbuffer=(unsigned char *)surf; for(yrepeat = y; yrepeat < y+ surfh; yrepeat++) for(xrepeat = x; xrepeat< x+surfw; xrepeat++,yptr++) - if(*yptr!=0)mbuffer[xrepeat+yrepeat*VIRTUAL_WIDTH] = (mbuffer[xrepeat+yrepeat*VIRTUAL_WIDTH]/2) + (*yptr/2); + if(*yptr!=0)mbuffer[xrepeat+yrepeat*VIRTUAL_WIDTH] = Opacity(mbuffer[xrepeat+yrepeat*VIRTUAL_WIDTH],*yptr); free(linesurf); diff --git a/libretro/libretro-core.h b/libretro/libretro-core.h index 494331f..ae328f0 100644 --- a/libretro/libretro-core.h +++ b/libretro/libretro-core.h @@ -58,11 +58,20 @@ extern int pauseg; #ifndef RENDER16B #define RGB565(r, g, b) (((r) << (5+16)) | ((g) << (5+8)) | (b<<5)) +#define R_RGB(rgb) (((rgb) >> (5+16)) & 255) +#define G_RGB(rgb) (((rgb) >> (5+8)) & 255) +#define B_RGB(rgb) ((rgb>>5) & 255) #else #if defined(ABGR1555) #define RGB565(r, g, b) (((b) << (10)) | ((g) << 5) | (r)) +#define B_RGB(rgb) (((rgb) >> (10)) & 31) +#define G_RGB(rgb) (((rgb) >> 5) & 31) +#define R_RGB(rgb) (rgb & 31) #else #define RGB565(r, g, b) (((r) << (5+6)) | ((g) << 6) | (b)) +#define R_RGB(rgb) (((rgb) >> (5+6)) & 31) +#define G_RGB(rgb) (((rgb) >> 6) & 31) +#define B_RGB(rgb) (rgb & 31) #endif #endif #define uint32 unsigned int