Unverified Commit 569c25d6 authored by Libretro-Admin's avatar Libretro-Admin Committed by GitHub
Browse files

Merge pull request #22 from jdgleaver/need-fullpath

Remove 'need_fullpath' requirement when using frontends with 'RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE' support
parents 00a7e82e 7219ac8a
Pipeline #37815 passed with stages
in 7 minutes and 54 seconds
......@@ -138,9 +138,20 @@ void retro_deinit(void)
void retro_set_environment(retro_environment_t cb)
{
static const struct retro_system_content_info_override content_overrides[] = {
{
RACE_EXTENSIONS, /* extensions */
false, /* need_fullpath */
false /* persistent_data */
},
{ NULL, false, false }
};
environ_cb = cb;
libretro_set_core_options(environ_cb);
environ_cb(RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE,
(void*)content_overrides);
}
void retro_set_audio_sample(retro_audio_sample_t cb)
......@@ -202,11 +213,13 @@ static bool race_initialize_sound(void)
return true;
}
static bool race_initialize_system(const char* gamepath)
static bool race_initialize_system(const char *gamepath,
const unsigned char *gamedata, size_t gamesize)
{
mainemuinit();
if(!handleInputFile((char *)gamepath)){
if (!handleInputFile(gamepath, gamedata, (int)gamesize))
{
handle_error("ERROR handleInputFile");
return false;
}
......@@ -298,8 +311,10 @@ bool retro_unserialize(const void *data, size_t size)
bool retro_load_game(const struct retro_game_info *info)
{
if (!info)
return false;
const struct retro_game_info_ext *info_ext = NULL;
const unsigned char *content_data = NULL;
size_t content_size = 0;
char content_path[_MAX_PATH];
struct retro_input_descriptor desc[] = {
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" },
......@@ -313,6 +328,44 @@ bool retro_load_game(const struct retro_game_info *info)
{ 0 },
};
content_path[0] = '\0';
/* Attempt to fetch extended game info */
if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &info_ext))
{
content_data = (const unsigned char *)info_ext->data;
content_size = info_ext->size;
if (info_ext->file_in_archive)
{
/* We don't have a 'physical' file in this
* case, but the core still needs a filename
* in order to build the save file path.
* We therefore fake it, using the content
* directory, canonical content name, and
* content file extension */
snprintf(content_path, sizeof(content_path), "%s%c%s.%s",
info_ext->dir, path_default_slash_c(),
info_ext->name, info_ext->ext);
}
else
{
strncpy(content_path, info_ext->full_path, sizeof(content_path));
content_path[sizeof(content_path) - 1] = '\0';
}
}
else
{
if (!info || !info->path)
return false;
content_data = NULL;
content_size = 0;
strncpy(content_path, info->path, sizeof(content_path));
content_path[sizeof(content_path) - 1] = '\0';
}
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);
screen = (struct ngp_screen*)calloc(1, sizeof(*screen));
......@@ -331,7 +384,8 @@ bool retro_load_game(const struct retro_game_info *info)
return false;
}
if (!race_initialize_system(info->path))
if (!race_initialize_system(content_path,
content_data, content_size))
return false;
if (!race_initialize_sound())
......
This diff is collapsed.
......@@ -261,7 +261,7 @@ static int loadFromZipByName(unsigned char *buffer, char *archive,
*filesize = zinfo.uncompressed_size;
/* Error: file size is zero */
if(*filesize <= 0 || *filesize > (4*1024*1024))
if(*filesize <= 0 || *filesize > MAINROM_SIZE_MAX)
{
unzClose(zhandle);
return (0);
......@@ -330,23 +330,35 @@ static int strrchr2(const char *src, int c)
return 0;
}
int handleInputFile(char *romName)
int handleInputFile(const char *romName,
const unsigned char *romData, int romSize)
{
FILE *romFile;
int iDepth = 0;
#ifdef WANT_ZIP
int size;
int iDepth = 0;
#endif
initSysInfo(); //initialize it all
#ifdef WANT_ZIP
//if it's a ZIP file, we need to handle that here.
iDepth = strrchr2(romName, '.');
iDepth++;
#endif
if (romData)
{
int size = romSize > MAINROM_SIZE_MAX ?
MAINROM_SIZE_MAX : romSize;
m_emuInfo.romSize = size;
memcpy(mainrom, romData, size);
strcpy(m_emuInfo.RomFileName, romName);
}
#ifdef WANT_ZIP
if( ( strcmp( romName + iDepth, "zip" ) == 0 ) || ( strcmp( romName + iDepth, "ZIP" ) == 0 ))
else if ( ( strcmp( romName + iDepth, "zip" ) == 0 ) || ( strcmp( romName + iDepth, "ZIP" ) == 0 ))
{
int size;
//get ROM from ZIP
if(check_zip(romName))
{
......@@ -365,9 +377,11 @@ int handleInputFile(char *romName)
return 0;
}
}
else
#endif // WANT_ZIP
else
{
FILE *romFile = NULL;
//get ROM from binary ROM file
romFile = fopen(romName, "rb");
if(!romFile)
......@@ -376,11 +390,13 @@ int handleInputFile(char *romName)
return 0;
}
m_emuInfo.romSize = fread(mainrom, 1, 4*1024*1024, romFile);
m_emuInfo.romSize = fread(mainrom, 1, MAINROM_SIZE_MAX, romFile);
strcpy(m_emuInfo.RomFileName, romName);
fclose(romFile);
}
if(!initRom())
if (!initRom())
{
fprintf(stderr, "initRom couldn't handle %s file\n", romName);
return 0;
......
......@@ -57,7 +57,8 @@ extern EMUINFO m_emuInfo;
extern SYSTEMINFO m_sysInfo[NR_OF_SYSTEMS];
extern int romSize;
int handleInputFile(char *romName);
int handleInputFile(const char *romName,
const unsigned char *romData, int romSize);
void mainemuinit(void);
#ifdef __cplusplus
......
......@@ -44,7 +44,7 @@ unsigned char cpuram[0x08a0];
* on the gameboy maximum of 128kbyte of RAM is possible, plus some internal ram (64KB) */
unsigned char __attribute__ ((__aligned__(4))) mainram[(64+32+128)*1024];
// rom area for roms (4 Megabyte)
unsigned char __attribute__ ((__aligned__(4))) mainrom[4*1024*1024];
unsigned char __attribute__ ((__aligned__(4))) mainrom[MAINROM_SIZE_MAX];
// cpu internal ROM including vector table starting at 0xff0000
unsigned char __attribute__ ((__aligned__(4))) cpurom[256*1024];//prob only needs 0x10000
//
......
......@@ -34,6 +34,9 @@
extern "C" {
#endif
/* Maximum ROM size is 4 megabytes */
#define MAINROM_SIZE_MAX (4*1024*1024)
extern unsigned char mainram[]; /* All RAM areas */
extern unsigned char mainrom[]; /* ROM image area */
extern unsigned char cpurom[]; /* Bios ROM image area */
......@@ -362,7 +365,7 @@ static INLINE unsigned int tlcsMemReadL(unsigned int addr)
i = *(gA++);
i |= (*(gA++)) << 8;
i |= (*(gA++)) << 16;
i |= (*gA) << 24;
i |= (unsigned int)(*gA) << 24;
#if 0
return tlcsMemReadB(addr) | (tlcsMemReadB(addr +1) << 8) | (tlcsMemReadB(addr +2) << 16) | (tlcsMemReadB(addr +3) << 24);
......
......@@ -792,7 +792,7 @@ static INLINE unsigned int readlong(void)
i = *(my_pc++);
i |= (*(my_pc++) << 8);
i |= (*(my_pc++) << 16);
i |= (*(my_pc++) << 24);
i |= ((unsigned int)(*(my_pc++)) << 24);
return i;
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment