Esempio n. 1
0
        /// <summary>
        /// Exposes the current watch state based on index
        /// </summary>
        public Watch this[int index]
        {
            get
            {
                if (_settings.Mode == Settings.SearchMode.Detailed)
                {
                    return(Watch.GenerateWatch(
                               _settings.Domain,
                               _watchList[index].Address,
                               _settings.Size,
                               _settings.Type,
                               _settings.BigEndian,
                               "",
                               0,
                               _watchList[index].Previous,
                               ((IMiniWatchDetails)_watchList[index]).ChangeCount));
                }

                return(Watch.GenerateWatch(
                           _settings.Domain,
                           _watchList[index].Address,
                           _settings.Size,
                           _settings.Type,
                           _settings.BigEndian,
                           "",
                           0,
                           _watchList[index].Previous));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Exposes the current watch state based on index
 /// </summary>
 public Watch this[int index]
 {
     get
     {
         if (_settings.Mode == Settings.SearchMode.Detailed)
         {
             return(Watch.GenerateWatch(
                        _settings.Domain,
                        _watchList[index].Address,
                        _settings.Size,
                        _settings.Type,
                        _settings.BigEndian,
                        string.Empty,
                        0,
                        _watchList[index].Previous,
                        (_watchList[index] as IMiniWatchDetails).ChangeCount
                        ));
         }
         else
         {
             return(Watch.GenerateWatch(
                        _settings.Domain,
                        _watchList[index].Address,
                        _settings.Size,
                        _settings.Type,
                        _settings.BigEndian,
                        string.Empty,
                        0,
                        _watchList[index].Previous,
                        0
                        ));
         }
     }
 }
Esempio n. 3
0
        public Cheat(Cheat cheat)
        {
            if (cheat.IsSeparator)
            {
                _enabled = false;
                _watch   = SeparatorWatch.Instance;
                _compare = null;
            }
            else
            {
                _enabled = cheat.Enabled;
                _watch   = Watch.GenerateWatch(
                    cheat.Domain,
                    cheat.Address ?? 0,
                    cheat.Size,
                    cheat.Type,
                    cheat.BigEndian ?? false,
                    cheat.Name
                    );
                _compare = cheat.Compare;
                _val     = cheat.Value ?? 0;

                Pulse();
            }
        }
        public void AddGameGenie(string code)
        {
            if (NESAvailable)
            {
                var decoder = new NESGameGenieDecoder(code);
                var watch   = Watch.GenerateWatch(
                    Global.Emulator.AsMemoryDomains()["System Bus"],
                    decoder.Address,
                    WatchSize.Byte,
                    DisplayType.Hex,
                    false,
                    code);

                Global.CheatList.Add(new Cheat(
                                         watch,
                                         decoder.Value,
                                         decoder.Compare));
            }
        }
Esempio n. 5
0
        public static Watch FromString(string line, IMemoryDomains domains)
        {
            try
            {
                var parts = line.Split(new[] { '\t' }, 6);

                if (parts.Length < 6)
                {
                    if (parts.Length >= 3 && parts[2] == "_")
                    {
                        return(SeparatorWatch.Instance);
                    }

                    return(null);
                }

                var address   = long.Parse(parts[0], NumberStyles.HexNumber);
                var size      = Watch.SizeFromChar(parts[1][0]);
                var type      = Watch.DisplayTypeFromChar(parts[2][0]);
                var bigEndian = parts[3] == "0" ? false : true;
                var domain    = domains[parts[4]];
                var notes     = parts[5].Trim(new[] { '\r', '\n' });

                return(Watch.GenerateWatch(
                           domain,
                           address,
                           size,
                           type,
                           notes,
                           bigEndian
                           ));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 6
0
        public bool Load(string path, bool append)
        {
            var file = new FileInfo(path);

            if (file.Exists == false)
            {
                return(false);
            }

            if (!append)
            {
                _currentFileName = path;
            }

            using (var sr = file.OpenText())
            {
                if (!append)
                {
                    Clear();
                }

                string s;
                while ((s = sr.ReadLine()) != null)
                {
                    try
                    {
                        if (s == "----")
                        {
                            _cheatList.Add(Cheat.Separator);
                        }
                        else
                        {
                            int?compare;
                            var size      = WatchSize.Byte;
                            var type      = DisplayType.Hex;
                            var bigendian = false;
                            Cheat.CompareType comparisonType = Cheat.CompareType.None;

                            if (s.Length < 6)
                            {
                                continue;
                            }

                            var vals    = s.Split('\t');
                            var address = int.Parse(vals[0], NumberStyles.HexNumber);
                            var value   = int.Parse(vals[1], NumberStyles.HexNumber);

                            if (vals[2] == "N")
                            {
                                compare = null;
                            }
                            else
                            {
                                compare = int.Parse(vals[2], NumberStyles.HexNumber);
                            }

                            var domain  = Global.Emulator.AsMemoryDomains()[vals[3]];
                            var enabled = vals[4] == "1";
                            var name    = vals[5];

                            // For backwards compatibility, don't assume these values exist
                            if (vals.Length > 6)
                            {
                                size      = Watch.SizeFromChar(vals[6][0]);
                                type      = Watch.DisplayTypeFromChar(vals[7][0]);
                                bigendian = vals[8] == "1";
                            }

                            // For backwards compatibility, don't assume these values exist
                            if (vals.Length > 9)
                            {
                                if (!Enum.TryParse <Cheat.CompareType>(vals[9], out comparisonType))
                                {
                                    continue;                                     // Not sure if this is the best answer, could just resort to ==
                                }
                            }

                            var watch = Watch.GenerateWatch(
                                domain,
                                address,
                                size,
                                type,
                                bigendian,
                                name);

                            Add(new Cheat(watch, value, compare, !Global.Config.DisableCheatsOnLoad && enabled, comparisonType));
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            }

            Changes = false;
            return(true);
        }