Skip to content

Commit 741aca6

Browse files
committed
add 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 fde53f0 commit 741aca6

File tree

3 files changed

+77
-29
lines changed

3 files changed

+77
-29
lines changed

menu/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ bool8_32 S9xDeinitUpdate (int Width, int Height, bool8_32)
297297
u32 y, pitch = sal_VideoGetPitch();
298298
u16 *src = (u16*) IntermediateScreen;
299299
u16 *dst_virtual = (u16*) sal_VideoGetBuffer();
300-
static int prev_aspect_ratio = ASPECT_RATIOS_TYPE_STRECHED;
300+
static int prev_aspect_ratio = ASPECT_RATIOS_TYPE_STRETCHED;
301301

302302
/* Clear screen */
303303
if(prev_aspect_ratio != aspect_ratio){

menu/menu.cpp

Lines changed: 75 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#define SCREEN_HORIZONTAL_SIZE RES_HW_SCREEN_HORIZONTAL
3737
#define SCREEN_VERTICAL_SIZE RES_HW_SCREEN_VERTICAL
3838

39-
#define SCROLL_SPEED_PX 240 //This means no animations but also no tearing effect
40-
#define FPS_MENU 30
39+
#define SCROLL_SPEED_PX 30
40+
#define FPS_MENU 50
4141
#define ARROWS_PADDING 8
4242

4343
#define MENU_ZONE_WIDTH SCREEN_HORIZONTAL_SIZE
@@ -132,14 +132,15 @@ int brightness_percentage = 0;
132132
#undef X
133133
#define X(a, b) b,
134134
const char *aspect_ratio_name[] = {ASPECT_RATIOS};
135-
int aspect_ratio = ASPECT_RATIOS_TYPE_STRECHED;
135+
int aspect_ratio = ASPECT_RATIOS_TYPE_STRETCHED;
136136
int aspect_ratio_factor_percent = 50;
137137
int aspect_ratio_factor_step = 10;
138138

139139
#undef X
140140
#define X(a, b) b,
141141
const char *resume_options_str[] = {RESUME_OPTIONS};
142142

143+
int quick_load_slot_chosen = 0;
143144
int savestate_slot = 0;
144145
extern u32 mExit;
145146

@@ -447,7 +448,7 @@ void init_menu_system_values(){
447448

448449
void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_confirmation, uint8_t menu_action){
449450
/// --------- Vars ---------
450-
int print_arrows = 1;
451+
int print_arrows = (scroll==0)?1:0;
451452

452453
/// --------- Clear HW screen ----------
453454
if(SDL_BlitSurface(backup_hw_screen, NULL, draw_screen, NULL)){
@@ -539,8 +540,13 @@ void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_co
539540

540541
case MENU_TYPE_LOAD:
541542
/// ---- Write slot -----
542-
sprintf(text_tmp, "FROM SLOT < %d >", savestate_slot+1);
543-
text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color);
543+
if(quick_load_slot_chosen){
544+
sprintf(text_tmp, "FROM AUTO SAVE");
545+
}
546+
else{
547+
sprintf(text_tmp, "FROM SLOT < %d >", savestate_slot+1);
548+
}
549+
text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color);
544550
text_pos.x = (draw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2;
545551
text_pos.y = draw_screen->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2;
546552
SDL_BlitSurface(text_surface, NULL, draw_screen, &text_pos);
@@ -554,18 +560,23 @@ void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_co
554560
sprintf(text_tmp, "Are you sure ?");
555561
text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color);
556562
}
557-
else{
558-
/// ---- Get current Load state ----
559-
if(mSaveState[savestate_slot].inUse)
560-
{
561-
printf("Found Load slot: %s\n", fname);
562-
strcpy(fname, mSaveState[savestate_slot].filename);
563-
if(strlen(fname) > limit_filename_size){fname[limit_filename_size]=0;} //limiting size
564-
text_surface = TTF_RenderText_Blended(menu_small_info_font,fname, text_color);
565-
}
566-
else{
567-
text_surface = TTF_RenderText_Blended(menu_info_font, "Free", text_color);
568-
}
563+
else {
564+
if(quick_load_slot_chosen){
565+
text_surface = TTF_RenderText_Blended(menu_info_font, " ", text_color);
566+
}
567+
else{
568+
/// ---- Get current Load state ----
569+
if(mSaveState[savestate_slot].inUse)
570+
{
571+
printf("Found Load slot: %s\n", fname);
572+
strcpy(fname, mSaveState[savestate_slot].filename);
573+
if(strlen(fname) > limit_filename_size){fname[limit_filename_size]=0;} //limiting size
574+
text_surface = TTF_RenderText_Blended(menu_small_info_font,fname, text_color);
575+
}
576+
else{
577+
text_surface = TTF_RenderText_Blended(menu_info_font, "Free", text_color);
578+
}
579+
}
569580
}
570581
}
571582
text_pos.x = (draw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2;
@@ -757,8 +768,21 @@ void run_menu_loop()
757768
}
758769
else if(idx_menus[menuItem] == MENU_TYPE_LOAD){
759770
MENU_DEBUG_PRINTF("Load Slot DOWN\n");
760-
//idx_load_slot = (!idx_load_slot)?(MAX_SAVE_SLOTS-1):(idx_load_slot-1);
761-
savestate_slot = (!savestate_slot)?(MAX_SAVE_SLOTS-1):(savestate_slot-1);
771+
772+
/** Choose quick save file or standard saveslot for loading */
773+
if(!quick_load_slot_chosen &&
774+
savestate_slot == 0 &&
775+
access(quick_save_file, F_OK ) != -1){
776+
quick_load_slot_chosen = 1;
777+
}
778+
else if(quick_load_slot_chosen){
779+
quick_load_slot_chosen = 0;
780+
savestate_slot = MAX_SAVE_SLOTS-1;
781+
}
782+
else{
783+
savestate_slot = (!savestate_slot)?(MAX_SAVE_SLOTS-1):(savestate_slot-1);
784+
}
785+
762786
/// ------ Refresh screen ------
763787
screen_refresh = 1;
764788
}
@@ -811,8 +835,21 @@ void run_menu_loop()
811835
}
812836
else if(idx_menus[menuItem] == MENU_TYPE_LOAD){
813837
MENU_DEBUG_PRINTF("Load Slot UP\n");
814-
//idx_load_slot = (idx_load_slot+1)%MAX_SAVE_SLOTS;
815-
savestate_slot = (savestate_slot+1)%MAX_SAVE_SLOTS;
838+
839+
/** Choose quick save file or standard saveslot for loading */
840+
if(!quick_load_slot_chosen &&
841+
savestate_slot == MAX_SAVE_SLOTS-1 &&
842+
access(quick_save_file, F_OK ) != -1){
843+
quick_load_slot_chosen = 1;
844+
}
845+
else if(quick_load_slot_chosen){
846+
quick_load_slot_chosen = 0;
847+
savestate_slot = 0;
848+
}
849+
else{
850+
savestate_slot = (savestate_slot+1)%MAX_SAVE_SLOTS;
851+
}
852+
816853
/// ------ Refresh screen ------
817854
screen_refresh = 1;
818855
}
@@ -861,11 +898,22 @@ void run_menu_loop()
861898
menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1);
862899

863900
/// ------ Load game ------
864-
LoadStateFile(mSaveState[savestate_slot].fullFilename);
901+
if(quick_load_slot_chosen){
902+
LoadStateFile(quick_save_file);
903+
}
904+
else{
905+
LoadStateFile(mSaveState[savestate_slot].fullFilename);
906+
}
865907

866908
/// ----- Hud Msg -----
867-
sprintf(shell_cmd, "%s %d \" LOADED FROM SLOT %d\"",
868-
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, savestate_slot+1);
909+
if(quick_load_slot_chosen){
910+
sprintf(shell_cmd, "%s %d \" LOADED FROM AUTO SAVE\"",
911+
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP);
912+
}
913+
else{
914+
sprintf(shell_cmd, "%s %d \" LOADED FROM SLOT %d\"",
915+
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, savestate_slot+1);
916+
}
869917
fp = popen(shell_cmd, "r");
870918
if (fp == NULL) {
871919
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
@@ -1939,8 +1987,8 @@ static void ScanSaveStates(s8 *romname)
19391987
*/
19401988
sprintf(mSaveState[i].filename,"%s%d",savename,i);
19411989
sprintf(mSaveState[i].fullFilename,"%s%s%s",mSystemDir,SAL_DIR_SEP,mSaveState[i].filename);
1942-
printf("In ScanSaveStates, mSaveState[%d].filename = %s\n", i, mSaveState[i].filename);
1943-
printf("In ScanSaveStates, mSaveState[%d].fullFilename = %s\n", i, mSaveState[i].fullFilename);
1990+
//printf("In ScanSaveStates, mSaveState[%d].filename = %s\n", i, mSaveState[i].filename);
1991+
//printf("In ScanSaveStates, mSaveState[%d].fullFilename = %s\n", i, mSaveState[i].fullFilename);
19441992
if (sal_FileExists(mSaveState[i].fullFilename)==SAL_TRUE)
19451993
{
19461994
// we have a savestate

menu/menu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ typedef enum{
167167

168168
///------ Definition of the different aspect ratios
169169
#define ASPECT_RATIOS \
170-
X(ASPECT_RATIOS_TYPE_STRECHED, "STRECHED") \
170+
X(ASPECT_RATIOS_TYPE_STRETCHED, "STRETCHED") \
171171
X(ASPECT_RATIOS_TYPE_CROPPED, "CROPPED") \
172172
X(NB_ASPECT_RATIOS_TYPES, "")
173173

0 commit comments

Comments
 (0)