Пример #1
0
        private void _breakpoints_BreakpointChanged()
        {
            // We remove the breakpoint icon
            foreach (InstructionViewModel inst in _addressWithBreakpoints.Values)
            {
                inst.HasBreakpoint = false;
            }

            // We recreate the list
            _addressWithBreakpoints = new Dictionary <ushort, InstructionViewModel>();

            // We update the breakpoints
            List <ushort> execBreakpoints = _cpu.GetBreakpoints(BreakpointKinds.EXECUTION);

            foreach (ushort breakpointAddress in execBreakpoints)
            {
                if (!_addressToInstruction.ContainsKey(breakpointAddress))
                {
                    continue;
                }

                InstructionViewModel inst = _addressToInstruction[breakpointAddress];
                _addressWithBreakpoints[breakpointAddress] = inst;
                inst.HasBreakpoint = true;
            }
        }
Пример #2
0
        public void SetCurrentInstruction(InstructionViewModel instruction)
        {
            if (_currentInstruction != null)
            {
                _currentInstruction.IsCurrent = false;
            }

            _currentInstruction           = instruction;
            _currentInstruction.IsCurrent = true;
        }
Пример #3
0
        private void Vm_BreakpointChanged()
        {
            // We recreate the instruction with breakpoints dictionary
            _addressWithBreakpoints = new Dictionary <ushort, InstructionViewModel>();
            List <ushort> execBreakpoints = _cpu.GetBreakpoints(BreakpointKinds.EXECUTION);

            foreach (ushort breakpointAddress in execBreakpoints)
            {
                if (!_addressToInstruction.ContainsKey(breakpointAddress))
                {
                    continue;
                }

                InstructionViewModel inst = _addressToInstruction[breakpointAddress];
                _addressWithBreakpoints[breakpointAddress] = inst;
            }

            _breakpoints.RecreateBreakpoints();
        }
