1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Merge pull request #13068 from fjtrujy/ps2/change_res

Change Resolution for PS2 platform
This commit is contained in:
Autechre 2021-10-05 12:42:07 +02:00 committed by GitHub
commit a264cad19a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 802 additions and 284 deletions

View File

@ -167,6 +167,23 @@
"cStandard": "c11", "cStandard": "c11",
"cppStandard": "c++11", "cppStandard": "c++11",
"intelliSenseMode": "gcc-x64" "intelliSenseMode": "gcc-x64"
},
{
"name": "ps2sdk-ee",
"includePath": [
"${env:PS2DEV}/ps2sdk/common/include",
"${env:PS2DEV}/ps2sdk/ee/include",
"${env:PS2DEV}/gsKit/include",
"${workspaceFolder}/**"
],
"defines": [
"PS2",
"_EE"
],
"compilerPath": "${env:PS2DEV}/ee/bin/mips64r5900el-ps2-elf-gcc",
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "gcc-x64"
} }
], ],
"version": 4 "version": 4

View File

@ -30,7 +30,7 @@ ASFLAGS = $(CFLAGS)
RARCH_DEFINES += -DPS2 -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DHAVE_REWIND -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_PATCH -DHAVE_CHEATS RARCH_DEFINES += -DPS2 -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DHAVE_REWIND -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_PATCH -DHAVE_CHEATS
RARCH_DEFINES += -DHAVE_ZLIB -DHAVE_NO_BUILTINZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -D_7ZIP_ST -DHAVE_CC_RESAMPLER -DHAVE_AUDIOMIXER RARCH_DEFINES += -DHAVE_ZLIB -DHAVE_NO_BUILTINZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -D_7ZIP_ST -DHAVE_CC_RESAMPLER -DHAVE_AUDIOMIXER
RARCH_DEFINES += -DHAVE_VIDEO_FILTER -DHAVE_RGUI RARCH_DEFINES += -DHAVE_WINDOW_OFFSET -DHAVE_VIDEO_FILTER -DHAVE_RGUI
RARCH_DEFINES += -DHAVE_DSP_FILTER RARCH_DEFINES += -DHAVE_DSP_FILTER
LDFLAGS += -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ports/lib -L. LDFLAGS += -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ports/lib -L.

View File

@ -280,6 +280,12 @@
#define DEFAULT_FULLSCREEN_Y 0 #define DEFAULT_FULLSCREEN_Y 0
#endif #endif
#if defined(HAVE_WINDOW_OFFSET)
/* Screen offsets to center content in CTRs */
#define DEFAULT_WINDOW_OFFSET_X 0
#define DEFAULT_WINDOW_OFFSET_Y 0
#endif
/* Number of threads to use for video recording */ /* Number of threads to use for video recording */
#define DEFAULT_VIDEO_RECORD_THREADS 2 #define DEFAULT_VIDEO_RECORD_THREADS 2

View File

@ -2327,6 +2327,10 @@ static struct config_int_setting *populate_settings_int(
#endif #endif
#ifdef HAVE_D3D12 #ifdef HAVE_D3D12
SETTING_INT("d3d12_gpu_index", &settings->ints.d3d12_gpu_index, true, DEFAULT_D3D12_GPU_INDEX, false); SETTING_INT("d3d12_gpu_index", &settings->ints.d3d12_gpu_index, true, DEFAULT_D3D12_GPU_INDEX, false);
#endif
#ifdef HAVE_WINDOW_OFFSET
SETTING_INT("video_window_offset_x", &settings->ints.video_window_offset_x, true, DEFAULT_WINDOW_OFFSET_X, false);
SETTING_INT("video_window_offset_y", &settings->ints.video_window_offset_y, true, DEFAULT_WINDOW_OFFSET_Y, false);
#endif #endif
SETTING_INT("content_favorites_size", &settings->ints.content_favorites_size, true, default_content_favorites_size, false); SETTING_INT("content_favorites_size", &settings->ints.content_favorites_size, true, default_content_favorites_size, false);

View File

@ -140,6 +140,10 @@ typedef struct settings
#endif #endif
#ifdef HAVE_D3D12 #ifdef HAVE_D3D12
int d3d12_gpu_index; int d3d12_gpu_index;
#endif
#ifdef HAVE_WINDOW_OFFSET
int video_window_offset_x;
int video_window_offset_y;
#endif #endif
int content_favorites_size; int content_favorites_size;
} ints; } ints;

View File

@ -2527,7 +2527,7 @@ bool win32_get_video_output(DEVMODE *dm, int mode, size_t len)
return true; return true;
} }
void win32_get_video_output_size(unsigned *width, unsigned *height) void win32_get_video_output_size(unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
DEVMODE dm; DEVMODE dm;

View File

@ -113,7 +113,7 @@ void win32_set_window(unsigned *width, unsigned *height,
bool fullscreen, bool windowed_full, void *rect_data); bool fullscreen, bool windowed_full, void *rect_data);
void win32_get_video_output_size( void win32_get_video_output_size(
unsigned *width, unsigned *height); unsigned *width, unsigned *height, char *desc, size_t desc_len);
void win32_get_video_output_prev( void win32_get_video_output_prev(
unsigned *width, unsigned *height); unsigned *width, unsigned *height);

View File

@ -1750,9 +1750,9 @@ static uint32_t d3d10_get_flags(void *data)
#ifndef __WINRT__ #ifndef __WINRT__
static void d3d10_get_video_output_size(void *data, static void d3d10_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
win32_get_video_output_size(width, height); win32_get_video_output_size(width, height, desc, desc_len);
} }
static void d3d10_get_video_output_prev(void *data) static void d3d10_get_video_output_prev(void *data)

View File

@ -2325,9 +2325,9 @@ static bool d3d11_get_hw_render_interface(
#ifndef __WINRT__ #ifndef __WINRT__
static void d3d11_get_video_output_size(void *data, static void d3d11_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
win32_get_video_output_size(width, height); win32_get_video_output_size(width, height, desc, desc_len);
} }
static void d3d11_get_video_output_prev(void *data) static void d3d11_get_video_output_prev(void *data)

View File

@ -2208,9 +2208,9 @@ static uint32_t d3d12_get_flags(void *data)
#ifndef __WINRT__ #ifndef __WINRT__
static void d3d12_get_video_output_size(void *data, static void d3d12_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
win32_get_video_output_size(width, height); win32_get_video_output_size(width, height, desc, desc_len);
} }
static void d3d12_get_video_output_prev(void *data) static void d3d12_get_video_output_prev(void *data)

View File

@ -349,7 +349,7 @@ static void fpga_set_osd_msg(void *data,
} }
static void fpga_get_video_output_size(void *data, static void fpga_get_video_output_size(void *data,
unsigned *width, unsigned *height) { } unsigned *width, unsigned *height, char *desc, size_t desc_len) { }
static void fpga_get_video_output_prev(void *data) { } static void fpga_get_video_output_prev(void *data) { }
static void fpga_get_video_output_next(void *data) { } static void fpga_get_video_output_next(void *data) { }

View File

@ -684,9 +684,9 @@ static void gdi_unload_texture(void *data,
static uint32_t gdi_get_flags(void *data) { return 0; } static uint32_t gdi_get_flags(void *data) { return 0; }
static void gdi_get_video_output_size(void *data, static void gdi_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
win32_get_video_output_size(width, height); win32_get_video_output_size(width, height, desc, desc_len);
} }
static void gdi_get_video_output_prev(void *data) static void gdi_get_video_output_prev(void *data)

View File

@ -1214,14 +1214,14 @@ static void gl1_set_texture_frame(void *data,
} }
static void gl1_get_video_output_size(void *data, static void gl1_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
gl1_t *gl = (gl1_t*)data; gl1_t *gl = (gl1_t*)data;
if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_size) if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_size)
return; return;
gl->ctx_driver->get_video_output_size( gl->ctx_driver->get_video_output_size(
gl->ctx_data, gl->ctx_data,
width, height); width, height, desc, desc_len);
} }
static void gl1_get_video_output_prev(void *data) static void gl1_get_video_output_prev(void *data)

View File

@ -4417,14 +4417,14 @@ static void gl2_apply_state_changes(void *data)
} }
static void gl2_get_video_output_size(void *data, static void gl2_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
gl2_t *gl = (gl2_t*)data; gl2_t *gl = (gl2_t*)data;
if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_size) if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_size)
return; return;
gl->ctx_driver->get_video_output_size( gl->ctx_driver->get_video_output_size(
gl->ctx_data, gl->ctx_data,
width, height); width, height, desc, desc_len);
} }
static void gl2_get_video_output_prev(void *data) static void gl2_get_video_output_prev(void *data)

View File

@ -2221,14 +2221,14 @@ static void gl_core_set_texture_enable(void *data, bool state, bool full_screen)
} }
static void gl_core_get_video_output_size(void *data, static void gl_core_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
gl_core_t *gl = (gl_core_t*)data; gl_core_t *gl = (gl_core_t*)data;
if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_size) if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_size)
return; return;
gl->ctx_driver->get_video_output_size( gl->ctx_driver->get_video_output_size(
gl->ctx_data, gl->ctx_data,
width, height); width, height, desc, desc_len);
} }
static void gl_core_get_video_output_prev(void *data) static void gl_core_get_video_output_prev(void *data)

View File

