Bladeren bron

added funkey changes from v1.93

Vincent-FK 3 jaren geleden
bovenliggende
commit
f1a2b41ffb

+ 1 - 1
.gitmodules

@@ -1,6 +1,6 @@
 [submodule "platform/libpicofe"]
 	path = platform/libpicofe
-	url = https://github.com/irixxxx/libpicofe.git
+	url = https://github.com/FunKey-Project/picofe-irixxxx.git
 [submodule "cpu/cyclone"]
 	path = cpu/cyclone
 	url = https://github.com/notaz/cyclone68000.git

+ 1 - 1
Makefile

@@ -210,7 +210,7 @@ endif
 ifeq "$(USE_FRONTEND)" "1"
 
 # common
-OBJS += platform/common/main.o platform/common/emu.o \
+OBJS += platform/common/main.o platform/common/configfile.o platform/common/emu.o \
 	platform/common/menu_pico.o platform/common/config_file.o
 
 # libpicofe

+ 5 - 4
configure

@@ -42,15 +42,16 @@ check_define()
 platform_list="generic pandora gp2x wiz caanoo dingux retrofw gcw0 rg350 opendingux rpi1 rpi2 psp"
 platform="generic"
 sound_driver_list="oss alsa sdl"
-sound_drivers=""
+sound_drivers="sdl"
 have_armv5=""
 have_armv6=""
-have_armv7=""
+have_armv7="yes"
 have_arm_oabi=""
-have_arm_neon=""
+have_arm_neon="yes"
 have_libavcodec=""
 have_libchdr=""
-need_sdl="no"
+need_sdl="yes"
+need_xlib="no"
 need_zlib="no"
 # these are for known platforms
 optimize_cortexa8="no"

+ 272 - 0
platform/common/configfile.c

@@ -0,0 +1,272 @@
+// configfile.c - handles loading and saving the configuration options
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <ctype.h>
+
+#include "configfile.h"
+
+#define ARRAY_LEN(arr) (sizeof(arr) / sizeof(arr[0]))
+
+enum ConfigOptionType {
+    CONFIG_TYPE_BOOL,
+    CONFIG_TYPE_UINT,
+    CONFIG_TYPE_FLOAT,
+    CONFIG_TYPE_ASPECT_RATIO,
+};
+
+struct ConfigOption {
+    const char *name;
+    enum ConfigOptionType type;
+    union {
+        bool *boolValue;
+        unsigned int *uintValue;
+        float *floatValue;
+    };
+};
+
+#undef X
+#define X(a, b) b,
+const char  *aspect_ratio_name[] = {ASPECT_RATIOS};
+unsigned int aspect_ratio_factor_step = 10;
+
+/*
+ *Config options and default values
+ */
+unsigned int aspect_ratio                   = ASPECT_RATIOS_TYPE_STRETCHED;
+unsigned int aspect_ratio_factor_percent    = 50;
+
+static const struct ConfigOption options[] = {
+    {.name = "aspect_ratio",                .type = CONFIG_TYPE_ASPECT_RATIO,    .uintValue = &aspect_ratio},
+    {.name = "aspect_ratio_factor_percent", .type = CONFIG_TYPE_UINT,            .uintValue = &aspect_ratio_factor_percent},
+};
+
+// Reads an entire line from a file (excluding the newline character) and returns an allocated string
+// Returns NULL if no lines could be read from the file
+static char *read_file_line(FILE *file) {
+    char *buffer;
+    size_t bufferSize = 64;
+    size_t offset = 0; // offset in buffer to write
+
+    buffer = (char*)malloc(bufferSize);
+    while (1) {
+        // Read a line from the file
+        if (fgets(buffer + offset, bufferSize - offset, file) == NULL) {
+            free(buffer);
+            return NULL; // Nothing could be read.
+        }
+        offset = strlen(buffer);
+        assert(offset > 0);
+
+        if (feof(file)) // EOF was reached
+            break;
+
+        // If a newline was found, remove the trailing newline and exit
+        if (buffer[offset - 1] == '\n') {
+            buffer[offset - 1] = '\0';
+            break;
+        }
+
+        // If no newline or EOF was reached, then the whole line wasn't read.
+        bufferSize *= 2; // Increase buffer size
+        buffer = (char*)realloc(buffer, bufferSize);
+        assert(buffer != NULL);
+    }
+
+    return buffer;
+}
+
+// Returns the position of the first non-whitespace character
+static char *skip_whitespace(char *str) {
+    while (isspace(*str))
+        str++;
+    return str;
+}
+
+// Returns the position of the first non-whitespace or '=' character
+static char *skip_whitespace_or_equal(char *str) {
+    while (isspace(*str) || *str=='=')
+        str++;
+    return str;
+}
+
+// NULL-terminates the current whitespace-delimited word, and returns a pointer to the next word
+static char *word_split(char *str) {
+    // Precondition: str must not point to whitespace
+    assert(!isspace(*str));
+
+    // Find either the next whitespace, '=' or end of string
+    while (!isspace(*str) && *str != '\0' && *str != '=')
+        str++;
+    if (*str == '\0') // End of string
+        return str;
+
+    // Terminate current word
+    *(str++) = '\0';
+
+    // Skip whitespace to next word
+    return skip_whitespace_or_equal(str);
+}
+
+// Splits a string into words, and stores the words into the 'tokens' array
+// 'maxTokens' is the length of the 'tokens' array
+// Returns the number of tokens parsed
+static unsigned int tokenize_string(char *str, int maxTokens, char **tokens) {
+    int count = 0;
+
+    str = skip_whitespace(str);
+    while (str[0] != '\0' && count < maxTokens) {
+        tokens[count] = str;
+        str = word_split(str);
+        count++;
+    }
+    return count;
+}
+
+// Loads the config file specified by 'filepath'
+void configfile_load(const char *filepath) {
+    FILE *file;
+    char *line;
+    unsigned int cur_line = 0;
+    char *current_section = NULL;
+
+    printf("Loading configuration from '%s'\n", filepath);
+
+    // Open file or create it if it does not exist
+    file = fopen(filepath, "r");
+    if (file == NULL) {
+        // Create a new config file and save defaults
+        printf("Config file '%s' not found. Creating it.\n", filepath);
+        configfile_save(filepath);
+        return;
+    }
+
+    // Go through each line in the file
+    while ((line = read_file_line(file)) != NULL) {
+        char *p = line;
+        char *tokens[2];
+        int numTokens;
+        cur_line++;
+
+        // Get tokens
+        while (isspace(*p)) p++;
+        numTokens = tokenize_string(p, 2, tokens);
+
+        // Get content
+        if (numTokens != 0) {            
+
+            // Pass comments
+            if(tokens[0][0]=='#') continue;
+
+            // Check sections - useless for now
+            if(tokens[0][0]=='['){
+                p=tokens[0];
+                while(*p != '\0' && *p!=']') p++;
+                if(*p == '\0') continue;
+                *p=0;
+                if(current_section) free(current_section);
+                current_section = (char*)malloc(strlen(tokens[0])); //strlen(tokens[0])-1+1
+                strcpy(current_section, &tokens[0][1]);
+                printf("New Section: %s\n", current_section);
+                continue;
+            }
+
+            if (numTokens == 2) {
+                const struct ConfigOption *option = NULL;
+
+                for (unsigned int i = 0; i < ARRAY_LEN(options); i++) {
+                    if (strcmp(tokens[0], options[i].name) == 0) {
+                        option = &options[i];
+                        break;
+                    }
+                }
+                if (option == NULL){
+                    printf("Unknown option '%s'\n", tokens[0]);
+                }
+                else {
+                    printf("Reading option: '%s', value: '%s'\n", tokens[0], tokens[1]);
+                    switch (option->type) {
+                        case CONFIG_TYPE_BOOL:
+                            if (strcmp(tokens[1], "true") == 0)
+                                *option->boolValue = true;
+                            else if (strcmp(tokens[1], "false") == 0)
+                                *option->boolValue = false;
+                            else{
+                                printf("Unknown CONFIG_TYPE_BOOL value: '%s', using default: %s\n", 
+                                    tokens[1], (*option->boolValue)?"true":"false");
+                            }
+                            break;
+                        case CONFIG_TYPE_UINT:
+                            sscanf(tokens[1], "%u", option->uintValue);
+                            break;
+                        case CONFIG_TYPE_FLOAT:
+                            sscanf(tokens[1], "%f", option->floatValue);
+                            break;
+                        case CONFIG_TYPE_ASPECT_RATIO:
+                            ;unsigned int cur_ar;
+                            for(cur_ar=0; cur_ar<NB_ASPECT_RATIOS_TYPES; cur_ar++){
+                                if(!strcmp(aspect_ratio_name[cur_ar], tokens[1])){
+                                    *option->uintValue = cur_ar;
+                                    break;
+                                }
+                            }
+                            if(cur_ar >= NB_ASPECT_RATIOS_TYPES){
+                                printf("Unknown CONFIG_TYPE_ASPECT_RATIO value: '%s', using default value: %s\n", 
+                                    tokens[1], aspect_ratio_name[*option->uintValue]);
+                            }
+                            break;
+                        default:
+                            printf("Unknown option type '%d'\n", option->type);
+                            break;
+                    }
+                }
+            } 
+            else{
+                fprintf(stderr, "Error in line %d: wrong format\n", cur_line);
+            }
+        }
+        free(line);
+    }
+
+    fclose(file);
+}
+
+// Writes the config file to 'filepath'
+void configfile_save(const char *filepath) {
+    FILE *file;
+
+    printf("Saving configuration to '%s'\n", filepath);
+
+    file = fopen(filepath, "w");
+    if (file == NULL) {
+        // error
+        printf("Could not save\n");
+        return;
+    }
+    printf("Saved !\n");
+
+    for (unsigned int i = 0; i < ARRAY_LEN(options); i++) {
+        const struct ConfigOption *option = &options[i];
+
+        switch (option->type) {
+            case CONFIG_TYPE_BOOL:
+                fprintf(file, "%s = %s\n", option->name, *option->boolValue ? "true" : "false");
+                break;
+            case CONFIG_TYPE_UINT:
+                fprintf(file, "%s = %u\n", option->name, *option->uintValue);
+                break;
+            case CONFIG_TYPE_FLOAT:
+                fprintf(file, "%s = %f\n", option->name, *option->floatValue);
+                break;
+            case CONFIG_TYPE_ASPECT_RATIO:
+                fprintf(file, "%s = %s\n", option->name, aspect_ratio_name[*option->uintValue]);
+                break;
+            default:
+                assert(0); // unknown type
+        }
+    }
+
+    fclose(file);
+}

