OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [emuThor/] [source/] [frmRun.h] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 robfinch
#pragma once
2
#include <math.h>
3
#include "fmrFreeRun.h"
4
#include "clsDisassem.h"
5
 
6
extern clsDisassem da;
7
extern bool isRunning;
8
extern bool quit;
9
extern bool stepout, stepover;
10
extern unsigned int step_depth, stepover_depth;
11
extern unsigned int stepoverBkpt;
12
extern unsigned int stepover_pc;
13
extern bool animate;
14
extern bool fullspeed;
15
extern bool runstop;
16
extern bool runClosed;
17
 
18
namespace emuThor {
19
 
20
        using namespace System;
21
        using namespace System::ComponentModel;
22
        using namespace System::Collections;
23
        using namespace System::Windows::Forms;
24
        using namespace System::Data;
25
        using namespace System::Drawing;
26
        using namespace System::Threading;
27
        using namespace System::Diagnostics;
28
 
29
        /// <summary>
30
        /// Summary for frmRun
31
        /// </summary>
32
        public ref class frmRun : public System::Windows::Forms::Form
33
        {
34
        public:
35
                frmRun(Mutex^ m)
36
                {
37
                        InitializeComponent();
38
                        //
39
                        //TODO: Add the constructor code here
40
                        //
41
                        mut = m;
42
                        stopwatch = gcnew Stopwatch;
43
                        InitializeBackgroundWorker();
44
                        toolTipMHz->SetToolTip(lblMHz,"Shows an estimate of the frequency of operation\n of the emulator compared to the FPGA version.");
45
                }
46
 
47
        protected:
48
                /// <summary>
49
                /// Clean up any resources being used.
50
                /// </summary>
51
                ~frmRun()
52
                {
53
                        if (components)
54
                        {
55
                                delete components;
56
                        }
57
                }
58
        private: System::Windows::Forms::TrackBar^  trackBar1;
59
        protected:
60
        private: System::Windows::Forms::ListBox^  listBoxCode;
61
        private: System::Windows::Forms::ListBox^  listBoxBytes;
62
        private: System::Windows::Forms::ListBox^  listBoxAdr;
63
        private: System::Windows::Forms::ToolStrip^  toolStrip1;
64
        private: System::Windows::Forms::ToolStripButton^  toolStripButton1;
65
        private: System::Windows::Forms::ToolStripButton^  toolStripButton2;
66
        private: System::Windows::Forms::ToolStripButton^  toolStripButton3;
67
        private: System::Windows::Forms::ToolStripButton^  toolStripButton4;
68
        private: System::Windows::Forms::ToolStripButton^  toolStripButton5;
69
 
70
 
71
        private: System::Windows::Forms::ToolStripButton^  toolStripButton8;
72
        private: Mutex^ mut;
73
        private: Stopwatch^ stopwatch;
74
        private: __int64 startTick, stopTick;
75
        private: System::Windows::Forms::MenuStrip^  menuStrip1;
76
 
77
        private: System::Windows::Forms::ToolStripMenuItem^  stepOverToolStripMenuItem;
78
        private: System::Windows::Forms::ToolStripMenuItem^  stepOutToolStripMenuItem;
79
 
80
        private: System::Windows::Forms::ToolStripMenuItem^  stopToolStripMenuItem;
81
        private: System::Windows::Forms::ToolStripMenuItem^  resetToolStripMenuItem;
82
        private: System::Windows::Forms::Timer^  timer1;
83
        private: System::Windows::Forms::ToolStripMenuItem^  animateToolStripMenuItem;
84
        private: System::Windows::Forms::Label^  label1;
85
        private: System::Windows::Forms::ProgressBar^  progressBar1;
86
        private: System::Windows::Forms::NumericUpDown^  numSteps;
87
 
88
        private: System::Windows::Forms::Label^  label2;
89
        private: System::Windows::Forms::Button^  button1;
90
        private: System::ComponentModel::BackgroundWorker^  backgroundWorker1;
91
        private: System::Windows::Forms::Button^  button2;
92
        private: System::Windows::Forms::Label^  label3;
93
        private: System::Windows::Forms::ToolStripMenuItem^  stepIntoToolStripMenuItem;
94
        private: System::Windows::Forms::Label^  lblMHz;
95
        private: System::Windows::Forms::ToolTip^  toolTipMHz;
96
 
97
        private: System::ComponentModel::IContainer^  components;
98
 
99
        private:
100
                /// <summary>
101
                /// Required designer variable.
102
                /// </summary>
103
 
104
 
105
#pragma region Windows Form Designer generated code
106
                /// <summary>
107
                /// Required method for Designer support - do not modify
108
                /// the contents of this method with the code editor.
109
                /// </summary>
110
                void InitializeComponent(void)
111
                {
112
                        this->components = (gcnew System::ComponentModel::Container());
113
                        System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(frmRun::typeid));
114
                        this->trackBar1 = (gcnew System::Windows::Forms::TrackBar());
115
                        this->listBoxCode = (gcnew System::Windows::Forms::ListBox());
116
                        this->listBoxBytes = (gcnew System::Windows::Forms::ListBox());
117
                        this->listBoxAdr = (gcnew System::Windows::Forms::ListBox());
118
                        this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
119
                        this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
120
                        this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());
121
                        this->toolStripButton3 = (gcnew System::Windows::Forms::ToolStripButton());
122
                        this->toolStripButton4 = (gcnew System::Windows::Forms::ToolStripButton());
123
                        this->toolStripButton5 = (gcnew System::Windows::Forms::ToolStripButton());
124
                        this->toolStripButton8 = (gcnew System::Windows::Forms::ToolStripButton());
125
                        this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
126
                        this->stepIntoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
127
                        this->stepOverToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
128
                        this->stepOutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
129
                        this->animateToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
130
                        this->stopToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
131
                        this->resetToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
132
                        this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
133
                        this->label1 = (gcnew System::Windows::Forms::Label());
134
                        this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
135
                        this->numSteps = (gcnew System::Windows::Forms::NumericUpDown());
136
                        this->label2 = (gcnew System::Windows::Forms::Label());
137
                        this->button1 = (gcnew System::Windows::Forms::Button());
138
                        this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
139
                        this->button2 = (gcnew System::Windows::Forms::Button());
140
                        this->label3 = (gcnew System::Windows::Forms::Label());
141
                        this->lblMHz = (gcnew System::Windows::Forms::Label());
142
                        this->toolTipMHz = (gcnew System::Windows::Forms::ToolTip(this->components));
143
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBar1))->BeginInit();
144
                        this->toolStrip1->SuspendLayout();
