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

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [emuThor/] [source/] [frmMain.h] - Blame information for rev 55

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 robfinch
#pragma once
2
#include <Windows.h>
3
#include <iostream>
4
#include <fstream>
5
#include <iomanip>
6
#include <string>
7
#include <vcclr.h>
8
#include <string.h>
9 32 robfinch
#include <math.h>
10 35 robfinch
#include "stdafx.h"
11
#include "frmRun.h"
12 30 robfinch
#include "frmRegisters.h"
13 32 robfinch
#include "frmBreakpoints.h"
14 30 robfinch
#include "frmScreen.h"
15
#include "frmKeyboard.h"
16 32 robfinch
#include "frmUart.h"
17
#include "fmrFreeRun.h"
18
#include "frmPCHistory.h"
19 30 robfinch
#include "About.h"
20
//#include "fmrPCS.h"
21 32 robfinch
#include "frmInterrupts.h"
22
#include "frmStack.h"
23 30 robfinch
#include "frmMemory.h"
24
 
25
clsDisassem da;
26
extern clsSystem system1;
27
extern unsigned int breakpoints[30];
28 32 robfinch
extern unsigned __int64 ibreakpoints[10];
29
extern bool ib_active[10];
30
bool isRunning;
31
bool quit;
32
bool stepout, stepover;
33
unsigned int step_depth, stepover_depth;
34
unsigned int stepoverBkpt;
35
unsigned int stepover_pc;
36
bool animate;
37
bool fullspeed;
38
bool runstop;
39 30 robfinch
 
40 35 robfinch
bool screenClosed;
41
bool dbgScreenClosed;
42
bool keyboardClosed;
43
 
