Virtual Machine Screen Not Working

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
After spending about a week trying to fix this I am still stuck. I cant get my virtual machines screen to work.
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Text;
using System.Drawing.Imaging;


namespace GW480_VM
{
public partial class Form1 : Form
{
private ushort m_ScreenMemoryLocation = 0xA000;
private byte[] m_ScreenMemory= new byte[3267];
private string command, A = "empty", B = "empty", C = "empty", X = "empty", Y = "empty", Z = "empty";
private int[] balpha = new int[3267], bred = new int[3267], bgreen = new int[3267], bblue = new int[3267], falpha = new int[3267], fred = new int[3267], fgreen = new int[3267], fblue = new int[3267];

public Form1()
{
InitializeComponent();
for (int i = 0; i < 3267; i++)
{
balpha = 255;
bred = 255;
bgreen = 255;
bblue = 255;
falpha = 0;
fred = 0;
fgreen = 0;
fblue = 0;
m_ScreenMemory = 32;

}
screen_update();



BIOS();



// Commands List
//RUN location
//DMP
//JMP address TODO
//LDA
//LDB
//LDC
//LDX
//LDY
//LDZ
//STA
//ADD Mathematics TODO
//SUB Mathematics TODO
//DIV Mathematics TODO
//MLP Mathematics TODO
//CMP address1 address2 cmpcode TODO
//POK address value

}

public void BIOS()
{
Interpret_DMP(); //Debuging purpose only



m_ScreenMemory[0] = 65;
m_ScreenMemory[1] = 66;
screen_update();
Interpret_DMP(); //Debuging purpose only
}
public void Interpret(StreamReader OS)
{

command = OS.ReadLine();
if (command.Contains("GW480") == true)
{
command = OS.ReadLine();
String StartAdd = command;
while ((command = OS.ReadLine()) != null)
{
if (command.Contains("RUN"))
{
command.Replace(" RUN ", "");
command.Replace(Environment.NewLine, "");
Interpret_RUN(command);

}
if (command.Contains("DMP"))
{

Interpret_DMP();
}
if (command.Contains("LDA"))
{
command.Replace(" LDA ", "");
command.Replace(Environment.NewLine, "");
A = command;
}
if (command.Contains("LDB"))
{
command.Replace(" LDB ", "");
command.Replace(Environment.NewLine, "");
B = command;
}
if (command.Contains("LDC"))
{
command.Replace(" LDC ", "");
command.Replace(Environment.NewLine, "");
C = command;
}
if (command.Contains("LDX"))
{
command.Replace(" LDX ", "");
command.Replace(Environment.NewLine, "");
X = command;
}
if (command.Contains("LDY"))
{
command.Replace(" LDY ", "");
command.Replace(Environment.NewLine, "");
Y = command;
}
if (command.Contains("LDZ"))
{
command.Replace(" LDZ ", "");
command.Replace(Environment.NewLine, "");
Z = command;
}
if (command.Contains("STA"))
{
command.Replace(" STA ", "");
command.Replace(Environment.NewLine, "");
switch (command)
{
case "A":
A = A;
break;
case "B":
A = B;
break;
case "C":
A = C;
break;
case "X":
A = X;
break;
case "Y":
A = Y;
break;
case "Z":
A = Z;
break;
default:
A = A;
break;
}
}
if (command.Contains("POK"))
{
command.Replace(" POK ", "");
string com_copy = command;
command.Remove(7);
com_copy.Replace(command + " ", "");
Interpret_POK(Convert.ToUInt16(command, 8), Convert.ToByte(com_copy, 2));

}

}
}
}
public void Interpret_RUN(string location)
{
StreamReader RUNapp = new StreamReader(location);
Interpret(RUNapp);
RUNapp.Close();
RUNapp.Dispose();
}

public void Interpret_DMP()
{
DialogResult result = saveFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
StreamWriter Dump = new StreamWriter(saveFileDialog1.FileName);
Dump.WriteLine("Dump Date = " + DateTime.Today);
Dump.WriteLine("Dump Time = " + DateTime.Now);
Dump.WriteLine("");
Dump.WriteLine("");
Dump.WriteLine("");
Dump.WriteLine("Registers");
Dump.WriteLine("");
Dump.WriteLine(" A = " + A);
Dump.WriteLine(" B = " + B);
Dump.WriteLine(" C = " + C);
Dump.WriteLine(" X = " + X);
Dump.WriteLine(" Y = " + Y);
Dump.WriteLine(" Z = " + Z);
Dump.WriteLine("");
Dump.WriteLine("");
Dump.WriteLine(" Current ARGB Values "+Environment.NewLine+Environment.NewLine);
Dump.WriteLine(" Background "+Environment.NewLine);
for (int i = 0; i < 3267; i++)
{
Dump.WriteLine(balpha + bred + bgreen + bblue);
}
Dump.WriteLine(Environment.NewLine+" Foreground "+ Environment.NewLine);
for (int i = 0; i < 3267; i++)
{
Dump.WriteLine(falpha + fred + fgreen + fblue);
}
Dump.WriteLine(Environment.NewLine+" Memory Details "+Environment.NewLine+Environment.NewLine);
for (int i = 0; i < 3267; i++)
{

Dump.WriteLine( Convert.ToInt16(i).ToString() + " :" + m_ScreenMemory.ToString());
}
Dump.WriteLine("DONE " + DateTime.Now);
Dump.Close();
Dump.Dispose();
}
}


public void Interpret_POK(ushort Address, byte Value)
{
ushort MemLoc;
try
{
MemLoc = (ushort)(Address - m_ScreenMemoryLocation);
}
catch (Exception)
{
return;
}
if (MemLoc < 0 || MemLoc > 3266)
return;
m_ScreenMemory[MemLoc] = Value;
screen_update();
}

private void screen_update()
{
SolidBrush Bgcolor = null;
SolidBrush Fgcolor = null;

Bitmap bmp;
Graphics bmp_graphic = this.CreateGraphics();
Font writing = new Font("Courier New", 10f, FontStyle.Bold);
int i; float xloc=0,yloc=0;

for (i = 0; i < 3267; i ++)
{
Bgcolor = new SolidBrush(Color.FromArgb(balpha, bred, bgreen, bblue));
Fgcolor = new SolidBrush(Color.FromArgb(falpha, fred, fgreen, fblue));
bmp_graphic.FillRectangle(Bgcolor, xloc, yloc, 20, 25);
bmp_graphic.DrawString(Encoding.ASCII.GetString(m_ScreenMemory, i, 1), writing, Fgcolor, xloc, yloc);
xloc += 6;
if ((xloc % 640) == 0 && xloc != 0)
{
xloc = 0;
yloc += 11;
}
bmp = new Bitmap(this.Width, this.Height, bmp_graphic);

bmp.Save("test.bmp");
this.BackgroundImage = bmp;

}






}
}
}

[/code]
I cant get anything to go onscreen but I can tell that the program is running because the CPU Usage jumps whenever I run this, it is supposed to be a black screen but nothing really appears.
http://stackoverflow.com/questions/12204858/virtual-machine-display-not-working http://stackoverflow.com/questions/12204858/virtual-machine-display-not-working
In this code after the fixes suggested as soon as I run the machine a cross mark appears on screen http://stackoverflow.com/questions/12204858/virtual-machine-display-not-working
Himanshu Goel
<br/>


View the full article
 
Back
Top