145
                        this->menuStrip1->SuspendLayout();
146
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numSteps))->BeginInit();
147
                        this->SuspendLayout();
148
                        // 
149
                        // trackBar1
150
                        // 
151
                        this->trackBar1->Location = System::Drawing::Point(565, 63);
152
                        this->trackBar1->Maximum = 12;
153
                        this->trackBar1->Name = L"trackBar1";
154
                        this->trackBar1->Size = System::Drawing::Size(137, 45);
155
                        this->trackBar1->TabIndex = 12;
156
                        this->trackBar1->TickStyle = System::Windows::Forms::TickStyle::TopLeft;
157
                        this->trackBar1->Value = 7;
158
                        this->trackBar1->Scroll += gcnew System::EventHandler(this, &frmRun::trackBar1_Scroll);
159
                        // 
160
                        // listBoxCode
161
                        // 
162
                        this->listBoxCode->FormattingEnabled = true;
163
                        this->listBoxCode->Location = System::Drawing::Point(232, 63);
164
                        this->listBoxCode->Name = L"listBoxCode";
165
                        this->listBoxCode->Size = System::Drawing::Size(327, 433);
166
                        this->listBoxCode->TabIndex = 11;
167
                        // 
168
                        // listBoxBytes
169
                        // 
170
                        this->listBoxBytes->FormattingEnabled = true;
171
                        this->listBoxBytes->Location = System::Drawing::Point(85, 63);
172
                        this->listBoxBytes->Name = L"listBoxBytes";
173
                        this->listBoxBytes->Size = System::Drawing::Size(141, 433);
174
                        this->listBoxBytes->TabIndex = 10;
175
                        // 
176
                        // listBoxAdr
177
                        // 
178
                        this->listBoxAdr->FormattingEnabled = true;
179
                        this->listBoxAdr->Location = System::Drawing::Point(8, 63);