44 30 robfinch
namespace emuThor {
45
 
46
        using namespace System;
47
        using namespace System::ComponentModel;
48
        using namespace System::Collections;
49
        using namespace System::Windows::Forms;
50
        using namespace System::Data;
51
        using namespace System::Drawing;
52
        using namespace System::Runtime::InteropServices;
53
        using namespace System::Threading;
54
 
55
        /// <summary>
56
        /// Summary for frmMain
57
        /// </summary>
58
        public ref class frmMain : public System::Windows::Forms::Form
59
        {
60
        public:
61
                frmMain(void)
62
                {
63
                        InitializeComponent();
64
                        //
65
                        //TODO: Add the constructor code here
66
                        //
67 32 robfinch
                        fullspeed = false;
68
                        runstop = false;
69
                        stepout = false;
70
                        stepover = false;
71
                        animate = false;
72
                        isRunning = false;
73
                        mut = gcnew Mutex(false, "emuThor");
74 35 robfinch
                        registersFrm = nullptr;
75
                        memoryFrm = nullptr;
76
                        stackFrm = nullptr;
77
                        interruptsFrm = nullptr;
78
                        PCHistoryFrm = nullptr;
79
                        breakpointsFrm = nullptr;
80
                        keyboardFrm = gcnew frmKeyboard(mut);
81 30 robfinch
                             keyboardFrm->Show();
82 35 robfinch
                        screenClosed = false;
83
                        dbgScreenClosed = false;
84
                        screenFrm = gcnew frmScreen(mut, "Main Screen");
85
                                mut->WaitOne();
86 32 robfinch
                            screenFrm->pVidMem = &system1.VideoMem[0];
87
                                screenFrm->pVidDirty = &system1.VideoMemDirty[0];
88 35 robfinch
                                screenFrm->which = 0;
89
                            mut->ReleaseMutex();
90 30 robfinch
                                screenFrm->Show();
91 35 robfinch
                        DBGScreenFrm = gcnew frmScreen(mut, "Debug Screen");
92
                                mut->WaitOne();
93 32 robfinch
                            DBGScreenFrm->pVidMem = &system1.DBGVideoMem[0];
94
                                DBGScreenFrm->pVidDirty = &system1.DBGVideoMemDirty[0];
95 35 robfinch
                                DBGScreenFrm->which = 1;
96
                                mut->ReleaseMutex();
97 32 robfinch
                                DBGScreenFrm->Show();
98 35 robfinch
                        uartFrm = gcnew frmUart(mut);
99
                                uartFrm->MdiParent = this;
100 32 robfinch
                                uartFrm->Show();
101
                                uartFrm->WindowState = FormWindowState::Minimized;
102 35 robfinch
                        runFrm = gcnew frmRun(mut);
103
                            runFrm->MdiParent = this;
104
                                runFrm->WindowState = FormWindowState::Maximized;
105
                                runFrm->Show();
106 32 robfinch
//                      myThreadDelegate = gcnew ThreadStart(this, &frmMain::Run);
107
//                      myThread = gcnew Thread(myThreadDelegate);                      
108
//                      myThread->Start();
109
 
110
//                      this->SetStyle(ControlStyles::AllPaintingInWmPaint |
111
//                      ControlStyles::Opaque, true);
112 30 robfinch
                }
113
 
114
        protected:
115
                /// <summary>
116
                /// Clean up any resources being used.
117
                /// </summary>
118
                ~frmMain()
119
                {
120 32 robfinch
//                      this->backgroundWorker1->CancelAsync();
121 30 robfinch
                        if (components)
122
                        {
123
                                delete components;
124
                        }
125 32 robfinch
                        system1.quit = true;
126 30 robfinch
                }
127
        private: System::Windows::Forms::MenuStrip^  menuStrip1;
128
        protected:
129
        private: System::Windows::Forms::ToolStripMenuItem^  viewToolStripMenuItem;
130
        private: System::Windows::Forms::ToolStripMenuItem^  registersToolStripMenuItem;
131
        private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
132 35 robfinch
 
133 30 robfinch
        private: System::Windows::Forms::ToolStripMenuItem^  aboutToolStripMenuItem;
134
        private: System::Windows::Forms::ToolStrip^  toolStrip1;
135 35 robfinch
 
136
 
137
 
138
 
139
 
140 30 robfinch
        private: System::Windows::Forms::ToolStripButton^  toolStripButton6;
141
        private: System::Windows::Forms::ToolStripButton^  toolStripButton7;
142
        private: System::Windows::Forms::ToolStripMenuItem^  loadINTELHexFIleToolStripMenuItem;
143
        private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
144
        private: System::Windows::Forms::Label^  lblChecksumError;
145
        private: System::Windows::Forms::ToolStripMenuItem^  memoryToolStripMenuItem;
146
        private: System::Windows::Forms::PictureBox^  pictureBox1;
147 35 robfinch
 
148
 
149
 
150
 
151
 
152 30 robfinch
        private: System::Windows::Forms::Label^  lblLEDS;
153 32 robfinch
        private: System::Windows::Forms::ToolStripMenuItem^  breakpointsToolStripMenuItem;
154
        private: ThreadStart^ myThreadDelegate;
155
        private: Thread^ myThread;
156 35 robfinch
 
157 32 robfinch
        private: System::Windows::Forms::Timer^  timer1;
158 35 robfinch
 
159
 
160
 
161 32 robfinch
        private: System::Windows::Forms::ToolStripMenuItem^  stackToolStripMenuItem;
162 35 robfinch
 
163 32 robfinch
        private: System::Windows::Forms::ToolStripMenuItem^  pCHistoryToolStripMenuItem;
164
        private: System::ComponentModel::BackgroundWorker^  backgroundWorker1;
165
        private: Mutex^ mut;
166 35 robfinch
        private: frmKeyboard^ keyboardFrm;
167
        private: frmScreen^ screenFrm;
168
        private: frmScreen^ DBGScreenFrm;
169
        private: frmRun^ runFrm;
170
        private: frmRegisters^ registersFrm;
171
        private: frmMemory^ memoryFrm;
172
        private: frmStack^ stackFrm;
173
        private: frmInterrupts^ interruptsFrm;
174
        private: frmPCHistory^ PCHistoryFrm;
175
        private: frmBreakpoints^ breakpointsFrm;
176
        private: frmUart^ uartFrm;
177
 
178 32 robfinch
        private: System::Windows::Forms::ToolStripMenuItem^  keyboardToolStripMenuItem;
179
        private: System::Windows::Forms::Timer^  timer30;
180
        private: System::Windows::Forms::Timer^  timer1024;
181 30 robfinch
 
182 35 robfinch
 
183
        private: System::Windows::Forms::ToolStripMenuItem^  screenToolStripMenuItem;
184
        private: System::Windows::Forms::ToolStripMenuItem^  debugScreenToolStripMenuItem;
185
private: System::Windows::Forms::ToolStripMenuItem^  runToolStripMenuItem1;
186
private: System::Windows::Forms::ToolStripMenuItem^  interruptsToolStripMenuItem;
187
private: System::Windows::Forms::ToolStripMenuItem^  uartToolStripMenuItem;
188
private: System::Windows::Forms::PictureBox^  pictureBox2;
189
 
190
 
191 32 robfinch
        private: System::ComponentModel::IContainer^  components;
192 30 robfinch
        private:
193
                /// <summary>
194
                /// Required designer variable.
195
                /// </summary>
196
 
197 32 robfinch
 
198 30 robfinch
#pragma region Windows Form Designer generated code
199
                /// <summary>
200
                /// Required method for Designer support - do not modify
201
                /// the contents of this method with the code editor.
202
                /// </summary>
203
                void InitializeComponent(void)
204
                {
205 32 robfinch
                        this->components = (gcnew System::ComponentModel::Container());
206 30 robfinch
                        System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(frmMain::typeid));
207
                        this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
208
                        this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
209
                        this->loadINTELHexFIleToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
210
                        this->viewToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
211
                        this->registersToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
212
                        this->memoryToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
213 32 robfinch
                        this->breakpointsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
214 35 robfinch
                        this->interruptsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
215 32 robfinch
                        this->stackToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
216
                        this->pCHistoryToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
217
                        this->keyboardToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
218 35 robfinch
                        this->screenToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
219
                        this->debugScreenToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
220
                        this->uartToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
221
                        this->runToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
222 30 robfinch
                        this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
223
                        this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
224
                        this->toolStripButton6 = (gcnew System::Windows::Forms::ToolStripButton());
225
                        this->toolStripButton7 = (gcnew System::Windows::Forms::ToolStripButton());
226
                        this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
227
                        this->lblChecksumError = (gcnew System::Windows::Forms::Label());
228
                        this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
229
                        this->lblLEDS = (gcnew System::Windows::Forms::Label());
230 32 robfinch
                        this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
231
                        this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
232
                        this->timer30 = (gcnew System::Windows::Forms::Timer(this->components));
233
                        this->timer1024 = (gcnew System::Windows::Forms::Timer(this->components));
234 35 robfinch
                        this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());
235 30 robfinch
                        this->menuStrip1->SuspendLayout();
236
                        this->toolStrip1->SuspendLayout();
237
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
238 35 robfinch
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox2))->BeginInit();
239 30 robfinch
                        this->SuspendLayout();
