6 AsmFileIOClass
, AsmGridClass
, CPUViewClass
, ConstantsClass
,
7 ExceptionViewClass
, FunctionsClass
, HardwareClass
, LogViewClass
,
8 MemoryViewClass
, MiscViewClass
, PrefixTreeClass
, ResourcesClass
,
9 StackViewClass
, SteppingClass
, TypesClass
,
10 Classes
, ComCtrls
, Controls
, Dialogs
, Forms
, Menus
, StdCtrls
;
13 TViewFPU
= class(TForm
)
18 HardwarePage
: TTabSheet
;
19 InstructionsPage
: TTabSheet
;
23 InstDescription
: TListBox
;
24 pOpenDialog
: TOpenDialog
;
25 pSaveDialog
: TSaveDialog
;
37 pOperandAdd
: TMenuItem
;
38 pOperandRemove
: TMenuItem
;
47 procedure FormCreate(Sender
: TObject
);
48 procedure FormResize(Sender
: TObject
);
49 // -----------------------------------------
50 procedure InstSearchClick(Sender
: TObject
);
51 procedure InstQueryChange(Sender
: TObject
);
52 procedure InstQueryKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
53 procedure InstructionsPageShow(Sender
: TObject
);
54 procedure InstListDblClick(Sender
: TObject
);
55 procedure InstListKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
56 // -----------------------------------------
57 procedure pNewClick(Sender
: TObject
);
58 procedure pOpenClick(Sender
: TObject
);
59 procedure pSaveClick(Sender
: TObject
);
60 procedure pExitClick(Sender
: TObject
);
61 procedure pResetClick(Sender
: TObject
);
62 procedure pStepClick(Sender
: TObject
);
63 procedure pOperandAddClick(Sender
: TObject
);
64 procedure pDefaultClick(Sender
: TObject
);
65 procedure pDarkClick(Sender
: TObject
);
66 procedure pClearClick(Sender
: TObject
);
67 procedure pAboutClick(Sender
: TObject
);
69 pAsmFileIO
: TAsmFileIO
;
73 pExceptionView
: TExceptionView
;
76 pMemoryView
: TMemoryView
;
78 pOldOnOperand
: TChangeEvent
;
80 pStackView
: TStackView
;
83 procedure pCustomOnClick(Sender
: TObject
); virtual;
84 procedure pOnOperand(Sender
: TObject
); virtual;
86 { Public declarations }
96 procedure TViewFPU
.FormCreate(Sender
: TObject
);
98 Caption
:= APP_VERSION
;
99 Application
.Title
:= APP_VERSION
;
100 pHardware
:= THardware
.Create
;
101 pOldOnOperand
:= pHardware
.OnOperand
;
102 pHardware
.OnOperand
:= pOnOperand
;
103 pLogView
:= TLogView
.CreateLogView(Self
, pHardware
);
104 pLogView
.Parent
:= HardwarePage
;
105 pStepping
:= TStepping
.Create
;
106 pStepping
.Hardware
:= pHardware
;
107 pAsmFileIO
:= TAsmFileIO
.Create
;
108 pAsmGrid
:= TAsmGrid
.CreateGrid(Self
, pStepping
);
109 pAsmGrid
.Parent
:= HardwarePage
;
110 pCPUView
:= TCPUView
.CreateCPUView(Self
, pHardware
);
111 pCPUView
.Parent
:= HardwarePage
;
112 pExceptionView
:= TExceptionView
.CreateExceptionView(Self
, pHardware
);
113 pExceptionView
.Parent
:= HardwarePage
;
114 pMemoryView
:= TMemoryView
.CreateMemoryView(Self
, pHardware
);
115 pMemoryView
.Parent
:= HardwarePage
;
116 pMiscView
:= TMiscView
.CreateMiscView(Self
, pHardware
);
117 pMiscView
.Parent
:= HardwarePage
;
118 pStackView
:= TStackView
.CreateStackView(Self
, pHardware
);
119 pStackView
.Parent
:= HardwarePage
;
120 Pages
.Width
:= ClientWidth
;
121 Pages
.Height
:= ClientHeight
;
122 Constraints
.MinWidth
:= LAY_MINWIDTH
+ (Width
- HardwarePage
.Width
);
123 Constraints
.MinHeight
:= LAY_MINHEIGHT
+ (Height
- HardwarePage
.Height
);
128 procedure TViewFPU
.FormResize(Sender
: TObject
);
130 lwidth
, lheight
: Extended
;
132 Pages
.Width
:= ClientWidth
;
133 Pages
.Height
:= ClientHeight
;
134 // HardwarePage layout
135 lwidth
:= (HardwarePage
.Width
- LAY_MINWIDTH
) / 6;
136 lheight
:= (HardwarePage
.Height
- LAY_MINHEIGHT
) / 10;
137 pAsmGrid
.Left
:= LAY_PADDING
;
138 pAsmGrid
.Top
:= LAY_PADDING
;
139 pAsmGrid
.Width
:= ASM_MINWIDTH
+ Round(4 * lwidth
);
140 pAsmGrid
.Height
:= ASM_MINHEIGHT
+ Round(7 * lheight
);
141 pMemoryView
.Left
:= pAsmGrid
.Left
;
142 pMemoryView
.Top
:= pAsmGrid
.Top
+ pAsmGrid
.Height
+ LAY_PADDING
;
143 pMemoryView
.Width
:= MEM_MINWIDTH
+ Round(6 * lwidth
);
144 pMemoryView
.Height
:= MEM_MINHEIGHT
+ Round(lheight
);
145 pLogView
.Left
:= pMemoryView
.Left
;
146 pLogView
.Top
:= pMemoryView
.Top
+ pMemoryView
.Height
+ LAY_PADDING
;
147 pLogView
.Width
:= pMemoryView
.Width
;
148 pLogView
.Height
:= LOG_MINHEIGHT
+ Round(2 * lheight
);
149 pStackView
.Left
:= pAsmGrid
.Left
+ pAsmGrid
.Width
+ LAY_PADDING
;
150 pStackView
.Top
:= pAsmGrid
.Top
;
151 pStackView
.Width
:= STA_MINWIDTH
+ Round(2 * lwidth
);
152 pStackView
.Height
:= STA_MINHEIGHT
+ Round(4 * lheight
);
153 pExceptionView
.Left
:= pStackView
.Left
;
154 pExceptionView
.Top
:= pStackView
.Top
+ pStackView
.Height
+ LAY_PADDING
;
155 pExceptionView
.Width
:= EXC_MINWIDTH
+ Round(lwidth
);
156 pExceptionView
.Height
:= EXC_MINHEIGHT
+ Round(3 * lheight
);
157 pMiscView
.Left
:= pExceptionView
.Left
+ pExceptionView
.Width
+ LAY_PADDING
;
158 pMiscView
.Top
:= pExceptionView
.Top
;
159 pMiscView
.Width
:= MSC_MINWIDTH
+ Round(lwidth
);
160 pMiscView
.Height
:= MSC_MINHEIGHT
+ Round(2 * lheight
);
161 pCPUView
.Left
:= pMiscView
.Left
;
162 pCPUView
.Top
:= pMiscView
.Top
+ pMiscView
.Height
+ LAY_PADDING
;
163 pCPUView
.Width
:= CPU_MINWIDTH
+ Round(lwidth
);
164 pCPUView
.Height
:= CPU_MINHEIGHT
+ Round(2 * lheight
);
165 // InstructionsPage layout
166 lwidth
:= InstructionsPage
.Width
- (3 * LAY_PADDING
);
167 lwidth
:= (lwidth
- INS_MINWIDTH
- InstSearch
.Width
) / 15;
168 lheight
:= InstructionsPage
.Height
- (3 * LAY_PADDING
);
169 InstQuery
.Left
:= LAY_PADDING
;
170 InstQuery
.Top
:= LAY_PADDING
;
171 InstQuery
.Width
:= INS_MINWIDTH
+ Round(lwidth
);
172 InstSearch
.Left
:= InstQuery
.Left
+ InstQuery
.Width
+ LAY_PADDING
;
173 InstSearch
.Top
:= LAY_PADDING
;
174 InstList
.Left
:= InstQuery
.Left
;
175 InstList
.Top
:= InstQuery
.Top
+ InstQuery
.Height
+ LAY_PADDING
;
176 InstList
.Width
:= InstQuery
.Width
+ LAY_PADDING
+ InstSearch
.Width
;
177 InstList
.Height
:= Round(lheight
) - InstQuery
.Height
;
178 InstDescription
.Left
:= InstList
.Left
+ InstList
.Width
+ LAY_PADDING
;
179 InstDescription
.Top
:= InstList
.Top
;
180 InstDescription
.Width
:= Round(14 * lwidth
);
181 InstDescription
.Height
:= InstList
.Height
;
184 procedure TViewFPU
.InstSearchClick(Sender
: TObject
);
186 lstrings
, ldescriptions
: TypesClass
.TStrings
;
190 if pDontChange
then Exit
;
191 SetLength(lstrings
, 0);
192 SetLength(ldescriptions
, 0);
195 if not(pText
= Text) or not(pPosition
= SelStart
) then
197 ltext
:= StringBefore(Text, SelStart
);
198 lstrings
:= pHardware
.InstructionsByPrefix(ltext
);
199 ldescriptions
:= pHardware
.DescriptionsByPrefix(ltext
);
200 InstDescription
.Clear
;
201 for i
:= 0 to (Length(ldescriptions
) - 1) do
202 InstDescription
.Items
.Add(ldescriptions
[i
]);
203 InstDescription
.TopIndex
:= 0;
205 if (Length(lstrings
) = 0) then
207 pHardware
.ValidateInstruction(ltext
);
208 InstList
.Items
.Add(pHardware
.LastError
);
212 for i
:= 0 to (Length(lstrings
) - 1) do
213 InstList
.Items
.Add(lstrings
[i
]);
214 InstList
.ItemIndex
:= 0;
218 pPosition
:= SelStart
;
222 procedure TViewFPU
.InstQueryChange(Sender
: TObject
);
227 procedure TViewFPU
.InstQueryKeyDown(Sender
: TObject
; var Key
: Word;
235 KEY_RETURN
: InstList
.OnDblClick(Self
);
236 KEY_HOME
: InstQuery
.SelStart
:= 0;
237 KEY_END
: InstQuery
.SelStart
:= Length(InstQuery
.Text);
238 KEY_LEFT
: InstQuery
.SelStart
:= InstQuery
.SelStart
- 1;
239 KEY_UP
: InstList
.ItemIndex
:= MaxOf(InstList
.ItemIndex
- 1, 0);
240 KEY_RIGHT
: InstQuery
.SelStart
:= InstQuery
.SelStart
+ 1;
241 KEY_DOWN
: InstList
.ItemIndex
:= InstList
.ItemIndex
+ 1;
247 procedure TViewFPU
.InstructionsPageShow(Sender
: TObject
);
253 procedure TViewFPU
.InstListDblClick(Sender
: TObject
);
258 InstListKeyDown(Sender
, lkey
, []);
261 procedure TViewFPU
.InstListKeyDown(Sender
: TObject
; var Key
: Word;
266 if (InstList
.Count
> 0) and not(InstList
.ItemIndex
< 0) then
269 InstQuery
.Text := InstList
.Items
[InstList
.ItemIndex
];
270 InstQuery
.SelStart
:= Length(InstQuery
.Text);
271 pDontChange
:= False;
277 // ************************************************************************** //
278 // * Menu items implementation * //
279 // ************************************************************************** //
281 procedure TViewFPU
.pNewClick(Sender
: TObject
);
283 pStepping
.InitializeBlocks
;
284 pHardware
.InitializeOperands
;
285 pHardware
.InitializeState
;
286 pAsmGrid
.ReloadInstructions
;
289 procedure TViewFPU
.pOpenClick(Sender
: TObject
);
291 if pOpenDialog
.Execute
then
293 pAsmFileIO
.LoadFromFile(pOpenDialog
.FileName
, pStepping
);
294 pAsmGrid
.ReloadInstructions
;
298 procedure TViewFPU
.pSaveClick(Sender
: TObject
);
300 if pSaveDialog
.Execute
then
301 pAsmFileIO
.SaveToFile(pSaveDialog
.FileName
, pStepping
);
304 procedure TViewFPU
.pExitClick(Sender
: TObject
);
306 Application
.Terminate
;
309 procedure TViewFPU
.pResetClick(Sender
: TObject
);
311 pAsmGrid
.ProgramReset
;
314 procedure TViewFPU
.pStepClick(Sender
: TObject
);
316 pAsmGrid
.ProgramStep
;
319 procedure TViewFPU
.pOperandAddClick(Sender
: TObject
);
321 pMemoryView
.OperandAdd
;
324 procedure TViewFPU
.pCustomOnClick(Sender
: TObject
);
326 pHardware
.OperandRemove(TMenuItem(Sender
).Hint
);
329 procedure TViewFPU
.pOnOperand(Sender
: TObject
);
332 ltrees
: TPrefixTrees
;
333 loper
: POperandRecord
;
335 pOperandRemove
.Clear
;
336 ltrees
:= pHardware
.Operands
.GetAllDescendants
;
337 for i
:= 0 to (Length(ltrees
) - 1) do
339 loper
:= POperandRecord(ltrees
[i
].Data
);
340 if (loper
^.Default
= '') then Continue
;
341 pOperandRemove
.Add(TMenuItem
.Create(pOperandRemove
));
342 with pOperandRemove
.Items
[pOperandRemove
.Count
- 1] do
344 Caption
:= loper
^.Name
;
346 OnClick
:= pCustomOnClick
;
347 Tag
:= Integer(loper
);
350 pOperandRemove
.Enabled
:= not(pOperandRemove
.Count
= 0);
351 if not(@pOldOnOperand
= nil) then pOldOnOperand(Sender
);
354 procedure TViewFPU
.pDefaultClick(Sender
: TObject
);
356 pDefault
.Checked
:= True;
357 pAsmGrid
.ColorTheme
:= THEME_GRID_DEFAULT
;
358 pStackView
.ColorTheme
:= THEME_VIEW_DEFAULT
;
359 pExceptionView
.ColorTheme
:= THEME_VIEW_DEFAULT
;
360 pMiscView
.ColorTheme
:= THEME_VIEW_DEFAULT
;
361 pCPUView
.ColorTheme
:= THEME_VIEW_DEFAULT
;
362 pMemoryView
.ColorTheme
:= THEME_VIEW_DEFAULT
;
363 pLogView
.ColorTheme
:= THEME_VIEW_DEFAULT
;
366 procedure TViewFPU
.pDarkClick(Sender
: TObject
);
368 pDark
.Checked
:= True;
369 pAsmGrid
.ColorTheme
:= THEME_GRID_DARK
;
370 pStackView
.ColorTheme
:= THEME_VIEW_DARK
;
371 pExceptionView
.ColorTheme
:= THEME_VIEW_DARK
;
372 pMiscView
.ColorTheme
:= THEME_VIEW_DARK
;
373 pCPUView
.ColorTheme
:= THEME_VIEW_DARK
;
374 pMemoryView
.ColorTheme
:= THEME_VIEW_DARK
;
375 pLogView
.ColorTheme
:= THEME_VIEW_DARK
;
378 procedure TViewFPU
.pClearClick(Sender
: TObject
);
380 pLogView
.Clear(Sender
);
383 procedure TViewFPU
.pAboutClick(Sender
: TObject
);
385 ShowMessage(ABO_TEXT
);