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

Subversion Repositories thor

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 robfinch
#pragma once
2
#include <Windows.h>
3
#include <string>
4
#include "clsSystem.h"
5
extern clsSystem system1;
6
extern char refscreen;
7 35 robfinch
extern bool screenClosed;
8
extern bool dbgScreenClosed;
9 30 robfinch
 
10
namespace emuThor {
11
 
12
        using namespace System;
13
        using namespace System::ComponentModel;
14
        using namespace System::Collections;
15
        using namespace System::Windows::Forms;
16
        using namespace System::Data;
17
        using namespace System::Drawing;
18 32 robfinch
        using namespace System::Threading;
19 30 robfinch
 
20
        /// <summary>
21
        /// Summary for frmScreen
22
        /// </summary>
23
        public ref class frmScreen : public System::Windows::Forms::Form
24
        {
25
                 System::Drawing::Rectangle ur;
26
        public:
27 32 robfinch
                Mutex^ mut;
28
                frmScreen(Mutex^ m, String^ tbs)
29 30 robfinch
                {
30 32 robfinch
                        mut = m;
31 30 robfinch
                        InitializeComponent();
32
                        //
33
                        //TODO: Add the constructor code here
34
                        //
35 32 robfinch
                        this->Text = L"emuFISA64 Test System Screen - " + tbs;
36 30 robfinch
                }
37
 
38
        protected:
39
                /// <summary>
40
                /// Clean up any resources being used.
41
                /// </summary>
42
                ~frmScreen()
43
                {
44
                        if (components)
45
                        {
46
                                delete components;
47
                        }
48
                }
49 35 robfinch
        public: int which;
50 32 robfinch
        public: unsigned long *pVidMem;
51
        public: bool *pVidDirty;
52 30 robfinch
        private: System::Windows::Forms::Timer^  timer1;
53
        private: System::Windows::Forms::PictureBox^  pictureBox1;
54
        protected:
55
        private: System::ComponentModel::IContainer^  components;
56
 
57
        private:
58
                /// <summary>
59
                /// Required designer variable.
60
                /// </summary>
61
 
62
 
63
#pragma region Windows Form Designer generated code
64
                /// <summary>
65
                /// Required method for Designer support - do not modify
66
                /// the contents of this method with the code editor.
67
                /// </summary>
68
                void InitializeComponent(void)
69
                {
70
                        this->components = (gcnew System::ComponentModel::Container());
71
                        this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
72
                        this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
73
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
74
                        this->SuspendLayout();
75
                        // 
76
                        // timer1
77
                        // 
78
                        this->timer1->Enabled = true;
79
                        this->timer1->Tick += gcnew System::EventHandler(this, &frmScreen::timer1_Tick);
80
                        // 
81
                        // pictureBox1
82
                        // 
83
                        this->pictureBox1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
84
                        this->pictureBox1->Location = System::Drawing::Point(2, 0);
85
                        this->pictureBox1->Name = L"pictureBox1";
86 32 robfinch
                        this->pictureBox1->Size = System::Drawing::Size(681, 328);
87 30 robfinch
                        this->pictureBox1->TabIndex = 0;
88
                        this->pictureBox1->TabStop = false;
89
                        this->pictureBox1->Click += gcnew System::EventHandler(this, &frmScreen::pictureBox1_Click);
90
                        this->pictureBox1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &frmScreen::pictureBox1_Paint);
91
                        // 
92
                        // frmScreen
93
                        // 
94
                        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
95
                        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
96
                        this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
97 32 robfinch
                        this->ClientSize = System::Drawing::Size(684, 332);
98 30 robfinch
                        this->Controls->Add(this->pictureBox1);
99
                        this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
100
                        this->MaximizeBox = false;
101
                        this->Name = L"frmScreen";
102
                        this->Text = L"emuFISA64 Test System Screen";
103 35 robfinch
                        this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &frmScreen::frmScreen_FormClosed);
104 30 robfinch
                        this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &frmScreen::frmScreen_Paint);
105
                        (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
106
                        this->ResumeLayout(false);
107
 
108
                }
109
#pragma endregion
110
        private: char ScreenToAscii(char ch)
111
{
112
     ch &= 0xFF;
113
     if (ch==0x1B)
114
        return 0x5B;
115
     if (ch==0x1D)
116
        return 0x5D;
117
     if (ch < 27)
118
        ch += 0x60;
119
     return ch;
120
}
121
 
122
        private: System::Void frmScreen_OnPaintBackground(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
123
                         }
124
        private: System::Void frmScreen_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