@ -600,7 +600,7 @@ static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
} }
static void gx_get_video_output_size(void *data, static void gx_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
if (!global) if (!global)
@ -621,6 +621,7 @@ static void gx_get_video_output_size(void *data,
static void setup_video_mode(gx_video_t *gx) static void setup_video_mode(gx_video_t *gx)
{ {
unsigned width, height; unsigned width, height;
char desc[64] = {0};
if (!gx->framebuf[0]) if (!gx->framebuf[0])
{ {
@ -633,7 +634,7 @@ static void setup_video_mode(gx_video_t *gx)
gx->orientation = ORIENTATION_NORMAL; gx->orientation = ORIENTATION_NORMAL;
OSInitThreadQueue(&g_video_cond); OSInitThreadQueue(&g_video_cond);
gx_get_video_output_size(gx, &width, &height); gx_get_video_output_size(gx, &width, &height, desc, sizeof(desc));
gx_set_video_mode(gx, width, height, true); gx_set_video_mode(gx, width, height, true);
} }

View File

@ -424,7 +424,7 @@ static void network_set_texture_frame(void *data,
} }
static void network_get_video_output_size(void *data, static void network_get_video_output_size(void *data,
unsigned *width, unsigned *height) { } unsigned *width, unsigned *height, char *desc, size_t desc_len) { }
static void network_get_video_output_prev(void *data) { } static void network_get_video_output_prev(void *data) { }
static void network_get_video_output_next(void *data) { } static void network_get_video_output_next(void *data) { }

View File

@ -24,12 +24,40 @@
#include "../../libretro-common/include/libretro_gskit_ps2.h" #include "../../libretro-common/include/libretro_gskit_ps2.h"
/* Generic tint color */ /* Generic tint color */
#define GS_TEXT GS_SETREG_RGBA(0x80,0x80,0x80,0x80) #define GS_TEXT GS_SETREG_RGBA(0x80, 0x80, 0x80, 0x80)
/* turn black GS Screen */ /* turn black GS Screen */
#define GS_BLACK GS_SETREG_RGBA(0x00,0x00,0x00,0x80) #define GS_BLACK GS_SETREG_RGBA(0x00, 0x00, 0x00, 0x80)
#define NTSC_WIDTH 640 #define NUM_RM_VMODES 7
#define NTSC_HEIGHT 448 #define PS2_RESOLUTION_LAST NUM_RM_VMODES - 1
#define RM_VMODE_AUTO 0
/* RM Vmode -> GS Vmode conversion table */
struct rm_mode
{
char mode;
short int width;
short int height;
short int VCK;
short int interlace;
short int field;
short int PAR1; /* Pixel Aspect Ratio 1 (For video modes with non-square pixels, like PAL/NTSC) */
short int PAR2; /* Pixel Aspect Ratio 2 (For video modes with non-square pixels, like PAL/NTSC) */
char *desc;
};
static struct rm_mode rm_mode_table[NUM_RM_VMODES] = {
/* SDTV modes */
{-1, 704, -1, 4, GS_INTERLACED, GS_FIELD, -1, 11, "AUTO"},
{GS_MODE_PAL, 704, 576, 4, GS_INTERLACED, GS_FIELD, 12, 11, "PAL@50Hz"},
{GS_MODE_NTSC, 704, 480, 4, GS_INTERLACED, GS_FIELD, 10, 11, "NTSC@60Hz"},
/* SDTV special modes */
{GS_MODE_PAL, 704, 288, 4, GS_NONINTERLACED, GS_FRAME, 12, 22, "PAL@50Hz-288p"},
{GS_MODE_NTSC, 704, 240, 4, GS_NONINTERLACED, GS_FRAME, 10, 22, "NTSC@60Hz-240p"},
/* EDTV modes (component cable!) */
{GS_MODE_DTV_480P, 704, 480, 2, GS_NONINTERLACED, GS_FRAME, 10, 11, "DTV480P@60Hz"},
{GS_MODE_DTV_576P, 704, 576, 2, GS_NONINTERLACED, GS_FRAME, 12, 11, "DTV576P@50Hz"},
};
typedef struct ps2_video typedef struct ps2_video
{ {
@ -41,9 +69,13 @@ typedef struct ps2_video
int vsync_callback_id; int vsync_callback_id;
bool force_aspect; bool force_aspect;
int8_t vmode;
int video_window_offset_x;
int video_window_offset_y;
int PSM; int PSM;
int tex_filter;
int menu_filter; int menu_filter;
int core_filter;
video_viewport_t vp; video_viewport_t vp;
@ -53,6 +85,17 @@ typedef struct ps2_video
GSGLOBAL *gsGlobal; GSGLOBAL *gsGlobal;
GSTEXTURE *menuTexture; GSTEXTURE *menuTexture;
GSTEXTURE *coreTexture; GSTEXTURE *coreTexture;
/* Last scaling state, for detecting changes */
int iTextureWidth;
int iTextureHeight;
float fDAR;
bool bScaleInteger;
struct retro_hw_ps2_insets padding;
/* Current scaling calculation result */
int iDisplayWidth;
int iDisplayHeight;
} ps2_video_t; } ps2_video_t;
static int vsync_sema_id; static int vsync_sema_id;
@ -66,50 +109,33 @@ static int vsync_handler()
return 0; return 0;
} }
static GSGLOBAL *init_GSGlobal(void) static void rmEnd(ps2_video_t *ps2)
{ {
ee_sema_t sema; if (!ps2->gsGlobal)
sema.init_count = 0; return;
sema.max_count = 1;
sema.option = 0;
vsync_sema_id = CreateSema(&sema);
GSGLOBAL *gsGlobal = gsKit_init_global(); gsKit_deinit_global(ps2->gsGlobal);
gsKit_remove_vsync_handler(ps2->vsync_callback_id);
gsGlobal->Mode = GS_MODE_NTSC;
gsGlobal->Interlace = GS_INTERLACED;
gsGlobal->Field = GS_FIELD;
gsGlobal->Width = NTSC_WIDTH;
gsGlobal->Height = NTSC_HEIGHT;
gsGlobal->PSM = GS_PSM_CT16;
gsGlobal->PSMZ = GS_PSMZ_16;
gsGlobal->DoubleBuffering = GS_SETTING_OFF;
gsGlobal->ZBuffering = GS_SETTING_OFF;
gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
/* Initialize the DMAC */
dmaKit_chan_init(DMA_CHANNEL_GIF);
gsKit_init_screen(gsGlobal);
gsKit_mode_switch(gsGlobal, GS_ONESHOT);
gsKit_set_test(gsGlobal, GS_ZTEST_OFF);
gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0);
gsKit_clear(gsGlobal, GS_BLACK);
return gsGlobal;
} }
static void deinit_GSGlobal(GSGLOBAL *gsGlobal) static void updateOffSetsIfNeeded(ps2_video_t *ps2)
{ {
gsKit_clear(gsGlobal, GS_BLACK); bool shouldUpdate = false;
gsKit_vram_clear(gsGlobal); settings_t *settings = config_get_ptr();
gsKit_deinit_global(gsGlobal); int video_window_offset_x = settings->ints.video_window_offset_x;
int video_window_offset_y = settings->ints.video_window_offset_y;
if (video_window_offset_x != ps2->video_window_offset_x || video_window_offset_y != ps2->video_window_offset_y)
shouldUpdate = true;
if (!shouldUpdate)
return;
ps2->video_window_offset_x = video_window_offset_x;
ps2->video_window_offset_y = video_window_offset_y;
gsKit_set_display_offset(ps2->gsGlobal, ps2->video_window_offset_x * rm_mode_table[ps2->vmode].VCK, ps2->video_window_offset_y);
RARCH_LOG("PS2_GFX Change offset: %d, %d\n", ps2->video_window_offset_x, ps2->video_window_offset_y);
} }
/* Copy of gsKit_sync_flip, but without the 'flip' */ /* Copy of gsKit_sync_flip, but without the 'flip' */
@ -118,7 +144,8 @@ static void gsKit_sync(GSGLOBAL *gsGlobal)
if (!gsGlobal->FirstFrame) if (!gsGlobal->FirstFrame)
WaitSema(vsync_sema_id); WaitSema(vsync_sema_id);
while (PollSema(vsync_sema_id) >= 0); while (PollSema(vsync_sema_id) >= 0)
;
} }
/* Copy of gsKit_sync_flip, but without the 'sync' */ /* Copy of gsKit_sync_flip, but without the 'sync' */
@ -128,131 +155,292 @@ static void gsKit_flip(GSGLOBAL *gsGlobal)
{ {
if (gsGlobal->DoubleBuffering == GS_SETTING_ON) if (gsGlobal->DoubleBuffering == GS_SETTING_ON)
{ {
GS_SET_DISPFB2( gsGlobal->ScreenBuffer[ GS_SET_DISPFB2(gsGlobal->ScreenBuffer[gsGlobal->ActiveBuffer & 1] / 8192,
gsGlobal->ActiveBuffer & 1] / 8192, gsGlobal->Width / 64, gsGlobal->PSM, 0, 0);
gsGlobal->Width / 64, gsGlobal->PSM, 0, 0 );
gsGlobal->ActiveBuffer ^= 1; gsGlobal->ActiveBuffer ^= 1;
} }
} }
gsKit_setactive(gsGlobal); gsKit_setactive(gsGlobal);
} }
static void rmSetMode(ps2_video_t *ps2, int force)
{
struct rm_mode *mode;
global_t *global = global_get_ptr();
/* we don't want to set the vmode without a reason... */
if (ps2->vmode == global->console.screen.resolutions.current.id && force == 0)
return;
/* Cleanup previous gsKit instance */
if (ps2->vmode >= 0)
{
rmEnd(ps2);
/* Set new mode */
global->console.screen.resolutions.current.id = ps2->vmode;
}
else
/* first driver init */
ps2->vmode = global->console.screen.resolutions.current.id;
mode = &rm_mode_table[ps2->vmode];
/* Invalidate scaling state */
ps2->iTextureWidth = 0;
ps2->iTextureHeight = 0;
ps2->gsGlobal = gsKit_init_global();
gsKit_TexManager_setmode(ps2->gsGlobal, ETM_DIRECT);
ps2->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler);
ps2->gsGlobal->Mode = mode->mode;
ps2->gsGlobal->Width = mode->width;
ps2->gsGlobal->Height = mode->height;
ps2->gsGlobal->Interlace = mode->interlace;
ps2->gsGlobal->Field = mode->field;
ps2->gsGlobal->PSM = GS_PSM_CT16;
ps2->gsGlobal->PSMZ = GS_PSMZ_16S;
ps2->gsGlobal->DoubleBuffering = GS_SETTING_ON;
ps2->gsGlobal->ZBuffering = GS_SETTING_OFF;
ps2->gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
if ((ps2->gsGlobal->Interlace == GS_INTERLACED) && (ps2->gsGlobal->Field == GS_FRAME))
ps2->gsGlobal->Height /= 2;
/* Coordinate space ranges from 0 to 4096 pixels
* Center the buffer in the coordinate space */
ps2->gsGlobal->OffsetX = ((4096 - ps2->gsGlobal->Width) / 2) * 16;
ps2->gsGlobal->OffsetY = ((4096 - ps2->gsGlobal->Height) / 2) * 16;
gsKit_init_screen(ps2->gsGlobal);
gsKit_mode_switch(ps2->gsGlobal, GS_ONESHOT);
gsKit_set_test(ps2->gsGlobal, GS_ZTEST_OFF);
gsKit_set_test(ps2->gsGlobal, GS_ATEST_OFF);
/* reset the contents of the screen to avoid garbage being displayed */
gsKit_clear(ps2->gsGlobal, GS_BLACK);
gsKit_sync(ps2->gsGlobal);
gsKit_flip(ps2->gsGlobal);
RARCH_LOG("PS2_GFX New vmode: %d, %d x %d\n", ps2->vmode, ps2->gsGlobal->Width, ps2->gsGlobal->Height);
updateOffSetsIfNeeded(ps2);
}
static void rmInit(ps2_video_t *ps2)
{
ee_sema_t sema;
sema.init_count = 0;
sema.max_count = 1;
sema.option = 0;
vsync_sema_id = CreateSema(&sema);
short int mode = gsKit_check_rom();
rm_mode_table[RM_VMODE_AUTO].mode = mode;
rm_mode_table[RM_VMODE_AUTO].height = (mode == GS_MODE_PAL) ? 576 : 480;
rm_mode_table[RM_VMODE_AUTO].PAR1 = (mode == GS_MODE_PAL) ? 12 : 10;
dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
/* Initialize the DMAC */
dmaKit_chan_init(DMA_CHANNEL_GIF);
rmSetMode(ps2, 1);
}
static GSTEXTURE *prepare_new_texture(void) static GSTEXTURE *prepare_new_texture(void)
{ {
GSTEXTURE *texture = (GSTEXTURE*)calloc(1, sizeof(GSTEXTURE)); GSTEXTURE *texture = (GSTEXTURE *)calloc(1, sizeof(GSTEXTURE));
return texture; return texture;
} }
static void init_ps2_video(ps2_video_t *ps2) static void init_ps2_video(ps2_video_t *ps2)
{ {
ps2->gsGlobal = init_GSGlobal(); ps2->vmode = -1;
gsKit_TexManager_init(ps2->gsGlobal); rmInit(ps2);
ps2->vp.x = 0; ps2->vp.x = 0;
ps2->vp.y = 0; ps2->vp.y = 0;
ps2->vp.width = ps2->gsGlobal->Width; ps2->vp.width = ps2->gsGlobal->Width;
ps2->vp.height = ps2->gsGlobal->Height; ps2->vp.height = ps2->gsGlobal->Height;
ps2->vp.full_width = ps2->gsGlobal->Width; ps2->vp.full_width = ps2->gsGlobal->Width;
ps2->vp.full_height = ps2->gsGlobal->Height; ps2->vp.full_height = ps2->gsGlobal->Height;
ps2->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler);
ps2->menuTexture = prepare_new_texture(); ps2->menuTexture = prepare_new_texture();
ps2->coreTexture = prepare_new_texture(); ps2->coreTexture = prepare_new_texture();
ps2->video_window_offset_x = 0;
ps2->video_window_offset_y = 0;
/* Used for cores that supports palette */ /* Used for cores that supports palette */
ps2->iface.interface_type = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2; ps2->iface.interface_type = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2;
ps2->iface.interface_version = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION; ps2->iface.interface_version = RETRO_HW_RENDER_INTERFACE_GSKIT_PS2_VERSION;
ps2->iface.coreTexture = ps2->coreTexture; ps2->iface.coreTexture = ps2->coreTexture;
} }
static void ps2_gfx_deinit_texture(GSTEXTURE *texture) static void ps2_gfx_deinit_texture(GSTEXTURE *texture)
{ {
texture->Mem = NULL; texture->Mem = NULL;
texture->Clut = NULL; texture->Clut = NULL;
} }
static void set_texture(GSTEXTURE *texture, const void *frame, static void set_texture(GSTEXTURE *texture, const void *frame,
int width, int height, int PSM, int filter) int width, int height, int PSM, int filter)
{ {
texture->Width = width; texture->Width = width;
texture->Height = height; texture->Height = height;
texture->PSM = PSM; texture->PSM = PSM;
texture->Filter = filter; texture->Filter = filter;
texture->Mem = (void *)frame; texture->Mem = (void *)frame;
} }
static void prim_texture(GSGLOBAL *gsGlobal, GSTEXTURE *texture, int zPosition, float aspect_ratio, bool scale_integer, struct retro_hw_ps2_insets padding) static int ABS(int v)
{ {
float x1, y1, x2, y2; return (v >= 0) ? v : -v;
float visible_width = texture->Width - padding.left - padding.right; }
float visible_height = texture->Height - padding.top - padding.bottom;
if (scale_integer) static void setupScalingMode(ps2_video_t *ps2, int iWidth, int iHeight, float fDAR, bool bScaleInteger)
{
GSGLOBAL *gsGlobal = ps2->gsGlobal;
struct rm_mode *currMode = &rm_mode_table[ps2->vmode];
int iBestFBWidth = currMode->width;
int iBestMagH = currMode->VCK - 1;
float fPAR;
/* Calculate the pixel aspect ratio (PAR) */
fPAR = (float)currMode->PAR2 / (float)currMode->PAR1;
#if defined(DEBUG)
printf("Aspect ratio: %.4f x %.4f = %.4f\n", fDAR, fPAR, fDAR * fPAR);
#endif
if (bScaleInteger == false)
{ {
float width_proportion = (float)gsGlobal->Width / (float)visible_width; /* Assume black bars left/right */
float height_proportion = (float)gsGlobal->Height / (float)visible_height; ps2->iDisplayHeight = currMode->height;
int delta = MIN(width_proportion, height_proportion); ps2->iDisplayWidth = (int)((float)ps2->iDisplayHeight * fDAR * fPAR + 0.5f);
float newWidth = visible_width * delta; if (ps2->iDisplayWidth > currMode->width)
float newHeight = visible_height * delta; {
/* Really wide screen, black bars top/bottom */
x1 = (gsGlobal->Width - newWidth) / 2.0f; ps2->iDisplayWidth = currMode->width;
y1 = (gsGlobal->Height - newHeight) / 2.0f; ps2->iDisplayHeight = (int)((float)ps2->iDisplayWidth / (fDAR * fPAR) + 0.5f);
x2 = newWidth + x1; }
y2 = newHeight + y1;
}
else if (aspect_ratio > 0)
{
float gs_aspect_ratio = (float)gsGlobal->Width / (float)gsGlobal->Height;
float newWidth = (gs_aspect_ratio > aspect_ratio) ? gsGlobal->Height * aspect_ratio : gsGlobal->Width;
float newHeight = (gs_aspect_ratio > aspect_ratio) ? gsGlobal->Height : gsGlobal->Width / aspect_ratio;
x1 = (gsGlobal->Width - newWidth) / 2.0f;
y1 = (gsGlobal->Height - newHeight) / 2.0f;
x2 = newWidth + x1;
y2 = newHeight + y1;
} }
else else
{ {
x1 = 0.0f; /* Best match the framebuffer width/height to a multiple of the texture
y1 = 0.0f; * Width, rounded down so it always fits */
x2 = gsGlobal->Width; int iHeightScale = MAX(1, currMode->height / iHeight);
y2 = gsGlobal->Height; ps2->iDisplayHeight = iHeight * iHeightScale;
/* Height, rounded */
int iWidthScale = MAX(1, (int)((float)ps2->iDisplayHeight * fDAR * fPAR + (float)(iWidth / 2)) / iWidth);
ps2->iDisplayWidth = iWidth * iWidthScale;
#if defined(DEBUG)
printf("Integer scaling:\n");
printf("- Width = %d x %d = %d\n", iWidth, iWidthScale, ps2->iDisplayWidth);
printf("- Height = %d x %d = %d\n", iHeight, iHeightScale, ps2->iDisplayHeight);
#endif
if (currMode->VCK > 1 && ps2->iDisplayWidth < currMode->width)
{
/* We try to best match the number of "VCK" units, for the best output
* For 576i/480i: 1 pixel = 4 VCK (4x super-resolution)
* For 576p/480p: 1 pixel = 2 VCK (2x super-resolution) */
int iTargetVCK = (int)((float)ps2->iDisplayHeight * fDAR * fPAR * (float)currMode->VCK + 0.5f);
int iBestVCK = ps2->iDisplayWidth * currMode->VCK;
/* Try all possible framebuffer widths */
#if defined(DEBUG)
printf("Find match for %d * SCALE * MagH = %d VCK (current = %d VCK)\n", iWidth, iTargetVCK, iBestVCK);
#endif
int iFBWidth;
for (iFBWidth = 64; iFBWidth <= currMode->width; iFBWidth += 64)
{
/* Ignore too small framebuffers */
if (iFBWidth < iWidth)
continue;
iWidthScale = iFBWidth / iWidth;
/* Try all possible magnifications */
int iMagH;
for (iMagH = 0; iMagH < 15; iMagH++)
{
int iVCK = iWidth * iWidthScale * (iMagH + 1);
if (ABS(iTargetVCK - iVCK) < ABS(iTargetVCK - iBestVCK))
{
#if defined(DEBUG)
printf("- found %d * %d * %d = %d\n", iWidth, iWidthScale, iMagH + 1, iVCK);
#endif
/* Better match */
iBestVCK = iVCK;
iBestFBWidth = iFBWidth;
iBestMagH = iMagH;
ps2->iDisplayWidth = iWidth * iWidthScale;
}
}
}
}
} }
gsKit_prim_sprite_texture( gsGlobal, texture, if ((gsGlobal->Interlace == GS_INTERLACED) && (gsGlobal->Field == GS_FRAME))
x1, /* X1 */ ps2->iDisplayHeight /= 2;
y1, /* Y1 */
padding.left, /* U1 */
padding.top, /* V1 */
x2, /* X2 */
y2, /* Y2 */
texture->Width - padding.right, /* U2 */
texture->Height - padding.bottom, /* V2 */
zPosition,
GS_TEXT);
}
static void refreshScreen(ps2_video_t *ps2) #if defined(DEBUG)
{ printf("Texture resolution:\n");
if (ps2->vsync) printf("- Width = %d x %.2f = %d\n", iWidth, (float)ps2->iDisplayWidth / (float)iWidth, ps2->iDisplayWidth);
{ printf("- Height = %d x %.2f = %d\n", iHeight, (float)ps2->iDisplayHeight / (float)iHeight, ps2->iDisplayHeight);
gsKit_sync(ps2->gsGlobal); printf("Setting custom framebuffer:\n");
gsKit_flip(ps2->gsGlobal); printf("- Width = %d x %d / %d = %d\n", iBestFBWidth, iBestMagH + 1, currMode->VCK, iBestFBWidth * (iBestMagH + 1) / currMode->VCK);
} printf("- Height = %d x %d = %d\n", currMode->height, gsGlobal->MagV + 1, currMode->height * (gsGlobal->MagV + 1));
gsKit_queue_exec(ps2->gsGlobal); #endif
gsKit_TexManager_nextFrame(ps2->gsGlobal);
/* Center on screen by adding the difference (in VCK units). */
gsGlobal->StartX += (gsGlobal->Width * (gsGlobal->MagH + 1) - iBestFBWidth * (iBestMagH + 1)) / 2;
/* Calculate the actual display width and height, again */
gsGlobal->DW = (iBestMagH + 1) * iBestFBWidth;
/* Override magh */
gsGlobal->MagH = iBestMagH;
/* Reset VRAM allocation */
gsGlobal->CurrentPointer = 0;
/* Allocate new framebuffer(s) */
gsGlobal->ScreenBuffer[0] = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(iBestFBWidth, currMode->height, gsGlobal->PSM), GSKIT_ALLOC_SYSBUFFER);
if (gsGlobal->DoubleBuffering == GS_SETTING_ON)
gsGlobal->ScreenBuffer[1] = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(iBestFBWidth, currMode->height, gsGlobal->PSM), GSKIT_ALLOC_SYSBUFFER);
/* Set the new framebuffer as display buffer */
gsGlobal->Width = iBestFBWidth;
gsKit_display_buffer(gsGlobal);
/* Update DISPLAY1/2 register (code from gsKit) */
GS_SET_DISPLAY1(
gsGlobal->StartX + gsGlobal->StartXOffset,
gsGlobal->StartY + gsGlobal->StartYOffset,
gsGlobal->MagH,
gsGlobal->MagV,
gsGlobal->DW - 1,
gsGlobal->DH - 1);
GS_SET_DISPLAY2(
gsGlobal->StartX + gsGlobal->StartXOffset,
gsGlobal->StartY + gsGlobal->StartYOffset,
gsGlobal->MagH,
gsGlobal->MagV,
gsGlobal->DW - 1,
gsGlobal->DH - 1);
} }
static void *ps2_gfx_init(const video_info_t *video, static void *ps2_gfx_init(const video_info_t *video,
input_driver_t **input, void **input_data) input_driver_t **input, void **input_data)
{ {
void *ps2input = NULL; void *ps2input = NULL;
ps2_video_t *ps2 = (ps2_video_t*)calloc(1, sizeof(ps2_video_t)); ps2_video_t *ps2 = (ps2_video_t *)calloc(1, sizeof(ps2_video_t));
*input_data = NULL; *input_data = NULL;
if (!ps2) if (!ps2)
return NULL; return NULL;
@ -260,37 +448,38 @@ static void *ps2_gfx_init(const video_info_t *video,
init_ps2_video(ps2); init_ps2_video(ps2);
if (video->font_enable) if (video->font_enable)
font_driver_init_osd(ps2, font_driver_init_osd(ps2,
video, video,
false, false,
video->is_threaded, video->is_threaded,
FONT_DRIVER_RENDER_PS2); FONT_DRIVER_RENDER_PS2);
ps2->PSM = (video->rgb32 ? GS_PSM_CT32 : GS_PSM_CT16); ps2->PSM = (video->rgb32 ? GS_PSM_CT32 : GS_PSM_CT16);
ps2->core_filter = video->smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST; ps2->tex_filter = video->smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST;
ps2->force_aspect = video->force_aspect; ps2->force_aspect = video->force_aspect;
ps2->vsync = video->vsync; ps2->vsync = video->vsync;
if (input && input_data) if (input && input_data)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
ps2input = input_driver_init_wrap(&input_ps2, ps2input = input_driver_init_wrap(&input_ps2,
settings->arrays.input_joypad_driver); settings->arrays.input_joypad_driver);
*input = ps2input ? &input_ps2 : NULL; *input = ps2input ? &input_ps2 : NULL;
*input_data = ps2input; *input_data = ps2input;
} }
return ps2; return ps2;
} }
static bool ps2_gfx_frame(void *data, const void *frame, static bool ps2_gfx_frame(void *data, const void *frame,
unsigned width, unsigned height, uint64_t frame_count, unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg, video_frame_info_t *video_info) unsigned pitch, const char *msg, video_frame_info_t *video_info)
{ {
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t *)data;
struct font_params *osd_params = (struct font_params*) GSGLOBAL *gsGlobal = ps2->gsGlobal;
&video_info->osd_stat_params; struct font_params *osd_params = (struct font_params *)&video_info->osd_stat_params;
bool statistics_show = video_info->statistics_show; bool statistics_show = video_info->statistics_show;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
GSTEXTURE *tex = ps2->coreTexture;
if (!width || !height) if (!width || !height)
return false; return false;
@ -300,42 +489,99 @@ static bool ps2_gfx_frame(void *data, const void *frame,
printf("ps2_gfx_frame %llu\n", frame_count); printf("ps2_gfx_frame %llu\n", frame_count);
#endif #endif
/* Check if user change offset values */
updateOffSetsIfNeeded(ps2);
if (frame) if (frame)
{ {
struct retro_hw_ps2_insets padding = empty_ps2_insets; /* New frame from core, update */
float fDAR = ps2->force_aspect ? video_driver_get_aspect_ratio() : 0;
bool bScaleInteger = settings->bools.video_scale_integer;
/* Checking if the transfer is done in the core */ /* Checking if the transfer is done in the core */
if (frame != RETRO_HW_FRAME_BUFFER_VALID) if (frame != RETRO_HW_FRAME_BUFFER_VALID)
{ {
/* calculate proper width based in the pitch */ /* SW rendered texture */
int shifh_per_bytes = (ps2->PSM == GS_PSM_CT32) ? 2 : 1; int shifh_per_bytes = (ps2->PSM == GS_PSM_CT32) ? 2 : 1;
int real_width = pitch >> shifh_per_bytes; int real_width = pitch >> shifh_per_bytes;
set_texture(ps2->coreTexture, frame, real_width, height, ps2->PSM, ps2->core_filter); set_texture(tex, frame, real_width, height, ps2->PSM, ps2->tex_filter);
padding.right = real_width - width; /* Padding */
ps2->padding = empty_ps2_insets;
ps2->padding.right = real_width - width;
} }
else else
{ {
padding = ps2->iface.padding; /* "HW" rendered texture */
/* Set current filter mode */
tex->Filter = ps2->tex_filter;
/* Padding */
ps2->padding = ps2->iface.padding;
} }
float aspect_ratio = ps2->force_aspect ? video_driver_get_aspect_ratio() : 0; /* Texture dimensions */
bool scale_integer = settings->bools.video_scale_integer; int iTextureWidth = tex->Width - ps2->padding.left - ps2->padding.right;
int iTextureHeight = tex->Height - ps2->padding.top - ps2->padding.bottom;
if (ps2->iTextureWidth != iTextureWidth ||
ps2->iTextureHeight != iTextureHeight ||
ps2->fDAR != fDAR ||
ps2->bScaleInteger != bScaleInteger)
{
/* Scaling changed, try to find best matching output mode */
ps2->iTextureWidth = iTextureWidth;
ps2->iTextureHeight = iTextureHeight;
ps2->fDAR = fDAR;
ps2->bScaleInteger = bScaleInteger;
setupScalingMode(ps2, iTextureWidth, iTextureHeight, fDAR, bScaleInteger);
}
/* Disable Alpha for cores */ gsKit_TexManager_invalidate(ps2->gsGlobal, tex);
ps2->gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
gsKit_set_test(ps2->gsGlobal, GS_ATEST_OFF);
gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->coreTexture);
gsKit_TexManager_bind(ps2->gsGlobal, ps2->coreTexture);
prim_texture(ps2->gsGlobal, ps2->coreTexture, 1, aspect_ratio, scale_integer, padding);
} }
/* Center texture on framebuffer */
float fDisplayOffsetX = (gsGlobal->Width - ps2->iDisplayWidth + 1) / 2 - 0.5f;
float fDisplayOffsetY = (gsGlobal->Height - ps2->iDisplayHeight + 1) / 2 - 0.5f;
/* Draw */
gsGlobal->PrimAlphaEnable = GS_SETTING_OFF;
gsKit_TexManager_bind(gsGlobal, tex);
gsKit_prim_sprite_texture(gsGlobal, tex,
fDisplayOffsetX, /* X1 */
fDisplayOffsetY, /* Y1 */
ps2->padding.left, /* U1 */
ps2->padding.top, /* V1 */
fDisplayOffsetX + ps2->iDisplayWidth, /* X2 */
fDisplayOffsetY + ps2->iDisplayHeight, /* Y2 */
ps2->padding.left + ps2->iTextureWidth, /* U2 */
ps2->padding.top + ps2->iTextureHeight, /* V2 */
1,
GS_TEXT);
if (ps2->menuVisible) if (ps2->menuVisible)
{ {
bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height; bool texture_empty = !ps2->menuTexture->Width || !ps2->menuTexture->Height;
if (!texture_empty) if (!texture_empty)
{ {
prim_texture(ps2->gsGlobal, ps2->menuTexture, 2, 0, 0, empty_ps2_insets); #define A_COLOR_SOURCE 0
#define A_COLOR_DEST 1
#define A_COLOR_NULL 2
#define A_ALPHA_SOURCE 0
#define A_ALPHA_DEST 1
#define A_ALPHA_FIX 2
/* (A - B) * C + D */
gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(A_COLOR_DEST, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_SOURCE, 0x20), 0);
gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
gsKit_prim_sprite_texture(gsGlobal, ps2->menuTexture,
-0.5f, /* X1 */
-0.5f, /* Y1 */
0, /* U1 */
0, /* V1 */
-0.5f + (float)gsGlobal->Width, /* X2 */
-0.5f + (float)gsGlobal->Height, /* Y2 */
ps2->menuTexture->Width, /* U2 */
ps2->menuTexture->Height, /* V2 */
2,
GS_TEXT);
} }
} }
else if (statistics_show) else if (statistics_show)
@ -347,15 +593,39 @@ static bool ps2_gfx_frame(void *data, const void *frame,
if (!string_is_empty(msg)) if (!string_is_empty(msg))
font_driver_render_msg(ps2, msg, NULL, NULL); font_driver_render_msg(ps2, msg, NULL, NULL);
refreshScreen(ps2); if (gsGlobal->DoubleBuffering == GS_SETTING_OFF)
{
/* Without double buffering:
* - Wait for VSync
* - Draw to front buffer (during VSync, so it's not visible to the user) */
if (ps2->vsync)
gsKit_sync(gsGlobal);
gsKit_queue_exec(gsGlobal);
}
else
{
/* With double buffering:
* - Draw to back buffer (invisible to user)
* - Make sure drawing is completed (gsKit_finish)
* - Wait for VSync
* - Flip (back and front) buffers */
gsKit_queue_exec(gsGlobal);
gsKit_finish();
if (ps2->vsync)
gsKit_sync(gsGlobal);
gsKit_flip(gsGlobal);
}
gsKit_TexManager_nextFrame(gsGlobal);
gsKit_clear(gsGlobal, GS_BLACK);
return true; return true;
} }
static void ps2_gfx_set_nonblock_state(void *data, bool toggle, static void ps2_gfx_set_nonblock_state(void *data, bool toggle,
bool adaptive_vsync_enabled, unsigned swap_interval) bool adaptive_vsync_enabled, unsigned swap_interval)
{ {
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t *)data;
if (ps2) if (ps2)
ps2->vsync = !toggle; ps2->vsync = !toggle;
@ -368,7 +638,7 @@ static bool ps2_gfx_has_windowed(void *data) { return false; }
static void ps2_gfx_free(void *data) static void ps2_gfx_free(void *data)
{ {
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t *)data;
gsKit_clear(ps2->gsGlobal, GS_BLACK); gsKit_clear(ps2->gsGlobal, GS_BLACK);
gsKit_vram_clear(ps2->gsGlobal); gsKit_vram_clear(ps2->gsGlobal);
@ -381,8 +651,7 @@ static void ps2_gfx_free(void *data)
free(ps2->menuTexture); free(ps2->menuTexture);
free(ps2->coreTexture); free(ps2->coreTexture);
gsKit_remove_vsync_handler(ps2->vsync_callback_id); rmEnd(ps2);
deinit_GSGlobal(ps2->gsGlobal);
if (vsync_sema_id >= 0) if (vsync_sema_id >= 0)
DeleteSema(vsync_sema_id); DeleteSema(vsync_sema_id);
@ -391,21 +660,72 @@ static void ps2_gfx_free(void *data)
} }
static bool ps2_gfx_set_shader(void *data, static bool ps2_gfx_set_shader(void *data,
enum rarch_shader_type type, const char *path) { return false; } enum rarch_shader_type type, const char *path) { return false; }
static void ps2_set_video_mode(void *data, unsigned fbWidth, unsigned lines,
bool fullscreen)
{
ps2_video_t *ps2 = (ps2_video_t *)data;
if (!ps2)
return;
rmSetMode(ps2, 0);
}
static void ps2_set_filtering(void *data, unsigned index, bool smooth, bool ctx_scaling) static void ps2_set_filtering(void *data, unsigned index, bool smooth, bool ctx_scaling)
{ {
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t *)data;
ps2->menu_filter = smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST; ps2->menu_filter = smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST;
} }
static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32, static void ps2_get_video_output_size(void *data,
unsigned width, unsigned height, float alpha) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t *)data;
if (!ps2)
return;
int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16); /* If the current index is out of bound default it to zero */
if (ps2->vmode > PS2_RESOLUTION_LAST || ps2->vmode < 0)
ps2->vmode = 0;
*width = rm_mode_table[ps2->vmode].width;
*height = rm_mode_table[ps2->vmode].height;
strlcpy(desc, rm_mode_table[ps2->vmode].desc, desc_len);
}
static void ps2_get_video_output_prev(void *data)
{
ps2_video_t *ps2 = (ps2_video_t *)data;
if (!ps2)
return;
if (ps2->vmode == 0)
ps2->vmode = PS2_RESOLUTION_LAST;
else
ps2->vmode--;
}
static void ps2_get_video_output_next(void *data)
{
ps2_video_t *ps2 = (ps2_video_t *)data;
if (!ps2)
return;
if (ps2->vmode >= PS2_RESOLUTION_LAST)
ps2->vmode = 0;
else
ps2->vmode++;
}
static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32,
unsigned width, unsigned height, float alpha)
{
ps2_video_t *ps2 = (ps2_video_t *)data;
int PSM = (rgb32 ? GS_PSM_CT32 : GS_PSM_CT16);
set_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter); set_texture(ps2->menuTexture, frame, width, height, PSM, ps2->menu_filter);
gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->menuTexture); gsKit_TexManager_invalidate(ps2->gsGlobal, ps2->menuTexture);
@ -414,93 +734,88 @@ static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32,
static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen) static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen)
{ {
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t *)data;
if (ps2->menuVisible != enable)
{
/* If Menu change status, CLEAR SCREEN */
gsKit_clear(ps2->gsGlobal, GS_BLACK);
}
ps2->menuVisible = enable; ps2->menuVisible = enable;
} }
static void ps2_set_osd_msg(void *data, static void ps2_set_osd_msg(void *data,
const char *msg, const char *msg,
const void *params, void *font) const void *params, void *font)
{ {
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t *)data;
if (ps2) if (ps2)
font_driver_render_msg(data, msg, params, font); font_driver_render_msg(data, msg, params, font);
} }
static bool ps2_get_hw_render_interface(void* data, static bool ps2_get_hw_render_interface(void *data,
const struct retro_hw_render_interface** iface) const struct retro_hw_render_interface **iface)
{ {
ps2_video_t *ps2 = (ps2_video_t*)data; ps2_video_t *ps2 = (ps2_video_t *)data;
ps2->iface.padding = empty_ps2_insets; ps2->iface.padding = empty_ps2_insets;
*iface = *iface =
(const struct retro_hw_render_interface*)&ps2->iface; (const struct retro_hw_render_interface *)&ps2->iface;
return true; return true;
} }
static const video_poke_interface_t ps2_poke_interface = { static const video_poke_interface_t ps2_poke_interface = {
NULL, /* get_flags */ NULL, /* get_flags */
NULL, NULL, /* load_texture */
NULL, NULL, /* unload_texture */
NULL, ps2_set_video_mode,
NULL, /* get_refresh_rate */ NULL, /* get_refresh_rate */
ps2_set_filtering, ps2_set_filtering,
NULL, /* get_video_output_size */ ps2_get_video_output_size,
NULL, /* get_video_output_prev */ ps2_get_video_output_prev,
NULL, /* get_video_output_next */ ps2_get_video_output_next,
NULL, /* get_current_framebuffer */ NULL, /* get_current_framebuffer */
NULL, /* get_proc_address */ NULL, /* get_proc_address */
NULL, /* set_aspect_ratio */ NULL, /* set_aspect_ratio */
NULL, /* apply_state_changes */ NULL, /* apply_state_changes */
ps2_set_texture_frame, ps2_set_texture_frame,
ps2_set_texture_enable, ps2_set_texture_enable,
ps2_set_osd_msg, /* set_osd_msg */ ps2_set_osd_msg,
NULL, /* show_mouse */ NULL, /* show_mouse */
NULL, /* grab_mouse_toggle */ NULL, /* grab_mouse_toggle */
NULL, /* get_current_shader */ NULL, /* get_current_shader */
NULL, /* get_current_software_framebuffer */ NULL, /* get_current_software_framebuffer */
ps2_get_hw_render_interface, /* get_hw_render_interface */ ps2_get_hw_render_interface,
NULL, /* set_hdr_max_nits */ NULL, /* set_hdr_max_nits */
NULL, /* set_hdr_paper_white_nits */ NULL, /* set_hdr_paper_white_nits */
NULL, /* set_hdr_contrast */ NULL, /* set_hdr_contrast */
NULL /* set_hdr_expand_gamut */ NULL /* set_hdr_expand_gamut */
}; };
static void ps2_gfx_get_poke_interface(void *data, static void ps2_gfx_get_poke_interface(void *data,
const video_poke_interface_t **iface) const video_poke_interface_t **iface)
{ {
(void)data; (void)data;
*iface = &ps2_poke_interface; *iface = &ps2_poke_interface;
} }
video_driver_t video_ps2 = { video_driver_t video_ps2 = {
ps2_gfx_init, ps2_gfx_init,
ps2_gfx_frame, ps2_gfx_frame,
ps2_gfx_set_nonblock_state, ps2_gfx_set_nonblock_state,
ps2_gfx_alive, ps2_gfx_alive,
ps2_gfx_focus, ps2_gfx_focus,
ps2_gfx_suppress_screensaver, ps2_gfx_suppress_screensaver,
ps2_gfx_has_windowed, ps2_gfx_has_windowed,
ps2_gfx_set_shader, ps2_gfx_set_shader,
ps2_gfx_free, ps2_gfx_free,
"ps2", "ps2",
NULL, /* set_viewport */ NULL, /* set_viewport */
NULL, /* set_rotation */ NULL, /* set_rotation */
NULL, /* viewport_info */ NULL, /* viewport_info */
NULL, /* read_viewport */ NULL, /* read_viewport */
NULL, /* read_frame_raw */ NULL, /* read_frame_raw */
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
NULL, /* overlay_interface */ NULL, /* overlay_interface */
#endif #endif
#ifdef HAVE_VIDEO_LAYOUT #ifdef HAVE_VIDEO_LAYOUT
NULL, NULL,
#endif #endif
ps2_gfx_get_poke_interface, ps2_gfx_get_poke_interface,
}; };

View File

@ -516,7 +516,7 @@ static void sixel_set_texture_frame(void *data,
} }
static void sixel_get_video_output_size(void *data, static void sixel_get_video_output_size(void *data,
unsigned *width, unsigned *height) { } unsigned *width, unsigned *height, char *desc, size_t desc_len) { }
static void sixel_get_video_output_prev(void *data) { } static void sixel_get_video_output_prev(void *data) { }
static void sixel_get_video_output_next(void *data) { } static void sixel_get_video_output_next(void *data) { }
static void sixel_set_video_mode(void *data, unsigned width, unsigned height, static void sixel_set_video_mode(void *data, unsigned width, unsigned height,

View File

@ -2590,14 +2590,14 @@ static uint32_t vulkan_get_flags(void *data)
} }
static void vulkan_get_video_output_size(void *data, static void vulkan_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
vk_t *vk = (vk_t*)data; vk_t *vk = (vk_t*)data;
if (!vk || !vk->ctx_driver || !vk->ctx_driver->get_video_output_size) if (!vk || !vk->ctx_driver || !vk->ctx_driver->get_video_output_size)
return; return;
vk->ctx_driver->get_video_output_size( vk->ctx_driver->get_video_output_size(
vk->ctx_data, vk->ctx_data,
width, height); width, height, desc, desc_len);
} }
static void vulkan_get_video_output_prev(void *data) static void vulkan_get_video_output_prev(void *data)

View File

@ -312,7 +312,7 @@ static bool gfx_ctx_ps3_bind_api(void *data,
} }
static void gfx_ctx_ps3_get_video_output_size(void *data, static void gfx_ctx_ps3_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();

View File

@ -249,7 +249,7 @@ static bool gfx_ctx_psl1ght_bind_api(void *data,
} }
static void gfx_ctx_psl1ght_get_video_output_size(void *data, static void gfx_ctx_psl1ght_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();

View File

@ -345,9 +345,9 @@ static uint32_t gfx_ctx_w_vk_get_flags(void *data)
static void gfx_ctx_w_vk_set_flags(void *data, uint32_t flags) { } static void gfx_ctx_w_vk_set_flags(void *data, uint32_t flags) { }
static void gfx_ctx_w_vk_get_video_output_size(void *data, static void gfx_ctx_w_vk_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
win32_get_video_output_size(width, height); win32_get_video_output_size(width, height, desc, desc_len);
} }
static void gfx_ctx_w_vk_get_video_output_prev(void *data) { } static void gfx_ctx_w_vk_get_video_output_prev(void *data) { }

View File

@ -836,9 +836,9 @@ static void gfx_ctx_wgl_set_flags(void *data, uint32_t flags)
} }
static void gfx_ctx_wgl_get_video_output_size(void *data, static void gfx_ctx_wgl_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
win32_get_video_output_size(width, height); win32_get_video_output_size(width, height, desc, desc_len);
} }
static void gfx_ctx_wgl_get_video_output_prev(void *data) { } static void gfx_ctx_wgl_get_video_output_prev(void *data) { }

View File

@ -148,6 +148,7 @@ static void ps2_font_render_line(
return; return;
/* Enable Alpha for font */ /* Enable Alpha for font */
gsKit_set_primalpha(ps2->gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0);
ps2->gsGlobal->PrimAlphaEnable = GS_SETTING_ON; ps2->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
gsKit_set_test(ps2->gsGlobal, GS_ATEST_ON); gsKit_set_test(ps2->gsGlobal, GS_ATEST_ON);

View File

@ -544,7 +544,7 @@ typedef struct gfx_ctx_driver
float (*get_refresh_rate)(void*); float (*get_refresh_rate)(void*);
void (*get_video_output_size)(void*, unsigned*, unsigned*); void (*get_video_output_size)(void*, unsigned*, unsigned*, char *, size_t);
void (*get_video_output_prev)(void*); void (*get_video_output_prev)(void*);
@ -687,7 +687,7 @@ typedef struct video_poke_interface
float (*get_refresh_rate)(void *data); float (*get_refresh_rate)(void *data);
void (*set_filtering)(void *data, unsigned index, bool smooth, bool ctx_scaling); void (*set_filtering)(void *data, unsigned index, bool smooth, bool ctx_scaling);
void (*get_video_output_size)(void *data, void (*get_video_output_size)(void *data,
unsigned *width, unsigned *height); unsigned *width, unsigned *height, char *desc, size_t desc_len);
/* Move index to previous resolution */ /* Move index to previous resolution */
void (*get_video_output_prev)(void *data); void (*get_video_output_prev)(void *data);
@ -922,7 +922,7 @@ bool video_driver_set_video_mode(unsigned width,
unsigned height, bool fullscreen); unsigned height, bool fullscreen);
bool video_driver_get_video_output_size( bool video_driver_get_video_output_size(
unsigned *width, unsigned *height); unsigned *width, unsigned *height, char *desc, size_t desc_len);
void video_driver_set_texture_enable(bool enable, bool full_screen); void video_driver_set_texture_enable(bool enable, bool full_screen);

View File

@ -1012,7 +1012,7 @@ static void thread_set_hdr_expand_gamut(void *data, bool expand_gamut)
} }
static void thread_get_video_output_size(void *data, static void thread_get_video_output_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
thread_video_t *thr = (thread_video_t*)data; thread_video_t *thr = (thread_video_t*)data;
@ -1022,7 +1022,7 @@ static void thread_get_video_output_size(void *data,
if (thr->poke && thr->poke->get_video_output_size) if (thr->poke && thr->poke->get_video_output_size)
thr->poke->get_video_output_size(thr->driver_data, thr->poke->get_video_output_size(thr->driver_data,
width, width,
height); height, desc, desc_len);
} }
static void thread_get_video_output_prev(void *data) static void thread_get_video_output_prev(void *data)

View File

@ -3316,6 +3316,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VIDEO_MONITOR_INDEX, MENU_ENUM_LABEL_VIDEO_MONITOR_INDEX,
"video_monitor_index" "video_monitor_index"
) )
MSG_HASH(
MENU_ENUM_LABEL_VIDEO_WINDOW_OFFSET_X,
"video_window_offset_x"
)
MSG_HASH(
MENU_ENUM_LABEL_VIDEO_WINDOW_OFFSET_Y,
"video_window_offset_y"
)
MSG_HASH( MSG_HASH(
MENU_ENUM_LABEL_VIDEO_POST_FILTER_RECORD, MENU_ENUM_LABEL_VIDEO_POST_FILTER_RECORD,
"video_post_filter_record" "video_post_filter_record"

View File

@ -1514,6 +1514,22 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_VIDEO_GPU_INDEX, MENU_ENUM_SUBLABEL_VIDEO_GPU_INDEX,
"Select which graphics card to use." "Select which graphics card to use."
) )
MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OFFSET_X,
"Screen Horizontal Offset"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_VIDEO_WINDOW_OFFSET_X,
"Forces a certain offset horizontally to the video. The offset is applied globaly."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OFFSET_Y,
"Screen Vertical Offset"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_VIDEO_WINDOW_OFFSET_Y,
"Forces a certain offset vertically to the video. The offset is applied globaly."
)
MSG_HASH( MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_REFRESH_RATE, MENU_ENUM_LABEL_VALUE_VIDEO_REFRESH_RATE,
"Vertical Refresh Rate" "Vertical Refresh Rate"
@ -12267,6 +12283,50 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION, MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION,
"Screen Resolution" "Screen Resolution"
) )
MSG_HASH(
MSG_SCREEN_RESOLUTION_FORMAT_NO_DESC,
"%ux%u"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_FORMAT_DESC,
"%ux%u - %s"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_DEFAULT,
"Screen Resolution: Default"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_NO_DESC,
"Screen Resolution: %dx%d"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_DESC,
"Screen Resolution: %dx%d - %s"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_APPLYING_DEFAULT,
"Applying: Default"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_APPLYING_NO_DESC,
"Applying: %dx%d\nSTART to reset"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_APPLYING_DESC,
"Applying: %dx%d - %s\nSTART to reset"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_RESETTING_DEFAULT,
"Resetting to: Default"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_RESETTING_NO_DESC,
"Resetting to: %dx%d"
)
MSG_HASH(
MSG_SCREEN_RESOLUTION_RESETTING_DESC,
"Resetting to: %dx%d - %s"
)
MSG_HASH( MSG_HASH(
MENU_ENUM_SUBLABEL_SCREEN_RESOLUTION, MENU_ENUM_SUBLABEL_SCREEN_RESOLUTION,
"Select display mode." "Select display mode."

View File

@ -1036,20 +1036,27 @@ static void menu_action_setting_disp_set_label_menu_video_resolution(
char *s2, size_t len2) char *s2, size_t len2)
{ {
unsigned width = 0, height = 0; unsigned width = 0, height = 0;
char desc[64] = {0};
*w = 19; *w = 19;
*s = '\0'; *s = '\0';
strlcpy(s2, path, len2); strlcpy(s2, path, len2);
if (video_driver_get_video_output_size(&width, &height)) if (video_driver_get_video_output_size(&width, &height, desc, sizeof(desc)))
{ {
#ifdef GEKKO #ifdef GEKKO
if (width == 0 || height == 0) if (width == 0 || height == 0)
strcpy_literal(s, "DEFAULT"); snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DONT_CARE));
else else
#endif #endif
snprintf(s, len, "%ux%u", width, height); {
if (!string_is_empty(desc))
snprintf(s, len, msg_hash_to_str(MSG_SCREEN_RESOLUTION_FORMAT_DESC),
width, height, desc);
else
snprintf(s, len, msg_hash_to_str(MSG_SCREEN_RESOLUTION_FORMAT_NO_DESC),
width, height);
}
} }
else else
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len); strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);

