| 358 | } |
| 359 | |
| 360 | void SaveStrippedROM(int invert) |
| 361 | { |
| 362 | //this is based off of iNesSave() |
| 363 | //todo: make this support NSFs |
| 364 | const char NESfilter[]="Stripped iNes Rom file (*.NES)\0*.nes\0All Files (*.*)\0*.*\0\0"; |
| 365 | const char NSFfilter[]="Stripped NSF file (*.NSF)\0*.nsf\0All Files (*.*)\0*.*\0\0"; |
| 366 | char sromfilename[MAX_PATH]; |
| 367 | FILE *fp; |
| 368 | OPENFILENAME ofn; |
| 369 | iNES_HEADER cdlhead; |
| 370 | int i; |
| 371 | |
| 372 | if (!GameInfo) |
| 373 | return; |
| 374 | |
| 375 | if (GameInfo->type==GIT_NSF) |
| 376 | { |
| 377 | MessageBox(NULL, "Sorry, you're not allowed to save optimized NSFs yet. Please don't optimize individual banks, as there are still some issues with several NSFs to be fixed, and it is easier to fix those issues with as much of the bank data intact as possible.", "Disallowed", MB_OK); |
| 378 | return; |
| 379 | } |
| 380 | |
| 381 | if(codecount == 0) |
| 382 | { |
| 383 | MessageBox(NULL, "Unable to Generate Stripped ROM. Get Something Logged and try again.", "Error", MB_OK); |
| 384 | return; |
| 385 | } |
| 386 | memset(&ofn,0,sizeof(ofn)); |
| 387 | ofn.lStructSize=sizeof(ofn); |
| 388 | ofn.hInstance=fceu_hInstance; |
| 389 | ofn.lpstrTitle="Save Stripped File As..."; |
| 390 | strcpy(sromfilename, mass_replace(GetRomName(), "|", ".").c_str()); |
| 391 | if (GameInfo->type==GIT_NSF) { |
| 392 | ofn.lpstrFilter=NSFfilter; |
| 393 | ofn.lpstrDefExt = "nsf"; |
| 394 | } else { |
| 395 | ofn.lpstrFilter=NESfilter; |
| 396 | ofn.lpstrDefExt = "nes"; |
| 397 | } |
| 398 | ofn.lpstrFile=sromfilename; |
| 399 | ofn.nMaxFile=256; |
| 400 | ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; |
| 401 | ofn.hwndOwner = hCDLogger; |
| 402 | if(!GetSaveFileName(&ofn))return; |
| 403 | |
| 404 | fp = fopen(sromfilename,"wb"); |
| 405 | if(!fp) |
| 406 | { |
| 407 | FCEUD_PrintError("Error opening target stripped rom file!"); |
| 408 | return; |
| 409 | } |
| 410 | |
| 411 | if(GameInfo->type==GIT_NSF) |
| 412 | { |
| 413 | //Not used because if bankswitching, the addresses involved |
| 414 | //could still end up being used through writes |
| 415 | //static uint16 LoadAddr; |
| 416 | //LoadAddr=NSFHeader.LoadAddressLow; |
| 417 | //LoadAddr|=(NSFHeader.LoadAddressHigh&0x7F)<<8; |
no test coverage detected