示例#1
0
        public void AddCheat(string code)
        {
            if (string.IsNullOrWhiteSpace(code))
            {
                return;
            }

            if (!MainForm.Emulator.HasMemoryDomains())
            {
                Log($"cheat codes not supported by the current system: {MainForm.Emulator.SystemId}");
                return;
            }

            var decoder = new GameSharkDecoder(MainForm.Emulator.AsMemoryDomains(), MainForm.Emulator.SystemId);
            var result  = decoder.Decode(code);

            if (result.IsValid)
            {
                var domain = decoder.CheatDomain();
                MainForm.CheatList.Add(result.ToCheat(domain, code));
            }
            else
            {
                Log(result.Error);
            }
        }
示例#2
0
        public void RemoveCheat(string code)
        {
            if (string.IsNullOrWhiteSpace(code))
            {
                return;
            }

            if (!MainForm.Emulator.HasMemoryDomains())
            {
                Log($"cheat codes not supported by the current system: {MainForm.Emulator.SystemId}");
                return;
            }

            var decoder = new GameSharkDecoder(MainForm.Emulator.AsMemoryDomains(), MainForm.Emulator.SystemId);
            var result  = decoder.Decode(code);

            if (result.IsValid)
            {
                MainForm.CheatList.RemoveRange(
                    MainForm.CheatList.Where(c => c.Address == result.Address));
            }
            else
            {
                Log(result.Error);
            }
        }
示例#3
0
        private void Go_Click(object sender, EventArgs e)
        {
            foreach (var l in txtCheat.Lines)
            {
                try
                {
                    var code    = l.ToUpper();
                    var decoder = new GameSharkDecoder(MemoryDomains, Emulator.SystemId);
                    var result  = decoder.Decode(code);
                    var domain  = decoder.CheatDomain();

                    if (result.IsValid)
                    {
                        var description = !string.IsNullOrWhiteSpace(txtDescription.Text)
                                                        ? txtDescription.Text
                                                        : code;
                        MainForm.CheatList.Add(result.ToCheat(domain, description));
                    }
                    else
                    {
                        MessageBox.Show(result.Error, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            txtCheat.Clear();
            txtDescription.Clear();
        }