Changeset 12 for trunk/Z80/Z80.pas
- Timestamp:
- Apr 21, 2026, 11:04:26 AM (6 days ago)
- File:
-
- 1 edited
-
trunk/Z80/Z80.pas (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Z80/Z80.pas
r11 r12 4 4 5 5 uses 6 Classes, SysUtils, Memory, Base, Z80Instructions; 6 Classes, SysUtils, Memory, Base, Z80Instructions, Generics.Collections, 7 Generics.Defaults; 7 8 8 9 type … … 41 42 42 43 TDebugMode = (dmNone, dmStepIn, dmStepOut, dmStepOver, dmStopAddress); 44 45 { TBreakPoints } 46 47 TBreakPoints = class(TList<Word>) 48 private 49 function Comparer(constref Left, Right: Word): Integer; 50 public 51 function Contains(Address: Word): Boolean; 52 procedure AddNew(Address: Word); 53 end; 43 54 44 55 { TCpuZ80 } … … 821 832 InterruptEnabled: Boolean; 822 833 InterruptMode: Byte; 834 BreakPoints: TBreakPoints; 823 835 DebugMode: TDebugMode; 824 836 DebugStopAddress: Word; … … 851 863 while not Terminated do begin 852 864 Cpu.Step; 853 if Cpu.DebugMode <> dmNone then begin854 if Cpu.DebugMode = dmStepIn then begin855 Cpu.DebugMode := dmNone;856 Terminate;857 end;858 if (Cpu.DebugMode = dmStopAddress) and (Cpu.DebugStopAddress = Cpu.PC) then begin859 Cpu.DebugMode := dmNone;860 Terminate;861 end;862 if Cpu.DebugMode = dmStepOver then begin863 Cpu.DebugMode := dmNone;864 Terminate;865 end;866 end;867 865 end; 868 866 Cpu.FRunning := False; 867 end; 868 869 { TBreakPoints } 870 871 function TBreakPoints.Comparer(constref Left, Right: Word): Integer; 872 begin 873 if Left > Right then Result := 1 874 else if Left < Right then Result := -1 875 else Result := 0; 876 end; 877 878 function TBreakPoints.Contains(Address: Word): Boolean; 879 var 880 Index: SizeInt; 881 begin 882 if (Count > 0) and BinarySearch(Address, Index, TComparer<Word>.Construct(Comparer)) then begin 883 Result := True; 884 end else Result := False; 885 end; 886 887 procedure TBreakPoints.AddNew(Address: Word); 888 begin 889 Add(Address); 890 Sort; 869 891 end; 870 892 … … 5533 5555 end; 5534 5556 Ticks := Cardinal(Ticks + 1); 5557 5558 // Debugging 5559 if DebugMode <> dmNone then begin 5560 if DebugMode = dmStepIn then begin 5561 DebugMode := dmNone; 5562 FThread.Terminate; 5563 end; 5564 if (DebugMode = dmStopAddress) and (DebugStopAddress = PC) then begin 5565 DebugMode := dmNone; 5566 FThread.Terminate; 5567 end; 5568 if DebugMode = dmStepOver then begin 5569 DebugMode := dmNone; 5570 FThread.Terminate; 5571 end; 5572 end; 5573 if BreakPoints.Contains(PC) then begin 5574 DebugMode := dmNone; 5575 FThread.Terminate; 5576 end; 5535 5577 end; 5536 5578 … … 5550 5592 constructor TCpuZ80.Create; 5551 5593 begin 5594 BreakPoints := TBreakPoints.Create; 5552 5595 InitInstructions; 5553 5596 Reset; … … 5557 5600 begin 5558 5601 Running := False; 5602 FreeAndNil(BreakPoints); 5559 5603 inherited; 5560 5604 end;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/mzxemu/chrome/site/your_project_logo.png)