Skip to content

Commit 67ecaa3

Browse files
committed
scroll animation in menu, stretched instead of streched, quick_save_file accessible as load file option
Signed-off-by: Vincent-FK <[email protected]>
1 parent f845d7e commit 67ecaa3

File tree

3 files changed

+85
-35
lines changed

3 files changed

+85
-35
lines changed

platform/common/menu_pico.c

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,18 @@ static const char *men_dummy[] = { NULL };
105105
#endif //MENU_ERROR
106106

107107

108-
#define RES_HW_SCREEN_HORIZONTAL 240
109-
#define RES_HW_SCREEN_VERTICAL 240
108+
#define RES_HW_SCREEN_HORIZONTAL 240
109+
#define RES_HW_SCREEN_VERTICAL 240
110110
#define SCREEN_HORIZONTAL_SIZE 240
111111
#define SCREEN_VERTICAL_SIZE 240
112112

113-
#define SCROLL_SPEED_PX 240 //This means no anumations but also no tearing effect
114-
#define FPS_MENU 30
113+
#define SCROLL_SPEED_PX 30
114+
#define FPS_MENU 50
115115
#define ARROWS_PADDING 8
116116

117117
#define MENU_ZONE_WIDTH SCREEN_HORIZONTAL_SIZE
118118
#define MENU_ZONE_HEIGHT SCREEN_VERTICAL_SIZE
119-
#define MENU_BG_SQUARE_WIDTH 180
119+
#define MENU_BG_SQUARE_WIDTH 180
120120
#define MENU_BG_SQUARE_HEIGHT 140
121121

122122
#define MENU_FONT_NAME_TITLE "/usr/games/menu_resources/OpenSans-Bold.ttf"
@@ -176,10 +176,12 @@ int brightness_percentage = 0;
176176
#undef X
177177
#define X(a, b) b,
178178
const char *aspect_ratio_name[] = {ASPECT_RATIOS};
179-
int aspect_ratio = ASPECT_RATIOS_TYPE_STRECHED;
179+
int aspect_ratio = ASPECT_RATIOS_TYPE_STRETCHED;
180180
int aspect_ratio_factor_percent = 50;
181181
int aspect_ratio_factor_step = 10;
182182

183+
int quick_load_slot_chosen = 0;
184+
183185
#undef X
184186
#define X(a, b) b,
185187
const char *resume_options_str[] = {RESUME_OPTIONS};
@@ -479,7 +481,7 @@ void init_menu_system_values(){
479481

480482
void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_confirmation, uint8_t menu_action){
481483
/// --------- Vars ---------
482-
int print_arrows = 1;
484+
int print_arrows = (scroll==0)?1:0;
483485

484486
/// --------- Clear HW screen ----------
485487
//SDL_FillRect(draw_screen, NULL, SDL_MapRGB(draw_screen->format, 255, 0, 0));
@@ -573,7 +575,12 @@ void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_co
573575

574576
case MENU_TYPE_LOAD:
575577
/// ---- Write slot -----
576-
sprintf(text_tmp, "FROM SLOT < %d >", state_slot+1);
578+
if(quick_load_slot_chosen){
579+
sprintf(text_tmp, "FROM AUTO SAVE");
580+
}
581+
else{
582+
sprintf(text_tmp, "FROM SLOT < %d >", state_slot+1);
583+
}
577584
text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color);
578585
text_pos.x = (draw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2;
579586
text_pos.y = draw_screen->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2;
@@ -589,17 +596,22 @@ void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_co
589596
text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color);
590597
}
591598
else{
592-
fname = emu_get_save_fname(1, 0, state_slot, NULL);
593-
if (fname == NULL) {
594-
text_surface = TTF_RenderText_Blended(menu_info_font, "Free", text_color);
595-
}
596-
else{
597-
printf("Found saved file: %s\n", fname);
598-
char *p = strrchr (fname, '/');
599-
char *basename = p ? p + 1 : (char *) fname;
600-
if(strlen(basename) > limit_filename_size){basename[limit_filename_size]=0;} //limiting size
601-
text_surface = TTF_RenderText_Blended(menu_small_info_font, basename, text_color);
602-
}
599+
if(quick_load_slot_chosen){
600+
text_surface = TTF_RenderText_Blended(menu_info_font, " ", text_color);
601+
}
602+
else{
603+
fname = emu_get_save_fname(1, 0, state_slot, NULL);
604+
if (fname == NULL) {
605+
text_surface = TTF_RenderText_Blended(menu_info_font, "Free", text_color);
606+
}
607+
else{
608+
printf("Found saved file: %s\n", fname);
609+
char *p = strrchr (fname, '/');
610+
char *basename = p ? p + 1 : (char *) fname;
611+
if(strlen(basename) > limit_filename_size){basename[limit_filename_size]=0;} //limiting size
612+
text_surface = TTF_RenderText_Blended(menu_small_info_font, basename, text_color);
613+
}
614+
}
603615
}
604616
}
605617
text_pos.x = (draw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2;
@@ -806,8 +818,21 @@ void run_menu_loop()
806818
}
807819
else if(idx_menus[menuItem] == MENU_TYPE_LOAD){
808820
MENU_DEBUG_PRINTF("Load Slot DOWN\n");
809-
//idx_load_slot = (!idx_load_slot)?(MAX_SAVE_SLOTS-1):(idx_load_slot-1);
810-
state_slot = (!state_slot)?(MAX_SAVE_SLOTS-1):(state_slot-1);
821+
822+
/** Choose quick save file or standard saveslot for loading */
823+
if(!quick_load_slot_chosen &&
824+
state_slot == 0 &&
825+
access(quick_save_file, F_OK ) != -1){
826+
quick_load_slot_chosen = 1;
827+
}
828+
else if(quick_load_slot_chosen){
829+
quick_load_slot_chosen = 0;
830+
state_slot = MAX_SAVE_SLOTS-1;
831+
}
832+
else{
833+
state_slot = (!state_slot)?(MAX_SAVE_SLOTS-1):(state_slot-1);
834+
}
835+
811836
/// ------ Refresh screen ------
812837
screen_refresh = 1;
813838
}
@@ -860,8 +885,21 @@ void run_menu_loop()
860885
}
861886
else if(idx_menus[menuItem] == MENU_TYPE_LOAD){
862887
MENU_DEBUG_PRINTF("Load Slot UP\n");
863-
//idx_load_slot = (idx_load_slot+1)%MAX_SAVE_SLOTS;
864-
state_slot = (state_slot+1)%MAX_SAVE_SLOTS;
888+
889+
/** Choose quick save file or standard saveslot for loading */
890+
if(!quick_load_slot_chosen &&
891+
state_slot == MAX_SAVE_SLOTS-1 &&
892+
access(quick_save_file, F_OK ) != -1){
893+
quick_load_slot_chosen = 1;
894+
}
895+
else if(quick_load_slot_chosen){
896+
quick_load_slot_chosen = 0;
897+
state_slot = 0;
898+
}
899+
else{
900+
state_slot = (state_slot+1)%MAX_SAVE_SLOTS;
901+
}
902+
865903
/// ------ Refresh screen ------
866904
screen_refresh = 1;
867905
}
@@ -915,7 +953,13 @@ void run_menu_loop()
915953
menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1);
916954

917955
/// ------ Load game ------
918-
int ret = emu_save_load_game(1, 0);
956+
int ret;
957+
if(quick_load_slot_chosen){
958+
ret = emu_save_load_game_from_file(1, quick_save_file);
959+
}
960+
else{
961+
ret = emu_save_load_game(1, 0);
962+
}
919963

920964
/// ----- Hud Msg -----
921965
if(ret){
@@ -924,8 +968,14 @@ void run_menu_loop()
924968
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP);
925969
}
926970
else{
927-
sprintf(shell_cmd, "%s %d \" LOADED FROM SLOT %d\"",
928-
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, state_slot+1);
971+
if(quick_load_slot_chosen){
972+
sprintf(shell_cmd, "%s %d \" LOADED FROM AUTO SAVE\"",
973+
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP);
974+
}
975+
else{
976+
sprintf(shell_cmd, "%s %d \" LOADED FROM SLOT %d\"",
977+
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, state_slot+1);
978+
}
929979
}
930980
fp = popen(shell_cmd, "r");
931981
if (fp == NULL) {

platform/common/menu_pico.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef enum{
1919
///------ Definition of the different aspect ratios
2020
#define ASPECT_RATIOS \
2121
X(ASPECT_RATIOS_TYPE_MANUAL, "MANUAL ZOOM") \
22-
X(ASPECT_RATIOS_TYPE_STRECHED, "STRETCHED") \
22+
X(ASPECT_RATIOS_TYPE_STRETCHED, "STRETCHED") \
2323
X(ASPECT_RATIOS_TYPE_CROPPED, "CROPPED") \
2424
X(ASPECT_RATIOS_TYPE_SCALED, "SCALED") \
2525
X(NB_ASPECT_RATIOS_TYPES, "")

platform/common/plat_sdl.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,10 +1630,10 @@ void plat_video_flip(void)
16301630
}
16311631

16321632
switch(aspect_ratio){
1633-
case ASPECT_RATIOS_TYPE_STRECHED:
1633+
case ASPECT_RATIOS_TYPE_STRETCHED:
16341634
if(game_surface->w == 320 && game_surface->h < RES_HW_SCREEN_VERTICAL){
1635-
flip_Downscale_OptimizedWidth320_mergeUpDown(game_surface, virtual_hw_screen,
1636-
RES_HW_SCREEN_HORIZONTAL, RES_HW_SCREEN_VERTICAL);
1635+
flip_Downscale_OptimizedWidth320_mergeUpDown(game_surface, virtual_hw_screen,
1636+
RES_HW_SCREEN_HORIZONTAL, RES_HW_SCREEN_VERTICAL);
16371637
}
16381638
else if(game_surface->w == 320){
16391639
flip_Downscale_LeftRightGaussianFilter_OptimizedWidth320(game_surface, virtual_hw_screen,
@@ -1666,11 +1666,11 @@ void plat_video_flip(void)
16661666
MIN(game_surface->h*RES_HW_SCREEN_HORIZONTAL/game_surface->w, RES_HW_SCREEN_VERTICAL));
16671667
break;
16681668
default:
1669-
printf("Wrong aspect ratio value: %d\n", aspect_ratio);
1670-
aspect_ratio = ASPECT_RATIOS_TYPE_STRECHED;
1671-
flip_NNOptimized_LeftRightUpDownBilinear_Optimized8(game_surface, virtual_hw_screen,
1672-
RES_HW_SCREEN_HORIZONTAL, RES_HW_SCREEN_VERTICAL);
1673-
break;
1669+
printf("Wrong aspect ratio value: %d\n", aspect_ratio);
1670+
aspect_ratio = ASPECT_RATIOS_TYPE_STRETCHED;
1671+
flip_NNOptimized_LeftRightUpDownBilinear_Optimized8(game_surface, virtual_hw_screen,
1672+
RES_HW_SCREEN_HORIZONTAL, RES_HW_SCREEN_VERTICAL);
1673+
break;
16741674
}
16751675

16761676

0 commit comments

Comments
 (0)