summaryrefslogtreecommitdiff
path: root/Form1.cs
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2017-06-06 11:35:55 +0000
committerIan C <ianc@noddybox.co.uk>2017-06-06 11:35:55 +0000
commitc339f69055655290d57432940d3db9d88d9a0897 (patch)
treede29b3c28862a8c341a0088a664e4f8f40b9d832 /Form1.cs
parenta1a2c114dec908650ed4bca33846375e58fffeca (diff)
Initial version.HEADmaster
Diffstat (limited to 'Form1.cs')
-rw-r--r--Form1.cs113
1 files changed, 113 insertions, 0 deletions
diff --git a/Form1.cs b/Form1.cs
new file mode 100644
index 0000000..980a5aa
--- /dev/null
+++ b/Form1.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.IO;
+using System.Drawing.Imaging;
+
+namespace Rip81Font
+{
+ public partial class Form1 : Form
+ {
+ private byte[] rom;
+
+ public Form1()
+ {
+ InitializeComponent();
+
+ rom = File.ReadAllBytes("Data/zx81.bin");
+
+ m_pictureBox.Image = new Bitmap(8, 8);
+ }
+
+ private void Rip(int code)
+ {
+ bool inv = false;
+
+ if (code > 127)
+ {
+ inv = true;
+ code -= 128;
+ }
+
+ if (code > 63)
+ {
+ using (Graphics g = Graphics.FromImage(m_pictureBox.Image))
+ {
+ g.FillRectangle(Brushes.Red, 0, 0, 8, 8);
+ }
+ }
+ else
+ {
+ int addr = 0x1e00 + code * 8;
+
+ using (Graphics g = Graphics.FromImage(m_pictureBox.Image))
+ {
+ for(int f = 0; f < 8; f++)
+ {
+ byte b = rom[addr+f];
+
+ for(int n = 0; n < 8; n++)
+ {
+ Brush p;
+
+ if ((b & (1 << n)) != 0)
+ {
+ if (inv)
+ {
+ p = Brushes.White;
+ }
+ else
+ {
+ p = Brushes.Black;
+ }
+ }
+ else
+ {
+ if (inv)
+ {
+ p = Brushes.Black;
+ }
+ else
+ {
+ p = Brushes.White;
+ }
+ }
+
+ g.FillRectangle(p, 7 - n, f, 1, 1);
+ }
+ }
+ }
+ }
+
+ using (Graphics g = m_pictureBox.CreateGraphics())
+ {
+ g.DrawImageUnscaled(m_pictureBox.Image, 0, 0);
+ }
+ }
+
+ private void OnCodeChanged(object sender, EventArgs e)
+ {
+ Rip(Convert.ToInt32(m_number.Value));
+ }
+
+ private void OnExportAll(object sender, EventArgs e)
+ {
+ Directory.CreateDirectory("Export");
+
+ for(int f = 0; f < 256; f++)
+ {
+ Rip(f);
+
+ string fname = String.Format("Export/{0}.png", f);
+
+ m_pictureBox.Image.Save(fname, ImageFormat.Png);
+ }
+ }
+ }
+}