Skip to content

Commit

Permalink
implement thumbnails for savestates
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Jan 11, 2019
1 parent 1dda1f0 commit 2829eaa
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 167 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
set(CMAKE_VERBOSE_MAKEFILE OFF)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 85)
set(VERSION_MINOR 86)

if(BUILD_PSP2)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
Expand Down Expand Up @@ -137,7 +137,7 @@ if(BUILD_PSP2)
-DGP2X -DPANDORA -D__PSP2__ -DUSE_AUTOCONFIG -DUSE_ZFILE -DUSE_FAME_CORE -DWITH_TESTMODE
-DUSE_SDL -DGCCCONSTFUNC="__attribute__\(\(const\)\)" -DUSE_UNDERSCORE
-DSHM_SUPPORT_LINKS=0 -DUNALIGNED_PROFITABLE -DOPTIMIZED_FLAGS -DOS_WITHOUT_MEMORY_MANAGEMENT
-DROM_PATH_PREFIX=\"ux0:/data/uae4all/roms/\" -DDATA_PREFIX=\"app0:/data/\" -DSAVE_PREFIX=\"ux0:/data/uae4all/saves/\"
-DROM_PATH_PREFIX=\"ux0:/data/uae4all/roms/\" -DDATA_PREFIX=\"app0:/data/\" -DSAVE_PREFIX=\"ux0:/data/uae4all/saves/\" -DTHUMB_PREFIX=\"ux0:/data/uae4all/thumbs/\"
-DUSE_UAE4ALL_VKBD
-DUSE_ARMV7
-DUSE_ARMNEON
Expand Down Expand Up @@ -218,6 +218,7 @@ if(BUILD_NX)
-DROM_PATH_PREFIX=\"./roms/\"
-DDATA_PREFIX=\"./data/\"
-DSAVE_PREFIX=\"./saves/\"
-DTHUMB_PREFIX=\"./thumbs/\"
-DUSE_UAE4ALL_VKBD
)

