6 ConstantsClass
, CustomViewClass
, FunctionsClass
, HardwareClass
, HexEditClass
,
7 ResourcesClass
, TypesClass
,
14 TMiscView
= class(TCustomView
)
17 function pGetWidth
: Integer; virtual;
18 procedure pCustomKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
); virtual;
19 procedure pOnState(Sender
: TObject
); virtual;
20 procedure pSetWidth(Width
: Integer); virtual;
22 constructor CreateMiscView(AOwner
: TComponent
; Hw
: THardware
); virtual;
23 procedure ChangeCW
; virtual;
24 procedure ChangeSW
; virtual;
25 procedure CyclePrecision
; virtual;
26 procedure CycleRound
; virtual;
27 procedure ToggleCondition(Line
: Integer); virtual;
28 property Width read pGetWidth write pSetWidth
;
33 // ************************************************************************** //
34 // * TMiscView implementation * //
35 // ************************************************************************** //
37 function TMiscView
.pGetWidth
: Integer;
39 Result
:= inherited Width
;
42 procedure TMiscView
.pCustomKeyDown(Sender
: TObject
; var Key
: Word;
47 lselect
:= Selection
.TopLeft
;
48 if not(lselect
.X
= 1) then Exit
;
50 KEY_RETURN
, KEY_SPACE
:
54 2..5: ToggleCondition(lselect
.Y
);
61 procedure TMiscView
.pOnState(Sender
: TObject
);
65 with Hardware
.State
.FPUState
do
67 Changes
[1, 0] := not(StatusWord
= Hardware
.OldState
.FPUState
.StatusWord
);
68 Changes
[0, 0] := Changes
[1, 0];
69 Cells
[0, 0] := MSC_VIEW_FSW
;
70 Cells
[1, 0] := CustomDataToHex(@StatusWord
, SizeOf(StatusWord
));
71 Changes
[1, 1] := not(ControlWord
= Hardware
.OldState
.FPUState
.ControlWord
);
72 Changes
[0, 1] := Changes
[1, 1];
73 Cells
[0, 1] := MSC_VIEW_FCW
;
74 Cells
[1, 1] := CustomDataToHex(@ControlWord
, SizeOf(ControlWord
));
75 Changes
[1, 6] := not CompareStatePrecision(Hardware
);
76 Changes
[0, 6] := Changes
[1, 6];
77 Cells
[0, 6] := MSC_VIEW_PREC
;
78 Cells
[1, 6] := DESC_PREC
[GetPrecision(Hardware
.State
)];
79 Changes
[1, 7] := not CompareStateRound(Hardware
);
80 Changes
[0, 7] := Changes
[1, 7];
81 Cells
[0, 7] := MSC_VIEW_ROUND
;
82 Cells
[1, 7] := DESC_ROUN
[GetRound(Hardware
.State
)];
86 Changes
[1, i
+ 2] := not CompareStateCondition(Hardware
, i
);
87 Changes
[0, i
+ 2] := Changes
[1, i
+ 2];
88 Cells
[0, i
+ 2] := DESC_COND
[i
];
89 if GetCondition(Hardware
.State
, i
) then Cells
[1, i
+ 2] := MSC_VIEW_TRUE
90 else Cells
[1, i
+ 2] := MSC_VIEW_FALSE
;
94 procedure TMiscView
.pSetWidth(Width
: Integer);
96 inherited Width
:= Width
;
97 ColWidths
[1] := ClientWidth
div 2;
98 ColWidths
[0] := ClientWidth
- ColWidths
[1];
101 constructor TMiscView
.CreateMiscView(AOwner
: TComponent
; Hw
: THardware
);
103 inherited CreateView(AOwner
, Hw
);
106 OnKeyDown
:= pCustomKeyDown
;
108 pHexEdit
:= THexEdit
.Create(Self
);
109 PopupMenu
:= TPopupMenu
.Create(Self
);
112 Items
.Add(TMenuItem
.Create(PopupMenu
));
113 with Items
[Items
.Count
- 1] do
115 Caption
:= MSC_VIEW_CHANGE
;
116 OnClick
:= OnDblClick
;
123 procedure TMiscView
.ChangeCW
;
125 lstate
: THardwareState
;
127 lstate
:= Hardware
.State
;
128 pHexEdit
.Caption
:= MSC_VIEW_CHG_CW
;
129 with lstate
.FPUState
do
130 if pHexEdit
.ShowBox(@ControlWord
, SizeOf(ControlWord
)) then
131 Hardware
.State
:= lstate
;
134 procedure TMiscView
.ChangeSW
;
136 lstate
: THardwareState
;
138 lstate
:= Hardware
.State
;
139 pHexEdit
.Caption
:= MSC_VIEW_CHG_SW
;
140 with lstate
.FPUState
do
141 if pHexEdit
.ShowBox(@StatusWord
, SizeOf(StatusWord
)) then
142 Hardware
.State
:= lstate
;
145 procedure TMiscView
.CyclePrecision
;
147 lstate
: THardwareState
;
149 lstate
:= Hardware
.State
;
150 SetPrecision(lstate
, (GetPrecision(Hardware
.State
) + 1) mod 4);
151 Hardware
.State
:= lstate
;
154 procedure TMiscView
.CycleRound
;
156 lstate
: THardwareState
;
158 lstate
:= Hardware
.State
;
159 SetRound(lstate
, (GetRound(Hardware
.State
) + 1) mod 4);
160 Hardware
.State
:= lstate
;
163 procedure TMiscView
.ToggleCondition(Line
: Integer);
165 lstate
: THardwareState
;
167 if (Line
< 2) or (Line
> 5) then Exit
;
169 lstate
:= Hardware
.State
;
170 SetCondition(lstate
, Line
, not GetCondition(lstate
, Line
));
171 Hardware
.State
:= lstate
;