180
                        this->listBoxAdr->Name = L"listBoxAdr";
181
                        this->listBoxAdr->Size = System::Drawing::Size(71, 433);
182
                        this->listBoxAdr->TabIndex = 9;
183
                        // 
184
                        // toolStrip1
185
                        // 
186
                        this->toolStrip1->Dock = System::Windows::Forms::DockStyle::None;
187
                        this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(6) {this->toolStripButton1,
188
                                this->toolStripButton2, this->toolStripButton3, this->toolStripButton4, this->toolStripButton5, this->toolStripButton8});
189
                        this->toolStrip1->Location = System::Drawing::Point(9, 35);
190
                        this->toolStrip1->Name = L"toolStrip1";
191
                        this->toolStrip1->Size = System::Drawing::Size(150, 25);
192
                        this->toolStrip1->TabIndex = 13;
193
                        this->toolStrip1->Text = L"toolStrip1";
194
                        // 
195
                        // toolStripButton1
196
                        // 
197
                        this->toolStripButton1->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
198
                        this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton1.Image")));
199
                        this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
200
                        this->toolStripButton1->Name = L"toolStripButton1";
201
                        this->toolStripButton1->Size = System::Drawing::Size(23, 22);
202
                        this->toolStripButton1->Text = L"Step Into";
203
                        this->toolStripButton1->Click += gcnew System::EventHandler(this, &frmRun::toolStripButton1_Click);
204
                        // 
205
                        // toolStripButton2
206
                        // 
207
                        this->toolStripButton2->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
208
                        this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton2.Image")));
209
                        this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Magenta;
210
                        this->toolStripButton2->Name = L"toolStripButton2";
211
                        this->toolStripButton2->Size = System::Drawing::Size(23, 22);
212
                        this->toolStripButton2->Text = L"Step Over (Bounce)";
213
                        this->toolStripButton2->Click += gcnew System::EventHandler(this, &frmRun::toolStripButton2_Click);
214
                        // 
215
                        // toolStripButton3
216
                        // 
217
                        this->toolStripButton3->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
218
                        this->toolStripButton3->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton3.Image")));
219
                        this->toolStripButton3->ImageTransparentColor = System::Drawing::Color::Magenta;
220
                        this->toolStripButton3->Name = L"toolStripButton3";
221
                        this->toolStripButton3->Size = System::Drawing::Size(23, 22);
222
                        this->toolStripButton3->Text = L"Step Out Of";
223
                        this->toolStripButton3->Click += gcnew System::EventHandler(this, &frmRun::toolStripButton3_Click);
224
                        // 
225
                        // toolStripButton4
226
                        // 
227
                        this->toolStripButton4->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
228
                        this->toolStripButton4->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton4.Image")));
229
                        this->toolStripButton4->ImageTransparentColor = System::Drawing::Color::Magenta;
230
                        this->toolStripButton4->Name = L"toolStripButton4";
231
                        this->toolStripButton4->Size = System::Drawing::Size(23, 22);
232
                        this->toolStripButton4->Text = L"Run";
233
                        this->toolStripButton4->Click += gcnew System::EventHandler(this, &frmRun::toolStripButton4_Click);
234
                        // 
235
                        // toolStripButton5
236
                        // 
237
                        this->toolStripButton5->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
238
                        this->toolStripButton5->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton5.Image")));
239
                        this->toolStripButton5->ImageTransparentColor = System::Drawing::Color::Magenta;
240
                        this->toolStripButton5->Name = L"toolStripButton5";
241
                        this->toolStripButton5->Size = System::Drawing::Size(23, 22);
242
                        this->toolStripButton5->Text = L"Stop";
243
                        this->toolStripButton5->Click += gcnew System::EventHandler(this, &frmRun::toolStripButton5_Click);
244
                        // 
245
                        // toolStripButton8
246
                        // 
247
                        this->toolStripButton8->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
248
                        this->toolStripButton8->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton8.Image")));
249
                        this->toolStripButton8->ImageTransparentColor = System::Drawing::Color::Magenta;
250
                        this->toolStripButton8->Name = L"toolStripButton8";
251
                        this->toolStripButton8->Size = System::Drawing::Size(23, 22);
252
                        this->toolStripButton8->Text = L"Reset Button";
253
                        this->toolStripButton8->Click += gcnew System::EventHandler(this, &frmRun::toolStripButton8_Click);
254
                        // 
255
                        // menuStrip1
256
                        // 
257
                        this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(6) {this->stepIntoToolStripMenuItem,
258
                                this->stepOverToolStripMenuItem, this->stepOutToolStripMenuItem, this->animateToolStripMenuItem, this->stopToolStripMenuItem,
259
                                this->resetToolStripMenuItem});
260
                        this->menuStrip1->Location = System::Drawing::Point(0, 0);
261
                        this->menuStrip1->Name = L"menuStrip1";
262
                        this->menuStrip1->Size = System::Drawing::Size(741, 24);
263
                        this->menuStrip1->TabIndex = 14;
264
                        this->menuStrip1->Text = L"menuStrip1";
265
                        this->menuStrip1->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &frmRun::menuStrip1_ItemClicked);
266
                        // 
267
                        // stepIntoToolStripMenuItem
268
                        // 
269
                        this->stepIntoToolStripMenuItem->Name = L"stepIntoToolStripMenuItem";
270
                        this->stepIntoToolStripMenuItem->Size = System::Drawing::Size(66, 20);
271
                        this->stepIntoToolStripMenuItem->Text = L"Step I&nto";
272
                        this->stepIntoToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmRun::stepIntoToolStripMenuItem_Click);
273
                        // 
274
                        // stepOverToolStripMenuItem
275
                        // 
276
                        this->stepOverToolStripMenuItem->Name = L"stepOverToolStripMenuItem";
277
                        this->stepOverToolStripMenuItem->Size = System::Drawing::Size(70, 20);
278
                        this->stepOverToolStripMenuItem->Text = L"Step &Over";
279
                        this->stepOverToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmRun::stepOverToolStripMenuItem_Click);
280
                        // 
281
                        // stepOutToolStripMenuItem
282
                        // 
283
                        this->stepOutToolStripMenuItem->Name = L"stepOutToolStripMenuItem";
284
                        this->stepOutToolStripMenuItem->Size = System::Drawing::Size(65, 20);
285
                        this->stepOutToolStripMenuItem->Text = L"Step Ou&t";
286
                        this->stepOutToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmRun::stepOutToolStripMenuItem_Click);
287
                        // 
288
                        // animateToolStripMenuItem
289
                        // 
290
                        this->animateToolStripMenuItem->Name = L"animateToolStripMenuItem";
291
                        this->animateToolStripMenuItem->Size = System::Drawing::Size(64, 20);
292
                        this->animateToolStripMenuItem->Text = L"&Animate";
293
                        this->animateToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmRun::animateToolStripMenuItem_Click);
294
                        // 
295
                        // stopToolStripMenuItem
296
                        // 
297
                        this->stopToolStripMenuItem->Name = L"stopToolStripMenuItem";
298
                        this->stopToolStripMenuItem->Size = System::Drawing::Size(43, 20);
299
                        this->stopToolStripMenuItem->Text = L"&Stop";
300
                        this->stopToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmRun::stopToolStripMenuItem_Click);
301
                        // 
302
                        // resetToolStripMenuItem
303
                        // 
304
                        this->resetToolStripMenuItem->Name = L"resetToolStripMenuItem";
305
                        this->resetToolStripMenuItem->Size = System::Drawing::Size(47, 20);
306
                        this->resetToolStripMenuItem->Text = L"&Reset";
307
                        this->resetToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmRun::resetToolStripMenuItem_Click);
308
                        // 
309
                        // timer1
310
                        // 
311
                        this->timer1->Tick += gcnew System::EventHandler(this, &frmRun::timer1_Tick);
312
                        // 
313
                        // label1
314
                        // 
315
                        this->label1->AutoSize = true;
316
                        this->label1->Location = System::Drawing::Point(568, 38);
317
                        this->label1->Name = L"label1";
318
                        this->label1->Size = System::Drawing::Size(79, 13);
319
                        this->label1->TabIndex = 15;
320
                        this->label1->Text = L"Animation Rate";
321
                        // 
322
                        // progressBar1
323
                        // 
324
                        this->progressBar1->Location = System::Drawing::Point(571, 231);
