MCPcopy Create free account
hub / github.com/TASEmulators/fceux / LoadFM2_binarychunk

Function LoadFM2_binarychunk

src/movie.cpp:607–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605}
606
607static void LoadFM2_binarychunk(MovieData& movieData, EMUFILE* fp, int size)
608{
609 int recordsize = 1; //1 for the command
610 if(movieData.fourscore)
611 recordsize += 4; //4 joysticks
612 else
613 {
614 for(int i=0;i<2;i++)
615 {
616 switch(movieData.ports[i])
617 {
618 case SI_GAMEPAD: recordsize++; break;
619 case SI_ZAPPER: recordsize+=12; break;
620 }
621 }
622 }
623
624 //find out how much remains in the file
625 int curr = fp->ftell();
626 fp->fseek(0,SEEK_END);
627 int end = fp->ftell();
628 int flen = end-curr;
629 fp->fseek(curr,SEEK_SET);
630
631 //the amount todo is the min of the limiting size we received and the remaining contents of the file
632 int todo = std::min<int>(size, flen);
633
634 int numRecords = todo/recordsize;
635 if (movieData.loadFrameCount!=-1 && movieData.loadFrameCount<numRecords)
636 numRecords=movieData.loadFrameCount;
637
638 movieData.records.resize(numRecords);
639 for(int i=0;i<numRecords;i++)
640 {
641 movieData.records[i].parseBinary(&movieData,fp);
642 }
643}
644
645//yuck... another custom text parser.
646bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader)

Callers 1

LoadFM2Function · 0.85

Calls 3

parseBinaryMethod · 0.80
ftellMethod · 0.45
fseekMethod · 0.45

Tested by

no test coverage detected