aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneonloop2021-08-27 16:37:06 +0000
committerneonloop2021-08-27 16:37:06 +0000
commit1a24f2c55bb5e950c5bdd68c83926f14d7626998 (patch)
tree48b9a26a2a4b942c0df66570fe55d90e5ea4e129
parent3f527c7426cbbdbd04962545b801c944434a0377 (diff)
downloadpicoarch-1a24f2c55bb5e950c5bdd68c83926f14d7626998.tar.gz
picoarch-1a24f2c55bb5e950c5bdd68c83926f14d7626998.tar.bz2
picoarch-1a24f2c55bb5e950c5bdd68c83926f14d7626998.zip
Adds eggs' 1.5x sharp scaler for GB resolutions
-rw-r--r--menu.c6
-rw-r--r--scale.c57
2 files changed, 60 insertions, 3 deletions
diff --git a/menu.c b/menu.c
index 77b1664..6ba1488 100644
--- a/menu.c
+++ b/menu.c
@@ -27,11 +27,11 @@ typedef enum
MA_MAIN_LOAD_STATE,
MA_MAIN_DISC_CTRL,
MA_MAIN_CORE_SEL,
- MA_MAIN_CORE_OPTS,
MA_MAIN_CONTENT_SEL,
MA_MAIN_RESET_GAME,
MA_MAIN_CREDITS,
MA_MAIN_EXIT,
+ MA_OPT_CORE_OPTS,
MA_OPT_SAVECFG,
MA_OPT_SAVECFG_GAME,
MA_OPT_RMCFG_GAME,
@@ -519,7 +519,7 @@ static int menu_loop_config_options(int id, int keys)
static menu_entry e_menu_options[] =
{
mee_handler ("Audio and video", menu_loop_video_options),
- mee_handler_id("Emulator options", MA_MAIN_CORE_OPTS, menu_loop_core_options),
+ mee_handler_id("Emulator options", MA_OPT_CORE_OPTS, menu_loop_core_options),
mee_handler_id("Player controls", MA_CTRL_PLAYER1, key_config_loop_wrap),
mee_handler_id("Emulator controls", MA_CTRL_EMU, key_config_loop_wrap),
mee_handler ("Save config", menu_loop_config_options),
@@ -615,7 +615,7 @@ void menu_loop(void)
bool needs_disc_ctrl = disc_get_count() > 1;
plat_video_menu_enter(1);
- me_enable(e_menu_main, MA_MAIN_CORE_OPTS, core_options.visible_len > 0);
+ me_enable(e_menu_options, MA_OPT_CORE_OPTS, core_options.visible_len > 0);
me_enable(e_menu_main, MA_MAIN_SAVE_STATE, state_allowed());
me_enable(e_menu_main, MA_MAIN_LOAD_STATE, state_allowed());
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;