Skip to content

Commit

Permalink
#43: Reverting changes Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
saku-kaarakainen committed Sep 10, 2016
1 parent 97c2ae8 commit b68f742
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
1 change: 0 additions & 1 deletion WinBoyEmulator/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 0 additions & 62 deletions WinBoyEmulator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ private void MainForm_Load(object sender, EventArgs e)
// Check Issues #30 and #31
// Check #31
_emulator = new Emulator { GamePath = "C:\\temp\\game.gb" };
_emulator.Graphics = CreateGraphics();
_emulator.DrawEventHandler += Draw;
_emulator.StartEmulation();
}

Expand All @@ -75,65 +73,5 @@ private void _openFileDialogMain_FileOk(object sender, CancelEventArgs e)
_emulator.GamePath = _openFileDialogMain.FileName;
_emulator.StartEmulation();
}

private void Draw(Screen screen, PaintEventArgs e)
{
if (screen == null)
{
_logWriter.Info("Cannot draw screen. Argument screen is null.");
return;
}

//
// TODO:
// Draw Screen screen into form.
// This might be good choise for that...:
// https://stackoverflow.com/questions/761003/draw-a-single-pixel-on-windows-forms
//

// Note: lock might be heavy
// This is because this method is used by multiple thread
// Maybe some sort of update would be enough...
lock (_syncRoot)
{
var rect = new Rectangle(0, 0, screen.Width, screen.Height);
Pen[] pens = new Pen[]
{
Pens.White,
Pens.Silver,
Pens.Gray,
Pens.Black
};


var kp = e.Graphics;
kp.DrawRectangle(pens, rect);

for(var i = 0; i < screen.Data.Length; i++)
{
var penIndex = screen.Data[i];

kp.DrawRectangle(pens[penIndex], new Rectangle());

switch(screen.Data[i])
{
case 0:

case 1:
case 2:
case 3:
default:
throw new Exception("ok");
}
}
}
}

private void MainForm_Paint(object sender, PaintEventArgs e)
{
//_emulator.Graphics = e.Graphics;

Draw(null, e);
}
}
}

0 comments on commit b68f742

Please sign in to comment.