mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2025-01-28 10:55:28 +01:00
+added optional Confirmation Prompt
+improved File Selection code (removed global variables, sound effect)
This commit is contained in:
parent
8aa21d446d
commit
28230082ed
@ -107,6 +107,7 @@ void config_default(void)
|
|||||||
config.bgm_volume = 100.0;
|
config.bgm_volume = 100.0;
|
||||||
config.sfx_volume = 100.0;
|
config.sfx_volume = 100.0;
|
||||||
config.screen_w = 658;
|
config.screen_w = 658;
|
||||||
|
config.askConfirm = 0;
|
||||||
|
|
||||||
/* restore saved configuration */
|
/* restore saved configuration */
|
||||||
config_load();
|
config_load();
|
||||||
|
@ -60,6 +60,7 @@ typedef struct
|
|||||||
int8 sram_auto;
|
int8 sram_auto;
|
||||||
int8 state_auto;
|
int8 state_auto;
|
||||||
int16 screen_w;
|
int16 screen_w;
|
||||||
|
uint8 askConfirm;
|
||||||
} t_config;
|
} t_config;
|
||||||
|
|
||||||
/* Global data */
|
/* Global data */
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "filesel.h"
|
#include "filesel.h"
|
||||||
|
#include "file_fat.h"
|
||||||
|
#include "file_dvd.h"
|
||||||
|
|
||||||
/** Minimal ISO Directory Definition **/
|
/** Minimal ISO Directory Definition **/
|
||||||
#define RECLEN 0 /* Record length */
|
#define RECLEN 0 /* Record length */
|
||||||
@ -39,6 +41,8 @@
|
|||||||
/** Minimal Primary Volume Descriptor **/
|
/** Minimal Primary Volume Descriptor **/
|
||||||
#define PVDROOT 0x9c
|
#define PVDROOT 0x9c
|
||||||
|
|
||||||
|
bool haveDVDdir = 0;
|
||||||
|
|
||||||
/** Static Variables **/
|
/** Static Variables **/
|
||||||
static u64 rootdir = 0; /* current root directory offset */
|
static u64 rootdir = 0; /* current root directory offset */
|
||||||
static u64 basedir = 0; /* base directory offset */
|
static u64 basedir = 0; /* base directory offset */
|
||||||
@ -185,7 +189,6 @@ static int getentry(int entrycount)
|
|||||||
|
|
||||||
filelist[entrycount].offset <<= 11;
|
filelist[entrycount].offset <<= 11;
|
||||||
filelist[entrycount].flags = filelist[entrycount].flags & 2;
|
filelist[entrycount].flags = filelist[entrycount].flags & 2;
|
||||||
filelist[entrycount].filename_offset = 0;
|
|
||||||
|
|
||||||
/*** Prepare for next entry ***/
|
/*** Prepare for next entry ***/
|
||||||
diroffset += dvdbuffer[diroffset];
|
diroffset += dvdbuffer[diroffset];
|
||||||
@ -201,31 +204,14 @@ static int getentry(int entrycount)
|
|||||||
*
|
*
|
||||||
* Update DVD current root directory
|
* Update DVD current root directory
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int DVD_UpdateDir(bool go_up)
|
int DVD_UpdateDir(bool go_up, u64 offset, u32 length)
|
||||||
{
|
{
|
||||||
/* root has no parent directory */
|
/* root has no parent directory */
|
||||||
if (go_up && (basedir == rootdir)) return 0;
|
if (go_up && (basedir == rootdir)) return 0;
|
||||||
|
|
||||||
/* by default, update current directory */
|
/* simply update current root directory */
|
||||||
rootdir = filelist[selection].offset;
|
rootdir = offset;
|
||||||
rootdirlength = filelist[selection].length;
|
rootdirlength = length;
|
||||||
|
|
||||||
/* reinit selector (previous value is saved for one level) */
|
|
||||||
if (selection == 0)
|
|
||||||
{
|
|
||||||
selection = old_selection;
|
|
||||||
offset = old_offset;
|
|
||||||
old_selection = 0;
|
|
||||||
old_offset = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* save current selector value */
|
|
||||||
old_selection = selection;
|
|
||||||
old_offset = offset;
|
|
||||||
selection = 0;
|
|
||||||
offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -285,7 +271,7 @@ int DVD_ParseDirectory(void)
|
|||||||
* This functions return the actual size of data copied into the buffer
|
* This functions return the actual size of data copied into the buffer
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int DVD_LoadFile(u8 *buffer)
|
int DVD_LoadFile(u8 *buffer, u32 selection)
|
||||||
{
|
{
|
||||||
/* file size */
|
/* file size */
|
||||||
int length = filelist[selection].length;
|
int length = filelist[selection].length;
|
||||||
@ -344,9 +330,6 @@ int DVD_LoadFile(u8 *buffer)
|
|||||||
|
|
||||||
int DVD_Open(void)
|
int DVD_Open(void)
|
||||||
{
|
{
|
||||||
/* reset flags */
|
|
||||||
useFAT = 0;
|
|
||||||
|
|
||||||
/* is DVD mounted ? */
|
/* is DVD mounted ? */
|
||||||
if (!getpvd())
|
if (!getpvd())
|
||||||
{
|
{
|
||||||
@ -400,11 +383,7 @@ int DVD_Open(void)
|
|||||||
haveFATdir = 0;
|
haveFATdir = 0;
|
||||||
|
|
||||||
/* reset File selector */
|
/* reset File selector */
|
||||||
maxfiles = max;
|
FileSelClear(max);
|
||||||
offset = 0;
|
|
||||||
selection = 0;
|
|
||||||
old_offset = 0;
|
|
||||||
old_selection = 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -25,9 +25,10 @@
|
|||||||
#ifndef _FILE_DVD_H
|
#ifndef _FILE_DVD_H
|
||||||
#define _FILE_DVD_H
|
#define _FILE_DVD_H
|
||||||
|
|
||||||
extern int DVD_UpdateDir(bool go_up);
|
extern int DVD_UpdateDir(bool go_up,u64 offset, u32 length);
|
||||||
extern int DVD_ParseDirectory(void);
|
extern int DVD_ParseDirectory(void);
|
||||||
extern int DVD_LoadFile(u8 *buffer);
|
extern int DVD_LoadFile(u8 *buffer,u32 selection);
|
||||||
extern int DVD_Open(void);
|
extern int DVD_Open(void);
|
||||||
|
extern bool haveDVDdir;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "filesel.h"
|
#include "filesel.h"
|
||||||
#include "file_fat.h"
|
#include "file_fat.h"
|
||||||
|
#include "file_dvd.h"
|
||||||
|
|
||||||
|
bool haveFATdir = 0;
|
||||||
|
|
||||||
/* current FAT directory */
|
/* current FAT directory */
|
||||||
static char fatdir[MAXPATHLEN];
|
static char fatdir[MAXPATHLEN];
|
||||||
@ -40,17 +43,14 @@ static int useHistory = 0;
|
|||||||
*
|
*
|
||||||
* Update FAT current root directory
|
* Update FAT current root directory
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int FAT_UpdateDir(bool go_up)
|
int FAT_UpdateDir(bool go_up, char *filename)
|
||||||
{
|
{
|
||||||
int size=0;
|
int size=0;
|
||||||
char *test;
|
char *test;
|
||||||
char temp[1024];
|
char temp[1024];
|
||||||
|
|
||||||
/* current directory doesn't change */
|
|
||||||
if (strcmp(filelist[selection].filename,".") == 0) return 1;
|
|
||||||
|
|
||||||
/* go up to parent directory */
|
/* go up to parent directory */
|
||||||
if (strcmp(filelist[selection].filename,"..") == 0)
|
if (strcmp(filename,"..") == 0)
|
||||||
{
|
{
|
||||||
/* determine last subdirectory namelength */
|
/* determine last subdirectory namelength */
|
||||||
sprintf(temp,"%s",fatdir);
|
sprintf(temp,"%s",fatdir);
|
||||||
@ -64,14 +64,6 @@ int FAT_UpdateDir(bool go_up)
|
|||||||
/* remove last subdirectory name */
|
/* remove last subdirectory name */
|
||||||
size = strlen(fatdir) - size;
|
size = strlen(fatdir) - size;
|
||||||
fatdir[size-1] = 0;
|
fatdir[size-1] = 0;
|
||||||
|
|
||||||
/* restore previous selector state */
|
|
||||||
selection = old_selection;
|
|
||||||
offset = old_offset;
|
|
||||||
|
|
||||||
/* reset old selection */
|
|
||||||
old_selection = 0;
|
|
||||||
old_offset = 0;
|
|
||||||
}
|
}
|
||||||
else if (go_up)
|
else if (go_up)
|
||||||
{
|
{
|
||||||
@ -81,15 +73,7 @@ int FAT_UpdateDir(bool go_up)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* by default, simply append folder name */
|
/* by default, simply append folder name */
|
||||||
sprintf(fatdir, "%s%s/",fatdir, filelist[selection].filename);
|
sprintf(fatdir, "%s%s/",fatdir, filename);
|
||||||
|
|
||||||
/* save current selector state */
|
|
||||||
old_selection = selection;
|
|
||||||
old_offset = offset;
|
|
||||||
|
|
||||||
/* reset selection */
|
|
||||||
selection = 0;
|
|
||||||
offset = 0;
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -140,7 +124,7 @@ int FAT_ParseDirectory(void)
|
|||||||
* This functions return the actual size of data copied into the buffer
|
* This functions return the actual size of data copied into the buffer
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int FAT_LoadFile(u8 *buffer)
|
int FAT_LoadFile(u8 *buffer, u32 selection)
|
||||||
{
|
{
|
||||||
/* If loading from history then we need to setup a few more things. */
|
/* If loading from history then we need to setup a few more things. */
|
||||||
if(useHistory)
|
if(useHistory)
|
||||||
@ -222,9 +206,6 @@ int FAT_Open(int type)
|
|||||||
int max = 0;
|
int max = 0;
|
||||||
char root[10] = "";
|
char root[10] = "";
|
||||||
|
|
||||||
/* reset flags */
|
|
||||||
useFAT = 1;
|
|
||||||
|
|
||||||
/* FAT header */
|
/* FAT header */
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
if (type == TYPE_SD) sprintf (root, "sd:");
|
if (type == TYPE_SD) sprintf (root, "sd:");
|
||||||
@ -254,7 +235,6 @@ int FAT_Open(int type)
|
|||||||
filelist[i].offset = 0;
|
filelist[i].offset = 0;
|
||||||
filelist[i].length = 0;
|
filelist[i].length = 0;
|
||||||
filelist[i].flags = 0;
|
filelist[i].flags = 0;
|
||||||
filelist[i].filename_offset = 0;
|
|
||||||
strncpy(filelist[i].filename, history.entries[i].filename, MAXJOLIET-1);
|
strncpy(filelist[i].filename, history.entries[i].filename, MAXJOLIET-1);
|
||||||
filelist[i].filename[MAXJOLIET-1] = '\0';
|
filelist[i].filename[MAXJOLIET-1] = '\0';
|
||||||
max++;
|
max++;
|
||||||
@ -286,12 +266,8 @@ int FAT_Open(int type)
|
|||||||
haveFATdir = 1;
|
haveFATdir = 1;
|
||||||
haveDVDdir = 0;
|
haveDVDdir = 0;
|
||||||
|
|
||||||
/* reset file selection */
|
/* reset File selector */
|
||||||
maxfiles = max;
|
FileSelClear(max);
|
||||||
offset = 0;
|
|
||||||
selection = 0;
|
|
||||||
old_offset = 0;
|
|
||||||
old_selection = 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -31,9 +31,10 @@
|
|||||||
#define TYPE_USB 2
|
#define TYPE_USB 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int FAT_UpdateDir(bool go_up);
|
extern int FAT_UpdateDir(bool go_up, char *filename);
|
||||||
extern int FAT_ParseDirectory(void);
|
extern int FAT_ParseDirectory(void);
|
||||||
extern int FAT_LoadFile(u8* buffer);
|
extern int FAT_LoadFile(u8* buffer,u32 selection);
|
||||||
extern int FAT_Open(int type);
|
extern int FAT_Open(int type);
|
||||||
|
extern bool haveFATdir;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,18 +36,14 @@
|
|||||||
#define PAGESIZE 11
|
#define PAGESIZE 11
|
||||||
#define PAGEOFFSET 120
|
#define PAGEOFFSET 120
|
||||||
|
|
||||||
/* Global Variables */
|
|
||||||
int maxfiles = 0;
|
|
||||||
int offset = 0;
|
|
||||||
int selection = 0;
|
|
||||||
int old_selection = 0;
|
|
||||||
int old_offset = 0;
|
|
||||||
int useFAT = 0;
|
|
||||||
int haveDVDdir = 0;
|
|
||||||
int haveFATdir = 0;
|
|
||||||
|
|
||||||
FILEENTRIES filelist[MAXFILES];
|
FILEENTRIES filelist[MAXFILES];
|
||||||
|
|
||||||
|
static int offset = 0;
|
||||||
|
static int selection = 0;
|
||||||
|
static int old_selection = 0;
|
||||||
|
static int old_offset = 0;
|
||||||
|
static int maxfiles = 0;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* GUI Buttons data */
|
/* GUI Buttons data */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -151,11 +147,13 @@ int FileSortCallback(const void *f1, const void *f2)
|
|||||||
* ROM size is returned
|
* ROM size is returned
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int FileSelector(unsigned char *buffer)
|
int FileSelector(unsigned char *buffer, bool useFAT)
|
||||||
{
|
{
|
||||||
short p;
|
short p;
|
||||||
int ret,i,yoffset,string_offset;
|
int ret,i,yoffset;
|
||||||
int size,go_up = 0;
|
int size = 0;
|
||||||
|
int go_up = 0;
|
||||||
|
int string_offset = 0;
|
||||||
int old = -1;
|
int old = -1;
|
||||||
char text[MAXPATHLEN];
|
char text[MAXPATHLEN];
|
||||||
char fname[MAXPATHLEN];
|
char fname[MAXPATHLEN];
|
||||||
@ -192,6 +190,11 @@ int FileSelector(unsigned char *buffer)
|
|||||||
if (old != selection)
|
if (old != selection)
|
||||||
{
|
{
|
||||||
old = selection;
|
old = selection;
|
||||||
|
string_offset = 0;
|
||||||
|
|
||||||
|
/* play sound effect */
|
||||||
|
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
|
||||||
|
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||||
|
|
||||||
/* delete previous texture if any */
|
/* delete previous texture if any */
|
||||||
gxTextureClose(&bg_filesel[8].texture);
|
gxTextureClose(&bg_filesel[8].texture);
|
||||||
@ -200,8 +203,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
|
|
||||||
if (!filelist[selection].flags)
|
if (!filelist[selection].flags)
|
||||||
{
|
{
|
||||||
strcpy(action_select.comment,"Load ROM File");
|
|
||||||
|
|
||||||
/* get ROM filename without extension */
|
/* get ROM filename without extension */
|
||||||
sprintf (text, "%s", filelist[selection].filename);
|
sprintf (text, "%s", filelist[selection].filename);
|
||||||
if (strlen(text) >= 4) text[strlen(text) - 4] = 0;
|
if (strlen(text) >= 4) text[strlen(text) - 4] = 0;
|
||||||
@ -225,21 +226,27 @@ int FileSelector(unsigned char *buffer)
|
|||||||
fclose(snap);
|
fclose(snap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update helper */
|
||||||
|
if (m->selected != -1)
|
||||||
|
{
|
||||||
|
/* out of focus */
|
||||||
|
strcpy(action_select.comment,"");
|
||||||
|
}
|
||||||
|
else if (!filelist[selection].flags)
|
||||||
|
{
|
||||||
|
/* this is a file */
|
||||||
|
strcpy(action_select.comment,"Load ROM File");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* update helper */
|
/* this is a directory */
|
||||||
if (!strcmp(filelist[selection].filename,".."))
|
if (!strcmp(filelist[selection].filename,".."))
|
||||||
strcpy(action_select.comment,"Previous Directory");
|
strcpy(action_select.comment,"Previous Directory");
|
||||||
else
|
else
|
||||||
strcpy(action_select.comment,"Open Directory");
|
strcpy(action_select.comment,"Open Directory");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
|
||||||
/* pointer is out of focus */
|
|
||||||
if (m->selected != -1)
|
|
||||||
strcpy(action_select.comment,"");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Draw menu*/
|
/* Draw menu*/
|
||||||
GUI_DrawMenu(m);
|
GUI_DrawMenu(m);
|
||||||
@ -251,14 +258,9 @@ int FileSelector(unsigned char *buffer)
|
|||||||
if (i == selection)
|
if (i == selection)
|
||||||
{
|
{
|
||||||
/* scrolling text */
|
/* scrolling text */
|
||||||
string_offset = filelist[i].filename_offset/10;
|
if ((string_offset/10) >= strlen(filelist[i].filename)) string_offset = 0;
|
||||||
if (string_offset >= strlen(filelist[i].filename))
|
sprintf(text, "%s ",filelist[i].filename + string_offset/10);
|
||||||
{
|
strncat(text, filelist[i].filename, string_offset/10);
|
||||||
string_offset = 0;
|
|
||||||
filelist[i].filename_offset = 0;
|
|
||||||
}
|
|
||||||
sprintf(text, "%s ",filelist[i].filename + string_offset);
|
|
||||||
strncat(text, filelist[i].filename, string_offset);
|
|
||||||
|
|
||||||
gxDrawTexture(bar_over.texture,bar_over.x,yoffset+bar_over.y,bar_over.w,bar_over.h,255);
|
gxDrawTexture(bar_over.texture,bar_over.x,yoffset+bar_over.y,bar_over.w,bar_over.h,255);
|
||||||
if (filelist[i].flags)
|
if (filelist[i].flags)
|
||||||
@ -268,7 +270,7 @@ int FileSelector(unsigned char *buffer)
|
|||||||
if (FONT_write(text,18,dir_icon.x+dir_icon.w+6,yoffset+16,bar_over.w-dir_icon.w-14,(GXColor)WHITE))
|
if (FONT_write(text,18,dir_icon.x+dir_icon.w+6,yoffset+16,bar_over.w-dir_icon.w-14,(GXColor)WHITE))
|
||||||
{
|
{
|
||||||
/* text scrolling */
|
/* text scrolling */
|
||||||
filelist[i].filename_offset ++;
|
string_offset ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -276,7 +278,7 @@ int FileSelector(unsigned char *buffer)
|
|||||||
if (FONT_write(text,18,dir_icon.x,yoffset+16,bar_over.w-8,(GXColor)WHITE))
|
if (FONT_write(text,18,dir_icon.x,yoffset+16,bar_over.w-8,(GXColor)WHITE))
|
||||||
{
|
{
|
||||||
/* text scrolling */
|
/* text scrolling */
|
||||||
filelist[i].filename_offset ++;
|
string_offset ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,7 +366,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
/* highlight next item */
|
/* highlight next item */
|
||||||
if (p & PAD_BUTTON_DOWN)
|
if (p & PAD_BUTTON_DOWN)
|
||||||
{
|
{
|
||||||
filelist[selection].filename_offset = 0;
|
|
||||||
selection++;
|
selection++;
|
||||||
if (selection == maxfiles) selection = offset = 0;
|
if (selection == maxfiles) selection = offset = 0;
|
||||||
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
|
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
|
||||||
@ -373,7 +374,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
/* highlight previous item */
|
/* highlight previous item */
|
||||||
else if (p & PAD_BUTTON_UP)
|
else if (p & PAD_BUTTON_UP)
|
||||||
{
|
{
|
||||||
filelist[selection].filename_offset = 0;
|
|
||||||
selection--;
|
selection--;
|
||||||
if (selection < 0)
|
if (selection < 0)
|
||||||
{
|
{
|
||||||
@ -387,7 +387,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
/* go back one page */
|
/* go back one page */
|
||||||
else if (p & PAD_TRIGGER_L)
|
else if (p & PAD_TRIGGER_L)
|
||||||
{
|
{
|
||||||
filelist[selection].filename_offset = 0;
|
|
||||||
selection -= PAGESIZE;
|
selection -= PAGESIZE;
|
||||||
if (selection < 0)
|
if (selection < 0)
|
||||||
{
|
{
|
||||||
@ -401,7 +400,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
/* go forward one page */
|
/* go forward one page */
|
||||||
else if (p & PAD_TRIGGER_R)
|
else if (p & PAD_TRIGGER_R)
|
||||||
{
|
{
|
||||||
filelist[selection].filename_offset = 0;
|
|
||||||
selection += PAGESIZE;
|
selection += PAGESIZE;
|
||||||
if (selection > maxfiles - 1) selection = offset = 0;
|
if (selection > maxfiles - 1) selection = offset = 0;
|
||||||
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
|
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
|
||||||
@ -410,7 +408,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
/* quit */
|
/* quit */
|
||||||
else if (p & PAD_TRIGGER_Z)
|
else if (p & PAD_TRIGGER_Z)
|
||||||
{
|
{
|
||||||
filelist[selection].filename_offset = 0;
|
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
gxTextureClose(&bar_over.texture);
|
gxTextureClose(&bar_over.texture);
|
||||||
gxTextureClose(&dir_icon.texture);
|
gxTextureClose(&dir_icon.texture);
|
||||||
@ -420,7 +417,7 @@ int FileSelector(unsigned char *buffer)
|
|||||||
/* open selected file or directory */
|
/* open selected file or directory */
|
||||||
else if ((p & PAD_BUTTON_A) || (p & PAD_BUTTON_B))
|
else if ((p & PAD_BUTTON_A) || (p & PAD_BUTTON_B))
|
||||||
{
|
{
|
||||||
filelist[selection].filename_offset = 0;
|
string_offset = 0;
|
||||||
go_up = 0;
|
go_up = 0;
|
||||||
|
|
||||||
if (p & PAD_BUTTON_B)
|
if (p & PAD_BUTTON_B)
|
||||||
@ -435,7 +432,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
/* arrow buttons selected */
|
/* arrow buttons selected */
|
||||||
if (m->selected == m->max_buttons) /* up arrow */
|
if (m->selected == m->max_buttons) /* up arrow */
|
||||||
{
|
{
|
||||||
filelist[selection].filename_offset = 0;
|
|
||||||
selection--;
|
selection--;
|
||||||
if (selection < 0)
|
if (selection < 0)
|
||||||
{
|
{
|
||||||
@ -447,7 +443,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
}
|
}
|
||||||
else if (m->selected == (m->max_buttons+1)) /* down arrow */
|
else if (m->selected == (m->max_buttons+1)) /* down arrow */
|
||||||
{
|
{
|
||||||
filelist[selection].filename_offset = 0;
|
|
||||||
selection++;
|
selection++;
|
||||||
if (selection == maxfiles) selection = offset = 0;
|
if (selection == maxfiles) selection = offset = 0;
|
||||||
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
|
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
|
||||||
@ -461,15 +456,40 @@ int FileSelector(unsigned char *buffer)
|
|||||||
/*** This is directory ***/
|
/*** This is directory ***/
|
||||||
if (filelist[selection].flags)
|
if (filelist[selection].flags)
|
||||||
{
|
{
|
||||||
|
/* force going up */
|
||||||
|
go_up = (selection == 0);
|
||||||
|
|
||||||
/* get new directory */
|
/* get new directory */
|
||||||
if (useFAT) ret = FAT_UpdateDir(go_up);
|
if (useFAT)
|
||||||
else ret = DVD_UpdateDir(go_up);
|
ret = FAT_UpdateDir(go_up,filelist[selection].filename);
|
||||||
|
else
|
||||||
|
ret = DVD_UpdateDir(go_up,filelist[selection].offset,filelist[selection].length);
|
||||||
|
|
||||||
/* get new entry list or quit */
|
/* get new entry list or quit */
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
if (useFAT) maxfiles = FAT_ParseDirectory();
|
/* reinit selector (previous value is saved for one level) */
|
||||||
else maxfiles = DVD_ParseDirectory();
|
if (selection == 0)
|
||||||
|
{
|
||||||
|
selection = old_selection;
|
||||||
|
offset = old_offset;
|
||||||
|
old_selection = 0;
|
||||||
|
old_offset = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* save current selector value */
|
||||||
|
old_selection = selection;
|
||||||
|
old_offset = offset;
|
||||||
|
selection = 0;
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get directory entries */
|
||||||
|
if (useFAT)
|
||||||
|
maxfiles = FAT_ParseDirectory();
|
||||||
|
else
|
||||||
|
maxfiles = DVD_ParseDirectory();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -493,22 +513,46 @@ int FileSelector(unsigned char *buffer)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (useFAT) size = FAT_LoadFile(buffer);
|
/* user confirmation */
|
||||||
else size = DVD_LoadFile(buffer);
|
if (GUI_ConfirmPrompt("WARNING", "Load File ?"))
|
||||||
|
{
|
||||||
|
/* Load ROM file from device */
|
||||||
|
if (useFAT)
|
||||||
|
size = FAT_LoadFile(buffer,selection);
|
||||||
|
else
|
||||||
|
size = DVD_LoadFile(buffer,selection);
|
||||||
|
|
||||||
|
/* Reload emulation */
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
memfile_autosave(-1,config.state_auto);
|
memfile_autosave(-1,config.state_auto);
|
||||||
reloadrom(size,filelist[selection].filename);
|
reloadrom(size,filelist[selection].filename);
|
||||||
memfile_autoload(config.sram_auto,config.state_auto);
|
memfile_autoload(config.sram_auto,config.state_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Exit */
|
||||||
GUI_MsgBoxClose();
|
GUI_MsgBoxClose();
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
gxTextureClose(&bar_over.texture);
|
gxTextureClose(&bar_over.texture);
|
||||||
gxTextureClose(&dir_icon.texture);
|
gxTextureClose(&dir_icon.texture);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* use canceled */
|
||||||
|
GUI_MsgBoxClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FileSelClear(u32 max)
|
||||||
|
{
|
||||||
|
maxfiles = max;
|
||||||
|
offset = 0;
|
||||||
|
selection = 0;
|
||||||
|
old_offset = 0;
|
||||||
|
old_selection = 0;
|
||||||
|
}
|
||||||
|
@ -32,25 +32,16 @@
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
u64 offset;
|
u64 offset;
|
||||||
unsigned int length;
|
u32 length;
|
||||||
char flags;
|
char flags;
|
||||||
char filename[MAXJOLIET];
|
char filename[MAXJOLIET];
|
||||||
u16 filename_offset;
|
u16 filename_offset;
|
||||||
}FILEENTRIES;
|
}FILEENTRIES;
|
||||||
|
|
||||||
|
/* Globals */
|
||||||
/* Global Variables */
|
extern int FileSelector(unsigned char *buffer, bool useFAT);
|
||||||
extern FILEENTRIES filelist[MAXFILES];
|
|
||||||
extern int maxfiles;
|
|
||||||
extern int offset;
|
|
||||||
extern int selection;
|
|
||||||
extern int old_selection;
|
|
||||||
extern int old_offset;
|
|
||||||
extern int useFAT;
|
|
||||||
extern int haveDVDdir;
|
|
||||||
extern int haveFATdir;
|
|
||||||
|
|
||||||
extern int FileSelector(unsigned char *buffer);
|
|
||||||
extern int FileSortCallback(const void *f1, const void *f2);
|
extern int FileSortCallback(const void *f1, const void *f2);
|
||||||
|
extern void FileSelClear(u32 max);
|
||||||
|
extern FILEENTRIES filelist[MAXFILES];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1398,10 +1398,39 @@ void GUI_WaitPrompt(char *title, char *msg)
|
|||||||
while (m_input.keys & PAD_BUTTON_A) VIDEO_WaitVSync();
|
while (m_input.keys & PAD_BUTTON_A) VIDEO_WaitVSync();
|
||||||
while (!(m_input.keys & PAD_BUTTON_A)) VIDEO_WaitVSync();
|
while (!(m_input.keys & PAD_BUTTON_A)) VIDEO_WaitVSync();
|
||||||
|
|
||||||
/* close message box if required */
|
/* close message box */
|
||||||
GUI_MsgBoxClose();
|
GUI_MsgBoxClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GUI_ConfirmPrompt(char *title, char *msg)
|
||||||
|
{
|
||||||
|
if (config.askConfirm)
|
||||||
|
{
|
||||||
|
/* update message box */
|
||||||
|
gxTextureClose(&message_box.throbber);
|
||||||
|
GUI_MsgBoxOpen(title, 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 */
|
/* Basic Fading */
|
||||||
void GUI_FadeOut()
|
void GUI_FadeOut()
|
||||||
{
|
{
|
||||||
|
@ -291,6 +291,7 @@ extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber);
|
|||||||
extern void GUI_MsgBoxUpdate(gui_menu *parent, char *title, char *msg);
|
extern void GUI_MsgBoxUpdate(gui_menu *parent, char *title, char *msg);
|
||||||
extern void GUI_MsgBoxClose(void);
|
extern void GUI_MsgBoxClose(void);
|
||||||
extern void GUI_WaitPrompt(char *title, char *msg);
|
extern void GUI_WaitPrompt(char *title, char *msg);
|
||||||
|
extern int GUI_ConfirmPrompt(char *title, char *msg);
|
||||||
extern void GUI_FadeOut();
|
extern void GUI_FadeOut();
|
||||||
extern void GUI_SetBgColor(GXColor color);
|
extern void GUI_SetBgColor(GXColor color);
|
||||||
extern void GUI_Initialize(void);
|
extern void GUI_Initialize(void);
|
||||||
|
@ -1798,7 +1798,7 @@ static int loadmenu ()
|
|||||||
if (DVD_Open())
|
if (DVD_Open())
|
||||||
{
|
{
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
size = FileSelector(cart_rom);
|
size = FileSelector(cart_rom,0);
|
||||||
if (size) return 1;
|
if (size) return 1;
|
||||||
GUI_InitMenu(m);
|
GUI_InitMenu(m);
|
||||||
}
|
}
|
||||||
@ -1809,7 +1809,7 @@ static int loadmenu ()
|
|||||||
if (FAT_Open(ret))
|
if (FAT_Open(ret))
|
||||||
{
|
{
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
size = FileSelector(cart_rom);
|
size = FileSelector(cart_rom,1);
|
||||||
if (size) return 1;
|
if (size) return 1;
|
||||||
GUI_InitMenu(m);
|
GUI_InitMenu(m);
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
#define DEFAULT_PATH "/genplus"
|
#define DEFAULT_PATH "/genplus"
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
#define VERSION "version 1.3.xW"
|
#define VERSION "version 1.3.2W"
|
||||||
#else
|
#else
|
||||||
#define VERSION "version 1.3.XG"
|
#define VERSION "version 1.3.2G"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* globals */
|
/* globals */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user