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

Subversion Repositories thor

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

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

powered by: WebSVN 2.1.0

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