240
                        // 
241
                        // menuStrip1
242
                        // 
243 35 robfinch
                        this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->fileToolStripMenuItem,
244
                                this->viewToolStripMenuItem, this->aboutToolStripMenuItem});
245 30 robfinch
                        this->menuStrip1->Location = System::Drawing::Point(0, 0);
246
                        this->menuStrip1->Name = L"menuStrip1";
247 35 robfinch
                        this->menuStrip1->Size = System::Drawing::Size(911, 24);
248 30 robfinch
                        this->menuStrip1->TabIndex = 0;
249
                        this->menuStrip1->Text = L"menuStrip1";
250
                        // 
251
                        // fileToolStripMenuItem
252
                        // 
253
                        this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->loadINTELHexFIleToolStripMenuItem});
254
                        this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
255
                        this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20);
256
                        this->fileToolStripMenuItem->Text = L"&File";
257
                        // 
258
                        // loadINTELHexFIleToolStripMenuItem
259
                        // 
260
                        this->loadINTELHexFIleToolStripMenuItem->Name = L"loadINTELHexFIleToolStripMenuItem";
261
                        this->loadINTELHexFIleToolStripMenuItem->Size = System::Drawing::Size(178, 22);
262
                        this->loadINTELHexFIleToolStripMenuItem->Text = L"&Load INTEL Hex FIle";
263
                        this->loadINTELHexFIleToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::loadINTELHexFIleToolStripMenuItem_Click);
264
                        // 
265
                        // viewToolStripMenuItem
266
                        // 
267 35 robfinch
                        this->viewToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(11) {this->registersToolStripMenuItem,
268
                                this->memoryToolStripMenuItem, this->breakpointsToolStripMenuItem, this->interruptsToolStripMenuItem, this->stackToolStripMenuItem,
269
                                this->pCHistoryToolStripMenuItem, this->keyboardToolStripMenuItem, this->screenToolStripMenuItem, this->debugScreenToolStripMenuItem,
270
                                this->uartToolStripMenuItem, this->runToolStripMenuItem1});
271 30 robfinch
                        this->viewToolStripMenuItem->Name = L"viewToolStripMenuItem";
272
                        this->viewToolStripMenuItem->Size = System::Drawing::Size(44, 20);
273
                        this->viewToolStripMenuItem->Text = L"&View";
274
                        // 
275
                        // registersToolStripMenuItem
276
                        // 
277
                        this->registersToolStripMenuItem->Name = L"registersToolStripMenuItem";
278 35 robfinch
                        this->registersToolStripMenuItem->Size = System::Drawing::Size(154, 22);
279 30 robfinch
                        this->registersToolStripMenuItem->Text = L"&Registers";
280
                        this->registersToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::registersToolStripMenuItem_Click);
281
                        // 
282
                        // memoryToolStripMenuItem
283
                        // 
284
                        this->memoryToolStripMenuItem->Name = L"memoryToolStripMenuItem";
285 35 robfinch
                        this->memoryToolStripMenuItem->Size = System::Drawing::Size(154, 22);
286 30 robfinch
                        this->memoryToolStripMenuItem->Text = L"&Memory";
287
                        this->memoryToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::memoryToolStripMenuItem_Click);
288
                        // 
289 32 robfinch
                        // breakpointsToolStripMenuItem
290
                        // 
291 35 robfinch
                        this->breakpointsToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"breakpointsToolStripMenuItem.Image")));
292 32 robfinch
                        this->breakpointsToolStripMenuItem->Name = L"breakpointsToolStripMenuItem";
293 35 robfinch
                        this->breakpointsToolStripMenuItem->Size = System::Drawing::Size(154, 22);
294 32 robfinch
                        this->breakpointsToolStripMenuItem->Text = L"&Breakpoints";
295
                        this->breakpointsToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::breakpointsToolStripMenuItem_Click);
296
                        // 
297 35 robfinch
                        // interruptsToolStripMenuItem
298
                        // 
299
                        this->interruptsToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"interruptsToolStripMenuItem.Image")));
300
                        this->interruptsToolStripMenuItem->Name = L"interruptsToolStripMenuItem";
301
                        this->interruptsToolStripMenuItem->Size = System::Drawing::Size(154, 22);
302
                        this->interruptsToolStripMenuItem->Text = L"&Interrupts - PIC";
303
                        this->interruptsToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::interruptsToolStripMenuItem_Click);
304
                        // 
305 32 robfinch
                        // stackToolStripMenuItem
306
                        // 
307
                        this->stackToolStripMenuItem->Name = L"stackToolStripMenuItem";