325
                        this->progressBar1->Name = L"progressBar1";
326
                        this->progressBar1->Size = System::Drawing::Size(158, 23);
327
                        this->progressBar1->TabIndex = 16;
328
                        // 
329
                        // numSteps
330
                        // 
331
                        this->numSteps->DecimalPlaces = 3;
332
                        this->numSteps->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
333
                        this->numSteps->Location = System::Drawing::Point(571, 177);
334
                        this->numSteps->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100000, 0, 0, 0});
335
                        this->numSteps->Name = L"numSteps";
336
                        this->numSteps->Size = System::Drawing::Size(120, 20);
337
                        this->numSteps->TabIndex = 17;
338
                        // 
339
                        // label2
340
                        // 
341
                        this->label2->AutoSize = true;
342
                        this->label2->Location = System::Drawing::Point(568, 161);
343
                        this->label2->Name = L"label2";
344
                        this->label2->Size = System::Drawing::Size(129, 13);
345
                        this->label2->TabIndex = 18;
346
                        this->label2->Text = L"Number of Steps (1,000\'s)";
347
                        // 
348
                        // button1
349
                        // 
350
                        this->button1->Location = System::Drawing::Point(571, 202);
351
                        this->button1->Name = L"button1";
352
                        this->button1->Size = System::Drawing::Size(75, 23);
353
                        this->button1->TabIndex = 19;
354
                        this->button1->Text = L"Run";
355
                        this->button1->UseVisualStyleBackColor = true;
356
                        this->button1->Click += gcnew System::EventHandler(this, &frmRun::button1_Click);
357
                        // 
358
                        // backgroundWorker1
359
                        // 
360
                        this->backgroundWorker1->WorkerReportsProgress = true;
361
                        this->backgroundWorker1->WorkerSupportsCancellation = true;
362
                        // 
363
                        // button2
364
                        // 
365
                        this->button2->Location = System::Drawing::Point(652, 202);
366
                        this->button2->Name = L"button2";
367
                        this->button2->Size = System::Drawing::Size(75, 23);
368
                        this->button2->TabIndex = 20;
369
                        this->button2->Text = L"Stop";
370
                        this->button2->UseVisualStyleBackColor = true;
371
                        this->button2->Click += gcnew System::EventHandler(this, &frmRun::button2_Click);
372
                        // 
373
                        // label3
374
                        // 
375
                        this->label3->AutoSize = true;
376
                        this->label3->Location = System::Drawing::Point(571, 137);
377
                        this->label3->Name = L"label3";
378
                        this->label3->Size = System::Drawing::Size(120, 13);
379
                        this->label3->TabIndex = 21;
380
                        this->label3->Text = L"Run at Maximum Speed";
381
                        // 
382
                        // lblMHz
383
                        // 
384
                        this->lblMHz->AutoSize = true;
385
                        this->lblMHz->Location = System::Drawing::Point(571, 266);
386
                        this->lblMHz->Name = L"lblMHz";
387
                        this->lblMHz->Size = System::Drawing::Size(47, 13);
388
                        this->lblMHz->TabIndex = 22;
389
                        this->lblMHz->Text = L"0.0 MHz";
390
                        this->lblMHz->MouseHover += gcnew System::EventHandler(this, &frmRun::lblMHz_MouseHover);
391
                        // 
392
                        // toolTipMHz
393
                        // 
394
                        this->toolTipMHz->IsBalloon = true;
395
                        // 
396
                        // frmRun
397
                        // 
398
                        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
399
                        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
400
                        this->ClientSize = System::Drawing::Size(741, 501);
401
                        this->Controls->Add(this->lblMHz);
402
                        this->Controls->Add(this->label3);
403
                        this->Controls->Add(this->button2);
404
                        this->Controls->Add(this->button1);
405
                        this->Controls->Add(this->label2);
406
                        this->Controls->Add(this->numSteps);
407
                        this->Controls->Add(this->progressBar1);
408
                        this->Controls->Add(this->label1);
409
                        this->Controls->Add(this->toolStrip1);
410
                        this->Controls->Add(this->menuStrip1);
411
                        this->Controls->Add(this->trackBar1);
412
                        this->Controls->Add(this->listBoxCode);
413
                        this->Controls->Add(this->listBoxBytes);
