From e692e05e9493bf7f72c114e8c81e9825b6351ec8 Mon Sep 17 00:00:00 2001 From: thelemonman Date: Wed, 30 Oct 2013 11:32:11 +0000 Subject: [PATCH] Make streamed roms working for non-windows systems. --- desmume/src/NDSSystem.cpp | 67 +-------------------------------------- desmume/src/path.cpp | 2 +- desmume/src/path.h | 6 ++-- 3 files changed, 6 insertions(+), 69 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 86a9ff22f..c6334db54 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -423,8 +423,6 @@ void GameInfo::populate() } -#ifdef _WINDOWS - static std::vector buffer; static std::vector v; @@ -528,7 +526,7 @@ static int rom_init_path(const char *filename, const char *physicalName, const c { int type = ROM_NDS; - path.init(logicalFilename); + path.init(logicalFilename? logicalFilename : filename); if ( path.isdsgba(path.path)) { type = ROM_DSGBA; @@ -564,69 +562,6 @@ static int rom_init_path(const char *filename, const char *physicalName, const c return 1; } -#else -static int rom_init_path(const char *filename, const char *physicalName, const char *logicalFilename) -{ - int ret; - int type; - ROMReader_struct *reader; - void *file; - u32 size; - char *noext; - - noext = strdup(filename); - reader = ROMReaderInit(&noext); - free(noext); - - if (logicalFilename) - path.init(logicalFilename); - else - path.init(filename); - - if (!strcasecmp(path.extension().c_str(), "zip")) - type = ROM_NDS; - else if (!strcasecmp(path.extension().c_str(), "nds")) - type = ROM_NDS; - else if (path.isdsgba(path.path)) - type = ROM_DSGBA; - else - type = ROM_NDS; - - file = reader->Init(filename); - if (!file) - { - reader->DeInit(file); - return -1; - } - - size = reader->Size(file); - - if(type == ROM_DSGBA) - { - reader->Seek(file, DSGBA_LOADER_SIZE, SEEK_SET); - size -= DSGBA_LOADER_SIZE; - } - - //check that size is at least the size of the header - if (size < 352) { - reader->DeInit(file); - return -1; - } - - // Make sure old ROM is freed first(at least this way we won't be eating - // up a ton of ram before the old ROM is freed) - - if(MMU.CART_ROM != MMU.UNUSED_RAM) - NDS_FreeROM(); - - gameInfo.resize(size); - ret = reader->Read(file, gameInfo.romdata, size); - gameInfo.fillGap(); - reader->DeInit(file); - - return ret; -} -#endif int NDS_LoadROM(const char *filename, const char *physicalName, const char *logicalFilename) { diff --git a/desmume/src/path.cpp b/desmume/src/path.cpp index a945e6b40..fe591b46d 100644 --- a/desmume/src/path.cpp +++ b/desmume/src/path.cpp @@ -180,4 +180,4 @@ void FCEUD_MakePathDirs(const char *fname) } while(1); } #endif -//------------------------------ \ No newline at end of file +//------------------------------ diff --git a/desmume/src/path.h b/desmume/src/path.h index 3494d2956..a3d7a649d 100644 --- a/desmume/src/path.h +++ b/desmume/src/path.h @@ -118,8 +118,8 @@ public: char pathToLua[MAX_PATH]; char pathToSlot1D[MAX_PATH]; - void init(const char *filename) { - + void init(const char *filename) + { path = std::string(filename); //extract the internal part of the logical rom name @@ -430,6 +430,8 @@ public: std::string GetRomNameWithoutExtension() { + if (RomName.c_str() == NULL) + return ""; return Path::GetFileNameWithoutExt(RomName); }