int UNIFLoad(const char *name, FCEUFILE *fp) { FCEU_fseek(fp,0,SEEK_SET); FCEU_fread(&unhead,1,4,fp); if(memcmp(&unhead,"UNIF",4)) return 0; ResetCartMapping(); ResetExState(0,0); ResetUNIF(); if(!FCEU_read32le(&unhead.info,fp)) goto aborto; if(FCEU_fseek(fp,0x20,SEEK_SET)<0) goto aborto; if(!LoadUNIFChunks(fp)) goto aborto; { int x; struct md5_context md5; md5_starts(&md5); for(x=0;x<32;x++) if(malloced[x]) { md5_update(&md5,malloced[x],mallocedsizes[x]); } md5_finish(&md5,UNIFCart.MD5); FCEU_printf(" ROM MD5: 0x"); for(x=0;x<16;x++) FCEU_printf("%02x",UNIFCart.MD5[x]); FCEU_printf("\n"); memcpy(&GameInfo->MD5,&UNIFCart.MD5,sizeof(UNIFCart.MD5)); } if(!InitializeBoard()) goto aborto; #if !defined(GEKKO)|| !defined(_XBOX) FCEU_LoadGameSave(&UNIFCart); #endif strcpy(LoadedRomFName,name); //For the debugger list GameInterface=UNIFGI; return 1; aborto: FreeUNIF(); ResetUNIF(); return 0; }
int UNIFLoad(const char *name, int fp) { FCEU_fseek(fp,0,SEEK_SET); FCEU_fread(&unhead,1,4,fp); if(memcmp(&unhead,"UNIF",4)) return 0; ResetCartMapping(); ResetExState(0,0); ResetUNIF(); if(!FCEU_read32(&unhead.info,fp)) goto aborto; if(FCEU_fseek(fp,0x20,SEEK_SET)<0) goto aborto; if(!LoadUNIFChunks(fp)) goto aborto; { int x; struct md5_context md5; md5_starts(&md5); for(x=0;x<32;x++) if(malloced[x]) { md5_update(&md5,malloced[x],mallocedsizes[x]); } md5_finish(&md5,UNIFCart.MD5); FCEU_printf(" ROM MD5: 0x"); for(x=0;x<16;x++) FCEU_printf("%02x",UNIFCart.MD5[x]); FCEU_printf("\n"); memcpy(FCEUGameInfo.MD5,UNIFCart.MD5,sizeof(UNIFCart.MD5)); } if(!InitializeBoard()) goto aborto; FCEU_LoadGameSave(&UNIFCart); GameInterface=UNIFGI; return 1; aborto: FreeUNIF(); ResetUNIF(); return 0; }
int CopyFamiLoad() { ResetCartMapping(); ResetExState(0, 0); sboardname = "COPYFAMI"; if (!InitializeBoard()) goto aborto; FCEU_LoadGameSave(&UNIFCart); GameInterface = UNIFGI; return 1; aborto: FreeUNIF(); ResetUNIF(); return 0; }
void UNIFLoad(Stream *fp, NESGameType *gt) { try { uint8 magic[4]; if(fp->read(magic, 4, false) != 4 || memcmp(magic, "UNIF", 4)) throw MDFN_Error(0, _("Not a valid UNIF file.")); ResetCartMapping(); ResetUNIF(); memset(WantInput, 0, sizeof(WantInput)); unhead.info = fp->get_LE<uint32>(); fp->seek(0x20, SEEK_SET); LoadUNIFChunks(fp); { md5_context md5; md5.starts(); for(int x = 0; x < 32; x++) { if(malloced[x]) { md5.update(malloced[x],mallocedsizes[x]); } } md5.finish(UNIFCart.MD5); MDFN_printf(_("ROM MD5: 0x%s\n"), md5_context::asciistr(UNIFCart.MD5, 0).c_str()); memcpy(MDFNGameInfo->MD5,UNIFCart.MD5,sizeof(UNIFCart.MD5)); MDFN_printf("\n"); } InitializeBoard(); MDFN_LoadGameSave(&UNIFCart); gt->Power = UNIF_Power; gt->Reset = UNIF_Reset; gt->SaveNV = UNIF_SaveNV; gt->Kill = UNIF_Kill; gt->StateAction = UNIF_StateAction; if(UNIFCart.CartExpSound.HiFill) GameExpSound.push_back(UNIFCart.CartExpSound); MDFNGameInfo->DesiredInput.push_back(WantInput[0]); MDFNGameInfo->DesiredInput.push_back(WantInput[1]); MDFNGameInfo->DesiredInput.push_back("gamepad"); MDFNGameInfo->DesiredInput.push_back("gamepad"); MDFNGameInfo->DesiredInput.push_back(WantInput[2]); } catch(...) { if(UNIFCart.Close) UNIFCart.Close(); FreeUNIF(); ResetUNIF(); throw; } }