+ 28 - 0
platform/common/configfile.h

@@ -0,0 +1,28 @@
+#ifndef CONFIGFILE_H
+#define CONFIGFILE_H
+
+#include <stdbool.h>
+
+
+///------ Definition of the different aspect ratios
+#define ASPECT_RATIOS \
+    X(ASPECT_RATIOS_TYPE_MANUAL, "ZOOMED") \
+    X(ASPECT_RATIOS_TYPE_STRETCHED, "STRETCHED") \
+    X(ASPECT_RATIOS_TYPE_CROPPED, "CROPPED") \
+    X(ASPECT_RATIOS_TYPE_SCALED, "SCALED") \
+    X(NB_ASPECT_RATIOS_TYPES, "")
+
+////------ Enumeration of the different aspect ratios ------
+#undef X
+#define X(a, b) a,
+typedef enum {ASPECT_RATIOS} ENUM_ASPECT_RATIOS_TYPES;
+
+extern unsigned int aspect_ratio;
+extern unsigned int aspect_ratio_factor_percent;
+extern const char *	aspect_ratio_name[];
+extern unsigned int aspect_ratio_factor_step;
+
+void configfile_load(const char *filename);
+void configfile_save(const char *filename);
+
+#endif

+ 241 - 10
platform/common/emu.c

@@ -21,6 +21,7 @@
 #include "../libpicofe/lprintf.h"
 #include "../libpicofe/plat.h"
 #include "emu.h"
+#include "configfile.h"
 #include "input_pico.h"
 #include "menu_pico.h"
 #include "config_file.h"
@@ -60,13 +61,15 @@ int pico_pen_x = 320/2, pico_pen_y = 240/2;
 int pico_inp_mode;
 int flip_after_sync;
 int engineState = PGS_Menu;
+int show_fps_bypass = 0;
+int need_screen_cleared = 0;
 
 static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
 
 /* tmp buff to reduce stack usage for plats with small stack */
-static char static_buff[512];
+static char static_buff[1024];
 const char *rom_fname_reload;
-char rom_fname_loaded[512];
+char rom_fname_loaded[1024];
 int reset_timing = 0;
 static unsigned int notice_msg_time;	/* when started showing */
 static char noticeMsg[40];
