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