414
                        this->Controls->Add(this->listBoxAdr);
415
                        this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
416
                        this->MainMenuStrip = this->menuStrip1;
417
                        this->Name = L"frmRun";
418
                        this->Text = L"emuThor - Run";
419
                        this->WindowState = System::Windows::Forms::FormWindowState::Maximized;
420
                        this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &frmRun::frmRun_FormClosing);
421
                        this->Load += gcnew System::EventHandler(this, &frmRun::frmRun_Load);
422
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBar1))->EndInit();
423
                        this->toolStrip1->ResumeLayout(false);
424
                        this->toolStrip1->PerformLayout();
425
                        this->menuStrip1->ResumeLayout(false);
426
                        this->menuStrip1->PerformLayout();
427
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numSteps))->EndInit();
428
                        this->ResumeLayout(false);
429
                        this->PerformLayout();
430
 
431
                }
432
#pragma endregion
433
private: void InitializeBackgroundWorker() {
434
        backgroundWorker1->DoWork += gcnew DoWorkEventHandler(this, &frmRun::backgroundWorker1_DoWork);
435
        backgroundWorker1->RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler(this, &frmRun::backgroundWorker1_RunWorkerCompleted);
436
        backgroundWorker1->ProgressChanged += gcnew ProgressChangedEventHandler(this, &frmRun::backgroundWorker1_ProgressChanged);
437
}
438
// Try and align the disassembled code with the current PC.
439
private: int PCIsInList(int as)
440
{
441
        int nn, nb;
442
        std::string dstr;
443
        int ae;
444
        int ad = as;
445
 
446
        for (ad = as; ad > as-32; ad--) {
447
                ae = ad;
448
                for (nn = 0; nn < 64; nn++) {
449
            mut->WaitOne();
450
                        if (ae==system1.cpu2.pc) {
451
                                mut->ReleaseMutex();
452
                                return ad;
453
                        }
454
                        mut->ReleaseMutex();
455
                dstr = da.Disassem(ae,&nb);
456
                ae += nb;
457
                }
458
        }
459
        return as;
460
}
461
 
462
public: void UpdateListBoxes()
463
                 {
464
                         int nn,nb,kk;
465
                         char buf2[100];
466
                         std::string dstr;
467
                         std::string buf;
468
                         int adr[32];
469
                         int adf;
470
                         int ad;
471
 
472
                         mut->WaitOne();
473
                         ad = PCIsInList(system1.cpu2.pc-32);
474
                         mut->ReleaseMutex();
475
                         listBoxAdr->Items->Clear();
476
                         listBoxBytes->Items->Clear();
477
                         listBoxCode->Items->Clear();
478
                         for (nn = 0; nn < 32; nn++) {
479
                                 adr[nn] = ad;
480
                                sprintf(buf2,"%06X", ad);
481
                                buf = std::string(buf2);
482
                                this->listBoxAdr->Items->Add(gcnew String(buf.c_str()));
483
                                dstr = da.Disassem(ad,&nb);
484
                                buf2[0] = '\0';
485
                                for (kk = 0; kk < nb; kk++) {
486
                                        mut->WaitOne();
487
                                        sprintf(&buf2[strlen(buf2)], "%02X ", system1.ReadByte(ad));
488
                                        mut->ReleaseMutex();
489
                                        ad++;
490
                                }
491
                                buf = std::string(buf2);
492
                                this->listBoxBytes->Items->Add(gcnew String(buf.c_str()));
493
                                this->listBoxCode->Items->Add(gcnew String(dstr.c_str()));
494
                         }
495
                         for (nn = 0; nn < 32; nn++) {
496
                                 mut->WaitOne();
497
                                 adf = system1.cpu2.pc;
498
                                 mut->ReleaseMutex();
499
                                if (adr[nn]==adf) {
500
                                        this->listBoxAdr->SetSelected(nn,true);
501
                                        this->listBoxBytes->SetSelected(nn,true);
502
                                        this->listBoxCode->SetSelected(nn,true);
503
                                }
504
                         }
505
                 }
