mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 07:38:05 -04:00
pandora: allow to move the overlay partially offscreen
to allow to cut off black bars, if the user chooses to do so
This commit is contained in:
parent
70db485b44
commit
ca980e1b0a
3 changed files with 86 additions and 51 deletions
|
@ -38,6 +38,8 @@
|
|||
static struct vout_fbdev *main_fb, *layer_fb;
|
||||
// g_layer_* - in use, g_layer_c* - configured custom
|
||||
int g_layer_cx = 80, g_layer_cy, g_layer_cw = 640, g_layer_ch = 480;
|
||||
int saved_start_line = 0, saved_line_count = 240;
|
||||
int saved_start_col = 0, saved_col_count = 320;
|
||||
static int g_layer_x, g_layer_y;
|
||||
static int g_layer_w = 320, g_layer_h = 240;
|
||||
static int g_osd_start_x, g_osd_fps_x, g_osd_y, doing_bg_frame;
|
||||
|
@ -47,22 +49,6 @@ static void *temp_frame;
|
|||
const char *renderer_names[] = { NULL };
|
||||
const char *renderer_names32x[] = { NULL };
|
||||
|
||||
static const char * const pandora_gpio_keys[KEY_MAX + 1] = {
|
||||
[KEY_UP] = "Up",
|
||||
[KEY_LEFT] = "Left",
|
||||
[KEY_RIGHT] = "Right",
|
||||
[KEY_DOWN] = "Down",
|
||||
[KEY_HOME] = "A",
|
||||
[KEY_PAGEDOWN] = "X",
|
||||
[KEY_END] = "B",
|
||||
[KEY_PAGEUP] = "Y",
|
||||
[KEY_RIGHTSHIFT]= "L",
|
||||
[KEY_RIGHTCTRL] = "R",
|
||||
[KEY_LEFTALT] = "Start",
|
||||
[KEY_LEFTCTRL] = "Select",
|
||||
[KEY_MENU] = "Pandora",
|
||||
};
|
||||
|
||||
static struct in_default_bind in_evdev_defbinds[] =
|
||||
{
|
||||
{ KEY_UP, IN_BINDTYPE_PLAYER12, GBTN_UP },
|
||||
|
@ -314,6 +300,13 @@ static int pnd_setup_layer_(int fd, int enabled, int x, int y, int w, int h)
|
|||
|
||||
int pnd_setup_layer(int enabled, int x, int y, int w, int h)
|
||||
{
|
||||
// it's not allowed for the layer to be partially offscreen,
|
||||
// instead it is faked by emu_video_mode_change()
|
||||
if (x < 0) { w += x; x = 0; }
|
||||
if (y < 0) { h += y; y = 0; }
|
||||
if (x + w > 800) w = 800 - x;
|
||||
if (y + h > 480) h = 480 - y;
|
||||
|
||||
return pnd_setup_layer_(vout_fbdev_get_fd(layer_fb), enabled, x, y, w, h);
|
||||
}
|
||||
|
||||
|
@ -332,26 +325,22 @@ void pnd_restore_layer_data(void)
|
|||
|
||||
void emu_video_mode_change(int start_line, int line_count, int start_col, int col_count)
|
||||
{
|
||||
int fb_w = 320, fb_h = 240, fb_left = 0, fb_right = 0, fb_top = 0, fb_bottom = 0;
|
||||
int fb_w, fb_h = 240, fb_left = 0, fb_right = 0, fb_top = 0, fb_bottom = 0;
|
||||
|
||||
if (doing_bg_frame)
|
||||
return;
|
||||
|
||||
fb_w = col_count;
|
||||
fb_left = start_col;
|
||||
fb_right = 320 - (fb_w + fb_left);
|
||||
|
||||
switch (currentConfig.scaling) {
|
||||
case SCALE_1x1:
|
||||
g_layer_w = fb_w;
|
||||
g_layer_w = col_count;
|
||||
g_layer_h = fb_h;
|
||||
break;
|
||||
case SCALE_2x2_3x2:
|
||||
g_layer_w = fb_w * (col_count < 320 ? 3 : 2);
|
||||
g_layer_w = col_count * (col_count < 320 ? 3 : 2);
|
||||
g_layer_h = fb_h * 2;
|
||||
break;
|
||||
case SCALE_2x2_2x2:
|
||||
g_layer_w = fb_w * 2;
|
||||
g_layer_w = col_count * 2;
|
||||
g_layer_h = fb_h * 2;
|
||||
break;
|
||||
case SCALE_FULLSCREEN:
|
||||
|
@ -376,17 +365,38 @@ void emu_video_mode_change(int start_line, int line_count, int start_col, int co
|
|||
case SCALE_FULLSCREEN:
|
||||
case SCALE_CUSTOM:
|
||||
fb_top = start_line;
|
||||
fb_h = line_count;
|
||||
fb_h = start_line + line_count;
|
||||
break;
|
||||
}
|
||||
g_osd_start_x = start_col;
|
||||
g_osd_fps_x = start_col + col_count - 5*8 - 2;
|
||||
g_osd_y = fb_top + fb_h - 8;
|
||||
fb_w = 320;
|
||||
fb_left = start_col;
|
||||
fb_right = 320 - (start_col + col_count);
|
||||
if (currentConfig.scaling == SCALE_CUSTOM) {
|
||||
int right = g_layer_x + g_layer_w;
|
||||
int bottom = g_layer_y + g_layer_h;
|
||||
if (g_layer_x < 0)
|
||||
fb_left += -g_layer_x * col_count / g_menuscreen_w;
|
||||
if (g_layer_y < 0)
|
||||
fb_top += -g_layer_y * line_count / g_menuscreen_h;
|
||||
if (right > g_menuscreen_w)
|
||||
fb_right += (right - g_menuscreen_w) * col_count / g_menuscreen_w;
|
||||
if (bottom > g_menuscreen_h)
|
||||
fb_bottom += (bottom - g_menuscreen_h) * line_count / g_menuscreen_h;
|
||||
}
|
||||
fb_w -= fb_left + fb_right;
|
||||
fb_h -= fb_top + fb_bottom;
|
||||
|
||||
pnd_setup_layer(1, g_layer_x, g_layer_y, g_layer_w, g_layer_h);
|
||||
vout_fbdev_resize(layer_fb, fb_w, fb_h, 16, fb_left, fb_right, fb_top, fb_bottom, 4, 0);
|
||||
vout_fbdev_clear(layer_fb);
|
||||
plat_video_flip();
|
||||
|
||||
g_osd_start_x = start_col;
|
||||
g_osd_fps_x = start_col + col_count - 5*8 - 2;
|
||||
g_osd_y = fb_top + fb_h - 8;
|
||||
|
||||
saved_start_line = start_line, saved_line_count = line_count;
|
||||
saved_start_col = start_col, saved_col_count = col_count;
|
||||
}
|
||||
|
||||
void plat_video_loop_prepare(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue