From 453ba4379f33c940b5fe0cf1e89bab8c2e25f3f2 Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Wed, 21 Dec 2016 02:10:42 -0600 Subject: [PATCH] VITA: moved shader config to Display menu --- src/gp2x/menu/menu.cpp | 6 +++ src/gp2x/menu/menu_display.cpp | 73 ++++++++++++++++++++++++++++++- src/gp2x/menu/menu_helper.cpp | 12 ++--- src/gp2x/menu/menu_misc.cpp | 80 +--------------------------------- src/od-joy.cpp | 4 +- 5 files changed, 87 insertions(+), 88 deletions(-) diff --git a/src/gp2x/menu/menu.cpp b/src/gp2x/menu/menu.cpp index efcfe85..fabd9b4 100755 --- a/src/gp2x/menu/menu.cpp +++ b/src/gp2x/menu/menu.cpp @@ -356,6 +356,12 @@ void init_text(int splash) SDL_SetVideoModeScaling(x, y, sw, sh); printf("init_text: SDL_SetVideoModeScaling(%i, %i, %i, %i)\n", x, y, (int)sw, (int)sh); + + //This requires a recent SDL-Vita branch SDL12 for example + //https://github.com/rsn8887/SDL-Vita/tree/SDL12 + //to compile + SDL_SetVideoModeBilinear(0); + #elif PANDORA setenv("SDL_OMAP_LAYER_SIZE","640x480",1); setenv("SDL_OMAP_BORDER_CUT","0,0,0,30",1); diff --git a/src/gp2x/menu/menu_display.cpp b/src/gp2x/menu/menu_display.cpp index 35b78ac..7db53a3 100755 --- a/src/gp2x/menu/menu_display.cpp +++ b/src/gp2x/menu/menu_display.cpp @@ -57,13 +57,27 @@ enum { MENUDISPLAY_CUTRIGHT, MENUDISPLAY_FRAMESKIP, MENUDISPLAY_REFRESHRATE, +#ifdef __PSP2__ + MENUDISPLAY_SHADER, +#endif MENUDISPLAY_SOUND, MENUDISPLAY_SNDRATE, MENUDISPLAY_STEREO, MENUDISPLAY_END }; - +#ifdef __PSP2__ +enum { + SHADER_NONE = 0, + SHADER_LCD3X, + SHADER_AAA, + SHADER_SCALE2X, + SHADER_SHARP_BILINEAR, + SHADER_SHARP_BILINEAR_SIMPLE, + SHADER_FXAA, + NUM_SHADERS, //NUM_SHADERS - 1 is the max allowed number in mainMenu_shader +}; +#endif static void draw_displayMenu(int c) { @@ -83,7 +97,7 @@ static void draw_displayMenu(int c) int bb=(b%6)/3; SDL_Rect r; extern SDL_Surface *text_screen; - char value[20]=""; + char value[25]=""; r.x=80-64; r.y=0; r.w=110+64+64; r.h=240; text_draw_background(); @@ -228,6 +242,43 @@ static void draw_displayMenu(int c) write_text_inv(tabstop3+1,menuLine,"60Hz"); else write_text(tabstop3+1,menuLine,"60Hz"); +#ifdef __PSP2__ + //Shader settings on Vita + //MENUDISPLAY_SHADER + menuLine+=2; + write_text(leftMargin,menuLine,"Shader"); + + switch (mainMenu_shader) + { + case SHADER_NONE: + snprintf((char*)value, 25, "NONE (perfect 2x)"); + break; + case SHADER_LCD3X: + snprintf((char*)value, 25, "LCD3X"); + break; + case SHADER_SCALE2X: + snprintf((char*)value, 25, "SCALE2X"); + break; + case SHADER_AAA: + snprintf((char*)value, 25, "AAA"); + break; + case SHADER_SHARP_BILINEAR: + snprintf((char*)value, 25, "SHARP_BILINEAR"); + break; + case SHADER_SHARP_BILINEAR_SIMPLE: + snprintf((char*)value, 25, "SHARP_BILINEAR_SIMPL"); + break; + case SHADER_FXAA: + snprintf((char*)value, 25, "FXAA"); + break; + default: + break; + } + if ((menuDisplay!=MENUDISPLAY_SHADER)||(bb)) + write_text_inv(tabstop3-2,menuLine,value); + else + write_text(tabstop3-2,menuLine,value); +#endif menuLine++; write_text(leftMargin,menuLine,text_str_display_separator); @@ -479,6 +530,24 @@ static int key_displayMenu(int *c) if ((left)||(right)) mainMenu_ntsc = !mainMenu_ntsc; break; +#ifdef __PSP2__ //shader choice on VITA + case MENUDISPLAY_SHADER: + if (left) + { + if (mainMenu_shader <= 0) + mainMenu_shader = 0; + else + mainMenu_shader -= 1; + } + else if (right) + { + if (mainMenu_shader >= NUM_SHADERS-1) + mainMenu_shader = NUM_SHADERS-1; + else + mainMenu_shader +=1; + } + break; +#endif case MENUDISPLAY_SOUND: if (left) diff --git a/src/gp2x/menu/menu_helper.cpp b/src/gp2x/menu/menu_helper.cpp index 2a3ed94..c49f950 100755 --- a/src/gp2x/menu/menu_helper.cpp +++ b/src/gp2x/menu/menu_helper.cpp @@ -155,26 +155,28 @@ void update_display() { int x; int y; - //is the sharp_bilinear_simple shader active? - if (mainMenu_shader == 5) + //is a shader active? + if (mainMenu_shader != 0) { sh = 544; sw = ((float)visibleAreaWidth*((float)544/(float)mainMenu_displayedLines)); x = (960 - sw) / 2; y = (544 - sh) / 2; - //This requires SDL-Vita branch SDL12 for example + //This requires a recent SDL-Vita branch SDL12 for example //https://github.com/rsn8887/SDL-Vita/tree/SDL12 //to compile - SDL_SetVideoModeScalingBilinear(x, y, sw, sh); + SDL_SetVideoModeScaling(x, y, sw, sh); + SDL_SetVideoModeBilinear(1); } - else //otherwise do regular integer 2* scaling to ensure good picture quality + else //otherwise do regular integer 2* scaling without filtering to ensure good picture quality { sh = (float) (2 * mainMenu_displayedLines); sw = (float) (2 * visibleAreaWidth); x = (960 - sw) / 2; y = (544 - sh) / 2; SDL_SetVideoModeScaling(x, y, sw, sh); + SDL_SetVideoModeBilinear(0); } printf("update_display: SDL_SetVideoModeScaling(%i, %i, %i, %i)\n", x, y, (int)sw, (int)sh); diff --git a/src/gp2x/menu/menu_misc.cpp b/src/gp2x/menu/menu_misc.cpp index b637c26..81a35ce 100755 --- a/src/gp2x/menu/menu_misc.cpp +++ b/src/gp2x/menu/menu_misc.cpp @@ -73,26 +73,9 @@ enum { MENUMISC_STATUSLINE, MENUMISC_MOUSEMULTIPLIER, MENUMISC_STYLUSOFFSET, -#ifdef __PSP2__ - MENUMISC_SHADER, -#else MENUMISC_TAPDELAY, -#endif MENUMISC_END }; - -#ifdef __PSP2__ -enum { - SHADER_NONE = 0, - SHADER_LCD3X, - SHADER_AAA, - SHADER_SCALE2X, - SHADER_SHARP_BILINEAR, - SHADER_SHARP_BILINEAR_SIMPLE, - SHADER_FXAA, - NUM_SHADERS, //NUM_SHADERS - 1 is the max allowed number in mainMenu_shader -}; -#endif static void draw_miscMenu(int c) { @@ -113,10 +96,6 @@ static void draw_miscMenu(int c) SDL_Rect r; extern SDL_Surface *text_screen; char cpuSpeed[8]; - -#ifdef __PSP2__ - char shaderName[25]; -#endif r.x=80-64; r.y=0; r.w=110+64+64; r.h=240; @@ -392,8 +371,7 @@ static void draw_miscMenu(int c) if ((mainMenu_stylusOffset==16)&&((menuMisc!=MENUMISC_STYLUSOFFSET)||(bb))) write_text_inv(tabstop9,menuLine,text_str_8px); else - write_text(tabstop9,menuLine,text_str_8px); -#ifndef __PSP2__ + write_text(tabstop9,menuLine,text_str_8px); // MENUMISC_TAPDELAY menuLine+=2; write_text(leftMargin,menuLine,text_str_tap_delay); @@ -412,43 +390,6 @@ static void draw_miscMenu(int c) write_text_inv(tabstop9,menuLine,text_str_none); else write_text(tabstop9,menuLine,text_str_none); -#else - //Shader settings on Vita - //MENUMISC_SHADER - menuLine+=2; - write_text(leftMargin,menuLine,"Shader"); - - switch (mainMenu_shader) - { - case SHADER_NONE: - snprintf((char*)shaderName, 25, "NONE (perfect 2*)"); - break; - case SHADER_LCD3X: - snprintf((char*)shaderName, 25, "LCD3X"); - break; - case SHADER_SCALE2X: - snprintf((char*)shaderName, 25, "SCALE2X"); - break; - case SHADER_AAA: - snprintf((char*)shaderName, 25, "AAA"); - break; - case SHADER_SHARP_BILINEAR: - snprintf((char*)shaderName, 25, "SHARP_BILINEAR"); - break; - case SHADER_SHARP_BILINEAR_SIMPLE: - snprintf((char*)shaderName, 25, "SHARP_BILNEAR_SIMPLE"); - break; - case SHADER_FXAA: - snprintf((char*)shaderName, 25, "FXAA"); - break; - default: - break; - } - if ((menuMisc!=MENUMISC_SHADER)||(bb)) - write_text_inv(tabstop3-2,menuLine,shaderName); - else - write_text(tabstop3-2,menuLine,shaderName); -#endif menuLine++; write_text(leftMargin,menuLine,text_str_misc_separator); @@ -704,24 +645,6 @@ static int key_miscMenu(int *c) mainMenu_stylusOffset = 0; } break; -#ifdef __PSP2__ //shader choice on VITA - case MENUMISC_SHADER: - if (left) - { - if (mainMenu_shader <= 0) - mainMenu_shader = 0; - else - mainMenu_shader -= 1; - } - else if (right) - { - if (mainMenu_shader >= NUM_SHADERS-1) - mainMenu_shader = NUM_SHADERS-1; - else - mainMenu_shader +=1; - } - break; -#else case MENUMISC_TAPDELAY: if (left) { @@ -742,7 +665,6 @@ static int key_miscMenu(int *c) mainMenu_tapDelay = 10; } break; -#endif //__PSP2__ } } diff --git a/src/od-joy.cpp b/src/od-joy.cpp index 02fe444..b12b6a1 100755 --- a/src/od-joy.cpp +++ b/src/od-joy.cpp @@ -209,8 +209,8 @@ void read_joystick(int nr, unsigned int *dir, int *button) //max movement is mouseScale. //that way, when in one of the other mouse modes, //the Y button to change scale still works - lastmx += (int) (analogX/32768.0f * mouseScale); - lastmy += (int) (analogY/32768.0f * mouseScale); + lastmx += (int) (analogX/32769.0f * mouseScale); + lastmy += (int) (analogY/32769.0f * mouseScale); newmousecounters=1; } #endif //__PSP2__