Пример #4
0
        public void Dissasemble(ushort currentAddress)
        {
            _addressToInstruction   = new Dictionary <ushort, InstructionViewModel>();
            _addressWithBreakpoints = new Dictionary <ushort, InstructionViewModel>();

            _disassembler.PoorManDisassemble(currentAddress);
            _instructions.Clear();
            byte[][] matrix    = _disassembler.DisassembledMatrix;
            int      instCount = 0xFFFF;

            for (int address = 0; address < instCount; ++address)
            {
                byte[] entry     = matrix[address];
                int    intLength = entry[0];
                bool   CB        = false;


                if (intLength == 0)
                {
                    searchStrings[address] = "";
                    continue;
                }

                string searchString = "";
                var    vm           = new InstructionViewModel(_cpu);
                // We check the length
                if (intLength == 1)
                {
                    vm.Address        = "0x" + address.ToString("x2");
                    vm.originalOpcode = entry[1];
                    vm.Opcode         = "0x" + entry[1].ToString("x2");
                    vm.Name           = CPUInstructionNames.Get(entry[1]);
                    vm.Description    = CPUInstructionDescriptions.Get(entry[1]);
                }
                else if (intLength == 2)
                {
                    if (entry[1] != 0xCB)
                    {
                        vm.Address        = "0x" + address.ToString("x2");
                        vm.originalOpcode = entry[1];
                        vm.Opcode         = "0x" + entry[1].ToString("x2");
                        vm.Name           = CPUInstructionNames.Get(entry[1]);
                        vm.Literal        = "0x" + entry[2].ToString("x2");
                        vm.Description    = CPUInstructionDescriptions.Get(entry[1]);
                    }
                    else
                    {
                        CB         = true;
                        vm.Address = "0x" + address.ToString("x2");
                        int instOpcode = ((entry[1] << 8) | entry[2]);
                        vm.originalOpcode = (ushort)instOpcode;
                        vm.Opcode         = "0x" + instOpcode.ToString("x2");
                        vm.Name           = CPUCBInstructionNames.Get(entry[2]);
                        vm.Literal        = "0x" + entry[2].ToString("x2");
                        vm.Description    = CPUCBInstructionDescriptions.Get(entry[2]);
                    }
                }
                else
                {
                    vm.Address        = "0x" + address.ToString("x2");
                    vm.originalOpcode = entry[1];
                    vm.Opcode         = "0x" + entry[1].ToString("x2");
                    vm.Name           = CPUInstructionNames.Get(entry[1]);
                    int literal = ((entry[2] << 8) | entry[3]);
                    vm.Literal     = "0x" + literal.ToString("x2");
                    vm.Description = CPUInstructionDescriptions.Get(entry[1]);
                }
                vm.originalAddress = (ushort)address;

                if (!CB)
                {
                    vm.Ticks = CPUSpace.Dictionaries.CPUInstructionClocks.Get((byte)vm.originalOpcode);
                }
                else
                {
                    vm.Ticks = CPUSpace.Dictionaries.CPUCBInstructionClocks.Get((byte)vm.originalOpcode);
                }

                _instructions.Add(vm);
                _addressToInstruction[(ushort)address] = vm;
                vm.BreakpointChanged += Vm_BreakpointChanged;

                searchString += vm.Address + "_";
                searchString += vm.Opcode + "_";
                searchString += vm.Name + "_";
                searchString += vm.Literal;

                searchStrings[address] = searchString;

                if (address == currentAddress)
                {
                    SelectedInstruction = vm;
                    SetCurrentInstruction(vm);
                }
            }

            // We update the breakpoints
            List <ushort> execBreakpoints = _cpu.GetBreakpoints(BreakpointKinds.EXECUTION);

            foreach (ushort breakpointAddress in execBreakpoints)
            {
                if (!_addressToInstruction.ContainsKey(breakpointAddress))
                {
                    continue;
                }

                InstructionViewModel inst = _addressToInstruction[breakpointAddress];
                _addressWithBreakpoints[breakpointAddress] = inst;
                inst.HasBreakpoint = true;
            }
        }
        public void Dissasemble(ushort currentAddress)
        {
            _addressToInstruction = new Dictionary<ushort, InstructionViewModel>();
            _addressWithBreakpoints = new Dictionary<ushort, InstructionViewModel>();

            _disassembler.PoorManDisassemble(currentAddress);
            _instructions.Clear();
            byte[][] matrix = _disassembler.DisassembledMatrix;
            int instCount = 0xFFFF;
            for (int address = 0; address < instCount; ++address)
            {
                byte[] entry = matrix[address];
                int intLength = entry[0];
                bool CB = false;


                if (intLength == 0) {
                    searchStrings[address] = "";
                    continue;
                }

                string searchString = "";
                var vm = new InstructionViewModel(_cpu);
                // We check the length
                if (intLength == 1)
                {
                    vm.Address = "0x" + address.ToString("x2");
                    vm.originalOpcode = entry[1];
                    vm.Opcode = "0x" + entry[1].ToString("x2");
                    vm.Name = CPUInstructionNames.Get(entry[1]);
                    vm.Description = CPUInstructionDescriptions.Get(entry[1]);
                }
                else if (intLength == 2)
                {
                    if (entry[1] != 0xCB)
                    {
                        vm.Address = "0x" + address.ToString("x2");
                        vm.originalOpcode = entry[1];
                        vm.Opcode = "0x" + entry[1].ToString("x2");
                        vm.Name = CPUInstructionNames.Get(entry[1]);
                        vm.Literal = "0x" + entry[2].ToString("x2");
                        vm.Description = CPUInstructionDescriptions.Get(entry[1]);
                    }
                    else
                    {
                        CB = true;
                        vm.Address = "0x" + address.ToString("x2");
                        int instOpcode = ((entry[1] << 8) | entry[2]);
                        vm.originalOpcode = (ushort)instOpcode;
                        vm.Opcode = "0x" + instOpcode.ToString("x2");
                        vm.Name = CPUCBInstructionNames.Get(entry[2]);
                        vm.Literal = "0x" + entry[2].ToString("x2");
                        vm.Description = CPUCBInstructionDescriptions.Get(entry[2]);
                    }
                }
                else
                {
                    vm.Address = "0x" + address.ToString("x2");
                    vm.originalOpcode = entry[1];
                    vm.Opcode = "0x" + entry[1].ToString("x2");
                    vm.Name = CPUInstructionNames.Get(entry[1]);
                    int literal = ((entry[2] << 8) | entry[3]);
                    vm.Literal = "0x" + literal.ToString("x2");
                    vm.Description = CPUInstructionDescriptions.Get(entry[1]);
                }
                vm.originalAddress = (ushort)address;

                if (!CB)
                {
                    vm.Ticks = CPUSpace.Dictionaries.CPUInstructionClocks.Get((byte)vm.originalOpcode);
                }
                else
                {
                    vm.Ticks = CPUSpace.Dictionaries.CPUCBInstructionClocks.Get((byte)vm.originalOpcode);
                }

                _instructions.Add(vm);
                _addressToInstruction[(ushort)address] = vm;
                vm.BreakpointChanged += Vm_BreakpointChanged;

                searchString += vm.Address + "_";
                searchString += vm.Opcode + "_";
                searchString += vm.Name + "_";
                searchString += vm.Literal;

                searchStrings[address] = searchString;

                if (address == currentAddress)
                {
                    SelectedInstruction = vm;
                    SetCurrentInstruction(vm);
                }
            }

            // We update the breakpoints
            List<ushort> execBreakpoints = _cpu.GetBreakpoints(BreakpointKinds.EXECUTION);
            foreach (ushort breakpointAddress in execBreakpoints)
            {
                if (!_addressToInstruction.ContainsKey(breakpointAddress)) { continue; }

                InstructionViewModel inst = _addressToInstruction[breakpointAddress];
                _addressWithBreakpoints[breakpointAddress] = inst;
                inst.HasBreakpoint = true;
            }
        }
        public void SetCurrentInstruction(InstructionViewModel instruction)
        {
            if (_currentInstruction != null)
            {
                _currentInstruction.IsCurrent = false;
            }

            _currentInstruction = instruction;
            _currentInstruction.IsCurrent = true;
        }