308 35 robfinch
                        this->stackToolStripMenuItem->Size = System::Drawing::Size(154, 22);
309 32 robfinch
                        this->stackToolStripMenuItem->Text = L"&Stack";
310
                        this->stackToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::stackToolStripMenuItem_Click);
311
                        // 
312
                        // pCHistoryToolStripMenuItem
313
                        // 
314
                        this->pCHistoryToolStripMenuItem->Name = L"pCHistoryToolStripMenuItem";
315 35 robfinch
                        this->pCHistoryToolStripMenuItem->Size = System::Drawing::Size(154, 22);
316 32 robfinch
                        this->pCHistoryToolStripMenuItem->Text = L"&PC History";
317
                        this->pCHistoryToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::pCHistoryToolStripMenuItem_Click);
318
                        // 
319
                        // keyboardToolStripMenuItem
320
                        // 
321
                        this->keyboardToolStripMenuItem->Name = L"keyboardToolStripMenuItem";
322 35 robfinch
                        this->keyboardToolStripMenuItem->Size = System::Drawing::Size(154, 22);
323 32 robfinch
                        this->keyboardToolStripMenuItem->Text = L"&Keyboard";
324
                        this->keyboardToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::keyboardToolStripMenuItem_Click);
325
                        // 
326 35 robfinch
                        // screenToolStripMenuItem
327
                        // 
328
                        this->screenToolStripMenuItem->Name = L"screenToolStripMenuItem";
329
                        this->screenToolStripMenuItem->Size = System::Drawing::Size(154, 22);
330
                        this->screenToolStripMenuItem->Text = L"Screen";
331
                        this->screenToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::screenToolStripMenuItem_Click);
332
                        // 
333
                        // debugScreenToolStripMenuItem
334
                        // 
335
                        this->debugScreenToolStripMenuItem->Name = L"debugScreenToolStripMenuItem";
336
                        this->debugScreenToolStripMenuItem->Size = System::Drawing::Size(154, 22);
337
                        this->debugScreenToolStripMenuItem->Text = L"Debug Screen";
338
                        this->debugScreenToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::debugScreenToolStripMenuItem_Click);
339
                        // 
340
                        // uartToolStripMenuItem
341
                        // 
342
                        this->uartToolStripMenuItem->Name = L"uartToolStripMenuItem";
343
                        this->uartToolStripMenuItem->Size = System::Drawing::Size(154, 22);
344
                        this->uartToolStripMenuItem->Text = L"&Uart";
345
                        this->uartToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::uartToolStripMenuItem_Click);
346
                        // 
347
                        // runToolStripMenuItem1
348
                        // 
349
                        this->runToolStripMenuItem1->Name = L"runToolStripMenuItem1";
350
                        this->runToolStripMenuItem1->Size = System::Drawing::Size(154, 22);
351
                        this->runToolStripMenuItem1->Text = L"Run";
352
                        this->runToolStripMenuItem1->Click += gcnew System::EventHandler(this, &frmMain::runToolStripMenuItem1_Click);
353
                        // 
354 30 robfinch
                        // aboutToolStripMenuItem
355
                        // 
356
                        this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem";
357
                        this->aboutToolStripMenuItem->Size = System::Drawing::Size(52, 20);
358
                        this->aboutToolStripMenuItem->Text = L"&About";
359
                        this->aboutToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::aboutToolStripMenuItem_Click);
360
                        // 
361
                        // toolStrip1
362
                        // 
363 35 robfinch
                        this->toolStrip1->Dock = System::Windows::Forms::DockStyle::None;
364
                        this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->toolStripButton6,
365
                                this->toolStripButton7});
366
                        this->toolStrip1->Location = System::Drawing::Point(12, 32);
367 30 robfinch
                        this->toolStrip1->Name = L"toolStrip1";
368 35 robfinch
                        this->toolStrip1->Size = System::Drawing::Size(58, 25);
369 30 robfinch
                        this->toolStrip1->TabIndex = 1;
370
                        this->toolStrip1->Text = L"toolStrip1";
371
                        // 
372
                        // toolStripButton6
373
                        // 
374
                        this->toolStripButton6->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
375
                        this->toolStripButton6->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton6.Image")));
376
                        this->toolStripButton6->ImageTransparentColor = System::Drawing::Color::Magenta;
377
                        this->toolStripButton6->Name = L"toolStripButton6";
378
                        this->toolStripButton6->Size = System::Drawing::Size(23, 22);
379
                        this->toolStripButton6->Text = L"Interrupt";
380 32 robfinch
                        this->toolStripButton6->Click += gcnew System::EventHandler(this, &frmMain::toolStripButton6_Click);
381 30 robfinch
                        // 
382
                        // toolStripButton7
383
                        // 
384
                        this->toolStripButton7->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
385
                        this->toolStripButton7->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton7.Image")));
386
                        this->toolStripButton7->ImageTransparentColor = System::Drawing::Color::Magenta;
387
                        this->toolStripButton7->Name = L"toolStripButton7";
388
                        this->toolStripButton7->Size = System::Drawing::Size(23, 22);
389
                        this->toolStripButton7->Text = L"Breakpoints";
