added DVD file autosorting, fixed automatic savestate/sram, fixed interlaced video mode switch, fixed audio buffers reset

This commit is contained in:
ekeeke31 2008-12-14 12:38:52 +00:00
parent 871375cc36
commit d21047daed
10 changed files with 49 additions and 44 deletions

View File

@ -275,6 +275,10 @@ int DVD_ParseDirectory ()
len += 2048; len += 2048;
pdoffset = rdoffset + len; pdoffset = rdoffset + len;
} }
/* Sort the file list */
qsort(filelist, filecount, sizeof(FILEENTRIES), FileSortCallback);
return filecount; return filecount;
} }

View File

@ -94,33 +94,6 @@ int FAT_UpdateDir(int go_up)
return 1; return 1;
} }
/***************************************************************************
* FileSortCallback (Marty Disibio)
*
* Quick sort callback to sort file entries with the following order:
* .
* ..
* <dirs>
* <files>
***************************************************************************/
static int FileSortCallback(const void *f1, const void *f2)
{
/* Special case for implicit directories */
if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.')
{
if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; }
if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; }
if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; }
if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; }
}
/* If one is a file and one is a directory the directory is first. */
if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1;
if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1;
return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename);
}
/*************************************************************************** /***************************************************************************
* FAT_ParseDirectory * FAT_ParseDirectory
* *

View File

@ -39,7 +39,6 @@ int haveDVDdir = 0;
int haveFATdir = 0; int haveFATdir = 0;
FILEENTRIES filelist[MAXFILES]; FILEENTRIES filelist[MAXFILES];
char rom_filename[MAXJOLIET];
/*************************************************************************** /***************************************************************************
* ShowFiles * ShowFiles
@ -66,6 +65,33 @@ static void ShowFiles (int offset, int selection)
SetScreen (); SetScreen ();
} }
/***************************************************************************
* FileSortCallback (Marty Disibio)
*
* Quick sort callback to sort file entries with the following order:
* .
* ..
* <dirs>
* <files>
***************************************************************************/
int FileSortCallback(const void *f1, const void *f2)
{
/* Special case for implicit directories */
if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.')
{
if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; }
if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; }
if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; }
if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; }
}
/* If one is a file and one is a directory the directory is first. */
if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1;
if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1;
return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename);
}
/**************************************************************************** /****************************************************************************
* FileSelector * FileSelector
* *
@ -203,16 +229,8 @@ int FileSelector(unsigned char *buffer)
if (go_up) return 0; if (go_up) return 0;
/* Load file */ /* Load file */
if (useFAT) ret = FAT_LoadFile(buffer); if (useFAT) return FAT_LoadFile(buffer);
else ret = DVD_LoadFile(buffer); else return DVD_LoadFile(buffer);
if (ret)
{
/* get filename and remove extension */
sprintf(rom_filename,"%s", filelist[selection].filename);
rom_filename[strlen(rom_filename) - 5] = 0;
}
return ret;
} }
redraw = 1; redraw = 1;
} }

View File

@ -45,7 +45,6 @@ typedef struct
/* Global Variables */ /* Global Variables */
extern FILEENTRIES filelist[MAXFILES]; extern FILEENTRIES filelist[MAXFILES];
extern char rom_filename[MAXJOLIET];
extern int maxfiles; extern int maxfiles;
extern int offset; extern int offset;
extern int selection; extern int selection;
@ -56,5 +55,6 @@ extern int haveDVDdir;
extern int haveFATdir; extern int haveFATdir;
extern int FileSelector(unsigned char *buffer); extern int FileSelector(unsigned char *buffer);
extern int FileSortCallback(const void *f1, const void *f2);
#endif #endif

View File

@ -47,6 +47,7 @@ static card_stat CardStatus;
* 64k SRAM + 2k Icon * 64k SRAM + 2k Icon
*/ */
static u8 savebuffer[0x26000] ATTRIBUTE_ALIGN (32); static u8 savebuffer[0x26000] ATTRIBUTE_ALIGN (32);
char rom_filename[MAXJOLIET];
int ManageSRAM(u8 direction, u8 device); int ManageSRAM(u8 direction, u8 device);
int ManageState(u8 direction, u8 device); int ManageState(u8 direction, u8 device);

