Open Memwatch File
| 527 | |
| 528 | //Open Memwatch File |
| 529 | static void LoadMemWatch() |
| 530 | { |
| 531 | const char filter[]="Memory address list (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"; |
| 532 | char watchfcontents[2048]; |
| 533 | |
| 534 | //Now clear last file used variable (memwLastFilename) |
| 535 | //This might be unecessary |
| 536 | for (int i=0;i<2048;i++) |
| 537 | { |
| 538 | memwLastFilename[i] = NULL; |
| 539 | } |
| 540 | |
| 541 | OPENFILENAME ofn; |
| 542 | memset(&ofn,0,sizeof(ofn)); |
| 543 | ofn.lStructSize=sizeof(ofn); |
| 544 | ofn.hInstance=fceu_hInstance; |
| 545 | ofn.lpstrTitle="Load Memory Watch..."; |
| 546 | ofn.lpstrFilter=filter; |
| 547 | memwLastFilename[0]=0; |
| 548 | ofn.lpstrFile=memwLastFilename; |
| 549 | ofn.nMaxFile=256; |
| 550 | ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; |
| 551 | string initdir = FCEU_GetPath(FCEUMKF_MEMW); |
| 552 | ofn.lpstrInitialDir=initdir.c_str(); |
| 553 | |
| 554 | if(GetOpenFileName(&ofn)) |
| 555 | { |
| 556 | int i,j; |
| 557 | |
| 558 | //Save the directory |
| 559 | if(ofn.nFileOffset < 1024) |
| 560 | { |
| 561 | free(MemWatchDir); |
| 562 | MemWatchDir=(char*)malloc(strlen(ofn.lpstrFile)+1); |
| 563 | strcpy(MemWatchDir,ofn.lpstrFile); |
| 564 | MemWatchDir[ofn.nFileOffset]=0; |
| 565 | } |
| 566 | |
| 567 | FILE *fp=FCEUD_UTF8fopen(memwLastFilename,"r"); |
| 568 | MemwAddRecentFile(memwLastFilename); |
| 569 | |
| 570 | for(i=0;i<NUMWATCHES;i++) |
| 571 | { |
| 572 | fscanf(fp, "%s ", watchfcontents); //Reads contents of newly opened file |
| 573 | for(j = 0; j < ADDRESSLENGTH; j++) |
| 574 | addresses[i][j] = watchfcontents[j]; |
| 575 | fscanf(fp, "%s\n", watchfcontents); |
| 576 | for(j = 0; j < LABELLENGTH; j++) |
| 577 | labels[i][j] = watchfcontents[j]; |
| 578 | |
| 579 | //Replace dummy strings with empty strings |
| 580 | if(addresses[i][0] == '|') |
| 581 | { |
| 582 | addresses[i][0] = 0; |
| 583 | } |
| 584 | if(labels[i][0] == '|') |
| 585 | { |
| 586 | labels[i][0] = 0; |
no test coverage detected