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) {
|
||||
|
||||
memorystream ms(buf);
|
||||
|
||||
std::ostream* os = (std::ostream*)&ms;
|
||||
|
||||
std::ifstream fl(fname.c_str());
|
||||
|
||||
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);
|
||||
std::istream is(&fb);
|
||||
|
||||
char *buffer = new char[size];
|
||||
is.read(buffer, size);
|
||||
ms.write((char*)buffer,size);
|
||||
|
||||
fb.close();
|
||||
|
||||
ms.trim();
|
||||
|
||||
gameInfo.romdata = &buffer[0];
|
||||
gameInfo.resize(size);
|
||||
is.read(gameInfo.romdata,size);
|
||||
|
||||
fb.close();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
else if ( !strcasecmp(path.extension().c_str(), "nds")) {
|
||||
|
||||
loadrom(&buffer, path.path);
|
||||
gameInfo.romsize = buffer.size();
|
||||
loadrom(NULL, path.path); //n.b. this does nothing if the file can't be found (i.e. if it was an extracted tempfile)...
|
||||
//...but since the data was extracted to gameInfo then it is ok
|
||||
type = ROM_NDS;
|
||||
}
|
||||
//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
|
||||
{
|
||||
GameInfo()
|
||||
: romdata(NULL)
|
||||
{}
|
||||
|
||||
void resize(int size) {
|
||||
if(romdata != NULL) delete[] romdata;
|
||||
romdata = new char[size];
|
||||
romsize = size;
|
||||
}
|
||||
u32 crc;
|
||||
NDS_header header;
|
||||
char ROMserial[20];
|
||||
|
|
|
@ -351,10 +351,7 @@ int ArchiveFile::ExtractItem(int index, const char* outFilename) const
|
|||
InFileStream* ifs = new InFileStream(m_filename);
|
||||
if(SUCCEEDED(object->Open(ifs,0,0)))
|
||||
{
|
||||
if(gameInfo.romdata != NULL)
|
||||
delete[] gameInfo.romdata;
|
||||
gameInfo.romdata = new char[rv];
|
||||
gameInfo.romsize = rv;
|
||||
gameInfo.resize(rv);
|
||||
OutStream* os = new OutStream(index, gameInfo.romdata, rv);
|
||||
const UInt32 indices [1] = {index};
|
||||
hr = object->Extract(indices, 1, 0, os);
|
||||
|
|
Loading…
Reference in New Issue