@@ -119,9 +122,13 @@ static void fname_ext(char *dst, int dstlen, const char *prefix, const char *ext
 
 	*dst = 0;
 	if (prefix) {
-		int len = plat_get_root_dir(dst, dstlen);
+		/*int len = plat_get_root_dir(dst, dstlen);
 		strcpy(dst + len, prefix);
-		prefix_len = len + strlen(prefix);
+		prefix_len = len + strlen(prefix);*/
+
+		/* Saves are in ROM folder */
+		prefix_len = strlen(mRomPath)+1;
+		sprintf(dst, "%s/", mRomPath);
 	}
 
 	p = fname + strlen(fname) - 1;
@@ -349,7 +356,9 @@ static void system_announce(void)
 	tv_standard = Pico.m.pal ? "PAL" : "NTSC";
 	fps = Pico.m.pal ? 50 : 60;
 
-	emu_status_msg("%s %s / %dFPS%s", tv_standard, sys_name, fps, extra);
+	//emu_status_msg("%s %s / %dFPS%s", tv_standard, sys_name, fps, extra);
+	printf("\nSystem Announce: %s, %s / %dFPS%s\n", sys_name, tv_standard, fps, extra);
+	printf("PicoIn.AHW = %d, Pico.m.hardware=%d\n", PicoIn.AHW, Pico.m.hardware);
 }
 
 static void do_region_override(const char *media_fname)
@@ -498,6 +507,15 @@ int emu_reload_rom(const char *rom_fname_in)
 		PicoIn.opt &= ~POPT_DIS_VDP_FIFO;
 	}
 
+	/* Set input map */
+	if (PicoIn.AHW & PAHW_SMS) {
+		printf("plat set sms input\n");
+		plat_set_sms_input();
+	}
+	else{
+		plat_set_genesis_input();
+	}
+
 	strncpy(rom_fname_loaded, rom_fname, sizeof(rom_fname_loaded)-1);
 	rom_fname_loaded[sizeof(rom_fname_loaded)-1] = 0;
 
@@ -873,6 +891,19 @@ int emu_check_save_file(int slot, int *time)
 	return emu_get_save_fname(1, 0, slot, time) ? 1 : 0;
 }
 
+int emu_save_load_game_from_file(int load, char *saveFname){
+	int ret = PicoState(saveFname, !load);
+	if (!ret) {
+		//emu_status_msg(load ? "STATE LOADED" : "STATE SAVED");
+	} else {
+		//emu_status_msg(load ? "LOAD FAILED" : "SAVE FAILED");
+		ret = -1;
+	}
+
+	return ret;
+}
+
+
 int emu_save_load_game(int load, int sram)
 {
 	int ret = 0;
@@ -881,8 +912,8 @@ int emu_save_load_game(int load, int sram)
 	// make save filename
 	saveFname = emu_get_save_fname(load, sram, state_slot, NULL);
 	if (saveFname == NULL) {
-		if (!sram)
-			emu_status_msg(load ? "LOAD FAILED (missing file)" : "SAVE FAILED");
+		/*if (!sram)
+			emu_status_msg(load ? "LOAD FAILED (missing file)" : "SAVE FAILED");*/
 		return -1;
 	}
 
@@ -950,9 +981,9 @@ int emu_save_load_game(int load, int sram)
 #ifdef __GP2X__
 			if (!load) sync();
 #endif
-			emu_status_msg(load ? "STATE LOADED" : "STATE SAVED");
+			//emu_status_msg(load ? "STATE LOADED" : "STATE SAVED");
 		} else {
-			emu_status_msg(load ? "LOAD FAILED" : "SAVE FAILED");
+			//emu_status_msg(load ? "LOAD FAILED" : "SAVE FAILED");
 			ret = -1;
 		}
 
