~ubuntu-branches/ubuntu/utopic/fceux/utopic-proposed

« back to all changes in this revision

Viewing changes to src/drivers/win/ramwatch.cpp

  • Committer: Package Import Robot
  • Author(s): Joe Nahmias
  • Date: 2014-03-02 19:22:04 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140302192204-9f0aehi5stfnhn7d
Tags: 2.2.2+dfsg0-1
* Imported Upstream version 2.2.2
  + remove patches merged upstream; refresh remaining
  + remove windows compiled help files and non-free Visual C files
* Use C++11 standard static assertion functionality
* fix upstream installation of support files
* New patch 0004-ignore-missing-windows-help-CHM-file.patch
* update d/copyright for new, renamed, deleted files
* d/control: bump std-ver to 3.9.5, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
422
422
        }
423
423
        const char DELIM = '\t';
424
424
        AddressWatcher Temp;
 
425
        Temp.Address = 0;       // default values
 
426
        Temp.Size = 'b';
 
427
        Temp.Type = 'h';
425
428
        char mode;
426
429
        fgets(Str_Tmp,1024,WatchFile);
427
430
        sscanf(Str_Tmp,"%c%*s",&mode);
428
 
        //if ((mode == '1' && !(SegaCD_Started)) || (mode == '2' && !(_32X_Started)))
429
 
        //{
430
 
        //      char Device[8];
431
 
        //      strcpy(Device,(mode > '1')?"32X":"SegaCD");
432
 
        //      sprintf(Str_Tmp,"Warning: %s not started. \nWatches for %s addresses will be ignored.",Device,Device);
433
 
        //      MessageBox(MESSAGEBOXPARENT,Str_Tmp,"Possible Device Mismatch",MB_OK);
434
 
        //}
435
431
        int WatchAdd;
436
432
        fgets(Str_Tmp,1024,WatchFile);
437
433
        sscanf(Str_Tmp,"%d%*s",&WatchAdd);
438
434
        WatchAdd+=WatchCount;
439
435
        for (int i = WatchCount; i < WatchAdd; i++)
440
436
        {
441
 
                while (i < 0)
442
 
                        i++;
443
 
                do {
444
 
                        fgets(Str_Tmp,1024,WatchFile);
 
437
                if (i < 0) i = 0;
 
438
                memset(Str_Tmp, 0, 1024);
 
439
                do
 
440
                {
 
441
                        fgets(Str_Tmp, 1024, WatchFile);
445
442
                } while (Str_Tmp[0] == '\n');
446
 
                sscanf(Str_Tmp,"%*05X%*c%04X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian));
447
 
                Temp.WrongEndian = 0;
448
 
                char *Comment = strrchr(Str_Tmp,DELIM) + 1;
449
 
                *strrchr(Comment,'\n') = '\0';
450
 
                InsertWatch(Temp,Comment);
 
443
                sscanf(Str_Tmp, "%*05X%*c%04X%*c%c%*c%c%*c%*c", &(Temp.Address), &(Temp.Size), &(Temp.Type));
 
444
                Temp.WrongEndian = false;
 
445
                char *Comment = strrchr(Str_Tmp, DELIM);
 
446
                if (Comment)
 
447
                {
 
448
                        Comment++;
 
449
                        char *CommentEnd = strrchr(Comment, '\n');
 
450
                        if (CommentEnd)
 
451
                        {
 
452
                                *CommentEnd = '\0';
 
453
                                InsertWatch(Temp, Comment);
 
454
                        } else
 
455
                        {
 
456
                                // the wch file is probably corrupted
 
457
                                InsertWatch(Temp, Comment);
 
458
                                break;
 
459
                        }
 
460
                } else
 
461
                        break;  // the wch file is probably corrupted
451
462
        }
452
463
 
453
464
        fclose(WatchFile);
531
542
        if(dot) *dot = 0;
532
543
        if(Change_File_S(Str_Tmp, applicationPath, "Save Watches", "Watchlist (*.wch)\0*.wch\0All Files (*.*)\0*.*\0\0", "wch", RamWatchHWnd))
533
544
        {
534
 
                FILE *WatchFile = fopen(Str_Tmp,"r+b");
535
 
                if (!WatchFile) WatchFile = fopen(Str_Tmp,"w+b");
 
545
                FILE *WatchFile = fopen(Str_Tmp,"w+b");
536
546
                fputc('\n',WatchFile);
537
547
                strcpy(currentWatch,Str_Tmp);
538
548
                RWAddRecentFile(currentWatch);
562
572
        }
563
573
                
564
574
                strcpy(Str_Tmp,currentWatch);
565
 
                FILE *WatchFile = fopen(Str_Tmp,"r+b");
566
 
                if (!WatchFile) WatchFile = fopen(Str_Tmp,"w+b");
 
575
                FILE *WatchFile = fopen(Str_Tmp,"w+b");
567
576
                fputc('\n',WatchFile);
568
577
                sprintf(Str_Tmp,"%d\n",WatchCount);
569
578
                fputs(Str_Tmp,WatchFile);
662
671
{
663
672
        if(!AskSave())
664
673
                return false;
665
 
        for (;WatchCount>=0;WatchCount--)
 
674
        for (;WatchCount >= 0; WatchCount--)
666
675
        {
667
676
                free(rswatches[WatchCount].comment);
668
677
                rswatches[WatchCount].comment = NULL;
669
678
        }
670
 
        WatchCount++;
671
 
        if (RamWatchHWnd) {
 
679
        WatchCount = 0;
 
680
        if (RamWatchHWnd)
 
681
        {
672
682
                ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
673
683
                RefreshWatchListSelectedCountControlStatus(RamWatchHWnd);
674
684
        }