mirror of
https://github.com/dborth/vbagx.git
synced 2024-12-25 18:21:51 +01:00
new menu
This commit is contained in:
parent
a3e494daf1
commit
afd2335815
@ -41,7 +41,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with
|
# any extra libraries we wish to link with
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -lpngu -lpng -lmxml -lbba -ltinysmb -lfat -lz -logc -lm -lfreetype
|
LIBS := -lpngu -lpng -lmxml -lmetaphrasis -lfat -lz -logc -lfreetype
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
@ -147,6 +147,10 @@ $(OUTPUT).elf: $(OFILES)
|
|||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
$(bin2o)
|
$(bin2o)
|
||||||
|
|
||||||
|
%.pcm.o : %.pcm
|
||||||
|
@echo $(notdir $<)
|
||||||
|
$(bin2o)
|
||||||
|
|
||||||
-include $(DEPENDS)
|
-include $(DEPENDS)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
@ -41,7 +41,8 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with
|
# any extra libraries we wish to link with
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -ldi -lpngu -lpng -lmxml -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype -ltinysmb
|
LIBS := -ldb -ldi -lpngu -lpng -lmxml -lmetaphrasis \
|
||||||
|
-lfat -lwiiuse -lz -lbte -logc -lasnd -ltremor -lfreetype -ltinysmb
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
@ -9,9 +9,11 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
|
#include <ogcsys.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <asndlib.h>
|
||||||
|
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
|
||||||
@ -90,6 +92,34 @@ void SetAudioRate(int type)
|
|||||||
gameType = type;
|
gameType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* SwitchAudioMode
|
||||||
|
*
|
||||||
|
* Switches between menu sound and emulator sound
|
||||||
|
***************************************************************************/
|
||||||
|
void
|
||||||
|
SwitchAudioMode(int mode)
|
||||||
|
{
|
||||||
|
if(mode == 0) // emulator
|
||||||
|
{
|
||||||
|
#ifndef NO_SOUND
|
||||||
|
ASND_Pause(1);
|
||||||
|
ASND_End();
|
||||||
|
#endif
|
||||||
|
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
||||||
|
AUDIO_RegisterDMACallback(AudioPlayer);
|
||||||
|
}
|
||||||
|
else // menu
|
||||||
|
{
|
||||||
|
AUDIO_StopDMA();
|
||||||
|
AUDIO_RegisterDMACallback(NULL);
|
||||||
|
#ifndef NO_SOUND
|
||||||
|
ASND_Init();
|
||||||
|
ASND_Pause(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* InitialiseSound
|
* InitialiseSound
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -97,8 +127,22 @@ void SetAudioRate(int type)
|
|||||||
void InitialiseSound()
|
void InitialiseSound()
|
||||||
{
|
{
|
||||||
AUDIO_Init(NULL); // Start audio subsystem
|
AUDIO_Init(NULL); // Start audio subsystem
|
||||||
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
}
|
||||||
AUDIO_RegisterDMACallback(AudioPlayer);
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ShutdownAudio
|
||||||
|
*
|
||||||
|
* Shuts down audio subsystem. Useful to avoid unpleasant sounds if a
|
||||||
|
* crash occurs during shutdown.
|
||||||
|
***************************************************************************/
|
||||||
|
void ShutdownAudio()
|
||||||
|
{
|
||||||
|
#ifndef NO_SOUND
|
||||||
|
ASND_Pause(1);
|
||||||
|
ASND_End();
|
||||||
|
#endif
|
||||||
|
AUDIO_StopDMA();
|
||||||
|
AUDIO_RegisterDMACallback(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
void InitialiseSound();
|
void InitialiseSound();
|
||||||
void StopAudio();
|
void StopAudio();
|
||||||
void SetAudioRate(int type);
|
void SetAudioRate(int type);
|
||||||
|
void SwitchAudioMode(int mode);
|
||||||
|
void ShutdownAudio();
|
||||||
|
|
||||||
class SoundWii: public SoundDriver
|
class SoundWii: public SoundDriver
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,50 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
CtrlrMap ctrlr_def[5] = {
|
CtrlrMap ctrlr_def[5] = {
|
||||||
|
// Gamecube controller btn def
|
||||||
|
{
|
||||||
|
CTRLR_GCPAD,
|
||||||
|
13,
|
||||||
|
{
|
||||||
|
{PAD_BUTTON_DOWN, "DOWN"},
|
||||||
|
{PAD_BUTTON_UP, "UP"},
|
||||||
|
{PAD_BUTTON_LEFT, "LEFT"},
|
||||||
|
{PAD_BUTTON_RIGHT, "RIGHT"},
|
||||||
|
{PAD_BUTTON_A, "A"},
|
||||||
|
{PAD_BUTTON_B, "B"},
|
||||||
|
{PAD_BUTTON_X, "X"},
|
||||||
|
{PAD_BUTTON_Y, "Y"},
|
||||||
|
{PAD_BUTTON_MENU, "START"},
|
||||||
|
{PAD_BUTTON_START, "START"},
|
||||||
|
{PAD_TRIGGER_L, "L"},
|
||||||
|
{PAD_TRIGGER_R, "R"},
|
||||||
|
{PAD_TRIGGER_Z, "Z"},
|
||||||
|
{0, ""},
|
||||||
|
{0, ""}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Wiimote btn def
|
||||||
|
{
|
||||||
|
CTRLR_WIIMOTE,
|
||||||
|
11,
|
||||||
|
{
|
||||||
|
{WPAD_BUTTON_DOWN, "DOWN"},
|
||||||
|
{WPAD_BUTTON_UP, "UP"},
|
||||||
|
{WPAD_BUTTON_LEFT, "LEFT"},
|
||||||
|
{WPAD_BUTTON_RIGHT, "RIGHT"},
|
||||||
|
{WPAD_BUTTON_A, "A"},
|
||||||
|
{WPAD_BUTTON_B, "B"},
|
||||||
|
{WPAD_BUTTON_1, "1"},
|
||||||
|
{WPAD_BUTTON_2, "2"},
|
||||||
|
{WPAD_BUTTON_PLUS, "PLUS"},
|
||||||
|
{WPAD_BUTTON_MINUS, "MINUS"},
|
||||||
|
{WPAD_BUTTON_HOME, "HOME"},
|
||||||
|
{0, ""},
|
||||||
|
{0, ""},
|
||||||
|
{0, ""},
|
||||||
|
{0, ""}
|
||||||
|
}
|
||||||
|
},
|
||||||
// Nunchuk btn def
|
// Nunchuk btn def
|
||||||
{
|
{
|
||||||
CTRLR_NUNCHUK,
|
CTRLR_NUNCHUK,
|
||||||
@ -63,56 +107,12 @@ CtrlrMap ctrlr_def[5] = {
|
|||||||
{WPAD_CLASSIC_BUTTON_PLUS, "PLUS"},
|
{WPAD_CLASSIC_BUTTON_PLUS, "PLUS"},
|
||||||
{WPAD_CLASSIC_BUTTON_MINUS, "MINUS"},
|
{WPAD_CLASSIC_BUTTON_MINUS, "MINUS"},
|
||||||
{WPAD_CLASSIC_BUTTON_HOME, "HOME"},
|
{WPAD_CLASSIC_BUTTON_HOME, "HOME"},
|
||||||
{WPAD_CLASSIC_BUTTON_FULL_L, "L TRIG"},
|
{WPAD_CLASSIC_BUTTON_FULL_L, "L"},
|
||||||
{WPAD_CLASSIC_BUTTON_FULL_R, "R TRIG"},
|
{WPAD_CLASSIC_BUTTON_FULL_R, "R"},
|
||||||
{WPAD_CLASSIC_BUTTON_ZL, "ZL"},
|
{WPAD_CLASSIC_BUTTON_ZL, "ZL"},
|
||||||
{WPAD_CLASSIC_BUTTON_ZR, "ZR"}
|
{WPAD_CLASSIC_BUTTON_ZR, "ZR"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Gamecube controller btn def
|
|
||||||
{
|
|
||||||
CTRLR_GCPAD,
|
|
||||||
13,
|
|
||||||
{
|
|
||||||
{PAD_BUTTON_DOWN, "DOWN"},
|
|
||||||
{PAD_BUTTON_UP, "UP"},
|
|
||||||
{PAD_BUTTON_LEFT, "LEFT"},
|
|
||||||
{PAD_BUTTON_RIGHT, "RIGHT"},
|
|
||||||
{PAD_BUTTON_A, "A"},
|
|
||||||
{PAD_BUTTON_B, "B"},
|
|
||||||
{PAD_BUTTON_X, "X"},
|
|
||||||
{PAD_BUTTON_Y, "Y"},
|
|
||||||
{PAD_BUTTON_MENU, "MENU"},
|
|
||||||
{PAD_BUTTON_START, "START"},
|
|
||||||
{PAD_TRIGGER_L, "L TRIG"},
|
|
||||||
{PAD_TRIGGER_R, "R TRIG"},
|
|
||||||
{PAD_TRIGGER_Z, "Z"},
|
|
||||||
{0, ""},
|
|
||||||
{0, ""}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Wiimote btn def
|
|
||||||
{
|
|
||||||
CTRLR_WIIMOTE,
|
|
||||||
11,
|
|
||||||
{
|
|
||||||
{WPAD_BUTTON_DOWN, "DOWN"},
|
|
||||||
{WPAD_BUTTON_UP, "UP"},
|
|
||||||
{WPAD_BUTTON_LEFT, "LEFT"},
|
|
||||||
{WPAD_BUTTON_RIGHT, "RIGHT"},
|
|
||||||
{WPAD_BUTTON_A, "A"},
|
|
||||||
{WPAD_BUTTON_B, "B"},
|
|
||||||
{WPAD_BUTTON_1, "1"},
|
|
||||||
{WPAD_BUTTON_2, "2"},
|
|
||||||
{WPAD_BUTTON_PLUS, "PLUS"},
|
|
||||||
{WPAD_BUTTON_MINUS, "MINUS"},
|
|
||||||
{WPAD_BUTTON_HOME, "HOME"},
|
|
||||||
{0, ""},
|
|
||||||
{0, ""},
|
|
||||||
{0, ""},
|
|
||||||
{0, ""}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Keyboard btn def, see http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
|
// Keyboard btn def, see http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
|
||||||
{
|
{
|
||||||
CTRLR_KEYBOARD,
|
CTRLR_KEYBOARD,
|
||||||
@ -250,9 +250,7 @@ CtrlrMap ctrlr_def[5] = {
|
|||||||
{231, "RWIN"},
|
{231, "RWIN"},
|
||||||
{232, "MOUSEL"},
|
{232, "MOUSEL"},
|
||||||
{233, "MOUSER"},
|
{233, "MOUSER"},
|
||||||
{234, "MOUSEM"},
|
{234, "MOUSEM"}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,14 +13,16 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
CTRLR_NONE = -1,
|
CTRLR_NONE = -1,
|
||||||
CTRLR_NUNCHUK,
|
|
||||||
CTRLR_CLASSIC,
|
|
||||||
CTRLR_GCPAD,
|
CTRLR_GCPAD,
|
||||||
CTRLR_WIIMOTE,
|
CTRLR_WIIMOTE,
|
||||||
CTRLR_KEYBOARD,
|
CTRLR_NUNCHUK,
|
||||||
CTRLR_SNES = 7 // give some other value for the snes padmap
|
CTRLR_CLASSIC,
|
||||||
|
CTRLR_KEYBOARD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char ctrlrName[4][20] =
|
||||||
|
{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller" };
|
||||||
|
|
||||||
typedef struct _btn_map {
|
typedef struct _btn_map {
|
||||||
u32 btn; // button 'id'
|
u32 btn; // button 'id'
|
||||||
char* name; // button name
|
char* name; // button name
|
||||||
|
@ -21,10 +21,11 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "menudraw.h"
|
|
||||||
#include "gcunzip.h"
|
|
||||||
#include "filesel.h"
|
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "gcunzip.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
|
#include "fileop.h"
|
||||||
|
|
||||||
#define MAXDVDFILES 2000
|
#define MAXDVDFILES 2000
|
||||||
|
|
||||||
@ -141,7 +142,6 @@ static int dvd_buffered_read(void *dst, u32 len, u64 offset)
|
|||||||
* This function relies on dvddir (file offset) being prepopulated!
|
* This function relies on dvddir (file offset) being prepopulated!
|
||||||
* returns: 1 - ok ; 0 - error
|
* returns: 1 - ok ; 0 - error
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int dvd_safe_read(void *dst_v, u32 len, u64 fileoffset)
|
int dvd_safe_read(void *dst_v, u32 len, u64 fileoffset)
|
||||||
{
|
{
|
||||||
u64 offset = dvddir + fileoffset;
|
u64 offset = dvddir + fileoffset;
|
||||||
@ -318,35 +318,40 @@ getpvd ()
|
|||||||
*
|
*
|
||||||
* Tests if a ISO9660 DVD is inserted and available, and mounts it
|
* Tests if a ISO9660 DVD is inserted and available, and mounts it
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
bool MountDVD(bool silent)
|
bool MountDVD(bool silent)
|
||||||
{
|
{
|
||||||
if (!getpvd())
|
bool res = false;
|
||||||
|
|
||||||
|
if (getpvd())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ShowAction("Loading DVD...");
|
ShowAction("Loading DVD...");
|
||||||
#ifdef HW_DOL
|
#ifdef HW_DOL
|
||||||
DVD_Mount(); // mount the DVD unit again
|
DVD_Mount(); // mount the DVD unit again
|
||||||
#elif HW_RVL
|
#else
|
||||||
u32 val;
|
u32 val;
|
||||||
DI_GetCoverRegister(&val);
|
DI_GetCoverRegister(&val);
|
||||||
if(val & 0x1) // True if no disc inside, use (val & 0x2) for true if disc inside.
|
if(val & 0x1) // True if no disc inside, use (val & 0x2) for true if disc inside.
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt("No disc inserted!");
|
ErrorPrompt("No disc inserted!");
|
||||||
|
CancelAction();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DI_Mount();
|
DI_Mount();
|
||||||
while(DI_GetStatus() & DVD_INIT);
|
while(DI_GetStatus() & DVD_INIT) usleep(20000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!getpvd())
|
if (getpvd())
|
||||||
{
|
res = true;
|
||||||
if(!silent)
|
else if(!silent)
|
||||||
WaitPrompt ("Invalid DVD.");
|
ErrorPrompt("Invalid DVD.");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
CancelAction();
|
||||||
return true;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -355,7 +360,6 @@ bool MountDVD(bool silent)
|
|||||||
* Support function to return the next file entry, if any
|
* Support function to return the next file entry, if any
|
||||||
* Declared static to avoid accidental external entry.
|
* Declared static to avoid accidental external entry.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
getentry (int entrycount, unsigned char dvdbuffer[])
|
getentry (int entrycount, unsigned char dvdbuffer[])
|
||||||
{
|
{
|
||||||
@ -445,7 +449,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
|||||||
if(!newBrowserList) // failed to allocate required memory
|
if(!newBrowserList) // failed to allocate required memory
|
||||||
{
|
{
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
WaitPrompt("Out of memory: too many files!");
|
ErrorPrompt("Out of memory: too many files!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -455,8 +459,16 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
|||||||
memset(&(browserList[entrycount]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
memset(&(browserList[entrycount]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||||
|
|
||||||
strncpy (browserList[entrycount].filename, fname, MAXJOLIET);
|
strncpy (browserList[entrycount].filename, fname, MAXJOLIET);
|
||||||
|
|
||||||
|
if(strcmp(fname,"..") == 0)
|
||||||
|
{
|
||||||
|
sprintf(browserList[entrycount].displayname, "Up One Level");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
StripExt(tmpname, fname); // hide file extension
|
StripExt(tmpname, fname); // hide file extension
|
||||||
strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY);
|
strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4);
|
memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4);
|
||||||
|
|
||||||
@ -483,7 +495,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
|||||||
* It relies on dvddir and dvddirlength being pre-populated by a call to
|
* It relies on dvddir and dvddirlength being pre-populated by a call to
|
||||||
* getpvd, a previous parse or a menu selection.
|
* getpvd, a previous parse or a menu selection.
|
||||||
*
|
*
|
||||||
* The return value is number of files collected, or 0 on failure.
|
* The return value is number of files collected, or -1 on failure.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int
|
int
|
||||||
ParseDVDdirectory ()
|
ParseDVDdirectory ()
|
||||||
@ -506,7 +518,7 @@ ParseDVDdirectory ()
|
|||||||
while (len < pdlength)
|
while (len < pdlength)
|
||||||
{
|
{
|
||||||
if (dvd_read (&dvdbuffer, 2048, pdoffset) == 0)
|
if (dvd_read (&dvdbuffer, 2048, pdoffset) == 0)
|
||||||
return 0;
|
return -1;
|
||||||
|
|
||||||
diroffset = 0;
|
diroffset = 0;
|
||||||
|
|
||||||
@ -523,6 +535,7 @@ ParseDVDdirectory ()
|
|||||||
// Sort the file list
|
// Sort the file list
|
||||||
qsort(browserList, filecount, sizeof(BROWSERENTRY), FileSortCallback);
|
qsort(browserList, filecount, sizeof(BROWSERENTRY), FileSortCallback);
|
||||||
|
|
||||||
|
browser.numEntries = filecount;
|
||||||
return filecount;
|
return filecount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +543,6 @@ ParseDVDdirectory ()
|
|||||||
* SetDVDdirectory
|
* SetDVDdirectory
|
||||||
* Set the current DVD file offset
|
* Set the current DVD file offset
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
void SetDVDdirectory(u64 dir, int length)
|
void SetDVDdirectory(u64 dir, int length)
|
||||||
{
|
{
|
||||||
dvddir = dir;
|
dvddir = dir;
|
||||||
@ -579,12 +591,18 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
|||||||
|
|
||||||
if(dirindex >= 0)
|
if(dirindex >= 0)
|
||||||
{
|
{
|
||||||
dvddir = browserList[dirindex].offset;
|
|
||||||
dvddirlength = browserList[dirindex].length;
|
|
||||||
browser.selIndex = dirindex;
|
browser.selIndex = dirindex;
|
||||||
|
|
||||||
if(browserList[dirindex].isdir) // only parse directories
|
if(browserList[dirindex].isdir) // only parse directories
|
||||||
browser.numEntries = ParseDVDdirectory();
|
{
|
||||||
|
UpdateDirName(METHOD_DVD);
|
||||||
|
ParseDVDdirectory();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dvddir = browserList[dirindex].offset;
|
||||||
|
dvddirlength = browserList[dirindex].length;
|
||||||
|
}
|
||||||
|
|
||||||
if(lastdir)
|
if(lastdir)
|
||||||
return true;
|
return true;
|
||||||
@ -597,8 +615,8 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
|||||||
bool SwitchDVDFolder(char origdir[])
|
bool SwitchDVDFolder(char origdir[])
|
||||||
{
|
{
|
||||||
// make a copy of origdir so we don't mess with original
|
// make a copy of origdir so we don't mess with original
|
||||||
char dir[200];
|
char dir[1024];
|
||||||
strcpy(dir, origdir);
|
strncpy(dir, origdir, 1024);
|
||||||
|
|
||||||
char * dirptr = dir;
|
char * dirptr = dir;
|
||||||
|
|
||||||
@ -612,6 +630,7 @@ bool SwitchDVDFolder(char origdir[])
|
|||||||
// start searching at root of DVD
|
// start searching at root of DVD
|
||||||
dvddir = dvdrootdir;
|
dvddir = dvdrootdir;
|
||||||
dvddirlength = dvdrootlength;
|
dvddirlength = dvdrootlength;
|
||||||
|
browser.dir[0] = 0;
|
||||||
ParseDVDdirectory();
|
ParseDVDdirectory();
|
||||||
|
|
||||||
return SwitchDVDFolderR(dirptr, 0);
|
return SwitchDVDFolderR(dirptr, 0);
|
||||||
@ -622,10 +641,10 @@ bool SwitchDVDFolder(char origdir[])
|
|||||||
* This function will load a file from DVD
|
* This function will load a file from DVD
|
||||||
* It assumes dvddir and dvddirlength are prepopulated
|
* It assumes dvddir and dvddirlength are prepopulated
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
LoadDVDFileOffset (unsigned char *buffer, int length)
|
LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||||
{
|
{
|
||||||
|
int result = 0;
|
||||||
int offset;
|
int offset;
|
||||||
int blocks;
|
int blocks;
|
||||||
int i;
|
int i;
|
||||||
@ -643,17 +662,19 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
{
|
{
|
||||||
ret = dvd_read (buffer, length, discoffset);
|
ret = dvd_read (buffer, length, discoffset);
|
||||||
if(ret <= 0) // read failure
|
if(ret <= 0) // read failure
|
||||||
return 0;
|
goto done;
|
||||||
|
else
|
||||||
|
result = length;
|
||||||
}
|
}
|
||||||
else // load whole file
|
else // load whole file
|
||||||
{
|
{
|
||||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||||
if(ret <= 0) // read failure
|
if(ret <= 0) // read failure
|
||||||
return 0;
|
goto done;
|
||||||
|
|
||||||
if (IsZipFile (readbuffer))
|
if (IsZipFile (readbuffer))
|
||||||
{
|
{
|
||||||
return UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
result = UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -661,7 +682,7 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
{
|
{
|
||||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||||
if(ret <= 0) // read failure
|
if(ret <= 0) // read failure
|
||||||
return 0;
|
goto done;
|
||||||
memcpy (buffer + offset, readbuffer, 2048);
|
memcpy (buffer + offset, readbuffer, 2048);
|
||||||
offset += 2048;
|
offset += 2048;
|
||||||
discoffset += 2048;
|
discoffset += 2048;
|
||||||
@ -674,12 +695,15 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
i = dvddirlength % 2048;
|
i = dvddirlength % 2048;
|
||||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||||
if(ret <= 0) // read failure
|
if(ret <= 0) // read failure
|
||||||
return 0;
|
goto done;
|
||||||
memcpy (buffer + offset, readbuffer, i);
|
memcpy (buffer + offset, readbuffer, i);
|
||||||
}
|
}
|
||||||
|
result = dvddirlength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dvddirlength;
|
done:
|
||||||
|
CancelAction();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -688,20 +712,30 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
* It will attempt to find the offset of the file, and if successful it
|
* It will attempt to find the offset of the file, and if successful it
|
||||||
* will populate dvddir and dvddirlength, and load the file
|
* will populate dvddir and dvddirlength, and load the file
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
LoadDVDFile(char * buffer, char *filepath, int datasize, bool silent)
|
LoadDVDFile(char * buffer, char *filepath, int datasize, bool silent)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
// retain original browser information
|
||||||
|
char origDir[MAXPATHLEN];
|
||||||
|
memset(origDir, 0, MAXPATHLEN);
|
||||||
|
strncpy(origDir, browser.dir, MAXPATHLEN);
|
||||||
|
int origSelIndex = browser.selIndex;
|
||||||
|
int origPageIndex = browser.selIndex;
|
||||||
|
|
||||||
if(SwitchDVDFolder(filepath))
|
if(SwitchDVDFolder(filepath))
|
||||||
{
|
ret = LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
||||||
return LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
else if(!silent)
|
||||||
}
|
ErrorPrompt("Error loading file!");
|
||||||
else
|
|
||||||
{
|
// restore browser information
|
||||||
if(!silent)
|
memset(browser.dir, 0, MAXPATHLEN);
|
||||||
WaitPrompt("Error loading file!");
|
strncpy(browser.dir, origDir, MAXPATHLEN);
|
||||||
return 0;
|
browser.selIndex = origSelIndex;
|
||||||
}
|
browser.pageIndex = origPageIndex;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -768,8 +802,8 @@ int dvd_driveid()
|
|||||||
dvd[6] = 0x20;
|
dvd[6] = 0x20;
|
||||||
dvd[7] = 3;
|
dvd[7] = 3;
|
||||||
|
|
||||||
while( dvd[7] & 1 )
|
while( dvd[7] & 1 );
|
||||||
;
|
|
||||||
DCFlushRange((void *)0x80000000, 32);
|
DCFlushRange((void *)0x80000000, 32);
|
||||||
|
|
||||||
return (int)inquiry[2];
|
return (int)inquiry[2];
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric September 2008
|
||||||
*
|
*
|
||||||
* filesel.cpp
|
* filebrowser.cpp
|
||||||
*
|
*
|
||||||
* Generic file routines - reading, writing, browsing
|
* Generic file routines - reading, writing, browsing
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -23,16 +23,16 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
|
#include "dvd.h"
|
||||||
#include "vbasupport.h"
|
#include "vbasupport.h"
|
||||||
#include "vmmem.h"
|
#include "vmmem.h"
|
||||||
#include "menudraw.h"
|
#include "filebrowser.h"
|
||||||
|
#include "menu.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
|
#include "networkop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "filesel.h"
|
|
||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "dvd.h"
|
|
||||||
#include "networkop.h"
|
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
#include "wiiusbsupport.h"
|
#include "wiiusbsupport.h"
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ int autoLoadMethod()
|
|||||||
{
|
{
|
||||||
ShowAction ("Attempting to determine load method...");
|
ShowAction ("Attempting to determine load method...");
|
||||||
|
|
||||||
int method = 0;
|
int method = METHOD_AUTO;
|
||||||
|
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
if(ChangeInterface(METHOD_SD, SILENT))
|
||||||
method = METHOD_SD;
|
method = METHOD_SD;
|
||||||
@ -66,10 +66,11 @@ int autoLoadMethod()
|
|||||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||||
method = METHOD_SMB;
|
method = METHOD_SMB;
|
||||||
else
|
else
|
||||||
WaitPrompt("Unable to auto-determine load method!");
|
ErrorPrompt("Unable to auto-determine load method!");
|
||||||
|
|
||||||
if(GCSettings.LoadMethod == METHOD_AUTO)
|
if(GCSettings.LoadMethod == METHOD_AUTO)
|
||||||
GCSettings.LoadMethod = method; // save method found for later use
|
GCSettings.LoadMethod = method; // save method found for later use
|
||||||
|
CancelAction();
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,23 +84,25 @@ int autoSaveMethod(bool silent)
|
|||||||
if(!silent)
|
if(!silent)
|
||||||
ShowAction ("Attempting to determine save method...");
|
ShowAction ("Attempting to determine save method...");
|
||||||
|
|
||||||
int method = 0;
|
int method = METHOD_AUTO;
|
||||||
|
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
if(ChangeInterface(METHOD_SD, SILENT))
|
||||||
method = METHOD_SD;
|
method = METHOD_SD;
|
||||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
else if(ChangeInterface(METHOD_USB, SILENT))
|
||||||
method = METHOD_USB;
|
method = METHOD_USB;
|
||||||
else if(TestCard(CARD_SLOTA, SILENT))
|
else if(ChangeInterface(METHOD_MC_SLOTA, SILENT))
|
||||||
method = METHOD_MC_SLOTA;
|
method = METHOD_MC_SLOTA;
|
||||||
else if(TestCard(CARD_SLOTB, SILENT))
|
else if(ChangeInterface(METHOD_MC_SLOTB, SILENT))
|
||||||
method = METHOD_MC_SLOTB;
|
method = METHOD_MC_SLOTB;
|
||||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||||
method = METHOD_SMB;
|
method = METHOD_SMB;
|
||||||
else if(!silent)
|
else if(!silent)
|
||||||
WaitPrompt("Unable to auto-determine save method!");
|
ErrorPrompt("Unable to auto-determine save method!");
|
||||||
|
|
||||||
if(GCSettings.SaveMethod == METHOD_AUTO)
|
if(GCSettings.SaveMethod == METHOD_AUTO)
|
||||||
GCSettings.SaveMethod = method; // save method found for later use
|
GCSettings.SaveMethod = method; // save method found for later use
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +112,9 @@ int autoSaveMethod(bool silent)
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void ResetBrowser()
|
void ResetBrowser()
|
||||||
{
|
{
|
||||||
browser.selIndex = browser.pageIndex = 0;
|
browser.numEntries = 0;
|
||||||
|
browser.selIndex = 0;
|
||||||
|
browser.pageIndex = 0;
|
||||||
|
|
||||||
// Clear any existing values
|
// Clear any existing values
|
||||||
if(browserList != NULL)
|
if(browserList != NULL)
|
||||||
@ -118,7 +123,7 @@ void ResetBrowser()
|
|||||||
browserList = NULL;
|
browserList = NULL;
|
||||||
}
|
}
|
||||||
// set aside space for 1 entry
|
// set aside space for 1 entry
|
||||||
browserList = (BROWSERENTRY *)memalign(32, sizeof(BROWSERENTRY));
|
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY));
|
||||||
memset(browserList, 0, sizeof(BROWSERENTRY));
|
memset(browserList, 0, sizeof(BROWSERENTRY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,16 +176,17 @@ int UpdateDirName(int method)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Directory name is too long!");
|
ErrorPrompt("Directory name is too long!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MakeFilePath(char filepath[], int type, int method)
|
bool MakeFilePath(char filepath[], int type, int method, char * filename, int filenum)
|
||||||
{
|
{
|
||||||
char file[512];
|
char file[512];
|
||||||
char folder[1024];
|
char folder[1024];
|
||||||
|
char ext[4];
|
||||||
char temppath[MAXPATHLEN];
|
char temppath[MAXPATHLEN];
|
||||||
|
|
||||||
if(type == FILE_ROM)
|
if(type == FILE_ROM)
|
||||||
@ -188,7 +194,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
|||||||
// Check path length
|
// Check path length
|
||||||
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) >= MAXPATHLEN)
|
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) >= MAXPATHLEN)
|
||||||
{
|
{
|
||||||
WaitPrompt("Maximum filepath length reached!");
|
ErrorPrompt("Maximum filepath length reached!");
|
||||||
filepath[0] = 0;
|
filepath[0] = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -202,12 +208,31 @@ bool MakeFilePath(char filepath[], int type, int method)
|
|||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case FILE_SRAM:
|
case FILE_SRAM:
|
||||||
sprintf(folder, GCSettings.SaveFolder);
|
|
||||||
sprintf(file, "%s.sav", ROMFilename);
|
|
||||||
break;
|
|
||||||
case FILE_SNAPSHOT:
|
case FILE_SNAPSHOT:
|
||||||
sprintf(folder, GCSettings.SaveFolder);
|
sprintf(folder, GCSettings.SaveFolder);
|
||||||
sprintf(file, "%s.sgm", ROMFilename);
|
|
||||||
|
if(type == FILE_SRAM) sprintf(ext, "sav");
|
||||||
|
else sprintf(ext, "sgm");
|
||||||
|
|
||||||
|
if(filenum >= 0)
|
||||||
|
{
|
||||||
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
filename[26] = 0; // truncate filename
|
||||||
|
sprintf(file, "%s%i.%s", filename, filenum, ext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(filenum == 0)
|
||||||
|
sprintf(file, "%s Auto.%s", filename, ext);
|
||||||
|
else
|
||||||
|
sprintf(file, "%s %i.%s", filename, filenum, ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(file, "%s", filename);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FILE_CHEAT:
|
case FILE_CHEAT:
|
||||||
sprintf(folder, GCSettings.CheatFolder);
|
sprintf(folder, GCSettings.CheatFolder);
|
||||||
@ -230,7 +255,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcpy(filepath, temppath);
|
strncpy(filepath, temppath, MAXPATHLEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +291,6 @@ int FileSortCallback(const void *f1, const void *f2)
|
|||||||
*
|
*
|
||||||
* Checks if the specified file is a 7z
|
* Checks if the specified file is a 7z
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
bool IsSz()
|
bool IsSz()
|
||||||
{
|
{
|
||||||
if (strlen(browserList[browser.selIndex].filename) > 4)
|
if (strlen(browserList[browser.selIndex].filename) > 4)
|
||||||
@ -285,129 +309,40 @@ bool IsSz()
|
|||||||
*
|
*
|
||||||
* Strips an extension from a filename
|
* Strips an extension from a filename
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
void StripExt(char* returnstring, char * inputstring)
|
void StripExt(char* returnstring, char * inputstring)
|
||||||
{
|
{
|
||||||
char* loc_dot;
|
char* loc_dot;
|
||||||
|
|
||||||
strcpy (returnstring, inputstring);
|
strncpy (returnstring, inputstring, 255);
|
||||||
|
|
||||||
|
if(inputstring == NULL || strlen(inputstring) < 4)
|
||||||
|
return;
|
||||||
|
|
||||||
loc_dot = strrchr(returnstring,'.');
|
loc_dot = strrchr(returnstring,'.');
|
||||||
if (loc_dot != NULL)
|
if (loc_dot != NULL)
|
||||||
*loc_dot = 0; // strip file extension
|
*loc_dot = 0; // strip file extension
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* FileSelector
|
* BrowserLoadSz
|
||||||
*
|
*
|
||||||
* Let user select a file from the listing
|
* Opens the selected 7z file, and parses a listing of the files within
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int FileSelector (int method)
|
int BrowserLoadSz(int method)
|
||||||
{
|
{
|
||||||
u32 p = 0;
|
char filepath[MAXPATHLEN];
|
||||||
u32 wp = 0;
|
memset(filepath, 0, MAXPATHLEN);
|
||||||
u32 ph = 0;
|
|
||||||
u32 wh = 0;
|
|
||||||
signed char gc_ay = 0;
|
|
||||||
signed char gc_sx = 0;
|
|
||||||
signed char wm_ay = 0;
|
|
||||||
signed char wm_sx = 0;
|
|
||||||
|
|
||||||
int haverom = 0;
|
|
||||||
int redraw = 1;
|
|
||||||
int selectit = 0;
|
|
||||||
|
|
||||||
int scroll_delay = 0;
|
|
||||||
bool move_selection = 0;
|
|
||||||
#define SCROLL_INITIAL_DELAY 15
|
|
||||||
#define SCROLL_LOOP_DELAY 2
|
|
||||||
|
|
||||||
while (haverom == 0)
|
|
||||||
{
|
|
||||||
if (redraw)
|
|
||||||
ShowFiles (browserList, browser.numEntries, browser.pageIndex, browser.selIndex);
|
|
||||||
redraw = 0;
|
|
||||||
|
|
||||||
updateRumbleFrame();
|
|
||||||
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
|
|
||||||
|
|
||||||
gc_ay = PAD_StickY (0);
|
|
||||||
gc_sx = PAD_SubStickX (0);
|
|
||||||
|
|
||||||
p = PAD_ButtonsDown (0);
|
|
||||||
ph = PAD_ButtonsHeld (0);
|
|
||||||
#ifdef HW_RVL
|
|
||||||
wm_ay = WPAD_Stick (0, 0, 0);
|
|
||||||
wm_sx = WPAD_Stick (0, 1, 1);
|
|
||||||
|
|
||||||
wp = WPAD_ButtonsDown (0);
|
|
||||||
wh = WPAD_ButtonsHeld (0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*** Check for exit combo ***/
|
|
||||||
if ( (gc_sx < -70) || (wm_sx < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) || DownUsbKeys[KB_ESC])
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*** Check buttons, perform actions ***/
|
|
||||||
if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) || DownUsbKeys[KB_ENTER] )
|
|
||||||
{
|
|
||||||
if ( selectit )
|
|
||||||
selectit = 0;
|
|
||||||
if (browserList[browser.selIndex].isdir) // This is directory
|
|
||||||
{
|
|
||||||
/* update current directory and set new entry list if directory has changed */
|
|
||||||
int status;
|
|
||||||
|
|
||||||
if(inSz && browser.selIndex == 0) // inside a 7z, requesting to leave
|
|
||||||
{
|
|
||||||
if(method == METHOD_DVD)
|
|
||||||
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
|
||||||
|
|
||||||
inSz = false;
|
|
||||||
status = 1;
|
|
||||||
SzClose();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = UpdateDirName(method);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == 1) // ok, open directory
|
|
||||||
{
|
|
||||||
switch (method)
|
|
||||||
{
|
|
||||||
case METHOD_DVD:
|
|
||||||
browser.numEntries = ParseDVDdirectory();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
browser.numEntries = ParseDirectory();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!browser.numEntries)
|
|
||||||
{
|
|
||||||
WaitPrompt ("Error reading directory!");
|
|
||||||
haverom = 1; // quit menu
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (status == -1) // directory name too long
|
|
||||||
{
|
|
||||||
haverom = 1; // quit menu
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // this is a file
|
|
||||||
{
|
|
||||||
// 7z file - let's open it up to select a file inside
|
|
||||||
if(IsSz())
|
|
||||||
{
|
|
||||||
// we'll store the 7z filepath for extraction later
|
// we'll store the 7z filepath for extraction later
|
||||||
if(!MakeFilePath(szpath, FILE_ROM, method))
|
if(!MakeFilePath(szpath, FILE_ROM, method))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// add device to filepath
|
// add device to filepath
|
||||||
char fullpath[1024];
|
if(method != METHOD_DVD)
|
||||||
sprintf(fullpath, "%s%s", rootdir, szpath);
|
{
|
||||||
strcpy(szpath, fullpath);
|
sprintf(filepath, "%s%s", rootdir, szpath);
|
||||||
|
memcpy(szpath, filepath, MAXPATHLEN);
|
||||||
|
}
|
||||||
|
|
||||||
int szfiles = SzParse(szpath, method);
|
int szfiles = SzParse(szpath, method);
|
||||||
if(szfiles)
|
if(szfiles)
|
||||||
@ -416,167 +351,99 @@ int FileSelector (int method)
|
|||||||
inSz = true;
|
inSz = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WaitPrompt("Error opening archive!");
|
ErrorPrompt("Error opening archive!");
|
||||||
}
|
|
||||||
else
|
return szfiles;
|
||||||
{
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* BrowserLoadFile
|
||||||
|
*
|
||||||
|
* Loads the selected ROM
|
||||||
|
***************************************************************************/
|
||||||
|
int BrowserLoadFile(int method)
|
||||||
|
{
|
||||||
// store the filename (w/o ext) - used for sram/freeze naming
|
// store the filename (w/o ext) - used for sram/freeze naming
|
||||||
StripExt(ROMFilename, browserList[browser.selIndex].filename);
|
StripExt(ROMFilename, browserList[browser.selIndex].filename);
|
||||||
|
|
||||||
ShowAction ("Loading...");
|
|
||||||
|
|
||||||
ROMLoaded = LoadVBAROM(method);
|
ROMLoaded = LoadVBAROM(method);
|
||||||
inSz = false;
|
inSz = false;
|
||||||
|
|
||||||
if (ROMLoaded)
|
if (!ROMLoaded)
|
||||||
{
|
{
|
||||||
return 1;
|
ErrorPrompt("Error loading ROM!");
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
|
||||||
redraw = 1;
|
|
||||||
} // End of A
|
|
||||||
if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || DownUsbKeys[KB_BKSP]))
|
|
||||||
{
|
{
|
||||||
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
|
ResetBrowser();
|
||||||
#ifdef HW_RVL
|
|
||||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
updateRumbleFrame();
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
}
|
}
|
||||||
if ( strcmp(browserList[0].filename,"..") == 0 )
|
CancelAction();
|
||||||
|
return ROMLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* BrowserChangeFolder
|
||||||
|
*
|
||||||
|
* Update current directory and set new entry list if directory has changed
|
||||||
|
***************************************************************************/
|
||||||
|
int BrowserChangeFolder(int method)
|
||||||
|
{
|
||||||
|
if(inSz && browser.selIndex == 0) // inside a 7z, requesting to leave
|
||||||
{
|
{
|
||||||
browser.selIndex = 0;
|
if(method == METHOD_DVD)
|
||||||
selectit = 1;
|
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
||||||
}
|
|
||||||
else if ( strcmp(browserList[1].filename,"..") == 0 )
|
inSz = false;
|
||||||
{
|
SzClose();
|
||||||
browser.selIndex = selectit = 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} // End of B
|
|
||||||
if ( ((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (gc_ay < -PADCAL) || (wm_ay < -PADCAL) )
|
|
||||||
{
|
|
||||||
if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/
|
|
||||||
scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
|
||||||
move_selection = 1; //continue (move selection)
|
|
||||||
}
|
|
||||||
else if (scroll_delay == 0) { /*** Button is held ***/
|
|
||||||
scroll_delay = SCROLL_LOOP_DELAY;
|
|
||||||
move_selection = 1; //continue (move selection)
|
|
||||||
} else {
|
|
||||||
scroll_delay--; // wait
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (move_selection)
|
if(!UpdateDirName(method))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
switch (method)
|
||||||
{
|
{
|
||||||
browser.selIndex++;
|
case METHOD_DVD:
|
||||||
if (browser.selIndex == browser.numEntries)
|
ParseDVDdirectory();
|
||||||
browser.selIndex = browser.pageIndex = 0;
|
break;
|
||||||
if ((browser.selIndex - browser.pageIndex) >= PAGESIZE)
|
|
||||||
browser.pageIndex += PAGESIZE;
|
default:
|
||||||
redraw = 1;
|
ParseDirectory(method);
|
||||||
move_selection = 0;
|
break;
|
||||||
}
|
|
||||||
} // End of down
|
|
||||||
if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (gc_ay > PADCAL) || (wm_ay > PADCAL) )
|
|
||||||
{
|
|
||||||
if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/
|
|
||||||
scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
|
||||||
move_selection = 1; //continue (move selection)
|
|
||||||
}
|
|
||||||
else if (scroll_delay == 0) { /*** Button is held ***/
|
|
||||||
scroll_delay = SCROLL_LOOP_DELAY;
|
|
||||||
move_selection = 1; //continue (move selection)
|
|
||||||
} else {
|
|
||||||
scroll_delay--; // wait
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (move_selection)
|
if (!browser.numEntries)
|
||||||
{
|
{
|
||||||
browser.selIndex--;
|
ErrorPrompt("Error reading directory!");
|
||||||
if (browser.selIndex < 0) {
|
|
||||||
browser.selIndex = browser.numEntries - 1;
|
|
||||||
browser.pageIndex = browser.selIndex - PAGESIZE + 1;
|
|
||||||
}
|
}
|
||||||
if (browser.selIndex < browser.pageIndex)
|
|
||||||
browser.pageIndex -= PAGESIZE;
|
return browser.numEntries;
|
||||||
if (browser.pageIndex < 0)
|
|
||||||
browser.pageIndex = 0;
|
|
||||||
redraw = 1;
|
|
||||||
move_selection = 0;
|
|
||||||
}
|
|
||||||
} // End of Up
|
|
||||||
if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) )
|
|
||||||
{
|
|
||||||
/*** Go back a page ***/
|
|
||||||
browser.selIndex -= PAGESIZE;
|
|
||||||
if (browser.selIndex < 0)
|
|
||||||
{
|
|
||||||
browser.selIndex = browser.numEntries - 1;
|
|
||||||
browser.pageIndex = browser.selIndex - PAGESIZE + 1;
|
|
||||||
}
|
|
||||||
if (browser.selIndex < browser.pageIndex)
|
|
||||||
browser.pageIndex -= PAGESIZE;
|
|
||||||
if (browser.pageIndex < 0)
|
|
||||||
browser.pageIndex = 0;
|
|
||||||
redraw = 1;
|
|
||||||
}
|
|
||||||
if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) )
|
|
||||||
{
|
|
||||||
/*** Go forward a page ***/
|
|
||||||
browser.selIndex += PAGESIZE;
|
|
||||||
if (browser.selIndex > browser.numEntries - 1)
|
|
||||||
browser.selIndex = browser.pageIndex = 0;
|
|
||||||
if ((browser.selIndex - browser.pageIndex) >= PAGESIZE)
|
|
||||||
browser.pageIndex += PAGESIZE;
|
|
||||||
redraw = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* OpenROM
|
* OpenROM
|
||||||
* Opens device specified by method, displays a list of ROMS
|
* Displays a list of ROMS on load device
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
OpenROM (int method)
|
OpenGameList ()
|
||||||
{
|
{
|
||||||
|
int method = GCSettings.LoadMethod;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoLoadMethod();
|
method = autoLoadMethod();
|
||||||
|
|
||||||
if(ChangeInterface(method, NOTSILENT))
|
|
||||||
{
|
|
||||||
// change current dir to roms directory
|
// change current dir to roms directory
|
||||||
switch(method)
|
switch(method)
|
||||||
{
|
{
|
||||||
case METHOD_DVD:
|
case METHOD_DVD:
|
||||||
browser.dir[0] = 0;
|
browser.dir[0] = 0;
|
||||||
browser.numEntries = ParseDVDdirectory(); // Parse root directory
|
if(MountDVD(NOTSILENT))
|
||||||
|
if(ParseDVDdirectory()) // Parse root directory
|
||||||
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(browser.dir, "/%s", GCSettings.LoadFolder);
|
sprintf(browser.dir, "/%s", GCSettings.LoadFolder);
|
||||||
browser.numEntries = ParseDirectory(); // Parse root directory
|
ParseDirectory(method); // Parse root directory
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return browser.numEntries;
|
||||||
if (browser.numEntries > 0)
|
|
||||||
{
|
|
||||||
// Select an entry
|
|
||||||
return FileSelector (method);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// no entries found
|
|
||||||
WaitPrompt ("No Files Found!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,19 @@
|
|||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric September 2008
|
||||||
*
|
*
|
||||||
* filesel.h
|
* filebrowser.h
|
||||||
*
|
*
|
||||||
* Generic file routines - reading, writing, browsing
|
* Generic file routines - reading, writing, browsing
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _NGCFILESEL_
|
#ifndef _FILEBROWSER_H_
|
||||||
#define _NGCFILESEL_
|
#define _FILEBROWSER_H_
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <gccore.h>
|
||||||
|
|
||||||
#define MAXJOLIET 255
|
#define MAXJOLIET 255
|
||||||
#define MAXDISPLAY 40
|
#define MAXDISPLAY 35
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -28,6 +29,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
u64 offset; // DVD offset
|
u64 offset; // DVD offset
|
||||||
unsigned int length; // file length
|
unsigned int length; // file length
|
||||||
|
time_t mtime; // file modified time
|
||||||
char isdir; // 0 - file, 1 - directory
|
char isdir; // 0 - file, 1 - directory
|
||||||
char filename[MAXJOLIET + 1]; // full filename
|
char filename[MAXJOLIET + 1]; // full filename
|
||||||
char displayname[MAXDISPLAY + 1]; // name for browser display
|
char displayname[MAXDISPLAY + 1]; // name for browser display
|
||||||
@ -36,17 +38,22 @@ typedef struct
|
|||||||
extern BROWSERINFO browser;
|
extern BROWSERINFO browser;
|
||||||
extern BROWSERENTRY * browserList;
|
extern BROWSERENTRY * browserList;
|
||||||
extern char rootdir[10];
|
extern char rootdir[10];
|
||||||
|
extern char ROMFilename[512];
|
||||||
|
extern bool ROMLoaded;
|
||||||
extern char szpath[MAXPATHLEN];
|
extern char szpath[MAXPATHLEN];
|
||||||
extern bool inSz;
|
extern bool inSz;
|
||||||
extern char ROMFilename[512];
|
|
||||||
|
|
||||||
bool MakeFilePath(char filepath[], int type, int method);
|
bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -1);
|
||||||
int OpenROM (int method);
|
int UpdateDirName(int method);
|
||||||
|
int OpenGameList();
|
||||||
int autoLoadMethod();
|
int autoLoadMethod();
|
||||||
int autoSaveMethod(bool silent);
|
int autoSaveMethod(bool silent);
|
||||||
int FileSortCallback(const void *f1, const void *f2);
|
int FileSortCallback(const void *f1, const void *f2);
|
||||||
void StripExt(char* returnstring, char * inputstring);
|
void StripExt(char* returnstring, char * inputstring);
|
||||||
|
bool IsSz();
|
||||||
void ResetBrowser();
|
void ResetBrowser();
|
||||||
|
int BrowserLoadSz(int method);
|
||||||
|
int BrowserChangeFolder(int method);
|
||||||
|
int BrowserLoadFile(int method);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
*
|
*
|
||||||
* filelist.h
|
* filelist.h
|
||||||
*
|
*
|
||||||
* Contains a list of all of the files in the images/ folder
|
* Contains a list of all of the files stored in the images/, fonts/, and
|
||||||
|
* sounds/ folders
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef _FILELIST_H_
|
#ifndef _FILELIST_H_
|
||||||
@ -16,6 +17,208 @@
|
|||||||
extern const u8 font_ttf[];
|
extern const u8 font_ttf[];
|
||||||
extern const u32 font_ttf_size;
|
extern const u32 font_ttf_size;
|
||||||
|
|
||||||
|
extern const u8 bg_music_ogg[];
|
||||||
|
extern const u32 bg_music_ogg_size;
|
||||||
|
|
||||||
|
extern const u8 enter_ogg[];
|
||||||
|
extern const u32 enter_ogg_size;
|
||||||
|
|
||||||
|
extern const u8 exit_ogg[];
|
||||||
|
extern const u32 exit_ogg_size;
|
||||||
|
|
||||||
|
extern const u8 button_over_pcm[];
|
||||||
|
extern const u32 button_over_pcm_size;
|
||||||
|
|
||||||
|
extern const u8 button_click_pcm[];
|
||||||
|
extern const u32 button_click_pcm_size;
|
||||||
|
|
||||||
|
extern const u8 logo_png[];
|
||||||
|
extern const u32 logo_png_size;
|
||||||
|
|
||||||
|
extern const u8 logo_over_png[];
|
||||||
|
extern const u32 logo_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 bg_top_png[];
|
||||||
|
extern const u32 bg_top_png_size;
|
||||||
|
|
||||||
|
extern const u8 bg_bottom_png[];
|
||||||
|
extern const u32 bg_bottom_png_size;
|
||||||
|
|
||||||
|
extern const u8 icon_settings_png[];
|
||||||
|
extern const u32 icon_settings_png_size;
|
||||||
|
|
||||||
|
extern const u8 icon_home_png[];
|
||||||
|
extern const u32 icon_home_png_size;
|
||||||
|
|
||||||
|
extern const u8 icon_game_cheats_png[];
|
||||||
|
extern const u32 icon_game_cheats_png_size;
|
||||||
|
extern const u8 icon_game_controllers_png[];
|
||||||
|
extern const u32 icon_game_controllers_png_size;
|
||||||
|
extern const u8 icon_game_load_png[];
|
||||||
|
extern const u32 icon_game_load_png_size;
|
||||||
|
extern const u8 icon_game_save_png[];
|
||||||
|
extern const u32 icon_game_save_png_size;
|
||||||
|
extern const u8 icon_game_reset_png[];
|
||||||
|
extern const u32 icon_game_reset_png_size;
|
||||||
|
|
||||||
|
extern const u8 icon_settings_wiimote_png[];
|
||||||
|
extern const u32 icon_settings_wiimote_png_size;
|
||||||
|
extern const u8 icon_settings_classic_png[];
|
||||||
|
extern const u32 icon_settings_classic_png_size;
|
||||||
|
extern const u8 icon_settings_gamecube_png[];
|
||||||
|
extern const u32 icon_settings_gamecube_png_size;
|
||||||
|
extern const u8 icon_settings_nunchuk_png[];
|
||||||
|
extern const u32 icon_settings_nunchuk_png_size;
|
||||||
|
|
||||||
|
extern const u8 icon_settings_file_png[];
|
||||||
|
extern const u32 icon_settings_file_png_size;
|
||||||
|
extern const u8 icon_settings_mappings_png[];
|
||||||
|
extern const u32 icon_settings_mappings_png_size;
|
||||||
|
extern const u8 icon_settings_menu_png[];
|
||||||
|
extern const u32 icon_settings_menu_png_size;
|
||||||
|
extern const u8 icon_settings_network_png[];
|
||||||
|
extern const u32 icon_settings_network_png_size;
|
||||||
|
extern const u8 icon_settings_video_png[];
|
||||||
|
extern const u32 icon_settings_video_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_png[];
|
||||||
|
extern const u32 button_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_over_png[];
|
||||||
|
extern const u32 button_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_small_png[];
|
||||||
|
extern const u32 button_small_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_small_over_png[];
|
||||||
|
extern const u32 button_small_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_large_png[];
|
||||||
|
extern const u32 button_large_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_large_over_png[];
|
||||||
|
extern const u32 button_large_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_arrow_left_png[];
|
||||||
|
extern const u32 button_arrow_left_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_arrow_right_png[];
|
||||||
|
extern const u32 button_arrow_right_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_arrow_up_png[];
|
||||||
|
extern const u32 button_arrow_up_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_arrow_down_png[];
|
||||||
|
extern const u32 button_arrow_down_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_arrow_left_over_png[];
|
||||||
|
extern const u32 button_arrow_left_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_arrow_right_over_png[];
|
||||||
|
extern const u32 button_arrow_right_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_arrow_up_over_png[];
|
||||||
|
extern const u32 button_arrow_up_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_arrow_down_over_png[];
|
||||||
|
extern const u32 button_arrow_down_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_gamesave_png[];
|
||||||
|
extern const u32 button_gamesave_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_gamesave_over_png[];
|
||||||
|
extern const u32 button_gamesave_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 button_gamesave_blank_png[];
|
||||||
|
extern const u32 button_gamesave_blank_png_size;
|
||||||
|
|
||||||
|
extern const u8 screen_position_png[];
|
||||||
|
extern const u32 screen_position_png_size;
|
||||||
|
|
||||||
|
extern const u8 dialogue_box_png[];
|
||||||
|
extern const u32 dialogue_box_png_size;
|
||||||
|
|
||||||
|
extern const u8 credits_box_png[];
|
||||||
|
extern const u32 credits_box_png_size;
|
||||||
|
|
||||||
|
extern const u8 progressbar_png[];
|
||||||
|
extern const u32 progressbar_png_size;
|
||||||
|
|
||||||
|
extern const u8 progressbar_empty_png[];
|
||||||
|
extern const u32 progressbar_empty_png_size;
|
||||||
|
|
||||||
|
extern const u8 progressbar_outline_png[];
|
||||||
|
extern const u32 progressbar_outline_png_size;
|
||||||
|
|
||||||
|
extern const u8 throbber_png[];
|
||||||
|
extern const u32 throbber_png_size;
|
||||||
|
|
||||||
|
extern const u8 folder_png[];
|
||||||
|
extern const u32 folder_png_size;
|
||||||
|
|
||||||
|
extern const u8 battery_png[];
|
||||||
|
extern const u32 battery_png_size;
|
||||||
|
|
||||||
|
extern const u8 battery_red_png[];
|
||||||
|
extern const u32 battery_red_png_size;
|
||||||
|
|
||||||
|
extern const u8 battery_bar_png[];
|
||||||
|
extern const u32 battery_bar_png_size;
|
||||||
|
|
||||||
|
extern const u8 bg_options_png[];
|
||||||
|
extern const u32 bg_options_png_size;
|
||||||
|
|
||||||
|
extern const u8 bg_options_entry_png[];
|
||||||
|
extern const u32 bg_options_entry_png_size;
|
||||||
|
|
||||||
|
extern const u8 bg_game_selection_png[];
|
||||||
|
extern const u32 bg_game_selection_png_size;
|
||||||
|
|
||||||
|
extern const u8 bg_game_selection_entry_png[];
|
||||||
|
extern const u32 bg_game_selection_entry_png_size;
|
||||||
|
|
||||||
|
extern const u8 scrollbar_png[];
|
||||||
|
extern const u32 scrollbar_png_size;
|
||||||
|
|
||||||
|
extern const u8 scrollbar_arrowup_png[];
|
||||||
|
extern const u32 scrollbar_arrowup_png_size;
|
||||||
|
|
||||||
|
extern const u8 scrollbar_arrowup_over_png[];
|
||||||
|
extern const u32 scrollbar_arrowup_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 scrollbar_arrowdown_png[];
|
||||||
|
extern const u32 scrollbar_arrowdown_png_size;
|
||||||
|
|
||||||
|
extern const u8 scrollbar_arrowdown_over_png[];
|
||||||
|
extern const u32 scrollbar_arrowdown_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 scrollbar_box_png[];
|
||||||
|
extern const u32 scrollbar_box_png_size;
|
||||||
|
|
||||||
|
extern const u8 scrollbar_box_over_png[];
|
||||||
|
extern const u32 scrollbar_box_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 keyboard_textbox_png[];
|
||||||
|
extern const u32 keyboard_textbox_png_size;
|
||||||
|
|
||||||
|
extern const u8 keyboard_key_png[];
|
||||||
|
extern const u32 keyboard_key_png_size;
|
||||||
|
|
||||||
|
extern const u8 keyboard_key_over_png[];
|
||||||
|
extern const u32 keyboard_key_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 keyboard_mediumkey_png[];
|
||||||
|
extern const u32 keyboard_mediumkey_png_size;
|
||||||
|
|
||||||
|
extern const u8 keyboard_mediumkey_over_png[];
|
||||||
|
extern const u32 keyboard_mediumkey_over_png_size;
|
||||||
|
|
||||||
|
extern const u8 keyboard_largekey_png[];
|
||||||
|
extern const u32 keyboard_largekey_png_size;
|
||||||
|
|
||||||
|
extern const u8 keyboard_largekey_over_png[];
|
||||||
|
extern const u32 keyboard_largekey_over_png_size;
|
||||||
|
|
||||||
extern const u8 player1_point_png[];
|
extern const u8 player1_point_png[];
|
||||||
extern const u32 player1_point_png_size;
|
extern const u32 player1_point_png_size;
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
|
||||||
unsigned char * savebuffer = NULL;
|
unsigned char * savebuffer = NULL;
|
||||||
@ -49,7 +49,7 @@ bool isMounted[9] = { false, false, false, false, false, false, false, false, fa
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* deviceThreading
|
* deviceThreading
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
lwp_t devicethread;
|
lwp_t devicethread = LWP_THREAD_NULL;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* devicecallback
|
* devicecallback
|
||||||
@ -103,7 +103,6 @@ devicecallback (void *arg)
|
|||||||
#endif
|
#endif
|
||||||
usleep(500000); // suspend thread for 1/2 sec
|
usleep(500000); // suspend thread for 1/2 sec
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +115,7 @@ devicecallback (void *arg)
|
|||||||
void
|
void
|
||||||
InitDeviceThread()
|
InitDeviceThread()
|
||||||
{
|
{
|
||||||
LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 80);
|
LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -181,6 +180,7 @@ bool MountFAT(int method)
|
|||||||
unmountRequired[method] = false;
|
unmountRequired[method] = false;
|
||||||
fatUnmount(rootdir);
|
fatUnmount(rootdir);
|
||||||
disc->shutdown();
|
disc->shutdown();
|
||||||
|
isMounted[method] = false;
|
||||||
}
|
}
|
||||||
if(!isMounted[method])
|
if(!isMounted[method])
|
||||||
{
|
{
|
||||||
@ -227,7 +227,7 @@ bool ChangeInterface(int method, bool silent)
|
|||||||
mounted = MountFAT(METHOD_SD_SLOTB); // try SD Gecko on slot B
|
mounted = MountFAT(METHOD_SD_SLOTB); // try SD Gecko on slot B
|
||||||
#endif
|
#endif
|
||||||
if(!mounted && !silent) // no SD device found
|
if(!mounted && !silent) // no SD device found
|
||||||
WaitPrompt ("SD card not found!");
|
ErrorPrompt("SD card not found!");
|
||||||
}
|
}
|
||||||
else if(method == METHOD_USB)
|
else if(method == METHOD_USB)
|
||||||
{
|
{
|
||||||
@ -235,19 +235,31 @@ bool ChangeInterface(int method, bool silent)
|
|||||||
mounted = MountFAT(method);
|
mounted = MountFAT(method);
|
||||||
|
|
||||||
if(!mounted && !silent)
|
if(!mounted && !silent)
|
||||||
WaitPrompt ("USB drive not found!");
|
ErrorPrompt("USB drive not found!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if(method == METHOD_DVD)
|
else if(method == METHOD_DVD)
|
||||||
{
|
{
|
||||||
sprintf(rootdir, "/");
|
rootdir[0] = 0;
|
||||||
mounted = MountDVD(silent);
|
mounted = MountDVD(silent);
|
||||||
}
|
}
|
||||||
|
#ifdef HW_RVL
|
||||||
else if(method == METHOD_SMB)
|
else if(method == METHOD_SMB)
|
||||||
{
|
{
|
||||||
sprintf(rootdir, "smb:/");
|
sprintf(rootdir, "smb:/");
|
||||||
mounted = ConnectShare(silent);
|
mounted = ConnectShare(silent);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
else if(method == METHOD_MC_SLOTA)
|
||||||
|
{
|
||||||
|
rootdir[0] = 0;
|
||||||
|
mounted = TestMC(CARD_SLOTA, silent);
|
||||||
|
}
|
||||||
|
else if(method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
rootdir[0] = 0;
|
||||||
|
mounted = TestMC(CARD_SLOTB, silent);
|
||||||
|
}
|
||||||
|
|
||||||
return mounted;
|
return mounted;
|
||||||
}
|
}
|
||||||
@ -256,39 +268,49 @@ bool ChangeInterface(int method, bool silent)
|
|||||||
* Browse subdirectories
|
* Browse subdirectories
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
int
|
int
|
||||||
ParseDirectory()
|
ParseDirectory(int method)
|
||||||
{
|
{
|
||||||
DIR_ITER *dir;
|
DIR_ITER *dir = NULL;
|
||||||
char fulldir[MAXPATHLEN];
|
char fulldir[MAXPATHLEN];
|
||||||
char filename[MAXPATHLEN];
|
char filename[MAXPATHLEN];
|
||||||
char tmpname[MAXPATHLEN];
|
char tmpname[MAXPATHLEN];
|
||||||
struct stat filestat;
|
struct stat filestat;
|
||||||
char msg[128];
|
char msg[128];
|
||||||
|
int retry = 1;
|
||||||
|
bool mounted = false;
|
||||||
|
|
||||||
// reset browser
|
// reset browser
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
|
|
||||||
// add device to path
|
ShowAction("Loading...");
|
||||||
sprintf(fulldir, "%s%s", rootdir, browser.dir);
|
|
||||||
|
|
||||||
// open the directory
|
// open the directory
|
||||||
dir = diropen(fulldir);
|
while(dir == NULL && retry == 1)
|
||||||
|
{
|
||||||
|
mounted = ChangeInterface(method, NOTSILENT);
|
||||||
|
sprintf(fulldir, "%s%s", rootdir, browser.dir); // add device to path
|
||||||
|
if(mounted) dir = diropen(fulldir);
|
||||||
|
if(dir == NULL)
|
||||||
|
{
|
||||||
|
unmountRequired[method] = true;
|
||||||
|
sprintf(msg, "Error opening %s", fulldir);
|
||||||
|
retry = ErrorPromptRetry(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we can't open the dir, try opening the root dir
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Error opening %s", fulldir);
|
if(ChangeInterface(method, SILENT))
|
||||||
WaitPrompt(msg);
|
{
|
||||||
|
|
||||||
// if we can't open the dir, open root dir
|
|
||||||
sprintf(browser.dir,"/");
|
sprintf(browser.dir,"/");
|
||||||
|
|
||||||
dir = diropen(rootdir);
|
dir = diropen(rootdir);
|
||||||
|
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Error opening %s", rootdir);
|
sprintf(msg, "Error opening %s", rootdir);
|
||||||
WaitPrompt(msg);
|
ErrorPrompt(msg);
|
||||||
return 0;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,8 +326,8 @@ ParseDirectory()
|
|||||||
if(!newBrowserList) // failed to allocate required memory
|
if(!newBrowserList) // failed to allocate required memory
|
||||||
{
|
{
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
WaitPrompt("Out of memory: too many files!");
|
ErrorPrompt("Out of memory: too many files!");
|
||||||
entryNum = 0;
|
entryNum = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -315,9 +337,19 @@ ParseDirectory()
|
|||||||
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||||
|
|
||||||
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
|
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
|
||||||
|
|
||||||
|
if(strcmp(filename,"..") == 0)
|
||||||
|
{
|
||||||
|
sprintf(browserList[entryNum].displayname, "Up One Level");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
StripExt(tmpname, filename); // hide file extension
|
StripExt(tmpname, filename); // hide file extension
|
||||||
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||||
|
}
|
||||||
|
|
||||||
browserList[entryNum].length = filestat.st_size;
|
browserList[entryNum].length = filestat.st_size;
|
||||||
|
browserList[entryNum].mtime = filestat.st_mtime;
|
||||||
browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||||
|
|
||||||
entryNum++;
|
entryNum++;
|
||||||
@ -330,6 +362,9 @@ ParseDirectory()
|
|||||||
// Sort the file list
|
// Sort the file list
|
||||||
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
|
browser.numEntries = entryNum;
|
||||||
return entryNum;
|
return entryNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,8 +375,8 @@ ParseDirectory()
|
|||||||
void
|
void
|
||||||
AllocSaveBuffer ()
|
AllocSaveBuffer ()
|
||||||
{
|
{
|
||||||
if (savebuffer != NULL)
|
while(savebuffer != NULL) // save buffer is in use
|
||||||
free(savebuffer);
|
usleep(50); // wait for it to be free
|
||||||
|
|
||||||
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
||||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||||
@ -382,7 +417,7 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Error opening file");
|
ErrorPrompt("Error opening file");
|
||||||
}
|
}
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
@ -400,9 +435,8 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
char zipbuffer[2048];
|
char zipbuffer[2048];
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
u32 readsize = 0;
|
u32 readsize = 0;
|
||||||
|
char fullpath[MAXPATHLEN];
|
||||||
if(!ChangeInterface(method, NOTSILENT))
|
int retry = 1;
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch(method)
|
switch(method)
|
||||||
{
|
{
|
||||||
@ -421,13 +455,15 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
// since we're loading a file
|
// since we're loading a file
|
||||||
LWP_SuspendThread (devicethread);
|
LWP_SuspendThread (devicethread);
|
||||||
|
|
||||||
// add device to filepath
|
// open the file
|
||||||
char fullpath[1024];
|
while(!size && retry == 1)
|
||||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
{
|
||||||
|
if(ChangeInterface(method, silent))
|
||||||
|
{
|
||||||
|
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||||
file = fopen (fullpath, "rb");
|
file = fopen (fullpath, "rb");
|
||||||
|
|
||||||
if (file > 0)
|
if(file > 0)
|
||||||
{
|
{
|
||||||
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
|
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
|
||||||
{
|
{
|
||||||
@ -452,17 +488,21 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
||||||
|
|
||||||
u32 offset = readsize;
|
u32 offset = readsize;
|
||||||
|
u32 nextread = 0;
|
||||||
while(offset < size)
|
while(offset < size)
|
||||||
{
|
{
|
||||||
|
if(size - offset > 1024*512) nextread = 1024*512;
|
||||||
|
else nextread = size-offset;
|
||||||
ShowProgress ("Loading...", offset, size);
|
ShowProgress ("Loading...", offset, size);
|
||||||
readsize = fread (rbuffer + offset, 1, (1024*512), file); // read in 512K chunks
|
readsize = fread (rbuffer + offset, 1, nextread, file); // read in next chunk
|
||||||
|
|
||||||
if(readsize <= 0 || readsize > (1024*512))
|
if(readsize <= 0 || readsize > nextread)
|
||||||
break; // read failure
|
break; // read failure
|
||||||
|
|
||||||
if(readsize > 0)
|
if(readsize > 0)
|
||||||
offset += readsize;
|
offset += readsize;
|
||||||
}
|
}
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
if(offset != size) // # bytes read doesn't match # expected
|
if(offset != size) // # bytes read doesn't match # expected
|
||||||
size = 0;
|
size = 0;
|
||||||
@ -471,19 +511,28 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
}
|
}
|
||||||
fclose (file);
|
fclose (file);
|
||||||
}
|
}
|
||||||
if(!size && !silent)
|
}
|
||||||
|
if(!size)
|
||||||
|
{
|
||||||
|
if(!silent)
|
||||||
{
|
{
|
||||||
unmountRequired[method] = true;
|
unmountRequired[method] = true;
|
||||||
WaitPrompt("Error loading file!");
|
retry = ErrorPromptRetry("Error loading file!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retry = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
LWP_ResumeThread (devicethread);
|
LWP_ResumeThread (devicethread);
|
||||||
|
CancelAction();
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 LoadFile(char filepath[], int method, bool silent)
|
u32 LoadFile(char * filepath, int method, bool silent)
|
||||||
{
|
{
|
||||||
return LoadFile((char *)savebuffer, filepath, 0, method, silent);
|
return LoadFile((char *)savebuffer, filepath, 0, method, silent);
|
||||||
}
|
}
|
||||||
@ -495,53 +544,59 @@ u32 LoadFile(char filepath[], int method, bool silent)
|
|||||||
u32
|
u32
|
||||||
SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||||
{
|
{
|
||||||
|
char fullpath[MAXPATHLEN];
|
||||||
u32 written = 0;
|
u32 written = 0;
|
||||||
|
int retry = 1;
|
||||||
|
|
||||||
if(!ChangeInterface(method, NOTSILENT))
|
if(datasize == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch(method)
|
ShowAction("Saving...");
|
||||||
|
|
||||||
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
{
|
{
|
||||||
case METHOD_MC_SLOTA:
|
if(method == METHOD_MC_SLOTA)
|
||||||
return SaveMCFile (buffer, CARD_SLOTA, filepath, datasize, silent);
|
return SaveMCFile (buffer, CARD_SLOTA, filepath, datasize, silent);
|
||||||
break;
|
else
|
||||||
case METHOD_MC_SLOTB:
|
|
||||||
return SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
return SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datasize)
|
|
||||||
{
|
|
||||||
// stop checking if devices were removed/inserted
|
// stop checking if devices were removed/inserted
|
||||||
// since we're saving a file
|
// since we're saving a file
|
||||||
LWP_SuspendThread (devicethread);
|
LWP_SuspendThread (devicethread);
|
||||||
|
|
||||||
// add device to filepath
|
while(!written && retry == 1)
|
||||||
char fullpath[1024];
|
{
|
||||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
if(ChangeInterface(method, silent))
|
||||||
|
{
|
||||||
// open file for writing
|
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||||
file = fopen (fullpath, "wb");
|
file = fopen (fullpath, "wb");
|
||||||
|
|
||||||
if (file > 0)
|
if (file > 0)
|
||||||
{
|
{
|
||||||
written = fwrite (savebuffer, 1, datasize, file);
|
written = fwrite (savebuffer, 1, datasize, file);
|
||||||
|
if(written < datasize) written = 0;
|
||||||
fclose (file);
|
fclose (file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(!written && !silent)
|
if(!written)
|
||||||
{
|
{
|
||||||
unmountRequired[method] = true;
|
unmountRequired[method] = true;
|
||||||
WaitPrompt ("Error saving file!");
|
if(!silent)
|
||||||
|
retry = ErrorPromptRetry("Error saving file!");
|
||||||
|
else
|
||||||
|
retry = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
LWP_ResumeThread (devicethread);
|
LWP_ResumeThread (devicethread);
|
||||||
}
|
|
||||||
|
CancelAction();
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 SaveFile(char filepath[], u32 datasize, int method, bool silent)
|
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent)
|
||||||
{
|
{
|
||||||
return SaveFile((char *)savebuffer, filepath, datasize, method, silent);
|
return SaveFile((char *)savebuffer, filepath, datasize, method, silent);
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,14 @@ void InitDeviceThread();
|
|||||||
void MountAllFAT();
|
void MountAllFAT();
|
||||||
void UnmountAllFAT();
|
void UnmountAllFAT();
|
||||||
bool ChangeInterface(int method, bool silent);
|
bool ChangeInterface(int method, bool silent);
|
||||||
int ParseDirectory();
|
int ParseDirectory(int method);
|
||||||
void AllocSaveBuffer();
|
void AllocSaveBuffer();
|
||||||
void FreeSaveBuffer();
|
void FreeSaveBuffer();
|
||||||
u32 LoadFile(char * rbuffer, char *filepath, u32 length, int method, bool silent);
|
u32 LoadFile(char * rbuffer, char *filepath, u32 length, int method, bool silent);
|
||||||
u32 LoadFile(char filepath[], int method, bool silent);
|
u32 LoadFile(char * filepath, int method, bool silent);
|
||||||
u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||||
u32 SaveFile(char * buffer, char *filepath, u32 datasize, int method, bool silent);
|
u32 SaveFile(char * buffer, char *filepath, u32 datasize, int method, bool silent);
|
||||||
u32 SaveFile(char filepath[], u32 datasize, int method, bool silent);
|
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent);
|
||||||
|
|
||||||
extern unsigned char * savebuffer;
|
extern unsigned char * savebuffer;
|
||||||
extern FILE * file;
|
extern FILE * file;
|
||||||
|
@ -20,13 +20,14 @@ extern "C" {
|
|||||||
#include "../sz/7zExtract.h"
|
#include "../sz/7zExtract.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "vba.h"
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
#include "networkop.h"
|
#include "networkop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
#include "vba.h"
|
|
||||||
|
|
||||||
#define ZIPCHUNK 2048
|
#define ZIPCHUNK 2048
|
||||||
|
|
||||||
@ -146,7 +147,7 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
|||||||
res = inflateInit2 (&zs, -MAX_WBITS);
|
res = inflateInit2 (&zs, -MAX_WBITS);
|
||||||
|
|
||||||
if (res != Z_OK)
|
if (res != Z_OK)
|
||||||
return 0;
|
goto done;
|
||||||
|
|
||||||
/*** Set ZipChunk for first pass ***/
|
/*** Set ZipChunk for first pass ***/
|
||||||
zipoffset =
|
zipoffset =
|
||||||
@ -170,8 +171,7 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
|||||||
|
|
||||||
if (res == Z_MEM_ERROR)
|
if (res == Z_MEM_ERROR)
|
||||||
{
|
{
|
||||||
inflateEnd (&zs);
|
goto done;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
have = ZIPCHUNK - zs.avail_out;
|
have = ZIPCHUNK - zs.avail_out;
|
||||||
@ -199,22 +199,19 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(sizeread <= 0)
|
if(sizeread <= 0)
|
||||||
break; // read failure
|
goto done; // read failure
|
||||||
|
|
||||||
ShowProgress ("Loading...", bufferoffset, pkzip.uncompressedSize);
|
ShowProgress ("Loading...", bufferoffset, pkzip.uncompressedSize);
|
||||||
}
|
}
|
||||||
while (res != Z_STREAM_END);
|
while (res != Z_STREAM_END);
|
||||||
|
|
||||||
|
done:
|
||||||
inflateEnd (&zs);
|
inflateEnd (&zs);
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
if (res == Z_STREAM_END)
|
if (res == Z_STREAM_END)
|
||||||
{
|
|
||||||
if (pkzip.uncompressedSize == (u32) bufferoffset)
|
|
||||||
return bufferoffset;
|
|
||||||
else
|
|
||||||
return pkzip.uncompressedSize;
|
return pkzip.uncompressedSize;
|
||||||
}
|
else
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +245,7 @@ GetFirstZipFilename (int method)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Error - Invalid ZIP file!");
|
ErrorPrompt("Error - Invalid ZIP file!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +315,7 @@ Is7ZipFile (char *buffer)
|
|||||||
// display an error message
|
// display an error message
|
||||||
static void SzDisplayError(SZ_RESULT res)
|
static void SzDisplayError(SZ_RESULT res)
|
||||||
{
|
{
|
||||||
WaitPrompt(szerrormsg[(res - 1)]);
|
ErrorPrompt(szerrormsg[(res - 1)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function used by the 7zip SDK to read data from SD/USB/DVD/SMB
|
// function used by the 7zip SDK to read data from SD/USB/DVD/SMB
|
||||||
@ -473,7 +470,7 @@ int SzParse(char * filepath, int method)
|
|||||||
if(!newBrowserList) // failed to allocate required memory
|
if(!newBrowserList) // failed to allocate required memory
|
||||||
{
|
{
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
WaitPrompt("Out of memory: too many files!");
|
ErrorPrompt("Out of memory: too many files!");
|
||||||
nbfiles = 0;
|
nbfiles = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -554,6 +551,8 @@ int SzExtractFile(int i, unsigned char *buffer)
|
|||||||
// close 7Zip archive and free memory
|
// close 7Zip archive and free memory
|
||||||
SzClose();
|
SzClose();
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
// check for errors
|
// check for errors
|
||||||
if(SzRes != SZ_OK)
|
if(SzRes != SZ_OK)
|
||||||
{
|
{
|
||||||
|
@ -40,12 +40,11 @@
|
|||||||
#include <asndlib.h>
|
#include <asndlib.h>
|
||||||
#include "pngu/pngu.h"
|
#include "pngu/pngu.h"
|
||||||
#include "FreeTypeGX.h"
|
#include "FreeTypeGX.h"
|
||||||
#include "snes9xGX.h"
|
#include "vba.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "filelist.h"
|
#include "filelist.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "menu.h"
|
|
||||||
#include "oggplayer.h"
|
#include "oggplayer.h"
|
||||||
|
|
||||||
#define SCROLL_INITIAL_DELAY 20
|
#define SCROLL_INITIAL_DELAY 20
|
||||||
|
@ -13,16 +13,14 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <ogcsys.h>
|
#include <ogcsys.h>
|
||||||
#include <network.h>
|
#include <network.h>
|
||||||
#include <ogc/lwp_watchdog.h>
|
#include <ogc/lwp_watchdog.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
static s32 tcp_socket(void)
|
static s32 tcp_socket(void)
|
||||||
@ -416,6 +414,7 @@ bool http_request(const char *url, FILE * hfile, u8 * buffer,
|
|||||||
ShowProgress("Downloading...", (content_length - bytesLeft),
|
ShowProgress("Downloading...", (content_length - bytesLeft),
|
||||||
content_length);
|
content_length);
|
||||||
}
|
}
|
||||||
|
CancelAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!b || !res)
|
if (!b || !res)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 829 B After Width: | Height: | Size: 843 B |
Binary file not shown.
Before Width: | Height: | Size: 750 B After Width: | Height: | Size: 768 B |
BIN
source/ngc/images/logo.png
Normal file
BIN
source/ngc/images/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
BIN
source/ngc/images/logo_over.png
Normal file
BIN
source/ngc/images/logo_over.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
@ -25,26 +25,29 @@
|
|||||||
#include "gameinput.h"
|
#include "gameinput.h"
|
||||||
#include "vbasupport.h"
|
#include "vbasupport.h"
|
||||||
#include "wiiusbsupport.h"
|
#include "wiiusbsupport.h"
|
||||||
|
#include "gui/gui.h"
|
||||||
#include "gba/GBA.h"
|
#include "gba/GBA.h"
|
||||||
#include "gba/bios.h"
|
#include "gba/bios.h"
|
||||||
#include "gba/GBAinline.h"
|
#include "gba/GBAinline.h"
|
||||||
|
|
||||||
extern bool InMenu;
|
|
||||||
int rumbleRequest[4] = {0,0,0,0};
|
int rumbleRequest[4] = {0,0,0,0};
|
||||||
|
GuiTrigger userInput[4];
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
static int rumbleCount[4] = {0,0,0,0};
|
static int rumbleCount[4] = {0,0,0,0};
|
||||||
|
#endif
|
||||||
|
|
||||||
bool cartridgeRumble = false;
|
bool cartridgeRumble = false;
|
||||||
int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0;
|
int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0;
|
||||||
|
|
||||||
unsigned int vbapadmap[10]; // VBA controller buttons
|
unsigned int vbapadmap[10]; // VBA controller buttons
|
||||||
unsigned int gcpadmap[10]; // Gamecube controller Padmap
|
u32 btnmap[5][10]; // button mapping
|
||||||
unsigned int wmpadmap[10]; // Wiimote Padmap
|
|
||||||
unsigned int ccpadmap[10]; // Classic Controller Padmap
|
|
||||||
unsigned int ncpadmap[10]; // Nunchuk + wiimote Padmap
|
|
||||||
unsigned int kbpadmap[10]; // Keyboard Padmap
|
|
||||||
|
|
||||||
void ResetControls()
|
void ResetControls()
|
||||||
{
|
{
|
||||||
int i = 0;
|
memset(btnmap, 0, sizeof(btnmap));
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
// VBA controller buttons
|
// VBA controller buttons
|
||||||
// All other pads are mapped to this
|
// All other pads are mapped to this
|
||||||
@ -62,70 +65,72 @@ void ResetControls()
|
|||||||
|
|
||||||
/*** Gamecube controller Padmap ***/
|
/*** Gamecube controller Padmap ***/
|
||||||
i=0;
|
i=0;
|
||||||
gcpadmap[i++] = PAD_BUTTON_B;
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_B;
|
||||||
gcpadmap[i++] = PAD_BUTTON_A;
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_A;
|
||||||
gcpadmap[i++] = PAD_TRIGGER_Z;
|
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_Z;
|
||||||
gcpadmap[i++] = PAD_BUTTON_START;
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_START;
|
||||||
gcpadmap[i++] = PAD_BUTTON_UP;
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_UP;
|
||||||
gcpadmap[i++] = PAD_BUTTON_DOWN;
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_DOWN;
|
||||||
gcpadmap[i++] = PAD_BUTTON_LEFT;
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_LEFT;
|
||||||
gcpadmap[i++] = PAD_BUTTON_RIGHT;
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_RIGHT;
|
||||||
gcpadmap[i++] = PAD_TRIGGER_L;
|
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_L;
|
||||||
gcpadmap[i++] = PAD_TRIGGER_R;
|
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_R;
|
||||||
|
|
||||||
/*** Wiimote Padmap ***/
|
/*** Wiimote Padmap ***/
|
||||||
i=0;
|
i=0;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_1;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_1;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_2;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_2;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_MINUS;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_MINUS;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_PLUS;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_PLUS;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_RIGHT;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_RIGHT;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_LEFT;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_LEFT;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_UP;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_UP;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_DOWN;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_DOWN;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_B;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_B;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_A;
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_A;
|
||||||
|
|
||||||
/*** Classic Controller Padmap ***/
|
/*** Classic Controller Padmap ***/
|
||||||
i=0;
|
i=0;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_Y;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_Y;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_B;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_B;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_UP;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_UP;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_FULL_R;
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_R;
|
||||||
|
|
||||||
/*** Nunchuk + wiimote Padmap ***/
|
/*** Nunchuk + wiimote Padmap ***/
|
||||||
i=0;
|
i=0;
|
||||||
ncpadmap[i++] = WPAD_NUNCHUK_BUTTON_C;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_C;
|
||||||
ncpadmap[i++] = WPAD_NUNCHUK_BUTTON_Z;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_Z;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_MINUS;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_MINUS;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_PLUS;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_PLUS;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_UP;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_UP;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_DOWN;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_DOWN;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_LEFT;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_LEFT;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_RIGHT;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_RIGHT;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_2;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_2;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_1;
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_1;
|
||||||
|
|
||||||
/*** Keyboard map ***/
|
/*** Keyboard map ***/
|
||||||
i=0;
|
i=0;
|
||||||
kbpadmap[i++] = KB_X; // VBA stupidly has B on the right instead of left
|
btnmap[CTRLR_KEYBOARD][i++] = KB_X; // VBA stupidly has B on the right instead of left
|
||||||
kbpadmap[i++] = KB_Z;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_Z;
|
||||||
kbpadmap[i++] = KB_BKSP;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_BKSP;
|
||||||
kbpadmap[i++] = KB_ENTER;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_ENTER;
|
||||||
kbpadmap[i++] = KB_UP;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_UP;
|
||||||
kbpadmap[i++] = KB_DOWN;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_DOWN;
|
||||||
kbpadmap[i++] = KB_LEFT;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_LEFT;
|
||||||
kbpadmap[i++] = KB_RIGHT;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_RIGHT;
|
||||||
kbpadmap[i++] = KB_A;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_A;
|
||||||
kbpadmap[i++] = KB_S;
|
btnmap[CTRLR_KEYBOARD][i++] = KB_S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ShutoffRumble
|
* ShutoffRumble
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -136,6 +141,7 @@ void ShutoffRumble()
|
|||||||
for(int i=0;i<4;i++)
|
for(int i=0;i<4;i++)
|
||||||
{
|
{
|
||||||
WPAD_Rumble(i, 0);
|
WPAD_Rumble(i, 0);
|
||||||
|
rumbleCount[i] = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
PAD_ControlMotor(PAD_CHAN0, PAD_MOTOR_STOP);
|
PAD_ControlMotor(PAD_CHAN0, PAD_MOTOR_STOP);
|
||||||
@ -164,10 +170,12 @@ void DoRumble(int i)
|
|||||||
WPAD_Rumble(i, 0); // rumble off
|
WPAD_Rumble(i, 0); // rumble off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void updateRumble() {
|
static void updateRumble()
|
||||||
|
{
|
||||||
bool r = false;
|
bool r = false;
|
||||||
if (InMenu) r = (menuRumbleCount > 0);
|
if (ConfigRequested) r = (menuRumbleCount > 0);
|
||||||
else r = cartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0);
|
else r = cartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0);
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
@ -187,7 +195,7 @@ void updateRumbleFrame() {
|
|||||||
if (rumbleCountAlready > 50+10)
|
if (rumbleCountAlready > 50+10)
|
||||||
rumbleCountAlready = 0;
|
rumbleCountAlready = 0;
|
||||||
else rumbleCountAlready++;
|
else rumbleCountAlready++;
|
||||||
} else if (InMenu) {
|
} else if (ConfigRequested) {
|
||||||
if (menuRumbleCount>0)
|
if (menuRumbleCount>0)
|
||||||
rumbleCountAlready++;
|
rumbleCountAlready++;
|
||||||
} else {
|
} else {
|
||||||
@ -195,7 +203,7 @@ void updateRumbleFrame() {
|
|||||||
rumbleCountAlready++;
|
rumbleCountAlready++;
|
||||||
}
|
}
|
||||||
updateRumble();
|
updateRumble();
|
||||||
if (gameRumbleCount>0 && !InMenu) gameRumbleCount--;
|
if (gameRumbleCount>0 && !ConfigRequested) gameRumbleCount--;
|
||||||
if (menuRumbleCount>0) menuRumbleCount--;
|
if (menuRumbleCount>0) menuRumbleCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +584,7 @@ u32 DecodeKeyboard(unsigned short pad)
|
|||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
for (int i = 0; i < MAXJP; i++)
|
for (int i = 0; i < MAXJP; i++)
|
||||||
{
|
{
|
||||||
if (DownUsbKeys[kbpadmap[i]]) // keyboard
|
if (DownUsbKeys[btnmap[CTRLR_KEYBOARD][i]]) // keyboard
|
||||||
J |= vbapadmap[i];
|
J |= vbapadmap[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -589,7 +597,7 @@ u32 DecodeGamecube(unsigned short pad)
|
|||||||
u32 jp = PAD_ButtonsHeld(pad);
|
u32 jp = PAD_ButtonsHeld(pad);
|
||||||
for (int i = 0; i < MAXJP; i++)
|
for (int i = 0; i < MAXJP; i++)
|
||||||
{
|
{
|
||||||
if (jp & gcpadmap[i])
|
if (jp & btnmap[CTRLR_GCPAD][i])
|
||||||
J |= vbapadmap[i];
|
J |= vbapadmap[i];
|
||||||
}
|
}
|
||||||
return J;
|
return J;
|
||||||
@ -602,7 +610,7 @@ u32 DecodeWiimote(unsigned short pad)
|
|||||||
WPADData * wp = WPAD_Data(pad);
|
WPADData * wp = WPAD_Data(pad);
|
||||||
for (int i = 0; i < MAXJP; i++)
|
for (int i = 0; i < MAXJP; i++)
|
||||||
{
|
{
|
||||||
if ( (wp->exp.type == WPAD_EXP_NONE) && (wp->btns_h & wmpadmap[i]) )
|
if ( (wp->exp.type == WPAD_EXP_NONE) && (wp->btns_h & btnmap[CTRLR_WIIMOTE][i]) )
|
||||||
J |= vbapadmap[i];
|
J |= vbapadmap[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -616,7 +624,7 @@ u32 DecodeClassic(unsigned short pad)
|
|||||||
WPADData * wp = WPAD_Data(pad);
|
WPADData * wp = WPAD_Data(pad);
|
||||||
for (int i = 0; i < MAXJP; i++)
|
for (int i = 0; i < MAXJP; i++)
|
||||||
{
|
{
|
||||||
if ( (wp->exp.type == WPAD_EXP_CLASSIC) && (wp->btns_h & ccpadmap[i]) )
|
if ( (wp->exp.type == WPAD_EXP_CLASSIC) && (wp->btns_h & btnmap[CTRLR_CLASSIC][i]) )
|
||||||
J |= vbapadmap[i];
|
J |= vbapadmap[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -630,7 +638,7 @@ u32 DecodeNunchuk(unsigned short pad)
|
|||||||
WPADData * wp = WPAD_Data(pad);
|
WPADData * wp = WPAD_Data(pad);
|
||||||
for (int i = 0; i < MAXJP; i++)
|
for (int i = 0; i < MAXJP; i++)
|
||||||
{
|
{
|
||||||
if ( (wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & ncpadmap[i]) )
|
if ( (wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & btnmap[CTRLR_NUNCHUK][i]) )
|
||||||
J |= vbapadmap[i];
|
J |= vbapadmap[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -859,12 +867,12 @@ static u32 DecodeJoy(unsigned short pad)
|
|||||||
|
|
||||||
for (i = 0; i < MAXJP; i++)
|
for (i = 0; i < MAXJP; i++)
|
||||||
{
|
{
|
||||||
if ((jp & gcpadmap[i]) // gamecube controller
|
if ((jp & btnmap[CTRLR_GCPAD][i]) // gamecube controller
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
|| ( (wp->exp.type == WPAD_EXP_NONE) && (wp->btns_h & wmpadmap[i]) ) // wiimote
|
|| ( (wp->exp.type == WPAD_EXP_NONE) && (wp->btns_h & btnmap[CTRLR_WIIMOTE][i]) ) // wiimote
|
||||||
|| ( (wp->exp.type == WPAD_EXP_CLASSIC) && (wp->btns_h & ccpadmap[i]) ) // classic controller
|
|| ( (wp->exp.type == WPAD_EXP_CLASSIC) && (wp->btns_h & btnmap[CTRLR_CLASSIC][i]) ) // classic controller
|
||||||
|| ( (wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & ncpadmap[i]) ) // nunchuk + wiimote
|
|| ( (wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & btnmap[CTRLR_NUNCHUK][i]) ) // nunchuk + wiimote
|
||||||
|| ( (DownUsbKeys[kbpadmap[i]]) ) // keyboard
|
|| ( (DownUsbKeys[btnmap[CTRLR_KEYBOARD][i]]) ) // keyboard
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
J |= vbapadmap[i];
|
J |= vbapadmap[i];
|
||||||
@ -878,24 +886,11 @@ u32 GetJoy(int pad)
|
|||||||
pad = 0;
|
pad = 0;
|
||||||
|
|
||||||
s8 gc_px = PAD_SubStickX(0);
|
s8 gc_px = PAD_SubStickX(0);
|
||||||
s8 gc_py = PAD_SubStickY(0);
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
s8 wm_sy = WPAD_Stick (0,1,1);
|
u32 wm_pb = WPAD_ButtonsDown(0); // wiimote / expansion button info
|
||||||
u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote / expansion button info
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check for video zoom
|
|
||||||
if (GCSettings.Zoom)
|
|
||||||
{
|
|
||||||
if (gc_py < -36 || gc_py > 36)
|
|
||||||
zoom((float) gc_py / -36);
|
|
||||||
#ifdef HW_RVL
|
|
||||||
if (wm_sy < -36 || wm_sy> 36)
|
|
||||||
zoom ((float) wm_sy / -36);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// request to go back to menu
|
// request to go back to menu
|
||||||
if ((gc_px < -70)
|
if ((gc_px < -70)
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
|
@ -12,10 +12,11 @@
|
|||||||
#define _INPUT_H_
|
#define _INPUT_H_
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
|
#include <wiiuse/wpad.h>
|
||||||
|
|
||||||
#define PI 3.14159265f
|
#define PI 3.14159265f
|
||||||
#define PADCAL 50
|
#define PADCAL 50
|
||||||
#define MAXJP 10
|
#define MAXJP 10 // # of mappable controller buttons
|
||||||
|
|
||||||
#define VBA_BUTTON_A 1
|
#define VBA_BUTTON_A 1
|
||||||
#define VBA_BUTTON_B 2
|
#define VBA_BUTTON_B 2
|
||||||
@ -30,13 +31,48 @@
|
|||||||
#define VBA_SPEED 1024
|
#define VBA_SPEED 1024
|
||||||
#define VBA_CAPTURE 2048
|
#define VBA_CAPTURE 2048
|
||||||
|
|
||||||
extern int rumbleRequest[4];
|
enum
|
||||||
|
{
|
||||||
|
TRIGGER_SIMPLE,
|
||||||
|
TRIGGER_BUTTON_ONLY,
|
||||||
|
TRIGGER_BUTTON_ONLY_IN_FOCUS
|
||||||
|
};
|
||||||
|
|
||||||
extern unsigned int gcpadmap[];
|
typedef struct _paddata {
|
||||||
extern unsigned int wmpadmap[];
|
u16 btns_d;
|
||||||
extern unsigned int ccpadmap[];
|
u16 btns_u;
|
||||||
extern unsigned int ncpadmap[];
|
u16 btns_h;
|
||||||
extern unsigned int kbpadmap[];
|
s8 stickX;
|
||||||
|
s8 stickY;
|
||||||
|
s8 substickX;
|
||||||
|
s8 substickY;
|
||||||
|
u8 triggerL;
|
||||||
|
u8 triggerR;
|
||||||
|
} PADData;
|
||||||
|
|
||||||
|
class GuiTrigger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiTrigger();
|
||||||
|
~GuiTrigger();
|
||||||
|
void SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||||
|
void SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||||
|
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||||
|
s8 WPAD_Stick(u8 right, int axis);
|
||||||
|
bool Left();
|
||||||
|
bool Right();
|
||||||
|
bool Up();
|
||||||
|
bool Down();
|
||||||
|
|
||||||
|
u8 type;
|
||||||
|
s32 chan;
|
||||||
|
WPADData wpad;
|
||||||
|
PADData pad;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern GuiTrigger userInput[4];
|
||||||
|
extern int rumbleRequest[4];
|
||||||
|
extern u32 btnmap[5][10];
|
||||||
|
|
||||||
void ResetControls();
|
void ResetControls();
|
||||||
void ShutoffRumble();
|
void ShutoffRumble();
|
||||||
|
@ -15,104 +15,133 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "system.h"
|
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "menudraw.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
|
#include "dvd.h"
|
||||||
|
#include "images/saveicon.h"
|
||||||
|
|
||||||
|
static u8 * SysArea = NULL;
|
||||||
|
static char savecomments[2][32];
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* CardFileExists
|
* MountMC
|
||||||
*
|
|
||||||
* Wrapper to search through the files on the card.
|
|
||||||
* Returns TRUE if found.
|
|
||||||
***************************************************************************/
|
|
||||||
static int
|
|
||||||
CardFileExists (char *filename, int slot)
|
|
||||||
{
|
|
||||||
card_dir CardDir;
|
|
||||||
int CardError;
|
|
||||||
|
|
||||||
CardError = CARD_FindFirst (slot, &CardDir, TRUE);
|
|
||||||
while (CardError != CARD_ERROR_NOFILE)
|
|
||||||
{
|
|
||||||
CardError = CARD_FindNext (&CardDir);
|
|
||||||
|
|
||||||
if (strcmp ((char *) CardDir.filename, filename) == 0)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* MountCard
|
|
||||||
*
|
*
|
||||||
* Mounts the memory card in the given slot.
|
* Mounts the memory card in the given slot.
|
||||||
* Returns the result of the last attempted CARD_Mount command.
|
* Returns the result of the last attempted CARD_Mount command.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
static int MountCard(int cslot, bool silent, u8 * SysArea)
|
static int MountMC(int slot, bool silent)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
|
|
||||||
|
// Initialize Card System
|
||||||
|
SysArea = (u8 *)memalign(32, CARD_WORKAREA);
|
||||||
|
memset (SysArea, 0, CARD_WORKAREA);
|
||||||
|
CARD_Init ("VBA0", "00");
|
||||||
|
|
||||||
// Mount the card
|
// Mount the card
|
||||||
while ( tries < 10 && ret != 0)
|
while(tries < 10 && ret != 0)
|
||||||
{
|
{
|
||||||
EXI_ProbeReset ();
|
EXI_ProbeReset();
|
||||||
ret = CARD_Mount (cslot, &SysArea, NULL);
|
ret = CARD_Mount (slot, SysArea, NULL);
|
||||||
updateRumbleFrame ();
|
VIDEO_WaitVSync();
|
||||||
VIDEO_WaitVSync ();
|
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ret != 0 && !silent)
|
||||||
|
{
|
||||||
|
if (slot == CARD_SLOTA)
|
||||||
|
ErrorPrompt("Unable to mount Slot A Memory Card!");
|
||||||
|
else
|
||||||
|
ErrorPrompt("Unable to mount Slot B Memory Card!");
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* TestCard
|
* TestMC
|
||||||
*
|
*
|
||||||
* Checks to see if a card is in the card slot specified
|
* Checks to see if a card is in the card slot specified
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
bool TestCard(int slot, bool silent)
|
bool TestMC(int slot, bool silent)
|
||||||
{
|
{
|
||||||
// Memory Cards do not work in Wii mode - disable
|
// Memory Cards do not work in Wii mode - disable
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*** Initialize Card System ***/
|
bool ret = false;
|
||||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
|
||||||
memset (SysArea, 0, CARD_WORKAREA);
|
|
||||||
CARD_Init ("VBA0", "00");
|
|
||||||
|
|
||||||
/*** Try to mount the card ***/
|
// Try to mount the card
|
||||||
if (MountCard(slot, silent, (u8 *)SysArea) == 0)
|
if (MountMC(slot, silent) == 0)
|
||||||
{
|
{
|
||||||
// Mount successful!
|
// Mount successful!
|
||||||
if(!silent)
|
|
||||||
{
|
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Mounted Slot A Memory Card!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Mounted Slot B Memory Card!");
|
|
||||||
}
|
|
||||||
CARD_Unmount (slot);
|
CARD_Unmount (slot);
|
||||||
return true;
|
ret = true;
|
||||||
|
}
|
||||||
|
free(SysArea);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ParseMCDirectory
|
||||||
|
*
|
||||||
|
* Parses a list of all files on the specified memory card
|
||||||
|
***************************************************************************/
|
||||||
|
int
|
||||||
|
ParseMCDirectory (int slot)
|
||||||
|
{
|
||||||
|
card_dir CardDir;
|
||||||
|
int CardError;
|
||||||
|
int entryNum = 0;
|
||||||
|
char tmpname[MAXPATHLEN];
|
||||||
|
|
||||||
|
// Try to mount the card
|
||||||
|
CardError = MountMC(slot, NOTSILENT);
|
||||||
|
|
||||||
|
if (CardError == 0)
|
||||||
|
{
|
||||||
|
CardError = CARD_FindFirst (slot, &CardDir, TRUE);
|
||||||
|
while (CardError != CARD_ERROR_NOFILE)
|
||||||
|
{
|
||||||
|
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (entryNum+1) * sizeof(BROWSERENTRY));
|
||||||
|
|
||||||
|
if(!newBrowserList) // failed to allocate required memory
|
||||||
|
{
|
||||||
|
ResetBrowser();
|
||||||
|
ErrorPrompt("Out of memory: too many files!");
|
||||||
|
entryNum = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!silent)
|
browserList = newBrowserList;
|
||||||
{
|
}
|
||||||
if (slot == CARD_SLOTA)
|
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
|
||||||
else
|
strncpy(browserList[entryNum].filename, (char *)CardDir.filename, MAXJOLIET);
|
||||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
StripExt(tmpname, (char *)CardDir.filename); // hide file extension
|
||||||
|
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||||
|
browserList[entryNum].length = CardDir.filelen;
|
||||||
|
|
||||||
|
entryNum++;
|
||||||
|
|
||||||
|
CardError = CARD_FindNext (&CardDir);
|
||||||
|
}
|
||||||
|
CARD_Unmount(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
// Sort the file list
|
||||||
}
|
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
|
browser.numEntries = entryNum;
|
||||||
|
return entryNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -122,37 +151,27 @@ static int
|
|||||||
VerifyMCFile (char *buf, int slot, char *filename, int datasize)
|
VerifyMCFile (char *buf, int slot, char *filename, int datasize)
|
||||||
{
|
{
|
||||||
card_file CardFile;
|
card_file CardFile;
|
||||||
unsigned char verifbuffer[65536] ATTRIBUTE_ALIGN (32);
|
unsigned char verifybuffer[65536] ATTRIBUTE_ALIGN (32);
|
||||||
int CardError;
|
int CardError;
|
||||||
unsigned int blocks;
|
unsigned int blocks;
|
||||||
unsigned int SectorSize;
|
unsigned int SectorSize;
|
||||||
char msg[80];
|
|
||||||
int bytesleft = 0;
|
int bytesleft = 0;
|
||||||
int bytesread = 0;
|
int bytesread = 0;
|
||||||
|
|
||||||
/*** Initialize Card System ***/
|
memset (verifybuffer, 0, 65536);
|
||||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
|
||||||
memset (SysArea, 0, CARD_WORKAREA);
|
|
||||||
CARD_Init ("VBA0", "00");
|
|
||||||
|
|
||||||
/*** Try to mount the card ***/
|
// Get Sector Size
|
||||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
|
||||||
|
|
||||||
if (CardError == 0)
|
|
||||||
{
|
|
||||||
/*** Get Sector Size ***/
|
|
||||||
CARD_GetSectorSize (slot, &SectorSize);
|
CARD_GetSectorSize (slot, &SectorSize);
|
||||||
|
|
||||||
if (!CardFileExists (filename, slot))
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Unable to open file for verify!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset (&CardFile, 0, sizeof (CardFile));
|
memset (&CardFile, 0, sizeof (CardFile));
|
||||||
CardError = CARD_Open (slot, filename, &CardFile);
|
CardError = CARD_Open (slot, filename, &CardFile);
|
||||||
|
|
||||||
|
if(CardError)
|
||||||
|
{
|
||||||
|
ErrorPrompt("Unable to open file!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
blocks = CardFile.len;
|
blocks = CardFile.len;
|
||||||
|
|
||||||
if (blocks < SectorSize)
|
if (blocks < SectorSize)
|
||||||
@ -164,38 +183,26 @@ VerifyMCFile (char *buf, int slot, char *filename, int datasize)
|
|||||||
if (blocks > (unsigned int)datasize)
|
if (blocks > (unsigned int)datasize)
|
||||||
blocks = datasize;
|
blocks = datasize;
|
||||||
|
|
||||||
memset (verifbuffer, 0, 65536);
|
|
||||||
bytesleft = blocks;
|
bytesleft = blocks;
|
||||||
bytesread = 0;
|
bytesread = 0;
|
||||||
while (bytesleft > 0)
|
while (bytesleft > 0)
|
||||||
{
|
{
|
||||||
CARD_Read (&CardFile, verifbuffer, SectorSize, bytesread);
|
CardError = CARD_Read (&CardFile, verifybuffer, SectorSize, bytesread);
|
||||||
if ( memcmp (buf + bytesread, verifbuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
|
if (CardError || memcmp (buf + bytesread, verifybuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
|
||||||
{
|
{
|
||||||
CARD_Close (&CardFile);
|
bytesread = 0;
|
||||||
CARD_Unmount (slot);
|
ErrorPrompt("File integrity could not be verified!");
|
||||||
WaitPrompt("File did not verify!");
|
break;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bytesleft -= SectorSize;
|
bytesleft -= SectorSize;
|
||||||
bytesread += SectorSize;
|
bytesread += SectorSize;
|
||||||
|
ShowProgress ("Verifying...", bytesread, blocks);
|
||||||
sprintf (msg, "Verified %d of %d bytes", bytesread, blocks);
|
|
||||||
ShowProgress (msg, bytesread, blocks);
|
|
||||||
}
|
}
|
||||||
CARD_Close (&CardFile);
|
CARD_Close (&CardFile);
|
||||||
CARD_Unmount (slot);
|
CancelAction();
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else
|
return bytesread;
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -212,29 +219,24 @@ LoadMCFile (char *buf, int slot, char *filename, bool silent)
|
|||||||
int bytesleft = 0;
|
int bytesleft = 0;
|
||||||
int bytesread = 0;
|
int bytesread = 0;
|
||||||
|
|
||||||
/*** Initialize Card System ***/
|
// Try to mount the card
|
||||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
CardError = MountMC(slot, NOTSILENT);
|
||||||
memset (SysArea, 0, CARD_WORKAREA);
|
|
||||||
CARD_Init ("VBA0", "00");
|
|
||||||
|
|
||||||
/*** Try to mount the card ***/
|
|
||||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
|
||||||
|
|
||||||
if (CardError == 0)
|
if (CardError == 0)
|
||||||
{
|
{
|
||||||
/*** Get Sector Size ***/
|
// Get Sector Size
|
||||||
CARD_GetSectorSize (slot, &SectorSize);
|
CARD_GetSectorSize (slot, &SectorSize);
|
||||||
|
|
||||||
if (!CardFileExists (filename, slot))
|
|
||||||
{
|
|
||||||
if (!silent)
|
|
||||||
WaitPrompt("Unable to open file");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset (&CardFile, 0, sizeof (CardFile));
|
memset (&CardFile, 0, sizeof (CardFile));
|
||||||
CardError = CARD_Open (slot, filename, &CardFile);
|
CardError = CARD_Open (slot, filename, &CardFile);
|
||||||
|
|
||||||
|
if(CardError)
|
||||||
|
{
|
||||||
|
if(!silent)
|
||||||
|
ErrorPrompt("Unable to open file!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
blocks = CardFile.len;
|
blocks = CardFile.len;
|
||||||
|
|
||||||
if (blocks < SectorSize)
|
if (blocks < SectorSize)
|
||||||
@ -243,25 +245,34 @@ LoadMCFile (char *buf, int slot, char *filename, bool silent)
|
|||||||
if (blocks % SectorSize)
|
if (blocks % SectorSize)
|
||||||
blocks += SectorSize;
|
blocks += SectorSize;
|
||||||
|
|
||||||
memset (buf, 0, 0x22000);
|
|
||||||
|
|
||||||
bytesleft = blocks;
|
bytesleft = blocks;
|
||||||
bytesread = 0;
|
bytesread = 0;
|
||||||
while (bytesleft > 0)
|
while (bytesleft > 0)
|
||||||
{
|
{
|
||||||
CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
|
CardError = CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
|
||||||
|
|
||||||
|
if(CardError)
|
||||||
|
{
|
||||||
|
ErrorPrompt("Error loading file!");
|
||||||
|
bytesread = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
bytesleft -= SectorSize;
|
bytesleft -= SectorSize;
|
||||||
bytesread += SectorSize;
|
bytesread += SectorSize;
|
||||||
|
ShowProgress ("Loading...", bytesread, blocks);
|
||||||
}
|
}
|
||||||
CARD_Close (&CardFile);
|
CARD_Close (&CardFile);
|
||||||
CARD_Unmount (slot);
|
CancelAction();
|
||||||
|
}
|
||||||
|
CARD_Unmount(slot);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
|
||||||
|
|
||||||
|
// discard save icon and comments
|
||||||
|
memmove(buf, buf+sizeof(saveicon)+64, bytesread);
|
||||||
|
bytesread -= (sizeof(saveicon)+64);
|
||||||
|
|
||||||
|
free(SysArea);
|
||||||
return bytesread;
|
return bytesread;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,99 +288,59 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
|||||||
int CardError;
|
int CardError;
|
||||||
unsigned int blocks;
|
unsigned int blocks;
|
||||||
unsigned int SectorSize;
|
unsigned int SectorSize;
|
||||||
char msg[80];
|
int byteswritten = 0;
|
||||||
|
int bytesleft = 0;
|
||||||
|
|
||||||
if(datasize <= 0)
|
if(datasize <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*** Initialize Card System ***/
|
// add save icon and comments
|
||||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
memmove(buf+sizeof(saveicon)+64, buf, datasize);
|
||||||
memset (SysArea, 0, CARD_WORKAREA);
|
memcpy(buf, saveicon, sizeof(saveicon));
|
||||||
CARD_Init ("VBA0", "00");
|
memcpy(buf+sizeof(saveicon), savecomments, 64);
|
||||||
|
datasize += (sizeof(saveicon)+64);
|
||||||
|
|
||||||
/*** Try to mount the card ***/
|
// Try to mount the card
|
||||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
CardError = MountMC(slot, NOTSILENT);
|
||||||
|
|
||||||
if (CardError == 0)
|
if (CardError == 0)
|
||||||
{
|
{
|
||||||
/*** Get Sector Size ***/
|
// Get Sector Size
|
||||||
CARD_GetSectorSize (slot, &SectorSize);
|
CARD_GetSectorSize (slot, &SectorSize);
|
||||||
|
|
||||||
/*** Calculate number of blocks required ***/
|
// Calculate number of blocks required
|
||||||
blocks = (datasize / SectorSize) * SectorSize;
|
blocks = (datasize / SectorSize) * SectorSize;
|
||||||
if (datasize % SectorSize)
|
if (datasize % SectorSize)
|
||||||
blocks += SectorSize;
|
blocks += SectorSize;
|
||||||
|
|
||||||
/*** Does this file exist ? ***/
|
// Delete existing file (if present)
|
||||||
if (CardFileExists (filename, slot))
|
memset(&CardStatus, 0, sizeof(card_stat));
|
||||||
{
|
|
||||||
/*** Try to open the file ***/
|
|
||||||
CardError = CARD_Open (slot, filename, &CardFile);
|
CardError = CARD_Open (slot, filename, &CardFile);
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Unable to open card file!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (s32)blocks > CardFile.len ) /*** new data is longer ***/
|
if(CardError == 0)
|
||||||
{
|
{
|
||||||
CARD_Close (&CardFile);
|
CARD_Close (&CardFile);
|
||||||
|
|
||||||
/*** Try to create temp file to check available space ***/
|
|
||||||
CardError = CARD_Create (slot, "TEMPFILESNES9XGX201", blocks, &CardFile);
|
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Not enough space to update file!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Delete the temporary file ***/
|
|
||||||
CARD_Close (&CardFile);
|
|
||||||
CardError = CARD_Delete(slot, "TEMPFILESNES9XGX201");
|
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Unable to delete temporary file!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Delete the existing shorter file ***/
|
|
||||||
CardError = CARD_Delete(slot, filename);
|
CardError = CARD_Delete(slot, filename);
|
||||||
if (CardError)
|
if (CardError)
|
||||||
{
|
{
|
||||||
CARD_Unmount (slot);
|
ErrorPrompt("Unable to delete existing file!");
|
||||||
WaitPrompt("Unable to delete existing file!");
|
goto done;
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Create new, longer file ***/
|
// Create new file
|
||||||
|
memset(&CardStatus, 0, sizeof(card_stat));
|
||||||
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
||||||
if (CardError)
|
if (CardError)
|
||||||
{
|
{
|
||||||
CARD_Unmount (slot);
|
if (CardError == CARD_ERROR_INSSPACE)
|
||||||
WaitPrompt("Unable to create updated card file!");
|
ErrorPrompt("Insufficient space to create file!");
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /*** no file existed, create new one ***/
|
|
||||||
{
|
|
||||||
/*** Create new file ***/
|
|
||||||
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
if ( CardError == CARD_ERROR_INSSPACE )
|
|
||||||
WaitPrompt("Not enough space to create file!");
|
|
||||||
else
|
else
|
||||||
WaitPrompt("Unable to create card file!");
|
ErrorPrompt("Unable to create card file!");
|
||||||
return 0;
|
goto done;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Now, have an open file handle, ready to send out the data ***/
|
// Now, have an open file handle, ready to send out the data
|
||||||
CARD_GetStatus (slot, CardFile.filenum, &CardStatus);
|
CARD_GetStatus (slot, CardFile.filenum, &CardStatus);
|
||||||
CardStatus.icon_addr = 0x0;
|
CardStatus.icon_addr = 0x0;
|
||||||
CardStatus.icon_fmt = 2;
|
CardStatus.icon_fmt = 2;
|
||||||
@ -377,40 +348,43 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
|||||||
CardStatus.comment_addr = 2048;
|
CardStatus.comment_addr = 2048;
|
||||||
CARD_SetStatus (slot, CardFile.filenum, &CardStatus);
|
CARD_SetStatus (slot, CardFile.filenum, &CardStatus);
|
||||||
|
|
||||||
int byteswritten = 0;
|
bytesleft = blocks;
|
||||||
int bytesleft = blocks;
|
|
||||||
while (bytesleft > 0)
|
while (bytesleft > 0)
|
||||||
{
|
{
|
||||||
CardError =
|
CardError =
|
||||||
CARD_Write (&CardFile, buf + byteswritten,
|
CARD_Write (&CardFile, buf + byteswritten, SectorSize, byteswritten);
|
||||||
SectorSize, byteswritten);
|
|
||||||
|
if(CardError)
|
||||||
|
{
|
||||||
|
ErrorPrompt("Error writing file!");
|
||||||
|
byteswritten = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
bytesleft -= SectorSize;
|
bytesleft -= SectorSize;
|
||||||
byteswritten += SectorSize;
|
byteswritten += SectorSize;
|
||||||
|
|
||||||
sprintf (msg, "Wrote %d of %d bytes", byteswritten, blocks);
|
ShowProgress ("Saving...", byteswritten, blocks);
|
||||||
ShowProgress (msg, byteswritten, blocks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CARD_Close (&CardFile);
|
CARD_Close (&CardFile);
|
||||||
CARD_Unmount (slot);
|
CancelAction();
|
||||||
|
|
||||||
if ( GCSettings.VerifySaves )
|
if (byteswritten > 0 && GCSettings.VerifySaves)
|
||||||
{
|
{
|
||||||
/*** Verify the written file, but only up to the length we wrote
|
// Verify the written file
|
||||||
because the file could be longer due to past writes ***/
|
if (!VerifyMCFile (buf, slot, filename, byteswritten) )
|
||||||
if ( VerifyMCFile (buf, slot, filename, byteswritten) )
|
byteswritten = 0;
|
||||||
return byteswritten;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else
|
done:
|
||||||
return byteswritten;
|
CARD_Unmount (slot);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
|
||||||
|
|
||||||
return 0;
|
free(SysArea);
|
||||||
|
return byteswritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMCSaveComments(char comments[2][32])
|
||||||
|
{
|
||||||
|
memcpy(savecomments, comments, 64);
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
* Memory Card routines
|
* Memory Card routines
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef _NGCMCSAVE_
|
#ifndef _MEMCARDOP_
|
||||||
#define _NGCMCSAVE_
|
#define _MEMCARDOP_
|
||||||
|
|
||||||
|
int ParseMCDirectory (int slot);
|
||||||
int LoadMCFile (char *buf, int slot, char *filename, bool silent);
|
int LoadMCFile (char *buf, int slot, char *filename, bool silent);
|
||||||
int SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent);
|
int SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent);
|
||||||
bool TestCard(int slot, bool silent);
|
bool TestMC(int slot, bool silent);
|
||||||
|
void SetMCSaveComments(char comments[2][32]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
3773
source/ngc/menu.cpp
3773
source/ngc/menu.cpp
File diff suppressed because it is too large
Load Diff
@ -9,9 +9,38 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef _NGCMENU_
|
#ifndef _NGCMENU_
|
||||||
|
|
||||||
#define _NGCMENU_
|
#define _NGCMENU_
|
||||||
|
|
||||||
void MainMenu (int selectedMenu);
|
#include <ogcsys.h>
|
||||||
|
#include "gui/gui.h"
|
||||||
|
|
||||||
|
extern GuiImageData * pointer[4];
|
||||||
|
|
||||||
|
void InitGUIThreads();
|
||||||
|
void MainMenu (int menuitem);
|
||||||
|
void ErrorPrompt(const char * msg);
|
||||||
|
int ErrorPromptRetry(const char * msg);
|
||||||
|
void InfoPrompt(const char * msg);
|
||||||
|
void ShowAction (const char *msg);
|
||||||
|
void CancelAction();
|
||||||
|
void ShowProgress (const char *msg, int done, int total);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MENU_EXIT = -1,
|
||||||
|
MENU_NONE,
|
||||||
|
MENU_SETTINGS,
|
||||||
|
MENU_SETTINGS_MAPPINGS,
|
||||||
|
MENU_SETTINGS_MAPPINGS_MAP,
|
||||||
|
MENU_SETTINGS_VIDEO,
|
||||||
|
MENU_SETTINGS_FILE,
|
||||||
|
MENU_SETTINGS_MENU,
|
||||||
|
MENU_SETTINGS_NETWORK,
|
||||||
|
MENU_GAMESELECTION,
|
||||||
|
MENU_GAME,
|
||||||
|
MENU_GAME_SAVE,
|
||||||
|
MENU_GAME_LOAD,
|
||||||
|
MENU_GAME_CHEATS
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,18 +8,20 @@
|
|||||||
* Network and SMB support routines
|
* Network and SMB support routines
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
|
||||||
#include <network.h>
|
#include <network.h>
|
||||||
#include <smb.h>
|
#include <smb.h>
|
||||||
#include <mxml.h>
|
#include <mxml.h>
|
||||||
|
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "miniunz.h"
|
#include "miniunz.h"
|
||||||
|
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
|
static bool inNetworkInit = false;
|
||||||
static bool networkInit = false;
|
static bool networkInit = false;
|
||||||
static bool autoNetworkInit = true;
|
static bool autoNetworkInit = true;
|
||||||
static bool networkShareInit = false;
|
static bool networkShareInit = false;
|
||||||
@ -44,7 +46,7 @@ void UpdateCheck()
|
|||||||
|
|
||||||
snprintf(url, 128, "http://vba-wii.googlecode.com/svn/trunk/update.xml");
|
snprintf(url, 128, "http://vba-wii.googlecode.com/svn/trunk/update.xml");
|
||||||
|
|
||||||
u8 * tmpbuffer = (u8 *)malloc(32768);
|
u8 * tmpbuffer = (u8 *)memalign(32,32768);
|
||||||
memset(tmpbuffer, 0, 32768);
|
memset(tmpbuffer, 0, 32768);
|
||||||
retval = http_request(url, NULL, tmpbuffer, 32768);
|
retval = http_request(url, NULL, tmpbuffer, 32768);
|
||||||
memset(url, 0, 128);
|
memset(url, 0, 128);
|
||||||
@ -64,7 +66,7 @@ void UpdateCheck()
|
|||||||
{
|
{
|
||||||
const char * version = mxmlElementGetAttr(item, "version");
|
const char * version = mxmlElementGetAttr(item, "version");
|
||||||
|
|
||||||
if(version)
|
if(version && strlen(version) == 5)
|
||||||
{
|
{
|
||||||
int verMajor = version[0] - '0';
|
int verMajor = version[0] - '0';
|
||||||
int verMinor = version[2] - '0';
|
int verMinor = version[2] - '0';
|
||||||
@ -78,8 +80,8 @@ void UpdateCheck()
|
|||||||
verMinor >= 0 && verMinor <= 9 &&
|
verMinor >= 0 && verMinor <= 9 &&
|
||||||
verPoint >= 0 && verPoint <= 9) &&
|
verPoint >= 0 && verPoint <= 9) &&
|
||||||
(verMajor > curMajor ||
|
(verMajor > curMajor ||
|
||||||
verMinor > curMinor ||
|
(verMajor == curMajor && verMinor > curMinor) ||
|
||||||
verPoint > curPoint))
|
(verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
|
||||||
{
|
{
|
||||||
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
|
||||||
if(item)
|
if(item)
|
||||||
@ -147,12 +149,12 @@ bool DownloadUpdate()
|
|||||||
if(unzipResult)
|
if(unzipResult)
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
WaitPrompt("Update successful!");
|
InfoPrompt("Update successful!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
WaitPrompt("Update failed!");
|
ErrorPrompt("Update failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFound = false; // updating is finished (successful or not!)
|
updateFound = false; // updating is finished (successful or not!)
|
||||||
@ -178,6 +180,14 @@ void InitializeNetwork(bool silent)
|
|||||||
if(!silent)
|
if(!silent)
|
||||||
ShowAction ("Initializing network...");
|
ShowAction ("Initializing network...");
|
||||||
|
|
||||||
|
while(inNetworkInit) // a network init is already in progress!
|
||||||
|
usleep(50);
|
||||||
|
|
||||||
|
if(networkInit) // check again if the network was inited
|
||||||
|
return;
|
||||||
|
|
||||||
|
inNetworkInit = true;
|
||||||
|
|
||||||
char ip[16];
|
char ip[16];
|
||||||
s32 initResult = if_config(ip, NULL, NULL, true);
|
s32 initResult = if_config(ip, NULL, NULL, true);
|
||||||
|
|
||||||
@ -194,15 +204,18 @@ void InitializeNetwork(bool silent)
|
|||||||
{
|
{
|
||||||
char msg[150];
|
char msg[150];
|
||||||
sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
|
sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
|
||||||
WaitPrompt(msg);
|
ErrorPrompt(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!silent)
|
||||||
|
CancelAction();
|
||||||
|
inNetworkInit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseShare()
|
void CloseShare()
|
||||||
{
|
{
|
||||||
if(networkShareInit)
|
if(networkShareInit)
|
||||||
smbClose("smb:");
|
smbClose("smb");
|
||||||
networkShareInit = false;
|
networkShareInit = false;
|
||||||
networkInit = false; // trigger a network reinit
|
networkInit = false; // trigger a network reinit
|
||||||
}
|
}
|
||||||
@ -243,7 +256,7 @@ ConnectShare (bool silent)
|
|||||||
sprintf(msg, "Share IP is blank.");
|
sprintf(msg, "Share IP is blank.");
|
||||||
|
|
||||||
sprintf(msg2, "Invalid network settings - %s", msg);
|
sprintf(msg2, "Invalid network settings - %s", msg);
|
||||||
WaitPrompt(msg2);
|
ErrorPrompt(msg2);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -266,11 +279,15 @@ ConnectShare (bool silent)
|
|||||||
{
|
{
|
||||||
networkShareInit = true;
|
networkShareInit = true;
|
||||||
}
|
}
|
||||||
|
if(!silent)
|
||||||
|
CancelAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!networkShareInit && !silent)
|
if(!networkShareInit && !silent)
|
||||||
WaitPrompt ("Failed to connect to network share.");
|
ErrorPrompt("Failed to connect to network share.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return networkShareInit;
|
return networkShareInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -15,12 +15,13 @@
|
|||||||
#include <mxml.h>
|
#include <mxml.h>
|
||||||
|
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "images/saveicon.h"
|
#include "vbaconfig.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "button_mapping.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Prepare Preferences Data
|
* Prepare Preferences Data
|
||||||
@ -107,31 +108,12 @@ static const char * XMLSaveCallback(mxml_node_t *node, int where)
|
|||||||
static int
|
static int
|
||||||
preparePrefsData (int method)
|
preparePrefsData (int method)
|
||||||
{
|
{
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
// add save icon and comments for Memory Card saves
|
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
offset = sizeof (saveicon);
|
|
||||||
|
|
||||||
// Copy in save icon
|
|
||||||
memcpy (savebuffer, saveicon, offset);
|
|
||||||
|
|
||||||
// And the comments
|
|
||||||
char prefscomment[2][32];
|
|
||||||
memset(prefscomment, 0, 64);
|
|
||||||
sprintf (prefscomment[0], "%s Prefs", APPNAME);
|
|
||||||
sprintf (prefscomment[1], "Preferences");
|
|
||||||
memcpy (savebuffer + offset, prefscomment, 64);
|
|
||||||
offset += 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml = mxmlNewXML("1.0");
|
xml = mxmlNewXML("1.0");
|
||||||
mxmlSetWrapMargin(0); // disable line wrapping
|
mxmlSetWrapMargin(0); // disable line wrapping
|
||||||
|
|
||||||
data = mxmlNewElement(xml, "file");
|
data = mxmlNewElement(xml, "file");
|
||||||
mxmlElementSetAttr(data, "app",APPNAME);
|
mxmlElementSetAttr(data, "app", APPNAME);
|
||||||
mxmlElementSetAttr(data, "version",APPVERSION);
|
mxmlElementSetAttr(data, "version", APPVERSION);
|
||||||
|
|
||||||
createXMLSection("File", "File Settings");
|
createXMLSection("File", "File Settings");
|
||||||
|
|
||||||
@ -151,23 +133,29 @@ preparePrefsData (int method)
|
|||||||
createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
|
createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
|
||||||
createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);
|
createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);
|
||||||
|
|
||||||
createXMLSection("Emulation", "Emulation Settings");
|
createXMLSection("Video", "Video Settings");
|
||||||
|
|
||||||
createXMLSetting("Zoom", "Zoom On/Off", toStr(GCSettings.Zoom));
|
|
||||||
createXMLSetting("ZoomLevel", "Zoom Level", FtoStr(GCSettings.ZoomLevel));
|
createXMLSetting("ZoomLevel", "Zoom Level", FtoStr(GCSettings.ZoomLevel));
|
||||||
createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
|
createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
|
||||||
createXMLSetting("scaling", "Aspect Ratio Correction", toStr(GCSettings.scaling));
|
createXMLSetting("scaling", "Aspect Ratio Correction", toStr(GCSettings.scaling));
|
||||||
createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
|
createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
|
||||||
createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift));
|
createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift));
|
||||||
|
|
||||||
|
createXMLSection("Menu", "Menu Settings");
|
||||||
|
|
||||||
|
createXMLSetting("WiimoteOrientation", "Wiimote Orientation", toStr(GCSettings.WiimoteOrientation));
|
||||||
|
createXMLSetting("ExitAction", "Exit Action", toStr(GCSettings.ExitAction));
|
||||||
|
createXMLSetting("MusicVolume", "Music Volume", toStr(GCSettings.MusicVolume));
|
||||||
|
createXMLSetting("SFXVolume", "Sound Effects Volume", toStr(GCSettings.SFXVolume));
|
||||||
|
|
||||||
createXMLSection("Controller", "Controller Settings");
|
createXMLSection("Controller", "Controller Settings");
|
||||||
|
|
||||||
createXMLSetting("WiiControls", "Match Wii Game", toStr(GCSettings.WiiControls));
|
createXMLSetting("WiiControls", "Match Wii Game", toStr(GCSettings.WiiControls));
|
||||||
createXMLController(gcpadmap, "gcpadmap", "GameCube Pad");
|
createXMLController(btnmap[CTRLR_GCPAD], "gcpadmap", "GameCube Pad");
|
||||||
createXMLController(wmpadmap, "wmpadmap", "Wiimote");
|
createXMLController(btnmap[CTRLR_WIIMOTE], "wmpadmap", "Wiimote");
|
||||||
createXMLController(ccpadmap, "ccpadmap", "Classic Controller");
|
createXMLController(btnmap[CTRLR_CLASSIC], "ccpadmap", "Classic Controller");
|
||||||
createXMLController(ncpadmap, "ncpadmap", "Nunchuk");
|
createXMLController(btnmap[CTRLR_NUNCHUK], "ncpadmap", "Nunchuk");
|
||||||
createXMLController(kbpadmap, "kbpadmap", "Keyboard");
|
createXMLController(btnmap[CTRLR_KEYBOARD], "kbpadmap", "Keyboard");
|
||||||
|
|
||||||
int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);
|
int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);
|
||||||
|
|
||||||
@ -176,7 +164,6 @@ preparePrefsData (int method)
|
|||||||
return datasize;
|
return datasize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* loadXMLSetting
|
* loadXMLSetting
|
||||||
*
|
*
|
||||||
@ -250,26 +237,19 @@ static bool
|
|||||||
decodePrefsData (int method)
|
decodePrefsData (int method)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
// skip save icon and comments for Memory Card saves
|
xml = mxmlLoadString(NULL, (char *)savebuffer, MXML_TEXT_CALLBACK);
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
offset = sizeof (saveicon);
|
|
||||||
offset += 64; // sizeof comments
|
|
||||||
}
|
|
||||||
|
|
||||||
xml = mxmlLoadString(NULL, (char *)savebuffer+offset, MXML_TEXT_CALLBACK);
|
|
||||||
|
|
||||||
if(xml)
|
if(xml)
|
||||||
{
|
{
|
||||||
// check settings version
|
// check settings version
|
||||||
|
// we don't do anything with the version #, but we'll store it anyway
|
||||||
item = mxmlFindElement(xml, xml, "file", "version", NULL, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "file", "version", NULL, MXML_DESCEND);
|
||||||
if(item) // a version entry exists
|
if(item) // a version entry exists
|
||||||
{
|
{
|
||||||
const char * version = mxmlElementGetAttr(item, "version");
|
const char * version = mxmlElementGetAttr(item, "version");
|
||||||
|
|
||||||
if(version)
|
if(version && strlen(version) == 5)
|
||||||
{
|
{
|
||||||
// this code assumes version in format X.X.X
|
// this code assumes version in format X.X.X
|
||||||
// XX.X.X, X.XX.X, or X.X.XX will NOT work
|
// XX.X.X, X.XX.X, or X.X.XX will NOT work
|
||||||
@ -314,27 +294,32 @@ decodePrefsData (int method)
|
|||||||
loadXMLSetting(GCSettings.smbuser, "smbuser", sizeof(GCSettings.smbuser));
|
loadXMLSetting(GCSettings.smbuser, "smbuser", sizeof(GCSettings.smbuser));
|
||||||
loadXMLSetting(GCSettings.smbpwd, "smbpwd", sizeof(GCSettings.smbpwd));
|
loadXMLSetting(GCSettings.smbpwd, "smbpwd", sizeof(GCSettings.smbpwd));
|
||||||
|
|
||||||
// Emulation Settings
|
// Video Settings
|
||||||
|
|
||||||
loadXMLSetting(&GCSettings.Zoom, "Zoom");
|
|
||||||
loadXMLSetting(&GCSettings.ZoomLevel, "ZoomLevel");
|
loadXMLSetting(&GCSettings.ZoomLevel, "ZoomLevel");
|
||||||
loadXMLSetting(&GCSettings.render, "render");
|
loadXMLSetting(&GCSettings.render, "render");
|
||||||
loadXMLSetting(&GCSettings.scaling, "scaling");
|
loadXMLSetting(&GCSettings.scaling, "scaling");
|
||||||
loadXMLSetting(&GCSettings.xshift, "xshift");
|
loadXMLSetting(&GCSettings.xshift, "xshift");
|
||||||
loadXMLSetting(&GCSettings.yshift, "yshift");
|
loadXMLSetting(&GCSettings.yshift, "yshift");
|
||||||
|
|
||||||
|
// Menu Settings
|
||||||
|
|
||||||
|
loadXMLSetting(&GCSettings.WiimoteOrientation, "WiimoteOrientation");
|
||||||
|
loadXMLSetting(&GCSettings.ExitAction, "ExitAction");
|
||||||
|
loadXMLSetting(&GCSettings.MusicVolume, "MusicVolume");
|
||||||
|
loadXMLSetting(&GCSettings.SFXVolume, "SFXVolume");
|
||||||
|
|
||||||
// Controller Settings
|
// Controller Settings
|
||||||
|
|
||||||
loadXMLSetting(&GCSettings.WiiControls, "WiiControls");
|
loadXMLSetting(&GCSettings.WiiControls, "WiiControls");
|
||||||
loadXMLController(gcpadmap, "gcpadmap");
|
loadXMLController(btnmap[CTRLR_GCPAD], "gcpadmap");
|
||||||
loadXMLController(wmpadmap, "wmpadmap");
|
loadXMLController(btnmap[CTRLR_WIIMOTE], "wmpadmap");
|
||||||
loadXMLController(ccpadmap, "ccpadmap");
|
loadXMLController(btnmap[CTRLR_CLASSIC], "ccpadmap");
|
||||||
loadXMLController(ncpadmap, "ncpadmap");
|
loadXMLController(btnmap[CTRLR_NUNCHUK], "ncpadmap");
|
||||||
loadXMLController(kbpadmap, "kbpadmap");
|
loadXMLController(btnmap[CTRLR_KEYBOARD], "kbpadmap");
|
||||||
}
|
}
|
||||||
mxmlDelete(xml);
|
mxmlDelete(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,23 +337,40 @@ SavePrefs (bool silent)
|
|||||||
// is the method preferences will be loaded from by default
|
// is the method preferences will be loaded from by default
|
||||||
int method = autoSaveMethod(silent);
|
int method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
if(!MakeFilePath(filepath, FILE_PREF, method))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
ShowAction ("Saving preferences...");
|
ShowAction ("Saving preferences...");
|
||||||
|
|
||||||
|
FixInvalidSettings();
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
datasize = preparePrefsData (method);
|
datasize = preparePrefsData (method);
|
||||||
|
|
||||||
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
// Set the comments
|
||||||
|
char prefscomment[2][32];
|
||||||
|
memset(prefscomment, 0, 64);
|
||||||
|
sprintf (prefscomment[0], "%s Prefs", APPNAME);
|
||||||
|
sprintf (prefscomment[1], "Preferences");
|
||||||
|
SetMCSaveComments(prefscomment);
|
||||||
|
}
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, method, silent);
|
offset = SaveFile(filepath, datasize, method, silent);
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
WaitPrompt ("Preferences saved");
|
InfoPrompt("Preferences saved");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -403,20 +405,29 @@ LoadPrefsFromMethod (int method)
|
|||||||
* Load Preferences
|
* Load Preferences
|
||||||
* Checks sources consecutively until we find a preference file
|
* Checks sources consecutively until we find a preference file
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
static bool prefLoaded = false;
|
||||||
|
|
||||||
bool LoadPrefs()
|
bool LoadPrefs()
|
||||||
{
|
{
|
||||||
ShowAction ("Loading preferences...");
|
if(prefLoaded) // already attempted loading
|
||||||
|
return true;
|
||||||
|
|
||||||
bool prefFound = false;
|
bool prefFound = false;
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
if(ChangeInterface(METHOD_SD, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
||||||
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_USB);
|
prefFound = LoadPrefsFromMethod(METHOD_USB);
|
||||||
if(!prefFound && TestCard(CARD_SLOTA, SILENT))
|
if(!prefFound && TestMC(CARD_SLOTA, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTA);
|
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTA);
|
||||||
if(!prefFound && TestCard(CARD_SLOTB, SILENT))
|
if(!prefFound && TestMC(CARD_SLOTB, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTB);
|
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTB);
|
||||||
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_SMB);
|
prefFound = LoadPrefsFromMethod(METHOD_SMB);
|
||||||
|
|
||||||
|
prefLoaded = true; // attempted to load preferences
|
||||||
|
|
||||||
|
if(prefFound)
|
||||||
|
FixInvalidSettings();
|
||||||
|
|
||||||
return prefFound;
|
return prefFound;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "FreeTypeGX.h"
|
||||||
|
|
||||||
#include "gba/Sound.h"
|
#include "gba/Sound.h"
|
||||||
|
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
@ -30,21 +32,21 @@ extern "C" {
|
|||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
#include "networkop.h"
|
#include "networkop.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "menudraw.h"
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "vbaconfig.h"
|
#include "vbaconfig.h"
|
||||||
#include "wiiusbsupport.h"
|
#include "wiiusbsupport.h"
|
||||||
|
|
||||||
extern bool ROMLoaded;
|
|
||||||
extern int emulating;
|
extern int emulating;
|
||||||
bool InMenu = true;
|
|
||||||
int ConfigRequested = 0;
|
int ConfigRequested = 0;
|
||||||
int ShutdownRequested = 0;
|
int ShutdownRequested = 0;
|
||||||
int ResetRequested = 0;
|
int ResetRequested = 0;
|
||||||
|
int ExitRequested = 0;
|
||||||
char appPath[1024];
|
char appPath[1024];
|
||||||
|
FreeTypeGX *fontSystem;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Shutdown / Reboot / Exit
|
* Shutdown / Reboot / Exit
|
||||||
@ -56,9 +58,11 @@ static void ExitCleanup()
|
|||||||
ShutoffRumble();
|
ShutoffRumble();
|
||||||
StopWiiKeyboard();
|
StopWiiKeyboard();
|
||||||
#endif
|
#endif
|
||||||
|
ShutdownAudio();
|
||||||
|
StopGX();
|
||||||
|
|
||||||
LWP_SuspendThread (devicethread);
|
LWP_SuspendThread (devicethread);
|
||||||
UnmountAllFAT();
|
UnmountAllFAT();
|
||||||
CloseShare();
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
DI_Close();
|
DI_Close();
|
||||||
@ -71,27 +75,32 @@ static void ExitCleanup()
|
|||||||
void (*PSOReload) () = (void (*)()) 0x80001800;
|
void (*PSOReload) () = (void (*)()) 0x80001800;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Reboot()
|
void ExitApp()
|
||||||
{
|
{
|
||||||
ExitCleanup();
|
ExitCleanup();
|
||||||
#ifdef HW_RVL
|
|
||||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
|
||||||
#else
|
|
||||||
#define SOFTRESET_ADR ((volatile u32*)0xCC003024)
|
|
||||||
*SOFTRESET_ADR = 0x00000000;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExitToLoader()
|
if(GCSettings.ExitAction == 0) // Exit to Loader
|
||||||
{
|
{
|
||||||
ExitCleanup();
|
|
||||||
// Exit to Loader
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
exit(0);
|
exit(0);
|
||||||
#else // gamecube
|
#else
|
||||||
if (psoid[0] == PSOSDLOADID)
|
if (psoid[0] == PSOSDLOADID)
|
||||||
PSOReload();
|
PSOReload ();
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else if(GCSettings.ExitAction == 1) // Exit to Menu
|
||||||
|
{
|
||||||
|
#ifdef HW_RVL
|
||||||
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||||
|
#else
|
||||||
|
#define SOFTRESET_ADR ((volatile u32*)0xCC003024)
|
||||||
|
*SOFTRESET_ADR = 0x00000000;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else // Shutdown Wii
|
||||||
|
{
|
||||||
|
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
@ -185,13 +194,13 @@ int main(int argc, char *argv[])
|
|||||||
WPAD_Init();
|
WPAD_Init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
InitialiseVideo();
|
InitializeVideo();
|
||||||
ResetVideo_Menu (); // change to menu video mode
|
ResetVideo_Menu (); // change to menu video mode
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
// read wiimote accelerometer and IR data
|
// read wiimote accelerometer and IR data
|
||||||
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
||||||
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
WPAD_SetVRes(WPAD_CHAN_ALL,screenwidth,screenheight);
|
||||||
|
|
||||||
// Wii Power/Reset buttons
|
// Wii Power/Reset buttons
|
||||||
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
|
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
|
||||||
@ -199,30 +208,24 @@ int main(int argc, char *argv[])
|
|||||||
SYS_SetResetCallback(ResetCB);
|
SYS_SetResetCallback(ResetCB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialise freetype font system
|
MountAllFAT(); // Initialize libFAT for SD and USB
|
||||||
if (FT_Init ())
|
|
||||||
{
|
|
||||||
printf ("Cannot initialise font subsystem!\n");
|
|
||||||
while (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize libFAT for SD and USB
|
|
||||||
MountAllFAT();
|
|
||||||
|
|
||||||
// Initialize DVD subsystem (GameCube only)
|
// Initialize DVD subsystem (GameCube only)
|
||||||
#ifdef HW_DOL
|
#ifdef HW_DOL
|
||||||
DVD_Init ();
|
DVD_Init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check if DVD drive belongs to a Wii
|
SetDVDDriveType(); // Check if DVD drive belongs to a Wii
|
||||||
SetDVDDriveType();
|
|
||||||
|
|
||||||
InitialiseSound();
|
InitialiseSound();
|
||||||
|
|
||||||
InitialisePalette();
|
InitialisePalette();
|
||||||
|
DefaultSettings (); // Set defaults
|
||||||
|
|
||||||
// Set defaults
|
// Initialize font system
|
||||||
DefaultSettings ();
|
fontSystem = new FreeTypeGX();
|
||||||
|
fontSystem->loadFont(font_ttf, font_ttf_size, 0);
|
||||||
|
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
|
||||||
|
|
||||||
|
InitGUIThreads();
|
||||||
|
|
||||||
// store path app was loaded from
|
// store path app was loaded from
|
||||||
sprintf(appPath, "vbagx");
|
sprintf(appPath, "vbagx");
|
||||||
@ -231,18 +234,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
StartWiiKeyboardMouse();
|
StartWiiKeyboardMouse();
|
||||||
|
|
||||||
int selectedMenu = -1;
|
|
||||||
|
|
||||||
// Load preferences
|
|
||||||
if(!LoadPrefs())
|
|
||||||
{
|
|
||||||
WaitPrompt("Preferences reset - check settings!");
|
|
||||||
selectedMenu = 2; // change to preferences menu
|
|
||||||
}
|
|
||||||
|
|
||||||
while(1) // main loop
|
while(1) // main loop
|
||||||
{
|
{
|
||||||
InMenu = true;
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
if(ShutdownRequested)
|
if(ShutdownRequested)
|
||||||
ShutdownWii();
|
ShutdownWii();
|
||||||
@ -252,15 +245,22 @@ int main(int argc, char *argv[])
|
|||||||
// since we're entering the menu
|
// since we're entering the menu
|
||||||
LWP_ResumeThread (devicethread);
|
LWP_ResumeThread (devicethread);
|
||||||
|
|
||||||
MainMenu(selectedMenu);
|
ConfigRequested = 1;
|
||||||
selectedMenu = 3; // return to game menu from now on
|
SwitchAudioMode(1);
|
||||||
|
|
||||||
|
if(!ROMLoaded)
|
||||||
|
MainMenu(MENU_GAMESELECTION);
|
||||||
|
else
|
||||||
|
MainMenu(MENU_GAME);
|
||||||
|
|
||||||
|
ConfigRequested = 0;
|
||||||
|
SwitchAudioMode(0);
|
||||||
|
|
||||||
// stop checking if devices were removed/inserted
|
// stop checking if devices were removed/inserted
|
||||||
// since we're starting emulation again
|
// since we're starting emulation again
|
||||||
LWP_SuspendThread (devicethread);
|
LWP_SuspendThread (devicethread);
|
||||||
|
|
||||||
ResetVideo_Emu();
|
ResetVideo_Emu();
|
||||||
InMenu = false;
|
|
||||||
|
|
||||||
while (emulating) // emulation loop
|
while (emulating) // emulation loop
|
||||||
{
|
{
|
||||||
@ -274,30 +274,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(ConfigRequested)
|
if(ConfigRequested)
|
||||||
{
|
{
|
||||||
InMenu = true;
|
TakeScreenshot();
|
||||||
ShutoffRumble();
|
ResetVideo_Menu();
|
||||||
StopAudio();
|
break; // leave emulation loop
|
||||||
ResetVideo_Menu (); // change to menu video mode
|
|
||||||
|
|
||||||
if (GCSettings.AutoSave == 1)
|
|
||||||
{
|
|
||||||
SaveBatteryOrState(GCSettings.SaveMethod, FILE_SRAM, SILENT); // save battery
|
|
||||||
}
|
|
||||||
else if (GCSettings.AutoSave == 2)
|
|
||||||
{
|
|
||||||
SaveBatteryOrState(GCSettings.SaveMethod, FILE_SNAPSHOT, SILENT); // save state
|
|
||||||
}
|
|
||||||
else if(GCSettings.AutoSave == 3)
|
|
||||||
{
|
|
||||||
SaveBatteryOrState(GCSettings.SaveMethod, FILE_SRAM, SILENT); // save battery
|
|
||||||
SaveBatteryOrState(GCSettings.SaveMethod, FILE_SNAPSHOT, SILENT); // save state
|
|
||||||
}
|
|
||||||
|
|
||||||
// save zoom level
|
|
||||||
SavePrefs(SILENT);
|
|
||||||
ConfigRequested = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // emulation loop
|
||||||
|
} // main loop
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
#ifndef _VBAGX_H_
|
#ifndef _VBAGX_H_
|
||||||
#define _VBAGX_H_
|
#define _VBAGX_H_
|
||||||
|
|
||||||
|
#include "FreeTypeGX.h"
|
||||||
|
#include "filelist.h"
|
||||||
|
|
||||||
#define APPNAME "Visual Boy Advance GX"
|
#define APPNAME "Visual Boy Advance GX"
|
||||||
#define APPVERSION "1.0.8"
|
#define APPVERSION "1.0.8"
|
||||||
#define PREF_FILE_NAME "settings.xml"
|
#define PREF_FILE_NAME "settings.xml"
|
||||||
@ -45,29 +48,32 @@ struct SGCSettings{
|
|||||||
char LoadFolder[200]; // Path to game files
|
char LoadFolder[200]; // Path to game files
|
||||||
char SaveFolder[200]; // Path to save files
|
char SaveFolder[200]; // Path to save files
|
||||||
char CheatFolder[200]; // Path to cheat files
|
char CheatFolder[200]; // Path to cheat files
|
||||||
|
int VerifySaves;
|
||||||
|
|
||||||
char smbip[16];
|
char smbip[16];
|
||||||
char smbuser[20];
|
char smbuser[20];
|
||||||
char smbpwd[20];
|
char smbpwd[20];
|
||||||
char smbshare[20];
|
char smbshare[20];
|
||||||
|
|
||||||
int Zoom; // 0 - off, 1 - on
|
|
||||||
float ZoomLevel; // zoom amount
|
float ZoomLevel; // zoom amount
|
||||||
int scaling; // 0 - default, 1 - partial stretch, 2 - stretch to fit, 3 - widescreen correction
|
int scaling; // 0 - default, 1 - partial stretch, 2 - stretch to fit, 3 - widescreen correction
|
||||||
int render; // 0 - original, 1 - filtered, 2 - unfiltered
|
int render; // 0 - original, 1 - filtered, 2 - unfiltered
|
||||||
int VerifySaves;
|
|
||||||
int xshift; // video output shift
|
int xshift; // video output shift
|
||||||
int yshift;
|
int yshift;
|
||||||
int WiiControls; // Match Wii Game
|
int WiiControls; // Match Wii Game
|
||||||
int WiimoteOrientation;
|
int WiimoteOrientation;
|
||||||
|
int ExitAction;
|
||||||
|
int MusicVolume;
|
||||||
|
int SFXVolume;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ExitToLoader();
|
void ExitApp();
|
||||||
void Reboot();
|
|
||||||
void ShutdownWii();
|
void ShutdownWii();
|
||||||
extern struct SGCSettings GCSettings;
|
extern struct SGCSettings GCSettings;
|
||||||
extern int ConfigRequested;
|
extern int ConfigRequested;
|
||||||
extern int ShutdownRequested;
|
extern int ShutdownRequested;
|
||||||
|
extern int ExitRequested;
|
||||||
extern char appPath[];
|
extern char appPath[];
|
||||||
|
extern FreeTypeGX *fontSystem;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,6 +16,33 @@
|
|||||||
|
|
||||||
struct SGCSettings GCSettings;
|
struct SGCSettings GCSettings;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* FixInvalidSettings
|
||||||
|
*
|
||||||
|
* Attempts to correct at least some invalid settings - the ones that
|
||||||
|
* might cause crashes
|
||||||
|
***************************************************************************/
|
||||||
|
void FixInvalidSettings()
|
||||||
|
{
|
||||||
|
if(!(GCSettings.ZoomLevel > 0.5 && GCSettings.ZoomLevel < 1.5))
|
||||||
|
GCSettings.ZoomLevel = 1.0;
|
||||||
|
if(!(GCSettings.xshift > -50 && GCSettings.xshift < 50))
|
||||||
|
GCSettings.xshift = 0;
|
||||||
|
if(!(GCSettings.yshift > -50 && GCSettings.yshift < 50))
|
||||||
|
GCSettings.yshift = 0;
|
||||||
|
if(!(GCSettings.MusicVolume >= 0 && GCSettings.MusicVolume <= 100))
|
||||||
|
GCSettings.MusicVolume = 40;
|
||||||
|
if(!(GCSettings.SFXVolume >= 0 && GCSettings.SFXVolume <= 100))
|
||||||
|
GCSettings.SFXVolume = 40;
|
||||||
|
if(!(GCSettings.render >= 0 && GCSettings.render < 2))
|
||||||
|
GCSettings.render = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* DefaultSettings
|
||||||
|
*
|
||||||
|
* Sets all the defaults!
|
||||||
|
***************************************************************************/
|
||||||
void
|
void
|
||||||
DefaultSettings ()
|
DefaultSettings ()
|
||||||
{
|
{
|
||||||
@ -44,12 +71,16 @@ DefaultSettings ()
|
|||||||
GCSettings.WiimoteOrientation = 0;
|
GCSettings.WiimoteOrientation = 0;
|
||||||
|
|
||||||
GCSettings.VerifySaves = 0;
|
GCSettings.VerifySaves = 0;
|
||||||
GCSettings.Zoom = 0; // zooming default off
|
|
||||||
GCSettings.ZoomLevel = 1.0; // zoom level
|
GCSettings.ZoomLevel = 1.0; // zoom level
|
||||||
GCSettings.render = 1; // Filtered
|
GCSettings.render = 1; // Filtered
|
||||||
GCSettings.scaling = 1; // partial stretch
|
GCSettings.scaling = 1; // partial stretch
|
||||||
GCSettings.WiiControls = true; // Match Wii Game
|
GCSettings.WiiControls = false; // Match Wii Game
|
||||||
|
|
||||||
GCSettings.xshift = 0; // video shift
|
GCSettings.xshift = 0; // horizontal video shift
|
||||||
GCSettings.yshift = 0;
|
GCSettings.yshift = 0; // vertical video shift
|
||||||
|
|
||||||
|
GCSettings.WiimoteOrientation = 0;
|
||||||
|
GCSettings.ExitAction = 0;
|
||||||
|
GCSettings.MusicVolume = 40;
|
||||||
|
GCSettings.SFXVolume = 40;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#define _VBACONFIG_
|
#define _VBACONFIG_
|
||||||
|
|
||||||
|
void FixInvalidSettings();
|
||||||
void DefaultSettings ();
|
void DefaultSettings ();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include "pngu/pngu.h"
|
||||||
|
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "common/Port.h"
|
#include "common/Port.h"
|
||||||
@ -32,6 +34,7 @@
|
|||||||
|
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
@ -39,10 +42,9 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "gameinput.h"
|
#include "gameinput.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
#include "gamesettings.h"
|
#include "gamesettings.h"
|
||||||
#include "images/saveicon.h"
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -251,9 +253,8 @@ int MemCPUWriteBatteryFile(char * membuffer)
|
|||||||
* action = FILE_SNAPSHOT - Load state
|
* action = FILE_SNAPSHOT - Load state
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool LoadBatteryOrState(int method, int action, bool silent)
|
bool LoadBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||||
{
|
{
|
||||||
char filepath[1024];
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
@ -270,15 +271,6 @@ bool LoadBatteryOrState(int method, int action, bool silent)
|
|||||||
// load the file into savebuffer
|
// load the file into savebuffer
|
||||||
offset = LoadFile(filepath, method, silent);
|
offset = LoadFile(filepath, method, silent);
|
||||||
|
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
// skip save icon and comments for Memory Card saves
|
|
||||||
int skip = sizeof (saveicon);
|
|
||||||
skip += 64; // sizeof savecomment
|
|
||||||
memmove(savebuffer, savebuffer+skip, offset-skip);
|
|
||||||
offset -= skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
// load savebuffer into VBA memory
|
// load savebuffer into VBA memory
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
@ -302,21 +294,36 @@ bool LoadBatteryOrState(int method, int action, bool silent)
|
|||||||
if(offset == 0)
|
if(offset == 0)
|
||||||
{
|
{
|
||||||
if(action == FILE_SRAM)
|
if(action == FILE_SRAM)
|
||||||
WaitPrompt ("Save file not found");
|
ErrorPrompt ("Save file not found");
|
||||||
else
|
else
|
||||||
WaitPrompt ("State file not found");
|
ErrorPrompt ("State file not found");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(action == FILE_SRAM)
|
if(action == FILE_SRAM)
|
||||||
WaitPrompt ("Invalid save file");
|
ErrorPrompt ("Invalid save file");
|
||||||
else
|
else
|
||||||
WaitPrompt ("Invalid state file");
|
ErrorPrompt ("Invalid state file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LoadBatteryOrStateAuto(int method, int action, bool silent)
|
||||||
|
{
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char filepath[1024];
|
||||||
|
|
||||||
|
if(!MakeFilePath(filepath, FILE_SNAPSHOT, method, ROMFilename, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return LoadBatteryOrState(filepath, method, action, silent);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* SaveBatteryOrState
|
* SaveBatteryOrState
|
||||||
@ -325,46 +332,34 @@ bool LoadBatteryOrState(int method, int action, bool silent)
|
|||||||
* action = 1 - Save state
|
* action = 1 - Save state
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool SaveBatteryOrState(int method, int action, bool silent)
|
bool SaveBatteryOrState(char * filename, int method, int action, bool silent)
|
||||||
{
|
{
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int datasize = 0; // we need the actual size of the data written
|
int datasize = 0; // we need the actual size of the data written
|
||||||
|
int imgSize = 0; // image screenshot bytes written
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoSaveMethod(silent);
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, action, method))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ShowAction ("Saving...");
|
|
||||||
|
|
||||||
AllocSaveBuffer();
|
AllocSaveBuffer();
|
||||||
|
|
||||||
// add save icon and comments for Memory Card saves
|
// set comments for Memory Card saves
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
{
|
{
|
||||||
char savecomment[2][32];
|
char savecomments[2][32];
|
||||||
memset(savecomment, 0, 64);
|
|
||||||
char savetype[10];
|
char savetype[10];
|
||||||
|
memset(savecomments, 0, 64);
|
||||||
|
|
||||||
offset = sizeof (saveicon);
|
|
||||||
|
|
||||||
// Copy in save icon
|
|
||||||
memcpy (savebuffer, saveicon, offset);
|
|
||||||
|
|
||||||
// And the comments
|
|
||||||
if(action == FILE_SRAM)
|
if(action == FILE_SRAM)
|
||||||
sprintf(savetype, "SRAM");
|
sprintf(savetype, "SRAM");
|
||||||
else
|
else
|
||||||
sprintf(savetype, "Freeze");
|
sprintf(savetype, "Freeze");
|
||||||
|
|
||||||
sprintf (savecomment[0], "%s %s", APPNAME, savetype);
|
sprintf (savecomments[0], "%s %s", APPNAME, savetype);
|
||||||
strncpy(savecomment[1], ROMFilename, 31); // truncate filename to 31 chars
|
snprintf (savecomments[1], 32, ROMFilename);
|
||||||
savecomment[1][31] = 0; // make sure last char is null byte
|
SetMCSaveComments(savecomments);
|
||||||
memcpy (savebuffer + offset, savecomment, 64);
|
|
||||||
offset += 64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// put VBA memory into savebuffer, sets datasize to size of memory written
|
// put VBA memory into savebuffer, sets datasize to size of memory written
|
||||||
@ -423,21 +418,61 @@ bool SaveBatteryOrState(int method, int action, bool silent)
|
|||||||
if(offset > 0)
|
if(offset > 0)
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt ("Save successful");
|
InfoPrompt ("Save successful");
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt("No data to save!");
|
InfoPrompt("No data to save!");
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeSaveBuffer();
|
FreeSaveBuffer();
|
||||||
|
|
||||||
|
// save screenshot - I would prefer to do this from gameScreenTex
|
||||||
|
if(offset > 0 && gameScreenTex2 != NULL && method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
|
IMGCTX pngContext = PNGU_SelectImageFromBuffer(savebuffer);
|
||||||
|
|
||||||
|
if (pngContext != NULL)
|
||||||
|
{
|
||||||
|
imgSize = PNGU_EncodeFromGXTexture(pngContext, 640, 480, gameScreenTex2, 0);
|
||||||
|
PNGU_ReleaseImageContext(pngContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(imgSize > 0)
|
||||||
|
{
|
||||||
|
char screenpath[1024];
|
||||||
|
filepath[strlen(filepath)-4] = 0;
|
||||||
|
sprintf(screenpath, "%s.png", filepath);
|
||||||
|
SaveFile(screenpath, imgSize, method, silent);
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeSaveBuffer ();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SaveBatteryOrStateAuto(int method, int action, bool silent)
|
||||||
|
{
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char filepath[1024];
|
||||||
|
|
||||||
|
if(!MakeFilePath(filepath, FILE_SNAPSHOT, method, ROMFilename, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return SaveBatteryOrState(filepath, method, action, silent);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Sound
|
* Sound
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -877,13 +912,13 @@ bool LoadVBAROM(int method)
|
|||||||
else if(utilIsGBImage(zippedFilename))
|
else if(utilIsGBImage(zippedFilename))
|
||||||
cartridgeType = 1;
|
cartridgeType = 1;
|
||||||
else {
|
else {
|
||||||
WaitPrompt("Rom must be 1st file in zip, or unzipped!");
|
ErrorPrompt("Rom must be 1st file in zip, or unzipped!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // loading the file failed
|
else // loading the file failed
|
||||||
{
|
{
|
||||||
WaitPrompt("Empty or invalid zip file!");
|
ErrorPrompt("Empty or invalid zip file!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -892,7 +927,7 @@ bool LoadVBAROM(int method)
|
|||||||
if(cartridgeType != 1 && cartridgeType != 2)
|
if(cartridgeType != 1 && cartridgeType != 2)
|
||||||
{
|
{
|
||||||
// Not zip gba agb gbc cgb sgb gb mb bin elf or dmg!
|
// Not zip gba agb gbc cgb sgb gb mb bin elf or dmg!
|
||||||
WaitPrompt("Invalid filename extension! Not a rom?");
|
ErrorPrompt("Invalid filename extension! Not a rom?");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,7 +980,7 @@ bool LoadVBAROM(int method)
|
|||||||
|
|
||||||
if(!loaded)
|
if(!loaded)
|
||||||
{
|
{
|
||||||
WaitPrompt("Error loading game!");
|
ErrorPrompt("Error loading game!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -22,7 +22,9 @@ extern bool TiltSideways;
|
|||||||
|
|
||||||
bool LoadVBAROM(int method);
|
bool LoadVBAROM(int method);
|
||||||
void InitialisePalette();
|
void InitialisePalette();
|
||||||
bool LoadBatteryOrState(int method, int action, bool silent);
|
bool LoadBatteryOrState(char * filepath, int method, int action, bool silent);
|
||||||
bool SaveBatteryOrState(int method, int action, bool silent);
|
bool LoadBatteryOrStateAuto(int method, int action, bool silent);
|
||||||
|
bool SaveBatteryOrState(char * filepath, int method, int action, bool silent);
|
||||||
|
bool SaveBatteryOrStateAuto(int method, int action, bool silent);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,21 +6,20 @@
|
|||||||
*
|
*
|
||||||
* video.cpp
|
* video.cpp
|
||||||
*
|
*
|
||||||
* Generic GX Support for Emulators
|
* Video routines
|
||||||
* NGC GX Video Functions
|
|
||||||
* These are pretty standard functions to setup and use GX scaling.
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <unistd.h>
|
#include <ogcsys.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
#include <unistd.h>
|
||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
#include "images/bg.h"
|
|
||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "gui/gui.h"
|
#include "input.h"
|
||||||
|
|
||||||
s32 CursorX, CursorY;
|
s32 CursorX, CursorY;
|
||||||
bool CursorVisible;
|
bool CursorVisible;
|
||||||
@ -28,7 +27,6 @@ bool CursorValid;
|
|||||||
bool TiltScreen = false;
|
bool TiltScreen = false;
|
||||||
float TiltAngle = 0;
|
float TiltAngle = 0;
|
||||||
u32 FrameTimer = 0;
|
u32 FrameTimer = 0;
|
||||||
GuiImageData * pointer1;
|
|
||||||
|
|
||||||
/*** External 2D Video ***/
|
/*** External 2D Video ***/
|
||||||
/*** 2D Video Globals ***/
|
/*** 2D Video Globals ***/
|
||||||
@ -36,6 +34,11 @@ static GXRModeObj *vmode = NULL; // Graphics Mode Object
|
|||||||
unsigned int *xfb[2]; // Framebuffers
|
unsigned int *xfb[2]; // Framebuffers
|
||||||
int whichfb = 0; // Frame buffer toggle
|
int whichfb = 0; // Frame buffer toggle
|
||||||
|
|
||||||
|
static Mtx GXmodelView2D;
|
||||||
|
|
||||||
|
u8 * gameScreenTex = NULL; // a GX texture screen capture of the game
|
||||||
|
u8 * gameScreenTex2 = NULL; // a GX texture screen capture of the game (copy)
|
||||||
|
|
||||||
int screenheight;
|
int screenheight;
|
||||||
int screenwidth;
|
int screenwidth;
|
||||||
|
|
||||||
@ -145,44 +148,6 @@ copy_to_xfb (u32 arg)
|
|||||||
FrameTimer++;
|
FrameTimer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Drawing screen
|
|
||||||
***************************************************************************/
|
|
||||||
void
|
|
||||||
clearscreen ()
|
|
||||||
{
|
|
||||||
// PAL is 640x576 NOT 640x480!
|
|
||||||
// Fill the bottom of the screen with the background's top? left corner
|
|
||||||
int colour = bg[0];
|
|
||||||
|
|
||||||
whichfb ^= 1;
|
|
||||||
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], colour);
|
|
||||||
if (vmode->xfbHeight==480)
|
|
||||||
{
|
|
||||||
memcpy (xfb[whichfb], &bg, 1280 * 480);
|
|
||||||
}
|
|
||||||
else if (vmode->xfbHeight<480)
|
|
||||||
{
|
|
||||||
memcpy (xfb[whichfb], &bg, 1280 * vmode->xfbHeight);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy (xfb[whichfb], &bg, 1280 * 240);
|
|
||||||
for (int i=0; i<vmode->xfbHeight-480; i++)
|
|
||||||
memcpy (((char *)xfb[whichfb])+1280*(240+i), ((char *)&bg)+1280 * 240, 1280 * 1);
|
|
||||||
|
|
||||||
memcpy (((char *)xfb[whichfb])+1280*(vmode->xfbHeight-240), ((char *)&bg)+1280 * 240, 1280 * 240);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
showscreen ()
|
|
||||||
{
|
|
||||||
VIDEO_SetNextFramebuffer (xfb[whichfb]);
|
|
||||||
VIDEO_Flush ();
|
|
||||||
updateRumbleFrame();
|
|
||||||
VIDEO_WaitVSync ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Scaler Support Functions
|
* Scaler Support Functions
|
||||||
@ -201,8 +166,17 @@ static void draw_init(void)
|
|||||||
GX_SetArray (GX_VA_POS, square, 3 * sizeof (s16));
|
GX_SetArray (GX_VA_POS, square, 3 * sizeof (s16));
|
||||||
|
|
||||||
GX_SetNumTexGens (1);
|
GX_SetNumTexGens (1);
|
||||||
|
GX_SetNumChans (0);
|
||||||
|
|
||||||
GX_SetTexCoordGen (GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
GX_SetTexCoordGen (GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
||||||
|
|
||||||
|
GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
|
||||||
|
GX_SetTevOrder (GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
|
||||||
|
|
||||||
|
memset (&view, 0, sizeof (Mtx));
|
||||||
|
guLookAt(view, &cam.pos, &cam.up, &cam.view);
|
||||||
|
GX_LoadPosMtxImm (view, GX_PNMTX0);
|
||||||
|
|
||||||
GX_InvVtxCache (); // update vertex cache
|
GX_InvVtxCache (); // update vertex cache
|
||||||
|
|
||||||
GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565,
|
GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565,
|
||||||
@ -245,12 +219,13 @@ static void draw_square(Mtx v)
|
|||||||
GX_End();
|
GX_End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
static void draw_cursor(Mtx v)
|
static void draw_cursor(Mtx v)
|
||||||
{
|
{
|
||||||
if (!CursorVisible || !CursorValid)
|
if (!CursorVisible || !CursorValid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GX_InitTexObj(&texobj, pointer1->GetImage(), 96, 96, GX_TF_RGBA8,GX_CLAMP, GX_CLAMP,GX_FALSE);
|
GX_InitTexObj(&texobj, pointer[0]->GetImage(), 96, 96, GX_TF_RGBA8,GX_CLAMP, GX_CLAMP,GX_FALSE);
|
||||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
||||||
GX_SetBlendMode(GX_BM_BLEND,GX_BL_DSTALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR);
|
GX_SetBlendMode(GX_BM_BLEND,GX_BL_DSTALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR);
|
||||||
GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
|
GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
|
||||||
@ -294,16 +269,16 @@ static void draw_cursor(Mtx v)
|
|||||||
GX_CLAMP, GX_CLAMP, GX_FALSE);
|
GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||||
if (!(GCSettings.render&1))
|
if (!(GCSettings.render&1))
|
||||||
GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,2.5,9.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); // original/unfiltered video mode: force texture filtering OFF
|
GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,2.5,9.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); // original/unfiltered video mode: force texture filtering OFF
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* StartGX
|
* StartGX
|
||||||
****************************************************************************/
|
*
|
||||||
static void GX_Start()
|
* Initialises GX and sets it up for use
|
||||||
|
***************************************************************************/
|
||||||
|
static void StartGX ()
|
||||||
{
|
{
|
||||||
Mtx44 p;
|
|
||||||
|
|
||||||
GXColor background = { 0, 0, 0, 0xff };
|
GXColor background = { 0, 0, 0, 0xff };
|
||||||
|
|
||||||
/*** Clear out FIFO area ***/
|
/*** Clear out FIFO area ***/
|
||||||
@ -313,27 +288,25 @@ static void GX_Start()
|
|||||||
GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE);
|
GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE);
|
||||||
GX_SetCopyClear (background, 0x00ffffff);
|
GX_SetCopyClear (background, 0x00ffffff);
|
||||||
|
|
||||||
GX_SetViewport (0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1);
|
|
||||||
GX_SetDispCopyYScale ((f32) vmode->xfbHeight / (f32) vmode->efbHeight);
|
|
||||||
GX_SetScissor (0, 0, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
|
|
||||||
GX_SetDispCopySrc (0, 0, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
GX_SetDispCopyDst (vmode->fbWidth, vmode->xfbHeight);
|
|
||||||
GX_SetCopyFilter (vmode->aa, vmode->sample_pattern, GX_TRUE, vmode->vfilter);
|
|
||||||
|
|
||||||
GX_SetFieldMode (vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
|
||||||
|
|
||||||
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
|
||||||
GX_SetCullMode (GX_CULL_NONE);
|
|
||||||
GX_SetDispCopyGamma (GX_GM_1_0);
|
GX_SetDispCopyGamma (GX_GM_1_0);
|
||||||
|
GX_SetCullMode (GX_CULL_NONE);
|
||||||
guOrtho(p, 480/2, -(480/2), -(640/2), 640/2, 10, 1000); // matrix, t, b, l, r, n, f
|
|
||||||
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
|
||||||
|
|
||||||
GX_CopyDisp (xfb[whichfb], GX_TRUE); // reset xfb
|
GX_CopyDisp (xfb[whichfb], GX_TRUE); // reset xfb
|
||||||
GX_Flush();
|
GX_Flush();
|
||||||
|
}
|
||||||
|
|
||||||
pointer1 = new GuiImageData(player1_point_png);
|
/****************************************************************************
|
||||||
|
* StopGX
|
||||||
|
*
|
||||||
|
* Stops GX (when exiting)
|
||||||
|
***************************************************************************/
|
||||||
|
void StopGX()
|
||||||
|
{
|
||||||
|
GX_AbortFrame();
|
||||||
|
GX_Flush();
|
||||||
|
|
||||||
|
VIDEO_SetBlack(TRUE);
|
||||||
|
VIDEO_Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -344,20 +317,41 @@ static void GX_Start()
|
|||||||
static void
|
static void
|
||||||
UpdatePadsCB ()
|
UpdatePadsCB ()
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
WPAD_ScanPads();
|
WPAD_ScanPads();
|
||||||
#endif
|
#endif
|
||||||
PAD_ScanPads();
|
PAD_ScanPads();
|
||||||
|
|
||||||
|
for(int i=3; i >= 0; i--)
|
||||||
|
{
|
||||||
|
#ifdef HW_RVL
|
||||||
|
memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
userInput[i].chan = i;
|
||||||
|
userInput[i].pad.btns_d = PAD_ButtonsDown(i);
|
||||||
|
userInput[i].pad.btns_u = PAD_ButtonsUp(i);
|
||||||
|
userInput[i].pad.btns_h = PAD_ButtonsHeld(i);
|
||||||
|
userInput[i].pad.stickX = PAD_StickX(i);
|
||||||
|
userInput[i].pad.stickY = PAD_StickY(i);
|
||||||
|
userInput[i].pad.substickX = PAD_SubStickX(i);
|
||||||
|
userInput[i].pad.substickY = PAD_SubStickY(i);
|
||||||
|
userInput[i].pad.triggerL = PAD_TriggerL(i);
|
||||||
|
userInput[i].pad.triggerR = PAD_TriggerR(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Initialise Video
|
* InitializeVideo
|
||||||
*
|
*
|
||||||
* Before doing anything in libogc, it's recommended to configure a video
|
* This function MUST be called at startup.
|
||||||
* output.
|
* - also sets up menu video mode
|
||||||
****************************************************************************/
|
***************************************************************************/
|
||||||
void InitialiseVideo ()
|
|
||||||
|
void
|
||||||
|
InitializeVideo ()
|
||||||
{
|
{
|
||||||
|
// get default video mode
|
||||||
vmode = VIDEO_GetPreferredMode(NULL);
|
vmode = VIDEO_GetPreferredMode(NULL);
|
||||||
|
|
||||||
switch (vmode->viTVMode >> 2)
|
switch (vmode->viTVMode >> 2)
|
||||||
@ -375,31 +369,33 @@ void InitialiseVideo ()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HW_DOL
|
#ifdef HW_DOL
|
||||||
/* we have component cables, why don't we switch into progressive?
|
/* we have component cables, but the preferred mode is interlaced
|
||||||
|
* why don't we switch into progressive?
|
||||||
* on the Wii, the user can do this themselves on their Wii Settings */
|
* on the Wii, the user can do this themselves on their Wii Settings */
|
||||||
if(VIDEO_HaveComponentCable())
|
if(VIDEO_HaveComponentCable())
|
||||||
vmode = &TVNtsc480Prog;
|
vmode = &TVNtsc480Prog;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// check for progressive scan
|
// check for progressive scan
|
||||||
if (vmode->viTVMode == VI_TVMODE_NTSC_PROG)
|
if (vmode->viTVMode == VI_TVMODE_NTSC_PROG)
|
||||||
progressive = true;
|
progressive = true;
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
// widescreen fix
|
// widescreen fix
|
||||||
if(CONF_GetAspectRatio())
|
if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
|
||||||
{
|
{
|
||||||
vmode->viWidth = VI_MAX_WIDTH_PAL-12;
|
vmode->viWidth = VI_MAX_WIDTH_PAL-12;
|
||||||
vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2;
|
vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VIDEO_Configure(vmode);
|
VIDEO_Configure (vmode);
|
||||||
|
|
||||||
screenheight = vmode->xfbHeight;
|
screenheight = vmode->xfbHeight;
|
||||||
screenwidth = vmode->fbWidth;
|
screenwidth = vmode->fbWidth;
|
||||||
|
|
||||||
|
// Allocate the video buffers
|
||||||
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||||
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||||
|
|
||||||
@ -415,21 +411,28 @@ void InitialiseVideo ()
|
|||||||
VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB);
|
VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB);
|
||||||
VIDEO_SetPreRetraceCallback ((VIRetraceCallback)copy_to_xfb);
|
VIDEO_SetPreRetraceCallback ((VIRetraceCallback)copy_to_xfb);
|
||||||
|
|
||||||
VIDEO_SetBlack(FALSE);
|
VIDEO_SetBlack (FALSE);
|
||||||
|
|
||||||
VIDEO_Flush();
|
VIDEO_Flush();
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
if(vmode->viTVMode&VI_NON_INTERLACE)
|
if(vmode->viTVMode & VI_NON_INTERLACE)
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
copynow = GX_FALSE;
|
copynow = GX_FALSE;
|
||||||
GX_Start();
|
|
||||||
draw_init();
|
|
||||||
|
|
||||||
|
StartGX ();
|
||||||
InitVideoThread ();
|
InitVideoThread ();
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
pointer[0] = new GuiImageData(player1_point_png);
|
||||||
|
pointer[1] = new GuiImageData(player2_point_png);
|
||||||
|
pointer[2] = new GuiImageData(player3_point_png);
|
||||||
|
pointer[3] = new GuiImageData(player4_point_png);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void UpdateScaling()
|
static void UpdateScaling()
|
||||||
{
|
{
|
||||||
int xscale;
|
int xscale;
|
||||||
@ -534,12 +537,12 @@ ResetVideo_Emu ()
|
|||||||
GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, (GCSettings.render == 1) ? GX_TRUE : GX_FALSE, rmode->vfilter); // deflickering filter only for filtered mode
|
GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, (GCSettings.render == 1) ? GX_TRUE : GX_FALSE, rmode->vfilter); // deflickering filter only for filtered mode
|
||||||
|
|
||||||
GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
||||||
|
|
||||||
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
||||||
GX_SetCullMode (GX_CULL_NONE);
|
GX_SetCullMode (GX_CULL_NONE);
|
||||||
GX_SetDispCopyGamma (GX_GM_1_0);
|
GX_SetDispCopyGamma (GX_GM_1_0);
|
||||||
|
GX_SetBlendMode(GX_BM_BLEND,GX_BL_DSTALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR);
|
||||||
|
|
||||||
guOrtho(p, 480/2, -(480/2), -(640/2), 640/2, 10, 1000); // matrix, t, b, l, r, n, f
|
guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 100, 1000); // matrix, t, b, l, r, n, f
|
||||||
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
||||||
|
|
||||||
// reinitialize texture
|
// reinitialize texture
|
||||||
@ -549,46 +552,12 @@ ResetVideo_Emu ()
|
|||||||
GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,2.5,9.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); // original/unfiltered video mode: force texture filtering OFF
|
GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,2.5,9.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); // original/unfiltered video mode: force texture filtering OFF
|
||||||
|
|
||||||
GX_Flush();
|
GX_Flush();
|
||||||
|
draw_init();
|
||||||
|
|
||||||
// set aspect ratio
|
// set aspect ratio
|
||||||
updateScaling = 1;
|
updateScaling = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* ResetVideo_Menu
|
|
||||||
*
|
|
||||||
* Reset the video/rendering mode for the menu
|
|
||||||
****************************************************************************/
|
|
||||||
void
|
|
||||||
ResetVideo_Menu ()
|
|
||||||
{
|
|
||||||
Mtx44 p;
|
|
||||||
|
|
||||||
VIDEO_Configure (vmode);
|
|
||||||
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
|
|
||||||
VIDEO_Flush();
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
if (vmode->viTVMode & VI_NON_INTERLACE)
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
else
|
|
||||||
while (VIDEO_GetNextField())
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
|
|
||||||
GX_SetViewport (0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1);
|
|
||||||
GX_SetDispCopyYScale ((f32) vmode->xfbHeight / (f32) vmode->efbHeight);
|
|
||||||
GX_SetScissor (0, 0, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
|
|
||||||
GX_SetDispCopySrc (0, 0, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
GX_SetDispCopyDst (vmode->fbWidth, vmode->xfbHeight);
|
|
||||||
GX_SetCopyFilter (vmode->aa, vmode->sample_pattern, GX_TRUE, vmode->vfilter);
|
|
||||||
|
|
||||||
GX_SetFieldMode (vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
|
||||||
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
|
||||||
|
|
||||||
guOrtho(p, 480/2, -(480/2), -(640/2), 640/2, 10, 1000); // matrix, t, b, l, r, n, f
|
|
||||||
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GX_Render_Init(int width, int height)
|
void GX_Render_Init(int width, int height)
|
||||||
{
|
{
|
||||||
if (texturemem)
|
if (texturemem)
|
||||||
@ -676,7 +645,9 @@ void GX_Render(int width, int height, u8 * buffer, int pitch)
|
|||||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
||||||
|
|
||||||
draw_square(view); // render textured quad
|
draw_square(view); // render textured quad
|
||||||
|
#ifdef HW_RVL
|
||||||
draw_cursor(view); // render cursor
|
draw_cursor(view); // render cursor
|
||||||
|
#endif
|
||||||
GX_DrawDone();
|
GX_DrawDone();
|
||||||
|
|
||||||
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||||
@ -706,14 +677,217 @@ zoom (float speed)
|
|||||||
GCSettings.ZoomLevel = 0.5;
|
GCSettings.ZoomLevel = 0.5;
|
||||||
else if (GCSettings.ZoomLevel > 2.0)
|
else if (GCSettings.ZoomLevel > 2.0)
|
||||||
GCSettings.ZoomLevel = 2.0;
|
GCSettings.ZoomLevel = 2.0;
|
||||||
|
|
||||||
updateScaling = 1; // update video
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zoom_reset ()
|
zoom_reset ()
|
||||||
{
|
{
|
||||||
GCSettings.ZoomLevel = 1.0;
|
GCSettings.ZoomLevel = 1.0;
|
||||||
updateScaling = 1; // update video
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* TakeScreenshot
|
||||||
|
*
|
||||||
|
* Copies the current screen into a GX texture
|
||||||
|
***************************************************************************/
|
||||||
|
void TakeScreenshot()
|
||||||
|
{
|
||||||
|
int texSize = vmode->fbWidth * vmode->efbHeight * 4;
|
||||||
|
|
||||||
|
if(gameScreenTex) free(gameScreenTex);
|
||||||
|
gameScreenTex = (u8 *)memalign(32, texSize);
|
||||||
|
if(gameScreenTex == NULL) return;
|
||||||
|
GX_SetTexCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight);
|
||||||
|
GX_SetTexCopyDst(vmode->fbWidth, vmode->efbHeight, GX_TF_RGBA8, GX_FALSE);
|
||||||
|
GX_CopyTex(gameScreenTex, GX_FALSE);
|
||||||
|
GX_PixModeSync();
|
||||||
|
DCFlushRange(gameScreenTex, texSize);
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
if(gameScreenTex2) free(gameScreenTex2);
|
||||||
|
gameScreenTex2 = (u8 *)memalign(32, texSize);
|
||||||
|
if(gameScreenTex2 == NULL) return;
|
||||||
|
GX_CopyTex(gameScreenTex2, GX_FALSE);
|
||||||
|
GX_PixModeSync();
|
||||||
|
DCFlushRange(gameScreenTex2, texSize);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ResetVideo_Menu
|
||||||
|
*
|
||||||
|
* Reset the video/rendering mode for the menu
|
||||||
|
****************************************************************************/
|
||||||
|
void
|
||||||
|
ResetVideo_Menu ()
|
||||||
|
{
|
||||||
|
Mtx44 p;
|
||||||
|
f32 yscale;
|
||||||
|
u32 xfbHeight;
|
||||||
|
|
||||||
|
VIDEO_Configure (vmode);
|
||||||
|
VIDEO_Flush();
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
if (vmode->viTVMode & VI_NON_INTERLACE)
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
else
|
||||||
|
while (VIDEO_GetNextField())
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
|
// clears the bg to color and clears the z buffer
|
||||||
|
GXColor background = {0, 0, 0, 255};
|
||||||
|
GX_SetCopyClear (background, 0x00ffffff);
|
||||||
|
|
||||||
|
yscale = GX_GetYScaleFactor(vmode->efbHeight,vmode->xfbHeight);
|
||||||
|
xfbHeight = GX_SetDispCopyYScale(yscale);
|
||||||
|
GX_SetScissor(0,0,vmode->fbWidth,vmode->efbHeight);
|
||||||
|
GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight);
|
||||||
|
GX_SetDispCopyDst(vmode->fbWidth,xfbHeight);
|
||||||
|
GX_SetCopyFilter(vmode->aa,vmode->sample_pattern,GX_TRUE,vmode->vfilter);
|
||||||
|
GX_SetFieldMode(vmode->field_rendering,((vmode->viHeight==2*vmode->xfbHeight)?GX_ENABLE:GX_DISABLE));
|
||||||
|
|
||||||
|
if (vmode->aa)
|
||||||
|
GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
|
||||||
|
else
|
||||||
|
GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
||||||
|
|
||||||
|
// setup the vertex descriptor
|
||||||
|
// tells the flipper to expect direct data
|
||||||
|
GX_ClearVtxDesc();
|
||||||
|
GX_InvVtxCache ();
|
||||||
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
|
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
|
||||||
|
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||||
|
GX_SetVtxDesc (GX_VA_CLR0, GX_DIRECT);
|
||||||
|
|
||||||
|
GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||||
|
GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
|
||||||
|
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
|
||||||
|
GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE);
|
||||||
|
|
||||||
|
GX_SetNumChans(1);
|
||||||
|
GX_SetNumTexGens(1);
|
||||||
|
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||||
|
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||||
|
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
||||||
|
|
||||||
|
guMtxIdentity(GXmodelView2D);
|
||||||
|
guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -50.0F);
|
||||||
|
GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);
|
||||||
|
|
||||||
|
guOrtho(p,0,479,0,639,0,300);
|
||||||
|
GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC);
|
||||||
|
|
||||||
|
GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1);
|
||||||
|
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
|
||||||
|
GX_SetAlphaUpdate(GX_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Menu_Render
|
||||||
|
*
|
||||||
|
* Renders everything current sent to GX, and flushes video
|
||||||
|
***************************************************************************/
|
||||||
|
void Menu_Render()
|
||||||
|
{
|
||||||
|
GX_DrawDone ();
|
||||||
|
|
||||||
|
whichfb ^= 1; // flip framebuffer
|
||||||
|
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||||
|
GX_SetColorUpdate(GX_TRUE);
|
||||||
|
GX_CopyDisp(xfb[whichfb],GX_TRUE);
|
||||||
|
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||||
|
VIDEO_Flush();
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Menu_DrawImg
|
||||||
|
*
|
||||||
|
* Draws the specified image on screen using GX
|
||||||
|
***************************************************************************/
|
||||||
|
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[],
|
||||||
|
f32 degrees, f32 scaleX, f32 scaleY, u8 alpha)
|
||||||
|
{
|
||||||
|
if(data == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GXTexObj texObj;
|
||||||
|
|
||||||
|
GX_InitTexObj(&texObj, data, width,height, GX_TF_RGBA8,GX_CLAMP, GX_CLAMP,GX_FALSE);
|
||||||
|
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||||
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
|
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
|
||||||
|
GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
|
||||||
|
|
||||||
|
Mtx m,m1,m2, mv;
|
||||||
|
width *=.5;
|
||||||
|
height*=.5;
|
||||||
|
guMtxIdentity (m1);
|
||||||
|
guMtxScaleApply(m1,m1,scaleX,scaleY,1.0);
|
||||||
|
Vector axis = (Vector) {0 , 0, 1 };
|
||||||
|
guMtxRotAxisDeg (m2, &axis, degrees);
|
||||||
|
guMtxConcat(m2,m1,m);
|
||||||
|
|
||||||
|
guMtxTransApply(m,m, xpos+width,ypos+height,0);
|
||||||
|
guMtxConcat (GXmodelView2D, m, mv);
|
||||||
|
GX_LoadPosMtxImm (mv, GX_PNMTX0);
|
||||||
|
|
||||||
|
GX_Begin(GX_QUADS, GX_VTXFMT0,4);
|
||||||
|
GX_Position3f32(-width, -height, 0);
|
||||||
|
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||||
|
GX_TexCoord2f32(0, 0);
|
||||||
|
|
||||||
|
GX_Position3f32(width, -height, 0);
|
||||||
|
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||||
|
GX_TexCoord2f32(1, 0);
|
||||||
|
|
||||||
|
GX_Position3f32(width, height, 0);
|
||||||
|
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||||
|
GX_TexCoord2f32(1, 1);
|
||||||
|
|
||||||
|
GX_Position3f32(-width, height, 0);
|
||||||
|
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||||
|
GX_TexCoord2f32(0, 1);
|
||||||
|
GX_End();
|
||||||
|
GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);
|
||||||
|
|
||||||
|
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||||
|
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Menu_DrawRectangle
|
||||||
|
*
|
||||||
|
* Draws a rectangle at the specified coordinates using GX
|
||||||
|
***************************************************************************/
|
||||||
|
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled)
|
||||||
|
{
|
||||||
|
u8 fmt;
|
||||||
|
long n;
|
||||||
|
int i;
|
||||||
|
f32 x2 = x+width;
|
||||||
|
f32 y2 = y+height;
|
||||||
|
Vector v[] = {{x,y,0.0f}, {x2,y,0.0f}, {x2,y2,0.0f}, {x,y2,0.0f}, {x,y,0.0f}};
|
||||||
|
|
||||||
|
if(!filled)
|
||||||
|
{
|
||||||
|
fmt = GX_LINESTRIP;
|
||||||
|
n = 5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fmt = GX_TRIANGLEFAN;
|
||||||
|
n = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
GX_Begin(fmt, GX_VTXFMT0, n);
|
||||||
|
for(i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
GX_Position3f32(v[i].x, v[i].y, v[i].z);
|
||||||
|
GX_Color4u8(color.r, color.g, color.b, color.a);
|
||||||
|
}
|
||||||
|
GX_End();
|
||||||
|
}
|
||||||
|
@ -6,23 +6,27 @@
|
|||||||
*
|
*
|
||||||
* video.h
|
* video.h
|
||||||
*
|
*
|
||||||
* Generic GX Support for Emulators
|
* Video routines
|
||||||
* NGC GX Video Functions
|
|
||||||
* These are pretty standard functions to setup and use GX scaling.
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef __VIDEOGX_H__
|
#ifndef _GCVIDEOH_
|
||||||
#define __VIDEOGX_H__
|
#define _GCVIDEOH_
|
||||||
|
|
||||||
void InitialiseVideo ();
|
#include <ogcsys.h>
|
||||||
|
|
||||||
|
void InitializeVideo ();
|
||||||
void GX_Render_Init(int width, int height);
|
void GX_Render_Init(int width, int height);
|
||||||
void GX_Render(int width, int height, u8 * buffer, int pitch);
|
void GX_Render(int width, int height, u8 * buffer, int pitch);
|
||||||
void clearscreen ();
|
void StopGX();
|
||||||
void showscreen ();
|
void ResetVideo_Emu();
|
||||||
void zoom (float speed);
|
void zoom (float speed);
|
||||||
void zoom_reset ();
|
void zoom_reset ();
|
||||||
void ResetVideo_Menu ();
|
|
||||||
void ResetVideo_Emu ();
|
void ResetVideo_Menu();
|
||||||
|
void TakeScreenshot();
|
||||||
|
void Menu_Render();
|
||||||
|
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF );
|
||||||
|
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled);
|
||||||
|
|
||||||
extern int screenheight;
|
extern int screenheight;
|
||||||
extern int screenwidth;
|
extern int screenwidth;
|
||||||
@ -31,5 +35,7 @@ extern bool CursorVisible;
|
|||||||
extern bool CursorValid;
|
extern bool CursorValid;
|
||||||
extern bool TiltScreen;
|
extern bool TiltScreen;
|
||||||
extern float TiltAngle;
|
extern float TiltAngle;
|
||||||
|
extern u8 * gameScreenTex;
|
||||||
|
extern u8 * gameScreenTex2;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -148,7 +148,7 @@ static void VMAllocGBA( void )
|
|||||||
paletteRAM == NULL || vram == NULL || oam == NULL ||
|
paletteRAM == NULL || vram == NULL || oam == NULL ||
|
||||||
pix == NULL || ioMem == NULL)
|
pix == NULL || ioMem == NULL)
|
||||||
{
|
{
|
||||||
WaitPrompt("Out of memory!");
|
ErrorPrompt("Out of memory!");
|
||||||
VMClose();
|
VMClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,7 +302,7 @@ int VMCPULoadROM(int method)
|
|||||||
// loading compressed files via VM is not supported
|
// loading compressed files via VM is not supported
|
||||||
if(!utilIsGBAImage(filepath))
|
if(!utilIsGBAImage(filepath))
|
||||||
{
|
{
|
||||||
WaitPrompt("Compressed GBA files are not supported!");
|
InfoPrompt("Compressed GBA files are not supported!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ int VMCPULoadROM(int method)
|
|||||||
|
|
||||||
if (romfile == NULL)
|
if (romfile == NULL)
|
||||||
{
|
{
|
||||||
WaitPrompt("Error opening file!");
|
InfoPrompt("Error opening file!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ int VMCPULoadROM(int method)
|
|||||||
if ( res != (1 << VMSHIFTBITS ) )
|
if ( res != (1 << VMSHIFTBITS ) )
|
||||||
{
|
{
|
||||||
sprintf(msg, "Error reading file! %i \n",res);
|
sprintf(msg, "Error reading file! %i \n",res);
|
||||||
WaitPrompt(msg);
|
InfoPrompt(msg);
|
||||||
VMClose();
|
VMClose();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -371,9 +371,9 @@ static void VMNewPage( int pageid )
|
|||||||
if (res) // fseek returns non-zero on a failure
|
if (res) // fseek returns non-zero on a failure
|
||||||
{
|
{
|
||||||
sprintf(msg, "Seek error! - Offset %d / %08x %d\n", pageid, pageid << VMSHIFTBITS, res);
|
sprintf(msg, "Seek error! - Offset %d / %08x %d\n", pageid, pageid << VMSHIFTBITS, res);
|
||||||
WaitPrompt(msg);
|
InfoPrompt(msg);
|
||||||
VMClose();
|
VMClose();
|
||||||
ExitToLoader();
|
ExitApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
VMAllocate( pageid );
|
VMAllocate( pageid );
|
||||||
@ -385,9 +385,9 @@ static void VMNewPage( int pageid )
|
|||||||
// and then end up here - but they still work - so we won't throw an error
|
// and then end up here - but they still work - so we won't throw an error
|
||||||
|
|
||||||
/*sprintf(msg, "Error reading! %d bytes only\n", res);
|
/*sprintf(msg, "Error reading! %d bytes only\n", res);
|
||||||
WaitPrompt(msg);
|
InfoPrompt(msg);
|
||||||
VMClose();
|
VMClose();
|
||||||
ExitToLoader();*/
|
ExitApp();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//mftb(&end);
|
//mftb(&end);
|
||||||
@ -424,9 +424,9 @@ u32 VMRead32( u32 address )
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
sprintf(msg, "VM32 : Unknown page type! (%d) [%d]", vmpage[pageid].pagetype, pageid);
|
sprintf(msg, "VM32 : Unknown page type! (%d) [%d]", vmpage[pageid].pagetype, pageid);
|
||||||
WaitPrompt(msg);
|
InfoPrompt(msg);
|
||||||
VMClose();
|
VMClose();
|
||||||
ExitToLoader();
|
ExitApp();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -456,9 +456,9 @@ u16 VMRead16( u32 address )
|
|||||||
return READ16LE( vmpage[pageid].pageptr + ( address & VMSHIFTMASK ) );
|
return READ16LE( vmpage[pageid].pageptr + ( address & VMSHIFTMASK ) );
|
||||||
|
|
||||||
default:
|
default:
|
||||||
WaitPrompt("VM16 : Unknown page type!");
|
InfoPrompt("VM16 : Unknown page type!");
|
||||||
VMClose();
|
VMClose();
|
||||||
ExitToLoader();
|
ExitApp();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,9 +488,9 @@ u8 VMRead8( u32 address )
|
|||||||
return (u8)vmpage[pageid].pageptr[ (address & VMSHIFTMASK) ];
|
return (u8)vmpage[pageid].pageptr[ (address & VMSHIFTMASK) ];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
WaitPrompt("VM8 : Unknown page type!");
|
InfoPrompt("VM8 : Unknown page type!");
|
||||||
VMClose();
|
VMClose();
|
||||||
ExitToLoader();
|
ExitApp();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
|
|
||||||
#define CASESENSITIVITY (0)
|
#define CASESENSITIVITY (0)
|
||||||
#define WRITEBUFFERSIZE (1024*256)
|
#define WRITEBUFFERSIZE (1024*256)
|
||||||
@ -303,7 +303,7 @@ int extractZip(unzFile uf,int opt_extract_without_path,int opt_overwrite,const c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CancelAction();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user