@@ -1092,6 +1123,11 @@ static void do_turbo(unsigned short *pad, int acts)
 
 static void run_events_ui(unsigned int which)
 {
+	char shell_cmd[100];
+	FILE *fp;
+	//emu_action_old = emu_action;
+	//printf("New event: %d\n", which);
+
 	if (which & (PEV_STATE_LOAD|PEV_STATE_SAVE))
 	{
 		int do_it = 1;
@@ -1136,6 +1172,155 @@ static void run_events_ui(unsigned int which)
 	{
 		plat_video_toggle_renderer(1, 0);
 	}
+	if (which & PEV_VOL_DOWN)
+	{
+		printf("PEV_VOL_DOWN\r\n");
+		/// ----- Compute new value -----
+		volume_percentage = (volume_percentage < STEP_CHANGE_VOLUME)?
+			0:(volume_percentage-STEP_CHANGE_VOLUME);
+		/// ----- HUD msg ------
+		char txt[100];
+		sprintf(txt, "VOLUME %d%%", volume_percentage);
+		plat_status_msg_busy_first(txt);
+		/// ----- Shell cmd ----
+		sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
+		fp = popen(shell_cmd, "r");
+		if (fp == NULL) {
+			printf("Failed to run command %s\n", shell_cmd);
+		}
+	}
+	if (which & PEV_VOL_UP)
+	{
+		printf("PEV_VOL_UP\r\n");
+		/// ----- Compute new value -----
+		volume_percentage = (volume_percentage > 100 - STEP_CHANGE_VOLUME)?
+			100:(volume_percentage+STEP_CHANGE_VOLUME);
+		/// ----- HUD msg ------
+		char txt[100];
+		sprintf(txt, "VOLUME %d%%", volume_percentage);
+		plat_status_msg_busy_first(txt);
+		/// ----- Shell cmd ----
+		sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
+		fp = popen(shell_cmd, "r");
+		if (fp == NULL) {
+			printf("Failed to run command %s\n", shell_cmd);
+		}
+	}
+	if (which & PEV_BRIGHT_UP)
+	{
+		printf("PEV_BRIGHT_UP\r\n");
+		/// ----- Compute new value -----
+		brightness_percentage = (brightness_percentage > 100 - STEP_CHANGE_BRIGHTNESS)?
+			100:(brightness_percentage+STEP_CHANGE_BRIGHTNESS);
+		/// ----- HUD msg ------
+		char txt[100];
+		sprintf(txt, "BRIGHTNESS %d%%", brightness_percentage);
+		plat_status_msg_busy_first(txt);
+		/// ----- Shell cmd ----
+		sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
+		fp = popen(shell_cmd, "r");
+		if (fp == NULL) {
+			printf("Failed to run command %s\n", shell_cmd);
+		}
+	}
+	if (which & PEV_BRIGHT_DOWN)
+	{
+		printf("PEV_BRIGHT_DOWN\r\n");
+		/// ----- Compute new value -----
+		brightness_percentage = (brightness_percentage < STEP_CHANGE_BRIGHTNESS)?
+			0:(brightness_percentage-STEP_CHANGE_BRIGHTNESS);
+		/// ----- HUD msg ------
+		char txt[100];
+		sprintf(txt, "BRIGHTNESS %d%%", brightness_percentage);
+		plat_status_msg_busy_first(txt);
+		/// ----- Shell cmd ----
+		sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
+		fp = popen(shell_cmd, "r");
+		if (fp == NULL) {
+			printf("Failed to run command %s\n", shell_cmd);
+		}
+	}
+	if (which & PEV_AR_FACT_UP)
+	{
+		printf("PEV_AR_FACT_UP\r\n");
+		/// ----- Compute new value -----
+		if(aspect_ratio == ASPECT_RATIOS_TYPE_MANUAL){
+			aspect_ratio_factor_percent = (aspect_ratio_factor_percent+aspect_ratio_factor_step<100)?
+				aspect_ratio_factor_percent+aspect_ratio_factor_step:100;
+			need_screen_cleared = 1;
+		}
+		else{
+			aspect_ratio = ASPECT_RATIOS_TYPE_MANUAL;
+		}
+		aspect_ratio = ASPECT_RATIOS_TYPE_MANUAL;
+		/// ----- HUD msg ------
+		/*char txt[100];
+		sprintf(txt, "    DISPLAY MODE: ZOOMED - %d%%", aspect_ratio_factor_percent);
+		plat_status_msg_busy_first(txt);*/
+		sprintf(shell_cmd, "%s %d \"    DISPLAY MODE: ZOOMED %d%%%%\"",
+			SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_factor_percent);
+		fp = popen(shell_cmd, "r");
+		if (fp == NULL) {
+			printf("Failed to run command %s\n", shell_cmd);
+		}
+
+        // Save config file
+        configfile_save(cfg_file_rom);
+	}
+	if (which & PEV_AR_FACT_DOWN)
+	{
+		printf("PEV_AR_FACT_DOWN\r\n");
+		/// ----- Compute new value -----
+		if(aspect_ratio == ASPECT_RATIOS_TYPE_MANUAL){
+			aspect_ratio_factor_percent = (aspect_ratio_factor_percent>aspect_ratio_factor_step)?
+				aspect_ratio_factor_percent-aspect_ratio_factor_step:0;
+			need_screen_cleared = 1;
+		}
+		else{
+			aspect_ratio = ASPECT_RATIOS_TYPE_MANUAL;
+		}
+		aspect_ratio = ASPECT_RATIOS_TYPE_MANUAL;
+		/// ----- HUD msg ------
+		/*char txt[100];
+		sprintf(txt, "    DISPLAY MODE: ZOOMED - %d%%", aspect_ratio_factor_percent);
+		plat_status_msg_busy_first(txt);*/
+        sprintf(shell_cmd, "%s %d \"    DISPLAY MODE: ZOOMED %d%%%%\"",
+			SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_factor_percent);
+        fp = popen(shell_cmd, "r");
+        if (fp == NULL) {
+		printf("Failed to run command %s\n", shell_cmd);
+
+        // Save config file
+        configfile_save(cfg_file_rom);
+	}
+
+	}
+	if (which & PEV_DISPMODE)
+	{
+		printf("PEV_DISPMODE\r\n");
+		/// ----- Compute new value -----
+		aspect_ratio = (aspect_ratio+1)%NB_ASPECT_RATIOS_TYPES;
+		/// ----- HUD msg ------
+		//char txt[100];
+		if(aspect_ratio == ASPECT_RATIOS_TYPE_MANUAL){
+			//sprintf(txt, "    DISPLAY MODE: ZOOMED - %d%%", aspect_ratio_factor_percent);
+			sprintf(shell_cmd, "%s %d \"    DISPLAY MODE: ZOOMED %d%%%%\"",
+				SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_factor_percent);
+		}
+		else{
+			//sprintf(txt, "DISPLAY MODE: %s", aspect_ratio_name[aspect_ratio]);
+			sprintf(shell_cmd, "%s %d \"    DISPLAY MODE: %s\"",
+				SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_name[aspect_ratio]);
+		}
+		//plat_status_msg_busy_first(txt);
+		fp = popen(shell_cmd, "r");
+		if (fp == NULL) {
+			printf("Failed to run command %s\n", shell_cmd);
+		}
+
+        // Save config file
+        configfile_save(cfg_file_rom);
+	}
 	if (which & (PEV_SSLOT_PREV|PEV_SSLOT_NEXT))
 	{
 		if (which & PEV_SSLOT_PREV) {
@@ -1191,10 +1376,13 @@ void emu_update_input(void)
 
 	events &= ~prev_events;
 
+	/* SMS */
 	if (PicoIn.AHW == PAHW_PICO)
 		run_events_pico(events);
+
 	if (events)
 		run_events_ui(events);
+
 	if (movie_data)
 		update_movie();
 
@@ -1236,6 +1424,39 @@ void emu_cmn_forced_frame(int no_scale, int do_emu, void *buf)
 	PicoIn.opt = po_old;
 }
 
+
+
+
+/* Quick save and turn off the console */
+void quick_save_and_poweroff()
+{
+    printf("Save Instant Play file\n");
+
+    /* Send command to cancel any previously scheduled powerdown */
+    if (popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r") == NULL)
+    {
+        /* Countdown is still ticking, so better do nothing
+	   than start writing and get interrupted!
+	*/
+        printf("Failed to cancel scheduled shutdown\n");
+	exit(0);
+    }
+
+    /* Save  */
+    emu_save_load_game_from_file(0, quick_save_file);
+
+    /* Perform Instant Play save and shutdown */
+    execlp(SHELL_CMD_INSTANT_PLAY, SHELL_CMD_INSTANT_PLAY,
+	   prog_name, "-loadStateFile", quick_save_file, mRomName, NULL);
+
+    /* Should not be reached */
+    printf("Failed to perform Instant Play save and shutdown\n");
+
+    /* Exit Emulator */
+    exit(0);
+}
+
+
 void emu_init(void)
 {
 	char path[512];
@@ -1309,6 +1530,8 @@ void emu_sound_start(void)
 	if (currentConfig.EmuOpt & EOPT_EN_SOUND)
 	{
 		int is_stereo = (PicoIn.opt & POPT_EN_STEREO) ? 1 : 0;
+		/// Hard Bypass Stereo to mono
+		//is_stereo = 0;
 
 		PsndRerate(Pico.m.frame_count ? 1 : 0);
 
@@ -1444,8 +1667,10 @@ void emu_loop(void)
 			sprintf(fpsbuff, "%02i/%02i/%02i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2);
 			printf("%s\n", fpsbuff);
 #else
-			if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
+			if (currentConfig.EmuOpt & EOPT_SHOW_FPS || show_fps_bypass){
+				printf("%02i/%02i  \n", frames_shown, frames_done);
 				snprintf(fpsbuff, 8, "%02i/%02i  ", frames_shown, frames_done);
+			}
 #endif
 			frames_shown = frames_done = 0;
 			timestamp_fps_x3 += ms_to_ticks(1000) * 3;
@@ -1486,6 +1711,12 @@ void emu_loop(void)
 			diff = timestamp_aim_x3 - timestamp_x3;
 		}
 
+        /* Quick save and poweroff */
+        if(mQuickSaveAndPoweroff){
+		quick_save_and_poweroff();
+		mQuickSaveAndPoweroff = 0;
+        }
+
 		emu_update_input();
 		if (skip) {
 			int do_audio = diff > -target_frametime_x3 * 2;

+ 13 - 1
platform/common/emu.h

@@ -87,6 +87,15 @@ extern int config_slot, config_slot_current;
 extern unsigned char *movie_data;
 extern int reset_timing;
 extern int flip_after_sync;
+extern int show_fps_bypass;
+extern int need_screen_cleared;
+extern int mQuickSaveAndPoweroff;
+
+extern char *prog_name;
+extern char *mRomName;
+extern char *mRomPath;
+extern char *quick_save_file;
+extern char *cfg_file_rom;
 
 #define PICO_PEN_ADJUST_X 4
 #define PICO_PEN_ADJUST_Y 2
@@ -94,7 +103,7 @@ extern int pico_pen_x, pico_pen_y;
 extern int pico_inp_mode;
 
 extern const char *rom_fname_reload;		// ROM to try loading on next PGS_ReloadRom
-extern char rom_fname_loaded[512];		// currently loaded ROM filename
+extern char rom_fname_loaded[1024];		// currently loaded ROM filename
 
 // engine states
 extern int engineState;
@@ -118,6 +127,7 @@ void  emu_loop(void);
 int   emu_reload_rom(const char *rom_fname_in);
 int   emu_swap_cd(const char *fname);
 int   emu_save_load_game(int load, int sram);
+int   emu_save_load_game_from_file(int load, char *saveFname);
 void  emu_reset_game(void);
 
 void  emu_prep_defconfig(void);
@@ -165,6 +175,8 @@ void pemu_sound_start(void);
 void plat_early_init(void);
 void plat_init(void);
 void plat_finish(void);
+void plat_set_sms_input(void);
+void plat_set_genesis_input(void);
 
 /* used before things blocking for a while (these funcs redraw on return) */
 void plat_status_msg_busy_first(const char *msg);

+ 38 - 27
platform/common/input_pico.h

@@ -16,34 +16,45 @@
 #define GBTN_MODE       11
 
 /* ui events */
-#define PEVB_VOL_DOWN   30
-#define PEVB_VOL_UP     29
-#define PEVB_STATE_LOAD 28
-#define PEVB_STATE_SAVE 27
-#define PEVB_SWITCH_RND 26
-#define PEVB_SSLOT_PREV 25
-#define PEVB_SSLOT_NEXT 24
-#define PEVB_MENU       23
-#define PEVB_FF         22
-#define PEVB_PICO_PNEXT 21
-#define PEVB_PICO_PPREV 20
-#define PEVB_PICO_SWINP 19
-#define PEVB_RESET      18
+#define PEVB_VOL_DOWN   	30
+#define PEVB_VOL_UP     	29
+#define PEVB_STATE_LOAD 	28
+#define PEVB_STATE_SAVE 	27
+#define PEVB_SWITCH_RND 	26
+#define PEVB_SSLOT_PREV 	25
+#define PEVB_SSLOT_NEXT 	24
+#define PEVB_MENU       	23
+#define PEVB_FF         	22
+#define PEVB_PICO_PNEXT 	21
+#define PEVB_PICO_PPREV 	20
+#define PEVB_PICO_SWINP 	19
+#define PEVB_RESET      	18
+#define PEVB_BRIGHT_UP  	17
+#define PEVB_BRIGHT_DOWN  	16
+#define PEVB_AR_FACT_UP  	15
+#define PEVB_AR_FACT_DOWN  	14
+#define PEVB_DISPMODE	  	13
 
-#define PEV_VOL_DOWN    (1 << PEVB_VOL_DOWN)
-#define PEV_VOL_UP      (1 << PEVB_VOL_UP)
-#define PEV_STATE_LOAD  (1 << PEVB_STATE_LOAD)
-#define PEV_STATE_SAVE  (1 << PEVB_STATE_SAVE)
-#define PEV_SWITCH_RND  (1 << PEVB_SWITCH_RND)
-#define PEV_SSLOT_PREV  (1 << PEVB_SSLOT_PREV)
-#define PEV_SSLOT_NEXT  (1 << PEVB_SSLOT_NEXT)
-#define PEV_MENU        (1 << PEVB_MENU)
-#define PEV_FF          (1 << PEVB_FF)
-#define PEV_PICO_PNEXT  (1 << PEVB_PICO_PNEXT)
-#define PEV_PICO_PPREV  (1 << PEVB_PICO_PPREV)
-#define PEV_PICO_SWINP  (1 << PEVB_PICO_SWINP)
-#define PEV_RESET       (1 << PEVB_RESET)
+#define PEV_VOL_DOWN    	(1 << PEVB_VOL_DOWN)
+#define PEV_VOL_UP      	(1 << PEVB_VOL_UP)
+#define PEV_STATE_LOAD  	(1 << PEVB_STATE_LOAD)
+#define PEV_STATE_SAVE  	(1 << PEVB_STATE_SAVE)
+#define PEV_SWITCH_RND  	(1 << PEVB_SWITCH_RND)
+#define PEV_SSLOT_PREV  	(1 << PEVB_SSLOT_PREV)
+#define PEV_SSLOT_NEXT  	(1 << PEVB_SSLOT_NEXT)
+#define PEV_MENU        	(1 << PEVB_MENU)
+#define PEV_FF          	(1 << PEVB_FF)
+#define PEV_PICO_PNEXT  	(1 << PEVB_PICO_PNEXT)
+#define PEV_PICO_PPREV  	(1 << PEVB_PICO_PPREV)
+#define PEV_PICO_SWINP  	(1 << PEVB_PICO_SWINP)
+#define PEV_RESET       	(1 << PEVB_RESET)
+#define PEV_BRIGHT_UP  		(1 << PEVB_BRIGHT_UP)
+#define PEV_BRIGHT_DOWN  	(1 << PEVB_BRIGHT_DOWN)
+#define PEV_AR_FACT_UP  	(1 << PEVB_AR_FACT_UP)
+#define PEV_AR_FACT_DOWN  	(1 << PEVB_AR_FACT_DOWN)
+#define PEV_DISPMODE	  	(1 << PEVB_DISPMODE)
 
-#define PEV_MASK 0x7ffc0000
+//#define PEV_MASK 0x7ffc0000
+#define PEV_MASK 0x7fffe000
 
 #endif /* INCLUDE_c48097f3ff2a6a9af1cce8fd7a9b3f0c */

+ 75 - 1
platform/common/inputmap_kbd.c

@@ -6,7 +6,7 @@
 #include "../common/input_pico.h"
 #include "../common/plat_sdl.h"
 
-const struct in_default_bind in_sdl_defbinds[] = {
+/*const struct in_default_bind in_sdl_defbinds[] = {
 	{ SDLK_UP,     IN_BINDTYPE_PLAYER12, GBTN_UP },
 	{ SDLK_DOWN,   IN_BINDTYPE_PLAYER12, GBTN_DOWN },
 	{ SDLK_LEFT,   IN_BINDTYPE_PLAYER12, GBTN_LEFT },
@@ -31,6 +31,80 @@ const struct in_default_bind in_sdl_defbinds[] = {
 	{ SDLK_F8,     IN_BINDTYPE_EMU, PEVB_PICO_SWINP },
 	{ SDLK_BACKSPACE, IN_BINDTYPE_EMU, PEVB_FF },
 	{ 0, 0, 0 }
+};*/
+
+const struct in_default_bind in_sdl_defbinds[] = {
+	{ SDLK_u,     	IN_BINDTYPE_PLAYER12, GBTN_UP },
+	{ SDLK_d,		IN_BINDTYPE_PLAYER12, GBTN_DOWN },
+	{ SDLK_l,   	IN_BINDTYPE_PLAYER12, GBTN_LEFT },
+	{ SDLK_r,  		IN_BINDTYPE_PLAYER12, GBTN_RIGHT },
+	{ SDLK_y,       IN_BINDTYPE_PLAYER12, GBTN_A },
+	{ SDLK_b,      	IN_BINDTYPE_PLAYER12, GBTN_B },
+	{ SDLK_a,      	IN_BINDTYPE_PLAYER12, GBTN_C },
+	{ SDLK_m,       IN_BINDTYPE_PLAYER12, GBTN_X },
+	{ SDLK_x,      	IN_BINDTYPE_PLAYER12, GBTN_Y },
+	{ SDLK_n,      	IN_BINDTYPE_PLAYER12, GBTN_Z },
+	{ SDLK_s, 		IN_BINDTYPE_PLAYER12, GBTN_START },
+	{ SDLK_k,      	IN_BINDTYPE_PLAYER12, GBTN_MODE },
+	{ SDLK_q, 		IN_BINDTYPE_EMU, PEVB_MENU },
+	{ SDLK_TAB,    	IN_BINDTYPE_EMU, PEVB_RESET },
+	//{ SDLK_p,     	IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
+	{ SDLK_F1,      IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
+	{ SDLK_F2,     	IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
+
+	{ SDLK_e,     	IN_BINDTYPE_EMU, PEVB_VOL_DOWN },
+	{ SDLK_c,     	IN_BINDTYPE_EMU, PEVB_VOL_UP },
+	{ SDLK_w,     	IN_BINDTYPE_EMU, PEVB_BRIGHT_DOWN },
+	{ SDLK_g,     	IN_BINDTYPE_EMU, PEVB_BRIGHT_UP },
+	{ SDLK_j,     	IN_BINDTYPE_EMU, PEVB_AR_FACT_DOWN },
+	{ SDLK_i,     	IN_BINDTYPE_EMU, PEVB_AR_FACT_UP },
+	{ SDLK_h,     	IN_BINDTYPE_EMU, PEVB_DISPMODE },
+
+	{ SDLK_F3,     	IN_BINDTYPE_EMU, PEVB_SSLOT_PREV },
+	{ SDLK_F4,     	IN_BINDTYPE_EMU, PEVB_SSLOT_NEXT },
+	{ SDLK_F5,     	IN_BINDTYPE_EMU, PEVB_SWITCH_RND },
+	{ SDLK_F6,     	IN_BINDTYPE_EMU, PEVB_PICO_PPREV },
+	{ SDLK_F7,     	IN_BINDTYPE_EMU, PEVB_PICO_PNEXT },
+	{ SDLK_F8,     	IN_BINDTYPE_EMU, PEVB_PICO_SWINP },
+	{ SDLK_BACKSPACE, IN_BINDTYPE_EMU, PEVB_FF },
+	{ 0, 0, 0 }
+};
+
+const struct in_default_bind in_sdl_defbinds_SMS[] = {
+	{ SDLK_u,       IN_BINDTYPE_PLAYER12, GBTN_UP },
+	{ SDLK_d,       IN_BINDTYPE_PLAYER12, GBTN_DOWN },
+	{ SDLK_l,       IN_BINDTYPE_PLAYER12, GBTN_LEFT },
+	{ SDLK_r,       IN_BINDTYPE_PLAYER12, GBTN_RIGHT },
+	{ SDLK_y,       IN_BINDTYPE_PLAYER12, GBTN_C },
+	{ SDLK_a,       IN_BINDTYPE_PLAYER12, GBTN_C },
+	{ SDLK_b,       IN_BINDTYPE_PLAYER12, GBTN_B },
+	{ SDLK_x,       IN_BINDTYPE_PLAYER12, GBTN_B },
+	{ SDLK_m,       IN_BINDTYPE_PLAYER12, GBTN_X },
+	{ SDLK_n,       IN_BINDTYPE_PLAYER12, GBTN_Z },
+	{ SDLK_s,       IN_BINDTYPE_PLAYER12, GBTN_START },
+	{ SDLK_k,       IN_BINDTYPE_PLAYER12, GBTN_MODE },
+	{ SDLK_q,       IN_BINDTYPE_EMU, PEVB_MENU },
+	{ SDLK_TAB,     IN_BINDTYPE_EMU, PEVB_RESET },
+	//{ SDLK_p,       IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
+	{ SDLK_F1,      IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
+	{ SDLK_F2,      IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
+
+	{ SDLK_e,       IN_BINDTYPE_EMU, PEVB_VOL_DOWN },
+	{ SDLK_c,       IN_BINDTYPE_EMU, PEVB_VOL_UP },
+	{ SDLK_w,       IN_BINDTYPE_EMU, PEVB_BRIGHT_DOWN },
+	{ SDLK_g,       IN_BINDTYPE_EMU, PEVB_BRIGHT_UP },
+	{ SDLK_j,       IN_BINDTYPE_EMU, PEVB_AR_FACT_DOWN },
+	{ SDLK_i,       IN_BINDTYPE_EMU, PEVB_AR_FACT_UP },
+	{ SDLK_h,       IN_BINDTYPE_EMU, PEVB_DISPMODE },
+
+	{ SDLK_F3,      IN_BINDTYPE_EMU, PEVB_SSLOT_PREV },
+	{ SDLK_F4,      IN_BINDTYPE_EMU, PEVB_SSLOT_NEXT },
+	{ SDLK_F5,      IN_BINDTYPE_EMU, PEVB_SWITCH_RND },
+	{ SDLK_F6,      IN_BINDTYPE_EMU, PEVB_PICO_PPREV },
+	{ SDLK_F7,      IN_BINDTYPE_EMU, PEVB_PICO_PNEXT },
+	{ SDLK_F8,      IN_BINDTYPE_EMU, PEVB_PICO_SWINP },
+	{ SDLK_BACKSPACE, IN_BINDTYPE_EMU, PEVB_FF },
+	{ 0, 0, 0 }
 };
 
 const struct menu_keymap in_sdl_key_map[] = {

+ 151 - 19
platform/common/main.c

@@ -8,8 +8,10 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <string.h>
 #include <strings.h>
+#include <signal.h>
 #ifdef USE_SDL
 #include <SDL.h>
 #endif
@@ -18,6 +20,7 @@
 #include "../libpicofe/plat.h"
 #include "menu_pico.h"
 #include "emu.h"
+#include "configfile.h"
 #include "version.h"
 #include <cpu/debug.h>
 
@@ -25,8 +28,43 @@
 #include "file_stream_transforms.h"
 #endif
 
-static int load_state_slot = -1;
 char **g_argv;
+char *prog_name;
+static char *load_state_file = NULL;
+static int load_state_slot = -1;
+static char *quick_save_file_extension = "quicksave";
+char *mRomName = NULL;
+char *mRomPath = NULL;
+char *quick_save_file = NULL;
+char *cfg_file_default = NULL;
+char *cfg_file_rom = NULL;
+static char *cfg_file_default_name = "default_config";
+static char *cfg_file_extension = "cfg";
+int mQuickSaveAndPoweroff=0;
+
+
+void usage(){
+	printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009,2013\n");
+	printf("usage: PicoDriveBin [options] [romfile]\n");
+	printf("options:\n"
+		" -config <file>    use specified config file instead of default 'config.cfg'\n"
+		" -fps				use to show fps\n"
+		" -loadStateSlot <num>  if ROM is specified, try loading savestate slot <num>\n"
+		" -loadStateFile <filePath>  if ROM is specified, try loading savestate file <filePath>\n");
+  exit(1);
+}
+
+/* Handler for SIGUSR1, caused by closing the console */
+void handle_sigusr1(int sig)
+{
+    //printf("Caught signal USR1 %d\n", sig);
+
+    /* Exit menu if it was launched */
+    stop_menu_loop = 1;
+
+    /* Signal to quick save and poweoff after next loop */
+    mQuickSaveAndPoweroff = 1;
+}
 
 void parse_cmd_line(int argc, char *argv[])
 {
@@ -39,11 +77,19 @@ void parse_cmd_line(int argc, char *argv[])
 			if (strcasecmp(argv[x], "-config") == 0) {
 				if (x+1 < argc) { ++x; PicoConfigFile = argv[x]; }
 			}
-			else if (strcasecmp(argv[x], "-loadstate") == 0
+			else if (strcasecmp(argv[x], "-loadStateSlot") == 0
 				 || strcasecmp(argv[x], "-load") == 0)
 			{
 				if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
 			}
+			else if (strcasecmp(argv[x], "-loadStateFile") == 0)
+			{
+				if (x+1 < argc) { ++x; load_state_file = argv[x]; }
+			}
+			else if (strcasecmp(argv[x], "-fps") == 0) {
+				currentConfig.EmuOpt |= EOPT_SHOW_FPS;
+				show_fps_bypass = 1;
+			}
 			else if (strcasecmp(argv[x], "-pdb") == 0) {
 				if (x+1 < argc) { ++x; pdb_command(argv[x]); }
 			}
@@ -54,26 +100,62 @@ void parse_cmd_line(int argc, char *argv[])
 				unrecognized = 1;
 				break;
 			}
-		} else {
+		}
+		/* Check if file exists, Save ROM name, and ROM path */
+		else {
+			mRomName = argv[x];
 			FILE *f = fopen(argv[x], "rb");
 			if (f) {
+				/* Save Rom path */
+		        mRomPath = (char *)malloc(strlen(mRomName)+1);
+		        strcpy(mRomPath, mRomName);
+		        char *slash = strrchr ((char*)mRomPath, '/');
+		        *slash = 0;
+
+		        /* Rom name without extension */
+		        char *point = strrchr ((char*)slash+1, '.');
+		        *point = 0;
+
+		        /* Set quicksave filename */
+		        quick_save_file = (char *)malloc(strlen(mRomPath) + strlen(slash+1) +
+		          strlen(quick_save_file_extension) + 2 + 1);
+		        sprintf(quick_save_file, "%s/%s.%s",
+		          mRomPath, slash+1, quick_save_file_extension);
+		        printf("Quick_save_file: %s\n", quick_save_file);
+				
+		        /* Set rom cfg filepath */
+		        cfg_file_rom = (char *)malloc(strlen(mRomPath) + strlen(slash+1) +
+		          strlen(cfg_file_extension) + 2 + 1);
+		        sprintf(cfg_file_rom, "%s/%s.%s",
+		          mRomPath, slash+1, cfg_file_extension);
+		        printf("cfg_file_rom: %s\n", cfg_file_rom);
+
+		        /* Set console cfg filepath */
+		        cfg_file_default = (char *)malloc(strlen(mRomPath) + strlen(cfg_file_default_name) +
+		          strlen(cfg_file_extension) + 2 + 1);
+		        sprintf(cfg_file_default, "%s/%s.%s",
+		          mRomPath, cfg_file_default_name, cfg_file_extension);
+		        printf("cfg_file_default: %s\n", cfg_file_default);
+
+		        /** Load config files */
+		        configfile_load(cfg_file_default);
+		        configfile_load(cfg_file_rom);
+
+		        /* Close file*/
 				fclose(f);
 				rom_fname_reload = argv[x];
 				engineState = PGS_ReloadRom;
 			}
-			else
+			else{
+				printf("Rom %s not found \n", mRomName);
 				unrecognized = 1;
+			}
 			break;
 		}
 	}
 
 	if (unrecognized) {
-		printf("\n\n\nPicoDrive v" VERSION " (c) notaz, 2006-2009,2013\n");
-		printf("usage: %s [options] [romfile]\n", argv[0]);
-		printf("options:\n"
-			" -config <file>    use specified config file instead of default 'config.cfg'\n"
-			" -loadstate <num>  if ROM is specified, try loading savestate slot <num>\n");
-		exit(1);
+		usage();
 	}
 }
 
@@ -82,6 +164,26 @@ int main(int argc, char *argv[])
 {
 	g_argv = argv;
 
+	/* Save program name */
+	prog_name = argv[0];
+
+	/* Engine initial state */
+	engineState = PGS_Menu;
+
+	/* Parse arguments */
+	if (argc > 1){
+		parse_cmd_line(argc, argv);
+	}
+	else{
+    		usage();
+	}
+
+	/* Init Signals */
+	signal(SIGUSR1, handle_sigusr1);
+
+    /* Set env var for no mouse */
+    putenv(strdup("SDL_NOMOUSE=1"));
+
 	plat_early_init();
 
 	in_init();
@@ -89,25 +191,54 @@ int main(int argc, char *argv[])
 
 	plat_target_init();
 	plat_init();
-	menu_init();
+	//menu_init();
 
 	emu_prep_defconfig(); // depends on input
 	emu_read_config(NULL, 0);
 
 	emu_init();
-
-	engineState = PGS_Menu;
-
-	if (argc > 1)
-		parse_cmd_line(argc, argv);
+	menu_init();
 
 	if (engineState == PGS_ReloadRom)
 	{
 		if (emu_reload_rom(rom_fname_reload)) {
 			engineState = PGS_Running;
-			if (load_state_slot >= 0) {
-				state_slot = load_state_slot;
+
+			/* Load slot */
+			if(load_state_slot != -1){
+				printf("LOADING FROM SLOT %d...\n", load_state_slot+1);
+				char fname[1024];
 				emu_save_load_game(1, 0);
+				printf("LOADED FROM SLOT %d\n", load_state_slot+1);
+				load_state_slot = -1;
+			}
+			/* Load file */
+			else if(load_state_file != NULL){
+				printf("LOADING FROM FILE %s...\n", load_state_file);
+				emu_save_load_game_from_file(1, load_state_file);
+				printf("LOADED FROM SLOT %s\n", load_state_file);
+				load_state_file = NULL;
+			}
+			/* Load quick save file */
+			else if(access( quick_save_file, F_OK ) != -1){
+				printf("Found quick save file: %s\n", quick_save_file);
+
+				int resume = launch_resume_menu_loop();
+				if(resume == RESUME_YES){
+					printf("Resume game from quick save file: %s\n", quick_save_file);
+					emu_save_load_game_from_file(1, quick_save_file);
+				}
+				else{
+					printf("Reset game\n");
+
+					/* Remove quicksave file if present */
+					if (remove(quick_save_file) == 0){
+						printf("Deleted successfully: %s\n", quick_save_file);
+					}
+					else{
+						printf("Unable to delete the file: %s\n", quick_save_file);
+					}
+				}
 			}
 		}
 	}
@@ -117,7 +248,8 @@ int main(int argc, char *argv[])
 		switch (engineState)
 		{
 			case PGS_Menu:
-				menu_loop();
+				//menu_loop();
+				menu_loop_funkey();
 				break;
 
 			case PGS_TrayMenu:

File diff suppressed because it is too large
+ 1292 - 0
platform/common/menu_pico.c


+ 61 - 0
platform/common/menu_pico.h

@@ -1,8 +1,69 @@
 #ifndef __MENU_PICO_H__
 #define __MENU_PICO_H__
 
+#include <SDL/SDL.h>
 #include "../libpicofe/menu.h"
 
+typedef enum{
+    MENU_TYPE_VOLUME,
+    MENU_TYPE_BRIGHTNESS,
+    MENU_TYPE_SAVE,
+    MENU_TYPE_LOAD,
+    MENU_TYPE_ASPECT_RATIO,
+    MENU_TYPE_EXIT,
+    MENU_TYPE_POWERDOWN,
+    NB_MENU_TYPES,
+} ENUM_MENU_TYPE;
+
+///------ Definition of the different resume options
+#define RESUME_OPTIONS \
+    X(RESUME_YES, "RESUME GAME") \
+    X(RESUME_NO, "NEW GAME") \
+    X(NB_RESUME_OPTIONS, "")
+
+////------ Enumeration of the different resume options ------
+#undef X
+#define X(a, b) a,
+typedef enum {RESUME_OPTIONS} ENUM_RESUME_OPTIONS;
+
+////------ Defines to be shared -------
+#define STEP_CHANGE_VOLUME          10
+#define STEP_CHANGE_BRIGHTNESS      10
+#define NOTIF_SECONDS_DISP          2
+
+////------ Menu commands -------
+#define SHELL_CMD_VOLUME_GET                "volume_get"
+#define SHELL_CMD_VOLUME_SET                "volume_set"
+#define SHELL_CMD_BRIGHTNESS_GET            "brightness_get"
+#define SHELL_CMD_BRIGHTNESS_SET            "brightness_set"
+#define SHELL_CMD_NOTIF                     "notif_set"
+#define SHELL_CMD_WRITE_QUICK_LOAD_CMD      "write_args_quick_load_file"
+#define SHELL_CMD_TURN_AMPLI_ON             "start_audio_amp 1"
+#define SHELL_CMD_TURN_AMPLI_OFF            "start_audio_amp 0"
+#define SHELL_CMD_CANCEL_SCHED_POWERDOWN    "cancel_sched_powerdown"
+#define SHELL_CMD_INSTANT_PLAY              "instant_play"
+#define SHELL_CMD_SHUTDOWN_FUNKEY           "shutdown_funkey"
+
+#define MAXPATHLEN	512
+
+extern void SDL_Rotate_270(SDL_Surface * hw_surface, SDL_Surface * virtual_hw_surface);
+
+void init_menu_SDL();
+void deinit_menu_SDL();
+void init_menu_zones();
+void init_menu_system_values();
+void menu_loop_funkey(void);
+void run_menu_loop();
+int launch_resume_menu_loop();
+
+extern int volume_percentage;
+extern int brightness_percentage;
+
+extern int stop_menu_loop;
+extern char *mRomName;
+extern char *mRomPath;
+extern char *quick_save_file;
+
 typedef enum
 {
 	MA_NONE = 1,

File diff suppressed because it is too large
+ 1392 - 0
platform/common/plat_sdl.c


+ 1 - 0
platform/common/plat_sdl.h

@@ -1,5 +1,6 @@
 
 extern const struct in_default_bind in_sdl_defbinds[];
+extern const struct in_default_bind in_sdl_defbinds_SMS[];
 extern const struct menu_keymap in_sdl_key_map[];
 extern const int in_sdl_key_map_sz;
 extern const struct menu_keymap in_sdl_joy_map[];

Some files were not shown because too many files changed in this diff