390 32 robfinch
                        this->toolStripButton7->Click += gcnew System::EventHandler(this, &frmMain::toolStripButton7_Click);
391 30 robfinch
                        // 
392
                        // openFileDialog1
393
                        // 
394
                        this->openFileDialog1->DefaultExt = L"hex";
395
                        this->openFileDialog1->FileName = L"boot";
396
                        this->openFileDialog1->Filter = L"\"INTEL Hex Files|*.hex|All Files|*.*\"";
397
                        this->openFileDialog1->FileOk += gcnew System::ComponentModel::CancelEventHandler(this, &frmMain::openFileDialog1_FileOk);
398
                        // 
399
                        // lblChecksumError
400
                        // 
401
                        this->lblChecksumError->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
402
                        this->lblChecksumError->AutoSize = true;
403 35 robfinch
                        this->lblChecksumError->Location = System::Drawing::Point(195, 655);
404 30 robfinch
                        this->lblChecksumError->Name = L"lblChecksumError";
405
                        this->lblChecksumError->Size = System::Drawing::Size(35, 13);
406
                        this->lblChecksumError->TabIndex = 2;
407
                        this->lblChecksumError->Text = L"label1";
408
                        // 
409
                        // pictureBox1
410
                        // 
411
                        this->pictureBox1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
412 35 robfinch
                        this->pictureBox1->Location = System::Drawing::Point(12, 640);
413 30 robfinch
                        this->pictureBox1->Name = L"pictureBox1";
414
                        this->pictureBox1->Size = System::Drawing::Size(218, 12);
415
                        this->pictureBox1->TabIndex = 3;
416
                        this->pictureBox1->TabStop = false;
417
                        this->pictureBox1->Click += gcnew System::EventHandler(this, &frmMain::pictureBox1_Click);
418
                        this->pictureBox1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &frmMain::pictureBox1_Paint);
419
                        // 
420
                        // lblLEDS
421
                        // 
422
                        this->lblLEDS->AutoSize = true;
423 35 robfinch
                        this->lblLEDS->Location = System::Drawing::Point(255, 639);
424 30 robfinch
                        this->lblLEDS->Name = L"lblLEDS";
425 35 robfinch
                        this->lblLEDS->Size = System::Drawing::Size(31, 13);
426 30 robfinch
                        this->lblLEDS->TabIndex = 7;
427 35 robfinch
                        this->lblLEDS->Text = L"0000";
428
                        this->lblLEDS->Visible = false;
429 30 robfinch
                        // 
430 32 robfinch
                        // timer1
431
                        // 
432
                        this->timer1->Enabled = true;
433
                        this->timer1->Tick += gcnew System::EventHandler(this, &frmMain::timer1_Tick);
434
                        // 
435
                        // timer30
436
                        // 
437
                        this->timer30->Tick += gcnew System::EventHandler(this, &frmMain::timer30_Tick);
438
                        // 
439
                        // timer1024
440
                        // 
441
                        this->timer1024->Tick += gcnew System::EventHandler(this, &frmMain::timer1024_Tick);
442
                        // 
443 35 robfinch
                        // pictureBox2
444
                        // 
445
                        this->pictureBox2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
446
                        this->pictureBox2->Location = System::Drawing::Point(305, 631);
447
                        this->pictureBox2->Name = L"pictureBox2";
448
                        this->pictureBox2->Size = System::Drawing::Size(172, 38);
449
                        this->pictureBox2->TabIndex = 9;
450
                        this->pictureBox2->TabStop = false;
451
                        this->pictureBox2->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &frmMain::pictureBox2_Paint);
452
                        // 
453 30 robfinch
                        // frmMain
454
                        // 
455
                        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
456
                        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
457 35 robfinch
                        this->ClientSize = System::Drawing::Size(911, 681);
458
                        this->Controls->Add(this->pictureBox2);
459
                        this->Controls->Add(this->toolStrip1);
460 30 robfinch
                        this->Controls->Add(this->lblLEDS);
461
                        this->Controls->Add(this->pictureBox1);
462
                        this->Controls->Add(this->lblChecksumError);
463
                        this->Controls->Add(this->menuStrip1);
464 35 robfinch
                        this->IsMdiContainer = true;
465 30 robfinch
                        this->MainMenuStrip = this->menuStrip1;
466
                        this->Name = L"frmMain";
467
                        this->Text = L"Thor ISA Emulator";
468
                        this->menuStrip1->ResumeLayout(false);
469
                        this->menuStrip1->PerformLayout();
470
                        this->toolStrip1->ResumeLayout(false);
471
                        this->toolStrip1->PerformLayout();
472
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
473 35 robfinch
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox2))->EndInit();
474 30 robfinch
                        this->ResumeLayout(false);
475
                        this->PerformLayout();
476
 
477
                }
478
#pragma endregion
479 32 robfinch
 
480 30 robfinch
        private: System::Void registersToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
481 35 robfinch
                                 if (registersFrm)
482
                                         registersFrm->Activate();
483
                                 else {
484
                                         registersFrm = gcnew frmRegisters(mut);
485
                                         registersFrm->MdiParent = this;
486
                                         registersFrm->Show();
487
                                 }
488 30 robfinch
                         }
489
        private: System::Void loadINTELHexFIleToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
