Skip to content

Commit

Permalink
VITA: moved shader config to Display menu
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Dec 21, 2016
1 parent bc49ce5 commit 453ba43
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 88 deletions.
6 changes: 6 additions & 0 deletions src/gp2x/menu/menu.cpp
Expand Up @@ -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);
Expand Down
73 changes: 71 additions & 2 deletions src/gp2x/menu/menu_display.cpp
Expand Up @@ -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)
{
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions src/gp2x/menu/menu_helper.cpp
Expand Up @@ -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);

Expand Down
80 changes: 1 addition & 79 deletions src/gp2x/menu/menu_misc.cpp
Expand Up @@ -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)
{
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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)
{
Expand All @@ -742,7 +665,6 @@ static int key_miscMenu(int *c)
mainMenu_tapDelay = 10;
}
break;
#endif //__PSP2__
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/od-joy.cpp
Expand Up @@ -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__
Expand Down

0 comments on commit 453ba43

Please sign in to comment.