Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        public void TestCheatcodeParsing(string systemID, string code, int address, int value, int?compare, WatchSize size)
        {
            var result = new GameSharkDecoder(null, systemID).Decode(code);

            Assert.IsTrue(result.IsValid(out var valid), "failed to parse");
            Assert.AreEqual(address, valid.Address, "wrong addr");
            Assert.AreEqual(size, valid.Size, "wrong size");
            Assert.AreEqual(
                value,
                valid.Size switch
            {
                WatchSize.Byte => valid.Value & 0xFF,
                WatchSize.Word => valid.Value & 0xFFFF,
                _ => valid.Value
            },