490
                         this->openFileDialog1->ShowDialog();
491
                         LoadIntelHexFile();
492 35 robfinch
                         if (runFrm)
493
                                 runFrm->UpdateListBoxes();
494 30 robfinch
                         return;
495
                         }
496
 
497
private: int IHChecksumCheck(const char *buf) {
498
        int nn;
499
        int sum;
500
        std::string str;
501
        std::string str1;
502
        str = std::string(buf);
503
        sum = 0;
504
        for (nn = 1; nn < str.length(); nn+=2) {
505
                str1 = str.substr(nn,2);
506
                sum += strtoul(str1.c_str(),NULL,16);
507
        }
508
        sum &= 0xff;
509
        return sum;
510
}
511
 
512
private: void LoadIntelHexFile() {
513
                         int nc,nn;
514
                         std::string buf;
515
                         std::string str_ad;
516
                         std::string str_insn;
517
                         std::string str_ad_insn;
518
                         std::string str_disassem;
519
                         unsigned int ad;
520
                         unsigned __int64 dat;
521
                         unsigned __int64 b0,b1,b2,b3,b4,b5,b6,b7;
522
                         unsigned int firstAdr;
523
                         char buf2[40];
524
                         unsigned int ad_msbs;
525
                         int chksum;
526
                         int lineno;    // 16531
527
 
528
                        char* str = (char*)(void*)Marshal::StringToHGlobalAnsi(this->openFileDialog1->FileName);
529
                        System::Windows::Forms::Cursor::Current = System::Windows::Forms::Cursors::WaitCursor;
530
                        std::ifstream fp_in;
531
                        fp_in.open(str,std::ios::in);
532
                        firstAdr = 0;
533
                        ad_msbs = 0;
534
                        chksum = 0;
535
                        lineno=0;
536
                        system1.WriteROM = true;
537
                        while (!fp_in.eof()) {
538
                                lineno++;
539
                                std::getline(fp_in, buf);
540
                                chksum += IHChecksumCheck(buf.c_str());
541
                                if (buf.c_str()[0]!=':') continue;
542
                                if (buf.c_str()[8]=='4') {
543
                                        strncpy(buf2,&((buf.c_str())[9]),4);
544
                                        buf2[4] = '\0';
545
                                        ad_msbs = strtoul(buf2,NULL,16);
546
                                        continue;
547
                                }
548
                                // Process record type #'00'
549
                                if (buf.c_str()[8]=='0') {
550
                                        ad = strtoul(buf.substr(3,4).c_str(),NULL,16) | (ad_msbs << 16);
551
                                        b0 = strtoul(buf.substr(9,2).c_str(),NULL,16);
552
                                        b1 = strtoul(buf.substr(11,2).c_str(),NULL,16);
553
                                        b2 = strtoul(buf.substr(13,2).c_str(),NULL,16);
554
                                        b3 = strtoul(buf.substr(15,2).c_str(),NULL,16);
555
                                        b4 = strtoul(buf.substr(17,2).c_str(),NULL,16);
556
                                        b5 = strtoul(buf.substr(19,2).c_str(),NULL,16);
557
                                        b6 = strtoul(buf.substr(21,2).c_str(),NULL,16);
558
                                        b7 = strtoul(buf.substr(23,2).c_str(),NULL,16);
559
                                        dat = b0 |
560
                                                (b1 << 8) |
561
                                                (b2 << 16) |
562
                                                (b3 << 24) |
563
                                                (b4 << 32) |
564
                                                (b5 << 40) |
565
                                                (b6 << 48) |
566
                                                (b7 << 56)
567
                                                ;
568
                                }
569
                                if (!firstAdr)
570
                                        firstAdr = ad;
571 32 robfinch
                                mut->WaitOne();
572 30 robfinch
                                system1.Write(ad, dat, 0xFF, 0);
573 32 robfinch
                                mut->ReleaseMutex();
574 30 robfinch
                                //system1.memory[ad>>2] = dat;
575
                                //sprintf(buf2,"%06X", ad);
576
                                //str_ad = std::string(buf2);
577
                                //sprintf(buf2,"%08X", dat);
578
                                //str_insn = std::string(buf2);
579
                                //str_disassem = Disassem(str_ad,str_insn);
580
                                //str_ad_insn = str_ad + "   " + str_insn + "    " + str_disassem;
581
                                //label1->Text = gcnew String(str_ad_insn.c_str());
582
                                //this->checkedListBox1->Items->Add(gcnew String(str_ad_insn.c_str()));
583
                        }
584
                fp_in.close();
585
                        system1.WriteROM = false;
586
                        ad = firstAdr;
587 35 robfinch
                        if (runFrm)
588
                                runFrm->UpdateListBoxes();
589 30 robfinch
                        if (chksum != 0) {
590
                                sprintf(buf2, "Checksum Error: %d", chksum);
591
                                this->lblChecksumError->Text = gcnew String(buf2);
592
                        }
593
                        else
594
                                this->lblChecksumError->Text = "Checksum OK";
595
                        System::Windows::Forms::Cursor::Current = System::Windows::Forms::Cursors::Default;
596
                 }
597
private: System::Void memoryToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
598 35 robfinch
                         if (memoryFrm)
599
                                 memoryFrm->Activate();