Expand Down Expand Up @@ -293,6 +294,7 @@ if(BUILD_NX)
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/kickstarts
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/saves
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/conf
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/thumbs
COMMAND cp -f ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.nro ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/${PROJECT_NAME}.nro
COMMAND cp -r ${CMAKE_SOURCE_DIR}/switchdata/data/* ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/data/
COMMAND cd ${CMAKE_BINARY_DIR}/release && zip -r ../${PROJECT_NAME}_${VERSION_MAJOR}.${VERSION_MINOR}_switch.zip ${PROJECT_NAME} && cd ${CMAKE_BINARY_DIR}
Expand Down
14 changes: 14 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ On the Switch, since v1.84, please use nsp injection to start uae4all2, otherwis

Recent changes
======
1.86

- implement thumbnail previews for savestates
- savestates are now always saved to and loaded from the `saves` folder, never in the rom folder anymore

1.85

- make some notifications in menu more readable
Expand Down Expand Up @@ -87,6 +92,10 @@ Vita/Switch-exclusive Features
- Rear touch panel can be enabled for mouse pointer control (Vita only)
- Split Joy-Con support (Switch only)
- A "fast mouse" custom button can be mapped to speed up the mouse
- Automatic full 1080p support in docked mode (Switch only)
- Savestate import/export to backup savestates
- Config file management (load, save as, etc.)
- Thumbnail previews for savestates

Controls
=====
Expand Down Expand Up @@ -302,6 +311,11 @@ Compiling

CHANGELOG
=====
1.86

- implement thumbnail previews for savestates
- savestates are now always saved to and loaded from the `saves` folder, never in the rom folder anymore

1.85

- make some notifications in menu more readable
Expand Down
11 changes: 2 additions & 9 deletions src/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,8 @@ static int var_VISIBLE_LEFT_BORDER = 73;
static int var_VISIBLE_RIGHT_BORDER = 393;
static int var_LINETOSCR_X_ADJUST_BYTES = 144;

#ifdef USE_GUICHAN
static char screenshot_filename_default[255]={
'/', 't', 'm', 'p', '/', 'n', 'u', 'l', 'l', '.', 'p', 'n', 'g', '\0'
};
char *screenshot_filename=(char *)&screenshot_filename_default[0];
FILE *screenshot_file=NULL;
#endif
static char screenshot_filename_default[255] = { "" };
char *screenshot_filename = (char *) &screenshot_filename_default[0];

// newWidth is always in LORES
void InitDisplayArea(int newWidth)
Expand Down Expand Up @@ -2320,9 +2315,7 @@ void vsync_handle_redraw (int long_frame, int lof_changed)
custom_prepare_savestate ();
savestate_state = STATE_SAVE;
pause_sound();
#if !defined(__PSP2__) && !defined(__SWITCH__)
save_thumb(SCREENSHOT, screenshot_filename);
#endif
save_state (savestate_filename, "Description!");
resume_sound();
gui_set_message("Saved", 50);
Expand Down
8 changes: 7 additions & 1 deletion src/gp2x/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ void CreateScreenshot(int code)
w=32;
h=32;
}

current_screenshot = SDL_CreateRGBSurface(prSDLScreen->flags,w,h,prSDLScreen->format->BitsPerPixel,prSDLScreen->format->Rmask,prSDLScreen->format->Gmask,prSDLScreen->format->Bmask,prSDLScreen->format->Amask);
SDL_BlitSurface(prSDLScreen, NULL, current_screenshot, NULL);
SDL_BlitSurface(prSDLScreen, NULL, current_screenshot, NULL);
}


Expand Down Expand Up @@ -614,6 +615,11 @@ 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);
Expand Down
2 changes: 2 additions & 0 deletions src/gp2x/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ void _text_draw_window_bar(SDL_Surface *sf, int x, int y, int w, int h, int per,
void CreateScreenshot(int code);
int save_thumb(int code,char *path);
int save_png(SDL_Surface* surface,char *path);
void load_savestate_thumbnail();
void draw_image_pos(SDL_Surface *img, int x, int y);

int createScript(int bIcon=0);

Expand Down
2 changes: 2 additions & 0 deletions src/gp2x/menu/menu_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,9 @@ void loadconfig(int general)
if (filebuffer[0]) {
strcpy(custom_kickrom, filebuffer);
}
// ignore this option. All saves are always made into saves folder now
fscanf(f,"useSavesFolder=%d\n",&mainMenu_useSavesFolder);
mainMenu_useSavesFolder = DEFAULT_USESAVESFOLDER;
#ifdef __SWITCH__
fscanf(f,"swapAB=%d\n",&mainMenu_swapAB);
fscanf(f,"singleJoycons=%d\n",&mainMenu_singleJoycons);
Expand Down
11 changes: 11 additions & 0 deletions src/gp2x/menu/menu_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ void extractFileName(char *str, char *buffer) {
strcpy(buffer, p);
}

void stateFilenameToThumbFilename(char *src, char *dst) {
char buffer[255] = "";
extractFileName(src, buffer);
char *p = buffer + strlen(buffer) - 4;
*p = 0;
p--;
strcat(p, ".png");
strcpy(dst, THUMB_PREFIX);
strcat(dst, buffer);
}

#ifdef ANDROIDSDL
void update_onscreen()
{
Expand Down
4 changes: 2 additions & 2 deletions src/gp2x/menu/menu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ int run_mainMenu()
{
int old_saveMenu_n_savestate = saveMenu_n_savestate;
saveMenu_n_savestate=11;
make_savestate_filenames(savestate_filename,NULL);
make_savestate_filenames(savestate_filename,screenshot_filename);
f=fopen(savestate_filename,"rb");
if (f)
{
Expand All @@ -1019,7 +1019,7 @@ int run_mainMenu()
} else
{
saveMenu_n_savestate=old_saveMenu_n_savestate;
make_savestate_filenames(savestate_filename,NULL);
make_savestate_filenames(savestate_filename,screenshot_filename);
}
}
}
Expand Down

0 comments on commit 2829eaa

Please sign in to comment.