public void ToggleBreakpoint() { List <ushort> execBreakpoints = _cpu.GetBreakpoints(BreakpointKinds.EXECUTION); if (execBreakpoints.Contains(originalAddress)) { _cpu.RemoveBreakpoint(BreakpointKinds.EXECUTION, originalAddress); HasBreakpoint = false; } else { _cpu.AddBreakpoint(BreakpointKinds.EXECUTION, originalAddress); HasBreakpoint = true; } if (BreakpointChanged != null) { BreakpointChanged(); } }
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; } }