View File

@ -6757,11 +6757,12 @@ static int generic_dropdown_box_list(size_t idx, unsigned lbl)
static int action_ok_video_resolution(const char *path, static int action_ok_video_resolution(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx) const char *label, unsigned type, size_t idx, size_t entry_idx)
{ {
#if defined(GEKKO) || !defined(__PSL1GHT__) && defined(__PS3__) #if defined(GEKKO) || defined(PS2) || !defined(__PSL1GHT__) && defined(__PS3__)
unsigned width = 0; unsigned width = 0;
unsigned height = 0; unsigned height = 0;
char desc[64] = {0};
if (video_driver_get_video_output_size(&width, &height)) if (video_driver_get_video_output_size(&width, &height, desc, sizeof(desc)))
{ {
char msg[PATH_MAX_LENGTH]; char msg[PATH_MAX_LENGTH];
@ -6773,12 +6774,17 @@ static int action_ok_video_resolution(const char *path,
video_driver_set_video_mode(width, height, true); video_driver_set_video_mode(width, height, true);
#ifdef GEKKO #ifdef GEKKO
if (width == 0 || height == 0) if (width == 0 || height == 0)
strcpy_literal(msg, "Applying: DEFAULT"); snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_SCREEN_RESOLUTION_APPLYING_DEFAULT));
else else
#endif #endif
snprintf(msg, sizeof(msg), {
"Applying: %dx%d\n START to reset", if (!string_is_empty(desc))
snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_SCREEN_RESOLUTION_APPLYING_DESC),
width, height, desc);
else
snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_SCREEN_RESOLUTION_APPLYING_NO_DESC),
width, height); width, height);
}
runloop_msg_queue_push(msg, 1, 100, true, NULL, runloop_msg_queue_push(msg, 1, 100, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
} }

View File

@ -486,14 +486,15 @@ static int action_start_video_resolution(
const char *path, const char *label, const char *path, const char *label,
unsigned type, size_t idx, size_t entry_idx) unsigned type, size_t idx, size_t entry_idx)
{ {
#if defined(GEKKO) || !defined(__PSL1GHT__) && !defined(__PS3__) #if defined(GEKKO) || defined(PS2) || !defined(__PSL1GHT__) && !defined(__PS3__)
unsigned width = 0, height = 0; unsigned width = 0, height = 0;
char desc[64] = {0};
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
/* Reset the resolution id to zero */ /* Reset the resolution id to zero */
global->console.screen.resolutions.current.id = 0; global->console.screen.resolutions.current.id = 0;
if (video_driver_get_video_output_size(&width, &height)) if (video_driver_get_video_output_size(&width, &height, desc, sizeof(desc)))
{ {
char msg[PATH_MAX_LENGTH]; char msg[PATH_MAX_LENGTH];
@ -508,8 +509,15 @@ static int action_start_video_resolution(
strlcpy(msg, "Resetting to: DEFAULT", sizeof(msg)); strlcpy(msg, "Resetting to: DEFAULT", sizeof(msg));
else else
#endif #endif
snprintf(msg, sizeof(msg), {
"Resetting to: %dx%d", width, height); if (!string_is_empty(desc))
snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_SCREEN_RESOLUTION_RESETTING_DESC),
width, height, desc);
else
snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_SCREEN_RESOLUTION_RESETTING_NO_DESC),
width, height);
}
runloop_msg_queue_push(msg, 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); runloop_msg_queue_push(msg, 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
} }
#endif #endif

View File