600
                         else {
601
                                 memoryFrm = gcnew frmMemory(mut);
602
                                 memoryFrm->MdiParent = this;
603
                                 memoryFrm->Show();
604
                         }
605 30 robfinch
                 }
606
private: System::Void pictureBox1_Click(System::Object^  sender, System::EventArgs^  e) {
607
                 }
608
private: System::Void pictureBox1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
609
                         Graphics^ gr = e->Graphics;
610
                         int h = pictureBox1->ClientSize.Height;
611
                         int w = h;
612
                         int nn,kk;
613 32 robfinch
                         int lds;
614
 
615
                         mut->WaitOne();
616
                         lds = system1.leds;
617
                         mut->ReleaseMutex();
618 30 robfinch
                         for (kk= 15, nn = 0; nn < 16; nn++, kk--) {
619 32 robfinch
                                if (lds & (1 << kk))
620 30 robfinch
                                        gr->FillEllipse(gcnew SolidBrush(Color::Green),System::Drawing::Rectangle(w*nn,0,w-1,h-1));
621
                                else
622
                                        gr->FillEllipse(gcnew SolidBrush(Color::FromArgb(0xFF003000)),System::Drawing::Rectangle(w*nn,0,w-1,h-1));
623
                         }
624
                 }
625
private: System::Void openFileDialog1_FileOk(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
626
                 }
627
private: System::Void aboutToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
628
                         About^ form = gcnew About;
629 35 robfinch
                         form->MdiParent = this;
630 30 robfinch
                         form->Show();
631
                 }
632 32 robfinch
private: System::Void breakpointsToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
633 35 robfinch
                         if (breakpointsFrm)
634
                                 breakpointsFrm->Activate();
635 32 robfinch
                         else {
636 35 robfinch
                                 breakpointsFrm = gcnew frmBreakpoints(mut);
637
                                 breakpointsFrm->MdiParent = this;
638
                                 breakpointsFrm->Show();
639 32 robfinch
                         }
640
                 }
641 35 robfinch
private: System::Void fullSpeedToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
642 32 robfinch
                 }
643
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
644
                         if (trigger30) {
645
                                 trigger30 = false;
646
                                 if (interval30==-1) {
647
                                         mut->WaitOne();
648
                                         system1.pic1.irq30Hz = true;
649
                                         mut->ReleaseMutex();
650
                                 }
651
                                 else {
652
                                         this->timer30->Interval = interval30;
653
                                         this->timer30->Enabled = true;
654
                                 }
655
                         }
656
                         if (trigger1024) {
657
                                 trigger1024 = false;
658
                                 if (interval1024==-1) {
659
                                         mut->WaitOne();
660
                                         system1.pic1.irq1024Hz = true;
661
                                         mut->ReleaseMutex();
662
                                 }
663
                                 else {
664
                                         this->timer1024->Interval = interval1024;
665
                                         this->timer1024->Enabled = true;
666
                                 }
667
                         }
668 35 robfinch
                        if (interruptsFrm)
669
                                interruptsFrm->UpdateForm();
670
                         if (isRunning) {
671
                                 if (registersFrm)
672
                                         registersFrm->UpdateForm();
673
                                 if (PCHistoryFrm)
674
                                         PCHistoryFrm->UpdateForm();
675
                                 if (stackFrm)
676
                                         stackFrm->UpdateForm();
677
                         }
678
                         pictureBox1->Invalidate();
679
                         pictureBox2->Invalidate();
680 32 robfinch
                 }
681 35 robfinch
private: System::Void toolStripButton7_Click(System::Object^  sender, System::EventArgs^  e) {
682
                         if (breakpointsFrm)
683
                                 breakpointsFrm->Activate();
684 32 robfinch
                         else {
685 35 robfinch
                                 breakpointsFrm = gcnew frmBreakpoints(mut);
686
                                 breakpointsFrm->MdiParent = this;
687
                                 breakpointsFrm->Show();
688 32 robfinch
                         }
689
                 }
690
private: System::Void stackToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
691 35 robfinch
                         if (stackFrm)
692
                                 stackFrm->Activate();
693
                         else {
694
                                 stackFrm = gcnew frmStack(mut);
695
                                 stackFrm->MdiParent = this;
696
                                 stackFrm->Show();
697
                         }
698 32 robfinch
                 }
699
private: System::Void interruptToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
700 35 robfinch
                         if (interruptsFrm)
701
                                 interruptsFrm->Activate();
702
                         else {
703
                                 interruptsFrm = gcnew frmInterrupts(mut);
704
                                 interruptsFrm->MdiParent = this;
705
                                 interruptsFrm->Show();
706
                         }
707 32 robfinch
                 }
708
private: System::Void toolStripButton6_Click(System::Object^  sender, System::EventArgs^  e) {
709 35 robfinch
                         if (interruptsFrm)
710
                                 interruptsFrm->Activate();
711
                         else {
712
                                 interruptsFrm = gcnew frmInterrupts(mut);
713
                                 interruptsFrm->MdiParent = this;
714
                                 interruptsFrm->Show();
715
                         }
716 32 robfinch
                 }
717
private: System::Void pCHistoryToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
718 35 robfinch
                         if (PCHistoryFrm)