125
                         }
126
        private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
127
                                 int nn;
128
                                 int xx,yy;
129
                                 int maxx,maxy,minx,miny;
130
                                 maxx = 0; maxy = 0;
131
                                 minx = 1000; miny = 1000;
132
                                 if (refscreen) {
133
                                         for (nn = 0; nn < 4096; nn++) {
134 32 robfinch
                                                 if (pVidDirty) {
135
                                                         mut->WaitOne();
136
                                                         if (pVidDirty[nn]) {
137
                                                                 xx = nn % 84;
138
                                                                 yy = nn / 84;
139
                                                                 maxx = max(xx,maxx);
140
                                                                 maxy = max(yy,maxy);
141
                                                                 minx = min(xx,minx);
142
                                                                 miny = min(yy,miny);
143
                                                         }
144
                                                         mut->ReleaseMutex();
145 30 robfinch
                                                 }
146
                                         }
147
                                        ur.X = minx<<3;
148 32 robfinch
                                        ur.Y = miny * 10;
149 30 robfinch
                                        ur.Width = (maxx - minx)<<3;
150 32 robfinch
                                        ur.Height = (maxy - miny) * 10;
151 30 robfinch
                                        this->pictureBox1->Invalidate(ur);
152
                                        refscreen = false;
153
//                                      this->Refresh();
154
                                 }
155
                         }
156
        private: System::Void pictureBox1_Click(System::Object^  sender, System::EventArgs^  e) {
157
                         }
158 35 robfinch
private: System::Void frmScreen_FormClosed(System::Object^  sender, System::Windows::Forms::FormClosedEventArgs^  e) {
159
                         if (which==0)
160
                                 screenClosed = true;
161
                         else
162
                                 dbgScreenClosed = true;
163
                 }
164 30 robfinch
private: System::Void pictureBox1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
165
                                 char buf[10];
166
                                 unsigned int ndx;
167
                                 int r,g,b;
168
                                 unsigned int v;
169
                                 System::Drawing::Font^ myfont;
170
                                 std::string str;
171
                                 Graphics^ gr = e->Graphics;
172
                                 SolidBrush^ bkbr;
173
                                 SolidBrush^ fgbr;
174
                                 Color^ col;
175
                                 myfont = gcnew System::Drawing::Font("Courier New", 6);
176
                                 col = gcnew System::Drawing::Color;
177
                                 bkbr = gcnew System::Drawing::SolidBrush(System::Drawing::Color::Blue);
178
                                 fgbr = gcnew System::Drawing::SolidBrush(System::Drawing::Color::White);
179
                                 int xx, yy;
180
                                 for (xx = ur.X; xx < ur.X + ur.Width; xx += 8) {
181 32 robfinch
                                         for (yy = ur.Y; yy < ur.Y + ur.Height; yy += 10) {
182
                                                 ndx = (xx/8 + yy/10 * 84);
183 30 robfinch
//                                               if (system1.VideoMemDirty[ndx]) {
184 32 robfinch
                                                        if (pVidMem) {
185
                                                                mut->WaitOne();
186
                                                                v = pVidMem[ndx];
187
                                                                mut->ReleaseMutex();
188
                                                                r = ((((v >> 10) >> 9) >> 6) & 7) << 5;
189
                                                                g = ((((v >> 10) >> 9) >> 3) & 7) << 5;
190
                                                                b = ((((v >> 10) >> 9) >> 0) & 7) << 5;
191
                                                                bkbr->Color = col->FromArgb(255,r,g,b);
192
                                                                gr->FillRectangle(bkbr,xx,yy,8,10);
193
                                                                r = ((((v >> 10)) >> 6) & 7) << 5;
194
                                                                g = ((((v >> 10)) >> 3) & 7)<< 5;
195
                                                                b = ((((v >> 10)) >> 0) & 7)<< 5;
196
                                                                fgbr->Color = col->FromArgb(255,r,g,b);
197
                                                                sprintf(buf,"%c",ScreenToAscii(v&0xff));
198
                                                                str = std::string(buf);
199
                                                                gr->DrawString(gcnew String(str.c_str()),myfont,fgbr,xx,yy);
200
                                                                if (pVidDirty) {
201
                                                                        mut->WaitOne();
202
                                                                        pVidDirty[ndx] = false;
203
                                                                        mut->ReleaseMutex();
204
                                                                }
205
                                                        }
206 30 robfinch
//                                               }
207
                                         }
208
                                 }
209
                 }
210
};
211
}

powered by: WebSVN 2.1.0

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