mirror of
https://github.com/dborth/vbagx.git
synced 2025-04-06 23:56:42 +02:00
DVD, SMB, ZIP loading support
This commit is contained in:
parent
53fa4f3804
commit
9edc1f9b4b
@ -22,11 +22,8 @@ extern "C" {
|
||||
|
||||
#include "menudraw.h"
|
||||
#include "gcunzip.h"
|
||||
#include "filesel.h"
|
||||
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
extern int maxfiles;
|
||||
u64 dvddir = 0;
|
||||
u64 dvdrootdir = 0;
|
||||
int dvddirlength = 0;
|
||||
|
@ -24,14 +24,20 @@
|
||||
#include "filesel.h"
|
||||
#include "preferences.h"
|
||||
|
||||
FILE * filehandle;
|
||||
// temporary
|
||||
#include "vmmem.h"
|
||||
#include "agb/GBA.h"
|
||||
#include "agb/agbprint.h"
|
||||
#include "Flash.h"
|
||||
#include "Port.h"
|
||||
#include "RTC.h"
|
||||
#include "Sound.h"
|
||||
#include "unzip.h"
|
||||
#include "Util.h"
|
||||
#include "dmg/GB.h"
|
||||
#include "dmg/gbGlobals.h"
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern char output[16384];
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
extern char currentdir[MAXPATHLEN];
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
FILE * filehandle;
|
||||
|
||||
/****************************************************************************
|
||||
* fat_is_mounted
|
||||
@ -170,13 +176,12 @@ ParseFATdirectory(int method)
|
||||
* LoadFATFile
|
||||
***************************************************************************/
|
||||
int
|
||||
LoadFATFile (char *filename, int length)
|
||||
LoadFATFile (char * rbuffer)
|
||||
{
|
||||
/*char zipbuffer[2048];
|
||||
FILE *handle;
|
||||
unsigned char *rbuffer;
|
||||
u32 size;*/
|
||||
char zipbuffer[2048];
|
||||
char filepath[MAXPATHLEN];
|
||||
FILE *handle;
|
||||
u32 size;
|
||||
|
||||
/* Check filename length */
|
||||
if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
|
||||
@ -186,8 +191,7 @@ LoadFATFile (char *filename, int length)
|
||||
WaitPrompt((char*) "Maximum filepath length reached!");
|
||||
return -1;
|
||||
}
|
||||
return loadVBAROM(filepath);
|
||||
/*
|
||||
|
||||
handle = fopen (filepath, "rb");
|
||||
if (handle > 0)
|
||||
{
|
||||
@ -195,17 +199,16 @@ LoadFATFile (char *filename, int length)
|
||||
|
||||
if (IsZipFile (zipbuffer))
|
||||
{
|
||||
size = UnZipFile (rbuffer, handle); // unzip from FAT
|
||||
size = UnZipFile ((unsigned char *)rbuffer, handle); // unzip from FAT
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just load the file up
|
||||
fseek(handle, 0, SEEK_END);
|
||||
length = ftell(handle); // get filesize
|
||||
size = ftell(handle); // get filesize
|
||||
fseek(handle, 2048, SEEK_SET); // seek back to point where we left off
|
||||
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
|
||||
fread (rbuffer + 2048, 1, length - 2048, handle);
|
||||
size = length;
|
||||
fread (rbuffer + 2048, 1, size - 2048, handle);
|
||||
}
|
||||
fclose (handle);
|
||||
return size;
|
||||
@ -216,7 +219,7 @@ LoadFATFile (char *filename, int length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
bool ChangeFATInterface(int method, bool silent);
|
||||
int ParseFATdirectory(int method);
|
||||
int LoadFATFile (char *filename, int length);
|
||||
int LoadFATFile (char * fbuffer);
|
||||
int SaveBufferToFAT (char *filepath, int datasize, bool silent);
|
||||
int LoadBufferFromFAT (char *filepath, bool silent);
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <string.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <sys/dir.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef WII_DVD
|
||||
extern "C" {
|
||||
@ -47,19 +48,23 @@ int hasloaded = 0;
|
||||
// Global file entry table
|
||||
FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN (32);
|
||||
|
||||
char ROMFilename[512];
|
||||
int ROMSize = 0;
|
||||
|
||||
unsigned char *savebuffer = NULL;
|
||||
|
||||
/****************************************************************************
|
||||
* ClearSaveBuffer ()
|
||||
* Clear the savebuffer
|
||||
* Allocate and clear the savebuffer
|
||||
***************************************************************************/
|
||||
void
|
||||
ClearSaveBuffer ()
|
||||
{
|
||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||
if (savebuffer)
|
||||
free(savebuffer);
|
||||
|
||||
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -309,27 +314,17 @@ int FileSelector (int method)
|
||||
|
||||
ShowAction ((char *)"Loading...");
|
||||
|
||||
switch (method)
|
||||
// setup variables for DVD loading
|
||||
if(method == METHOD_DVD)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
ROMSize = LoadFATFile (filelist[selection].filename, filelist[selection].length);
|
||||
break;
|
||||
|
||||
case METHOD_DVD:
|
||||
dvddir = filelist[selection].offset;
|
||||
dvddirlength = filelist[selection].length;
|
||||
//ROMSize = LoadDVDFile (Memory.ROM);
|
||||
break;
|
||||
|
||||
case METHOD_SMB:
|
||||
//ROMSize = LoadSMBFile (filelist[selection].filename, filelist[selection].length);
|
||||
break;
|
||||
}
|
||||
|
||||
ROMSize = loadVBAROM(method);
|
||||
|
||||
if (ROMSize > 0)
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
@ -11,7 +11,9 @@
|
||||
#ifndef _NGCFILESEL_
|
||||
#define _NGCFILESEL_
|
||||
|
||||
#define SAVEBUFFERSIZE ((512 * 1024) + 2048 + 64 + 4 + 4)
|
||||
#include <unistd.h>
|
||||
|
||||
#define SAVEBUFFERSIZE (512 * 1024)
|
||||
#define MAXJOLIET 255
|
||||
#define MAXDISPLAY 44
|
||||
|
||||
@ -26,6 +28,12 @@ typedef struct
|
||||
|
||||
#define MAXFILES 2000 // Restrict to 2000 files per dir
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
extern unsigned char *savebuffer;
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
extern char currentdir[MAXPATHLEN];
|
||||
extern int maxfiles;
|
||||
|
||||
extern char ROMFilename[512];
|
||||
|
||||
void ClearSaveBuffer ();
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#define VERIFBUFFERSIZE 65536
|
||||
static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
extern unsigned char savebuffer[];
|
||||
unsigned char verifbuffer[VERIFBUFFERSIZE] ATTRIBUTE_ALIGN (32);
|
||||
card_dir CardDir;
|
||||
card_file CardFile;
|
||||
|
@ -125,10 +125,6 @@ PreferencesMenu ()
|
||||
// skip
|
||||
if(GCSettings.LoadMethod == METHOD_DVD)
|
||||
GCSettings.LoadMethod++;
|
||||
if(GCSettings.LoadMethod == METHOD_SMB)
|
||||
GCSettings.LoadMethod++;
|
||||
if(GCSettings.SaveMethod == METHOD_SMB)
|
||||
GCSettings.SaveMethod++;
|
||||
if(GCSettings.SaveMethod == METHOD_MC_SLOTA)
|
||||
GCSettings.SaveMethod++;
|
||||
if(GCSettings.SaveMethod == METHOD_MC_SLOTB)
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "filesel.h"
|
||||
#include "input.h"
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern int currconfig[4];
|
||||
|
||||
// button map configurations
|
||||
@ -117,7 +116,7 @@ int
|
||||
preparePrefsData (int method)
|
||||
{
|
||||
int offset = 0;
|
||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||
ClearSaveBuffer();
|
||||
|
||||
// add save icon and comments for Memory Card saves
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
|
@ -33,14 +33,6 @@ unsigned int SMBTimer = 0;
|
||||
SMBCONN smbconn;
|
||||
#define ZIPCHUNK 16384
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern char output[16384];
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
extern char currentdir[MAXPATHLEN];
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* InitializeNetwork
|
||||
* Initializes the Wii/GameCube network interface
|
||||
@ -222,7 +214,7 @@ ParseSMBdirectory ()
|
||||
* Load SMB file
|
||||
****************************************************************************/
|
||||
int
|
||||
LoadSMBFile (char *filename, int length)
|
||||
LoadSMBFile (char * rom)
|
||||
{
|
||||
char filepath[MAXPATHLEN];
|
||||
|
||||
@ -234,8 +226,7 @@ LoadSMBFile (char *filename, int length)
|
||||
WaitPrompt((char*) "Maximum filepath length reached!");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
//return LoadBufferFromSMB((char *)Memory.ROM, SMBPath(filepath), NOTSILENT);
|
||||
return LoadBufferFromSMB(rom, SMBPath(filepath), NOTSILENT);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -17,7 +17,7 @@ bool ConnectShare (bool silent);
|
||||
char * SMBPath(char * path);
|
||||
int UpdateSMBdirname();
|
||||
int ParseSMBdirectory ();
|
||||
int LoadSMBFile (char *filename, int length);
|
||||
int LoadSMBFile (char * fbuffer);
|
||||
int LoadBufferFromSMB (char *filepath, bool silent);
|
||||
int LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent);
|
||||
int SaveBufferToSMB (char *filepath, int datasize, bool silent);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "Util.h"
|
||||
#include "dmg/GB.h"
|
||||
#include "dmg/gbGlobals.h"
|
||||
//#include "dmg/gbSound.h"
|
||||
|
||||
#include "vba.h"
|
||||
#include "fileop.h"
|
||||
@ -341,8 +342,16 @@ void systemDrawScreen()
|
||||
#endif
|
||||
}
|
||||
|
||||
int loadVBAROM(char filename[])
|
||||
int loadVBAROM(int method)
|
||||
{
|
||||
int type = 2;
|
||||
|
||||
// image type (checks file extension)
|
||||
/* if(utilIsGBAImage(filename))
|
||||
type = 2;
|
||||
else if(utilIsGBImage(filename))
|
||||
type = 1;
|
||||
*/
|
||||
cartridgeType = 0;
|
||||
srcWidth = 0;
|
||||
srcHeight = 0;
|
||||
@ -350,17 +359,15 @@ int loadVBAROM(char filename[])
|
||||
destHeight = 0;
|
||||
srcPitch = 0;
|
||||
|
||||
IMAGE_TYPE type = utilFindType(filename);
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case IMAGE_GBA:
|
||||
case 2:
|
||||
//WaitPrompt("GameBoy Advance Image");
|
||||
cartridgeType = 2;
|
||||
emulator = GBASystem;
|
||||
srcWidth = 240;
|
||||
srcHeight = 160;
|
||||
VMCPULoadROM(filename);
|
||||
VMCPULoadROM(method);
|
||||
// Actual Visual Aspect is 1.57
|
||||
hAspect = 70;
|
||||
vAspect = 46;
|
||||
@ -370,13 +377,13 @@ int loadVBAROM(char filename[])
|
||||
cpuSaveType = 0;
|
||||
break;
|
||||
|
||||
case IMAGE_GB:
|
||||
case 1:
|
||||
//WaitPrompt("GameBoy Image");
|
||||
cartridgeType = 1;
|
||||
emulator = GBSystem;
|
||||
srcWidth = 160;
|
||||
srcHeight = 144;
|
||||
gbLoadRom(filename);
|
||||
//gbLoadRom(filepath);
|
||||
// Actual physical aspect is 1.0
|
||||
hAspect = 60;
|
||||
vAspect = 46;
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
extern struct EmulatedSystem emulator;
|
||||
extern u32 loadtimeradjust;
|
||||
int loadVBAROM(char filename[]);
|
||||
int loadVBAROM(int method);
|
||||
void InitialisePalette();
|
||||
bool LoadBattery(int method, bool silent);
|
||||
bool SaveBattery(int method, bool silent);
|
||||
|
@ -22,6 +22,10 @@
|
||||
#include "Util.h"
|
||||
#include "Port.h"
|
||||
|
||||
#include "vba.h"
|
||||
#include "smbop.h"
|
||||
#include "fileop.h"
|
||||
#include "dvd.h"
|
||||
#include "menudraw.h"
|
||||
|
||||
extern "C" {
|
||||
@ -37,7 +41,7 @@ unsigned int MEM2Storage = 0x91000000;
|
||||
static char *gbabase = NULL;
|
||||
static FILE *romfile = NULL;
|
||||
static u32 GBAROMSize = 0;
|
||||
static char romfilename[1024];
|
||||
//static char romfilename[1024];
|
||||
|
||||
/**
|
||||
* GBA Memory
|
||||
@ -101,46 +105,41 @@ static void VMClose( void )
|
||||
*
|
||||
* MEM2 version of GBA CPULoadROM
|
||||
****************************************************************************/
|
||||
int VMCPULoadROM( char *filename )
|
||||
|
||||
int VMCPULoadROM(int method)
|
||||
{
|
||||
int res=0;
|
||||
//char temp[512];
|
||||
VMClose();
|
||||
VMAllocGBA();
|
||||
|
||||
GBAROMSize = 0;
|
||||
|
||||
romfile = gen_fopen(filename, "rb");
|
||||
if ( romfile == NULL )
|
||||
{
|
||||
WaitPrompt((char*) "Error opening file!");
|
||||
VMClose();
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek(romfile, 0, SEEK_END);
|
||||
GBAROMSize = ftell(romfile);
|
||||
fseek(romfile, 0, SEEK_SET);
|
||||
|
||||
//sprintf(temp,"ROM Size %dMb (%dMBit)", GBAROMSize/1024/1024,(GBAROMSize*8)/1024/1024);
|
||||
//WaitPrompt(temp);
|
||||
int res=0;
|
||||
VMClose();
|
||||
VMAllocGBA();
|
||||
|
||||
GBAROMSize = 0;
|
||||
rom = (u8 *)MEM2Storage;
|
||||
|
||||
/* Always use MEM2, regardless of ROM size */
|
||||
res = gen_fread(rom, 1, GBAROMSize, romfile);
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoLoadMethod();
|
||||
|
||||
if ( (u32)res != GBAROMSize )
|
||||
{
|
||||
WaitPrompt((char*) "Error reading file!");
|
||||
VMClose();
|
||||
return 0;
|
||||
}
|
||||
strcpy( romfilename, filename );
|
||||
switch (method)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
res = LoadFATFile ((char *)rom);
|
||||
break;
|
||||
|
||||
CPUUpdateRenderBuffers( true );
|
||||
case METHOD_DVD:
|
||||
res = LoadDVDFile ((unsigned char *)rom);
|
||||
break;
|
||||
|
||||
return 1;
|
||||
case METHOD_SMB:
|
||||
res = LoadSMBFile ((char *)rom);
|
||||
break;
|
||||
}
|
||||
|
||||
if(res)
|
||||
CPUUpdateRenderBuffers( true );
|
||||
else
|
||||
VMClose();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef __VBAVMHDR__
|
||||
#define __VBAVMHDR__
|
||||
|
||||
int VMCPULoadROM( char *filename );
|
||||
int VMCPULoadROM(int method);
|
||||
u32 VMRead32( u32 address );
|
||||
u16 VMRead16( u32 address );
|
||||
u8 VMRead8( u32 address );
|
||||
|
Loading…
x
Reference in New Issue
Block a user