movie speedups
This commit is contained in:
parent
988753e116
commit
bccf3f2f85
|
@ -12,3 +12,17 @@ bool EMUFILE::readAllBytes(std::vector<u8>* dstbuf, const std::string& fname)
|
|||
file.fread(&dstbuf->at(0),size);
|
||||
return true;
|
||||
}
|
||||
|
||||
EMUFILE* EMUFILE::memwrap(EMUFILE* fp)
|
||||
{
|
||||
EMUFILE_FILE* file;
|
||||
EMUFILE_MEMORY* mem;
|
||||
file = dynamic_cast<EMUFILE_FILE*>(fp);
|
||||
mem = dynamic_cast<EMUFILE_MEMORY*>(fp);
|
||||
if(mem) return mem;
|
||||
mem = new EMUFILE_MEMORY(file->size());
|
||||
if(file->size()==0) return mem;
|
||||
file->fread(mem->buf(),file->size());
|
||||
delete file;
|
||||
return mem;
|
||||
}
|
|
@ -52,6 +52,10 @@ public:
|
|||
: failbit(false)
|
||||
{}
|
||||
|
||||
|
||||
//takes control of the provided EMUFILE and returns a new EMUFILE which is guranteed to be in memory
|
||||
static EMUFILE* memwrap(EMUFILE* fp);
|
||||
|
||||
virtual ~EMUFILE() {}
|
||||
|
||||
static bool readAllBytes(std::vector<u8>* buf, const std::string& fname);
|
||||
|
@ -141,9 +145,19 @@ public:
|
|||
|
||||
virtual int fgetc() {
|
||||
u8 temp;
|
||||
if(_fread(&temp,1) != 1)
|
||||
return EOF;
|
||||
else return temp;
|
||||
|
||||
//need an optimized codepath
|
||||
//if(_fread(&temp,1) != 1)
|
||||
// return EOF;
|
||||
//else return temp;
|
||||
u32 remain = len-pos;
|
||||
if(remain<1) {
|
||||
failbit = true;
|
||||
return -1;
|
||||
}
|
||||
temp = buf()[pos];
|
||||
pos++;
|
||||
return temp;
|
||||
}
|
||||
virtual int fputc(int c) {
|
||||
u8 temp = (u8)c;
|
||||
|
|
|
@ -906,6 +906,7 @@ bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _paus
|
|||
|
||||
strcpy(curMovieFilename, fname);
|
||||
FCEUFILE *fp = FCEU_fopen(fname,0,"rb",0);
|
||||
fp->stream = EMUFILE::memwrap(fp->stream);
|
||||
if (!fp) return false;
|
||||
if(fp->isArchive() && !_read_only) {
|
||||
FCEU_PrintError("Cannot open a movie in read+write from an archive.");
|
||||
|
|
Loading…
Reference in New Issue