bool savestate_save(EMUFILE* outstream) { #ifdef HAVE_JIT arm_jit_sync(); #endif EMUFILE_MEMORY ms; EMUFILE* os = outstream; os->fseek(32,SEEK_SET); //skip the header writechunks(os); //save the length of the file u32 len = os->ftell(); u32 comprlen = 0xFFFFFFFF; u8* cbuf; //dump the header outstream->fseek(0,SEEK_SET); outstream->fwrite(magic,16); write32le(SAVESTATE_VERSION,outstream); write32le(EMU_DESMUME_VERSION_NUMERIC(),outstream); //desmume version write32le(len,outstream); //uncompressed length write32le(comprlen,outstream); //compressed length (-1 if it is not compressed) return true; }
u32 scanSaveTypeGBA() { if (!fROM) return 0xFF; fROM->fseek(0, SEEK_SET); int size = fROM->size(); int lastpct=1; int len = fROM->size(); for(;;) { u32 tmp; u32 readed = fROM->fread(&tmp, 4); int pos = fROM->ftell(); int currPct = pos*100/(size-1); for(int i=lastpct;i<currPct;i++) { if(i%10==0) printf(" %d%%\n",i/10*10); else printf("."); lastpct = currPct; } if (readed < 4) break; if(pos >= len) break; switch (tmp) { case EEPROM: return 1; case SRAM_: return 2; case FLASH: { u32 tmp = fROM->read32le(); return ((tmp == FLASH1M_)?3:5); } case SIIRTC_V: return 4; } } return 0xFF; }