View File

@ -26,6 +26,7 @@
#include "font.h" #include "font.h"
#include "file_dvd.h" #include "file_dvd.h"
#include "file_fat.h" #include "file_fat.h"
#include "filesel.h"
#ifdef HW_RVL #ifdef HW_RVL
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
@ -889,6 +890,7 @@ int filemenu ()
* Load Rom menu * Load Rom menu
* *
****************************************************************************/ ****************************************************************************/
extern char rom_filename[MAXJOLIET];
static u8 load_menu = 0; static u8 load_menu = 0;
static u8 dvd_on = 0; static u8 dvd_on = 0;
@ -946,6 +948,9 @@ int loadmenu ()
genromsize = size; genromsize = size;
memfile_autosave(); memfile_autosave();
reloadrom(); reloadrom();
sprintf(rom_filename,"%s",filelist[selection].filename);
rom_filename[strlen(rom_filename) - 4] = 0;
memfile_autoload();
memfile_autoload(); memfile_autoload();
return 1; return 1;
} }
@ -968,9 +973,12 @@ int loadmenu ()
size = FAT_Open(ret,cart_rom); size = FAT_Open(ret,cart_rom);
if (size) if (size)
{ {
genromsize = size;
memfile_autosave(); memfile_autosave();
genromsize = size;
reloadrom(); reloadrom();
sprintf(rom_filename,"%s",filelist[selection].filename);
rom_filename[strlen(rom_filename) - 4] = 0;
memfile_autoload();
memfile_autoload(); memfile_autoload();
return 1; return 1;
} }

View File

@ -263,6 +263,7 @@ int main (int argc, char *argv[])
ConfigRequested = 0; ConfigRequested = 0;
/* reset frame timings */ /* reset frame timings */
frameticker = 0;
prev = gettime(); prev = gettime();
FrameCount = 0; FrameCount = 0;
RenderedFrameCount = 0; RenderedFrameCount = 0;

View File

@ -69,7 +69,6 @@ void ogc_audio__init(void)
AUDIO_Init (NULL); AUDIO_Init (NULL);
AUDIO_SetDSPSampleRate (AI_SAMPLERATE_48KHZ); AUDIO_SetDSPSampleRate (AI_SAMPLERATE_48KHZ);
AUDIO_RegisterDMACallback (AudioSwitchBuffers); AUDIO_RegisterDMACallback (AudioSwitchBuffers);
memset(soundbuffer, 0, 16 * 3840);
} }
void ogc_audio__reset(void) void ogc_audio__reset(void)
@ -78,6 +77,7 @@ void ogc_audio__reset(void)
IsPlaying = 0; IsPlaying = 0;
mixbuffer = 0; mixbuffer = 0;
playbuffer = 0; playbuffer = 0;
memset(soundbuffer, 0, 16 * 3840);
} }
void ogc_audio__update(void) void ogc_audio__update(void)

View File

@ -537,8 +537,8 @@ void ogc_video__reset()
if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
else while (VIDEO_GetNextField()) VIDEO_WaitVSync(); else while (VIDEO_GetNextField()) VIDEO_WaitVSync();
/* reset frame counter */ /* reset frame counter (unless it's interlaced mode change) */
frameticker = 0; if (!interlaced) frameticker = 0;
/* Configure GX */ /* Configure GX */
GX_SetViewport (0.0F, 0.0F, rmode->fbWidth, rmode->efbHeight, 0.0F, 1.0F); GX_SetViewport (0.0F, 0.0F, rmode->fbWidth, rmode->efbHeight, 0.0F, 1.0F);

View File

@ -26,7 +26,7 @@
extern void ogc_video__init(void); extern void ogc_video__init(void);
extern void ogc_video__update(void); extern void ogc_video__update(void);
extern void ogc_video__reset(void); extern void ogc_video__reset();
extern BOOL gc_pal; extern BOOL gc_pal;
extern unsigned int *xfb[2]; extern unsigned int *xfb[2];