diff --git a/source/gx/config.c b/source/gx/config.c index 9cc8e8d..549b19c 100644 --- a/source/gx/config.c +++ b/source/gx/config.c @@ -115,6 +115,7 @@ void config_default(void) gx_input_SetDefault(); /* menu options */ + config.autoload = 0; #ifdef HW_RVL config.s_auto = 1; #else @@ -125,10 +126,15 @@ void config_default(void) config.bg_color = 0; config.bg_overlay = 0; config.screen_w = 658; - config.ask_confirm = 0; config.bgm_volume = 100.0; config.sfx_volume = 100.0; + /* default ROM directories */ + sprintf (config.sddir, "sd:%s/roms/", DEFAULT_PATH); +#ifdef HW_RVL + sprintf (config.usbdir, "usb:%s/roms/", DEFAULT_PATH); +#endif + /* restore from config file */ config_load(); io_init(); diff --git a/source/gx/config.h b/source/gx/config.h index c75a69e..0a8a3e5 100644 --- a/source/gx/config.h +++ b/source/gx/config.h @@ -31,12 +31,12 @@ typedef struct { char version[16]; - uint8 hq_fm; - uint8 psgBoostNoise; int32 psg_preamp; int32 fm_preamp; + uint8 hq_fm; + uint8 psgBoostNoise; uint8 filter; - int16 lp_range; + int8 lp_range; int16 low_freq; int16 high_freq; float lg; @@ -61,24 +61,26 @@ typedef struct uint8 render; uint8 ntsc; uint8 bilinear; -#ifdef HW_RVL - uint8 trap; - float gamma; -#endif uint8 gun_cursor[2]; uint8 invert_mouse; uint16 pad_keymap[4][MAX_KEYS]; - uint32 wpad_keymap[4*3][MAX_KEYS]; t_input_config input[MAX_INPUTS]; + uint8 autoload; uint8 s_auto; uint8 s_default; uint8 s_device; int8 bg_color; int8 bg_overlay; int16 screen_w; - uint8 ask_confirm; float bgm_volume; float sfx_volume; + char sddir[MAXPATHLEN]; +#ifdef HW_RVL + float gamma; + uint32 trap; + uint32 wpad_keymap[4*3][MAX_KEYS]; + char usbdir[MAXPATHLEN]; +#endif } t_config; /* Global data */ diff --git a/source/gx/fileio/dvd.c b/source/gx/fileio/dvd.c index f3e757a..c954a45 100644 --- a/source/gx/fileio/dvd.c +++ b/source/gx/fileio/dvd.c @@ -45,7 +45,8 @@ static u8 DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32); /* data buffer for all DVD u32 dvd_read (void *dst, u32 len, u64 offset) { /*** We only allow 2k reads **/ - if (len > DVDCHUNK) return 0; + if (len > DVDCHUNK) + return 0; /*** Let's not read past end of DVD ***/ if(offset < DvdMaxOffset) @@ -64,14 +65,17 @@ u32 dvd_read (void *dst, u32 len, u64 offset) dvd[7] = 3; /*** Enable reading with DMA ***/ - while (dvd[7] & 1) usleep(10); + while (dvd[7] & 1) + usleep(10); memcpy (dst, buffer, len); /*** Ensure it has completed ***/ - if (dvd[0] & 0x4) return 0; + if (dvd[0] & 0x4) + return 0; #else - if (DI_ReadDVD(buffer, len >> 11, (u32)(offset >> 11))) return 0; + if (DI_ReadDVD(buffer, len >> 11, (u32)(offset >> 11))) + return 0; memcpy (dst, buffer, len); #endif return 1; @@ -100,7 +104,8 @@ void dvd_motor_off( ) dvd[5] = 0; dvd[6] = 0; dvd[7] = 1; // Do immediate - while (dvd[7] & 1) usleep(10); + while (dvd[7] & 1) + usleep(10); /*** PSO Stops blackscreen at reload ***/ dvd[0] = 0x14; @@ -133,8 +138,8 @@ void uselessinquiry () dvd[5] = 0x80000000; dvd[6] = 0x20; dvd[7] = 1; - - while (dvd[7] & 1) usleep(10); + while (dvd[7] & 1) + usleep(10); } /**************************************************************************** @@ -153,11 +158,11 @@ void dvd_drive_detect() dvd[5] = 0x80000000; dvd[6] = 0x20; dvd[7] = 3; - while( dvd[7] & 1 ) usleep(10); - DCFlushRange((void *)0x80000000, 32); + while (dvd[7] & 1) + usleep(10); + DCFlushRange((void *)0x80000000, 32); int driveid = (int)inquiry[2]; - if ((driveid == 4) || (driveid == 6) || (driveid == 8)) { /* Gamecube DVD Drive (1.4 GB)*/ diff --git a/source/gx/fileio/file_dvd.c b/source/gx/fileio/file_dvd.c index 7593669..32229cd 100644 --- a/source/gx/fileio/file_dvd.c +++ b/source/gx/fileio/file_dvd.c @@ -79,11 +79,14 @@ static int getpvd() break; } } - else return 0; /*** Can't read sector! ***/ + else + return 0; /*** Can't read sector! ***/ + sector++; } - if (IsJoliet > 0) return 1; /*** Joliet PVD Found ? ***/ + if (IsJoliet > 0) + return 1; /*** Joliet PVD Found ? ***/ /*** Look for standard ISO9660 PVD ***/ sector = 16; @@ -101,8 +104,10 @@ static int getpvd() break; } } - else return 0; /*** Can't read sector! ***/ - sector++; + else + return 0; /*** Can't read sector! ***/ + + sector++; } return (IsJoliet == 0); @@ -125,8 +130,10 @@ static int getentry(int entrycount) u32 offset32; /* Basic checks */ - if (entrycount >= MAXFILES) return 0; - if (diroffset >= DVDCHUNK) return 0; + if (entrycount >= MAXFILES) + return 0; + if (diroffset >= DVDCHUNK) + return 0; /** Decode this entry **/ if (dvdbuffer[diroffset]) /* Record length available */ @@ -139,32 +146,36 @@ static int getentry(int entrycount) /* Check for wrap round - illegal in ISO spec, * but certain crap writers do it! */ - if ((diroffset + dvdbuffer[diroffset]) > DVDCHUNK) return 0; + if ((diroffset + dvdbuffer[diroffset]) > DVDCHUNK) + return 0; if (*filenamelength) { memset (&fname, 0, 512); - /*** Do ISO 9660 first ***/ - if (!IsJoliet) strcpy (fname, filename); + /** Do ISO 9660 first **/ + if (!IsJoliet) + strcpy (fname, filename); + else { - /*** The more tortuous unicode joliet entries ***/ + /** The more tortuous unicode joliet entries **/ for (j = 0; j < (*filenamelength >> 1); j++) - { fname[j] = filename[j * 2 + 1]; - } - fname[j] = 0; - if (strlen (fname) >= MAXJOLIET) fname[MAXJOLIET - 1] = 0; - if (strlen (fname) == 0) fname[0] = filename[0]; + if (strlen (fname) >= MAXJOLIET) + fname[MAXJOLIET - 1] = 0; + if (strlen (fname) == 0) + fname[0] = filename[0]; } - if (strlen (fname) == 0) strcpy (fname, "."); + if (strlen (fname) == 0) + strcpy (fname, "."); else { - if (fname[0] == 1) strcpy (fname, ".."); + if (fname[0] == 1) + strcpy (fname, ".."); else { /* @@ -176,20 +187,20 @@ static int getentry(int entrycount) } } - /** Rockridge Check **/ + /* Rockridge Check */ rr = strstr (fname, ";"); - if (rr != NULL) *rr = 0; + if (rr != NULL) + *rr = 0; strcpy (filelist[entrycount].filename, fname); memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4); filelist[entrycount].offset = (u64)offset32; memcpy (&filelist[entrycount].length, &dvdbuffer[diroffset + FILE_LENGTH], 4); memcpy (&filelist[entrycount].flags, &dvdbuffer[diroffset + FILE_FLAGS], 1); - filelist[entrycount].offset <<= 11; filelist[entrycount].flags = filelist[entrycount].flags & 2; - /*** Prepare for next entry ***/ + /* Prepare for next entry */ diroffset += dvdbuffer[diroffset]; return 1; @@ -216,7 +227,8 @@ void DVD_ClearDirectory(void) int DVD_UpdateDirectory(bool go_up, u64 offset, u32 length) { /* root has no parent directory */ - if (go_up && (basedir == rootdir)) return 0; + if (go_up && (basedir == rootdir)) + return 0; /* simply update current root directory */ rootdir = offset; @@ -252,7 +264,8 @@ int DVD_ParseDirectory(void) /*** Get as many files as possible ***/ while (len < pdlength) { - if (dvd_read (&dvdbuffer, DVDCHUNK, pdoffset) == 0) return 0; + if (dvd_read (&dvdbuffer, DVDCHUNK, pdoffset) == 0) + return 0; diroffset = 0; @@ -342,8 +355,9 @@ int DVD_Open(void) /* is DVD mounted ? */ if (!getpvd()) { - /* mount DVD */ + /* remount DVD */ GUI_MsgBoxOpen("Information", "Mounting DVD ...",1); + haveDVDdir = 0; #ifdef HW_RVL u32 val; @@ -368,7 +382,6 @@ int DVD_Open(void) DVD_Mount(); #endif - haveDVDdir = 0; if (!getpvd()) { GUI_WaitPrompt("Error","Disc can not be read !"); @@ -378,27 +391,32 @@ int DVD_Open(void) GUI_MsgBoxClose(); } - if (haveDVDdir == 0) + if (!haveDVDdir) { - /* reset root directory */ + /* reset current directory */ rootdir = basedir; - /* parse root directory */ + /* parse current directory */ int max = DVD_ParseDirectory (); + if (max) { - /* set DVD as default */ + /* set DVD access flag */ haveDVDdir = 1; - FAT_ClearDirectory(); /* reset File selector */ ClearSelector(max); + + /* clear FAT access flag */ + FAT_ClearDirectory(); + return 1; } else { /* no entries found */ GUI_WaitPrompt("Error","No files found !"); + return 0; } } diff --git a/source/gx/fileio/file_fat.c b/source/gx/fileio/file_fat.c index 4d10923..6b70347 100644 --- a/source/gx/fileio/file_fat.c +++ b/source/gx/fileio/file_fat.c @@ -29,24 +29,20 @@ #include "file_fat.h" #include "file_dvd.h" -/* FAT directory has been updated */ -static int haveFATdir = 0; - /* current FAT directory */ -static char fatdir[MAXPATHLEN]; +static char *fatdir; /* current FAT device */ -static int fat_type = 0; -static int useHistory = 0; +static int fatType = -1; /*************************************************************************** * FAT_ClearDirectory * - * Clear FAT directory flag + * Clear FAT access flag ***************************************************************************/ void FAT_ClearDirectory(void) { - haveFATdir = 0; + fatType = -1; } /*************************************************************************** @@ -54,14 +50,14 @@ void FAT_ClearDirectory(void) * * Update FAT current root directory ***************************************************************************/ -int FAT_UpdateDirectory(bool go_up, char *filename) +int FAT_UpdateDirectory(bool go_up, char *dirname) { int size=0; char *test; char temp[1024]; /* go up to parent directory */ - if (strcmp(filename,"..") == 0) + if (strcmp(dirname,"..") == 0) { /* determine last subdirectory namelength */ sprintf(temp,"%s",fatdir); @@ -84,7 +80,7 @@ int FAT_UpdateDirectory(bool go_up, char *filename) else { /* by default, simply append folder name */ - sprintf(fatdir, "%s%s/",fatdir, filename); + sprintf(fatdir, "%s%s/",fatdir, dirname); } return 1; } @@ -137,55 +133,51 @@ int FAT_ParseDirectory(void) ****************************************************************************/ int FAT_LoadFile(u8 *buffer, u32 selection) { - /* If loading from history then we need to setup a few more things. */ - if(useHistory) + char fname[MAXPATHLEN]; + int length = 0; + + /* Loading from history */ + if(fatType == TYPE_RECENT) { - /* Get the parent folder for the file. */ - strncpy(fatdir, history.entries[selection].filepath, MAXJOLIET-1); - fatdir[MAXJOLIET-1] = '\0'; + /* full filename */ + sprintf(fname,"%s%s",history.entries[selection].filepath,filelist[selection].filename); - /* Get the length of the file. This has to be done - * before calling LoadFile(). */ - char filepath[MAXJOLIET]; + /* get the length of the file */ struct stat filestat; - snprintf(filepath, MAXJOLIET-1, "%s%s", history.entries[selection].filepath, history.entries[selection].filename); - filepath[MAXJOLIET-1] = '\0'; - if(stat(filepath, &filestat) == 0) - { - filelist[selection].length = filestat.st_size; - } - - /* update filelist */ - haveFATdir = 0; + if(stat(fname, &filestat) == 0) + length = filestat.st_size; } + else + { + /* full filename */ + sprintf(fname, "%s%s",fatdir,filelist[selection].filename); - /* file size */ - int length = filelist[selection].length; + /* get the length of the file */ + length = filelist[selection].length; + } if (length > 0) { - /* Add/move the file to the top of the history. */ - history_add_file(fatdir, filelist[selection].filename); - - /* full filename */ - char fname[MAXPATHLEN]; - sprintf(fname, "%s%s",fatdir,filelist[selection].filename); - - /* open file */ + /* Open file */ FILE *sdfile = fopen(fname, "rb"); if (sdfile == NULL) { GUI_WaitPrompt("Error","Unable to open file !"); - haveFATdir = 0; return 0; } + /* Add/move the file to the top of the history. */ + if(fatType == TYPE_RECENT) + history_add_file(history.entries[selection].filepath, filelist[selection].filename); + else + history_add_file(fatdir, filelist[selection].filename); + /* Read first data chunk */ unsigned char temp[FATCHUNK]; fread(temp, FATCHUNK, 1, sdfile); fclose(sdfile); - /* determine file type */ + /* Determine file type */ if (!IsZipFile ((char *) temp)) { /* re-open and read file */ @@ -195,22 +187,23 @@ int FAT_LoadFile(u8 *buffer, u32 selection) char msg[50]; sprintf(msg,"Loading %d bytes ...", length); GUI_MsgBoxOpen("Information",msg,1); - int i = 0; + int done = 0; while (length > FATCHUNK) { - fread(buffer+i, FATCHUNK, 1, sdfile); + fread(buffer + done, FATCHUNK, 1, sdfile); length -= FATCHUNK; - i += FATCHUNK; + done += FATCHUNK; } - fread(buffer+i, length, 1, sdfile); + fread(buffer + done, length, 1, sdfile); + done += length; fclose(sdfile); - return filelist[selection].length; + return done; } } else { /* unzip file */ - return UnZipBuffer (buffer, 0, fname); + return UnZipBuffer(buffer, 0, fname); } } @@ -225,78 +218,73 @@ int FAT_LoadFile(u8 *buffer, u32 selection) int FAT_Open(int type) { int max = 0; - char root[10] = ""; -#ifdef HW_RVL - /* FAT header */ - if (type == TYPE_SD) sprintf (root, "sd:"); - else if (type == TYPE_USB) sprintf (root, "usb:"); -#endif - - /* if FAT device type changed, reload filelist */ - if (fat_type != type) + if (type == TYPE_RECENT) { - fat_type = type; - haveFATdir = 0; - } - - /* update filelist */ - if (haveFATdir == 0) - { - useHistory = 0; - if (type == TYPE_RECENT) + /* fetch history list */ + int i; + for(i=0; i < NUM_HISTORY_ENTRIES; i++) { - /* fetch history list */ - useHistory = 1; - int i; - for(i=0; i < NUM_HISTORY_ENTRIES; i++) + if(history.entries[i].filepath[0] > 0) { - if(history.entries[i].filepath[0] > 0) - { - filelist[i].offset = 0; - filelist[i].length = 0; - filelist[i].flags = 0; - strncpy(filelist[i].filename, history.entries[i].filename, MAXJOLIET-1); - filelist[i].filename[MAXJOLIET-1] = '\0'; - max++; - } - else - { - /* Found the end of the list. */ - break; - } + filelist[i].offset = 0; + filelist[i].length = 0; + filelist[i].flags = 0; + strncpy(filelist[i].filename, history.entries[i].filename, MAXJOLIET-1); + filelist[i].filename[MAXJOLIET-1] = '\0'; + max++; + } + else + { + /* Found the end of the list. */ + break; } } + } + else + { + /* default directory */ + fatdir = config.sddir; +#ifdef HW_RVL + if (type == TYPE_USB) + fatdir = config.usbdir; +#endif + + /* verify current dir exists, otherwise browse from root */ + DIR_ITER *dir = diropen(fatdir); + if (dir) + dirclose(dir); +#ifdef HW_RVL + else if (type == TYPE_USB) + sprintf (fatdir, "usb:/"); +#endif else - { - /* reset root directory */ - sprintf (fatdir, "%s%s/roms/", root, DEFAULT_PATH); + sprintf (fatdir, "sd:/"); - /* if directory doesn't exist, use root as default */ - DIR_ITER *dir = diropen(fatdir); - if (dir == NULL) sprintf (fatdir, "%s/", root); - else dirclose(dir); + /* parse current directory */ + max = FAT_ParseDirectory (); + } - /* parse root directory */ - max = FAT_ParseDirectory (); - } + if (max < 0) + return 0; - if (max > 0) - { - /* FAT is default */ - haveFATdir = 1; - DVD_ClearDirectory(); + if (max == 0) + { + GUI_WaitPrompt("Error","No files found !"); + return 0; + } - /* reset File selector */ - ClearSelector(max); - return 1; - } - else - { - /* no entries found */ - if (max == 0) GUI_WaitPrompt("Error","No files found !"); - return 0; - } + /* check if access type has changed */ + if (type != fatType) + { + /* set current access type */ + fatType = type; + + /* reset File selector */ + ClearSelector(max); + + /* clear DVD access flag */ + DVD_ClearDirectory(); } return 1; diff --git a/source/gx/fileio/file_fat.h b/source/gx/fileio/file_fat.h index a9cc4b2..90573f0 100644 --- a/source/gx/fileio/file_fat.h +++ b/source/gx/fileio/file_fat.h @@ -26,7 +26,6 @@ #define TYPE_RECENT 0 #define TYPE_SD 1 - #ifdef HW_RVL #define TYPE_USB 2 #endif diff --git a/source/gx/fileio/history.c b/source/gx/fileio/history.c index 50423c9..f97143a 100644 --- a/source/gx/fileio/history.c +++ b/source/gx/fileio/history.c @@ -105,9 +105,7 @@ void history_default(void) { int i; for(i=0; i < NUM_HISTORY_ENTRIES; i++) - { memset(&history.entries[i], 0, sizeof(t_history_entry)); - } /* restore history */ history_load(); diff --git a/source/gx/fileio/unzip.c b/source/gx/fileio/unzip.c index 27b3e2a..c3320c5 100644 --- a/source/gx/fileio/unzip.c +++ b/source/gx/fileio/unzip.c @@ -115,7 +115,8 @@ int UnZipBuffer (unsigned char *outbuffer, u64 discoffset, char *filename) if (filename) { fatfile = fopen(filename, "rb"); - if (fatfile == NULL) return 0; + if (fatfile == NULL) + return 0; } /*** Read Zip Header ***/ @@ -203,12 +204,15 @@ int UnZipBuffer (unsigned char *outbuffer, u64 discoffset, char *filename) inflateEnd (&zs); /* close file */ - if (fatfile) fclose(fatfile); + if (fatfile) + fclose(fatfile); if (res == Z_STREAM_END) { - if (FLIP32 (pkzip.uncompressedSize) == (u32) bufferoffset) return bufferoffset; - else return FLIP32 (pkzip.uncompressedSize); + if (FLIP32 (pkzip.uncompressedSize) == (u32) bufferoffset) + return bufferoffset; + else + return FLIP32 (pkzip.uncompressedSize); } return 0; } diff --git a/source/gx/gui/filesel.c b/source/gx/gui/filesel.c index c3191d6..9c1701e 100644 --- a/source/gx/gui/filesel.c +++ b/source/gx/gui/filesel.c @@ -540,35 +540,28 @@ int FileSelector(unsigned char *buffer, bool useFAT) } else { - /* user confirmation */ - if (GUI_ConfirmPrompt("Load selected File ?")) + /* Load ROM file from device */ + if (useFAT) + size = FAT_LoadFile(buffer,selection); + else + size = DVD_LoadFile(buffer,selection); + + /* Reload emulation */ + if (size) { - /* Load ROM file from device */ - if (useFAT) - size = FAT_LoadFile(buffer,selection); - else - size = DVD_LoadFile(buffer,selection); - - /* Reload emulation */ - if (size) - { - if (config.s_auto & 2) - slot_autosave(config.s_default,config.s_device); - reloadrom(size,filelist[selection].filename); - if (config.s_auto & 1) - slot_autoload(0,config.s_device); - if (config.s_auto & 2) - slot_autoload(config.s_default,config.s_device); - } - - /* Exit */ - GUI_MsgBoxClose(); - GUI_DeleteMenu(m); - return size; + if (config.s_auto & 2) + slot_autosave(config.s_default,config.s_device); + reloadrom(size,filelist[selection].filename); + if (config.s_auto & 1) + slot_autoload(0,config.s_device); + if (config.s_auto & 2) + slot_autoload(config.s_default,config.s_device); } - /* user canceled */ + /* Exit */ GUI_MsgBoxClose(); + GUI_DeleteMenu(m); + return size; } } } diff --git a/source/gx/gui/gui.c b/source/gx/gui/gui.c index 48d6c36..28374de 100644 --- a/source/gx/gui/gui.c +++ b/source/gx/gui/gui.c @@ -2027,37 +2027,6 @@ void GUI_WaitPrompt(char *title, char *msg) GUI_MsgBoxClose(); } -int GUI_ConfirmPrompt(char *msg) -{ - if (config.ask_confirm) - { - /* update message box */ - GUI_MsgBoxOpen("User Confirmation", msg, 0); - - /* allocate textures */ - message_box.buttonA = gxTextureOpenPNG(Key_A_png,0); - message_box.buttonB = gxTextureOpenPNG(Key_B_png,0); - - /* wait for button A or button B*/ - s16 p = 0; - while (m_input.keys) - VIDEO_WaitVSync(); - while (!(p & (PAD_BUTTON_A | PAD_BUTTON_B))) - { - VIDEO_WaitVSync(); - p = m_input.keys; - } - - /* return user choice */ - if (p & PAD_BUTTON_A) - return 1; - else - return 0; - } - - return 1; -} - /* Basic Fading */ void GUI_FadeOut() { diff --git a/source/gx/gui/gui.h b/source/gx/gui/gui.h index aa9186f..0ea5a5d 100644 --- a/source/gx/gui/gui.h +++ b/source/gx/gui/gui.h @@ -228,7 +228,6 @@ extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber); extern void GUI_MsgBoxUpdate(char *title, char *msg); extern void GUI_MsgBoxClose(void); extern void GUI_WaitPrompt(char *title, char *msg); -extern int GUI_ConfirmPrompt(char *msg); extern void GUI_FadeOut(); extern GXColor *GUI_GetBgColor(void); extern void GUI_SetBgColor(u8 color); diff --git a/source/gx/gui/menu.c b/source/gx/gui/menu.c index 2b47ed3..be6b259 100644 --- a/source/gx/gui/menu.c +++ b/source/gx/gui/menu.c @@ -284,14 +284,14 @@ static gui_item items_video[8] = /* Menu options */ static gui_item items_prefs[8] = { - {NULL,NULL,"Auto SRAM: OFF", "Enable/disable automatic SRAM", 52,132,276,48}, - {NULL,NULL,"Auto STATE: OFF", "Enable/disable automatic Savestate", 52,132,276,48}, - {NULL,NULL,"SFX Volume: 100", "Adjust sound effects volume", 52,132,276,48}, - {NULL,NULL,"BGM Volume: 100", "Adjust background music volume", 52,132,276,48}, - {NULL,NULL,"BG Color: DEFAULT", "Change background color", 52,132,276,48}, - {NULL,NULL,"BG Overlay: ON", "Enable/disable background overlay", 52,132,276,48}, - {NULL,NULL,"Screen Width: 658", "Adjust Screen Width", 52,132,276,48}, - {NULL,NULL,"Confirm Box: OFF", "Enable/disable user confirmation", 52,132,276,48} + {NULL,NULL,"Load ROM Auto: OFF","Enable/Disable automatic ROM loading on startup", 52,132,276,48}, + {NULL,NULL,"Auto Saves: OFF", "Enable/Disable automatic saves", 52,132,276,48}, + {NULL,NULL,"Saves Device: FAT", "Configure default device for saves", 52,132,276,48}, + {NULL,NULL,"SFX Volume: 100", "Adjust sound effects volume", 52,132,276,48}, + {NULL,NULL,"BGM Volume: 100", "Adjust background music volume", 52,132,276,48}, + {NULL,NULL,"BG Color: DEFAULT", "Select background color", 52,132,276,48}, + {NULL,NULL,"BG Overlay: ON", "Enable/disable background overlay", 52,132,276,48}, + {NULL,NULL,"Screen Width: 658", "Adjust menu screen width in pixels", 52,132,276,48}, }; /* Save Manager */ @@ -552,29 +552,29 @@ static void prefmenu () gui_menu *m = &menu_prefs; gui_item *items = m->items; + sprintf (items[0].text, "Load ROM Auto: %s", config.autoload ? "ON":"OFF"); if (config.s_auto == 3) - sprintf (items[0].text, "Auto Saves: ALL"); + sprintf (items[1].text, "Auto Saves: ALL"); else if (config.s_auto == 2) - sprintf (items[0].text, "Auto Saves: STATE ONLY"); + sprintf (items[1].text, "Auto Saves: STATE ONLY"); else if (config.s_auto == 1) - sprintf (items[0].text, "Auto Saves: SRAM ONLY"); + sprintf (items[1].text, "Auto Saves: SRAM ONLY"); else - sprintf (items[0].text, "Auto Saves: NONE"); + sprintf (items[1].text, "Auto Saves: NONE"); if (config.s_device == 1) - sprintf (items[1].text, "Saves Device: MCARD A"); + sprintf (items[2].text, "Saves Device: MCARD A"); else if (config.s_device == 2) - sprintf (items[1].text, "Saves Device: MCARD B"); + sprintf (items[2].text, "Saves Device: MCARD B"); else - sprintf (items[1].text, "Saves Device: FAT"); - sprintf (items[2].text, "SFX Volume: %1.1f", config.sfx_volume); - sprintf (items[3].text, "BGM Volume: %1.1f", config.bgm_volume); + sprintf (items[2].text, "Saves Device: FAT"); + sprintf (items[3].text, "SFX Volume: %1.1f", config.sfx_volume); + sprintf (items[4].text, "BGM Volume: %1.1f", config.bgm_volume); if (config.bg_color) - sprintf (items[4].text, "BG Color: TYPE %d", config.bg_color); + sprintf (items[5].text, "BG Color: TYPE %d", config.bg_color); else - sprintf (items[4].text, "BG Color: DEFAULT"); - sprintf (items[5].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); - sprintf (items[6].text, "Screen Width: %d", config.screen_w); - sprintf (items[7].text, "Confirmation Box: %s",config.ask_confirm ? "ON":"OFF"); + sprintf (items[5].text, "BG Color: DEFAULT"); + sprintf (items[6].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); + sprintf (items[7].text, "Screen Width: %d", config.screen_w); GUI_InitMenu(m); GUI_SlideMenuTitle(m,strlen("Menu ")); @@ -585,45 +585,56 @@ static void prefmenu () switch (ret) { - case 0: /*** Auto load/save ***/ + case 0: /* Auto load last ROM file */ + config.autoload ^= 1; + sprintf (items[ret].text, "Load ROM Auto: %s", config.autoload ? "ON":"OFF"); + break; + + case 1: /*** Auto load/save STATE & SRAM files ***/ config.s_auto = (config.s_auto + 1) % 4; if (config.s_auto == 3) - sprintf (items[0].text, "Auto Saves: ALL"); + sprintf (items[ret].text, "Auto Saves: ALL"); else if (config.s_auto == 2) - sprintf (items[0].text, "Auto Saves: STATE ONLY"); + sprintf (items[ret].text, "Auto Saves: STATE ONLY"); else if (config.s_auto == 1) - sprintf (items[0].text, "Auto Saves: SRAM ONLY"); + sprintf (items[ret].text, "Auto Saves: SRAM ONLY"); else - sprintf (items[0].text, "Auto Saves: NONE"); + sprintf (items[ret].text, "Auto Saves: NONE"); break; - case 1: /*** Default saves device ***/ + case 2: /*** Default saves device ***/ config.s_device = (config.s_device + 1) % 3; if (config.s_device == 1) - sprintf (items[1].text, "Saves Device: MCARD A"); + sprintf (items[ret].text, "Saves Device: MCARD A"); else if (config.s_device == 2) - sprintf (items[1].text, "Saves Device: MCARD B"); + sprintf (items[ret].text, "Saves Device: MCARD B"); else - sprintf (items[1].text, "Saves Device: FAT"); + sprintf (items[ret].text, "Saves Device: FAT"); break; - case 2: /*** Sound effects volume ***/ + case 3: /*** Sound effects volume ***/ GUI_OptionBox(m,0,"SFX Volume",(void *)&config.sfx_volume,10.0,0.0,100.0,0); - sprintf (items[2].text, "SFX Volume: %1.1f", config.sfx_volume); + sprintf (items[ret].text, "SFX Volume: %1.1f", config.sfx_volume); break; - case 3: /*** Background music volume ***/ + case 4: /*** Background music volume ***/ GUI_OptionBox(m,update_bgm,"BGM Volume",(void *)&config.bgm_volume,10.0,0.0,100.0,0); - sprintf (items[3].text, "BGM Volume: %1.1f", config.bgm_volume); + sprintf (items[ret].text, "BGM Volume: %1.1f", config.bgm_volume); break; - case 4: /*** Background color ***/ - if (ret < 0) config.bg_color --; - else config.bg_color ++; - if (config.bg_color < 0) config.bg_color = BG_COLOR_MAX - 1; - else if (config.bg_color >= BG_COLOR_MAX) config.bg_color = 0; - if (config.bg_color) sprintf (items[4].text, "BG Color: TYPE %d", config.bg_color); - else sprintf (items[4].text, "BG Color: DEFAULT"); + case 5: /*** Background color ***/ + if (ret < 0) + config.bg_color --; + else + config.bg_color ++; + if (config.bg_color < 0) + config.bg_color = BG_COLOR_MAX - 1; + else if (config.bg_color >= BG_COLOR_MAX) + config.bg_color = 0; + if (config.bg_color) + sprintf (items[ret].text, "BG Color: TYPE %d", config.bg_color); + else + sprintf (items[ret].text, "BG Color: DEFAULT"); GUI_SetBgColor((u8)config.bg_color); GUI_DeleteMenu(m); if (config.bg_color == 0) @@ -645,9 +656,8 @@ static void prefmenu () GUI_InitMenu(m); break; - case 5: /*** Background items ***/ + case 6: /*** Background items ***/ config.bg_overlay ^= 1; - sprintf (items[5].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); if (config.bg_overlay) { bg_main[1].state |= IMAGE_VISIBLE; @@ -664,16 +674,12 @@ static void prefmenu () bg_list[1].state &= ~IMAGE_VISIBLE; bg_saves[2].state &= ~IMAGE_VISIBLE; } + sprintf (items[ret].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); break; - case 6: /*** Screen Width ***/ + case 7: /*** Screen Width ***/ GUI_OptionBox(m,update_screen_w,"Screen Width",(void *)&config.screen_w,2,640,VI_MAX_WIDTH_NTSC,1); - sprintf (items[6].text, "Screen Width: %d", config.screen_w); - break; - - case 7: /*** User COnfirmation ***/ - config.ask_confirm ^= 1; - sprintf (items[7].text, "Confirmation Box: %s",config.ask_confirm ? "ON":"OFF"); + sprintf (items[ret].text, "Screen Width: %d", config.screen_w); break; case -1: @@ -2229,7 +2235,6 @@ static void optionmenu(void) GUI_DrawMenuFX(m,30,1); GUI_DeleteMenu(m); - config_save(); } /**************************************************************************** @@ -2393,7 +2398,6 @@ static int savemenu(void) case 6: /* set default slot */ { config.s_default = slot; - config_save(); break; } @@ -2952,7 +2956,8 @@ void MainMenu (void) /*** ROM information screen (TODO !!!) ***/ case 8: - if (!cart.romsize) break; + if (!cart.romsize) + break; GUI_DrawMenuFX(m,30,1); GUI_DeleteMenu(m); showrominfo(); diff --git a/source/gx/gx_input.c b/source/gx/gx_input.c index 16ee272..2b8f764 100644 --- a/source/gx/gx_input.c +++ b/source/gx/gx_input.c @@ -36,9 +36,6 @@ /* lower is the value, faster is the key update */ #define HELD_SPEED 4 -/* Menu request flag */ -u32 ConfigRequested = 0; - /* Configurable Genesis keys */ #define KEY_BUTTONA 0 #define KEY_BUTTONB 1 diff --git a/source/gx/gx_input.h b/source/gx/gx_input.h index 9dd5db9..8528305 100644 --- a/source/gx/gx_input.h +++ b/source/gx/gx_input.h @@ -49,6 +49,4 @@ extern void gx_input_Config(u8 num, u8 type, u8 max_keys); extern void gx_input_UpdateEmu(void); extern void gx_input_UpdateMenu(u32 cnt); -extern u32 ConfigRequested; - #endif diff --git a/source/gx/main.c b/source/gx/main.c index bf72dfd..d28f487 100644 --- a/source/gx/main.c +++ b/source/gx/main.c @@ -25,10 +25,12 @@ #include "shared.h" #include "font.h" #include "gui.h" -#include "history.h" #include "aram.h" #include "dvd.h" +#include "history.h" #include "file_slot.h" +#include "file_fat.h" +#include "filesel.h" #ifdef HW_RVL #include "usb2storage.h" @@ -42,6 +44,7 @@ #endif u32 Shutdown = 0; +u32 ConfigRequested = 1; #ifdef HW_RVL /**************************************************************************** @@ -196,6 +199,7 @@ void reloadrom (int size, char *name) void shutdown(void) { /* system shutdown */ + config_save(); if (config.s_auto & 2) slot_autosave(config.s_default,config.s_device); system_shutdown(); @@ -249,26 +253,30 @@ int main (int argc, char *argv[]) /* initialize FAT devices */ if (fatInitDefault()) { - DIR_ITER *dir = NULL; - /* base directory */ char pathname[MAXPATHLEN]; sprintf (pathname, DEFAULT_PATH); - dir = diropen(pathname); - if (dir == NULL) mkdir(pathname,S_IRWXU); - else dirclose(dir); + DIR_ITER *dir = diropen(pathname); + if (dir) + dirclose(dir); + else + mkdir(pathname,S_IRWXU); /* default SRAM & Savestate files directory */ sprintf (pathname, "%s/saves",DEFAULT_PATH); dir = diropen(pathname); - if (dir == NULL) mkdir(pathname,S_IRWXU); - else dirclose(dir); + if (dir) + dirclose(dir); + else + mkdir(pathname,S_IRWXU); /* default Snapshot files directory */ sprintf (pathname, "%s/snaps",DEFAULT_PATH); dir = diropen(pathname); - if (dir == NULL) mkdir(pathname,S_IRWXU); - else dirclose(dir); + if (dir) + dirclose(dir); + else + mkdir(pathname,S_IRWXU); } /* initialize input engine */ @@ -286,16 +294,35 @@ int main (int argc, char *argv[]) /* run any injected rom */ if (cart.romsize) { - ARAMFetch((char *)cart.rom, (void *)0x8000, cart.romsize); - reloadrom (cart.romsize,"INJECT.bin"); + int size = cart.romsize; + cart.romsize = 0; + ARAMFetch((char *)cart.rom, (void *)0x8000, size); + reloadrom(size,"INJECT.bin"); + ConfigRequested = 0; gx_video_Start(); gx_audio_Start(); frameticker = 1; } - else + else if (config.autoload) { - /* Main Menu */ - ConfigRequested = 1; + SILENT = 1; + if (FAT_Open(TYPE_RECENT)) + { + int size = FAT_LoadFile(cart.rom,0); + if (size) + { + reloadrom(size,filelist[0].filename); + if (config.s_auto & 1) + slot_autoload(0,config.s_device); + if (config.s_auto & 2) + slot_autoload(config.s_default,config.s_device); + gx_video_Start(); + gx_audio_Start(); + frameticker = 1; + ConfigRequested = 0; + } + } + SILENT = 0; } /* initialize GUI engine */ diff --git a/source/gx/osd.h b/source/gx/osd.h index 8da711a..d9dd258 100644 --- a/source/gx/osd.h +++ b/source/gx/osd.h @@ -33,9 +33,9 @@ #define SK_UPMEM "/genplus/sk2chip.bin" #ifdef HW_RVL -#define VERSION "version 1.4.0W" +#define VERSION "version 1.3.xW" #else -#define VERSION "version 1.4.0G" +#define VERSION "version 1.3.xG" #endif #define osd_input_Update() gx_input_UpdateEmu() @@ -50,5 +50,6 @@ extern void reloadrom (int size, char *name); extern void shutdown(); extern u32 frameticker; extern u32 Shutdown; +extern u32 ConfigRequested; #endif /* _OSD_H_ */