mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-01 00:15:10 +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
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
@ -147,6 +147,10 @@ $(OUTPUT).elf: $(OFILES)
|
||||
@echo $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
%.pcm.o : %.pcm
|
||||
@echo $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
@ -41,7 +41,8 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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
|
||||
|
@ -9,9 +9,11 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <asndlib.h>
|
||||
|
||||
#include "audio.h"
|
||||
|
||||
@ -90,6 +92,34 @@ void SetAudioRate(int 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
|
||||
***************************************************************************/
|
||||
@ -97,8 +127,22 @@ void SetAudioRate(int type)
|
||||
void InitialiseSound()
|
||||
{
|
||||
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 StopAudio();
|
||||
void SetAudioRate(int type);
|
||||
void SwitchAudioMode(int mode);
|
||||
void ShutdownAudio();
|
||||
|
||||
class SoundWii: public SoundDriver
|
||||
{
|
||||
|
@ -25,6 +25,50 @@
|
||||
***************************************************************************/
|
||||
|
||||
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
|
||||
{
|
||||
CTRLR_NUNCHUK,
|
||||
@ -63,56 +107,12 @@ CtrlrMap ctrlr_def[5] = {
|
||||
{WPAD_CLASSIC_BUTTON_PLUS, "PLUS"},
|
||||
{WPAD_CLASSIC_BUTTON_MINUS, "MINUS"},
|
||||
{WPAD_CLASSIC_BUTTON_HOME, "HOME"},
|
||||
{WPAD_CLASSIC_BUTTON_FULL_L, "L TRIG"},
|
||||
{WPAD_CLASSIC_BUTTON_FULL_R, "R TRIG"},
|
||||
{WPAD_CLASSIC_BUTTON_FULL_L, "L"},
|
||||
{WPAD_CLASSIC_BUTTON_FULL_R, "R"},
|
||||
{WPAD_CLASSIC_BUTTON_ZL, "ZL"},
|
||||
{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
|
||||
{
|
||||
CTRLR_KEYBOARD,
|
||||
@ -250,9 +250,7 @@ CtrlrMap ctrlr_def[5] = {
|
||||
{231, "RWIN"},
|
||||
{232, "MOUSEL"},
|
||||
{233, "MOUSER"},
|
||||
{234, "MOUSEM"},
|
||||
|
||||
{234, "MOUSEM"}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -13,14 +13,16 @@
|
||||
|
||||
enum {
|
||||
CTRLR_NONE = -1,
|
||||
CTRLR_NUNCHUK,
|
||||
CTRLR_CLASSIC,
|
||||
CTRLR_GCPAD,
|
||||
CTRLR_WIIMOTE,
|
||||
CTRLR_KEYBOARD,
|
||||
CTRLR_SNES = 7 // give some other value for the snes padmap
|
||||
CTRLR_NUNCHUK,
|
||||
CTRLR_CLASSIC,
|
||||
CTRLR_KEYBOARD
|
||||
};
|
||||
|
||||
const char ctrlrName[4][20] =
|
||||
{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller" };
|
||||
|
||||
typedef struct _btn_map {
|
||||
u32 btn; // button 'id'
|
||||
char* name; // button name
|
||||
|
@ -21,10 +21,11 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "menudraw.h"
|
||||
#include "gcunzip.h"
|
||||
#include "filesel.h"
|
||||
#include "vba.h"
|
||||
#include "menu.h"
|
||||
#include "gcunzip.h"
|
||||
#include "filebrowser.h"
|
||||
#include "fileop.h"
|
||||
|
||||
#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!
|
||||
* returns: 1 - ok ; 0 - error
|
||||
***************************************************************************/
|
||||
|
||||
int dvd_safe_read(void *dst_v, u32 len, u64 fileoffset)
|
||||
{
|
||||
u64 offset = dvddir + fileoffset;
|
||||
@ -318,35 +318,40 @@ getpvd ()
|
||||
*
|
||||
* Tests if a ISO9660 DVD is inserted and available, and mounts it
|
||||
***************************************************************************/
|
||||
|
||||
bool MountDVD(bool silent)
|
||||
{
|
||||
if (!getpvd())
|
||||
bool res = false;
|
||||
|
||||
if (getpvd())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowAction("Loading DVD...");
|
||||
#ifdef HW_DOL
|
||||
DVD_Mount(); // mount the DVD unit again
|
||||
#elif HW_RVL
|
||||
#else
|
||||
u32 val;
|
||||
DI_GetCoverRegister(&val);
|
||||
if(val & 0x1) // True if no disc inside, use (val & 0x2) for true if disc inside.
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt("No disc inserted!");
|
||||
ErrorPrompt("No disc inserted!");
|
||||
CancelAction();
|
||||
return false;
|
||||
}
|
||||
DI_Mount();
|
||||
while(DI_GetStatus() & DVD_INIT);
|
||||
while(DI_GetStatus() & DVD_INIT) usleep(20000);
|
||||
#endif
|
||||
|
||||
if (!getpvd())
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt ("Invalid DVD.");
|
||||
return false;
|
||||
}
|
||||
if (getpvd())
|
||||
res = true;
|
||||
else if(!silent)
|
||||
ErrorPrompt("Invalid DVD.");
|
||||
}
|
||||
return true;
|
||||
CancelAction();
|
||||
return res;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -355,7 +360,6 @@ bool MountDVD(bool silent)
|
||||
* Support function to return the next file entry, if any
|
||||
* Declared static to avoid accidental external entry.
|
||||
***************************************************************************/
|
||||
|
||||
static int
|
||||
getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
{
|
||||
@ -445,7 +449,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
WaitPrompt("Out of memory: too many files!");
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@ -455,8 +459,16 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
memset(&(browserList[entrycount]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy (browserList[entrycount].filename, fname, MAXJOLIET);
|
||||
StripExt(tmpname, fname); // hide file extension
|
||||
strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY);
|
||||
|
||||
if(strcmp(fname,"..") == 0)
|
||||
{
|
||||
sprintf(browserList[entrycount].displayname, "Up One Level");
|
||||
}
|
||||
else
|
||||
{
|
||||
StripExt(tmpname, fname); // hide file extension
|
||||
strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY);
|
||||
}
|
||||
|
||||
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
|
||||
* 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
|
||||
ParseDVDdirectory ()
|
||||
@ -506,7 +518,7 @@ ParseDVDdirectory ()
|
||||
while (len < pdlength)
|
||||
{
|
||||
if (dvd_read (&dvdbuffer, 2048, pdoffset) == 0)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
diroffset = 0;
|
||||
|
||||
@ -523,6 +535,7 @@ ParseDVDdirectory ()
|
||||
// Sort the file list
|
||||
qsort(browserList, filecount, sizeof(BROWSERENTRY), FileSortCallback);
|
||||
|
||||
browser.numEntries = filecount;
|
||||
return filecount;
|
||||
}
|
||||
|
||||
@ -530,7 +543,6 @@ ParseDVDdirectory ()
|
||||
* SetDVDdirectory
|
||||
* Set the current DVD file offset
|
||||
***************************************************************************/
|
||||
|
||||
void SetDVDdirectory(u64 dir, int length)
|
||||
{
|
||||
dvddir = dir;
|
||||
@ -579,12 +591,18 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
||||
|
||||
if(dirindex >= 0)
|
||||
{
|
||||
dvddir = browserList[dirindex].offset;
|
||||
dvddirlength = browserList[dirindex].length;
|
||||
browser.selIndex = dirindex;
|
||||
|
||||
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)
|
||||
return true;
|
||||
@ -597,8 +615,8 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
||||
bool SwitchDVDFolder(char origdir[])
|
||||
{
|
||||
// make a copy of origdir so we don't mess with original
|
||||
char dir[200];
|
||||
strcpy(dir, origdir);
|
||||
char dir[1024];
|
||||
strncpy(dir, origdir, 1024);
|
||||
|
||||
char * dirptr = dir;
|
||||
|
||||
@ -612,6 +630,7 @@ bool SwitchDVDFolder(char origdir[])
|
||||
// start searching at root of DVD
|
||||
dvddir = dvdrootdir;
|
||||
dvddirlength = dvdrootlength;
|
||||
browser.dir[0] = 0;
|
||||
ParseDVDdirectory();
|
||||
|
||||
return SwitchDVDFolderR(dirptr, 0);
|
||||
@ -622,10 +641,10 @@ bool SwitchDVDFolder(char origdir[])
|
||||
* This function will load a file from DVD
|
||||
* It assumes dvddir and dvddirlength are prepopulated
|
||||
***************************************************************************/
|
||||
|
||||
int
|
||||
LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
{
|
||||
int result = 0;
|
||||
int offset;
|
||||
int blocks;
|
||||
int i;
|
||||
@ -643,17 +662,19 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
{
|
||||
ret = dvd_read (buffer, length, discoffset);
|
||||
if(ret <= 0) // read failure
|
||||
return 0;
|
||||
goto done;
|
||||
else
|
||||
result = length;
|
||||
}
|
||||
else // load whole file
|
||||
{
|
||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||
if(ret <= 0) // read failure
|
||||
return 0;
|
||||
goto done;
|
||||
|
||||
if (IsZipFile (readbuffer))
|
||||
{
|
||||
return UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
||||
result = UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -661,7 +682,7 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
{
|
||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||
if(ret <= 0) // read failure
|
||||
return 0;
|
||||
goto done;
|
||||
memcpy (buffer + offset, readbuffer, 2048);
|
||||
offset += 2048;
|
||||
discoffset += 2048;
|
||||
@ -674,12 +695,15 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
i = dvddirlength % 2048;
|
||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||
if(ret <= 0) // read failure
|
||||
return 0;
|
||||
goto done;
|
||||
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
|
||||
* will populate dvddir and dvddirlength, and load the file
|
||||
***************************************************************************/
|
||||
|
||||
int
|
||||
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))
|
||||
{
|
||||
return LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt("Error loading file!");
|
||||
return 0;
|
||||
}
|
||||
ret = LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
||||
else if(!silent)
|
||||
ErrorPrompt("Error loading file!");
|
||||
|
||||
// restore browser information
|
||||
memset(browser.dir, 0, MAXPATHLEN);
|
||||
strncpy(browser.dir, origDir, MAXPATHLEN);
|
||||
browser.selIndex = origSelIndex;
|
||||
browser.pageIndex = origPageIndex;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -768,8 +802,8 @@ int dvd_driveid()
|
||||
dvd[6] = 0x20;
|
||||
dvd[7] = 3;
|
||||
|
||||
while( dvd[7] & 1 )
|
||||
;
|
||||
while( dvd[7] & 1 );
|
||||
|
||||
DCFlushRange((void *)0x80000000, 32);
|
||||
|
||||
return (int)inquiry[2];
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Tantric September 2008
|
||||
*
|
||||
* filesel.cpp
|
||||
* filebrowser.cpp
|
||||
*
|
||||
* Generic file routines - reading, writing, browsing
|
||||
***************************************************************************/
|
||||
@ -23,16 +23,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "vba.h"
|
||||
#include "dvd.h"
|
||||
#include "vbasupport.h"
|
||||
#include "vmmem.h"
|
||||
#include "menudraw.h"
|
||||
#include "filebrowser.h"
|
||||
#include "menu.h"
|
||||
#include "video.h"
|
||||
#include "networkop.h"
|
||||
#include "fileop.h"
|
||||
#include "filesel.h"
|
||||
#include "memcardop.h"
|
||||
#include "input.h"
|
||||
#include "dvd.h"
|
||||
#include "networkop.h"
|
||||
#include "gcunzip.h"
|
||||
#include "wiiusbsupport.h"
|
||||
|
||||
@ -55,7 +55,7 @@ int autoLoadMethod()
|
||||
{
|
||||
ShowAction ("Attempting to determine load method...");
|
||||
|
||||
int method = 0;
|
||||
int method = METHOD_AUTO;
|
||||
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
method = METHOD_SD;
|
||||
@ -66,10 +66,11 @@ int autoLoadMethod()
|
||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||
method = METHOD_SMB;
|
||||
else
|
||||
WaitPrompt("Unable to auto-determine load method!");
|
||||
ErrorPrompt("Unable to auto-determine load method!");
|
||||
|
||||
if(GCSettings.LoadMethod == METHOD_AUTO)
|
||||
GCSettings.LoadMethod = method; // save method found for later use
|
||||
CancelAction();
|
||||
return method;
|
||||
}
|
||||
|
||||
@ -83,23 +84,25 @@ int autoSaveMethod(bool silent)
|
||||
if(!silent)
|
||||
ShowAction ("Attempting to determine save method...");
|
||||
|
||||
int method = 0;
|
||||
int method = METHOD_AUTO;
|
||||
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
method = METHOD_SD;
|
||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
||||
method = METHOD_USB;
|
||||
else if(TestCard(CARD_SLOTA, SILENT))
|
||||
else if(ChangeInterface(METHOD_MC_SLOTA, SILENT))
|
||||
method = METHOD_MC_SLOTA;
|
||||
else if(TestCard(CARD_SLOTB, SILENT))
|
||||
else if(ChangeInterface(METHOD_MC_SLOTB, SILENT))
|
||||
method = METHOD_MC_SLOTB;
|
||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||
method = METHOD_SMB;
|
||||
else if(!silent)
|
||||
WaitPrompt("Unable to auto-determine save method!");
|
||||
ErrorPrompt("Unable to auto-determine save method!");
|
||||
|
||||
if(GCSettings.SaveMethod == METHOD_AUTO)
|
||||
GCSettings.SaveMethod = method; // save method found for later use
|
||||
|
||||
CancelAction();
|
||||
return method;
|
||||
}
|
||||
|
||||
@ -109,7 +112,9 @@ int autoSaveMethod(bool silent)
|
||||
***************************************************************************/
|
||||
void ResetBrowser()
|
||||
{
|
||||
browser.selIndex = browser.pageIndex = 0;
|
||||
browser.numEntries = 0;
|
||||
browser.selIndex = 0;
|
||||
browser.pageIndex = 0;
|
||||
|
||||
// Clear any existing values
|
||||
if(browserList != NULL)
|
||||
@ -118,7 +123,7 @@ void ResetBrowser()
|
||||
browserList = NULL;
|
||||
}
|
||||
// set aside space for 1 entry
|
||||
browserList = (BROWSERENTRY *)memalign(32, sizeof(BROWSERENTRY));
|
||||
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY));
|
||||
memset(browserList, 0, sizeof(BROWSERENTRY));
|
||||
}
|
||||
|
||||
@ -171,16 +176,17 @@ int UpdateDirName(int method)
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Directory name is too long!");
|
||||
ErrorPrompt("Directory name is too long!");
|
||||
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 folder[1024];
|
||||
char ext[4];
|
||||
char temppath[MAXPATHLEN];
|
||||
|
||||
if(type == FILE_ROM)
|
||||
@ -188,7 +194,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
||||
// Check path length
|
||||
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) >= MAXPATHLEN)
|
||||
{
|
||||
WaitPrompt("Maximum filepath length reached!");
|
||||
ErrorPrompt("Maximum filepath length reached!");
|
||||
filepath[0] = 0;
|
||||
return false;
|
||||
}
|
||||
@ -202,12 +208,31 @@ bool MakeFilePath(char filepath[], int type, int method)
|
||||
switch(type)
|
||||
{
|
||||
case FILE_SRAM:
|
||||
sprintf(folder, GCSettings.SaveFolder);
|
||||
sprintf(file, "%s.sav", ROMFilename);
|
||||
break;
|
||||
case FILE_SNAPSHOT:
|
||||
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;
|
||||
case FILE_CHEAT:
|
||||
sprintf(folder, GCSettings.CheatFolder);
|
||||
@ -230,7 +255,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
||||
break;
|
||||
}
|
||||
}
|
||||
strcpy(filepath, temppath);
|
||||
strncpy(filepath, temppath, MAXPATHLEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -266,7 +291,6 @@ int FileSortCallback(const void *f1, const void *f2)
|
||||
*
|
||||
* Checks if the specified file is a 7z
|
||||
***************************************************************************/
|
||||
|
||||
bool IsSz()
|
||||
{
|
||||
if (strlen(browserList[browser.selIndex].filename) > 4)
|
||||
@ -285,298 +309,141 @@ bool IsSz()
|
||||
*
|
||||
* Strips an extension from a filename
|
||||
***************************************************************************/
|
||||
|
||||
void StripExt(char* returnstring, char * inputstring)
|
||||
{
|
||||
char* loc_dot;
|
||||
|
||||
strcpy (returnstring, inputstring);
|
||||
strncpy (returnstring, inputstring, 255);
|
||||
|
||||
if(inputstring == NULL || strlen(inputstring) < 4)
|
||||
return;
|
||||
|
||||
loc_dot = strrchr(returnstring,'.');
|
||||
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;
|
||||
u32 wp = 0;
|
||||
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;
|
||||
char filepath[MAXPATHLEN];
|
||||
memset(filepath, 0, MAXPATHLEN);
|
||||
|
||||
int haverom = 0;
|
||||
int redraw = 1;
|
||||
int selectit = 0;
|
||||
// we'll store the 7z filepath for extraction later
|
||||
if(!MakeFilePath(szpath, FILE_ROM, method))
|
||||
return 0;
|
||||
|
||||
int scroll_delay = 0;
|
||||
bool move_selection = 0;
|
||||
#define SCROLL_INITIAL_DELAY 15
|
||||
#define SCROLL_LOOP_DELAY 2
|
||||
// add device to filepath
|
||||
if(method != METHOD_DVD)
|
||||
{
|
||||
sprintf(filepath, "%s%s", rootdir, szpath);
|
||||
memcpy(szpath, filepath, MAXPATHLEN);
|
||||
}
|
||||
|
||||
while (haverom == 0)
|
||||
{
|
||||
if (redraw)
|
||||
ShowFiles (browserList, browser.numEntries, browser.pageIndex, browser.selIndex);
|
||||
redraw = 0;
|
||||
int szfiles = SzParse(szpath, method);
|
||||
if(szfiles)
|
||||
{
|
||||
browser.numEntries = szfiles;
|
||||
inSz = true;
|
||||
}
|
||||
else
|
||||
ErrorPrompt("Error opening archive!");
|
||||
|
||||
updateRumbleFrame();
|
||||
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
|
||||
return szfiles;
|
||||
}
|
||||
|
||||
gc_ay = PAD_StickY (0);
|
||||
gc_sx = PAD_SubStickX (0);
|
||||
/****************************************************************************
|
||||
* BrowserLoadFile
|
||||
*
|
||||
* Loads the selected ROM
|
||||
***************************************************************************/
|
||||
int BrowserLoadFile(int method)
|
||||
{
|
||||
// store the filename (w/o ext) - used for sram/freeze naming
|
||||
StripExt(ROMFilename, browserList[browser.selIndex].filename);
|
||||
|
||||
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);
|
||||
ROMLoaded = LoadVBAROM(method);
|
||||
inSz = false;
|
||||
|
||||
wp = WPAD_ButtonsDown (0);
|
||||
wh = WPAD_ButtonsHeld (0);
|
||||
#endif
|
||||
if (!ROMLoaded)
|
||||
{
|
||||
ErrorPrompt("Error loading ROM!");
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetBrowser();
|
||||
}
|
||||
CancelAction();
|
||||
return ROMLoaded;
|
||||
}
|
||||
|
||||
/*** 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;
|
||||
/****************************************************************************
|
||||
* 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
|
||||
{
|
||||
if(method == METHOD_DVD)
|
||||
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
||||
|
||||
/*** 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;
|
||||
inSz = false;
|
||||
SzClose();
|
||||
}
|
||||
|
||||
if(inSz && browser.selIndex == 0) // inside a 7z, requesting to leave
|
||||
{
|
||||
if(method == METHOD_DVD)
|
||||
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
||||
if(!UpdateDirName(method))
|
||||
return -1;
|
||||
|
||||
inSz = false;
|
||||
status = 1;
|
||||
SzClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
status = UpdateDirName(method);
|
||||
}
|
||||
switch (method)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
ParseDVDdirectory();
|
||||
break;
|
||||
|
||||
if (status == 1) // ok, open directory
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
browser.numEntries = ParseDVDdirectory();
|
||||
break;
|
||||
default:
|
||||
ParseDirectory(method);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
browser.numEntries = ParseDirectory();
|
||||
break;
|
||||
}
|
||||
if (!browser.numEntries)
|
||||
{
|
||||
ErrorPrompt("Error reading directory!");
|
||||
}
|
||||
|
||||
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
|
||||
if(!MakeFilePath(szpath, FILE_ROM, method))
|
||||
return 0;
|
||||
|
||||
// add device to filepath
|
||||
char fullpath[1024];
|
||||
sprintf(fullpath, "%s%s", rootdir, szpath);
|
||||
strcpy(szpath, fullpath);
|
||||
|
||||
int szfiles = SzParse(szpath, method);
|
||||
if(szfiles)
|
||||
{
|
||||
browser.numEntries = szfiles;
|
||||
inSz = true;
|
||||
}
|
||||
else
|
||||
WaitPrompt("Error opening archive!");
|
||||
}
|
||||
else
|
||||
{
|
||||
// store the filename (w/o ext) - used for sram/freeze naming
|
||||
StripExt(ROMFilename, browserList[browser.selIndex].filename);
|
||||
|
||||
ShowAction ("Loading...");
|
||||
|
||||
ROMLoaded = LoadVBAROM(method);
|
||||
inSz = false;
|
||||
|
||||
if (ROMLoaded)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
#ifdef HW_RVL
|
||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|
||||
#endif
|
||||
) {
|
||||
updateRumbleFrame();
|
||||
VIDEO_WaitVSync();
|
||||
}
|
||||
if ( strcmp(browserList[0].filename,"..") == 0 )
|
||||
{
|
||||
browser.selIndex = 0;
|
||||
selectit = 1;
|
||||
}
|
||||
else if ( strcmp(browserList[1].filename,"..") == 0 )
|
||||
{
|
||||
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)
|
||||
{
|
||||
browser.selIndex++;
|
||||
if (browser.selIndex == browser.numEntries)
|
||||
browser.selIndex = browser.pageIndex = 0;
|
||||
if ((browser.selIndex - browser.pageIndex) >= PAGESIZE)
|
||||
browser.pageIndex += PAGESIZE;
|
||||
redraw = 1;
|
||||
move_selection = 0;
|
||||
}
|
||||
} // 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)
|
||||
{
|
||||
browser.selIndex--;
|
||||
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;
|
||||
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;
|
||||
return browser.numEntries;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* OpenROM
|
||||
* Opens device specified by method, displays a list of ROMS
|
||||
* Displays a list of ROMS on load device
|
||||
***************************************************************************/
|
||||
|
||||
int
|
||||
OpenROM (int method)
|
||||
OpenGameList ()
|
||||
{
|
||||
int method = GCSettings.LoadMethod;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoLoadMethod();
|
||||
|
||||
if(ChangeInterface(method, NOTSILENT))
|
||||
// change current dir to roms directory
|
||||
switch(method)
|
||||
{
|
||||
// change current dir to roms directory
|
||||
switch(method)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
browser.dir[0] = 0;
|
||||
browser.numEntries = ParseDVDdirectory(); // Parse root directory
|
||||
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
||||
break;
|
||||
default:
|
||||
sprintf(browser.dir, "/%s", GCSettings.LoadFolder);
|
||||
browser.numEntries = ParseDirectory(); // Parse root directory
|
||||
break;
|
||||
}
|
||||
|
||||
if (browser.numEntries > 0)
|
||||
{
|
||||
// Select an entry
|
||||
return FileSelector (method);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no entries found
|
||||
WaitPrompt ("No Files Found!");
|
||||
return 0;
|
||||
}
|
||||
case METHOD_DVD:
|
||||
browser.dir[0] = 0;
|
||||
if(MountDVD(NOTSILENT))
|
||||
if(ParseDVDdirectory()) // Parse root directory
|
||||
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
||||
break;
|
||||
default:
|
||||
sprintf(browser.dir, "/%s", GCSettings.LoadFolder);
|
||||
ParseDirectory(method); // Parse root directory
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return browser.numEntries;
|
||||
}
|
||||
|
@ -3,18 +3,19 @@
|
||||
*
|
||||
* Tantric September 2008
|
||||
*
|
||||
* filesel.h
|
||||
* filebrowser.h
|
||||
*
|
||||
* Generic file routines - reading, writing, browsing
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _NGCFILESEL_
|
||||
#define _NGCFILESEL_
|
||||
#ifndef _FILEBROWSER_H_
|
||||
#define _FILEBROWSER_H_
|
||||
|
||||
#include <unistd.h>
|
||||
#include <gccore.h>
|
||||
|
||||
#define MAXJOLIET 255
|
||||
#define MAXDISPLAY 40
|
||||
#define MAXDISPLAY 35
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -28,6 +29,7 @@ typedef struct
|
||||
{
|
||||
u64 offset; // DVD offset
|
||||
unsigned int length; // file length
|
||||
time_t mtime; // file modified time
|
||||
char isdir; // 0 - file, 1 - directory
|
||||
char filename[MAXJOLIET + 1]; // full filename
|
||||
char displayname[MAXDISPLAY + 1]; // name for browser display
|
||||
@ -36,17 +38,22 @@ typedef struct
|
||||
extern BROWSERINFO browser;
|
||||
extern BROWSERENTRY * browserList;
|
||||
extern char rootdir[10];
|
||||
extern char ROMFilename[512];
|
||||
extern bool ROMLoaded;
|
||||
extern char szpath[MAXPATHLEN];
|
||||
extern bool inSz;
|
||||
extern char ROMFilename[512];
|
||||
|
||||
bool MakeFilePath(char filepath[], int type, int method);
|
||||
int OpenROM (int method);
|
||||
bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -1);
|
||||
int UpdateDirName(int method);
|
||||
int OpenGameList();
|
||||
int autoLoadMethod();
|
||||
int autoSaveMethod(bool silent);
|
||||
int FileSortCallback(const void *f1, const void *f2);
|
||||
void StripExt(char* returnstring, char * inputstring);
|
||||
bool IsSz();
|
||||
void ResetBrowser();
|
||||
|
||||
int BrowserLoadSz(int method);
|
||||
int BrowserChangeFolder(int method);
|
||||
int BrowserLoadFile(int method);
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,8 @@
|
||||
*
|
||||
* 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_
|
||||
@ -16,6 +17,208 @@
|
||||
extern const u8 font_ttf[];
|
||||
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 u32 player1_point_png_size;
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include "memcardop.h"
|
||||
#include "gcunzip.h"
|
||||
#include "video.h"
|
||||
#include "menudraw.h"
|
||||
#include "filesel.h"
|
||||
#include "menu.h"
|
||||
#include "filebrowser.h"
|
||||
#include "preferences.h"
|
||||
|
||||
unsigned char * savebuffer = NULL;
|
||||
@ -49,7 +49,7 @@ bool isMounted[9] = { false, false, false, false, false, false, false, false, fa
|
||||
/****************************************************************************
|
||||
* deviceThreading
|
||||
***************************************************************************/
|
||||
lwp_t devicethread;
|
||||
lwp_t devicethread = LWP_THREAD_NULL;
|
||||
|
||||
/****************************************************************************
|
||||
* devicecallback
|
||||
@ -103,7 +103,6 @@ devicecallback (void *arg)
|
||||
#endif
|
||||
usleep(500000); // suspend thread for 1/2 sec
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -116,7 +115,7 @@ devicecallback (void *arg)
|
||||
void
|
||||
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;
|
||||
fatUnmount(rootdir);
|
||||
disc->shutdown();
|
||||
isMounted[method] = false;
|
||||
}
|
||||
if(!isMounted[method])
|
||||
{
|
||||
@ -227,7 +227,7 @@ bool ChangeInterface(int method, bool silent)
|
||||
mounted = MountFAT(METHOD_SD_SLOTB); // try SD Gecko on slot B
|
||||
#endif
|
||||
if(!mounted && !silent) // no SD device found
|
||||
WaitPrompt ("SD card not found!");
|
||||
ErrorPrompt("SD card not found!");
|
||||
}
|
||||
else if(method == METHOD_USB)
|
||||
{
|
||||
@ -235,19 +235,31 @@ bool ChangeInterface(int method, bool silent)
|
||||
mounted = MountFAT(method);
|
||||
|
||||
if(!mounted && !silent)
|
||||
WaitPrompt ("USB drive not found!");
|
||||
ErrorPrompt("USB drive not found!");
|
||||
#endif
|
||||
}
|
||||
else if(method == METHOD_DVD)
|
||||
{
|
||||
sprintf(rootdir, "/");
|
||||
rootdir[0] = 0;
|
||||
mounted = MountDVD(silent);
|
||||
}
|
||||
#ifdef HW_RVL
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
sprintf(rootdir, "smb:/");
|
||||
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;
|
||||
}
|
||||
@ -256,39 +268,49 @@ bool ChangeInterface(int method, bool silent)
|
||||
* Browse subdirectories
|
||||
**************************************************************************/
|
||||
int
|
||||
ParseDirectory()
|
||||
ParseDirectory(int method)
|
||||
{
|
||||
DIR_ITER *dir;
|
||||
DIR_ITER *dir = NULL;
|
||||
char fulldir[MAXPATHLEN];
|
||||
char filename[MAXPATHLEN];
|
||||
char tmpname[MAXPATHLEN];
|
||||
struct stat filestat;
|
||||
char msg[128];
|
||||
int retry = 1;
|
||||
bool mounted = false;
|
||||
|
||||
// reset browser
|
||||
ResetBrowser();
|
||||
|
||||
// add device to path
|
||||
sprintf(fulldir, "%s%s", rootdir, browser.dir);
|
||||
ShowAction("Loading...");
|
||||
|
||||
// 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)
|
||||
{
|
||||
sprintf(msg, "Error opening %s", fulldir);
|
||||
WaitPrompt(msg);
|
||||
|
||||
// if we can't open the dir, open root dir
|
||||
sprintf(browser.dir,"/");
|
||||
|
||||
dir = diropen(rootdir);
|
||||
|
||||
if (dir == NULL)
|
||||
if(ChangeInterface(method, SILENT))
|
||||
{
|
||||
sprintf(msg, "Error opening %s", rootdir);
|
||||
WaitPrompt(msg);
|
||||
return 0;
|
||||
sprintf(browser.dir,"/");
|
||||
dir = diropen(rootdir);
|
||||
if (dir == NULL)
|
||||
{
|
||||
sprintf(msg, "Error opening %s", rootdir);
|
||||
ErrorPrompt(msg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,8 +326,8 @@ ParseDirectory()
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
WaitPrompt("Out of memory: too many files!");
|
||||
entryNum = 0;
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
entryNum = -1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -315,9 +337,19 @@ ParseDirectory()
|
||||
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
|
||||
StripExt(tmpname, filename); // hide file extension
|
||||
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||
|
||||
if(strcmp(filename,"..") == 0)
|
||||
{
|
||||
sprintf(browserList[entryNum].displayname, "Up One Level");
|
||||
}
|
||||
else
|
||||
{
|
||||
StripExt(tmpname, filename); // hide file extension
|
||||
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
entryNum++;
|
||||
@ -330,6 +362,9 @@ ParseDirectory()
|
||||
// Sort the file list
|
||||
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
||||
|
||||
CancelAction();
|
||||
|
||||
browser.numEntries = entryNum;
|
||||
return entryNum;
|
||||
}
|
||||
|
||||
@ -340,8 +375,8 @@ ParseDirectory()
|
||||
void
|
||||
AllocSaveBuffer ()
|
||||
{
|
||||
if (savebuffer != NULL)
|
||||
free(savebuffer);
|
||||
while(savebuffer != NULL) // save buffer is in use
|
||||
usleep(50); // wait for it to be free
|
||||
|
||||
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||
@ -382,7 +417,7 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Error opening file");
|
||||
ErrorPrompt("Error opening file");
|
||||
}
|
||||
|
||||
// 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];
|
||||
u32 size = 0;
|
||||
u32 readsize = 0;
|
||||
|
||||
if(!ChangeInterface(method, NOTSILENT))
|
||||
return 0;
|
||||
char fullpath[MAXPATHLEN];
|
||||
int retry = 1;
|
||||
|
||||
switch(method)
|
||||
{
|
||||
@ -421,69 +455,84 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
// since we're loading a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
// add device to filepath
|
||||
char fullpath[1024];
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
||||
|
||||
file = fopen (fullpath, "rb");
|
||||
|
||||
if (file > 0)
|
||||
// open the file
|
||||
while(!size && retry == 1)
|
||||
{
|
||||
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
|
||||
if(ChangeInterface(method, silent))
|
||||
{
|
||||
size = fread (rbuffer, 1, length, file);
|
||||
}
|
||||
else // load whole file
|
||||
{
|
||||
readsize = fread (zipbuffer, 1, 2048, file);
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||
file = fopen (fullpath, "rb");
|
||||
|
||||
if(readsize > 0)
|
||||
if(file > 0)
|
||||
{
|
||||
if (IsZipFile (zipbuffer))
|
||||
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
|
||||
{
|
||||
size = UnZipBuffer ((unsigned char *)rbuffer, method); // unzip
|
||||
size = fread (rbuffer, 1, length, file);
|
||||
}
|
||||
else
|
||||
else // load whole file
|
||||
{
|
||||
struct stat fileinfo;
|
||||
fstat(file->_file, &fileinfo);
|
||||
size = fileinfo.st_size;
|
||||
readsize = fread (zipbuffer, 1, 2048, file);
|
||||
|
||||
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
||||
|
||||
u32 offset = readsize;
|
||||
while(offset < size)
|
||||
if(readsize > 0)
|
||||
{
|
||||
ShowProgress ("Loading...", offset, size);
|
||||
readsize = fread (rbuffer + offset, 1, (1024*512), file); // read in 512K chunks
|
||||
if (IsZipFile (zipbuffer))
|
||||
{
|
||||
size = UnZipBuffer ((unsigned char *)rbuffer, method); // unzip
|
||||
}
|
||||
else
|
||||
{
|
||||
struct stat fileinfo;
|
||||
fstat(file->_file, &fileinfo);
|
||||
size = fileinfo.st_size;
|
||||
|
||||
if(readsize <= 0 || readsize > (1024*512))
|
||||
break; // read failure
|
||||
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
||||
|
||||
if(readsize > 0)
|
||||
offset += readsize;
|
||||
u32 offset = readsize;
|
||||
u32 nextread = 0;
|
||||
while(offset < size)
|
||||
{
|
||||
if(size - offset > 1024*512) nextread = 1024*512;
|
||||
else nextread = size-offset;
|
||||
ShowProgress ("Loading...", offset, size);
|
||||
readsize = fread (rbuffer + offset, 1, nextread, file); // read in next chunk
|
||||
|
||||
if(readsize <= 0 || readsize > nextread)
|
||||
break; // read failure
|
||||
|
||||
if(readsize > 0)
|
||||
offset += readsize;
|
||||
}
|
||||
CancelAction();
|
||||
|
||||
if(offset != size) // # bytes read doesn't match # expected
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(offset != size) // # bytes read doesn't match # expected
|
||||
size = 0;
|
||||
}
|
||||
fclose (file);
|
||||
}
|
||||
}
|
||||
if(!size)
|
||||
{
|
||||
if(!silent)
|
||||
{
|
||||
unmountRequired[method] = true;
|
||||
retry = ErrorPromptRetry("Error loading file!");
|
||||
}
|
||||
else
|
||||
{
|
||||
retry = 0;
|
||||
}
|
||||
}
|
||||
fclose (file);
|
||||
}
|
||||
if(!size && !silent)
|
||||
{
|
||||
unmountRequired[method] = true;
|
||||
WaitPrompt("Error loading file!");
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
|
||||
CancelAction();
|
||||
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);
|
||||
}
|
||||
@ -495,53 +544,59 @@ u32 LoadFile(char filepath[], int method, bool silent)
|
||||
u32
|
||||
SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
{
|
||||
char fullpath[MAXPATHLEN];
|
||||
u32 written = 0;
|
||||
int retry = 1;
|
||||
|
||||
if(!ChangeInterface(method, NOTSILENT))
|
||||
if(datasize == 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);
|
||||
break;
|
||||
case METHOD_MC_SLOTB:
|
||||
else
|
||||
return SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
||||
break;
|
||||
}
|
||||
|
||||
if (datasize)
|
||||
{
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're saving a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're saving a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
// add device to filepath
|
||||
char fullpath[1024];
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
||||
|
||||
// open file for writing
|
||||
file = fopen (fullpath, "wb");
|
||||
|
||||
if (file > 0)
|
||||
while(!written && retry == 1)
|
||||
{
|
||||
if(ChangeInterface(method, silent))
|
||||
{
|
||||
written = fwrite (savebuffer, 1, datasize, file);
|
||||
fclose (file);
|
||||
}
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||
file = fopen (fullpath, "wb");
|
||||
|
||||
if(!written && !silent)
|
||||
if (file > 0)
|
||||
{
|
||||
written = fwrite (savebuffer, 1, datasize, file);
|
||||
if(written < datasize) written = 0;
|
||||
fclose (file);
|
||||
}
|
||||
}
|
||||
if(!written)
|
||||
{
|
||||
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
|
||||
LWP_ResumeThread (devicethread);
|
||||
}
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
|
||||
CancelAction();
|
||||
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);
|
||||
}
|
||||
|
@ -24,14 +24,14 @@ void InitDeviceThread();
|
||||
void MountAllFAT();
|
||||
void UnmountAllFAT();
|
||||
bool ChangeInterface(int method, bool silent);
|
||||
int ParseDirectory();
|
||||
int ParseDirectory(int method);
|
||||
void AllocSaveBuffer();
|
||||
void FreeSaveBuffer();
|
||||
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 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 FILE * file;
|
||||
|
@ -20,13 +20,14 @@ extern "C" {
|
||||
#include "../sz/7zExtract.h"
|
||||
}
|
||||
|
||||
#include "vba.h"
|
||||
#include "dvd.h"
|
||||
#include "networkop.h"
|
||||
#include "fileop.h"
|
||||
#include "filebrowser.h"
|
||||
#include "video.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "gcunzip.h"
|
||||
#include "vba.h"
|
||||
|
||||
#define ZIPCHUNK 2048
|
||||
|
||||
@ -146,7 +147,7 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
res = inflateInit2 (&zs, -MAX_WBITS);
|
||||
|
||||
if (res != Z_OK)
|
||||
return 0;
|
||||
goto done;
|
||||
|
||||
/*** Set ZipChunk for first pass ***/
|
||||
zipoffset =
|
||||
@ -170,8 +171,7 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
|
||||
if (res == Z_MEM_ERROR)
|
||||
{
|
||||
inflateEnd (&zs);
|
||||
return 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
have = ZIPCHUNK - zs.avail_out;
|
||||
@ -199,23 +199,20 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
break;
|
||||
}
|
||||
if(sizeread <= 0)
|
||||
break; // read failure
|
||||
goto done; // read failure
|
||||
|
||||
ShowProgress ("Loading...", bufferoffset, pkzip.uncompressedSize);
|
||||
}
|
||||
while (res != Z_STREAM_END);
|
||||
|
||||
done:
|
||||
inflateEnd (&zs);
|
||||
CancelAction();
|
||||
|
||||
if (res == Z_STREAM_END)
|
||||
{
|
||||
if (pkzip.uncompressedSize == (u32) bufferoffset)
|
||||
return bufferoffset;
|
||||
else
|
||||
return pkzip.uncompressedSize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return pkzip.uncompressedSize;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -248,7 +245,7 @@ GetFirstZipFilename (int method)
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Error - Invalid ZIP file!");
|
||||
ErrorPrompt("Error - Invalid ZIP file!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,7 +315,7 @@ Is7ZipFile (char *buffer)
|
||||
// display an error message
|
||||
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
|
||||
@ -473,7 +470,7 @@ int SzParse(char * filepath, int method)
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
WaitPrompt("Out of memory: too many files!");
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
nbfiles = 0;
|
||||
break;
|
||||
}
|
||||
@ -554,6 +551,8 @@ int SzExtractFile(int i, unsigned char *buffer)
|
||||
// close 7Zip archive and free memory
|
||||
SzClose();
|
||||
|
||||
CancelAction();
|
||||
|
||||
// check for errors
|
||||
if(SzRes != SZ_OK)
|
||||
{
|
||||
|
@ -40,12 +40,11 @@
|
||||
#include <asndlib.h>
|
||||
#include "pngu/pngu.h"
|
||||
#include "FreeTypeGX.h"
|
||||
#include "snes9xGX.h"
|
||||
#include "vba.h"
|
||||
#include "video.h"
|
||||
#include "input.h"
|
||||
#include "filelist.h"
|
||||
#include "fileop.h"
|
||||
#include "menu.h"
|
||||
#include "oggplayer.h"
|
||||
|
||||
#define SCROLL_INITIAL_DELAY 20
|
||||
|
@ -13,16 +13,14 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ogcsys.h>
|
||||
#include <network.h>
|
||||
#include <ogc/lwp_watchdog.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "http.h"
|
||||
|
||||
static s32 tcp_socket(void)
|
||||
@ -416,6 +414,7 @@ bool http_request(const char *url, FILE * hfile, u8 * buffer,
|
||||
ShowProgress("Downloading...", (content_length - bytesLeft),
|
||||
content_length);
|
||||
}
|
||||
CancelAction();
|
||||
}
|
||||
|
||||
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 "vbasupport.h"
|
||||
#include "wiiusbsupport.h"
|
||||
#include "gui/gui.h"
|
||||
#include "gba/GBA.h"
|
||||
#include "gba/bios.h"
|
||||
#include "gba/GBAinline.h"
|
||||
|
||||
extern bool InMenu;
|
||||
int rumbleRequest[4] = {0,0,0,0};
|
||||
GuiTrigger userInput[4];
|
||||
|
||||
#ifdef HW_RVL
|
||||
static int rumbleCount[4] = {0,0,0,0};
|
||||
#endif
|
||||
|
||||
bool cartridgeRumble = false;
|
||||
int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0;
|
||||
|
||||
unsigned int vbapadmap[10]; // VBA controller buttons
|
||||
unsigned int gcpadmap[10]; // Gamecube controller Padmap
|
||||
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
|
||||
u32 btnmap[5][10]; // button mapping
|
||||
|
||||
void ResetControls()
|
||||
{
|
||||
int i = 0;
|
||||
memset(btnmap, 0, sizeof(btnmap));
|
||||
|
||||
int i;
|
||||
|
||||
// VBA controller buttons
|
||||
// All other pads are mapped to this
|
||||
@ -62,70 +65,72 @@ void ResetControls()
|
||||
|
||||
/*** Gamecube controller Padmap ***/
|
||||
i=0;
|
||||
gcpadmap[i++] = PAD_BUTTON_B;
|
||||
gcpadmap[i++] = PAD_BUTTON_A;
|
||||
gcpadmap[i++] = PAD_TRIGGER_Z;
|
||||
gcpadmap[i++] = PAD_BUTTON_START;
|
||||
gcpadmap[i++] = PAD_BUTTON_UP;
|
||||
gcpadmap[i++] = PAD_BUTTON_DOWN;
|
||||
gcpadmap[i++] = PAD_BUTTON_LEFT;
|
||||
gcpadmap[i++] = PAD_BUTTON_RIGHT;
|
||||
gcpadmap[i++] = PAD_TRIGGER_L;
|
||||
gcpadmap[i++] = PAD_TRIGGER_R;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_B;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_A;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_Z;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_START;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_UP;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_DOWN;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_LEFT;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_RIGHT;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_L;
|
||||
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_R;
|
||||
|
||||
/*** Wiimote Padmap ***/
|
||||
i=0;
|
||||
wmpadmap[i++] = WPAD_BUTTON_1;
|
||||
wmpadmap[i++] = WPAD_BUTTON_2;
|
||||
wmpadmap[i++] = WPAD_BUTTON_MINUS;
|
||||
wmpadmap[i++] = WPAD_BUTTON_PLUS;
|
||||
wmpadmap[i++] = WPAD_BUTTON_RIGHT;
|
||||
wmpadmap[i++] = WPAD_BUTTON_LEFT;
|
||||
wmpadmap[i++] = WPAD_BUTTON_UP;
|
||||
wmpadmap[i++] = WPAD_BUTTON_DOWN;
|
||||
wmpadmap[i++] = WPAD_BUTTON_B;
|
||||
wmpadmap[i++] = WPAD_BUTTON_A;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_1;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_2;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_MINUS;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_PLUS;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_RIGHT;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_LEFT;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_UP;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_DOWN;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_B;
|
||||
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_A;
|
||||
|
||||
/*** Classic Controller Padmap ***/
|
||||
i=0;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_Y;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_B;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_UP;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_FULL_R;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_Y;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_B;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_UP;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
||||
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_R;
|
||||
|
||||
/*** Nunchuk + wiimote Padmap ***/
|
||||
i=0;
|
||||
ncpadmap[i++] = WPAD_NUNCHUK_BUTTON_C;
|
||||
ncpadmap[i++] = WPAD_NUNCHUK_BUTTON_Z;
|
||||
ncpadmap[i++] = WPAD_BUTTON_MINUS;
|
||||
ncpadmap[i++] = WPAD_BUTTON_PLUS;
|
||||
ncpadmap[i++] = WPAD_BUTTON_UP;
|
||||
ncpadmap[i++] = WPAD_BUTTON_DOWN;
|
||||
ncpadmap[i++] = WPAD_BUTTON_LEFT;
|
||||
ncpadmap[i++] = WPAD_BUTTON_RIGHT;
|
||||
ncpadmap[i++] = WPAD_BUTTON_2;
|
||||
ncpadmap[i++] = WPAD_BUTTON_1;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_C;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_Z;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_MINUS;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_PLUS;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_UP;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_DOWN;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_LEFT;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_RIGHT;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_2;
|
||||
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_1;
|
||||
|
||||
/*** Keyboard map ***/
|
||||
i=0;
|
||||
kbpadmap[i++] = KB_X; // VBA stupidly has B on the right instead of left
|
||||
kbpadmap[i++] = KB_Z;
|
||||
kbpadmap[i++] = KB_BKSP;
|
||||
kbpadmap[i++] = KB_ENTER;
|
||||
kbpadmap[i++] = KB_UP;
|
||||
kbpadmap[i++] = KB_DOWN;
|
||||
kbpadmap[i++] = KB_LEFT;
|
||||
kbpadmap[i++] = KB_RIGHT;
|
||||
kbpadmap[i++] = KB_A;
|
||||
kbpadmap[i++] = KB_S;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_X; // VBA stupidly has B on the right instead of left
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_Z;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_BKSP;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_ENTER;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_UP;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_DOWN;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_LEFT;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_RIGHT;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_A;
|
||||
btnmap[CTRLR_KEYBOARD][i++] = KB_S;
|
||||
}
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
/****************************************************************************
|
||||
* ShutoffRumble
|
||||
***************************************************************************/
|
||||
@ -136,6 +141,7 @@ void ShutoffRumble()
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
WPAD_Rumble(i, 0);
|
||||
rumbleCount[i] = 0;
|
||||
}
|
||||
#endif
|
||||
PAD_ControlMotor(PAD_CHAN0, PAD_MOTOR_STOP);
|
||||
@ -164,10 +170,12 @@ void DoRumble(int i)
|
||||
WPAD_Rumble(i, 0); // rumble off
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void updateRumble() {
|
||||
static void updateRumble()
|
||||
{
|
||||
bool r = false;
|
||||
if (InMenu) r = (menuRumbleCount > 0);
|
||||
if (ConfigRequested) r = (menuRumbleCount > 0);
|
||||
else r = cartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0);
|
||||
|
||||
#ifdef HW_RVL
|
||||
@ -178,7 +186,7 @@ static void updateRumble() {
|
||||
}
|
||||
|
||||
void updateRumbleFrame() {
|
||||
// If we already rumbled continuously for more than 50 frames,
|
||||
// If we already rumbled continuously for more than 50 frames,
|
||||
// then disable rumbling for a while.
|
||||
if (rumbleCountAlready > 50) {
|
||||
gameRumbleCount = 0;
|
||||
@ -187,7 +195,7 @@ void updateRumbleFrame() {
|
||||
if (rumbleCountAlready > 50+10)
|
||||
rumbleCountAlready = 0;
|
||||
else rumbleCountAlready++;
|
||||
} else if (InMenu) {
|
||||
} else if (ConfigRequested) {
|
||||
if (menuRumbleCount>0)
|
||||
rumbleCountAlready++;
|
||||
} else {
|
||||
@ -195,7 +203,7 @@ void updateRumbleFrame() {
|
||||
rumbleCountAlready++;
|
||||
}
|
||||
updateRumble();
|
||||
if (gameRumbleCount>0 && !InMenu) gameRumbleCount--;
|
||||
if (gameRumbleCount>0 && !ConfigRequested) gameRumbleCount--;
|
||||
if (menuRumbleCount>0) menuRumbleCount--;
|
||||
}
|
||||
|
||||
@ -576,7 +584,7 @@ u32 DecodeKeyboard(unsigned short pad)
|
||||
#ifdef HW_RVL
|
||||
for (int i = 0; i < MAXJP; i++)
|
||||
{
|
||||
if (DownUsbKeys[kbpadmap[i]]) // keyboard
|
||||
if (DownUsbKeys[btnmap[CTRLR_KEYBOARD][i]]) // keyboard
|
||||
J |= vbapadmap[i];
|
||||
}
|
||||
#endif
|
||||
@ -589,7 +597,7 @@ u32 DecodeGamecube(unsigned short pad)
|
||||
u32 jp = PAD_ButtonsHeld(pad);
|
||||
for (int i = 0; i < MAXJP; i++)
|
||||
{
|
||||
if (jp & gcpadmap[i])
|
||||
if (jp & btnmap[CTRLR_GCPAD][i])
|
||||
J |= vbapadmap[i];
|
||||
}
|
||||
return J;
|
||||
@ -602,7 +610,7 @@ u32 DecodeWiimote(unsigned short pad)
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
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];
|
||||
}
|
||||
#endif
|
||||
@ -616,7 +624,7 @@ u32 DecodeClassic(unsigned short pad)
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
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];
|
||||
}
|
||||
#endif
|
||||
@ -630,7 +638,7 @@ u32 DecodeNunchuk(unsigned short pad)
|
||||
WPADData * wp = WPAD_Data(pad);
|
||||
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];
|
||||
}
|
||||
#endif
|
||||
@ -714,7 +722,7 @@ static u32 DecodeJoy(unsigned short pad)
|
||||
#endif
|
||||
|
||||
// check for games that should have special Wii controls
|
||||
if (GCSettings.WiiControls)
|
||||
if (GCSettings.WiiControls)
|
||||
switch (RomIdCode & 0xFFFFFF)
|
||||
{
|
||||
// Zelda
|
||||
@ -828,7 +836,7 @@ static u32 DecodeJoy(unsigned short pad)
|
||||
case BOKTAI2:
|
||||
case BOKTAI3:
|
||||
return Boktai2Input(pad);
|
||||
|
||||
|
||||
// One Piece
|
||||
case ONEPIECE:
|
||||
return OnePieceInput(pad);
|
||||
@ -859,12 +867,12 @@ static u32 DecodeJoy(unsigned short pad)
|
||||
|
||||
for (i = 0; i < MAXJP; i++)
|
||||
{
|
||||
if ((jp & gcpadmap[i]) // gamecube controller
|
||||
if ((jp & btnmap[CTRLR_GCPAD][i]) // gamecube controller
|
||||
#ifdef HW_RVL
|
||||
|| ( (wp->exp.type == WPAD_EXP_NONE) && (wp->btns_h & wmpadmap[i]) ) // wiimote
|
||||
|| ( (wp->exp.type == WPAD_EXP_CLASSIC) && (wp->btns_h & ccpadmap[i]) ) // classic controller
|
||||
|| ( (wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & ncpadmap[i]) ) // nunchuk + wiimote
|
||||
|| ( (DownUsbKeys[kbpadmap[i]]) ) // keyboard
|
||||
|| ( (wp->exp.type == WPAD_EXP_NONE) && (wp->btns_h & btnmap[CTRLR_WIIMOTE][i]) ) // wiimote
|
||||
|| ( (wp->exp.type == WPAD_EXP_CLASSIC) && (wp->btns_h & btnmap[CTRLR_CLASSIC][i]) ) // classic controller
|
||||
|| ( (wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & btnmap[CTRLR_NUNCHUK][i]) ) // nunchuk + wiimote
|
||||
|| ( (DownUsbKeys[btnmap[CTRLR_KEYBOARD][i]]) ) // keyboard
|
||||
#endif
|
||||
)
|
||||
J |= vbapadmap[i];
|
||||
@ -878,24 +886,11 @@ u32 GetJoy(int pad)
|
||||
pad = 0;
|
||||
|
||||
s8 gc_px = PAD_SubStickX(0);
|
||||
s8 gc_py = PAD_SubStickY(0);
|
||||
|
||||
#ifdef HW_RVL
|
||||
s8 wm_sy = WPAD_Stick (0,1,1);
|
||||
u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote / expansion button info
|
||||
u32 wm_pb = WPAD_ButtonsDown(0); // wiimote / expansion button info
|
||||
#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
|
||||
if ((gc_px < -70)
|
||||
#ifdef HW_RVL
|
||||
|
@ -12,10 +12,11 @@
|
||||
#define _INPUT_H_
|
||||
|
||||
#include <gccore.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#define PI 3.14159265f
|
||||
#define PADCAL 50
|
||||
#define MAXJP 10
|
||||
#define PI 3.14159265f
|
||||
#define PADCAL 50
|
||||
#define MAXJP 10 // # of mappable controller buttons
|
||||
|
||||
#define VBA_BUTTON_A 1
|
||||
#define VBA_BUTTON_B 2
|
||||
@ -30,13 +31,48 @@
|
||||
#define VBA_SPEED 1024
|
||||
#define VBA_CAPTURE 2048
|
||||
|
||||
extern int rumbleRequest[4];
|
||||
enum
|
||||
{
|
||||
TRIGGER_SIMPLE,
|
||||
TRIGGER_BUTTON_ONLY,
|
||||
TRIGGER_BUTTON_ONLY_IN_FOCUS
|
||||
};
|
||||
|
||||
extern unsigned int gcpadmap[];
|
||||
extern unsigned int wmpadmap[];
|
||||
extern unsigned int ccpadmap[];
|
||||
extern unsigned int ncpadmap[];
|
||||
extern unsigned int kbpadmap[];
|
||||
typedef struct _paddata {
|
||||
u16 btns_d;
|
||||
u16 btns_u;
|
||||
u16 btns_h;
|
||||
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 ShutoffRumble();
|
||||
|
@ -15,104 +15,133 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "vba.h"
|
||||
#include "video.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "preferences.h"
|
||||
#include "filebrowser.h"
|
||||
#include "fileop.h"
|
||||
#include "dvd.h"
|
||||
#include "images/saveicon.h"
|
||||
|
||||
static u8 * SysArea = NULL;
|
||||
static char savecomments[2][32];
|
||||
|
||||
/****************************************************************************
|
||||
* CardFileExists
|
||||
*
|
||||
* 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
|
||||
* MountMC
|
||||
*
|
||||
* Mounts the memory card in the given slot.
|
||||
* 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 tries = 0;
|
||||
|
||||
// Initialize Card System
|
||||
SysArea = (u8 *)memalign(32, CARD_WORKAREA);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("VBA0", "00");
|
||||
|
||||
// Mount the card
|
||||
while ( tries < 10 && ret != 0)
|
||||
while(tries < 10 && ret != 0)
|
||||
{
|
||||
EXI_ProbeReset ();
|
||||
ret = CARD_Mount (cslot, &SysArea, NULL);
|
||||
updateRumbleFrame ();
|
||||
VIDEO_WaitVSync ();
|
||||
EXI_ProbeReset();
|
||||
ret = CARD_Mount (slot, SysArea, NULL);
|
||||
VIDEO_WaitVSync();
|
||||
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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* TestCard
|
||||
* TestMC
|
||||
*
|
||||
* 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
|
||||
#ifdef HW_RVL
|
||||
return false;
|
||||
#endif
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("VBA0", "00");
|
||||
bool ret = false;
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
if (MountCard(slot, silent, (u8 *)SysArea) == 0)
|
||||
// Try to mount the card
|
||||
if (MountMC(slot, silent) == 0)
|
||||
{
|
||||
// Mount successful!
|
||||
if(!silent)
|
||||
{
|
||||
if (slot == CARD_SLOTA)
|
||||
WaitPrompt("Mounted Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt("Mounted Slot B Memory Card!");
|
||||
}
|
||||
CARD_Unmount (slot);
|
||||
return true;
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!silent)
|
||||
{
|
||||
if (slot == CARD_SLOTA)
|
||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
||||
}
|
||||
free(SysArea);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return false;
|
||||
/****************************************************************************
|
||||
* 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
|
||||
{
|
||||
browserList = newBrowserList;
|
||||
}
|
||||
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy(browserList[entryNum].filename, (char *)CardDir.filename, MAXJOLIET);
|
||||
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);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
card_file CardFile;
|
||||
unsigned char verifbuffer[65536] ATTRIBUTE_ALIGN (32);
|
||||
unsigned char verifybuffer[65536] ATTRIBUTE_ALIGN (32);
|
||||
int CardError;
|
||||
unsigned int blocks;
|
||||
unsigned int SectorSize;
|
||||
char msg[80];
|
||||
int bytesleft = 0;
|
||||
int bytesread = 0;
|
||||
int bytesleft = 0;
|
||||
int bytesread = 0;
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("VBA0", "00");
|
||||
memset (verifybuffer, 0, 65536);
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
||||
// Get Sector Size
|
||||
CARD_GetSectorSize (slot, &SectorSize);
|
||||
|
||||
if (CardError == 0)
|
||||
memset (&CardFile, 0, sizeof (CardFile));
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
|
||||
if(CardError)
|
||||
{
|
||||
ErrorPrompt("Unable to open file!");
|
||||
}
|
||||
else
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
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));
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
|
||||
blocks = CardFile.len;
|
||||
|
||||
if (blocks < SectorSize)
|
||||
@ -161,41 +180,29 @@ VerifyMCFile (char *buf, int slot, char *filename, int datasize)
|
||||
if (blocks % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
if (blocks > (unsigned int)datasize)
|
||||
blocks = datasize;
|
||||
if (blocks > (unsigned int)datasize)
|
||||
blocks = datasize;
|
||||
|
||||
memset (verifbuffer, 0, 65536);
|
||||
bytesleft = blocks;
|
||||
bytesread = 0;
|
||||
while (bytesleft > 0)
|
||||
{
|
||||
CARD_Read (&CardFile, verifbuffer, SectorSize, bytesread);
|
||||
if ( memcmp (buf + bytesread, verifbuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
|
||||
{
|
||||
CARD_Close (&CardFile);
|
||||
CARD_Unmount (slot);
|
||||
WaitPrompt("File did not verify!");
|
||||
return 0;
|
||||
}
|
||||
CardError = CARD_Read (&CardFile, verifybuffer, SectorSize, bytesread);
|
||||
if (CardError || memcmp (buf + bytesread, verifybuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
|
||||
{
|
||||
bytesread = 0;
|
||||
ErrorPrompt("File integrity could not be verified!");
|
||||
break;
|
||||
}
|
||||
|
||||
bytesleft -= SectorSize;
|
||||
bytesread += SectorSize;
|
||||
|
||||
sprintf (msg, "Verified %d of %d bytes", bytesread, blocks);
|
||||
ShowProgress (msg, bytesread, blocks);
|
||||
ShowProgress ("Verifying...", bytesread, blocks);
|
||||
}
|
||||
CARD_Close (&CardFile);
|
||||
CARD_Unmount (slot);
|
||||
|
||||
return 1;
|
||||
CancelAction();
|
||||
}
|
||||
else
|
||||
if (slot == CARD_SLOTA)
|
||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
||||
|
||||
return 0;
|
||||
return bytesread;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -209,59 +216,63 @@ LoadMCFile (char *buf, int slot, char *filename, bool silent)
|
||||
int CardError;
|
||||
unsigned int blocks;
|
||||
unsigned int SectorSize;
|
||||
int bytesleft = 0;
|
||||
int bytesread = 0;
|
||||
int bytesleft = 0;
|
||||
int bytesread = 0;
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("VBA0", "00");
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
||||
// Try to mount the card
|
||||
CardError = MountMC(slot, NOTSILENT);
|
||||
|
||||
if (CardError == 0)
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
// Get Sector Size
|
||||
CARD_GetSectorSize (slot, &SectorSize);
|
||||
|
||||
if (!CardFileExists (filename, slot))
|
||||
{
|
||||
if (!silent)
|
||||
WaitPrompt("Unable to open file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset (&CardFile, 0, sizeof (CardFile));
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
|
||||
blocks = CardFile.len;
|
||||
|
||||
if (blocks < SectorSize)
|
||||
blocks = SectorSize;
|
||||
|
||||
if (blocks % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
memset (buf, 0, 0x22000);
|
||||
|
||||
bytesleft = blocks;
|
||||
bytesread = 0;
|
||||
while (bytesleft > 0)
|
||||
if(CardError)
|
||||
{
|
||||
CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
|
||||
bytesleft -= SectorSize;
|
||||
bytesread += SectorSize;
|
||||
if(!silent)
|
||||
ErrorPrompt("Unable to open file!");
|
||||
}
|
||||
CARD_Close (&CardFile);
|
||||
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!");
|
||||
{
|
||||
blocks = CardFile.len;
|
||||
|
||||
if (blocks < SectorSize)
|
||||
blocks = SectorSize;
|
||||
|
||||
if (blocks % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
bytesleft = blocks;
|
||||
bytesread = 0;
|
||||
while (bytesleft > 0)
|
||||
{
|
||||
CardError = CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
|
||||
|
||||
if(CardError)
|
||||
{
|
||||
ErrorPrompt("Error loading file!");
|
||||
bytesread = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
bytesleft -= SectorSize;
|
||||
bytesread += SectorSize;
|
||||
ShowProgress ("Loading...", bytesread, blocks);
|
||||
}
|
||||
CARD_Close (&CardFile);
|
||||
CancelAction();
|
||||
}
|
||||
CARD_Unmount(slot);
|
||||
}
|
||||
|
||||
// discard save icon and comments
|
||||
memmove(buf, buf+sizeof(saveicon)+64, bytesread);
|
||||
bytesread -= (sizeof(saveicon)+64);
|
||||
|
||||
free(SysArea);
|
||||
return bytesread;
|
||||
}
|
||||
|
||||
@ -277,99 +288,59 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
||||
int CardError;
|
||||
unsigned int blocks;
|
||||
unsigned int SectorSize;
|
||||
char msg[80];
|
||||
int byteswritten = 0;
|
||||
int bytesleft = 0;
|
||||
|
||||
if(datasize <= 0)
|
||||
return 0;
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("VBA0", "00");
|
||||
// add save icon and comments
|
||||
memmove(buf+sizeof(saveicon)+64, buf, datasize);
|
||||
memcpy(buf, saveicon, sizeof(saveicon));
|
||||
memcpy(buf+sizeof(saveicon), savecomments, 64);
|
||||
datasize += (sizeof(saveicon)+64);
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
||||
// Try to mount the card
|
||||
CardError = MountMC(slot, NOTSILENT);
|
||||
|
||||
if (CardError == 0)
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
// Get Sector Size
|
||||
CARD_GetSectorSize (slot, &SectorSize);
|
||||
|
||||
/*** Calculate number of blocks required ***/
|
||||
// Calculate number of blocks required
|
||||
blocks = (datasize / SectorSize) * SectorSize;
|
||||
if (datasize % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
/*** Does this file exist ? ***/
|
||||
if (CardFileExists (filename, slot))
|
||||
// Delete existing file (if present)
|
||||
memset(&CardStatus, 0, sizeof(card_stat));
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
|
||||
if(CardError == 0)
|
||||
{
|
||||
/*** Try to open the file ***/
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
CARD_Close (&CardFile);
|
||||
CardError = CARD_Delete(slot, filename);
|
||||
if (CardError)
|
||||
{
|
||||
CARD_Unmount (slot);
|
||||
WaitPrompt("Unable to open card file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( (s32)blocks > CardFile.len ) /*** new data is longer ***/
|
||||
{
|
||||
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);
|
||||
if (CardError)
|
||||
{
|
||||
CARD_Unmount (slot);
|
||||
WaitPrompt("Unable to delete existing file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*** Create new, longer file ***/
|
||||
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
||||
if (CardError)
|
||||
{
|
||||
CARD_Unmount (slot);
|
||||
WaitPrompt("Unable to create updated card 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
|
||||
WaitPrompt("Unable to create card file!");
|
||||
return 0;
|
||||
ErrorPrompt("Unable to delete existing file!");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/*** Now, have an open file handle, ready to send out the data ***/
|
||||
// Create new file
|
||||
memset(&CardStatus, 0, sizeof(card_stat));
|
||||
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
||||
if (CardError)
|
||||
{
|
||||
if (CardError == CARD_ERROR_INSSPACE)
|
||||
ErrorPrompt("Insufficient space to create file!");
|
||||
else
|
||||
ErrorPrompt("Unable to create card file!");
|
||||
goto done;
|
||||
}
|
||||
|
||||
// Now, have an open file handle, ready to send out the data
|
||||
CARD_GetStatus (slot, CardFile.filenum, &CardStatus);
|
||||
CardStatus.icon_addr = 0x0;
|
||||
CardStatus.icon_fmt = 2;
|
||||
@ -377,40 +348,43 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
||||
CardStatus.comment_addr = 2048;
|
||||
CARD_SetStatus (slot, CardFile.filenum, &CardStatus);
|
||||
|
||||
int byteswritten = 0;
|
||||
int bytesleft = blocks;
|
||||
bytesleft = blocks;
|
||||
|
||||
while (bytesleft > 0)
|
||||
{
|
||||
CardError =
|
||||
CARD_Write (&CardFile, buf + byteswritten,
|
||||
SectorSize, byteswritten);
|
||||
CARD_Write (&CardFile, buf + byteswritten, SectorSize, byteswritten);
|
||||
|
||||
if(CardError)
|
||||
{
|
||||
ErrorPrompt("Error writing file!");
|
||||
byteswritten = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
bytesleft -= SectorSize;
|
||||
byteswritten += SectorSize;
|
||||
|
||||
sprintf (msg, "Wrote %d of %d bytes", byteswritten, blocks);
|
||||
ShowProgress (msg, byteswritten, blocks);
|
||||
ShowProgress ("Saving...", byteswritten, blocks);
|
||||
}
|
||||
|
||||
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
|
||||
because the file could be longer due to past writes ***/
|
||||
if ( VerifyMCFile (buf, slot, filename, byteswritten) )
|
||||
return byteswritten;
|
||||
else
|
||||
return 0;
|
||||
// Verify the written file
|
||||
if (!VerifyMCFile (buf, slot, filename, byteswritten) )
|
||||
byteswritten = 0;
|
||||
}
|
||||
else
|
||||
return byteswritten;
|
||||
done:
|
||||
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
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _NGCMCSAVE_
|
||||
#define _NGCMCSAVE_
|
||||
#ifndef _MEMCARDOP_
|
||||
#define _MEMCARDOP_
|
||||
|
||||
int ParseMCDirectory (int slot);
|
||||
int LoadMCFile (char *buf, int slot, char *filename, 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
|
||||
|
3777
source/ngc/menu.cpp
3777
source/ngc/menu.cpp
File diff suppressed because it is too large
Load Diff
@ -9,9 +9,38 @@
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _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
|
||||
|
@ -8,18 +8,20 @@
|
||||
* Network and SMB support routines
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
#include <network.h>
|
||||
#include <smb.h>
|
||||
#include <mxml.h>
|
||||
|
||||
#include "unzip.h"
|
||||
#include "miniunz.h"
|
||||
|
||||
#include "vba.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "fileop.h"
|
||||
#include "http.h"
|
||||
|
||||
static bool inNetworkInit = false;
|
||||
static bool networkInit = false;
|
||||
static bool autoNetworkInit = true;
|
||||
static bool networkShareInit = false;
|
||||
@ -44,7 +46,7 @@ void UpdateCheck()
|
||||
|
||||
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);
|
||||
retval = http_request(url, NULL, tmpbuffer, 32768);
|
||||
memset(url, 0, 128);
|
||||
@ -64,7 +66,7 @@ void UpdateCheck()
|
||||
{
|
||||
const char * version = mxmlElementGetAttr(item, "version");
|
||||
|
||||
if(version)
|
||||
if(version && strlen(version) == 5)
|
||||
{
|
||||
int verMajor = version[0] - '0';
|
||||
int verMinor = version[2] - '0';
|
||||
@ -78,8 +80,8 @@ void UpdateCheck()
|
||||
verMinor >= 0 && verMinor <= 9 &&
|
||||
verPoint >= 0 && verPoint <= 9) &&
|
||||
(verMajor > curMajor ||
|
||||
verMinor > curMinor ||
|
||||
verPoint > curPoint))
|
||||
(verMajor == curMajor && verMinor > curMinor) ||
|
||||
(verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
|
||||
{
|
||||
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
|
||||
if(item)
|
||||
@ -147,12 +149,12 @@ bool DownloadUpdate()
|
||||
if(unzipResult)
|
||||
{
|
||||
result = true;
|
||||
WaitPrompt("Update successful!");
|
||||
InfoPrompt("Update successful!");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
WaitPrompt("Update failed!");
|
||||
ErrorPrompt("Update failed!");
|
||||
}
|
||||
|
||||
updateFound = false; // updating is finished (successful or not!)
|
||||
@ -178,6 +180,14 @@ void InitializeNetwork(bool silent)
|
||||
if(!silent)
|
||||
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];
|
||||
s32 initResult = if_config(ip, NULL, NULL, true);
|
||||
|
||||
@ -194,15 +204,18 @@ void InitializeNetwork(bool silent)
|
||||
{
|
||||
char msg[150];
|
||||
sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
|
||||
WaitPrompt(msg);
|
||||
ErrorPrompt(msg);
|
||||
}
|
||||
}
|
||||
if(!silent)
|
||||
CancelAction();
|
||||
inNetworkInit = false;
|
||||
}
|
||||
|
||||
void CloseShare()
|
||||
{
|
||||
if(networkShareInit)
|
||||
smbClose("smb:");
|
||||
smbClose("smb");
|
||||
networkShareInit = false;
|
||||
networkInit = false; // trigger a network reinit
|
||||
}
|
||||
@ -243,7 +256,7 @@ ConnectShare (bool silent)
|
||||
sprintf(msg, "Share IP is blank.");
|
||||
|
||||
sprintf(msg2, "Invalid network settings - %s", msg);
|
||||
WaitPrompt(msg2);
|
||||
ErrorPrompt(msg2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -266,11 +279,15 @@ ConnectShare (bool silent)
|
||||
{
|
||||
networkShareInit = true;
|
||||
}
|
||||
if(!silent)
|
||||
CancelAction();
|
||||
}
|
||||
|
||||
if(!networkShareInit && !silent)
|
||||
WaitPrompt ("Failed to connect to network share.");
|
||||
ErrorPrompt("Failed to connect to network share.");
|
||||
}
|
||||
|
||||
return networkShareInit;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -15,12 +15,13 @@
|
||||
#include <mxml.h>
|
||||
|
||||
#include "vba.h"
|
||||
#include "images/saveicon.h"
|
||||
#include "menudraw.h"
|
||||
#include "vbaconfig.h"
|
||||
#include "menu.h"
|
||||
#include "memcardop.h"
|
||||
#include "fileop.h"
|
||||
#include "filesel.h"
|
||||
#include "filebrowser.h"
|
||||
#include "input.h"
|
||||
#include "button_mapping.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Prepare Preferences Data
|
||||
@ -107,31 +108,12 @@ static const char * XMLSaveCallback(mxml_node_t *node, int where)
|
||||
static int
|
||||
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");
|
||||
mxmlSetWrapMargin(0); // disable line wrapping
|
||||
|
||||
data = mxmlNewElement(xml, "file");
|
||||
mxmlElementSetAttr(data, "app",APPNAME);
|
||||
mxmlElementSetAttr(data, "version",APPVERSION);
|
||||
mxmlElementSetAttr(data, "app", APPNAME);
|
||||
mxmlElementSetAttr(data, "version", APPVERSION);
|
||||
|
||||
createXMLSection("File", "File Settings");
|
||||
|
||||
@ -151,23 +133,29 @@ preparePrefsData (int method)
|
||||
createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
|
||||
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("render", "Video Filtering", toStr(GCSettings.render));
|
||||
createXMLSetting("scaling", "Aspect Ratio Correction", toStr(GCSettings.scaling));
|
||||
createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
|
||||
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");
|
||||
|
||||
createXMLSetting("WiiControls", "Match Wii Game", toStr(GCSettings.WiiControls));
|
||||
createXMLController(gcpadmap, "gcpadmap", "GameCube Pad");
|
||||
createXMLController(wmpadmap, "wmpadmap", "Wiimote");
|
||||
createXMLController(ccpadmap, "ccpadmap", "Classic Controller");
|
||||
createXMLController(ncpadmap, "ncpadmap", "Nunchuk");
|
||||
createXMLController(kbpadmap, "kbpadmap", "Keyboard");
|
||||
createXMLController(btnmap[CTRLR_GCPAD], "gcpadmap", "GameCube Pad");
|
||||
createXMLController(btnmap[CTRLR_WIIMOTE], "wmpadmap", "Wiimote");
|
||||
createXMLController(btnmap[CTRLR_CLASSIC], "ccpadmap", "Classic Controller");
|
||||
createXMLController(btnmap[CTRLR_NUNCHUK], "ncpadmap", "Nunchuk");
|
||||
createXMLController(btnmap[CTRLR_KEYBOARD], "kbpadmap", "Keyboard");
|
||||
|
||||
int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);
|
||||
|
||||
@ -176,7 +164,6 @@ preparePrefsData (int method)
|
||||
return datasize;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* loadXMLSetting
|
||||
*
|
||||
@ -250,26 +237,19 @@ static bool
|
||||
decodePrefsData (int method)
|
||||
{
|
||||
bool result = false;
|
||||
int offset = 0;
|
||||
|
||||
// skip save icon and comments for Memory Card saves
|
||||
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);
|
||||
xml = mxmlLoadString(NULL, (char *)savebuffer, MXML_TEXT_CALLBACK);
|
||||
|
||||
if(xml)
|
||||
{
|
||||
// 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);
|
||||
if(item) // a version entry exists
|
||||
{
|
||||
const char * version = mxmlElementGetAttr(item, "version");
|
||||
|
||||
if(version)
|
||||
if(version && strlen(version) == 5)
|
||||
{
|
||||
// this code assumes version in format X.X.X
|
||||
// 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.smbpwd, "smbpwd", sizeof(GCSettings.smbpwd));
|
||||
|
||||
// Emulation Settings
|
||||
// Video Settings
|
||||
|
||||
loadXMLSetting(&GCSettings.Zoom, "Zoom");
|
||||
loadXMLSetting(&GCSettings.ZoomLevel, "ZoomLevel");
|
||||
loadXMLSetting(&GCSettings.render, "render");
|
||||
loadXMLSetting(&GCSettings.scaling, "scaling");
|
||||
loadXMLSetting(&GCSettings.xshift, "xshift");
|
||||
loadXMLSetting(&GCSettings.yshift, "yshift");
|
||||
|
||||
// Menu Settings
|
||||
|
||||
loadXMLSetting(&GCSettings.WiimoteOrientation, "WiimoteOrientation");
|
||||
loadXMLSetting(&GCSettings.ExitAction, "ExitAction");
|
||||
loadXMLSetting(&GCSettings.MusicVolume, "MusicVolume");
|
||||
loadXMLSetting(&GCSettings.SFXVolume, "SFXVolume");
|
||||
|
||||
// Controller Settings
|
||||
|
||||
loadXMLSetting(&GCSettings.WiiControls, "WiiControls");
|
||||
loadXMLController(gcpadmap, "gcpadmap");
|
||||
loadXMLController(wmpadmap, "wmpadmap");
|
||||
loadXMLController(ccpadmap, "ccpadmap");
|
||||
loadXMLController(ncpadmap, "ncpadmap");
|
||||
loadXMLController(kbpadmap, "kbpadmap");
|
||||
loadXMLController(btnmap[CTRLR_GCPAD], "gcpadmap");
|
||||
loadXMLController(btnmap[CTRLR_WIIMOTE], "wmpadmap");
|
||||
loadXMLController(btnmap[CTRLR_CLASSIC], "ccpadmap");
|
||||
loadXMLController(btnmap[CTRLR_NUNCHUK], "ncpadmap");
|
||||
loadXMLController(btnmap[CTRLR_KEYBOARD], "kbpadmap");
|
||||
}
|
||||
mxmlDelete(xml);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -352,23 +337,40 @@ SavePrefs (bool silent)
|
||||
// is the method preferences will be loaded from by default
|
||||
int method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
||||
return false;
|
||||
|
||||
if (!silent)
|
||||
ShowAction ("Saving preferences...");
|
||||
|
||||
FixInvalidSettings();
|
||||
|
||||
AllocSaveBuffer ();
|
||||
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);
|
||||
|
||||
FreeSaveBuffer ();
|
||||
|
||||
CancelAction();
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
if (!silent)
|
||||
WaitPrompt ("Preferences saved");
|
||||
InfoPrompt("Preferences saved");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -403,20 +405,29 @@ LoadPrefsFromMethod (int method)
|
||||
* Load Preferences
|
||||
* Checks sources consecutively until we find a preference file
|
||||
***************************************************************************/
|
||||
static bool prefLoaded = false;
|
||||
|
||||
bool LoadPrefs()
|
||||
{
|
||||
ShowAction ("Loading preferences...");
|
||||
if(prefLoaded) // already attempted loading
|
||||
return true;
|
||||
|
||||
bool prefFound = false;
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
||||
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_USB);
|
||||
if(!prefFound && TestCard(CARD_SLOTA, SILENT))
|
||||
if(!prefFound && TestMC(CARD_SLOTA, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTA);
|
||||
if(!prefFound && TestCard(CARD_SLOTB, SILENT))
|
||||
if(!prefFound && TestMC(CARD_SLOTB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTB);
|
||||
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_SMB);
|
||||
|
||||
prefLoaded = true; // attempted to load preferences
|
||||
|
||||
if(prefFound)
|
||||
FixInvalidSettings();
|
||||
|
||||
return prefFound;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "FreeTypeGX.h"
|
||||
|
||||
#include "gba/Sound.h"
|
||||
|
||||
#include "vba.h"
|
||||
@ -30,21 +32,21 @@ extern "C" {
|
||||
#include "audio.h"
|
||||
#include "dvd.h"
|
||||
#include "networkop.h"
|
||||
#include "filebrowser.h"
|
||||
#include "fileop.h"
|
||||
#include "menu.h"
|
||||
#include "menudraw.h"
|
||||
#include "input.h"
|
||||
#include "video.h"
|
||||
#include "vbaconfig.h"
|
||||
#include "wiiusbsupport.h"
|
||||
|
||||
extern bool ROMLoaded;
|
||||
extern int emulating;
|
||||
bool InMenu = true;
|
||||
int ConfigRequested = 0;
|
||||
int ShutdownRequested = 0;
|
||||
int ResetRequested = 0;
|
||||
int ExitRequested = 0;
|
||||
char appPath[1024];
|
||||
FreeTypeGX *fontSystem;
|
||||
|
||||
/****************************************************************************
|
||||
* Shutdown / Reboot / Exit
|
||||
@ -56,9 +58,11 @@ static void ExitCleanup()
|
||||
ShutoffRumble();
|
||||
StopWiiKeyboard();
|
||||
#endif
|
||||
ShutdownAudio();
|
||||
StopGX();
|
||||
|
||||
LWP_SuspendThread (devicethread);
|
||||
UnmountAllFAT();
|
||||
CloseShare();
|
||||
|
||||
#ifdef HW_RVL
|
||||
DI_Close();
|
||||
@ -71,27 +75,32 @@ static void ExitCleanup()
|
||||
void (*PSOReload) () = (void (*)()) 0x80001800;
|
||||
#endif
|
||||
|
||||
void Reboot()
|
||||
void ExitApp()
|
||||
{
|
||||
ExitCleanup();
|
||||
#ifdef HW_RVL
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
#else
|
||||
#define SOFTRESET_ADR ((volatile u32*)0xCC003024)
|
||||
*SOFTRESET_ADR = 0x00000000;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExitToLoader()
|
||||
{
|
||||
ExitCleanup();
|
||||
// Exit to Loader
|
||||
#ifdef HW_RVL
|
||||
exit(0);
|
||||
#else // gamecube
|
||||
if (psoid[0] == PSOSDLOADID)
|
||||
PSOReload();
|
||||
#endif
|
||||
if(GCSettings.ExitAction == 0) // Exit to Loader
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
exit(0);
|
||||
#else
|
||||
if (psoid[0] == PSOSDLOADID)
|
||||
PSOReload ();
|
||||
#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
|
||||
@ -185,13 +194,13 @@ int main(int argc, char *argv[])
|
||||
WPAD_Init();
|
||||
#endif
|
||||
|
||||
InitialiseVideo();
|
||||
InitializeVideo();
|
||||
ResetVideo_Menu (); // change to menu video mode
|
||||
|
||||
#ifdef HW_RVL
|
||||
// read wiimote accelerometer and IR data
|
||||
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
|
||||
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
|
||||
@ -199,30 +208,24 @@ int main(int argc, char *argv[])
|
||||
SYS_SetResetCallback(ResetCB);
|
||||
#endif
|
||||
|
||||
// Initialise freetype font system
|
||||
if (FT_Init ())
|
||||
{
|
||||
printf ("Cannot initialise font subsystem!\n");
|
||||
while (1);
|
||||
}
|
||||
|
||||
// Initialize libFAT for SD and USB
|
||||
MountAllFAT();
|
||||
MountAllFAT(); // Initialize libFAT for SD and USB
|
||||
|
||||
// Initialize DVD subsystem (GameCube only)
|
||||
#ifdef HW_DOL
|
||||
DVD_Init ();
|
||||
#endif
|
||||
|
||||
// Check if DVD drive belongs to a Wii
|
||||
SetDVDDriveType();
|
||||
|
||||
SetDVDDriveType(); // Check if DVD drive belongs to a Wii
|
||||
InitialiseSound();
|
||||
|
||||
InitialisePalette();
|
||||
DefaultSettings (); // Set defaults
|
||||
|
||||
// Set defaults
|
||||
DefaultSettings ();
|
||||
// Initialize font system
|
||||
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
|
||||
sprintf(appPath, "vbagx");
|
||||
@ -231,18 +234,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
StartWiiKeyboardMouse();
|
||||
|
||||
int selectedMenu = -1;
|
||||
|
||||
// Load preferences
|
||||
if(!LoadPrefs())
|
||||
{
|
||||
WaitPrompt("Preferences reset - check settings!");
|
||||
selectedMenu = 2; // change to preferences menu
|
||||
}
|
||||
|
||||
while(1) // main loop
|
||||
{
|
||||
InMenu = true;
|
||||
#ifdef HW_RVL
|
||||
if(ShutdownRequested)
|
||||
ShutdownWii();
|
||||
@ -252,15 +245,22 @@ int main(int argc, char *argv[])
|
||||
// since we're entering the menu
|
||||
LWP_ResumeThread (devicethread);
|
||||
|
||||
MainMenu(selectedMenu);
|
||||
selectedMenu = 3; // return to game menu from now on
|
||||
ConfigRequested = 1;
|
||||
SwitchAudioMode(1);
|
||||
|
||||
if(!ROMLoaded)
|
||||
MainMenu(MENU_GAMESELECTION);
|
||||
else
|
||||
MainMenu(MENU_GAME);
|
||||
|
||||
ConfigRequested = 0;
|
||||
SwitchAudioMode(0);
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're starting emulation again
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
ResetVideo_Emu();
|
||||
InMenu = false;
|
||||
|
||||
while (emulating) // emulation loop
|
||||
{
|
||||
@ -274,30 +274,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(ConfigRequested)
|
||||
{
|
||||
InMenu = true;
|
||||
ShutoffRumble();
|
||||
StopAudio();
|
||||
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;
|
||||
TakeScreenshot();
|
||||
ResetVideo_Menu();
|
||||
break; // leave emulation loop
|
||||
}
|
||||
}
|
||||
}
|
||||
} // emulation loop
|
||||
} // main loop
|
||||
}
|
||||
|
@ -10,6 +10,9 @@
|
||||
#ifndef _VBAGX_H_
|
||||
#define _VBAGX_H_
|
||||
|
||||
#include "FreeTypeGX.h"
|
||||
#include "filelist.h"
|
||||
|
||||
#define APPNAME "Visual Boy Advance GX"
|
||||
#define APPVERSION "1.0.8"
|
||||
#define PREF_FILE_NAME "settings.xml"
|
||||
@ -45,29 +48,32 @@ struct SGCSettings{
|
||||
char LoadFolder[200]; // Path to game files
|
||||
char SaveFolder[200]; // Path to save files
|
||||
char CheatFolder[200]; // Path to cheat files
|
||||
int VerifySaves;
|
||||
|
||||
char smbip[16];
|
||||
char smbuser[20];
|
||||
char smbpwd[20];
|
||||
char smbshare[20];
|
||||
|
||||
int Zoom; // 0 - off, 1 - on
|
||||
float ZoomLevel; // zoom amount
|
||||
int scaling; // 0 - default, 1 - partial stretch, 2 - stretch to fit, 3 - widescreen correction
|
||||
int render; // 0 - original, 1 - filtered, 2 - unfiltered
|
||||
int VerifySaves;
|
||||
int xshift; // video output shift
|
||||
int yshift;
|
||||
int WiiControls; // Match Wii Game
|
||||
int WiimoteOrientation;
|
||||
int ExitAction;
|
||||
int MusicVolume;
|
||||
int SFXVolume;
|
||||
};
|
||||
|
||||
void ExitToLoader();
|
||||
void Reboot();
|
||||
void ExitApp();
|
||||
void ShutdownWii();
|
||||
extern struct SGCSettings GCSettings;
|
||||
extern int ConfigRequested;
|
||||
extern int ShutdownRequested;
|
||||
extern int ExitRequested;
|
||||
extern char appPath[];
|
||||
extern FreeTypeGX *fontSystem;
|
||||
|
||||
#endif
|
||||
|
@ -16,6 +16,33 @@
|
||||
|
||||
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
|
||||
DefaultSettings ()
|
||||
{
|
||||
@ -44,12 +71,16 @@ DefaultSettings ()
|
||||
GCSettings.WiimoteOrientation = 0;
|
||||
|
||||
GCSettings.VerifySaves = 0;
|
||||
GCSettings.Zoom = 0; // zooming default off
|
||||
GCSettings.ZoomLevel = 1.0; // zoom level
|
||||
GCSettings.render = 1; // Filtered
|
||||
GCSettings.scaling = 1; // partial stretch
|
||||
GCSettings.WiiControls = true; // Match Wii Game
|
||||
GCSettings.WiiControls = false; // Match Wii Game
|
||||
|
||||
GCSettings.xshift = 0; // video shift
|
||||
GCSettings.yshift = 0;
|
||||
GCSettings.xshift = 0; // horizontal video shift
|
||||
GCSettings.yshift = 0; // vertical video shift
|
||||
|
||||
GCSettings.WiimoteOrientation = 0;
|
||||
GCSettings.ExitAction = 0;
|
||||
GCSettings.MusicVolume = 40;
|
||||
GCSettings.SFXVolume = 40;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#define _VBACONFIG_
|
||||
|
||||
void FixInvalidSettings();
|
||||
void DefaultSettings ();
|
||||
|
||||
#endif
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "pngu/pngu.h"
|
||||
|
||||
#include "unzip.h"
|
||||
#include "Util.h"
|
||||
#include "common/Port.h"
|
||||
@ -32,6 +34,7 @@
|
||||
|
||||
#include "vba.h"
|
||||
#include "fileop.h"
|
||||
#include "filebrowser.h"
|
||||
#include "dvd.h"
|
||||
#include "memcardop.h"
|
||||
#include "audio.h"
|
||||
@ -39,10 +42,9 @@
|
||||
#include "input.h"
|
||||
#include "gameinput.h"
|
||||
#include "video.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "gcunzip.h"
|
||||
#include "gamesettings.h"
|
||||
#include "images/saveicon.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -251,9 +253,8 @@ int MemCPUWriteBatteryFile(char * membuffer)
|
||||
* 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;
|
||||
int offset = 0;
|
||||
|
||||
@ -270,15 +271,6 @@ bool LoadBatteryOrState(int method, int action, bool silent)
|
||||
// load the file into savebuffer
|
||||
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
|
||||
if (offset > 0)
|
||||
{
|
||||
@ -302,21 +294,36 @@ bool LoadBatteryOrState(int method, int action, bool silent)
|
||||
if(offset == 0)
|
||||
{
|
||||
if(action == FILE_SRAM)
|
||||
WaitPrompt ("Save file not found");
|
||||
ErrorPrompt ("Save file not found");
|
||||
else
|
||||
WaitPrompt ("State file not found");
|
||||
ErrorPrompt ("State file not found");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(action == FILE_SRAM)
|
||||
WaitPrompt ("Invalid save file");
|
||||
ErrorPrompt ("Invalid save file");
|
||||
else
|
||||
WaitPrompt ("Invalid state file");
|
||||
ErrorPrompt ("Invalid state file");
|
||||
}
|
||||
}
|
||||
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
|
||||
@ -325,46 +332,34 @@ bool LoadBatteryOrState(int method, int action, bool silent)
|
||||
* 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];
|
||||
bool result = false;
|
||||
int offset = 0;
|
||||
int datasize = 0; // we need the actual size of the data written
|
||||
int imgSize = 0; // image screenshot bytes written
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(!MakeFilePath(filepath, action, method))
|
||||
return false;
|
||||
|
||||
ShowAction ("Saving...");
|
||||
|
||||
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)
|
||||
{
|
||||
char savecomment[2][32];
|
||||
memset(savecomment, 0, 64);
|
||||
char savecomments[2][32];
|
||||
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)
|
||||
sprintf(savetype, "SRAM");
|
||||
else
|
||||
sprintf(savetype, "Freeze");
|
||||
|
||||
sprintf (savecomment[0], "%s %s", APPNAME, savetype);
|
||||
strncpy(savecomment[1], ROMFilename, 31); // truncate filename to 31 chars
|
||||
savecomment[1][31] = 0; // make sure last char is null byte
|
||||
memcpy (savebuffer + offset, savecomment, 64);
|
||||
offset += 64;
|
||||
sprintf (savecomments[0], "%s %s", APPNAME, savetype);
|
||||
snprintf (savecomments[1], 32, ROMFilename);
|
||||
SetMCSaveComments(savecomments);
|
||||
}
|
||||
|
||||
// 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(!silent)
|
||||
WaitPrompt ("Save successful");
|
||||
InfoPrompt ("Save successful");
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt("No data to save!");
|
||||
InfoPrompt("No data to save!");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
****************************************************************************/
|
||||
@ -877,13 +912,13 @@ bool LoadVBAROM(int method)
|
||||
else if(utilIsGBImage(zippedFilename))
|
||||
cartridgeType = 1;
|
||||
else {
|
||||
WaitPrompt("Rom must be 1st file in zip, or unzipped!");
|
||||
ErrorPrompt("Rom must be 1st file in zip, or unzipped!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // loading the file failed
|
||||
{
|
||||
WaitPrompt("Empty or invalid zip file!");
|
||||
ErrorPrompt("Empty or invalid zip file!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -892,7 +927,7 @@ bool LoadVBAROM(int method)
|
||||
if(cartridgeType != 1 && cartridgeType != 2)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -945,7 +980,7 @@ bool LoadVBAROM(int method)
|
||||
|
||||
if(!loaded)
|
||||
{
|
||||
WaitPrompt("Error loading game!");
|
||||
ErrorPrompt("Error loading game!");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
@ -22,7 +22,9 @@ extern bool TiltSideways;
|
||||
|
||||
bool LoadVBAROM(int method);
|
||||
void InitialisePalette();
|
||||
bool LoadBatteryOrState(int method, int action, bool silent);
|
||||
bool SaveBatteryOrState(int method, int action, bool silent);
|
||||
bool LoadBatteryOrState(char * filepath, 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
|
||||
|
@ -6,21 +6,20 @@
|
||||
*
|
||||
* video.cpp
|
||||
*
|
||||
* Generic GX Support for Emulators
|
||||
* NGC GX Video Functions
|
||||
* These are pretty standard functions to setup and use GX scaling.
|
||||
* Video routines
|
||||
***************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <unistd.h>
|
||||
#include <ogcsys.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <unistd.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include "images/bg.h"
|
||||
|
||||
#include "vba.h"
|
||||
#include "menudraw.h"
|
||||
#include "gui/gui.h"
|
||||
#include "menu.h"
|
||||
#include "input.h"
|
||||
|
||||
s32 CursorX, CursorY;
|
||||
bool CursorVisible;
|
||||
@ -28,7 +27,6 @@ bool CursorValid;
|
||||
bool TiltScreen = false;
|
||||
float TiltAngle = 0;
|
||||
u32 FrameTimer = 0;
|
||||
GuiImageData * pointer1;
|
||||
|
||||
/*** External 2D Video ***/
|
||||
/*** 2D Video Globals ***/
|
||||
@ -36,6 +34,11 @@ static GXRModeObj *vmode = NULL; // Graphics Mode Object
|
||||
unsigned int *xfb[2]; // Framebuffers
|
||||
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 screenwidth;
|
||||
|
||||
@ -145,44 +148,6 @@ copy_to_xfb (u32 arg)
|
||||
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
|
||||
@ -201,8 +166,17 @@ static void draw_init(void)
|
||||
GX_SetArray (GX_VA_POS, square, 3 * sizeof (s16));
|
||||
|
||||
GX_SetNumTexGens (1);
|
||||
GX_SetNumChans (0);
|
||||
|
||||
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_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565,
|
||||
@ -245,12 +219,13 @@ static void draw_square(Mtx v)
|
||||
GX_End();
|
||||
}
|
||||
|
||||
#ifdef HW_RVL
|
||||
static void draw_cursor(Mtx v)
|
||||
{
|
||||
if (!CursorVisible || !CursorValid)
|
||||
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_SetBlendMode(GX_BM_BLEND,GX_BL_DSTALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR);
|
||||
GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
|
||||
@ -294,16 +269,16 @@ static void draw_cursor(Mtx v)
|
||||
GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
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
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* StartGX
|
||||
****************************************************************************/
|
||||
static void GX_Start()
|
||||
*
|
||||
* Initialises GX and sets it up for use
|
||||
***************************************************************************/
|
||||
static void StartGX ()
|
||||
{
|
||||
Mtx44 p;
|
||||
|
||||
GXColor background = { 0, 0, 0, 0xff };
|
||||
|
||||
/*** Clear out FIFO area ***/
|
||||
@ -313,27 +288,25 @@ static void GX_Start()
|
||||
GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE);
|
||||
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);
|
||||
|
||||
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_SetCullMode (GX_CULL_NONE);
|
||||
|
||||
GX_CopyDisp (xfb[whichfb], GX_TRUE); // reset xfb
|
||||
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
|
||||
UpdatePadsCB ()
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
#ifdef HW_RVL
|
||||
WPAD_ScanPads();
|
||||
#endif
|
||||
#endif
|
||||
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
|
||||
*
|
||||
* Before doing anything in libogc, it's recommended to configure a video
|
||||
* output.
|
||||
****************************************************************************/
|
||||
void InitialiseVideo ()
|
||||
* InitializeVideo
|
||||
*
|
||||
* This function MUST be called at startup.
|
||||
* - also sets up menu video mode
|
||||
***************************************************************************/
|
||||
|
||||
void
|
||||
InitializeVideo ()
|
||||
{
|
||||
// get default video mode
|
||||
vmode = VIDEO_GetPreferredMode(NULL);
|
||||
|
||||
switch (vmode->viTVMode >> 2)
|
||||
@ -375,31 +369,33 @@ void InitialiseVideo ()
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HW_DOL
|
||||
/* we have component cables, why don't we switch into progressive?
|
||||
* on the Wii, the user can do this themselves on their Wii Settings */
|
||||
#ifdef HW_DOL
|
||||
/* 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 */
|
||||
if(VIDEO_HaveComponentCable())
|
||||
vmode = &TVNtsc480Prog;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// check for progressive scan
|
||||
if (vmode->viTVMode == VI_TVMODE_NTSC_PROG)
|
||||
progressive = true;
|
||||
|
||||
#ifdef HW_RVL
|
||||
#ifdef HW_RVL
|
||||
// widescreen fix
|
||||
if(CONF_GetAspectRatio())
|
||||
if(CONF_GetAspectRatio() == CONF_ASPECT_16_9)
|
||||
{
|
||||
vmode->viWidth = VI_MAX_WIDTH_PAL-12;
|
||||
vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
VIDEO_Configure(vmode);
|
||||
VIDEO_Configure (vmode);
|
||||
|
||||
screenheight = vmode->xfbHeight;
|
||||
screenwidth = vmode->fbWidth;
|
||||
|
||||
// Allocate the video buffers
|
||||
xfb[0] = (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_SetPreRetraceCallback ((VIRetraceCallback)copy_to_xfb);
|
||||
|
||||
VIDEO_SetBlack(FALSE);
|
||||
VIDEO_SetBlack (FALSE);
|
||||
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
if(vmode->viTVMode&VI_NON_INTERLACE)
|
||||
if(vmode->viTVMode & VI_NON_INTERLACE)
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
copynow = GX_FALSE;
|
||||
GX_Start();
|
||||
draw_init();
|
||||
|
||||
StartGX ();
|
||||
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()
|
||||
{
|
||||
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_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->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_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);
|
||||
|
||||
// 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_Flush();
|
||||
draw_init();
|
||||
|
||||
// set aspect ratio
|
||||
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)
|
||||
{
|
||||
if (texturemem)
|
||||
@ -676,7 +645,9 @@ void GX_Render(int width, int height, u8 * buffer, int pitch)
|
||||
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
||||
|
||||
draw_square(view); // render textured quad
|
||||
#ifdef HW_RVL
|
||||
draw_cursor(view); // render cursor
|
||||
#endif
|
||||
GX_DrawDone();
|
||||
|
||||
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
@ -706,14 +677,217 @@ zoom (float speed)
|
||||
GCSettings.ZoomLevel = 0.5;
|
||||
else if (GCSettings.ZoomLevel > 2.0)
|
||||
GCSettings.ZoomLevel = 2.0;
|
||||
|
||||
updateScaling = 1; // update video
|
||||
}
|
||||
|
||||
void
|
||||
zoom_reset ()
|
||||
{
|
||||
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
|
||||
*
|
||||
* Generic GX Support for Emulators
|
||||
* NGC GX Video Functions
|
||||
* These are pretty standard functions to setup and use GX scaling.
|
||||
* Video routines
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __VIDEOGX_H__
|
||||
#define __VIDEOGX_H__
|
||||
#ifndef _GCVIDEOH_
|
||||
#define _GCVIDEOH_
|
||||
|
||||
void InitialiseVideo ();
|
||||
#include <ogcsys.h>
|
||||
|
||||
void InitializeVideo ();
|
||||
void GX_Render_Init(int width, int height);
|
||||
void GX_Render(int width, int height, u8 * buffer, int pitch);
|
||||
void clearscreen ();
|
||||
void showscreen ();
|
||||
void StopGX();
|
||||
void ResetVideo_Emu();
|
||||
void zoom (float speed);
|
||||
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 screenwidth;
|
||||
@ -31,5 +35,7 @@ extern bool CursorVisible;
|
||||
extern bool CursorValid;
|
||||
extern bool TiltScreen;
|
||||
extern float TiltAngle;
|
||||
extern u8 * gameScreenTex;
|
||||
extern u8 * gameScreenTex2;
|
||||
|
||||
#endif
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "vba.h"
|
||||
#include "fileop.h"
|
||||
#include "dvd.h"
|
||||
#include "menudraw.h"
|
||||
#include "filesel.h"
|
||||
#include "menu.h"
|
||||
#include "filebrowser.h"
|
||||
#include "gcunzip.h"
|
||||
|
||||
extern "C" {
|
||||
@ -148,7 +148,7 @@ static void VMAllocGBA( void )
|
||||
paletteRAM == NULL || vram == NULL || oam == NULL ||
|
||||
pix == NULL || ioMem == NULL)
|
||||
{
|
||||
WaitPrompt("Out of memory!");
|
||||
ErrorPrompt("Out of memory!");
|
||||
VMClose();
|
||||
}
|
||||
}
|
||||
@ -302,7 +302,7 @@ int VMCPULoadROM(int method)
|
||||
// loading compressed files via VM is not supported
|
||||
if(!utilIsGBAImage(filepath))
|
||||
{
|
||||
WaitPrompt("Compressed GBA files are not supported!");
|
||||
InfoPrompt("Compressed GBA files are not supported!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ int VMCPULoadROM(int method)
|
||||
|
||||
if (romfile == NULL)
|
||||
{
|
||||
WaitPrompt("Error opening file!");
|
||||
InfoPrompt("Error opening file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ int VMCPULoadROM(int method)
|
||||
if ( res != (1 << VMSHIFTBITS ) )
|
||||
{
|
||||
sprintf(msg, "Error reading file! %i \n",res);
|
||||
WaitPrompt(msg);
|
||||
InfoPrompt(msg);
|
||||
VMClose();
|
||||
return 0;
|
||||
}
|
||||
@ -371,9 +371,9 @@ static void VMNewPage( int pageid )
|
||||
if (res) // fseek returns non-zero on a failure
|
||||
{
|
||||
sprintf(msg, "Seek error! - Offset %d / %08x %d\n", pageid, pageid << VMSHIFTBITS, res);
|
||||
WaitPrompt(msg);
|
||||
InfoPrompt(msg);
|
||||
VMClose();
|
||||
ExitToLoader();
|
||||
ExitApp();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
/*sprintf(msg, "Error reading! %d bytes only\n", res);
|
||||
WaitPrompt(msg);
|
||||
InfoPrompt(msg);
|
||||
VMClose();
|
||||
ExitToLoader();*/
|
||||
ExitApp();*/
|
||||
}
|
||||
|
||||
//mftb(&end);
|
||||
@ -424,9 +424,9 @@ u32 VMRead32( u32 address )
|
||||
|
||||
default:
|
||||
sprintf(msg, "VM32 : Unknown page type! (%d) [%d]", vmpage[pageid].pagetype, pageid);
|
||||
WaitPrompt(msg);
|
||||
InfoPrompt(msg);
|
||||
VMClose();
|
||||
ExitToLoader();
|
||||
ExitApp();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -456,9 +456,9 @@ u16 VMRead16( u32 address )
|
||||
return READ16LE( vmpage[pageid].pageptr + ( address & VMSHIFTMASK ) );
|
||||
|
||||
default:
|
||||
WaitPrompt("VM16 : Unknown page type!");
|
||||
InfoPrompt("VM16 : Unknown page type!");
|
||||
VMClose();
|
||||
ExitToLoader();
|
||||
ExitApp();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -488,9 +488,9 @@ u8 VMRead8( u32 address )
|
||||
return (u8)vmpage[pageid].pageptr[ (address & VMSHIFTMASK) ];
|
||||
|
||||
default:
|
||||
WaitPrompt("VM8 : Unknown page type!");
|
||||
InfoPrompt("VM8 : Unknown page type!");
|
||||
VMClose();
|
||||
ExitToLoader();
|
||||
ExitApp();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <utime.h>
|
||||
|
||||
#include "unzip.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
|
||||
#define CASESENSITIVITY (0)
|
||||
#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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user