719
                                 PCHistoryFrm->Activate();
720
                         else {
721
                                 PCHistoryFrm = gcnew frmPCHistory(mut);
722
                                 PCHistoryFrm->MdiParent = this;
723
                                 PCHistoryFrm->Show();
724
                         }
725 32 robfinch
                 }
726
private: System::Void keyboardToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
727 35 robfinch
                        if (keyboardFrm)
728
                                keyboardFrm->Show();
729
                        else {
730
                                keyboardFrm = gcnew frmKeyboard(mut);
731
                            keyboardFrm->Show();
732
                        }
733 32 robfinch
                 }
734
private: System::Void timer30_Tick(System::Object^  sender, System::EventArgs^  e) {
735
                         mut->WaitOne();
736
                         system1.pic1.irq30Hz = true;
737
                         mut->ReleaseMutex();
738
                 }
739
private: System::Void timer1024_Tick(System::Object^  sender, System::EventArgs^  e) {
740
                         mut->WaitOne();
741
                         system1.pic1.irq1024Hz = true;
742
                         mut->ReleaseMutex();
743
                 }
744 35 robfinch
private: System::Void screenToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
745
                         if (screenClosed) {
746
                                screenFrm = gcnew frmScreen(mut, "Main Screen");
747
                                mut->WaitOne();
748
                            screenFrm->pVidMem = &system1.VideoMem[0];
749
                                screenFrm->pVidDirty = &system1.VideoMemDirty[0];
750
                                screenFrm->which = 0;
751
                                mut->ReleaseMutex();
752
                                screenFrm->Show();
753
                         }
754
                         else
755
                                 screenFrm->Activate();
756
                 }
757
private: System::Void debugScreenToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
758
                         if (dbgScreenClosed) {
759
                                DBGScreenFrm = gcnew frmScreen(mut, "Debug Screen");
760
                                mut->WaitOne();
761
                                DBGScreenFrm->pVidMem = &system1.DBGVideoMem[0];
762
                                DBGScreenFrm->pVidDirty = &system1.DBGVideoMemDirty[0];
763
                                DBGScreenFrm->which = 1;
764
                                mut->ReleaseMutex();
765
                                DBGScreenFrm->Show();
766
                         }
767
                         else
768
                                DBGScreenFrm->Activate();
769
                 }
770
private: System::Void runToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
771
                         if (runFrm == nullptr) {
772
                                 runFrm = gcnew frmRun(mut);
773
                                 runFrm->MdiParent = this;
774
                                 runFrm->WindowState = FormWindowState::Maximized;
775
                                 runFrm->Show();
776
                         }
777
                         else
778
                                 runFrm->Activate();
779
                 }
780
private: System::Void interruptsToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
781
                         if (interruptsFrm)
782
                                 interruptsFrm->Activate();
783
                         else {
784
                                 interruptsFrm = gcnew frmInterrupts(mut);
785
                                 interruptsFrm->MdiParent = this;
786
                                 interruptsFrm->Show();
787
                         }
788
                 }
789
private: System::Void uartToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
790
                         if (uartFrm==nullptr) {
791
                                uartFrm = gcnew frmUart(mut);
792
                                uartFrm->MdiParent = this;
793
                                uartFrm->Show();
794
                         }
795
                         else
796
                                 uartFrm->Activate();
797
                 }
798
private: System::Void pictureBox2_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
799
                        Graphics^ gr = e->Graphics;
800
                        System::Drawing::Font^ myfont;
801
                        std::string str;
802
                        SolidBrush^ bkbr;
803
                        SolidBrush^ fgbr;
804
                        int xx,kk;
805
                        char buf[9];
806
                        for (xx = 0; xx < 8; xx++)
807
                        {
808
                                kk = (system1.sevenseg.dat >> (xx * 4)) & 0xF;
809
                                if (kk < 10)
810
                                        buf[7-xx] = '0' + kk;
811
                                else
812
                                        switch(kk) {
813
                                        case 10:        buf[7-xx] = 'A'; break;
814
                                        case 11:        buf[7-xx] = 'b'; break;
815
                                        case 12:        buf[7-xx] = 'C'; break;
816
                                        case 13:        buf[7-xx] = 'd'; break;
817
                                        case 14:        buf[7-xx] = 'E'; break;
818
                                        case 15:        buf[7-xx] = 'F'; break;
819
                                        }
820
                        }
821
                        buf[8] = '\0';
822
                        myfont = gcnew System::Drawing::Font("Lucida Console", 24);
823
                        bkbr = gcnew System::Drawing::SolidBrush(System::Drawing::Color::Black);
824
                        gr->FillRectangle(bkbr,this->pictureBox2->ClientRectangle);
825
                        fgbr = gcnew System::Drawing::SolidBrush(Color::FromArgb(0xFF3F0000));
826
                        gr->DrawString(gcnew String("88888888"),myfont,fgbr,0,0);
827
                        fgbr = gcnew System::Drawing::SolidBrush(Color::FromArgb(0x7FFF0000));
828
                        gr->DrawString(gcnew String(buf),myfont,fgbr,2,2);
829
                 }
830 30 robfinch
};
831
}
832
 

powered by: WebSVN 2.1.0

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