506
public: void DoStepInto() {
507
//                       animate = false;
508
//                       isRunning = false;
509
                         char buf[100];
510
                         mut->WaitOne();
511
                         system1.Step();
512
                         mut->ReleaseMutex();
513
                         UpdateListBoxes();
514
//                       sprintf(buf, "%04X", system1.leds);
515
//                       lblLEDS->Text = gcnew String(buf);
516
//                       pictureBox1->Refresh();
517
                 }
518
public: void DoStepOut() {
519
                         int xx;
520
                         mut->WaitOne();
521
                         step_depth = system1.cpu2.sub_depth;
522
                         stepout = true;
523
                         animate = false;
524
                         fullspeed = true;
525
                         isRunning = true;
526
                         mut->ReleaseMutex();
527
                         int ticks = (int)(1000 * 1000);
528
 
529
                         this->button1->Enabled = false;
530
                         backgroundWorker1->RunWorkerAsync(ticks);
531
                         this->button2->Enabled = true;
532
                         progressBar1->Value = 0;
533
                         //UpdateListBoxes();
534
                         //this->fullSpeedToolStripMenuItem->Checked = true;
535
                }
536
public: void DoStepOver() {
537
                         mut->WaitOne();
538
                         stepover_pc = system1.cpu2.pc;
539
                         stepover_depth = system1.cpu2.sub_depth;
540
                         stepover = true;
541
                         animate = false;
542
                         fullspeed = true;
543
                         isRunning = true;
544
                         mut->ReleaseMutex();
545
                         UpdateListBoxes();
546
//                       this->fullSpeedToolStripMenuItem->Checked = true;
547
                }
548
public: void DoStopButton() {
549
                         timer1->Enabled = false;
550
                         mut->WaitOne();
551
                         animate = false;
552
                         isRunning = false;
553
//                       cpu2.brk = true;
554
                         fullspeed = false;
555
                         mut->ReleaseMutex();
556
                         UpdateListBoxes();
557
//                       this->fullSpeedToolStripMenuItem->Checked = false;
558
//                       this->animateFastToolStripMenuItem->Checked = false;
559
//                       this->timer1->Interval = 100;
560
                 }
561
private: void Reset() {
562
                         int ad;
563
                         mut->WaitOne();
564
                         system1.Reset();
565
                         ad = system1.cpu2.pc-32;
566
                         mut->ReleaseMutex();
567
                         UpdateListBoxes();
568
                 }
569
 
570
private: System::Void toolStripButton8_Click(System::Object^  sender, System::EventArgs^  e) {
571
                         Reset();
572
                         }
573
private: System::Void toolStripButton7_Click(System::Object^  sender, System::EventArgs^  e) {
574
//                       frmBreakpoints^ form = gcnew frmBreakpoints(mut);
575
//                       form->MdiParent = this->MdiParent;
576
//                       form->ShowDialog();
577
                 }
578
private: System::Void toolStripButton4_Click(System::Object^  sender, System::EventArgs^  e) {
579
                                 int xx;
580
                                 int ticks = (int)(this->numSteps->Value * 1000);
581
 
582
                                 this->button1->Enabled = false;
583
                                 backgroundWorker1->RunWorkerAsync(ticks);
584
                                 this->button2->Enabled = true;
585
                                 progressBar1->Value = 0;
586
                 }
587
private: System::Void toolStripButton1_Click(System::Object^  sender, System::EventArgs^  e) {
588
                         DoStepInto();
589
                 }
590
private: System::Void toolStripButton5_Click(System::Object^  sender, System::EventArgs^  e) {
591
                         DoStopButton();
592
                 }
593
private: System::Void toolStripButton2_Click(System::Object^  sender, System::EventArgs^  e) {
594
                         DoStepOver();
595
                 }
596
private: System::Void stepToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
597
                         DoStepInto();
598
                 }
599
private: System::Void toolStripButton3_Click(System::Object^  sender, System::EventArgs^  e) {
600
                         DoStepOut();
601
                 }
602
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
603
                         static int tt = 0;
604
 
605
                         mut->WaitOne();
606
                         system1.Step();
607
                         mut->ReleaseMutex();
608
 
609
                         if (this->timer1->Interval < 10)
610
                                 tt += 1;
611
                                 if (tt == 10 * this->timer1->Interval) {
612
                                         tt = 0;
613
                                         UpdateListBoxes();
614
                                 }
615
                         else
616
                                UpdateListBoxes();
