-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWatchViewForm.pas
More file actions
118 lines (105 loc) · 2.94 KB
/
WatchViewForm.pas
File metadata and controls
118 lines (105 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
unit WatchViewForm;
interface
uses
Types, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, ValEdit, Emulator, RoutineMapping, Debugger;
type
TWatchView = class(TForm)
Values: TValueListEditor;
private
FDebugger: TDebugger;
{ Private declarations }
function SpecifierToAddress(ASpecifier: string): Word;
function AccessToAddress(AString: string): Word;
function IsRegisterOnly(AString: string): Boolean;
public
{ Public declarations }
property Debugger: TDebugger read FDebugger write FDebugger;
procedure UpdateData(ARoutine: TRoutineMapping);
end;
var
WatchView: TWatchView;
implementation
uses
StrUtils, EmuTypes;
{$R *.dfm}
{ TWatchView }
function TWatchView.AccessToAddress(AString: string): Word;
var
LData: TStringDynArray;
LSpecifier: string;
begin
Result := 0;
LData := SplitString(AString, '+');
for LSpecifier in LData do
begin
Result := Result + SpecifierToAddress(LSpecifier);
end;
end;
function TWatchView.IsRegisterOnly(AString: string): Boolean;
begin
Result := RegisterToIndex(Trim(AString)) > -1;
end;
function TWatchView.SpecifierToAddress(ASpecifier: string): Word;
var
LValue: Integer;
begin
if TryStrToInt(Trim(ASpecifier), LValue) then
begin
Result := LValue;
end
else
begin
Result := FDebugger.ReadRegister(RegisterToIndex(Trim(ASpecifier)));
end;
end;
procedure TWatchView.UpdateData(ARoutine: TRoutineMapping);
var
LParameter: TParameter;
LValue: Integer;
LText: string;
begin
Values.Strings.BeginUpdate();
try
Values.Strings.Clear;
if Assigned(ARoutine) then
begin
for LParameter in ARoutine.Parameters do
begin
if IsRegisterOnly(LParameter.Access) then
begin
LValue := FDebugger.ReadRegister(RegisterToIndex(Trim(LParameter.Access)));
end
else
begin
LValue := FDebugger.ReadWord(AccessToAddress(LParameter.Access));
end;
case AnsiIndexText(LParameter.TypeName, ['string', 'char']) of
0: LText := FDebugger.ReadString(LValue);
1: LText := Char(LValue and 127);
else
begin
LText := IntToStr(LValue);
end;
end;
Values.InsertRow(LParameter.Name, LText, True);
end;
for LParameter in ARoutine.Locals do
begin
LValue := FDebugger.ReadWord(AccessToAddress(LParameter.Access));
case AnsiIndexText(LParameter.TypeName, ['string', 'char']) of
0: LText := FDebugger.ReadString(LValue);
1: LText := Char(LValue and 127); //FDebugger.ReadChar(LValue);
else
begin
LText := IntToStr(LValue);
end;
end;
Values.InsertRow(LParameter.Name, LText, True);
end;
end;
finally
Values.Strings.EndUpdate();
end;
end;
end.