diff --git a/src/oldmovie.cpp b/src/oldmovie.cpp index 345af2da..4d200c66 100644 --- a/src/oldmovie.cpp +++ b/src/oldmovie.cpp @@ -542,11 +542,11 @@ EFCM_CONVERTRESULT convert_fcm(MovieData& md, std::string fname) int movieConvertOffset1=0, movieConvertOffset2=0,movieSyncHackOn=0; - ifstream* fp = (ifstream*)FCEUD_UTF8_fstream(fname, "rb"); + EMUFILE* fp = FCEUD_UTF8_fstream(fname, "rb"); if(!fp) false; // read header - uint32 magic; + uint32 magic = 0; uint32 version; uint8 flags[4]; @@ -576,7 +576,7 @@ EFCM_CONVERTRESULT convert_fcm(MovieData& md, std::string fname) } - fp->read((char*)&flags,4); + fp->fread((char*)&flags,4); read32le(&framecount, fp); read32le(&rerecord_count, fp); read32le(&moviedatasize, fp); @@ -584,7 +584,7 @@ EFCM_CONVERTRESULT convert_fcm(MovieData& md, std::string fname) read32le(&firstframeoffset, fp); //read header values - fp->read((char*)&md.romChecksum,16); + fp->fread((char*)&md.romChecksum,16); read32le((uint32*)&md.emuVersion,fp); md.romFilename = readNullTerminatedAscii(fp); @@ -625,9 +625,9 @@ EFCM_CONVERTRESULT convert_fcm(MovieData& md, std::string fname) //analyze input types? //ResetInputTypes(); - fp->seekg(firstframeoffset,ios::beg); + fp->fseek(firstframeoffset,SEEK_SET); moviedata = (uint8*)realloc(moviedata, moviedatasize); - fp->read((char*)moviedata,moviedatasize); + fp->fread((char*)moviedata,moviedatasize); frameptr = 0; memset(joop,0,sizeof(joop)); diff --git a/src/utils/xstring.cpp b/src/utils/xstring.cpp index afdc82dd..21e988aa 100644 --- a/src/utils/xstring.cpp +++ b/src/utils/xstring.cpp @@ -553,13 +553,13 @@ std::string stditoa(int n) } -std::string readNullTerminatedAscii(std::istream* is) +std::string readNullTerminatedAscii(EMUFILE* is) { std::string ret; ret.reserve(50); for(;;) { - int c = is->get(); + int c = is->fgetc(); if(c == 0) break; else ret += (char)c; } diff --git a/src/utils/xstring.h b/src/utils/xstring.h index a5f1d6b6..aad37674 100644 --- a/src/utils/xstring.h +++ b/src/utils/xstring.h @@ -63,35 +63,9 @@ char *U16ToHexStr(uint16 a); std::string stditoa(int n); -std::string readNullTerminatedAscii(std::istream* is); +std::string readNullTerminatedAscii(EMUFILE* is); //extracts a decimal uint from an istream -template T templateIntegerDecFromIstream(std::istream* is) -{ - unsigned int ret = 0; - bool pre = true; - - for(;;) - { - int c = is->get(); - if(c == -1) return ret; - int d = c - '0'; - if((d<0 || d>9)) - { - if(!pre) - break; - } - else - { - pre = false; - ret *= 10; - ret += d; - } - } - is->unget(); - return ret; -} - template T templateIntegerDecFromIstream(EMUFILE* is) { unsigned int ret = 0; @@ -118,33 +92,9 @@ template T templateIntegerDecFromIstream(EMUFILE* is) return ret; } -inline uint32 uint32DecFromIstream(std::istream* is) { return templateIntegerDecFromIstream(is); } -inline uint64 uint64DecFromIstream(std::istream* is) { return templateIntegerDecFromIstream(is); } inline uint32 uint32DecFromIstream(EMUFILE* is) { return templateIntegerDecFromIstream(is); } inline uint64 uint64DecFromIstream(EMUFILE* is) { return templateIntegerDecFromIstream(is); } -//puts an optionally 0-padded decimal integer of type T into the ostream (0-padding is quicker) -template void putdec(std::ostream* os, T dec) -{ - char temp[DIGITS]; - int ctr = 0; - for(int i=0;iwrite(temp+DIGITS-ctr-1,ctr+1); - else - os->write(temp,DIGITS); -} - //puts an optionally 0-padded decimal integer of type T into the ostream (0-padding is quicker) template void putdec(EMUFILE* os, T dec) {