aboutsummaryrefslogtreecommitdiff
path: root/scale.c
diff options
context:
space:
mode:
authorneonloop2021-08-27 16:37:06 +0000
committerneonloop2021-08-27 16:37:06 +0000
commit1a24f2c55bb5e950c5bdd68c83926f14d7626998 (patch)
tree48b9a26a2a4b942c0df66570fe55d90e5ea4e129 /scale.c
parent3f527c7426cbbdbd04962545b801c944434a0377 (diff)
downloadpicoarch-1a24f2c55bb5e950c5bdd68c83926f14d7626998.tar.gz
picoarch-1a24f2c55bb5e950c5bdd68c83926f14d7626998.tar.bz2
picoarch-1a24f2c55bb5e950c5bdd68c83926f14d7626998.zip
Adds eggs' 1.5x sharp scaler for GB resolutions
Diffstat (limited to 'scale.c')
-rw-r--r--scale.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/scale.c b/scale.c
index b145d60..acf03e3 100644
--- a/scale.c
+++ b/scale.c
@@ -246,6 +246,52 @@ static void scale_blend(unsigned w, unsigned h, size_t pitch, const void *src, v
}
}
+#define DARKER(c1, c2) (c1 > c2 ? c2 : c1)
+
+// GB 160x144 to 240x216 (40,12) via eggs
+static void scale_sharp_160x144_240x216(unsigned _w, unsigned _h, size_t pitch, const void *src_bytes, void *dst_bytes) {
+ register uint_fast16_t a,b,c,d,e,f;
+ uint32_t x,y;
+ uint16_t *src = (uint16_t *)src_bytes;
+ uint16_t *dst = (uint16_t *)dst_bytes;
+ size_t pitch16 = pitch / sizeof(uint16_t);
+
+ dst += dst_offs / sizeof(uint16_t);
+
+ for (y=(144/2); y>0 ; y--, src+=(pitch16*2 - 160), dst+=(SCREEN_WIDTH*3 - 240))
+ {
+ for (x=(160/4); x>0; x--, src+=4, dst+=6)
+ {
+ a = *(src+0);
+ b = *(src+1);
+ c = *(src+pitch16);
+ d = *(src+pitch16+1);
+ e = DARKER(a,c);
+ f = DARKER(b,d);
+
+ *(uint32_t*)(dst+ 0) = a|(DARKER(a,b)<<16);
+ *(uint32_t*)(dst+SCREEN_WIDTH ) = e|(DARKER(e,f)<<16);
+ *(uint32_t*)(dst+SCREEN_WIDTH*2) = c|(DARKER(c,d)<<16);
+
+ c = *(src+pitch16+2);
+ a = *(src+2);
+ e = DARKER(a,c);
+
+ *(uint32_t*)(dst+ 2) = b|(a<<16);
+ *(uint32_t*)(dst+SCREEN_WIDTH+ 2) = f|(e<<16);
+ *(uint32_t*)(dst+(SCREEN_WIDTH*2)+2) = d|(c<<16);
+
+ b = *(src+3);
+ d = *(src+pitch16+3);
+ f = DARKER(b,d);
+
+ *(uint32_t*)(dst+ 4) = DARKER(a,b)|(b<<16);
+ *(uint32_t*)(dst+SCREEN_WIDTH+ 4) = DARKER(e,f)|(f<<16);
+ *(uint32_t*)(dst+(SCREEN_WIDTH*2)+4) = DARKER(c,d)|(d<<16);
+ }
+ }
+}
+
/* drowsnug's nofilter upscaler, edited by eggs for smoothness */
static void scale_sharp_240x160_320xXXX(unsigned _w, unsigned _h, size_t _pitch, const void *src_bytes, void *dst_bytes)
{
@@ -389,6 +435,17 @@ static void scale_select_scaler(unsigned w, unsigned h, size_t pitch) {
return;
}
+ if (!scaler && w == 160 && h == 144) {
+ if (scale_size == SCALE_SIZE_ASPECT && scale_filter == SCALE_FILTER_SHARP) {
+ unsigned dst_x = ((320 - 240) * SCREEN_BPP / 2);
+ unsigned dst_y = ((240 - 216) / 2);
+ dst_offs = dst_y * SCREEN_PITCH + dst_x;
+
+ scaler = scale_sharp_160x144_240x216;
+ return;
+ }
+ }
+
if (!scaler && w == 240 && h == 160) {
if (scale_filter == SCALE_FILTER_SHARP) {
scaler = scale_sharp_240x160_320xXXX;