617
                 }
618
private: System::Void animateToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
619
                         timer1->Enabled = true;
620
                         timer1->Interval = (1<<(12-trackBar1->Value));
621
                 }
622
private: System::Void trackBar1_Scroll(System::Object^  sender, System::EventArgs^  e) {
623
                         timer1->Interval = (1<<(12-trackBar1->Value));
624
                 }
625
private: System::Void menuStrip1_ItemClicked(System::Object^  sender, System::Windows::Forms::ToolStripItemClickedEventArgs^  e) {
626
                 }
627
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
628
                                 int xx;
629
                                 int ticks = (int)(this->numSteps->Value * 1000);
630
 
631
                                 this->button1->Enabled = false;
632
                                 backgroundWorker1->RunWorkerAsync(ticks);
633
                                 this->button2->Enabled = true;
634
                                 progressBar1->Value = 0;
635
                 }
636
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
637
                                 backgroundWorker1->CancelAsync();
638
                                 this->button2->Enabled = false;
639
                 }
640
        private: void backgroundWorker1_DoWork(Object^ sender, DoWorkEventArgs^ e) {
641
                int xx;
642
                BackgroundWorker^ worker = dynamic_cast<BackgroundWorker^>(sender);
643
                int div = safe_cast<Int32>(e->Argument) / 100;
644
                int percentComplete = 0;
645
 
646
                mut->WaitOne();
647
                isRunning = true;
648
            stopwatch->Reset();
649
                stopwatch->Start();
650
                startTick = system1.cpu2.tick;
651
                mut->ReleaseMutex();
652
                for (xx = 0; xx < safe_cast<Int32>(e->Argument) && isRunning; xx++) {
653
                        if (worker->CancellationPending) {
654
                                e->Cancel = true;
655
                                xx = safe_cast<Int32>(e->Argument);
656
                        }
657
                        if (xx % div == 0) {
658
                                worker->ReportProgress(percentComplete);
659
                                percentComplete++;
660
                        }
661
                        mut->WaitOne();
662
                        system1.Run();
663
                        mut->ReleaseMutex();
664
                }
665
                mut->WaitOne();
666
        stopwatch->Stop();
667
                stopTick = system1.cpu2.tick;
668
                isRunning = false;
669
                mut->ReleaseMutex();
670
                e->Result = 0;
671
        }
672
        private: void backgroundWorker1_ProgressChanged(Object^ sender, ProgressChangedEventArgs^ e) {
673
                this->progressBar1->Value = e->ProgressPercentage;
674
        }
675
        private: void backgroundWorker1_RunWorkerCompleted( Object^ , RunWorkerCompletedEventArgs^ e) {
676
                char buf[100];
677
                if (e->Error != nullptr) {
678
                        MessageBox::Show(e->Error->Message);
679
                }
680
                else if (e->Cancelled) {
681
                        /* possibly display cancelled message in a label */
682
                }
683
                else {
684
                        /* possibly display result status */
685
                }
686
                __int64 elapsed = stopwatch->ElapsedMilliseconds;
687
                double MHz = ((double)(stopTick-startTick)/(double)elapsed)/(double)1000;
688
                sprintf(buf,"%3.3g MHz", MHz);
689
                this->lblMHz->Text = gcnew String(buf);
690
                this->button2->Enabled = false;
691
                this->button1->Enabled = true;
692
                this->progressBar1->Value = 0;
693
                this->UpdateListBoxes();
694
        }
695
private: System::Void frmRun_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
696
                         if (e->CloseReason==CloseReason::UserClosing)
697
                                 e->Cancel = true;
698
                 }
699
private: System::Void resetToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
700
                         Reset();
701
                 }
702
private: System::Void stopToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
703
                         DoStopButton();
704
                 }
705
private: System::Void stepOverToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
706
                         DoStepOver();
707
                 }
708
private: System::Void stepOutToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
709
                         DoStepOut();
710
                 }
711
private: System::Void stepIntoToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
712
                         DoStepInto();
713
                 }
714
private: System::Void frmRun_Load(System::Object^  sender, System::EventArgs^  e) {
715
                 }
716
private: System::Void lblMHz_MouseHover(System::Object^  sender, System::EventArgs^  e) {
717
                 }
718
};
719
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.