@ -935,6 +935,11 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_overscan_correction_top, ME
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_overscan_correction_bottom, MENU_ENUM_SUBLABEL_VIDEO_OVERSCAN_CORRECTION_BOTTOM) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_overscan_correction_bottom, MENU_ENUM_SUBLABEL_VIDEO_OVERSCAN_CORRECTION_BOTTOM)
#endif #endif
#if defined(HAVE_WINDOW_OFFSET)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_window_offset_x, MENU_ENUM_SUBLABEL_VIDEO_WINDOW_OFFSET_X)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_window_offset_y, MENU_ENUM_SUBLABEL_VIDEO_WINDOW_OFFSET_Y)
#endif
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_playlist_show_sublabels, MENU_ENUM_SUBLABEL_PLAYLIST_SHOW_SUBLABELS) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_playlist_show_sublabels, MENU_ENUM_SUBLABEL_PLAYLIST_SHOW_SUBLABELS)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_playlist_show_entry_idx, MENU_ENUM_SUBLABEL_PLAYLIST_SHOW_ENTRY_IDX) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_playlist_show_entry_idx, MENU_ENUM_SUBLABEL_PLAYLIST_SHOW_ENTRY_IDX)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_rgui_border_filler_enable, MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_ENABLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_rgui_border_filler_enable, MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_ENABLE)
@ -3763,6 +3768,14 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_VIDEO_MONITOR_INDEX: case MENU_ENUM_LABEL_VIDEO_MONITOR_INDEX:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_monitor_index); BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_monitor_index);
break; break;
#if defined(HAVE_WINDOW_OFFSET)
case MENU_ENUM_LABEL_VIDEO_WINDOW_OFFSET_X:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_window_offset_x);
break;
case MENU_ENUM_LABEL_VIDEO_WINDOW_OFFSET_Y:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_window_offset_y);
break;
#endif
case MENU_ENUM_LABEL_LOG_VERBOSITY: case MENU_ENUM_LABEL_LOG_VERBOSITY:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_log_verbosity); BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_log_verbosity);
break; break;
@ -4241,6 +4254,14 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_VIDEO_OVERSCAN_CORRECTION_BOTTOM: case MENU_ENUM_LABEL_VIDEO_OVERSCAN_CORRECTION_BOTTOM:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_overscan_correction_bottom); BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_overscan_correction_bottom);
break; break;
#endif
#if defined(HAVE_WINDOW_OFFSET)
case MENU_ENUM_SUBLABEL_VIDEO_WINDOW_OFFSET_X:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_window_offset_x);
break;
case MENU_ENUM_SUBLABEL_VIDEO_WINDOW_OFFSET_Y:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_window_offset_y);
break;
#endif #endif
case MENU_ENUM_LABEL_CHEAT_APPLY_AFTER_LOAD: case MENU_ENUM_LABEL_CHEAT_APPLY_AFTER_LOAD:
#ifdef HAVE_CHEATS #ifdef HAVE_CHEATS

View File

@ -7893,7 +7893,7 @@ unsigned menu_displaylist_build_list(
PARSE_ONLY_UINT, false) == 0) PARSE_ONLY_UINT, false) == 0)
count++; count++;
#if defined(GEKKO) || !defined(__PSL1GHT__) && defined(__PS3__) #if defined(GEKKO) || defined(PS2) || !defined(__PSL1GHT__) && defined(__PS3__)
if (true) if (true)
#else #else
if (video_display_server_has_resolution_list()) if (video_display_server_has_resolution_list())
@ -7904,7 +7904,17 @@ unsigned menu_displaylist_build_list(
PARSE_ACTION, false) == 0) PARSE_ACTION, false) == 0)
count++; count++;
} }
#if defined(HAVE_WINDOW_OFFSET)
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_VIDEO_WINDOW_OFFSET_X,
PARSE_ONLY_INT, false) == 0)
count++;
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_VIDEO_WINDOW_OFFSET_Y,
PARSE_ONLY_INT, false) == 0)
count++;
#endif
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_PAL60_ENABLE, MENU_ENUM_LABEL_PAL60_ENABLE,
PARSE_ONLY_BOOL, false) == 0) PARSE_ONLY_BOOL, false) == 0)

View File

@ -11390,7 +11390,7 @@ static bool setting_append_list(
CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); CMD_EVENT_VIDEO_APPLY_STATE_CHANGES);
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_LAKKA_ADVANCED); SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_LAKKA_ADVANCED);
#if defined(GEKKO) || !defined(__PSL1GHT__) && defined(__PS3__) #if defined(GEKKO) || defined(PS2) || !defined(__PSL1GHT__) && defined(__PS3__)
if (true) if (true)
#else #else
if (!string_is_equal(video_display_server_get_ident(), "null")) if (!string_is_equal(video_display_server_get_ident(), "null"))
@ -11405,6 +11405,34 @@ static bool setting_append_list(
parent_group); parent_group);
} }
#if defined(HAVE_WINDOW_OFFSET)
CONFIG_INT(
list, list_info,
&settings->ints.video_window_offset_x,
MENU_ENUM_LABEL_VIDEO_WINDOW_OFFSET_X,
MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OFFSET_X,
DEFAULT_WINDOW_OFFSET_X,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, -50, 50, 1, true, true);
CONFIG_INT(
list, list_info,
&settings->ints.video_window_offset_y,
MENU_ENUM_LABEL_VIDEO_WINDOW_OFFSET_Y,
MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OFFSET_Y,
DEFAULT_WINDOW_OFFSET_Y,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, -50, 50, 1, true, true);
#endif
CONFIG_UINT( CONFIG_UINT(
list, list_info, list, list_info,
&custom_vp->width, &custom_vp->width,

View File

@ -1088,6 +1088,8 @@ enum msg_hash_enums
MENU_LABEL(VIDEO_FULLSCREEN), MENU_LABEL(VIDEO_FULLSCREEN),
MENU_LABEL(VIDEO_MONITOR_INDEX), MENU_LABEL(VIDEO_MONITOR_INDEX),
MENU_LABEL(VIDEO_WINDOW_SCALE), MENU_LABEL(VIDEO_WINDOW_SCALE),
MENU_LABEL(VIDEO_WINDOW_OFFSET_X),
MENU_LABEL(VIDEO_WINDOW_OFFSET_Y),
MENU_LABEL(VIDEO_REFRESH_RATE), MENU_LABEL(VIDEO_REFRESH_RATE),
MENU_LABEL(VIDEO_REFRESH_RATE_AUTO), MENU_LABEL(VIDEO_REFRESH_RATE_AUTO),
MENU_LABEL(VIDEO_REFRESH_RATE_POLLED), MENU_LABEL(VIDEO_REFRESH_RATE_POLLED),
@ -1843,6 +1845,19 @@ enum msg_hash_enums
MENU_LABEL(CHEAT_COPY_MATCH), MENU_LABEL(CHEAT_COPY_MATCH),
MENU_LABEL(CHEAT_DELETE_MATCH), MENU_LABEL(CHEAT_DELETE_MATCH),
MENU_LABEL(SCREEN_RESOLUTION), MENU_LABEL(SCREEN_RESOLUTION),
MSG_SCREEN_RESOLUTION_FORMAT_NO_DESC,
MSG_SCREEN_RESOLUTION_FORMAT_DESC,
MSG_SCREEN_RESOLUTION_DEFAULT,
MSG_SCREEN_RESOLUTION_NO_DESC,
MSG_SCREEN_RESOLUTION_DESC,
MSG_SCREEN_RESOLUTION_APPLYING_DEFAULT,
MSG_SCREEN_RESOLUTION_APPLYING_NO_DESC,
MSG_SCREEN_RESOLUTION_APPLYING_DESC,
MSG_SCREEN_RESOLUTION_RESETTING_DEFAULT,
MSG_SCREEN_RESOLUTION_RESETTING_NO_DESC,
MSG_SCREEN_RESOLUTION_RESETTING_DESC,
MENU_LABEL(SAVESTATE_AUTO_INDEX), MENU_LABEL(SAVESTATE_AUTO_INDEX),
MENU_LABEL(SAVESTATE_MAX_KEEP), MENU_LABEL(SAVESTATE_MAX_KEEP),
MENU_LABEL(SAVESTATE_AUTO_SAVE), MENU_LABEL(SAVESTATE_AUTO_SAVE),

View File

@ -7197,22 +7197,29 @@ bool command_event(enum event_command cmd, void *data)
#if defined(GEKKO) #if defined(GEKKO)
{ {
unsigned width = 0, height = 0; unsigned width = 0, height = 0;
char desc[64] = {0};
command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL); command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL);
if (video_driver_get_video_output_size(&width, &height)) if (video_driver_get_video_output_size(&width, &height, desc, sizeof(desc)))
{ {
char msg[128] = {0}; char msg[128] = {0};
video_driver_set_video_mode(width, height, true); video_driver_set_video_mode(width, height, true);
if (width == 0 || height == 0) if (width == 0 || height == 0)
snprintf(msg, sizeof(msg), "%s: DEFAULT", snprintf(msg, sizeof(msg), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION_DEFAULT));
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION));
else else
snprintf(msg, sizeof(msg),"%s: %dx%d", {
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION), if (!string_is_empty(desc))
snprintf(msg, sizeof(msg),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION_DESC),
width, height, desc);
else
snprintf(msg, sizeof(msg), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCREEN_RESOLUTION_NO_DESC),
width, height); width, height);
}
runloop_msg_queue_push(msg, 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); runloop_msg_queue_push(msg, 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
} }
} }
@ -18454,13 +18461,13 @@ bool video_driver_set_video_mode(unsigned width,
return false; return false;
} }
bool video_driver_get_video_output_size(unsigned *width, unsigned *height) bool video_driver_get_video_output_size(unsigned *width, unsigned *height, char *desc, size_t desc_len)
{ {
struct rarch_state *p_rarch = &rarch_st; struct rarch_state *p_rarch = &rarch_st;
if (!p_rarch->video_driver_poke || !p_rarch->video_driver_poke->get_video_output_size) if (!p_rarch->video_driver_poke || !p_rarch->video_driver_poke->get_video_output_size)
return false; return false;
p_rarch->video_driver_poke->get_video_output_size(p_rarch->video_driver_data, p_rarch->video_driver_poke->get_video_output_size(p_rarch->video_driver_data,
width, height); width, height, desc, desc_len);
return true; return true;
} }