Unverified Commit e362d5c0 authored by Mr-Figs's avatar Mr-Figs Committed by GitHub
Browse files

Add screen-gap core option (#128)

* Add screen-gap core option

* Fix screen-gap with OpenGL
parent 5c38b09f
Pipeline #62020 canceled with stages
......@@ -114,6 +114,18 @@ void retro_set_environment(retro_environment_t cb)
struct retro_vfs_interface_info vfs_iface_info;
environ_cb = cb;
std::string screen_gap = "Screen gap; ";
static const int MAX_SCREEN_GAP = 192; // arbitrarily choose screen Y res
for (int i = 0; i <= MAX_SCREEN_GAP; i++)
{
screen_gap.append(std::to_string(i));
if (i != MAX_SCREEN_GAP)
screen_gap.append("|");
}
#ifdef HAVE_OPENGL
std::string opengl_resolution = "OpenGL Internal Resolution; ";
......@@ -157,6 +169,7 @@ void retro_set_environment(retro_environment_t cb)
{ "melonds_console_mode", "Console Mode; DS|DSi" },
{ "melonds_boot_directly", "Boot game directly; enabled|disabled" },
{ "melonds_screen_layout", "Screen Layout; Top/Bottom|Bottom/Top|Left/Right|Right/Left|Top Only|Bottom Only|Hybrid Top|Hybrid Bottom" },
{ "melonds_screen_gap", screen_gap.c_str() },
{ "melonds_hybrid_small_screen", "Hybrid small screen mode; Bottom|Top|Duplicate" },
{ "melonds_swapscreen_mode", "Swap Screen mode; Toggle|Hold" },
#ifdef HAVE_THREADS
......@@ -291,6 +304,12 @@ static void check_variables(bool init)
layout = ScreenLayout::HybridBottom;
}
var.key = "melonds_screen_gap";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
screen_layout_data.screen_gap_unscaled = std::stoi(var.value);
}
#ifdef HAVE_OPENGL
var.key = "melonds_hybrid_ratio";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value != NULL)
......
......@@ -177,6 +177,7 @@ void setup_opengl_frame_state(void)
float screen_width = (float)screen_layout_data.screen_width;
float screen_height = (float)screen_layout_data.screen_height;
float screen_gap = (float)screen_layout_data.screen_gap;
float top_screen_x = 0.0f;
float top_screen_y = 0.0f;
......@@ -206,10 +207,10 @@ void setup_opengl_frame_state(void)
switch (screen_layout_data.displayed_layout)
{
case ScreenLayout::TopBottom:
bottom_screen_y = screen_height;
bottom_screen_y = screen_height + screen_gap;
break;
case ScreenLayout::BottomTop:
top_screen_y = screen_height;
top_screen_y = screen_height + screen_gap;
break;
case ScreenLayout::LeftRight:
bottom_screen_x = screen_width;
......
......@@ -37,6 +37,7 @@ void update_screenlayout(ScreenLayout layout, ScreenLayoutData *data, bool openg
data->screen_width = VIDEO_WIDTH * scale;
data->screen_height = VIDEO_HEIGHT * scale;
data->screen_gap = data->screen_gap_unscaled * scale;
current_screen_layout = layout;
......@@ -79,14 +80,14 @@ void update_screenlayout(ScreenLayout layout, ScreenLayoutData *data, bool openg
data->direct_copy = true;
data->buffer_width = data->screen_width;
data->buffer_height = data->screen_height * 2;
data->buffer_height = data->screen_height * 2 + data->screen_gap;
data->buffer_stride = data->screen_width * pixel_size;
data->touch_offset_x = 0;
data->touch_offset_y = data->screen_height;
data->touch_offset_y = data->screen_height + data->screen_gap;
data->top_screen_offset = 0;
data->bottom_screen_offset = data->buffer_width * data->screen_height;
data->bottom_screen_offset = data->buffer_width * (data->screen_height + data->screen_gap);
break;
case ScreenLayout::BottomTop:
......@@ -95,13 +96,13 @@ void update_screenlayout(ScreenLayout layout, ScreenLayoutData *data, bool openg
data->direct_copy = true;
data->buffer_width = data->screen_width;
data->buffer_height = data->screen_height * 2;
data->buffer_height = data->screen_height * 2 + data->screen_gap;
data->buffer_stride = data->screen_width * pixel_size;
data->touch_offset_x = 0;
data->touch_offset_y = 0;
data->top_screen_offset = data->buffer_width * data->screen_height;
data->top_screen_offset = data->buffer_width * (data->screen_height + data->screen_gap);
data->bottom_screen_offset = 0;
break;
......@@ -218,4 +219,4 @@ void clean_screenlayout_buffer(ScreenLayoutData *data)
unsigned size = data->buffer_stride * data->buffer_height;
memset(data->buffer_ptr, 0, size);
}
\ No newline at end of file
}
......@@ -54,6 +54,9 @@ struct ScreenLayoutData
unsigned touch_offset_x;
unsigned touch_offset_y;
unsigned screen_gap_unscaled;
unsigned screen_gap;
bool hybrid;
SmallScreenLayout hybrid_small_screen;
unsigned hybrid_ratio;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment