From 5c3304872788b3b414fa8d7961d9cab423c00c0c Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Fri, 11 Jan 2019 19:55:52 -0600 Subject: [PATCH] improve savestate thumbnail quality, clarify joystick option --- CMakeLists.txt | 3 +- src/gp2x/menu/menu.cpp | 32 +++++++---- src/gp2x/menu/menu.h | 1 + src/gp2x/menu/menu_config.cpp | 10 +--- src/gp2x/menu/menu_misc.cpp | 95 +++++++++++++++---------------- src/gp2x/menu/menu_savestates.cpp | 30 +++++++++- src/od-joy.cpp | 15 ++--- src/switch/sdl2_to_sdl1.cpp | 2 +- 8 files changed, 105 insertions(+), 83 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5039c4..d75a1a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0) set(CMAKE_VERBOSE_MAKEFILE OFF) set(VERSION_MAJOR 1) -set(VERSION_MINOR 86) +set(VERSION_MINOR 87) if(BUILD_PSP2) if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) @@ -255,6 +255,7 @@ if(BUILD_NX) set(LIBS SDL2 SDL2_image + SDL2_gfx EGL GLESv2 glapi diff --git a/src/gp2x/menu/menu.cpp b/src/gp2x/menu/menu.cpp index c4382e2..04097e3 100755 --- a/src/gp2x/menu/menu.cpp +++ b/src/gp2x/menu/menu.cpp @@ -70,6 +70,8 @@ Uint32 menu_msg_time=0x12345678; int skipintro=1; int kickstart_warning=0; int displaying_menu = 1; +int menu_screen_width = 640; +int menu_screen_height = 480; static void obten_colores(void) { @@ -337,10 +339,23 @@ else update_window_color(); } +void text_flip_with_image(SDL_Surface *img, int x, int y) +{ +#if !defined(__PSP2__) && !defined(__SWITCH__) + SDL_Delay(10); +#endif + SDL_SoftStretch(text_screen,NULL,prSDLScreen,NULL); + SDL_Rect dst = { 2 * x, 2 * y , 0 , 0 }; + SDL_BlitSurface(img, NULL, prSDLScreen, &dst); + SDL_Flip(prSDLScreen); +} + void text_flip(void) { +#if !defined(__PSP2__) && !defined(__SWITCH__) SDL_Delay(10); - SDL_BlitSurface(text_screen,NULL,prSDLScreen,NULL); +#endif + SDL_SoftStretch(text_screen,NULL,prSDLScreen,NULL); SDL_Flip(prSDLScreen); } @@ -412,11 +427,11 @@ void init_text(int splash) displaying_menu = 1; - prSDLScreen = SDL_SetVideoMode(320, 240, 16, SDL_HWSURFACE|SDL_DOUBLEBUF); - printf("init_text: SDL_SetVideoMode(%i, %i, 16)\n", 320, 240); + prSDLScreen = SDL_SetVideoMode(menu_screen_width, menu_screen_height, 16, SDL_HWSURFACE|SDL_DOUBLEBUF); + printf("init_text: SDL_SetVideoMode(%i, %i, 16)\n", menu_screen_width, menu_screen_height); float sh = (float) 480; - float sw = (float)320*((float)480/(float)240); + float sw = (float)menu_screen_width*((float)480/(float)menu_screen_height); int x = (960-sw)/2; int y = (544-sh)/2; @@ -451,8 +466,8 @@ void init_text(int splash) if (!text_screen) { - text_screen=SDL_CreateRGBSurface(prSDLScreen->flags,prSDLScreen->w,prSDLScreen->h,prSDLScreen->format->BitsPerPixel,prSDLScreen->format->Rmask,prSDLScreen->format->Gmask,prSDLScreen->format->Bmask,prSDLScreen->format->Amask); - window_screen=SDL_CreateRGBSurface(prSDLScreen->flags,prSDLScreen->w,prSDLScreen->h,prSDLScreen->format->BitsPerPixel,prSDLScreen->format->Rmask,prSDLScreen->format->Gmask,prSDLScreen->format->Bmask,prSDLScreen->format->Amask); + text_screen=SDL_CreateRGBSurface(prSDLScreen->flags,prSDLScreen->w / 2,prSDLScreen->h / 2,prSDLScreen->format->BitsPerPixel,prSDLScreen->format->Rmask,prSDLScreen->format->Gmask,prSDLScreen->format->Bmask,prSDLScreen->format->Amask); + window_screen=SDL_CreateRGBSurface(prSDLScreen->flags,prSDLScreen->w / 2,prSDLScreen->h / 2,prSDLScreen->format->BitsPerPixel,prSDLScreen->format->Rmask,prSDLScreen->format->Gmask,prSDLScreen->format->Bmask,prSDLScreen->format->Amask); tmp=SDL_LoadBMP(MENU_FILE_TEXT_0); if (text_screen==NULL || tmp==NULL) @@ -615,11 +630,6 @@ void quit_text(void) window_screen = NULL; } -void draw_image_pos(SDL_Surface *img, int x, int y) { - SDL_Rect dst = { x, y, 0, 0 }; - SDL_BlitSurface(img, NULL, text_screen, &dst); -} - void write_text(int x, int y, const char * str) { write_text_pos(x * 7, y * 7, str); diff --git a/src/gp2x/menu/menu.h b/src/gp2x/menu/menu.h index 98dfd2c..fb2893e 100755 --- a/src/gp2x/menu/menu.h +++ b/src/gp2x/menu/menu.h @@ -37,6 +37,7 @@ void draw_image_pos(SDL_Surface *img, int x, int y); int createScript(int bIcon=0); void text_flip(void); +void text_flip_with_image(SDL_Surface *img, int x, int y); void set_joyConf(void); void loadconfig(int general=0); int saveconfig(int general=0); diff --git a/src/gp2x/menu/menu_config.cpp b/src/gp2x/menu/menu_config.cpp index dc85c6a..0d62e25 100755 --- a/src/gp2x/menu/menu_config.cpp +++ b/src/gp2x/menu/menu_config.cpp @@ -74,11 +74,7 @@ int mainMenu_CPU_speed = 0; int mainMenu_cpuSpeed = 600; int mainMenu_joyConf = 0; -#if defined(__PSP2__) || defined(__SWITCH__) int mainMenu_joyPort = 2; // Default to port 1 on Vita because mouse is always on. -#else -int mainMenu_joyPort = 0; // Both ports -#endif int mainMenu_autofireRate = 8; int mainMenu_customAutofireButton = 0; int mainMenu_showStatus = DEFAULT_STATUSLN; @@ -253,11 +249,7 @@ void SetDefaultMenuSettings(int general) mainMenu_cpuSpeed = 600; mainMenu_joyConf = 0; -#if defined(__PSP2__) || defined(__SWITCH__) mainMenu_joyPort = 2; // Default to port 1 on Vita because mouse is always on. -#else - mainMenu_joyPort = 0; -#endif mainMenu_autofireRate = 8; mainMenu_customAutofireButton = 0; mainMenu_showStatus = DEFAULT_STATUSLN; @@ -1636,6 +1628,8 @@ void loadconfig(int general) fscanf(f,"joyconf=%d\n",&joybuffer); mainMenu_joyConf = (joybuffer & 0x0f); mainMenu_joyPort = ((joybuffer >> 4) & 0x0f); + if (mainMenu_joyPort == 0) + mainMenu_joyPort = 2; fscanf(f,"autofireRate=%d\n",&mainMenu_autofireRate); fscanf(f,"autofire=%d\n",&mainMenu_autofire); fscanf(f,"customAutofireButton=%d\n",&mainMenu_customAutofireButton); diff --git a/src/gp2x/menu/menu_misc.cpp b/src/gp2x/menu/menu_misc.cpp index 76a87b7..ae96990 100755 --- a/src/gp2x/menu/menu_misc.cpp +++ b/src/gp2x/menu/menu_misc.cpp @@ -33,7 +33,7 @@ static int justSwitchedSingleJoycons = 0; #endif -const char *text_str_misc_separator="--------------------------------------"; +const char *text_str_misc_separator="----------------------------------------"; static const char *text_str_misc_title= "Miscellanous"; static const char *text_str_stylus_offset="StylusOffset"; static const char *text_str_0px="0px"; @@ -121,7 +121,7 @@ static void draw_miscMenu(int c) r.x=80-64; r.y=0; r.w=110+64+64; r.h=240; text_draw_background(); - text_draw_window(2,2,40,30,text_str_misc_title); + text_draw_window(2,2,42,30,text_str_misc_title); // MENUMISC_RETURNMAIN if (menuMisc == MENUMISC_RETURNMAIN && bb) @@ -136,103 +136,103 @@ static void draw_miscMenu(int c) // MENUMISC_CPU write_text(leftMargin,menuLine,"CPU"); if ((mainMenu_CPU_model==0)&&((menuMisc!=MENUMISC_CPU)||(bb))) - write_text_inv(tabstop1,menuLine,"68000"); + write_text_inv(tabstop2,menuLine,"68000"); else - write_text(tabstop1,menuLine,"68000"); + write_text(tabstop2,menuLine,"68000"); if ((mainMenu_CPU_model==1)&&((menuMisc!=MENUMISC_CPU)||(bb))) - write_text_inv(tabstop4,menuLine,"68020"); + write_text_inv(tabstop5,menuLine,"68020"); else - write_text(tabstop4,menuLine,"68020"); + write_text(tabstop5,menuLine,"68020"); // MENUMISC_CHIPSET menuLine+=2; write_text(leftMargin,menuLine,"Chipset"); if (((mainMenu_chipset & 0xff)==0)&&((menuMisc!=MENUMISC_CHIPSET)||(bb))) - write_text_inv(tabstop1,menuLine,"OCS"); + write_text_inv(tabstop2,menuLine,"OCS"); else - write_text(tabstop1,menuLine,"OCS"); + write_text(tabstop2,menuLine,"OCS"); if (((mainMenu_chipset & 0xff)==1)&&((menuMisc!=MENUMISC_CHIPSET)||(bb))) - write_text_inv(tabstop3,menuLine,"ECS"); + write_text_inv(tabstop4,menuLine,"ECS"); else - write_text(tabstop3,menuLine,"ECS"); + write_text(tabstop4,menuLine,"ECS"); if (((mainMenu_chipset & 0xff)==2)&&((menuMisc!=MENUMISC_CHIPSET)||(bb))) - write_text_inv(tabstop5,menuLine,"AGA"); + write_text_inv(tabstop6,menuLine,"AGA"); else - write_text(tabstop5,menuLine,"AGA"); + write_text(tabstop6,menuLine,"AGA"); // MENUMISC_KICKSTART menuLine+=2; write_text(leftMargin,menuLine,"Kickstart"); if ((kickstart==0)&&((menuMisc!=MENUMISC_KICKSTART)||(bb))) - write_text_inv(tabstop1,menuLine,"1.2"); + write_text_inv(tabstop2,menuLine,"1.2"); else - write_text(tabstop1,menuLine,"1.2"); + write_text(tabstop2,menuLine,"1.2"); if ((kickstart==1)&&((menuMisc!=MENUMISC_KICKSTART)||(bb))) - write_text_inv(tabstop3,menuLine,"1.3"); + write_text_inv(tabstop4,menuLine,"1.3"); else - write_text(tabstop3,menuLine,"1.3"); + write_text(tabstop4,menuLine,"1.3"); if ((kickstart==2)&&((menuMisc!=MENUMISC_KICKSTART)||(bb))) - write_text_inv(tabstop5,menuLine,"2.0"); + write_text_inv(tabstop6,menuLine,"2.0"); else - write_text(tabstop5,menuLine,"2.0"); + write_text(tabstop6,menuLine,"2.0"); if ((kickstart==3)&&((menuMisc!=MENUMISC_KICKSTART)||(bb))) - write_text_inv(tabstop7,menuLine,"3.1"); + write_text_inv(tabstop8,menuLine,"3.1"); else - write_text(tabstop7,menuLine,"3.1"); + write_text(tabstop8,menuLine,"3.1"); if ((kickstart==4)&&((menuMisc!=MENUMISC_KICKSTART)||(bb))) - write_text_inv(tabstop9,menuLine,"Custom"); + write_text_inv(tabstop9+2,menuLine,"Custom"); else - write_text(tabstop9,menuLine,"Custom"); + write_text(tabstop9+2,menuLine,"Custom"); // MENUMISC_CPUSPEED menuLine+=2; write_text(leftMargin,menuLine,"CPU Speed"); if ((mainMenu_CPU_speed==0)&&((menuMisc!=MENUMISC_CPUSPEED)||(bb))) - write_text_inv(tabstop1,menuLine,"7MHz"); + write_text_inv(tabstop2,menuLine,"7MHz"); else - write_text(tabstop1,menuLine,"7MHz"); + write_text(tabstop2,menuLine,"7MHz"); if ((mainMenu_CPU_speed==1)&&((menuMisc!=MENUMISC_CPUSPEED)||(bb))) - write_text_inv(tabstop4,menuLine,"14MHz"); + write_text_inv(tabstop5,menuLine,"14MHz"); else - write_text(tabstop4,menuLine,"14MHz"); + write_text(tabstop5,menuLine,"14MHz"); if ((mainMenu_CPU_speed==2)&&((menuMisc!=MENUMISC_CPUSPEED)||(bb))) - write_text_inv(tabstop7,menuLine,"28MHz"); + write_text_inv(tabstop8,menuLine,"28MHz"); else - write_text(tabstop7,menuLine,"28MHz"); + write_text(tabstop8,menuLine,"28MHz"); if ((mainMenu_CPU_speed==3)&&((menuMisc!=MENUMISC_CPUSPEED)||(bb))) - write_text_inv(tabstop7+6,menuLine,"56MHz"); + write_text_inv(tabstop9+4,menuLine,"56MHz"); else - write_text(tabstop7+6,menuLine,"56MHz"); + write_text(tabstop9+4,menuLine,"56MHz"); // MENUMISC_BLITTER menuLine+=2; write_text(leftMargin,menuLine,"Blitter"); if (((mainMenu_chipset & 0xff00)!=0x100 && (mainMenu_chipset & 0xff00)!=0x200)&&((menuMisc!=MENUMISC_BLITTER)||(bb))) - write_text_inv(tabstop1,menuLine,"Normal"); + write_text_inv(tabstop2,menuLine,"Normal"); else - write_text(tabstop1,menuLine,"Normal"); + write_text(tabstop2,menuLine,"Normal"); if (((mainMenu_chipset & 0xff00)==0x100)&&((menuMisc!=MENUMISC_BLITTER)||(bb))) - write_text_inv(tabstop5-2,menuLine,"Immediate"); + write_text_inv(tabstop5,menuLine,"Immediate"); else - write_text(tabstop5-2,menuLine,"Immediate"); + write_text(tabstop5,menuLine,"Immediate"); if (((mainMenu_chipset & 0xff00)==0x200)&&((menuMisc!=MENUMISC_BLITTER)||(bb))) - write_text_inv(tabstop9,menuLine,"Improved"); + write_text_inv(tabstop9+2,menuLine,"Improved"); else - write_text(tabstop9,menuLine,"Improved"); + write_text(tabstop9+2,menuLine,"Improved"); // MENUMISC_SPRITECOLLISIONS menuLine+=2; @@ -322,31 +322,26 @@ static void draw_miscMenu(int c) // MENUMISC_JOYSTICK menuLine+=2; - write_text(leftMargin,menuLine,"Joystick"); + write_text(leftMargin,menuLine,"Controller 1"); if ((mainMenu_joyPort==1)&&((menuMisc!=MENUMISC_JOYSTICK)||(bb))) - write_text_inv(tabstop3-2,menuLine,"Port0"); + write_text_inv(tabstop2,menuLine,"Amiga Port0"); else - write_text(tabstop3-2,menuLine,"Port0"); + write_text(tabstop2,menuLine,"Amiga Port0"); if ((mainMenu_joyPort==2)&&((menuMisc!=MENUMISC_JOYSTICK)||(bb))) - write_text_inv(tabstop6-2,menuLine,"Port1"); + write_text_inv(tabstop9-1,menuLine,"Amiga Port1"); else - write_text(tabstop6-2,menuLine,"Port1"); - - if ((mainMenu_joyPort==0)&&((menuMisc!=MENUMISC_JOYSTICK)||(bb))) - write_text_inv(tabstop9-1,menuLine,"Both"); - else - write_text(tabstop9-1,menuLine,"Both"); + write_text(tabstop9-1,menuLine,"Amiga Port1"); // MENUMISC_AUTOFIRERATE menuLine+=2; write_text(leftMargin,menuLine,"Autofire Rate"); if ((mainMenu_autofireRate==8)&&((menuMisc!=MENUMISC_AUTOFIRERATE)||(bb))) - write_text_inv(tabstop3-2,menuLine,"Light"); + write_text_inv(tabstop2,menuLine,"Light"); else - write_text(tabstop3-2,menuLine,"Light"); + write_text(tabstop2,menuLine,"Light"); if ((mainMenu_autofireRate==4)&&((menuMisc!=MENUMISC_AUTOFIRERATE)||(bb))) write_text_inv(tabstop6-2,menuLine,"Medium"); @@ -957,7 +952,7 @@ static int key_miscMenu(int *c) case MENUMISC_JOYSTICK: if (left) { - if (mainMenu_joyPort>0) + if (mainMenu_joyPort>1) mainMenu_joyPort--; else mainMenu_joyPort=2; @@ -967,7 +962,7 @@ static int key_miscMenu(int *c) if (mainMenu_joyPort<2) mainMenu_joyPort++; else - mainMenu_joyPort=0; + mainMenu_joyPort=1; } break; case MENUMISC_AUTOFIRERATE: diff --git a/src/gp2x/menu/menu_savestates.cpp b/src/gp2x/menu/menu_savestates.cpp index 07413b0..629906b 100755 --- a/src/gp2x/menu/menu_savestates.cpp +++ b/src/gp2x/menu/menu_savestates.cpp @@ -12,6 +12,13 @@ #include "gui.h" #include #include +#ifdef USE_SDL2 +#include +#else +#ifndef __PSP2__ +#include +#endif +#endif #include "gp2x.h" #include #include "savestate.h" @@ -183,9 +190,10 @@ static inline void draw_savestatesMenu(int c) write_text(leftMargin,menuLine,text_str_separator); menuLine++; + int menuLineForThumb = menuLine; if (!savestate_empty) { if (thumbnail_image != NULL) { - draw_image_pos(thumbnail_image, (320 - thumbnail_image->w) / 2 , menuLine * 7); + //draw_image_pos(thumbnail_image, (320 - thumbnail_image->w) / 2 , menuLine * 7); } else { write_text(tabstop1,menuLine+9,"No preview found"); } @@ -236,7 +244,10 @@ static inline void draw_savestatesMenu(int c) else write_text(leftMargin,menuLine,text_str_deleteslot); - text_flip(); + if (!savestate_empty && thumbnail_image != NULL) + text_flip_with_image(thumbnail_image, (320 - (thumbnail_image->w / 2)) / 2, menuLineForThumb * 7 + (132 - thumbnail_image->h / 2) / 2); + else + text_flip(); b++; } @@ -605,6 +616,10 @@ void make_savestate_filenames(char *save, char *thumb) } void load_savestate_thumbnail() { + if (thumbnail_image) { + SDL_FreeSurface(thumbnail_image); + thumbnail_image = NULL; + } FILE *test=fopen(savestate_filename,"rb"); if (test) { fclose(test); @@ -618,12 +633,21 @@ void load_savestate_thumbnail() { SDL_Rect dst = {0, 0, 0, 0 }; src.h = loadedImage->h; src.w = loadedImage->w; - dst.h = 132; +#ifdef __PSP2__ + dst.h = (src.h <= 132 * 2)? src.h : 132 * 2; +#else + dst.h = 132 * 2; +#endif dst.w = (dst.h * src.w) / src.h; if (src.w >= 640) dst.w /= 2; +#ifdef __PSP2__ thumbnail_image = SDL_CreateRGBSurface(loadedImage->flags, dst.w, dst.h, loadedImage->format->BitsPerPixel, loadedImage->format->Rmask, loadedImage->format->Gmask, loadedImage->format->Bmask, loadedImage->format->Amask); SDL_SoftStretch(loadedImage, &src, thumbnail_image, &dst); +#else + thumbnail_image = zoomSurface(loadedImage, (float) dst.w / (float) src.w, (float) dst.h / (float) src.h, SMOOTHING_ON); +#endif SDL_FreeSurface(loadedImage); + loadedImage = NULL; } else thumbnail_image = NULL; } else thumbnail_image = NULL; } else savestate_empty = 1; diff --git a/src/od-joy.cpp b/src/od-joy.cpp index 84a94f4..6a5fc5a 100755 --- a/src/od-joy.cpp +++ b/src/od-joy.cpp @@ -125,9 +125,9 @@ void read_joystick(int nr, unsigned int *dir, int *button) // are we trying to figure out the regular GP2X controls for the primary (or first two) joysticks? #ifdef USE_UAE4ALL_VKBD - int usingRegularControls = ((!mainMenu_customControls) && ((mainMenu_joyPort == 0 && (nr == 0 || nr == 1)) || (nr == 1 && mainMenu_joyPort == 2) || (nr == 0 && mainMenu_joyPort == 1)) && !(buttonStart[0] && triggerR[0]) && !vkbd_mode); + int usingRegularControls = ((!mainMenu_customControls) && ((nr == 1 && mainMenu_joyPort == 2) || (nr == 0 && mainMenu_joyPort == 1)) && !(buttonStart[0] && triggerR[0]) && !vkbd_mode); #else - int usingRegularControls = ((!mainMenu_customControls) && ((mainMenu_joyPort == 0 && (nr == 0 || nr == 1)) || (nr == 1 && mainMenu_joyPort == 2) || (nr == 0 && mainMenu_joyPort == 1)) && !(buttonStart[0] && triggerR[0])); + int usingRegularControls = ((!mainMenu_customControls) && ((nr == 1 && mainMenu_joyPort == 2) || (nr == 0 && mainMenu_joyPort == 1)) && !(buttonStart[0] && triggerR[0])); #endif //PSP2 updates joysticks in handle_events function which is always called //just before read_joystick is called. No need to update them again here @@ -835,14 +835,11 @@ void read_joystick(int nr, unsigned int *dir, int *button) //If not on Vita, zero the "other" joystick if (!mainMenu_customControls) { - if(mainMenu_joyPort != 0) + // Only one joystick active + if((nr == 0 && mainMenu_joyPort == 2) || (nr == 1 && mainMenu_joyPort == 1)) { - // Only one joystick active - if((nr == 0 && mainMenu_joyPort == 2) || (nr == 1 && mainMenu_joyPort == 1)) - { - *dir = 0; - *button = 0; - } + *dir = 0; + *button = 0; } } diff --git a/src/switch/sdl2_to_sdl1.cpp b/src/switch/sdl2_to_sdl1.cpp index a107225..9503273 100644 --- a/src/switch/sdl2_to_sdl1.cpp +++ b/src/switch/sdl2_to_sdl1.cpp @@ -130,7 +130,7 @@ void SDL_SetVideoModeScaling(int x, int y, float sw, float sh) { SDL_DestroyTexture(prescaled); prescaled = NULL; } - if (mainMenu_shader == 1) { + if (mainMenu_shader == 1 && !displaying_menu) { prescale_factor_x = scaled_width / surface_width; prescale_factor_y = scaled_height / surface_height; prescaled_width = prescale_factor_x * surface_width;