diff --git a/source/fceultra/input.cpp b/source/fceultra/input.cpp index 54d826b..975fc1a 100644 --- a/source/fceultra/input.cpp +++ b/source/fceultra/input.cpp @@ -975,8 +975,10 @@ static void ToggleFullscreen(void) UpdateCheckedMenuItems(); changerecursive=1; - if(!SetVideoMode(fullscreen^1)) - SetVideoMode(fullscreen); + + int oldmode = fullscreen; + if(!SetVideoMode(oldmode ^1)) + SetVideoMode(oldmode); changerecursive=0; #endif -} \ No newline at end of file +} diff --git a/source/fceultra/movie.cpp b/source/fceultra/movie.cpp index 62a981b..8e10a23 100644 --- a/source/fceultra/movie.cpp +++ b/source/fceultra/movie.cpp @@ -403,6 +403,10 @@ void MovieData::installValue(std::string& key, std::string& val) StringToBytes(val,&savestate[0],len); // decodes either base64 or hex } } + else if (key == "length") + { + installInt(val, loadFrameCount); + } #endif } @@ -427,12 +431,16 @@ int MovieData::dump(std::ostream *os, bool binary) for(uint32 i=0;irecords.size() << endl; + if(binary) { //put one | to start the binary dump @@ -451,6 +459,54 @@ int MovieData::dump(std::ostream *os, bool binary) #endif } +int MovieData::dumpGreenzone(std::ostream *os, bool binary) +{ +#ifdef GEKKO + return 0; +#endif + int start = os->tellp(); + int frame, size; + for (int i=0; i<(int)records.size(); ++i) + { + if (records[i].savestate.empty()) + continue; + frame=i; + size=records[i].savestate.size(); + write32le(frame, os); + write32le(size, os); + + os->write(&records[i].savestate[0], size); + } + frame=-1; + size=currMovieData.greenZoneCount; + write32le(frame, os); + write32le(size, os); + + int end= os->tellp(); + + return end-start; +} + +int MovieData::loadGreenzone(std::istream *is, bool binary) +{ +#ifdef GEKKO + return 0; +#endif + int frame, size; + while(1) + { + if (!read32le((uint32 *)&frame, is)) {size=0; break;} + if (!read32le((uint32 *)&size, is)) {size=0; break;} + if (frame==-1) break; + int pos = is->tellg(); + FCEUSS_LoadFP(is, SSLOADPARAM_NOBACKUP); + is->seekg(pos+size); + } + greenZoneCount=size; + + return 1; +} + int FCEUMOV_GetFrame(void) { return currFrameCounter; @@ -524,6 +580,9 @@ static void LoadFM2_binarychunk(MovieData& movieData, std::istream* fp, int size int todo = std::min(size, flen); int numRecords = todo/recordsize; + if (movieData.loadFrameCount!=-1 && movieData.loadFrameCounttellg(); diff --git a/source/fceultra/movie.h b/source/fceultra/movie.h index f8ab0e7..1863a77 100644 --- a/source/fceultra/movie.h +++ b/source/fceultra/movie.h @@ -186,6 +186,7 @@ public: //----TasEdit stuff--- int greenZoneCount; + int loadFrameCount; //---- int getNumRecords() { return records.size(); } @@ -221,6 +222,9 @@ public: void truncateAt(int frame); void installValue(std::string& key, std::string& val); int dump(std::ostream* os, bool binary); + int dumpGreenzone(std::ostream *os, bool binary); + int loadGreenzone(std::istream *is, bool binary); + void clearRecordRange(int start, int len); void insertEmpty(int at, int frames); diff --git a/source/fceultra/ppu.cpp b/source/fceultra/ppu.cpp index dcd1506..c53fd75 100644 --- a/source/fceultra/ppu.cpp +++ b/source/fceultra/ppu.cpp @@ -2338,9 +2338,10 @@ int FCEUX_PPU_Loop(int skip) { if(yp >= spr[0] && yp < spr[0]+spriteHeight) { //if we already have maxsprites, then this new one causes an overflow, //set the flag and bail out. - if(oamcount == maxsprites) { + if(oamcount >= 8 && PPUON) { PPU_status |= 0x20; - break; + if (maxsprites == 8) + break; } //just copy some bytes into the internal sprite buffer