fix some rom loading things
This commit is contained in:
parent
a61483d87d
commit
81b885777c
|
@ -739,10 +739,6 @@ static std::vector<char> v;
|
||||||
|
|
||||||
static void loadrom(std::vector<char>* buf, std::string fname) {
|
static void loadrom(std::vector<char>* buf, std::string fname) {
|
||||||
|
|
||||||
memorystream ms(buf);
|
|
||||||
|
|
||||||
std::ostream* os = (std::ostream*)&ms;
|
|
||||||
|
|
||||||
std::ifstream fl(fname.c_str());
|
std::ifstream fl(fname.c_str());
|
||||||
|
|
||||||
if (!fl.is_open())
|
if (!fl.is_open())
|
||||||
|
@ -755,16 +751,10 @@ static void loadrom(std::vector<char>* buf, std::string fname) {
|
||||||
fb.open (fname.c_str(), std::ios::in | std::ios::binary);
|
fb.open (fname.c_str(), std::ios::in | std::ios::binary);
|
||||||
std::istream is(&fb);
|
std::istream is(&fb);
|
||||||
|
|
||||||
char *buffer = new char[size];
|
gameInfo.resize(size);
|
||||||
is.read(buffer, size);
|
is.read(gameInfo.romdata,size);
|
||||||
ms.write((char*)buffer,size);
|
|
||||||
|
|
||||||
fb.close();
|
fb.close();
|
||||||
|
|
||||||
ms.trim();
|
|
||||||
|
|
||||||
gameInfo.romdata = &buffer[0];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int NDS_LoadROM(const char *filename, const char *logicalFilename)
|
int NDS_LoadROM(const char *filename, const char *logicalFilename)
|
||||||
|
@ -784,9 +774,8 @@ int NDS_LoadROM(const char *filename, const char *logicalFilename)
|
||||||
gameInfo.romsize = buffer.size();
|
gameInfo.romsize = buffer.size();
|
||||||
}
|
}
|
||||||
else if ( !strcasecmp(path.extension().c_str(), "nds")) {
|
else if ( !strcasecmp(path.extension().c_str(), "nds")) {
|
||||||
|
loadrom(NULL, path.path); //n.b. this does nothing if the file can't be found (i.e. if it was an extracted tempfile)...
|
||||||
loadrom(&buffer, path.path);
|
//...but since the data was extracted to gameInfo then it is ok
|
||||||
gameInfo.romsize = buffer.size();
|
|
||||||
type = ROM_NDS;
|
type = ROM_NDS;
|
||||||
}
|
}
|
||||||
//ds.gba in archives, it's already been loaded into memory at this point
|
//ds.gba in archives, it's already been loaded into memory at this point
|
||||||
|
|
|
@ -276,6 +276,15 @@ NDS_header * NDS_getROMHeader(void);
|
||||||
|
|
||||||
struct GameInfo
|
struct GameInfo
|
||||||
{
|
{
|
||||||
|
GameInfo()
|
||||||
|
: romdata(NULL)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void resize(int size) {
|
||||||
|
if(romdata != NULL) delete[] romdata;
|
||||||
|
romdata = new char[size];
|
||||||
|
romsize = size;
|
||||||
|
}
|
||||||
u32 crc;
|
u32 crc;
|
||||||
NDS_header header;
|
NDS_header header;
|
||||||
char ROMserial[20];
|
char ROMserial[20];
|
||||||
|
|
|
@ -351,10 +351,7 @@ int ArchiveFile::ExtractItem(int index, const char* outFilename) const
|
||||||
InFileStream* ifs = new InFileStream(m_filename);
|
InFileStream* ifs = new InFileStream(m_filename);
|
||||||
if(SUCCEEDED(object->Open(ifs,0,0)))
|
if(SUCCEEDED(object->Open(ifs,0,0)))
|
||||||
{
|
{
|
||||||
if(gameInfo.romdata != NULL)
|
gameInfo.resize(rv);
|
||||||
delete[] gameInfo.romdata;
|
|
||||||
gameInfo.romdata = new char[rv];
|
|
||||||
gameInfo.romsize = rv;
|
|
||||||
OutStream* os = new OutStream(index, gameInfo.romdata, rv);
|
OutStream* os = new OutStream(index, gameInfo.romdata, rv);
|
||||||
const UInt32 indices [1] = {index};
|
const UInt32 indices [1] = {index};
|
||||||
hr = object->Extract(indices, 1, 0, os);
|
hr = object->Extract(indices, 1, 0, os);
|
||||||
|
|
Loading…
Reference in New Issue